From f59a500d24291d7f54b71dcca939a2a23dedca7c Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 18 六月 2020 17:52:03 +0800 Subject: [PATCH] 2020-06-18 --- src/templates/comtableconfig/index.jsx | 2544 ++++++++++------------------------------------------------ 1 files changed, 439 insertions(+), 2,105 deletions(-) diff --git a/src/templates/comtableconfig/index.jsx b/src/templates/comtableconfig/index.jsx index 1b241b7..8f6904e 100644 --- a/src/templates/comtableconfig/index.jsx +++ b/src/templates/comtableconfig/index.jsx @@ -4,43 +4,35 @@ import { is, fromJS } from 'immutable' import { DndProvider } from 'react-dnd' import HTML5Backend from 'react-dnd-html5-backend' -import { Button, Card, Modal, Collapse, notification, Spin, Select, List, Icon, Empty, Switch, Tooltip } from 'antd' +import { Button, Card, Modal, Collapse, notification, Spin, Icon, Switch, Tooltip, Col } from 'antd' import moment from 'moment' import Api from '@/api' import Utils from '@/utils/utils.js' -import zhCN from '@/locales/zh-CN/comtable.js' -import enUS from '@/locales/en-US/comtable.js' -import { getSearchForm, getActionForm, getColumnForm } from '@/templates/zshare/formconfig' -import { queryTableSql } from '@/utils/option.js' +import zhCN from '@/locales/zh-CN/model.js' +import enUS from '@/locales/en-US/model.js' +import { getMainMenuForm } from '@/templates/zshare/formconfig' -import ActionForm from './actionform' -import SettingForm from './settingform' -import TabForm from '@/templates/zshare/tabform' -import SearchForm from '@/templates/zshare/searchform' -import ColumnForm from '@/templates/zshare/columnform' -import PasteForm from '@/templates/zshare/pasteform' -import DragElement from '@/templates/zshare/dragelement' -import ColspanForm from '@/templates/zshare/colspanform' -import GridBtnForm from '@/templates/zshare/gridbtnform' -import EditCard from '@/templates/zshare/editcard' -import VerifyCard from '@/templates/zshare/verifycard' -import VerifyCardExcelIn from '@/templates/zshare/verifycardexcelin' -import VerifyCardExcelOut from '@/templates/zshare/verifycardexcelout' -import VerifyCardPrint from '@/templates/zshare/verifycardprint' +import asyncComponent from '@/utils/asyncComponent' +import SearchComponent from '@/templates/sharecomponent/searchcomponent' +import ActionComponent from '@/templates/sharecomponent/actioncomponent' +import ColumnComponent from '@/templates/sharecomponent/columncomponent' + import MenuForm from '@/templates/zshare/menuform' -import TabDragElement from '@/templates/zshare/tabdragelement' -import TransferForm from '@/components/transferform' -import SourceElement from '@/templates/zshare/dragelement/source' -import CreateFunc from '@/templates/zshare/createfunc' -import CreateInterface from '@/templates/zshare/createinterface' +import EditComponent from '@/templates/zshare/editcomponent' +import SourceElement from '@/templates/zshare/dragsource' 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 SettingComponent = asyncComponent(() => import('@/templates/sharecomponent/settingcomponent')) +const TableComponent = asyncComponent(() => import('@/templates/sharecomponent/tablecomponent')) +const FieldsComponent = asyncComponent(() => import('@/templates/sharecomponent/fieldscomponent')) +const ChartGroupComponent = asyncComponent(() => import('@/templates/sharecomponent/chartgroupcomponent')) +const ChartComponent = asyncComponent(() => import('@/templates/sharecomponent/chartcomponent')) +const CardComponent = asyncComponent(() => import('@/templates/sharecomponent/cardcomponent')) +const TabsComponent = asyncComponent(() => import('@/templates/sharecomponent/tabscomponent')) class ComTableConfig extends Component { static propTpyes = { @@ -51,35 +43,28 @@ } state = { - dict: CommonDict, // 瀛楀吀 + dict: localStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, config: null, // 椤甸潰閰嶇疆 - tableVisible: false, // 鏁版嵁琛ㄥ瓧娈垫ā鎬佹 - addType: '', // 娣诲姞绫诲瀷-鎼滅储鏉′欢鎴栨樉绀哄垪 - tableColumns: [], // 琛ㄦ牸鏄剧ず鍒� + tableFields: [], // 琛ㄦ牸鏄剧ず鍒� fields: null, // 鎼滅储鏉′欢鍙婃樉绀哄垪锛屽彲閫夊瓧娈� menuformlist: null, // 鍩烘湰淇℃伅琛ㄥ崟瀛楁 formlist: null, // 鎼滅储鏉′欢銆佹寜閽�佹樉绀哄垪琛ㄥ崟瀛楁 - modaltype: '', // 妯℃�佹绫诲瀷锛屾帶鍒舵ā鎬佹鏄剧ず - card: null, // 缂栬緫鍏冪礌 menuloading: false, // 鑿滃崟淇濆瓨涓� menucloseloading: false, // 鑿滃崟鍏抽棴鏃讹紝閫夋嫨淇濆瓨 loading: false, // 鍔犺浇涓紝椤甸潰spin - settingVisible: false, // 鍏ㄥ眬閰嶇疆妯℃�佹 closeVisible: false, // 鍏抽棴妯℃�佹 tables: [], // 鍙敤琛ㄥ悕 - selectedTables: [], // 宸查�夎〃鍚� originMenu: null, // 鍘熷鑿滃崟 originActions: null, // 鍘熷鎸夐挳淇℃伅锛屼娇鐢ㄥ凡鏈夌敤鎴锋ā鏉� delActions: [], // 鍒犻櫎鎸夐挳鍒楄〃 copyActions: [], // 澶嶅埗鎸夐挳缁� - showColumnName: false, // 鏄剧ず鍒楀瓧娈靛悕鎺у埗 tabviews: [], // 鎵�鏈夋爣绛鹃〉 - profileVisible: false, // 楠岃瘉淇℃伅妯℃�佹 optionLibs: null, // 鑷畾涔変笅鎷夐�夐」搴� - thawBtnVisible: false, // 瑙e喕鎸夐挳寮圭獥 - thawbtnlist: null, // 瑙e喕鎸夐挳鍒楄〃 thawButtons: [], // 宸查�夋嫨瑕佽В鍐荤殑鎸夐挳 - activeKey: '0' // 榛樿灞曞紑鍩烘湰淇℃伅 + activeKey: '0', // 榛樿灞曞紑鍩烘湰淇℃伅 + chartview: null, // 褰撳墠瑙嗗浘 + pasteContent: null, // 绮樿创閰嶇疆淇℃伅 + openEdition: '' // 缂栬緫鐗堟湰鏍囪锛岄槻姝㈠浜烘搷浣� } /** @@ -94,9 +79,9 @@ let _config = '' if (!_LongParam) { - _config = JSON.parse(JSON.stringify(Source.baseConfig)) + _config = fromJS(Source.baseConfig).toJS() if (!menu.isSubtable) { // 涓嶆槸閫夋嫨涓诲瓙琛ㄦ椂锛岄殣钘忔爣绛鹃〉 - _config.tabs = [] + _config.tabgroups = [{ uuid: 'tabs', sublist: [] }] } _config.isAdd = true } else { @@ -118,11 +103,76 @@ }) } - // 閰嶇疆榛樿鍊硷紝鍏煎 - _config.tabs = _config.tabs || [] - _config.tabgroups = _config.tabgroups || ['tabs'] - _config.setting.subtabs = _config.setting.subtabs || [] - _config.Template = 'CommonTable' + if (!_config.version || _config.version < '1.0') { + // 閰嶇疆榛樿鍊硷紝鍏煎 + _config.version = '1.0' + _config.Template = 'CommonTable' + _config.easyCode = _config.easyCode || '' + + if (!_config.tabgroups) { + _config.tabgroups = [{ uuid: 'tabs', sublist: [] }] + } else if (typeof(_config.tabgroups[0]) === 'string') { + let _tabgroups = [] + _config.tabgroups.forEach(groupId => { + let _group = { + uuid: groupId, + sublist: fromJS(_config[groupId]).toJS() + } + + delete _config[groupId] + + _tabgroups.push(_group) + }) + + _config.tabgroups = _tabgroups + } + + // 鍏煎鍥捐〃 + if (!_config.charts) { + _config.expand = false + _config.charts = [{ + uuid: Utils.getuuid(), + label: '', + title: '', + chartType: 'table', + icon: 'table', + Hide: 'false', + blacklist: [] + }] + } else { + _config.charts.forEach(card => { + if (card.chartType === 'card') { + card.details = card.details.map(_cell => { + if (!_cell.fontSize) { + _cell.fontSize = 14 + } + if (!_cell.width) { + _cell.width = 100 + } else if (_cell.width === 'helf') { + _cell.width = 50 + } else if (_cell.width === 'third') { + _cell.width = 33 + } + + if (_cell.bold === 'true') { + _cell.fontWeight = 'normal' + } + + if (!_cell.height) { + _cell.height = 1 + } + + return _cell + }) + + if (card.widthType === 'ratio' && card.avatar && card.avatar.widthType !== 'ratio') { + card.avatar.widthType = 'ratio' + card.avatar.width = 32 + } + } + }) + } + } let _oriActions = [] if (_config.type === 'user') { @@ -135,13 +185,13 @@ if (item.OpenType === 'pop') { // 鍚湁瀛愰厤缃」鐨勬寜閽�(琛ㄥ崟) _oriActions.push({ - prebtn: JSON.parse(JSON.stringify(item)), + prebtn: fromJS(item).toJS(), curuuid: uuid, Template: 'Modal' }) } else if (item.OpenType === 'tab' || item.OpenType === 'blank') { // 鍚湁瀛愰厤缃」鐨勬寜閽�(鏍囩鍚庡綋鍓嶉〉鎵撳紑) _oriActions.push({ - prebtn: JSON.parse(JSON.stringify(item)), + prebtn: fromJS(item).toJS(), curuuid: uuid, Template: item.tabTemplate }) @@ -153,7 +203,7 @@ // 閲嶇疆鏍囩ID _config.tabgroups.forEach(group => { - _config[group] = _config[group].map(tab => { + group.sublist = group.sublist.map(tab => { tab.uuid = Utils.getuuid() if (tab.linkTab) { @@ -166,188 +216,22 @@ } this.setState({ + chartview: _config.charts[0].uuid, config: _config, + openEdition: menu.open_edition || '', activeKey: menu.activeKey || '0', optionLibs: optionLibs, originActions: _oriActions, - originMenu: JSON.parse(JSON.stringify(menu)), - selectedTables: _config.tables || [], - menuformlist: [ - { - type: 'select', - key: 'fstMenuId', - label: '涓�绾ц彍鍗�', - initVal: menu.fstMenuId, - required: true, - readonly: false, - options: menu.fstMenuList - }, - { - type: 'select', - key: 'parentId', - label: '浜岀骇鑿滃崟', - initVal: menu.ParentID, - required: true, - readonly: false, - options: menu.supMenuList - }, - { - type: 'text', - key: 'menuName', - label: this.state.dict['header.menu.menuName'], - initVal: menu.MenuName, - required: true, - readonly: false - }, - { - type: 'text', - key: 'menuNo', - label: this.state.dict['header.menu.menuNo'], - initVal: menu.MenuNo, - required: true, - readonly: false - }, - { - type: 'select', - key: 'opentype', - label: this.state.dict['header.menu.openType'], - initVal: menu.PageParam.OpenType, - required: true, - options: [{ - MenuID: 'newtab', - text: this.state.dict['header.form.tab'] - }, { - MenuID: 'newpage', - text: this.state.dict['header.form.newpage'] - }, { - MenuID: 'currenttab', - text: this.state.dict['header.form.currenttab'] - }] - } - ] + originMenu: fromJS(menu).toJS(), + menuformlist: getMainMenuForm(menu, _config) }) } /** - * @description 鍔犺浇瀹屾垚鍚� - * 1銆佽幏鍙栫郴缁熷彲浣跨敤琛� - * 2銆佹牴鎹厤缃俊鎭腑宸蹭娇鐢ㄨ〃鑾峰彇鐩稿叧瀛楁淇℃伅 - * 3銆佽幏鍙栨墍鏈夋爣绛鹃〉淇℃伅 + * @description 鍔犺浇瀹屾垚鍚�, 鑾峰彇鎵�鏈夋爣绛鹃〉淇℃伅 */ componentDidMount () { - let param = { - func: 'sPC_Get_SelectedList', - LText: queryTableSql, - obj_name: 'data', - arr_field: 'TbName,Remark' - } - - param.LText = Utils.formatOptions(param.LText) - param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' - param.secretkey = Utils.encrypt(param.LText, param.timestamp) - - Api.getSystemConfig(param).then(res => { - if (res.status) { - this.setState({ - tables: res.data - }) - } else { - notification.warning({ - top: 92, - message: res.message, - duration: 10 - }) - } - }) - - let deffers = this.state.selectedTables.map(item => { - return new Promise(resolve => { - Api.getSystemConfig({func: 'sPC_Get_FieldName', TBName: item.TbName}).then(res => { - res.TBName = item.TbName - resolve(res) - }) - }) - }) - Promise.all(deffers).then(response => { - let _columns = [] - response.forEach(res => { - if (res.status) { - let tabmsg = { - tableName: res.TBName, - columns: res.FDName.map(item => { - let _type = item.FieldType.toLowerCase() - let _decimal = 0 - if (/^nvarchar/.test(_type)) { - _type = 'text' - } else if (/^int/.test(_type)) { - _type = 'number' - } else if (/^decimal/.test(_type)) { - _decimal = _type.split(',')[1] - _decimal = parseInt(_decimal) - if (_decimal > 4) { - _decimal = 4 - } - _type = 'number' - } else if (/^decimal/.test(_type)) { - _decimal = _type.split(',')[1] - _decimal = parseInt(_decimal) - if (_decimal > 4) { - _decimal = 4 - } - _type = 'number' - } else if (/^datetime/.test(_type)) { - _type = 'datetime' - } else if (/^date/.test(_type)) { - _type = 'date' - } else { - _type = 'text' - } - - return { - field: item.FieldName, - label: item.FieldDec, - type: _type, - datatype: _type, - decimal: _decimal - } - }) - } - _columns.push(tabmsg) - } else { - notification.warning({ - top: 92, - message: res.message, - duration: 10 - }) - } - }) - - this.setState({ - tableColumns: _columns - }) - }) - - Api.getSystemConfig({func: 'sPC_Get_UserTemp', TypeCharTwo: 'tab'}).then(res => { - if (res.status) { - this.setState({ - tabviews: res.UserTemp.map(temp => { - return { - uuid: temp.MenuID, - value: temp.MenuID, - text: temp.MenuName, - type: temp.Template, - MenuNo: temp.MenuNo - } - }) - }) - } else { - notification.warning({ - top: 92, - message: res.message, - duration: 10 - }) - } - }) + this.reloadTab(false) } /** @@ -362,9 +246,9 @@ /** * @description 鍔犺浇鎴栧埛鏂版爣绛句俊鎭� */ - reloadTab = () => { + reloadTab = (type) => { this.setState({ - loading: true, + loading: type, tabviews: [] }) Api.getSystemConfig({func: 'sPC_Get_UserTemp', TypeCharTwo: 'tab'}).then(res => { @@ -381,11 +265,14 @@ } }) }) - notification.success({ - top: 92, - message: '鍒锋柊鎴愬姛銆�', - duration: 2 - }) + + if (type) { + notification.success({ + top: 92, + message: '鍒锋柊鎴愬姛銆�', + duration: 2 + }) + } } else { this.setState({ loading: false @@ -393,904 +280,10 @@ notification.warning({ top: 92, message: res.message, - duration: 10 + duration: 5 }) } }) - } - - /** - * @description 鍏冪礌娣诲姞鎴栨嫋鍔ㄦ椂椤哄簭鍙樺寲 - */ - handleList = (type, list, card) => { - 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 (list.length > config[type].length) { - list = list.filter(item => !item.origin) - if (type === 'search') { - this.handleSearch(card) - } else if (type === 'action') { - this.handleAction(card) - } else if (type === 'columns') { - this.handleColumn(card) - } - } - - this.setState({ - config: {...config, [type]: list } - }) - } - } - - /** - * @description 鎼滅储鏉′欢缂栬緫锛岃幏鍙栨悳绱㈡潯浠惰〃鍗曚俊鎭� - */ - handleSearch = (card) => { - const { menu } = this.props - - this.setState({ - modaltype: 'search', - card: card, - formlist: getSearchForm(card, menu.roleList) - }) - } - - /** - * @description 鎸夐挳缂栬緫锛岃幏鍙栨寜閽〃鍗曚俊鎭� - */ - handleAction = (card, type) => { - let ableField = this.props.permFuncField.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> - </div> - - this.setState({ - modaltype: type === 'copy' ? 'actionCopy' : 'actionEdit', - card: card, - formlist: getActionForm(card, functip, this.state.config, this.props.permFuncField) - }) - } - - /** - * @description 鏄剧ず鍒椾笌鍚堝苟鍒楃紪杈戯紝鑾峰彇琛ㄥ崟淇℃伅 - */ - handleColumn = (card) => { - const { menu } = this.props - - if (card.type !== 'colspan') { - this.setState({ - modaltype: 'columns', - card: card, - formlist: getColumnForm(card, menu.roleList) - }) - } else { - this.setState({ - modaltype: 'colspan', - card: card - }) - } - } - - /** - * @description 鏍囩缂栬緫锛岀瓫閫夊彲閫夌殑涓嬬骇鏍囩涓庡凡鍏宠仈鐨勪笅绾ф爣绛� - */ - 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: this.state.dict['header.form.linkTab'], - 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 鎿嶄綔鍒楃紪杈� - */ - handleGridBtn = () => { - this.setState({ - modaltype: 'gridbtn' - }) - } - - /** - * @description 鎼滅储銆佹寜閽�佹樉绀哄垪淇敼鍚庢彁浜や繚瀛� - * 1銆佹悳绱㈡潯浠朵繚瀛� - * 2銆佹寜閽寘鎷甯哥紪杈戝拰澶嶅埗锛屽鍒舵椂,鏈熬娣诲姞,濡傛寜閽负琛ㄥ崟锛堜繚瀛樿嚦鏁版嵁搴擄級锛屽鍒舵寜閽甶d瀛樹簬澶嶅埗鍒楄〃锛堢偣鍑讳笉淇濆瓨鏃跺垹闄わ級 - * 3銆佸鎸夐挳浣嶇疆璁剧疆涓鸿〃鏍硷紝鍒欎慨鏀规搷浣滃垪鏄剧ず鐘舵�� - */ - handleSubmit = () => { - const { menu } = this.props - const { config, card, modaltype, optionLibs } = this.state - - if (modaltype === 'search') { - this.searchFormRef.handleConfirm().then(res => { - if ( // 鏇存柊涓嬫媺瀛楀吀 - (res.type === 'select' || res.type === 'multiselect' || res.type === 'link') && - res.resourceType === '0' && - res.options && res.options.length > 0 - ) { - optionLibs.set(menu.MenuID + res.uuid, { - uuid: menu.MenuID + res.uuid, - label: res.label, - parname: menu.MenuName, - type: 'search', - options: res.options - }) - } - - let _search = config.search.map(item => { - if (item.uuid === res.uuid) { - return res - } else { - return item - } - }) - _search = _search.filter(item => !item.origin) - - this.setState({ - config: {...config, search: _search}, - optionLibs: optionLibs, - modaltype: '' - }) - }) - } else if (modaltype === 'actionEdit' || modaltype === 'actionCopy') { - this.actionFormRef.handleConfirm().then(res => { - let _action = config.action.map(item => { - if (item.uuid === res.uuid) { - return res - } else { - return item - } - }) - _action = _action.filter(item => !item.origin) - - if (modaltype === 'actionCopy') { - _action.push(res) - } - - // 澶嶅埗鎸夐挳鍓嶅悗鐨嗕负琛ㄥ崟鏃讹紝澶嶅埗琛ㄥ崟閰嶇疆淇℃伅锛宨d瀛樹簬澶嶅埗鍒楄〃 - if (res.OpenType === 'pop' && card.originCard && card.originCard.OpenType === 'pop') { - Api.getSystemConfig({ - func: 'sPC_Get_LongParam', - MenuID: card.originCard.uuid - }).then(result => { - if (result.status && result.LongParam) { - let _LongParam = '' - - // 瑙f瀽閰嶇疆锛屼慨鏀规ā鎬佹鏍囬鍚嶇О - if (result.LongParam) { - try { - _LongParam = JSON.parse(window.decodeURIComponent(window.atob(result.LongParam))) - } catch (e) { - console.warn('Parse Failure') - _LongParam = '' - } - } - if (_LongParam && _LongParam.type === 'Modal') { - try { - _LongParam.setting.title = res.label - _LongParam = window.btoa(window.encodeURIComponent(JSON.stringify(_LongParam))) - } catch { - console.warn('Stringify Failure') - _LongParam = '' - } - } else { - _LongParam = '' - } - - let param = { - func: 'sPC_ButtonParam_AddUpt', - ParentID: menu.MenuID, - MenuID: res.uuid, - MenuNo: menu.MenuNo, - Template: 'Modal', - MenuName: res.label, - PageParam: JSON.stringify({Template: 'Modal'}), - LongParam: _LongParam - } - Api.getSystemConfig(param).then(response => { - if (!response.status) { - notification.warning({ - top: 92, - message: response.message, - duration: 10 - }) - } else { - this.setState({ - copyActions: [...this.state.copyActions, res.uuid] - }) - } - }) - } - }) - } else if ( - (res.OpenType === 'tab' || res.OpenType === 'blank') && - card.originCard && - (card.originCard.OpenType === 'tab' || card.originCard.OpenType === 'blank') - ) { - Api.getSystemConfig({ - func: 'sPC_Get_LongParam', - MenuID: card.originCard.uuid - }).then(result => { - if (result.status && result.LongParam) { - let _LongParam = '' - - // 瑙f瀽閰嶇疆锛屼慨鏀规ā鎬佹鏍囬鍚嶇О - if (result.LongParam) { - try { - _LongParam = JSON.parse(window.decodeURIComponent(window.atob(result.LongParam))) - } catch (e) { - console.warn('Parse Failure') - _LongParam = '' - } - } - - let _temp = '' - if (_LongParam && _LongParam.type === 'FormTab') { - try { - _LongParam.action = _LongParam.action.map(_btn => { - _btn.uuid = Utils.getuuid() - - return _btn - }) - _LongParam.tabgroups.forEach(_groupId => { - _LongParam[_groupId] = _LongParam[_groupId].map(_tab => { - _tab.uuid = Utils.getuuid() - - return _tab - }) - }) - _LongParam = window.btoa(window.encodeURIComponent(JSON.stringify(_LongParam))) - _temp = 'FormTab' - } catch { - console.warn('Stringify Failure') - _LongParam = '' - } - } else { - _LongParam = '' - } - - if (!_temp) return - - let param = { - func: 'sPC_ButtonParam_AddUpt', - ParentID: menu.MenuID, - MenuID: res.uuid, - MenuNo: menu.MenuNo, - Template: _temp, - MenuName: res.label, - PageParam: JSON.stringify({Template: _temp}), - LongParam: _LongParam - } - - Api.getSystemConfig(param).then(response => { - if (!response.status) { - notification.warning({ - top: 92, - message: response.message, - duration: 10 - }) - } else { - this.setState({ - copyActions: [...this.state.copyActions, res.uuid] - }) - } - }) - } - }) - } - - // 鍒ゆ柇鏄惁瀛樺湪鎿嶄綔鍒� - let _hasGridbtn = _action.filter(act => act.position === 'grid').length > 0 - let _gridBtn = config.gridBtn - - if (_gridBtn) { - _gridBtn.display = _hasGridbtn - } else { - _gridBtn = { - display: _hasGridbtn, - Align: 'center', - IsSort: 'false', - uuid: Utils.getuuid(), - label: this.state.dict['header.form.column.action'], - type: 'action', - style: 'button', - show: 'horizontal', - Width: 120 - } - } - - this.setState({ - config: {...config, action: _action, gridBtn: _gridBtn}, - modaltype: '' - }) - }) - } else if (modaltype === 'columns' || modaltype === 'colspan') { - this.columnFormRef.handleConfirm().then(res => { - let _columns = config.columns.map(item => { - if (item.uuid === res.uuid) { - return res - } else { - return item - } - }) - _columns = _columns.filter(item => !item.origin) - - this.setState({ - config: {...config, columns: _columns}, - modaltype: '' - }) - }) - } else if (modaltype === 'gridbtn') { - this.gridBtnFormRef.handleConfirm().then(res => { - this.setState({ - config: {...config, gridBtn: res}, - 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: '' - }) - }) - } - } - - /** - * @description 鍙栨秷淇濆瓨锛屽鏋滃厓绱犱负鏂版坊鍏冪礌锛屽垯浠庡簭鍒椾腑鍒犻櫎 - */ - editModalCancel = () => { - const { config, card, modaltype } = this.state - - if (card.focus) { - let _config = null - if (modaltype === 'search') { - let _search = config.search.filter(item => item.uuid !== card.uuid) - _config = {...config, search: _search} - } else if (modaltype === 'actionEdit') { - let _action = config.action.filter(item => item.uuid !== card.uuid) - _config = {...config, action: _action} - } else if (modaltype === 'columns' || modaltype === 'colspan') { - let _columns = config.columns.filter(item => item.uuid !== card.uuid) - _config = {...config, columns: _columns} - } else if (modaltype === 'tabs') { - let _tabgroup = config[card.groupId].filter(item => item.uuid !== card.uuid) - _config = {...config, [card.groupId]: _tabgroup} - } else { - _config = config - } - - this.setState({ - card: null, - config: _config, - modaltype: '' - }) - } else { - this.setState({ - card: null, - modaltype: '' - }) - } - } - - /** - * @description 鎸夐挳-鍒涘缓瀛樺偍杩囩▼ - */ - creatFunc = () => { - const { menu } = this.props - const { config } = this.state - - this.actionFormRef.handleConfirm().then(res => { - let btn = res // 鎸夐挳淇℃伅 - let newLText = '' // 鍒涘缓瀛樺偍杩囩▼sql - let DelText = '' // 鍒犻櫎瀛樺偍杩囩▼sql - - // 鍒涘缓瀛樺偍杩囩▼锛屽繀椤诲~鍐欏唴閮ㄥ嚱鏁板悕 - if (!btn.innerFunc) { - notification.warning({ - top: 92, - message: '璇峰~鍐欏唴閮ㄥ嚱鏁帮紒', - duration: 10 - }) - return - } - - new Promise(resolve => { - // 寮圭獥锛堣〃鍗曪級绫绘寜閽紝鍏堣幏鍙栨寜閽厤缃俊鎭紝濡傛灉灏氭湭閰嶇疆鎸夐挳鍒欎細鎶ラ敊骞剁粓姝€�� - // 鑾峰彇淇℃伅鍚庣敓鎴愬垹闄ゅ拰鍒涘缓瀛樺偍杩囩▼鐨勮鍙� - if (btn.OpenType === 'pop') { - Api.getSystemConfig({ - func: 'sPC_Get_LongParam', - MenuID: btn.uuid - }).then(res => { - let _LongParam = '' - if (res.status && res.LongParam) { - try { - _LongParam = JSON.parse(window.decodeURIComponent(window.atob(res.LongParam))) - } catch (e) { - console.warn('Parse Failure') - _LongParam = '' - } - } - - if (_LongParam) { - let fields = [] - if (_LongParam.groups.length > 0) { - _LongParam.groups.forEach(group => { - fields = [...fields, ...group.sublist] - }) - } else { - fields = _LongParam.fields - } - - let _param = { - funcName: btn.innerFunc, - name: config.setting.tableName || '', - fields: fields, - menuNo: menu.MenuNo - } - newLText = Utils.formatOptions(Utils.getfunc(_param, btn, menu, config)) - DelText = Utils.formatOptions(Utils.dropfunc(_param.funcName)) - resolve(true) - } else { - notification.warning({ - top: 92, - message: '寮圭獥锛堣〃鍗曪級鎸夐挳锛岃鍏堥厤缃〃鍗曚俊鎭紒', - duration: 10 - }) - resolve(false) - } - }) - } else if (btn.OpenType === 'excelIn') { - if (btn.verify && btn.verify.sheet && btn.verify.columns && btn.verify.columns.length > 0) { - let _param = { - funcName: btn.innerFunc, - menuNo: menu.MenuNo - } - newLText = Utils.formatOptions(Utils.getexcelInfunc(_param, btn, menu)) - DelText = Utils.formatOptions(Utils.dropfunc(_param.funcName)) - resolve(true) - } else { - notification.warning({ - top: 92, - message: '璇峰畬鍠勫鍏xcel楠岃瘉淇℃伅锛�', - duration: 10 - }) - resolve(false) - } - } else if (btn.OpenType === 'excelOut') { - let _param = { - innerFunc: btn.innerFunc - } - - newLText = Utils.formatOptions(Utils.getTableFunc(_param, menu, config )) - DelText = Utils.formatOptions(Utils.dropfunc(btn.innerFunc)) - resolve(true) - } else { - let _param = { - funcName: btn.innerFunc, - name: config.setting.tableName || '', - fields: '', - menuNo: menu.MenuNo - } - newLText = Utils.formatOptions(Utils.getfunc(_param, btn, menu, config)) - DelText = Utils.formatOptions(Utils.dropfunc(_param.funcName)) - resolve(true) - } - }).then(res => { - if (!res) return - - this.refs.btnCreatFunc.exec(btn.innerFunc, newLText, DelText).then(result => { - if (result !== 'success') return - - let _action = config.action.map(item => { - if (item.uuid === btn.uuid) { - return btn - } else { - return item - } - }) - _action = _action.filter(item => !item.origin) - - // 鍒ゆ柇鏄惁瀛樺湪鎿嶄綔鍒� - let _hasGridbtn = _action.filter(act => act.position === 'grid').length > 0 - let _gridBtn = config.gridBtn - - if (_gridBtn) { - _gridBtn.display = _hasGridbtn - } else { - _gridBtn = { - display: _hasGridbtn, - Align: 'center', - IsSort: 'false', - uuid: Utils.getuuid(), - label: this.state.dict['header.form.column.action'], - type: 'action', - style: 'button', - show: 'horizontal', - Width: 120 - } - } - - this.setState({ - config: {...config, action: _action, gridBtn: _gridBtn} - }) - }) - }) - }) - } - - /** - * @description 鍒涘缓琛ㄦ牸瀛樺偍杩囩▼ - */ - tableCreatFunc = () => { - const { menu } = this.props - const { config } = this.state - - this.settingRef.handleConfirm().then(setting => { - - if (!(setting.interType === 'inner') || !setting.innerFunc) { - notification.warning({ - top: 92, - message: '鎺ュ彛绫诲瀷涓�-鍐呴儴锛屼笖瀛樺湪鍐呴儴鍑芥暟鏃讹紝鎵嶅彲浠ュ垱寤哄瓨鍌ㄨ繃绋嬶紒', - duration: 10 - }) - return - } - - if (/[^\s]+\s+[^\s]+/ig.test(setting.dataresource) && config.setting.dataresource !== setting.dataresource) { - let param = { - func: 's_DataSrc_Save', - LText: setting.dataresource, - MenuID: menu.MenuID - } - - param.LText = Utils.formatOptions(param.LText) - param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' - param.secretkey = Utils.encrypt(param.LText, param.timestamp) - - Api.getLocalConfig(param) - } - - let _config = {...config, setting: setting} - let newLText = Utils.formatOptions(Utils.getTableFunc(setting, menu, _config)) // 鍒涘缓瀛樺偍杩囩▼sql - let DelText = Utils.formatOptions(Utils.dropfunc(setting.innerFunc)) // 鍒犻櫎瀛樺偍杩囩▼sql - - this.refs.tableCreatFunc.exec(setting.innerFunc, newLText, DelText).then(result => { - if (result === 'success') { - this.setState({ - config: _config - }) - } - }) - }) - } - - /** - * @description 鍒涘缓琛ㄦ牸鎺ュ彛 - */ - tableCreatInterface = () => { - const { menu } = this.props - const { config } = this.state - - this.menuformRef.handleConfirm().then(res => { - this.settingRef.handleConfirm().then(setting => { - if (/[^\s]+\s+[^\s]+/ig.test(setting.dataresource) && config.setting.dataresource !== setting.dataresource) { - let param = { - func: 's_DataSrc_Save', - LText: setting.dataresource, - MenuID: menu.MenuID - } - - param.LText = Utils.formatOptions(param.LText) - param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' - param.secretkey = Utils.encrypt(param.LText, param.timestamp) - - Api.getLocalConfig(param) - } - - if (setting.interType !== 'inner' || setting.innerFunc) { - notification.warning({ - top: 92, - message: '鎺ュ彛绫诲瀷涓�-鍐呴儴锛屼笖涓嶅瓨鍦ㄥ唴閮ㄥ嚱鏁版椂锛屾墠鍙互鍒涘缓鎺ュ彛锛�', - duration: 10 - }) - return - } - - let _config = {...config, setting: setting} - let _menu = { - type: 'main', - MenuID: menu.MenuID, - menuName: res.menuName, - menuNo: res.menuNo - } - - this.refs.tableCreatInterface.exec(_menu, _config).then(result => { - if (result === 'success') { - this.setState({ - config: _config - }) - } - }) - }) - }) - } - - deleteElement = (element) => { - const { config, thawButtons } = this.state - let _this = this - - confirm({ - content: `纭畾鍒犻櫎<<${element.card.label}>>鍚楋紵`, - okText: this.state.dict['header.confirm'], - cancelText: this.state.dict['header.cancel'], - onOk() { - let _config = null - - if (element.type === 'tabs') { - let _tabgroup = config[element.card.groupId].filter(item => { - if (item.uuid === element.card.uuid) { - return false - } else { - return true - } - }) - _config = {...config, [element.card.groupId]: _tabgroup} - } else { - let list = config[element.type].filter(item => { - if (item.uuid === element.card.uuid) { - return false - } else { - return true - } - }) - - _config = {...config, [element.type]: list} - - // 鍒犻櫎鎸夐挳鏃跺垽鏂槸鍚﹀瓨鍦ㄦ搷浣滃垪 - if (element.type === 'action' && _config.gridBtn) { - _config.gridBtn.display = _config.action.filter(act => act.position === 'grid').length > 0 - } - } - - // 鍒犻櫎鎸夐挳鍏冪礌 - let _delActions = _this.state.delActions - if (element.type === 'action' || element.type === 'tabs') { - _delActions.push(element) - } - - _this.setState({ - config: _config, - delActions: _delActions, - thawButtons: thawButtons.filter(key => key !== element.card.uuid) - }) - }, - onCancel() {} - }) - } - - /** - * @description 楠岃瘉淇℃伅閰嶇疆 - */ - profileAction = (element) => { - this.setState({ - profileVisible: true, - card: element - }) - } - - /** - * @description 楠岃瘉淇℃伅淇濆瓨 - */ - verifySubmit = () => { - const { card } = this.state - let config = JSON.parse(JSON.stringify(this.state.config)) - - if (card.OpenType === 'excelIn') { - 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: '', - }) - }) - } else if (card.execMode) { - 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: '', - }) - }) - } else { - let _verify = this.verifyRef.state.verify - - if (card.OpenType !== 'excelOut' && _verify.default === 'false' && _verify.scripts.length === 0) { - notification.warning({ - top: 92, - message: '涓嶆墽琛岄粯璁ql鏃讹紝蹇呴』璁剧疆鑷畾涔夎剼鏈紒', - duration: 10 - }) - return - } else if (card.OpenType === 'excelOut') { - let _cols = _verify.columns.map(col => col.Column) - let _vcols = Array.from(new Set(_cols)) - if (_cols.length > _vcols.length) { - notification.warning({ - top: 92, - message: 'Excel鍒楀瓧娈靛悕锛屼笉鍙噸澶�!', - duration: 10 - }) - - return - } - } - - config.action = config.action.map(item => { - if (item.uuid === card.uuid) { - item.verify = _verify - } - - return item - }) - - this.setState({ - profileVisible: false, - config: config, - card: '', - }) - } - } - - /** - * @description 涓夌骇鑿滃崟鍒囨崲妯℃澘 - */ - changeTemplate = () => { - this.props.handleView({tabview: 'template'}) } getFuncNames = (data, funcNames, tableNames) => { @@ -1322,24 +315,16 @@ */ submitConfig = () => { const { menu } = this.props - const { originMenu, delActions, thawButtons } = this.state + const { originMenu, delActions, thawButtons, openEdition } = this.state - let config = JSON.parse(JSON.stringify(this.state.config)) + let config = fromJS(this.state.config).toJS() this.menuformRef.handleConfirm().then(res => { if (config.isAdd) { - if (config.search[0] && config.search[0].origin) { - config.search = config.search.filter(item => !item.origin) - } - if (config.action[0] && config.action[0].origin) { - config.action = config.action.filter(item => !item.origin) - } - if (config.columns[0] && config.columns[0].origin) { - config.columns = config.columns.filter(item => !item.origin) - } - if (config.tabs[0] && config.tabs[0].origin) { - config.tabs = config.tabs.filter(item => !item.origin) - } + config.search = config.search.filter(item => !item.origin) + config.action = config.action.filter(item => !item.origin) + config.columns = config.columns.filter(item => !item.origin) + config.tabgroups[0].sublist = config.tabgroups[0].sublist.filter(item => !item.origin) } if (config.type === 'user') { // 浣跨敤宸叉湁鑿滃崟鏃讹紝榛樿娣诲姞鍏宠仈鏍囩id @@ -1351,31 +336,23 @@ }) config.tabgroups.forEach(group => { - config[group] = config[group].map(tab => { + group.sublist = group.sublist.map(tab => { if (!tab.linkTab) { tab.linkTab = Utils.getuuid() } - return tab }) }) } let _LongParam = '' - let _config = {...config, tables: this.state.selectedTables} + let _config = {...config, easyCode: res.easyCode} let _pageParam = {...menu.PageParam, OpenType: res.opentype} // 鏈缃暟鎹簮鎴栨爣绛句笉鍚堟硶鏃讹紝鍚敤鐘舵�佷负false - if (_config.setting.interType === 'inner' && !_config.setting.innerFunc && !_config.setting.dataresource) { + let vresult = this.verifyconfig(_config) + if (vresult !== true) { _config.enabled = false - } else if (!_config.setting.primaryKey) { - _config.enabled = false - } else if (_config.tabgroups.length > 1) { - _config.tabgroups.forEach(group => { - if (_config[group].length === 0) { - _config.enabled = false - } - }) } _config.funcs = [] // 椤甸潰鍙婂瓙椤甸潰瀛樺偍杩囩▼闆� @@ -1430,10 +407,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', @@ -1506,7 +481,7 @@ notification.warning({ top: 92, message: '缂栬瘧閿欒', - duration: 10 + duration: 5 }) this.setState({ menucloseloading: false, @@ -1522,7 +497,7 @@ func: 'sPC_Button_AddUpt', Type: 40, // 娣诲姞鑿滃崟涓嬬殑鎸夐挳type涓�40锛屾寜閽笅鐨勬寜閽畉ype涓�60 ParentID: menu.MenuID, - MenuNo: res.menuNo, + MenuNo: res.MenuNo, Template: menu.PageParam.Template || '', PageParam: '', LongParam: '', @@ -1558,8 +533,8 @@ 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(groupId => { - _config[groupId].forEach(item => { + _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`) }) @@ -1580,9 +555,10 @@ SndID: res.parentId, ParentID: res.parentId, MenuID: menu.MenuID, - MenuNo: res.menuNo, + MenuNo: res.MenuNo, + EasyCode: res.easyCode, Template: menu.PageParam.Template || '', - MenuName: res.menuName, + MenuName: res.MenuName, PageParam: JSON.stringify(_pageParam), LongParam: _LongParam, LText: _vals.func.map(item => `select '${menu.MenuID}' as MenuID,'${item.func}' as ProcName,'${item.label}' as MenuName`), @@ -1600,6 +576,10 @@ param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' param.secretkey = Utils.encrypt(param.LText, param.timestamp) + if (openEdition) { // 鐗堟湰绠$悊 + param.open_edition = openEdition + } + // 鏈夋寜閽垨鏍囩鍒犻櫎鏃讹紝鍏堣繘琛屽垹闄ゆ搷浣� // 鍒犻櫎鎴愬姛鍚庯紝淇濆瓨椤甸潰閰嶇疆 new Promise(resolve => { @@ -1607,7 +587,7 @@ let deffers = delActions.map(item => { let _param = { func: 'sPC_MainMenu_Del', - MenuID: item.card.uuid + MenuID: item.card ? item.card.uuid : item.uuid } if (item.type === 'action') { @@ -1647,7 +627,7 @@ notification.warning({ top: 92, message: error.message, - duration: 10 + duration: 5 }) resolve(false) } else { @@ -1691,7 +671,7 @@ notification.warning({ top: 92, message: msg, - duration: 10 + duration: 5 }) return false } else { @@ -1702,7 +682,7 @@ } }).then(resp => { if (resp === false) return - let localParam = JSON.parse(JSON.stringify(param)) + let localParam = fromJS(param).toJS() Api.getSystemConfig(param).then(response => { if (response.status) { @@ -1714,18 +694,19 @@ this.setState({ config: _config, + openEdition: response.open_edition || '', originMenu: { ...originMenu, LongParam: _config, PageParam: _pageParam, - MenuName: res.menuName, - MenuNo: res.menuNo, + MenuName: res.MenuName, + MenuNo: res.MenuNo, ParentID: res.parentId, fstMenuId: res.fstMenuId, supMenuList: _supMenuList } }) - + this.props.reloadmenu() this.submitAction(btnParam, tabParam) @@ -1735,6 +716,8 @@ delete localParam.PageParam delete localParam.Template delete localParam.Sort + delete localParam.EasyCode + delete localParam.open_edition Api.getLocalConfig(localParam) } else { @@ -1745,7 +728,7 @@ notification.warning({ top: 92, message: response.message, - duration: 10 + duration: 5 }) } }) @@ -1755,7 +738,7 @@ notification.warning({ top: 92, message: this.state.dict['header.menu.basemsg'], - duration: 10 + duration: 5 }) }) } @@ -1807,7 +790,7 @@ notification.warning({ top: 92, message: error.message, - duration: 10 + duration: 5 }) resolve(false) } else { @@ -1862,13 +845,27 @@ return _btn }) - _subconfig.tabgroups.forEach(_groupId => { - _subconfig[_groupId] = _subconfig[_groupId].map(_tab => { - _tab.uuid = Utils.getuuid() - - if (_tab.linkTab) { - _tab.linkTab = '' + + // 鍏煎宸叉湁缁撴瀯 + 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 }) @@ -1939,7 +936,7 @@ if (config.isAdd) { confirm({ content: '鑿滃崟灏氭湭鎻愪氦锛岀‘瀹氭斁寮冧繚瀛樺悧锛�', - okText: this.state.dict['header.confirm'], + okText: this.state.dict['model.confirm'], cancelText: this.state.dict['header.cancel'], onOk() { _this.props.handleView() @@ -1948,14 +945,14 @@ }) } else { this.menuformRef.handleConfirm().then(res => { - let _config = {...config, tables: this.state.selectedTables} + let _config = {...config, easyCode: res.easyCode} let _pageParam = {...menu.PageParam, OpenType: res.opentype} let _originMenu = { ...originMenu, LongParam: _config, PageParam: _pageParam, - MenuName: res.menuName, - MenuNo: res.menuNo, + MenuName: res.MenuName, + MenuNo: res.MenuNo, ParentID: res.parentId, fstMenuId: res.fstMenuId } @@ -1976,346 +973,28 @@ } /** - * @description 绛涢�夊彲鐢ㄥ瓧娈甸泦 - */ - queryField = (type) => { - const {selectedTables, tableColumns, config} = this.state - // 鍒ゆ柇鏄惁宸查�夋嫨琛ㄥ悕 - if (selectedTables.length === 0) { - notification.warning({ - top: 92, - message: '璇烽�夋嫨琛ㄥ悕锛�', - duration: 10 - }) - return - } - - // 琛ㄥ瓧娈甸泦杞负map鏁版嵁 - let columns = new Map() - tableColumns.forEach(table => { - table.columns.forEach(column => { - columns.set(column.field, column) - }) - }) - - if (type === 'search') { - // 娣诲姞鎼滅储鏉′欢锛屽瓧娈甸泦涓瓨鍦ㄦ悳绱㈡潯浠跺瓧娈碉紝浣跨敤鎼滅储鏉′欢瀵硅薄鏇挎崲瀛楁闆嗭紝璁剧疆鏁版嵁绫诲瀷 - config.search.forEach(item => { - if (columns.has(item.field)) { - let _datatype = columns.get(item.field).datatype - columns.set(item.field, {...item, selected: true, datatype: _datatype}) - } - }) - } else if (type === 'columns') { - // 娣诲姞鏄剧ず鍒楋紝瀛楁闆嗕腑瀛樺湪鏄剧ず鍒楀瓧娈碉紝浣跨敤鏄剧ず鍒楀璞℃浛鎹㈠瓧娈甸泦锛岃缃暟鎹被鍨� - config.columns.forEach(item => { - if (columns.has(item.field)) { - let _datatype = columns.get(item.field).datatype - columns.set(item.field, {...item, selected: true, datatype: _datatype}) - } - }) - } - - // 鏄剧ず瀛楁闆嗗脊绐� - this.setState({ - addType: type, - tableVisible: true, - fields: [...columns.values()] - }) - } - - /** - * @description 娣诲姞瀛楁闆� - */ - addFieldSubmit = () => { - const {addType, config} = this.state - - // 瀛楁闆嗕负绌猴紝鍏抽棴寮圭獥 - if (!this.state.fields || this.state.fields.length === 0) { - this.setState({ - tableVisible: false, - addType: '' - }) - } - - const textmatch = { // 閫夋嫨text鏃跺尮閰嶈鍒� - text: 'like', - number: 'like', - datetime: 'like', - date: 'like' - } - const selectmatch = { // 閫夋嫨select鏃跺尮閰嶈鍒� - text: '=', - number: '=', - datetime: '=', - date: '=' - } - const datematch = { // 閫夋嫨dateRange鏃跺尮閰嶈鍒� - text: 'between', - number: 'between', - datetime: 'between', - date: 'between' - } - - // 鑾峰彇宸查�夊瓧娈甸泦鍚� - let cards = this.refs.searchcard.state.selectCards - - if (cards.length === 0) { - notification.warning({ - top: 92, - message: '璇烽�夋嫨娣诲姞瀛楁', - duration: 10 - }) - return - } - - let columnsMap = new Map() - cards.forEach(card => { - columnsMap.set(card.field, card) - }) - - if (addType === 'search') { - let _search = config.search.filter(item => !item.origin) - - // 閲嶇疆鍘熸湁鎼滅礌鏉′欢 - _search = _search.map(item => { - if (columnsMap.has(item.field)) { - let cell = columnsMap.get(item.field) - - if (cell.type !== item.type) { // 鏁版嵁绫诲瀷淇敼 - if (cell.type === 'select') { - item.match = selectmatch[cell.datatype] - } else if (cell.type === 'daterange') { - item.match = datematch[cell.datatype] - } else { - cell.type = 'text' - item.match = textmatch[cell.datatype] - } - - item.type = cell.type - item.initval = '' - } - columnsMap.delete(item.field) - } - return item - }) - - let _columns = [...columnsMap.values()] - - // 椤哄簭娣诲姞鏂板鎼滅储 - _columns.forEach(item => { - let _match = '' - if (item.type === 'select') { - _match = selectmatch[item.datatype] - } else if (item.type === 'daterange') { - _match = datematch[item.datatype] - } else { - _match = textmatch[item.datatype] - } - - let newcard = { - uuid: Utils.getuuid(), - label: item.label, - field: item.field, - initval: '', - type: item.type || 'text', - resourceType: '0', - setAll: 'false', - options: [], - orderType: 'asc', - match: _match, - display: 'dropdown' - } - - _search.push(newcard) - }) - - this.setState({ - config: {...config, search: _search} - }) - } else { - let _columns = config.columns.filter(item => !item.origin) - - // 閲嶇疆鍘熸湁鏄剧ず鍒楃被鍨� - _columns = _columns.map(item => { - if (columnsMap.has(item.field)) { - let cell = columnsMap.get(item.field) - - if (cell.type) { - item.type = cell.type - } - - columnsMap.delete(item.field) - } - return item - }) - - let _cols = [...columnsMap.values()] - - // 娣诲姞鏄剧ず鍒� - _cols.forEach(item => { - let newcard = { - uuid: Utils.getuuid(), - Align: 'left', - label: item.label, - field: item.field, - Hide: 'false', - IsSort: item.type === 'picture' ? 'false' : 'true', - type: item.type, - Width: 120 - } - - _columns.push(newcard) - }) - - this.setState({ - config: {...config, columns: _columns} - }) - } - - notification.success({ - top: 92, - message: '鎿嶄綔鎴愬姛', - duration: 2 - }) - } - - /** - * @description 琛ㄥ悕鍒囨崲鏃讹紝娣诲姞琛ㄥ悕锛屾柊澧炴椂鏌ヨ琛ㄧ浉鍏冲瓧娈� - */ - onTableChange = (value) => { - const {tables, selectedTables, tableColumns} = this.state - - let _table = tables.filter(item => item.TbName === value)[0] - let isSelected = !!selectedTables.filter(cell => cell.TbName === value)[0] - if (!isSelected) { - this.setState({ - selectedTables: [...selectedTables, _table] - }) - Api.getSystemConfig({func: 'sPC_Get_FieldName', TBName: value}).then(res => { - if (res.status) { - let tabmsg = { - tableName: _table.name, - columns: res.FDName.map(item => { - let _type = item.FieldType.toLowerCase() - let _decimal = 0 - if (/^nvarchar/.test(_type)) { - _type = 'text' - } else if (/^int/.test(_type)) { - _type = 'number' - } else if (/^decimal/.test(_type)) { - _decimal = _type.split(',')[1] - _decimal = parseInt(_decimal) - _type = 'number' - } else if (/^datetime/.test(_type)) { - _type = 'datetime' - } else if (/^date/.test(_type)) { - _type = 'date' - } else { - _type = 'text' - } - - return { - field: item.FieldName, - label: item.FieldDec, - type: _type, - datatype: _type, - decimal: _decimal - } - }) - } - this.setState({ - tableColumns: [...tableColumns, tabmsg] - }) - } else { - notification.warning({ - top: 92, - message: res.message, - duration: 10 - }) - } - }) - } - } - - /** - * @description 鍒犻櫎琛ㄥ悕浠ュ強琛ㄧ浉鍏冲瓧娈� - */ - deleteTable = (table) => { - const {selectedTables, tableColumns} = this.state - - this.setState({ - selectedTables: selectedTables.filter(item => item.TbName !== table.TbName), - tableColumns: tableColumns.filter(item => item.tableName !== table.TbName) - }) - } - - /** - * @description 椤甸潰閰嶇疆淇℃伅妯℃�佹鏄剧ず - */ - changeSetting = () => { - this.setState({ - settingVisible: true - }) - } - - /** - * @description 淇濆瓨椤甸潰閰嶇疆淇℃伅 - */ - settingSave = () => { - const { menu } = this.props - const {config} = this.state - - this.settingRef.handleConfirm().then(res => { - if ( - res.interType === 'inner' && - !res.innerFunc && - /[^\s]+\s+[^\s]+/ig.test(res.dataresource) && - config.setting.dataresource !== res.dataresource - ) { - let param = { - func: 's_DataSrc_Save', - LText: res.dataresource, - MenuID: menu.MenuID - } - - param.LText = Utils.formatOptions(param.LText) - param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' - param.secretkey = Utils.encrypt(param.LText, param.timestamp) - - Api.getLocalConfig(param) - } - - this.setState({ - config: {...config, setting: res}, - settingVisible: false, - }) - }) - } - - /** * @description 璁剧疆鍙厤缃寜閽� */ setSubConfig = (item, type) => { const { menu } = this.props - const { config, originMenu, optionLibs, activeKey } = this.state + const { config, originMenu, optionLibs, activeKey, openEdition } = this.state if (!originMenu.MenuID) { // menuID涓嶅瓨鍦ㄦ椂锛屼负鏂板缓鑿滃崟锛屾彁绀鸿彍鍗曞皻鏈繚瀛� notification.warning({ top: 92, message: this.state.dict['header.menu.config.notsave'], - duration: 10 + duration: 5 }) } else { this.menuformRef.handleConfirm().then(res => { - let _config = {...config, tables: this.state.selectedTables} + let _config = {...config, easyCode: res.easyCode} let _pageParam = {...menu.PageParam, OpenType: res.opentype} let _originMenu = { ...originMenu, LongParam: _config, PageParam: _pageParam, - MenuName: res.menuName, - MenuNo: res.menuNo, + MenuName: res.MenuName, + MenuNo: res.MenuNo, ParentID: res.parentId, fstMenuId: res.fstMenuId } @@ -2324,7 +1003,7 @@ notification.warning({ top: 92, message: this.state.dict['header.menu.config.update'], - duration: 10 + duration: 5 }) return } @@ -2350,8 +1029,8 @@ isbutton = false } - // 淇濆瓨褰撳墠鎵撳紑椤电 - _originMenu.activeKey = activeKey + _originMenu.activeKey = activeKey // 淇濆瓨褰撳墠鎵撳紑椤电 + _originMenu.open_edition = openEdition // 鏇存柊鐗堟湰鍙� let param = { optionLibs: optionLibs, @@ -2365,6 +1044,11 @@ editAction: isbutton ? item : '', subConfig: '', tabview: _view + } + + // 褰撳瓙琛ㄤ娇鐢ㄤ富椤垫悳绱㈡潯浠舵椂锛屽皢涓婚〉鎼滅储鍚戜笅浼犻�� + if (param.editTab && param.editTab.searchPass === 'true') { + param.editTab.mainsearch = fromJS(_config.search).toJS() } this.setState({ @@ -2397,6 +1081,14 @@ param.subConfig = _LongParam } + if (param.editTab) { + param.editTab.open_edition = res.open_edition || '' + } else if (param.editAction) { + param.editAction.open_edition = res.open_edition || '' + } else if (param.btnTab) { + param.btnTab.open_edition = res.open_edition || '' + } + this.props.handleView(param) } else { this.setState({ @@ -2405,7 +1097,7 @@ notification.warning({ top: 92, message: res.message, - duration: 10 + duration: 5 }) } }) @@ -2413,7 +1105,7 @@ notification.warning({ top: 92, message: this.state.dict['header.menu.config.update'], - duration: 10 + duration: 5 }) }) } @@ -2425,221 +1117,62 @@ onEnabledChange = () => { const { config } = this.state + let _enabled = !config.enabled + let result = this.verifyconfig(config) + if (_enabled && result !== true) { + notification.warning({ + top: 92, + message: result, + duration: 5 + }) + return + } + + this.setState({ + config: {...config, enabled: _enabled} + }) + } + + /** + * @description 鏍¢獙閰嶇疆淇℃伅鐨勫悎娉曟�� + */ + verifyconfig = (config) => { let tabinvalid = true if (config.tabgroups.length > 1) { config.tabgroups.forEach(group => { - if (config[group].length === 0) { + if (group.sublist.length === 0) { tabinvalid = false } }) } - if (config.setting.interType === 'inner' && !config.setting.innerFunc && !config.setting.dataresource) { - notification.warning({ - top: 92, - message: '鑿滃崟灏氭湭璁剧疆鏁版嵁婧愶紝涓嶅彲鍚敤锛�', - duration: 10 - }) + let charterr = '' + config.charts.forEach(chart => { + if (!charterr && ['line', 'bar', 'pie'].includes(chart.chartType) && !chart.Xaxis) { + charterr = '鍥捐〃' + (chart.title ? '銆�' + chart.title + '銆�' : '') + '鍧愭爣杞存湭璁剧疆锛屼笉鍙惎鐢紒' + } + }) + + let hasKey = false + config.columns.forEach(col => { + if (config.setting.primaryKey === col.field) { + hasKey = true + } + }) + + if (config.setting.interType === 'inner' && !config.setting.innerFunc && config.setting.default !== 'false' && !config.setting.dataresource) { + return '鑿滃崟灏氭湭璁剧疆鏁版嵁婧愶紝涓嶅彲鍚敤锛�' } else if (!config.setting.primaryKey) { - notification.warning({ - top: 92, - message: '鑿滃崟灏氭湭璁剧疆涓婚敭锛屼笉鍙惎鐢紒', - duration: 10 - }) + return '鑿滃崟灏氭湭璁剧疆涓婚敭锛屼笉鍙惎鐢紒' + } else if (!hasKey) { + return '鏄剧ず鍒椾腑涓嶅瓨鍦ㄤ富閿瓧娈碉紝涓嶅彲鍚敤锛�' } else if (!tabinvalid) { - notification.warning({ - top: 92, - message: '鑿滃崟鏍囩椤佃缃敊璇紙澶氳鏍囩鍐咃紝琛屾爣绛句笉鍙负绌猴級锛屼笉鍙惎鐢紒', - duration: 10 - }) + return '鑿滃崟鏍囩椤佃缃敊璇紙瀛樺湪澶氳鏍囩鏃讹紝琛屾爣绛句笉鍙负绌猴級锛�' + } else if (charterr) { + return charterr } else { - this.setState({ - config: {...config, enabled: !config.enabled} - }) + return true } - } - - /** - * @description 鏄剧ず闅愯棌鏄剧ず鍒楀瓧娈靛悕 - */ - onColumnNameChange = () => { - const { showColumnName, config } = this.state - - if (!showColumnName) { - let fields = [] - config.columns.forEach(col => { - if (col.field) { - fields.push(col.field) - } - }) - - fields = fields.join(',') - - let textArea = document.createElement('textarea') - textArea.value = fields - document.body.appendChild(textArea) - textArea.select() - - try { - document.execCommand('copy') - document.body.removeChild(textArea) - } catch (err) { - document.body.removeChild(textArea) - } - } - - this.setState({ - showColumnName: !showColumnName - }) - } - - /** - * @description 澧炲姞鏍囩椤靛垎缁� - */ - 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() {} - }) - } - - /** - * @description 鍒犻櫎鏍囩椤靛垎缁� - */ - 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() {} - }) - } - - /** - * @description 瑙e喕鎸夐挳 - */ - handleThaw = () => { - const { menu } = this.props - - this.setState({ - thawBtnVisible: true - }) - - Api.getSystemConfig({ - func: 'sPC_Get_FrozenMenu', - ParentID: menu.MenuID, - TYPE: 40 - }).then(res => { - if (res.status) { - let _list = [] - - res.data.forEach(menu => { - let _conf = '' - - if (menu.ParentParam) { - try { - _conf = JSON.parse(window.decodeURIComponent(window.atob(menu.ParentParam))) - } catch (e) { - console.warn('Parse Failure') - _conf = '' - } - } - - if (_conf) { - _list.push({ - key: menu.MenuID, - title: menu.MenuName, - btnParam: _conf - }) - } - }) - - this.setState({ - thawbtnlist: _list - }) - } else { - notification.warning({ - top: 92, - message: res.message, - duration: 10 - }) - } - }) - } - - /** - * @description 瑙e喕鎸夐挳鎻愪氦 - */ - thawBtnSubmit = () => { - const { thawButtons, config, thawbtnlist } = this.state - // 涓夌骇鑿滃崟瑙i櫎鍐荤粨 - if (this.refs.trawmenu.state.targetKeys.length === 0) { - notification.warning({ - top: 92, - message: this.state.dict['form.required.select'] + this.state.dict['header.form.thawbutton'], - duration: 10 - }) - } else { - - thawbtnlist.forEach(item => { - if (this.refs.trawmenu.state.targetKeys.includes(item.key)) { - config.action.push(item.btnParam) - } - }) - - this.setState({ - thawButtons: [...thawButtons, ...this.refs.trawmenu.state.targetKeys], - config: config, - thawBtnVisible: false - }) - } - } - - handleGroup = (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]) - } - - this.setState({ - config: config - }) - - notification.success({ - top: 92, - message: '璋冩暣鎴愬姛', - duration: 2 - }) } /** @@ -2656,34 +1189,102 @@ this.props.handleView() } - pasteSubmit = () => { - this.pasteFormRef.handleConfirm().then(res => { - if (res.copyType !== 'action') { - notification.warning({ - top: 92, - message: '閰嶇疆淇℃伅鏍煎紡閿欒锛�', - duration: 10 - }) - return - } - + /** + * @description 缂栬緫鍔熻兘瀹屾垚鏇存柊锛屽寘鎷В鍐绘寜閽�佺矘璐淬�佹浛鎹㈢瓑 + */ + editConfig = (res) => { + if (res.type === 'thaw') { this.setState({ - modaltype: '' - }, () => { - this.handleAction(res, 'copy') + thawButtons: res.thawButtons, + config: res.config }) + } else if (res.type === 'paste') { + this.setState({ + pasteContent: res.content + }, () => { + this.setState({ + pasteContent: null + }) + }) + } + } + + /** + * @description 鏇存柊鎼滅储鏉′欢閰嶇疆淇℃伅 + */ + updatesearch = (config, options) => { + const { optionLibs } = this.state + + this.setState({ + config: config, + optionLibs: options || optionLibs + }) + } + + /** + * @description 鏇存柊鎸夐挳閰嶇疆淇℃伅 + */ + updateaction = (config, copyId, delcard) => { + const { copyActions, delActions } = this.state + + this.setState({ + config: config, + copyActions: copyId ? [...copyActions, copyId] : copyActions, + delActions: delcard ? [...delActions, delcard] : delActions + }) + } + + /** + * @description 鏇存柊鍥捐〃缁勯厤缃俊鎭� + */ + updatechartgroup = (config, _chartview) => { + this.setState({ + config: config, + chartview: _chartview + }) + } + + /** + * @description 鏇存柊甯哥敤琛ㄤ俊鎭紝蹇嵎娣诲姞鍚庢洿鏂伴厤缃俊鎭� + */ + updatetable = (config, fields) => { + const { tableFields } = this.state + + this.setState({ + config: config, + tableFields: fields ? fields : tableFields + }) + } + + /** + * @description 鏇存柊鏍囩閰嶇疆淇℃伅 + */ + updatetabs = (config, delcards) => { + const { delActions } = this.state + + this.setState({ + config: config, + delActions: delcards ? [...delActions, ...delcards] : delActions + }) + } + + /** + * @description 鏇存柊閰嶇疆淇℃伅 + */ + updateconfig = (config) => { + this.setState({ + config: config }) } render () { - const { modaltype, activeKey } = this.state - const configAction = this.state.config.action.filter(_action => - !_action.origin && (_action.OpenType === 'pop' || _action.OpenType === 'popview' || _action.OpenType === 'blank' || _action.OpenType === 'tab') - ) + const { activeKey, config, chartview } = this.state + + const confActions = config.action.filter(_action => !_action.origin && ['pop', 'popview', 'blank', 'tab'].includes(_action.OpenType)) let configTabs = [] - this.state.config.tabgroups.forEach(group => { - configTabs.push(...this.state.config[group]) + config.tabgroups.forEach(group => { + configTabs.push(...group.sublist) }) return ( @@ -2693,7 +1294,7 @@ <div className="tools"> <Collapse accordion defaultActiveKey={activeKey} bordered={false} onChange={(key) => this.setState({activeKey: key})}> {/* 鍩烘湰淇℃伅 */} - <Panel forceRender={true} 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="main-basedata"> {/* 鑿滃崟淇℃伅 */} <MenuForm dict={this.state.dict} @@ -2701,61 +1302,31 @@ wrappedComponentRef={(inst) => this.menuformRef = inst} /> {/* 琛ㄥ悕娣诲姞 */} - <div className="ant-col ant-form-item-label"> - <label> - <Tooltip placement="topLeft" title="姝ゅ鍙互娣诲姞閰嶇疆鐩稿叧鐨勫父鐢ㄨ〃锛屽湪娣诲姞鎼滅储鏉′欢鍜屾樉绀哄垪鏃讹紝鍙�氳繃宸ュ叿鏍忎腑鐨勬坊鍔犳寜閽紝鎵归噺娣诲姞琛ㄦ牸鐩稿叧瀛楁銆�"> - <Icon type="question-circle" /> - {this.state.dict['header.menu.table.add']} - </Tooltip> - </label> - </div> - <Select - showSearch - className="tables" - style={{ width: '100%' }} - optionFilterProp="children" - value={this.state.dict['header.menu.table.placeholder']} - onChange={this.onTableChange} - showArrow={false} - getPopupContainer={() => document.getElementById('common-basedata')} - filterOption={(input, option) => { - return option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0 || - option.props.value.toLowerCase().indexOf(input.toLowerCase()) >= 0 - }} - > - {this.state.tables.map((table, index) => ( - <Option key={index} title={table.TbName} value={table.TbName}>{table.Remark}</Option> - ))} - </Select> - {this.state.selectedTables.length > 0 && <List - size="small" - bordered - dataSource={this.state.selectedTables} - renderItem={(item, index) => <List.Item key={index} title={item.Remark + ' (' + item.TbName + ')'}> - {item.Remark + ' (' + item.TbName + ')'} - <Icon type="close" onClick={() => this.deleteTable(item)}/> - <div className="bottom-mask"></div> - </List.Item>} - />} + <TableComponent + config={config} + containerId="main-basedata" + updatetable={this.updatetable} + /> </Panel> {/* 鎼滅储鏉′欢娣诲姞 */} <Panel header={this.state.dict['header.menu.search']} key="1"> <div className="search-element"> - {Source.searchItems.map((item, index) => { - return (<SourceElement key={index} content={item}/>) - })} + {Source.searchItems.map((item, index) => (<SourceElement key={index} content={item}/>))} </div> - <Button type="primary" block onClick={() => this.queryField('search')}>{this.state.dict['header.menu.search.add']}</Button> + <FieldsComponent + config={config} + type="search" + tableFields={this.state.tableFields} + updatefield={this.updateconfig} + /> </Panel> {/* 鎸夐挳娣诲姞 */} <Panel header={this.state.dict['header.menu.action']} key="2"> <div className="search-element"> - {Source.actionItems.map((item, index) => { - return (<SourceElement key={index} content={item}/>) - })} + {Source.actionItems.map((item, index) => (<SourceElement key={index} content={item}/>))} </div> <div className="config-btn"> - {configAction.length > 0 ? + {confActions.length > 0 ? <p className="config-btn-title"> <Tooltip placement="topLeft" title="鐐瑰嚮鎸夐挳锛屽彲瀹屾垚鎴栨煡鐪嬫寜閽厤缃俊鎭��"> <Icon type="question-circle" /> @@ -2763,11 +1334,8 @@ {this.state.dict['header.menu.action.configurable']} </p> : null } - <div className="thawbutton" title={this.state.dict['header.form.thawbutton']} onClick={this.handleThaw}> - <Icon type="unlock" /> - </div> </div> - {configAction.map((item, index) => { + {confActions.map((item, index) => { return ( <div key={index}> <Button @@ -2783,18 +1351,19 @@ {/* 娣诲姞鏄剧ず鍒� */} <Panel header={this.state.dict['header.menu.column']} key="3"> <div className="search-element"> - {Source.columnItems.map((item, index) => { - return (<SourceElement key={index} content={item}/>) - })} + {Source.columnItems.map((item, index) => (<SourceElement key={index} content={item}/>))} </div> - <Button type="primary" block onClick={() => this.queryField('columns')}>{this.state.dict['header.menu.column.add']}</Button> + <FieldsComponent + config={config} + type="columns" + tableFields={this.state.tableFields} + updatefield={this.updateconfig} + /> </Panel> {/* 娣诲姞鏍囩 */} <Panel header={this.state.dict['header.menu.tab']} key="4"> <div className="search-element"> - {Source.tabItems.map((item, index) => { - return (<SourceElement key={index} content={item}/>) - })} + {Source.tabItems.map((item, index) => (<SourceElement key={index} content={item}/>))} </div> {configTabs.length > 0 ? <p className="config-btn-title"> @@ -2823,309 +1392,100 @@ <Card title={ <div> {this.state.dict['header.menu.page.configurable']} - <Icon type="redo" style={{marginLeft: '10px'}} title="鍒锋柊鏍囩鍒楄〃" onClick={this.reloadTab} /> + <Icon type="redo" 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="鍚�" unCheckedChildren="鍋�" checked={this.state.config.enabled} onChange={this.onEnabledChange} /> - <Button type="primary" onClick={this.changeTemplate}>{this.state.dict['header.menu.template.change']}</Button> <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> </div> } style={{ width: '100%' }}> - <Icon type="setting" onClick={this.changeSetting} /> - <div className="search-list"> - <Tooltip placement="bottomLeft" overlayClassName="middle" title="鍦ㄥ乏渚у伐鍏锋爮銆婃悳绱€�嬩腑锛岄�夋嫨瀵瑰簲鎼滅储妗嗘嫋鑷虫澶勬坊鍔狅紱鎴栫偣鍑绘寜閽�婃坊鍔犳悳绱㈡潯浠躲�嬫壒閲忔坊鍔狅紝閫夋嫨鎵归噺娣诲姞鏃讹紝闇�鎻愬墠閫夋嫨浣跨敤琛ㄣ��"> - <Icon type="question-circle" /> - </Tooltip> - <DragElement - type="search" - list={this.state.config.search} - handleList={this.handleList} - handleMenu={this.handleSearch} - deleteMenu={this.deleteElement} - placeholder={this.state.dict['header.form.search.placeholder']} - /> - </div> - <div className="action-list" id="action-list"> - <Tooltip placement="bottomLeft" overlayClassName="middle" title="鍦ㄥ乏渚у伐鍏锋爮銆婃寜閽�嬩腑锛岄�夋嫨瀵瑰簲绫诲瀷鐨勬寜閽嫋鑷虫澶勬坊鍔狅紝濡傞�夋嫨鎸夐挳绫诲瀷涓鸿〃鍗曘�佹柊鏍囩椤电瓑鍚湁閰嶇疆椤甸潰鐨勬寜閽紝鍙湪宸︿晶宸ュ叿鏍�-鎸夐挳-鍙厤缃寜閽锛岀偣鍑绘寜閽畬鎴愮浉鍏抽厤缃�傛敞锛氬綋璁剧疆鎸夐挳鏄剧ず浣嶇疆涓鸿〃鏍兼椂锛屾樉绀哄垪浼氬鍔犳搷浣滃垪銆�"> - <Icon type="question-circle" /> - </Tooltip> - <div className="copybutton" title={this.state.dict['header.form.paste']} onClick={() => {this.setState({modaltype: 'paste'})}}> - <Icon type="snippets" /> - </div> - <DragElement - type="action" - list={this.state.config.action} - setting={this.state.config.setting} - handleList={this.handleList} - handleMenu={this.handleAction} - copyElement={(val) => this.handleAction(val, 'copy')} - deleteMenu={this.deleteElement} - profileMenu={this.profileAction} - placeholder={this.state.dict['header.form.action.placeholder']} - /> - </div> - {/* 鏄剧ず鍒� */} - <div className="column-list"> - <Tooltip placement="bottomLeft" overlayClassName="middle" title="鍦ㄥ乏渚у伐鍏锋爮銆婃樉绀哄垪銆嬩腑锛岄�夋嫨瀵瑰簲绫诲瀷鐨勬樉绀哄垪鎷栬嚦姝ゅ娣诲姞锛涙垨鐐瑰嚮銆婃坊鍔犳樉绀哄垪銆嬫寜閽壒閲忔坊鍔狅紝閫夋嫨鎵归噺娣诲姞鏃讹紝闇�鎻愬墠閫夋嫨浣跨敤琛ㄣ�傛敞锛氭坊鍔犲悎骞跺垪鏃讹紝闇�璁剧疆鍙�夊垪銆�"> - <Icon type="question-circle" /> - </Tooltip> - <Switch checkedChildren="寮�" unCheckedChildren="鍏�" defaultChecked={this.state.showColumnName} onChange={this.onColumnNameChange} /> - <DragElement - type="columns" - list={this.state.config.columns} - setting={this.state.config.setting} - gridBtn={this.state.config.gridBtn} - handleList={this.handleList} - handleMenu={this.handleColumn} - deleteMenu={this.deleteElement} - handleGridBtn={this.handleGridBtn} - showfield={this.state.showColumnName} - placeholder={this.state.dict['header.form.column.placeholder']} - /> + <SettingComponent + type="main" + config={config} + MenuID={this.props.menu.MenuID} + menuformRef={this.menuformRef} + permFuncField={this.props.permFuncField} + updatesetting={this.updateconfig} + /> + <SearchComponent + menu={{MenuID: this.props.menu.MenuID, MenuName: this.props.menu.MenuName}} + config={config} + pasteContent={this.state.pasteContent} + sysRoles={this.props.sysRoles} + optionLibs={this.state.optionLibs} + updatesearch={this.updatesearch} + /> + <div className="chart-view" style={{position: 'relative'}}> + {/* 瑙嗗浘缁� 鏉冮檺 浼氬憳绛夌骇20+ */} + {this.props.memberLevel >= 20 ? <ChartGroupComponent + config={config} + sysRoles={this.props.sysRoles} + updatechartgroup={this.updatechartgroup} + /> : null} + {config.charts.map(item => { + if (!config.expand && chartview !== item.uuid) return '' + + if (item.chartType === 'table') { + return ( + <Col span={item.width || 24} key={item.uuid}> + {config.charts.length > 1 && item.title ? <p className="chart-title">{item.title}</p> : null} + <ActionComponent + type="main" + menu={{ MenuID: this.props.menu.MenuID, MenuName: this.props.menu.MenuName, MenuNo: this.props.menu.MenuNo }} + config={config} + tabs={this.state.tabviews} + menuformRef={this.menuformRef} + pasteContent={this.state.pasteContent} + usefulFields={this.props.permFuncField} + setSubConfig={(_btn) => this.setSubConfig(_btn, 'button')} + updateaction={this.updateaction} + /> + <ColumnComponent + config={config} + menu={this.props.menu} + sysRoles={this.props.sysRoles} + pasteContent={this.state.pasteContent} + updatecolumn={this.updateconfig} + /> + </Col> + ) + } else if (item.chartType === 'card') { + return ( + <Col span={item.width} key={item.uuid}> + <CardComponent + card={item} + config={config} + plotchange={this.updateconfig} + /> + </Col> + ) + } else { + return ( + <Col span={item.width} key={item.uuid}> + <ChartComponent + plot={item} + config={config} + plotchange={this.updateconfig} + /> + </Col> + ) + } + })} </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.handleGroup(index, 'down')}} /> : null - } - {index !== 0 ? <Icon type="arrow-up" onClick={() => {this.handleGroup(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> - {/* 缂栬緫鎼滅储鏉′欢 */} - <Modal - title={this.state.dict['header.modal.search.edit']} - visible={modaltype === 'search'} - width={700} - maskClosable={false} - onOk={this.handleSubmit} - onCancel={this.editModalCancel} - destroyOnClose - > - <SearchForm - dict={this.state.dict} - card={this.state.card} - inputSubmit={this.handleSubmit} - optionLibs={this.state.optionLibs} - formlist={this.state.formlist} - wrappedComponentRef={(inst) => this.searchFormRef = inst} - /> - </Modal> - {/* 缂栬緫鎸夐挳锛氬鍒躲�佺紪杈� */} - <Modal - title={modaltype === 'actionEdit' ? this.state.dict['header.modal.action.edit'] : this.state.dict['header.modal.action.copy']} - visible={modaltype === 'actionEdit' || modaltype === 'actionCopy'} - width={800} - maskClosable={false} - onCancel={this.editModalCancel} - footer={[ - modaltype === 'actionEdit' ? <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> - ]} - destroyOnClose - > - <ActionForm - dict={this.state.dict} - card={this.state.card} - tabs={this.state.tabviews} - formlist={this.state.formlist} - inputSubmit={this.handleSubmit} - setting={this.state.config.setting} - wrappedComponentRef={(inst) => this.actionFormRef = inst} - /> - </Modal> - {/* 鏄剧ず鍒楃紪杈� */} - <Modal - title={this.state.dict['header.modal.column.edit']} - visible={modaltype === 'columns'} - width={700} - maskClosable={false} - onOk={this.handleSubmit} - onCancel={this.editModalCancel} - destroyOnClose - > - <ColumnForm - dict={this.state.dict} - card={this.state.card} - inputSubmit={this.handleSubmit} - formlist={this.state.formlist} - wrappedComponentRef={(inst) => this.columnFormRef = inst} - /> - </Modal> - {/* 鍚堝苟鍒楃紪杈� */} - <Modal - title={this.state.dict['header.modal.colspan.edit']} - visible={modaltype === 'colspan'} - width={700} - maskClosable={false} - onOk={this.handleSubmit} - onCancel={this.editModalCancel} - destroyOnClose - > - <ColspanForm - dict={this.state.dict} - card={this.state.card} - inputSubmit={this.handleSubmit} - columns={this.state.config.columns} - wrappedComponentRef={(inst) => this.columnFormRef = inst} - /> - </Modal> - {/* 鎿嶄綔鍒楃紪杈� */} - <Modal - title={this.state.dict['header.modal.gridbtn.edit']} - visible={modaltype === 'gridbtn'} - width={700} - maskClosable={false} - onOk={this.handleSubmit} - onCancel={this.editModalCancel} - destroyOnClose - > - <GridBtnForm - dict={this.state.dict} - inputSubmit={this.handleSubmit} - card={this.state.config.gridBtn} - wrappedComponentRef={(inst) => this.gridBtnFormRef = 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']} - visible={this.state.tableVisible} - width={'65vw'} - maskClosable={false} - style={{minWidth: '900px', maxWidth: '1200px'}} - cancelText={this.state.dict['header.close']} - onOk={this.addFieldSubmit} - onCancel={() => { // 鍙栨秷娣诲姞 - this.setState({ - tableVisible: false, - addType: '' - }) - }} - destroyOnClose - > - {this.state.addType && this.state.fields.length > 0 ? - <EditCard data={this.state.fields} ref="searchcard" type={this.state.addType} dict={this.state.dict} /> : null - } - {(!this.state.fields || this.state.fields.length === 0) && - <Empty /> - } - </Modal> - {/* 鎸夐挳浣跨敤绯荤粺瀛樺偍杩囩▼鏃讹紝楠岃瘉淇℃伅妯℃�佹 */} - <Modal - wrapClassName="common-table-fields-modal" - title={'楠岃瘉淇℃伅'} - maskClosable={false} - visible={this.state.profileVisible} - width={'75vw'} - style={{minWidth: '900px', maxWidth: '1200px'}} - onOk={this.verifySubmit} - onCancel={() => { this.setState({ profileVisible: false }) }} - destroyOnClose - > - {this.state.card && !this.state.card.execMode && this.state.card.OpenType !== 'excelIn' && this.state.card.OpenType !== 'excelOut' ? - <VerifyCard - card={this.state.card} - dict={this.state.dict} - columns={this.state.config.columns} - wrappedComponentRef={(inst) => this.verifyRef = inst} - /> : null - } - {this.state.card && this.state.card.execMode ? - <VerifyCardPrint - card={this.state.card} - dict={this.state.dict} - columns={this.state.config.columns} - wrappedComponentRef={(inst) => this.verifyRef = inst} - /> : null - } - {this.state.card && this.state.card.OpenType === 'excelIn' ? - <VerifyCardExcelIn - card={this.state.card} - dict={this.state.dict} - columns={this.state.config.columns} - wrappedComponentRef={(inst) => this.verifyRef = inst} - /> : null - } - {this.state.card && this.state.card.OpenType === 'excelOut' ? - <VerifyCardExcelOut - card={this.state.card} - dict={this.state.dict} - wrappedComponentRef={(inst) => this.verifyRef = inst} - /> : null - } - </Modal> - {/* 璁剧疆鍏ㄥ眬閰嶇疆鍙婂垪琛ㄦ暟鎹簮 */} - <Modal - title={this.state.dict['header.edit']} - visible={this.state.settingVisible} - width={700} - maskClosable={false} - onCancel={() => { // 鍙栨秷淇敼 - this.setState({ - settingVisible: false - }) - }} - footer={[ - <CreateInterface key="interface" dict={this.state.dict} ref="tableCreatInterface" trigger={this.tableCreatInterface}/>, - <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> - ]} - destroyOnClose - > - <SettingForm - dict={this.state.dict} - menu={this.props.menu} - inputSubmit={this.settingSave} - data={this.state.config.setting} - columns={this.state.config.columns} - usefulFields={this.props.permFuncField} - wrappedComponentRef={(inst) => this.settingRef = inst} - /> - </Modal> + {/* 杩斿洖鏃舵湭淇濆瓨鎻愮ず */} <Modal bodyStyle={{textAlign: 'center', color: '#000000', fontSize: '16px'}} closable={false} @@ -3141,34 +1501,6 @@ > {this.state.dict['header.menu.config.placeholder']} </Modal> - {/* 瑙e喕鎸夐挳妯℃�佹 */} - <Modal - title={this.state.dict['header.form.thawbutton']} - okText={this.state.dict['header.confirm']} - cancelText={this.state.dict['header.cancel']} - visible={this.state.thawBtnVisible} - onOk={this.thawBtnSubmit} - onCancel={() => {this.setState({thawBtnVisible: false, thawbtnlist: null})}} - destroyOnClose - > - {!this.state.thawbtnlist && <Spin style={{marginLeft: 'calc(50% - 22px)', marginTop: '70px', marginBottom: '70px'}} size="large" />} - {this.state.thawbtnlist && <TransferForm ref="trawmenu" menulist={this.state.thawbtnlist}/>} - </Modal> - {/* 鎸夐挳閰嶇疆淇℃伅绮樿创澶嶅埗 */} - <Modal - title={this.state.dict['header.form.paste']} - visible={modaltype === 'paste'} - width={600} - maskClosable={false} - onOk={this.pasteSubmit} - onCancel={() => {this.setState({modaltype: ''})}} - destroyOnClose - > - <PasteForm - dict={this.state.dict} - wrappedComponentRef={(inst) => this.pasteFormRef = inst} - /> - </Modal> {this.state.loading && <Spin size="large" />} </div> ) @@ -3177,7 +1509,9 @@ const mapStateToProps = (state) => { return { - permFuncField: state.permFuncField + sysRoles: state.sysRoles, + permFuncField: state.permFuncField, + memberLevel: state.memberLevel } } -- Gitblit v1.8.0