From f9f60bb0dd17a764ba03faa8041f5b6e9e071553 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期六, 18 一月 2025 23:37:44 +0800
Subject: [PATCH] 2025-01-18

---
 src/menu/debug/index.jsx |   94 +++++++++++++++++++++++++++++++---------------
 1 files changed, 63 insertions(+), 31 deletions(-)

diff --git a/src/menu/debug/index.jsx b/src/menu/debug/index.jsx
index 2631cf0..9708b3d 100644
--- a/src/menu/debug/index.jsx
+++ b/src/menu/debug/index.jsx
@@ -637,9 +637,12 @@
     if (!_prev) return _back
 
     let tbs = []
-    _prev.replace(/\n|\r/g, ' ').split(/\sdeclare\s/ig).forEach(line => {
-      if (!/^\s*(@|#)[a-zA-Z0-9_]+\s+table\s+\(/ig.test(line)) return
-      let tb = line.match(/(@|#)[a-zA-Z0-9_]+\s+table\s+\(.+(\)|date|datetime)\s*\)/ig)
+    _prev.replace(/\/\*[^/*]+\*\//g, '').replace(/\n|\r/g, ' ').split(/\sdeclare\s+|\screate\s+table\s+/ig).forEach(line => {
+      if (/^\s*(@|#)[a-zA-Z0-9_]+\s+table\s+\(/ig.test(line)) {
+        line = line.replace(/\s+table\s+\(/, '(')
+      }
+      if (!/^\s*(@|#)[a-zA-Z0-9_]+\s*\(/ig.test(line)) return
+      let tb = line.match(/(@|#)[a-zA-Z0-9_]+\s*\(.+(\)|date|datetime)\s*\)/ig)
 
       if (tb && tb.length === 1) {
         tbs.push(tb[0])
@@ -651,7 +654,7 @@
 
       if (!tbName) return
 
-      let content = tb.replace(/(@|#)[a-zA-Z0-9_]+\s+table\s+\(\s*/, '').replace(/\s*\)$/, '')
+      let content = tb.replace(/(@|#)[a-zA-Z0-9_]+\s*\(\s*/, '').replace(/\s*\)$/, '')
       content = content.replace(/decimal\(\s*\d+\s*,\s*\d+\s*\)/ig, 'decimal')
 
       let keys = []
@@ -780,6 +783,11 @@
             writein: item.writein !== 'false',
             type: item.type
           }
+
+          if (item.type === 'linkMain' && item.verifyVal === 'true') {
+            _item.$verify = true
+            _item.label = item.label
+          }
     
           if (_item.type === 'datemonth') {
             _item.type = 'text'
@@ -829,6 +837,11 @@
             writein: item.writein !== 'false',
             type: item.type
           }
+
+          if (item.type === 'linkMain' && item.verifyVal === 'true') {
+            _item.$verify = true
+            _item.label = item.label
+          }
     
           if (_item.type === 'datemonth') {
             _item.type = 'text'
@@ -866,8 +879,20 @@
         key: 'mk_n_id'
       })
     }
+
+    let verifyValSql = ''
     // 鑾峰彇瀛楁閿�煎
     formdata && formdata.forEach(form => {
+      if (form.$verify) {
+        verifyValSql += `
+        if @${form.key}=${form.type === 'number' ? 0 : `''`}
+        begin
+          select @errorcode='E',@retmsg='${form.label}锛屽叧鑱斾富琛ㄥけ鏁�'
+          goto aaa
+        end
+        `
+      }
+
       let _key = form.key.toLowerCase()
       if (!_initvars.includes(_key)) {
         _initvars.push(_key)
@@ -1108,22 +1133,21 @@
   
       verify.billcodes.forEach(item => {
         let _key = item.field.toLowerCase()
-        let _linkKey = item.linkField ? item.linkField.toLowerCase() : ''
   
         if (!keys.includes(_key)) return // 琛ㄥ崟涓笉鍚崟鍙风敓鎴愬瓧娈�
   
         let _lpline = ''
         if (item.TypeCharOne === 'Lp') {
-          if (_linkKey === 'bid' && BID) { // 鏇挎崲bid
+          if (/^BID$/ig.test(item.linkField)) {
             _lpline = `set @ModularDetailCode= 'Lp'+ right('${item.mark || btn.uuid}'+@BID@,48)`
           } else {
-            _lpline = `set @ModularDetailCode= 'Lp'+ right('${item.mark || btn.uuid}'+@${_linkKey},48)`
+            _lpline = `set @ModularDetailCode= 'Lp'+ right('${item.mark || btn.uuid}'+@${item.linkField},48)`
           }
         } else if (item.TypeCharOne === 'BN') {
-          if (_linkKey === 'bid' && BID) { // 鏇挎崲bid
+          if (/^BID$/ig.test(item.linkField)) {
             _lpline = `set @ModularDetailCode= 'BN'+ right(@BID@,48)`
           } else {
-            _lpline = `set @ModularDetailCode= 'BN'+ right(@${_linkKey},48)`
+            _lpline = `set @ModularDetailCode= 'BN'+ right(@${item.linkField},48)`
           }
         } else {
           _lpline = `set @ModularDetailCode= right('${item.ModularDetailCode}',50)`
@@ -1154,17 +1178,6 @@
   
     // 鍞竴鎬ч獙璇侊紝蹇呴』瀛樺湪琛ㄥ崟锛堣〃鍗曞瓨鍦ㄦ椂锛屼富閿潎涓哄崟鍊硷級,蹇呴』濉啓鏁版嵁婧愶紝澶氳鎷兼帴鏃朵笉鍙敤
     if (formdata && verify.uniques && verify.uniques.length > 0 && btn.Ot !== 'requiredOnce') {
-      let dateForms = []
-      let numForms = []
-      formdata.forEach(form => {
-        let _key = form.key.toLowerCase()
-        if (form.type === 'date') {
-          dateForms.push(_key)
-        } else if (form.type === 'number' || form.type === 'rate') {
-          numForms.push(_key)
-        }
-      })
-
       verify.uniques.forEach(item => {
         let _fieldValue = []                     // 琛ㄥ崟閿�煎field=value
         let _value = []                          // 琛ㄥ崟鍊硷紝鐢ㄤ簬閿欒鎻愮ず
@@ -1174,21 +1187,26 @@
         item.field.split(',').forEach((_field, index) => {
           let _key = _field.toLowerCase()
           let _val = ''
+          let _val2 = ''
   
           arr.push(_key)
-          if (_key === 'bid') { // 琛ㄥ崟涓病鏈塨id鍒欎娇鐢ㄧ郴缁焍id鍙橀噺
-            _val = BID
-          } else if (numForms.includes(_key)) {
-            _val = '1'
-          } else if (dateForms.includes(_key)) {
-            _val = '1949-10-01'
+          if (_key === 'bid') {
+            _val = `'${BID}'`
+          } else {
+            _val = `@${_field}`
           }
 
-          _fieldValue.push(`${_key}='${_val}'`)
-          _value.push(`${_labels[index] || ''}锛�${_val || ''}`)
+          if (_key === 'bid') {
+            _val2 = BID
+          } else {
+            _val2 = `' + @${_field} + '`
+          }
+
+          _fieldValue.push(`${_key}=${_val}`)
+          _value.push(`${_labels[index] || ''}锛�${_val2}`)
         })
   
-        if (!arr.includes(primaryKey.toLowerCase())) {
+        if (!arr.includes(primaryKey.toLowerCase()) && btn.Ot !== 'notRequired') {
           _fieldValue.push(`${primaryKey} !='${primaryId}'`)
         }
   
@@ -1239,15 +1257,20 @@
     let hasvoucher = false
   
     // 鍑瘉-鏄剧ず鍒椾腑閫夊彇,蹇呴』閫夎
-    if (verify.voucher && verify.voucher.enabled && btn.Ot !== 'requiredOnce') {
+    if (verify.voucher && verify.voucher.enabled) {
       let _voucher = verify.voucher
+      let linkField = `@${_voucher.linkField}`
   
+      if (/^BID$/ig.test(_voucher.linkField)) {
+        linkField = `'${BID}'`
+      }
+
       hasvoucher = true
   
       _sql += `
         /* 鍒涘缓鍑瘉 */
         exec s_BVoucher_Create
-          @Bill ='0',
+          @Bill = ${linkField},
           @BVoucherType ='${_voucher.BVoucherType}',
           @VoucherTypeOne ='${_voucher.VoucherTypeOne}',
           @VoucherTypeTwo ='${_voucher.VoucherTypeTwo}',
@@ -1510,6 +1533,10 @@
       }
     } else if (_backCustomScript) {
       _sql += _backCustomScript
+    }
+
+    if (verifyValSql) {
+      _sql += verifyValSql
     }
   
     if (btn.procMode === 'system') {
@@ -2072,6 +2099,11 @@
       { reg: /@datam@/ig, value: `''` },
     ]
 
+    let process = this.props.config.process === 'true'
+    if (process) {
+      regs.push({ reg: /@works_flow_code@/ig, value: `'1949-10-01 15:00:00'` })
+    }
+
     let sql = this.formatDataSource(item, regs)
 
     return sql

--
Gitblit v1.8.0