From 07c005cf28acf74e3afde82122e4c53e1000d70c Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期一, 12 六月 2023 12:06:18 +0800
Subject: [PATCH] Merge branch 'master' into positec

---
 src/utils/utils.js |  114 ++++++++++++++++++++++++++------------------------------
 1 files changed, 53 insertions(+), 61 deletions(-)

diff --git a/src/utils/utils.js b/src/utils/utils.js
index 119a3ee..5f9d942 100644
--- a/src/utils/utils.js
+++ b/src/utils/utils.js
@@ -142,19 +142,19 @@
   static verifySql (sql, type) {
     if (!sql) return ''
     let chars = [
-      {key: 'create', reg: /(^|\s)create\s/ig},
-      {key: 'insert', reg: /(^|\s)insert\s/ig},
-      {key: 'delete', reg: /(^|\s)delete\s/ig},
-      {key: 'update', reg: /(^|\s)update\s/ig},
-      {key: 'set', reg: /(^|\s)set\s/ig},
-      {key: 'drop', reg: /(^|\s)drop\s/ig},
-      {key: 'alter', reg: /(^|\s)alter\s/ig},
-      {key: 'truncate', reg: /(^|\s)truncate\s/ig},
-      {key: 'if', reg: /(^|\s)if\s/ig},
-      {key: 'exec', reg: /(^|\s)exec(\s|\()/ig},
-      {key: 'OBJECT', reg: /(^|\s)object(\s|\()/ig},
-      {key: 'sys.', reg: /(^|\s)sys\./ig},
-      {key: 'kill', reg: /(^|\s)kill\s/ig}
+      {key: 'create', reg: /(^|\s|\(|\))create\s/ig},
+      {key: 'insert', reg: /(^|\s|\(|\))insert\s/ig},
+      {key: 'delete', reg: /(^|\s|\(|\))delete\s/ig},
+      {key: 'update', reg: /(^|\s|\(|\))update\s/ig},
+      {key: 'set', reg: /(^|\s|\(|\))set\s/ig},
+      {key: 'drop', reg: /(^|\s|\(|\))drop\s/ig},
+      {key: 'alter', reg: /(^|\s|\(|\))alter\s/ig},
+      {key: 'truncate', reg: /(^|\s|\(|\))truncate\s/ig},
+      {key: 'if', reg: /(^|\s|\(|\))if\s/ig},
+      {key: 'exec', reg: /(^|\s|\(|\))exec(\s|\()/ig},
+      {key: 'OBJECT', reg: /(^|\s|\(|\))object(\s|\()/ig},
+      {key: 'sys.', reg: /(^|\s|\(|\))sys\./ig},
+      {key: 'kill', reg: /(^|\s|\(|\))kill\s/ig}
     ]
     
     if (type === 'customscript') {
@@ -808,6 +808,8 @@
     }
     if (['select', 'radio', 'link', 'checkcard'].includes(item.type) && item.linkSubField && item.linkSubField.length > 0) {
       arrfield.push(...item.linkSubField)
+    } else if (item.type === 'text' && item.editType === 'select' && item.linkSubField && item.linkSubField.length > 0) { // 鍙紪杈戣〃
+      arrfield.push(...item.linkSubField)
     }
     if (item.disableField) {
       arrfield.push(item.disableField)
@@ -958,11 +960,13 @@
       let _position = (_topline + lindex + 1) + '琛� ' + _colindex + '鍒� '
 
       if (/^Nvarchar/ig.test(col.type)) {
-        if (typeof(val) === 'number') {
-          val = val.toString()
+        val = val + ''
+
+        if (/'/.test(val)) {
+          val = val.replace(/'/ig, '"')
         }
 
-        val = val.replace(/(^\s*$)|\t*|\v*|'*/ig, '')
+        val = val.replace(/(^\s*$)|\t*|\v*/ig, '')
 
         if (!val && col.required === 'true') {            // 蹇呭~鏍¢獙
           errors.push(_position + '鍐呭涓嶅彲涓虹┖')
@@ -976,38 +980,15 @@
             }
           })
         }
-      } else if (/^int/ig.test(col.type)) {
+      } else if (/^Decimal/ig.test(col.type) || /^int/ig.test(col.type)) {
         if (!val && val !== 0) {
           errors.push(_position + '鍐呭涓嶅彲涓虹┖')
-        } else {
-          let _val = val + ''
-
-          if (!/^(([^0][0-9]+|0)$)|^(([1-9]+)$)/.test(_val)) {               // 妫�楠屾槸鍚︿负鏁存暟
-            errors.push(_position + '鍐呭搴斾负鏁存暟')
-          } else if ((col.min || col.min === 0) && val < col.min) {          // 鏈�灏忓�兼楠�
-            errors.push(_position + '灏忎簬鏈�灏忓��')
-          } else if ((col.max || col.max === 0) && val > col.max) {          // 鏈�澶у�兼楠�
-            errors.push(_position + '澶т簬鏈�澶у��')
-          }
-        }
-      } else if (/^Decimal/ig.test(col.type)) {
-        if (!val && val !== 0) {
-          errors.push(_position + '鍐呭涓嶅彲涓虹┖')
-        } else {
-          let _val = val + ''
-          let _vals = _val.split('.')
-
-          if (!/^(([^0][0-9]+|0)\.([0-9]+)$)|^(([^0][0-9]+|0)$)|^(([1-9]+)\.([0-9]+)$)|^(([1-9]+)$)/.test(_val)) {                           // 妫�楠屾槸鍚︿负娴偣鏁�
-            errors.push(_position + '鍐呭搴斾负娴偣鏁�')
-          } else if (_vals[0].length > 18) {                          // 妫�楠屾暣鏁颁綅
-            errors.push(_position + '鏁存暟浣嶈秴鍑鸿寖鍥�')
-          } else if (_vals[1] && _vals[1].length > col.limit) {       // 鏈�灏忓�兼楠�
-            errors.push(_position + '灏忔暟浣嶈秴鍑鸿寖鍥�')
-          } else if ((col.min || col.min === 0) && val < col.min) {   // 鏈�灏忓�兼楠�
-            errors.push(_position + '灏忎簬鏈�灏忓��')
-          } else if ((col.max || col.max === 0) && val > col.max) {   // 鏈�澶у�兼楠�
-            errors.push(_position + '澶т簬鏈�澶у��')
-          }
+        } else if (isNaN(val)) {                                  // 妫�楠屾槸鍚︿负鏁板��
+          errors.push(_position + '鍐呭搴斾负鏁板��')
+        } else if ((col.min || col.min === 0) && val < col.min) { // 鏈�灏忓�兼楠�
+          errors.push(_position + '灏忎簬鏈�灏忓��')
+        } else if ((col.max || col.max === 0) && val > col.max) { // 鏈�澶у�兼楠�
+          errors.push(_position + '澶т簬鏈�澶у��')
         }
       } else if (col.type === 'date') {
         if (typeof(val) === 'number') {
@@ -1066,14 +1047,14 @@
     let _uniquesql = ''
     if (btn.uniques && btn.uniques.length > 0) {
       btn.uniques.forEach(unique => {
-        if (unique.status === 'false') return
+        if (unique.status === 'false' || !unique.verifyType) return
 
         let _fields = unique.field.split(',')
         let _fields_ = _fields.map(_field => `a.${_field}=b.${_field}`)
         let _afields = _fields.map(_field => `a.${_field}`)
         _fields_ = _fields_.join(' and ')
 
-        if (unique.verifyType !== 'physical') {
+        if (unique.verifyType === 'logic' || unique.verifyType === 'logic_temp') {
           _fields_ += ' and b.deleted=0'
         }
 
@@ -1088,14 +1069,14 @@
         goto aaa
       end
       
-      Set @tbid=''
+      ${unique.verifyType.indexOf('temp') === -1 ? `Set @tbid=''
       Select top 1 @tbid=${_afields.join('+\' \'+')} from  @${sheet} a Inner join ${sheet} b on ${_fields_}
       
       If @tbid!=''
       Begin
         select @ErrorCode='${unique.errorCode}',@retmsg=@tbid+' 涓庡凡鏈夋暟鎹噸澶�'
         goto aaa
-      end
+      end` : ''}
       `
       })
     }
@@ -1287,14 +1268,14 @@
     let _uniquesql = ''
     if (btn.uniques && btn.uniques.length > 0) {
       btn.uniques.forEach(unique => {
-        if (unique.status === 'false') return
+        if (unique.status === 'false' || !unique.verifyType) return
 
         let _fields = unique.field.split(',')
         let _fields_ = _fields.map(_field => `a.${_field}=b.${_field}`)
         let _afields = _fields.map(_field => `a.${_field}`)
         _fields_ = _fields_.join(' and ')
 
-        if (unique.verifyType !== 'physical') {
+        if (unique.verifyType === 'logic' || unique.verifyType === 'logic_temp') {
           _fields_ += ' and b.deleted=0'
         }
 
@@ -1309,14 +1290,14 @@
         goto aaa
       end
       
-      Set @tbid=''
+      ${unique.verifyType.indexOf('temp') === -1 ? `Set @tbid=''
       Select top 1 @tbid=${_afields.join('+\' \'+')} from  @${sheet} a Inner join ${sheet} b on ${_fields_}
       
       If @tbid!=''
       Begin
         select @ErrorCode='${unique.errorCode}',@retmsg=@tbid+' 涓庡凡鏈夋暟鎹噸澶�'
         goto aaa
-      end
+      end` : ''}
       `
       })
     }
@@ -1449,7 +1430,7 @@
   })
 
   // 闇�瑕佸0鏄庣殑鍙橀噺闆�
-  let _vars = ['tbid', 'errorcode', 'retmsg', 'billcode', 'bvoucher', 'fibvoucherdate', 'fiyear', 'username', 'fullname', 'modulardetailcode', 'roleid', 'mk_departmentcode', 'mk_organization', 'mk_user_type', 'mk_nation', 'mk_province', 'mk_city', 'mk_district', 'mk_address', 'bid']
+  let _vars = ['tbid', 'errorcode', 'retmsg', 'billcode', 'bvoucher', 'fibvoucherdate', 'fiyear', 'username', 'fullname', 'modulardetailcode', 'roleid', 'mk_departmentcode', 'mk_organization', 'mk_user_type', 'mk_nation', 'mk_province', 'mk_city', 'mk_district', 'mk_address', 'mk_deleted', 'bid']
 
   // 涓婚敭瀛楁
   let primaryKey = setting.primaryKey || 'id'
@@ -1469,17 +1450,24 @@
 
     if (!_initvars.includes(_key)) {
       _initvars.push(_key)
+      let val = form.value
 
       if (form.type === 'number' || form.type === 'rate') {
-        let val = form.value
         if (isNaN(val)) {
           val = 0
         }
         _initFormfields.push(`@${_key}=${val}`)
       } else if (['date', 'datemonth'].includes(form.type)) {
-        _initFormfields.push(`@${_key}='${form.value || '1949-10-01'}'`)
+        _initFormfields.push(`@${_key}='${val || '1949-10-01'}'`)
       } else {
-        _initFormfields.push(`@${_key}='${form.value}'`)
+        if (/'/.test(val)) {
+          val = val.replace(/'/ig, '"')
+        }
+        if (form.isconst) {
+          _initFormfields.push(`@${_key}=N'${val}'`)
+        } else {
+          _initFormfields.push(`@${_key}='${val}'`)
+        }
       }
     }
     
@@ -1524,6 +1512,10 @@
 
         if (col.datatype && /^date/ig.test(col.datatype) && !_val) {
           _val = '1949-10-01'
+        }
+
+        if (/'/.test(_val)) {
+          _val = _val.replace(/'/ig, '"')
         }
 
         _initvars.push(_key)
@@ -1571,7 +1563,7 @@
     _declarefields = ',' + _declarefields
   }
   _sql = `/* 绯荤粺鐢熸垚 */
-      Declare @tbid nvarchar(50),@ErrorCode nvarchar(50),@retmsg nvarchar(4000),@BillCode nvarchar(50),@BVoucher nvarchar(50),@FIBVoucherDate nvarchar(50), @FiYear nvarchar(50),@ModularDetailCode nvarchar(50), @UserName nvarchar(50),@FullName nvarchar(50),@RoleID nvarchar(512),@mk_departmentcode nvarchar(512),@mk_organization nvarchar(512),@mk_user_type nvarchar(20),@mk_nation nvarchar(50),@mk_province nvarchar(50),@mk_city nvarchar(50),@mk_district nvarchar(50),@mk_address nvarchar(100),@bid nvarchar(50)${_declarefields}
+      Declare @tbid nvarchar(50),@ErrorCode nvarchar(50),@retmsg nvarchar(4000),@BillCode nvarchar(50),@BVoucher nvarchar(50),@FIBVoucherDate nvarchar(50), @FiYear nvarchar(50),@ModularDetailCode nvarchar(50), @UserName nvarchar(50),@FullName nvarchar(50),@RoleID nvarchar(512),@mk_departmentcode nvarchar(512),@mk_organization nvarchar(512),@mk_user_type nvarchar(20),@mk_nation nvarchar(50),@mk_province nvarchar(50),@mk_city nvarchar(50),@mk_district nvarchar(50),@mk_address nvarchar(100),@mk_deleted int,@bid nvarchar(50)${_declarefields}
     `
 
   let userName = sessionStorage.getItem('User_Name') || ''
@@ -1594,7 +1586,7 @@
   // 鍒濆鍖栧嚟璇佸強鐢ㄦ埛淇℃伅瀛楁
   _sql += `
       /* 鍑瘉鍙婄敤鎴蜂俊鎭垵濮嬪寲璧嬪�� */
-      select @BVoucher='',@FIBVoucherDate='',@FiYear='',@ErrorCode='',@retmsg='',@UserName='${userName}', @FullName='${fullName}', @RoleID='${RoleID}', @mk_departmentcode='${departmentcode}', @mk_organization='${organization}', @mk_user_type='${mk_user_type}', @mk_nation='${nation}', @mk_province='${province}', @mk_city='${city}', @mk_district='${district}', @mk_address='${address}', @bid='${BID}', @BillCode='', @ModularDetailCode=''
+      select @BVoucher='',@FIBVoucherDate='',@FiYear='',@ErrorCode='',@retmsg='',@UserName='${userName}', @FullName='${fullName}', @RoleID='${RoleID}', @mk_departmentcode='${departmentcode}', @mk_organization='${organization}', @mk_user_type='${mk_user_type}', @mk_nation='${nation}', @mk_province='${province}', @mk_city='${city}', @mk_district='${district}', @mk_address='${address}', @mk_deleted=1, @bid='${BID}', @BillCode='', @ModularDetailCode=''
       `
 
   // 琛ㄥ崟鍙橀噺璧嬪��
@@ -2067,7 +2059,7 @@
 
     _sql += `
       /* 榛樿sql */
-      update ${btn.sql} set deleted=1,modifydate=getdate(),modifyuser=@username,modifystaff=@fullname,modifyuserid=@userid@ where ${primaryKey}${_ID};`
+      update ${btn.sql} set deleted=@mk_deleted,modifydate=getdate(),modifyuser=@username,modifystaff=@fullname,modifyuserid=@userid@ where ${primaryKey}${_ID};`
   
   } else if (_actionType === 'delete') {      // 鐗╃悊鍒犻櫎
     let _msg = ''

--
Gitblit v1.8.0