From c7aece35a62b6e91fd98a625bf0e53f64bfbd18d Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 17 八月 2023 16:22:15 +0800 Subject: [PATCH] 2023-08-17 --- src/components/normalform/modalform/index.jsx | 94 ++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 76 insertions(+), 18 deletions(-) diff --git a/src/components/normalform/modalform/index.jsx b/src/components/normalform/modalform/index.jsx index 7162b0c..2b9b80c 100644 --- a/src/components/normalform/modalform/index.jsx +++ b/src/components/normalform/modalform/index.jsx @@ -45,6 +45,8 @@ item.hidden = false + if (item.forbid && item.del) return false + if (item.forbid) { item.hidden = true } @@ -57,6 +59,10 @@ required: item.required, message: item.label + '涓嶅彲涓虹┖!' }] + + if (item.rules) { + _rules.push(...item.rules) + } item.rules = _rules } else if (item.type === 'number') { @@ -100,8 +106,13 @@ if (!fieldMap.has(key)) return let supItem = fieldMap.get(key) + let supval = supItem.initval + + if (supItem.initval && supItem.type !== 'checkbox' && JSON.stringify(supItem.initval) === '[]') { + supval = '' + } + let fields = [] - controlFields[key].forEach(item => { if (!fieldMap.has(item.field)) return @@ -109,18 +120,21 @@ if (cell.hidden) return - if (supItem.hidden) { + if (cell.skip && supItem.forbid) { // 涓婄骇琛ㄥ崟绂佺敤鏃讹紝姝よ〃鍗曚笉鍙楁帶鍒� + + } else if (supItem.hidden) { cell.hidden = true } else if (supItem.type === 'checkbox') { - let vals = [...supItem.initval, ...item.values] + let vals = [...supval, ...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 = !supval + } else if (!item.values.includes(supval)) { cell.hidden = true } + fieldMap.set(item.field, cell) fields.push(item) @@ -164,7 +178,9 @@ recordChange = (values, item) => { this.record = {...this.record, ...values} - if (item && item.controlFields) { + if (!item) return + + if (item.controlFields) { let map = new Map() this.state.formlist.forEach(cell => { if (!cell.field) return @@ -173,6 +189,10 @@ let reset = (current) => { let val = this.record[current.field] + + if (val && current.type !== 'checkbox' && JSON.stringify(val) === '[]') { + val = '' + } current.controlFields.forEach(cell => { let m = map.get(cell.field) @@ -187,7 +207,7 @@ m.hidden = true } } else if (cell.notNull) { - m.hidden = !val || JSON.stringify(val) === '[]' + m.hidden = !val } else { m.hidden = !cell.values.includes(val) } @@ -217,6 +237,24 @@ item.options = item.oriOptions.filter(option => option.ParentID === supInitVal) } + + 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) + + this.setState({ + formlist: this.state.formlist.map(cell => { + if (!cell.field) return cell + + let item = map.get(cell.field) return item || cell }) @@ -261,21 +299,41 @@ } else if (item.type === 'source') { content = (<SourceComponent type="" placement="right"/>) } else if (item.type === 'table') { - content = (<MKTable columns={item.columns || []}/>) + content = (<MKTable tip={item.tip || ''} fixed={item.fixed === true} columns={item.columns || []} actions={item.actions || []}/>) + } else if (item.type === 'hint') { + fields.push( + <Col span={24} key={index}> + <div style={{color: '#1890ff', borderBottom: '1px solid #e9e9e9', marginBottom: '15px', paddingLeft: '10px'}}>{item.label}</div> + </Col> + ) + return } if (!content) return - fields.push( - <Col span={item.span || 12} key={index}> - <Form.Item label={label}> - {getFieldDecorator(item.field, { - initialValue: item.initval, - rules: item.rules - })(content)} - </Form.Item> - </Col> - ) + if (item.help) { + fields.push( + <Col span={item.span || 12} key={index}> + <Form.Item label={label} help={<span style={{fontSize: '12px'}}>{item.help}</span>}> + {getFieldDecorator(item.field, { + initialValue: item.initval, + rules: item.rules + })(content)} + </Form.Item> + </Col> + ) + } else { + fields.push( + <Col span={item.span || 12} key={index}> + <Form.Item label={label}> + {getFieldDecorator(item.field, { + initialValue: item.initval, + rules: item.rules + })(content)} + </Form.Item> + </Col> + ) + } }) return fields -- Gitblit v1.8.0