From 592ff0aa0f2d45d143872b672a1468e268d3157f Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期六, 22 二月 2020 17:25:20 +0800
Subject: [PATCH] 2020-02-22

---
 src/utils/utils.js |   83 +++++++++++++++++++++++------------------
 1 files changed, 47 insertions(+), 36 deletions(-)

diff --git a/src/utils/utils.js b/src/utils/utils.js
index ea12648..ba0e8e1 100644
--- a/src/utils/utils.js
+++ b/src/utils/utils.js
@@ -464,12 +464,10 @@
 
           val = val.replace(/(^\s*$)|\t*|\v*/ig, '')
 
-          let limitlen = col.type.match(/\d+/)[0]
-
           if (!val && col.required === 'true') { // 蹇呭~鏍¢獙
             let _error =  _position + dict['main.excel.content.emptyerror']
             errors.push(_error)
-          } else if (val.length > limitlen) {    // 闀垮害鏍¢獙
+          } else if (val.length > col.limit) {    // 闀垮害鏍¢獙
             let _error =  _position + dict['main.excel.content.maxlimit']
             errors.push(_error)
           } else {                               // 鍏抽敭瀛楁牎楠�
@@ -482,36 +480,47 @@
             })
           }
         } else if (/^int/ig.test(col.type)) {
-          if (typeof(val) !== 'number' || parseInt(val) < parseFloat(val)) { // 妫�楠屾槸鍚︿负鏁存暟
-            let _error = _position + dict['main.excel.content.interror']
+          if (!val) {
+            let _error =  _position + dict['main.excel.content.emptyerror']
             errors.push(_error)
-          } else if ((col.min || col.min === 0) && val < col.min) {          // 鏈�灏忓�兼楠�
-            let _error = _position + dict['main.excel.content.limitmin']
-            errors.push(_error)
-          } else if ((col.max || col.max === 0) && val > col.max) {          // 鏈�澶у�兼楠�
-            let _error = _position + dict['main.excel.content.limitmax']
-            errors.push(_error)
+          } else {
+            let _val = val + ''
+
+            if (!/^(([^0][0-9]+|0)$)|^(([1-9]+)$)/.test(_val)) {               // 妫�楠屾槸鍚︿负鏁存暟
+              let _error = _position + dict['main.excel.content.interror']
+              errors.push(_error)
+            } else if ((col.min || col.min === 0) && val < col.min) {          // 鏈�灏忓�兼楠�
+              let _error = _position + dict['main.excel.content.limitmin']
+              errors.push(_error)
+            } else if ((col.max || col.max === 0) && val > col.max) {          // 鏈�澶у�兼楠�
+              let _error = _position + dict['main.excel.content.limitmax']
+              errors.push(_error)
+            }
           }
         } else if (/^Decimal/ig.test(col.type)) {
-          let _val = val + ''
-          _val = _val.split('.')
-          let limitlen = col.type.match(/\d+/ig)[1]
+          if (!val) {
+            let _error =  _position + dict['main.excel.content.emptyerror']
+            errors.push(_error)
+          } else {
+            let _val = val + ''
+            let _vals = _val.split('.')
 
-          if (typeof(val) !== 'number') {                           // 妫�楠屾槸鍚︿负娴偣鏁�
-            let _error = _position + dict['main.excel.content.floaterror']
-            errors.push(_error)
-          } else if (_val[0].length > 18) {                         // 妫�楠屾暣鏁颁綅
-            let _error = _position + dict['main.excel.content.floatIntover']
-            errors.push(_error)
-          } else if (_val[1] && _val[1].length > limitlen) {        // 鏈�灏忓�兼楠�
-            let _error = _position + dict['main.excel.content.floatPointover']
-            errors.push(_error)
-          } else if ((col.min || col.min === 0) && val < col.min) { // 鏈�灏忓�兼楠�
-            let _error = _position + dict['main.excel.content.limitmin']
-            errors.push(_error)
-          } else if ((col.max || col.max === 0) && val > col.max) { // 鏈�澶у�兼楠�
-            let _error = _position + dict['main.excel.content.limitmax']
-            errors.push(_error)
+            if (!/^(([^0][0-9]+|0)\.([0-9]+)$)|^(([^0][0-9]+|0)$)|^(([1-9]+)\.([0-9]+)$)|^(([1-9]+)$)/.test(_val)) {                           // 妫�楠屾槸鍚︿负娴偣鏁�
+              let _error = _position + dict['main.excel.content.floaterror']
+              errors.push(_error)
+            } else if (_vals[0].length > 18) {                         // 妫�楠屾暣鏁颁綅
+              let _error = _position + dict['main.excel.content.floatIntover']
+              errors.push(_error)
+            } else if (_vals[1] && _vals[1].length > col.limit) {       // 鏈�灏忓�兼楠�
+              let _error = _position + dict['main.excel.content.floatPointover']
+              errors.push(_error)
+            } else if ((col.min || col.min === 0) && val < col.min) { // 鏈�灏忓�兼楠�
+              let _error = _position + dict['main.excel.content.limitmin']
+              errors.push(_error)
+            } else if ((col.max || col.max === 0) && val > col.max) { // 鏈�澶у�兼楠�
+              let _error = _position + dict['main.excel.content.limitmax']
+              errors.push(_error)
+            }
           }
         }
         
@@ -1012,7 +1021,6 @@
       config.search.forEach(item => {
         if (item.field) {
           let type = ''
-          let _f = item.field
 
           if (item.type.match(/date/ig)) {
             type = 'datetime=null'
@@ -1020,12 +1028,15 @@
             type = 'nvarchar(50)=\'\''
           }
 
-          if (_fields.has(item.field)) {
-            _f = _f + '1'
-          }
-
-          _fields.set(item.field, true)
-          formParam = formParam + `mchr13k@${_f} ${type},`
+          item.field.split(',').forEach(cell => {
+            let _f = cell
+            if (_fields.has(cell)) {
+              _f = _f + '1'
+            }
+  
+            _fields.set(cell, true)
+            formParam = formParam + `mchr13k@${_f} ${type},`
+          })
         }
       })
     }

--
Gitblit v1.8.0