From 75623dd039b742dbb44fb4c6b4af563404ed9c7f Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期一, 03 二月 2020 16:06:04 +0800 Subject: [PATCH] 2020-02-03 --- src/templates/formtabconfig/index.jsx | 120 ++++++++++++++++++++++++++++++++--------------------------- 1 files changed, 65 insertions(+), 55 deletions(-) diff --git a/src/templates/formtabconfig/index.jsx b/src/templates/formtabconfig/index.jsx index a059ebf..c691a2d 100644 --- a/src/templates/formtabconfig/index.jsx +++ b/src/templates/formtabconfig/index.jsx @@ -35,10 +35,9 @@ class ComTableConfig extends Component { static propTpyes = { menu: PropTypes.any, - editAction: PropTypes.object, + btnTab: PropTypes.object, config: PropTypes.any, - handleConfig: PropTypes.func, - handleSubConfig: PropTypes.func + handleView: PropTypes.func } state = { @@ -73,21 +72,20 @@ * 2銆佽缃搷浣滅被鍨嬨�佸師濮嬭彍鍗曚俊鎭紙姣忔淇濆瓨鍚庨噸缃級銆佸凡浣跨敤琛ㄥ強鍩烘湰淇℃伅琛ㄥ崟 */ UNSAFE_componentWillMount () { - const { menu, editAction, config } = this.props + const { menu, btnTab, config } = this.props let _config = '' - let _originMenu = '' if (!config) { _config = JSON.parse(JSON.stringify(Source.baseConfig)) + _config.isAdd = true } else { _config = config - _originMenu = JSON.parse(JSON.stringify(_config)) } this.setState({ config: _config, - originMenu: _originMenu, + originMenu: JSON.parse(JSON.stringify(_config)), selectedTables: _config.tables, menuformlist: [ { @@ -101,7 +99,7 @@ type: 'text', key: 'actionName', label: '鎸夐挳鍚嶇О', - initVal: editAction.label, + initVal: btnTab.label, readonly: true } ] @@ -231,6 +229,26 @@ this.setState = () => { return } + } + + // 椤甸潰杩斿洖 + handleViewBack = () => { + const { menu } = this.props + let _tabview = menu ? menu.LongParam.Template : '' + let param = { + editMenu: menu, + editTab: null, + tabConfig: null, + editSubTab: null, + subTabConfig: null, + btnTab: null, + btnTabConfig: null, + editAction: null, + subConfig: null, + tabview: _tabview + } + + this.props.handleView(param) } handleList = (type, list, card, groupId, elementId) => { @@ -1139,21 +1157,23 @@ * @description 鑿滃崟淇濆瓨 */ submitConfig = () => { - const { menu, editAction } = this.props + const { menu, btnTab } = this.props const { delActions } = this.state let config = JSON.parse(JSON.stringify(this.state.config)) this.menuformRef.handleConfirm().then(res => { - if (config.groups[0] && config.groups[0].sublist[0] && config.groups[0].sublist[0].origin) { - config.groups[0].sublist = config.groups[0].sublist.filter(item => !item.origin) - } - if (config.action[0] && config.action[0].origin) { - config.action = config.action.filter(item => !item.origin) - } - if (config.tabs[0] && config.tabs[0].origin) { - config.tabs = config.tabs.filter(item => !item.origin) + if (config.isAdd) { + if (config.groups[0] && config.groups[0].sublist[0] && config.groups[0].sublist[0].origin) { + config.groups[0].sublist = config.groups[0].sublist.filter(item => !item.origin) + } + if (config.action[0] && config.action[0].origin) { + config.action = config.action.filter(item => !item.origin) + } + if (config.tabs[0] && config.tabs[0].origin) { + config.tabs = config.tabs.filter(item => !item.origin) + } } let _LongParam = '' @@ -1167,6 +1187,8 @@ } }) } + + delete _config.isAdd try { _LongParam = window.btoa(window.encodeURIComponent(JSON.stringify(_config))) @@ -1199,9 +1221,9 @@ let tabParam = { // 娣诲姞鑿滃崟tab椤� func: 'sPC_sMenusTab_AddUpt', - MenuID: editAction.uuid, + MenuID: btnTab.uuid, LText: config.tabs.map((item, index) => { - return `select '${editAction.uuid}' as MenuID ,'${item.linkTab}' as Tabid,'${item.label}' as TabName ,'${(index + 1) * 10}' as Sort` + return `select '${btnTab.uuid}' as MenuID ,'${item.linkTab}' as Tabid,'${item.label}' as TabName ,'${(index + 1) * 10}' as Sort` }) } tabParam.LText = tabParam.LText.join(' union all ') @@ -1212,10 +1234,10 @@ let param = { func: 'sPC_ButtonParam_AddUpt', ParentID: menu.MenuID, - MenuID: editAction.uuid, + MenuID: btnTab.uuid, MenuNo: menu.MenuNo, Template: 'FormTab', - MenuName: editAction.label, + MenuName: btnTab.label, PageParam: JSON.stringify({Template: 'FormTab'}), LongParam: _LongParam } @@ -1363,7 +1385,7 @@ duration: 2 }) if (this.state.closeVisible) { - this.props.handleConfig('') + this.handleViewBack() } else { this.setState({ menuloading: false, @@ -1384,13 +1406,13 @@ let _this = this - if (!originMenu) { + if (config.isAdd) { confirm({ content: '鎸夐挳閰嶇疆灏氭湭鎻愪氦锛岀‘瀹氭斁寮冧繚瀛樺悧锛�', okText: this.state.dict['header.confirm'], cancelText: this.state.dict['header.cancel'], onOk() { - _this.props.handleConfig('') + _this.handleViewBack() }, onCancel() {} }) @@ -1402,7 +1424,7 @@ closeVisible: true }) } else { - this.props.handleConfig('') + this.handleViewBack() } } } @@ -1617,19 +1639,10 @@ * @description 璁剧疆鍙厤缃爣绛� */ setSubConfig = (btn, type) => { + const {menu, btnTab} = this.props const { config, originMenu } = this.state - let isAdd = false - - if ( - (config.search[0] && config.search[0].origin) || - (config.action[0] && config.action[0].origin) || - (config.tabs[0] && config.tabs[0].origin) - ) { - isAdd = true - } - - if (isAdd) { + if (config.isAdd) { notification.warning({ top: 92, message: '鑿滃崟灏氭湭淇濆瓨锛岃淇濆瓨鑿滃崟閰嶇疆锛�', @@ -1650,21 +1663,22 @@ loading: true }) - let uuid = '' - let _type = type - if (type === 'button' && btn.OpenType === 'popview') { - _type = 'tab' - } - - if (_type === 'button') { - uuid = btn.uuid - } else { - uuid = btn.linkTab + let param = { + editMenu: menu, + editTab: btn, + tabConfig: null, + editSubTab: null, + subTabConfig: null, + btnTab: btnTab, + btnTabConfig: _config, + editAction: null, + subConfig: '', + tabview: btn.type } Api.getSystemConfig({ func: 'sPC_Get_LongParam', - MenuID: uuid + MenuID: btn.linkTab }).then(res => { if (res.status) { this.setState({ @@ -1680,15 +1694,11 @@ } } - if (_type === 'tab' && !_LongParam) { - _LongParam = { - ...btn, - uuid: btn.linkTab, - create: true - } + if (_LongParam && param.tabview === 'SubTable' && _LongParam.Template === 'SubTable') { + param.subConfig = _LongParam } - this.props.handleSubConfig(btn, originMenu, _LongParam, _type) + this.props.handleView(param) } else { this.setState({ loading: false @@ -2168,7 +2178,7 @@ 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.props.handleConfig('')}}>{this.state.dict['header.notsave']}</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> ]} destroyOnClose -- Gitblit v1.8.0