From e9640ccdc9fe57f91919e3f51462c780e44fadb0 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期三, 23 十二月 2020 13:14:20 +0800 Subject: [PATCH] 2020-12-23 --- src/templates/subtableconfig/index.jsx | 427 +++++++++++++++++++++-------------------------------- 1 files changed, 169 insertions(+), 258 deletions(-) diff --git a/src/templates/subtableconfig/index.jsx b/src/templates/subtableconfig/index.jsx index 131aabb..3acb99e 100644 --- a/src/templates/subtableconfig/index.jsx +++ b/src/templates/subtableconfig/index.jsx @@ -275,50 +275,6 @@ _config.enabled = false } - // _config.funcs = [] - - // _config.funcs.push({ - // type: 'view', - // subtype: 'view', - // uuid: _config.uuid, - // intertype: _config.setting.interType || 'system', - // interface: _config.setting.interface || '', - // tableName: _config.setting.tableName || '', - // innerFunc: _config.setting.innerFunc || '', - // outerFunc: _config.setting.outerFunc || '' - // }) - - // _config.action.forEach(item => { - // let tablename = item.OpenType === 'excelIn' ? (item.sheet || '') : (item.sql || '') - - // if (item.OpenType === 'excelOut' && item.intertype === 'system') { - // tablename = _config.setting.tableName || '' - // } - - // if (item.OpenType === 'popview') { - // _config.funcs.push({ - // type: 'tab', - // subtype: 'btn', - // uuid: item.uuid, - // label: item.label, - // linkTab: item.linkTab - // }) - // } else { - // _config.funcs.push({ - // type: 'button', - // subtype: 'btn', - // uuid: item.uuid, - // label: item.label, - // tableName: tablename, - // intertype: item.intertype, - // interface: item.interface || '', - // innerFunc: item.innerFunc || '', - // outerFunc: item.outerFunc || '', - // callbackFunc: item.callbackFunc || '' - // }) - // } - // }) - if (this.state.closeVisible) { // 鏄剧ず鍏抽棴瀵硅瘽妗嗘椂锛屾ā鎬佹涓繚瀛樻寜閽紝鏄剧ず淇濆瓨涓姸鎬� this.setState({ menucloseloading: true @@ -329,251 +285,206 @@ }) } - new Promise(resolve => { - // 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 = JSON.parse(window.decodeURIComponent(window.atob(result.LongParam))) - // } catch (e) { - // console.warn('Parse Failure') - // _LongParam = '' - // } - // } - - // if (_LongParam) { - // item.menuNo = _LongParam.tabNo - // item.subfuncs = _LongParam.funcs || [] - // } - // } - // resolve() - // }) - // }) + // 淇濆瓨鏃跺垹闄ら厤缃被鍨嬶紝system 銆乽ser + delete _config.type + delete _config.isAdd - // deffers.push(deffer) - // } - // }) + let _LongParam = '' - // if (deffers.length === 0) { - // resolve() - // } else { - // Promise.all(deffers).then(() => { - // resolve() - // }) - // } - resolve() - }).then(() => { - // 淇濆瓨鏃跺垹闄ら厤缃被鍨嬶紝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`) + try { + _LongParam = window.btoa(window.encodeURIComponent(JSON.stringify(_config))) + } catch (e) { + notification.warning({ + top: 92, + message: '缂栬瘧閿欒', + duration: 5 }) - 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) + this.setState({ + menucloseloading: false, + menuloading: false + }) + return + } - let tabParam = { // 娣诲姞鏍囩鎸夐挳tab椤� - func: 'sPC_sMenusTab_AddUpt', - MenuID: _config.uuid, - LText: btntabs.join(' union all ') + 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`) + }) - tabParam.LText = Utils.formatOptions(tabParam.LText) - tabParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') - tabParam.secretkey = Utils.encrypt(tabParam.LText, tabParam.timestamp) + 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 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 - } + let tabParam = { // 娣诲姞鏍囩鎸夐挳tab椤� + func: 'sPC_sMenusTab_AddUpt', + MenuID: _config.uuid, + LText: btntabs.join(' union all ') + } - if (openEdition) { - param.open_edition = openEdition - } + tabParam.LText = Utils.formatOptions(tabParam.LText) + tabParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + tabParam.secretkey = Utils.encrypt(tabParam.LText, tabParam.timestamp) - // 鏈夋寜閽垨鏍囩鍒犻櫎鏃讹紝鍏堣繘琛屽垹闄ゆ搷浣� - // 鍒犻櫎鎴愬姛鍚庯紝淇濆瓨椤甸潰閰嶇疆 - new Promise(resolve => { - if (delActions.length > 0) { - let deffers = delActions.map(item => { - let _param = { - func: 'sPC_MainMenu_Del', - MenuID: item.card.uuid - } + 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 + } - let _ParentParam = null + if (openEdition) { + param.open_edition = openEdition + } - try { - _ParentParam = window.btoa(window.encodeURIComponent(JSON.stringify(item.card))) - } catch (e) { - console.warn('Stringify Failure') - _ParentParam = null - } + // 鏈夋寜閽垨鏍囩鍒犻櫎鏃讹紝鍏堣繘琛屽垹闄ゆ搷浣� + // 鍒犻櫎鎴愬姛鍚庯紝淇濆瓨椤甸潰閰嶇疆 + new Promise(resolve => { + if (delActions.length > 0) { + let deffers = delActions.map(item => { + let _param = { + func: 'sPC_MainMenu_Del', + MenuID: item.card.uuid + } - if (_ParentParam) { // 鍒犻櫎鎸夐挳鏃讹紝淇濆瓨鎸夐挳閰嶇疆淇℃伅锛岀敤浜庢仮澶嶆寜閽� - _param.ParentParam = _ParentParam - } + let _ParentParam = null - return new Promise(resolve => { - Api.getSystemConfig(_param).then(response => { - resolve(response) - }) + 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 - } - }) - - if (error) { - this.setState({ - menuloading: false, - menucloseloading: false - }) - notification.warning({ - top: 92, - message: error.message, - duration: 5 - }) - resolve(false) - } else { - this.setState({ - delActions: [] - }) - resolve(true) + }) + 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 - 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 { + if (error) { this.setState({ menuloading: false, menucloseloading: false }) notification.warning({ top: 92, - message: response.message, + message: error.message, duration: 5 }) + resolve(false) + } else { + this.setState({ + delActions: [] + }) + resolve(true) } }) + } 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 + }) + } }) }) - } /** -- Gitblit v1.8.0