From 76a4300654a18d228838c3f27455dc8e7a8cd616 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 15 一月 2021 17:04:42 +0800 Subject: [PATCH] Merge branch 'master' into bms --- src/templates/treepageconfig/index.jsx | 463 +++++++++++++++++++++++---------------------------------- 1 files changed, 190 insertions(+), 273 deletions(-) diff --git a/src/templates/treepageconfig/index.jsx b/src/templates/treepageconfig/index.jsx index 24d2716..a01bcd6 100644 --- a/src/templates/treepageconfig/index.jsx +++ b/src/templates/treepageconfig/index.jsx @@ -164,30 +164,6 @@ }) } - getFuncNames = (data, funcNames, tableNames) => { - data.forEach(item => { - // if (item.subfuncs) { - // this.getFuncNames(item.subfuncs, funcNames, tableNames) - // return - // } - if (item.tableName) { - tableNames.push(item.tableName) - } - if (item.innerFunc) { - funcNames.push({func: item.innerFunc, label: item.label || ''}) - } - - if (item.callbackFunc) { - funcNames.push({func: item.callbackFunc, label: item.label || ''}) - } - }) - - return { - func: funcNames, - table: tableNames - } - } - /** * @description 涓夌骇鑿滃崟淇濆瓨 */ @@ -231,31 +207,6 @@ _config.enabled = false } - _config.funcs = [] // 椤甸潰鍙婂瓙椤甸潰瀛樺偍杩囩▼闆� - - _config.funcs.push({ - type: 'view', - subtype: 'view', - uuid: menu.MenuID, - intertype: _config.setting.interType || 'inner', - interface: _config.setting.interface || '', - tableName: _config.setting.tableName || '', - innerFunc: _config.setting.innerFunc || '', - outerFunc: _config.setting.outerFunc || '' - }) - - _config.tabgroups.forEach(group => { - group.sublist.forEach(tab => { - _config.funcs.push({ - type: 'tab', - subtype: 'tab', - uuid: tab.uuid, - label: tab.label, - linkTab: tab.linkTab - }) - }) - }) - if (this.state.closeVisible) { // 鏄剧ず鍏抽棴瀵硅瘽妗嗘椂锛屾ā鎬佹涓繚瀛樻寜閽紝鏄剧ず淇濆瓨涓姸鎬� this.setState({ menucloseloading: true @@ -266,258 +217,224 @@ }) } - new Promise(resolve => { - // let deffers = [] - // _config.funcs.forEach(item => { - // if (item.type === 'tab') { - // let deffer = new Promise(resolve => { - // Api.getSystemConfig({ - // func: 'sPC_Get_LongParam', - // MenuID: item.linkTab - // }).then(result => { - // if (result.status && result.LongParam) { - // let _LongParam = '' - - // if (result.LongParam) { - // try { - // _LongParam = JSON.parse(window.decodeURIComponent(window.atob(result.LongParam))) - // } catch (e) { - // console.warn('Parse Failure') - // _LongParam = '' - // } - // } + // 淇濆瓨鏃跺垹闄ら厤缃被鍨嬶紝system 銆乽ser + delete _config.type + delete _config.isAdd + + let _LongParam = '' + + try { + _LongParam = window.btoa(window.encodeURIComponent(JSON.stringify(_config))) + } catch (e) { + notification.warning({ + top: 92, + message: '缂栬瘧閿欒', + duration: 5 + }) + this.setState({ + menucloseloading: false, + menuloading: false + }) + return + } + + let _sort = 0 + let btntabs = [] - // if (_LongParam) { - // item.menuNo = _LongParam.tabNo || '' - // item.subfuncs = _LongParam.funcs || [] - // } - // } - // resolve() - // }) - // }) + let tabParam = { // 娣诲姞鑿滃崟tab椤� + func: 'sPC_sMenusTab_AddUpt', + MenuID: menu.MenuID + } - // deffers.push(deffer) - // } - // }) + let _LText = [] - // if (deffers.length === 0) { - // resolve() - // } else { - // Promise.all(deffers).then(() => { - // resolve() - // }) - // } - resolve() - }).then(() => { - // 淇濆瓨鏃跺垹闄ら厤缃被鍨嬶紝system 銆乽ser - delete _config.type - delete _config.isAdd - - let _LongParam = '' - - try { - _LongParam = window.btoa(window.encodeURIComponent(JSON.stringify(_config))) - } catch (e) { - notification.warning({ - top: 92, - message: '缂栬瘧閿欒', - duration: 5 - }) - this.setState({ - menucloseloading: false, - menuloading: false - }) - return - } - - let _sort = 0 - let btntabs = [] - - let tabParam = { // 娣诲姞鑿滃崟tab椤� - func: 'sPC_sMenusTab_AddUpt', - MenuID: menu.MenuID - } - - 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`) + 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(group => { + group.sublist.forEach(item => { + _sort++ + _LText.push(`select '${menu.MenuID}' as MenuID ,'${item.linkTab}' as Tabid,'${item.label}' as TabName ,'${_sort * 10}' as Sort`) }) - _config.tabgroups.forEach(group => { - group.sublist.forEach(item => { - _sort++ - _LText.push(`select '${menu.MenuID}' as MenuID ,'${item.linkTab}' as Tabid,'${item.label}' as TabName ,'${_sort * 10}' as Sort`) - }) - }) + }) - _LText = _LText.join(' union all ') + _LText = _LText.join(' union all ') - tabParam.LText = Utils.formatOptions(_LText) - tabParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') - tabParam.secretkey = Utils.encrypt(tabParam.LText, tabParam.timestamp) + tabParam.LText = Utils.formatOptions(_LText) + tabParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + tabParam.secretkey = Utils.encrypt(tabParam.LText, tabParam.timestamp) - let _vals = this.getFuncNames(_config.funcs, [], []) - let _tables = Array.from(new Set(_vals.table)) + let _funcs = [] + let _tables = [] - let param = { - func: 'sPC_TrdMenu_AddUpt', - FstID: _config.fstMenuId, - SndID: _config.ParentId, - ParentID: _config.ParentId, - MenuID: menu.MenuID, - MenuNo: _config.MenuNo, - EasyCode: _config.easyCode, - Template: _config.Template, - MenuName: _config.MenuName, - PageParam: JSON.stringify({...menu.PageParam, Template: _config.Template, OpenType: _config.OpenType}), - LongParam: _LongParam, - LText: _vals.func.map(item => `select '${menu.MenuID}' as MenuID,'${item.func}' as ProcName,'${item.label}' as MenuName`), - LTexttb: _tables.map(item => `select '${menu.MenuID}' as MenuID,'${item}' as tbName`) - } + if (_config.setting.tableName) { + _tables.push(_config.setting.tableName) + } + if (_config.setting.innerFunc) { + _funcs.push({func: _config.setting.innerFunc, label: _config.MenuName || ''}) + } + if (_config.setting.outerFunc) { + _funcs.push({func: _config.setting.outerFunc, label: _config.MenuName || ''}) + } - if (menu.menuSort) { // 鑿滃崟鏂板缓鏃惰缃帓搴� - param.Sort = menu.menuSort - } + let param = { + func: 'sPC_TrdMenu_AddUpt', + FstID: _config.fstMenuId, + SndID: _config.ParentId, + ParentID: _config.ParentId, + MenuID: menu.MenuID, + MenuNo: _config.MenuNo, + EasyCode: _config.easyCode, + Template: _config.Template, + MenuName: _config.MenuName, + PageParam: JSON.stringify({...menu.PageParam, Template: _config.Template, OpenType: _config.OpenType}), + LongParam: _LongParam, + LText: _funcs.map(item => `select '${menu.MenuID}' as MenuID,'${item.func}' as ProcName,'${item.label}' as MenuName`), + LTexttb: _tables.map(item => `select '${menu.MenuID}' as MenuID,'${item}' as tbName`) + } - param.LText = param.LText.join(' union all ') - param.LText = Utils.formatOptions(param.LText) - param.LTexttb = param.LTexttb.join(' union all ') - param.LTexttb = Utils.formatOptions(param.LTexttb) - param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') - param.secretkey = Utils.encrypt(param.LText, param.timestamp) + if (menu.menuSort) { // 鑿滃崟鏂板缓鏃惰缃帓搴� + param.Sort = menu.menuSort + } - if (openEdition) { // 鐗堟湰绠$悊 - param.open_edition = openEdition - } + param.LText = param.LText.join(' union all ') + param.LText = Utils.formatOptions(param.LText) + param.LTexttb = param.LTexttb.join(' union all ') + param.LTexttb = Utils.formatOptions(param.LTexttb) + param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + param.secretkey = Utils.encrypt(param.LText, param.timestamp) - // 鏈夋寜閽垨鏍囩鍒犻櫎鏃讹紝鍏堣繘琛屽垹闄ゆ搷浣� - // 鍒犻櫎鎴愬姛鍚庯紝淇濆瓨椤甸潰閰嶇疆 - new Promise(resolve => { - if (delTabs.length > 0) { - let deffers = delTabs.map(item => { - let _param = { - func: 'sPC_MainMenu_Del', - MenuID: item.uuid - } + if (openEdition) { // 鐗堟湰绠$悊 + param.open_edition = openEdition + } - return new Promise(resolve => { - Api.getSystemConfig(_param).then(response => { - resolve(response) - }) + // 鏈夋寜閽垨鏍囩鍒犻櫎鏃讹紝鍏堣繘琛屽垹闄ゆ搷浣� + // 鍒犻櫎鎴愬姛鍚庯紝淇濆瓨椤甸潰閰嶇疆 + new Promise(resolve => { + if (delTabs.length > 0) { + let deffers = delTabs.map(item => { + let _param = { + func: 'sPC_MainMenu_Del', + MenuID: item.uuid + } + + return new Promise(resolve => { + Api.getSystemConfig(_param).then(response => { + resolve(response) }) }) - Promise.all(deffers).then(result => { - let error = null - result.forEach(response => { - if (!response.status) { - error = response - } - }) - - if (error) { - this.setState({ - menuloading: false, - menucloseloading: false - }) - notification.warning({ - top: 92, - message: error.message, - duration: 5 - }) - resolve(false) - } else { - this.setState({ - delTabs: [] - }) - resolve(true) + }) + Promise.all(deffers).then(result => { + let error = null + result.forEach(response => { + if (!response.status) { + error = response } }) - } else if (delTabs.length === 0) { - resolve(true) - } - }).then(resp => { - if (resp === false) return - let localParam = fromJS(param).toJS() - localParam.func = 'sPC_TrdMenu_AddUpt_For_Local' - delete localParam.LongParam - delete localParam.PageParam - delete localParam.Template - delete localParam.Sort - delete localParam.EasyCode - delete localParam.open_edition - Api.getSystemConfig(param).then(response => { - if (response.status) { - this.setState({ - config: _config, - openEdition: response.open_edition || '', - originMenu: fromJS(_config).toJS() - }) - - // 瀛樺湪鏍囩椤垫椂 - if (tabParam.LText) { - Api.getSystemConfig(tabParam).then(result => { - if (result.status) { - notification.success({ - top: 92, - message: '淇濆瓨鎴愬姛', - duration: 2 - }) - - this.props.reloadmenu() - Api.getLocalConfig(localParam) - - if (this.state.closeVisible) { - this.props.handleView() - } else { - this.setState({ - menuloading: false, - menucloseloading: false - }) - } - } else { - notification.warning({ - top: 92, - message: result.message, - duration: 5 - }) - this.setState({ - menuloading: false, - menucloseloading: false - }) - } - }) - } else { - notification.success({ - top: 92, - message: '淇濆瓨鎴愬姛', - duration: 2 - }) - - this.props.reloadmenu() - Api.getLocalConfig(localParam) - - if (this.state.closeVisible) { - this.props.handleView() - } else { - this.setState({ - menuloading: false, - menucloseloading: false - }) - } - } - } else { + if (error) { this.setState({ menuloading: false, menucloseloading: false }) notification.warning({ top: 92, - message: response.message, + message: error.message, duration: 5 }) + resolve(false) + } else { + this.setState({ + delTabs: [] + }) + resolve(true) } }) + } else if (delTabs.length === 0) { + resolve(true) + } + }).then(resp => { + if (resp === false) return + let localParam = fromJS(param).toJS() + localParam.func = 'sPC_TrdMenu_AddUpt_For_Local' + delete localParam.LongParam + delete localParam.PageParam + delete localParam.Template + delete localParam.Sort + delete localParam.EasyCode + delete localParam.open_edition + + Api.getSystemConfig(param).then(response => { + if (response.status) { + this.setState({ + config: _config, + openEdition: response.open_edition || '', + originMenu: fromJS(_config).toJS() + }) + + // 瀛樺湪鏍囩椤垫椂 + if (tabParam.LText) { + Api.getSystemConfig(tabParam).then(result => { + if (result.status) { + notification.success({ + top: 92, + message: '淇濆瓨鎴愬姛', + duration: 2 + }) + + this.props.reloadmenu() + Api.getLocalConfig(localParam) + + if (this.state.closeVisible) { + this.props.handleView() + } else { + this.setState({ + menuloading: false, + menucloseloading: false + }) + } + } else { + notification.warning({ + top: 92, + message: result.message, + duration: 5 + }) + this.setState({ + menuloading: false, + menucloseloading: false + }) + } + }) + } else { + notification.success({ + top: 92, + message: '淇濆瓨鎴愬姛', + duration: 2 + }) + + this.props.reloadmenu() + Api.getLocalConfig(localParam) + + if (this.state.closeVisible) { + this.props.handleView() + } else { + this.setState({ + menuloading: false, + menucloseloading: false + }) + } + } + } else { + this.setState({ + menuloading: false, + menucloseloading: false + }) + notification.warning({ + top: 92, + message: response.message, + duration: 5 + }) + } }) }) } -- Gitblit v1.8.0