From 8eb9303af35b6bee86daaa9ff478b623516fc183 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期一, 16 三月 2020 11:49:29 +0800 Subject: [PATCH] 2020-03-16 --- src/components/sidemenu/editthdmenu/menuform/index.jsx | 61 +++++++++++++++++++++++++++--- 1 files changed, 54 insertions(+), 7 deletions(-) diff --git a/src/components/sidemenu/editthdmenu/menuform/index.jsx b/src/components/sidemenu/editthdmenu/menuform/index.jsx index c366f49..162f0ab 100644 --- a/src/components/sidemenu/editthdmenu/menuform/index.jsx +++ b/src/components/sidemenu/editthdmenu/menuform/index.jsx @@ -11,7 +11,29 @@ supMenuList: PropTypes.any // 琛ㄦ牸鏁版嵁 } - state = {} + state = { + menu: null + } + + UNSAFE_componentWillMount () { + this.setState({ + menu: this.props.menu + }) + } + + changeMenu = (val) => { + const { menu } = this.state + + let submenu = menu.fstMenuList.filter(item => item.MenuID === val)[0] + + if (submenu) { + this.setState({ + menu: {...menu, supMenuList: submenu.options} + }, () => { + this.props.form.setFieldsValue({ParentID: submenu.options[0] ? submenu.options[0].MenuID : ''}) + }) + } + } handleConfirm = () => { // 琛ㄥ崟鎻愪氦鏃舵鏌ヨ緭鍏ュ�兼槸鍚︽纭� @@ -28,6 +50,7 @@ render() { const { getFieldDecorator } = this.props.form + const { menu } = this.state const formItemLayout = { labelCol: { xs: { span: 24 }, @@ -38,13 +61,37 @@ sm: { span: 16 } } } + return ( <Form {...formItemLayout} style={{paddingRight: '20px'}}> <Row gutter={24}> <Col span={24}> - <Form.Item label={'涓婄骇鑿滃崟'}> + <Form.Item label={'涓�绾ц彍鍗�'}> + {getFieldDecorator('fstMenuId', { + initialValue: menu.fstMenuId, + rules: [ + { + required: true, + message: this.props.dict['form.required.select'] + '涓婄骇鑿滃崟!' + } + ] + })( + <Select + showSearch + filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} + onChange={this.changeMenu} + > + {menu.fstMenuList.map(option => + <Select.Option id={option.MenuID} title={option.text} key={option.MenuID} value={option.MenuID}>{option.text}</Select.Option> + )} + </Select> + )} + </Form.Item> + </Col> + <Col span={24}> + <Form.Item label={'浜岀骇鑿滃崟'}> {getFieldDecorator('ParentID', { - initialValue: this.props.menu.ParentID, + initialValue: menu.ParentID, rules: [ { required: true, @@ -56,8 +103,8 @@ showSearch filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} > - {this.props.supMenuList.map(option => - <Select.Option id={option.id} title={option.text} key={option.id} value={option.id}>{option.text}</Select.Option> + {menu.supMenuList.map(option => + <Select.Option id={option.MenuID} title={option.text} key={option.MenuID} value={option.MenuID}>{option.text}</Select.Option> )} </Select> )} @@ -66,7 +113,7 @@ <Col span={24}> <Form.Item label={'鑿滃崟鍚嶇О'}> {getFieldDecorator('MenuName', { - initialValue: this.props.menu.MenuName || '', + initialValue: menu.MenuName || '', rules: [ { required: true, @@ -79,7 +126,7 @@ <Col span={24}> <Form.Item label={'鑿滃崟鍙傛暟'}> {getFieldDecorator('MenuNo', { - initialValue: this.props.menu.MenuNo || '', + initialValue: menu.MenuNo || '', rules: [ { required: true, -- Gitblit v1.8.0