From b021c0b56c3dbef7266b8abe530b482b33c14d69 Mon Sep 17 00:00:00 2001 From: wangailin Date: Mon, 24 Jan 2022 17:13:56 +0800 Subject: [PATCH 01/10] =?UTF-8?q?feat:=20=E8=AF=A6=E6=83=85=E9=A1=B5?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=98=AF=E5=90=A6=E5=BC=80=E5=90=AF=E5=88=86?= =?UTF-8?q?=E6=A0=8F=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/detail/group/index.tsx | 1 + src/steps/detail/index.tsx | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/detail/group/index.tsx b/src/components/detail/group/index.tsx index 6d0dcf1..879b315 100644 --- a/src/components/detail/group/index.tsx +++ b/src/components/detail/group/index.tsx @@ -223,6 +223,7 @@ export default class GroupField extends DetailField {this.renderComponent({ + columns: config?.columns?.enable ? config.columns : undefined, children: (this.props.config.fields || []).map((detailFieldConfig, detailFieldIndex) => { if (!ConditionHelper(detailFieldConfig.condition, { record: value, data: this.props.data, step: this.props.step })) { this.detailFieldsMounted[detailFieldIndex] = false diff --git a/src/steps/detail/index.tsx b/src/steps/detail/index.tsx index 3823d28..7074e70 100644 --- a/src/steps/detail/index.tsx +++ b/src/steps/detail/index.tsx @@ -399,8 +399,8 @@ export default class DetailStep extends Step { {/* 渲染表单 */} {this.renderComponent({ layout, + columns: config.columns?.enable ? config.columns : undefined, onBack: this.props.config.hiddenBack ? undefined : async () => this.handleCancel(), - columns: config.columns, backText: this.props.config?.backText?.replace(/(^\s*)|(\s*$)/g, ''), children: fields.map((detailFieldConfig, detailFieldIndex) => { if (!ConditionHelper(detailFieldConfig.condition, { record: detailValue, data, step })) { -- Gitee From bdb5e9eb2f57c62c64d5d3a0cdccf8e86080155a Mon Sep 17 00:00:00 2001 From: wangailin Date: Mon, 24 Jan 2022 18:44:05 +0800 Subject: [PATCH 02/10] =?UTF-8?q?feat:=20=E8=A1=A5=E5=85=85=E8=AF=A6?= =?UTF-8?q?=E6=83=85=E5=88=86=E6=A0=8F=E6=B7=BB=E5=8A=A0=E5=BC=80=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/detail/group/index.tsx | 11 +++++----- src/components/detail/importSubform/index.tsx | 11 ++++++++++ src/steps/detail/index.tsx | 20 ++++++++++--------- 3 files changed, 28 insertions(+), 14 deletions(-) diff --git a/src/components/detail/group/index.tsx b/src/components/detail/group/index.tsx index 879b315..47cc62d 100644 --- a/src/components/detail/group/index.tsx +++ b/src/components/detail/group/index.tsx @@ -10,6 +10,7 @@ import { ColumnsConfig } from '../../../interface' export interface GroupFieldConfig extends DetailFieldConfig { type: 'group' fields: DetailFieldConfigs[] + childColumns?: ColumnsConfig } export interface IGroupField { @@ -249,11 +250,11 @@ export default class GroupField extends DetailField {this.renderComponent({ + columns: config?.columns?.enable ? config.columns : undefined, children: this.state.didMount ? fields.map((formFieldConfig, formFieldIndex) => { if (!ConditionHelper(formFieldConfig.condition, { record: value, data, step })) { @@ -222,6 +224,15 @@ export default class ImportSubformField extends DetailField { * 初始化表单的值 * @param props */ - constructor (props: StepProps) { + constructor(props: StepProps) { super(props) this.state = { ready: false, @@ -373,7 +373,7 @@ export default class DetailStep extends Step { } - render () { + render() { const { config, data, @@ -432,13 +432,15 @@ export default class DetailStep extends Step { label: detailFieldConfig.label, // status: detailFieldConfig.field !== undefined ? getValue(detailData, detailFieldConfig.field, {}).status || 'normal' : 'normal', // message: detailFieldConfig.field !== undefined ? getValue(detailData, detailFieldConfig.field, {}).message || '' : '', - columns: { - type: detailFieldConfig.columns?.type || config.columns?.type || 'span', - value: detailFieldConfig.columns?.value || config.columns?.value || 1, - wrap: detailFieldConfig.columns?.wrap || config.columns?.wrap || false, - gap: detailFieldConfig.columns?.gap || config.columns?.gap || 0, - rowGap: detailFieldConfig.columns?.rowGap || config.columns?.rowGap || 0 - }, + columns: config.columns?.enable + ? { + type: detailFieldConfig.columns?.type || config.columns?.type || 'span', + value: detailFieldConfig.columns?.value || config.columns?.value || 1, + wrap: detailFieldConfig.columns?.wrap || config.columns?.wrap || false, + gap: detailFieldConfig.columns?.gap || config.columns?.gap || 0, + rowGap: detailFieldConfig.columns?.rowGap || config.columns?.rowGap || 0 + } + : undefined, layout, styles: detailFieldConfig.styles || {}, visitable: display, -- Gitee From b5a20622ab76070ae288b5a5361d2358c2a91a60 Mon Sep 17 00:00:00 2001 From: cuiwenlong7 Date: Wed, 23 Feb 2022 16:09:44 +0800 Subject: [PATCH 03/10] =?UTF-8?q?feat:=20=E9=85=8D=E5=90=88upload=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E4=B8=8D=E6=8B=BC=E5=90=88=E8=B7=AF=E5=BE=84noPathCom?= =?UTF-8?q?bination=E9=85=8D=E7=BD=AE=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/detail/common.tsx | 8 +- src/components/detail/enum/index.tsx | 3 +- src/components/detail/group/index.tsx | 99 +++-------------- src/components/detail/importSubform/index.tsx | 34 +++--- src/components/formFields/common.tsx | 20 ++-- src/components/formFields/form/index.tsx | 30 ++--- src/components/formFields/group/index.tsx | 30 ++--- .../formFields/importSubform/index.tsx | 30 ++--- src/components/formFields/object/index.tsx | 30 ++--- src/components/formFields/tabs/index.tsx | 30 ++--- src/components/formFields/upload/index.tsx | 8 +- src/steps/detail/index.tsx | 104 ++++-------------- src/steps/filter/index.tsx | 31 +++--- src/steps/form/index.tsx | 30 ++--- 14 files changed, 181 insertions(+), 306 deletions(-) diff --git a/src/components/detail/common.tsx b/src/components/detail/common.tsx index adcf97c..c72bb7a 100644 --- a/src/components/detail/common.tsx +++ b/src/components/detail/common.tsx @@ -81,13 +81,13 @@ export interface DetailFieldProps { // TODO 待删除 onChange: (value: T) => Promise // 事件:设置值 - onValueSet: (path: string, value: T, validation: true | DetailFieldError[]) => Promise + onValueSet: (path: string, value: T, options?: { noPathCombination?: true }) => Promise // // 事件:置空值 - onValueUnset: (path: string, validation: true | DetailFieldError[]) => Promise + onValueUnset: (path: string, options?: { noPathCombination?: true }) => Promise // 事件:修改值 - 列表 - 追加 - onValueListAppend: (path: string, value: any, validation: true | DetailFieldError[]) => Promise + onValueListAppend: (path: string, value: any, options?: { noPathCombination?: true }) => Promise // 事件:修改值 - 列表 - 删除 - onValueListSplice: (path: string, index: number, count: number, validation: true | DetailFieldError[]) => Promise + onValueListSplice: (path: string, index: number, count: number, options?: { noPathCombination?: true }) => Promise baseRoute: string, loadDomain: (domain: string) => Promise } diff --git a/src/components/detail/enum/index.tsx b/src/components/detail/enum/index.tsx index c79b2cf..d30c108 100644 --- a/src/components/detail/enum/index.tsx +++ b/src/components/detail/enum/index.tsx @@ -1,6 +1,5 @@ -import { config } from 'process' import React from 'react' -import { DetailField, DetailFieldConfig, DetailFieldError, DetailFieldProps, IDetailField } from '../common' +import { DetailField, DetailFieldConfig, IDetailField } from '../common' export interface EnumDetailConfig extends DetailFieldConfig { type: 'detail_enum' diff --git a/src/components/detail/group/index.tsx b/src/components/detail/group/index.tsx index 47cc62d..d6533e4 100644 --- a/src/components/detail/group/index.tsx +++ b/src/components/detail/group/index.tsx @@ -1,7 +1,7 @@ import React from 'react' import { cloneDeep } from 'lodash' import { setValue, getValue } from '../../../util/value' -import { DetailField, DetailFieldConfig, DetailFieldError, DetailFieldProps, IDetailField } from '../common' +import { DetailField, DetailFieldConfig, DetailFieldProps, IDetailField } from '../common' import getALLComponents, { DetailFieldConfigs } from '../' import { IDetailItem } from '../../../steps/detail' import ConditionHelper from '../../../util/condition' @@ -20,7 +20,6 @@ export interface IGroupField { } interface IGroupFieldState { - detailData: { status: 'normal' | 'error' | 'loading', message?: string }[] } export default class GroupField extends DetailField implements IDetailField { @@ -33,9 +32,7 @@ export default class GroupField extends DetailField) { super(props) - this.state = { - detailData: [] - } + this.state = {} } get = async () => { @@ -68,22 +65,6 @@ export default class GroupField extends DetailField { - detailData[detailFieldIndex] = { status: 'normal' } - return { detailData: cloneDeep(detailData) } - }) - } else { - await this.setState(({ detailData }) => { - detailData[detailFieldIndex] = { status: 'error', message: validation[0].message } - return { detailData: cloneDeep(detailData) } - }) - } await detailField?.didMount() } } @@ -118,79 +99,35 @@ export default class GroupField extends DetailField { + handleValueSet = async (detailFieldIndex: number, path: string, value: any, options?: { noPathCombination?: true }) => { const detailFieldConfig = (this.props.config.fields || [])[detailFieldIndex] if (detailFieldConfig) { - const fullPath = detailFieldConfig.field === '' || path === '' ? `${detailFieldConfig.field}${path}` : `${detailFieldConfig.field}.${path}` - await this.props.onValueSet(fullPath, value, true) - - const detailData = cloneDeep(this.state.detailData) - if (validation === true) { - detailData[detailFieldIndex] = { status: 'normal' } - } else { - detailData[detailFieldIndex] = { status: 'error', message: validation[0].message } - } - - this.setState({ - detailData - }) + const fullPath = options && options.noPathCombination ? path : (detailFieldConfig.field === '' || path === '' ? `${detailFieldConfig.field}${path}` : `${detailFieldConfig.field}.${path}`) + await this.props.onValueSet(fullPath, value) } } - handleValueUnset = async (detailFieldIndex: number, path: string, validation: true | DetailFieldError[]) => { + handleValueUnset = async (detailFieldIndex: number, path: string, options?: { noPathCombination?: true }) => { const detailFieldConfig = (this.props.config.fields || [])[detailFieldIndex] if (detailFieldConfig) { - const fullPath = detailFieldConfig.field === '' || path === '' ? `${detailFieldConfig.field}${path}` : `${detailFieldConfig.field}.${path}` - await this.props.onValueUnset(fullPath, true) - - const detailData = cloneDeep(this.state.detailData) - if (validation === true) { - detailData[detailFieldIndex] = { status: 'normal' } - } else { - detailData[detailFieldIndex] = { status: 'error', message: validation[0].message } - } - - this.setState({ - detailData - }) + const fullPath = options && options.noPathCombination ? path : (detailFieldConfig.field === '' || path === '' ? `${detailFieldConfig.field}${path}` : `${detailFieldConfig.field}.${path}`) + await this.props.onValueUnset(fullPath) } } - handleValueListAppend = async (detailFieldIndex: number, path: string, value: any, validation: true | DetailFieldError[]) => { + handleValueListAppend = async (detailFieldIndex: number, path: string, value: any, options?: { noPathCombination?: true }) => { const detailFieldConfig = (this.props.config.fields || [])[detailFieldIndex] if (detailFieldConfig) { - const fullPath = detailFieldConfig.field === '' || path === '' ? `${detailFieldConfig.field}${path}` : `${detailFieldConfig.field}.${path}` - await this.props.onValueListAppend(fullPath, value, true) - - const detailData = cloneDeep(this.state.detailData) - if (validation === true) { - detailData[detailFieldIndex] = { status: 'normal' } - } else { - detailData[detailFieldIndex] = { status: 'error', message: validation[0].message } - } - - this.setState({ - detailData - }) + const fullPath = options && options.noPathCombination ? path : (detailFieldConfig.field === '' || path === '' ? `${detailFieldConfig.field}${path}` : `${detailFieldConfig.field}.${path}`) + await this.props.onValueListAppend(fullPath, value) } } - handleValueListSplice = async (detailFieldIndex: number, path: string, index: number, count: number, validation: true | DetailFieldError[]) => { + handleValueListSplice = async (detailFieldIndex: number, path: string, index: number, count: number, options?: { noPathCombination?: true }) => { const detailFieldConfig = (this.props.config.fields || [])[detailFieldIndex] if (detailFieldConfig) { - const fullPath = detailFieldConfig.field === '' || path === '' ? `${detailFieldConfig.field}${path}` : `${detailFieldConfig.field}.${path}` - await this.props.onValueListSplice(fullPath, index, count, true) - - const detailData = cloneDeep(this.state.detailData) - if (validation === true) { - detailData[detailFieldIndex] = { status: 'normal' } - } else { - detailData[detailFieldIndex] = { status: 'error', message: validation[0].message } - } - - this.setState({ - detailData - }) + const fullPath = options && options.noPathCombination ? path : (detailFieldConfig.field === '' || path === '' ? `${detailFieldConfig.field}${path}` : `${detailFieldConfig.field}.${path}`) + await this.props.onValueListSplice(fullPath, index, count) } } @@ -278,10 +215,10 @@ export default class GroupField extends DetailField { await this.handleChange(detailFieldIndex, value) }} - onValueSet={async (path, value, validation) => this.handleValueSet(detailFieldIndex, path, value, validation)} - onValueUnset={async (path, validation) => this.handleValueUnset(detailFieldIndex, path, validation)} - onValueListAppend={async (path, value, validation) => this.handleValueListAppend(detailFieldIndex, path, value, validation)} - onValueListSplice={async (path, index, count, validation) => this.handleValueListSplice(detailFieldIndex, path, index, count, validation)} + onValueSet={async (path, value, options) => this.handleValueSet(detailFieldIndex, path, value, options)} + onValueUnset={async (path, options) => this.handleValueUnset(detailFieldIndex, path, options)} + onValueListAppend={async (path, value, options) => this.handleValueListAppend(detailFieldIndex, path, value, options)} + onValueListSplice={async (path, index, count, options) => this.handleValueListSplice(detailFieldIndex, path, index, count, options)} baseRoute={this.props.baseRoute} loadDomain={async (domain: string) => await this.props.loadDomain(domain)} /> diff --git a/src/components/detail/importSubform/index.tsx b/src/components/detail/importSubform/index.tsx index 1565bc1..fdd618a 100644 --- a/src/components/detail/importSubform/index.tsx +++ b/src/components/detail/importSubform/index.tsx @@ -98,42 +98,42 @@ export default class ImportSubformField extends DetailField { + handleValueSet = async (formFieldIndex: number, path: string, value: any, options?: { noPathCombination?: true }) => { const formFieldConfig = (this.state.fields || [])[formFieldIndex] if (formFieldConfig) { - const fullPath = this.getFullpath(formFieldConfig.field, path) - await this.props.onValueSet(fullPath, value, true) + const fullPath = options && options.noPathCombination ? path : this.getFullpath(formFieldConfig.field, path) + await this.props.onValueSet(fullPath, value) } } - handleValueUnset = async (formFieldIndex: number, path: string) => { + handleValueUnset = async (formFieldIndex: number, path: string, options?: { noPathCombination?: true }) => { const formFieldConfig = (this.state.fields || [])[formFieldIndex] if (formFieldConfig) { - const fullPath = this.getFullpath(formFieldConfig.field, path) - await this.props.onValueUnset(fullPath, true) + const fullPath = options && options.noPathCombination ? path : this.getFullpath(formFieldConfig.field, path) + await this.props.onValueUnset(fullPath) } } - handleValueListAppend = async (formFieldIndex: number, path: string, value: any) => { + handleValueListAppend = async (formFieldIndex: number, path: string, value: any, options?: { noPathCombination?: true }) => { const formFieldConfig = (this.state.fields || [])[formFieldIndex] if (formFieldConfig) { - const fullPath = this.getFullpath(formFieldConfig.field, path) - await this.props.onValueListAppend(fullPath, value, true) + const fullPath = options && options.noPathCombination ? path : this.getFullpath(formFieldConfig.field, path) + await this.props.onValueListAppend(fullPath, value) } } - handleValueListSplice = async (formFieldIndex: number, path: string, index: number, count: number) => { + handleValueListSplice = async (formFieldIndex: number, path: string, index: number, count: number, options?: { noPathCombination?: true }) => { const formFieldConfig = (this.state.fields || [])[formFieldIndex] if (formFieldConfig) { - const fullPath = this.getFullpath(formFieldConfig.field, path) - await this.props.onValueListSplice(fullPath, index, count, true) + const fullPath = options && options.noPathCombination ? path : this.getFullpath(formFieldConfig.field, path) + await this.props.onValueListSplice(fullPath, index, count) } } @@ -250,10 +250,10 @@ export default class ImportSubformField extends DetailField this.handleValueSet(formFieldIndex, path, value)} - onValueUnset={async (path) => this.handleValueUnset(formFieldIndex, path)} - onValueListAppend={async (path, value) => this.handleValueListAppend(formFieldIndex, path, value)} - onValueListSplice={async (path, index, count) => this.handleValueListSplice(formFieldIndex, path, index, count)} + onValueSet={async (path, value, options) => this.handleValueSet(formFieldIndex, path, value, options)} + onValueUnset={async (path, options) => this.handleValueUnset(formFieldIndex, path, options)} + onValueListAppend={async (path, value, options) => this.handleValueListAppend(formFieldIndex, path, value, options)} + onValueListSplice={async (path, index, count, options) => this.handleValueListSplice(formFieldIndex, path, index, count, options)} baseRoute={this.props.baseRoute} loadDomain={async (domain: string) => await this.props.loadDomain(domain)} /> diff --git a/src/components/formFields/common.tsx b/src/components/formFields/common.tsx index 9539759..412bb04 100644 --- a/src/components/formFields/common.tsx +++ b/src/components/formFields/common.tsx @@ -83,16 +83,16 @@ export interface FieldProps { config: C // TODO 待删除 onChange: (value: T) => Promise - // 事件:设置值 - onValueSet: (path: string, value: T, validation: true | FieldError[]) => Promise + // 事件:设置值 noPathCombination:为true时不做路径拼接 + onValueSet: (path: string, value: T, validation: true | FieldError[], options?: { noPathCombination?: true }) => Promise // 事件:置空值 - onValueUnset: (path: string, validation: true | FieldError[]) => Promise + onValueUnset: (path: string, validation: true | FieldError[], options?: { noPathCombination?: true }) => Promise // 事件:修改值 - 列表 - 追加 - onValueListAppend: (path: string, value: any, validation: true | FieldError[]) => Promise + onValueListAppend: (path: string, value: any, validation: true | FieldError[], options?: { noPathCombination?: true }) => Promise // 事件:修改值 - 列表 - 删除 - onValueListSplice: (path: string, index: number, count: number, validation: true | FieldError[]) => Promise + onValueListSplice: (path: string, index: number, count: number, validation: true | FieldError[], options?: { noPathCombination?: true }) => Promise // 事件:修改值 - 列表 - 修改顺序 - onValueListSort: (path: string, index: number, sortType: 'up' | 'down', validation: true | FieldError[]) => Promise + onValueListSort: (path: string, index: number, sortType: 'up' | 'down', validation: true | FieldError[], options?: { noPathCombination?: true }) => Promise baseRoute: string, loadDomain: (domain: string) => Promise } @@ -187,13 +187,13 @@ export interface DisplayProps { step: number, config: C, // 事件:设置值 - onValueSet: (path: string, value: T, validation: true | FieldError[]) => Promise + onValueSet: (path: string, value: T, options?: { noPathCombination?: true }) => Promise // 事件:置空值 - onValueUnset: (path: string, validation: true | FieldError[]) => Promise + onValueUnset: (path: string, options?: { noPathCombination?: true }) => Promise // 事件:修改值 - 列表 - 追加 - onValueListAppend: (path: string, value: any, validation: true | FieldError[]) => Promise + onValueListAppend: (path: string, value: any, options?: { noPathCombination?: true }) => Promise // 事件:修改值 - 列表 - 删除 - onValueListSplice: (path: string, index: number, count: number, validation: true | FieldError[]) => Promise + onValueListSplice: (path: string, index: number, count: number, options?: { noPathCombination?: true }) => Promise baseRoute: string, loadDomain: (domain: string) => Promise } diff --git a/src/components/formFields/form/index.tsx b/src/components/formFields/form/index.tsx index 111ac3c..f56278c 100644 --- a/src/components/formFields/form/index.tsx +++ b/src/components/formFields/form/index.tsx @@ -327,10 +327,10 @@ export default class FormField extends Field { + handleValueSet = async (index: number, formFieldIndex: number, path: string, value: any, validation: true | FieldError[], options?: { noPathCombination?: true }) => { const formFieldConfig = (this.props.config.fields || [])[formFieldIndex] if (formFieldConfig) { - const fullPath = formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}` + const fullPath = options && options.noPathCombination ? path : (formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}`) await this.props.onValueSet(`[${index}]${fullPath}`, value, true) const formDataList = cloneDeep(this.state.formDataList) @@ -346,10 +346,10 @@ export default class FormField extends Field { + handleValueUnset = async (index: number, formFieldIndex: number, path: string, validation: true | FieldError[], options?: { noPathCombination?: true }) => { const formFieldConfig = (this.props.config.fields || [])[formFieldIndex] if (formFieldConfig) { - const fullPath = formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}` + const fullPath = options && options.noPathCombination ? path : (formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}`) await this.props.onValueUnset(`[${index}]${fullPath}`, true) const formDataList = cloneDeep(this.state.formDataList) @@ -365,10 +365,10 @@ export default class FormField extends Field { + handleValueListAppend = async (index: number, formFieldIndex: number, path: string, value: any, validation: true | FieldError[], options?: { noPathCombination?: true }) => { const formFieldConfig = (this.props.config.fields || [])[formFieldIndex] if (formFieldConfig) { - const fullPath = formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}` + const fullPath = options && options.noPathCombination ? path : (formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}`) await this.props.onValueListAppend(`[${index}]${fullPath}`, value, true) const formDataList = cloneDeep(this.state.formDataList) @@ -384,10 +384,10 @@ export default class FormField extends Field { + handleValueListSplice = async (index: number, formFieldIndex: number, path: string, _index: number, count: number, validation: true | FieldError[], options?: { noPathCombination?: true }) => { const formFieldConfig = (this.props.config.fields || [])[formFieldIndex] if (formFieldConfig) { - const fullPath = formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}` + const fullPath = options && options.noPathCombination ? path : (formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}`) await this.props.onValueListSplice(`[${index}]${fullPath}`, _index, count, true) const formDataList = cloneDeep(this.state.formDataList) @@ -403,10 +403,10 @@ export default class FormField extends Field { + handleValueListSort = async (index: number, formFieldIndex: number, path: string, _index: number, sortType: 'up' | 'down', validation: true | FieldError[], options?: { noPathCombination?: true }) => { const formFieldConfig = (this.props.config.fields || [])[formFieldIndex] if (formFieldConfig) { - const fullPath = formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}` + const fullPath = options && options.noPathCombination ? path : (formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}`) await this.props.onValueListSort(`[${index}]${fullPath}`, _index, sortType, true) const formDataList = cloneDeep(this.state.formDataList) @@ -539,11 +539,11 @@ export default class FormField extends Field this.handleChange(index, fieldIndex, value)} - onValueSet={async (path, value, validation) => this.handleValueSet(index, fieldIndex, path, value, validation)} - onValueUnset={async (path, validation) => this.handleValueUnset(index, fieldIndex, path, validation)} - onValueListAppend={async (path, value, validation) => this.handleValueListAppend(index, fieldIndex, path, value, validation)} - onValueListSplice={async (path, _index, count, validation) => this.handleValueListSplice(index, fieldIndex, path, _index, count, validation)} - onValueListSort={async (path, _index, sortType, validation) => await this.handleValueListSort(index, fieldIndex, path, _index, sortType, validation)} + onValueSet={async (path, value, validation, options) => this.handleValueSet(index, fieldIndex, path, value, validation, options)} + onValueUnset={async (path, validation, options) => this.handleValueUnset(index, fieldIndex, path, validation, options)} + onValueListAppend={async (path, value, validation, options) => this.handleValueListAppend(index, fieldIndex, path, value, validation, options)} + onValueListSplice={async (path, _index, count, validation, options) => this.handleValueListSplice(index, fieldIndex, path, _index, count, validation, options)} + onValueListSort={async (path, _index, sortType, validation, options) => await this.handleValueListSort(index, fieldIndex, path, _index, sortType, validation, options)} baseRoute={this.props.baseRoute} loadDomain={async (domain: string) => await this.props.loadDomain(domain)} /> diff --git a/src/components/formFields/group/index.tsx b/src/components/formFields/group/index.tsx index da312b8..bd4b8ef 100644 --- a/src/components/formFields/group/index.tsx +++ b/src/components/formFields/group/index.tsx @@ -189,10 +189,10 @@ export default class GroupField extends Field { + handleValueSet = async (formFieldIndex: number, path: string, value: any, validation: true | FieldError[], options?: { noPathCombination?: true }) => { const formFieldConfig = (this.props.config.fields || [])[formFieldIndex] if (formFieldConfig) { - const fullPath = formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}` + const fullPath = options && options.noPathCombination ? path : (formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}`) await this.props.onValueSet(fullPath, value, true) const formData = cloneDeep(this.state.formData) if (validation === true) { @@ -207,10 +207,10 @@ export default class GroupField extends Field { + handleValueUnset = async (formFieldIndex: number, path: string, validation: true | FieldError[], options?: { noPathCombination?: true }) => { const formFieldConfig = (this.props.config.fields || [])[formFieldIndex] if (formFieldConfig) { - const fullPath = formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}` + const fullPath = options && options.noPathCombination ? path : (formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}`) await this.props.onValueUnset(fullPath, true) const formData = cloneDeep(this.state.formData) if (validation === true) { @@ -225,10 +225,10 @@ export default class GroupField extends Field { + handleValueListAppend = async (formFieldIndex: number, path: string, value: any, validation: true | FieldError[], options?: { noPathCombination?: true }) => { const formFieldConfig = (this.props.config.fields || [])[formFieldIndex] if (formFieldConfig) { - const fullPath = formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}` + const fullPath = options && options.noPathCombination ? path : (formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}`) await this.props.onValueListAppend(fullPath, value, true) const formData = cloneDeep(this.state.formData) if (validation === true) { @@ -243,10 +243,10 @@ export default class GroupField extends Field { + handleValueListSplice = async (formFieldIndex: number, path: string, index: number, count: number, validation: true | FieldError[], options?: { noPathCombination?: true }) => { const formFieldConfig = (this.props.config.fields || [])[formFieldIndex] if (formFieldConfig) { - const fullPath = formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}` + const fullPath = options && options.noPathCombination ? path : (formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}`) await this.props.onValueListSplice(fullPath, index, count, true) const formData = cloneDeep(this.state.formData) if (validation === true) { @@ -261,10 +261,10 @@ export default class GroupField extends Field { + handleValueListSort = async (formFieldIndex: number, path: string, index: number, sortType: 'up' | 'down', validation: true | FieldError[], options?: { noPathCombination?: true }) => { const formFieldConfig = (this.props.config.fields || [])[formFieldIndex] if (formFieldConfig) { - const fullPath = formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}` + const fullPath = options && options.noPathCombination ? path : (formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}`) await this.props.onValueListSort(fullPath, index, sortType, true) const formData = cloneDeep(this.state.formData) if (validation === true) { @@ -375,11 +375,11 @@ export default class GroupField extends Field { await this.handleChange(formFieldIndex, value) }} - onValueSet={async (path, value, validation) => this.handleValueSet(formFieldIndex, path, value, validation)} - onValueUnset={async (path, validation) => this.handleValueUnset(formFieldIndex, path, validation)} - onValueListAppend={async (path, value, validation) => this.handleValueListAppend(formFieldIndex, path, value, validation)} - onValueListSplice={async (path, index, count, validation) => this.handleValueListSplice(formFieldIndex, path, index, count, validation)} - onValueListSort={async (path, index, sortType, validation) => this.handleValueListSort(formFieldIndex, path, index, sortType, validation)} + onValueSet={async (path, value, validation, options) => this.handleValueSet(formFieldIndex, path, value, validation, options)} + onValueUnset={async (path, validation, options) => this.handleValueUnset(formFieldIndex, path, validation, options)} + onValueListAppend={async (path, value, validation, options) => this.handleValueListAppend(formFieldIndex, path, value, validation, options)} + onValueListSplice={async (path, index, count, validation, options) => this.handleValueListSplice(formFieldIndex, path, index, count, validation, options)} + onValueListSort={async (path, index, sortType, validation, options) => this.handleValueListSort(formFieldIndex, path, index, sortType, validation, options)} baseRoute={this.props.baseRoute} loadDomain={async (domain: string) => await this.props.loadDomain(domain)} /> diff --git a/src/components/formFields/importSubform/index.tsx b/src/components/formFields/importSubform/index.tsx index 5735eb9..5210cca 100644 --- a/src/components/formFields/importSubform/index.tsx +++ b/src/components/formFields/importSubform/index.tsx @@ -214,10 +214,10 @@ export default class ImportSubformField extends Field { + handleValueSet = async (formFieldIndex: number, path: string, value: any, validation: true | FieldError[], options?: { noPathCombination?: true }) => { const formFieldConfig = (this.state.fields || [])[formFieldIndex] if (formFieldConfig) { - const fullPath = this.getFullpath(formFieldConfig.field, path) + const fullPath = options && options.noPathCombination ? path : this.getFullpath(formFieldConfig.field, path) await this.props.onValueSet(fullPath, value, true) const formData = cloneDeep(this.state.formData) @@ -233,10 +233,10 @@ export default class ImportSubformField extends Field { + handleValueUnset = async (formFieldIndex: number, path: string, validation: true | FieldError[], options?: { noPathCombination?: true }) => { const formFieldConfig = (this.state.fields || [])[formFieldIndex] if (formFieldConfig) { - const fullPath = this.getFullpath(formFieldConfig.field, path) + const fullPath = options && options.noPathCombination ? path : this.getFullpath(formFieldConfig.field, path) await this.props.onValueUnset(fullPath, true) const formData = cloneDeep(this.state.formData) @@ -252,10 +252,10 @@ export default class ImportSubformField extends Field { + handleValueListAppend = async (formFieldIndex: number, path: string, value: any, validation: true | FieldError[], options?: { noPathCombination?: true }) => { const formFieldConfig = (this.state.fields || [])[formFieldIndex] if (formFieldConfig) { - const fullPath = this.getFullpath(formFieldConfig.field, path) + const fullPath = options && options.noPathCombination ? path : this.getFullpath(formFieldConfig.field, path) await this.props.onValueListAppend(fullPath, value, true) const formData = cloneDeep(this.state.formData) @@ -271,10 +271,10 @@ export default class ImportSubformField extends Field { + handleValueListSplice = async (formFieldIndex: number, path: string, index: number, count: number, validation: true | FieldError[], options?: { noPathCombination?: true }) => { const formFieldConfig = (this.state.fields || [])[formFieldIndex] if (formFieldConfig) { - const fullPath = this.getFullpath(formFieldConfig.field, path) + const fullPath = options && options.noPathCombination ? path : this.getFullpath(formFieldConfig.field, path) await this.props.onValueListSplice(fullPath, index, count, true) const formData = cloneDeep(this.state.formData) @@ -290,10 +290,10 @@ export default class ImportSubformField extends Field { + handleValueListSort = async (formFieldIndex: number, path: string, index: number, sortType: 'up' | 'down', validation: true | FieldError[], options?: { noPathCombination?: true }) => { const formFieldConfig = (this.state.fields || [])[formFieldIndex] if (formFieldConfig) { - const fullPath = this.getFullpath(formFieldConfig.field, path) + const fullPath = options && options.noPathCombination ? path : this.getFullpath(formFieldConfig.field, path) await this.props.onValueListSort(fullPath, index, sortType, true) const formData = cloneDeep(this.state.formData) @@ -434,11 +434,11 @@ export default class ImportSubformField extends Field { await this.handleChange(formFieldIndex, value) }} - onValueSet={async (path, value, validation) => this.handleValueSet(formFieldIndex, path, value, validation)} - onValueUnset={async (path, validation) => this.handleValueUnset(formFieldIndex, path, validation)} - onValueListAppend={async (path, value, validation) => this.handleValueListAppend(formFieldIndex, path, value, validation)} - onValueListSplice={async (path, index, count, validation) => this.handleValueListSplice(formFieldIndex, path, index, count, validation)} - onValueListSort={async (path, index, sortType, validation) => this.handleValueListSort(formFieldIndex, path, index, sortType, validation)} + onValueSet={async (path, value, validation, options) => this.handleValueSet(formFieldIndex, path, value, validation, options)} + onValueUnset={async (path, validation, options) => this.handleValueUnset(formFieldIndex, path, validation, options)} + onValueListAppend={async (path, value, validation, options) => this.handleValueListAppend(formFieldIndex, path, value, validation, options)} + onValueListSplice={async (path, index, count, validation, options) => this.handleValueListSplice(formFieldIndex, path, index, count, validation, options)} + onValueListSort={async (path, index, sortType, validation, options) => this.handleValueListSort(formFieldIndex, path, index, sortType, validation, options)} baseRoute={this.props.baseRoute} loadDomain={async (domain: string) => await this.props.loadDomain(domain)} /> diff --git a/src/components/formFields/object/index.tsx b/src/components/formFields/object/index.tsx index b0de063..12bb936 100644 --- a/src/components/formFields/object/index.tsx +++ b/src/components/formFields/object/index.tsx @@ -259,10 +259,10 @@ export default class ObjectField extends Field { + handleValueSet = async (key: string, formFieldIndex: number, path: string, value: any, validation: true | FieldError[], options?: { noPathCombination?: true }) => { const formFieldConfig = (this.props.config.fields || [])[formFieldIndex] if (formFieldConfig) { - const fullPath = formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}` + const fullPath = options && options.noPathCombination ? path : (formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}`) await this.props.onValueSet(fullPath === '' ? key : `${key}.${fullPath}`, value, true) const formDataList = cloneDeep(this.state.formDataList) @@ -278,10 +278,10 @@ export default class ObjectField extends Field { + handleValueUnset = async (key: string, formFieldIndex: number, path: string, validation: true | FieldError[], options?: { noPathCombination?: true }) => { const formFieldConfig = (this.props.config.fields || [])[formFieldIndex] if (formFieldConfig) { - const fullPath = formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}` + const fullPath = options && options.noPathCombination ? path : (formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}`) await this.props.onValueUnset(fullPath === '' ? key : `${key}.${fullPath}`, true) const formDataList = cloneDeep(this.state.formDataList) @@ -297,10 +297,10 @@ export default class ObjectField extends Field { + handleValueListAppend = async (key: string, formFieldIndex: number, path: string, value: any, validation: true | FieldError[], options?: { noPathCombination?: true }) => { const formFieldConfig = (this.props.config.fields || [])[formFieldIndex] if (formFieldConfig) { - const fullPath = formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}` + const fullPath = options && options.noPathCombination ? path : (formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}`) await this.props.onValueListAppend(fullPath === '' ? key : `${key}.${fullPath}`, value, true) const formDataList = cloneDeep(this.state.formDataList) @@ -316,10 +316,10 @@ export default class ObjectField extends Field { + handleValueListSplice = async (key: string, formFieldIndex: number, path: string, _index: number, count: number, validation: true | FieldError[], options?: { noPathCombination?: true }) => { const formFieldConfig = (this.props.config.fields || [])[formFieldIndex] if (formFieldConfig) { - const fullPath = formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}` + const fullPath = options && options.noPathCombination ? path : (formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}`) await this.props.onValueListSplice(fullPath === '' ? key : `${key}.${fullPath}`, _index, count, true) const formDataList = cloneDeep(this.state.formDataList) @@ -335,10 +335,10 @@ export default class ObjectField extends Field { + handleValueListSort = async (key: string, formFieldIndex: number, path: string, _index: number, sortType: 'up' | 'down', validation: true | FieldError[], options?: { noPathCombination?: true }) => { const formFieldConfig = (this.props.config.fields || [])[formFieldIndex] if (formFieldConfig) { - const fullPath = formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}` + const fullPath = options && options.noPathCombination ? path : (formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}`) await this.props.onValueListSort(fullPath === '' ? key : `${key}.${fullPath}`, _index, sortType, true) const formDataList = cloneDeep(this.state.formDataList) @@ -472,11 +472,11 @@ export default class ObjectField extends Field this.handleChange(key, formFieldIndex, value)} - onValueSet={async (path, value, validation) => this.handleValueSet(key, formFieldIndex, path, value, validation)} - onValueUnset={async (path, validation) => this.handleValueUnset(key, formFieldIndex, path, validation)} - onValueListAppend={async (path, value, validation) => this.handleValueListAppend(key, formFieldIndex, path, value, validation)} - onValueListSplice={async (path, _index, count, validation) => this.handleValueListSplice(key, formFieldIndex, path, _index, count, validation)} - onValueListSort={async (path, _index, sortType, validation) => this.handleValueListSort(key, formFieldIndex, path, _index, sortType, validation)} + onValueSet={async (path, value, validation, options) => this.handleValueSet(key, formFieldIndex, path, value, validation, options)} + onValueUnset={async (path, validation, options) => this.handleValueUnset(key, formFieldIndex, path, validation, options)} + onValueListAppend={async (path, value, validation, options) => this.handleValueListAppend(key, formFieldIndex, path, value, validation, options)} + onValueListSplice={async (path, _index, count, validation, options) => this.handleValueListSplice(key, formFieldIndex, path, _index, count, validation, options)} + onValueListSort={async (path, _index, sortType, validation, options) => this.handleValueListSort(key, formFieldIndex, path, _index, sortType, validation, options)} baseRoute={this.props.baseRoute} loadDomain={async (domain: string) => this.props.loadDomain(domain)} /> diff --git a/src/components/formFields/tabs/index.tsx b/src/components/formFields/tabs/index.tsx index 0ed46c2..be6079a 100644 --- a/src/components/formFields/tabs/index.tsx +++ b/src/components/formFields/tabs/index.tsx @@ -205,13 +205,13 @@ export default class TabsField extends Field { } - handleValueSet = async (index: number, formFieldIndex: number, path: string, value: any, validation: true | FieldError[]) => { + handleValueSet = async (index: number, formFieldIndex: number, path: string, value: any, validation: true | FieldError[], options?: { noPathCombination?: true }) => { const tab = (this.props.config.tabs || [])[index] const fields = this.props.config.mode === 'same' ? (this.props.config.fields || []) : (((this.props.config.tabs || [])[index] || {}).fields || []) const formFieldConfig = fields[formFieldIndex] if (formFieldConfig) { - const fieldPath = formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}` + const fieldPath = options && options.noPathCombination ? path : (formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}`) const fullPath = tab.field === '' || fieldPath === '' ? `${tab.field}${fieldPath}` : `${tab.field}.${fieldPath}` await this.props.onValueSet(fullPath, value, true) @@ -229,13 +229,13 @@ export default class TabsField extends Field { + handleValueUnset = async (index: number, formFieldIndex: number, path: string, validation: true | FieldError[], options?: { noPathCombination?: true }) => { const tab = (this.props.config.tabs || [])[index] const fields = this.props.config.mode === 'same' ? (this.props.config.fields || []) : (((this.props.config.tabs || [])[index] || {}).fields || []) const formFieldConfig = fields[formFieldIndex] if (formFieldConfig) { - const fieldPath = formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}` + const fieldPath = options && options.noPathCombination ? path : (formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}`) const fullPath = tab.field === '' || fieldPath === '' ? `${tab.field}${fieldPath}` : `${tab.field}.${fieldPath}` await this.props.onValueUnset(fullPath, true) @@ -253,13 +253,13 @@ export default class TabsField extends Field { + handleValueListAppend = async (index: number, formFieldIndex: number, path: string, value: any, validation: true | FieldError[], options?: { noPathCombination?: true }) => { const tab = (this.props.config.tabs || [])[index] const fields = this.props.config.mode === 'same' ? (this.props.config.fields || []) : (((this.props.config.tabs || [])[index] || {}).fields || []) const formFieldConfig = fields[formFieldIndex] if (formFieldConfig) { - const fieldPath = formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}` + const fieldPath = options && options.noPathCombination ? path : (formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}`) const fullPath = tab.field === '' || fieldPath === '' ? `${tab.field}${fieldPath}` : `${tab.field}.${fieldPath}` await this.props.onValueListAppend(fullPath, value, true) @@ -277,13 +277,13 @@ export default class TabsField extends Field { + handleValueListSplice = async (index: number, formFieldIndex: number, path: string, _index: number, count: number, validation: true | FieldError[], options?: { noPathCombination?: true }) => { const tab = (this.props.config.tabs || [])[index] const fields = this.props.config.mode === 'same' ? (this.props.config.fields || []) : (((this.props.config.tabs || [])[index] || {}).fields || []) const formFieldConfig = fields[formFieldIndex] if (formFieldConfig) { - const fieldPath = formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}` + const fieldPath = options && options.noPathCombination ? path : (formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}`) const fullPath = tab.field === '' || fieldPath === '' ? `${tab.field}${fieldPath}` : `${tab.field}.${fieldPath}` await this.props.onValueListSplice(fullPath, _index, count, true) @@ -301,13 +301,13 @@ export default class TabsField extends Field { + handleValueListSort = async (index: number, formFieldIndex: number, path: string, _index: number, sortType: 'up' | 'down', validation: true | FieldError[], options?: { noPathCombination?: true }) => { const tab = (this.props.config.tabs || [])[index] const fields = this.props.config.mode === 'same' ? (this.props.config.fields || []) : (((this.props.config.tabs || [])[index] || {}).fields || []) const formFieldConfig = fields[formFieldIndex] if (formFieldConfig) { - const fieldPath = formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}` + const fieldPath = options && options.noPathCombination ? path : (formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}`) const fullPath = tab.field === '' || fieldPath === '' ? `${tab.field}${fieldPath}` : `${tab.field}.${fieldPath}` await this.props.onValueListSort(fullPath, _index, sortType, true) @@ -436,11 +436,11 @@ export default class TabsField extends Field this.handleChange(index, formFieldIndex, value)} - onValueSet={async (path, value, validation) => this.handleValueSet(index, formFieldIndex, path, value, validation)} - onValueUnset={async (path, validation) => this.handleValueUnset(index, formFieldIndex, path, validation)} - onValueListAppend={async (path, value, validation) => this.handleValueListAppend(index, formFieldIndex, path, value, validation)} - onValueListSplice={async (path, _index, count, validation) => this.handleValueListSplice(index, formFieldIndex, path, _index, count, validation)} - onValueListSort={async (path, _index, sortType, validation) => this.handleValueListSort(index, formFieldIndex, path, _index, sortType, validation)} + onValueSet={async (path, value, validation, options) => this.handleValueSet(index, formFieldIndex, path, value, validation, options)} + onValueUnset={async (path, validation, options) => this.handleValueUnset(index, formFieldIndex, path, validation, options)} + onValueListAppend={async (path, value, validation, options) => this.handleValueListAppend(index, formFieldIndex, path, value, validation, options)} + onValueListSplice={async (path, _index, count, validation, options) => this.handleValueListSplice(index, formFieldIndex, path, _index, count, validation, options)} + onValueListSort={async (path, _index, sortType, validation, options) => this.handleValueListSort(index, formFieldIndex, path, _index, sortType, validation, options)} baseRoute={this.props.baseRoute} loadDomain={async (domain: string) => await this.props.loadDomain(domain)} /> diff --git a/src/components/formFields/upload/index.tsx b/src/components/formFields/upload/index.tsx index 5b8fc83..295ec68 100644 --- a/src/components/formFields/upload/index.tsx +++ b/src/components/formFields/upload/index.tsx @@ -11,6 +11,7 @@ export interface UploadFieldConfigBasic extends FieldConfig { interface: InterfaceConfig requireField: string responseField: string + extraResponseField: Array<{from: string, to: string}> } export interface UploadFieldConfigImage extends UploadFieldConfigBasic { @@ -150,7 +151,6 @@ export default class UploadField extends Field { * 初始化表单的值 * @param props */ - constructor(props: StepProps) { + constructor (props: StepProps) { super(props) this.state = { ready: false, - detailValue: {}, - detailData: [] + detailValue: {} } } @@ -142,8 +140,6 @@ export default class DetailStep extends Step { onMount } = this.props - const detailData = cloneDeep(this.state.detailData) - if (this.props.config.defaultValue) { let detailDefault = ParamHelper(this.props.config.defaultValue, { data, step }) if (this.props.config.unstringify) { @@ -160,14 +156,12 @@ export default class DetailStep extends Step { const detailFieldConfig = detailFieldsConfig[detailFieldIndex] const value = getValue(detailDefault, detailFieldConfig.field) this.detailValue = setValue(this.detailValue, detailFieldConfig.field, value) - detailData[detailFieldIndex] = { status: 'normal', name: detailFieldConfig.label } } } await this.setState({ ready: true, - detailValue: this.detailValue, - detailData: cloneDeep(detailData) + detailValue: this.detailValue }) // 表单初始化结束,展示表单界面。 @@ -180,8 +174,6 @@ export default class DetailStep extends Step { } this.detailFieldsMounted[detailFieldIndex] = true - const detailData = cloneDeep(this.state.detailData) - if (this.detailFields[detailFieldIndex]) { const detailField = this.detailFields[detailFieldIndex] if (detailField) { @@ -190,20 +182,12 @@ export default class DetailStep extends Step { const value = getValue(this.detailValue, detailFieldConfig.field) this.detailValue = setValue(this.detailValue, detailFieldConfig.field, value) - const validation = await detailField.validate(value) - if (validation === true) { - detailData[detailFieldIndex] = { status: 'normal', name: detailFieldConfig.label } - } else { - // 首次进入错误提示; - detailData[detailFieldIndex] = { status: 'error', message: validation[0].message, name: detailFieldConfig.label } - } await detailField.didMount() } } await this.setState({ - detailValue: this.detailValue, - detailData: cloneDeep(detailData) + detailValue: this.detailValue }) } @@ -224,23 +208,13 @@ export default class DetailStep extends Step { * @param value 目标值 */ handleChange = async (detailFieldIndex: number, value: any) => { - const detailData = cloneDeep(this.state.detailData) - const detailField = this.detailFields[detailFieldIndex] const detailFieldConfig = (this.props.config.fields || [])[detailFieldIndex] if (detailField && detailFieldConfig) { this.detailValue = setValue(this.detailValue, detailFieldConfig.field, value) - const validation = await detailField.validate(value) - if (validation === true) { - detailData[detailFieldIndex] = { status: 'normal', name: detailFieldConfig.label } - } else { - detailData[detailFieldIndex] = { status: 'error', message: validation[0].message, name: detailFieldConfig.label } - } - await this.setState({ - detailValue: this.detailValue, - detailData + detailValue: this.detailValue }) if (this.props.onChange) { this.props.onChange(this.detailValue) @@ -248,10 +222,10 @@ export default class DetailStep extends Step { } } - handleValueSet = async (detailFieldIndex: number, path: string, value: any, validation: true | DetailFieldError[]) => { + handleValueSet = async (detailFieldIndex: number, path: string, value: any, options?: { noPathCombination?: true }) => { const detailFieldConfig = (this.props.config.fields || [])[detailFieldIndex] if (detailFieldConfig) { - const fullPath = detailFieldConfig.field === '' || path === '' ? `${detailFieldConfig.field}${path}` : `${detailFieldConfig.field}.${path}` + const fullPath = options && options.noPathCombination ? path : (detailFieldConfig.field === '' || path === '' ? `${detailFieldConfig.field}${path}` : `${detailFieldConfig.field}.${path}`) set(this.detailValue, fullPath, value) this.setState({ @@ -260,22 +234,13 @@ export default class DetailStep extends Step { if (this.props.onChange) { this.props.onChange(this.detailValue) } - - if (validation === true) { - this.detailData[detailFieldIndex] = { status: 'normal', name: detailFieldConfig.label, hidden: false } - } else { - this.detailData[detailFieldIndex] = { status: 'error', message: validation[0].message, name: detailFieldConfig.label, hidden: false } - } - await this.setState({ - detailData: this.detailData - }) } } - handleValueUnset = async (detailFieldIndex: number, path: string, validation: true | DetailFieldError[]) => { + handleValueUnset = async (detailFieldIndex: number, path: string, options?: { noPathCombination?: true }) => { const detailFieldConfig = (this.props.config.fields || [])[detailFieldIndex] if (detailFieldConfig) { - const fullPath = detailFieldConfig.field === '' || path === '' ? `${detailFieldConfig.field}${path}` : `${detailFieldConfig.field}.${path}` + const fullPath = options && options.noPathCombination ? path : (detailFieldConfig.field === '' || path === '' ? `${detailFieldConfig.field}${path}` : `${detailFieldConfig.field}.${path}`) unset(this.detailValue, fullPath) this.setState({ @@ -284,23 +249,13 @@ export default class DetailStep extends Step { if (this.props.onChange) { this.props.onChange(this.detailValue) } - - if (validation === true) { - this.detailData[detailFieldIndex] = { status: 'normal', name: detailFieldConfig.label, hidden: false } - } else { - this.detailData[detailFieldIndex] = { status: 'error', message: validation[0].message, name: detailFieldConfig.label, hidden: false } - } - - await this.setState({ - detailData: this.detailData - }) } } - handleValueListAppend = async (detailFieldIndex: number, path: string, value: any, validation: true | DetailFieldError[]) => { + handleValueListAppend = async (detailFieldIndex: number, path: string, value: any, options?: { noPathCombination?: true }) => { const detailFieldConfig = (this.props.config.fields || [])[detailFieldIndex] if (detailFieldConfig) { - const fullPath = detailFieldConfig.field === '' || path === '' ? `${detailFieldConfig.field}${path}` : `${detailFieldConfig.field}.${path}` + const fullPath = options && options.noPathCombination ? path : (detailFieldConfig.field === '' || path === '' ? `${detailFieldConfig.field}${path}` : `${detailFieldConfig.field}.${path}`) const list = get(this.detailValue, fullPath, []) list.push(value) @@ -311,23 +266,13 @@ export default class DetailStep extends Step { if (this.props.onChange) { this.props.onChange(this.detailValue) } - - if (validation === true) { - this.detailData[detailFieldIndex] = { status: 'normal', name: detailFieldConfig.label, hidden: false } - } else { - this.detailData[detailFieldIndex] = { status: 'error', message: validation[0].message, name: detailFieldConfig.label, hidden: false } - } - - await this.setState({ - detailData: this.detailData - }) } } - handleValueListSplice = async (detailFieldIndex: number, path: string, index: number, count: number, validation: true | DetailFieldError[]) => { + handleValueListSplice = async (detailFieldIndex: number, path: string, index: number, count: number, options?: { noPathCombination?: true }) => { const detailFieldConfig = (this.props.config.fields || [])[detailFieldIndex] if (detailFieldConfig) { - const fullPath = detailFieldConfig.field === '' || path === '' ? `${detailFieldConfig.field}${path}` : `${detailFieldConfig.field}.${path}` + const fullPath = options && options.noPathCombination ? path : (detailFieldConfig.field === '' || path === '' ? `${detailFieldConfig.field}${path}` : `${detailFieldConfig.field}.${path}`) const list = get(this.detailValue, fullPath, []) list.splice(index, count) @@ -338,16 +283,6 @@ export default class DetailStep extends Step { if (this.props.onChange) { this.props.onChange(this.detailValue) } - - if (validation === true) { - this.detailData[detailFieldIndex] = { status: 'normal', name: detailFieldConfig.label, hidden: false } - } else { - this.detailData[detailFieldIndex] = { status: 'error', message: validation[0].message, name: detailFieldConfig.label, hidden: false } - } - - await this.setState({ - detailData: this.detailData - }) } } @@ -373,7 +308,7 @@ export default class DetailStep extends Step { } - render() { + render () { const { config, data, @@ -389,8 +324,7 @@ export default class DetailStep extends Step { const { ready, - detailValue, - detailData + detailValue } = this.state if (ready) { @@ -462,10 +396,10 @@ export default class DetailStep extends Step { step={step} config={detailFieldConfig} onChange={async (value: any) => { await this.handleChange(detailFieldIndex, value) }} - onValueSet={async (path, value, validation) => await this.handleValueSet(detailFieldIndex, path, value, validation)} - onValueUnset={async (path, validation) => await this.handleValueUnset(detailFieldIndex, path, validation)} - onValueListAppend={async (path, value, validation) => await this.handleValueListAppend(detailFieldIndex, path, value, validation)} - onValueListSplice={async (path, index, count, validation) => await this.handleValueListSplice(detailFieldIndex, path, index, count, validation)} + onValueSet={async (path, value) => await this.handleValueSet(detailFieldIndex, path, value)} + onValueUnset={async (path) => await this.handleValueUnset(detailFieldIndex, path)} + onValueListAppend={async (path, value) => await this.handleValueListAppend(detailFieldIndex, path, value)} + onValueListSplice={async (path, index, count) => await this.handleValueListSplice(detailFieldIndex, path, index, count)} baseRoute={this.props.baseRoute} loadDomain={async (domain: string) => await this.props.loadDomain(domain)} /> diff --git a/src/steps/filter/index.tsx b/src/steps/filter/index.tsx index 3f1bd37..4169148 100644 --- a/src/steps/filter/index.tsx +++ b/src/steps/filter/index.tsx @@ -278,10 +278,10 @@ export default class FilterStep extends Step { } } - handleValueSet = async (formFieldIndex: number, path: string, value: any, validation: true | FieldError[]) => { + handleValueSet = async (formFieldIndex: number, path: string, value: any, validation: true | FieldError[], options?: { noPathCombination?: true }) => { const formFieldConfig = (this.props.config.fields || [])[formFieldIndex] if (formFieldConfig) { - const fullPath = formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}` + const fullPath = options && options.noPathCombination ? path : (formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}`) set(this.formValue, fullPath, value) this.setState({ @@ -303,10 +303,10 @@ export default class FilterStep extends Step { } } - handleValueUnset = async (formFieldIndex: number, path: string, validation: true | FieldError[]) => { + handleValueUnset = async (formFieldIndex: number, path: string, validation: true | FieldError[], options?: { noPathCombination?: true }) => { const formFieldConfig = (this.props.config.fields || [])[formFieldIndex] if (formFieldConfig) { - const fullPath = formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}` + const fullPath = options && options.noPathCombination ? path : (formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}`) unset(this.formValue, fullPath) this.setState({ @@ -328,10 +328,10 @@ export default class FilterStep extends Step { } } - handleValueListAppend = async (formFieldIndex: number, path: string, value: any, validation: true | FieldError[]) => { + handleValueListAppend = async (formFieldIndex: number, path: string, value: any, validation: true | FieldError[], options?: { noPathCombination?: true }) => { const formFieldConfig = (this.props.config.fields || [])[formFieldIndex] if (formFieldConfig) { - const fullPath = formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}` + const fullPath = options && options.noPathCombination ? path : (formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}`) const list = get(this.formValue, fullPath, []) list.push(value) @@ -355,10 +355,10 @@ export default class FilterStep extends Step { } } - handleValueListSplice = async (formFieldIndex: number, path: string, index: number, count: number, validation: true | FieldError[]) => { + handleValueListSplice = async (formFieldIndex: number, path: string, index: number, count: number, validation: true | FieldError[], options?: { noPathCombination?: true }) => { const formFieldConfig = (this.props.config.fields || [])[formFieldIndex] if (formFieldConfig) { - const fullPath = formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}` + const fullPath = options && options.noPathCombination ? path : (formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}`) const list = get(this.formValue, fullPath, []) list.splice(index, count) @@ -381,10 +381,11 @@ export default class FilterStep extends Step { }) } } - handleValueListSort = async (formFieldIndex: number, path: string, index: number, sortType: 'up' | 'down', validation: true | FieldError[]) => { + + handleValueListSort = async (formFieldIndex: number, path: string, index: number, sortType: 'up' | 'down', validation: true | FieldError[], options?: { noPathCombination?: true }) => { const formFieldConfig = (this.props.config.fields || [])[formFieldIndex] if (formFieldConfig) { - const fullPath = formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}` + const fullPath = options && options.noPathCombination ? path : (formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}`) const list = listItemMove(get(this.formValue, fullPath, []), index, sortType) set(this.formValue, fullPath, list) @@ -500,11 +501,11 @@ export default class FilterStep extends Step { step={step} config={formFieldConfig} onChange={async (value: any) => { await this.handleChange(formFieldIndex, value) }} - onValueSet={async (path, value, validation) => await this.handleValueSet(formFieldIndex, path, value, validation)} - onValueUnset={async (path, validation) => await this.handleValueUnset(formFieldIndex, path, validation)} - onValueListAppend={async (path, value, validation) => await this.handleValueListAppend(formFieldIndex, path, value, validation)} - onValueListSplice={async (path, index, count, validation) => await this.handleValueListSplice(formFieldIndex, path, index, count, validation)} - onValueListSort={async (path, index, sortType, validation) => await this.handleValueListSort(formFieldIndex, path, index, sortType, validation)} + onValueSet={async (path, value, validation, options) => await this.handleValueSet(formFieldIndex, path, value, validation, options)} + onValueUnset={async (path, validation, options) => await this.handleValueUnset(formFieldIndex, path, validation, options)} + onValueListAppend={async (path, value, validation, options) => await this.handleValueListAppend(formFieldIndex, path, value, validation, options)} + onValueListSplice={async (path, index, count, validation, options) => await this.handleValueListSplice(formFieldIndex, path, index, count, validation, options)} + onValueListSort={async (path, index, sortType, validation, options) => await this.handleValueListSort(formFieldIndex, path, index, sortType, validation, options)} baseRoute={this.props.baseRoute} loadDomain={async (domain: string) => await this.props.loadDomain(domain)} /> diff --git a/src/steps/form/index.tsx b/src/steps/form/index.tsx index e021e8c..ad76d9d 100644 --- a/src/steps/form/index.tsx +++ b/src/steps/form/index.tsx @@ -389,10 +389,10 @@ export default class FormStep extends Step { } } - handleValueSet = async (formFieldIndex: number, path: string, value: any, validation: true | FieldError[]) => { + handleValueSet = async (formFieldIndex: number, path: string, value: any, validation: true | FieldError[], options?: { noPathCombination?: true }) => { const formFieldConfig = (this.props.config.fields || [])[formFieldIndex] if (formFieldConfig) { - const fullPath = formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}` + const fullPath = options && options.noPathCombination ? path : (formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}`) set(this.formValue, fullPath, value) this.setState({ @@ -416,10 +416,10 @@ export default class FormStep extends Step { } } - handleValueUnset = async (formFieldIndex: number, path: string, validation: true | FieldError[]) => { + handleValueUnset = async (formFieldIndex: number, path: string, validation: true | FieldError[], options?: { noPathCombination?: true }) => { const formFieldConfig = (this.props.config.fields || [])[formFieldIndex] if (formFieldConfig) { - const fullPath = formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}` + const fullPath = options && options.noPathCombination ? path : (formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}`) unset(this.formValue, fullPath) this.setState({ @@ -441,10 +441,10 @@ export default class FormStep extends Step { } } - handleValueListAppend = async (formFieldIndex: number, path: string, value: any, validation: true | FieldError[]) => { + handleValueListAppend = async (formFieldIndex: number, path: string, value: any, validation: true | FieldError[], options?: { noPathCombination?: true }) => { const formFieldConfig = (this.props.config.fields || [])[formFieldIndex] if (formFieldConfig) { - const fullPath = formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}` + const fullPath = options && options.noPathCombination ? path : (formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}`) let list = get(this.formValue, fullPath, []) if (!Array.isArray(list)) list = [] @@ -469,10 +469,10 @@ export default class FormStep extends Step { } } - handleValueListSplice = async (formFieldIndex: number, path: string, index: number, count: number, validation: true | FieldError[]) => { + handleValueListSplice = async (formFieldIndex: number, path: string, index: number, count: number, validation: true | FieldError[], options?: { noPathCombination?: true }) => { const formFieldConfig = (this.props.config.fields || [])[formFieldIndex] if (formFieldConfig) { - const fullPath = formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}` + const fullPath = options && options.noPathCombination ? path : (formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}`) const list = get(this.formValue, fullPath, []) list.splice(index, count) @@ -496,10 +496,10 @@ export default class FormStep extends Step { } } - handleValueListSort = async (formFieldIndex: number, path: string, index: number, sortType: 'up' | 'down', validation: true | FieldError[]) => { + handleValueListSort = async (formFieldIndex: number, path: string, index: number, sortType: 'up' | 'down', validation: true | FieldError[], options?: { noPathCombination?: true }) => { const formFieldConfig = (this.props.config.fields || [])[formFieldIndex] if (formFieldConfig) { - const fullPath = formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}` + const fullPath = options && options.noPathCombination ? path : (formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}`) const list = listItemMove(get(this.formValue, fullPath, []), index, sortType) set(this.formValue, fullPath, list) @@ -725,11 +725,11 @@ export default class FormStep extends Step { step={step} config={formFieldConfig} onChange={async (value: any) => { await this.handleChange(formFieldIndex, value) }} - onValueSet={async (path, value, validation) => await this.handleValueSet(formFieldIndex, path, value, validation)} - onValueUnset={async (path, validation) => await this.handleValueUnset(formFieldIndex, path, validation)} - onValueListAppend={async (path, value, validation) => await this.handleValueListAppend(formFieldIndex, path, value, validation)} - onValueListSplice={async (path, index, count, validation) => await this.handleValueListSplice(formFieldIndex, path, index, count, validation)} - onValueListSort={async (path, index, sortType, validation) => await this.handleValueListSort(formFieldIndex, path, index, sortType, validation)} + onValueSet={async (path, value, validation, options) => await this.handleValueSet(formFieldIndex, path, value, validation, options)} + onValueUnset={async (path, validation, options) => await this.handleValueUnset(formFieldIndex, path, validation, options)} + onValueListAppend={async (path, value, validation, options) => await this.handleValueListAppend(formFieldIndex, path, value, validation, options)} + onValueListSplice={async (path, index, count, validation, options) => await this.handleValueListSplice(formFieldIndex, path, index, count, validation, options)} + onValueListSort={async (path, index, sortType, validation, options) => await this.handleValueListSort(formFieldIndex, path, index, sortType, validation, options)} baseRoute={this.props.baseRoute} loadDomain={async (domain: string) => await this.props.loadDomain(domain)} /> -- Gitee From efa24a3ecd6d0d81c181828b4b98c60ff777521a Mon Sep 17 00:00:00 2001 From: cuiwenlong7 Date: Thu, 24 Feb 2022 12:57:11 +0800 Subject: [PATCH 04/10] =?UTF-8?q?feat:=20=E5=8A=A8=E6=80=81=E5=AD=90?= =?UTF-8?q?=E8=A1=A8=E5=8D=95=E6=94=AF=E6=8C=81=E4=B8=A4=E7=A7=8D=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E6=9D=A5=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/detail/importSubform/index.tsx | 9 ++- .../formFields/importSubform/index.tsx | 80 ++++++++++++++----- 2 files changed, 66 insertions(+), 23 deletions(-) diff --git a/src/components/detail/importSubform/index.tsx b/src/components/detail/importSubform/index.tsx index fdd618a..d6fe75c 100644 --- a/src/components/detail/importSubform/index.tsx +++ b/src/components/detail/importSubform/index.tsx @@ -12,10 +12,11 @@ import { ColumnsConfig } from '../../../interface' /** * 子表单配置项 - * - withConfig: 拓展配置 - * - * - enable: 是否开启 - * - * - dataField: (序列化)数据 - * - * - configField: (序列化)配置 + * - configFrom: 配置来源(get用途) + * - * - type: 'data' | 'interface' // 来源类型 + * - * - dataField: 值来源字段 // 仅type为data时生效 + * - * - configField: 配置来源字段 // 仅type为data时生效 + * - * - interface: 来源接口配置 // 仅type为interface时生效 */ export interface ImportSubformFieldConfig extends DetailFieldConfig { type: 'import_subform', diff --git a/src/components/formFields/importSubform/index.tsx b/src/components/formFields/importSubform/index.tsx index 5210cca..0883417 100644 --- a/src/components/formFields/importSubform/index.tsx +++ b/src/components/formFields/importSubform/index.tsx @@ -4,7 +4,7 @@ import { setValue, getValue, getBoolean } from '../../../util/value' import { Field, FieldConfig, FieldError, FieldProps, IField } from '../common' import getALLComponents, { FieldConfigs } from '../' import { IFormItem } from '../../../steps/form' -import { cloneDeep } from 'lodash' +import { cloneDeep, isEqual } from 'lodash' import ConditionHelper from '../../../util/condition' import InterfaceHelper, { InterfaceConfig } from '../../../util/interface' import StatementHelper from '../../../util/statement' @@ -12,7 +12,12 @@ import { ColumnsConfig } from '../../../interface' /** * 子表单配置项 - * - withConfig: 拓展配置 + * - configFrom: 配置来源(get用途) + * - * - type: 'data' | 'interface' // 来源类型 + * - * - dataField: 值来源字段 // 仅type为data时生效 + * - * - configField: 配置项来源字段 // 仅type为data时生效 + * - * - interface: 来源接口配置 // 仅type为interface时生效 + * - withConfig: 拓展配置(set用途) * - * - enable: 是否开启 * - * - dataField: (序列化)数据 * - * - configField: (序列化)配置 @@ -20,6 +25,7 @@ import { ColumnsConfig } from '../../../interface' export interface ImportSubformFieldConfig extends FieldConfig { type: 'import_subform', interface?: InterfaceConfig + configFrom?: ImportSubformConfigFromData | ImportSubformConfigFromInterface withConfig?: { enable: boolean dataField: string @@ -27,7 +33,16 @@ export interface ImportSubformFieldConfig extends FieldConfig { } childColumns?: ColumnsConfig } +interface ImportSubformConfigFromData { + type: 'data' + dataField?: string + configField?: string +} +interface ImportSubformConfigFromInterface { + type: 'interface' + interface?: InterfaceConfig +} export interface IImportSubformField { columns?: ColumnsConfig children: React.ReactNode[] @@ -309,6 +324,24 @@ export default class ImportSubformField extends Field { + let dataToUnstringfy = data + if (Object.prototype.toString.call(data) === '[object String]') { + try { + dataToUnstringfy = JSON.parse(data) + } catch (e) { + console.error('当前动态子表单接口响应数据格式不是合格的json字符串') + dataToUnstringfy = [] + } + } + return dataToUnstringfy + } + renderComponent = (props: IImportSubformField) => { return 您当前使用的UI版本没有实现ImportSubformField组件。 @@ -336,27 +369,36 @@ export default class ImportSubformField extends Field { - let dataToUnstringfy = data - let dataToStringfy = JSON.stringify(data) - if (Object.prototype.toString.call(data) === '[object String]') { - try { - dataToStringfy = data - dataToUnstringfy = JSON.parse(data) - } catch (e) { - console.error('当前动态子表单接口响应数据格式不是合格的json字符串') - dataToUnstringfy = [] - dataToStringfy = '[]' - } - } - (this.props.config.withConfig?.enable && this.props.config.withConfig?.configField) && this.props.onValueSet(this.props.config.withConfig.configField, data, true) - if (dataToStringfy !== JSON.stringify(this.state.fields)) { + const dataToUnstringfy = this.handleDataToUnstringfy(data) + if (this.props.config.withConfig?.enable && this.props.config.withConfig?.configField) this.props.onValueSet(this.props.config.withConfig.configField, data, true) + if (!isEqual(dataToUnstringfy, this.state.fields)) { this.setState({ fields: dataToUnstringfy }) @@ -364,7 +406,7 @@ export default class ImportSubformField extends Field } else { return ( -- Gitee From e193be34d87cad28a4d372f51b755a980da92117 Mon Sep 17 00:00:00 2001 From: cuiwenlong7 Date: Mon, 28 Feb 2022 18:30:14 +0800 Subject: [PATCH 05/10] =?UTF-8?q?feat:=20code=E7=BC=96=E8=BE=91=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/detail/importSubform/index.tsx | 2 +- src/components/formFields/code/index.tsx | 88 +++++++++++++++++++ src/components/formFields/index.tsx | 10 ++- src/index.tsx | 1 + 4 files changed, 97 insertions(+), 4 deletions(-) create mode 100644 src/components/formFields/code/index.tsx diff --git a/src/components/detail/importSubform/index.tsx b/src/components/detail/importSubform/index.tsx index d6fe75c..dbcb395 100644 --- a/src/components/detail/importSubform/index.tsx +++ b/src/components/detail/importSubform/index.tsx @@ -46,7 +46,7 @@ interface IImportSubformFieldState { formData: { status: 'normal' | 'error' | 'loading', message?: string }[] } -export default class ImportSubformField extends DetailField implements IDetailField { +export default class DetailImportSubformField extends DetailField implements IDetailField { // 各表单项对应的类型所使用的UI组件的类 getALLComponents = (type: any): typeof Display => getALLComponents[type] diff --git a/src/components/formFields/code/index.tsx b/src/components/formFields/code/index.tsx new file mode 100644 index 0000000..545c506 --- /dev/null +++ b/src/components/formFields/code/index.tsx @@ -0,0 +1,88 @@ +import React from 'react' +import { Field, FieldConfig, FieldError, IField } from '../common' +import { getBoolean } from '../../../util/value' + +/** + * code编辑器配置项 + * - codeType: 语言类型 + * - height: 代码编辑器高度 + * - theme: 编辑器主题风格 + * - fullScreen: 是否全屏 + */ +export interface CodeFieldConfig extends FieldConfig { + type: 'code' + codeType: 'xml' | 'json' | 'javascript' | 'java' + height: number + theme: 'light' | 'vs-dark' + fullScreen: boolean +} + +export interface ICodeField { + codeType: 'xml' | 'json' | 'javascript' | 'java' + height: number + theme: 'light' | 'vs-dark' + value: string + fullScreen: boolean + onChange: (value: string) => Promise +} + +export default class CodeField extends Field implements IField { + reset: () => Promise = async () => { + const defaults = await this.defaultValue() + return (defaults === undefined) ? '' : defaults + } + + validate = async (value: string): Promise => { + const { + config: { + label, + required + } + } = this.props + + const errors: FieldError[] = [] + + if (getBoolean(required)) { + if (value === '' || value === undefined || value === null || String(value).trim() === '') { + errors.push(new FieldError(`输入${label}`)) + return errors + } + } + + return errors.length ? errors : true + } + + renderComponent = (props: ICodeField) => { + return + 您当前使用的UI版本没有实现CodeField组件。 +
+ +
+
+ } + + render = () => { + const { + value, + config: { + theme, + fullScreen, + height, + codeType + } + } = this.props + + return ( + + { this.renderComponent({ + codeType, + value, + theme, + fullScreen, + height, + onChange: async (value: string) => await this.props.onValueSet('', value, await this.validate(value)) + })} + + ) + } +} diff --git a/src/components/formFields/index.tsx b/src/components/formFields/index.tsx index e7735a6..4419556 100644 --- a/src/components/formFields/index.tsx +++ b/src/components/formFields/index.tsx @@ -23,6 +23,7 @@ import HiddenField from './hidden' import TabsField, { TabsFieldConfig } from './tabs' import MultipleTextField, { MultipleTextFieldConfig } from './multipleText' import CustomField, { CustomFieldConfig } from './custom' +import CodeField, { CodeFieldConfig } from './code' import TextDisplay from './text/display' import RadioDisplay from './radio/display' @@ -67,7 +68,8 @@ export type FieldConfigs = ObjectFieldConfig | TabsFieldConfig | MultipleTextFieldConfig | - CustomFieldConfig + CustomFieldConfig | + CodeFieldConfig export type componentType = 'text' | @@ -93,7 +95,8 @@ export type componentType = 'object' | 'tabs' | 'multiple_text'| - 'custom' + 'custom' | + 'code' export default { text: TextField, @@ -118,7 +121,8 @@ export default { hidden: HiddenField, tabs: TabsField, multiple_text: MultipleTextField, - custom: CustomField + custom: CustomField, + code: CodeField } export const display = { diff --git a/src/index.tsx b/src/index.tsx index 5e8ec9d..699a36d 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -26,6 +26,7 @@ export { default as HiddenField } from './components/formFields/hidden' export { default as TabsField } from './components/formFields/tabs' export { default as MultipleTextField } from './components/formFields/multipleText' export { default as CustomField } from './components/formFields/custom' +export { default as CodeField } from './components/formFields/code' export { default as TextDisplay } from './components/formFields/text/display' export { default as LongTextDisplay } from './components/formFields/longtext/display' -- Gitee From 209efcd56cef7197d6e3d467bd2a6389a0476a4e Mon Sep 17 00:00:00 2001 From: cuiwenlong7 Date: Tue, 1 Mar 2022 18:31:34 +0800 Subject: [PATCH 06/10] =?UTF-8?q?refactor:=20code=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E5=99=A8=E4=BA=A4=E4=BA=92=E9=80=BB=E8=BE=91=E6=94=BE=E5=88=B0?= =?UTF-8?q?renderContainer?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/formFields/code/index.tsx | 86 +++++++++++++++++++++--- 1 file changed, 75 insertions(+), 11 deletions(-) diff --git a/src/components/formFields/code/index.tsx b/src/components/formFields/code/index.tsx index 545c506..dfac081 100644 --- a/src/components/formFields/code/index.tsx +++ b/src/components/formFields/code/index.tsx @@ -1,4 +1,4 @@ -import React from 'react' +import React, { KeyboardEvent } from 'react' import { Field, FieldConfig, FieldError, IField } from '../common' import { getBoolean } from '../../../util/value' @@ -7,26 +7,51 @@ import { getBoolean } from '../../../util/value' * - codeType: 语言类型 * - height: 代码编辑器高度 * - theme: 编辑器主题风格 - * - fullScreen: 是否全屏 + * - fullScreen: 是否支持全屏 */ export interface CodeFieldConfig extends FieldConfig { type: 'code' codeType: 'xml' | 'json' | 'javascript' | 'java' height: number - theme: 'light' | 'vs-dark' + theme: 'white' | 'black' fullScreen: boolean } export interface ICodeField { codeType: 'xml' | 'json' | 'javascript' | 'java' + fullScreenStatus: boolean height: number - theme: 'light' | 'vs-dark' + theme: 'white' | 'black' value: string - fullScreen: boolean onChange: (value: string) => Promise } +/** + * code编辑器配置项 + * - codeType: 语言类型 + * - height: 代码编辑器高度 + * - onResetValue: 编辑器重置为默认值 + * - fullScreen: 是否支持全屏 + * - fullScreenStatus: 编辑器是不是处于全屏状态 + */ +export interface ICodeFieldContainer { + fullScreen: boolean + fullScreenStatus: boolean + theme: 'white' | 'black' + children: React.ReactNode + onResetValue: (value: string) => Promise + keydownCallback: (value: KeyboardEvent) => Promise + enterFull: (value: string) => Promise + exitFull: (value: string) => Promise +} +interface State { + fullScreenStatus: boolean // 编辑器是不是处于全屏状态 +} export default class CodeField extends Field implements IField { + state:State = { + fullScreenStatus: false + } + reset: () => Promise = async () => { const defaults = await this.defaultValue() return (defaults === undefined) ? '' : defaults @@ -52,6 +77,35 @@ export default class CodeField extends Field { + const keyCode = e.keyCode || e.which || e.charCode + const ctrlKey = e.ctrlKey || e.metaKey + if (this.props.config.fullScreen) { + if ((e.key === 'j' || keyCode === 74) && ctrlKey) { + this.enterFull() + } else if ((e.key === 'Escape' || keyCode === 27)) { + this.exitFull() + } + } + } + + enterFull = () => { + this.setState({ fullScreenStatus: true }) + } + + exitFull = () => { + this.setState({ fullScreenStatus: false }) + } + + renderContainer = (props: any) => { + return + 您当前使用的UI版本没有实现CodeField的container组件。 +
+ +
+
+ } + renderComponent = (props: ICodeField) => { return 您当前使用的UI版本没有实现CodeField组件。 @@ -71,16 +125,26 @@ export default class CodeField extends Field - { this.renderComponent({ - codeType, - value, - theme, + {this.renderContainer({ + fullScreenStatus, fullScreen, - height, - onChange: async (value: string) => await this.props.onValueSet('', value, await this.validate(value)) + theme, + onResetValue: async (defaultCodeValue: string) => await this.props.onValueSet('', defaultCodeValue, await this.validate(defaultCodeValue)), + keydownCallback: async (e: KeyboardEvent) => await this.keydownCallback(e), + enterFull: this.enterFull, + exitFull: this.exitFull, + children: this.renderComponent({ + codeType, + fullScreenStatus, + value, + theme, + height, + onChange: async (value: string) => await this.props.onValueSet('', value, await this.validate(value)) + }) })} ) -- Gitee From b5070533a472ee6aeef9135d72ce0b4da472b1cd Mon Sep 17 00:00:00 2001 From: cuiwenlong7 Date: Wed, 2 Mar 2022 10:37:37 +0800 Subject: [PATCH 07/10] =?UTF-8?q?fix:=20code=E7=BC=96=E8=BE=91=E5=99=A8ent?= =?UTF-8?q?erFull=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/formFields/code/index.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/formFields/code/index.tsx b/src/components/formFields/code/index.tsx index dfac081..731af17 100644 --- a/src/components/formFields/code/index.tsx +++ b/src/components/formFields/code/index.tsx @@ -41,8 +41,8 @@ export interface ICodeFieldContainer { children: React.ReactNode onResetValue: (value: string) => Promise keydownCallback: (value: KeyboardEvent) => Promise - enterFull: (value: string) => Promise - exitFull: (value: string) => Promise + enterFull: () => void + exitFull: () => void } interface State { fullScreenStatus: boolean // 编辑器是不是处于全屏状态 -- Gitee From 801796fdcbfa6306aef38b326063d6bff294be6e Mon Sep 17 00:00:00 2001 From: cuiwenlong7 Date: Wed, 2 Mar 2022 22:39:05 +0800 Subject: [PATCH 08/10] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E8=A1=A8?= =?UTF-8?q?=E6=A0=BC=E9=A1=B9=E8=87=AA=E5=AE=9A=E4=B9=89=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/tableColumns/common.tsx | 4 ++ src/components/tableColumns/custom/index.tsx | 76 ++++++++++++++++++++ src/components/tableColumns/index.tsx | 6 +- src/index.tsx | 1 + src/steps/table/index.tsx | 7 +- 5 files changed, 92 insertions(+), 2 deletions(-) create mode 100644 src/components/tableColumns/custom/index.tsx diff --git a/src/components/tableColumns/common.tsx b/src/components/tableColumns/common.tsx index a613f19..3c09f86 100644 --- a/src/components/tableColumns/common.tsx +++ b/src/components/tableColumns/common.tsx @@ -30,6 +30,10 @@ export interface ColumnProps { data: any[], step: number, config: T + // 挂载引用 + column?: React.ReactNode + baseRoute: string + loadDomain: (domain: string) => Promise } interface ColumnState { diff --git a/src/components/tableColumns/custom/index.tsx b/src/components/tableColumns/custom/index.tsx new file mode 100644 index 0000000..15f1d54 --- /dev/null +++ b/src/components/tableColumns/custom/index.tsx @@ -0,0 +1,76 @@ +import React, { RefObject } from 'react' +import Column, { ColumnConfig, ColumnProps, IColumn } from '../common' +import { loadMicroApp, MicroApp } from 'qiankun' +import moment from 'moment' +import { cloneDeep } from 'lodash' + +export interface CustomColumnConfig extends ColumnConfig { + type: 'custom' + entry: string +} + +export default class CustomColumn extends Column implements IColumn { + identifier: string = '' + entry: string = '' + container: RefObject = React.createRef() + customColumn: MicroApp | null = null + + componentDidMount () { + this.loadCustomColumn(this.props.config.entry) + } + + getSnapshotBeforeUpdate () { + const snapshot: string[] = [] + if (this.entry !== this.props.config.entry) { + snapshot.push('entry') + } + return snapshot + } + + componentDidUpdate (_: ColumnProps, __: {}, snapshot: string[]) { + if (snapshot.includes('entry')) { + this.loadCustomColumn(this.props.config.entry) + } else { + if (this.customColumn && this.customColumn.update) { + this.customColumn.update({ + value: this.props.value, + record: this.props.record, + data: cloneDeep(this.props.data), + step: this.props.step, + config: this.props.config, + column: this.props.column, + base: this.props.baseRoute, + loadDomain: this.props.loadDomain + }) + } + } + } + + loadCustomColumn = (entry: string) => { + if (this.container.current && entry) { + this.entry = this.props.config.entry + this.identifier = `custom|${moment().format('x')}|${Math.floor(Math.random() * 1000)}` + this.customColumn = loadMicroApp({ + name: this.identifier, + entry, + container: this.container.current, + props: { + value: this.props.value, + record: this.props.record, + data: cloneDeep(this.props.data), + step: this.props.step, + config: this.props.config, + column: this.props.column, + base: this.props.baseRoute, + loadDomain: this.props.loadDomain + } + }) + } + } + + render = () => { + return ( +
+ ) + } +} diff --git a/src/components/tableColumns/index.tsx b/src/components/tableColumns/index.tsx index aa8159b..ff52f94 100644 --- a/src/components/tableColumns/index.tsx +++ b/src/components/tableColumns/index.tsx @@ -7,6 +7,7 @@ import DatetimeColumn, { DatetimeColumnConfig } from './datetime' import DatetimeRangeColumn, { DatetimeRangeColumnConfig } from './datetimeRange' import MultirowColumn, { MultirowColumnConfig } from './multirowText' import ImageColumn, { ImageColumnConfig } from './image' +import CustomColumn, { CustomColumnConfig } from './custom' export interface componentType { type: 'text' @@ -17,6 +18,7 @@ export interface componentType { | 'Aenum' | 'multirowText' | 'image' + | 'custom' } export type ColumnConfigs = TextColumnConfig @@ -27,6 +29,7 @@ export type ColumnConfigs = TextColumnConfig | NumberColumnConfig | NumberRangeColumnConfig | ImageColumnConfig + | CustomColumnConfig export default { text: TextColumn, @@ -36,5 +39,6 @@ export default { Aenum: EnumColumn, number: NumberColumn, numberRange: NumberRangeColumn, - image: ImageColumn + image: ImageColumn, + custom: CustomColumn } diff --git a/src/index.tsx b/src/index.tsx index 699a36d..c9f3797 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -51,6 +51,7 @@ export { default as NumberRangeColumn } from './components/tableColumns/numberRa export { default as MultirowTextColumn } from './components/tableColumns/multirowText' export { default as DatetimeRangeColumn } from './components/tableColumns/datetimeRange' export { default as ImageColumn } from './components/tableColumns/image' +export { default as CustomColumn } from './components/tableColumns/custom' export { default as FetchStep } from './steps/fetch' export { default as DetailStep } from './steps/detail' diff --git a/src/steps/table/index.tsx b/src/steps/table/index.tsx index 0dad9a4..e910a43 100644 --- a/src/steps/table/index.tsx +++ b/src/steps/table/index.tsx @@ -2,6 +2,7 @@ import React from 'react' import queryString from 'query-string' import { getParam, getParamText, getValue } from '../../util/value' import getALLComponents, { ColumnConfigs } from '../../components/tableColumns' +import Column from '../../components/tableColumns/common' import Step, { StepConfig, StepProps } from '../common' import { ParamConfig } from '../../interface' import ColumnStyleComponent from './common/columnStyle' @@ -245,7 +246,7 @@ interface TableState { */ export default class TableStep extends Step { CCMS = CCMS - getALLComponents = (type: any) => getALLComponents[type] + getALLComponents = (type: any): typeof Column => getALLComponents[type] interfaceHelper = new InterfaceHelper() /** * 页面权限获取状态 @@ -554,11 +555,15 @@ export default class TableStep extends Step { const addfix = ['multirowText'].some((val) => val !== column.field) return {}} record={record} value={value} data={data} step={step} config={column} + column={this} + baseRoute={this.props.baseRoute} + loadDomain={async (domain: string) => await this.props.loadDomain(domain)} /> } -- Gitee From 9ed54352b919755a00b74c34d699503302f6f0b0 Mon Sep 17 00:00:00 2001 From: cuiwenlong7 Date: Mon, 7 Mar 2022 16:11:50 +0800 Subject: [PATCH 09/10] =?UTF-8?q?feat:=20diffCode=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/formFields/code/index.tsx | 4 +- src/components/formFields/diffCode/index.tsx | 147 +++++++++++++++++++ src/components/formFields/index.tsx | 10 +- src/index.tsx | 1 + 4 files changed, 157 insertions(+), 5 deletions(-) create mode 100644 src/components/formFields/diffCode/index.tsx diff --git a/src/components/formFields/code/index.tsx b/src/components/formFields/code/index.tsx index 731af17..69aabb9 100644 --- a/src/components/formFields/code/index.tsx +++ b/src/components/formFields/code/index.tsx @@ -97,11 +97,11 @@ export default class CodeField extends Field { + renderContainer = (props: ICodeFieldContainer) => { return 您当前使用的UI版本没有实现CodeField的container组件。
- +
} diff --git a/src/components/formFields/diffCode/index.tsx b/src/components/formFields/diffCode/index.tsx new file mode 100644 index 0000000..3649f88 --- /dev/null +++ b/src/components/formFields/diffCode/index.tsx @@ -0,0 +1,147 @@ +import React, { KeyboardEvent } from 'react' +import { get } from 'lodash' +import { Field, FieldConfig, FieldError, IField } from '../common' + +/** + * diffCode编辑器配置项 + * - codeType: 语言类型 + * - height: 代码编辑器高度 + * - theme: 编辑器主题风格 + * - fullScreen: 是否支持全屏 + * - originalCodeField: 代码原始值入参字段 + * - modifiedCodeField: 代码修改值入参字段 + */ +export interface DiffCodeFieldConfig extends FieldConfig { + type: 'diffcode' + codeType: 'xml' | 'json' | 'javascript' | 'java' + height: number + theme: 'white' | 'black' + fullScreen: boolean + originalCodeField: string + modifiedCodeField: string +} + +export interface IDiffCodeField { + codeType: 'xml' | 'json' | 'javascript' | 'java' + fullScreenStatus: boolean + height: number + theme: 'white' | 'black' + originalCode: string + modifiedCode: string +} + +/** + * diffCode编辑器配置项 + * - codeType: 语言类型 + * - height: 代码编辑器高度 + * - fullScreen: 是否支持全屏 + * - fullScreenStatus: 编辑器是不是处于全屏状态 + */ +export interface IDiffCodeFieldContainer { + fullScreen: boolean + fullScreenStatus: boolean + theme: 'white' | 'black' + children: React.ReactNode + keydownCallback: (value: KeyboardEvent) => Promise + enterFull: () => void + exitFull: () => void +} +interface DiffCodeFieldValue { + [field: string]: any +} +interface State { + fullScreenStatus: boolean // 编辑器是不是处于全屏状态 +} + +export default class DiffCodeField extends Field implements IField { + state:State = { + fullScreenStatus: false + } + + get: () => Promise = async () => { + if (this.props.config.disabled) return '' + return {} + } + + reset: () => Promise = async () => { + const defaults = await this.defaultValue() + return (defaults === undefined) ? '' : defaults + } + + validate = async (value: DiffCodeFieldValue): Promise => { + return true + } + + keydownCallback = (e: KeyboardEvent) => { + const keyCode = e.keyCode || e.which || e.charCode + const ctrlKey = e.ctrlKey || e.metaKey + if (this.props.config.fullScreen) { + if ((e.key === 'j' || keyCode === 74) && ctrlKey) { + this.enterFull() + } else if ((e.key === 'Escape' || keyCode === 27)) { + this.exitFull() + } + } + } + + enterFull = () => { + this.setState({ fullScreenStatus: true }) + } + + exitFull = () => { + this.setState({ fullScreenStatus: false }) + } + + renderContainer = (props: IDiffCodeFieldContainer) => { + return + 您当前使用的UI版本没有实现CodeField的container组件。 +
+
+
+ } + + renderComponent = (props: IDiffCodeField) => { + return + 您当前使用的UI版本没有实现CodeField组件。 +
+
+
+ } + + render = () => { + const { + value, + config: { + theme, + fullScreen, + height, + codeType, + originalCodeField, + modifiedCodeField + } + } = this.props + const { fullScreenStatus } = this.state + const originalCode = get(value, originalCodeField) || '' + const modifiedCode = get(value, modifiedCodeField) || '' + return ( + + {this.renderContainer({ + fullScreenStatus, + fullScreen, + theme, + keydownCallback: async (e: KeyboardEvent) => await this.keydownCallback(e), + enterFull: this.enterFull, + exitFull: this.exitFull, + children: this.renderComponent({ + codeType, + fullScreenStatus, + originalCode, + modifiedCode, + theme, + height + }) + })} + + ) + } +} diff --git a/src/components/formFields/index.tsx b/src/components/formFields/index.tsx index 4419556..d7e9013 100644 --- a/src/components/formFields/index.tsx +++ b/src/components/formFields/index.tsx @@ -24,6 +24,7 @@ import TabsField, { TabsFieldConfig } from './tabs' import MultipleTextField, { MultipleTextFieldConfig } from './multipleText' import CustomField, { CustomFieldConfig } from './custom' import CodeField, { CodeFieldConfig } from './code' +import DiffCodeField, { DiffCodeFieldConfig } from './diffCode' import TextDisplay from './text/display' import RadioDisplay from './radio/display' @@ -69,7 +70,8 @@ export type FieldConfigs = TabsFieldConfig | MultipleTextFieldConfig | CustomFieldConfig | - CodeFieldConfig + CodeFieldConfig | + DiffCodeFieldConfig export type componentType = 'text' | @@ -96,7 +98,8 @@ export type componentType = 'tabs' | 'multiple_text'| 'custom' | - 'code' + 'code' | + 'diffcode' export default { text: TextField, @@ -122,7 +125,8 @@ export default { tabs: TabsField, multiple_text: MultipleTextField, custom: CustomField, - code: CodeField + code: CodeField, + diffcode: DiffCodeField } export const display = { diff --git a/src/index.tsx b/src/index.tsx index c9f3797..367c2de 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -27,6 +27,7 @@ export { default as TabsField } from './components/formFields/tabs' export { default as MultipleTextField } from './components/formFields/multipleText' export { default as CustomField } from './components/formFields/custom' export { default as CodeField } from './components/formFields/code' +export { default as DiffCodeField } from './components/formFields/diffCode' export { default as TextDisplay } from './components/formFields/text/display' export { default as LongTextDisplay } from './components/formFields/longtext/display' -- Gitee From 788020ec49998ff2ff3be9b733dd7d210c844852 Mon Sep 17 00:00:00 2001 From: cuiwenlong7 Date: Mon, 7 Mar 2022 17:57:52 +0800 Subject: [PATCH 10/10] =?UTF-8?q?feat:=20=E8=A1=A8=E5=8D=95=E9=A1=B9?= =?UTF-8?q?=E9=85=8D=E7=BD=AEdisable=E4=B8=8D=E4=BC=9A=E6=8F=90=E4=BA=A4?= =?UTF-8?q?=E5=88=B0submitData?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/formFields/diffCode/index.tsx | 1 - src/components/formFields/form/index.tsx | 4 ++-- src/components/formFields/group/index.tsx | 4 ++-- src/components/formFields/importSubform/index.tsx | 4 ++-- src/components/formFields/tabs/index.tsx | 4 ++-- src/steps/form/index.tsx | 2 +- 6 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/components/formFields/diffCode/index.tsx b/src/components/formFields/diffCode/index.tsx index 3649f88..eea5d6f 100644 --- a/src/components/formFields/diffCode/index.tsx +++ b/src/components/formFields/diffCode/index.tsx @@ -59,7 +59,6 @@ export default class DiffCodeField extends Field Promise = async () => { - if (this.props.config.disabled) return '' return {} } diff --git a/src/components/formFields/form/index.tsx b/src/components/formFields/form/index.tsx index f56278c..5a07d68 100644 --- a/src/components/formFields/form/index.tsx +++ b/src/components/formFields/form/index.tsx @@ -136,7 +136,7 @@ export default class FormField extends Field extends Field extends Field { if (this.formFields[formFieldIndex]) { const formField = this.formFields[formFieldIndex] const formFieldConfig = (this.props.config.fields || [])[formFieldIndex] - if (formField && formFieldConfig) { + if (formField && formFieldConfig && !formFieldConfig.disabled) { const value = await formField.get() const validation = await formField.validate(value) if (validation !== true) { -- Gitee