From 7fc1598ca4c4a03e0c4ef8ff5589ba61e720f27f Mon Sep 17 00:00:00 2001 From: wangailin Date: Mon, 21 Feb 2022 14:40:10 +0800 Subject: [PATCH 01/34] feat: version 1.2.4 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 91472ce..b1fc05e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ccms", - "version": "1.2.0", + "version": "1.2.4", "description": "ConfigableCMS", "main": "lib/index.js", "module": "dist/index.js", -- Gitee From 77c6aa3b4f09a9944d7f0f45c0ac423b7bc805b3 Mon Sep 17 00:00:00 2001 From: wangailin Date: Wed, 23 Feb 2022 16:07:56 +0800 Subject: [PATCH 02/34] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E8=A1=A8?= =?UTF-8?q?=E5=8D=95=E9=9A=90=E8=97=8F=E9=A1=B9=E6=8F=90=E4=BA=A4=E6=97=B6?= =?UTF-8?q?=E7=9A=84=E6=A0=A1=E9=AA=8C=E9=80=BB=E8=BE=91=EF=BC=9B=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E8=A1=A8=E5=8D=95=E9=A1=B9=E6=A0=A1=E9=AA=8C=E7=9A=84?= =?UTF-8?q?=E6=96=87=E6=A1=88=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/formFields/form/index.tsx | 8 +++++++- src/components/formFields/group/index.tsx | 12 ++++++++++-- src/components/formFields/tabs/index.tsx | 10 +++++++--- src/steps/form/index.tsx | 2 +- 4 files changed, 25 insertions(+), 7 deletions(-) diff --git a/src/components/formFields/form/index.tsx b/src/components/formFields/form/index.tsx index d95ddea..94d287f 100644 --- a/src/components/formFields/form/index.tsx +++ b/src/components/formFields/form/index.tsx @@ -127,6 +127,7 @@ export default class FormField extends Field = [] const formDataList = cloneDeep(this.state.formDataList) @@ -143,6 +144,10 @@ export default class FormField extends Field 0) { - errors.push(new FieldError(`子项中存在${childrenError}个错误。`)) + errors.push(new FieldError(`${this.props.config.label || ''} ${childrenErrorMsg.map(err => `${err.name}:${err.msg}`).join('; ')}`)) } return errors.length ? errors : true @@ -494,6 +499,7 @@ export default class FormField extends Field = [] const formData = cloneDeep(this.state.formData) for (const fieldIndex in (this.props.config.fields || [])) { const formItem = this.formFields[fieldIndex] + const formConfig = this.props.config.fields?.[fieldIndex] if (formItem !== null && formItem !== undefined) { const validation = await formItem.validate(getValue(value, (this.props.config.fields || [])[fieldIndex].field)) - if (validation === true || this.formFieldsMounted[fieldIndex] === false) { + if (validation === true) { formData[fieldIndex] = { status: 'normal' } } else { childrenError++ formData[fieldIndex] = { status: 'error', message: validation[0].message } + childrenErrorMsg.push({ + name: formConfig?.label, + msg: validation[0].message + }) + console.log(formData[fieldIndex], 'group') } } } @@ -88,7 +95,7 @@ export default class GroupField extends Field 0) { - errors.push(new FieldError(`子项中存在${childrenError}个错误。`)) + errors.push(new FieldError(`${this.props.config.label || ''}子项中存在${childrenError}个错误。\n ${childrenErrorMsg.map(err => `${err.name}:${err.msg}`).join('; ')}。`)) } return errors.length ? errors : true @@ -307,6 +314,7 @@ export default class GroupField extends Field { if (!ConditionHelper(formFieldConfig.condition, { record: value, data: this.props.data, step: this.props.step })) { this.formFieldsMounted[formFieldIndex] = false + this.formFields[formFieldIndex] = null return null } let hidden: boolean = true diff --git a/src/components/formFields/tabs/index.tsx b/src/components/formFields/tabs/index.tsx index a32b115..51e252a 100644 --- a/src/components/formFields/tabs/index.tsx +++ b/src/components/formFields/tabs/index.tsx @@ -113,6 +113,7 @@ export default class TabsField extends Field = [] const formDataList = cloneDeep(this.state.formDataList) @@ -127,12 +128,15 @@ export default class TabsField extends Field extends Field 0) { - errors.push(new FieldError(`子项中存在${childrenError}个错误。`)) + errors.push(new FieldError(`${this.props.config.label || ''}子项中存在${childrenError}个错误。\n ${childrenErrorMsg.map(err => `${err.name}:${err.msg}`).join('; ')}。`)) } return errors.length ? errors : true @@ -380,6 +383,7 @@ export default class TabsField extends Field { if (formField && formFieldConfig) { const value = await formField.get() const validation = await formField.validate(value) - if (validation !== true) { console.warn('表单项中存在问题', value, formFieldConfig) this.formData[formFieldIndex] = { status: 'error', message: validation[0].message, name: formFieldConfig.label } @@ -661,6 +660,7 @@ export default class FormStep extends Step { children: fields.map((formFieldConfig, formFieldIndex) => { if (!ConditionHelper(formFieldConfig.condition, { record: formValue, data, step })) { this.formFieldsMounted[formFieldIndex] = false + this.formFields[formFieldIndex] = null return null } let hidden: boolean = true -- Gitee From 7fdd246c933ebbe859615ff3a80639179920d9c6 Mon Sep 17 00:00:00 2001 From: wangailin Date: Wed, 23 Feb 2022 16:09:45 +0800 Subject: [PATCH 03/34] =?UTF-8?q?feat:=20=E8=AF=A6=E6=83=85=E9=A1=B5?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=87=AA=E5=AE=9A=E4=B9=89=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=EF=BC=9B=20=E8=A1=A8=E6=A0=BC=E5=A2=9E=E5=8A=A0=E6=8C=89?= =?UTF-8?q?=E9=92=AE=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/detail/common.tsx | 2 + src/components/detail/custom/index.tsx | 95 ++++++++++++++++++++++++++ src/components/detail/group/index.tsx | 1 + src/components/detail/index.tsx | 11 +-- src/index.tsx | 1 + src/steps/detail/index.tsx | 1 + src/steps/table/index.tsx | 6 ++ 7 files changed, 113 insertions(+), 4 deletions(-) create mode 100644 src/components/detail/custom/index.tsx diff --git a/src/components/detail/common.tsx b/src/components/detail/common.tsx index 57902c1..adcf97c 100644 --- a/src/components/detail/common.tsx +++ b/src/components/detail/common.tsx @@ -76,6 +76,8 @@ export interface DetailFieldProps { data: any[], step: number, config: C + // 挂载引用 + detail?: React.ReactNode // TODO 待删除 onChange: (value: T) => Promise // 事件:设置值 diff --git a/src/components/detail/custom/index.tsx b/src/components/detail/custom/index.tsx new file mode 100644 index 0000000..19a582f --- /dev/null +++ b/src/components/detail/custom/index.tsx @@ -0,0 +1,95 @@ +import React, { RefObject } from 'react' +import { DetailField, DetailFieldConfig, DetailFieldProps, IDetailField } from '../common' +import { loadMicroApp, MicroApp } from 'qiankun' +import moment from 'moment' +import { cloneDeep } from 'lodash' + +export interface CustomDetailConfig extends DetailFieldConfig { + type: 'custom' + entry: string +} + +export default class CustomDtail extends DetailField implements IDetailField { + identifier: string = '' + entry: string = '' + container: RefObject = React.createRef() + customField: MicroApp | null = null + _get: () => Promise = async () => this.props.value + + componentDidMount () { + this.loadCustomField(this.props.config.entry) + } + + getSnapshotBeforeUpdate () { + const snapshot: string[] = [] + if (this.entry !== this.props.config.entry) { + snapshot.push('entry') + } + return snapshot + } + + get = async (): Promise => { + return await this._get() + } + + bindGet = async (get: () => Promise): Promise => { + this._get = get + } + + componentDidUpdate (_: DetailFieldProps, __: {}, snapshot: string[]) { + if (snapshot.includes('entry')) { + this.loadCustomField(this.props.config.entry) + } else { + if (this.customField && this.customField.update) { + this.customField.update({ + value: this.props.value, + record: this.props.record, + data: cloneDeep(this.props.data), + step: this.props.step, + config: this.props.config, + detail: this.props.detail, + onChange: this.props.onChange, + onValueSet: this.props.onValueSet, + onValueUnset: this.props.onValueUnset, + onValueListAppend: this.props.onValueListAppend, + onValueListSplice: this.props.onValueListSplice, + base: this.props.baseRoute, + loadDomain: this.props.loadDomain + }) + } + } + } + + loadCustomField = (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.customField = 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, + detail: this.props.detail, + onChange: this.props.onChange, + onValueSet: this.props.onValueSet, + onValueUnset: this.props.onValueUnset, + onValueListAppend: this.props.onValueListAppend, + onValueListSplice: this.props.onValueListSplice, + base: this.props.baseRoute, + loadDomain: this.props.loadDomain + } + }) + } + } + + render = () => { + return ( +
+ ) + } +} diff --git a/src/components/detail/group/index.tsx b/src/components/detail/group/index.tsx index 1dd5220..6d0dcf1 100644 --- a/src/components/detail/group/index.tsx +++ b/src/components/detail/group/index.tsx @@ -274,6 +274,7 @@ 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)} diff --git a/src/components/detail/index.tsx b/src/components/detail/index.tsx index 24ae057..0d661f1 100644 --- a/src/components/detail/index.tsx +++ b/src/components/detail/index.tsx @@ -2,7 +2,7 @@ import TextField, { TextFieldConfig } from './text' import EnumDetail, { EnumDetailConfig } from './enum' import StatementDetail, { StatementDetailConfig } from './statement' - +import CustomDetail, { CustomDetailConfig } from './custom' import GroupField, { GroupFieldConfig } from './group' import ImportSubformField, { ImportSubformFieldConfig } from './importSubform' @@ -14,19 +14,22 @@ export type DetailFieldConfigs = EnumDetailConfig | StatementDetailConfig | GroupFieldConfig | - ImportSubformFieldConfig + ImportSubformFieldConfig | + CustomDetailConfig export type componentType = 'text' | 'group' | 'detail_enum' | 'statement' | - 'import_subform' + 'import_subform' | + 'custom' export default { group: GroupField, text: TextField, import_subform: ImportSubformField, detail_enum: EnumDetail, - statement: StatementDetail + statement: StatementDetail, + custom: CustomDetail } diff --git a/src/index.tsx b/src/index.tsx index b193a05..5e8ec9d 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -58,6 +58,7 @@ export { default as DetailEunmField } from './components/detail/enum' export { default as DetailStatementField } from './components/detail/statement' export { default as DetailTextField } from './components/detail/text' export { default as DetailImportSubformField } from './components/detail/importSubform' +export { default as CustomDetail } from './components/detail/custom' export { default as HeaderStep } from './steps/header' diff --git a/src/steps/detail/index.tsx b/src/steps/detail/index.tsx index 0ff404c..3823d28 100644 --- a/src/steps/detail/index.tsx +++ b/src/steps/detail/index.tsx @@ -456,6 +456,7 @@ export default class DetailStep extends Step { value={detailFieldConfig.field !== undefined ? getValue(detailValue, detailFieldConfig.field) || detailFieldConfig.defaultValue : undefined} record={detailValue} data={cloneDeep(data)} + detail={this} step={step} config={detailFieldConfig} onChange={async (value: any) => { await this.handleChange(detailFieldIndex, value) }} diff --git a/src/steps/table/index.tsx b/src/steps/table/index.tsx index 66a364d..5df516f 100644 --- a/src/steps/table/index.tsx +++ b/src/steps/table/index.tsx @@ -51,6 +51,7 @@ export interface TableOperationGroupConfig { label?: string level?: 'normal' | 'primary' | 'danger' operations: Array + align: 'left' | 'right' } /** @@ -64,6 +65,7 @@ export interface TableOperationConfig { confirm?: { enable: false } | TableOperationConfirmConfig handle: TableCCMSOperationConfig | TableLinkOperationConfig condition?: ConditionConfig + align: 'left' | 'right' } export interface TableCCMSOperationConfig { @@ -154,6 +156,7 @@ export interface ITableStepTableOperation { export interface ITableStepRowOperationButton { label: string level: 'normal' | 'primary' | 'danger' + align: 'left' | 'right' disabled?: boolean onClick: () => Promise } @@ -164,6 +167,7 @@ export interface ITableStepRowOperationButton { export interface ITableStepRowOperationGroup { label?: string children: React.ReactNode[] + align: 'left' | 'right' } /** @@ -732,6 +736,7 @@ export default class TableStep extends Step { : this.renderRowOperationButtonComponent({ label: operation.label, level: operation.level || 'normal', + align: operation.align, onClick: async () => { await this.handleRowOperation(operation, record) } })} @@ -741,6 +746,7 @@ export default class TableStep extends Step { {this.renderRowOperationGroupComponent({ label: operation.label, + align: operation.align, children: (operation.operations || []).map((operation) => { if (!ConditionHelper(operation.condition, { record, data, step })) { return null -- Gitee From 6c3284b1fa1c4522372da30f49db4db4bad4a776 Mon Sep 17 00:00:00 2001 From: wangailin Date: Wed, 23 Feb 2022 16:58:26 +0800 Subject: [PATCH 04/34] =?UTF-8?q?feat:=20=E7=BD=AE=E7=A9=BA=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=89=8D=E7=BD=AE=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/formFields/form/index.tsx | 2 +- src/components/formFields/group/index.tsx | 2 +- src/components/formFields/tabs/index.tsx | 2 +- src/steps/form/index.tsx | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/formFields/form/index.tsx b/src/components/formFields/form/index.tsx index 94d287f..111ac3c 100644 --- a/src/components/formFields/form/index.tsx +++ b/src/components/formFields/form/index.tsx @@ -499,7 +499,7 @@ export default class FormField extends Field { if (!ConditionHelper(formFieldConfig.condition, { record: value, data: this.props.data, step: this.props.step })) { this.formFieldsMounted[formFieldIndex] = false - this.formFields[formFieldIndex] = null + this.formFields && (this.formFields[formFieldIndex] = null) return null } let hidden: boolean = true diff --git a/src/components/formFields/tabs/index.tsx b/src/components/formFields/tabs/index.tsx index 51e252a..0ed46c2 100644 --- a/src/components/formFields/tabs/index.tsx +++ b/src/components/formFields/tabs/index.tsx @@ -383,7 +383,7 @@ export default class TabsField extends Field { children: fields.map((formFieldConfig, formFieldIndex) => { if (!ConditionHelper(formFieldConfig.condition, { record: formValue, data, step })) { this.formFieldsMounted[formFieldIndex] = false - this.formFields[formFieldIndex] = null + this.formFields && (this.formFields[formFieldIndex] = null) return null } let hidden: boolean = true -- Gitee From 8691169638644f26e173068872e16f1b0a13c9e5 Mon Sep 17 00:00:00 2001 From: zjt Date: Wed, 23 Feb 2022 22:16:26 +0800 Subject: [PATCH 05/34] =?UTF-8?q?feat:=20=E8=A1=A5=E5=85=85treeSelect?= =?UTF-8?q?=E5=92=8Cselect?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/formFields/select/common.tsx | 60 ++++++- .../formFields/select/multiple/index.tsx | 8 +- .../formFields/treeSelect/index.tsx | 162 +++++++++++++----- src/interface.ts | 89 +++++----- 4 files changed, 232 insertions(+), 87 deletions(-) diff --git a/src/components/formFields/select/common.tsx b/src/components/formFields/select/common.tsx index 528b21d..2779ab8 100644 --- a/src/components/formFields/select/common.tsx +++ b/src/components/formFields/select/common.tsx @@ -1,7 +1,29 @@ import { ReactNode } from 'react' -import EnumerationHelper, { EnumerationOptionsConfig } from '../../../util/enumeration' +import EnumerationHelper, { EnumerationOptionsConfig, InterfaceEnumerationOptionsKVConfig, InterfaceEnumerationOptionsListConfig } from '../../../util/enumeration' import InterfaceHelper from '../../../util/interface' import { Field, FieldConfig, FieldProps, IField, Display, DisplayProps } from '../common' +import { + RecordParamConfig, + DataParamConfig, + StepParamConfig, + SourceParamConfig +} from '../../../interface' +import ParamHelper from '../../../util/param' +import { getValue } from '../../../util/value' + +type OptionsConfigDefaultValue = + | RecordParamConfig + | DataParamConfig + | StepParamConfig + | SourceParamConfig; + +interface AutomaticEnumerationOptionsConfig { + from: 'automatic'; + defaultValue?: OptionsConfigDefaultValue; + format?: + | InterfaceEnumerationOptionsKVConfig + | InterfaceEnumerationOptionsListConfig; +} export interface SelectFieldConfig extends FieldConfig { options?: EnumerationOptionsConfig @@ -25,7 +47,7 @@ interface SelectSingleFieldState { export default class SelectField extends Field implements IField { interfaceHelper = new InterfaceHelper() - constructor (props: FieldProps) { + constructor(props: FieldProps) { super(props) this.state = { @@ -33,10 +55,40 @@ export default class SelectField extends Fiel } } + optionsAutomaticValue = (defaultValue: OptionsConfigDefaultValue) => { + if (defaultValue !== undefined) { + return ParamHelper(defaultValue, { record: this.props.record, data: this.props.data, step: this.props.step }) + } + return undefined + } + options = ( - config: EnumerationOptionsConfig | undefined + config: EnumerationOptionsConfig | undefined | AutomaticEnumerationOptionsConfig ) => { if (config) { + if (config.from === 'automatic') { + if (config.defaultValue && config.defaultValue.source && config.defaultValue.field) { + const data = this.optionsAutomaticValue(config.defaultValue) + if (config.format) { + if (config.format.type === 'kv') { + return Object.keys(data).map((key) => ({ + value: key, + label: data[key] + })) + } else if (config.format.type === 'list') { + if (Array.isArray(data)) { + return data.map((item: any) => { + return { + value: getValue(item, (config.format as InterfaceEnumerationOptionsListConfig).keyField), + label: getValue(item, (config.format as InterfaceEnumerationOptionsListConfig).labelField) + } + }) + } + } + } + } + return [] + } EnumerationHelper.options(config, (config, source) => this.interfaceHelper.request(config, source, { record: this.props.record, data: this.props.data, step: this.props.step }, { loadDomain: this.props.loadDomain })).then((options) => { if (JSON.stringify(this.state.options) !== JSON.stringify(options)) { this.setState({ @@ -54,7 +106,7 @@ export default class SelectField extends Fiel export class SelectDisplay extends Display { interfaceHelper = new InterfaceHelper() - constructor (props: DisplayProps) { + constructor(props: DisplayProps) { super(props) this.state = { diff --git a/src/components/formFields/select/multiple/index.tsx b/src/components/formFields/select/multiple/index.tsx index d2dd263..0d84ff1 100644 --- a/src/components/formFields/select/multiple/index.tsx +++ b/src/components/formFields/select/multiple/index.tsx @@ -114,7 +114,13 @@ export default class SelectMultipleField extends SelectField { await this.props.onValueSet('', value, await this.validate(value)) }, + onChange: async (value: string | Array | undefined) => { + let useV = value + if (Array.isArray(useV) && multiple !== true && multiple?.type === 'split') { + useV = useV.join(multiple.split || ',') + } + return await this.props.onValueSet('', useV, await this.validate(useV)) + }, onClear: this.props.config.canClear ? async () => { await this.props.onValueSet('', undefined, await this.validate(undefined)) } : undefined, disabled: getBoolean(disabled), readonly: getBoolean(readonly), diff --git a/src/components/formFields/treeSelect/index.tsx b/src/components/formFields/treeSelect/index.tsx index 6d3973a..6546deb 100644 --- a/src/components/formFields/treeSelect/index.tsx +++ b/src/components/formFields/treeSelect/index.tsx @@ -2,20 +2,42 @@ import React, { ReactNode } from 'react' import { get } from 'lodash' import { Field, FieldConfig, IField, FieldError, FieldProps } from '../common' import InterfaceHelper, { InterfaceConfig } from '../../../util/interface' +import ParamHelper from '../../../util/param' +import { RecordParamConfig, DataParamConfig, StepParamConfig, SourceParamConfig } from '../../../interface' +type OptionsConfigDefaultValue = RecordParamConfig | DataParamConfig | StepParamConfig | SourceParamConfig export interface TreeSelectFieldConfig extends FieldConfig { type: 'tree_select' - treeData?: ManualOptionsConfig | InterfaceOptionsConfig + mode?: 'tree' | 'table' + multiple?: true | TreeSelectMultipleArrayConfig | TreeSelectMultipleSplitConfig, + titleColumn: string, + treeData?: ManualOptionsConfig | InterfaceOptionsConfig | DefaultOptionsConfig +} + +interface TreeSelectMultipleArrayConfig { + type: 'array' +} + +interface TreeSelectMultipleSplitConfig { + type: 'split', + split?: string +} +export interface DefaultOptionsConfig { + from: 'automatic' + defaultValue?: OptionsConfigDefaultValue, + format?: InterfaceOptionsListConfig } export interface ManualOptionsConfig { from: 'manual' defaultIndex?: string | number - data?: Array<{ - value: string | number - title: string - [extra: string]: any - }> + data?: treeTableDataConfig[] +} + +export interface treeTableDataConfig { + value: any + title: string + children: treeTableDataConfig[] } export interface InterfaceOptionsConfig { @@ -36,36 +58,32 @@ export interface InterfaceOptionsListConfig { } export interface ISelectFieldOption { - value: string | number, - title: ReactNode, + key: any + value: any + title: ReactNode children?: Array } -interface treeData { - value: any, - title: string, - children?: treeData[] -} - -interface SelectSingleFieldState { - interfaceOptionsData: treeData[] +interface TreeSelectFieldState { + interfaceOptionsData: ISelectFieldOption[] } export interface ITreeSelectField { - value?: string, + value?: any, treeData: Array - onChange: (value: string) => Promise + titleColumn?: string + onChange: (value: any) => Promise } -export default class TreeSelectField extends Field implements IField { +export default class TreeSelectField extends Field | undefined> { interfaceHelper = new InterfaceHelper() interfaceOptionsConfig: string = '' - state: SelectSingleFieldState = { + state: TreeSelectFieldState = { interfaceOptionsData: [] } - constructor (props: FieldProps) { + constructor(props: FieldProps | undefined>) { super(props) this.state = { @@ -73,17 +91,26 @@ export default class TreeSelectField extends Field { + if (defaultValue !== undefined) { + return ParamHelper(defaultValue, { record: this.props.record, data: this.props.data, step: this.props.step }) + } + return undefined + } + formatTree = (treeList: any, value: string, title: string, children: string) => { - const rsMenu: treeData[] = [] + const rsMenu: ISelectFieldOption[] = [] treeList.forEach((val: any) => { - const theMenu: treeData = { + const theMenu: ISelectFieldOption = { title: '', - value: null + value: null, + key: null } theMenu.title = get(val, title) theMenu.value = get(val, value) + theMenu.key = get(val, value) if (get(val, children)) { theMenu.children = this.formatTree(get(val, children), value, title, children) @@ -95,7 +122,7 @@ export default class TreeSelectField extends Field { if (config) { - if (config.from === 'manual') { + if (config.from === 'automatic') { + if (config.defaultValue && config.defaultValue.source && config.defaultValue.field) { + const data = this.optionsAutomaticValue(config.defaultValue) + if (Array.isArray(data)) { + return this.formatTree( + data, + config.format?.keyField || 'value', + config.format?.titleField || 'title', + config.format?.childrenField || 'children' + ) + } + } + } else if (config.from === 'manual') { if (config.data) { return this.formatTree(config.data, 'value', 'title', 'children') } @@ -151,7 +190,7 @@ export default class TreeSelectField extends Field => { + validate = async (_value: string | Array | undefined): Promise => { const { config: { required @@ -169,11 +208,20 @@ export default class TreeSelectField extends Field { + renderTreeComponent = (props: ITreeSelectField) => { return - 您当前使用的UI版本没有实现TreeSelectSingleField组件的SelectSingle模式。 + 您当前使用的UI版本没有实现TreeSelectField组件的tree模式。
- + +
+
+ } + + renderTableComponent = (props: ITreeSelectField) => { + return + 您当前使用的UI版本没有实现TreeSelectField组件的table模式。 +
+
} @@ -182,24 +230,54 @@ export default class TreeSelectField extends Field - {this.renderComponent({ - value, - treeData: this.state.interfaceOptionsData, - onChange: async (value: string) => await this.props.onValueSet('', value, await this.validate(value)) - })} -
- ) + const temp = this.options(optionsConfig, { record, data, step }) + const props: ITreeSelectField = { + value: undefined, + treeData: this.state.interfaceOptionsData, + onChange: async (value: string | Array | undefined) => { + let useV = value + if (Array.isArray(useV) && multiple !== true && multiple?.type === 'split') { + useV = useV.join(multiple.split || ',') + } + return await this.props.onValueSet('', useV, await this.validate(useV)) + } + } + if (optionsConfig && (optionsConfig.from === 'manual' || optionsConfig.from === 'automatic')) { + props.treeData = temp + } + if (multiple === true || multiple?.type === 'array') { + if (Array.isArray(value)) { + props.value = (value as Array) + } else if (value !== undefined) { + props.value = undefined + console.warn('数组类型的树形选框的值需要是字符串或数值的数组。') + } + } else if (multiple?.type === 'split') { + if (typeof value === 'string') { + props.value = String(value).split(multiple.split || ',') + } else if (value !== undefined) { + props.value = undefined + console.warn('字符串分隔类型的树形选框的值需要是字符串。') + } + } else { + props.value = Array.isArray(value) ? value : undefined + } + + if (mode === 'table') { + props.titleColumn = titleColumn + return this.renderTableComponent(props) + } else { + return this.renderTreeComponent(props) + } } } diff --git a/src/interface.ts b/src/interface.ts index 1f55966..60a20c5 100644 --- a/src/interface.ts +++ b/src/interface.ts @@ -7,75 +7,84 @@ * - content: 内容 */ export interface RichStringConfig { - type: 'plain' | 'markdown' | 'html' - content: string + type: 'plain' | 'markdown' | 'html'; + content: string; } -export type ParamConfig = RecordParamConfig | DataParamConfig | StepParamConfig | SourceParamConfig | URLParamConfig | QueryParamConfig | HashParamConfig | InterfaceParamConfig | StaticParamConfig +export type ParamConfig = + | RecordParamConfig + | DataParamConfig + | StepParamConfig + | SourceParamConfig + | URLParamConfig + | QueryParamConfig + | HashParamConfig + | InterfaceParamConfig + | StaticParamConfig; -interface RecordParamConfig { - source: 'record' - field: string +export interface RecordParamConfig { + source: 'record'; + field: string; } -interface DataParamConfig { - source: 'data' - field: string +export interface DataParamConfig { + source: 'data'; + field: string; } -interface StepParamConfig { - source: 'step' - step: number - field: string +export interface StepParamConfig { + source: 'step'; + step: number; + field: string; } -interface SourceParamConfig { - source: 'source', - field: string +export interface SourceParamConfig { + source: 'source'; + field: string; } interface URLParamConfig { - source: 'url', - field: string + source: 'url'; + field: string; } interface QueryParamConfig { - source: 'query', - filed: any + source: 'query'; + filed: any; } interface HashParamConfig { - source: 'hash', - filed: any + source: 'hash'; + filed: any; } interface InterfaceParamConfig { - source: 'interface', + source: 'interface'; // api: { // url: string, // method: 'POST', // contentType: 'json', // withCredentials: true // }, - api: object, - apiResponse: string + api: object; + apiResponse: string; } interface StaticParamConfig { - source: 'static', - value: any + source: 'static'; + value: any; } /** * 表单/详情分栏配置定义 -* - * type: 分栏类型 -* - * - * span: 固定分栏 -* - * - * width: 宽度分栏 -* - * value: 分栏相关配置值 -* - * wrap: 分栏后是否换行 -* - * gap: 分栏边距 -*/ + * - * type: 分栏类型 + * - * - * span: 固定分栏 + * - * - * width: 宽度分栏 + * - * value: 分栏相关配置值 + * - * wrap: 分栏后是否换行 + * - * gap: 分栏边距 + */ export interface ColumnsConfig { - enable?: boolean - type?: 'span' | 'width' - value?: number | string, - wrap?: boolean - gap?: number | string - rowGap?: number | string + enable?: boolean; + type?: 'span' | 'width'; + value?: number | string; + wrap?: boolean; + gap?: number | string; + rowGap?: number | string; } -- Gitee From 23d2ec3ad3b30c2a549bb6e41ace5243472402f5 Mon Sep 17 00:00:00 2001 From: zjt Date: Thu, 24 Feb 2022 10:54:10 +0800 Subject: [PATCH 06/34] =?UTF-8?q?fix:=20=E8=A1=A5=E5=85=85export?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/util/enumeration.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/util/enumeration.ts b/src/util/enumeration.ts index 0b3c41d..f56f413 100644 --- a/src/util/enumeration.ts +++ b/src/util/enumeration.ts @@ -1,5 +1,5 @@ -import { InterfaceConfig } from "./interface"; -import { getValue } from "./value"; +import { InterfaceConfig } from './interface' +import { getValue } from './value' export type EnumerationOptionsConfig = ManualEnumerationOptionsConfig | InterfaceEnumerationOptionsConfig @@ -18,11 +18,11 @@ interface InterfaceEnumerationOptionsConfig { format?: InterfaceEnumerationOptionsKVConfig | InterfaceEnumerationOptionsListConfig } -interface InterfaceEnumerationOptionsKVConfig { +export interface InterfaceEnumerationOptionsKVConfig { type: 'kv' } -interface InterfaceEnumerationOptionsListConfig { +export interface InterfaceEnumerationOptionsListConfig { type: 'list' keyField: string labelField: string @@ -74,4 +74,4 @@ export default class EnumerationHelper { } return await EnumerationHelper._instance.options(config, interfaceRequire) } -} \ No newline at end of file +} -- Gitee From b021c0b56c3dbef7266b8abe530b482b33c14d69 Mon Sep 17 00:00:00 2001 From: wangailin Date: Mon, 24 Jan 2022 17:13:56 +0800 Subject: [PATCH 07/34] =?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 08/34] =?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 09/34] =?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 10/34] =?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 f597cd1d664e2317b9f4ea9b0e1fcf47e77c343a Mon Sep 17 00:00:00 2001 From: zjt Date: Thu, 24 Feb 2022 21:07:23 +0800 Subject: [PATCH 11/34] =?UTF-8?q?peat:=20=E4=BF=AE=E6=94=B9=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E5=90=8D&=E5=85=BC=E5=AE=B9mini?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/formFields/select/common.tsx | 12 +++--- .../formFields/treeSelect/index.tsx | 42 ++++++++++++++----- 2 files changed, 37 insertions(+), 17 deletions(-) diff --git a/src/components/formFields/select/common.tsx b/src/components/formFields/select/common.tsx index 2779ab8..550175d 100644 --- a/src/components/formFields/select/common.tsx +++ b/src/components/formFields/select/common.tsx @@ -19,7 +19,7 @@ type OptionsConfigDefaultValue = interface AutomaticEnumerationOptionsConfig { from: 'automatic'; - defaultValue?: OptionsConfigDefaultValue; + sourceConfig?: OptionsConfigDefaultValue; format?: | InterfaceEnumerationOptionsKVConfig | InterfaceEnumerationOptionsListConfig; @@ -55,9 +55,9 @@ export default class SelectField extends Fiel } } - optionsAutomaticValue = (defaultValue: OptionsConfigDefaultValue) => { - if (defaultValue !== undefined) { - return ParamHelper(defaultValue, { record: this.props.record, data: this.props.data, step: this.props.step }) + optionsAutomaticValue = (sourceConfig: OptionsConfigDefaultValue) => { + if (sourceConfig !== undefined) { + return ParamHelper(sourceConfig, { record: this.props.record, data: this.props.data, step: this.props.step }) } return undefined } @@ -67,8 +67,8 @@ export default class SelectField extends Fiel ) => { if (config) { if (config.from === 'automatic') { - if (config.defaultValue && config.defaultValue.source && config.defaultValue.field) { - const data = this.optionsAutomaticValue(config.defaultValue) + if (config.sourceConfig && config.sourceConfig.source && config.sourceConfig.field) { + const data = this.optionsAutomaticValue(config.sourceConfig) if (config.format) { if (config.format.type === 'kv') { return Object.keys(data).map((key) => ({ diff --git a/src/components/formFields/treeSelect/index.tsx b/src/components/formFields/treeSelect/index.tsx index 6546deb..405d701 100644 --- a/src/components/formFields/treeSelect/index.tsx +++ b/src/components/formFields/treeSelect/index.tsx @@ -10,8 +10,8 @@ export interface TreeSelectFieldConfig extends FieldConfig { type: 'tree_select' mode?: 'tree' | 'table' multiple?: true | TreeSelectMultipleArrayConfig | TreeSelectMultipleSplitConfig, - titleColumn: string, - treeData?: ManualOptionsConfig | InterfaceOptionsConfig | DefaultOptionsConfig + titleColumn?: string, + treeData?: ManualOptionsConfig | InterfaceOptionsConfig | AutomaticOptionsConfig } interface TreeSelectMultipleArrayConfig { @@ -22,9 +22,9 @@ interface TreeSelectMultipleSplitConfig { type: 'split', split?: string } -export interface DefaultOptionsConfig { +export interface AutomaticOptionsConfig { from: 'automatic' - defaultValue?: OptionsConfigDefaultValue, + sourceConfig?: OptionsConfigDefaultValue, format?: InterfaceOptionsListConfig } @@ -91,9 +91,9 @@ export default class TreeSelectField extends Field { - if (defaultValue !== undefined) { - return ParamHelper(defaultValue, { record: this.props.record, data: this.props.data, step: this.props.step }) + optionsAutomatic = (sourceConfig: OptionsConfigDefaultValue) => { + if (sourceConfig !== undefined) { + return ParamHelper(sourceConfig, { record: this.props.record, data: this.props.data, step: this.props.step }) } return undefined } @@ -122,7 +122,7 @@ export default class TreeSelectField extends Field { if (config) { if (config.from === 'automatic') { - if (config.defaultValue && config.defaultValue.source && config.defaultValue.field) { - const data = this.optionsAutomaticValue(config.defaultValue) + if (config.sourceConfig && config.sourceConfig.source && config.sourceConfig.field) { + const data = this.optionsAutomatic(config.sourceConfig) if (Array.isArray(data)) { return this.formatTree( data, @@ -208,6 +208,15 @@ export default class TreeSelectField extends Field { + return + 您当前使用的UI版本没有实现TreeSelectSingleField组件的SelectSingle模式。 +
+ +
+
+ } + renderTreeComponent = (props: ITreeSelectField) => { return 您当前使用的UI版本没有实现TreeSelectField组件的tree模式。 @@ -255,6 +264,7 @@ export default class TreeSelectField extends Field) @@ -276,8 +286,18 @@ export default class TreeSelectField extends Field + {this.renderComponent({ + value, + treeData: this.state.interfaceOptionsData, + onChange: async (value: string) => await this.props.onValueSet('', value, await this.validate(value)) + })} + + ) } } } -- Gitee From 0501370816a331b77266d761247cf1fc19ab05b2 Mon Sep 17 00:00:00 2001 From: zjt Date: Fri, 25 Feb 2022 10:53:05 +0800 Subject: [PATCH 12/34] =?UTF-8?q?fix:=20=E5=8E=BB=E9=99=A4debug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/formFields/treeSelect/index.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/formFields/treeSelect/index.tsx b/src/components/formFields/treeSelect/index.tsx index 405d701..33433a2 100644 --- a/src/components/formFields/treeSelect/index.tsx +++ b/src/components/formFields/treeSelect/index.tsx @@ -264,7 +264,6 @@ export default class TreeSelectField extends Field) -- Gitee From 3c1ebc2fea83b79c67b0691479141a7f03cf21a1 Mon Sep 17 00:00:00 2001 From: zjt Date: Fri, 25 Feb 2022 15:31:45 +0800 Subject: [PATCH 13/34] =?UTF-8?q?fix:=20select=E5=85=BC=E5=AE=B9=E5=80=BC?= =?UTF-8?q?=E4=B8=BA=E7=A9=BA=E5=AD=97=E7=AC=A6=E4=B8=B2=E7=9A=84=E6=83=85?= =?UTF-8?q?=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- src/components/formFields/select/multiple/index.tsx | 2 +- src/components/formFields/treeSelect/index.tsx | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index b1fc05e..a420bb7 100644 --- a/package.json +++ b/package.json @@ -85,4 +85,4 @@ "react": "^16.13.1", "react-dom": "^16.13.1" } -} +} \ No newline at end of file diff --git a/src/components/formFields/select/multiple/index.tsx b/src/components/formFields/select/multiple/index.tsx index 0d84ff1..9254fde 100644 --- a/src/components/formFields/select/multiple/index.tsx +++ b/src/components/formFields/select/multiple/index.tsx @@ -135,7 +135,7 @@ export default class SelectMultipleField extends SelectField Date: Fri, 25 Feb 2022 18:35:50 +0800 Subject: [PATCH 14/34] =?UTF-8?q?feat:=20=E5=AD=97=E7=AC=A6=E5=88=86?= =?UTF-8?q?=E9=9A=94=E5=A2=9E=E5=8A=A0=E5=80=BC=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../formFields/select/multiple/index.tsx | 10 ++++--- .../formFields/treeSelect/index.tsx | 6 +++-- src/util/value.ts | 26 +++++++++++++++++-- 3 files changed, 34 insertions(+), 8 deletions(-) diff --git a/src/components/formFields/select/multiple/index.tsx b/src/components/formFields/select/multiple/index.tsx index 9254fde..262c998 100644 --- a/src/components/formFields/select/multiple/index.tsx +++ b/src/components/formFields/select/multiple/index.tsx @@ -1,5 +1,5 @@ import React from 'react' -import { getBoolean } from '../../../../util/value' +import { getBoolean, transformValueType } from '../../../../util/value' import { FieldError } from '../../common' import SelectField, { ISelectFieldOption, SelectFieldConfig } from '../common' @@ -17,7 +17,8 @@ interface SelectMultipleArrayConfig { interface SelectMultipleSplitConfig { type: 'split', - split?: string + split?: string, + valueType?: string } export interface ISelectMultipleField { @@ -136,7 +137,7 @@ export default class SelectMultipleField extends SelectField option.value) props.value.filter((v) => { - if (props.options.map((option) => option.value).includes(v.toString())) { + if (values.includes(v)) { return true } else { console.warn(`选择框的当前值中${v}不在选项中。`) diff --git a/src/components/formFields/treeSelect/index.tsx b/src/components/formFields/treeSelect/index.tsx index 21b5be9..9ed3fa9 100644 --- a/src/components/formFields/treeSelect/index.tsx +++ b/src/components/formFields/treeSelect/index.tsx @@ -4,6 +4,7 @@ import { Field, FieldConfig, IField, FieldError, FieldProps } from '../common' import InterfaceHelper, { InterfaceConfig } from '../../../util/interface' import ParamHelper from '../../../util/param' import { RecordParamConfig, DataParamConfig, StepParamConfig, SourceParamConfig } from '../../../interface' +import { transformValueType } from '../../../util/value' type OptionsConfigDefaultValue = RecordParamConfig | DataParamConfig | StepParamConfig | SourceParamConfig export interface TreeSelectFieldConfig extends FieldConfig { @@ -20,7 +21,8 @@ interface TreeSelectMultipleArrayConfig { interface TreeSelectMultipleSplitConfig { type: 'split', - split?: string + split?: string, + valueType?: string } export interface AutomaticOptionsConfig { from: 'automatic' @@ -273,7 +275,7 @@ export default class TreeSelectField extends Field { + switch (type) { + case 'string': + return list.map(v => String(v)) + + case 'number': + return list.map(v => +v) + + case 'boolean': + return list.map(v => Boolean(v)) + + default: + return list + } +} -- Gitee From e193be34d87cad28a4d372f51b755a980da92117 Mon Sep 17 00:00:00 2001 From: cuiwenlong7 Date: Mon, 28 Feb 2022 18:30:14 +0800 Subject: [PATCH 15/34] =?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 16/34] =?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 17/34] =?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 18/34] =?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 86287838868296e3c0e4ed2837dbfed054ca9aea Mon Sep 17 00:00:00 2001 From: wangailin Date: Fri, 4 Mar 2022 14:46:33 +0800 Subject: [PATCH 19/34] =?UTF-8?q?feat:=20=E8=A1=A8=E6=A0=BC=E5=88=97?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=8F=9C=E5=8D=95=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/steps/table/index.tsx | 224 +++++++++++++++++++++++++++----------- 1 file changed, 162 insertions(+), 62 deletions(-) diff --git a/src/steps/table/index.tsx b/src/steps/table/index.tsx index 0dad9a4..c4c317d 100644 --- a/src/steps/table/index.tsx +++ b/src/steps/table/index.tsx @@ -24,9 +24,10 @@ export interface TableConfig extends StepConfig { primary: string columns: ColumnConfigs[] operations?: { - tableOperations?: Array - rowOperations?: Array - multirowOperations?: Array + tableOperations?: Array + leftTableOperations?: Array + rowOperations?: Array + multirowOperations?: Array } pagination?: { mode: 'none' | 'client' | 'server' @@ -43,6 +44,11 @@ export interface TableConfig extends StepConfig { } } +/** + * 表格步骤-菜单配置 + */ +export type TableOperationsType = TableOperationConfig | TableOperationGroupConfig | TableOperationDropdownConfig + /** * 表格步骤-操作配置文件格式 */ @@ -54,6 +60,17 @@ export interface TableOperationGroupConfig { align: 'left' | 'right' } +/** + * 表格步骤-操作配置文件下拉菜单 + */ +export interface TableOperationDropdownConfig { + type: 'dropdown' + label?: string + level?: 'normal' | 'primary' | 'danger' + operations: Array + align: 'left' | 'right' +} + /** * 表格步骤-操作配置文件格式 */ @@ -101,6 +118,12 @@ interface TableOperationConfirmConfig { cancelText: string } +export interface DescriptionConfig { + type: 'text' | 'tooltip' | 'modal' + label: string | undefined + content: React.ReactNode + showIcon: boolean +} /** * 表格步骤组件 - UI渲染方法 - 入参 * - data: 数据 @@ -117,13 +140,9 @@ export interface ITable { onChange: (page: number, pageSize: number) => void } tableOperations: React.ReactNode | null + leftTableOperations: React.ReactNode | null multirowOperations: React.ReactNode | null, - description?: { - type: 'text' | 'tooltip' | 'modal' - label: string | undefined - content: React.ReactNode - showIcon: boolean - } + description?: DescriptionConfig } /** @@ -459,6 +478,18 @@ export default class TableStep extends Step {
} + renderRowOperationDropdownComponent = (props: ITableStepRowOperationGroup) => { + return + 您当前使用的UI版本没有实现Table组件的OperationDropdown部分。 + + } + + renderRowOperationDropdownItemComponent = (props: ITableStepRowOperationGroupItem) => { + return + 您当前使用的UI版本没有实现Table组件的OperationDropdownItem部分。 + + } + renderTableOperationComponent = (props: ITableStepTableOperation) => { return 您当前使用的UI版本没有实现Table组件的OperationButton部分。 @@ -482,7 +513,19 @@ export default class TableStep extends Step { 您当前使用的UI版本没有实现Table组件的OperationGroupItem部分。 } - + + renderTableOperationDropdownComponent = (props: ITableStepTableOperationGroup) => { + return + 您当前使用的UI版本没有实现Table组件的OperationDropdown部分。 + + } + + renderTableOperationDropdownItemComponent = (props: ITableStepTableOperationGroupItem) => { + return + 您当前使用的UI版本没有实现Table组件的OperationDropdownItem部分。 + + } + renderOperationModal = (props: ITableStepOperationModal) => { const mask = document.createElement('DIV') mask.style.position = 'fixed' @@ -500,7 +543,80 @@ export default class TableStep extends Step { document.body.appendChild(mask) } - render() { + tableOperations = (tabOperations: Array, getDate: Array<{}>) => { + const { + pageAuth + } = this.state + return tabOperations.length > 0 + ? this.renderTableOperationComponent({ + children: tabOperations.map((operation: TableOperationsType, index: number) => { + if (operation.type === 'button') { + let hidden = false + if (operation.handle && operation.handle.type === 'ccms') { + hidden = operation.handle.page === undefined || !pageAuth[operation.handle.page.toString()] + operation.handle.page !== undefined && this.checkPageAuth(operation.handle.page.toString()) + } + + return hidden + ? + : + {this.renderTableOperationButtonComponent({ + label: operation.label, + level: operation.level || 'normal', + onClick: async () => { + await this.handleRowOperation(operation, getDate) + } + })} + + } else if (operation.type === 'group') { + return + {this.renderTableOperationGroupComponent({ + label: operation.label, + children: (operation.operations || []).map((operation) => { + let hidden = false + if (operation.handle && operation.handle.type === 'ccms') { + hidden = operation.handle.page === undefined || !pageAuth[operation.handle.page.toString()] + operation.handle.page !== undefined && this.checkPageAuth(operation.handle.page.toString()) + } + return hidden + ? null + : this.renderTableOperationGroupItemComponent({ + label: operation.label, + level: operation.level || 'normal', + onClick: async () => { await this.handleRowOperation(operation, getDate) } + }) + }) + })} + + } else if (operation.type === 'dropdown') { + return + {this.renderTableOperationDropdownComponent({ + label: operation.label, + children: (operation.operations || []).map((operation) => { + let hidden = false + if (operation.handle && operation.handle.type === 'ccms') { + hidden = operation.handle.page === undefined || !pageAuth[operation.handle.page.toString()] + operation.handle.page !== undefined && this.checkPageAuth(operation.handle.page.toString()) + } + return hidden + ? null + : this.renderTableOperationDropdownItemComponent({ + label: operation.label, + level: operation.level || 'normal', + onClick: async () => { await this.handleRowOperation(operation, getDate) } + }) + }) + })} + + } else { + return + } + }) + }) + : null + } + + render () { const { config: { field, @@ -565,57 +681,13 @@ export default class TableStep extends Step { } } }), - tableOperations: operations && operations.tableOperations - ? this.renderTableOperationComponent({ - children: operations.tableOperations.map((operation, index) => { - if (operation.type === 'button') { - let hidden = false - if (operation.handle && operation.handle.type === 'ccms') { - hidden = operation.handle.page === undefined || !pageAuth[operation.handle.page.toString()] - operation.handle.page !== undefined && this.checkPageAuth(operation.handle.page.toString()) - } - - return hidden - ? - : - {this.renderTableOperationButtonComponent({ - label: operation.label, - level: operation.level || 'normal', - onClick: async () => { - await this.handleRowOperation(operation, getDate) - } - })} - - } else if (operation.type === 'group') { - return - {this.renderTableOperationGroupComponent({ - label: operation.label, - children: (operation.operations || []).map((operation) => { - let hidden = false - if (operation.handle && operation.handle.type === 'ccms') { - hidden = operation.handle.page === undefined || !pageAuth[operation.handle.page.toString()] - operation.handle.page !== undefined && this.checkPageAuth(operation.handle.page.toString()) - } - return hidden - ? null - : this.renderTableOperationGroupItemComponent({ - label: operation.label, - level: operation.level || 'normal', - onClick: async () => { await this.handleRowOperation(operation, getDate) } - }) - }) - })} - - } else { - return - } - }) - }) - : null, + tableOperations: this.tableOperations(operations?.tableOperations || [], getDate), + leftTableOperations: this.tableOperations(operations?.leftTableOperations || [], getDate), multirowOperations: null } - if(description) { - if(description.type === 'text') { + + if (description) { + if (description.type === 'text') { props.description = { type: 'text', label: StatementHelper(description.label, { data: this.props.data, step: this.props.step }), @@ -637,7 +709,7 @@ export default class TableStep extends Step { showIcon: description.showIcon } } - if(description.content !== undefined) { + if (description.content !== undefined) { const descriptionType = description.mode switch (descriptionType) { case 'plain': @@ -647,7 +719,7 @@ export default class TableStep extends Step { props.description && (props.description.content =
) break case 'html': - props.description && (props.description.content =
) + props.description && (props.description.content =
) break } } @@ -738,6 +810,34 @@ export default class TableStep extends Step { })}
) + } else if (operation.type === 'dropdown') { + return ( + + {this.renderRowOperationDropdownComponent({ + label: operation.label, + align: operation.align, + children: (operation.operations || []).map((operation) => { + if (!ConditionHelper(operation.condition, { record, data, step })) { + return null + } + + let hidden = false + if (operation.handle && operation.handle.type === 'ccms') { + hidden = operation.handle.page === undefined || !pageAuth[operation.handle.page.toString()] + operation.handle.page !== undefined && this.checkPageAuth(operation.handle.page.toString()) + } + + return hidden + ? null + : this.renderRowOperationDropdownItemComponent({ + label: operation.label, + level: operation.level || 'normal', + onClick: async () => { await this.handleRowOperation(operation, record) } + }) + }) + })} + + ) } else { return } -- Gitee From 9ed54352b919755a00b74c34d699503302f6f0b0 Mon Sep 17 00:00:00 2001 From: cuiwenlong7 Date: Mon, 7 Mar 2022 16:11:50 +0800 Subject: [PATCH 20/34] =?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 21/34] =?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 From 061b589558c718d0e9bc263d847cd96b37b3b417 Mon Sep 17 00:00:00 2001 From: wangailin Date: Mon, 7 Mar 2022 21:34:03 +0800 Subject: [PATCH 22/34] =?UTF-8?q?feat:=20=E8=A1=A8=E6=A0=BC=E9=A1=B9?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8F=AF=E8=B7=B3=E8=BD=AC=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/tableColumns/text/index.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/components/tableColumns/text/index.tsx b/src/components/tableColumns/text/index.tsx index 639f6fc..9581be7 100644 --- a/src/components/tableColumns/text/index.tsx +++ b/src/components/tableColumns/text/index.tsx @@ -3,10 +3,12 @@ import Column, { ColumnConfig } from '../common' export interface TextColumnConfig extends ColumnConfig { type: 'text' + linkUrl: boolean } export interface ITextColumn { value: string + linkUrl: boolean } export default class TextColumn extends Column { @@ -31,11 +33,17 @@ export default class TextColumn extends Column { } render = () => { + const { + config: { + linkUrl + } + } = this.props + const value = this.getValue() return ( - {this.renderComponent({ value })} + {this.renderComponent({ value, linkUrl })} ) } -- Gitee From 0a1358b0aaf79b737dace629a00db2f702fa29ed Mon Sep 17 00:00:00 2001 From: wangailin Date: Wed, 9 Mar 2022 15:50:02 +0800 Subject: [PATCH 23/34] =?UTF-8?q?feat:=20[form]=E6=96=B0=E5=A2=9E=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E6=8C=89=E9=92=AE=E6=B7=BB=E5=8A=A0=E6=8C=89?= =?UTF-8?q?=E9=92=AE=E6=8F=90=E4=BA=A4=E6=98=AF=E5=90=A6=E9=AA=8C=E8=AF=81?= =?UTF-8?q?=E8=A1=A8=E5=8D=95=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/steps/form/index.tsx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/steps/form/index.tsx b/src/steps/form/index.tsx index 5be24f0..54c2a72 100644 --- a/src/steps/form/index.tsx +++ b/src/steps/form/index.tsx @@ -79,6 +79,7 @@ export interface ActionConfig { type: 'submit' | 'cancel' | 'ccms', label: string, mode: 'normal' | 'primary' | 'link', + submitValidate: boolean condition?: ConditionConfig handle?: OperationConfig callback?: { @@ -620,6 +621,7 @@ export default class FormStep extends Step { onClick: () => this.handleCancel() })) } else { + const submitValidate = actions[index].submitValidate const OperationHelperWrapper = { this.renderButtonComponent({ label: actions[index].label || '', mode: actions[index].mode, - onClick + onClick: submitValidate + ? async () => { + await this.handleValidations() + console.info('表单参数信息', this.submitData, this.state.formValue, this.formData) + if (this.canSubmit) { + onClick() + } + } + : onClick }) )} -- Gitee From a9e9f28131550c54713363f30619f4328508a5bf Mon Sep 17 00:00:00 2001 From: wangailin Date: Wed, 9 Mar 2022 15:51:36 +0800 Subject: [PATCH 24/34] =?UTF-8?q?feat:=20[table]=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E6=93=8D=E4=BD=9C=E6=A0=8F=E4=BD=8D=E7=BD=AE=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/steps/table/index.tsx | 47 +++++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/src/steps/table/index.tsx b/src/steps/table/index.tsx index 72111dc..0e733cb 100644 --- a/src/steps/table/index.tsx +++ b/src/steps/table/index.tsx @@ -22,6 +22,7 @@ export interface TableConfig extends StepConfig { label: string primary: string columns: ColumnConfigs[] + rowOperationsPosition: 'left' operations?: { tableOperations?: Array rowOperations?: Array @@ -228,7 +229,7 @@ export default class TableStep extends Step { /* 服务端分页情况下页码溢出标识:页码溢出时退回重新请求,此标识符用于防止死循环判断 */ pageOverflow: boolean = false - constructor(props: StepProps) { + constructor (props: StepProps) { super(props) this.state = { @@ -448,12 +449,13 @@ export default class TableStep extends Step { document.body.appendChild(mask) } - render() { + render () { const { config: { field, label, width, + rowOperationsPosition, primary, columns, operations, @@ -503,6 +505,7 @@ export default class TableStep extends Step { const addfix = ['multirowText'].some((val) => val !== column.field) return { }} record={record} value={value} data={data} @@ -591,7 +594,7 @@ export default class TableStep extends Step { } if (operations && operations.rowOperations && operations.rowOperations.length > 0) { - props.columns.push({ + const rowOperationData: ITableColumn = { field: 'ccms-table-rowOperation', label: '操作', align: 'left', @@ -657,7 +660,13 @@ export default class TableStep extends Step { return } } - }) + } + + if (rowOperationsPosition === 'left') { + props.columns.unshift(rowOperationData) + } else { + props.columns.push(rowOperationData) + } } const CCMS = this.CCMS @@ -668,11 +677,11 @@ export default class TableStep extends Step { {operationEnable && ( operationTarget === 'current' ? ( - this.renderOperationModal({ - title: operationTitle, - width, - visible: operationVisible, - children: ( + this.renderOperationModal({ + title: operationTitle, + width, + visible: operationVisible, + children: ( { } }} /> - ), - onClose: () => { - const { operation } = this.state - operation.enable = false - operation.visible = false - this.setState({ operation }) - } - }) - ) + ), + onClose: () => { + const { operation } = this.state + operation.enable = false + operation.visible = false + this.setState({ operation }) + } + }) + ) : ( { } }} /> - ) + ) )}
) -- Gitee From e9fd1de76293cbd9601fdc587a353a43ac8c5222 Mon Sep 17 00:00:00 2001 From: wangailin Date: Wed, 9 Mar 2022 17:40:53 +0800 Subject: [PATCH 25/34] docs: update version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f8968d7..ae9e8e6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ccms", - "version": "1.2.2", + "version": "1.2.3", "description": "ConfigableCMS", "main": "lib/index.js", "module": "dist/index.js", -- Gitee From 2880f2240ac6b39b8023dd3e7750c26cec60ebdf Mon Sep 17 00:00:00 2001 From: wangailin Date: Wed, 9 Mar 2022 17:42:01 +0800 Subject: [PATCH 26/34] feat: update version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ae9e8e6..b1fc05e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ccms", - "version": "1.2.3", + "version": "1.2.4", "description": "ConfigableCMS", "main": "lib/index.js", "module": "dist/index.js", -- Gitee From 8b75272e5c14675ea396f8782062a6e3872e6a2f Mon Sep 17 00:00:00 2001 From: wangailin Date: Wed, 9 Mar 2022 17:57:38 +0800 Subject: [PATCH 27/34] =?UTF-8?q?feat:=20[form]=E6=96=B0=E5=A2=9E=E9=85=8D?= =?UTF-8?q?=E7=BD=AE-=E8=87=AA=E5=AE=9A=E4=B9=89=E6=8C=89=E9=92=AE?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=8C=89=E9=92=AE=E6=8F=90=E4=BA=A4=E6=98=AF?= =?UTF-8?q?=E5=90=A6=E9=AA=8C=E8=AF=81=E8=A1=A8=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/steps/form/index.tsx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/steps/form/index.tsx b/src/steps/form/index.tsx index 5be24f0..27debc8 100644 --- a/src/steps/form/index.tsx +++ b/src/steps/form/index.tsx @@ -79,6 +79,7 @@ export interface ActionConfig { type: 'submit' | 'cancel' | 'ccms', label: string, mode: 'normal' | 'primary' | 'link', + submitValidate: boolean condition?: ConditionConfig handle?: OperationConfig callback?: { @@ -620,6 +621,7 @@ export default class FormStep extends Step { onClick: () => this.handleCancel() })) } else { + const submitValidate = actions[index].submitValidate const OperationHelperWrapper = { this.renderButtonComponent({ label: actions[index].label || '', mode: actions[index].mode, - onClick + onClick: submitValidate + ? async () => { + await this.handleValidations() + console.info('表单参数信息', this.submitData, this.state.formValue, this.formData) + if (this.canSubmit) { + onClick() + } + } + : onClick }) )} @@ -645,7 +655,7 @@ export default class FormStep extends Step { } } } - + if (ready) { return ( -- Gitee From 7bd56496854778a43eec7fb0c097a7f9227ede81 Mon Sep 17 00:00:00 2001 From: wangailin Date: Wed, 9 Mar 2022 19:29:40 +0800 Subject: [PATCH 28/34] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E6=8C=89?= =?UTF-8?q?=E9=92=AE=E5=88=87=E6=8D=A2=E6=97=B6=E6=9B=BF=E6=8D=A2=E8=B7=AF?= =?UTF-8?q?=E7=94=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/steps/table/index.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/steps/table/index.tsx b/src/steps/table/index.tsx index a3a5dbd..ea388da 100644 --- a/src/steps/table/index.tsx +++ b/src/steps/table/index.tsx @@ -62,6 +62,7 @@ export interface TableCCMSOperationConfig { type: 'ccms' page: any target: 'current' | 'page' | 'open' | 'handle' + historyTpye?: 'replace' targetURL: string data: { [key: string]: ParamConfig } params?: { field: string, data: ParamConfig }[] @@ -337,7 +338,11 @@ export default class TableStep extends Step { if (this.props.handlePageRedirect) { this.props.handlePageRedirect(`${targetURL}${targetKey}`) } else { - window.location.href = `${targetURL}${targetKey}` + if (operation.handle.historyTpye === 'replace') { + window.location.replace(`${targetURL}${targetKey}`) + } else { + window.location.href = `${targetURL}${targetKey}` + } } } else if (operation.handle.target === 'open') { const sourceURL = await this.props.loadPageFrameURL(operation.handle.page) -- Gitee From 5110b2e64ba3361075f7882463c0001cfe229c47 Mon Sep 17 00:00:00 2001 From: wangailin Date: Wed, 9 Mar 2022 20:19:11 +0800 Subject: [PATCH 29/34] =?UTF-8?q?feat:=20=E4=BF=AE=E5=A4=8D=E5=AD=90?= =?UTF-8?q?=E8=A1=A8=E5=8D=95=E5=BC=B9=E7=AA=97=E5=AE=BD=E5=BA=A6=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/steps/table/index.tsx | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/steps/table/index.tsx b/src/steps/table/index.tsx index ea388da..894ef65 100644 --- a/src/steps/table/index.tsx +++ b/src/steps/table/index.tsx @@ -492,7 +492,6 @@ export default class TableStep extends Step { config: { field, label, - width, primary, columns, operations, @@ -507,6 +506,7 @@ export default class TableStep extends Step { operation: { enable: operationEnable, target: operationTarget, + width: operationWidth, title: operationTitle, visible: operationVisible, config: operationConfig, @@ -707,11 +707,11 @@ export default class TableStep extends Step { {operationEnable && ( operationTarget === 'current' ? ( - this.renderOperationModal({ - title: operationTitle, - width, - visible: operationVisible, - children: ( + this.renderOperationModal({ + title: operationTitle, + width: operationWidth, + visible: operationVisible, + children: ( { } }} /> - ), - onClose: () => { - const { operation } = this.state - operation.enable = false - operation.visible = false - this.setState({ operation }) - } - }) - ) + ), + onClose: () => { + const { operation } = this.state + operation.enable = false + operation.visible = false + this.setState({ operation }) + } + }) + ) : ( { } }} /> - ) + ) )} ) -- Gitee From 856cedff77128e8bee4509a6e2d0413a02c9f357 Mon Sep 17 00:00:00 2001 From: wangailin Date: Wed, 9 Mar 2022 20:27:38 +0800 Subject: [PATCH 30/34] =?UTF-8?q?feat:=20=E5=BC=B9=E5=B1=82=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E8=A1=A8=E6=A0=BC=E5=AE=BD=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/steps/table/index.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/steps/table/index.tsx b/src/steps/table/index.tsx index 894ef65..d62034a 100644 --- a/src/steps/table/index.tsx +++ b/src/steps/table/index.tsx @@ -64,6 +64,7 @@ export interface TableCCMSOperationConfig { target: 'current' | 'page' | 'open' | 'handle' historyTpye?: 'replace' targetURL: string + width: string data: { [key: string]: ParamConfig } params?: { field: string, data: ParamConfig }[] callback?: boolean @@ -214,6 +215,7 @@ interface TableState { operation: { enable: boolean target: 'current' | 'handle' + width: string title: string visible: boolean config: CCMSConfig @@ -246,6 +248,7 @@ export default class TableStep extends Step { enable: false, target: 'current', title: '', + width: '400px', visible: false, config: {}, data: {}, @@ -323,6 +326,7 @@ export default class TableStep extends Step { operation: { enable: true, target: operation.handle.target, + width: operation.handle.width, title: operation.label, visible: true, config: operationConfig, -- Gitee From 36bae42d441f8829b5c9f296f0fca10ed193e528 Mon Sep 17 00:00:00 2001 From: wangailin Date: Wed, 9 Mar 2022 20:37:41 +0800 Subject: [PATCH 31/34] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E8=A1=A8?= =?UTF-8?q?=E6=A0=BC=E5=AE=BD=E5=BA=A6=E4=BC=A0=E9=80=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/steps/table/index.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/steps/table/index.tsx b/src/steps/table/index.tsx index d62034a..44071b1 100644 --- a/src/steps/table/index.tsx +++ b/src/steps/table/index.tsx @@ -100,6 +100,7 @@ interface TableOperationConfirmConfig { export interface ITable { title: string | null primary: string + width: string data: { [field: string]: any }[] columns: ITableColumn[] pagination?: { @@ -496,6 +497,7 @@ export default class TableStep extends Step { config: { field, label, + width, primary, columns, operations, @@ -527,6 +529,7 @@ export default class TableStep extends Step { const props: ITable = { title: label, + width, primary, data: getDate, columns: (columns || []).filter((column) => column.field !== undefined && column.field !== '').map((column, index) => { -- Gitee From bbf4cd213f32ab03df0d4f1a4b627dbd1916771e Mon Sep 17 00:00:00 2001 From: cuiwenlong7 Date: Thu, 10 Mar 2022 11:32:09 +0800 Subject: [PATCH 32/34] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9noPathCombinatio?= =?UTF-8?q?n=E7=9A=84=E7=B1=BB=E5=9E=8B=E4=B8=BAboolean?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/detail/common.tsx | 8 ++++---- src/components/detail/group/index.tsx | 8 ++++---- src/components/detail/importSubform/index.tsx | 8 ++++---- src/components/formFields/common.tsx | 18 +++++++++--------- src/components/formFields/form/index.tsx | 10 +++++----- src/components/formFields/group/index.tsx | 10 +++++----- .../formFields/importSubform/index.tsx | 10 +++++----- src/components/formFields/object/index.tsx | 14 +++++++------- src/components/formFields/tabs/index.tsx | 10 +++++----- src/components/formFields/upload/index.tsx | 2 +- src/steps/detail/index.tsx | 8 ++++---- src/steps/filter/index.tsx | 10 +++++----- src/steps/form/index.tsx | 10 +++++----- 13 files changed, 63 insertions(+), 63 deletions(-) diff --git a/src/components/detail/common.tsx b/src/components/detail/common.tsx index c72bb7a..9ec2155 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, options?: { noPathCombination?: true }) => Promise + onValueSet: (path: string, value: T, options?: { noPathCombination?: boolean }) => Promise // // 事件:置空值 - onValueUnset: (path: string, options?: { noPathCombination?: true }) => Promise + onValueUnset: (path: string, options?: { noPathCombination?: boolean }) => Promise // 事件:修改值 - 列表 - 追加 - onValueListAppend: (path: string, value: any, options?: { noPathCombination?: true }) => Promise + onValueListAppend: (path: string, value: any, options?: { noPathCombination?: boolean }) => Promise // 事件:修改值 - 列表 - 删除 - onValueListSplice: (path: string, index: number, count: number, options?: { noPathCombination?: true }) => Promise + onValueListSplice: (path: string, index: number, count: number, options?: { noPathCombination?: boolean }) => Promise baseRoute: string, loadDomain: (domain: string) => Promise } diff --git a/src/components/detail/group/index.tsx b/src/components/detail/group/index.tsx index d6533e4..a8e574b 100644 --- a/src/components/detail/group/index.tsx +++ b/src/components/detail/group/index.tsx @@ -99,7 +99,7 @@ export default class GroupField extends DetailField { + handleValueSet = async (detailFieldIndex: number, path: string, value: any, options?: { noPathCombination?: boolean }) => { const detailFieldConfig = (this.props.config.fields || [])[detailFieldIndex] if (detailFieldConfig) { const fullPath = options && options.noPathCombination ? path : (detailFieldConfig.field === '' || path === '' ? `${detailFieldConfig.field}${path}` : `${detailFieldConfig.field}.${path}`) @@ -107,7 +107,7 @@ export default class GroupField extends DetailField { + handleValueUnset = async (detailFieldIndex: number, path: string, options?: { noPathCombination?: boolean }) => { const detailFieldConfig = (this.props.config.fields || [])[detailFieldIndex] if (detailFieldConfig) { const fullPath = options && options.noPathCombination ? path : (detailFieldConfig.field === '' || path === '' ? `${detailFieldConfig.field}${path}` : `${detailFieldConfig.field}.${path}`) @@ -115,7 +115,7 @@ export default class GroupField extends DetailField { + handleValueListAppend = async (detailFieldIndex: number, path: string, value: any, options?: { noPathCombination?: boolean }) => { const detailFieldConfig = (this.props.config.fields || [])[detailFieldIndex] if (detailFieldConfig) { const fullPath = options && options.noPathCombination ? path : (detailFieldConfig.field === '' || path === '' ? `${detailFieldConfig.field}${path}` : `${detailFieldConfig.field}.${path}`) @@ -123,7 +123,7 @@ export default class GroupField extends DetailField { + handleValueListSplice = async (detailFieldIndex: number, path: string, index: number, count: number, options?: { noPathCombination?: boolean }) => { const detailFieldConfig = (this.props.config.fields || [])[detailFieldIndex] if (detailFieldConfig) { const fullPath = options && options.noPathCombination ? path : (detailFieldConfig.field === '' || path === '' ? `${detailFieldConfig.field}${path}` : `${detailFieldConfig.field}.${path}`) diff --git a/src/components/detail/importSubform/index.tsx b/src/components/detail/importSubform/index.tsx index dbcb395..5e59af5 100644 --- a/src/components/detail/importSubform/index.tsx +++ b/src/components/detail/importSubform/index.tsx @@ -106,7 +106,7 @@ export default class DetailImportSubformField extends DetailField { + handleValueSet = async (formFieldIndex: number, path: string, value: any, options?: { noPathCombination?: boolean }) => { const formFieldConfig = (this.state.fields || [])[formFieldIndex] if (formFieldConfig) { const fullPath = options && options.noPathCombination ? path : this.getFullpath(formFieldConfig.field, path) @@ -114,7 +114,7 @@ export default class DetailImportSubformField extends DetailField { + handleValueUnset = async (formFieldIndex: number, path: string, options?: { noPathCombination?: boolean }) => { const formFieldConfig = (this.state.fields || [])[formFieldIndex] if (formFieldConfig) { const fullPath = options && options.noPathCombination ? path : this.getFullpath(formFieldConfig.field, path) @@ -122,7 +122,7 @@ export default class DetailImportSubformField extends DetailField { + handleValueListAppend = async (formFieldIndex: number, path: string, value: any, options?: { noPathCombination?: boolean }) => { const formFieldConfig = (this.state.fields || [])[formFieldIndex] if (formFieldConfig) { const fullPath = options && options.noPathCombination ? path : this.getFullpath(formFieldConfig.field, path) @@ -130,7 +130,7 @@ export default class DetailImportSubformField extends DetailField { + handleValueListSplice = async (formFieldIndex: number, path: string, index: number, count: number, options?: { noPathCombination?: boolean }) => { const formFieldConfig = (this.state.fields || [])[formFieldIndex] if (formFieldConfig) { const fullPath = options && options.noPathCombination ? path : this.getFullpath(formFieldConfig.field, path) diff --git a/src/components/formFields/common.tsx b/src/components/formFields/common.tsx index 412bb04..cf36a02 100644 --- a/src/components/formFields/common.tsx +++ b/src/components/formFields/common.tsx @@ -84,15 +84,15 @@ export interface FieldProps { // TODO 待删除 onChange: (value: T) => Promise // 事件:设置值 noPathCombination:为true时不做路径拼接 - onValueSet: (path: string, value: T, validation: true | FieldError[], options?: { noPathCombination?: true }) => Promise + onValueSet: (path: string, value: T, validation: true | FieldError[], options?: { noPathCombination?: boolean }) => Promise // 事件:置空值 - onValueUnset: (path: string, validation: true | FieldError[], options?: { noPathCombination?: true }) => Promise + onValueUnset: (path: string, validation: true | FieldError[], options?: { noPathCombination?: boolean }) => Promise // 事件:修改值 - 列表 - 追加 - onValueListAppend: (path: string, value: any, validation: true | FieldError[], options?: { noPathCombination?: true }) => Promise + onValueListAppend: (path: string, value: any, validation: true | FieldError[], options?: { noPathCombination?: boolean }) => Promise // 事件:修改值 - 列表 - 删除 - onValueListSplice: (path: string, index: number, count: number, validation: true | FieldError[], options?: { noPathCombination?: true }) => Promise + onValueListSplice: (path: string, index: number, count: number, validation: true | FieldError[], options?: { noPathCombination?: boolean }) => Promise // 事件:修改值 - 列表 - 修改顺序 - onValueListSort: (path: string, index: number, sortType: 'up' | 'down', validation: true | FieldError[], options?: { noPathCombination?: true }) => Promise + onValueListSort: (path: string, index: number, sortType: 'up' | 'down', validation: true | FieldError[], options?: { noPathCombination?: boolean }) => Promise baseRoute: string, loadDomain: (domain: string) => Promise } @@ -187,13 +187,13 @@ export interface DisplayProps { step: number, config: C, // 事件:设置值 - onValueSet: (path: string, value: T, options?: { noPathCombination?: true }) => Promise + onValueSet: (path: string, value: T, options?: { noPathCombination?: boolean }) => Promise // 事件:置空值 - onValueUnset: (path: string, options?: { noPathCombination?: true }) => Promise + onValueUnset: (path: string, options?: { noPathCombination?: boolean }) => Promise // 事件:修改值 - 列表 - 追加 - onValueListAppend: (path: string, value: any, options?: { noPathCombination?: true }) => Promise + onValueListAppend: (path: string, value: any, options?: { noPathCombination?: boolean }) => Promise // 事件:修改值 - 列表 - 删除 - onValueListSplice: (path: string, index: number, count: number, options?: { noPathCombination?: true }) => Promise + onValueListSplice: (path: string, index: number, count: number, options?: { noPathCombination?: boolean }) => Promise baseRoute: string, loadDomain: (domain: string) => Promise } diff --git a/src/components/formFields/form/index.tsx b/src/components/formFields/form/index.tsx index 5a07d68..ab2055e 100644 --- a/src/components/formFields/form/index.tsx +++ b/src/components/formFields/form/index.tsx @@ -327,7 +327,7 @@ export default class FormField extends Field { + handleValueSet = async (index: number, formFieldIndex: number, path: string, value: any, validation: true | FieldError[], options?: { noPathCombination?: boolean }) => { const formFieldConfig = (this.props.config.fields || [])[formFieldIndex] if (formFieldConfig) { const fullPath = options && options.noPathCombination ? path : (formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}`) @@ -346,7 +346,7 @@ export default class FormField extends Field { + handleValueUnset = async (index: number, formFieldIndex: number, path: string, validation: true | FieldError[], options?: { noPathCombination?: boolean }) => { const formFieldConfig = (this.props.config.fields || [])[formFieldIndex] if (formFieldConfig) { const fullPath = options && options.noPathCombination ? path : (formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}`) @@ -365,7 +365,7 @@ export default class FormField extends Field { + handleValueListAppend = async (index: number, formFieldIndex: number, path: string, value: any, validation: true | FieldError[], options?: { noPathCombination?: boolean }) => { const formFieldConfig = (this.props.config.fields || [])[formFieldIndex] if (formFieldConfig) { const fullPath = options && options.noPathCombination ? path : (formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}`) @@ -384,7 +384,7 @@ export default class FormField extends Field { + handleValueListSplice = async (index: number, formFieldIndex: number, path: string, _index: number, count: number, validation: true | FieldError[], options?: { noPathCombination?: boolean }) => { const formFieldConfig = (this.props.config.fields || [])[formFieldIndex] if (formFieldConfig) { const fullPath = options && options.noPathCombination ? path : (formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}`) @@ -403,7 +403,7 @@ export default class FormField extends Field { + handleValueListSort = async (index: number, formFieldIndex: number, path: string, _index: number, sortType: 'up' | 'down', validation: true | FieldError[], options?: { noPathCombination?: boolean }) => { const formFieldConfig = (this.props.config.fields || [])[formFieldIndex] if (formFieldConfig) { const fullPath = options && options.noPathCombination ? path : (formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}`) diff --git a/src/components/formFields/group/index.tsx b/src/components/formFields/group/index.tsx index 36f2baf..621b55f 100644 --- a/src/components/formFields/group/index.tsx +++ b/src/components/formFields/group/index.tsx @@ -189,7 +189,7 @@ export default class GroupField extends Field { + handleValueSet = async (formFieldIndex: number, path: string, value: any, validation: true | FieldError[], options?: { noPathCombination?: boolean }) => { const formFieldConfig = (this.props.config.fields || [])[formFieldIndex] if (formFieldConfig) { const fullPath = options && options.noPathCombination ? path : (formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}`) @@ -207,7 +207,7 @@ export default class GroupField extends Field { + handleValueUnset = async (formFieldIndex: number, path: string, validation: true | FieldError[], options?: { noPathCombination?: boolean }) => { const formFieldConfig = (this.props.config.fields || [])[formFieldIndex] if (formFieldConfig) { const fullPath = options && options.noPathCombination ? path : (formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}`) @@ -225,7 +225,7 @@ export default class GroupField extends Field { + handleValueListAppend = async (formFieldIndex: number, path: string, value: any, validation: true | FieldError[], options?: { noPathCombination?: boolean }) => { const formFieldConfig = (this.props.config.fields || [])[formFieldIndex] if (formFieldConfig) { const fullPath = options && options.noPathCombination ? path : (formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}`) @@ -243,7 +243,7 @@ export default class GroupField extends Field { + handleValueListSplice = async (formFieldIndex: number, path: string, index: number, count: number, validation: true | FieldError[], options?: { noPathCombination?: boolean }) => { const formFieldConfig = (this.props.config.fields || [])[formFieldIndex] if (formFieldConfig) { const fullPath = options && options.noPathCombination ? path : (formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}`) @@ -261,7 +261,7 @@ export default class GroupField extends Field { + handleValueListSort = async (formFieldIndex: number, path: string, index: number, sortType: 'up' | 'down', validation: true | FieldError[], options?: { noPathCombination?: boolean }) => { const formFieldConfig = (this.props.config.fields || [])[formFieldIndex] if (formFieldConfig) { const fullPath = options && options.noPathCombination ? path : (formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}`) diff --git a/src/components/formFields/importSubform/index.tsx b/src/components/formFields/importSubform/index.tsx index fda69c4..5863faf 100644 --- a/src/components/formFields/importSubform/index.tsx +++ b/src/components/formFields/importSubform/index.tsx @@ -229,7 +229,7 @@ export default class ImportSubformField extends Field { + handleValueSet = async (formFieldIndex: number, path: string, value: any, validation: true | FieldError[], options?: { noPathCombination?: boolean }) => { const formFieldConfig = (this.state.fields || [])[formFieldIndex] if (formFieldConfig) { const fullPath = options && options.noPathCombination ? path : this.getFullpath(formFieldConfig.field, path) @@ -248,7 +248,7 @@ export default class ImportSubformField extends Field { + handleValueUnset = async (formFieldIndex: number, path: string, validation: true | FieldError[], options?: { noPathCombination?: boolean }) => { const formFieldConfig = (this.state.fields || [])[formFieldIndex] if (formFieldConfig) { const fullPath = options && options.noPathCombination ? path : this.getFullpath(formFieldConfig.field, path) @@ -267,7 +267,7 @@ export default class ImportSubformField extends Field { + handleValueListAppend = async (formFieldIndex: number, path: string, value: any, validation: true | FieldError[], options?: { noPathCombination?: boolean }) => { const formFieldConfig = (this.state.fields || [])[formFieldIndex] if (formFieldConfig) { const fullPath = options && options.noPathCombination ? path : this.getFullpath(formFieldConfig.field, path) @@ -286,7 +286,7 @@ export default class ImportSubformField extends Field { + handleValueListSplice = async (formFieldIndex: number, path: string, index: number, count: number, validation: true | FieldError[], options?: { noPathCombination?: boolean }) => { const formFieldConfig = (this.state.fields || [])[formFieldIndex] if (formFieldConfig) { const fullPath = options && options.noPathCombination ? path : this.getFullpath(formFieldConfig.field, path) @@ -305,7 +305,7 @@ export default class ImportSubformField extends Field { + handleValueListSort = async (formFieldIndex: number, path: string, index: number, sortType: 'up' | 'down', validation: true | FieldError[], options?: { noPathCombination?: boolean }) => { const formFieldConfig = (this.state.fields || [])[formFieldIndex] if (formFieldConfig) { const fullPath = options && options.noPathCombination ? path : this.getFullpath(formFieldConfig.field, path) diff --git a/src/components/formFields/object/index.tsx b/src/components/formFields/object/index.tsx index 12bb936..e3ddba5 100644 --- a/src/components/formFields/object/index.tsx +++ b/src/components/formFields/object/index.tsx @@ -83,7 +83,7 @@ export default class ObjectField extends Field extends Field extends Field { + handleValueSet = async (key: string, formFieldIndex: number, path: string, value: any, validation: true | FieldError[], options?: { noPathCombination?: boolean }) => { const formFieldConfig = (this.props.config.fields || [])[formFieldIndex] if (formFieldConfig) { const fullPath = options && options.noPathCombination ? path : (formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}`) @@ -278,7 +278,7 @@ export default class ObjectField extends Field { + handleValueUnset = async (key: string, formFieldIndex: number, path: string, validation: true | FieldError[], options?: { noPathCombination?: boolean }) => { const formFieldConfig = (this.props.config.fields || [])[formFieldIndex] if (formFieldConfig) { const fullPath = options && options.noPathCombination ? path : (formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}`) @@ -297,7 +297,7 @@ export default class ObjectField extends Field { + handleValueListAppend = async (key: string, formFieldIndex: number, path: string, value: any, validation: true | FieldError[], options?: { noPathCombination?: boolean }) => { const formFieldConfig = (this.props.config.fields || [])[formFieldIndex] if (formFieldConfig) { const fullPath = options && options.noPathCombination ? path : (formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}`) @@ -316,7 +316,7 @@ export default class ObjectField extends Field { + handleValueListSplice = async (key: string, formFieldIndex: number, path: string, _index: number, count: number, validation: true | FieldError[], options?: { noPathCombination?: boolean }) => { const formFieldConfig = (this.props.config.fields || [])[formFieldIndex] if (formFieldConfig) { const fullPath = options && options.noPathCombination ? path : (formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}`) @@ -335,7 +335,7 @@ export default class ObjectField extends Field { + handleValueListSort = async (key: string, formFieldIndex: number, path: string, _index: number, sortType: 'up' | 'down', validation: true | FieldError[], options?: { noPathCombination?: boolean }) => { const formFieldConfig = (this.props.config.fields || [])[formFieldIndex] if (formFieldConfig) { const fullPath = options && options.noPathCombination ? path : (formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}`) diff --git a/src/components/formFields/tabs/index.tsx b/src/components/formFields/tabs/index.tsx index 2be57a1..2c479f7 100644 --- a/src/components/formFields/tabs/index.tsx +++ b/src/components/formFields/tabs/index.tsx @@ -205,7 +205,7 @@ export default class TabsField extends Field { } - handleValueSet = async (index: number, formFieldIndex: number, path: string, value: any, validation: true | FieldError[], options?: { noPathCombination?: true }) => { + handleValueSet = async (index: number, formFieldIndex: number, path: string, value: any, validation: true | FieldError[], options?: { noPathCombination?: boolean }) => { const tab = (this.props.config.tabs || [])[index] const fields = this.props.config.mode === 'same' ? (this.props.config.fields || []) : (((this.props.config.tabs || [])[index] || {}).fields || []) @@ -229,7 +229,7 @@ export default class TabsField extends Field { + handleValueUnset = async (index: number, formFieldIndex: number, path: string, validation: true | FieldError[], options?: { noPathCombination?: boolean }) => { const tab = (this.props.config.tabs || [])[index] const fields = this.props.config.mode === 'same' ? (this.props.config.fields || []) : (((this.props.config.tabs || [])[index] || {}).fields || []) @@ -253,7 +253,7 @@ export default class TabsField extends Field { + handleValueListAppend = async (index: number, formFieldIndex: number, path: string, value: any, validation: true | FieldError[], options?: { noPathCombination?: boolean }) => { const tab = (this.props.config.tabs || [])[index] const fields = this.props.config.mode === 'same' ? (this.props.config.fields || []) : (((this.props.config.tabs || [])[index] || {}).fields || []) @@ -277,7 +277,7 @@ export default class TabsField extends Field { + handleValueListSplice = async (index: number, formFieldIndex: number, path: string, _index: number, count: number, validation: true | FieldError[], options?: { noPathCombination?: boolean }) => { const tab = (this.props.config.tabs || [])[index] const fields = this.props.config.mode === 'same' ? (this.props.config.fields || []) : (((this.props.config.tabs || [])[index] || {}).fields || []) @@ -301,7 +301,7 @@ export default class TabsField extends Field { + handleValueListSort = async (index: number, formFieldIndex: number, path: string, _index: number, sortType: 'up' | 'down', validation: true | FieldError[], options?: { noPathCombination?: boolean }) => { const tab = (this.props.config.tabs || [])[index] const fields = this.props.config.mode === 'same' ? (this.props.config.fields || []) : (((this.props.config.tabs || [])[index] || {}).fields || []) diff --git a/src/components/formFields/upload/index.tsx b/src/components/formFields/upload/index.tsx index 295ec68..0013ca1 100644 --- a/src/components/formFields/upload/index.tsx +++ b/src/components/formFields/upload/index.tsx @@ -165,7 +165,7 @@ export default class UploadField extends Field { } } - handleValueSet = async (detailFieldIndex: number, path: string, value: any, options?: { noPathCombination?: true }) => { + handleValueSet = async (detailFieldIndex: number, path: string, value: any, options?: { noPathCombination?: boolean }) => { const detailFieldConfig = (this.props.config.fields || [])[detailFieldIndex] if (detailFieldConfig) { const fullPath = options && options.noPathCombination ? path : (detailFieldConfig.field === '' || path === '' ? `${detailFieldConfig.field}${path}` : `${detailFieldConfig.field}.${path}`) @@ -237,7 +237,7 @@ export default class DetailStep extends Step { } } - handleValueUnset = async (detailFieldIndex: number, path: string, options?: { noPathCombination?: true }) => { + handleValueUnset = async (detailFieldIndex: number, path: string, options?: { noPathCombination?: boolean }) => { const detailFieldConfig = (this.props.config.fields || [])[detailFieldIndex] if (detailFieldConfig) { const fullPath = options && options.noPathCombination ? path : (detailFieldConfig.field === '' || path === '' ? `${detailFieldConfig.field}${path}` : `${detailFieldConfig.field}.${path}`) @@ -252,7 +252,7 @@ export default class DetailStep extends Step { } } - handleValueListAppend = async (detailFieldIndex: number, path: string, value: any, options?: { noPathCombination?: true }) => { + handleValueListAppend = async (detailFieldIndex: number, path: string, value: any, options?: { noPathCombination?: boolean }) => { const detailFieldConfig = (this.props.config.fields || [])[detailFieldIndex] if (detailFieldConfig) { const fullPath = options && options.noPathCombination ? path : (detailFieldConfig.field === '' || path === '' ? `${detailFieldConfig.field}${path}` : `${detailFieldConfig.field}.${path}`) @@ -269,7 +269,7 @@ export default class DetailStep extends Step { } } - handleValueListSplice = async (detailFieldIndex: number, path: string, index: number, count: number, options?: { noPathCombination?: true }) => { + handleValueListSplice = async (detailFieldIndex: number, path: string, index: number, count: number, options?: { noPathCombination?: boolean }) => { const detailFieldConfig = (this.props.config.fields || [])[detailFieldIndex] if (detailFieldConfig) { const fullPath = options && options.noPathCombination ? path : (detailFieldConfig.field === '' || path === '' ? `${detailFieldConfig.field}${path}` : `${detailFieldConfig.field}.${path}`) diff --git a/src/steps/filter/index.tsx b/src/steps/filter/index.tsx index 4169148..8d828f6 100644 --- a/src/steps/filter/index.tsx +++ b/src/steps/filter/index.tsx @@ -278,7 +278,7 @@ export default class FilterStep extends Step { } } - handleValueSet = async (formFieldIndex: number, path: string, value: any, validation: true | FieldError[], options?: { noPathCombination?: true }) => { + handleValueSet = async (formFieldIndex: number, path: string, value: any, validation: true | FieldError[], options?: { noPathCombination?: boolean }) => { const formFieldConfig = (this.props.config.fields || [])[formFieldIndex] if (formFieldConfig) { const fullPath = options && options.noPathCombination ? path : (formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}`) @@ -303,7 +303,7 @@ export default class FilterStep extends Step { } } - handleValueUnset = async (formFieldIndex: number, path: string, validation: true | FieldError[], options?: { noPathCombination?: true }) => { + handleValueUnset = async (formFieldIndex: number, path: string, validation: true | FieldError[], options?: { noPathCombination?: boolean }) => { const formFieldConfig = (this.props.config.fields || [])[formFieldIndex] if (formFieldConfig) { const fullPath = options && options.noPathCombination ? path : (formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}`) @@ -328,7 +328,7 @@ export default class FilterStep extends Step { } } - handleValueListAppend = async (formFieldIndex: number, path: string, value: any, validation: true | FieldError[], options?: { noPathCombination?: true }) => { + handleValueListAppend = async (formFieldIndex: number, path: string, value: any, validation: true | FieldError[], options?: { noPathCombination?: boolean }) => { const formFieldConfig = (this.props.config.fields || [])[formFieldIndex] if (formFieldConfig) { const fullPath = options && options.noPathCombination ? path : (formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}`) @@ -355,7 +355,7 @@ export default class FilterStep extends Step { } } - handleValueListSplice = async (formFieldIndex: number, path: string, index: number, count: number, validation: true | FieldError[], options?: { noPathCombination?: true }) => { + handleValueListSplice = async (formFieldIndex: number, path: string, index: number, count: number, validation: true | FieldError[], options?: { noPathCombination?: boolean }) => { const formFieldConfig = (this.props.config.fields || [])[formFieldIndex] if (formFieldConfig) { const fullPath = options && options.noPathCombination ? path : (formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}`) @@ -382,7 +382,7 @@ export default class FilterStep extends Step { } } - handleValueListSort = async (formFieldIndex: number, path: string, index: number, sortType: 'up' | 'down', validation: true | FieldError[], options?: { noPathCombination?: true }) => { + handleValueListSort = async (formFieldIndex: number, path: string, index: number, sortType: 'up' | 'down', validation: true | FieldError[], options?: { noPathCombination?: boolean }) => { const formFieldConfig = (this.props.config.fields || [])[formFieldIndex] if (formFieldConfig) { const fullPath = options && options.noPathCombination ? path : (formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}`) diff --git a/src/steps/form/index.tsx b/src/steps/form/index.tsx index 5e91489..27d57d3 100644 --- a/src/steps/form/index.tsx +++ b/src/steps/form/index.tsx @@ -389,7 +389,7 @@ export default class FormStep extends Step { } } - handleValueSet = async (formFieldIndex: number, path: string, value: any, validation: true | FieldError[], options?: { noPathCombination?: true }) => { + handleValueSet = async (formFieldIndex: number, path: string, value: any, validation: true | FieldError[], options?: { noPathCombination?: boolean }) => { const formFieldConfig = (this.props.config.fields || [])[formFieldIndex] if (formFieldConfig) { const fullPath = options && options.noPathCombination ? path : (formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}`) @@ -416,7 +416,7 @@ export default class FormStep extends Step { } } - handleValueUnset = async (formFieldIndex: number, path: string, validation: true | FieldError[], options?: { noPathCombination?: true }) => { + handleValueUnset = async (formFieldIndex: number, path: string, validation: true | FieldError[], options?: { noPathCombination?: boolean }) => { const formFieldConfig = (this.props.config.fields || [])[formFieldIndex] if (formFieldConfig) { const fullPath = options && options.noPathCombination ? path : (formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}`) @@ -441,7 +441,7 @@ export default class FormStep extends Step { } } - handleValueListAppend = async (formFieldIndex: number, path: string, value: any, validation: true | FieldError[], options?: { noPathCombination?: true }) => { + handleValueListAppend = async (formFieldIndex: number, path: string, value: any, validation: true | FieldError[], options?: { noPathCombination?: boolean }) => { const formFieldConfig = (this.props.config.fields || [])[formFieldIndex] if (formFieldConfig) { const fullPath = options && options.noPathCombination ? path : (formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}`) @@ -469,7 +469,7 @@ export default class FormStep extends Step { } } - handleValueListSplice = async (formFieldIndex: number, path: string, index: number, count: number, validation: true | FieldError[], options?: { noPathCombination?: true }) => { + handleValueListSplice = async (formFieldIndex: number, path: string, index: number, count: number, validation: true | FieldError[], options?: { noPathCombination?: boolean }) => { const formFieldConfig = (this.props.config.fields || [])[formFieldIndex] if (formFieldConfig) { const fullPath = options && options.noPathCombination ? path : (formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}`) @@ -496,7 +496,7 @@ export default class FormStep extends Step { } } - handleValueListSort = async (formFieldIndex: number, path: string, index: number, sortType: 'up' | 'down', validation: true | FieldError[], options?: { noPathCombination?: true }) => { + handleValueListSort = async (formFieldIndex: number, path: string, index: number, sortType: 'up' | 'down', validation: true | FieldError[], options?: { noPathCombination?: boolean }) => { const formFieldConfig = (this.props.config.fields || [])[formFieldIndex] if (formFieldConfig) { const fullPath = options && options.noPathCombination ? path : (formFieldConfig.field === '' || path === '' ? `${formFieldConfig.field}${path}` : `${formFieldConfig.field}.${path}`) -- Gitee From 2c4043a72a146f210738a4f2182926a05627dc53 Mon Sep 17 00:00:00 2001 From: cuiwenlong7 Date: Thu, 10 Mar 2022 18:05:52 +0800 Subject: [PATCH 33/34] =?UTF-8?q?fix:=20=E7=BC=96=E8=BE=91=E5=99=A8ESC?= =?UTF-8?q?=E5=BF=AB=E6=8D=B7=E9=94=AE=E5=AF=BC=E8=87=B4antd=20modal?= =?UTF-8?q?=E5=85=B3=E9=97=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/formFields/code/index.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/formFields/code/index.tsx b/src/components/formFields/code/index.tsx index 69aabb9..09d8f27 100644 --- a/src/components/formFields/code/index.tsx +++ b/src/components/formFields/code/index.tsx @@ -78,6 +78,7 @@ export default class CodeField extends Field { + e.stopPropagation() const keyCode = e.keyCode || e.which || e.charCode const ctrlKey = e.ctrlKey || e.metaKey if (this.props.config.fullScreen) { -- Gitee From 0ee419276a72c4589c381fb41d737b20e0e2e77d Mon Sep 17 00:00:00 2001 From: "ext.pangzhaoqun1" Date: Thu, 31 Mar 2022 18:22:31 +0800 Subject: [PATCH 34/34] =?UTF-8?q?=E4=BF=9D=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/steps/form/index.tsx | 10 ++++++++-- src/steps/table/index.tsx | 11 +++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/steps/form/index.tsx b/src/steps/form/index.tsx index df2917c..bbb9e78 100644 --- a/src/steps/form/index.tsx +++ b/src/steps/form/index.tsx @@ -33,6 +33,7 @@ import OperationHelper, { OperationConfig } from '../../util/operation' * - * - condition: (全局校验子项中)校验条件 * - * - message: 校验失败提示文本 * - actions: 表单步骤按钮列表 + * - modalWidth: 弹窗宽度 */ export interface FormConfig extends StepConfig { type: 'form' @@ -55,6 +56,7 @@ export interface FormConfig extends StepConfig { hiddenCancel?: boolean // 是否隐藏取消按钮 TODO 待删除 submitText?: string // 自定义确认按钮文本 TODO 待删除 cancelText?: string // 自定义取消按钮文本 TODO 待删除 + modalWidth?: string // 弹窗宽度 } /** @@ -121,6 +123,7 @@ export interface IForm { onCancel?: () => Promise submitText?: string // 自定义确认按钮文本 cancelText?: string // 自定义取消按钮文本 + modalWidth?: string // 弹窗宽度 } /** @@ -164,6 +167,7 @@ export interface IFormItem { visitable: boolean fieldType: string children: React.ReactNode + modalWidth?: string } /** @@ -587,7 +591,8 @@ export default class FormStep extends Step { columns, // layout = 'horizontal', // fields = [] - actions + actions, + modalWidth } } = this.props @@ -707,10 +712,11 @@ export default class FormStep extends Step { type: formFieldConfig.columns?.type || columns?.type || 'span', value: formFieldConfig.columns?.value || columns?.value || 1, wrap: formFieldConfig.columns?.wrap || columns?.wrap || false, - gap: columns?.gap || 0, + // gap: columns?.gap || 0, rowGap: columns?.rowGap || 0 } : undefined, + modalWidth, status, message: formData[formFieldIndex]?.message || '', extra: StatementHelper(formFieldConfig.extra, { data: this.props.data, step: this.props.step }), diff --git a/src/steps/table/index.tsx b/src/steps/table/index.tsx index f881277..423918b 100644 --- a/src/steps/table/index.tsx +++ b/src/steps/table/index.tsx @@ -82,6 +82,7 @@ export interface TableOperationConfig { confirm?: { enable: false } | TableOperationConfirmConfig handle: TableCCMSOperationConfig | TableLinkOperationConfig condition?: ConditionConfig + modalWidth?: number } export interface TableCCMSOperationConfig { @@ -146,6 +147,7 @@ export interface ITable { leftTableOperations: React.ReactNode | null multirowOperations: React.ReactNode | null, description?: DescriptionConfig + } /** @@ -245,6 +247,7 @@ export interface ITableStepOperationModal { width: string children: React.ReactNode onClose: () => void + modalWidth?: number } interface TableState { @@ -254,11 +257,11 @@ interface TableState { width: string title: string visible: boolean + modalWidth?: number config: CCMSConfig data: any callback?: boolean cancelCallback?: boolean - } pageAuth: { [page: string]: boolean } } @@ -288,6 +291,7 @@ export default class TableStep extends Step { title: '', width: '400px', visible: false, + modalWidth: 1000, config: {}, data: {}, callback: false, @@ -368,6 +372,7 @@ export default class TableStep extends Step { width: operation.handle.width, title: operation.label, visible: true, + modalWidth: operation.modalWidth, config: operationConfig, data: params, callback: operation.handle.callback, @@ -655,6 +660,7 @@ export default class TableStep extends Step { width: operationWidth, title: operationTitle, visible: operationVisible, + modalWidth: operationModalWidth, config: operationConfig, data: operationData, callback: operationCallback, @@ -876,7 +882,7 @@ export default class TableStep extends Step { } const CCMS = this.CCMS - + console.log(operationModalWidth, 'hehe') return ( {this.renderComponent(props)} @@ -887,6 +893,7 @@ export default class TableStep extends Step { title: operationTitle, width: operationWidth, visible: operationVisible, + modalWidth: operationModalWidth, children: (