From 542054288debe0251270f782daad7fa2c6e53c5b Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 24 十二月 2020 19:24:06 +0800 Subject: [PATCH] 2020-12-24 --- src/menu/popview/index.jsx | 183 ++++++++++++++++++++------------------------- 1 files changed, 82 insertions(+), 101 deletions(-) diff --git a/src/menu/popview/index.jsx b/src/menu/popview/index.jsx index 471b71a..eb19d48 100644 --- a/src/menu/popview/index.jsx +++ b/src/menu/popview/index.jsx @@ -19,13 +19,11 @@ const { Panel } = Collapse const { confirm } = Modal -const Header = asyncComponent(() => import('@/menu/header')) +const MenuForm = asyncComponent(() => import('./menuform')) const SourceWrap = asyncComponent(() => import('@/menu/modelsource')) const MenuShell = asyncComponent(() => import('@/menu/menushell')) const BgController = asyncComponent(() => import('@/menu/bgcontroller')) const PaddingController = asyncComponent(() => import('@/menu/padcontroller')) -const StyleController = asyncComponent(() => import('@/menu/stylecontroller')) -const ModalController = asyncComponent(() => import('@/menu/modalconfig/controller')) const TableComponent = asyncComponent(() => import('@/templates/sharecomponent/tablecomponent')) sessionStorage.setItem('isEditState', 'true') @@ -33,7 +31,6 @@ class MenuDesign extends Component { static propTpyes = { btn: PropTypes.object, - handleSave: PropTypes.func, handleBack: PropTypes.func } @@ -78,24 +75,25 @@ const { oriConfig, config } = this.state if (!config) { - window.close() + this.props.handleBack() return } let _config = fromJS(config).toJS() delete _config.tableFields + const _this = this if (!is(fromJS(oriConfig), fromJS(_config))) { confirm({ title: '閰嶇疆宸蹭慨鏀癸紝鏀惧純淇濆瓨鍚楋紵', content: '', onOk() { - window.close() + _this.props.handleBack() }, onCancel() {} }) } else { - window.close() + this.props.handleBack() } } @@ -112,7 +110,7 @@ let config = null try { - config = JSON.parse(window.decodeURIComponent(window.atob(result.LongParam))) + config = result.LongParam ? JSON.parse(window.decodeURIComponent(window.atob(result.LongParam))) : null } catch (e) { console.warn('Parse Failure') config = null @@ -144,8 +142,6 @@ config: fromJS(config).toJS(), openEdition: result.open_edition || '', }) - - this.getRoleFields() } else { notification.warning({ top: 92, @@ -229,7 +225,8 @@ } submitConfig = () => { - const { openEdition } = this.state + // const { btn } = this.props + const { openEdition, delButtons } = this.state let config = fromJS(this.state.config).toJS() if (config.cacheUseful === 'true' && !config.cacheTime) { @@ -251,24 +248,16 @@ delete _config.tableFields let param = { - func: 'sPC_TrdMenu_AddUpt', - FstID: _config.fstMenuId || '', - SndID: _config.parentId, - ParentID: _config.parentId, + func: 'sPC_Tab_AddUpt', MenuID: _config.uuid, - MenuNo: _config.MenuNo || '', - EasyCode: _config.easyCode || '', + MenuNo: _config.tabNo, Template: 'CustomPage', - MenuName: _config.MenuName || '', - PageParam: JSON.stringify({Template: 'CustomPage', OpenType: 'newtab'}), - LongParam: window.btoa(window.encodeURIComponent(JSON.stringify(_config))), - LText: '', - LTexttb: '' + MenuName: _config.tabName, + Remark: '', + Sort: 0, + PageParam: JSON.stringify({Template: 'CustomPage'}), + LongParam: window.btoa(window.encodeURIComponent(JSON.stringify(_config))) } - - param.LText = Utils.formatOptions(param.LText) - param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') - param.secretkey = Utils.encrypt(param.LText, param.timestamp) if (openEdition) { // 鐗堟湰绠$悊 param.open_edition = openEdition @@ -295,11 +284,36 @@ menuloading: true }, () => { new Promise(resolve => { - resolve(true) + if (delButtons.length === 0) { + resolve({ + status: true + }) + } else { + let _param = { + func: 'sPC_MainMenu_Del', + MenuID: delButtons.join(',') + } + Api.getSystemConfig(_param).then(res => { + resolve(res) + }) + } }).then(res => { - if (!res) return - - return Api.getSystemConfig(param) + if (res.status) { + this.setState({ + delButtons: [] + }) + return Api.getSystemConfig(param) + } else { + this.setState({ + menuloading: false + }) + notification.warning({ + top: 92, + message: res.message, + duration: 5 + }) + return false + } }).then(res => { if (!res) return @@ -355,37 +369,6 @@ }) } }) - }) - } - - getRoleFields = () => { - Api.getSystemConfig({func: 'sPC_Get_Roles_sModular'}).then(res => { - if (res.status) { - let _permFuncField = [] - let _sysRoles = [] - - if (res.Roles && res.Roles.length > 0) { - _sysRoles = res.Roles.map(role => { - return { - uuid: Utils.getuuid(), - value: role.RoleID, - text: role.RoleName - } - }) - } - - if (res.sModular && res.sModular.length > 0) { - res.sModular.forEach(field => { - if (field.ModularNo) { - _permFuncField.push(field.ModularNo) - } - }) - _permFuncField = _permFuncField.sort() - } - - sessionStorage.setItem('sysRoles', JSON.stringify(_sysRoles)) - sessionStorage.setItem('permFuncField', JSON.stringify(_permFuncField)) - } }) } @@ -462,50 +445,48 @@ } render () { + const { btn } = this.props const { activeKey, MenuType, dict, config, menuloading } = this.state return ( - <div className="pc-menu-view" id="view"> - <Header /> - <DndProvider backend={HTML5Backend}> - <div className="menu-body"> - <div className="menu-setting"> - <Collapse accordion activeKey={activeKey} bordered={false} onChange={(key) => this.setState({activeKey: key})}> - {/* 鍩烘湰淇℃伅 */} - <Panel header={dict['mob.basemsg']} key="basedata"> - {/* 琛ㄥ悕娣诲姞 */} - {config ? <TableComponent config={config} updatetable={this.updatetable}/> : null} - </Panel> - {/* 缁勪欢娣诲姞 */} - <Panel header={dict['mob.component']} key="component"> - <SourceWrap MenuType={MenuType} /> - </Panel> - <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> - <div className={'menu-view ' + (menuloading ? 'saving' : '')}> - <Card title={ - <div> {config && config.MenuName} </div> - } bordered={false} extra={ - <div> - {config ? <Switch className="big" checkedChildren={dict['mob.enable']} unCheckedChildren={dict['mob.disable']} checked={config.enabled} onChange={this.onEnabledChange} /> : null} - <Button type="primary" onClick={this.submitConfig} loading={menuloading}>{dict['mob.save']}</Button> - <Button type="default" onClick={this.closeView}>{dict['mob.return']}</Button> - </div> - } style={{ width: '100%' }}> - {config && config.components ? <MenuShell menu={config} handleList={this.updateConfig} /> : null} - </Card> - </div> + <DndProvider backend={HTML5Backend}> + <div className="menu-body"> + <div className="menu-setting"> + <Collapse accordion activeKey={activeKey} bordered={false} onChange={(key) => this.setState({activeKey: key})}> + {/* 鍩烘湰淇℃伅 */} + <Panel header={dict['mob.basemsg']} key="basedata"> + {/* 鑿滃崟淇℃伅 */} + {config ? <MenuForm dict={dict} config={config} btn={btn} updateConfig={this.updateConfig}/> : null} + {/* 琛ㄥ悕娣诲姞 */} + {config ? <TableComponent config={config} updatetable={this.updatetable}/> : null} + </Panel> + {/* 缁勪欢娣诲姞 */} + <Panel header={dict['mob.component']} key="component"> + <SourceWrap MenuType={MenuType} /> + </Panel> + <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> - </DndProvider> - <StyleController /> - <ModalController /> - </div> + <div className={'menu-view ' + (menuloading ? 'saving' : '')}> + <Card title={ + <div> {config && config.MenuName} </div> + } bordered={false} extra={ + <div> + {config ? <Switch className="big" checkedChildren={dict['mob.enable']} unCheckedChildren={dict['mob.disable']} checked={config.enabled} onChange={this.onEnabledChange} /> : null} + <Button type="primary" onClick={this.submitConfig} loading={menuloading}>{dict['mob.save']}</Button> + <Button type="default" onClick={this.closeView}>{dict['mob.return']}</Button> + </div> + } style={{ width: '100%' }}> + {config && config.components ? <MenuShell menu={config} handleList={this.updateConfig} /> : null} + </Card> + </div> + </div> + </DndProvider> ) } } -- Gitblit v1.8.0