| | |
| | | import React, { Component } from 'react' |
| | | import { DndProvider } from 'react-dnd' |
| | | import { withRouter } from 'react-router' |
| | | import { is, fromJS } from 'immutable' |
| | | import moment from 'moment' |
| | | import HTML5Backend from 'react-dnd-html5-backend' |
| | |
| | | import Utils, { setGLOBFuncs } from '@/utils/utils.js' |
| | | import zhCN from '@/locales/zh-CN/mob.js' |
| | | import enUS from '@/locales/en-US/mob.js' |
| | | import antdEnUS from 'antd/es/locale/en_US' |
| | | // import antdEnUS from 'antd/es/locale/en_US' |
| | | import antdZhCN from 'antd/es/locale/zh_CN' |
| | | import MKEmitter from '@/utils/events.js' |
| | | import MenuUtils from '@/utils/utils-custom.js' |
| | |
| | | const { Panel } = Collapse |
| | | const { confirm } = Modal |
| | | const { Paragraph } = Typography |
| | | const _locale = sessionStorage.getItem('lang') !== 'en-US' ? antdZhCN : antdEnUS |
| | | const _locale = antdZhCN |
| | | |
| | | const MenuForm = asyncComponent(() => import('./menuform')) |
| | | const HomeForm = asyncComponent(() => import('./homeform')) |
| | |
| | | const MenuShell = asyncComponent(() => import('@/menu/menushell')) |
| | | const PrintMenuForm = asyncComponent(() => import('./printmenuform')) |
| | | const SourceWrap = asyncComponent(() => import('@/menu/modulesource')) |
| | | const PopviewController = asyncComponent(() => import('@/menu/popview')) |
| | | const BgController = asyncComponent(() => import('@/menu/bgcontroller')) |
| | | const BgController = asyncComponent(() => import('@/pc/bgcontroller')) |
| | | const PasteController = asyncComponent(() => import('@/menu/pastecontroller')) |
| | | const PaddingController = asyncComponent(() => import('@/menu/padcontroller')) |
| | | const StyleController = asyncComponent(() => import('@/menu/stylecontroller')) |
| | | const ReplaceField = asyncComponent(() => import('@/menu/replaceField')) |
| | | const Versions = asyncComponent(() => import('@/menu/versions')) |
| | |
| | | const TableComponent = asyncComponent(() => import('@/templates/sharecomponent/tablecomponent')) |
| | | |
| | | sessionStorage.setItem('isEditState', 'true') |
| | | sessionStorage.setItem('editMenuType', 'menu') // 编辑菜单类型 |
| | | sessionStorage.setItem('appType', '') // 应用类型 |
| | | document.body.className = '' |
| | | window.GLOB.UserComponentMap = new Map() // 缓存用户自定义组件 |
| | | window.GLOB.TabsMap = new Map() // 缓存用户操作的标签页 |
| | | window.GLOB.urlFields = [] // url变量 |
| | | window.GLOB.customMenu = null // 保存菜单信息 |
| | | |
| | | class MenuDesign extends Component { |
| | | state = { |
| | |
| | | MenuNo: '', |
| | | delButtons: [], |
| | | copyButtons: [], |
| | | thawButtons: [], |
| | | activeKey: 'basedata', |
| | | menuloading: false, |
| | | oriConfig: null, |
| | | config: null, |
| | | popBtn: null, // 弹窗标签页 |
| | | visible: false, |
| | | customComponents: [], |
| | | comloading: false, |
| | | settingshow: true, |
| | |
| | | } |
| | | |
| | | UNSAFE_componentWillMount() { |
| | | sessionStorage.setItem('editMenuType', 'menu') // 编辑菜单类型 |
| | | |
| | | window.GLOB.UserComponentMap = new Map() // 缓存用户自定义组件 |
| | | window.GLOB.TabsMap = new Map() // 缓存用户操作的标签页 |
| | | window.GLOB.urlFields = [] // url变量 |
| | | window.GLOB.customMenu = null // 保存菜单信息 |
| | | |
| | | try { |
| | | let param = JSON.parse(window.decodeURIComponent(window.atob(this.props.match.params.param))) |
| | | |
| | |
| | | componentDidMount () { |
| | | MKEmitter.addListener('delButtons', this.delButtons) |
| | | MKEmitter.addListener('modalStatus', this.modalStatus) |
| | | MKEmitter.addListener('thawButtons', this.thawButtons) |
| | | // MKEmitter.addListener('thawButtons', this.thawButtons) |
| | | MKEmitter.addListener('copyButtons', this.copyButtons) |
| | | MKEmitter.addListener('changePopview', this.initPopview) |
| | | MKEmitter.addListener('triggerMenuSave', this.triggerMenuSave) |
| | |
| | | |
| | | let node = document.getElementById('save-modal-config') |
| | | if (!node) { |
| | | node = document.getElementById('save-pop-config') |
| | | } |
| | | if (!node) { |
| | | node = document.getElementById('save-config') |
| | | } |
| | | |
| | |
| | | } |
| | | MKEmitter.removeListener('delButtons', this.delButtons) |
| | | MKEmitter.removeListener('modalStatus', this.modalStatus) |
| | | MKEmitter.removeListener('thawButtons', this.thawButtons) |
| | | // MKEmitter.removeListener('thawButtons', this.thawButtons) |
| | | MKEmitter.removeListener('copyButtons', this.copyButtons) |
| | | MKEmitter.removeListener('changePopview', this.initPopview) |
| | | MKEmitter.removeListener('triggerMenuSave', this.triggerMenuSave) |
| | |
| | | } |
| | | |
| | | triggerMenuSave = () => { |
| | | if (this.state.visible) return |
| | | |
| | | this.submitConfig() |
| | | } |
| | | |
| | |
| | | this.setState({copyButtons: [...this.state.copyButtons, ...items]}) |
| | | } |
| | | |
| | | thawButtons = (item) => { |
| | | this.setState({thawButtons: [...this.state.thawButtons, item]}) |
| | | } |
| | | // thawButtons = (item) => { |
| | | // this.setState({thawButtons: [...this.state.thawButtons, item]}) |
| | | // } |
| | | |
| | | initPopview = (card, btn) => { |
| | | const { oriConfig, config } = this.state |
| | |
| | | return |
| | | } |
| | | |
| | | btn.config = fromJS(config).toJS() |
| | | btn.component = card |
| | | let _btn = fromJS(btn).toJS() |
| | | _btn.MenuName = config.MenuName + '-' + card.name + '-' + btn.label |
| | | _btn.ParentMenuID = config.uuid |
| | | |
| | | sessionStorage.setItem('editMenuType', 'popview') // 编辑弹窗标签 |
| | | |
| | | this.setState({popBtn: btn, visible: true}) |
| | | } |
| | | |
| | | handleBack = () => { |
| | | this.setState({popBtn: null, delButtons: [], copyButtons: []}, () => { |
| | | sessionStorage.setItem('editMenuType', 'menu') |
| | | window.GLOB.customMenu = this.state.config |
| | | this.setState({visible: false}) |
| | | }) |
| | | this.props.history.push('/popdesign/' + window.btoa(window.encodeURIComponent((JSON.stringify(_btn))))) |
| | | } |
| | | |
| | | closeView = () => { |
| | |
| | | delButtons.push(btn.uuid) |
| | | return |
| | | } |
| | | this.checkBtn(btn) |
| | | buttons.push(`select '${btn.uuid}' as menuid, '${item.name + '-' + btn.label}' as menuname, '${_sort * 10}' as Sort`) |
| | | _sort++ |
| | | }) |
| | |
| | | delButtons.push(cell.uuid) |
| | | return |
| | | } |
| | | this.checkBtn(cell) |
| | | buttons.push(`select '${cell.uuid}' as menuid, '${item.name + '-' + cell.label}' as menuname, '${_sort * 10}' as Sort`) |
| | | _sort++ |
| | | }) |
| | |
| | | delButtons.push(cell.uuid) |
| | | return |
| | | } |
| | | this.checkBtn(cell) |
| | | buttons.push(`select '${cell.uuid}' as menuid, '${item.name + '-' + cell.label}' as menuname, '${_sort * 10}' as Sort`) |
| | | _sort++ |
| | | }) |
| | |
| | | delButtons.push(cell.uuid) |
| | | return |
| | | } |
| | | this.checkBtn(cell) |
| | | buttons.push(`select '${cell.uuid}' as menuid, '${item.name + '-' + cell.label}' as menuname, '${_sort * 10}' as Sort`) |
| | | _sort++ |
| | | }) |
| | |
| | | delButtons.push(cell.uuid) |
| | | return |
| | | } |
| | | this.checkBtn(cell) |
| | | buttons.push(`select '${cell.uuid}' as menuid, '${item.name + '-' + cell.label}' as menuname, '${_sort * 10}' as Sort`) |
| | | _sort++ |
| | | }) |
| | |
| | | delButtons.push(btn.uuid) |
| | | return |
| | | } |
| | | this.checkBtn(btn) |
| | | buttons.push(`select '${btn.uuid}' as menuid, '${item.name + '-' + btn.label}' as menuname, '${_sort * 10}' as Sort`) |
| | | _sort++ |
| | | }) |
| | |
| | | delButtons.push(btn.uuid) |
| | | return |
| | | } |
| | | this.checkBtn(btn) |
| | | buttons.push(`select '${btn.uuid}' as menuid, '${item.name + '-' + btn.label}' as menuname, '${_sort * 10}' as Sort`) |
| | | _sort++ |
| | | }) |
| | |
| | | delButtons.push(btn.uuid) |
| | | return |
| | | } |
| | | this.checkBtn(btn) |
| | | buttons.push(`select '${btn.uuid}' as menuid, '${item.name + '-' + btn.label}' as menuname, '${_sort * 10}' as Sort`) |
| | | _sort++ |
| | | }) |
| | |
| | | return buttons |
| | | } |
| | | |
| | | checkBtn = (btn) => { |
| | | if (['prompt', 'exec', 'pop'].includes(btn.OpenType) && btn.Ot === 'required' && btn.verify && btn.verify.scripts && btn.verify.scripts.length > 0) { |
| | | let hascheck = false |
| | | btn.verify.scripts.forEach(item => { |
| | | if (item.status === 'false') return |
| | | |
| | | if (/\$check@|@check\$/ig.test(item.sql)) { |
| | | hascheck = true |
| | | } |
| | | }) |
| | | if (hascheck) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: `可选择多行的按钮《${btn.label}》中 $check@ 或 @check$ 将不会生效!`, |
| | | duration: 5 |
| | | }) |
| | | } |
| | | } |
| | | } |
| | | |
| | | submitConfig = () => { |
| | | const { MenuType, copyButtons, thawButtons } = this.state |
| | | const { MenuType, copyButtons } = this.state |
| | | let config = fromJS(this.state.config).toJS() |
| | | |
| | | if (MenuType === 'billPrint' && config.printPage === 'page' && !config.everyPCount) { |
| | |
| | | } |
| | | return Api.getSystemConfig(_param) |
| | | } |
| | | }).then(res => { // 按钮解除冻结 |
| | | if (!res) return |
| | | if (!res.status) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: res.message, |
| | | duration: 5 |
| | | }) |
| | | return false |
| | | } |
| | | // }).then(res => { // 按钮解除冻结 |
| | | // if (!res) return |
| | | // if (!res.status) { |
| | | // notification.warning({ |
| | | // top: 92, |
| | | // message: res.message, |
| | | // duration: 5 |
| | | // }) |
| | | // return false |
| | | // } |
| | | |
| | | let ids = thawButtons.filter(item => btnIds.indexOf(item) !== -1) |
| | | if (ids.length === 0) { |
| | | return { |
| | | status: true |
| | | } |
| | | } else { |
| | | return Api.getSystemConfig({ |
| | | func: 'sPC_MainMenu_ReDel', |
| | | MenuID: ids.join(',') |
| | | }) |
| | | } |
| | | // let ids = thawButtons.filter(item => btnIds.indexOf(item) !== -1) |
| | | // if (ids.length === 0) { |
| | | // return { |
| | | // status: true |
| | | // } |
| | | // } else { |
| | | // return Api.getSystemConfig({ |
| | | // func: 'sPC_MainMenu_ReDel', |
| | | // MenuID: ids.join(',') |
| | | // }) |
| | | // } |
| | | }).then(res => { // 页面保存 |
| | | if (!res) return |
| | | |
| | |
| | | this.setState({ |
| | | delButtons: [], |
| | | copyButtons: [], |
| | | thawButtons: [], |
| | | menuloading: false |
| | | }) |
| | | notification.success({ |
| | |
| | | } |
| | | |
| | | render () { |
| | | const { activeKey, comloading, MenuType, popBtn, visible, dict, MenuId, config, settingshow, ParentId, menuloading, customComponents, eyeopen } = this.state |
| | | const { activeKey, comloading, MenuType, dict, MenuId, config, settingshow, ParentId, menuloading, customComponents, eyeopen } = this.state |
| | | |
| | | return ( |
| | | <ConfigProvider locale={_locale}> |
| | | <div className={'pc-menu-view ' + (MenuType || '')} id="mk-menu-design-view"> |
| | | <Header /> |
| | | {!popBtn && !visible ? <DndProvider backend={HTML5Backend}> |
| | | <DndProvider backend={HTML5Backend}> |
| | | <div className="menu-body"> |
| | | <div className={'menu-setting ' + (!settingshow ? 'hidden' : '')}> |
| | | <div className="draw"> |
| | |
| | | </div> |
| | | <Collapse accordion activeKey={activeKey} bordered={false} onChange={(key) => this.setState({activeKey: key})}> |
| | | {/* 基本信息 */} |
| | | <Panel header={dict['mob.basemsg']} key="basedata"> |
| | | <Panel header="基本信息" key="basedata"> |
| | | {/* 菜单信息 */} |
| | | {config && MenuType === 'custom' ? <MenuForm |
| | | dict={dict} |
| | |
| | | {config ? <Paragraph style={{padding: '15px 0px 0px 18px'}} copyable={{ text: MenuId }}>菜单ID</Paragraph> : null} |
| | | </Panel> |
| | | {/* 组件添加 */} |
| | | <Panel header={dict['mob.component']} key="component"> |
| | | <Panel header="组件" key="component"> |
| | | <SourceWrap MenuType={MenuType} /> |
| | | </Panel> |
| | | {customComponents && customComponents.length ? <Panel header="自定义组件" key="cuscomponent"> |
| | | <SourceWrap components={customComponents} MenuType={MenuType} /> |
| | | </Panel> : null} |
| | | <Panel header={'页面背景'} key="background"> |
| | | <Panel header="页面样式" key="background"> |
| | | {config ? <BgController config={config} updateConfig={this.updateConfig} /> : null} |
| | | </Panel> |
| | | <Panel header={'页面内边距'} key="padding"> |
| | | {config ? <PaddingController config={config} updateConfig={this.updateConfig} /> : null} |
| | | </Panel> |
| | | </Collapse> |
| | | </div> |
| | |
| | | </Card> |
| | | </div> |
| | | </div> |
| | | </DndProvider> : null} |
| | | {popBtn && visible ? <PopviewController btn={popBtn} handleBack={this.handleBack}/> : null} |
| | | </DndProvider> |
| | | <StyleController /> |
| | | <StyleCombController /> |
| | | <ModalController /> |
| | |
| | | } |
| | | } |
| | | |
| | | export default MenuDesign |
| | | export default withRouter(MenuDesign) |