From c0930736f5b5955efecdac4c0ca85957d4f7b574 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期一, 16 十二月 2019 22:55:17 +0800
Subject: [PATCH] 2019-12-16

---
 src/tabviews/commontable/mainAction/index.jsx |  153 +++++++++++++++++++++++++++++++++++---------------
 1 files changed, 106 insertions(+), 47 deletions(-)

diff --git a/src/tabviews/commontable/mainAction/index.jsx b/src/tabviews/commontable/mainAction/index.jsx
index f7e16d1..0469e7c 100644
--- a/src/tabviews/commontable/mainAction/index.jsx
+++ b/src/tabviews/commontable/mainAction/index.jsx
@@ -1,8 +1,9 @@
 import React, {Component} from 'react'
 import PropTypes from 'prop-types'
-// import { is, fromJS } from 'immutable'
+import moment from 'moment'
 import { Button, Affix, Modal, notification } from 'antd'
 import MutilForm from '../mutilform'
+import Utils from '@/utils/utils.js'
 import Api from '@/api'
 import './index.scss'
 
@@ -100,38 +101,80 @@
     }
   }
 
-  execSubmit = (btn, data, _resolve) => {
+  execSubmit = (btn, data, _resolve, formdata) => {
     const { setting } = this.props
     if (btn.intertype === 'inner') {
-      // 浣跨敤鍐呴儴鎺ュ彛鏃讹紝鍐呴儴鍑芥暟鍜屾暟鎹簮涓嶅彲鍚屾椂涓虹┖
-      if (!btn.innerFunc && !btn.sql) {
+      // 浣跨敤鍐呴儴鎺ュ彛鏃讹紝鍐呴儴鍑芥暟鍜屾暟鎹簮涓嶅彲鍚屾椂涓虹┖, 浣跨敤绯荤粺鍑芥暟鏃讹紝绫诲瀷涓嶅彲涓虹┖
+      if (!btn.innerFunc && (!btn.sql || (btn.sql && !btn.sqlType))) {
         this.actionSettingError()
         _resolve()
         return
       }
 
-      if (btn.Ot === 'notRequired' || btn.Ot === 'requiredSgl' || btn.Ot === 'requiredOnce') {
-        // 鑾峰彇id
-        let param = {
+      if (
+        btn.Ot === 'notRequired' ||
+        btn.Ot === 'requiredSgl' ||
+        (btn.Ot === 'requiredOnce' && btn.OpenType !== 'pop') ||
+        (btn.OpenType === 'pop' && !btn.innerFunc && btn.sql && btn.sqlType === 'insert')
+      ) {
+        let param = { // 绯荤粺瀛樺偍杩囩▼
           func: 'sPC_TableData_InUpDe'
         }
-        let ID = ''
-        if (btn.Ot === 'notRequired') {
-          
-        } else if (btn.Ot === 'requiredSgl') {
-          ID = data[0][setting.primaryKey]
-        } else if (btn.Ot === 'requiredOnce') {
-          let ids = data.map(d => { return d[setting.primaryKey]})
-          ID = ids.join(',')
-        }
 
-        if (btn.innerFunc) {
-          param.func = btn.innerFunc
+        if (btn.OpenType === 'prompt' || btn.OpenType === 'exec') { // 鏄惁寮规鎴栫洿鎺ユ墽琛�
+          let ID = ''
+          if (btn.Ot === 'notRequired') {
+            
+          } else if (btn.Ot === 'requiredSgl') {
+            ID = data[0][setting.primaryKey]
+          } else if (btn.Ot === 'requiredOnce') {
+            let ids = data.map(d => { return d[setting.primaryKey]})
+            ID = ids.join(',')
+          }
+
           param.ID = ID
           param.BID = ''
-        } else if (btn.sql) {
-          param.LText = btn.sql // 鏁版嵁婧�
+
+          if (btn.innerFunc) {
+            param.func = btn.innerFunc
+          } else if (btn.sql) {
+            param.LText = Utils.formatOptions(Utils.getSysDefaultSql(btn, setting)) // 鏁版嵁婧�
+            param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000'
+            param.secretkey = Utils.encrypt(param.LText, param.timestamp)
+          }
+        } else if (btn.OpenType === 'pop') { // 琛ㄥ崟
+          if (btn.innerFunc) {
+            param.func = btn.innerFunc
+
+            formdata.forEach(_data => {
+              param[_data.key] = _data.value
+            })
+            if (setting.primaryKey) {
+              if (!param.hasOwnProperty(setting.primaryKey) && data[0] && data[0][setting.primaryKey]) {
+                param[setting.primaryKey] = data[0][setting.primaryKey]
+              }
+            }
+            if (!param.hasOwnProperty('ID') && setting.primaryKey && data[0] && data[0][setting.primaryKey]) {
+              param.ID = data[0][setting.primaryKey]
+            }
+            if (!param.hasOwnProperty('BID')) {
+              param.BID = ''
+            }
+          } else if (btn.sql && btn.sqlType === 'insert') {
+            param.ID = Utils.getguid()
+            param.BID = ''
+            param.LText = Utils.formatOptions(Utils.getSysDefaultSql(btn, setting, formdata)) // 鏁版嵁婧�
+            param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000'
+            param.secretkey = Utils.encrypt(param.LText, param.timestamp)
+          } else if (btn.sql) {
+            param.ID = data[0][setting.primaryKey]
+            param.BID = ''
+            param.LText = Utils.formatOptions(Utils.getSysDefaultSql(btn, setting, formdata)) // 鏁版嵁婧�
+            param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000'
+            param.secretkey = Utils.encrypt(param.LText, param.timestamp)
+          }
         }
+        
 
         Api.genericInterface(param).then((res) => {
           if (res.status) {
@@ -141,19 +184,43 @@
           }
           _resolve()
         })
-      } else if (btn.Ot === 'required') {
+      } else if (btn.Ot === 'required' || (btn.Ot === 'requiredOnce' && btn.OpenType === 'pop')) {
         let deffers = data.map(cell => {
           let param = {
             func: 'sPC_TableData_InUpDe'
           }
-          let ID = cell[setting.primaryKey]
 
-          if (btn.innerFunc) {
-            param.func = btn.innerFunc
-            param.ID = ID
+          if (btn.OpenType === 'prompt' || btn.OpenType === 'exec') { // 鏄惁寮规鎴栫洿鎺ユ墽琛�
+            param.ID = cell[setting.primaryKey]
             param.BID = ''
-          } else if (btn.sql) {
-            param.LText = btn.sql // 鏁版嵁婧�
+
+            if (btn.innerFunc) {
+              param.func = btn.innerFunc
+            } else if (btn.sql) {
+              param.LText = Utils.formatOptions(Utils.getSysDefaultSql(btn, setting)) // 鏁版嵁婧�
+              param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000'
+              param.secretkey = Utils.encrypt(param.LText, param.timestamp)
+            }
+          } else if (btn.OpenType === 'pop') { // 琛ㄥ崟
+            if (btn.innerFunc) {
+              param.func = btn.innerFunc
+  
+              formdata.forEach(_data => {
+                param[_data.key] = _data.value
+              })
+              if (!param.hasOwnProperty(setting.primaryKey) && cell[setting.primaryKey]) {
+                param[setting.primaryKey] = cell[setting.primaryKey]
+              }
+              if (!param.hasOwnProperty('ID') && cell[setting.primaryKey]) {
+                param.ID = cell[setting.primaryKey]
+              }
+            } else if (btn.sql) {
+              param.ID = cell[setting.primaryKey]
+              param.BID = ''
+              param.LText = Utils.formatOptions(Utils.getSysDefaultSql(btn, setting, formdata)) // 鏁版嵁婧�
+              param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000'
+              param.secretkey = Utils.encrypt(param.LText, param.timestamp)
+            }
           }
 
           return new Promise(resolve => {
@@ -439,6 +506,11 @@
       message: this.props.dict['main.action.confirm.success'],
       duration: 5
     })
+    if (btn.OpenType === 'pop') {
+      this.setState({
+        visible: false
+      })
+    }
     this.refreshdata(btn, 'success')
   }
 
@@ -464,26 +536,12 @@
       this.setState({
         confirmLoading: true
       })
+      this.execSubmit(this.state.execAction, this.state.tabledata, () => {
+        this.setState({
+          confirmLoading: false
+        })
+      }, res)
       console.log(res)
-      // Api.setActionSubmit({
-      //   func: 'SetActionSubmitSuccess'
-      // }).then((res) => {
-      //   if (res.status) {
-      //     notification.success({
-      //       top: 92,
-      //       message: this.props.dict['main.action.confirm.success']
-      //     })
-      //     this.setState({
-      //       confirmLoading: false,
-      //       visible: false
-      //     })
-      //   } else {
-      //     notification.error({
-      //       top: 92,
-      //       message: res.message
-      //     })
-      //   }
-      // })
     }, () => {})
   }
 
@@ -526,7 +584,8 @@
         <MutilForm
           dict={this.props.dict}
           action={execAction}
-          data={this.state.tabledata}
+          configMap={this.props.configMap}
+          data={this.state.tabledata[0]}
           wrappedComponentRef={(inst) => this.formRef = inst}
         />
       </Modal>

--
Gitblit v1.8.0