From 31ec63f0419895876cbaba99637a884a32d33d0d Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期三, 01 九月 2021 10:31:45 +0800 Subject: [PATCH] 2021-09-01 --- src/templates/formtabconfig/index.jsx | 808 +++++++++++++++++++++++++-------------------------------- 1 files changed, 354 insertions(+), 454 deletions(-) diff --git a/src/templates/formtabconfig/index.jsx b/src/templates/formtabconfig/index.jsx index cf0047c..e2aacac 100644 --- a/src/templates/formtabconfig/index.jsx +++ b/src/templates/formtabconfig/index.jsx @@ -8,43 +8,44 @@ import { Button, Card, Modal, Collapse, notification, Spin, Select, List, Icon, Empty, Switch, Tooltip } from 'antd' import Api from '@/api' -import zhCN from '@/locales/zh-CN/comtable.js' -import enUS from '@/locales/en-US/comtable.js' -import Utils from '@/utils/utils.js' +import zhCN from '@/locales/zh-CN/model.js' +import enUS from '@/locales/en-US/model.js' +import Utils, { FuncUtils } from '@/utils/utils.js' import { getModalForm, getActionForm } from '@/templates/zshare/formconfig' import { queryTableSql } from '@/utils/option.js' -import ModalForm from '@/templates/zshare/modalform' +import TabsComponent from '@/templates/sharecomponent/tabscomponent' + +import PasteForm from '@/templates/zshare/pasteform' import ActionForm from './actionform' import SettingForm from './settingform' import DragElement from './dragelement' import GroupForm from './groupform' -import TabForm from '@/templates/zshare/tabform' import EditCard from '@/templates/zshare/editcard' -import VerifyCard from '@/templates/zshare/verifycard' + import MenuForm from '@/templates/zshare/menuform' -import TabDragElement from '@/templates/zshare/tabdragelement' -import SourceElement from '@/templates/zshare/dragelement/source' -import CreateFunc from '@/templates/zshare/createfunc' +import SourceElement from '@/templates/zshare/dragsource' +import asyncComponent from '@/utils/asyncComponent' import Source from './source' import './index.scss' const { Panel } = Collapse const { Option } = Select const { confirm } = Modal -const CommonDict = (!localStorage.getItem('lang') || localStorage.getItem('lang') === 'zh-CN') ? zhCN : enUS +const ModalForm = asyncComponent(() => import('@/templates/zshare/modalform')) +const CreateFunc = asyncComponent(() => import('@/templates/zshare/createfunc')) +const VerifyCard = asyncComponent(() => import('@/templates/zshare/verifycard')) class ComTableConfig extends Component { static propTpyes = { menu: PropTypes.any, - optionLibs: PropTypes.any, btnTab: PropTypes.object, config: PropTypes.any, handleView: PropTypes.func } state = { - dict: CommonDict, // 瀛楀吀 + dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, // 瀛楀吀 config: null, // 椤甸潰閰嶇疆 modaltype: '', // 妯℃�佹绫诲瀷锛屾帶鍒舵ā鎬佹鏄剧ず tableVisible: false, // 鏁版嵁琛ㄥ瓧娈垫ā鎬佹 @@ -66,7 +67,10 @@ profileVisible: false, // 楠岃瘉淇℃伅妯℃�佹 editgroup: null, // 褰撳墠缂栬緫缁� groupVisible: false, // 缂栬緫缁勬ā鎬佹 - optionLibs: null // 鑷畾涔変笅鎷夐�夐」搴� + activeKey: '0', // 榛樿灞曞紑鍩烘湰淇℃伅 + pasteVisible: false, // 绮樿创妯℃�佹 + sqlVerifing: false, // sql楠岃瘉 + openEdition: '' // 缂栬緫鐗堟湰鏍囪锛岄槻姝㈠浜烘搷浣� } /** @@ -75,7 +79,7 @@ * 2銆佽缃搷浣滅被鍨嬨�佸師濮嬭彍鍗曚俊鎭紙姣忔淇濆瓨鍚庨噸缃級銆佸凡浣跨敤琛ㄥ強鍩烘湰淇℃伅琛ㄥ崟 */ UNSAFE_componentWillMount () { - const { menu, btnTab, config, optionLibs } = this.props + const { menu, btnTab, config } = this.props let _config = '' let columns = [] @@ -99,33 +103,43 @@ if (menu && menu.LongParam && menu.LongParam.setting) { _config.setting.primaryKey = menu.LongParam.setting.primaryKey } + } - _config.groups.forEach(group => { - group.sublist.forEach(item => { - if ( - (item.type === 'select' || item.type === 'multiselect' || item.type === 'link') && - item.resourceType === '0' && - item.options && item.options.length > 0 - ) { - optionLibs.set(btnTab.uuid + item.uuid, { - uuid: btnTab.uuid + item.uuid, - label: item.label, - parname: btnTab.label, - type: 'Modal', - options: item.options - }) - } - }) + 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 (menu && menu.LongParam && menu.LongParam.columns) { columns = menu.LongParam.columns } + // 閰嶇疆榛樿鍊硷紝鍏煎 + _config.Template = 'FormTab' + _config.action = _config.action.map(item => { + if (item.intertype === 'inner' && !item.innerFunc) { + item.intertype = 'system' + } + return item + }) + this.setState({ config: _config, - optionLibs: optionLibs, + activeKey: btnTab.activeKey || '0', + openEdition: btnTab.open_edition || '', columns: columns, originMenu: JSON.parse(JSON.stringify(_config)), selectedTables: _config.tables, @@ -133,7 +147,7 @@ { type: 'text', key: 'menuName', - label: this.state.dict['header.menu.menuName'], + label: this.state.dict['model.menu'] + this.state.dict['model.name'], initVal: menu.MenuName, readonly: true }, @@ -163,8 +177,10 @@ } param.LText = Utils.formatOptions(param.LText) - param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' + 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) { @@ -175,7 +191,7 @@ notification.warning({ top: 92, message: res.message, - duration: 10 + duration: 5 }) } }) @@ -237,7 +253,7 @@ notification.warning({ top: 92, message: res.message, - duration: 10 + duration: 5 }) } }) @@ -264,7 +280,7 @@ notification.warning({ top: 92, message: res.message, - duration: 10 + duration: 5 }) } }) @@ -313,7 +329,7 @@ notification.warning({ top: 92, message: res.message, - duration: 10 + duration: 5 }) } }) @@ -325,7 +341,6 @@ let _tabview = menu ? menu.LongParam.Template : '' let param = { editMenu: menu, - optionLibs: this.state.optionLibs, editTab: null, tabConfig: null, editSubTab: null, @@ -343,15 +358,7 @@ handleList = (type, list, card, groupId, elementId) => { const { config } = this.state - if (type === 'tabs') { // 鏍囩椤佃皟鏁撮『搴忔垨娣诲姞鍏冪礌 - if (list.length > config[card.groupId].length) { - list = list.filter(item => !item.origin) - - this.handleTab(card) - } - - this.setState({config: {...config, [card.groupId]: list}}) - } else if (type === 'action') { + if (type === 'action') { if (list.length > config.action.length) { this.handleAction(card) @@ -420,6 +427,7 @@ const { menu } = this.props const { config } = this.state let _inputfields = [] + let _tabfields = [] let _linkableFields = [] let _linksupFields = [{ value: '', @@ -429,12 +437,12 @@ // 璁剧疆涓嬫媺鑿滃崟鍙叧鑱斿瓧娈� config.groups.forEach(group => { - let sublist = group.sublist.filter(item => item.type === 'text' || item.type === 'number') - _inputfields = [..._inputfields, ...sublist] - - let suplist = group.sublist.filter(item => item.type === 'select' || item.type === 'link') - _formfields = [..._formfields, ...suplist] + _formfields = [..._formfields, ...group.sublist] }) + + _inputfields = _formfields.filter(item => item.type === 'text' || item.type === 'number' || item.type === 'textarea' || item.type === 'color') + _tabfields = _formfields.filter(item => card.field !== item.field && item.hidden !== 'true' && ['text', 'number', 'select', 'link'].includes(item.type)) + _tabfields.unshift({field: '', text: '鍘熻〃鍗�'}) if (card.linkSubField && card.linkSubField.length > 0) { let fields = _inputfields.map(item => item.field) @@ -445,6 +453,7 @@ uniq.set(card.field, true) _formfields.forEach(item => { + if (item.type !== 'select' && item.type !== 'link') return if (item.field && !uniq.has(item.field)) { uniq.set(item.field, true) @@ -472,150 +481,42 @@ }) } - let roleList = [] - if (menu.roleList && menu.roleList.length > 0) { - roleList = menu.roleList.map(role => { - return { - uuid: role.uuid, - field: role.value, - label: role.text - } - }) - } - this.setState({ modaltype: 'search', card: card, - formlist: getModalForm(card, _inputfields, _linkableFields, _linksupFields, false, roleList) + formlist: getModalForm(card, _inputfields, _tabfields, _linkableFields, _linksupFields, false).map(item => { + if (item.key === 'type') { + item.options = item.options.filter(option => !['switch', 'checkbox', 'radio', 'checkcard', 'hint'].includes(option.value)) + } + return item + }) }) } handleAction = (card) => { - let ableField = this.props.permFuncField.join(', ') + let usefulFields = sessionStorage.getItem('permFuncField') + if (usefulFields) { + try { + usefulFields = JSON.parse(usefulFields) + } catch (e) { + usefulFields = [] + } + } else { + usefulFields = [] + } + + let ableField = usefulFields.join(', ') let functip = <div> - <p style={{marginBottom: '5px'}}>{this.state.dict['header.modal.func.innerface'].replace('@ableField', ableField)}</p> - <p>{this.state.dict['header.modal.func.outface']}</p> + <p style={{marginBottom: '5px'}}>{this.state.dict['model.tooltip.func.innerface'].replace('@ableField', ableField)}</p> </div> this.setState({ modaltype: 'actionEdit', card: card, - formlist: getActionForm(card, functip, this.state.config, this.props.permFuncField) + formlist: getActionForm(card, functip, this.state.config, usefulFields) }) } - handleTab = (card) => { - const { config } = this.state - - let menus = [ - {value: '', text: '绌�'}, - {value: 'mainTable', text: '涓绘暟鎹�'} - ] - let equalTabs = [] - let supMenu = card.supMenu || '' - let equalTab = card.equalTab || [] - let isuptab = true - let equalTabIds = [] - - config.tabgroups.forEach((groupId, i) => { - if (groupId === card.groupId) { - isuptab = false - config[card.groupId].forEach(tab => { // 鍙叧鑱旂殑鍚岀骇鏍囩 - if (tab.uuid === card.uuid) return - - equalTabIds.push(tab.uuid) - equalTabs.push(tab) - }) - } else if (isuptab) { - config[groupId].forEach(tab => { - menus.push({ - value: tab.uuid, - text: tab.label - }) - }) - } - }) - - if (supMenu && menus.filter(menu => menu.value === supMenu).length === 0) { - supMenu = '' - } - - if (equalTab.length > 0) { - equalTab = equalTab.filter(tabId => equalTabIds.includes(tabId)) - } - - this.setState({ - modaltype: 'tabs', - card: card, - formlist: [ - { - type: 'text', - key: 'label', - label: this.state.dict['header.menu.tabName'], - initVal: card.label || '', - required: true - }, - { - type: 'select', - key: 'type', - label: this.state.dict['header.form.tabType'], - initVal: card.type || 'SubTable', - required: true, - options: [{ - value: 'SubTable', - text: this.state.dict['header.menu.tab.subtable'] - }] - }, - { - type: 'select', - key: 'linkTab', - label: '鍏宠仈鏍囩', - initVal: card.linkTab || '', - required: false, - options: [] - }, - { - type: 'select', - key: 'icon', - label: this.state.dict['header.menu.icon'], - initVal: card.icon || '', - required: false, - options: [{ - value: '', - text: this.state.dict['header.form.empty'] - }, { - value: 'table', - text: 'table' - }, { - value: 'bar-chart', - text: 'bar-chart' - }, { - value: 'pie-chart', - text: 'pie-chart' - }, { - value: 'line-chart', - text: 'line-chart' - }] - }, - { - type: 'select', - key: 'supMenu', - label: this.state.dict['header.form.supTab'], - initVal: supMenu, - required: false, - options: menus - }, - { - type: 'mutilselect', - key: 'equalTab', - label: this.state.dict['header.form.equalTab'], - initVal: equalTab, - required: false, - options: equalTabs - } - ] - }) - } /** * @description 鎼滅储銆佹寜閽�佹樉绀哄垪淇敼鍚庢彁浜や繚瀛� @@ -624,38 +525,27 @@ * 3銆佹坊鍔犳垨缂栬緫鍒楋紝淇濆瓨鏃讹紝濡傛寜閽綅缃缃负琛ㄦ牸锛屽垯淇敼鎿嶄綔鍒楁樉绀虹姸鎬� */ handleSubmit = () => { - const { btnTab } = this.props - const { config, modaltype, optionLibs, card } = this.state + const { config, modaltype, card } = this.state if (modaltype === 'search') { this.modalFormRef.handleConfirm().then(res => { - if (config.setting.primaryKey && config.setting.primaryKey.toLowerCase() === res.field.toLowerCase()) { + let _config = JSON.parse(JSON.stringify(config)) + + if (_config.setting.primaryKey && _config.setting.primaryKey.toLowerCase() === res.field.toLowerCase()) { notification.warning({ top: 92, message: '琛ㄥ崟涓瓧娈靛悕涓嶅彲涓庝富閿噸澶嶏紒', - duration: 10 + duration: 5 }) return } - if ( // 鏇存柊涓嬫媺瀛楀吀 - (res.type === 'select' || res.type === 'multiselect' || res.type === 'link') && - res.resourceType === '0' && - res.options && res.options.length > 0 - ) { - optionLibs.set(btnTab.uuid + res.uuid, { - uuid: btnTab.uuid + res.uuid, - label: res.label, - parname: btnTab.label, - type: 'Modal', - options: res.options - }) - } let _groups = null - let fieldrepet = false // 瀛楁閲嶅 + let fieldrepet = false // 瀛楁閲嶅 + let labelrepeat = false // 鎻愮ず鏂囧瓧閲嶅 if (card.iscopy) { - _groups = config.groups.map(group => { + _groups = _config.groups.map(group => { let _index = null group.sublist.forEach((item, index) => { if (item.uuid === card.originUuid) { @@ -664,6 +554,8 @@ if (item.uuid !== res.uuid && item.field === res.field) { fieldrepet = true + } else if (item.uuid !== res.uuid && item.label === res.label) { + labelrepeat = true } }) @@ -677,10 +569,12 @@ return group }) } else { - _groups = config.groups.map(group => { + _groups = _config.groups.map(group => { group.sublist = group.sublist.map(item => { if (item.uuid !== res.uuid && item.field === res.field) { fieldrepet = true + } else if (item.uuid !== res.uuid && item.label === res.label) { + labelrepeat = true } if (item.uuid === res.uuid) { @@ -699,17 +593,61 @@ if (fieldrepet) { notification.warning({ top: 92, - message: '瀛楁鍚嶉噸澶嶏紒', - duration: 10 + message: '瀛楁宸插瓨鍦紒', + duration: 5 + }) + return + } else if (labelrepeat) { + notification.warning({ + top: 92, + message: '鍚嶇О宸插瓨鍦紒', + duration: 5 }) return } - this.setState({ - config: {...config, groups: _groups}, - optionLibs: optionLibs, - modaltype: '' - }) + if ((res.type === 'select' || res.type === 'multiselect' || res.type === 'link') && res.resourceType === '1' && /\s/.test(res.dataSource)) { + this.setState({ + sqlVerifing: true + }) + + let param = { + func: 's_debug_sql', + exec_type: 'y', + LText: res.dataSource + } + + param.LText = param.LText.replace(/@\$|\$@/ig, '') + + param.LText = Utils.formatOptions(param.LText) + param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + param.secretkey = Utils.encrypt('', param.timestamp) + + if (window.GLOB.mainSystemApi && res.database === 'sso') { + param.rduri = window.GLOB.mainSystemApi + } + + Api.getLocalConfig(param).then(result => { + if (result.status) { + this.setState({ + sqlVerifing: false, + config: {..._config, groups: _groups}, + modaltype: '' + }) + } else { + this.setState({sqlVerifing: false}) + + Modal.error({ + title: result.message + }) + } + }) + } else { + this.setState({ + config: {..._config, groups: _groups}, + modaltype: '' + }) + } }) } else if (modaltype === 'actionEdit') { this.actionFormRef.handleConfirm().then(res => { @@ -723,22 +661,6 @@ this.setState({ config: {...config, action: _action}, - modaltype: '' - }) - }) - } else if (modaltype === 'tabs') { - this.tabsFormRef.handleConfirm().then(res => { - let _tabgroup = config[res.groupId].map(item => { - if (item.uuid === res.uuid) { - return res - } else { - return item - } - }) - _tabgroup = _tabgroup.filter(item => !item.origin) - - this.setState({ - config: {...config, [res.groupId]: _tabgroup}, modaltype: '' }) }) @@ -759,9 +681,6 @@ } else if (modaltype === 'actionEdit') { let _action = config.action.filter(item => item.uuid !== card.uuid) _config = {...config, action: _action} - } else if (modaltype === 'tabs') { - let _tabgroup = config[card.groupId].filter(item => item.uuid !== card.uuid) - _config = {...config, [card.groupId]: _tabgroup} } else { _config = config } @@ -796,7 +715,7 @@ notification.warning({ top: 92, message: '璇峰~鍐欏唴閮ㄥ嚱鏁帮紒', - duration: 10 + duration: 5 }) return } @@ -813,30 +732,10 @@ menuNo: menu.MenuNo } - newLText = Utils.formatOptions(Utils.getfunc(_param, btn, menu, _config)) - DelText = Utils.formatOptions(Utils.dropfunc(_param.funcName)) + newLText = Utils.formatOptions(FuncUtils.getfunc(_param, btn, menu, _config)) + DelText = Utils.formatOptions(FuncUtils.dropfunc(_param.funcName)) - this.refs.btnCreatFunc.exec(btn.innerFunc, newLText, DelText).then(result => { - if (result !== 'success') return - - let isupdate = false - _config.action = _config.action.map(item => { - if (item.uuid === btn.uuid) { - isupdate = true - return btn - } else { - return item - } - }) - - if (!isupdate) { // 鎿嶄綔涓嶆槸淇敼锛屾坊鍔犲厓绱犺嚦鍒楄〃 - _config.action.push(btn) - } - - this.setState({ - config: _config - }) - }) + this.refs.btnCreatFunc.exec(btn.innerFunc, newLText, DelText) }) } @@ -845,15 +744,15 @@ */ tableCreatFunc = () => { const { menu } = this.props - let config = JSON.parse(JSON.stringify(this.state.config)) + const { config } = this.state - this.settingRef.handleConfirm().then(res => { - const setting = res + this.settingRef.handleConfirm().then(setting => { + if (!(setting.interType === 'inner') || !setting.innerFunc) { notification.warning({ top: 92, message: '鎺ュ彛绫诲瀷涓�-鍐呴儴锛屼笖瀛樺湪鍐呴儴鍑芥暟鏃讹紝鎵嶅彲浠ュ垱寤哄瓨鍌ㄨ繃绋嬶紒', - duration: 10 + duration: 5 }) return } @@ -866,19 +765,20 @@ } param.LText = Utils.formatOptions(param.LText) - param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' + param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') param.secretkey = Utils.encrypt(param.LText, param.timestamp) Api.getLocalConfig(param) } - let newLText = Utils.formatOptions(Utils.getTableFunc(setting, menu, config)) // 鍒涘缓瀛樺偍杩囩▼sql - let DelText = Utils.formatOptions(Utils.dropfunc(setting.innerFunc)) // 鍒犻櫎瀛樺偍杩囩▼sql + let _config = {...config, setting: setting} + let newLText = Utils.formatOptions(FuncUtils.getTableFunc(setting, menu, _config)) // 鍒涘缓瀛樺偍杩囩▼sql + let DelText = Utils.formatOptions(FuncUtils.dropfunc(setting.innerFunc)) // 鍒犻櫎瀛樺偍杩囩▼sql this.refs.tableCreatFunc.exec(setting.innerFunc, newLText, DelText).then(result => { if (result === 'success') { this.setState({ - config: {...config, setting: setting} + config: _config }) } }) @@ -889,22 +789,11 @@ let _this = this confirm({ content: `纭畾鍒犻櫎<<${element.card.label}>>鍚楋紵`, - okText: this.state.dict['header.confirm'], - cancelText: this.state.dict['header.cancel'], onOk() { let _config = JSON.parse(JSON.stringify(_this.state.config)) let _delActions = _this.state.delActions - if (element.type === 'tabs') { - _config[element.card.groupId] = _config[element.card.groupId].filter(item => { - if (item.uuid === element.card.uuid) { - return false - } else { - return true - } - }) - _delActions.push(element.card.uuid) - } else if (element.type === 'search') { + if (element.type === 'search') { _config.groups = _config.groups.map(group => { group.sublist = group.sublist.filter(item => item.uuid !== element.card.uuid) return group @@ -945,20 +834,21 @@ verifySubmit = () => { const { card } = this.state let config = JSON.parse(JSON.stringify(this.state.config)) - let _verify = this.verifyRef.state.verify - config.action = config.action.map(item => { - if (item.uuid === card.uuid) { - item.verify = _verify - } - - return item - }) - - this.setState({ - profileVisible: false, - config: config, - card: '', + this.verifyRef.handleConfirm().then(res => { + config.action = config.action.map(item => { + if (item.uuid === card.uuid) { + item.verify = res + } + + return item + }) + + this.setState({ + profileVisible: false, + config: config, + card: '' + }) }) } @@ -967,19 +857,27 @@ */ submitConfig = () => { const { menu, btnTab } = this.props - const { delActions } = this.state + const { delActions, openEdition } = this.state let config = JSON.parse(JSON.stringify(this.state.config)) this.menuformRef.handleConfirm().then(res => { - if (config.isAdd) { if (config.groups[0] && config.groups[0].sublist[0] && config.groups[0].sublist[0].origin) { config.groups[0].sublist = config.groups[0].sublist.filter(item => !item.origin) } - if (config.tabs[0] && config.tabs[0].origin) { - config.tabs = config.tabs.filter(item => !item.origin) - } + config.tabgroups[0].sublist = config.tabgroups[0].sublist.filter(item => !item.origin) + } + + let btnNames = config.action.map(item => item.label) + btnNames = Array.from(new Set(btnNames)) + if (btnNames.length < config.action.length) { + notification.warning({ + top: 92, + message: '鎸夐挳鍚嶇О涓嶅彲鐩稿悓锛�', + duration: 5 + }) + return } let _LongParam = '' @@ -994,8 +892,8 @@ // 鏍囩涓嶅悎娉曟椂锛屽惎鐢ㄧ姸鎬佷负false if (_config.tabgroups.length > 1) { - _config.tabgroups.forEach(groupId => { - if (_config[groupId].length === 0) { + _config.tabgroups.forEach(group => { + if (group.sublist.length === 0) { _config.enabled = false } }) @@ -1009,7 +907,7 @@ if (_ismutil && group.sublist.length === 0) { _config.enabled = false } - let arr = group.sublist.filter(item => item.field.toLowerCase() === _primary) + let arr = group.sublist.filter(item => item.field && item.field.toLowerCase() === _primary) if (arr.length > 0) { _config.enabled = false @@ -1048,10 +946,8 @@ } }) - _config.tabgroups.forEach(groupId => { - if (_config[groupId].length === 0) return - - _config[groupId].forEach(tab => { + _config.tabgroups.forEach(group => { + group.sublist.forEach(tab => { _config.funcs.push({ type: 'tab', subtype: 'tab', @@ -1124,7 +1020,7 @@ notification.warning({ top: 92, message: '缂栬瘧閿欒', - duration: 10 + duration: 5 }) this.setState({ @@ -1152,7 +1048,7 @@ 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.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') btnParam.secretkey = Utils.encrypt(btnParam.LText, btnParam.timestamp) let tabParam = { // 娣诲姞鑿滃崟tab椤� @@ -1162,8 +1058,8 @@ let _LText = [] - config.tabgroups.forEach(groupId => { - config[groupId].forEach(item => { + config.tabgroups.forEach(group => { + group.sublist.forEach(item => { _sort++ _LText.push(`select '${btnTab.uuid}' as MenuID ,'${item.linkTab}' as Tabid,'${item.label}' as TabName ,'${_sort * 10}' as Sort`) }) @@ -1173,7 +1069,7 @@ tabParam.LText = Utils.formatOptions(_LText) - tabParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' + tabParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') tabParam.secretkey = Utils.encrypt(tabParam.LText, tabParam.timestamp) let param = { @@ -1185,6 +1081,10 @@ MenuName: btnTab.label, PageParam: JSON.stringify({Template: 'FormTab'}), LongParam: _LongParam + } + + if (openEdition) { + param.open_edition = openEdition } // 鏈夋寜閽垨鏍囩鍒犻櫎鏃讹紝鍏堣繘琛屽垹闄ゆ搷浣� @@ -1218,7 +1118,7 @@ notification.warning({ top: 92, message: error.message, - duration: 10 + duration: 5 }) resolve(false) } else { @@ -1237,6 +1137,7 @@ Api.getSystemConfig(param).then(response => { if (response.status) { this.setState({ + openEdition: response.open_edition || '', config: _config, originMenu: _config }) @@ -1250,7 +1151,7 @@ notification.warning({ top: 92, message: response.message, - duration: 10 + duration: 5 }) } }) @@ -1259,8 +1160,8 @@ }, () => { notification.warning({ top: 92, - message: this.state.dict['header.menu.basemsg'], - duration: 10 + message: this.state.dict['model.menu.basemsg'], + duration: 5 }) }) } @@ -1305,7 +1206,7 @@ notification.warning({ top: 92, message: error.message, - duration: 10 + duration: 5 }) resolve(false) } else { @@ -1345,8 +1246,6 @@ if (config.isAdd) { confirm({ content: '鎸夐挳閰嶇疆灏氭湭鎻愪氦锛岀‘瀹氭斁寮冧繚瀛樺悧锛�', - okText: this.state.dict['header.confirm'], - cancelText: this.state.dict['header.cancel'], onOk() { _this.handleViewBack() }, @@ -1372,7 +1271,7 @@ notification.warning({ top: 92, message: '璇烽�夋嫨琛ㄥ悕锛�', - duration: 10 + duration: 5 }) return } @@ -1518,7 +1417,7 @@ notification.warning({ top: 92, message: res.message, - duration: 10 + duration: 5 }) } }) @@ -1558,16 +1457,50 @@ } param.LText = Utils.formatOptions(param.LText) - param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' + param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') param.secretkey = Utils.encrypt(param.LText, param.timestamp) Api.getLocalConfig(param) } - this.setState({ - config: {...config, setting: res}, - settingVisible: false, - }) + if (res.interType === 'inner' && !res.innerFunc && res.dataresource && /\s/.test(res.dataresource)) { + this.setState({ + sqlVerifing: true + }) + + let param = { + func: 's_debug_sql', + exec_type: 'y', + LText: res.dataresource + } + + param.LText = param.LText.replace(/@\$|\$@/ig, '') + + param.LText = Utils.formatOptions(param.LText) + param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + param.secretkey = Utils.encrypt('', param.timestamp) + + Api.getLocalConfig(param).then(result => { + if (result.status) { + this.setState({ + sqlVerifing: false, + config: {...config, setting: res}, + settingVisible: false + }) + } else { + this.setState({sqlVerifing: false}) + + Modal.error({ + title: result.message + }) + } + }) + } else { + this.setState({ + config: {...config, setting: res}, + settingVisible: false + }) + } }) } @@ -1576,13 +1509,13 @@ */ setSubConfig = (btn) => { const {menu, btnTab} = this.props - const { config, originMenu } = this.state + const { config, originMenu, activeKey, openEdition } = this.state if (config.isAdd) { notification.warning({ top: 92, message: '鑿滃崟灏氭湭淇濆瓨锛岃淇濆瓨鑿滃崟閰嶇疆锛�', - duration: 10 + duration: 5 }) } else { this.menuformRef.handleConfirm().then(res => { @@ -1592,16 +1525,18 @@ notification.warning({ top: 92, message: '鑿滃崟閰嶇疆宸蹭慨鏀癸紝璇蜂繚瀛橈紒', - duration: 10 + duration: 5 }) } else { this.setState({ loading: true }) + btnTab.activeKey = activeKey // 淇濆瓨褰撳墠鎵撳紑椤电 + btnTab.open_edition = openEdition // 鏇存柊鐗堟湰鍙� + let param = { editMenu: menu, - optionLibs: this.state.optionLibs, editTab: btn, tabConfig: null, editSubTab: null, @@ -1635,6 +1570,10 @@ param.subConfig = _LongParam } + if (param.editTab) { + param.editTab.open_edition = res.open_edition || '' + } + this.props.handleView(param) } else { this.setState({ @@ -1643,7 +1582,7 @@ notification.warning({ top: 92, message: res.message, - duration: 10 + duration: 5 }) } }) @@ -1652,7 +1591,7 @@ notification.warning({ top: 92, message: '鑿滃崟鍩烘湰淇℃伅宸蹭慨鏀癸紝璇蜂繚瀛橈紒', - duration: 10 + duration: 5 }) }) } @@ -1664,7 +1603,7 @@ let tabinvalid = true if (config.tabgroups.length > 1) { config.tabgroups.forEach(group => { - if (config[group].length === 0) { + if (group.sublist.length === 0) { tabinvalid = false } }) @@ -1682,7 +1621,7 @@ let primaryrepeat = false config.groups.forEach(group => { - let arr = group.sublist.filter(item => item.field.toLowerCase() === _primary) + let arr = group.sublist.filter(item => item.field && item.field.toLowerCase() === _primary) if (arr.length > 0) { primaryrepeat = true @@ -1693,31 +1632,31 @@ notification.warning({ top: 92, message: '灏氭湭璁剧疆鏁版嵁婧愶紝涓嶅彲鍚敤锛�', - duration: 10 + duration: 5 }) } else if (config.setting.datatype === 'query' && !config.setting.primaryKey) { notification.warning({ top: 92, message: '灏氭湭璁剧疆涓婚敭锛屼笉鍙惎鐢紒', - duration: 10 + duration: 5 }) } else if (!tabinvalid) { notification.warning({ top: 92, message: '瀛樺湪澶氫綑鏍囩缁勶紝涓嶅彲鍚敤锛�', - duration: 10 + duration: 5 }) } else if (!forminvalid) { notification.warning({ top: 92, message: '瀛樺湪澶氫綑绌鸿〃鍗曠粍锛屼笉鍙惎鐢紒', - duration: 10 + duration: 5 }) } else if (primaryrepeat) { notification.warning({ top: 92, message: '琛ㄥ崟瀛楁涓庝富閿噸澶嶏紝涓嶅彲鍚敤锛�', - duration: 10 + duration: 5 }) } else { this.setState({ @@ -1726,48 +1665,7 @@ } } - addTabGroup = () => { - let _this = this - let _config = JSON.parse(JSON.stringify(this.state.config)) - confirm({ - content: `纭畾鏂板缓鏍囩缁勫悧锛焋, - okText: this.state.dict['header.confirm'], - cancelText: this.state.dict['header.cancel'], - onOk() { - let newgroup = 'tabs' + Utils.getuuid() - - _config.tabgroups.push(newgroup) - _config[newgroup] = [] - - _this.setState({ - config: _config, - }) - }, - onCancel() {} - }) - } - - delTabGroup = (groupId) => { - let _this = this - let _config = JSON.parse(JSON.stringify(this.state.config)) - - confirm({ - content: `纭畾鍒犻櫎鏍囩缁勫悧锛焋, - okText: this.state.dict['header.confirm'], - cancelText: this.state.dict['header.cancel'], - onOk() { - - _config.tabgroups = _config.tabgroups.filter(group => group !== groupId) - delete _config[groupId] - - _this.setState({ - config: _config - }) - }, - onCancel() {} - }) - } handleGroup = (group) => { let editgroup = { @@ -1793,8 +1691,6 @@ confirm({ content: `纭畾鍒犻櫎鍒嗙粍<<${group.label}>>鍚楋紵`, - okText: this.state.dict['header.confirm'], - cancelText: this.state.dict['header.cancel'], onOk() { let groups = config.groups.filter(item => !(item.uuid === group.uuid)) groups = groups.map(item => { @@ -1836,33 +1732,62 @@ }) } - handleTabGroup = (index, type) => { - let config = JSON.parse(JSON.stringify(this.state.config)) - - if (type === 'up') { - config.tabgroups.splice(index, 0, config.tabgroups.splice(index - 1, 1)[0]) - } else { - config.tabgroups.splice(index, 0, config.tabgroups.splice(index + 1, 1)[0]) - } + + pasteSubmit = () => { + let _config = JSON.parse(JSON.stringify(this.state.config)) + + this.pasteFormRef.handleConfirm().then(res => { + if (res.copyType === 'form') { + _config.groups.forEach(group => { + if (group.isDefault) { + group.sublist.push(res) + } + }) + + if (res.type === 'linkMain') { + notification.warning({ + top: 92, + message: '涓嶆敮鎸佹琛ㄥ崟绫诲瀷锛�', + duration: 5 + }) + return + } + + this.setState({ + config: _config, + pasteVisible: null + }, () => { + this.handleSearch(res) + }) + } else { + notification.warning({ + top: 92, + message: '閰嶇疆淇℃伅鏍煎紡閿欒锛�', + duration: 5 + }) + } + }) + } + + /** + * @description 鏇存柊鏍囩閰嶇疆淇℃伅 + */ + updatetabs = (config, delcards) => { + const { delActions } = this.state this.setState({ - config: config - }) - - notification.success({ - top: 92, - message: '璋冩暣鎴愬姛', - duration: 2 + config: config, + delActions: delcards ? [...delActions, ...delcards.map(item => item.uuid)] : delActions }) } render () { - const { config, modaltype } = this.state + const { config, modaltype, activeKey } = this.state let _length = config.groups.length let configTabs = [] - this.state.config.tabgroups.forEach(group => { - configTabs.push(...this.state.config[group]) + config.tabgroups.forEach(group => { + configTabs.push(...group.sublist) }) return ( @@ -1870,9 +1795,9 @@ <DndProvider backend={HTML5Backend}> {/* 宸ュ叿鏍� */} <div className="tools"> - <Collapse accordion defaultActiveKey="0" bordered={false}> + <Collapse accordion defaultActiveKey={activeKey} bordered={false} onChange={(key) => this.setState({activeKey: key})}> {/* 鍩烘湰淇℃伅 */} - <Panel header={this.state.dict['header.menu.basedata']} key="0" id="common-basedata"> + <Panel forceRender={true} header={this.state.dict['header.menu.basedata']} key="0" id="common-basedata"> {/* 鑿滃崟淇℃伅 */} <MenuForm dict={this.state.dict} @@ -1973,8 +1898,8 @@ } bordered={false} extra={ <div> <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> + <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%' }}> <Icon type="setting" onClick={this.changeSetting} /> @@ -2002,6 +1927,7 @@ /> </span> )}> + {group.isDefault ? <Icon type="snippets" title={this.state.dict['header.form.paste']} onClick={() => {this.setState({pasteVisible: true})}} /> : null} <DragElement type="search" groupId={group.uuid} @@ -2030,29 +1956,12 @@ /> </div> {/* 鏍囩缁� */} - {this.state.config.tabgroups.map((groupId, index) => { - return ( - <div key={index} className="tab-list"> - {index === 0 ? <Tooltip placement="bottomLeft" overlayClassName="middle" title="鍦ㄥ乏渚у伐鍏锋爮銆婃爣绛鹃〉銆嬩腑锛岄�夋嫨瀵瑰簲绫诲瀷鐨勬爣绛鹃〉鎷栬嚦姝ゅ娣诲姞銆�"> - <Icon type="question-circle" /> - </Tooltip> : null} - {index !== (this.state.config.tabgroups.length - 1) ? - <Icon type="arrow-down" onClick={() => {this.handleTabGroup(index, 'down')}} /> : null - } - {index !== 0 ? <Icon type="arrow-up" onClick={() => {this.handleTabGroup(index, 'up')}} /> : null} - {index === 0 ? <Icon type="plus" onClick={this.addTabGroup} /> : null} - {index !== 0 ? <Icon type="delete" onClick={() => {this.delTabGroup(groupId)}} /> : null} - <TabDragElement - type="tabs" - groupId={groupId} - list={this.state.config[groupId]} - handleList={this.handleList} - handleMenu={this.handleTab} - deleteMenu={this.deleteElement} - placeholder={this.state.dict['header.form.tab.placeholder']} - /> - </div>) - })} + <TabsComponent + config={config} + tabs={this.state.tabviews} + setSubConfig={(item) => this.setSubConfig(item, 'tab')} + updatetabs={this.updatetabs} + /> </Card> </div> </DndProvider> @@ -2063,6 +1972,7 @@ width={700} maskClosable={false} onOk={this.handleSubmit} + confirmLoading={this.state.sqlVerifing} onCancel={this.editModalCancel} destroyOnClose > @@ -2071,13 +1981,12 @@ card={this.state.card} formlist={this.state.formlist} inputSubmit={this.handleSubmit} - optionLibs={this.state.optionLibs} wrappedComponentRef={(inst) => this.modalFormRef = inst} /> </Modal> {/* 缂栬緫鎸夐挳锛氬鍒躲�佺紪杈� */} <Modal - title={this.state.dict['header.modal.action.edit']} + title={this.state.dict['model.action'] + '-' + this.state.dict['model.edit']} visible={modaltype === 'actionEdit'} width={700} maskClosable={false} @@ -2085,8 +1994,8 @@ footer={[ this.state.card && this.state.card.btnType !== 'cancel' ? <CreateFunc key="create" dict={this.state.dict} ref="btnCreatFunc" trigger={this.creatFunc}/> : null, - <Button key="cancel" onClick={this.editModalCancel}>{this.state.dict['header.cancel']}</Button>, - <Button key="confirm" type="primary" onClick={this.handleSubmit}>{this.state.dict['header.confirm']}</Button> + <Button key="cancel" onClick={this.editModalCancel}>{this.state.dict['model.cancel']}</Button>, + <Button key="confirm" type="primary" onClick={this.handleSubmit}>{this.state.dict['model.confirm']}</Button> ]} destroyOnClose > @@ -2099,35 +2008,14 @@ wrappedComponentRef={(inst) => this.actionFormRef = inst} /> </Modal> - {/* 鏍囩缂栬緫 */} - <Modal - title={this.state.dict['header.modal.tabs.edit']} - visible={modaltype === 'tabs'} - width={700} - maskClosable={false} - onOk={this.handleSubmit} - onCancel={this.editModalCancel} - destroyOnClose - > - <TabForm - type="tabs" - dict={this.state.dict} - card={this.state.card} - tabs={this.state.tabviews} - formlist={this.state.formlist} - inputSubmit={this.handleSubmit} - wrappedComponentRef={(inst) => this.tabsFormRef = inst} - /> - </Modal> {/* 鏍规嵁瀛楁鍚嶆坊鍔犳樉绀哄垪鍙婃悳绱㈡潯浠� */} <Modal wrapClassName="common-table-fields-modal" - title={this.state.dict['header.edit']} + title={this.state.dict['model.edit']} visible={this.state.tableVisible} width={'65vw'} maskClosable={false} - style={{minWidth: '900px', maxWidth: '1200px'}} - cancelText={this.state.dict['header.close']} + cancelText={this.state.dict['model.close']} onOk={this.addFieldSubmit} onCancel={() => { // 鍙栨秷娣诲姞 this.setState({ @@ -2150,7 +2038,7 @@ visible={this.state.profileVisible} width={'75vw'} maskClosable={false} - style={{minWidth: '900px', maxWidth: '1200px'}} + okText={this.state.dict['model.submit']} onOk={this.verifySubmit} onCancel={() => { this.setState({ profileVisible: false }) }} destroyOnClose @@ -2166,7 +2054,7 @@ </Modal> {/* 璁剧疆鍏ㄥ眬閰嶇疆鍙婂垪琛ㄦ暟鎹簮 */} <Modal - title={this.state.dict['header.edit']} + title={this.state.dict['model.edit']} visible={this.state.settingVisible} width={700} maskClosable={false} @@ -2177,8 +2065,8 @@ }} footer={[ <CreateFunc key="create" dict={this.state.dict} ref="tableCreatFunc" trigger={this.tableCreatFunc}/>, - <Button key="cancel" onClick={() => { this.setState({ settingVisible: false }) }}>{this.state.dict['header.cancel']}</Button>, - <Button key="confirm" type="primary" onClick={this.settingSave}>{this.state.dict['header.confirm']}</Button> + <Button key="cancel" onClick={() => { this.setState({ settingVisible: false }) }}>{this.state.dict['model.cancel']}</Button>, + <Button key="confirm" type="primary" loading={this.state.sqlVerifing} onClick={this.settingSave}>{this.state.dict['model.confirm']}</Button> ]} destroyOnClose > @@ -2187,7 +2075,6 @@ menu={this.props.menu} config={this.state.config} inputSubmit={this.settingSave} - usefulFields={this.props.permFuncField} wrappedComponentRef={(inst) => this.settingRef = inst} /> </Modal> @@ -2198,9 +2085,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="confirm" className="mk-btn mk-yellow" onClick={this.handleViewBack}>{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="confirm" className="mk-btn mk-yellow" onClick={this.handleViewBack}>{this.state.dict['model.notsave']}</Button>, + <Button key="cancel" onClick={() => { this.setState({closeVisible: false}) }}>{this.state.dict['model.cancel']}</Button> ]} destroyOnClose > @@ -2223,16 +2110,29 @@ wrappedComponentRef={(inst) => this.groupRef = inst} /> </Modal> + {/* 鎸夐挳閰嶇疆淇℃伅绮樿创澶嶅埗 */} + <Modal + title={this.state.dict['header.form.paste']} + visible={this.state.pasteVisible} + width={600} + maskClosable={false} + onOk={this.pasteSubmit} + onCancel={() => {this.setState({pasteVisible: null})}} + destroyOnClose + > + <PasteForm + dict={this.state.dict} + wrappedComponentRef={(inst) => this.pasteFormRef = inst} + /> + </Modal> {this.state.loading && <Spin size="large" />} </div> ) } } -const mapStateToProps = (state) => { - return { - permFuncField: state.permFuncField - } +const mapStateToProps = () => { + return {} } const mapDispatchToProps = () => { -- Gitblit v1.8.0