From 4d6b9f8a2d7b316633e43b489eae9ada949c07b5 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 10 九月 2024 10:18:08 +0800 Subject: [PATCH] Merge branch 'master' into positec --- src/views/tabledesign/index.jsx | 937 +++++++++++++++++++++++++++++++++++----------------------- 1 files changed, 568 insertions(+), 369 deletions(-) diff --git a/src/views/tabledesign/index.jsx b/src/views/tabledesign/index.jsx index 3ebbafb..5e04a17 100644 --- a/src/views/tabledesign/index.jsx +++ b/src/views/tabledesign/index.jsx @@ -4,13 +4,15 @@ import { is, fromJS } from 'immutable' import moment from 'moment' import HTML5Backend from 'react-dnd-html5-backend' -import { ConfigProvider, notification, Modal, Collapse, Card, Switch, Button, Typography } from 'antd' +import { notification, Modal, Collapse, Card, Switch, Button, Typography } from 'antd' import { DoubleLeftOutlined, DoubleRightOutlined } from '@ant-design/icons' +import md5 from 'md5' import Api from '@/api' -import Utils, { setGLOBFuncs } from '@/utils/utils.js' -import antdZhCN from 'antd/es/locale/zh_CN' +import Utils from '@/utils/utils.js' +import { langs } from '@/store/options' import MKEmitter from '@/utils/events.js' +import { getTables, getFuncsAndInters, getOutMessage, getLangTrans, getAllSqls } from '@/utils/utils-custom.js' import SourceElement from '@/templates/zshare/dragsource' import asyncComponent from '@/utils/asyncComponent' import Source from './source' @@ -21,21 +23,25 @@ const { Panel } = Collapse const { confirm } = Modal const { Paragraph } = Typography -const _locale = antdZhCN const MenuForm = asyncComponent(() => import('./menuform')) +const PopView = asyncComponent(() => import('./popview')) +const TableNodes = asyncComponent(() => import('@/menu/tablenodes')) const TableSource = asyncComponent(() => import('./tablesource')) const Header = asyncComponent(() => import('@/menu/header')) const MenuShell = asyncComponent(() => import('@/menu/tableshell')) const BgController = asyncComponent(() => import('@/pc/bgcontroller')) const StyleController = asyncComponent(() => import('@/menu/stylecontroller')) const ReplaceField = asyncComponent(() => import('@/menu/replaceField')) +const Debug = asyncComponent(() => import('@/menu/debug')) const Versions = asyncComponent(() => import('@/menu/versions')) +const Transfer = asyncComponent(() => import('@/menu/transfer')) +const Unattended = asyncComponent(() => import('@/templates/zshare/unattended')) const UrlFieldComponent = asyncComponent(() => import('@/menu/urlfieldcomponent')) const ModalController = asyncComponent(() => import('@/menu/modalconfig/controller')) const TableComponent = asyncComponent(() => import('@/templates/sharecomponent/tablecomponent')) +const PasteBaseTable = asyncComponent(() => import('@/menu/components/share/pastebasetable')) -sessionStorage.setItem('isEditState', 'true') sessionStorage.setItem('appType', '') // 搴旂敤绫诲瀷 document.body.className = '' @@ -49,28 +55,49 @@ menuloading: false, oriConfig: null, config: null, - customComponents: [], comloading: false, - settingshow: true, - modalStatus: false // 寮圭獥鏄惁寮�鍚紝鍒ゆ柇ctrl+s鏄惁鍙敤 + settingshow: sessionStorage.getItem('settingshow') !== 'false', + view: null, + langName: '', + popConfig: null } UNSAFE_componentWillMount() { + if (sessionStorage.getItem('devError') === 'true') { + sessionStorage.clear() + window.history.replaceState(null, null, window.location.href.split('#')[0] + '#/login') + window.location.reload() + return + } + + if (!sessionStorage.getItem('UserID')) { + sessionStorage.removeItem('appType') + this.props.history.replace('/login') + return + } + sessionStorage.setItem('editMenuType', 'menu') // 缂栬緫鑿滃崟绫诲瀷 + window.GLOB.curDate = moment().format('YYYY-MM-DD') window.GLOB.UserComponentMap = new Map() // 缂撳瓨鐢ㄦ埛鑷畾涔夌粍浠� window.GLOB.TabsMap = new Map() // 缂撳瓨鐢ㄦ埛鎿嶄綔鐨勬爣绛鹃〉 window.GLOB.urlFields = [] // url鍙橀噺 window.GLOB.customMenu = null // 淇濆瓨鑿滃崟淇℃伅 + window.GLOB.developing = true try { let param = JSON.parse(window.decodeURIComponent(window.atob(this.props.match.params.param))) + if (param.lang) { + sessionStorage.setItem('lang', param.lang) + } + this.setState({ MenuId: param.MenuID, ParentId: param.ParentId || '', MenuName: param.MenuName || '', MenuNo: param.MenuNo || '', + langName: sessionStorage.getItem('lang') !== 'zh-CN' && langs[sessionStorage.getItem('lang')] ? `锛�${langs[sessionStorage.getItem('lang')]}锛塦 : '' }, () => { this.getMenuParam() }) @@ -88,23 +115,13 @@ } componentDidMount () { - MKEmitter.addListener('modalStatus', this.modalStatus) + if (!sessionStorage.getItem('UserID')) return + MKEmitter.addListener('changePopview', this.initPopview) MKEmitter.addListener('triggerMenuSave', this.triggerMenuSave) - MKEmitter.addListener('updateCustomComponent', this.updateCustomComponent) setTimeout(() => { - if (sessionStorage.getItem('app_custom_components')) { - let list = sessionStorage.getItem('app_custom_components') - list = JSON.parse(list) - - this.setCustomComponent(list) - } else { - this.updateCustomComponent() - } - this.getAppPictures() - this.getPrintTemp() this.getRoleFields() - setGLOBFuncs() + // setGLOBFuncs() }, 1000) document.onkeydown = (event) => { @@ -126,16 +143,32 @@ let _shortcut = `${preKey}+${keyCode}` if (_shortcut === 'ctrl+83') { - if (this.state.modalStatus) { + 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: '璇蜂繚瀛�' + this.state.modalStatus, + message: '璇蜂繚瀛�' + msg, duration: 5 }) return false } let node = document.getElementById('save-modal-config') + if (!node) { + node = document.getElementById('save-pop-config') + } if (!node) { node = document.getElementById('save-config') } @@ -155,168 +188,135 @@ this.setState = () => { return } - MKEmitter.removeListener('modalStatus', this.modalStatus) MKEmitter.removeListener('changePopview', this.initPopview) MKEmitter.removeListener('triggerMenuSave', this.triggerMenuSave) - MKEmitter.removeListener('updateCustomComponent', this.updateCustomComponent) - } - - modalStatus = (val) => { - this.setState({modalStatus: val}) } triggerMenuSave = () => { + if (this.state.view === 'popview') return + this.submitConfig() } - getPrintTemp = () => { - if (!sessionStorage.getItem('printTemps')) { - let _sql = `select ID,Images,PrintTempNO+PrintTempName as PN from sPrintTemplate - where appkey= @appkey@ and Deleted=0 and typechartwo='web_print' - union select ID,Images,a.PrintTempNO+PrintTempName as PN - from (select * from sPrintTemplate where appkey= '' and Deleted=0 and typechartwo='web_print') a - left join (select PrintTempNO from sPrintTemplate where appkey= @appkey@ and Deleted=0 ) b - on a.PrintTempNO=b.PrintTempNO - left join (select Srcid from sPrintTemplate_Log where appkey='' and apicode= @appkey@ and Deleted=0 ) c - on a.ID=c.Srcid where b.PrintTempNO is null and c.Srcid is null` - - let param = { - func: 'sPC_Get_SelectedList', - LText: Utils.formatOptions(_sql), - obj_name: 'data', - arr_field: 'PN,ID,Images' - } - - param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') - param.secretkey = Utils.encrypt(param.LText, param.timestamp) - - param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp) // 浜戠鏁版嵁楠岃瘉 - - Api.getSystemConfig(param).then(res => { - if (res.status) { - let temps = res.data.map(temp => { - return { - value: temp.ID, - text: temp.PN - } - }) - - sessionStorage.setItem('printTemps', JSON.stringify(temps)) - } else { - notification.warning({ - top: 92, - message: res.message, - duration: 5 - }) - } - }) - } - } - - getAppPictures = () => { - if (sessionStorage.getItem('app_videos') || sessionStorage.getItem('app_pictures')) return - - Api.getSystemConfig({ - func: 's_url_db_adduptdel', - PageIndex: 0, // 0 浠h〃鍏ㄩ儴 - PageSize: 0, // 0 浠h〃鍏ㄩ儴 - typecharone: 'image', - type: 'search' - }).then(res => { - if (res.status) { - sessionStorage.setItem('app_pictures', JSON.stringify(res.data || [])) - } - - Api.getSystemConfig({ - func: 's_url_db_adduptdel', - PageIndex: 0, // 0 浠h〃鍏ㄩ儴 - PageSize: 0, // 0 浠h〃鍏ㄩ儴 - typecharone: 'video', - type: 'search' - }).then(res => { - if (res.status) { - sessionStorage.setItem('app_videos', JSON.stringify(res.data || [])) - } - }) - Api.getSystemConfig({ - func: 's_url_db_adduptdel', - PageIndex: 0, // 0 浠h〃鍏ㄩ儴 - PageSize: 0, // 0 浠h〃鍏ㄩ儴 - typecharone: 'color', - type: 'search' - }).then(res => { - if (res.status) { - sessionStorage.setItem('app_colors', JSON.stringify(res.data || [])) - } - }) - }) - } - - updateCustomComponent = () => { - Api.getSystemConfig({ - func: 's_get_custom_components', - typename: '', - typecharone: '' - }).then(res => { - if (!res.status) { - notification.warning({ - top: 92, - message: res.message, - duration: 5 - }) - } else if (res.cus_list) { - sessionStorage.setItem('app_custom_components', JSON.stringify(res.cus_list)) - this.setCustomComponent(res.cus_list) - } - }) - } - - setCustomComponent = (cus_list) => { - let coms = [] - - cus_list.forEach(item => { - let config = '' - - try { - config = JSON.parse(window.decodeURIComponent(window.atob(item.long_param))) - } catch (e) { - console.warn('Parse Failure') - config = '' - } - - if (!config || !item.c_name) return - - window.GLOB.UserComponentMap.set(item.c_id, item.c_name) - coms.push({ - uuid: item.c_id, - type: 'menu', - title: item.c_name, - url: item.images, - component: config.type, - subtype: config.subtype, - config - }) - }) - this.setState({customComponents: coms}) - } - initPopview = (card, btn) => { - const { oriConfig, config } = this.state + const { config } = this.state - if (!is(fromJS(oriConfig), fromJS(config))) { - notification.warning({ - top: 92, - message: '閰嶇疆宸蹭慨鏀癸紝璇蜂繚瀛橈紒', - duration: 5 - }) + if (!this.checkBase()) { return } let _btn = fromJS(btn).toJS() - _btn.MenuName = config.MenuName + '-' + card.name + '-' + btn.label - _btn.ParentMenuID = config.uuid - this.props.history.push('/popdesign/' + window.btoa(window.encodeURIComponent((JSON.stringify(_btn))))) + if (_btn.config) { + _btn.config.uuid = _btn.uuid + _btn.config.MenuID = _btn.uuid + _btn.config.ParentId = card.uuid + _btn.config.MenuName = _btn.label + _btn.config.components = _btn.config.components || [] + _btn.config.components.forEach(item => { + if (item.type === 'tabs') { + item.subtabs.forEach(tab => { + tab.components[0].cols = tab.components[0].cols.map(col => { + if (col.type === 'action') { + col.type = 'custom' + } + return col + }) + }) + } else if (item.cols) { + item.cols = item.cols.map(col => { + if (col.type === 'action') { + col.type = 'custom' + } + return col + }) + } + }) + } else { + _btn.config = { + uuid: _btn.uuid, + MenuID: _btn.uuid, + ParentId: card.uuid, + enabled: false, + MenuName: _btn.label, + tables: config.tables || [], + Template: 'BaseTable', + components: [{ + uuid: Utils.getuuid(), + type: 'table', + width: 24, + name: '涓昏〃', + subtype: 'basetable', + isNew: true + }], + viewType: 'popview', + style: { backgroundColor: '#ffffff', backgroundImage: '', paddingTop: '16px', paddingBottom: '40px', paddingLeft: '16px', paddingRight: '16px' } + } + } + + this.setState({view: 'popview', popConfig: _btn}) + } + + submitPopConfig = (btnconfig) => { + let config = fromJS(this.state.config).toJS() + + let loopCol = (cols) => { + cols.forEach(col => { + if (col.type === 'colspan') { + loopCol(col.subcols) + } else if (col.type === 'custom') { + col.elements.forEach(cell => { + if (cell.eleType !== 'button') return + if (cell.OpenType === 'popview' && cell.uuid === btnconfig.uuid) { + cell.config = btnconfig + } + }) + } + }) + } + + config.components.forEach(item => { + if (item.type === 'tabs') { + item.subtabs.forEach(tab => { + if (btnconfig.ParentId !== tab.components[0].uuid) return + + tab.components[0].action.forEach(btn => { + if (btn.OpenType === 'popview' && btn.uuid === btnconfig.uuid) { + btn.config = btnconfig + } + }) + + loopCol(tab.components[0].cols) + + tab.components[0].$tables = getTables(tab.components[0]) + }) + } else if (item.uuid === btnconfig.ParentId) { + item.action.forEach(btn => { + if (btn.OpenType === 'popview' && btn.uuid === btnconfig.uuid) { + btn.config = btnconfig + } + }) + + loopCol(item.cols) + + item.$tables = getTables(item) + } + }) + + this.setState({ config }, () => { + this.submitConfig() + }) + } + + closePop = () => { + const { config } = this.state + + sessionStorage.setItem('editMenuType', 'menu') + + window.GLOB.urlFields = config.urlFields || [] + window.GLOB.customMenu = config + + this.setState({view: '', popConfig: null}) } closeView = () => { @@ -349,7 +349,7 @@ MenuID: MenuId } - Api.getSystemConfig(param).then(result => { + Api.getCloudConfig(param).then(result => { if (result.status) { let config = null @@ -383,23 +383,55 @@ } ], viewType: 'menu', - style: { - backgroundColor: '#ffffff', backgroundImage: '', - paddingTop: '16px', paddingBottom: '80px', paddingLeft: '16px', paddingRight: '16px' - }, + style: { backgroundColor: '#ffffff', paddingTop: '16px', paddingBottom: '80px', paddingLeft: '16px', paddingRight: '16px'}, } } else { + if (config.Template === 'CommonTable' && !config.components) { + let urlparam = JSON.parse(window.decodeURIComponent(window.atob(this.props.match.params.param))) + urlparam.type = 'CommonTable' + if (urlparam.PageParam) { + urlparam.PageParam.Template = 'CommonTable' + } + urlparam = window.btoa(window.encodeURIComponent(JSON.stringify(urlparam))) + + let url = `#/basedesign/${urlparam}` + + window.history.replaceState(null, null, window.location.href.split('#')[0] + url) + window.location.reload() + return + } config.uuid = MenuId config.MenuID = MenuId config.Template = 'BaseTable' + config.components.forEach(item => { + if (item.type === 'tabs') { + item.subtabs.forEach(tab => { + tab.components[0].name = tab.label + tab.components[0].cols = tab.components[0].cols.map(col => { + if (col.type === 'action') { + col.type = 'custom' + } + return col + }) + }) + } else { + item.cols = item.cols.map(col => { + if (col.type === 'action') { + col.type = 'custom' + } + return col + }) + item.name = '涓昏〃' + } + }) } config.open_edition = result.open_edition || '' window.GLOB.urlFields = config.urlFields || [] this.setState({ - oriConfig: config, - config: fromJS(config).toJS() + oriConfig: config.components[0].isNew ? {} : fromJS(config).toJS(), + config: config }) window.GLOB.customMenu = config } else { @@ -412,48 +444,82 @@ }) } - getMenuMessage = (delButtons) => { + getMenuMessage = (tbs) => { const { config } = this.state let buttons = [] let _sort = 1 - let traversal = (components) => { - components.forEach(item => { - if (item.type === 'tabs') { - item.subtabs.forEach(tab => { - traversal(tab.components) + config.components.forEach(item => { + if (item.type === 'tabs') { + item.subtabs.forEach(tab => { + if (tab.components[0].$tables) { + tbs.push(...tab.components[0].$tables) + } + + if (tab.permission !== 'true' || tab.hide === 'true') return + + buttons.push(`select '${tab.components[0].uuid}' as menuid, '${tab.label}' as menuname, '${_sort * 10}' as Sort, '${config.uuid}' as parentid, 40 as Type`) + _sort++ + + let _s = 1 + + tab.components[0].action.forEach(btn => { + if (btn.hidden === 'true' || btn.permission === 'false') return + + buttons.push(`select '${btn.uuid}' as menuid, '${btn.label}' as menuname, '${_s * 10}' as Sort, '${tab.components[0].uuid}' as parentid, 60 as Type`) + _s++ }) - } else { - item.action && item.action.forEach(btn => { - if (btn.hidden === 'true') { - delButtons.push(btn.uuid) - return - } - buttons.push(`select '${btn.uuid}' as menuid, '${item.name + '-' + btn.label}' as menuname, '${_sort * 10}' as Sort`) - _sort++ - }) - item.cols && item.cols.forEach(col => { - if (col.type !== 'action') return - col.elements.forEach(btn => { - if (btn.hidden === 'true') { - delButtons.push(btn.uuid) - return + + let loopCol = (cols) => { + cols.forEach(col => { + if (col.type === 'colspan') { + loopCol(col.subcols) + } else if (col.type === 'custom') { + col.elements.forEach(cell => { + if (cell.eleType !== 'button' || cell.hidden === 'true' || cell.permission === 'false') return + buttons.push(`select '${cell.uuid}' as menuid, '${cell.label}' as menuname, '${_s * 10}' as Sort, '${tab.components[0].uuid}' as parentid, 60 as Type`) + _s++ + }) } - buttons.push(`select '${btn.uuid}' as menuid, '${item.name + '-' + btn.label}' as menuname, '${_sort * 10}' as Sort`) - _sort++ }) + } + + loopCol(tab.components[0].cols) + }) + } else { + if (item.$tables) { + tbs.push(...item.$tables) + } + item.action.forEach(btn => { + if (btn.hidden === 'true' || btn.permission === 'false') return + + buttons.push(`select '${btn.uuid}' as menuid, '${btn.label}' as menuname, '${_sort * 10}' as Sort, '${config.uuid}' as parentid, 40 as Type`) + _sort++ + }) + + let loopCol = (cols) => { + cols.forEach(col => { + if (col.type === 'colspan') { + loopCol(col.subcols) + } else if (col.type === 'custom') { + col.elements.forEach(cell => { + if (cell.eleType !== 'button' || cell.hidden === 'true' || cell.permission === 'false') return + buttons.push(`select '${cell.uuid}' as menuid, '${cell.label}' as menuname, '${_sort * 10}' as Sort, '${config.uuid}' as parentid, 40 as Type`) + _sort++ + }) + } }) } - }) - } - traversal(config.components) + loopCol(item.cols) + } + }) return buttons } - submitConfig = () => { - let config = fromJS(this.state.config).toJS() + checkBase = () => { + const { config } = this.state if (!config.MenuName || !config.MenuNo || !config.fstMenuId || !config.parentId) { notification.warning({ @@ -461,7 +527,30 @@ message: '璇峰畬鍠勮彍鍗曞熀鏈俊鎭紒', duration: 5 }) + return false + } + return true + } + + submitConfig = () => { + let config = fromJS(this.state.config).toJS() + + if (!this.checkBase()) { return + } else if (this.checklog()) { + if (sessionStorage.getItem('langList') && !config.trans) { + + } else if (window.backend && config.enabled && !config.allSqls) { + + } else { + notification.success({ + top: 92, + message: '褰撳墠閰嶇疆鏈慨鏀癸紝鏃犻渶淇濆瓨銆�', + duration: 5 + }) + MKEmitter.emit('completeSave') + return + } } this.setState({ @@ -469,9 +558,98 @@ }) setTimeout(() => { - if (config.enabled && this.verifyConfig()) { + let _pass = this.verifyConfig(config) + + if (config.enabled && !_pass) { config.enabled = false + config.force = true + } else if (!config.enabled && config.force && _pass) { + config.enabled = true + delete config.force } + + let long_data = '' + if (window.backend && config.enabled) { + let sqls = getAllSqls(config) + let _t = moment().format('YYYYMMDDHHmmss') + let getguid = () => { + let uuid = '' + for (let i = 0; i < 18; i++) { + uuid += String.fromCharCode(Math.floor(Math.random() * 26) + 65) + } + return uuid + } + + long_data = [] + let oriIds = {} + if (config.allSqls) { + config.allSqls.forEach(item => { + if (!item.md5) return + oriIds[item.uuid + item.md5] = item.v_id + }) + } + + config.allSqls = sqls.map(item => { + let v_id = _t + getguid() + + if (oriIds[item.uuid + item.md5]) { + v_id = oriIds[item.uuid + item.md5] + } + + long_data.push(`${md5(window.GLOB.appkey + v_id)},${item.uuid},${v_id},${window.btoa(window.encodeURIComponent(item.LText))}`) + + return { + uuid: item.uuid, + v_id: v_id, + type: item.type, + reps: item.reps, + md5: item.md5 || '', + luser: item.luser === true + } + }) + + long_data = long_data.join(';') + } else { + delete config.allSqls + } + + let tbs = [] + let btns = this.getMenuMessage(tbs) + let arr = [] + tbs = tbs.filter(tb => { + let _tb = tb.toLowerCase() + + if (arr.includes(_tb)) return false + arr.push(_tb) + + return true + }) + tbs.sort() + if (tbs.length && sessionStorage.getItem('mk_tb_names')) { + let names = sessionStorage.getItem('mk_tb_names') + tbs = tbs.filter(tb => names.indexOf(',' + tb.toLowerCase() + ',') > -1) + } + tbs = tbs.map(tb => `'${tb}'`).join(';') + + let key = md5(config.uuid + tbs.toLowerCase()) + let url = '' + + if (config.tbkey === key) { + key = '' + } else { + let urlparam = JSON.parse(window.decodeURIComponent(window.atob(this.props.match.params.param))) + urlparam.type = 'admin' + urlparam.MenuType = 'BaseTable' + urlparam.lang = sessionStorage.getItem('lang') + + url = window.btoa(window.encodeURIComponent(JSON.stringify(urlparam))) + config.tbkey = key + } + + let interfaces = getFuncsAndInters(config) + let msg = getOutMessage(config) + let urlFields = config.urlFields ? config.urlFields.join(',') : '' + let langSql = getLangTrans(config) let param = { func: 'sPC_TrdMenu_AddUpt', @@ -483,16 +661,21 @@ EasyCode: config.easyCode || '', Template: 'BaseTable', MenuName: config.MenuName || '', - PageParam: JSON.stringify({Template: 'BaseTable', OpenType: config.OpenType || 'newtab', hidden: config.hidden || 'false'}), - LongParam: window.btoa(window.encodeURIComponent(JSON.stringify(config))), + PageParam: JSON.stringify({Template: 'BaseTable', OpenType: config.OpenType || 'newtab', hidden: config.hidden || 'false', menuColor: config.menuColor || '', interfaces, msg, urlFields}), open_edition: config.open_edition, - LText: '', - LTexttb: '' + long_data: long_data, + debug_md5: key, + debug_url: url, + debug_list: window.btoa(tbs), + LongParam: window.btoa(window.encodeURIComponent(JSON.stringify(config))) } - param.LText = Utils.formatOptions(param.LText) + if (langSql) { + param.lang_translation = window.btoa(window.encodeURIComponent(langSql)) + } + param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') - param.secretkey = Utils.encrypt(param.LText, param.timestamp) + param.secretkey = Utils.encrypt('', param.timestamp) let btnParam = { // 娣诲姞鑿滃崟鎸夐挳 func: 'sPC_Button_AddUpt', @@ -500,109 +683,74 @@ ParentID: config.uuid, MenuNo: config.MenuNo, Template: 'BaseTable', - PageParam: '', - LongParam: '', - LText: [] + button_proc_edition: 'Y', + exec_type: 'x' } - let delButtons = [] - - btnParam.LText = this.getMenuMessage(delButtons) - btnParam.LText = btnParam.LText.join(' union all ') - - btnParam.LText = Utils.formatOptions(btnParam.LText) + btnParam.LText = btns.join(' union all ') + btnParam.LText = Utils.formatOptions(btnParam.LText, 'x') btnParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') - btnParam.secretkey = Utils.encrypt(btnParam.LText, btnParam.timestamp) + btnParam.secretkey = Utils.encrypt('', btnParam.timestamp) new Promise(resolve => { - resolve(true) - }).then(res => { // 鎸夐挳鍒犻櫎 - if (delButtons.length === 0) { - return { - status: true - } - } else { - let _param = { - func: 'sPC_MainMenu_Del', - MenuID: delButtons.join(',') - } - return Api.getSystemConfig(_param) - } - }).then(res => { // 椤甸潰淇濆瓨 - if (!res) return - - if (res.status) { - return Api.getSystemConfig(param) - } else { - notification.warning({ - top: 92, - message: res.message, - duration: 5 - }) - return false - } - }).then(res => { // 椤甸潰鎸夐挳鍏崇郴淇濆瓨 - if (!res) return - - if (res.status) { - let ori = this.state.oriConfig - if (config.MenuName !== ori.MenuName || config.MenuNo !== ori.MenuNo || config.parentId !== ori.parentId) { - localStorage.setItem('menuUpdate', new Date().getTime()) - } - config.open_edition = res.open_edition || '' - this.setState({ - config, - oriConfig: fromJS(config).toJS(), - }) - - if (btnParam.LText) { - return Api.getSystemConfig(btnParam) - } else { - return { - status: true - } - } - } else { - notification.warning({ - top: 92, - message: res.message, - duration: 5 - }) - return false - } - }).then(res => { // 鎸夐挳澶嶅埗 - if (!res) return - if (!res.status) { - notification.warning({ - top: 92, - message: res.message, - duration: 5 - }) - return false - } + Api.getCloudConfig(param).then(res => { + resolve(res) + }, this.netError) }).then(res => { - if (res && res.status) { - this.setState({ - menuloading: false - }) + if (!res || !res.status) return res + + localStorage.setItem('menuUpdate', new Date().getTime() + ',' + config.uuid) + config.open_edition = res.open_edition || '' + + this.setState({ + config, + oriConfig: fromJS(config).toJS(), + }) + + return Api.getCloudConfig(btnParam) + }).then(res => { + this.setState({ + menuloading: false + }) + + if (!res) return + + if (res.status) { notification.success({ top: 92, message: '淇濆瓨鎴愬姛', duration: 2 }) } else { - this.setState({ - menuloading: false + Modal.warning({ + width: 400, + title: res.message, + okText: '鐭ラ亾浜�' }) } MKEmitter.emit('completeSave') - }) + }, this.netError) }, 300 + (+sessionStorage.getItem('mkDelay'))) + } + + netError = (error) => { + this.setState({ + menuloading: false + }) + + if (!error) { + notification.warning({ + top: 92, + message: '淇濆瓨澶辫触锛岃妫�鏌ョ綉缁滄槸鍚︽甯搞��', + duration: 5 + }) + } + MKEmitter.emit('completeSave') } getRoleFields = () => { if (sessionStorage.getItem('sysRoles')) return - Api.getSystemConfig({func: 'sPC_Get_Roles_sModular'}).then(res => { + Api.getCloudConfig({func: 'sPC_Get_Roles_sModular'}).then(res => { if (res.status) { let _permFuncField = [] let _sysRoles = [] @@ -635,45 +783,56 @@ onEnabledChange = () => { const { config } = this.state - if (!config || (!config.enabled && this.verifyConfig(true))) { - return - } + let _config = {...config, enabled: !config.enabled} - this.setState({ - config: {...config, enabled: !config.enabled} - }) - } + delete _config.force - verifyConfig = (show) => { - const { config } = this.state - let error = '' - - let check = (components) => { - components.forEach(item => { - if (error) return - - if (item.type === 'tabs') { - item.subtabs.forEach(tab => { - check(tab.components) - }) - return - } else if (item.type === 'group') { - check(item.components) - return - } else if (!item.errors || item.errors.length === 0) { - return - } - - item.errors.forEach(err => { - if (err.level !== 0 || error) return - error = `缁勪欢銆�${item.name}銆�${err.detail}` - }) + if (!_config.enabled) { + this.setState({ + config: _config + }) + } else if (this.verifyConfig(_config)) { + this.setState({ + config: _config }) } + } - check(config.components) + verifyConfig = (config) => { + let error = '' - if (show && error) { + config.components.forEach(item => { + if (error) return + + if (item.type === 'tabs') { + item.subtabs.forEach(tab => { + if (!tab.components[0].errors || tab.components[0].errors.length === 0 || error) return + tab.components[0].errors.forEach(err => { + if (err.level !== 0 || error) return + error = `瀛愯〃銆�${tab.label}銆�${err.detail}` + }) + }) + } else { + item.errors.forEach(err => { + if (err.level !== 0 || error) return + error = `涓昏〃 ${err.detail}` + }) + } + }) + + if (!error && config.autoMatic && config.autoMatic.enable === 'true') { + let pass = false + config.components[0].action.forEach(item => { + if (item.uuid === config.autoMatic.action && (['pop', 'prompt', 'exec'].includes(item.OpenType) || (item.OpenType === 'funcbutton' && item.funcType === 'print'))) { + pass = true + } + }) + if (!pass) { + error = '鏃犱汉鍊煎畧璁剧疆鏃犳晥锛�' + } + } + + if (config.enabled && error) { notification.warning({ top: 92, message: error, @@ -681,7 +840,7 @@ }) } - return error + return error === '' } // 鏇存柊閰嶇疆淇℃伅 @@ -707,30 +866,59 @@ insert = (item) => { let config = fromJS(this.state.config).toJS() - config.components.push(item) + let tabs = { + uuid: Utils.getuuid(), + type: 'tabs', + subtype: 'tabletabs', + width: 24, + setting: {}, + style: {}, + subtabs: [ + { uuid: Utils.getuuid(), label: item.name || '瀛愯〃1', icon: '', components: [item] }, + ] + } + + config.components.push(tabs) this.setState({config}) window.GLOB.customMenu = config - - notification.success({ - top: 92, - message: '绮樿创鎴愬姛锛�', - duration: 2 - }) } changeSetting = () => { this.setState({settingshow: !this.state.settingshow}) + sessionStorage.setItem('settingshow', '' + !this.state.settingshow) + } + + checklog = () => { + const { oriConfig, config } = this.state + + return is(fromJS(oriConfig), fromJS(config)) + } + + updateLogConfig = (config) => { + config.fstMenuId = this.state.config.fstMenuId || config.fstMenuId || '' + config.parentId = this.state.config.parentId || config.parentId || '' + config.open_edition = this.state.config.open_edition || '' + + this.setState({ + config: null + }, () => { + this.setState({ + config: config + }) + }) + + window.GLOB.customMenu = config } render () { - const { activeKey, comloading, MenuId, config, settingshow, ParentId, menuloading } = this.state + const { view, activeKey, comloading, MenuId, config, settingshow, ParentId, menuloading, langName } = this.state return ( - <ConfigProvider locale={_locale}> - <div className="pc-table-view"> - <Header /> - <DndProvider backend={HTML5Backend}> + <> + <Header menuName={config ? config.MenuName + langName : ''}/> + <DndProvider backend={HTML5Backend}> + {view !== 'popview' ? <div className="pc-table-view"> <div className="menu-body"> <div className={'menu-setting ' + (!settingshow ? 'hidden' : '')}> <div className="draw"> @@ -739,22 +927,23 @@ <Collapse accordion activeKey={activeKey} bordered={false} onChange={(key) => this.setState({activeKey: key})}> {/* 鍩烘湰淇℃伅 */} <Panel header="鍩烘湰淇℃伅" key="basedata"> - {/* 鑿滃崟淇℃伅 */} - {config ? <MenuForm - config={config} - MenuId={MenuId} - parentId={ParentId} - MenuName={config.MenuName} - MenuNo={config.MenuNo} - updateConfig={this.updateConfig} - /> : null} - {config ? <UrlFieldComponent - config={config} - updateConfig={this.updateConfig} - /> : null} - {/* 琛ㄥ悕娣诲姞 */} - {config ? <TableComponent config={config} updatetable={this.updateConfig}/> : null} - {config ? <Paragraph style={{padding: '15px 0px 0px 18px'}} copyable={{ text: MenuId }}>鑿滃崟ID</Paragraph> : null} + {config ? <> + <MenuForm + config={config} + MenuId={MenuId} + parentId={ParentId} + MenuName={config.MenuName} + MenuNo={config.MenuNo} + updateConfig={this.updateConfig} + /> + <UrlFieldComponent + config={config} + updateConfig={this.updateConfig} + /> + {/* 琛ㄥ悕娣诲姞 */} + <TableComponent config={config} updatetable={this.updateConfig}/> + <Paragraph style={{padding: '15px 0px 0px 18px'}} copyable={{ text: MenuId }}>鑿滃崟ID</Paragraph> + </> : null} </Panel> <Panel header="鎼滅储" key="search"> {Source.searchItems.map((item, index) => (<SourceElement key={index} content={item}/>))} @@ -774,26 +963,36 @@ </Collapse> </div> <div className={'menu-view' + (menuloading ? ' saving' : '')}> - <Card title={ - <div style={{paddingLeft: '15px'}}> {config && config.MenuName} </div> - } bordered={false} extra={ - <div> - <Versions MenuId={MenuId} open_edition={config ? config.open_edition : ''}/> + <Card bordered={false} extra={ + <div className="mk-opeartion-list"> + {/* <Dropdown overlay={ + <div className="mk-button-dropdown-wrap"> + <ReplaceField type="custom" config={config} updateConfig={this.resetConfig}/> + </div> + } trigger={['click']} placement="bottomCenter"> + <Button className="mk-button-more">鏇村<DownOutlined/></Button> + </Dropdown> */} + {config ? <Debug config={config}/> : null} + {config ? <Transfer config={config}/> : null} + {config ? <Unattended config={config} updateConfig={this.updateConfig}/> : null} + {config ? <Versions MenuId={MenuId} Template="BaseTable" checklog={this.checklog} updateConfig={this.updateLogConfig}/> : null} + <TableNodes config={config} /> <ReplaceField type="custom" config={config} updateConfig={this.resetConfig}/> - <Switch className="big" checkedChildren="鍚�" unCheckedChildren="鍋�" checked={config && config.enabled} onChange={this.onEnabledChange} /> + <PasteBaseTable type="page" insert={this.insert}/> + {config ? <Switch className="big" checkedChildren="鍚�" unCheckedChildren="鍋�" checked={config.enabled} onChange={this.onEnabledChange} /> : null} <Button type="primary" id="save-config" onClick={this.submitConfig} loading={menuloading}>淇濆瓨</Button> - <Button type="default" onClick={this.closeView}>鍏抽棴</Button> + <Button type="default" disabled={menuloading} onClick={this.closeView}>鍏抽棴</Button> </div> } style={{ width: '100%' }}> {config && !comloading ? <MenuShell menu={config} handleList={this.updateConfig} /> : null} </Card> </div> </div> - </DndProvider> - <StyleController /> - <ModalController /> - </div> - </ConfigProvider> + </div> : <PopView btn={this.state.popConfig} save={this.submitPopConfig} cancel={this.closePop}/>} + </DndProvider> + <StyleController /> + <ModalController /> + </> ) } } -- Gitblit v1.8.0