From 268be11f39b248920a76568135f8b7b6c4fa9e52 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 13 三月 2020 16:37:22 +0800 Subject: [PATCH] 2020-03-13 --- src/tabviews/rolemanage/index.scss | 2 src/components/header/index.jsx | 12 - src/tabviews/rolemanage/index.jsx | 132 +++++++++++++++++++++----- src/tabviews/subtable/index.jsx | 2 src/tabviews/commontable/index.jsx | 2 src/components/sidemenu/editthdmenu/index.jsx | 8 + src/templates/comtableconfig/index.jsx | 23 +++ src/templates/subtableconfig/index.jsx | 85 ++++++++++++++-- 8 files changed, 211 insertions(+), 55 deletions(-) diff --git a/src/components/header/index.jsx b/src/components/header/index.jsx index 78bd106..2ef03c9 100644 --- a/src/components/header/index.jsx +++ b/src/components/header/index.jsx @@ -83,14 +83,9 @@ _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' // 鏃堕棿鎴� _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp) // md5瀵嗛挜 - let localResult = await Api.getLocalConfig(_param) - let result = {status: true} + let result = await Api.getSystemConfig(_param) // 鍙栨秷淇敼鏈湴瀵嗙爜锛屽彧淇敼鍗曠偣鏈嶅姟鍣� - if (window.GLOB.mainSystemApi && window.GLOB.subSystemApi !== window.GLOB.mainSystemApi) { - result = await Api.getSystemConfig(_param) - } - - if (result.status && localResult.status) { + if (result.status) { this.setState({ visible: false, confirmLoading: false @@ -103,7 +98,7 @@ } else { notification.warning({ top: 92, - message: result.message || localResult.message, + message: result.message, duration: 10 }) this.setState({ @@ -214,6 +209,7 @@ let _permFuncField = [] if (result.UserRoles && result.UserRoles[0] && result.UserRoles[0].RoleMenu) { result.UserRoles[0].RoleMenu.forEach(menu => { + if (!menu.MenuID) return _permAction[menu.MenuID] = true }) } diff --git a/src/components/sidemenu/editthdmenu/index.jsx b/src/components/sidemenu/editthdmenu/index.jsx index 4a22b20..0d1a91f 100644 --- a/src/components/sidemenu/editthdmenu/index.jsx +++ b/src/components/sidemenu/editthdmenu/index.jsx @@ -668,15 +668,21 @@ let param = { func: 'sPC_TrdMenu_AddUpt', + SndID: res.ParentID, ParentID: res.ParentID, MenuID: sysMenu.MenuID, MenuNo: res.MenuNo, Template: sysMenu.Template, MenuName: res.MenuName, PageParam: JSON.stringify({Template: sysMenu.Template, OpenType: 'newtab'}), - LongParam: '' + LongParam: '', + LText: '', + LTexttb: '' } + param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' + param.secretkey = Utils.encrypt(param.LText, param.timestamp) + this.setState({ confirmLoading: true }) diff --git a/src/tabviews/commontable/index.jsx b/src/tabviews/commontable/index.jsx index b60f2b6..d131e3a 100644 --- a/src/tabviews/commontable/index.jsx +++ b/src/tabviews/commontable/index.jsx @@ -118,7 +118,7 @@ } // 鏉冮檺杩囨护 - config.action = config.action.filter(item => permAction[item.uuid]) + config.action = config.action.filter(item => permAction[item.uuid] || (item.linkTab && permAction[item.linkTab])) config.tabgroups.forEach(group => { if (!config[group]) return diff --git a/src/tabviews/rolemanage/index.jsx b/src/tabviews/rolemanage/index.jsx index d34b705..a123a32 100644 --- a/src/tabviews/rolemanage/index.jsx +++ b/src/tabviews/rolemanage/index.jsx @@ -12,7 +12,9 @@ const { Search } = Input const { TabPane } = Tabs const { TreeNode, DirectoryTree } = Tree -let _checkedKeys = null +let checkedKeysMap = null +let linkMap = null +let selectMap = null export default class RoleManage extends Component { static propTpyes = { @@ -72,7 +74,8 @@ return { title: item.MenuName, key: item.MenuID, - children: [] + children: [], + selected: true } }) }, () => { @@ -107,19 +110,15 @@ } if (tabKey === '') { - let _mainMenuKeys = mainMenus.map(menu => menu.key) - - _checkedKeys = [] - let _checkMainKeys = [] // 閫変腑鐨勪竴绾ц彍鍗曪紝闇�鍒ゆ柇鏄惁鍚湁瀛愯彍鍗� let _initCheckKeys = [] // 鍒濆閫変腑鐨勮彍鍗昳d + checkedKeysMap = new Map() + linkMap = new Map() + selectMap = new Map() + result.data.forEach(item => { if (item.Selected !== 'true') return - if (!_mainMenuKeys.includes(item.MenuID)) { - _checkedKeys.push(item.MenuID) - } else { - _checkMainKeys.push(item.MenuID) - } + checkedKeysMap.set(item.MenuID, true) _initCheckKeys.push(item.MenuID) }) @@ -131,18 +130,12 @@ this.getOpenNode(_tree[0], _openKeys) } - _tree.forEach(item => { - if (_checkMainKeys.includes(item.key) && !item.children) { - _checkedKeys.push(item.key) - } - }) - _state.menuTrees = _tree _state.initCheckKeys = _initCheckKeys - _state.checkedKeys = _checkedKeys + _state.checkedKeys = Array.from(checkedKeysMap.keys()) _state.menuOpenKeys = _openKeys } else { - _tree = this.getTree(JSON.parse(JSON.stringify(mainMenus)), result.data) + _tree = this.getSelectTree(JSON.parse(JSON.stringify(mainMenus)), result.data) _tree = _tree.filter(node => node.children) if (_tree[0]) { @@ -179,12 +172,14 @@ parents.forEach(parent => { parent.children = [] - options.forEach((option, index) => { + options.forEach(option => { if (option.ParentID === parent.key) { parent.children.push({ title: option.MenuName, key: option.MenuID, - selected: option.Selected === 'true' + selected: parent.selected && option.Selected === 'true', + addSelf: option.OnlySelf === 'true', + tabs: option.Tabs }) } }) @@ -192,11 +187,75 @@ if (parent.children.length === 0) { parent.children = null - } else { - if (_checkedKeys && parent.selected) { - _checkedKeys = _checkedKeys.filter(key => key !== parent.key) + if (parent.tabs) { + let _uuid = Utils.getuuid() + linkMap.set(_uuid, parent.key) + + if (parent.selected) { + checkedKeysMap.set(_uuid, true) + checkedKeysMap.delete(parent.key) + + selectMap.set(_uuid, parent.key) + } + + parent.key = _uuid } + } else { + if (parent.selected) { + checkedKeysMap.delete(parent.key) + } + if (parent.addSelf) { + let _uuid = Utils.getuuid() + linkMap.set(_uuid, parent.key) + + if (parent.selected) { + checkedKeysMap.set(_uuid, true) + } + + parent.children.unshift({ + title: parent.title + '(浠呴〉闈�)', + key: _uuid, + }) + } + + if (parent.tabs) { + let _uuid = Utils.getuuid() + linkMap.set(_uuid, parent.key) + + if (parent.selected) { + selectMap.set(_uuid, parent.key) + } + + parent.key = _uuid + } + parent.children = this.getTree(parent.children, options) + } + }) + + return parents + } + + getSelectTree = (parents, options) => { + parents.forEach(parent => { + parent.children = [] + + options.forEach(option => { + if (option.ParentID === parent.key) { + parent.children.push({ + title: option.MenuName, + key: option.MenuID, + tabs: option.Tabs + }) + } + }) + + + parent.key = Utils.getuuid() + if (parent.children.length === 0) { + parent.children = null + } else { + parent.children = this.getSelectTree(parent.children, options) } }) @@ -234,7 +293,6 @@ } onCheck = (checkedKeys, info) => { - console.log(checkedKeys) this.setState({ checkedKeys: checkedKeys, halfCheckedKeys: info.halfCheckedKeys, @@ -262,7 +320,24 @@ if (initCheckKeys) { _keys = initCheckKeys } else { - _keys = checkedKeys.concat(halfCheckedKeys) + let _cKeys = checkedKeys.concat(halfCheckedKeys) + _cKeys.forEach(key => { + if (linkMap.has(key)) { + _keys.push(linkMap.get(key)) + } else { + _keys.push(key) + } + }) + _cKeys = new Map(_cKeys.map(key => [key, true])) + _keys = new Map(_keys.map(key => [key, true])) + + Array.from(selectMap.keys()).forEach(key => { + if (!_cKeys.has(key)) { + _keys.delete(selectMap.get(key)) + } + }) + + _keys = Array.from(_keys.keys()) } let _LText = _keys.map(key => `select '${key}' as MenuID`) @@ -288,8 +363,13 @@ }) this.setState({ submitloading: false, + menuTrees: null, + checkedKeys: [], + menuOpenKeys: [], selectMenuTrees: null, selectMenuOpenKeys: [] + }, () => { + this.getAllMenuList() }) } else { notification.warning({ diff --git a/src/tabviews/rolemanage/index.scss b/src/tabviews/rolemanage/index.scss index 0010344..7140d77 100644 --- a/src/tabviews/rolemanage/index.scss +++ b/src/tabviews/rolemanage/index.scss @@ -14,7 +14,6 @@ .role-title { display: inline-block; width: 100%; - // color: #36c6d3; color: #1890ff; .anticon-bank { margin-right: 5px; @@ -26,6 +25,7 @@ float: right; input { border-radius: 20px; + // border: 1px solid #e9e9e9; height: 30px; } } diff --git a/src/tabviews/subtable/index.jsx b/src/tabviews/subtable/index.jsx index 5a14bc9..c8e8bc6 100644 --- a/src/tabviews/subtable/index.jsx +++ b/src/tabviews/subtable/index.jsx @@ -119,7 +119,7 @@ // 鏉冮檺杩囨护 if (this.props.menuType !== 'HS') { - config.action = config.action.filter(item => permAction[item.uuid]) + config.action = config.action.filter(item => permAction[item.uuid] || (item.linkTab && permAction[item.linkTab])) } // 1銆佺瓫閫夊瓧娈甸泦锛�2銆佽繃婊ら殣钘忓垪鍙婂悎骞跺垪涓殑瀛楁uuid diff --git a/src/templates/comtableconfig/index.jsx b/src/templates/comtableconfig/index.jsx index db2e165..c245ad2 100644 --- a/src/templates/comtableconfig/index.jsx +++ b/src/templates/comtableconfig/index.jsx @@ -1760,6 +1760,7 @@ } let _sort = 0 + let btntabs = [] let btnParam = { // 娣诲姞鑿滃崟鎸夐挳 func: 'sPC_Button_AddUpt', @@ -1769,11 +1770,22 @@ Template: menu.PageParam.Template || '', PageParam: '', LongParam: '', - LText: _config.action.map(item => { - _sort++ - return `select '${item.uuid}' as menuid, '${item.label}' as menuname, '${_sort * 10}' as Sort` - }) + LText: [] } + + _config.action.forEach(item => { + _sort++ + if (item.OpenType === 'popview') { + btntabs.push({ + uuid: item.uuid, + linkTab: item.linkTab, + label: item.label, + sort: _sort + }) + } else { + btnParam.LText.push(`select '${item.uuid}' as menuid, '${item.label}' as menuname, '${_sort * 10}' as Sort`) + } + }) btnParam.LText = btnParam.LText.join(' union all ') btnParam.LText = Utils.formatOptions(btnParam.LText) @@ -1787,6 +1799,9 @@ let _LText = [] + btntabs.forEach(item => { + _LText.push(`select '${item.uuid}' as MenuID ,'${item.linkTab}' as Tabid,'${item.label}' as TabName ,'${item.sort * 10}' as Sort`) + }) _config.tabgroups.forEach(groupId => { _config[groupId].forEach(item => { _sort++ diff --git a/src/templates/subtableconfig/index.jsx b/src/templates/subtableconfig/index.jsx index 1de6f80..0cfba96 100644 --- a/src/templates/subtableconfig/index.jsx +++ b/src/templates/subtableconfig/index.jsx @@ -344,6 +344,14 @@ tabview: _tabview } + this.state.copyActions.forEach(item => { + let _param = { + func: 'sPC_MainMenu_Del', + MenuID: item + } + Api.getSystemConfig(_param) + }) + this.props.handleView(param) } @@ -1440,15 +1448,33 @@ Template: 'SubTable', PageParam: '', LongParam: '', - LText: config.action.map((item, index) => { - return `select '${item.uuid}' as menuid, '${item.label}' as menuname, '${(index + 1) * 10}' as Sort` - }) + LText: [] } + + let btntabs = [] + + config.action.forEach((item, index) => { + if (item.OpenType === 'popview') { + btntabs.push(`select '${item.uuid}' as MenuID ,'${item.linkTab}' as Tabid,'${item.label}' as TabName ,'${(index + 1) * 10}' as Sort`) + } else { + btnParam.LText.push(`select '${item.uuid}' as menuid, '${item.label}' as menuname, '${(index + 1) * 10}' as Sort`) + } + }) btnParam.LText = btnParam.LText.join(' union all ') btnParam.LText = Utils.formatOptions(btnParam.LText) btnParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' btnParam.secretkey = Utils.encrypt(btnParam.LText, btnParam.timestamp) + + let tabParam = { // 娣诲姞鏍囩鎸夐挳tab椤� + func: 'sPC_sMenusTab_AddUpt', + MenuID: _config.uuid, + LText: btntabs.join(' union all ') + } + + tabParam.LText = Utils.formatOptions(tabParam.LText) + tabParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' + tabParam.secretkey = Utils.encrypt(tabParam.LText, tabParam.timestamp) let param = { func: 'sPC_Tab_AddUpt', @@ -1573,7 +1599,7 @@ menuloading: false, menucloseloading: false }) - this.submitAction(btnParam) + this.submitAction(btnParam, tabParam) }) } else { this.setState({ @@ -1601,24 +1627,57 @@ /** * @description 淇濆瓨鎴栦慨鏀硅彍鍗曟寜閽� */ - submitAction = (param) => { + submitAction = (btnParam, tabParam) => { const { config } = this.state + new Promise(resolve => { - if (param.LText) { - Api.getSystemConfig(param).then(res => { - if (res.status) { - resolve(true) - } else { + let deffers = [] + + if (tabParam.LText) { + let defer = new Promise(resolve => { + Api.getSystemConfig(tabParam).then(result => { + resolve(result) + }) + }) + deffers.push(defer) + } + + if (btnParam.LText) { + let defer = new Promise(resolve => { + Api.getSystemConfig(btnParam).then(result => { + if (result.status) { + this.setState({ // 淇濆瓨鎴愬姛鍚庢竻绌哄鍒跺垪琛� + copyActions: [] + }) + } + resolve(result) + }) + }) + deffers.push(defer) + } + + if (deffers.length === 0) { + resolve(true) + } else { + Promise.all(deffers).then(result => { + let error = false + result.forEach(res => { + if (!res.status) { + error = res + } + }) + + if (error) { notification.warning({ top: 92, - message: res.message, + message: error.message, duration: 10 }) resolve(false) + } else { + resolve(true) } }) - } else { - resolve(true) } }).then(response => { if (response === false) return response -- Gitblit v1.8.0