From 063b983daaf51a7f1e8677bde1e9c0e618866c91 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 21 二月 2020 10:30:19 +0800 Subject: [PATCH] 2020-02-21 --- src/templates/formtabconfig/index.jsx | 316 +++++++++++++++++++++++++++++++++++----------------- 1 files changed, 212 insertions(+), 104 deletions(-) diff --git a/src/templates/formtabconfig/index.jsx b/src/templates/formtabconfig/index.jsx index 1c350e4..ec9ca6c 100644 --- a/src/templates/formtabconfig/index.jsx +++ b/src/templates/formtabconfig/index.jsx @@ -81,9 +81,11 @@ if (!config) { _config = JSON.parse(JSON.stringify(Source.baseConfig)) _config.isAdd = true + if (menu && menu.LongParam && menu.LongParam.setting.dataresource) { + _config.setting.dataresource = menu.LongParam.setting.dataresource + } } else { _config = config - // _config.action = Source.baseConfig.action } if (menu && menu.LongParam && menu.LongParam.columns) { @@ -374,7 +376,10 @@ handleTab = (card) => { const { config } = this.state - let menus = [{value: 'mainTable', text: '涓绘暟鎹�'}] + let menus = [ + {value: '', text: '绌�'}, + {value: 'mainTable', text: '涓绘暟鎹�'} + ] let equalTabs = [] let supMenu = card.supMenu || '' let equalTab = card.equalTab || [] @@ -1189,8 +1194,8 @@ // 鏍囩涓嶅悎娉曟椂锛屽惎鐢ㄧ姸鎬佷负false if (_config.tabgroups.length > 1) { - _config.tabgroups.forEach(group => { - if (_config[group].length === 0) { + _config.tabgroups.forEach(groupId => { + if (_config[groupId].length === 0) { _config.enabled = false } }) @@ -1205,60 +1210,52 @@ }) } - delete _config.isAdd + _config.funcs = [] // 椤甸潰鍙婂瓙椤甸潰瀛樺偍杩囩▼闆� - try { - _LongParam = window.btoa(window.encodeURIComponent(JSON.stringify(_config))) - } catch (e) { - notification.warning({ - top: 92, - message: '缂栬瘧閿欒', - duration: 10 - }) - return - } - - let btnParam = { // 娣诲姞鑿滃崟鎸夐挳 - func: 'sPC_Button_AddUpt', - Type: 60, // 娣诲姞鎸夐挳琛ㄥ崟椤典笅鐨勬寜閽� - ParentID: menu.MenuID, - MenuNo: menu.MenuNo, - Template: menu.PageParam.Template || '', - 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.setting.datatype === 'query') { + _config.funcs.push({ + type: 'view', + subtype: 'view', + uuid: btnTab.uuid, + intertype: _config.setting.interType || 'inner', + interface: _config.setting.interface || '', + tableName: _config.setting.tableName || '', + innerFunc: _config.setting.innerFunc || '', + outerFunc: _config.setting.outerFunc || '' }) } - 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 tabParam = { // 娣诲姞鑿滃崟tab椤� - func: 'sPC_sMenusTab_AddUpt', - MenuID: btnTab.uuid, - LText: config.tabs.map((item, index) => { - 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 ') - tabParam.LText = Utils.formatOptions(tabParam.LText) - tabParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' - tabParam.secretkey = Utils.encrypt(tabParam.LText, tabParam.timestamp) + _config.action.forEach(item => { + if (item.btnType !== 'cancel') { + _config.funcs.push({ + type: 'button', + subtype: 'btn', + uuid: item.uuid, + label: item.label, + tablename: item.sql || '', + intertype: item.intertype, + interface: item.interface || '', + innerFunc: item.innerFunc || '', + outerFunc: item.outerFunc || '', + callbackFunc: item.callbackFunc || '' + }) + } + }) - let param = { - func: 'sPC_ButtonParam_AddUpt', - ParentID: menu.MenuID, - MenuID: btnTab.uuid, - MenuNo: menu.MenuNo, - Template: 'FormTab', - MenuName: btnTab.label, - PageParam: JSON.stringify({Template: 'FormTab'}), - LongParam: _LongParam - } - + _config.tabgroups.forEach(groupId => { + if (_config[groupId].length === 0) return + + _config[groupId].forEach(tab => { + _config.funcs.push({ + type: 'tab', + subtype: 'tab', + uuid: tab.uuid, + label: tab.label, + linkTab: tab.linkTab + }) + }) + }) + if (this.state.closeVisible) { // 鏄剧ず鍏抽棴瀵硅瘽妗嗘椂锛屾ā鎬佹涓繚瀛樻寜閽紝鏄剧ず淇濆瓨涓姸鎬� this.setState({ menucloseloading: true @@ -1269,72 +1266,176 @@ }) } - // 鏈夋寜閽垨鏍囩鍒犻櫎鏃讹紝鍏堣繘琛屽垹闄ゆ搷浣� - // 鍒犻櫎鎴愬姛鍚庯紝淇濆瓨椤甸潰閰嶇疆 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) + let deffers = [] + _config.funcs.forEach(item => { + if (item.type === 'tab') { + let deffer = new Promise(resolve => { + Api.getSystemConfig({ + func: 'sPC_Get_LongParam', + MenuID: item.linkTab + }).then(result => { + if (result.status && result.LongParam) { + let _LongParam = '' + + if (result.LongParam) { + try { + _LongParam = window.decodeURIComponent(window.atob(result.LongParam)) + _LongParam = JSON.parse(_LongParam) + } catch (e) { + _LongParam = '' + } + } + + if (_LongParam) { + item.menuNo = _LongParam.tabNo + item.subfuncs = _LongParam.funcs || [] + } + } + resolve() }) }) + + deffers.push(deffer) + } + }) + + if (deffers.length === 0) { + resolve() + } else { + Promise.all(deffers).then(() => { + resolve() }) - Promise.all(deffers).then(result => { - let error = null - result.forEach(response => { - if (!response.status) { - error = response + } + }).then(() => { + + // 鍒犻櫎娣诲姞鏍囪瘑 + delete _config.isAdd + + try { + _LongParam = window.btoa(window.encodeURIComponent(JSON.stringify(_config))) + } catch (e) { + notification.warning({ + top: 92, + message: '缂栬瘧閿欒', + duration: 10 + }) + + this.setState({ + menucloseloading: false, + menuloading: false + }) + return + } + + let btnParam = { // 娣诲姞鑿滃崟鎸夐挳 + func: 'sPC_Button_AddUpt', + Type: 60, // 娣诲姞鎸夐挳琛ㄥ崟椤典笅鐨勬寜閽� + ParentID: menu.MenuID, + MenuNo: menu.MenuNo, + Template: menu.PageParam.Template || '', + PageParam: '', + LongParam: '', + LText: config.action.map((item, index) => { + return `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') + '.000' + btnParam.secretkey = Utils.encrypt(btnParam.LText, btnParam.timestamp) + + let tabParam = { // 娣诲姞鑿滃崟tab椤� + func: 'sPC_sMenusTab_AddUpt', + MenuID: btnTab.uuid, + LText: config.tabs.map((item, index) => { + 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 ') + tabParam.LText = Utils.formatOptions(tabParam.LText) + tabParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' + tabParam.secretkey = Utils.encrypt(tabParam.LText, tabParam.timestamp) + + let param = { + func: 'sPC_ButtonParam_AddUpt', + ParentID: menu.MenuID, + MenuID: btnTab.uuid, + MenuNo: menu.MenuNo, + Template: 'FormTab', + MenuName: btnTab.label, + PageParam: JSON.stringify({Template: 'FormTab'}), + LongParam: _LongParam + } + + // 鏈夋寜閽垨鏍囩鍒犻櫎鏃讹紝鍏堣繘琛屽垹闄ゆ搷浣� + // 鍒犻櫎鎴愬姛鍚庯紝淇濆瓨椤甸潰閰嶇疆 + 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 + } + }) + + 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 (error) { + } 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, + originMenu: _config + }) + + this.submitAction(btnParam, tabParam) + } else { this.setState({ menuloading: false, menucloseloading: false }) notification.warning({ top: 92, - message: error.message, + message: response.message, duration: 10 }) - resolve(false) - } else { - this.setState({ - delActions: [] - }) - resolve(true) } }) - } 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, - originMenu: _config - }) - - this.submitAction(btnParam, tabParam) - } else { - this.setState({ - menuloading: false, - menucloseloading: false - }) - notification.warning({ - top: 92, - message: response.message, - duration: 10 - }) - } }) }) }, () => { @@ -2095,6 +2196,7 @@ title={this.state.dict['header.modal.form.edit']} visible={modaltype === 'search'} width={700} + maskClosable={false} onOk={this.handleSubmit} onCancel={this.editModalCancel} destroyOnClose @@ -2111,6 +2213,7 @@ title={this.state.dict['header.modal.action.edit']} visible={modaltype === 'actionEdit'} width={700} + maskClosable={false} onCancel={this.editModalCancel} footer={[ this.state.card && this.state.card.btnType !== 'cancel' ? @@ -2133,6 +2236,7 @@ title={this.state.dict['header.modal.tabs.edit']} visible={modaltype === 'tabs'} width={700} + maskClosable={false} onOk={this.handleSubmit} onCancel={this.editModalCancel} destroyOnClose @@ -2152,6 +2256,7 @@ 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} @@ -2175,6 +2280,7 @@ title={'楠岃瘉淇℃伅'} visible={this.state.profileVisible} width={'75vw'} + maskClosable={false} style={{minWidth: '900px', maxWidth: '1200px'}} onOk={this.verifySubmit} onCancel={() => { this.setState({ profileVisible: false }) }} @@ -2194,7 +2300,7 @@ title={this.state.dict['header.edit']} visible={this.state.settingVisible} width={700} - // onOk={this.settingSave} + maskClosable={false} onCancel={() => { // 鍙栨秷淇敼 this.setState({ settingVisible: false @@ -2218,6 +2324,7 @@ <Modal bodyStyle={{textAlign: 'center', color: '#000000', fontSize: '16px'}} closable={false} + maskClosable={false} visible={this.state.closeVisible} onCancel={() => { this.setState({closeVisible: false}) }} footer={[ @@ -2233,6 +2340,7 @@ title={this.state.dict['header.menu.group.manage']} visible={this.state.groupVisible} width={700} + maskClosable={false} onOk={this.handleGroupSave} onCancel={() => { this.setState({ groupVisible: false }) }} destroyOnClose -- Gitblit v1.8.0