From aa53227bc006816a30258c6390084aa74defb4d1 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期一, 27 十一月 2023 18:05:55 +0800
Subject: [PATCH] 2023-11-27

---
 src/components/normalform/modalform/index.jsx |   20 +++++++++++++-------
 1 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/src/components/normalform/modalform/index.jsx b/src/components/normalform/modalform/index.jsx
index 2b9b80c..33b243c 100644
--- a/src/components/normalform/modalform/index.jsx
+++ b/src/components/normalform/modalform/index.jsx
@@ -7,6 +7,7 @@
 import asyncComponent from '@/utils/asyncComponent'
 import MKEInput from './mkInput'
 import MKNumberInput from './mkNumberInput'
+import MKEmitter from '@/utils/events.js'
 import MKSelect from './mkSelect'
 import './index.scss'
 
@@ -23,8 +24,9 @@
 
 class ModalForm extends Component {
   static propTpyes = {
-    formlist: PropTypes.array,   // 琛ㄥ崟鍒楄〃
-    inputSubmit: PropTypes.func  // input鍥炶溅鎻愪氦
+    formlist: PropTypes.array,
+    inputSubmit: PropTypes.func,
+    transVals: PropTypes.func,
   }
 
   state = {
@@ -108,7 +110,7 @@
       let supItem = fieldMap.get(key)
       let supval = supItem.initval
 
-      if (supItem.initval && supItem.type !== 'checkbox' && JSON.stringify(supItem.initval) === '[]') {
+      if (supItem.initval && supItem.type !== 'checkbox' && supItem.type !== 'multiselect' && JSON.stringify(supItem.initval) === '[]') {
         supval = ''
       }
 
@@ -124,7 +126,7 @@
 
         } else if (supItem.hidden) {
           cell.hidden = true
-        } else if (supItem.type === 'checkbox') {
+        } else if (supItem.type === 'checkbox' || supItem.type === 'multiselect') {
           let vals = [...supval, ...item.values]
           if (vals.length === new Set(vals).size) {
             cell.hidden = true
@@ -179,6 +181,10 @@
     this.record = {...this.record, ...values}
 
     if (!item) return
+
+    if (item.$trans) {
+      this.props.transVals && this.props.transVals(values, item.field)
+    }
     
     if (item.controlFields) {
       let map = new Map()
@@ -190,7 +196,7 @@
       let reset = (current) => {
         let val = this.record[current.field]
 
-        if (val && current.type !== 'checkbox' && JSON.stringify(val) === '[]') {
+        if (val && current.type !== 'checkbox' && current.type !== 'multiselect' && JSON.stringify(val) === '[]') {
           val = ''
         }
 
@@ -199,7 +205,7 @@
 
           if (current.hidden) {
             m.hidden = true
-          } else if (current.type === 'checkbox') {
+          } else if (current.type === 'checkbox' || current.type === 'multiselect') {
             let vals = [...val, ...cell.values]
             if (vals.length !== new Set(vals).size) {
               m.hidden = false
@@ -248,7 +254,7 @@
         map.set(cell.field, cell)
       })
 
-      item.callback(map, this.record)
+      item.callback(map, this.record, MKEmitter)
 
       this.setState({
         formlist: this.state.formlist.map(cell => {

--
Gitblit v1.8.0