From f22bb55c4ff50a8a63c795487b057c0cebdae649 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期四, 12 十二月 2019 09:19:58 +0800
Subject: [PATCH] 2019-12-12

---
 src/templates/comtableconfig/index.jsx |  205 ++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 161 insertions(+), 44 deletions(-)

diff --git a/src/templates/comtableconfig/index.jsx b/src/templates/comtableconfig/index.jsx
index 2ca9f9a..2385c9b 100644
--- a/src/templates/comtableconfig/index.jsx
+++ b/src/templates/comtableconfig/index.jsx
@@ -929,26 +929,15 @@
           }
         }
   
-        if (this.state.operaType === 'add') {
-          _config[res.type] = _config[res.type].map(item => {
-            if (item.uuid === res.values.uuid) {
-              isupdate = true
-              return res.values
-            } else {
-              return item
-            }
-          })
-          _config[res.type] = _config[res.type].filter(item => !item.origin)
-        } else {
-          _config[res.type] = _config[res.type].map(item => {
-            if (item.uuid === res.values.uuid) {
-              isupdate = true
-              return res.values
-            } else {
-              return item
-            }
-          })
-        }
+        _config[res.type] = _config[res.type].map(item => {
+          if (item.uuid === res.values.uuid) {
+            isupdate = true
+            return res.values
+          } else {
+            return item
+          }
+        })
+        _config[res.type] = _config[res.type].filter(item => !item.origin)
   
         if (!isupdate) { // 鎿嶄綔涓嶆槸淇敼锛屾坊鍔犲厓绱犺嚦鍒楄〃
           _config[res.type].push(res.values)
@@ -1005,6 +994,126 @@
     }
   }
 
+  creatFunc = () => {
+    // let _config = JSON.parse(JSON.stringify(this.state.config))
+
+    this.formRef.handleConfirm().then(res => {
+      let btn = res.values
+      let LText = ''
+      if (!btn.innerFunc) {
+        notification.warning({
+          top: 92,
+          message: '璇峰~鍐欏唴閮ㄥ嚱鏁帮紒',
+          duration: 10
+        })
+        return
+      }
+
+      new Promise(resolve => {
+        // 鍐呴儴璇锋眰
+        if (btn.OpenType === 'pop') {
+          Api.getSystemConfig({
+            func: 'sPC_Get_LongParam',
+            MenuID: btn.uuid
+          }).then(res => {
+            let _LongParam = ''
+            if (res.status && res.LongParam) {
+              _LongParam = window.decodeURIComponent(window.atob(res.LongParam))
+              try {
+                _LongParam = JSON.parse(_LongParam)
+              } catch (e) {
+                _LongParam = ''
+              }
+            }
+
+            if (_LongParam) {
+              resolve(_LongParam)
+            } else {
+              resolve(false)
+              notification.warning({
+                top: 92,
+                message: '寮圭獥锛堣〃鍗曪級鎸夐挳锛岃鍏堥厤缃〃鍗曚俊鎭紒',
+                duration: 10
+              })
+            }
+          })
+        } else {
+          resolve(true)
+        }
+      }).then(res => {
+        if (!res) return
+        LText = Utils.formatOptions(Utils.getfunc())
+        console.log(LText)
+        return Api.getSystemConfig({
+          func: 'sPC_Get_TVP',
+          TVPName: btn.innerFunc
+        })
+      }).then(res => {
+        console.log(res)
+        if (res.status) {
+          return true
+        } else {
+          notification.warning({
+            top: 92,
+            message: res.message,
+            duration: 10
+          })
+          return false
+        }
+      }).then(res => {
+        console.log(res)
+      })
+
+      // let isupdate = false
+      // _config.action = _config.action.map(item => {
+      //   if (item.uuid === res.values.uuid) {
+      //     isupdate = true
+      //     return res.values
+      //   } else {
+      //     return item
+      //   }
+      // })
+      // _config.action = _config.action.filter(item => !item.origin)
+
+
+      // if (!isupdate) { // 鎿嶄綔涓嶆槸淇敼锛屾坊鍔犲厓绱犺嚦鍒楄〃
+      //   _config.action.push(res.values)
+      // }
+
+      // let gridbtn = _config.action.filter(act => act.position === 'grid')
+      // let _display = false
+
+      // if (gridbtn.length > 0) {
+      //   _display = true
+      // }
+
+      // if (_config.gridBtn) {
+      //   _config.gridBtn.display = _display
+      // } else {
+      //   _config.gridBtn = {
+      //     display: _display,
+      //     Align: 'center',
+      //     IsSort: 'false',
+      //     uuid: Utils.getuuid(),
+      //     label: this.state.dict['header.form.column.action'],
+      //     type: 'action',
+      //     style: 'button',
+      //     show: 'horizontal',
+      //     Width: 120
+      //   }
+      // }
+
+      // this.setState({
+      //   config: _config,
+      //   actionloading: true
+      // }, () => {
+      //   this.setState({
+      //     actionloading: false
+      //   })
+      // })
+    })
+  }
+
   deleteElement = (element) => {
     let _this = this
     confirm({
@@ -1045,30 +1154,32 @@
     const { config, originMenu } = this.state
     this.menuformRef.handleConfirm().then(res => {
       config.search = config.search.filter(item => !item.origin)
-      if (config.search[0] && config.search[0].origin) {
-        notification.warning({
-          top: 92,
-          message: '璇疯缃悳绱㈡潯浠�',
-          duration: 10
-        })
-        return
-      }
-      if (config.action[0] && config.action[0].origin) {
-        notification.warning({
-          top: 92,
-          message: '璇疯缃寜閽�',
-          duration: 10
-        })
-        return
-      }
-      if (config.columns[0] && config.columns[0].origin) {
-        notification.warning({
-          top: 92,
-          message: '璇疯缃樉绀哄垪',
-          duration: 10
-        })
-        return
-      }
+      config.action = config.action.filter(item => !item.origin)
+      config.columns = config.columns.filter(item => !item.origin)
+      // if (config.search[0] && config.search[0].origin) {
+      //   notification.warning({
+      //     top: 92,
+      //     message: '璇疯缃悳绱㈡潯浠�',
+      //     duration: 10
+      //   })
+      //   return
+      // }
+      // if (config.action[0] && config.action[0].origin) {
+      //   notification.warning({
+      //     top: 92,
+      //     message: '璇疯缃寜閽�',
+      //     duration: 10
+      //   })
+      //   return
+      // }
+      // if (config.columns[0] && config.columns[0].origin) {
+      //   notification.warning({
+      //     top: 92,
+      //     message: '璇疯缃樉绀哄垪',
+      //     duration: 10
+      //   })
+      //   return
+      // }
 
       let _LongParam = ''
       let _config = {...config, tables: this.state.selectedTables}
@@ -1833,6 +1944,12 @@
           width={700}
           onCancel={() => { this.setState({ visible: false }) }}
           onOk={this.handleSubmit}
+          footer={[
+            this.state.formtemp === 'action' ?
+            <Button key="delete" className="mk-btn mk-purple" onClick={this.creatFunc} loading={this.state.confirmLoading}>{this.state.dict['header.delete']}</Button> : null,
+            <Button key="cancel" onClick={() => { this.setState({ visible: false }) }}>{this.state.dict['header.cancel']}</Button>,
+            <Button key="confirm" type="primary" onClick={this.handleSubmit}>{this.state.dict['header.confirm']}</Button>
+          ]}
           destroyOnClose
         >
           {this.state.formtemp === 'search' ?

--
Gitblit v1.8.0