From e36eb1999794bd71e76482b92a0b0b20f49d0032 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 05 三月 2021 19:37:03 +0800 Subject: [PATCH] 2021-03-05 --- src/templates/subtableconfig/index.jsx | 2510 +++++++++++++++++------------------------------------------ 1 files changed, 731 insertions(+), 1,779 deletions(-) diff --git a/src/templates/subtableconfig/index.jsx b/src/templates/subtableconfig/index.jsx index e0a3e2a..d3bda26 100644 --- a/src/templates/subtableconfig/index.jsx +++ b/src/templates/subtableconfig/index.jsx @@ -4,33 +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 zhCN from '@/locales/zh-CN/comtable.js' -import enUS from '@/locales/en-US/comtable.js' +import zhCN from '@/locales/zh-CN/model.js' +import enUS from '@/locales/en-US/model.js' import Utils from '@/utils/utils.js' -import { getSearchForm, getActionForm, getColumnForm } from '@/templates/tableshare/formconfig' +import { updateSubTable } from '@/utils/utils-update.js' -import ActionForm from './actionform' -import SettingForm from './settingform' -import SearchForm from '@/templates/tableshare/searchform' -import ColumnForm from '@/templates/tableshare/columnform' -import DragElement from '@/templates/tableshare/dragelement' -import ColspanForm from '@/templates/tableshare/colspanform' -import GridBtnForm from '@/templates/tableshare/gridbtnform' -import EditCard from '@/templates/tableshare/editcard' -import VerifyCard from '@/templates/tableshare/verifycard' -import MenuForm from '@/templates/tableshare/menuform' -import SourceElement from '@/templates/tableshare/dragelement/source' +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 './menuform' +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 EditComponent = asyncComponent(() => import('@/templates/zshare/editcomponent')) +const SettingComponent = asyncComponent(() => import('@/templates/sharecomponent/settingcomponent')) +const TableComponent = asyncComponent(() => import('@/templates/sharecomponent/tablecomponent')) +const FieldsComponent = asyncComponent(() => import('@/templates/sharecomponent/fieldscomponent')) +const ChartGroupComponent = asyncComponent(() => import('@/templates/sharecomponent/chartgroupcomponent')) +const ChartComponent = asyncComponent(() => import('@/templates/sharecomponent/chartcomponent')) +const CardComponent = asyncComponent(() => import('@/templates/sharecomponent/cardcomponent')) class SubTableConfig extends Component { static propTpyes = { @@ -38,39 +40,29 @@ editTab: PropTypes.any, tabConfig: PropTypes.any, editSubTab: PropTypes.any, + btnTab: PropTypes.any, + btnTabConfig: PropTypes.any, config: PropTypes.any, handleView: PropTypes.func } state = { - dict: CommonDict, // 瀛楀吀 + dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, // 瀛楀吀 config: null, // 椤甸潰閰嶇疆 visible: false, // 鎼滅储鏉′欢銆佹寜閽�佹樉绀哄垪锛屾ā鎬佹鏄剧ず鎺у埗 - modalTitle: '', // 妯℃�佹鐨勬爣棰� - tableVisible: false, // 鏁版嵁琛ㄥ瓧娈垫ā鎬佹 - addType: '', // 娣诲姞绫诲瀷-鎼滅储鏉′欢鎴栨樉绀哄垪 - tableColumns: [], // 琛ㄦ牸鏄剧ず鍒� - fields: null, // 鎼滅储鏉′欢鍙婃樉绀哄垪锛屽彲閫夊瓧娈� - menuformlist: null, // 鍩烘湰淇℃伅琛ㄥ崟瀛楁 - formlist: null, // 鎼滅储鏉′欢銆佹寜閽�佹樉绀哄垪琛ㄥ崟瀛楁 - formtemp: '', // 琛ㄥ崟绫诲瀷锛屾樉绀哄垪銆佹寜閽�佹悳绱㈡潯浠� - modaltype: '', // 妯℃�佹绫诲瀷锛屾帶鍒舵ā鎬佹鏄剧ず - card: null, // 缂栬緫鍏冪礌 menuloading: false, // 鑿滃崟淇濆瓨涓� menucloseloading: false, // 鑿滃崟鍏抽棴鏃讹紝閫夋嫨淇濆瓨 loading: false, // 鍔犺浇涓紝椤甸潰spin - settingVisible: false, // 鍏ㄥ眬閰嶇疆妯℃�佹 closeVisible: false, // 鍏抽棴妯℃�佹 - tables: [], // 鍙敤琛ㄥ悕 - selectedTables: [], // 宸查�夎〃鍚� originConfig: null, // 鍘熼厤缃� originActions: null, // 鍘熷鎸夐挳淇℃伅锛屼娇鐢ㄥ凡鏈夌敤鎴锋ā鏉� delActions: [], // 鍒犻櫎鎸夐挳鍒楄〃 copyActions: [], // 澶嶅埗鎸夐挳缁� - funcLoading: false, // 瀛樺偍杩囩▼鍒涘缓涓� - showColumnName: false, // 鏄剧ず鍒楀瓧娈靛悕鎺у埗 tabviews: [], // 鎵�鏈夋爣绛鹃〉 - profileVisible: false // 楠岃瘉淇℃伅妯℃�佹 + thawButtons: [], // 宸查�夋嫨瑕佽В鍐荤殑鎸夐挳 + activeKey: '0', // 榛樿灞曞紑鍩烘湰淇℃伅 + chartview: null, // 褰撳墠瑙嗗浘 + openEdition: '' // 缂栬緫鐗堟湰鏍囪锛岄槻姝㈠浜烘搷浣� } /** @@ -84,12 +76,12 @@ let _config = null if (!config) { - _config = JSON.parse(JSON.stringify(Source.baseConfig)) + _config = fromJS(Source.baseConfig).toJS() _config.uuid = editSubTab ? editSubTab.linkTab : editTab.linkTab _config.tabName = editSubTab ? editSubTab.label : editTab.label _config.isAdd = true } else { - _config = JSON.parse(JSON.stringify(config)) + _config = fromJS(config).toJS() } let _oriActions = [] @@ -97,9 +89,14 @@ if (_config.type === 'user') { _config.action = _config.action.map(item => { let uuid = Utils.getuuid() + + if (item.linkTab) { + item.linkTab = '' + } + if (item.OpenType === 'pop') { // 鍚湁瀛愰厤缃」鐨勬寜閽� _oriActions.push({ - prebtn: JSON.parse(JSON.stringify(item)), + prebtn: fromJS(item).toJS(), curuuid: uuid, Template: 'Modal' }) @@ -110,37 +107,18 @@ }) } + let _activeKey = editSubTab ? editSubTab.activeKey : editTab.activeKey + + // 鐗堟湰鍏煎 + _config = updateSubTable(_config) + this.setState({ + openEdition: editSubTab ? (editSubTab.open_edition || '') : (editTab.open_edition || ''), + chartview: _config.charts[0].uuid, originActions: _oriActions, config: _config, - originConfig: _config, - selectedTables: _config.tables || [], - menuformlist: [ - { - type: 'text', - key: 'tabName', - label: this.state.dict['header.menu.tabName'], - initVal: _config.tabName, - required: true, - readonly: false - }, - { - type: 'text', - key: 'tabNo', - label: this.state.dict['header.menu.menuNo'], - initVal: _config.tabNo, - required: true, - readonly: false - }, - { - type: 'text', - key: 'Remark', - label: this.state.dict['header.menu.Remark'], - initVal: _config.Remark, - required: false, - readonly: false - } - ] + activeKey: _activeKey || '0', + originConfig: fromJS(_config).toJS(), }) } @@ -150,110 +128,54 @@ * 2銆佹牴鎹厤缃俊鎭腑宸蹭娇鐢ㄨ〃鑾峰彇鐩稿叧瀛楁淇℃伅 */ componentDidMount () { - let param = { - func: 'sPC_Get_SelectedList', - LText: 'select TbName ,Remark from sDataDictionary where IsKey!=\'\' and Deleted =0', - obj_name: 'data', - arr_field: 'TbName,Remark' - } + this.reloadTab(false) + } - 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 => { + /** + * @description 鍔犺浇鎴栧埛鏂版爣绛句俊鎭� + */ + reloadTab = (type) => { + this.setState({ + loading: type, + tabviews: [] + }) + Api.getSystemConfig({func: 'sPC_Get_UserTemp', TypeCharTwo: 'tab'}).then(res => { if (res.status) { - this.setState({ - tables: res.data + let _tabviews = [] + res.UserTemp.forEach(temp => { + let item = { + uuid: temp.MenuID, + value: temp.MenuID, + text: temp.MenuName, + type: temp.Template, + MenuNo: temp.MenuNo + } + + if (this.props.config && temp.MenuID === this.props.config.uuid) return + + _tabviews.push(item) }) + + this.setState({ + loading: false, + tabviews: _tabviews + }) + + if (type) { + notification.success({ + top: 92, + message: '鍒锋柊鎴愬姛銆�', + duration: 2 + }) + } } else { + this.setState({ + loading: false + }) 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 - } - }) + duration: 5 }) } }) @@ -270,15 +192,20 @@ // 椤甸潰杩斿洖 handleViewBack = () => { - const {menu, editTab, tabConfig, editSubTab} = this.props + const {menu, editTab, tabConfig, editSubTab, btnTab, btnTabConfig} = this.props let _tabview = menu ? menu.LongParam.Template : '' + let _subconfig = null if (editSubTab) { + _subconfig = tabConfig if (editTab.hasOwnProperty('OpenType')) { - _tabview = editTab.tabType + _tabview = editTab.tabType || 'SubTable' } else { _tabview = editTab.type } + } else if (!editSubTab && btnTab) { + _tabview = btnTab.tabTemplate + _subconfig = btnTabConfig } let param = { @@ -287,983 +214,279 @@ tabConfig: null, editSubTab: null, subTabConfig: null, + btnTab: btnTab, + btnTabConfig: btnTabConfig, editAction: null, - subConfig: tabConfig, + subConfig: _subconfig, tabview: _tabview } + this.state.copyActions.forEach(item => { + let _param = { + func: 'sPC_MainMenu_Del', + MenuID: item + } + Api.getSystemConfig(_param) + }) + this.props.handleView(param) - } - - /** - * @description 鍏冪礌娣诲姞鎴栨嫋鍔ㄦ椂椤哄簭鍙樺寲 - */ - handleList = (type, list, card) => { - const { config } = this.state - - 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) => { - this.setState({ - modaltype: 'search', - card: card, - formlist: getSearchForm(card) - }) - } - - /** - * @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) => { - if (card.type !== 'colspan') { - this.setState({ - modaltype: 'columns', - card: card, - formlist: getColumnForm(card) - }) - } else { - this.setState({ - modaltype: 'colspan', - card: card - }) - } - } - - /** - * @description 鎿嶄綔鍒楃紪杈� - */ - handleGridBtn = () => { - this.setState({ - modaltype: 'gridbtn' - }) - } - - /** - * @description 鎼滅储銆佹寜閽�佹樉绀哄垪淇敼鍚庢彁浜や繚瀛� - * 1銆佹悳绱㈡潯浠朵繚瀛橈紝褰撶被鍨嬩负涓嬫媺妗嗕笖瀛樺湪鏁版嵁婧愭椂锛屽皢鏌ヨ鏉′欢鎷兼帴涓簊ql锛屽苟鐢╞ase64杞爜 - * 2銆佹寜閽寘鎷甯哥紪杈戝拰澶嶅埗锛屽鍒舵椂,鎸夐挳鍒楁湯灏炬坊鍔� - * 3銆佹坊鍔犳垨缂栬緫鍒楋紝淇濆瓨鏃讹紝濡傛寜閽綅缃缃负琛ㄦ牸锛屽垯淇敼鎿嶄綔鍒楁樉绀虹姸鎬� - */ - handleSubmit = () => { - const { card, config, modaltype } = this.state - - if (modaltype === 'search') { - this.searchFormRef.handleConfirm().then(res => { - 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}, - 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 param = { - func: 'sPC_ButtonParam_AddUpt', - ParentID: config.uuid, - MenuID: res.uuid, - MenuNo: config.tabNo, - Template: 'Modal', - MenuName: res.label, - PageParam: JSON.stringify({Template: 'Modal'}), - LongParam: result.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: '' - }) - }) - } - } - - /** - * @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 { - _config = config - } - - this.setState({ - card: null, - config: _config, - modaltype: '' - }) - } else { - this.setState({ - card: null, - modaltype: '' - }) - } - } - - /** - * @description 鍒涘缓鎸夐挳瀛樺偍杩囩▼ - */ - creatFunc = () => { - let _config = JSON.parse(JSON.stringify(this.state.config)) - - this.actionFormRef.handleConfirm().then(res => { - let btn = res // 鎸夐挳淇℃伅 - let newLText = '' // 鍒涘缓瀛樺偍杩囩▼sql - let DelText = '' // 鍒犻櫎瀛樺偍杩囩▼sql - let isExit = false // 瀛樺偍杩囩▼鏄惁瀛樺湪 - let sysTVPText = '' // 宸叉湁鐨勫瓨鍌ㄨ繃绋嬭鍙�(浜戠) - let localTVPText = '' // 宸叉湁鐨勫瓨鍌ㄨ繃绋嬭鍙�(鏈湴) - - // 鍒涘缓瀛樺偍杩囩▼锛屽繀椤诲~鍐欏唴閮ㄥ嚱鏁板悕 - if (!btn.innerFunc) { - notification.warning({ - top: 92, - message: '璇峰~鍐欏唴閮ㄥ嚱鏁帮紒', - duration: 10 - }) - return - } - - // 鍒涘缓涓� - this.setState({ - funcLoading: true - }) - - 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) { - _LongParam = window.decodeURIComponent(window.atob(res.LongParam)) - try { - _LongParam = JSON.parse(_LongParam) - } catch (e) { - _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: _config.tabNo - } - newLText = Utils.formatOptions(Utils.getfunc(_param, btn, {MenuID: _config.uuid, MenuName: _config.tabName}, _config)) - DelText = Utils.formatOptions(Utils.dropfunc(_param.funcName)) - resolve(true) - } else { - resolve(false) - notification.warning({ - top: 92, - message: '寮圭獥锛堣〃鍗曪級鎸夐挳锛岃鍏堥厤缃〃鍗曚俊鎭紒', - duration: 10 - }) - } - }) - } else { - let _param = { - funcName: btn.innerFunc, - name: _config.setting.tableName || '', - fields: '', - menuNo: _config.tabNo - } - newLText = Utils.formatOptions(Utils.getfunc(_param, btn, {MenuID: _config.uuid, MenuName: _config.tabName}, _config)) - DelText = Utils.formatOptions(Utils.dropfunc(_param.funcName)) - resolve(true) - } - }).then(res => { - // 鑾峰彇浜戠鍙婃湰鍦帮紝鏄惁宸插瓨鍦ㄨ瀛樺偍杩囩▼鐨勪俊鎭� - if (res === false) return res - - let sysDefer = new Promise(resolve => { - Api.getSystemConfig({ - func: 'sPC_Get_TVP', // 浜戠鑾峰彇瀛樺偍缁撴灉 - TVPName: btn.innerFunc - }).then(result => { - resolve(result) - }) - }) - - let localDefer = new Promise(resolve => { - let _param = { // 鑾峰彇鏈湴瀛樺偍杩囩▼淇℃伅 - func: 's_get_userproc', - LText: btn.innerFunc - } - _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' - _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp) - - Api.getLocalConfig(_param).then(result => { - resolve(result) - }) - }) - - return Promise.all([sysDefer, localDefer]) - }).then(res => { - // 浜戠缁撴灉涓庢柊璇彞涓嶅悓鏃讹紝鏇存柊浜戠淇℃伅 - if (res === false) return res - - let isError = false - - res.forEach((result, index) => { - if (!result.status) { - notification.warning({ - top: 92, - message: result.message, - duration: 10 - }) - isError = true - } else if (index === 0) { - sysTVPText = result.TVPText - } else { - if (result.Ltext) { // 鏈湴瀛樺偍杩囩▼鏄惁瀛樺湪 - isExit = true - } - localTVPText = Utils.formatOptions(result.Ltext) - } - }) - - if (isError) return false - - if ((newLText === localTVPText) && (newLText === sysTVPText)) { - return 'drop' - } else if (!localTVPText || (localTVPText === sysTVPText)) { - // 鏈湴瀛樺偍杩囩▼涓嶅瓨鍦紝灏嗘柊鐨勫瓨鍌ㄨ繃绋嬫洿鏂拌嚦浜戠 - return Api.getSystemConfig({ - func: 'sPC_TVP_InUp', - TVPName: btn.innerFunc, - TVPText: newLText, - TypeName: 'P' - }) - } else { - return new Promise(resolve => { - Api.getSystemConfig({ // 娣诲姞鐜版湁鐨勬湰鍦板瓨鍌ㄨ繃绋嬭嚦浜戠 - func: 'sPC_TVP_InUp', - TVPName: btn.innerFunc, - TVPText: localTVPText, - TypeName: 'P' - }).then(result => { - if (result.status) { - Api.getSystemConfig({ - func: 'sPC_TVP_InUp', // 娣诲姞鏈�鏂扮殑瀛樺偍杩囩▼鑷充簯绔� - TVPName: btn.innerFunc, - TVPText: newLText, - TypeName: 'P' - }).then(response => { - resolve(response) - }) - } else { - resolve(result) - } - }) - }) - } - }).then(res => { - // 浜戠淇℃伅鏇存柊鍚庯紝鍒ゆ柇鏄垹闄ゆ垨鏄洿鎺ユ柊寤哄瓨鍌ㄨ繃绋� - if (res === false || res === 'drop') return res - - if (!res.status) { - notification.warning({ - top: 92, - message: res.message, - duration: 10 - }) - return false - } else if (isExit) { - return 'drop' - } else { - return 'create' - } - }).then(res => { - // 鍒犻櫎瀛樺偍杩囩▼ - if (res === false || res === 'create') return res - - let _param = { - func: 'sPC_TableData_InUpDe', - LText: DelText, - TypeCharOne: 'proc' // 鍒犻櫎鎴栧垱寤哄瓨鍌ㄨ繃绋� - } - - _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' - _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp) - - return Api.getLocalConfig(_param) - }).then(res => { - // 鏍规嵁涓婅堪鎿嶄綔缁撴灉锛屽垽鏂槸鍚︽柊寤哄瓨鍌ㄨ繃绋� - if (res === false || res === 'create') return res - - if (!res.status) { - notification.warning({ - top: 92, - message: res.message, - duration: 10 - }) - return false - } else { - return 'create' - } - }).then(res => { - // 鏂板缓瀛樺偍杩囩▼ - if (res === false) return res - - let _param = { - func: 'sPC_TableData_InUpDe', - LText: newLText, - TypeCharOne: 'proc' // 鍒犻櫎鎴栧垱寤哄瓨鍌ㄨ繃绋� - } - _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' - _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp) - - return Api.getLocalConfig(_param) - }).then(res => { - // 澶勭悊鏂板缓缁撴灉 - if (res === false) return res - - if (!res.status) { - notification.warning({ - top: 92, - message: res.message, - duration: 10 - }) - return false - } else { - notification.success({ - top: 92, - message: '鍒涘缓鎴愬姛', - duration: 2 - }) - return true - } - }).then(res => { - // 鏂板缓鎴愬姛鍚庯紝鏇存柊椤甸潰鎸夐挳淇℃伅 - if (res === false) { - this.setState({ - funcLoading: false - }) - return - } - - _config.action = _config.action.map(item => { - if (item.uuid === btn.uuid) { - return btn - } else { - return item - } - }) - _config.action = _config.action.filter(item => !item.origin) - - // 鍒ゆ柇鏄惁瀛樺湪鎿嶄綔鍒� - let _hasGridbtn = _config.action.filter(act => act.position === 'grid').length > 0 - - if (_config.gridBtn) { - _config.gridBtn.display = _hasGridbtn - } else { - _config.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, - funcLoading: false - }) - }) - }) - } - - /** - * @description 鍒涘缓琛ㄦ牸瀛樺偍杩囩▼ - */ - tableCreatFunc = () => { - let config = JSON.parse(JSON.stringify(this.state.config)) - - this.settingRef.handleConfirm().then(res => { - const setting = res - if (!(setting.interType === 'inner') || !setting.innerFunc) { - notification.warning({ - top: 92, - message: '鎺ュ彛绫诲瀷涓�-鍐呴儴锛屼笖瀛樺湪鍐呴儴鍑芥暟鏃讹紝鎵嶅彲浠ュ垱寤哄瓨鍌ㄨ繃绋嬶紒', - duration: 10 - }) - return - } - - if (setting.dataresource.length > 50 && config.setting.dataresource !== setting.dataresource) { - let param = { - func: 's_DataSrc_Save', - LText: setting.dataresource, - MenuID: config.uuid - } - - 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({ - funcLoading: true - }) - - let newLText = Utils.formatOptions(Utils.getTableFunc(setting, {MenuID: config.uuid, MenuName: config.tabName, MenuNo: config.tabNo}, config)) // 鍒涘缓瀛樺偍杩囩▼sql - let DelText = Utils.formatOptions(Utils.dropfunc(setting.innerFunc)) // 鍒犻櫎瀛樺偍杩囩▼sql - - new Promise(resolve => { - let sysDefer = new Promise(resolve => { - Api.getSystemConfig({ - func: 'sPC_Get_TVP', // 浜戠鑾峰彇瀛樺偍缁撴灉 - TVPName: setting.innerFunc - }).then(result => { - if (!result.status) { - notification.warning({ - top: 92, - message: result.message, - duration: 10 - }) - resolve(false) - } else { - resolve(result) - } - }) - }) - - let localDefer = new Promise(resolve => { - let _param = { // 鑾峰彇鏈湴瀛樺偍杩囩▼淇℃伅 - func: 's_get_userproc', - LText: setting.innerFunc - } - _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' - _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp) - - Api.getLocalConfig(_param).then(result => { - if (!result.status) { - notification.warning({ - top: 92, - message: result.message, - duration: 10 - }) - resolve(false) - } else { - resolve(result) - } - }) - }) - - Promise.all([sysDefer, localDefer]).then(result => { - resolve(result) - }) - }).then(res => { - // 鑾峰彇浜戠鍙婃湰鍦帮紝鏄惁宸插瓨鍦ㄨ瀛樺偍杩囩▼鐨勪俊鎭� - if (res === false) return res - if (res[0] === false || res[1] === false) return false - - let cloudfunc = '' - let localfunc = '' - res.forEach((item, index) => { - if (index === 0 && item.TVPText) { - cloudfunc = item.TVPText - } else if (index === 1 && item.Ltext) { - localfunc = Utils.formatOptions(item.Ltext) - } - }) - - if ((newLText === localfunc) && (newLText === cloudfunc)) { - return 'drop' - } else if (!localfunc || (cloudfunc === localfunc)) { - // 鏈湴瀛樺偍杩囩▼涓嶅瓨鍦紝鎴栦簯绔拰鏈湴瀛樺偍杩囩▼涓�鑷存椂锛屽皢鏂扮殑瀛樺偍杩囩▼鏇存柊鑷充簯绔� - return Api.getSystemConfig({ - func: 'sPC_TVP_InUp', - TVPName: setting.innerFunc, - TVPText: newLText, - TypeName: 'P' - }) - } else { - return new Promise(resolve => { - Api.getSystemConfig({ // 娣诲姞鐜版湁鐨勬湰鍦板瓨鍌ㄨ繃绋嬭嚦浜戠 - func: 'sPC_TVP_InUp', - TVPName: setting.innerFunc, - TVPText: localfunc, - TypeName: 'P' - }).then(result => { - if (result.status) { - Api.getSystemConfig({ - func: 'sPC_TVP_InUp', // 娣诲姞鏈�鏂扮殑瀛樺偍杩囩▼鑷充簯绔� - TVPName: setting.innerFunc, - TVPText: newLText, - TypeName: 'P' - }).then(response => { - resolve(response) - }) - } else { - resolve(result) - } - }) - }) - } - }).then(res => { - // 浜戠淇℃伅鏇存柊鍚庯紝鍒ゆ柇鏄垹闄ゆ垨鏄洿鎺ユ柊寤哄瓨鍌ㄨ繃绋� - if (res === false || res === 'drop') return res - - if (!res.status) { - notification.warning({ - top: 92, - message: res.message, - duration: 10 - }) - return false - } else { - return 'create' - } - }).then(res => { - // 鍒犻櫎瀛樺偍杩囩▼ - if (res === false || res === 'create') return res - - let _param = { - func: 'sPC_TableData_InUpDe', - LText: DelText, - TypeCharOne: 'proc' // 鍒犻櫎鎴栧垱寤哄瓨鍌ㄨ繃绋� - } - - _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' - _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp) - - return Api.getLocalConfig(_param) - }).then(res => { - // 鏍规嵁涓婅堪鎿嶄綔缁撴灉锛屽垽鏂槸鍚︽柊寤哄瓨鍌ㄨ繃绋� - if (res === false || res === 'create') return res - - if (!res.status) { - notification.warning({ - top: 92, - message: res.message, - duration: 10 - }) - return false - } else { - return 'create' - } - }).then(res => { - // 鏂板缓瀛樺偍杩囩▼ - if (res === false) return res - - let _param = { - func: 'sPC_TableData_InUpDe', - LText: newLText, - TypeCharOne: 'proc' // 鍒犻櫎鎴栧垱寤哄瓨鍌ㄨ繃绋� - } - _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' - _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp) - - return Api.getLocalConfig(_param) - }).then(res => { - // 澶勭悊鏂板缓缁撴灉 - if (res === false) return res - - if (!res.status) { - notification.warning({ - top: 92, - message: res.message, - duration: 10 - }) - return false - } else { - notification.success({ - top: 92, - message: '鍒涘缓鎴愬姛', - duration: 2 - }) - return true - } - }).then(res => { - // 鏂板缓鎴愬姛鍚庯紝鏇存柊椤甸潰鎸夐挳淇℃伅 - if (res === false) { - this.setState({ - funcLoading: false - }) - return - } - - this.setState({ - config: {...config, setting: setting} - }) - }) - }) - } - - deleteElement = (element) => { - 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)) - _config[element.type] = _config[element.type].filter(item => { - if (item.uuid === element.card.uuid) { - return false - } else { - return true - } - }) - - // 鍒犻櫎鎸夐挳鍏冪礌 - let _delActions = _this.state.delActions - if (element.type === 'action') { - _delActions.push(element.card.uuid) - } - - _this.setState({ - config: _config, - delActions: _delActions - }) - }, - 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)) - 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: '' - }) } /** * @description 鏍囩椤典繚瀛� */ submitConfig = () => { - const { delActions, originConfig } = this.state - let config = JSON.parse(JSON.stringify(this.state.config)) + const { delActions, thawButtons, openEdition } = this.state + let _config = fromJS(this.state.config).toJS() + let copyreg = /\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}$/ig - this.menuformRef.handleConfirm().then(res => { + // 鍩烘湰淇℃伅楠岃瘉 + if (!_config.tabName || !_config.tabNo) { + notification.warning({ + top: 92, + message: this.state.dict['model.menu.basemsg'], + duration: 5 + }) + this.setState({activeKey: '0'}) + return + } - if (originConfig.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 (copyreg.test(_config.tabNo) || copyreg.test(_config.tabName)) { + notification.warning({ + top: 92, + message: '姝ゆ爣绛句负澶嶅埗鏍囩锛岃淇敼鏍囩鍚嶇О鍜屾爣绛惧弬鏁帮紝涓嶅彲浠ユ椂闂存牸寮� YYYY-MM-DD HH:mm:ss 缁撳熬锛�', + duration: 5 + }) + return + } + + if (_config.isAdd) { + if (_config.search[0] && _config.search[0].origin) { + _config.search = _config.search.filter(item => !item.origin) } - - let _LongParam = '' - let _config = {...config, tables: this.state.selectedTables, ...res} - - // 淇濆瓨鏃跺垹闄ら厤缃被鍨嬶紝system 銆乽ser - delete _config.type - delete _config.isAdd - - try { - _LongParam = window.btoa(window.encodeURIComponent(JSON.stringify(_config))) - } catch (e) { - notification.warning({ - top: 92, - message: '缂栬瘧閿欒', - duration: 10 - }) - return + if (_config.action[0] && _config.action[0].origin) { + _config.action = _config.action.filter(item => !item.origin) } - - let btnParam = { - func: 'sPC_Button_AddUpt', - Type: 40, - ParentID: _config.uuid, - MenuNo: res.tabNo, - Template: 'SubTable', - PageParam: '', - LongParam: '', - LText: config.action.map((item, index) => { - return `select '${item.uuid}' as menuid, '${item.label}' as menuname, '${(index + 1) * 10}' as Sort` - }) + if (_config.columns[0] && _config.columns[0].origin) { + _config.columns = _config.columns.filter(item => !item.origin) } + } - btnParam.LText = btnParam.LText.join(' union all ') - btnParam.LText = Utils.formatOptions(btnParam.LText) - btnParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' - btnParam.secretkey = Utils.encrypt(btnParam.LText, btnParam.timestamp) - - let param = { - func: 'sPC_Tab_AddUpt', - MenuID: _config.uuid, - MenuNo: res.tabNo, - Template: 'SubTable', - MenuName: res.tabName, - Remark: res.Remark, - Sort: 0, - PageParam: JSON.stringify({Template: 'SubTable'}), - LongParam: _LongParam - } - - if (this.state.closeVisible) { // 鏄剧ず鍏抽棴瀵硅瘽妗嗘椂锛屾ā鎬佹涓繚瀛樻寜閽紝鏄剧ず淇濆瓨涓姸鎬� - this.setState({ - menucloseloading: true - }) - } else { - this.setState({ - menuloading: true - }) - } - - - // 鏈夋寜閽垨鏍囩鍒犻櫎鏃讹紝鍏堣繘琛屽垹闄ゆ搷浣� - // 鍒犻櫎鎴愬姛鍚庯紝淇濆瓨椤甸潰閰嶇疆 - new Promise(resolve => { - if (delActions.length > 0) { - let deffers = delActions.map(item => { - let _param = { - func: 'sPC_MainMenu_Del', - MenuID: item - } - return new Promise(resolve => { - Api.getSystemConfig(_param).then(response => { - resolve(response) - }) - }) - }) - Promise.all(deffers).then(result => { - let error = null - result.forEach(response => { - if (!response.status) { - error = response - } - }) + // 鏈缃暟鎹簮鎴栦富閿椂锛屽惎鐢ㄧ姸鎬佷负false + let result = this.verifyconfig(_config) - if (error) { - this.setState({ - menuloading: false, - menucloseloading: false - }) - notification.warning({ - top: 92, - message: error.message, - duration: 10 - }) - resolve(false) - } else { - this.setState({ - delActions: [] - }) - resolve(true) + if (result !== true) { + _config.enabled = false + } + + if (this.state.closeVisible) { // 鏄剧ず鍏抽棴瀵硅瘽妗嗘椂锛屾ā鎬佹涓繚瀛樻寜閽紝鏄剧ず淇濆瓨涓姸鎬� + this.setState({ + menucloseloading: true + }) + } else { + this.setState({ + menuloading: true + }) + } + + // 淇濆瓨鏃跺垹闄ら厤缃被鍨嬶紝system 銆乽ser + delete _config.type + delete _config.isAdd + + let _LongParam = '' + + try { + _LongParam = window.btoa(window.encodeURIComponent(JSON.stringify(_config))) + } catch (e) { + notification.warning({ + top: 92, + message: '缂栬瘧閿欒', + duration: 5 + }) + + this.setState({ + menucloseloading: false, + menuloading: false + }) + return + } + + let btnParam = { + func: 'sPC_Button_AddUpt', + Type: 40, + ParentID: _config.uuid, + MenuNo: _config.tabNo, + Template: 'SubTable', + PageParam: '', + LongParam: '', + LText: [] + } + + let btntabs = [] + + _config.action.forEach((item, index) => { + if (item.OpenType === 'popview') { + btntabs.push(`select '${item.uuid}' as MenuID ,'${item.linkTab}' as Tabid,'${item.label}' as TabName ,'${(index + 1) * 10}' as Sort`) + } + btnParam.LText.push(`select '${item.uuid}' as menuid, '${item.label}' as menuname, '${(index + 1) * 10}' as Sort`) + }) + + btnParam.LText = btnParam.LText.join(' union all ') + btnParam.LText = Utils.formatOptions(btnParam.LText) + btnParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + btnParam.secretkey = Utils.encrypt(btnParam.LText, btnParam.timestamp) + + let tabParam = { // 娣诲姞鏍囩鎸夐挳tab椤� + func: 'sPC_sMenusTab_AddUpt', + MenuID: _config.uuid, + LText: btntabs.join(' union all ') + } + + tabParam.LText = Utils.formatOptions(tabParam.LText) + tabParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + tabParam.secretkey = Utils.encrypt(tabParam.LText, tabParam.timestamp) + + let param = { + func: 'sPC_Tab_AddUpt', + MenuID: _config.uuid, + MenuNo: _config.tabNo, + Template: 'SubTable', + MenuName: _config.tabName, + Remark: _config.Remark, + Sort: 0, + PageParam: JSON.stringify({Template: 'SubTable'}), + LongParam: _LongParam + } + + if (openEdition) { + param.open_edition = openEdition + } + + // 鏈夋寜閽垨鏍囩鍒犻櫎鏃讹紝鍏堣繘琛屽垹闄ゆ搷浣� + // 鍒犻櫎鎴愬姛鍚庯紝淇濆瓨椤甸潰閰嶇疆 + new Promise(resolve => { + if (delActions.length > 0) { + let deffers = delActions.map(item => { + let _param = { + func: 'sPC_MainMenu_Del', + MenuID: item.card.uuid + } + + let _ParentParam = null + + try { + _ParentParam = window.btoa(window.encodeURIComponent(JSON.stringify(item.card))) + } catch (e) { + console.warn('Stringify Failure') + _ParentParam = null + } + + if (_ParentParam) { // 鍒犻櫎鎸夐挳鏃讹紝淇濆瓨鎸夐挳閰嶇疆淇℃伅锛岀敤浜庢仮澶嶆寜閽� + _param.ParentParam = _ParentParam + } + + return new Promise(resolve => { + Api.getSystemConfig(_param).then(response => { + resolve(response) + }) + }) + }) + Promise.all(deffers).then(result => { + let error = null + result.forEach(response => { + if (!response.status) { + error = response } }) - } else if (delActions.length === 0) { - resolve(true) - } - }).then(resp => { - if (resp === false) return - Api.getSystemConfig(param).then(response => { - if (response.status) { - this.setState({ - config: _config, - originConfig: _config - }, () => { - this.setState({ - menuloading: false, - menucloseloading: false - }) - this.submitAction(btnParam) - }) - } else { + if (error) { this.setState({ menuloading: false, menucloseloading: false }) notification.warning({ top: 92, - message: response.message, - duration: 10 + message: error.message, + duration: 5 }) + resolve(false) + } else { + this.setState({ + delActions: [] + }) + resolve(true) } }) - }) - }, () => { - notification.warning({ - top: 92, - message: this.state.dict['header.menu.basemsg'], - duration: 10 + } else if (delActions.length === 0) { + resolve(true) + } + }).then(resp => { + if (resp === false) return + + if (thawButtons.length > 0) { + let defers = thawButtons.map(item => { + return new Promise((resolve) => { + Api.getSystemConfig({ + func: 'sPC_MainMenu_ReDel', + MenuID: item + }).then(res => { + if (res.status) { + resolve('') + } else { + resolve(res.message) + } + }) + }) + }) + + return Promise.all(defers) + } else { + return true + } + }).then(res => { + if (res === true || res === false) return res + + let msg = res.filter(Boolean)[0] + if (msg) { + notification.warning({ + top: 92, + message: msg, + duration: 5 + }) + return false + } else { + this.setState({ + thawButtons: [] + }) + return true + } + }).then(resp => { + if (resp === false) return + + Api.getSystemConfig(param).then(response => { + if (response.status) { + this.setState({ + openEdition: response.open_edition || '', + config: _config, + originConfig: fromJS(_config).toJS() + }, () => { + this.setState({ + menuloading: false, + menucloseloading: false + }) + this.submitAction(btnParam, tabParam) + }) + } else { + this.setState({ + menuloading: false, + menucloseloading: false + }) + notification.warning({ + top: 92, + message: response.message, + duration: 5 + }) + } }) }) } @@ -1271,24 +494,57 @@ /** * @description 淇濆瓨鎴栦慨鏀硅彍鍗曟寜閽� */ - submitAction = (param) => { + submitAction = (btnParam, tabParam) => { const { config } = this.state + new Promise(resolve => { - if (param.LText) { - Api.getSystemConfig(param).then(res => { - if (res.status) { - resolve(true) - } else { + let deffers = [] + + if (tabParam.LText) { + let defer = new Promise(resolve => { + Api.getSystemConfig(tabParam).then(result => { + resolve(result) + }) + }) + deffers.push(defer) + } + + if (btnParam.LText) { + let defer = new Promise(resolve => { + Api.getSystemConfig(btnParam).then(result => { + if (result.status) { + this.setState({ // 淇濆瓨鎴愬姛鍚庢竻绌哄鍒跺垪琛� + copyActions: [] + }) + } + resolve(result) + }) + }) + deffers.push(defer) + } + + if (deffers.length === 0) { + resolve(true) + } else { + Promise.all(deffers).then(result => { + let error = false + result.forEach(res => { + if (!res.status) { + error = res + } + }) + + if (error) { notification.warning({ top: 92, - message: res.message, - duration: 10 + message: error.message, + duration: 5 }) resolve(false) + } else { + resolve(true) } }) - } else { - resolve(true) } }).then(response => { if (response === false) return response @@ -1298,6 +554,7 @@ let curBtn = config.action.filter(cell => item.curuuid === cell.uuid)[0] // 鏌ョ湅鍒濆鍖栨寜閽槸鍚﹀瓨鍦� if (!curBtn) return if (curBtn.OpenType !== item.prebtn.OpenType) return + if (curBtn.OpenType === 'funcbutton' && curBtn.execMode !== 'pop') return oriActions.push({ prebtn: item.prebtn, @@ -1316,10 +573,10 @@ let _LongParam = '' if (result.LongParam) { - _LongParam = window.decodeURIComponent(window.atob(result.LongParam)) try { - _LongParam = JSON.parse(_LongParam) + _LongParam = JSON.parse(window.decodeURIComponent(window.atob(result.LongParam))) } catch (e) { + console.warn('Parse Failure') _LongParam = '' } } @@ -1373,505 +630,317 @@ if (originConfig.isAdd) { confirm({ content: '鑿滃崟灏氭湭鎻愪氦锛岀‘瀹氭斁寮冧繚瀛樺悧锛�', - okText: this.state.dict['header.confirm'], - cancelText: this.state.dict['header.cancel'], onOk() { _this.handleViewBack() }, onCancel() {} }) } else { - this.menuformRef.handleConfirm().then(res => { - let _config = {...config, tables: this.state.selectedTables, ...res} - - if (!is(fromJS(originConfig), fromJS(_config))) { - this.setState({ - closeVisible: true - }) - } else { - this.handleViewBack() - } - }, () => { + if (!is(fromJS(originConfig), fromJS(config))) { this.setState({ closeVisible: true }) - }) - } - } - - 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()] - }) - } - - addFieldSubmit = () => { - // 瀛楁闆嗕负绌猴紝鍏抽棴寮圭獥 - if (!this.state.fields || this.state.fields.length === 0) { - this.setState({ - tableVisible: false, - addType: '' - }) - } - - const {addType, config} = this.state - 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 - let columnsMap = new Map() - cards.forEach(card => { - columnsMap.set(card.field, card) - }) - - let items = [] - if (addType === 'search') { - config.search.forEach(item => { - if (columnsMap.has(item.field)) { - let cell = columnsMap.get(item.field) - - if (cell.selected && cell.type === item.type) { // 鏁版嵁鏈慨鏀� - items.push(item) - } else if (cell.selected) { // 鏁版嵁绫诲瀷淇敼 - if (cell.type === 'text') { - item.match = textmatch[cell.datatype] - } else 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 = '' - items.push(item) - } - columnsMap.delete(item.field) - } else if (!item.origin) { - items.push(item) - } - }) - - let _columns = [...columnsMap.values()] - - _columns.forEach(item => { - if (item.selected) { - let _match = '' - if (item.type === 'text') { - _match = textmatch[item.datatype] - } else if (item.type === 'select') { - _match = selectmatch[item.datatype] - } else if (item.type === 'daterange') { - _match = datematch[item.datatype] - } else { - item.type = 'text' - _match = textmatch[item.datatype] - } - - let newcard = { - uuid: Utils.getuuid(), - label: item.label, - field: item.field, - initval: '', - type: item.type, - resourceType: '0', - setAll: 'false', - options: [], - dataSource: '', - linkField: '', - valueField: '', - valueText: '', - orderBy: '', - orderType: 'asc', - match: _match, - display: 'dropdown' - } - - items.push(newcard) - } - }) - } else { - config.columns.forEach(item => { - if (columnsMap.has(item.field)) { - let cell = columnsMap.get(item.field) - - if (cell.selected) { - items.push(item) - } - columnsMap.delete(item.field) - } else if (!item.origin) { - items.push(item) - } - }) - - let _columns = [...columnsMap.values()] - - _columns.forEach(item => { - if (item.selected) { - 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 - } - - items.push(newcard) - } - }) - } - - this.setState({ - config: {...config, [addType]: items} - }) - - notification.success({ - top: 92, - message: '鎿嶄綔鎴愬姛', - duration: 2 - }) - } - - 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 - }) - } - }) - } - } - - 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) - }) - } - - changeSetting = () => { - this.setState({ - settingVisible: true - }) - } - - settingSave = () => { - const { config } = this.state - - this.settingRef.handleConfirm().then(res => { - if ( - res.interType === 'inner' && - !res.innerFunc && - res.dataresource.length > 50 && - config.setting.dataresource !== res.dataresource - ) { - let param = { - func: 's_DataSrc_Save', - LText: res.dataresource, - MenuID: config.uuid - } - - 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) + } else { + this.handleViewBack() } - - this.setState({ - config: {...config, setting: res}, - settingVisible: false, - }) - }) + } } /** * @description 璁剧疆鍙厤缃寜閽� */ setSubConfig = (btn) => { - const {menu, editTab, tabConfig, editSubTab} = this.props - const { config, originConfig } = this.state + const {menu, editTab, tabConfig, editSubTab, btnTab, btnTabConfig} = this.props + const { config, originConfig, activeKey, openEdition } = this.state if (originConfig.isAdd) { notification.warning({ top: 92, message: '鑿滃崟灏氭湭淇濆瓨锛岃淇濆瓨鑿滃崟閰嶇疆锛�', - duration: 10 + duration: 5 }) } else { - this.menuformRef.handleConfirm().then(res => { - let _config = {...config, tables: this.state.selectedTables, ...res} - - if (!is(fromJS(originConfig), fromJS(_config))) { - notification.warning({ - top: 92, - message: '鑿滃崟閰嶇疆宸蹭慨鏀癸紝璇蜂繚瀛橈紒', - duration: 10 - }) - } else { - this.setState({ - loading: true - }) - - // 瀛愯彍鍗曚俊鎭獙璇侀�氳繃鍚庯紝璺宠浆瀛愭寜閽厤缃〉闈� - let _view = '' - let _subtab = editSubTab - - if (btn.OpenType === 'pop') { - _view = 'Modal' // 琛ㄥ崟椤甸潰 - } else if (btn.OpenType === 'popview') { - _view = btn.tabType // 鏂板脊绐楁爣绛炬ā鏉� - _subtab = btn - } - - let param = { - editMenu: menu, - editTab: editTab, - tabConfig: editSubTab ? tabConfig : originConfig, - editSubTab: _subtab, - subTabConfig: editSubTab ? originConfig : null, - editAction: btn, - subConfig: '', - tabview: _view - } - - Api.getSystemConfig({ - func: 'sPC_Get_LongParam', - MenuID: btn.OpenType === 'popview' ? btn.linkTab : btn.uuid - }).then(res => { - if (res.status) { - this.setState({ - loading: false - }) - let _LongParam = '' - if (res.LongParam) { - _LongParam = window.decodeURIComponent(window.atob(res.LongParam)) - try { - _LongParam = JSON.parse(_LongParam) - } catch (e) { - _LongParam = '' - } - } - - if (_LongParam && param.tabview === 'Modal' && _LongParam.type === 'Modal') { - param.subConfig = _LongParam - } else if (_LongParam && param.tabview === 'SubTable' && _LongParam.Template === 'SubTable') { - param.subConfig = _LongParam - } - - this.props.handleView(param) - } else { - this.setState({ - loading: false - }) - notification.warning({ - top: 92, - message: res.message, - duration: 10 - }) - } - }) - } - }, () => { + if (!is(fromJS(originConfig), fromJS(config))) { notification.warning({ top: 92, - message: '鑿滃崟鍩烘湰淇℃伅宸蹭慨鏀癸紝璇蜂繚瀛橈紒', - duration: 10 + message: '鑿滃崟閰嶇疆宸蹭慨鏀癸紝璇蜂繚瀛橈紒', + duration: 5 }) - }) + } else { + // 瀛愯彍鍗曚俊鎭獙璇侀�氳繃鍚庯紝璺宠浆瀛愭寜閽厤缃〉闈� + let _view = '' + let _subtab = editSubTab + + if (btn.OpenType === 'pop' || btn.execMode === 'pop') { + _view = 'Modal' // 琛ㄥ崟椤甸潰 + } else if (btn.OpenType === 'popview') { + _view = 'SubTable' // 鏂板脊绐楁爣绛炬ā鏉� tabType 灞炴�у凡鍘婚櫎 + _subtab = btn + + if (editSubTab) { + notification.warning({ + top: 92, + message: '寮圭獥(鏍囩)涓笉鏀寔姝ゆ寜閽墦寮�鏂瑰紡锛�', + duration: 5 + }) + return + } + } + + if (editSubTab) { + editSubTab.activeKey = activeKey + editSubTab.open_edition = openEdition // 鏇存柊鐗堟湰鍙� + } else { + editTab.activeKey = activeKey + editTab.open_edition = openEdition // 鏇存柊鐗堟湰鍙� + } + + let param = { + editMenu: menu, + editTab: editTab, + tabConfig: editSubTab ? tabConfig : originConfig, + editSubTab: _subtab, + subTabConfig: editSubTab ? originConfig : null, + btnTab: btnTab, + btnTabConfig: btnTabConfig, + editAction: btn, + subConfig: '', + tabview: _view + } + + this.setState({ + loading: true + }) + + Api.getSystemConfig({ + func: 'sPC_Get_LongParam', + MenuID: btn.OpenType === 'popview' ? btn.linkTab : btn.uuid + }).then(res => { + if (res.status) { + this.setState({ + loading: false + }) + let _LongParam = '' + if (res.LongParam) { + try { + _LongParam = JSON.parse(window.decodeURIComponent(window.atob(res.LongParam))) + } catch (e) { + console.warn('Parse Failure') + _LongParam = '' + } + } + + if (_LongParam && param.tabview === 'Modal' && _LongParam.type === 'Modal') { + param.subConfig = _LongParam + } else if (_LongParam && param.tabview === 'SubTable' && _LongParam.Template === 'SubTable') { + param.subConfig = _LongParam + } + + if (param.editAction) { + param.editAction.open_edition = res.open_edition || '' + } else if (param.editSubTab) { + param.editSubTab.open_edition = res.open_edition || '' + } + + this.props.handleView(param) + } else { + this.setState({ + loading: false + }) + notification.warning({ + top: 92, + message: res.message, + duration: 5 + }) + } + }) + } } } + /** + * @description 鍒囨崲鏍囩鏄惁鍚敤 + */ onEnabledChange = () => { const { config } = this.state - if (config.setting.interType === 'inner' && !config.setting.innerFunc && !config.setting.dataresource) { + let _enabled = !config.enabled + let result = this.verifyconfig(config) + + if (_enabled && result !== true) { notification.warning({ top: 92, - message: '鑿滃崟灏氭湭璁剧疆鏁版嵁婧愶紝涓嶅彲鍚敤锛�', - duration: 10 + message: result, + duration: 5 }) + return + } + + this.setState({ + config: {...config, enabled: _enabled} + }) + } + + /** + * @description 鏍¢獙閰嶇疆淇℃伅鐨勫悎娉曟�� + */ + verifyconfig = (config) => { + let hasKey = false + let chartcols = [] + config.columns.forEach(col => { + if (col.field) { + chartcols.push(col.field) + } + if (config.setting.primaryKey === col.field) { + hasKey = true + } + }) + + let chartError = '' + config.charts && config.charts.forEach((chart, index) => { + if (chartError) return + if (chart.Hide === 'true') return + if (!['line', 'bar', 'pie'].includes(chart.chartType)) return + + if (!chart.Xaxis) { + chartError = `鍥捐〃${chart.title ? '銆�' + chart.title + '銆�' : index + 1}鍧愭爣杞村瓧娈靛皻鏈缃紝涓嶅彲鍚敤锛乣 + } else if (['line', 'bar'].includes(chart.chartType) && chart.datatype !== 'statistics' && (!chart.Yaxis || chart.Yaxis.length === 0)) { // query 鏌ヨ鏁版嵁 + chartError = `鍥捐〃${chart.title ? '銆�' + chart.title + '銆�' : index + 1}鍧愭爣杞村瓧娈靛皻鏈缃紝涓嶅彲鍚敤锛乣 + } else if (['line', 'bar'].includes(chart.chartType) && chart.datatype === 'statistics' && (!chart.InfoType || !chart.InfoValue)) { // statistics 缁熻鏁版嵁 + chartError = `鍥捐〃${chart.title ? '銆�' + chart.title + '銆�' : index + 1}鍧愭爣杞村瓧娈靛皻鏈缃紝涓嶅彲鍚敤锛乣 + } else if (chart.chartType === 'pie' && !chart.Yaxis) { + chartError = `鍥捐〃${chart.title ? '銆�' + chart.title + '銆�' : index + 1}鍧愭爣杞村瓧娈靛皻鏈缃紝涓嶅彲鍚敤锛乣 + } else if (!chartcols.includes(chart.Xaxis)) { + chartError = `鍥捐〃${chart.title ? '銆�' + chart.title + '銆�' : index + 1}鍧愭爣杞村瓧娈靛湪鏄剧ず鍒椾腑涓嶅瓨鍦紝涓嶅彲鍚敤锛乣 + } else if (chart.chartType === 'pie' && !chartcols.includes(chart.Yaxis)) { + chartError = `鍥捐〃${chart.title ? '銆�' + chart.title + '銆�' : index + 1}鍧愭爣杞村瓧娈靛湪鏄剧ず鍒椾腑涓嶅瓨鍦紝涓嶅彲鍚敤锛乣 + } else if (['line', 'bar'].includes(chart.chartType) && chart.datatype === 'statistics' && (!chartcols.includes(chart.InfoType) || !chartcols.includes(chart.InfoValue))) { // statistics 缁熻鏁版嵁 + chartError = `鍥捐〃${chart.title ? '銆�' + chart.title + '銆�' : index + 1}鍧愭爣杞村瓧娈靛湪鏄剧ず鍒椾腑涓嶅瓨鍦紝涓嶅彲鍚敤锛乣 + } else if (['line', 'bar'].includes(chart.chartType) && chart.datatype !== 'statistics' && chart.Yaxis.filter(yaxis => !chartcols.includes(yaxis)).length > 0) { + chartError = `鍥捐〃${chart.title ? '銆�' + chart.title + '銆�' : index + 1}鍧愭爣杞村瓧娈靛湪鏄剧ず鍒椾腑涓嶅瓨鍦紝涓嶅彲鍚敤锛乣 + } + }) + + config.action && config.action.forEach((btn) => { + if (['prompt', 'exec', 'pop'].includes(btn.OpenType) && btn.Ot === 'required' && btn.verify && btn.verify.scripts && btn.verify.scripts.length > 0) { + let hascheck = false + btn.verify.scripts.forEach(item => { + if (item.status === 'false') return + + if (/\$check@|@check\$/ig.test(item.sql)) { + hascheck = true + } + }) + if (hascheck) { + notification.warning({ + top: 92, + message: `鍙�夋嫨澶氳鐨勬寜閽��${btn.label}銆嬩腑 $check@ 鎴� @check$ 灏嗕笉浼氱敓鏁堬紒`, + duration: 5 + }) + } + } + }) + + if ((config.setting.interType === 'system' || config.setting.requestMode === 'system') && config.setting.default === 'false' && config.setting.scripts && config.setting.scripts.filter(item => item.status !== 'false').length === 0) { + return '鏁版嵁婧愪腑涓嶆墽琛岄粯璁ql锛屼笖鏈坊鍔犺嚜瀹氫箟鑴氭湰锛屼笉鍙惎鐢紒' + } else if (config.setting.interType === 'custom' && config.setting.procMode !== 'inner' && config.setting.preScripts && config.setting.preScripts.filter(item => item.status !== 'false').length === 0) { + return '鏁版嵁婧愭湭璁剧疆鍓嶇疆鑴氭湰锛屼笉鍙惎鐢紒' + } else if (config.setting.interType === 'custom' && config.setting.callbackType === 'script' && config.setting.cbScripts && config.setting.cbScripts.filter(item => item.status !== 'false').length === 0) { + return '鏁版嵁婧愭湭璁剧疆鍥炶皟鑴氭湰锛屼笉鍙惎鐢紒' + } else if (!config.setting.primaryKey) { + return '灏氭湭璁剧疆涓婚敭锛屼笉鍙惎鐢紒' + } else if (config.columns.length === 0) { + return '灏氭湭璁剧疆鏄剧ず鍒楋紝涓嶅彲鍚敤锛�' + } else if (!hasKey) { + return '鏄剧ず鍒椾腑涓嶅瓨鍦ㄤ富閿瓧娈碉紝涓嶅彲鍚敤锛�' + } else if (chartError) { + return chartError } else { - this.setState({ - config: {...config, enabled: !config.enabled} - }) + return true } } - onColumnNameChange = () => { - const { showColumnName } = this.state + /** + * @description 缂栬緫鍔熻兘瀹屾垚鏇存柊锛屽寘鎷В鍐绘寜閽�佺矘璐淬�佹浛鎹㈢瓑 + */ + updateConfig = (res) => { + if (res.type === 'thaw') { + this.setState({ + thawButtons: res.thawButtons, + config: res.config + }) + } else if (res.type === 'paste') { + this.setState({config: res.config}) + } + } + + /** + * @description 鏇存柊鎼滅储鏉′欢閰嶇疆淇℃伅 + */ + updatesearch = (config) => { this.setState({ - showColumnName: !showColumnName + config: config + }) + } + + /** + * @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 鏇存柊鏄剧ず鍒楅厤缃俊鎭� + */ + updateconfig = (config) => { + this.setState({ + config: config + }) + } + + /** + * @description 鏇存柊鍥捐〃缁勯厤缃俊鎭� + */ + updatechartgroup = (config, _chartview) => { + this.setState({ + config: config, + chartview: _chartview }) } render () { - const { modaltype } = 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'].includes(_action.OpenType) || (_action.OpenType === 'funcbutton' && _action.execMode === 'pop'))) return ( - <div className="common-table-board"> + <div className="model-subtable-board"> <DndProvider backend={HTML5Backend}> {/* 宸ュ叿鏍� */} <div className="tools"> - <Collapse accordion defaultActiveKey="0" bordered={false}> + <Collapse accordion activeKey={activeKey} bordered={false} onChange={(key) => this.setState({activeKey: key})}> {/* 鍩烘湰淇℃伅 */} - <Panel header={'鏍囩鍩烘湰淇℃伅'} key="0" id="common-basedata"> + <Panel forceRender={true} header={'鏍囩鍩烘湰淇℃伅'} key="0" id="subtable-basedata"> {/* 鑿滃崟淇℃伅 */} <MenuForm dict={this.state.dict} - formlist={this.state.menuformlist} - wrappedComponentRef={(inst) => this.menuformRef = inst} + config={config} + updatemenu={this.updateconfig} /> {/* 琛ㄥ悕娣诲姞 */} - <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="subtable-basedata" + updatetable={this.updateconfig} + /> </Panel> {/* 鎼滅储鏉′欢娣诲姞 */} <Panel header={this.state.dict['header.menu.search']} key="1"> @@ -1880,7 +949,11 @@ return (<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" + updatefield={this.updateconfig} + /> </Panel> {/* 鎸夐挳娣诲姞 */} <Panel header={this.state.dict['header.menu.action']} key="2"> @@ -1889,15 +962,17 @@ return (<SourceElement key={index} content={item}/>) })} </div> - {configAction.length > 0 ? - <p className="config-btn-title"> - <Tooltip placement="topLeft" title="鐐瑰嚮鎸夐挳锛屽彲瀹屾垚鎴栨煡鐪嬫寜閽厤缃俊鎭��"> - <Icon type="question-circle" /> - </Tooltip> - {this.state.dict['header.menu.action.configurable']} - </p> : null - } - {configAction.map((item, index) => { + <div className="config-btn"> + {confActions.length > 0 ? + <p className="config-btn-title"> + <Tooltip placement="topLeft" title="鐐瑰嚮鎸夐挳锛屽彲瀹屾垚鎴栨煡鐪嬫寜閽厤缃俊鎭��"> + <Icon type="question-circle" /> + </Tooltip> + {this.state.dict['header.menu.action.configurable']} + </p> : null + } + </div> + {confActions.map((item, index) => { return ( <div key={index}> <Button @@ -1917,225 +992,102 @@ return (<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" + updatefield={this.updateconfig} + /> </Panel> </Collapse> </div> <div className="setting"> - <Card title={'鏍囩锛堝瓙琛級椤甸潰閰嶇疆'} bordered={false} extra={ + <Card title={ <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> + 鏍囩锛堝瓙琛級椤甸潰閰嶇疆 + <Icon type="redo" style={{marginLeft: '10px'}} title="鍒锋柊鏍囩鍒楄〃" onClick={() => this.reloadTab(true)} /> + </div> + } bordered={false} extra={ + <div> + <EditComponent dict={this.state.dict} options={['search', 'action', 'columns']} config={config} MenuID={config.uuid} thawButtons={this.state.thawButtons} refresh={this.updateConfig}/> + <Switch className="big" checkedChildren="鍚�" unCheckedChildren="鍋�" checked={config.enabled} onChange={this.onEnabledChange} /> + <Button type="primary" onClick={this.submitConfig} loading={this.state.menuloading}>{this.state.dict['model.save']}</Button> + <Button onClick={this.cancelConfig}>{this.state.dict['model.back']}</Button> </div> } style={{ width: '100%' }}> - <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"> - <Tooltip placement="bottomLeft" overlayClassName="middle" title="鍦ㄥ乏渚у伐鍏锋爮銆婃寜閽�嬩腑锛岄�夋嫨瀵瑰簲绫诲瀷鐨勬寜閽嫋鑷虫澶勬坊鍔狅紝濡傞�夋嫨鎸夐挳绫诲瀷涓鸿〃鍗曘�佹柊鏍囩椤电瓑鍚湁閰嶇疆椤甸潰鐨勬寜閽紝鍙湪宸︿晶宸ュ叿鏍�-鎸夐挳-鍙厤缃寜閽锛岀偣鍑绘寜閽畬鎴愮浉鍏抽厤缃�傛敞锛氬綋璁剧疆鎸夐挳鏄剧ず浣嶇疆涓鸿〃鏍兼椂锛屾樉绀哄垪浼氬鍔犳搷浣滃垪銆�"> - <Icon type="question-circle" /> - </Tooltip> - <DragElement - type="action" - list={this.state.config.action} - 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 + config={config} + mainsearch={!this.props.editSubTab && this.props.editTab.mainsearch ? this.props.editTab.mainsearch : ''} + MenuID={config.uuid} + updatesetting={this.updateconfig} + /> + <SearchComponent + config={config} + updatesearch={this.updatesearch} + /> + <div className="chart-view" style={{position: 'relative'}}> + {/* 瑙嗗浘缁� 鏉冮檺 浼氬憳绛夌骇20+ */} + {this.props.memberLevel >= 20 ? <ChartGroupComponent + config={config} + 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 ? <p className="chart-title">{item.title}</p> : null} + <ActionComponent + type="subtable" + menu={{MenuID: config.uuid, MenuName: config.tabName, MenuNo: config.tabNo, fstMenuList: this.props.menu.fstMenuList}} + config={config} + tabs={this.state.tabviews} + setSubConfig={this.setSubConfig} + updateaction={this.updateaction} + /> + <ColumnComponent + config={config} + menu={this.props.menu} + 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> </Card> </div> </DndProvider> - {/* 缂栬緫鎼滅储鏉′欢 */} - <Modal - title={this.state.dict['header.modal.search.edit']} - visible={modaltype === 'search'} - width={700} - onOk={this.handleSubmit} - onCancel={this.editModalCancel} - destroyOnClose - > - <SearchForm - dict={this.state.dict} - card={this.state.card} - 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={700} - onCancel={this.editModalCancel} - footer={[ - modaltype === 'actionEdit' ? <Button key="delete" className="mk-btn mk-purple" onClick={this.creatFunc} loading={this.state.funcLoading}>{this.state.dict['header.menu.func.create']}</Button> : 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} - wrappedComponentRef={(inst) => this.actionFormRef = inst} - /> - </Modal> - {/* 鏄剧ず鍒楃紪杈� */} - <Modal - title={this.state.dict['header.modal.column.edit']} - visible={modaltype === 'columns'} - width={700} - onOk={this.handleSubmit} - onCancel={this.editModalCancel} - destroyOnClose - > - <ColumnForm - dict={this.state.dict} - card={this.state.card} - formlist={this.state.formlist} - wrappedComponentRef={(inst) => this.columnFormRef = inst} - /> - </Modal> - {/* 鍚堝苟鍒楃紪杈� */} - <Modal - title={this.state.dict['header.modal.colspan.edit']} - visible={modaltype === 'colspan'} - width={700} - onOk={this.handleSubmit} - onCancel={this.editModalCancel} - destroyOnClose - > - <ColspanForm - dict={this.state.dict} - card={this.state.card} - 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} - onOk={this.handleSubmit} - onCancel={this.editModalCancel} - destroyOnClose - > - <GridBtnForm - dict={this.state.dict} - card={this.state.config.gridBtn} - wrappedComponentRef={(inst) => this.gridBtnFormRef = inst} - /> - </Modal> - {/* 鏍规嵁瀛楁鍚嶆坊鍔犳樉绀哄垪鍙婃悳绱㈡潯浠� */} - <Modal - wrapClassName="common-table-fields-modal" - title={this.state.dict['header.edit']} - visible={this.state.tableVisible} - width={'65vw'} - 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={'楠岃瘉淇℃伅'} - visible={this.state.profileVisible} - width={'75vw'} - style={{minWidth: '900px', maxWidth: '1200px'}} - onOk={this.verifySubmit} - onCancel={() => { this.setState({ profileVisible: false }) }} - destroyOnClose - > - <VerifyCard floor="subtable" card={this.state.card} columns={this.state.config.columns} wrappedComponentRef={(inst) => this.verifyRef = inst} dict={this.state.dict} /> - </Modal> - {/* 璁剧疆鍏ㄥ眬閰嶇疆鍙婂垪琛ㄦ暟鎹簮 */} - <Modal - title={this.state.dict['header.edit']} - visible={this.state.settingVisible} - width={700} - // onOk={this.settingSave} - onCancel={() => { // 鍙栨秷淇敼 - this.setState({ - settingVisible: false - }) - }} - footer={[ - <Button key="delete" className="mk-btn mk-purple" onClick={this.tableCreatFunc} loading={this.state.funcLoading}>{this.state.dict['header.menu.func.create']}</Button>, - <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} - tabId={this.state.config.uuid} - 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} + maskClosable={false} 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 > @@ -2149,7 +1101,7 @@ const mapStateToProps = (state) => { return { - permFuncField: state.permFuncField + memberLevel: state.memberLevel } } -- Gitblit v1.8.0