From c8c8bdf0c362ca76253d8e0cbb0dbaa13efad4a3 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期三, 12 二月 2025 23:09:48 +0800
Subject: [PATCH] 2025-02-12

---
 src/utils/utils.js |   50 +++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 41 insertions(+), 9 deletions(-)

diff --git a/src/utils/utils.js b/src/utils/utils.js
index 09650c6..dbda559 100644
--- a/src/utils/utils.js
+++ b/src/utils/utils.js
@@ -1140,16 +1140,34 @@
     cols.push('A' + cols[i])
   }
 
+  let columns = JSON.parse(JSON.stringify(btn.columns))
+  columns = columns.filter((col, index) => {
+    col.colIndex = cols[index] || (index + 1)
+    if (col.import !== 'init' && (/^Decimal/ig.test(col.type) || /^int/ig.test(col.type))) {
+      col.declen = 0
+      if (/^Decimal/ig.test(col.type)) {
+        col.declen = +col.type.match(/\d+/g)[1]
+      }
+      col.declen = col.declen || 0
+    }
+    if (col.required === 'false') {
+      delete col.min
+      delete col.max
+    }
+
+    return col.import !== 'false'
+  })
+
   let _Ltext = data.map((item, lindex) => {
     let vals = []
-    btn.columns.forEach((col, cindex) => {
-      if (col.import === 'false') return
-
+    columns.forEach(col => {
       let val = item[col.Column] !== undefined ? item[col.Column] : ''
-      let _colindex = cols[cindex] || (cindex + 1)
-      let _position = (_topline + lindex + 1) + '琛� ' + _colindex + '鍒� '
+      let _position = (_topline + lindex + 1) + '琛� ' + col.colIndex + '鍒� '
+      let eLen = errors.length
 
-      if (col.import === 'init') {
+      if (col.$error) {
+
+      } else if (col.import === 'init') {
         if (/^Nvarchar/ig.test(col.type)) {
           val = ''
         } else if (/^Decimal/ig.test(col.type) || /^int/ig.test(col.type)) {
@@ -1185,14 +1203,24 @@
           if (!val || isNaN(val)) {
             val = 0
           }
-        } else if (!val && val !== 0) {
+        }
+        if (!val && val !== 0) {
           errors.push(_position + '鍐呭涓嶅彲涓虹┖')
         } else if (isNaN(val)) {                                  // 妫�楠屾槸鍚︿负鏁板��
           errors.push(_position + '鍐呭搴斾负鏁板��')
-        } else if ((col.min || col.min === 0) && val < col.min) { // 鏈�灏忓�兼楠�
+        } else if (typeof(col.min) === 'number' && val < col.min) { // 鏈�灏忓�兼楠�
           errors.push(_position + '灏忎簬鏈�灏忓��')
-        } else if ((col.max || col.max === 0) && val > col.max) { // 鏈�澶у�兼楠�
+        } else if (typeof(col.max) === 'number' && val > col.max) { // 鏈�澶у�兼楠�
           errors.push(_position + '澶т簬鏈�澶у��')
+        } else {
+          let _float = (val + '').split('.')[1]
+          if (_float && _float.length > col.declen) {
+            if (col.declen) {
+              errors.push(_position + `鏁板�间笉鍙ぇ浜�${col.declen}浣嶅皬鏁癭)
+            } else {
+              errors.push(_position + '鏁板�煎簲涓烘暣鏁�')
+            }
+          }
         }
       } else if (col.type === 'date' || col.type === 'datetime') {
         if (typeof(val) === 'number') {
@@ -1229,6 +1257,10 @@
         }
       }
 
+      if (errors.length > eLen) {
+        col.$error = true
+      }
+
       vals.push(`'${val}'`)
     })
 

--
Gitblit v1.8.0