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/tableshare/columnform/index.jsx |    5 
 src/templates/formtabconfig/index.jsx         |  153 +++++++++-------
 src/templates/comtableconfig/index.jsx        |  180 +++++++++++--------
 src/templates/subtableconfig/index.jsx        |  145 ++++++++-------
 4 files changed, 267 insertions(+), 216 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
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: '淇濆瓨鎴愬姛',
diff --git a/src/templates/subtableconfig/index.jsx b/src/templates/subtableconfig/index.jsx
index c3fe1aa..d0cfec9 100644
--- a/src/templates/subtableconfig/index.jsx
+++ b/src/templates/subtableconfig/index.jsx
@@ -1089,6 +1089,7 @@
    * @description 鏍囩椤典繚瀛�
    */
   submitConfig = () => {
+    const { delActions } = this.state
     let config = JSON.parse(JSON.stringify(this.state.config))
 
     this.menuformRef.handleConfirm().then(res => {
@@ -1159,29 +1160,78 @@
         })
       }
 
-      Api.getSystemConfig(param).then(response => {
-        if (response.status) {
-          this.setState({
-            config: _config,
-            originConfig: _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)
+              })
+            })
+          })
+          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)
+            }
+          })
+        } 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,
+              originConfig: _config
+            }, () => {
+              this.setState({
+                menuloading: false,
+                menucloseloading: false
+              })
+              this.submitAction(btnParam)
+            })
+          } else {
             this.setState({
               menuloading: false,
               menucloseloading: false
             })
-            this.submitAction(btnParam)
-          })
-        } else {
-          this.setState({
-            menuloading: false,
-            menucloseloading: false
-          })
-          notification.warning({
-            top: 92,
-            message: response.message,
-            duration: 10
-          })
-        }
+            notification.warning({
+              top: 92,
+              message: response.message,
+              duration: 10
+            })
+          }
+        })
       })
     }, () => {
       notification.warning({
@@ -1198,64 +1248,21 @@
   submitAction = (param) => {
     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)
-            })
-          })
-        })
-        Promise.all(deffers).then(result => {
-          let error = false
-          result.forEach(res => {
-            if (!res.status) {
-              error = res
-            }
-          })
-
-          if (error) {
+      if (param.LText) {
+        Api.getSystemConfig(param).then(res => {
+          if (res.status) {
+            resolve(true)
+          } else {
             notification.warning({
               top: 92,
-              message: error.message,
+              message: res.message,
               duration: 10
             })
             resolve(false)
-          } else {
-            this.setState({
-              delActions: []
-            })
-            resolve(param)
           }
         })
-      } else if (this.state.delActions.length === 0) {
-        resolve(param)
-      }
-    }).then(res => {
-      if (res === false) return res
-
-      if (res.LText) {
-        return Api.getSystemConfig(res)
       } else {
-        return 'copy'
-      }
-    }).then(response => {
-      if (response === false || response === 'copy') return response
-
-      if (response.status) {
-        return 'copy'
-      } else {
-        notification.warning({
-          top: 92,
-          message: response.message,
-          duration: 10
-        })
-        return false
+        resolve(true)
       }
     }).then(response => {
       if (response === false) return response
diff --git a/src/templates/tableshare/columnform/index.jsx b/src/templates/tableshare/columnform/index.jsx
index a908637..7bfec98 100644
--- a/src/templates/tableshare/columnform/index.jsx
+++ b/src/templates/tableshare/columnform/index.jsx
@@ -216,10 +216,7 @@
         if (!err) {
           values.id = this.props.card.id
           values.uuid = this.props.card.uuid
-          resolve({
-            type: 'columns',
-            values
-          })
+          resolve(values)
         } else {
           reject(err)
         }

--
Gitblit v1.8.0