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 | 63 +++++++++++++++++++++++++++---- 1 files changed, 55 insertions(+), 8 deletions(-) diff --git a/src/components/normalform/modalform/index.jsx b/src/components/normalform/modalform/index.jsx index 9ad6f5d..b8d4c89 100644 --- a/src/components/normalform/modalform/index.jsx +++ b/src/components/normalform/modalform/index.jsx @@ -1,7 +1,7 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' -// import { fromJS } from 'immutable' -import { Form, Row, Col, Tooltip, Icon, Cascader } from 'antd' +import { fromJS } from 'immutable' +import { Form, Row, Col, Tooltip, Icon, Cascader, Input } from 'antd' import asyncComponent from '@/utils/asyncComponent' import MKEInput from './mkInput' @@ -9,10 +9,15 @@ import MKSelect from './mkSelect' import './index.scss' +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')) +const MkIcon = asyncComponent(() => import('@/components/mkIcon')) +const SourceComponent = asyncComponent(() => import('@/menu/components/share/sourcecomponent')) class ModalForm extends Component { static propTpyes = { @@ -37,6 +42,13 @@ } item.hidden = false + + if (item.forbid) { + item.hidden = true + } + if (item.options) { + item.oriOptions = fromJS(item.options).toJS() + } if (item.type === 'text') { let _rules = [{ @@ -89,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) }) @@ -103,7 +122,15 @@ }) formlist = formlist.map(cell => { - return fieldMap.get(cell.field) || cell + let item = fieldMap.get(cell.field) + + if (item.linkField) { + let supInitVal = fieldMap.get(item.linkField).initval || '' + + item.options = item.oriOptions.filter(option => option.ParentID === supInitVal) + } + + return item }) this.record = record @@ -139,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] @@ -173,7 +212,7 @@ const fields = [] formlist.forEach((item, index) => { - if (item.hidden) return + 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 @@ -190,10 +229,18 @@ 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 allowClear={item.allowClear}/>) + } else if (item.type === 'source') { + content = (<SourceComponent type="" placement="right"/>) } if (!content) return -- Gitblit v1.8.0