From 3659f0773a14b54c18ed0af8b64de4afe8227489 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 04 十二月 2020 19:31:12 +0800 Subject: [PATCH] 2020-12-04 --- src/tabviews/custom/index.jsx | 65 ++++++++++++++++++++++++-------- 1 files changed, 48 insertions(+), 17 deletions(-) diff --git a/src/tabviews/custom/index.jsx b/src/tabviews/custom/index.jsx index 74a4302..23148b7 100644 --- a/src/tabviews/custom/index.jsx +++ b/src/tabviews/custom/index.jsx @@ -55,7 +55,7 @@ * @description 鑾峰彇椤甸潰閰嶇疆淇℃伅 */ async loadconfig () { - const { permAction, param } = this.props + const { permAction, permMenus, param } = this.props let _param = { func: 'sPC_Get_LongParam', @@ -113,9 +113,7 @@ // 鏉冮檺杩囨护 let roleId = sessionStorage.getItem('role_id') || '' // 瑙掕壊ID - if (this.props.menuType !== 'HS') { - config.components = this.filterComponent(config.components, roleId) - } + config.components = this.filterComponent(config.components, roleId, permAction, permMenus) // 鑾峰彇涓绘悳绱㈡潯浠� let mainSearch = [] @@ -150,7 +148,7 @@ inherit.cacheTime = config.cacheTime } - config.components = this.formatSetting(config.components, params, mainSearch, permAction, inherit) + config.components = this.formatSetting(config.components, params, mainSearch, inherit) this.setState({ BID: BID, @@ -181,7 +179,7 @@ } } - filterComponent = (components, roleId) => { + filterComponent = (components, roleId, permAction, permMenus) => { return components.filter(item => { if (item.type === 'tabs') { if ( @@ -192,7 +190,7 @@ } item.subtabs = item.subtabs.map(tab => { - tab.components = this.filterComponent(tab.components, roleId) + tab.components = this.filterComponent(tab.components, roleId, permAction, permMenus) return tab }) @@ -222,6 +220,7 @@ return false } } + // 鎼滅储榛戝悕鍗曡繃婊� if (item.search && item.search.length > 0) { item.search = item.search.map(cell => { cell.oriInitval = cell.initval @@ -234,26 +233,57 @@ return item }) } + if (item.type === 'table' && item.subtype === 'normaltable') { + item.cols = item.cols.map(col => { + if (!col.blacklist || col.blacklist.length === 0) return col + if (col.blacklist.filter(v => roleId.indexOf(v) > -1).length > 0) { + col.Hide = 'true' + } + + if (col.Hide !== 'true' && col.linkmenu && col.linkmenu.length > 0) { + let menu_id = col.linkmenu.slice(-1)[0] + col.linkThdMenu = permMenus.filter(m => m.MenuID === menu_id)[0] || '' + } else { + col.linkThdMenu = '' + } + + return col + }) + } + // 鏉冮檺杩囨护 + if (this.props.menuType !== 'HS') { + if (item.action && item.action.length > 0) { + item.action = item.action.filter(cell => permAction[cell.uuid]) + } + if (item.type === 'card') { + item.subcards.forEach(card => { + card.elements = card.elements.filter(cell => cell.eleType !== 'button' || permAction[cell.uuid]) + card.backElements = card.backElements.filter(cell => cell.eleType !== 'button' || permAction[cell.uuid]) + }) + } else if (item.type === 'table' && item.subtype === 'tablecard') { + item.subcards.forEach(card => { + card.elements = card.elements.filter(cell => cell.eleType !== 'button' || permAction[cell.uuid]) + }) + } else if (item.type === 'table' && item.subtype === 'normaltable') { + item.cols.forEach(col => { + if (col.type !== 'action') return + col.elements = col.elements.filter(cell => permAction[cell.uuid]) + }) + } + } return true }) } // 鏍煎紡鍖栭粯璁よ缃� - formatSetting = (components, params, mainSearch, permAction, inherit) => { + formatSetting = (components, params, mainSearch, inherit) => { return components.map(component => { if (component.type === 'tabs') { component.subtabs = component.subtabs.map(tab => { - tab.components = this.formatSetting(tab.components, [], [], permAction, inherit) + tab.components = this.formatSetting(tab.components, [], [], inherit) tab = {...tab, ...inherit} return tab }) - } - - // 鏉冮檺杩囨护 - if (this.props.menuType !== 'HS') { - if (component.action) { - component.action = component.action.filter(item => permAction[item.uuid]) - } } if (!component.setting) return component // 涓嶄娇鐢ㄧ郴缁熷嚱鏁版椂 @@ -613,7 +643,8 @@ return { menuType: state.editLevel, refreshTab: state.refreshTab, - permAction: state.permAction + permAction: state.permAction, + permMenus: state.permMenus } } -- Gitblit v1.8.0