From c7df5603e14b98d6f80da425fab31d30574ca417 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 22 一月 2021 19:10:18 +0800 Subject: [PATCH] 2021-01-22 --- src/tabviews/zshare/mutilform/index.jsx | 62 ++++++++++++++++++++---------- 1 files changed, 41 insertions(+), 21 deletions(-) diff --git a/src/tabviews/zshare/mutilform/index.jsx b/src/tabviews/zshare/mutilform/index.jsx index d7c2ba4..aee32e1 100644 --- a/src/tabviews/zshare/mutilform/index.jsx +++ b/src/tabviews/zshare/mutilform/index.jsx @@ -228,6 +228,10 @@ if (['select', 'link', 'multiselect', 'radio', 'checkbox', 'checkcard'].includes(item.type) && item.resourceType === '1') { deForms.push(item) + } else if (['select', 'link', 'radio'].includes(item.type) && item.resourceType !== '1') { // 閫変腑绗竴椤� + if (item.initval.indexOf('$first') > -1) { + item.initval = item.options[0] ? item.options[0].Value : '' + } } return item @@ -449,6 +453,7 @@ } return item }) + let values = [] this.setState({ formlist: _formlist.map(item => { @@ -457,8 +462,21 @@ } else if (['select', 'multiselect', 'radio', 'checkbox', 'checkcard'].includes(item.type)) { item.options = item.oriOptions } + if (['select', 'link', 'radio'].includes(item.type) && item.initval.indexOf('$first') > -1) { // 閫変腑绗竴椤� + item.initval = item.options[0] ? item.options[0].Value : '' + values.push({field: item.field, value: item.initval}) + } return item }) + }, () => { + if (values.length === 0) return + let fieldsvalue = {} + values.forEach(item => { + if (this.props.form.getFieldValue(item.field) !== undefined) { + fieldsvalue[item.field] = item.value + } + }) + this.props.form.setFieldsValue(fieldsvalue) }) }) } @@ -542,6 +560,7 @@ } return item }) + let values = [] this.setState({ formlist: _formlist.map(item => { @@ -550,8 +569,21 @@ } else if (['select', 'multiselect', 'radio', 'checkbox', 'checkcard'].includes(item.type)) { item.options = item.oriOptions } + if (['select', 'link', 'radio'].includes(item.type) && item.initval.indexOf('$first') > -1) { // 閫変腑绗竴椤� + item.initval = item.options[0] ? item.options[0].Value : '' + values.push({field: item.field, value: item.initval}) + } return item }) + }, () => { + if (values.length === 0) return + let fieldsvalue = {} + values.forEach(item => { + if (this.props.form.getFieldValue(item.field) !== undefined) { + fieldsvalue[item.field] = item.value + } + }) + this.props.form.setFieldsValue(fieldsvalue) }) }) } @@ -621,30 +653,18 @@ } if (subfields.length === 0) { - if (Object.keys(fieldsvalue).length > 0) { - this.props.form.setFieldsValue(fieldsvalue) - } - if (Object.keys(_record).length > 0) { - this.setState({ - record: {...record, ..._record} - }) - } + this.props.form.setFieldsValue(fieldsvalue) + this.setState({ + record: {...record, ..._record} + }) } else { let result = this.resetform(formlist, subfields, 0, fieldsvalue) - if (Object.keys(result.fieldsvalue).length > 0) { - this.props.form.setFieldsValue(fieldsvalue) - } - - let _param = { - formlist: result.formlist - } - - if (Object.keys(_record).length > 0) { - _param.record = {...record, ..._record} - } - - this.setState(_param) + this.props.form.setFieldsValue(fieldsvalue) + this.setState({ + formlist: result.formlist, + record: {...record, ..._record} + }) } this.setState({}, () => { -- Gitblit v1.8.0