| | |
| | | const StyleCombController = asyncComponent(() => import('@/menu/stylecombcontroller')) |
| | | const StyleCombControlButton = asyncComponent(() => import('@/menu/stylecombcontrolbutton')) |
| | | const TableComponent = asyncComponent(() => import('@/templates/sharecomponent/tablecomponent')) |
| | | const PopView = asyncComponent(() => import('./popview')) |
| | | |
| | | sessionStorage.setItem('isEditState', 'true') |
| | | sessionStorage.setItem('editMenuType', 'menu') // 编辑菜单类型 |
| | |
| | | comloading: false, |
| | | adapters: [], |
| | | viewType: 'menu', |
| | | view: '', |
| | | eyeopen: false, |
| | | needUpdate: false |
| | | } |
| | |
| | | document.getElementById('mk-mob-design-view').innerHTML = '<div style="text-align: center; font-size: 30px; margin-top: 40vh; height: 100vh; background: #fff;">本应用没有PC端页面的编辑权限,请联系管理员!</div>' |
| | | return |
| | | } |
| | | MKEmitter.addListener('changePopview', this.initPopview) |
| | | MKEmitter.addListener('triggerMenuSave', this.submitConfig) |
| | | MKEmitter.addListener('changeEditMenu', this.changeEditMenu) |
| | | setTimeout(() => { |
| | |
| | | this.setState = () => { |
| | | return |
| | | } |
| | | MKEmitter.removeListener('changePopview', this.initPopview) |
| | | MKEmitter.removeListener('triggerMenuSave', this.submitConfig) |
| | | MKEmitter.removeListener('changeEditMenu', this.changeEditMenu) |
| | | } |
| | | |
| | | initPopview = (card, btn) => { |
| | | const { config } = this.state |
| | | |
| | | if (!this.checkBase()) { |
| | | return |
| | | } |
| | | |
| | | let _btn = fromJS(btn).toJS() |
| | | |
| | | if (_btn.config) { |
| | | _btn.config.uuid = _btn.uuid |
| | | _btn.config.MenuID = _btn.uuid |
| | | _btn.config.ParentId = card.uuid |
| | | _btn.config.MenuName = _btn.label |
| | | } else { |
| | | _btn.config = { |
| | | uuid: _btn.uuid, |
| | | MenuID: _btn.uuid, |
| | | ParentId: card.uuid, |
| | | enabled: false, |
| | | MenuName: _btn.label, |
| | | tables: config.tables || [], |
| | | Template: 'CustomPage', |
| | | components: [], |
| | | viewType: 'popview', |
| | | style: { backgroundColor: '#ffffff', backgroundImage: '', paddingTop: '16px', paddingBottom: '40px', paddingLeft: '16px', paddingRight: '16px' } |
| | | } |
| | | } |
| | | |
| | | this.setState({view: 'popview', popConfig: _btn}) |
| | | } |
| | | |
| | | closePop = () => { |
| | | const {config} = this.state |
| | | |
| | | sessionStorage.setItem('editMenuType', 'menu') |
| | | |
| | | window.GLOB.urlFields = config.urlFields || [] |
| | | window.GLOB.customMenu = config |
| | | |
| | | this.setState({view: '', popConfig: null}) |
| | | } |
| | | |
| | | submitPopConfig = (btnconfig) => { |
| | | let parents = {[btnconfig.ParentId]: true} |
| | | let popbtns = {[btnconfig.uuid]: fromJS(btnconfig).toJS()} |
| | | let config = fromJS(this.state.config).toJS() |
| | | |
| | | config.components = this.setPopView(config.components, parents, popbtns) |
| | | |
| | | this.setState({ config }, () => { |
| | | this.submitConfig() |
| | | }) |
| | | } |
| | | |
| | | setPopView = (components, parents, popbtns) => { |
| | | return components.map(item => { |
| | | if (item.type === 'tabs') { |
| | | item.subtabs.forEach(tab => { |
| | | tab.components = this.setPopView(tab.components, parents, popbtns) |
| | | }) |
| | | } else if (item.type === 'group') { |
| | | item.components = this.setPopView(item.components, parents, popbtns) |
| | | } else if (parents[item.uuid]) { |
| | | this.setpopConfig(item, popbtns) |
| | | } |
| | | return item |
| | | }) |
| | | } |
| | | |
| | | setpopConfig = (config, popbtns) => { |
| | | config.subcards && config.subcards.forEach(item => { |
| | | item.elements.forEach(cell => { |
| | | if (cell.eleType !== 'button') return |
| | | if (cell.OpenType === 'popview' && popbtns[cell.uuid]) { |
| | | cell.config = popbtns[cell.uuid] |
| | | } |
| | | }) |
| | | }) |
| | | |
| | | config.cols && config.cols.forEach(col => { |
| | | if (col.type === 'action') { |
| | | col.elements.forEach(cell => { |
| | | if (cell.OpenType === 'popview' && popbtns[cell.uuid]) { |
| | | cell.config = popbtns[cell.uuid] |
| | | } |
| | | }) |
| | | } |
| | | }) |
| | | |
| | | config.elements && config.elements.forEach(cell => { |
| | | if (cell.eleType !== 'button') return |
| | | if (cell.OpenType === 'popview' && popbtns[cell.uuid]) { |
| | | cell.config = popbtns[cell.uuid] |
| | | } |
| | | }) |
| | | |
| | | config.action && config.action.forEach(cell => { |
| | | if (cell.OpenType === 'popview' && popbtns[cell.uuid]) { |
| | | cell.config = popbtns[cell.uuid] |
| | | } |
| | | }) |
| | | |
| | | config.$tables = getTables(config) |
| | | } |
| | | |
| | | checkBase = () => { |
| | | const { config } = this.state |
| | | |
| | | if (!config.MenuName || !config.MenuNo) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '请完善菜单基本信息!', |
| | | duration: 5 |
| | | }) |
| | | return false |
| | | } |
| | | return true |
| | | } |
| | | |
| | | getSmStemp = () => { |
| | |
| | | |
| | | |
| | | render () { |
| | | const { viewType, comloading, loading, settingshow, controlshow, activeKey, MenuId, config, menuloading, adapters, eyeopen, needUpdate } = this.state |
| | | const { view, viewType, comloading, loading, settingshow, controlshow, activeKey, MenuId, config, menuloading, adapters, eyeopen, needUpdate } = this.state |
| | | |
| | | return ( |
| | | <ConfigProvider locale={antdZhCN}> |
| | |
| | | <Header/> |
| | | {loading ? <Spin className="view-spin" size="large" /> : null} |
| | | <DndProvider backend={HTML5Backend}> |
| | | <div className={'menu-setting ' + (!settingshow ? 'hidden' : '')}> |
| | | {view !== 'popview' ? <><div className={'menu-setting ' + (!settingshow ? 'hidden' : '')}> |
| | | <div className="draw"> |
| | | {settingshow ? <DoubleLeftOutlined onClick={() => {this.setState({settingshow: false})}} /> : null} |
| | | {!settingshow ? <DoubleRightOutlined onClick={() => {this.setState({settingshow: true})}} /> : null} |
| | |
| | | {config && !comloading ? <div className="mob-shell" style={{width: window.GLOB.shellWidth, height: window.GLOB.shellHeight}}> |
| | | <MobShell menu={config} handleList={this.updateConfig} /> |
| | | </div> : null} |
| | | </div> |
| | | </div></> : <PopView btn={this.state.popConfig} save={this.submitPopConfig} cancel={this.closePop}/>} |
| | | </DndProvider> |
| | | <StyleController /> |
| | | <StyleCombController /> |