From bef4f9e4fc767e8dd80b106a47545f78e75e7e41 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 17 一月 2020 11:52:30 +0800 Subject: [PATCH] 2020-01-17 --- src/templates/formtabconfig/index.jsx | 153 +++++++++++++++++++++++++++++--------------------- 1 files changed, 88 insertions(+), 65 deletions(-) diff --git a/src/templates/formtabconfig/index.jsx b/src/templates/formtabconfig/index.jsx index 5771fba..081cc1f 100644 --- a/src/templates/formtabconfig/index.jsx +++ b/src/templates/formtabconfig/index.jsx @@ -1076,6 +1076,7 @@ return true } }) + _delActions.push(element.card.uuid) } else if (element.type === 'search') { _config.groups = _config.groups.map(group => { group.sublist = group.sublist.filter(item => item.uuid !== element.card.uuid) @@ -1139,6 +1140,7 @@ */ submitConfig = () => { const { menu, editAction } = this.props + const { delActions } = this.state let config = JSON.parse(JSON.stringify(this.state.config)) @@ -1228,25 +1230,73 @@ }) } - Api.getSystemConfig(param).then(response => { - if (response.status) { - this.setState({ - config: _config, - originMenu: _config + // 鏈夋寜閽垨鏍囩鍒犻櫎鏃讹紝鍏堣繘琛屽垹闄ゆ搷浣� + // 鍒犻櫎鎴愬姛鍚庯紝淇濆瓨椤甸潰閰嶇疆 + 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) + }) + }) }) - - this.submitAction(btnParam, tabParam) - } else { - this.setState({ - menuloading: false, - menucloseloading: false + 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) + } }) - notification.warning({ - top: 92, - message: response.message, - duration: 10 - }) + } 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 + }) + } + }) }) }, () => { notification.warning({ @@ -1262,19 +1312,29 @@ */ submitAction = (btnParam, tabParam) => { new Promise(resolve => { - // 鍐呴儴璇锋眰 - if (this.state.delActions.length > 0) { - let deffers = this.state.delActions.map(item => { - let _param = { - func: 'sPC_MainMenu_Del', - MenuID: item - } - return new Promise(resolve => { - Api.getSystemConfig(_param).then(res => { - resolve(res) - }) + 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 => { + resolve(result) + }) + }) + deffers.push(defer) + } + + if (deffers.length === 0) { + resolve(true) + } else { Promise.all(deffers).then(result => { let error = false result.forEach(res => { @@ -1291,49 +1351,12 @@ }) resolve(false) } else { - this.setState({ - delActions: [] - }) resolve(true) } }) - } else if (this.state.delActions.length === 0) { - resolve(true) - } - }).then(res => { - if (res === false) return res - - if (tabParam.LText) { - Api.getSystemConfig(tabParam).then(result => { - if (!result.status) { - notification.warning({ - top: 92, - message: result.message, - duration: 10 - }) - } - }) - } - if (btnParam.LText) { - return Api.getSystemConfig(btnParam) - } else { - return 'true' } }).then(response => { - if (response === false || response === 'true') return response - - if (response.status) { - return 'true' - } else { - notification.warning({ - top: 92, - message: response.message, - duration: 10 - }) - return false - } - }).then(response => { - if (response === 'true') { + if (response) { notification.success({ top: 92, message: '淇濆瓨鎴愬姛', -- Gitblit v1.8.0