From e36eb1999794bd71e76482b92a0b0b20f49d0032 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 05 三月 2021 19:37:03 +0800 Subject: [PATCH] 2021-03-05 --- src/templates/comtableconfig/index.jsx | 1351 ++++++++++++++++++++++++--------------------------------- 1 files changed, 570 insertions(+), 781 deletions(-) diff --git a/src/templates/comtableconfig/index.jsx b/src/templates/comtableconfig/index.jsx index 8f6904e..f944b3b 100644 --- a/src/templates/comtableconfig/index.jsx +++ b/src/templates/comtableconfig/index.jsx @@ -9,23 +9,23 @@ import Api from '@/api' import Utils from '@/utils/utils.js' +import { updateCommonTable } from '@/utils/utils-update.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 EditComponent from '@/templates/zshare/editcomponent' +import MenuForm from './menuform' import SourceElement from '@/templates/zshare/dragsource' import Source from './source' import './index.scss' const { Panel } = Collapse const { confirm } = Modal +const EditComponent = asyncComponent(() => import('@/templates/zshare/editcomponent')) const SettingComponent = asyncComponent(() => import('@/templates/sharecomponent/settingcomponent')) const TableComponent = asyncComponent(() => import('@/templates/sharecomponent/tablecomponent')) const FieldsComponent = asyncComponent(() => import('@/templates/sharecomponent/fieldscomponent')) @@ -37,33 +37,26 @@ class ComTableConfig extends Component { static propTpyes = { menu: PropTypes.any, - optionLibs: PropTypes.any, reloadmenu: PropTypes.func, handleView: PropTypes.func } state = { - dict: localStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, + dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, config: null, // 椤甸潰閰嶇疆 - tableFields: [], // 琛ㄦ牸鏄剧ず鍒� - fields: null, // 鎼滅储鏉′欢鍙婃樉绀哄垪锛屽彲閫夊瓧娈� - menuformlist: null, // 鍩烘湰淇℃伅琛ㄥ崟瀛楁 formlist: null, // 鎼滅储鏉′欢銆佹寜閽�佹樉绀哄垪琛ㄥ崟瀛楁 menuloading: false, // 鑿滃崟淇濆瓨涓� menucloseloading: false, // 鑿滃崟鍏抽棴鏃讹紝閫夋嫨淇濆瓨 loading: false, // 鍔犺浇涓紝椤甸潰spin closeVisible: false, // 鍏抽棴妯℃�佹 - tables: [], // 鍙敤琛ㄥ悕 originMenu: null, // 鍘熷鑿滃崟 originActions: null, // 鍘熷鎸夐挳淇℃伅锛屼娇鐢ㄥ凡鏈夌敤鎴锋ā鏉� delActions: [], // 鍒犻櫎鎸夐挳鍒楄〃 copyActions: [], // 澶嶅埗鎸夐挳缁� tabviews: [], // 鎵�鏈夋爣绛鹃〉 - optionLibs: null, // 鑷畾涔変笅鎷夐�夐」搴� thawButtons: [], // 宸查�夋嫨瑕佽В鍐荤殑鎸夐挳 activeKey: '0', // 榛樿灞曞紑鍩烘湰淇℃伅 chartview: null, // 褰撳墠瑙嗗浘 - pasteContent: null, // 绮樿创閰嶇疆淇℃伅 openEdition: '' // 缂栬緫鐗堟湰鏍囪锛岄槻姝㈠浜烘搷浣� } @@ -73,8 +66,7 @@ * 2銆佽缃搷浣滅被鍨嬨�佸師濮嬭彍鍗曚俊鎭紙姣忔淇濆瓨鍚庨噸缃級銆佸凡浣跨敤琛ㄥ強鍩烘湰淇℃伅琛ㄥ崟 */ UNSAFE_componentWillMount () { - const { menu, optionLibs } = this.props - + const { menu } = this.props let _LongParam = menu.LongParam let _config = '' @@ -86,93 +78,18 @@ _config.isAdd = true } else { _config = _LongParam - _config.search.forEach(item => { - if ( - (item.type === 'select' || item.type === 'multiselect' || item.type === 'link') && - item.resourceType === '0' && - item.options && item.options.length > 0 - ) { - optionLibs.set(menu.MenuID + item.uuid, { - uuid: menu.MenuID + item.uuid, - label: item.label, - parname: menu.MenuName, - type: 'search', - options: item.options - }) - } - }) } - if (!_config.version || _config.version < '1.0') { - // 閰嶇疆榛樿鍊硷紝鍏煎 - _config.version = '1.0' - _config.Template = 'CommonTable' - _config.easyCode = _config.easyCode || '' - - if (!_config.tabgroups) { - _config.tabgroups = [{ uuid: 'tabs', sublist: [] }] - } else if (typeof(_config.tabgroups[0]) === 'string') { - let _tabgroups = [] - _config.tabgroups.forEach(groupId => { - let _group = { - uuid: groupId, - sublist: fromJS(_config[groupId]).toJS() - } - - delete _config[groupId] - - _tabgroups.push(_group) - }) - - _config.tabgroups = _tabgroups - } - - // 鍏煎鍥捐〃 - if (!_config.charts) { - _config.expand = false - _config.charts = [{ - uuid: Utils.getuuid(), - label: '', - title: '', - chartType: 'table', - icon: 'table', - Hide: 'false', - blacklist: [] - }] - } else { - _config.charts.forEach(card => { - if (card.chartType === 'card') { - card.details = card.details.map(_cell => { - if (!_cell.fontSize) { - _cell.fontSize = 14 - } - if (!_cell.width) { - _cell.width = 100 - } else if (_cell.width === 'helf') { - _cell.width = 50 - } else if (_cell.width === 'third') { - _cell.width = 33 - } - - if (_cell.bold === 'true') { - _cell.fontWeight = 'normal' - } + // 椤甸潰閰嶇疆涓繚鐣欒彍鍗曚俊鎭紝鍙敤浜庢暟鎹紶閫� + _config.ParentId = menu.ParentId + _config.fstMenuId = menu.fstMenuId + _config.MenuName = menu.MenuName || '' + _config.MenuNo = menu.MenuNo || '' + _config.OpenType = menu.PageParam ? menu.PageParam.OpenType : '' + _config.easyCode = _config.easyCode || '' - if (!_cell.height) { - _cell.height = 1 - } - - return _cell - }) - - if (card.widthType === 'ratio' && card.avatar && card.avatar.widthType !== 'ratio') { - card.avatar.widthType = 'ratio' - card.avatar.width = 32 - } - } - }) - } - } + // 鐗堟湰鍏煎 + _config = updateCommonTable(_config) let _oriActions = [] if (_config.type === 'user') { @@ -183,17 +100,17 @@ item.linkTab = '' } - if (item.OpenType === 'pop') { // 鍚湁瀛愰厤缃」鐨勬寜閽�(琛ㄥ崟) + if (item.OpenType === 'pop' || item.execMode === 'pop') { // 鍚湁瀛愰厤缃」鐨勬寜閽�(琛ㄥ崟) _oriActions.push({ prebtn: fromJS(item).toJS(), curuuid: uuid, Template: 'Modal' }) - } else if (item.OpenType === 'tab' || item.OpenType === 'blank') { // 鍚湁瀛愰厤缃」鐨勬寜閽�(鏍囩鍚庡綋鍓嶉〉鎵撳紑) + } else if (item.OpenType === 'tab' && item.tabTemplate === 'FormTab') { // 鍚湁瀛愰厤缃」鐨勬寜閽�(鏍囩椤垫墦寮�) _oriActions.push({ prebtn: fromJS(item).toJS(), curuuid: uuid, - Template: item.tabTemplate + Template: 'FormTab' }) } @@ -220,10 +137,8 @@ config: _config, openEdition: menu.open_edition || '', activeKey: menu.activeKey || '0', - optionLibs: optionLibs, originActions: _oriActions, - originMenu: fromJS(menu).toJS(), - menuformlist: getMainMenuForm(menu, _config) + originMenu: fromJS(_config).toJS() }) } @@ -286,23 +201,41 @@ }) } - getFuncNames = (data, funcNames, tableNames) => { - data.forEach(item => { - if (item.subfuncs) { - this.getFuncNames(item.subfuncs, funcNames, tableNames) - } else { - if (item.tableName) { - tableNames.push(item.tableName) + getFuncNames = (config) => { + let funcNames = [] + let tableNames = [] + + if (config.setting.tableName) { + tableNames.push(config.setting.tableName) + } + if (config.setting.innerFunc) { + funcNames.push({func: config.setting.innerFunc, label: config.MenuName || ''}) + } + if (config.setting.outerFunc) { + funcNames.push({func: config.setting.outerFunc, label: config.MenuName || ''}) + } + + config.action.forEach(item => { + let tablename = item.OpenType === 'excelIn' ? (item.sheet || '') : (item.sql || '') + + if (item.OpenType === 'excelOut' && item.intertype === 'system') { + tablename = config.setting.tableName || '' + } + + if (['pop', 'prompt', 'exec', 'excelIn', 'excelOut', 'funcbutton'].includes(item.OpenType)) { + if (tablename) { + tableNames.push(tablename) } if (item.innerFunc) { funcNames.push({func: item.innerFunc, label: item.label || ''}) } - if (item.callbackFunc) { funcNames.push({func: item.callbackFunc, label: item.label || ''}) } } }) + + tableNames = Array.from(new Set(tableNames)) return { func: funcNames, @@ -315,430 +248,310 @@ */ 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.type === 'user') { // 浣跨敤宸叉湁鑿滃崟鏃讹紝榛樿娣诲姞鍏宠仈鏍囩id - 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 tab - }) - }) - } - - 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 - } - - _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 - - 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 => { - _sort++ - if (item.OpenType === 'popview') { - btntabs.push({ - uuid: item.uuid, - linkTab: item.linkTab, - label: item.label, - sort: _sort - }) - } - - 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 ') - - 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: 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 { - this.setState({ - menuloading: false, - menucloseloading: false - }) - notification.warning({ - top: 92, - message: response.message, - duration: 5 - }) - } - }) - }) - }) - }, () => { + // 鍩烘湰淇℃伅楠岃瘉 + if (!_config.fstMenuId || !_config.ParentId || !_config.MenuName || !_config.MenuNo) { notification.warning({ top: 92, - message: this.state.dict['header.menu.basemsg'], + message: this.state.dict['model.menu.basemsg'], duration: 5 + }) + this.setState({activeKey: '0'}) + return + } + + // 鏂板缓鑿滃崟锛屾竻闄ら粯璁ら」 + 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 tab + }) + }) + } + + // 鏈缃暟鎹簮鎴栨爣绛句笉鍚堟硶鏃讹紝鍚敤鐘舵�佷负false + let vresult = this.verifyconfig(_config) + if (vresult !== true) { + _config.enabled = false + } + + if (this.state.closeVisible) { // 鏄剧ず鍏抽棴瀵硅瘽妗嗘椂锛屾ā鎬佹涓繚瀛樻寜閽紝鏄剧ず淇濆瓨涓姸鎬� + this.setState({ + menucloseloading: true + }) + } else { + this.setState({ + menuloading: true + }) + } + + // 淇濆瓨鏃跺垹闄ら厤缃被鍨嬶紝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 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 => { + _sort++ + if (item.OpenType === 'popview') { + btntabs.push({ + uuid: item.uuid, + linkTab: item.linkTab, + label: item.label, + sort: _sort + }) + } + + 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') + 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') + tabParam.secretkey = Utils.encrypt(tabParam.LText, tabParam.timestamp) + + let _vals = this.getFuncNames(_config) + + 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: _vals.table.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') + 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) { + this.setState({ + config: _config, + openEdition: response.open_edition || '', + originMenu: fromJS(_config).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 + + this.submitAction(btnParam, tabParam, localParam) + } else { + this.setState({ + menuloading: false, + menucloseloading: false + }) + notification.warning({ + top: 92, + message: response.message, + duration: 5 + }) + } }) }) } @@ -746,20 +559,18 @@ /** * @description 淇濆瓨鎴栦慨鏀硅彍鍗曟寜閽泦 */ - submitAction = (btnParam, tabParam) => { + submitAction = (btnParam, tabParam, localParam) => { const { config } = this.state new Promise(resolve => { let deffers = [] - if (tabParam.LText) { - let defer = new Promise(resolve => { - Api.getSystemConfig(tabParam).then(result => { - resolve(result) - }) + let defer = new Promise(resolve => { + Api.getSystemConfig(tabParam).then(result => { + resolve(result) }) - deffers.push(defer) - } + }) + deffers.push(defer) if (btnParam.LText) { let defer = new Promise(resolve => { @@ -775,29 +586,25 @@ 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: error.message, - duration: 5 - }) - resolve(false) - } else { - resolve(true) + Promise.all(deffers).then(result => { + let error = false + result.forEach(res => { + if (!res.status) { + error = res } }) - } + + if (error) { + notification.warning({ + top: 92, + message: error.message, + duration: 5 + }) + resolve(false) + } else { + resolve(true) + } + }) }).then(response => { if (response === false) return response @@ -808,6 +615,8 @@ let curBtn = config.action.filter(cell => item.curuuid === cell.uuid)[0] // 鏌ョ湅鍒濆鍖栨寜閽槸鍚﹀瓨鍦� if (!curBtn) return if (curBtn.OpenType !== item.prebtn.OpenType) return + if (curBtn.OpenType === 'tab' && curBtn.tabTemplate !== 'FormTab') return + if (curBtn.OpenType === 'funcbutton' && curBtn.execMode !== 'pop') return oriActions.push({ prebtn: item.prebtn, @@ -887,7 +696,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}), @@ -915,6 +724,8 @@ menucloseloading: false }) } + this.props.reloadmenu() + Api.getLocalConfig(localParam) } else { this.setState({ menuloading: false, @@ -928,7 +739,6 @@ * @description 鐐瑰嚮杩斿洖鏃讹紝鍒ゆ柇閰嶇疆淇濆瓨鐘舵�� */ cancelConfig = () => { - const { menu } = this.props const { config, originMenu } = this.state let _this = this @@ -936,39 +746,19 @@ if (config.isAdd) { confirm({ content: '鑿滃崟灏氭湭鎻愪氦锛岀‘瀹氭斁寮冧繚瀛樺悧锛�', - okText: this.state.dict['model.confirm'], - cancelText: this.state.dict['header.cancel'], onOk() { _this.props.handleView() }, 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() + } } } @@ -977,136 +767,128 @@ */ setSubConfig = (item, type) => { const { menu } = this.props - const { config, originMenu, optionLibs, activeKey, openEdition } = this.state + const { config, originMenu, activeKey, openEdition } = this.state - if (!originMenu.MenuID) { // menuID涓嶅瓨鍦ㄦ椂锛屼负鏂板缓鑿滃崟锛屾彁绀鸿彍鍗曞皻鏈繚瀛� + if (config.isAdd) { // 鏂板缓鑿滃崟锛屾彁绀鸿彍鍗曞皻鏈繚瀛� notification.warning({ top: 92, message: this.state.dict['header.menu.config.notsave'], 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 - }) - - 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 - }) - } - }) - }, () => { + 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(_menu => _menu.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.children : [] + } + + // 鑿滃崟淇℃伅楠岃瘉閫氳繃鍚庯紝璺宠浆瀛愰厤缃〉闈� + let _view = '' + let uuid = item.uuid + let isbutton = true + let _btnTab = null + + if (type === 'button' && (item.OpenType === 'pop' || item.execMode === 'pop')) { + _view = 'Modal' // 琛ㄥ崟椤甸潰 + } else if (type === 'button' && item.OpenType === 'tab') { + _view = 'FormTab' // 琛ㄥ崟鏍囩椤垫ā鏉� + _btnTab = item + } else if (type === 'button' && item.OpenType === 'popview') { + _view = 'SubTable' // 鏂板脊绐楁爣绛炬ā鏉� tabType 灞炴�у凡鍘婚櫎 + uuid = item.linkTab + isbutton = false + } else if (type === 'tab') { + _view = 'SubTable' // 鏍囩妯℃澘 + uuid = item.linkTab + isbutton = false + } + + _Menu.activeKey = activeKey // 淇濆瓨褰撳墠鎵撳紑椤电 + _Menu.open_edition = openEdition // 鏇存柊鐗堟湰鍙� + + let param = { + 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 + }) + } }) } } @@ -1146,30 +928,85 @@ }) } - let charterr = '' - config.charts.forEach(chart => { - if (!charterr && ['line', 'bar', 'pie'].includes(chart.chartType) && !chart.Xaxis) { - charterr = '鍥捐〃' + (chart.title ? '銆�' + chart.title + '銆�' : '') + '鍧愭爣杞存湭璁剧疆锛屼笉鍙惎鐢紒' - } - }) - let hasKey = false + let chartcols = [] config.columns.forEach(col => { + if (col.field) { + chartcols.push(col.field) + } if (config.setting.primaryKey === col.field) { hasKey = true } }) - if (config.setting.interType === 'inner' && !config.setting.innerFunc && config.setting.default !== 'false' && !config.setting.dataresource) { - return '鑿滃崟灏氭湭璁剧疆鏁版嵁婧愶紝涓嶅彲鍚敤锛�' + let chartError = '' + config.charts && config.charts.forEach((chart, index) => { + if (chartError) return + if (chart.Hide === 'true') return + if (!['line', 'bar', 'pie'].includes(chart.chartType)) return + + if (!chart.Xaxis) { + chartError = `鍥捐〃${chart.title ? '銆�' + chart.title + '銆�' : index + 1}鍧愭爣杞村瓧娈靛皻鏈缃紝涓嶅彲鍚敤锛乣 + } else if (['line', 'bar'].includes(chart.chartType) && chart.datatype !== 'statistics' && (!chart.Yaxis || chart.Yaxis.length === 0)) { // query 鏌ヨ鏁版嵁 + chartError = `鍥捐〃${chart.title ? '銆�' + chart.title + '銆�' : index + 1}鍧愭爣杞村瓧娈靛皻鏈缃紝涓嶅彲鍚敤锛乣 + } else if (['line', 'bar'].includes(chart.chartType) && chart.datatype === 'statistics' && (!chart.InfoType || !chart.InfoValue)) { // statistics 缁熻鏁版嵁 + chartError = `鍥捐〃${chart.title ? '銆�' + chart.title + '銆�' : index + 1}鍧愭爣杞村瓧娈靛皻鏈缃紝涓嶅彲鍚敤锛乣 + } else if (chart.chartType === 'pie' && !chart.Yaxis) { + chartError = `鍥捐〃${chart.title ? '銆�' + chart.title + '銆�' : index + 1}鍧愭爣杞村瓧娈靛皻鏈缃紝涓嶅彲鍚敤锛乣 + } else if (!chartcols.includes(chart.Xaxis)) { + chartError = `鍥捐〃${chart.title ? '銆�' + chart.title + '銆�' : index + 1}鍧愭爣杞村瓧娈靛湪鏄剧ず鍒椾腑涓嶅瓨鍦紝涓嶅彲鍚敤锛乣 + } else if (chart.chartType === 'pie' && !chartcols.includes(chart.Yaxis)) { + chartError = `鍥捐〃${chart.title ? '銆�' + chart.title + '銆�' : index + 1}鍧愭爣杞村瓧娈靛湪鏄剧ず鍒椾腑涓嶅瓨鍦紝涓嶅彲鍚敤锛乣 + } else if (['line', 'bar'].includes(chart.chartType) && chart.datatype === 'statistics' && (!chartcols.includes(chart.InfoType) || !chartcols.includes(chart.InfoValue))) { // statistics 缁熻鏁版嵁 + chartError = `鍥捐〃${chart.title ? '銆�' + chart.title + '銆�' : index + 1}鍧愭爣杞村瓧娈靛湪鏄剧ず鍒椾腑涓嶅瓨鍦紝涓嶅彲鍚敤锛乣 + } else if (['line', 'bar'].includes(chart.chartType) && chart.datatype !== 'statistics' && chart.Yaxis.filter(yaxis => !chartcols.includes(yaxis)).length > 0) { + chartError = `鍥捐〃${chart.title ? '銆�' + chart.title + '銆�' : index + 1}鍧愭爣杞村瓧娈靛湪鏄剧ず鍒椾腑涓嶅瓨鍦紝涓嶅彲鍚敤锛乣 + } + }) + + config.action && config.action.forEach((btn) => { + if (['prompt', 'exec', 'pop'].includes(btn.OpenType) && btn.Ot === 'required' && btn.verify && btn.verify.scripts && btn.verify.scripts.length > 0) { + let hascheck = false + btn.verify.scripts.forEach(item => { + if (item.status === 'false') return + + if (/\$check@|@check\$/ig.test(item.sql)) { + hascheck = true + } + }) + if (hascheck) { + notification.warning({ + top: 92, + message: `鍙�夋嫨澶氳鐨勬寜閽��${btn.label}銆嬩腑 $check@ 鎴� @check$ 灏嗕笉浼氱敓鏁堬紒`, + duration: 5 + }) + } + } + if (btn.intertype === 'custom' && btn.callbackType === 'script' && (!btn.verify || !btn.verify.cbScripts || !btn.verify.cbScripts.filter(item => item.status !== 'false').length === 0)) { + notification.warning({ + top: 92, + message: `鎸夐挳銆�${btn.label}銆嬫湭璁剧疆鍥炶皟鑴氭湰锛� 灏嗕笉浼氱敓鏁堬紒`, + duration: 5 + }) + } + }) + + if ((config.setting.interType === 'system' || config.setting.requestMode === 'system') && config.setting.default === 'false' && config.setting.scripts && config.setting.scripts.filter(item => item.status !== 'false').length === 0) { + return '鏁版嵁婧愪腑涓嶆墽琛岄粯璁ql锛屼笖鏈坊鍔犺嚜瀹氫箟鑴氭湰锛屼笉鍙惎鐢紒' + } else if (config.setting.interType === 'custom' && config.setting.procMode !== 'inner' && config.setting.preScripts && config.setting.preScripts.filter(item => item.status !== 'false').length === 0) { + return '鏁版嵁婧愭湭璁剧疆鍓嶇疆鑴氭湰锛屼笉鍙惎鐢紒' + } else if (config.setting.interType === 'custom' && config.setting.callbackType === 'script' && config.setting.cbScripts && config.setting.cbScripts.filter(item => item.status !== 'false').length === 0) { + return '鏁版嵁婧愭湭璁剧疆鍥炶皟鑴氭湰锛屼笉鍙惎鐢紒' } else if (!config.setting.primaryKey) { return '鑿滃崟灏氭湭璁剧疆涓婚敭锛屼笉鍙惎鐢紒' + } else if (config.columns.length === 0) { + return '鑿滃崟灏氭湭璁剧疆鏄剧ず鍒楋紝涓嶅彲鍚敤锛�' } else if (!hasKey) { return '鏄剧ず鍒椾腑涓嶅瓨鍦ㄤ富閿瓧娈碉紝涓嶅彲鍚敤锛�' } else if (!tabinvalid) { return '鑿滃崟鏍囩椤佃缃敊璇紙瀛樺湪澶氳鏍囩鏃讹紝琛屾爣绛句笉鍙负绌猴級锛�' - } else if (charterr) { - return charterr + } else if (chartError) { + return chartError } else { return true } @@ -1199,25 +1036,16 @@ config: res.config }) } else if (res.type === 'paste') { - this.setState({ - pasteContent: res.content - }, () => { - this.setState({ - pasteContent: null - }) - }) + this.setState({config: res.config}) } } /** * @description 鏇存柊鎼滅储鏉′欢閰嶇疆淇℃伅 */ - updatesearch = (config, options) => { - const { optionLibs } = this.state - + updatesearch = (config) => { this.setState({ - config: config, - optionLibs: options || optionLibs + config: config }) } @@ -1245,30 +1073,6 @@ } /** - * @description 鏇存柊甯哥敤琛ㄤ俊鎭紝蹇嵎娣诲姞鍚庢洿鏂伴厤缃俊鎭� - */ - updatetable = (config, fields) => { - const { tableFields } = this.state - - this.setState({ - config: config, - tableFields: fields ? fields : tableFields - }) - } - - /** - * @description 鏇存柊鏍囩閰嶇疆淇℃伅 - */ - updatetabs = (config, delcards) => { - const { delActions } = this.state - - this.setState({ - config: config, - delActions: delcards ? [...delActions, ...delcards] : delActions - }) - } - - /** * @description 鏇存柊閰嶇疆淇℃伅 */ updateconfig = (config) => { @@ -1278,9 +1082,10 @@ } 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)) + const confActions = config.action.filter(_action => !_action.origin && (['pop', 'popview'].includes(_action.OpenType) || (_action.OpenType === 'tab' && _action.tabTemplate === 'FormTab') || (_action.OpenType === 'funcbutton' && _action.execMode === 'pop'))) let configTabs = [] config.tabgroups.forEach(group => { @@ -1292,20 +1097,21 @@ <DndProvider backend={HTML5Backend}> {/* 宸ュ叿鏍� */} <div className="tools"> - <Collapse accordion defaultActiveKey={activeKey} bordered={false} onChange={(key) => this.setState({activeKey: key})}> + <Collapse accordion activeKey={activeKey} bordered={false} onChange={(key) => this.setState({activeKey: key})}> {/* 鍩烘湰淇℃伅 */} <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 config={config} containerId="main-basedata" - updatetable={this.updatetable} + updatetable={this.updateconfig} /> </Panel> {/* 鎼滅储鏉′欢娣诲姞 */} @@ -1316,7 +1122,6 @@ <FieldsComponent config={config} type="search" - tableFields={this.state.tableFields} updatefield={this.updateconfig} /> </Panel> @@ -1356,7 +1161,6 @@ <FieldsComponent config={config} type="columns" - tableFields={this.state.tableFields} updatefield={this.updateconfig} /> </Panel> @@ -1396,33 +1200,25 @@ </div> } bordered={false} extra={ <div> - <EditComponent dict={this.state.dict} type="maintable" config={this.state.config} MenuID={this.props.menu.MenuID} thawButtons={this.state.thawButtons} refresh={this.editConfig}/> - <Switch className="big" checkedChildren="鍚�" unCheckedChildren="鍋�" checked={this.state.config.enabled} onChange={this.onEnabledChange} /> - <Button type="primary" onClick={this.submitConfig} loading={this.state.menuloading}>{this.state.dict['header.save']}</Button> - <Button onClick={this.cancelConfig}>{this.state.dict['header.return']}</Button> + <EditComponent dict={this.state.dict} options={['search', 'action', 'columns']} config={this.state.config} MenuID={this.props.menu.MenuID} thawButtons={this.state.thawButtons} refresh={this.editConfig}/> + <Switch className="big" checkedChildren={this.state.dict['model.enable']} unCheckedChildren={this.state.dict['model.disable']} checked={this.state.config.enabled} onChange={this.onEnabledChange} /> + <Button type="primary" onClick={this.submitConfig} loading={this.state.menuloading}>{this.state.dict['model.save']}</Button> + <Button onClick={this.cancelConfig}>{this.state.dict['model.back']}</Button> </div> } style={{ width: '100%' }}> <SettingComponent - 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}} config={config} - pasteContent={this.state.pasteContent} - sysRoles={this.props.sysRoles} - optionLibs={this.state.optionLibs} updatesearch={this.updatesearch} /> <div className="chart-view" style={{position: 'relative'}}> {/* 瑙嗗浘缁� 鏉冮檺 浼氬憳绛夌骇20+ */} {this.props.memberLevel >= 20 ? <ChartGroupComponent config={config} - sysRoles={this.props.sysRoles} updatechartgroup={this.updatechartgroup} /> : null} {config.charts.map(item => { @@ -1434,20 +1230,15 @@ {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 }} + 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')} updateaction={this.updateaction} /> <ColumnComponent config={config} menu={this.props.menu} - sysRoles={this.props.sysRoles} - pasteContent={this.state.pasteContent} updatecolumn={this.updateconfig} /> </Col> @@ -1480,7 +1271,7 @@ config={config} tabs={this.state.tabviews} setSubConfig={(item) => this.setSubConfig(item, 'tab')} - updatetabs={this.updatetabs} + updatetabs={this.updateconfig} /> </Card> </div> @@ -1493,9 +1284,9 @@ visible={this.state.closeVisible} onCancel={() => { this.setState({closeVisible: false}) }} footer={[ - <Button key="save" className="mk-btn mk-green" loading={this.state.menucloseloading} onClick={this.submitConfig}>{this.state.dict['header.save']}</Button>, - <Button key="notsave" className="mk-btn mk-yellow" onClick={this.notsave}>{this.state.dict['header.notsave']}</Button>, - <Button key="cancel" onClick={() => { this.setState({closeVisible: false}) }}>{this.state.dict['header.cancel']}</Button> + <Button key="save" className="mk-btn mk-green" loading={this.state.menucloseloading} onClick={this.submitConfig}>{this.state.dict['model.save']}</Button>, + <Button key="notsave" className="mk-btn mk-yellow" onClick={this.notsave}>{this.state.dict['model.notsave']}</Button>, + <Button key="cancel" onClick={() => { this.setState({closeVisible: false}) }}>{this.state.dict['model.cancel']}</Button> ]} destroyOnClose > @@ -1509,8 +1300,6 @@ const mapStateToProps = (state) => { return { - sysRoles: state.sysRoles, - permFuncField: state.permFuncField, memberLevel: state.memberLevel } } -- Gitblit v1.8.0