From 432b788acf901b0720184b8ee8bc81a2e6fa47e0 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期二, 28 九月 2021 18:22:02 +0800
Subject: [PATCH] 2021-09-28

---
 src/components/normalform/modalform/index.jsx |   32 +++++++++++++++++++++++++++-----
 1 files changed, 27 insertions(+), 5 deletions(-)

diff --git a/src/components/normalform/modalform/index.jsx b/src/components/normalform/modalform/index.jsx
index 5420d00..b8d4c89 100644
--- a/src/components/normalform/modalform/index.jsx
+++ b/src/components/normalform/modalform/index.jsx
@@ -12,6 +12,7 @@
 const { TextArea } = Input
 
 const MKRadio = asyncComponent(() => import('./mkRadio'))
+const MKCheckbox = asyncComponent(() => import('./mkCheckbox'))
 const StyleInput = asyncComponent(() => import('./styleInput'))
 const MKFileUpload = asyncComponent(() => import('@/tabviews/zshare/fileupload'))
 const MKColor = asyncComponent(() => import('@/tabviews/zshare/mutilform/mkColor'))
@@ -100,10 +101,17 @@
 
         if (cell.hidden) return
 
-        if (supItem.hidden || !item.values.includes(supItem.initval)) {
+        if (supItem.hidden) {
           cell.hidden = true
-          fieldMap.set(item.field, cell)
+        } else if (supItem.type === 'checkbox') {
+          let vals = [...supItem.initval, ...item.values]
+          if (vals.length === new Set(vals).size) {
+            cell.hidden = true
+          }
+        } else if (!item.values.includes(supItem.initval)) {
+          cell.hidden = true
         }
+        fieldMap.set(item.field, cell)
 
         fields.push(item)
       })
@@ -158,7 +166,19 @@
 
         current.controlFields.forEach(cell => {
           let m = map.get(cell.field)
-          m.hidden = current.hidden || !cell.values.includes(val)
+
+          if (current.hidden) {
+            m.hidden = true
+          } else if (current.type === 'checkbox') {
+            let vals = [...val, ...cell.values]
+            if (vals.length !== new Set(vals).size) {
+              m.hidden = false
+            } else {
+              m.hidden = true
+            }
+          } else {
+            m.hidden = !cell.values.includes(val)
+          }
 
           if (m.hidden) {
             m.initval = this.record[m.field]
@@ -209,14 +229,16 @@
         content = (<StyleInput config={item} onChange={(val) => this.recordChange({[item.field]: val})}/>)
       } else if (item.type === 'radio') {
         content = (<MKRadio config={item} onChange={(val, other) => this.recordChange({[item.field]: val, ...other}, item)}/>)
+      } else if (item.type === 'checkbox') {
+        content = (<MKCheckbox config={item} onChange={(val) => this.recordChange({[item.field]: val}, item)}/>)
       } else if (item.type === 'fileupload') {
         content = (<MKFileUpload config={item} onChange={(val) => this.recordChange({[item.field]: val})} />)
       } else if (item.type === 'cascader') {
-        content = (<Cascader options={item.options} expandTrigger="hover" placeholder="" />)
+        content = (<Cascader allowClear={!!item.allowClear} options={item.options} expandTrigger="hover" placeholder="" />)
       } else if (item.type === 'textarea') {
         content = (<TextArea rows={item.rows || 2} placeholder=""/>)
       } else if (item.type === 'mkicon') {
-        content = (<MkIcon />)
+        content = (<MkIcon allowClear={item.allowClear}/>)
       } else if (item.type === 'source') {
         content = (<SourceComponent type="" placement="right"/>)
       }

--
Gitblit v1.8.0