From b6c7f588b831d6fa4eb23b50ec08ea0b263a0717 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期一, 17 六月 2024 20:27:56 +0800 Subject: [PATCH] 2024-06-17 --- src/components/normalform/modalform/index.jsx | 62 ++++++++++++++++++------------ 1 files changed, 37 insertions(+), 25 deletions(-) diff --git a/src/components/normalform/modalform/index.jsx b/src/components/normalform/modalform/index.jsx index aafd7bf..e30a12a 100644 --- a/src/components/normalform/modalform/index.jsx +++ b/src/components/normalform/modalform/index.jsx @@ -7,7 +7,6 @@ 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' @@ -18,6 +17,7 @@ const MKCheckbox = asyncComponent(() => import('./mkCheckbox')) const StyleInput = asyncComponent(() => import('./styleInput')) const MKFileUpload = asyncComponent(() => import('@/tabviews/zshare/fileupload')) +const MkPrintTemps = asyncComponent(() => import('@/menu/components/share/actioncomponent/actionform/mkPrintTemps')) const MKColor = asyncComponent(() => import('@/mob/colorsketch')) // const MKColor = asyncComponent(() => import('@/tabviews/zshare/mutilform/mkColor')) const MkEditIcon = asyncComponent(() => import('@/components/mkIcon')) @@ -154,7 +154,7 @@ if (item.linkField) { let supInitVal = fieldMap.get(item.linkField).initval || '' - item.options = item.oriOptions.filter(option => option.ParentID === supInitVal) + item.options = item.oriOptions.filter(option => option.ParentID === supInitVal || option.ParentID === '') } return item @@ -242,30 +242,27 @@ if (item && item.linkField) { let supInitVal = this.record[item.linkField] || '' - item.options = item.oriOptions.filter(option => option.ParentID === supInitVal) + item.options = item.oriOptions.filter(option => option.ParentID === supInitVal || option.ParentID === '') } return item || cell }) }) } else if (item.reset_source) { - let map = new Map() - this.state.formlist.forEach(cell => { - if (!cell.field) return - map.set(cell.field, cell) - }) - - item.callback(map, this.record, MKEmitter) - - this.setState({ - formlist: this.state.formlist.map(cell => { - if (!cell.field) return cell - - let item = map.get(cell.field) - - return item || cell + let reOptions = item.callback(this.record) + + if (reOptions) { + this.setState({ + formlist: this.state.formlist.map(cell => { + if (!cell.field || !reOptions[cell.field]) return cell + + cell.options = reOptions[cell.field] + cell.timestamp = new Date().getTime() + + return cell + }) }) - }) + } } } @@ -279,12 +276,19 @@ if (item.hidden || item.forbid) return let content = null - let label = item.tooltip ? <Tooltip placement="topLeft" title={item.tooltip}><QuestionCircleOutlined className="mk-form-tip" />{item.label}</Tooltip> : item.label + let label = item.label + if (item.tooltip) { + if (item.toolWidth) { + label = <Tooltip placement="topLeft" overlayStyle={{maxWidth: item.toolWidth}} title={<div onClick={(e) => e.stopPropagation()}>{item.tooltip}</div>}><QuestionCircleOutlined className="mk-form-tip" />{item.label}</Tooltip> + } else { + label = <Tooltip placement="topLeft" title={<div onClick={(e) => e.stopPropagation()}>{item.tooltip}</div>}><QuestionCircleOutlined className="mk-form-tip" />{item.label}</Tooltip> + } + } if (item.type === 'text') { - content = (<MKEInput config={item} onChange={(val, defer) => !defer && this.recordChange({[item.field]: val})} onSubmit={this.props.inputSubmit} />) + content = (<MKEInput config={item} onChange={(val, defer) => !defer && this.recordChange({[item.field]: val}, item)} onSubmit={this.props.inputSubmit} />) } else if (item.type === 'number') { - content = (<MKNumberInput config={item} onChange={(val, defer) => !defer && this.recordChange({[item.field]: val})} onSubmit={this.props.inputSubmit} />) + content = (<MKNumberInput config={item} onChange={(val, defer) => !defer && this.recordChange({[item.field]: val}, item)} onSubmit={this.props.inputSubmit} />) } else if (item.type === 'select' || item.type === 'multiselect') { content = (<MKSelect config={item} onChange={(val, other) => this.recordChange({[item.field]: val, ...other}, item)} />) } else if (item.type === 'color') { @@ -306,7 +310,7 @@ } else if (item.type === 'source') { content = (<SourceComponent type="" placement="right"/>) } else if (item.type === 'table') { - content = (<MKTable tip={item.tip || ''} fixed={item.fixed === true} columns={item.columns || []} actions={item.actions || []}/>) + content = (<MKTable tip={item.tip || ''} columns={item.columns || []} actions={item.actions || []}/>) } else if (item.type === 'hint') { fields.push( <Col span={24} key={index}> @@ -314,14 +318,22 @@ </Col> ) return + } else if (item.type === 'printTemps') { + content = <MkPrintTemps onChange={(val) => this.recordChange({[item.field]: val})}/> } if (!content) return if (item.help) { + let help = null + if (typeof(item.help) === 'function') { + help = item.help(this.record) + } else { + help = <span style={{fontSize: '12px'}}>{item.help}</span> + } fields.push( <Col span={item.span || 12} key={index}> - <Form.Item label={label} help={<span style={{fontSize: '12px'}}>{item.help}</span>}> + <Form.Item label={label} help={help}> {getFieldDecorator(item.field, { initialValue: item.initval, rules: item.rules @@ -373,7 +385,7 @@ } return ( - <Form {...formItemLayout} className="normal-form-field"> + <Form {...formItemLayout} className="normal-form-field" id="normal-form-field"> <Row gutter={24}>{this.getFields()}</Row> </Form> ) -- Gitblit v1.8.0