From cb9ade2afd2a367ad767bc605ab7086c695dd010 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 09 十二月 2022 15:53:32 +0800 Subject: [PATCH] 2022-12-09 --- src/views/menudesign/menuform/index.jsx | 103 +++++++++++++++++++++++++++++++++++++-------------- 1 files changed, 75 insertions(+), 28 deletions(-) diff --git a/src/views/menudesign/menuform/index.jsx b/src/views/menudesign/menuform/index.jsx index 78f5593..dc39e55 100644 --- a/src/views/menudesign/menuform/index.jsx +++ b/src/views/menudesign/menuform/index.jsx @@ -11,7 +11,6 @@ class CustomMenuForm extends Component { static propTpyes = { - dict: PropTypes.object, // 瀛楀吀椤� config: PropTypes.object, MenuId: PropTypes.string, MenuName: PropTypes.string, @@ -27,11 +26,58 @@ } UNSAFE_componentWillMount () { - const { MenuId, config } = this.props - let _param = {func: 's_get_pc_menus', systemType: options.sysType, debug: 'Y'} - _param.pro_sys = window.GLOB.systemType === 'production' ? 'Y' : '' + if (sessionStorage.getItem('thdMenuList') && sessionStorage.getItem('fstMenuList')) { + this.setMenus() + } else { + this.getMenus() + } + } - Api.getSystemConfig(_param).then(result => { + setMenus = () => { + const { MenuId, config } = this.props + + let menulist = sessionStorage.getItem('fstMenuList') + let thdMenuList = sessionStorage.getItem('thdMenuList') + + menulist = JSON.parse(menulist) + thdMenuList = JSON.parse(thdMenuList) + + let thdMenu = null + + thdMenuList.forEach(trd => { + if (MenuId === trd.MenuID) { + thdMenu = trd + } + }) + + let smenulist = [] + + if (thdMenu) { + menulist.forEach(item => { + if (item.MenuID === thdMenu.FstId) { + smenulist = item.children + } + }) + } + + this.props.updateConfig({...config, fstMenuId: thdMenu ? thdMenu.FstId : ''}) + + this.setState({ + fstMenuId: thdMenu ? thdMenu.FstId : '', + menulist, + smenulist + }, () => { + this.props.form.setFieldsValue({ + fstMenuId: thdMenu ? thdMenu.FstId : '', + parentId: thdMenu ? thdMenu.ParentId : '' + }) + }) + } + + getMenus = () => { + const { MenuId, config } = this.props + + Api.getSystemConfig({func: 's_get_pc_menus', systemType: options.sysType, debug: 'Y'}).then(result => { if (result.status) { let thdMenu = null let thdMenuList = [] @@ -68,12 +114,7 @@ value: trd.MenuID, label: trd.MenuName, type: 'CommonTable', - // disabled: trd.MenuID === MenuId disabled: false - } - - if (MenuId === trd.MenuID) { - thdMenu = trdItem } if (trd.PageParam) { @@ -83,6 +124,10 @@ } catch (e) { } + } + + if (MenuId === trd.MenuID) { + thdMenu = trdItem } thdMenuList.push(trdItem) @@ -97,11 +142,13 @@ }) let smenulist = [] - menulist.forEach(item => { - if (thdMenu && (item.MenuID === thdMenu.FstId)) { - smenulist = item.children - } - }) + if (thdMenu) { + menulist.forEach(item => { + if (item.MenuID === thdMenu.FstId) { + smenulist = item.children + } + }) + } sessionStorage.setItem('fstMenuList', JSON.stringify(menulist)) sessionStorage.setItem('thdMenuList', JSON.stringify(thdMenuList)) this.props.updateConfig({...config, fstMenuId: thdMenu ? thdMenu.FstId : ''}) @@ -188,7 +235,7 @@ } render() { - const { dict, MenuName, MenuNo, config } = this.props + const { MenuName, MenuNo, config } = this.props const { menulist, smenulist } = this.state const { getFieldDecorator } = this.props.form const formItemLayout = { @@ -206,13 +253,13 @@ <Form {...formItemLayout} className="custom-menu-form"> <Row> <Col span={24}> - <Form.Item label={dict['mob.menu.first'] + dict['mob.menu']}> + <Form.Item label="涓�绾ц彍鍗�"> {getFieldDecorator('fstMenuId', { initialValue: '', rules: [ { required: true, - message: dict['mob.required.select'] + dict['mob.menu.first'] + dict['mob.menu'] + '!' + message: '璇烽�夋嫨涓�绾ц彍鍗�!' } ] })( @@ -227,13 +274,13 @@ </Form.Item> </Col> <Col span={24}> - <Form.Item label={dict['mob.menu.second'] + dict['mob.menu']}> + <Form.Item label="浜岀骇鑿滃崟"> {getFieldDecorator('parentId', { initialValue: '', rules: [ { required: true, - message: dict['mob.required.select'] + dict['mob.menu.second'] + dict['mob.menu'] + '!' + message: '璇烽�夋嫨浜岀骇鑿滃崟!' } ] })( @@ -248,26 +295,26 @@ </Form.Item> </Col> <Col span={24}> - <Form.Item label={dict['mob.menu'] + dict['mob.name']}> + <Form.Item label="鑿滃崟鍚嶇О"> {getFieldDecorator('MenuName', { initialValue: MenuName, rules: [ { required: true, - message: dict['mob.required.input'] + dict['mob.menu'] + dict['mob.name'] + '!' + message: '璇疯緭鍏ヨ彍鍗曞悕绉�!' } ] })(<Input placeholder="" autoComplete="off" onChange={this.changeName}/>)} </Form.Item> </Col> <Col span={24}> - <Form.Item label={dict['mob.menu'] + dict['mob.param']}> + <Form.Item label="鑿滃崟鍙傛暟"> {getFieldDecorator('MenuNo', { initialValue: MenuNo, rules: [ { required: true, - message: dict['mob.required.input'] + dict['mob.menu'] + dict['mob.param'] + '!' + message: '璇疯緭鍏ヨ彍鍗曞弬鏁�!' } ] })(<Input placeholder="" autoComplete="off" onChange={this.changeNo}/>)} @@ -280,7 +327,7 @@ rules: [ { required: true, - message: dict['form.required.select'] + dict['model.openway'] + '!' + message: '璇烽�夋嫨鎵撳紑鏂瑰紡!' } ] })( @@ -344,7 +391,7 @@ rules: [ { required: true, - message: dict['mob.required.input'] + '鏃堕暱!' + message: '璇疯緭鍏ユ椂闀�!' } ] })( @@ -353,14 +400,14 @@ </Form.Item> </Col> : null} <Col span={24}> - <Form.Item label={dict['mob.menu.easycode']}> + <Form.Item label="鍔╄鐮�"> {getFieldDecorator('easyCode', { initialValue: config.easyCode })(<Input placeholder="" autoComplete="off" onChange={this.changeEasyCode}/>)} </Form.Item> </Col> <Col span={24}> - <Form.Item label={'闅愯棌鑿滃崟'}> + <Form.Item label="闅愯棌鑿滃崟"> <Switch checkedChildren={'鏄�'} checked={config.hidden === 'true'} unCheckedChildren={'鍚�'} onChange={(value) => { this.selectChange('hidden', value + '') }} /> -- Gitblit v1.8.0