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/comtableconfig/index.jsx | 180 ++++++++++++++++++++++++++++++++++-------------------------- 1 files changed, 102 insertions(+), 78 deletions(-) diff --git a/src/templates/comtableconfig/index.jsx b/src/templates/comtableconfig/index.jsx index 9977ac4..d382550 100644 --- a/src/templates/comtableconfig/index.jsx +++ b/src/templates/comtableconfig/index.jsx @@ -1221,7 +1221,7 @@ // 鍒犻櫎鎸夐挳鍏冪礌 let _delActions = _this.state.delActions - if (element.type === 'action') { + if (element.type === 'action' || element.type === 'tabs') { _delActions.push(element.card.uuid) } @@ -1279,7 +1279,7 @@ */ submitConfig = () => { const { menu } = this.props - const { originMenu } = this.state + const { originMenu, delActions } = this.state let config = JSON.parse(JSON.stringify(this.state.config)) @@ -1379,34 +1379,82 @@ }) } - Api.getSystemConfig(param).then(response => { - if (response.status) { - this.setState({ - config: _config, - originMenu: { - ...originMenu, - LongParam: _config, - PageParam: _pageParam, - MenuName: res.menuName, - MenuNo: res.menuNo, - ParentID: res.parentId + // 鏈夋寜閽垨鏍囩鍒犻櫎鏃讹紝鍏堣繘琛屽垹闄ゆ搷浣� + // 鍒犻櫎鎴愬姛鍚庯紝淇濆瓨椤甸潰閰嶇疆 + 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) } }) - - this.props.reloadmenu() - - this.submitAction(btnParam, tabParam) - } else { - this.setState({ - menuloading: false, - menucloseloading: false - }) - 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: { + ...originMenu, + LongParam: _config, + PageParam: _pageParam, + MenuName: res.menuName, + MenuNo: res.menuNo, + ParentID: res.parentId + } + }) + + this.props.reloadmenu() + + this.submitAction(btnParam, tabParam) + } else { + this.setState({ + menuloading: false, + menucloseloading: false + }) + notification.warning({ + top: 92, + message: response.message, + duration: 10 + }) + } + }) }) }, () => { notification.warning({ @@ -1422,20 +1470,36 @@ */ submitAction = (btnParam, tabParam) => { const { config } = this.state + 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 => { + 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 => { @@ -1452,49 +1516,9 @@ }) 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 'copy' - } - }).then(response => { - if (response === false || response === 'copy') return response - - if (response.status) { - this.setState({ - copyActions: [] - }) - return 'copy' - } else { - notification.warning({ - top: 92, - message: response.message, - duration: 10 - }) - return false } }).then(response => { if (response === false) return response -- Gitblit v1.8.0