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/index.jsx | 278 +++++++++++++++++++++++-------------------------------- 1 files changed, 116 insertions(+), 162 deletions(-) diff --git a/src/components/sidemenu/editthdmenu/index.jsx b/src/components/sidemenu/editthdmenu/index.jsx index 0d1a91f..327e280 100644 --- a/src/components/sidemenu/editthdmenu/index.jsx +++ b/src/components/sidemenu/editthdmenu/index.jsx @@ -71,7 +71,8 @@ sysMenu: false, // 娣诲姞鎴栫紪杈戣彍鍗曪紙瑙掕壊鏉冮檺鍒嗛厤绛夛級 optionLibs: [], // 鑷畾涔変笅鎷夐�夐」搴� fstMenuId: null, // 涓�绾ц彍鍗旾d - fstMenuList: null // 涓�绾ц彍鍗曞垪琛� + fstMenuList: null, // 涓�绾ц彍鍗曞垪琛� + roleList: null // 瑙掕壊鍒楄〃锛屽缓绔嬮粦鍚嶅崟 } /** @@ -129,16 +130,27 @@ delete _menu.src delete _menu.text + if (!this.state.fstMenuId) { + notification.warning({ + top: 92, + message: '鏈幏鍙栧埌涓�绾ц彍鍗曚俊鎭紝璇风◢绛夋垨鍒锋柊閲嶈瘯銆�', + duration: 10 + }) + return + } + + _menu.ParentID = this.props.supMenu.MenuID + _menu.supMenuList = this.props.supMenuList + _menu.fstMenuId = this.state.fstMenuId + _menu.fstMenuList = this.state.fstMenuList + _menu.roleList = this.state.roleList + if (_menu.PageParam && _menu.PageParam.Template === 'RolePermission') { // 鍗曢〉闈慨鏀� - let _menu_ = { - ..._menu, - ParentID: this.props.supMenu.MenuID, - Template: _menu.PageParam.Template - } + _menu.Template = _menu.PageParam.Template this.setState({ handleMVisible: true, - sysMenu: _menu_ + sysMenu: _menu }) return @@ -167,8 +179,7 @@ } _menu.LongParam = _LongParam - _menu.ParentID = this.props.supMenu.MenuID - _menu.supMenuList = this.props.supMenuList + // 妫�娴嬫ā鏉挎槸鍚﹀瓨鍦� let _Template = this.state.sysTemplates.filter(temp => temp.type === _menu.PageParam.Template) @@ -190,65 +201,15 @@ document.getElementById('root').style.overflowY = 'hidden' }) } else { - if (this.state.fstMenuId) { - _menu.fstMenuId = this.state.fstMenuId - _menu.fstMenuList = this.state.fstMenuList - - this.setState({ - type: 'edit', - editMenu: _menu, - loading: false, - optionLibs: new Map(), // 缂栬緫鏃讹紝鍒濆鍖栦负绌� - tabview: _menu.PageParam.Template - }, () => { - document.getElementById('root').style.overflowY = 'hidden' - }) - } else { - let _param = { - func: 's_Get_FSMenusForOpen', - SndMenuID: this.props.supMenu.MenuID, - TYPE: 20, - TypeCharOne: 'PC' - } - - Api.getSystemConfig(_param).then(result => { - if (result.status) { - _menu.fstMenuId = result.FstIDSeleted - _menu.fstMenuList = result.data.map(smenu => { - let _smenu = { - MenuID: smenu.FstID, - text: smenu.FstName, - options: smenu.SndData.map(menu => { - return { - MenuID: menu.SndID, - text: menu.SndName, - } - }) - } - return _smenu - }) - - this.setState({ - type: 'edit', - editMenu: _menu, - loading: false, - optionLibs: new Map(), // 缂栬緫鏃讹紝鍒濆鍖栦负绌� - tabview: _menu.PageParam.Template - }, () => { - document.getElementById('root').style.overflowY = 'hidden' - }) - } else { - this.setState({ - loading: false - }) - notification.warning({ - top: 92, - message: result.message, - duration: 10 - }) - } - }) - } + this.setState({ + type: 'edit', + editMenu: _menu, + loading: false, + optionLibs: new Map(), // 缂栬緫鏃讹紝鍒濆鍖栦负绌� + tabview: _menu.PageParam.Template + }, () => { + document.getElementById('root').style.overflowY = 'hidden' + }) } } else { this.setState({ @@ -276,75 +237,34 @@ return } - if (this.state.fstMenuId) { - this.setState({ - tabview: 'template', - editMenu: { - MenuID: Utils.getuuid(), - MenuName: '', - MenuNo: '', - type: '', - PageParam: '', - LongParam: '', - isSubtable: '', // 鏄惁涓轰富瀛愯〃 - ParentID: this.props.supMenu.MenuID, - supMenuList: this.props.supMenuList, - fstMenuId: this.state.fstMenuId, - fstMenuList: this.state.fstMenuList - } - }, () => { - document.getElementById('root').style.overflowY = 'hidden' + if (!this.state.fstMenuId) { + notification.warning({ + top: 92, + message: '鏈幏鍙栧埌涓�绾ц彍鍗曚俊鎭紝璇风◢绛夋垨鍒锋柊閲嶈瘯', + duration: 10 }) - } else { - let _param = { - func: 's_Get_FSMenusForOpen', - SndMenuID: this.props.supMenu.MenuID, - TYPE: 20, - TypeCharOne: 'PC' - } - - Api.getSystemConfig(_param).then(result => { - if (result.status) { - this.setState({ - tabview: 'template', - editMenu: { - MenuID: Utils.getuuid(), - MenuName: '', - MenuNo: '', - type: '', - PageParam: '', - LongParam: '', - isSubtable: '', // 鏄惁涓轰富瀛愯〃 - ParentID: this.props.supMenu.MenuID, - supMenuList: this.props.supMenuList, - fstMenuId: result.FstIDSeleted, - fstMenuList: result.data.map(smenu => { - let _smenu = { - MenuID: smenu.FstID, - text: smenu.FstName, - options: smenu.SndData.map(menu => { - return { - MenuID: menu.SndID, - text: menu.SndName, - } - }) - } - return _smenu - }) - } - }, () => { - document.getElementById('root').style.overflowY = 'hidden' - }) - } else { - notification.warning({ - top: 92, - message: result.message, - duration: 10 - }) - } - }) + return } - + + this.setState({ + tabview: 'template', + editMenu: { + MenuID: Utils.getuuid(), + MenuName: '', + MenuNo: '', + type: '', + PageParam: '', + LongParam: '', + isSubtable: '', // 鏄惁涓轰富瀛愯〃 + ParentID: this.props.supMenu.MenuID, + supMenuList: this.props.supMenuList, + roleList: this.state.roleList, + fstMenuId: this.state.fstMenuId, + fstMenuList: this.state.fstMenuList + } + }, () => { + document.getElementById('root').style.overflowY = 'hidden' + }) } else if (type === 'thaw') { if (!is(fromJS(this.props.menulist), fromJS(this.state.menulist))) { notification.warning({ @@ -668,6 +588,7 @@ let param = { func: 'sPC_TrdMenu_AddUpt', + FstID: res.fstMenuId, SndID: res.ParentID, ParentID: res.ParentID, MenuID: sysMenu.MenuID, @@ -728,33 +649,67 @@ TYPE: 20, TypeCharOne: 'PC' } + this.setState({ + loading: true + }) - Api.getSystemConfig(_param).then(result => { - if (result.status) { - this.setState({ - fstMenuId: result.FstIDSeleted, - fstMenuList: result.data.map(smenu => { - let _smenu = { - MenuID: smenu.FstID, - text: smenu.FstName, - options: smenu.SndData.map(menu => { - return { - MenuID: menu.SndID, - text: menu.SndName, - } - }) - } - - return _smenu + let menuDefer = new Promise(resolve => { + Api.getSystemConfig(_param).then(result => { + if (result.status) { + this.setState({ + fstMenuId: result.FstIDSeleted, + fstMenuList: result.data.map(smenu => { + let _smenu = { + MenuID: smenu.FstID, + text: smenu.FstName, + options: smenu.SndData.map(menu => { + return { + MenuID: menu.SndID, + text: menu.SndName, + } + }) + } + + return _smenu + }) }) - }) - } else { - notification.warning({ - top: 92, - message: result.message, - duration: 10 - }) - } + } else { + notification.warning({ + top: 92, + message: result.message, + duration: 10 + }) + } + resolve() + }) + }) + + let roleDefer = new Promise(resolve => { + Api.getSystemConfig({func: 'sPC_Get_RolesMenu'}).then(res => { + if (res.status) { + this.setState({ + roleList: res.Roles.map(role => { + return { + value: role.RoleID, + text: role.RoleName + } + }) + }) + } else { + notification.warning({ + top: 92, + message: res.message, + duration: 10 + }) + } + resolve() + }) + }) + + Promise.all([menuDefer, roleDefer]).then(() => { + this.setState({ + loading: false + }) }) } @@ -924,7 +879,7 @@ {!this.state.thawmenulist && <Spin style={{marginLeft: 'calc(50% - 22px)', marginTop: '70px', marginBottom: '70px'}} size="large" />} {this.state.thawmenulist && <TransferForm ref="trawmenu" dict={this.state.dict} menulist={this.state.thawmenulist}/>} </Modal> - {/* 瑙e喕鑿滃崟妯℃�佹 */} + {/* 娣诲姞绯荤粺鑿滃崟 */} <Modal title={this.state.sysMenu && this.state.sysMenu.isSystem ? this.state.dict['header.menu.tadd'] : this.state.dict['header.menu.tupdate']} okText={this.state.dict['header.confirm']} @@ -938,7 +893,6 @@ <MenuForm menu={this.state.sysMenu} dict={this.state.dict} - supMenuList={this.props.supMenuList} wrappedComponentRef={(inst) => this.menuFormRef = inst} /> </Modal> -- Gitblit v1.8.0