From 9c141d3d86f498ae15b0538e389543fc85c4fc39 Mon Sep 17 00:00:00 2001 From: wangailin Date: Thu, 10 Mar 2022 17:23:55 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20=E5=AD=90=E8=A1=A8=E5=8D=95?= =?UTF-8?q?=E9=A1=B9=E6=9C=AA=E5=A1=AB=E5=86=99=E9=A1=B9=E5=85=B7=E4=BD=93?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E6=8F=90=E7=A4=BA=E5=86=85=E5=AE=B9=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=EF=BC=8C=E5=AD=90=E8=A1=A8=E5=8D=95=E9=A1=B9=E9=9A=90?= =?UTF-8?q?=E8=97=8F=E9=A1=B9=E4=B8=8D=E5=81=9A=E8=A1=A8=E5=8D=95=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/formFields/form/index.tsx | 9 ++++++++- src/components/formFields/group/index.tsx | 12 ++++++++++-- src/components/formFields/importSubform/index.tsx | 10 +++++++++- src/components/formFields/tabs/index.tsx | 9 ++++++++- src/steps/form/index.tsx | 1 + 5 files changed, 36 insertions(+), 5 deletions(-) diff --git a/src/components/formFields/form/index.tsx b/src/components/formFields/form/index.tsx index d95ddea..778cdcf 100644 --- a/src/components/formFields/form/index.tsx +++ b/src/components/formFields/form/index.tsx @@ -127,6 +127,7 @@ export default class FormField extends Field = [] const formDataList = cloneDeep(this.state.formDataList) @@ -143,6 +144,10 @@ export default class FormField extends Field 0) { - errors.push(new FieldError(`子项中存在${childrenError}个错误。`)) + const errTips = `${this.props.config.label || ''} ${childrenErrorMsg.map(err => `${err.name}:${err.msg}`).join('; ')}` + errors.push(new FieldError(errTips)) } return errors.length ? errors : true @@ -494,6 +500,7 @@ export default class FormField extends Field = [] const formData = cloneDeep(this.state.formData) for (const fieldIndex in (this.props.config.fields || [])) { const formItem = this.formFields[fieldIndex] + const formConfig = this.props.config.fields?.[fieldIndex] if (formItem !== null && formItem !== undefined) { const validation = await formItem.validate(getValue(value, (this.props.config.fields || [])[fieldIndex].field)) - if (validation === true || this.formFieldsMounted[fieldIndex] === false) { + if (validation === true) { formData[fieldIndex] = { status: 'normal' } } else { childrenError++ formData[fieldIndex] = { status: 'error', message: validation[0].message } + childrenErrorMsg.push({ + name: formConfig?.label, + msg: validation[0].message + }) } } } @@ -88,7 +94,8 @@ export default class GroupField extends Field 0) { - errors.push(new FieldError(`子项中存在${childrenError}个错误。`)) + const errTips = `${this.props.config.label || ''}子项中存在${childrenError}个错误。\n ${childrenErrorMsg.map(err => `${err.name}:${err.msg}`).join('; ')}。` + errors.push(new FieldError(errTips)) } return errors.length ? errors : true @@ -307,6 +314,7 @@ export default class GroupField extends Field { if (!ConditionHelper(formFieldConfig.condition, { record: value, data: this.props.data, step: this.props.step })) { this.formFieldsMounted[formFieldIndex] = false + this.formFields && (this.formFields[formFieldIndex] = null) return null } let hidden: boolean = true diff --git a/src/components/formFields/importSubform/index.tsx b/src/components/formFields/importSubform/index.tsx index 5735eb9..23f933d 100644 --- a/src/components/formFields/importSubform/index.tsx +++ b/src/components/formFields/importSubform/index.tsx @@ -116,11 +116,13 @@ export default class ImportSubformField extends Field = [] const formData = cloneDeep(this.state.formData) for (const fieldIndex in (this.state.fields || [])) { const formItem = this.formFields[fieldIndex] + const formConfig = this.state.fields?.[fieldIndex] if (formItem !== null && formItem !== undefined) { const validation = await formItem.validate(getValue(value, this.getFullpath((this.state.fields || [])[fieldIndex].field))) @@ -129,6 +131,10 @@ export default class ImportSubformField extends Field 0) { - errors.push(new FieldError('子项中存在错误')) + const errTips = `${this.props.config.label || ''}子项中存在${childrenError}个错误。\n ${childrenErrorMsg.map(err => `${err.name}:${err.msg}`).join('; ')}。` + errors.push(new FieldError(errTips)) } return errors.length ? errors : true @@ -375,6 +382,7 @@ export default class ImportSubformField extends Field { if (!ConditionHelper(formFieldConfig.condition, { record: value, data, step })) { this.formFieldsMounted[formFieldIndex] = false + this.formFields && (this.formFields[formFieldIndex] = null) return null } let hidden: boolean = true diff --git a/src/components/formFields/tabs/index.tsx b/src/components/formFields/tabs/index.tsx index a32b115..9167351 100644 --- a/src/components/formFields/tabs/index.tsx +++ b/src/components/formFields/tabs/index.tsx @@ -113,6 +113,7 @@ export default class TabsField extends Field = [] const formDataList = cloneDeep(this.state.formDataList) @@ -133,6 +134,10 @@ export default class TabsField extends Field extends Field 0) { - errors.push(new FieldError(`子项中存在${childrenError}个错误。`)) + const errTips = `${this.props.config.label || ''}子项中存在${childrenError}个错误。\n ${childrenErrorMsg.map(err => `${err.name}:${err.msg}`).join('; ')}。` + errors.push(new FieldError(errTips)) } return errors.length ? errors : true @@ -380,6 +386,7 @@ export default class TabsField extends Field { children: fields.map((formFieldConfig, formFieldIndex) => { if (!ConditionHelper(formFieldConfig.condition, { record: formValue, data, step })) { this.formFieldsMounted[formFieldIndex] = false + this.formFields && (this.formFields[formFieldIndex] = null) return null } let hidden: boolean = true -- Gitee From 1dada1a3d1650a2fb4de1b2617e8931b74c49299 Mon Sep 17 00:00:00 2001 From: wangailin Date: Thu, 14 Apr 2022 15:01:01 +0800 Subject: [PATCH 2/2] =?UTF-8?q?feat:=20=E5=8E=BB=E6=8E=89=E5=AD=90?= =?UTF-8?q?=E9=A1=B9=E4=B8=AD=E5=AD=98=E5=9C=A8=E9=94=99=E8=AF=AF=E6=95=B0?= =?UTF-8?q?=EF=BC=8C=E7=BB=9F=E4=B8=80=E6=96=87=E6=A1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/formFields/group/index.tsx | 2 +- src/components/formFields/importSubform/index.tsx | 2 +- src/components/formFields/object/index.tsx | 2 +- src/components/formFields/tabs/index.tsx | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/formFields/group/index.tsx b/src/components/formFields/group/index.tsx index e97cb98..5fa6f47 100644 --- a/src/components/formFields/group/index.tsx +++ b/src/components/formFields/group/index.tsx @@ -94,7 +94,7 @@ export default class GroupField extends Field 0) { - const errTips = `${this.props.config.label || ''}子项中存在${childrenError}个错误。\n ${childrenErrorMsg.map(err => `${err.name}:${err.msg}`).join('; ')}。` + const errTips = `${this.props.config.label || ''}子项中存在错误。\n ${childrenErrorMsg.map(err => `${err.name}:${err.msg}`).join('; ')}。` errors.push(new FieldError(errTips)) } diff --git a/src/components/formFields/importSubform/index.tsx b/src/components/formFields/importSubform/index.tsx index 23f933d..cdecd33 100644 --- a/src/components/formFields/importSubform/index.tsx +++ b/src/components/formFields/importSubform/index.tsx @@ -144,7 +144,7 @@ export default class ImportSubformField extends Field 0) { - const errTips = `${this.props.config.label || ''}子项中存在${childrenError}个错误。\n ${childrenErrorMsg.map(err => `${err.name}:${err.msg}`).join('; ')}。` + const errTips = `${this.props.config.label || ''}子项中错误。\n ${childrenErrorMsg.map(err => `${err.name}:${err.msg}`).join('; ')}。` errors.push(new FieldError(errTips)) } diff --git a/src/components/formFields/object/index.tsx b/src/components/formFields/object/index.tsx index b0de063..0b2e8fd 100644 --- a/src/components/formFields/object/index.tsx +++ b/src/components/formFields/object/index.tsx @@ -130,7 +130,7 @@ export default class ObjectField extends Field 0) { - errors.push(new FieldError(`子项中存在${childrenError}个错误。`)) + errors.push(new FieldError('子项中存在错误。')) } return errors.length ? errors : true diff --git a/src/components/formFields/tabs/index.tsx b/src/components/formFields/tabs/index.tsx index 9167351..36ab708 100644 --- a/src/components/formFields/tabs/index.tsx +++ b/src/components/formFields/tabs/index.tsx @@ -148,7 +148,7 @@ export default class TabsField extends Field 0) { - const errTips = `${this.props.config.label || ''}子项中存在${childrenError}个错误。\n ${childrenErrorMsg.map(err => `${err.name}:${err.msg}`).join('; ')}。` + const errTips = `${this.props.config.label || ''}子项中存在错误。\n ${childrenErrorMsg.map(err => `${err.name}:${err.msg}`).join('; ')}` errors.push(new FieldError(errTips)) } -- Gitee