From f830c733cbc071f023c9a9a4e1571b7c81d672bf Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期四, 12 十一月 2020 11:47:33 +0800
Subject: [PATCH] 2020-11-12

---
 src/templates/zshare/createinterface/index.jsx |   41 ++++++++++++++++++++++++++++++++---------
 1 files changed, 32 insertions(+), 9 deletions(-)

diff --git a/src/templates/zshare/createinterface/index.jsx b/src/templates/zshare/createinterface/index.jsx
index 9efec6b..3bc051f 100644
--- a/src/templates/zshare/createinterface/index.jsx
+++ b/src/templates/zshare/createinterface/index.jsx
@@ -452,7 +452,7 @@
                   fieldlen: _fieldlen,
                   key: cell.field,
                   required: cell.required === 'true' ? 'required' : '',
-                  writein: cell.required !== 'false',
+                  writein: cell.writein !== 'false',
                   value: cell.initval || ''
                 }
 
@@ -720,10 +720,10 @@
         `
     }
 
-    if (_initcolumnfields.length > 0) {
-      _sql += `select ${_initcolumnfields.join(',')} from ${setting.dataresource} where ${primaryKey}=@ID@
-        `
-    }
+    // if (_initcolumnfields.length > 0) {
+    //   _sql += `select ${_initcolumnfields.join(',')} from (${setting.dataresource})tb where ${primaryKey}=@ID@
+    //     `
+    // }
     
     // 鍘婚櫎绂佺敤鐨勯獙璇�
     if (verify.contrasts) {
@@ -955,8 +955,10 @@
       receiptKeys.push('bid')
     }
 
+    let _insertsql = ''
+    let _updatesql = ''
     // 娣诲姞銆佷慨鏀广�侀�昏緫鍒犻櫎銆佺墿鐞嗗垹闄�
-    if (_actionType === 'insert') {
+    if (_actionType === 'insert' || _actionType === 'insertOrUpdate') {
       let keys = []
       let values = []
 
@@ -991,10 +993,12 @@
 
       keys = keys.join(',')
       values = values.join(',')
-      _sql += `
+      _insertsql = `
         /* 榛樿sql */
         insert into ${btn.sql} (${keys}) select ${values};`
-    } else if (_actionType === 'update') {
+    }
+
+    if (_actionType === 'update' || _actionType === 'audit' || _actionType === 'insertOrUpdate') {
       let _form = []
       let _arr = []
 
@@ -1034,9 +1038,28 @@
       }
 
       _form = _form.join(',')
-      _sql += `
+      _updatesql = `
         /* 榛樿sql */
         update ${btn.sql} set ${_form} where ${primaryKey}=@${primaryKey}@;`
+    }
+    
+    if (_actionType === 'insert') {
+      _sql += _insertsql
+    } else if (_actionType === 'update' || _actionType === 'audit') {
+      _sql += _updatesql
+    } else if (_actionType === 'insertOrUpdate') {
+      _sql += `
+        select @tbid=''
+        select @tbid='X' from ${btn.sql} where ${primaryKey}=@ID@
+        if @tbid=''
+          begin
+          ${_insertsql}
+          end
+        else
+          begin
+          ${_updatesql}
+          end
+      `
     } else if (_actionType === 'LogicDelete') { // 閫昏緫鍒犻櫎
       _sql += `
         /* 榛樿sql */

--
Gitblit v1.8.0