From 3c7455f8d64b989181e5773efa6c22368351fa38 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期三, 24 四月 2024 23:10:39 +0800
Subject: [PATCH] 2024-04-24

---
 src/utils/utils.js |   19 +++++++++++++++++--
 1 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/src/utils/utils.js b/src/utils/utils.js
index 46e40aa..cf6abd4 100644
--- a/src/utils/utils.js
+++ b/src/utils/utils.js
@@ -1145,6 +1145,13 @@
 
     let _uniquesql = ''
     if (btn.uniques && btn.uniques.length > 0) {
+      let textFields = []
+      btn.columns.forEach((col) => {
+        if (/^Nvarchar/ig.test(col.type)) {
+          textFields.push(col.Column)
+        }
+      })
+
       btn.uniques.forEach(unique => {
         if (unique.status === 'false' || !unique.verifyType) return
 
@@ -1153,6 +1160,14 @@
         let _afields = _fields.map(_field => `a.${_field}`)
         _fields_ = _fields_.join(' and ')
 
+        let _where = []
+        _fields.forEach(f => {
+          if (textFields.includes(f)) {
+            _where.push(`${f}!=''`)
+          }
+        })
+        _where = _where.length ? `where ${_where.join(' and ')} ` : ''
+
         if (unique.verifyType === 'logic' || unique.verifyType === 'logic_temp') {
           _fields_ += ' and b.deleted=0'
         }
@@ -1160,7 +1175,7 @@
         _uniquesql += `
       /* 閲嶅鎬ч獙璇� */
       Set @tbid=''
-      Select top 1 @tbid=${_fields.join('+\' \'+')} from (select 1 as n,${unique.field} from #${sheet} ) a group by ${unique.field} having sum(n)>1
+      Select top 1 @tbid=${_fields.join('+\' \'+')} from (select 1 as n,${unique.field} from #${sheet} ${_where}) a group by ${unique.field} having sum(n)>1
       
       If @tbid!=''
       Begin
@@ -1169,7 +1184,7 @@
       end
       
       ${unique.verifyType.indexOf('temp') === -1 ? `Set @tbid=''
-      Select top 1 @tbid=${_afields.join('+\' \'+')} from  #${sheet} a Inner join ${database}${sheet} b on ${_fields_}
+      Select top 1 @tbid=${_afields.join('+\' \'+')} from ${_where ? `(select * from #${sheet} ${_where})` : `#${sheet}`} a Inner join ${database}${sheet} b on ${_fields_}
       
       If @tbid!=''
       Begin

--
Gitblit v1.8.0