From af6486b3629d23e426ce85b87dbc20dfa15b1afe Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期一, 07 十一月 2022 18:50:27 +0800 Subject: [PATCH] 2022-11-07 --- src/templates/comtableconfig/index.jsx | 855 +++++++++++++++++++++++++++----------------------------- 1 files changed, 408 insertions(+), 447 deletions(-) diff --git a/src/templates/comtableconfig/index.jsx b/src/templates/comtableconfig/index.jsx index d637149..09683e2 100644 --- a/src/templates/comtableconfig/index.jsx +++ b/src/templates/comtableconfig/index.jsx @@ -1,17 +1,16 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' -import { connect } from 'react-redux' import { is, fromJS } from 'immutable' import { DndProvider } from 'react-dnd' import HTML5Backend from 'react-dnd-html5-backend' -import { Button, Card, Modal, Collapse, notification, Spin, Icon, Switch, Tooltip, Col } from 'antd' +import { Button, Card, Modal, Collapse, notification, Spin, Switch, Tooltip, Col } from 'antd' +import { QuestionCircleOutlined, RedoOutlined } from '@ant-design/icons' import moment from 'moment' import Api from '@/api' import Utils from '@/utils/utils.js' -import UtilsUpdate from '@/utils/utils-update.js' -import zhCN from '@/locales/zh-CN/model.js' -import enUS from '@/locales/en-US/model.js' +import MKEmitter from '@/utils/events.js' +import { updateCommonTable } from '@/utils/utils-update.js' import asyncComponent from '@/utils/asyncComponent' import SearchComponent from '@/templates/sharecomponent/searchcomponent' @@ -25,6 +24,12 @@ const { Panel } = Collapse const { confirm } = Modal + +const Versions = asyncComponent(() => import('@/menu/versions')) +const UrlFieldComponent = asyncComponent(() => import('@/menu/urlfieldcomponent')) +const ReplaceField = asyncComponent(() => import('@/menu/replaceField')) +const UpdateTable = asyncComponent(() => import('./updatetable')) +const Unattended = asyncComponent(() => import('@/templates/zshare/unattended')) const EditComponent = asyncComponent(() => import('@/templates/zshare/editcomponent')) const SettingComponent = asyncComponent(() => import('@/templates/sharecomponent/settingcomponent')) const TableComponent = asyncComponent(() => import('@/templates/sharecomponent/tablecomponent')) @@ -42,15 +47,12 @@ } state = { - dict: localStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, config: null, // 椤甸潰閰嶇疆 - tableFields: [], // 琛ㄦ牸鏄剧ず鍒� formlist: null, // 鎼滅储鏉′欢銆佹寜閽�佹樉绀哄垪琛ㄥ崟瀛楁 menuloading: false, // 鑿滃崟淇濆瓨涓� menucloseloading: false, // 鑿滃崟鍏抽棴鏃讹紝閫夋嫨淇濆瓨 loading: false, // 鍔犺浇涓紝椤甸潰spin closeVisible: false, // 鍏抽棴妯℃�佹 - tables: [], // 鍙敤琛ㄥ悕 originMenu: null, // 鍘熷鑿滃崟 originActions: null, // 鍘熷鎸夐挳淇℃伅锛屼娇鐢ㄥ凡鏈夌敤鎴锋ā鏉� delActions: [], // 鍒犻櫎鎸夐挳鍒楄〃 @@ -59,7 +61,7 @@ thawButtons: [], // 宸查�夋嫨瑕佽В鍐荤殑鎸夐挳 activeKey: '0', // 榛樿灞曞紑鍩烘湰淇℃伅 chartview: null, // 褰撳墠瑙嗗浘 - openEdition: '' // 缂栬緫鐗堟湰鏍囪锛岄槻姝㈠浜烘搷浣� + openEdition: '', // 缂栬緫鐗堟湰鏍囪锛岄槻姝㈠浜烘搷浣� } /** @@ -74,9 +76,6 @@ if (!_LongParam) { _config = fromJS(Source.baseConfig).toJS() - if (!menu.isSubtable) { // 涓嶆槸閫夋嫨涓诲瓙琛ㄦ椂锛岄殣钘忔爣绛鹃〉 - _config.tabgroups = [{ uuid: 'tabs', sublist: [] }] - } _config.isAdd = true } else { _config = _LongParam @@ -89,9 +88,10 @@ _config.MenuNo = menu.MenuNo || '' _config.OpenType = menu.PageParam ? menu.PageParam.OpenType : '' _config.easyCode = _config.easyCode || '' + _config.uuid = menu.MenuID || '' // 鐗堟湰鍏煎 - _config = UtilsUpdate.updateCommonTable(_config) + _config = updateCommonTable(_config) let _oriActions = [] if (_config.type === 'user') { @@ -102,17 +102,11 @@ 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') { // 鍚湁瀛愰厤缃」鐨勬寜閽�(鏍囩鍚庡綋鍓嶉〉鎵撳紑) - _oriActions.push({ - prebtn: fromJS(item).toJS(), - curuuid: uuid, - Template: item.tabTemplate }) } @@ -135,7 +129,7 @@ } this.setState({ - chartview: _config.charts[0].uuid, + chartview: _config.charts ? _config.charts[0].uuid : '', config: _config, openEdition: menu.open_edition || '', activeKey: menu.activeKey || '0', @@ -149,6 +143,55 @@ */ componentDidMount () { this.reloadTab(false) + + document.onkeydown = (event) => { + let e = event || window.event + let keyCode = e.keyCode || e.which || e.charCode + let preKey = '' + + if (e.ctrlKey) { + preKey = 'ctrl' + } + if (e.shiftKey) { + preKey = 'shift' + } else if (e.altKey) { + preKey = 'alt' + } + + if (!preKey || !keyCode) return + + let _shortcut = `${preKey}+${keyCode}` + + if (_shortcut === 'ctrl+83') { + let modals = document.querySelectorAll('.mk-pop-modal') + let msg = null + for (let i = 0; i < modals.length; i++) { + if (msg) { + break + } + + let node = modals[i].querySelector('.mk-com-name') + + if (node) { + msg = node.innerText + } + } + if (msg) { + notification.warning({ + top: 92, + message: '璇蜂繚瀛�' + msg, + duration: 5 + }) + return false + } + + let node = document.getElementById('save-config') + if (node && node.click) { + node.click() + } + return false + } + } } /** @@ -158,6 +201,7 @@ this.setState = () => { return } + document.onkeydown = () => {} } /** @@ -203,23 +247,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, @@ -240,7 +302,7 @@ if (!_config.fstMenuId || !_config.ParentId || !_config.MenuName || !_config.MenuNo) { notification.warning({ top: 92, - message: this.state.dict['model.menu.basemsg'], + message: '璇峰畬鍠勮彍鍗曞熀鏈俊鎭紒', duration: 5 }) this.setState({activeKey: '0'}) @@ -274,75 +336,16 @@ }) } + // 鎸夐挳涓嶅瓨鍦ㄦ椂锛屽幓鎺夌粦瀹氱殑鍙屽嚮鎸夐挳 + if (_config.setting.doubleClick && _config.action.findIndex((item) => item.uuid === _config.setting.doubleClick) === -1) { + _config.setting.doubleClick = '' + } + // 鏈缃暟鎹簮鎴栨爣绛句笉鍚堟硶鏃讹紝鍚敤鐘舵�佷负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 || 'system', - 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 === 'system') { - 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({ @@ -354,164 +357,124 @@ }) } - 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 = '' + let _LongParam = '' + let reload = _config.isAdd + + // 淇濆瓨鏃跺垹闄ら厤缃被鍨嬶紝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: _config.MenuNo, + Template: _config.Template || '', + PageParam: '', + LongParam: '', + LText: [] + } + + _config.action.forEach(item => { + if (item.hidden === 'true') return + _sort++ + if (item.OpenType === 'popview') { + btntabs.push({ + uuid: item.uuid, + linkTab: item.linkTab, + label: item.label, + sort: _sort + }) + } - if (result.LongParam) { - try { - _LongParam = JSON.parse(window.decodeURIComponent(window.atob(result.LongParam))) - } catch (e) { - console.warn('Parse Failure') - _LongParam = '' - } - } + 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) - 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() - }) - } - }).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 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 => { + 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 - }) - } - - btnParam.LText.push(`select '${item.uuid}' as menuid, '${item.label}' as menuname, '${_sort * 10}' as Sort`) + _LText.push(`select '${menu.MenuID}' as MenuID ,'${item.linkTab}' as Tabid,'${item.label}' as TabName ,'${_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 - } + _LText = _LText.join(' union all ') - let _LText = [] + // 娓呯┖鑿滃崟涓嬪叧鑱旂殑鏍囩 + if (!_LText) { + _LText = `select '${menu.MenuID}' as MenuID ,'' as Tabid,'' as TabName ,'0' 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`) - }) - }) + tabParam.LText = Utils.formatOptions(_LText) + tabParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + tabParam.secretkey = Utils.encrypt(tabParam.LText, tabParam.timestamp) - _LText = _LText.join(' union all ') + let _vals = this.getFuncNames(_config) - // 娓呯┖鑿滃崟涓嬪叧鑱旂殑鏍囩 - if (!_LText) { - _LText = `select '${menu.MenuID}' as MenuID ,'' as Tabid,'' as TabName ,'0' as Sort` - } + 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, hidden: _config.hidden || 'false'}), + 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`) + } - tabParam.LText = Utils.formatOptions(_LText) - tabParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') - tabParam.secretkey = Utils.encrypt(tabParam.LText, tabParam.timestamp) + if (menu.menuSort) { // 鑿滃崟鏂板缓鏃惰缃帓搴� + param.Sort = menu.menuSort + } - let _vals = this.getFuncNames(_config.funcs, [], []) - let _tables = Array.from(new Set(_vals.table)) + 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) - 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 (openEdition) { // 鐗堟湰绠$悊 + param.open_edition = openEdition + } - 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 - } - + setTimeout(() => { // 鏈夋寜閽垨鏍囩鍒犻櫎鏃讹紝鍏堣繘琛屽垹闄ゆ搷浣� // 鍒犻櫎鎴愬姛鍚庯紝淇濆瓨椤甸潰閰嶇疆 new Promise(resolve => { @@ -550,7 +513,7 @@ error = response } }) - + if (error) { this.setState({ menuloading: false, @@ -621,11 +584,9 @@ config: _config, openEdition: response.open_edition || '', originMenu: fromJS(_config).toJS() + }, () => { + reload && MKEmitter.emit('revert') }) - - this.props.reloadmenu() - - this.submitAction(btnParam, tabParam) localParam.func = 'sPC_TrdMenu_AddUpt_For_Local' delete localParam.LongParam @@ -635,7 +596,7 @@ delete localParam.EasyCode delete localParam.open_edition - Api.getLocalConfig(localParam) + this.submitAction(btnParam, tabParam, localParam) } else { this.setState({ menuloading: false, @@ -649,13 +610,13 @@ } }) }) - }) + }, +sessionStorage.getItem('mkDelay')) } /** * @description 淇濆瓨鎴栦慨鏀硅彍鍗曟寜閽泦 */ - submitAction = (btnParam, tabParam) => { + submitAction = (btnParam, tabParam, localParam) => { const { config } = this.state new Promise(resolve => { @@ -682,29 +643,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 @@ -715,6 +672,7 @@ let curBtn = config.action.filter(cell => item.curuuid === cell.uuid)[0] // 鏌ョ湅鍒濆鍖栨寜閽槸鍚﹀瓨鍦� if (!curBtn) return if (curBtn.OpenType !== item.prebtn.OpenType) return + if (curBtn.OpenType === 'funcbutton' && curBtn.execMode !== 'pop') return oriActions.push({ prebtn: item.prebtn, @@ -732,76 +690,30 @@ MenuID: action.prebtn.uuid }).then(result => { if (result.status && result.LongParam) { - let _LongParam = '' let _temp = '' - if (result.LongParam) { - let _subconfig = '' - try { - _subconfig = JSON.parse(window.decodeURIComponent(window.atob(result.LongParam))) - _temp = _subconfig.type - } catch (e) { - console.warn('Parse Failure') - _subconfig = '' - } - - if (_temp === 'FormTab') { - try { - _subconfig.action = _subconfig.action.map(_btn => { - _btn.uuid = Utils.getuuid() - - return _btn - }) - - // 鍏煎宸叉湁缁撴瀯 - if (!_subconfig.tabgroups) { - _subconfig.tabgroups = [{ uuid: 'tabs', sublist: [] }] - } else if (typeof(_subconfig.tabgroups[0]) === 'string') { - let _tabgroups = [] - _subconfig.tabgroups.forEach(groupId => { - let _group = { - uuid: groupId, - sublist: fromJS(_subconfig[groupId]).toJS() - } - delete _subconfig[groupId] - _tabgroups.push(_group) - }) - _subconfig.tabgroups = _tabgroups - } - - _subconfig.tabgroups.forEach(group => { - group.sublist = group.sublist.map(_tab => { - _tab.uuid = Utils.getuuid() - _tab.linkTab = Utils.getuuid() - - return _tab - }) - }) - _subconfig = window.btoa(window.encodeURIComponent(JSON.stringify(_subconfig))) - } catch { - console.warn('Stringify Failure') - _subconfig = '' - } - - _LongParam = _subconfig - } else if (_subconfig) { - _LongParam = result.LongParam - } + let _subconfig = '' + try { + _subconfig = JSON.parse(window.decodeURIComponent(window.atob(result.LongParam))) + _temp = _subconfig.type + } catch (e) { + console.warn('Parse Failure') + _subconfig = '' } - if (_LongParam) { - let param = { - func: 'sPC_ButtonParam_AddUpt', - ParentID: this.props.menu.MenuID, - MenuID: action.curBtn.uuid, - MenuNo: config.MenuNo, - Template: _temp, - MenuName: action.curBtn.label, - PageParam: JSON.stringify({Template: _temp}), - LongParam: _LongParam - } - Api.getSystemConfig(param).then(() => {}) + if (!_subconfig) return + + let param = { + func: 'sPC_ButtonParam_AddUpt', + ParentID: this.props.menu.MenuID, + MenuID: action.curBtn.uuid, + MenuNo: config.MenuNo, + Template: _temp, + MenuName: action.curBtn.label, + PageParam: JSON.stringify({Template: _temp}), + LongParam: result.LongParam } + Api.getSystemConfig(param).then(() => {}) } }) }) @@ -822,6 +734,8 @@ menucloseloading: false }) } + this.props.reloadmenu() + Api.genericInterface(localParam) } else { this.setState({ menuloading: false, @@ -868,30 +782,20 @@ if (config.isAdd) { // 鏂板缓鑿滃崟锛屾彁绀鸿彍鍗曞皻鏈繚瀛� notification.warning({ top: 92, - message: this.state.dict['header.menu.config.notsave'], + message: '鑿滃崟灏氭湭淇濆瓨锛岃鍏堜繚瀛樿彍鍗曢厤缃紒', duration: 5 }) } else { - // 鍩烘湰淇℃伅楠岃瘉 - if (!config.fstMenuId || !config.ParentId || !config.MenuName || !config.MenuNo) { - notification.warning({ - top: 92, - message: this.state.dict['model.menu.basemsg'], - duration: 5 - }) - this.setState({activeKey: '0'}) - return - } if (!is(fromJS(originMenu), fromJS(config))) { // 鑿滃崟淇℃伅鍙樺寲鏃讹紝鎻愮ず淇濆瓨 notification.warning({ top: 92, - message: this.state.dict['header.menu.config.update'], + message: '鑿滃崟閰嶇疆宸蹭慨鏀癸紝璇蜂繚瀛橈紒', duration: 5 }) return } - let submenu = menu.fstMenuList.filter(item => item.MenuID === config.fstMenuId)[0] + let submenu = menu.fstMenuList.filter(_menu => _menu.MenuID === config.fstMenuId)[0] let _Menu = { ...menu, @@ -910,17 +814,17 @@ 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 // 鏂版爣绛鹃〉妯℃澘 + 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 = item.tabType // 鏂板脊绐楁爣绛炬ā鏉� + _view = 'SubTable' // 鏂板脊绐楁爣绛炬ā鏉� tabType 灞炴�у凡鍘婚櫎 uuid = item.linkTab isbutton = false } else if (type === 'tab') { - _view = item.type // 鏍囩妯℃澘 + _view = 'SubTable' // 鏍囩妯℃澘 uuid = item.linkTab isbutton = false } @@ -975,7 +879,7 @@ } 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) { @@ -1070,9 +974,39 @@ } }) + 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.default !== 'false' && !config.setting.dataresource) { - return '鑿滃崟灏氭湭璁剧疆鏁版嵁婧愶紝涓嶅彲鍚敤锛�' + 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) { @@ -1106,25 +1040,10 @@ * @description 缂栬緫鍔熻兘瀹屾垚鏇存柊锛屽寘鎷В鍐绘寜閽�佺矘璐淬�佹浛鎹㈢瓑 */ editConfig = (res) => { - - - if (res.type === 'thaw') { - this.setState({ - thawButtons: res.thawButtons, - config: res.config - }) - } else if (res.type === 'paste') { - let config = fromJS(this.state.config).toJS() - if (res.content.copyType === 'search') { - config.search.push(res.content) - } else if (res.content.copyType === 'action') { - config.action.push(res.content) - } else if (res.content.copyType === 'columns' && res.content.columns && res.content.columns.length > 0) { - config.columns = config.columns.filter(col => !col.origin) - config.columns = [...config.columns, ...res.content.columns] - } - this.setState({config}) - } + this.setState({ + thawButtons: res.thawButtons, + config: res.config + }) } /** @@ -1160,28 +1079,6 @@ } /** - * @description 鏇存柊甯哥敤琛ㄤ俊鎭紝蹇嵎娣诲姞鍚庢洿鏂伴厤缃俊鎭� - */ - updatetable = (config, fields) => { - const { tableFields } = this.state - - this.setState({ - config: config, - tableFields: fields ? fields : tableFields - }) - } - - /** - * @description 鏇存柊鏍囩閰嶇疆淇℃伅 - */ - updatetabs = (config) => { - - this.setState({ - config: config - }) - } - - /** * @description 鏇存柊閰嶇疆淇℃伅 */ updateconfig = (config) => { @@ -1190,11 +1087,74 @@ }) } + refreshConfig = () => { + const { menu } = this.props + + let param = { + func: 'sPC_Get_LongParam', + MenuID: menu.MenuID + } + + Api.getSystemConfig(param).then(res => { + if (res.status) { + let _config = '' + if (res.LongParam) { + try { + _config = JSON.parse(window.decodeURIComponent(window.atob(res.LongParam))) + } catch (e) { + console.warn('Parse Failure') + _config = '' + } + } + + if (!_config) { + notification.warning({ + top: 92, + message: '鏈幏鍙栧埌閰嶇疆淇℃伅锛�', + duration: 5 + }) + return + } + + _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 || '' + + // 鐗堟湰鍏煎 + _config = updateCommonTable(_config) + + this.setState({ + config: null + }, () => { + this.setState({ + chartview: _config.charts ? _config.charts[0].uuid : '', + config: _config, + openEdition: res.open_edition || '', + activeKey: menu.activeKey || '0', + originActions: [], + originMenu: fromJS(_config).toJS() + }) + }) + } else { + notification.warning({ + top: 92, + message: res.message, + duration: 5 + }) + } + }) + } + render () { const { menu } = this.props - const { activeKey, config, chartview } = this.state + const { activeKey, config, chartview, openEdition } = this.state - const confActions = config.action.filter(_action => !_action.origin && ['pop', 'popview', 'blank', 'tab'].includes(_action.OpenType)) + if (!config) return null + + 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 => { @@ -1208,35 +1168,33 @@ <div className="tools"> <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"> + <Panel forceRender={true} header="鍩烘湰淇℃伅" key="0" id="main-basedata"> {/* 鑿滃崟淇℃伅 */} <MenuForm menu={menu} config={config} - dict={this.state.dict} updatemenu={this.updateconfig} /> + {config ? <UrlFieldComponent + config={config} + updateConfig={this.updateconfig} + /> : null} {/* 琛ㄥ悕娣诲姞 */} <TableComponent config={config} containerId="main-basedata" - updatetable={this.updatetable} + updatetable={this.updateconfig} /> </Panel> {/* 鎼滅储鏉′欢娣诲姞 */} - <Panel header={this.state.dict['header.menu.search']} key="1"> + <Panel header="鎼滅储" key="1"> <div className="search-element"> {Source.searchItems.map((item, index) => (<SourceElement key={index} content={item}/>))} </div> - <FieldsComponent - config={config} - type="search" - tableFields={this.state.tableFields} - updatefield={this.updateconfig} - /> + <FieldsComponent config={config} type="search" /> </Panel> {/* 鎸夐挳娣诲姞 */} - <Panel header={this.state.dict['header.menu.action']} key="2"> + <Panel header="鎸夐挳" key="2"> <div className="search-element"> {Source.actionItems.map((item, index) => (<SourceElement key={index} content={item}/>))} </div> @@ -1244,9 +1202,9 @@ {confActions.length > 0 ? <p className="config-btn-title"> <Tooltip placement="topLeft" title="鐐瑰嚮鎸夐挳锛屽彲瀹屾垚鎴栨煡鐪嬫寜閽厤缃俊鎭��"> - <Icon type="question-circle" /> + <QuestionCircleOutlined className="mk-form-tip"/> </Tooltip> - {this.state.dict['header.menu.action.configurable']} + 鎸夐挳閰嶇疆 </p> : null } </div> @@ -1264,28 +1222,23 @@ })} </Panel> {/* 娣诲姞鏄剧ず鍒� */} - <Panel header={this.state.dict['header.menu.column']} key="3"> + <Panel header="鏄剧ず鍒�" key="3"> <div className="search-element"> {Source.columnItems.map((item, index) => (<SourceElement key={index} content={item}/>))} </div> - <FieldsComponent - config={config} - type="columns" - tableFields={this.state.tableFields} - updatefield={this.updateconfig} - /> + <FieldsComponent config={config} type="columns"/> </Panel> {/* 娣诲姞鏍囩 */} - <Panel header={this.state.dict['header.menu.tab']} key="4"> + <Panel header="鏍囩椤�" key="4"> <div className="search-element"> {Source.tabItems.map((item, index) => (<SourceElement key={index} content={item}/>))} </div> {configTabs.length > 0 ? <p className="config-btn-title"> <Tooltip placement="topLeft" title="鐐瑰嚮鎸夐挳锛屽彲瀹屾垚鎴栨煡鐪嬫爣绛鹃厤缃俊鎭��"> - <Icon type="question-circle" /> + <QuestionCircleOutlined className="mk-form-tip"/> </Tooltip> - {this.state.dict['header.menu.tab.configurable']} + 鏍囩閰嶇疆 </p> : null } {configTabs.map((item, index) => { @@ -1306,32 +1259,36 @@ <div className="setting"> <Card title={ <div> - {this.state.dict['header.menu.page.configurable']} - <Icon type="redo" style={{marginLeft: '10px'}} title="鍒锋柊鏍囩鍒楄〃" onClick={() => this.reloadTab(true)} /> + 椤甸潰閰嶇疆 + <RedoOutlined style={{marginLeft: '10px'}} title="鍒锋柊鏍囩鍒楄〃" onClick={() => this.reloadTab(true)} /> </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={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> + <Unattended config={config} updateConfig={this.updateconfig}/> + <Versions MenuId={menu.MenuID} open_edition={openEdition} updateConfig={this.refreshConfig}/> + <ReplaceField type="table" config={config} updateConfig={this.updateconfig}/> + <EditComponent type="table" options={['search', 'form', 'action', 'columns']} config={this.state.config} MenuID={this.props.menu.MenuID} thawButtons={this.state.thawButtons} refresh={this.editConfig}/> + <UpdateTable config={config}/> + <Switch className="big" checkedChildren="鍚�" unCheckedChildren="鍋�" checked={this.state.config.enabled} onChange={this.onEnabledChange} /> + <Button type="primary" id="save-config" onClick={this.submitConfig} loading={this.state.menuloading}>淇濆瓨</Button> + <Button onClick={this.cancelConfig}>鍏抽棴</Button> </div> } style={{ width: '100%' }}> <SettingComponent config={config} - MenuID={this.props.menu.MenuID} + MenuID={menu.MenuID} updatesetting={this.updateconfig} /> <SearchComponent config={config} updatesearch={this.updatesearch} /> - <div className="chart-view" style={{position: 'relative'}}> - {/* 瑙嗗浘缁� 鏉冮檺 浼氬憳绛夌骇20+ */} - {this.props.memberLevel >= 20 ? <ChartGroupComponent + {config.charts ? <div className="chart-view" style={{position: 'relative'}}> + {/* 瑙嗗浘缁� 宸插純鐢� */} + <ChartGroupComponent config={config} updatechartgroup={this.updatechartgroup} - /> : null} + /> {config.charts.map(item => { if (!config.expand && chartview !== item.uuid) return '' @@ -1376,13 +1333,27 @@ ) } })} - </div> + </div> : <> + <ActionComponent + type="main" + menu={{ MenuID: this.props.menu.MenuID, MenuName: config.MenuName, MenuNo: config.MenuNo, fstMenuList: this.props.menu.fstMenuList }} + config={config} + tabs={this.state.tabviews} + setSubConfig={(_btn) => this.setSubConfig(_btn, 'button')} + updateaction={this.updateaction} + /> + <ColumnComponent + config={config} + menu={this.props.menu} + updatecolumn={this.updateconfig} + /> + </>} {/* 鏍囩缁� */} <TabsComponent config={config} tabs={this.state.tabviews} setSubConfig={(item) => this.setSubConfig(item, 'tab')} - updatetabs={this.updatetabs} + updatetabs={this.updateconfig} /> </Card> </div> @@ -1395,13 +1366,13 @@ 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['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> + <Button key="save" className="mk-btn mk-green" loading={this.state.menucloseloading} onClick={this.submitConfig}>淇濆瓨</Button>, + <Button key="notsave" className="mk-btn mk-yellow" onClick={this.notsave}>涓嶄繚瀛�</Button>, + <Button key="cancel" onClick={() => { this.setState({closeVisible: false}) }}>鍙栨秷</Button> ]} destroyOnClose > - {this.state.dict['header.menu.config.placeholder']} + 閰嶇疆宸蹭慨鏀癸紝鏄惁淇濆瓨閰嶇疆淇℃伅锛� </Modal> {this.state.loading && <Spin size="large" />} </div> @@ -1409,14 +1380,4 @@ } } -const mapStateToProps = (state) => { - return { - memberLevel: state.memberLevel - } -} - -const mapDispatchToProps = () => { - return {} -} - -export default connect(mapStateToProps, mapDispatchToProps)(ComTableConfig) +export default ComTableConfig -- Gitblit v1.8.0