From d59f518f466274b2caeb2e01c10c92deafe7c93b Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期三, 09 二月 2022 11:48:29 +0800
Subject: [PATCH] 2022-02-09

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

diff --git a/src/components/normalform/modalform/index.jsx b/src/components/normalform/modalform/index.jsx
index e0927dc..7162b0c 100644
--- a/src/components/normalform/modalform/index.jsx
+++ b/src/components/normalform/modalform/index.jsx
@@ -1,7 +1,8 @@
 import React, {Component} from 'react'
 import PropTypes from 'prop-types'
 import { fromJS } from 'immutable'
-import { Form, Row, Col, Tooltip, Icon, Cascader, Input } from 'antd'
+import { Form, Row, Col, Tooltip, Cascader, Input } from 'antd'
+import { QuestionCircleOutlined } from '@ant-design/icons'
 
 import asyncComponent from '@/utils/asyncComponent'
 import MKEInput from './mkInput'
@@ -12,10 +13,12 @@
 const { TextArea } = Input
 
 const MKRadio = asyncComponent(() => import('./mkRadio'))
+const MKTable = asyncComponent(() => import('./mkTable'))
+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'))
-const MkIcon = asyncComponent(() => import('@/components/mkIcon'))
+const MkEditIcon = asyncComponent(() => import('@/components/mkIcon'))
 const SourceComponent = asyncComponent(() => import('@/menu/components/share/sourcecomponent'))
 
 class ModalForm extends Component {
@@ -64,13 +67,19 @@
           validator: (rule, value, callback) => this.handleConfirmPassword(rule, value, callback, item)
         }]
       } else if (item.type === 'textarea') {
-        let _rules = [
+        item.rules = [
           {
             required: item.required,
             message: item.label + '涓嶅彲涓虹┖!'
           }
         ]
-        item.rules = _rules
+      } else if (item.type === 'table') {
+        item.rules = [
+          {
+            required: item.required,
+            message: '璇锋坊鍔�' + item.label + '!'
+          }
+        ]
       } else {
         item.rules = [
           {
@@ -100,10 +109,19 @@
 
         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.notNull) {
+          cell.hidden = !supItem.initval || JSON.stringify(supItem.initval) === '[]'
+        } else if (!item.values.includes(supItem.initval)) {
+          cell.hidden = true
         }
+        fieldMap.set(item.field, cell)
 
         fields.push(item)
       })
@@ -158,7 +176,21 @@
 
         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 if (cell.notNull) {
+            m.hidden = !val || JSON.stringify(val) === '[]'
+          } else {
+            m.hidden = !cell.values.includes(val)
+          }
 
           if (m.hidden) {
             m.initval = this.record[m.field]
@@ -176,10 +208,17 @@
 
       this.setState({
         formlist: this.state.formlist.map(cell => {
-          if (cell.field) {
-            return map.get(cell.field)
+          if (!cell.field) return cell
+
+          let item = map.get(cell.field)
+
+          if (item && item.linkField) {
+            let supInitVal = this.record[item.linkField] || ''
+            
+            item.options = item.oriOptions.filter(option => option.ParentID === supInitVal)
           }
-          return cell
+
+          return item || cell
         })
       })
     }
@@ -195,7 +234,7 @@
       if (item.hidden || item.forbid) return
 
       let content = null
-      let label = item.tooltip ? <Tooltip placement="topLeft" title={item.tooltip}><Icon type="question-circle" />{item.label}</Tooltip> : item.label
+      let label = item.tooltip ? <Tooltip placement="topLeft" title={item.tooltip}><QuestionCircleOutlined className="mk-form-tip" />{item.label}</Tooltip> : item.label
     
       if (item.type === 'text') {
         content = (<MKEInput config={item} onChange={(val, defer) => !defer && this.recordChange({[item.field]: val})} onSubmit={this.props.inputSubmit} />)
@@ -209,16 +248,20 @@
         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} onChange={(val) => this.recordChange({[item.field]: val}, item)} 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 allowClear={item.allowClear}/>)
+        content = (<MkEditIcon allowClear={item.allowClear}/>)
       } else if (item.type === 'source') {
         content = (<SourceComponent type="" placement="right"/>)
+      } else if (item.type === 'table') {
+        content = (<MKTable columns={item.columns || []}/>)
       }
 
       if (!content) return

--
Gitblit v1.8.0