From fa80db0a824464cd0cbc46d5207021263211236d Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 05 十一月 2019 09:21:32 +0800 Subject: [PATCH] thirdmenu --- src/components/sidemenu/menuform/index.jsx | 89 +++++++++++++++++++++++++++++++++++++++----- 1 files changed, 78 insertions(+), 11 deletions(-) diff --git a/src/components/sidemenu/menuform/index.jsx b/src/components/sidemenu/menuform/index.jsx index 549b996..71151ef 100644 --- a/src/components/sidemenu/menuform/index.jsx +++ b/src/components/sidemenu/menuform/index.jsx @@ -38,12 +38,38 @@ initVal: 'folder', required: true, options: [{ - id: 'folder', + MenuID: 'folder', text: 'folder' }, { - id: 'api', + MenuID: 'api', text: 'api' }] + } + ], + tlevel: [ + { + type: 'select', + key: 'parentId', + label: this.props.dict['header.menu.supMenu'], + initVal: '', + required: true, + options: [] + }, + { + type: 'text', + key: 'menuName', + label: this.props.dict['header.menu.menuName'], + initVal: '', + required: true, + readonly: false + }, + { + type: 'text', + key: 'menuNo', + label: this.props.dict['header.menu.menuNo'], + initVal: '', + required: true, + readonly: false } ] } @@ -55,7 +81,6 @@ UNSAFE_componentWillReceiveProps (nextProps) { if (nextProps.options.visible && !is(fromJS(this.props.options), fromJS(nextProps.options))) { - console.log(nextProps.options) this.resetform(nextProps.options) } } @@ -64,8 +89,7 @@ if (!options.visible) return let formlist = JSON.parse(JSON.stringify(this.state.menuform[options.level])) - - if (options.type === 'add') { + if (options.type === 'add' && options.level === 'slevel') { this.setState({ formlist: formlist.map(item =>{ if (item.key === 'parentId') { @@ -75,16 +99,40 @@ return item }) }) - } else { + } else if (options.type === 'add' && options.level === 'tlevel') { + this.setState({ + formlist: formlist.map(item =>{ + if (item.key === 'parentId') { + item.initVal = options.parentMenu.MenuID + item.options = options.supMenuList + } + return item + }) + }) + } else if (options.type === 'edit' && options.level === 'slevel') { this.setState({ formlist: formlist.map(item => { if (item.key === 'parentId') { item.initVal = options.parentMenu.MenuID item.options = options.supMenuList } else if (item.key === 'menuName') { - item.initVal = options.menu.MenuNameP + item.initVal = options.menu.text } else if (item.key === 'icon') { item.initVal = options.menu.PageParam.Icon + } + return item + }) + }) + } else if (options.type === 'edit' && options.level === 'tlevel') { + this.setState({ + formlist: formlist.map(item => { + if (item.key === 'parentId') { + item.initVal = options.parentMenu.MenuID + item.options = options.supMenuList + } else if (item.key === 'menuName') { + item.initVal = options.menu.text + } else if (item.key === 'menuNo') { + item.initVal = options.menu.MenuNo } return item }) @@ -150,12 +198,12 @@ })( <Select showSearch - filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} + filterOption={(input, option) => option.props.children[2].toLowerCase().indexOf(input.toLowerCase()) >= 0} onChange={(value) => {this.openTypeChange(item.key, value)}} getPopupContainer={() => document.getElementById('form-box')} > {item.options.map(option => - <Select.Option id={option.id} title={option.text} key={option.id} value={option.id}> + <Select.Option id={option.MenuID} title={option.text} key={option.MenuID} value={option.MenuID}> {item.key === 'icon' && <Icon type={option.text} />} {option.text} </Select.Option> )} @@ -185,15 +233,34 @@ Icon: values.icon }) }) - } else { + } else if (this.props.options.type === 'edit' && this.props.options.level === 'slevel') { resolve({ ParentID: values.parentId, - MenuID: this.props.options.menu.ParentID, + MenuID: this.props.options.menu.MenuID, MenuName: values.menuName, PageParam: JSON.stringify({ Icon: values.icon }) }) + } else if (this.props.options.type === 'add' && this.props.options.level === 'tlevel') { + resolve({ + ParentID: values.parentId, + MenuID: this.props.options.menu.MenuID, + MenuName: values.menuName, + PageParam: JSON.stringify({ + Icon: values.icon + }) + }) + } else if (this.props.options.type === 'edit' && this.props.options.level === 'tlevel') { + resolve({ + ParentID: values.parentId, + MenuID: this.props.options.menu.MenuID, + MenuName: values.menuName, + MenuNo: values.menuNo, + PageParam: JSON.stringify({ + Icon: values.icon + }) + }) } } else { reject(err) -- Gitblit v1.8.0