From f3d4db769ba9b51b799d981511a710fd443d0e08 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期一, 21 四月 2025 12:18:03 +0800 Subject: [PATCH] Merge branch 'master' into positec --- src/components/normalform/modalform/index.jsx | 89 ++++++++++++++++++++++++++++++++------------ 1 files changed, 65 insertions(+), 24 deletions(-) diff --git a/src/components/normalform/modalform/index.jsx b/src/components/normalform/modalform/index.jsx index 8a7599f..5b1cb47 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' @@ -23,6 +22,7 @@ // const MKColor = asyncComponent(() => import('@/tabviews/zshare/mutilform/mkColor')) const MkEditIcon = asyncComponent(() => import('@/components/mkIcon')) const SourceComponent = asyncComponent(() => import('@/menu/components/share/sourcecomponent')) +const CodeMirror = asyncComponent(() => import('@/templates/zshare/codemirror')) class ModalForm extends Component { static propTpyes = { @@ -33,6 +33,7 @@ state = { formlist: [], // 琛ㄥ崟椤� + formId: '' } record = {} @@ -41,6 +42,15 @@ let record = {} let controlFields = {} let fieldMap = new Map() + let formId = (() => { + let uuid = [] + let _options = '0123456789abcdefghigklmnopqrstuv' + for (let i = 0; i < 19; i++) { + uuid.push(_options.substr(Math.floor(Math.random() * 0x20), 1)) + } + uuid = uuid.join('') + return uuid + })() let formlist = this.props.formlist.filter(item => { if (item.controlFields) { // 澶氬眰琛ㄥ崟鎺у埗 @@ -57,6 +67,7 @@ if (item.options) { item.oriOptions = fromJS(item.options).toJS() } + item.$formId = formId if (item.type === 'text') { let _rules = [{ @@ -122,10 +133,11 @@ let cell = fieldMap.get(item.field) - if (cell.hidden) return + cell.$ctrls = cell.$ctrls || [] + cell.$ctrls.push(key) - if (cell.skip && supItem.forbid) { // 涓婄骇琛ㄥ崟绂佺敤鏃讹紝姝よ〃鍗曚笉鍙楁帶鍒� - + if (cell.hidden) { + } else if (supItem.hidden) { cell.hidden = true } else if (item.notNull) { @@ -152,10 +164,14 @@ formlist = formlist.map(cell => { let item = fieldMap.get(cell.field) + if (item.$ctrls && item.$ctrls.length === 1) { + delete item.$ctrls + } + 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 @@ -163,7 +179,7 @@ this.record = record - this.setState({ formlist }) + this.setState({ formlist, formId }) } checkNumber = (rule, value, callback, item) => { @@ -220,6 +236,32 @@ m.hidden = !cell.values.includes(val) } + if (!m.hidden && m.$ctrls) { + m.$ctrls.forEach(n => { + if (n === current.field || m.hidden) return + + let oth = map.get(n) + let _val = this.record[n] + + if (_val && JSON.stringify(_val) === '[]') { + _val = '' + } + + let p = oth.controlFields.filter(q => q.field === m.field)[0] + + if (oth.hidden || (p.notNull && !_val)) { + m.hidden = true + } else if (oth.type === 'checkbox' || oth.type === 'multiselect') { + let _vals = [...(_val || []), ...p.values] + if (_vals.length === new Set(_vals).size) { + m.hidden = true + } + } else if (p.values && !p.values.includes(_val)) { + m.hidden = true + } + }) + } + if (m.hidden) { m.initval = this.record[m.field] } @@ -243,30 +285,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 + }) }) - }) + } } } @@ -324,6 +363,8 @@ return } else if (item.type === 'printTemps') { content = <MkPrintTemps onChange={(val) => this.recordChange({[item.field]: val})}/> + } else if (item.type === 'codemirror') { + content = <CodeMirror mode="text/javascript" theme="cobalt" onChange={(val) => this.recordChange({[item.field]: val})}/> } if (!content) return @@ -389,7 +430,7 @@ } return ( - <Form {...formItemLayout} className="normal-form-field"> + <Form {...formItemLayout} className="normal-form-field" id={this.state.formId}> <Row gutter={24}>{this.getFields()}</Row> </Form> ) -- Gitblit v1.8.0