From 835b48025a582b1c19c4de128906aff6a5e63612 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期六, 22 八月 2020 12:08:35 +0800 Subject: [PATCH] 2020-08-22 --- src/templates/comtableconfig/index.jsx | 1055 ++++++++++++++++++++++++++++------------------------------ 1 files changed, 514 insertions(+), 541 deletions(-) diff --git a/src/templates/comtableconfig/index.jsx b/src/templates/comtableconfig/index.jsx index dbba872..6d3530e 100644 --- a/src/templates/comtableconfig/index.jsx +++ b/src/templates/comtableconfig/index.jsx @@ -11,14 +11,13 @@ import Utils from '@/utils/utils.js' import zhCN from '@/locales/zh-CN/model.js' import enUS from '@/locales/en-US/model.js' -import { getMainMenuForm } from '@/templates/zshare/formconfig' import asyncComponent from '@/utils/asyncComponent' import SearchComponent from '@/templates/sharecomponent/searchcomponent' import ActionComponent from '@/templates/sharecomponent/actioncomponent' import ColumnComponent from '@/templates/sharecomponent/columncomponent' -import MenuForm from '@/templates/zshare/menuform' +import MenuForm from './menuform' import SourceElement from '@/templates/zshare/dragsource' import Source from './source' import './index.scss' @@ -46,8 +45,6 @@ dict: localStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, config: null, // 椤甸潰閰嶇疆 tableFields: [], // 琛ㄦ牸鏄剧ず鍒� - fields: null, // 鎼滅储鏉′欢鍙婃樉绀哄垪锛屽彲閫夊瓧娈� - menuformlist: null, // 鍩烘湰淇℃伅琛ㄥ崟瀛楁 formlist: null, // 鎼滅储鏉′欢銆佹寜閽�佹樉绀哄垪琛ㄥ崟瀛楁 menuloading: false, // 鑿滃崟淇濆瓨涓� menucloseloading: false, // 鑿滃崟鍏抽棴鏃讹紝閫夋嫨淇濆瓨 @@ -101,6 +98,13 @@ } }) } + + // 椤甸潰閰嶇疆涓繚鐣欒彍鍗曚俊鎭紝鍙敤浜庢暟鎹紶閫� + _config.ParentId = menu.ParentId + _config.fstMenuId = menu.fstMenuId + _config.MenuName = menu.MenuName || '' + _config.MenuNo = menu.MenuNo || '' + _config.OpenType = menu.PageParam ? menu.PageParam.OpenType : '' if (!_config.version || _config.version < '1.0') { // 閰嶇疆榛樿鍊硷紝鍏煎 @@ -221,8 +225,7 @@ activeKey: menu.activeKey || '0', optionLibs: optionLibs, originActions: _oriActions, - originMenu: fromJS(menu).toJS(), - menuformlist: getMainMenuForm(menu, _config) + originMenu: fromJS(_config).toJS() }) } @@ -314,435 +317,422 @@ */ submitConfig = () => { const { menu } = this.props - const { originMenu, delActions, thawButtons, openEdition } = this.state + const { delActions, thawButtons, openEdition } = this.state - let config = fromJS(this.state.config).toJS() + let _config = fromJS(this.state.config).toJS() - this.menuformRef.handleConfirm().then(res => { - if (config.isAdd) { - config.search = config.search.filter(item => !item.origin) - config.action = config.action.filter(item => !item.origin) - config.columns = config.columns.filter(item => !item.origin) - config.tabgroups[0].sublist = config.tabgroups[0].sublist.filter(item => !item.origin) - } + // 鍩烘湰淇℃伅楠岃瘉 + if (!_config.fstMenuId || !_config.ParentId || !_config.MenuName || !_config.MenuNo) { + notification.warning({ + top: 92, + message: this.state.dict['model.menu.basemsg'], + duration: 5 + }) + return + } - if (config.type === 'user') { // 浣跨敤宸叉湁鑿滃崟鏃讹紝榛樿娣诲姞鍏宠仈鏍囩id - config.action = config.action.map(item => { - if (item.OpenType === 'popview' && !item.linkTab) { - item.linkTab = Utils.getuuid() + // 鏂板缓鑿滃崟锛屾竻闄ら粯璁ら」 + if (_config.isAdd) { + _config.search = _config.search.filter(item => !item.origin) + _config.action = _config.action.filter(item => !item.origin) + _config.columns = _config.columns.filter(item => !item.origin) + _config.tabgroups[0].sublist = _config.tabgroups[0].sublist.filter(item => !item.origin) + } + + // 浣跨敤宸叉湁鑿滃崟鏃讹紝榛樿娣诲姞鍏宠仈鏍囩id + if (_config.type === 'user') { + _config.action = _config.action.map(item => { + if (item.OpenType === 'popview' && !item.linkTab) { + item.linkTab = Utils.getuuid() + } + return item + }) + + _config.tabgroups.forEach(group => { + group.sublist = group.sublist.map(tab => { + if (!tab.linkTab) { + tab.linkTab = Utils.getuuid() } - return item + return tab }) - - config.tabgroups.forEach(group => { - group.sublist = group.sublist.map(tab => { - if (!tab.linkTab) { - tab.linkTab = Utils.getuuid() - } - return tab - }) + }) + } + + // 鏈缃暟鎹簮鎴栨爣绛句笉鍚堟硶鏃讹紝鍚敤鐘舵�佷负false + let vresult = this.verifyconfig(_config) + if (vresult !== true) { + _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.action.forEach(item => { + let tablename = item.OpenType === 'excelIn' ? (item.sheet || '') : (item.sql || '') + + if (item.OpenType === 'excelOut' && item.intertype === 'inner' && !item.innerFunc) { + tablename = _config.setting.tableName || '' + } + + if (item.OpenType === 'tab' || item.OpenType === 'blank') { + _config.funcs.push({ + type: 'tab', + subtype: 'btn', + uuid: item.uuid, + label: item.label, + linkTab: item.uuid + }) + } else if (item.OpenType === 'popview') { + _config.funcs.push({ + type: 'tab', + subtype: 'btn', + uuid: item.uuid, + label: item.label, + linkTab: item.linkTab + }) + } else if (['pop', 'prompt', 'exec', 'excelIn', 'excelOut'].includes(item.OpenType)) { + _config.funcs.push({ + type: 'button', + subtype: 'btn', + uuid: item.uuid, + label: item.label, + tableName: tablename, + intertype: item.intertype, + interface: item.interface || '', + innerFunc: item.innerFunc || '', + outerFunc: item.outerFunc || '', + callbackFunc: item.callbackFunc || '' }) } + }) + + _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 + }) + } else { + this.setState({ + menuloading: true + }) + } + + 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 = '' + } + } + + if (_LongParam) { + item.menuNo = _LongParam.tabNo || '' + item.subfuncs = _LongParam.funcs || [] + } + } + resolve() + }) + }) + + deffers.push(deffer) + } + }) + + if (deffers.length === 0) { + resolve() + } else { + Promise.all(deffers).then(() => { + resolve() + }) + } + }).then(() => { + // 淇濆瓨鏃跺垹闄ら厤缃被鍨嬶紝system 銆乽ser + delete _config.type + delete _config.isAdd let _LongParam = '' - let _config = {...config, easyCode: res.easyCode} - let _pageParam = {...menu.PageParam, OpenType: res.opentype} - // 鏈缃暟鎹簮鎴栨爣绛句笉鍚堟硶鏃讹紝鍚敤鐘舵�佷负false - let vresult = this.verifyconfig(_config) - if (vresult !== true) { - _config.enabled = false + 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 } - _config.funcs = [] // 椤甸潰鍙婂瓙椤甸潰瀛樺偍杩囩▼闆� + let _sort = 0 + let btntabs = [] - _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 || '' - }) + let btnParam = { // 娣诲姞鑿滃崟鎸夐挳 + func: 'sPC_Button_AddUpt', + Type: 40, // 娣诲姞鑿滃崟涓嬬殑鎸夐挳type涓�40锛屾寜閽笅鐨勬寜閽畉ype涓�60 + ParentID: menu.MenuID, + MenuNo: _config.MenuNo, + Template: _config.Template || '', + PageParam: '', + LongParam: '', + LText: [] + } _config.action.forEach(item => { - let tablename = item.OpenType === 'excelIn' ? (item.sheet || '') : (item.sql || '') - - if (item.OpenType === 'excelOut' && item.intertype === 'inner' && !item.innerFunc) { - tablename = _config.setting.tableName || '' - } - - if (item.OpenType === 'tab' || item.OpenType === 'blank') { - _config.funcs.push({ - type: 'tab', - subtype: 'btn', + _sort++ + if (item.OpenType === 'popview') { + btntabs.push({ uuid: item.uuid, + linkTab: item.linkTab, label: item.label, - linkTab: item.uuid - }) - } else if (item.OpenType === 'popview') { - _config.funcs.push({ - type: 'tab', - subtype: 'btn', - uuid: item.uuid, - label: item.label, - linkTab: item.linkTab - }) - } else if (['pop', 'prompt', 'exec', 'excelIn', 'excelOut'].includes(item.OpenType)) { - _config.funcs.push({ - type: 'button', - subtype: 'btn', - uuid: item.uuid, - label: item.label, - tableName: tablename, - intertype: item.intertype, - interface: item.interface || '', - innerFunc: item.innerFunc || '', - outerFunc: item.outerFunc || '', - callbackFunc: item.callbackFunc || '' + sort: _sort }) } + + btnParam.LText.push(`select '${item.uuid}' as menuid, '${item.label}' as menuname, '${_sort * 10}' as Sort`) }) - _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 - }) - } else { - this.setState({ - menuloading: true - }) + 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: menu.MenuID } - 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 = '' - } - } - - if (_LongParam) { - item.menuNo = _LongParam.tabNo || '' - item.subfuncs = _LongParam.funcs || [] - } - } - resolve() - }) - }) + let _LText = [] - deffers.push(deffer) - } - }) - - if (deffers.length === 0) { - resolve() - } else { - Promise.all(deffers).then(() => { - resolve() - }) - } - }).then(() => { - // 淇濆瓨鏃跺垹闄ら厤缃被鍨嬶紝system 銆乽ser - delete _config.type - delete _config.isAdd - - 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 btnParam = { // 娣诲姞鑿滃崟鎸夐挳 - func: 'sPC_Button_AddUpt', - Type: 40, // 娣诲姞鑿滃崟涓嬬殑鎸夐挳type涓�40锛屾寜閽笅鐨勬寜閽畉ype涓�60 - ParentID: menu.MenuID, - MenuNo: res.MenuNo, - Template: menu.PageParam.Template || '', - PageParam: '', - LongParam: '', - LText: [] - } - - _config.action.forEach(item => { + 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++ - if (item.OpenType === 'popview') { - btntabs.push({ - uuid: item.uuid, - linkTab: item.linkTab, - label: item.label, - sort: _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 ') + + // 娓呯┖鑿滃崟涓嬪叧鑱旂殑鏍囩 + if (!_LText) { + _LText = `select '${menu.MenuID}' as MenuID ,'' as Tabid,'' as TabName ,'0' as Sort` + } + + tabParam.LText = Utils.formatOptions(_LText) + tabParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' + tabParam.secretkey = Utils.encrypt(tabParam.LText, tabParam.timestamp) + + let _vals = this.getFuncNames(_config.funcs, [], []) + let _tables = Array.from(new Set(_vals.table)) + + 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 (menu.menuSort) { // 鑿滃崟鏂板缓鏃惰缃帓搴� + param.Sort = menu.menuSort + } + + 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') + '.000' + param.secretkey = Utils.encrypt(param.LText, param.timestamp) + + if (openEdition) { // 鐗堟湰绠$悊 + param.open_edition = openEdition + } + + // 鏈夋寜閽垨鏍囩鍒犻櫎鏃讹紝鍏堣繘琛屽垹闄ゆ搷浣� + // 鍒犻櫎鎴愬姛鍚庯紝淇濆瓨椤甸潰閰嶇疆 + new Promise(resolve => { + if (delActions.length > 0) { + let deffers = delActions.map(item => { + let _param = { + func: 'sPC_MainMenu_Del', + MenuID: item.card ? item.card.uuid : item.uuid + } + + if (item.type === 'action') { + let _ParentParam = null + + try { + _ParentParam = window.btoa(window.encodeURIComponent(JSON.stringify(item.card))) + } catch (e) { + console.warn('Stringify Failure') + _ParentParam = null + } + + if (_ParentParam) { // 鍒犻櫎鎸夐挳鏃讹紝淇濆瓨鎸夐挳閰嶇疆淇℃伅锛岀敤浜庢仮澶嶆寜閽� + _param.ParentParam = _ParentParam + } + } + + return new Promise(resolve => { + Api.getSystemConfig(_param).then(response => { + resolve(response) + }) }) - } - - 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) - 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: 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`) - }) - _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 ') - - // 娓呯┖鑿滃崟涓嬪叧鑱旂殑鏍囩 - if (!_LText) { - _LText = `select '${menu.MenuID}' as MenuID ,'' as Tabid,'' as TabName ,'0' as Sort` - } - - tabParam.LText = Utils.formatOptions(_LText) - tabParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' - tabParam.secretkey = Utils.encrypt(tabParam.LText, tabParam.timestamp) + Promise.all(deffers).then(result => { + let error = null + result.forEach(response => { + if (!response.status) { + error = response + } + }) - let _vals = this.getFuncNames(_config.funcs, [], []) - let _tables = Array.from(new Set(_vals.table)) - - let param = { - func: 'sPC_TrdMenu_AddUpt', - FstID: res.fstMenuId, - SndID: res.parentId, - ParentID: res.parentId, - MenuID: menu.MenuID, - MenuNo: res.MenuNo, - EasyCode: res.easyCode, - Template: menu.PageParam.Template || '', - MenuName: res.MenuName, - PageParam: JSON.stringify(_pageParam), - 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 (menu.menuSort) { // 鑿滃崟鏂板缓鏃惰缃帓搴� - param.Sort = menu.menuSort - } - - 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') + '.000' - param.secretkey = Utils.encrypt(param.LText, param.timestamp) - - if (openEdition) { // 鐗堟湰绠$悊 - param.open_edition = openEdition - } - - // 鏈夋寜閽垨鏍囩鍒犻櫎鏃讹紝鍏堣繘琛屽垹闄ゆ搷浣� - // 鍒犻櫎鎴愬姛鍚庯紝淇濆瓨椤甸潰閰嶇疆 - new Promise(resolve => { - if (delActions.length > 0) { - let deffers = delActions.map(item => { - let _param = { - func: 'sPC_MainMenu_Del', - MenuID: item.card ? item.card.uuid : item.uuid - } - - if (item.type === 'action') { - let _ParentParam = null - - try { - _ParentParam = window.btoa(window.encodeURIComponent(JSON.stringify(item.card))) - } catch (e) { - console.warn('Stringify Failure') - _ParentParam = null - } - - if (_ParentParam) { // 鍒犻櫎鎸夐挳鏃讹紝淇濆瓨鎸夐挳閰嶇疆淇℃伅锛岀敤浜庢仮澶嶆寜閽� - _param.ParentParam = _ParentParam - } - } - - 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({ - delActions: [] - }) - resolve(true) - } - }) - } else if (delActions.length === 0) { - resolve(true) - } - }).then(resp => { - if (resp === false) return - - if (thawButtons.length > 0) { - let defers = thawButtons.map(item => { - return new Promise((resolve) => { - Api.getSystemConfig({ - func: 'sPC_MainMenu_ReDel', - MenuID: item - }).then(res => { - if (res.status) { - resolve('') - } else { - resolve(res.message) - } - }) - }) - }) - - return Promise.all(defers) - } else { - return true - } - }).then(res => { - if (res === true || res === false) return res - - let msg = res.filter(Boolean)[0] - if (msg) { - notification.warning({ - top: 92, - message: msg, - duration: 5 - }) - return false - } else { - this.setState({ - thawButtons: [] - }) - return true - } - }).then(resp => { - if (resp === false) return - let localParam = fromJS(param).toJS() - - Api.getSystemConfig(param).then(response => { - if (response.status) { - let _FMenu = originMenu.fstMenuList.filter(fstM => fstM.MenuID === res.fstMenuId)[0] - let _supMenuList = [] - if (_FMenu) { - _supMenuList = _FMenu.options - } - - this.setState({ - config: _config, - openEdition: response.open_edition || '', - originMenu: { - ...originMenu, - LongParam: _config, - PageParam: _pageParam, - MenuName: res.MenuName, - MenuNo: res.MenuNo, - ParentID: res.parentId, - fstMenuId: res.fstMenuId, - supMenuList: _supMenuList - } - }) - - this.props.reloadmenu() - - this.submitAction(btnParam, tabParam) - - 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.getLocalConfig(localParam) - } 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({ + delActions: [] + }) + resolve(true) } }) + } else if (delActions.length === 0) { + resolve(true) + } + }).then(resp => { + if (resp === false) return + + if (thawButtons.length > 0) { + let defers = thawButtons.map(item => { + return new Promise((resolve) => { + Api.getSystemConfig({ + func: 'sPC_MainMenu_ReDel', + MenuID: item + }).then(res => { + if (res.status) { + resolve('') + } else { + resolve(res.message) + } + }) + }) + }) + + return Promise.all(defers) + } else { + return true + } + }).then(res => { + if (res === true || res === false) return res + + let msg = res.filter(Boolean)[0] + if (msg) { + notification.warning({ + top: 92, + message: msg, + duration: 5 + }) + return false + } else { + this.setState({ + thawButtons: [] + }) + return true + } + }).then(resp => { + if (resp === false) return + let localParam = fromJS(param).toJS() + + Api.getSystemConfig(param).then(response => { + if (response.status) { + this.setState({ + config: _config, + openEdition: response.open_edition || '', + originMenu: fromJS(_config).toJS() + }) + + this.props.reloadmenu() + + this.submitAction(btnParam, tabParam) + + 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.getLocalConfig(localParam) + } else { + this.setState({ + menuloading: false, + menucloseloading: false + }) + notification.warning({ + top: 92, + message: response.message, + duration: 5 + }) + } }) - }) - }, () => { - notification.warning({ - top: 92, - message: this.state.dict['model.menu.basemsg'], - duration: 5 }) }) } @@ -889,7 +879,7 @@ func: 'sPC_ButtonParam_AddUpt', ParentID: this.props.menu.MenuID, MenuID: action.curBtn.uuid, - MenuNo: this.props.menu.MenuNo, + MenuNo: config.MenuNo, Template: _temp, MenuName: action.curBtn.label, PageParam: JSON.stringify({Template: _temp}), @@ -930,7 +920,6 @@ * @description 鐐瑰嚮杩斿洖鏃讹紝鍒ゆ柇閰嶇疆淇濆瓨鐘舵�� */ cancelConfig = () => { - const { menu } = this.props const { config, originMenu } = this.state let _this = this @@ -946,31 +935,13 @@ onCancel() {} }) } else { - this.menuformRef.handleConfirm().then(res => { - let _config = {...config, easyCode: res.easyCode} - let _pageParam = {...menu.PageParam, OpenType: res.opentype} - let _originMenu = { - ...originMenu, - LongParam: _config, - PageParam: _pageParam, - MenuName: res.MenuName, - MenuNo: res.MenuNo, - ParentID: res.parentId, - fstMenuId: res.fstMenuId - } - - if (!is(fromJS(originMenu), fromJS(_originMenu))) { - this.setState({ - closeVisible: true - }) - } else { - this.props.handleView() - } - }, () => { + if (!is(fromJS(originMenu), fromJS(config))) { this.setState({ closeVisible: true }) - }) + } else { + this.props.handleView() + } } } @@ -988,127 +959,129 @@ duration: 5 }) } else { - this.menuformRef.handleConfirm().then(res => { - let _config = {...config, easyCode: res.easyCode} - let _pageParam = {...menu.PageParam, OpenType: res.opentype} - let _originMenu = { - ...originMenu, - LongParam: _config, - PageParam: _pageParam, - MenuName: res.MenuName, - MenuNo: res.MenuNo, - ParentID: res.parentId, - fstMenuId: res.fstMenuId - } - - if (!is(fromJS(originMenu), fromJS(_originMenu))) { // 鑿滃崟淇℃伅鍙樺寲鏃讹紝鎻愮ず淇濆瓨 - notification.warning({ - top: 92, - message: this.state.dict['header.menu.config.update'], - duration: 5 - }) - return - } - - // 鑿滃崟淇℃伅楠岃瘉閫氳繃鍚庯紝璺宠浆瀛愰厤缃〉闈� - let _view = '' - let uuid = item.uuid - let isbutton = true - let _btnTab = null - - if (type === 'button' && item.OpenType === 'pop') { - _view = 'Modal' // 琛ㄥ崟椤甸潰 - } else if (type === 'button' && (item.OpenType === 'tab' || item.OpenType === 'blank')) { - _view = item.tabTemplate // 鏂版爣绛鹃〉妯℃澘 - _btnTab = item - } else if (type === 'button' && item.OpenType === 'popview') { - _view = item.tabType // 鏂板脊绐楁爣绛炬ā鏉� - uuid = item.linkTab - isbutton = false - } else if (type === 'tab') { - _view = item.type // 鏍囩妯℃澘 - uuid = item.linkTab - isbutton = false - } - - _originMenu.activeKey = activeKey // 淇濆瓨褰撳墠鎵撳紑椤电 - _originMenu.open_edition = openEdition // 鏇存柊鐗堟湰鍙� - - let param = { - optionLibs: optionLibs, - editMenu: _originMenu, - editTab: !isbutton ? item : '', - tabConfig: null, - editSubTab: null, - subTabConfig: null, - btnTab: _btnTab, - btnTabConfig: null, - editAction: isbutton ? item : '', - subConfig: '', - tabview: _view - } - - // 褰撳瓙琛ㄤ娇鐢ㄤ富椤垫悳绱㈡潯浠舵椂锛屽皢涓婚〉鎼滅储鍚戜笅浼犻�� - if (param.editTab && param.editTab.searchPass === 'true') { - param.editTab.mainsearch = fromJS(_config.search).toJS() - } - - this.setState({ - loading: true + // 鍩烘湰淇℃伅楠岃瘉 + if (!config.fstMenuId || !config.ParentId || !config.MenuName || !config.MenuNo) { + notification.warning({ + top: 92, + message: this.state.dict['model.menu.basemsg'], + duration: 5 }) - - Api.getSystemConfig({ - func: 'sPC_Get_LongParam', - MenuID: uuid - }).then(res => { - if (res.status) { - this.setState({ - loading: false - }) - let _LongParam = '' - if (res.LongParam) { - try { - _LongParam = JSON.parse(window.decodeURIComponent(window.atob(res.LongParam))) - } catch (e) { - console.warn('Parse Failure') - _LongParam = '' - } - } - - if (_LongParam && param.tabview === 'Modal' && _LongParam.type === 'Modal') { - param.subConfig = _LongParam - } else if (_LongParam && param.tabview === 'FormTab' && _LongParam.type === 'FormTab') { - param.subConfig = _LongParam - } else if (_LongParam && param.tabview === 'SubTable' && _LongParam.Template === 'SubTable') { - param.subConfig = _LongParam - } - - if (param.editTab) { - param.editTab.open_edition = res.open_edition || '' - } else if (param.editAction) { - param.editAction.open_edition = res.open_edition || '' - } else if (param.btnTab) { - param.btnTab.open_edition = res.open_edition || '' - } - - this.props.handleView(param) - } else { - this.setState({ - loading: false - }) - notification.warning({ - top: 92, - message: res.message, - duration: 5 - }) - } - }) - }, () => { + return + } + if (!is(fromJS(originMenu), fromJS(config))) { // 鑿滃崟淇℃伅鍙樺寲鏃讹紝鎻愮ず淇濆瓨 notification.warning({ top: 92, message: this.state.dict['header.menu.config.update'], duration: 5 }) + return + } + + let submenu = menu.fstMenuList.filter(item => item.MenuID === config.fstMenuId)[0] + + let _Menu = { + ...menu, + LongParam: config, + PageParam: {...menu.PageParam, Template: config.Template, OpenType: config.OpenType}, + MenuName: config.MenuName, + MenuNo: config.MenuNo, + ParentId: config.ParentId, + fstMenuId: config.fstMenuId, + supMenuList: submenu ? submenu.options : [] + } + + // 鑿滃崟淇℃伅楠岃瘉閫氳繃鍚庯紝璺宠浆瀛愰厤缃〉闈� + let _view = '' + let uuid = item.uuid + let isbutton = true + let _btnTab = null + + if (type === 'button' && item.OpenType === 'pop') { + _view = 'Modal' // 琛ㄥ崟椤甸潰 + } else if (type === 'button' && (item.OpenType === 'tab' || item.OpenType === 'blank')) { + _view = item.tabTemplate // 鏂版爣绛鹃〉妯℃澘 + _btnTab = item + } else if (type === 'button' && item.OpenType === 'popview') { + _view = item.tabType // 鏂板脊绐楁爣绛炬ā鏉� + uuid = item.linkTab + isbutton = false + } else if (type === 'tab') { + _view = item.type // 鏍囩妯℃澘 + uuid = item.linkTab + isbutton = false + } + + _Menu.activeKey = activeKey // 淇濆瓨褰撳墠鎵撳紑椤电 + _Menu.open_edition = openEdition // 鏇存柊鐗堟湰鍙� + + let param = { + optionLibs: optionLibs, + editMenu: _Menu, + editTab: !isbutton ? item : '', + tabConfig: null, + editSubTab: null, + subTabConfig: null, + btnTab: _btnTab, + btnTabConfig: null, + editAction: isbutton ? item : '', + subConfig: '', + tabview: _view + } + + // 褰撳瓙琛ㄤ娇鐢ㄤ富椤垫悳绱㈡潯浠舵椂锛屽皢涓婚〉鎼滅储鍚戜笅浼犻�� + if (param.editTab && param.editTab.searchPass === 'true') { + param.editTab.mainsearch = fromJS(config.search).toJS() + } + + this.setState({ + loading: true + }) + + Api.getSystemConfig({ + func: 'sPC_Get_LongParam', + MenuID: uuid + }).then(res => { + if (res.status) { + this.setState({ + loading: false + }) + let _LongParam = '' + if (res.LongParam) { + try { + _LongParam = JSON.parse(window.decodeURIComponent(window.atob(res.LongParam))) + } catch (e) { + console.warn('Parse Failure') + _LongParam = '' + } + } + + if (_LongParam && param.tabview === 'Modal' && _LongParam.type === 'Modal') { + param.subConfig = _LongParam + } else if (_LongParam && param.tabview === 'FormTab' && _LongParam.type === 'FormTab') { + param.subConfig = _LongParam + } else if (_LongParam && param.tabview === 'SubTable' && _LongParam.Template === 'SubTable') { + param.subConfig = _LongParam + } + + if (param.editTab) { + param.editTab.open_edition = res.open_edition || '' + } else if (param.editAction) { + param.editAction.open_edition = res.open_edition || '' + } else if (param.btnTab) { + param.btnTab.open_edition = res.open_edition || '' + } + + this.props.handleView(param) + } else { + this.setState({ + loading: false + }) + notification.warning({ + top: 92, + message: res.message, + duration: 5 + }) + } }) } } @@ -1301,6 +1274,7 @@ } render () { + const { menu } = this.props const { activeKey, config, chartview } = this.state const confActions = config.action.filter(_action => !_action.origin && ['pop', 'popview', 'blank', 'tab'].includes(_action.OpenType)) @@ -1320,9 +1294,10 @@ <Panel forceRender={true} header={this.state.dict['header.menu.basedata']} key="0" id="main-basedata"> {/* 鑿滃崟淇℃伅 */} <MenuForm + menu={menu} + config={config} dict={this.state.dict} - formlist={this.state.menuformlist} - wrappedComponentRef={(inst) => this.menuformRef = inst} + updatemenu={this.updateconfig} /> {/* 琛ㄥ悕娣诲姞 */} <TableComponent @@ -1429,12 +1404,11 @@ type="main" config={config} MenuID={this.props.menu.MenuID} - menuformRef={this.menuformRef} permFuncField={this.props.permFuncField} updatesetting={this.updateconfig} /> <SearchComponent - menu={{MenuID: this.props.menu.MenuID, MenuName: this.props.menu.MenuName}} + menu={{MenuID: this.props.menu.MenuID, MenuName: config.MenuName}} config={config} pasteContent={this.state.pasteContent} sysRoles={this.props.sysRoles} @@ -1457,10 +1431,9 @@ {config.charts.length > 1 && item.title ? <p className="chart-title">{item.title}</p> : null} <ActionComponent type="main" - menu={{ MenuID: this.props.menu.MenuID, MenuName: this.props.menu.MenuName, MenuNo: this.props.menu.MenuNo, fstMenuList: this.props.menu.fstMenuList }} + menu={{ MenuID: this.props.menu.MenuID, MenuName: config.MenuName, MenuNo: config.MenuNo, fstMenuList: this.props.menu.fstMenuList }} config={config} tabs={this.state.tabviews} - menuformRef={this.menuformRef} pasteContent={this.state.pasteContent} usefulFields={this.props.permFuncField} setSubConfig={(_btn) => this.setSubConfig(_btn, 'button')} -- Gitblit v1.8.0