From aa8a9f0845ed197adbfdf152376121e172bee574 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 01 六月 2023 10:44:05 +0800 Subject: [PATCH] 2023-06-01 --- src/views/menudesign/menuform/index.jsx | 196 +++++++++++++++++++++++++++++++------------------ 1 files changed, 124 insertions(+), 72 deletions(-) diff --git a/src/views/menudesign/menuform/index.jsx b/src/views/menudesign/menuform/index.jsx index 5f217c5..f746df1 100644 --- a/src/views/menudesign/menuform/index.jsx +++ b/src/views/menudesign/menuform/index.jsx @@ -26,7 +26,57 @@ } UNSAFE_componentWillMount () { + if (sessionStorage.getItem('thdMenuList') && sessionStorage.getItem('fstMenuList')) { + this.setMenus() + } else { + this.getMenus() + } + } + + 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 @@ -64,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) { @@ -79,6 +124,10 @@ } catch (e) { } + } + + if (MenuId === trd.MenuID) { + thdMenu = trdItem } thdMenuList.push(trdItem) @@ -93,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 : ''}) @@ -142,45 +193,14 @@ this.props.form.setFieldsValue({parentId: _id}) this.props.updateConfig({...config, fstMenuId: value, parentId: _id}) }) - } else if (key === 'parentId') { - this.props.updateConfig({...config, parentId: value}) - } else if (key === 'cacheUseful') { - this.props.updateConfig({...config, cacheUseful: value}) - } else if (key === 'timeUnit') { - this.props.updateConfig({...config, timeUnit: value}) - } else if (key === 'OpenType') { - this.props.updateConfig({...config, OpenType: value}) - } else if (key === 'hidden') { - this.props.updateConfig({...config, hidden: value}) - } else if (key === 'permission') { - this.props.updateConfig({...config, permission: value}) + } else { + if (key === 'cacheTime' || key === 'minWidth') { + if (typeof(value) !== 'number') { + value = '' + } + } + this.props.updateConfig({...config, [key]: value}) } - } - - // 鑿滃崟鍚嶇О - changeName = (e) => { - this.props.updateConfig({...this.props.config, MenuName: e.target.value}) - } - - // 鑿滃崟鍙傛暟 - changeNo = (e) => { - this.props.updateConfig({...this.props.config, MenuNo: e.target.value}) - } - - // 鍔╄鐮� - changeEasyCode = (e) => { - this.props.updateConfig({...this.props.config, easyCode: e.target.value}) - } - - changeRemark = (e) => { - this.props.updateConfig({...this.props.config, Remark: e.target.value}) - } - - changeCacheDay = (val) => { - if (typeof(val) !== 'number') { - val = '' - } - this.props.updateConfig({...this.props.config, cacheTime: val}) } render() { @@ -253,7 +273,7 @@ message: '璇疯緭鍏ヨ彍鍗曞悕绉�!' } ] - })(<Input placeholder="" autoComplete="off" onChange={this.changeName}/>)} + })(<Input placeholder="" autoComplete="off" onChange={(e) => {this.selectChange('MenuName', e.target.value)}}/>)} </Form.Item> </Col> <Col span={24}> @@ -266,7 +286,7 @@ message: '璇疯緭鍏ヨ彍鍗曞弬鏁�!' } ] - })(<Input placeholder="" autoComplete="off" onChange={this.changeNo}/>)} + })(<Input placeholder="" autoComplete="off" onChange={(e) => {this.selectChange('MenuNo', e.target.value)}}/>)} </Form.Item> </Col> <Col span={24}> @@ -289,23 +309,6 @@ </Col> <Col span={24}> <Form.Item label={ - <Tooltip placement="topLeft" title="瀵逛簬涓嶇粡甯告�у彉鍔ㄧ殑淇℃伅锛岀紦瀛樻暟鎹湁鍔╀簬鎻愰珮鏌ヨ鏁堢巼銆�"> - <QuestionCircleOutlined className="mk-form-tip" /> - 缂撳瓨鏁版嵁 - </Tooltip> - }> - {getFieldDecorator('cacheUseful', { - initialValue: config.cacheUseful || 'false' - })( - <Radio.Group onChange={(e) => {this.selectChange('cacheUseful', e.target.value)}}> - <Radio value="true">浣跨敤</Radio> - <Radio value="false">涓嶄娇鐢�</Radio> - </Radio.Group> - )} - </Form.Item> - </Col> - <Col span={24}> - <Form.Item label={ <Tooltip placement="topLeft" title="璺宠繃鏉冮檺楠岃瘉鏃讹紝椤甸潰涓粍浠跺強鎸夐挳涓嶅湪杩涜鏉冮檺鎺у埗銆�"> <QuestionCircleOutlined className="mk-form-tip" /> 鏉冮檺楠岃瘉 @@ -321,14 +324,49 @@ )} </Form.Item> </Col> + <Col span={24}> + <Form.Item label={ + <Tooltip placement="topLeft" title="鏁版嵁浼氱紦瀛樺埌鐢ㄦ埛鏈湴锛屾柟渚块〉闈㈠揩閫熷憟鐜般��"> + <QuestionCircleOutlined className="mk-form-tip" /> + 鏈湴缂撳瓨 + </Tooltip> + }> + {getFieldDecorator('cacheLocal', { + initialValue: config.cacheLocal || 'false' + })( + <Radio.Group onChange={(e) => {this.selectChange('cacheLocal', e.target.value)}}> + <Radio value="true">浣跨敤</Radio> + <Radio value="false">涓嶄娇鐢�</Radio> + </Radio.Group> + )} + </Form.Item> + </Col> + <Col span={24}> + <Form.Item label={ + <Tooltip placement="topLeft" title="瀵逛簬涓嶇粡甯告�у彉鍔ㄧ殑淇℃伅锛岀紦瀛樻暟鎹湁鍔╀簬鎻愰珮鏌ヨ鏁堢巼銆�"> + <QuestionCircleOutlined className="mk-form-tip" /> + 鍚庣缂撳瓨 + </Tooltip> + }> + {getFieldDecorator('cacheUseful', { + initialValue: config.cacheUseful || 'false' + })( + <Radio.Group onChange={(e) => {this.selectChange('cacheUseful', e.target.value)}}> + <Radio value="true">浣跨敤</Radio> + <Radio value="false">涓嶄娇鐢�</Radio> + </Radio.Group> + )} + </Form.Item> + </Col> {config.cacheUseful === 'true' ? <Col span={24}> <Form.Item label="鍗曚綅"> {getFieldDecorator('timeUnit', { initialValue: config.timeUnit || 'day' })( - <Radio.Group onChange={(e) => {this.selectChange('timeUnit', e.target.value)}}> + <Radio.Group style={{whiteSpace: 'nowrap'}} onChange={(e) => {this.selectChange('timeUnit', e.target.value)}}> <Radio value="day">澶�</Radio> <Radio value="hour">灏忔椂</Radio> + <Radio value="minute">鍒嗛挓</Radio> </Radio.Group> )} </Form.Item> @@ -344,15 +382,29 @@ } ] })( - <InputNumber min={1} max={config.timeUnit !== 'hour' ? 7 : 23} precision={0} onChange={this.changeCacheDay}/> + <InputNumber min={1} max={config.timeUnit === 'day' ? 7 : (config.timeUnit === 'hour' ? 23 : 59)} precision={0} onChange={(val) => {this.selectChange('cacheTime', val)}}/> )} </Form.Item> </Col> : null} <Col span={24}> + <Form.Item label={ + <Tooltip placement="topLeft" title="濡傛灉椤甸潰鍐呭鍦ㄧ獥鍙d腑鏃犳硶瀹屽叏灞曠ず锛屽彲璁剧疆鏈�灏忓搴︼紝瀹炵幇椤甸潰鐨勬í鍚戞粴鍔ㄣ��"> + <QuestionCircleOutlined className="mk-form-tip" /> + 鏈�灏忓搴� + </Tooltip> + }> + {getFieldDecorator('minWidth', { + initialValue: config.minWidth + })( + <InputNumber min={0} precision={0} onChange={(val) => {this.selectChange('minWidth', val)}}/> + )} + </Form.Item> + </Col> + <Col span={24}> <Form.Item label="鍔╄鐮�"> {getFieldDecorator('easyCode', { initialValue: config.easyCode - })(<Input placeholder="" autoComplete="off" onChange={this.changeEasyCode}/>)} + })(<Input placeholder="" autoComplete="off" onChange={(e) => {this.selectChange('easyCode', e.target.value)}}/>)} </Form.Item> </Col> <Col span={24}> @@ -362,7 +414,7 @@ }} /> </Form.Item> </Col> - <Col span={24}> + <Col span={24} className="red-font"> <Form.Item label="澶囨敞"> {getFieldDecorator('Remark', { initialValue: config.Remark || '', @@ -372,7 +424,7 @@ message: '澶囨敞鏈�澶�512涓瓧绗︼紒' } ] - })(<TextArea rows={2} placeholder={''} onChange={this.changeRemark} />)} + })(<TextArea rows={2} placeholder={''} onChange={(e) => {this.selectChange('Remark', e.target.value)}}/>)} </Form.Item> </Col> </Row> -- Gitblit v1.8.0