From a29d9d644a2a30e9ef4afcc6d728c20c218dc359 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期四, 15 六月 2023 14:25:28 +0800
Subject: [PATCH] 2023-06-15

---
 src/tabviews/zshare/mutilform/mkCheckCard/index.jsx |   35 +++++++++++++++++++++++++++++++++--
 1 files changed, 33 insertions(+), 2 deletions(-)

diff --git a/src/tabviews/zshare/mutilform/mkCheckCard/index.jsx b/src/tabviews/zshare/mutilform/mkCheckCard/index.jsx
index 74100ed..9d9cb2c 100644
--- a/src/tabviews/zshare/mutilform/mkCheckCard/index.jsx
+++ b/src/tabviews/zshare/mutilform/mkCheckCard/index.jsx
@@ -23,8 +23,11 @@
     let config = fromJS(this.props.config).toJS()
 
     let selectKeys = config.initval
+    let initlength = 0
     if (config.multiple === 'true') {
       selectKeys = config.initval ? config.initval.split(',') : []
+      initlength = selectKeys.length
+      selectKeys = this.filterVals(config.options, selectKeys)
     }
 
     if (!config.selectStyle && config.backgroundColor) {
@@ -44,6 +47,10 @@
       config: config,
       options: fromJS(config.options).toJS(),
       selectKeys: selectKeys
+    }, () => {
+      if (config.multiple === 'true' && selectKeys.length < initlength) {
+        this.props.onChange(selectKeys.join(','))
+      }
     })
   }
 
@@ -60,9 +67,20 @@
   }
 
   UNSAFE_componentWillReceiveProps (nextProps) {
-    const { config } = this.state
+    const { config, selectKeys } = this.state
 
     if (!is(fromJS(config.oriOptions), fromJS(nextProps.config.oriOptions))) {
+      if (config.multiple === 'true') {
+        let keys = this.filterVals(nextProps.config.options, fromJS(selectKeys).toJS())
+        if (keys.length < selectKeys.length) {
+          this.setState({
+            selectKeys: keys
+          }, () => {
+            this.props.onChange(keys.join(','))
+          })
+        }
+      }
+
       this.setState({
         config: {...config, oriOptions: nextProps.config.oriOptions},
         options: fromJS(nextProps.config.options).toJS()
@@ -75,6 +93,16 @@
       return
     }
     MKEmitter.removeListener('mkFP', this.mkFormHandle)
+  }
+
+  filterVals = (options, vals) => {
+    if (options.length === 0 || vals.length === 0) return vals
+
+    let ops = options.map(item => item.$value)
+
+    vals = vals.filter(val => ops.includes(val))
+
+    return vals
   }
 
   mkFormHandle = (uuid, parentId, level) => {
@@ -191,7 +219,7 @@
         }
 
         return <Col span={width} key={item.key}>
-          <div className={'card-color-cell' + (_active ? ' active' : '') + (item.$disabled ? ' disabled' : '')} style={{background: item.$value}} onClick={() => this.changeCard(item)}>
+          <div className={'card-color-cell' + (_active ? ' active' : '') + (item.$disabled ? ' disabled' : '')} style={{background: item.$color}} onClick={() => this.changeCard(item)}>
             {fields.map(col => {
               return <span className="content-line" key={col.key} style={{color: col.color, fontSize: col.fontSize + 'px', height: col.fontSize * 1.5 + 'px', textAlign: col.align}}>{item[col.field]}</span>
             })}
@@ -261,6 +289,9 @@
     if (options.length * config.width > 24) {
       extend += ' mutile-line'
     }
+    if (config.border === 'hide') {
+      extend += ' border-hide'
+    }
 
     return (
       <div className={'check-card-form-box ' + extend}>

--
Gitblit v1.8.0