From ac1d52c46ff9019fcc93cf3d5e7ab17cf850824e Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期四, 10 八月 2023 16:05:24 +0800
Subject: [PATCH] 2023-08-10

---
 src/templates/zshare/modalform/index.jsx                          |    2 
 src/tabviews/custom/components/chart/antv-bar-line/index.jsx      |    2 
 src/templates/zshare/editTable/index.jsx                          |   87 +++++++++++++++++++++--------
 src/views/login/loginform.jsx                                     |    8 +-
 src/menu/components/share/markcomponent/index.jsx                 |   47 ++++++++++++---
 src/views/login/logincloudform.jsx                                |    4 
 src/tabviews/zshare/actionList/printbutton/index.jsx              |    2 
 src/tabviews/zshare/mutilform/index.jsx                           |    2 
 src/tabviews/zshare/actionList/normalbutton/index.jsx             |    2 
 src/components/header/loginform.jsx                               |    4 
 src/menu/components/share/markcomponent/markform/index.jsx        |    3 +
 src/utils/utils.js                                                |    4 
 src/templates/sharecomponent/searchcomponent/searchform/index.jsx |    2 
 13 files changed, 118 insertions(+), 51 deletions(-)

diff --git a/src/components/header/loginform.jsx b/src/components/header/loginform.jsx
index 8639861..95e702f 100644
--- a/src/components/header/loginform.jsx
+++ b/src/components/header/loginform.jsx
@@ -59,8 +59,8 @@
             values.password = oripassword
           }
           
-          values.username = values.username.replace(/\t*|\v*|\s*/g, '')
-          values.password = values.password.replace(/\t*|\v*|\s*/g, '')
+          values.username = values.username.replace(/\t+|\v+|\s+/g, '')
+          values.password = values.password.replace(/\t+|\v+|\s+/g, '')
 
           resolve(values)
         } else {
diff --git a/src/menu/components/share/markcomponent/index.jsx b/src/menu/components/share/markcomponent/index.jsx
index c188601..246f2ea 100644
--- a/src/menu/components/share/markcomponent/index.jsx
+++ b/src/menu/components/share/markcomponent/index.jsx
@@ -1,7 +1,7 @@
 import React, {Component} from 'react'
 import PropTypes from 'prop-types'
 import { fromJS } from 'immutable'
-import { Modal, Col } from 'antd'
+import { Modal, Col, notification } from 'antd'
 import { AntDesignOutlined } from '@ant-design/icons'
 
 import Utils from '@/utils/utils.js'
@@ -32,6 +32,20 @@
         dataIndex: 'field',
         width: '16%',
         editable: true,
+        unique: true,
+        uniqueFunc: (data, item) => {
+          let index = data.findIndex(mark => mark.uuid !== item.uuid && mark.contrastValue === item.contrastValue && mark.match === item.match && mark.field.join('') === item.field.join(''))
+
+          if (index > -1) {
+            notification.warning({
+              top: 92,
+              message: '姝ゆ爣璁板凡瀛樺湪锛�',
+              duration: 5
+            })
+            return false
+          }
+          return true
+        },
         inputType: 'cascader',
         options: [],
         rules: [{
@@ -118,18 +132,24 @@
   markChange = (values) => {
     let _marks = fromJS(this.state.marks).toJS()
 
-    if (values.uuid) {
-      _marks = _marks.map(item => {
-        if (item.uuid === values.uuid) {
-          return values
-        } else {
-          return item
-        }
+    let has = false
+    _marks.forEach(mark => {
+      if (mark.contrastValue === values.contrastValue && mark.match === values.match && mark.field.join('') === values.field.join('')) {
+        has = true
+      }
+    })
+
+    if (has) {
+      notification.warning({
+        top: 92,
+        message: '姝ゆ爣璁板凡瀛樺湪锛�',
+        duration: 5
       })
-    } else {
-      values.uuid = Utils.getuuid()
-      _marks.push(values)
+      return
     }
+
+    values.uuid = Utils.getuuid()
+    _marks.push(values)
 
     this.setState({
       marks: _marks
@@ -319,6 +339,11 @@
           item.fontColor = ''
         }
       }
+
+      if (item.contrastValue) {
+        item.contrastValue = item.contrastValue.replace(/\t+|\v+|\s+/g, '')
+      }
+
       if (val && item.contrastValue === val) {
         save = true
       }
diff --git a/src/menu/components/share/markcomponent/markform/index.jsx b/src/menu/components/share/markcomponent/markform/index.jsx
index 0603b31..0fb88dc 100644
--- a/src/menu/components/share/markcomponent/markform/index.jsx
+++ b/src/menu/components/share/markcomponent/markform/index.jsx
@@ -18,6 +18,9 @@
     // 琛ㄥ崟鎻愪氦鏃舵鏌ヨ緭鍏ュ�兼槸鍚︽纭�
     this.props.form.validateFieldsAndScroll((err, values) => {
       if (!err) {
+        if (values.contrastValue) {
+          values.contrastValue = values.contrastValue.replace(/\t+|\v+|\s+/g, '')
+        }
         this.props.markChange(values)
       }
     })
diff --git a/src/tabviews/custom/components/chart/antv-bar-line/index.jsx b/src/tabviews/custom/components/chart/antv-bar-line/index.jsx
index 5bdf293..0057c07 100644
--- a/src/tabviews/custom/components/chart/antv-bar-line/index.jsx
+++ b/src/tabviews/custom/components/chart/antv-bar-line/index.jsx
@@ -207,7 +207,7 @@
 
     let xc = {label: {
       formatter: (val) => {
-        if (!val || /^\s*$/.test(val)) return val
+        if (!val || /^\s+$/.test(val)) return val
         let _val = `${val}`
         if (_val.length <= limit) return val
         return _val.substring(0, limit) + '...'
diff --git a/src/tabviews/zshare/actionList/normalbutton/index.jsx b/src/tabviews/zshare/actionList/normalbutton/index.jsx
index 425cce5..7ab6d6e 100644
--- a/src/tabviews/zshare/actionList/normalbutton/index.jsx
+++ b/src/tabviews/zshare/actionList/normalbutton/index.jsx
@@ -2866,7 +2866,7 @@
         _item.fieldlen = item.decimal || 0
       } else if (['text', 'textarea', 'linkMain'].includes(_item.type)) {
         _item.value = _item.value + ''
-        _item.value = _item.value.replace(/\t*|\v*/g, '')       // 鍘婚櫎鍒惰〃绗�
+        _item.value = _item.value.replace(/\t+|\v+/g, '')       // 鍘婚櫎鍒惰〃绗�
 
         if (item.interception !== 'false') {                    // 鍘婚櫎棣栧熬绌烘牸
           _item.value = _item.value.replace(/(^\s*|\s*$)/g, '')
diff --git a/src/tabviews/zshare/actionList/printbutton/index.jsx b/src/tabviews/zshare/actionList/printbutton/index.jsx
index 28aa16d..f89c377 100644
--- a/src/tabviews/zshare/actionList/printbutton/index.jsx
+++ b/src/tabviews/zshare/actionList/printbutton/index.jsx
@@ -2167,7 +2167,7 @@
         _item.fieldlen = item.decimal || 0
       } else if (['text', 'textarea', 'linkMain'].includes(_item.type)) {
         _item.value = _item.value + ''
-        _item.value = _item.value.replace(/\t*|\v*/g, '')       // 鍘婚櫎鍒惰〃绗�
+        _item.value = _item.value.replace(/\t+|\v+/g, '')       // 鍘婚櫎鍒惰〃绗�
 
         if (item.interception !== 'false') {                    // 鍘婚櫎棣栧熬绌烘牸
           _item.value = _item.value.replace(/(^\s*|\s*$)/g, '')
diff --git a/src/tabviews/zshare/mutilform/index.jsx b/src/tabviews/zshare/mutilform/index.jsx
index 337129f..0cc3dbd 100644
--- a/src/tabviews/zshare/mutilform/index.jsx
+++ b/src/tabviews/zshare/mutilform/index.jsx
@@ -1151,7 +1151,7 @@
             _item.fieldlen = item.decimal || 0
           } else if (['text', 'textarea', 'linkMain'].includes(item.type)) {
             _item.value = _item.value + ''
-            _item.value = _item.value.replace(/\t*|\v*/g, '')       // 鍘婚櫎鍒惰〃绗�
+            _item.value = _item.value.replace(/\t+|\v+/g, '')       // 鍘婚櫎鍒惰〃绗�
     
             if (item.interception !== 'false') {                    // 鍘婚櫎棣栧熬绌烘牸
               _item.value = _item.value.replace(/(^\s*|\s*$)/g, '')
diff --git a/src/templates/sharecomponent/searchcomponent/searchform/index.jsx b/src/templates/sharecomponent/searchcomponent/searchform/index.jsx
index 3d14095..34b71e8 100644
--- a/src/templates/sharecomponent/searchcomponent/searchform/index.jsx
+++ b/src/templates/sharecomponent/searchcomponent/searchform/index.jsx
@@ -756,7 +756,7 @@
 
           ['linkField', 'valueField', 'valueText', 'orderBy'].forEach(item => {
             if (values[item]) {
-              values[item] = values[item].replace(/\s* | \t* | \v* | \r*/ig, '')
+              values[item] = values[item].replace(/\s+|\t+|\v+|\r+/ig, '')
             }
           })
 
diff --git a/src/templates/zshare/editTable/index.jsx b/src/templates/zshare/editTable/index.jsx
index 205ece1..159a4c8 100644
--- a/src/templates/zshare/editTable/index.jsx
+++ b/src/templates/zshare/editTable/index.jsx
@@ -416,7 +416,9 @@
       columns.forEach(col => {
         if (col.unique !== true || !unique) return
 
-        if (col.strict) {
+        if (col.uniqueFunc) {
+          unique = col.uniqueFunc(data, res.data)
+        } else if (col.strict) {
           let key = res.data[col.dataIndex].toLowerCase()
           let _index = data.findIndex(item => key === item[col.dataIndex].toLowerCase())
 
@@ -455,7 +457,9 @@
         columns.forEach(col => {
           if (col.unique !== true || !unique) return
 
-          if (col.strict) {
+          if (col.uniqueFunc) {
+            unique = col.uniqueFunc(data, cell)
+          } else if (col.strict) {
             let _index = data.findIndex(item => cell[col.dataIndex].toLowerCase() === item[col.dataIndex].toLowerCase())
   
             if (_index > -1) {
@@ -518,15 +522,32 @@
     columns.forEach(col => {
       if (col.unique !== true || !unique) return
 
-      let _index = newData.findIndex(item => record.uuid !== item.uuid && record[col.dataIndex] === item[col.dataIndex])
+      if (col.uniqueFunc) {
+        unique = col.uniqueFunc(newData, record)
+        return
+      } else if (col.strict) {
+        let key = record[col.dataIndex].toLowerCase()
+        let _index = newData.findIndex(item => key === item[col.dataIndex].toLowerCase())
 
-      if (_index > -1) {
-        notification.warning({
-          top: 92,
-          message: col.title + '涓嶅彲閲嶅锛�',
-          duration: 5
-        })
-        unique = false
+        if (_index > -1) {
+          notification.warning({
+            top: 92,
+            message: col.title + '涓嶅彲閲嶅锛�',
+            duration: 5
+          })
+          unique = false
+        }
+      } else {
+        let _index = newData.findIndex(item => record.uuid !== item.uuid && record[col.dataIndex] === item[col.dataIndex])
+  
+        if (_index > -1) {
+          notification.warning({
+            top: 92,
+            message: col.title + '涓嶅彲閲嶅锛�',
+            duration: 5
+          })
+          unique = false
+        }
       }
     })
 
@@ -557,31 +578,49 @@
       }
       const newData = [...this.state.data]
       const index = newData.findIndex(item => uuid === item.uuid)
+      if (index > -1) {
+        row = {...newData[index], ...row}
+      } else {
+        row.uuid = uuid
+      }
 
       let unique = true
       columns.forEach(col => {
         if (col.unique !== true || !unique) return
 
-        let _index = newData.findIndex(item => uuid !== item.uuid && row[col.dataIndex] === item[col.dataIndex])
-
-        if (_index > -1) {
-          notification.warning({
-            top: 92,
-            message: col.title + '涓嶅彲閲嶅锛�',
-            duration: 5
-          })
-          unique = false
+        if (col.uniqueFunc) {
+          unique = col.uniqueFunc(newData, row)
+          return
+        } else if (col.strict) {
+          let key = row[col.dataIndex].toLowerCase()
+          let _index = newData.findIndex(item => key === item[col.dataIndex].toLowerCase())
+  
+          if (_index > -1) {
+            notification.warning({
+              top: 92,
+              message: col.title + '涓嶅彲閲嶅锛�',
+              duration: 5
+            })
+            unique = false
+          }
+        } else {
+          let _index = newData.findIndex(item => row.uuid !== item.uuid && row[col.dataIndex] === item[col.dataIndex])
+  
+          if (_index > -1) {
+            notification.warning({
+              top: 92,
+              message: col.title + '涓嶅彲閲嶅锛�',
+              duration: 5
+            })
+            unique = false
+          }
         }
       })
 
       if (!unique) return
 
       if (index > -1) {
-        const item = newData[index]
-        newData.splice(index, 1, {
-          ...item,
-          ...row,
-        })
+        newData.splice(index, 1, row)
         this.setState({ data: newData, editingKey: '' }, () => {
           this.props.onChange(newData)
         })
diff --git a/src/templates/zshare/modalform/index.jsx b/src/templates/zshare/modalform/index.jsx
index 364f8a2..b49f28b 100644
--- a/src/templates/zshare/modalform/index.jsx
+++ b/src/templates/zshare/modalform/index.jsx
@@ -986,7 +986,7 @@
 
           ['linkField', 'valueField', 'valueText', 'orderBy'].forEach(item => {
             if (values[item]) {
-              values[item] = values[item].replace(/\s*|\t*|\v*|\r*/ig, '')
+              values[item] = values[item].replace(/\s+|\t+|\v+|\r+/ig, '')
             }
           })
 
diff --git a/src/utils/utils.js b/src/utils/utils.js
index 07320a8..bd64787 100644
--- a/src/utils/utils.js
+++ b/src/utils/utils.js
@@ -983,7 +983,7 @@
           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 + '鍐呭涓嶅彲涓虹┖')
@@ -1018,7 +1018,7 @@
             val = moment('19000101', 'YYYYMMDD').add(Math.floor(val - 2), 'days').format('YYYY-MM-DD')
           }
         } else if (typeof(val) === 'string') {
-          val = val.replace(/(^\s*$)|\t*|\v*/ig, '')
+          val = val.replace(/(^\s+$)|\t+|\v+/ig, '')
           if (!val && col.required === 'true') {           // 鏃堕棿蹇呭~鏍¢獙
             errors.push(_position + '鍐呭涓嶅彲涓虹┖')
           } else if (val && !/^[1-9][0-9]{3}/.test(val)) { // 鏃堕棿姝e垯鏍¢獙
diff --git a/src/views/login/logincloudform.jsx b/src/views/login/logincloudform.jsx
index c87cf3f..374ef07 100644
--- a/src/views/login/logincloudform.jsx
+++ b/src/views/login/logincloudform.jsx
@@ -20,8 +20,8 @@
     return new Promise((resolve, reject) => {
       this.props.form.validateFieldsAndScroll((err, values) => {
         if (!err) {
-          values.cloudusername = values.cloudusername.replace(/\t*|\v*|\s*/g, '')
-          values.cloudpassword = values.cloudpassword.replace(/\t*|\v*|\s*/g, '')
+          values.cloudusername = values.cloudusername.replace(/\t+|\v+|\s+/g, '')
+          values.cloudpassword = values.cloudpassword.replace(/\t+|\v+|\s+/g, '')
           resolve(values)
         } else {
           reject(err)
diff --git a/src/views/login/loginform.jsx b/src/views/login/loginform.jsx
index 1645257..a9b5143 100644
--- a/src/views/login/loginform.jsx
+++ b/src/views/login/loginform.jsx
@@ -161,11 +161,11 @@
       this.props.form.validateFieldsAndScroll((err, values) => {
         if (!err) {
           if (activeKey === 'uname_pwd') {
-            values.username = values.username.replace(/\t*|\v*|\s*/g, '')
-            values.password = values.password.replace(/\t*|\v*|\s*/g, '')
+            values.username = values.username.replace(/\t+|\v+|\s+/g, '')
+            values.password = values.password.replace(/\t+|\v+|\s+/g, '')
           } else if (activeKey === 'sms_vcode') {
-            values.phone = values.phone.replace(/\t*|\v*|\s*/g, '')
-            values.vercode = values.vercode.replace(/\t*|\v*|\s*/g, '')
+            values.phone = values.phone.replace(/\t+|\v+|\s+/g, '')
+            values.vercode = values.vercode.replace(/\t+|\v+|\s+/g, '')
           }
           resolve({type: activeKey, ...values})
         } else {

--
Gitblit v1.8.0