From 390c5026c78d2be9dca4357041f4a0ec8ac3668f Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期二, 04 二月 2020 13:57:31 +0800
Subject: [PATCH] 2020-02-04

---
 src/utils/utils.js |   32 +++++++++++++++++++++++++-------
 1 files changed, 25 insertions(+), 7 deletions(-)

diff --git a/src/utils/utils.js b/src/utils/utils.js
index 3492fa5..3a83691 100644
--- a/src/utils/utils.js
+++ b/src/utils/utils.js
@@ -459,8 +459,17 @@
 
     let primaryKey = setting.primaryKey || 'id' // 涓婚敭瀛楁
     // 绯荤粺鍙橀噺澹版槑涓庤缃垵濮嬪��
-    let _sql = `Declare @tbid nvarchar(50), @ErrorCode nvarchar(50),@retmsg nvarchar(4000),@BillCode nvarchar(50),@BVoucher nvarchar(50),@FIBVoucherDate nvarchar(50), @FiYear nvarchar(50)
-      Select @BVoucher='',@FIBVoucherDate='',@FiYear=''
+    let _sql = `Declare @tbid nvarchar(50),@ErrorCode nvarchar(50),@retmsg nvarchar(4000),@BillCode nvarchar(50),@BVoucher nvarchar(50),@FIBVoucherDate nvarchar(50), @FiYear nvarchar(50)
+      `
+    if (verify && verify.scripts && verify.scripts.length > 0 && formdata) {
+      let _formfields = formdata.filter(form => !['tbid', 'ErrorCode', 'retmsg', 'BillCode', 'BVoucher', 'FIBVoucherDate', 'FiYear'].includes(form.key))
+      _formfields = _formfields.map(form => `@${form.key} nvarchar(50)`)
+      _formfields = _formfields.join(',')
+      _sql += `${_formfields}
+        `
+    }
+
+    _sql += `Select @BVoucher='',@FIBVoucherDate='',@FiYear=''
       `
 
     if (verify && verify.accountdate === 'true') { // 鍚敤璐︽湡楠岃瘉
@@ -555,7 +564,7 @@
           let _val = ''
           if (item.linkField === 'BID' && BID) { // 鏇挎崲bid
             _val = BID
-          } else if (data.hasOwnProperty(item.linkField)) {
+          } else if (data && data.hasOwnProperty(item.linkField)) {
             _val = data[item.linkField]
           }
           _ModularDetailCode = item.TypeCharOne + _val
@@ -582,7 +591,7 @@
 
     let _updateconfig = ''
 
-    if (verify && verify.voucher && verify.voucher.enabled) { // 鍑瘉-鏄剧ず鍒椾腑閫夊彇,蹇呴』閫夎
+    if (verify && verify.voucher && verify.voucher.enabled && data) { // 鍑瘉-鏄剧ず鍒椾腑閫夊彇,蹇呴』閫夎
       let _voucher = verify.voucher
 
       _updateconfig = ',BVoucher=@BVoucher,FIBVoucherDate=@FIBVoucherDate,FiYear=@FiYear'
@@ -643,9 +652,18 @@
     } else if ((btn.OpenType === 'prompt' || btn.OpenType === 'exec') && btn.sqlType === 'delete') {      // 鐗╃悊鍒犻櫎
       _sql += `insert into snote (remark,createuserid) select '鍒犻櫎琛�:${btn.sql} 鏁版嵁: ${primaryKey}='+@${primaryKey},@userid delete ${btn.sql} where ${primaryKey}=@${primaryKey}`
     }
-    _sql += `
-      aaa:
-      select @ErrorCode as ErrorCode,@retmsg as retmsg
+
+    if (verify && verify.scripts && verify.scripts.length > 0) {
+      let _scripts = ''
+      verify.scripts.forEach(item => {
+        _scripts += `${item.sql}
+        `
+      })
+      _sql += `
+        ${_scripts}`
+    }
+
+    _sql += `aaa: select @ErrorCode as ErrorCode,@retmsg as retmsg
       `
     console.log(_sql)
     return _sql

--
Gitblit v1.8.0