From 38cb9e9a72eba38d8e560a289ca2d9a7e30815a3 Mon Sep 17 00:00:00 2001 From: "ext.pangzhaoqun1" Date: Mon, 24 Jan 2022 15:38:43 +0800 Subject: [PATCH 01/17] =?UTF-8?q?=E6=8B=89=E5=8F=96=E8=BF=9C=E7=A8=8B?= =?UTF-8?q?=E5=88=86=E6=94=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/steps/table/index.tsx | 62 +++++++++++++++++++++++++++++++++++---- 1 file changed, 57 insertions(+), 5 deletions(-) diff --git a/src/steps/table/index.tsx b/src/steps/table/index.tsx index 72111dc..6fdd48d 100644 --- a/src/steps/table/index.tsx +++ b/src/steps/table/index.tsx @@ -9,6 +9,8 @@ import CCMS, { CCMSConfig } from '../../main' import { cloneDeep, get, set } from 'lodash' import InterfaceHelper, { InterfaceConfig } from '../../util/interface' import ConditionHelper, { ConditionConfig } from '../../util/condition' +import { StatementConfig } from '../../util/statement' +import marked from 'marked' /** * 表格步骤配置文件格式定义 @@ -32,6 +34,12 @@ export interface TableConfig extends StepConfig { current?: string pageSize?: string total?: string + }, + description?: { + type: 'text' | 'tooltip' | 'modal' + label?: string | undefined + mode: 'plain' | 'markdown' | 'html' + content?: string | undefined } } @@ -98,7 +106,12 @@ export interface ITable { onChange: (page: number, pageSize: number) => void } tableOperations: React.ReactNode | null - multirowOperations: React.ReactNode | null + multirowOperations: React.ReactNode | null, + description?: { + type: string + label: string | undefined + content: React.ReactNode + } } /** @@ -430,7 +443,7 @@ export default class TableStep extends Step { 您当前使用的UI版本没有实现Table组件的OperationGroupItem部分。 } - + renderOperationModal = (props: ITableStepOperationModal) => { const mask = document.createElement('DIV') mask.style.position = 'fixed' @@ -457,13 +470,16 @@ export default class TableStep extends Step { primary, columns, operations, - pagination + pagination, + description }, data, step, onUnmount } = this.props + console.log(this.props) + const { operation: { enable: operationEnable, @@ -481,14 +497,13 @@ export default class TableStep extends Step { if (Object.prototype.toString.call(getDate) !== '[object Array]') { getDate = [] } - + console.log(getDate) const props: ITable = { title: label, primary, data: getDate, columns: (columns || []).filter((column) => column.field !== undefined && column.field !== '').map((column, index) => { const field = column.field.split('.')[0] - return { field, label: column.label, @@ -564,6 +579,43 @@ export default class TableStep extends Step { multirowOperations: null } + if(description) { + if(description.type === 'text') { + props.description = { + type: 'text', + label: description.label, + content: description.content + } + } else if (description.type === 'tooltip') { + props.description = { + type: 'tooltip', + label: description.label, + content: description.content + } + } else { + props.description = { + type: 'modal', + label: description.label, + content: description.content + } + } + } + + if (description && description.content !== undefined) { + const descriptionType = description.mode + switch (descriptionType) { + case 'plain': + props.description && (props.description.content = description.content) + break + case 'markdown': + props.description && (props.description.content =
) + break + case 'html': + props.description && (props.description.content =
) + break + } + } + if (pagination && pagination.mode === 'server') { const paginationCurrent = Number((pagination.current === undefined || pagination.current === '') ? data[step] : get(data[step], pagination.current, 1)) const paginationPageSize = Number((pagination.pageSize === undefined || pagination.pageSize === '') ? data[step] : get(data[step], pagination.pageSize, 10)) -- Gitee From 1188c3ec25ad4e87d5b1c2985d4bf88496565fcc Mon Sep 17 00:00:00 2001 From: "ext.pangzhaoqun1" Date: Tue, 25 Jan 2022 10:38:46 +0800 Subject: [PATCH 02/17] =?UTF-8?q?=E5=88=A0=E9=99=A4console.log?= 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 deletions(-) diff --git a/src/steps/table/index.tsx b/src/steps/table/index.tsx index 6fdd48d..b3f9af1 100644 --- a/src/steps/table/index.tsx +++ b/src/steps/table/index.tsx @@ -478,8 +478,6 @@ export default class TableStep extends Step { onUnmount } = this.props - console.log(this.props) - const { operation: { enable: operationEnable, @@ -497,7 +495,6 @@ export default class TableStep extends Step { if (Object.prototype.toString.call(getDate) !== '[object Array]') { getDate = [] } - console.log(getDate) const props: ITable = { title: label, primary, -- Gitee From d425cd01d1cbf8ced007f08ce3a8b8cde268e089 Mon Sep 17 00:00:00 2001 From: "ext.pangzhaoqun1" Date: Tue, 25 Jan 2022 11:26:06 +0800 Subject: [PATCH 03/17] =?UTF-8?q?=E4=BF=AE=E6=94=B9description-type?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/steps/table/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/steps/table/index.tsx b/src/steps/table/index.tsx index b3f9af1..72b09b1 100644 --- a/src/steps/table/index.tsx +++ b/src/steps/table/index.tsx @@ -108,7 +108,7 @@ export interface ITable { tableOperations: React.ReactNode | null multirowOperations: React.ReactNode | null, description?: { - type: string + type: 'text' | 'tooltip' | 'modal' label: string | undefined content: React.ReactNode } -- Gitee From cbdf549bba4e7b86e6439196647c4c25c31edddb Mon Sep 17 00:00:00 2001 From: "ext.pangzhaoqun1" Date: Tue, 25 Jan 2022 18:54:20 +0800 Subject: [PATCH 04/17] =?UTF-8?q?=E4=BF=AE=E6=94=B9review=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/steps/table/index.tsx | 51 ++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/src/steps/table/index.tsx b/src/steps/table/index.tsx index 72b09b1..bee726d 100644 --- a/src/steps/table/index.tsx +++ b/src/steps/table/index.tsx @@ -9,9 +9,8 @@ import CCMS, { CCMSConfig } from '../../main' import { cloneDeep, get, set } from 'lodash' import InterfaceHelper, { InterfaceConfig } from '../../util/interface' import ConditionHelper, { ConditionConfig } from '../../util/condition' -import { StatementConfig } from '../../util/statement' +import StatementHelper, { StatementConfig } from '../../util/statement' import marked from 'marked' - /** * 表格步骤配置文件格式定义 * - field: 表格列表数据来源字段 @@ -37,9 +36,10 @@ export interface TableConfig extends StepConfig { }, description?: { type: 'text' | 'tooltip' | 'modal' - label?: string | undefined + label?: StatementConfig mode: 'plain' | 'markdown' | 'html' content?: string | undefined + showIcon: boolean } } @@ -111,6 +111,7 @@ export interface ITable { type: 'text' | 'tooltip' | 'modal' label: string | undefined content: React.ReactNode + showIcon: boolean } } @@ -575,44 +576,44 @@ export default class TableStep extends Step { : null, multirowOperations: null } - if(description) { if(description.type === 'text') { props.description = { type: 'text', - label: description.label, - content: description.content + label: StatementHelper(description.label, { data: this.props.data, step: this.props.step }), + content: description.content, + showIcon: description.showIcon } } else if (description.type === 'tooltip') { props.description = { type: 'tooltip', - label: description.label, - content: description.content + label: StatementHelper(description.label, { data: this.props.data, step: this.props.step }), + content: description.content, + showIcon: description.showIcon } } else { props.description = { type: 'modal', - label: description.label, - content: description.content + label: StatementHelper(description.label, { data: this.props.data, step: this.props.step }), + content: description.content, + showIcon: description.showIcon } } - } - - if (description && description.content !== undefined) { - const descriptionType = description.mode - switch (descriptionType) { - case 'plain': - props.description && (props.description.content = description.content) - break - case 'markdown': - props.description && (props.description.content =
) - break - case 'html': - props.description && (props.description.content =
) - break + if(description.content !== undefined) { + const descriptionType = description.mode + switch (descriptionType) { + case 'plain': + props.description && (props.description.content = description.content) + break + case 'markdown': + props.description && (props.description.content =
) + break + case 'html': + props.description && (props.description.content =
) + break + } } } - if (pagination && pagination.mode === 'server') { const paginationCurrent = Number((pagination.current === undefined || pagination.current === '') ? data[step] : get(data[step], pagination.current, 1)) const paginationPageSize = Number((pagination.pageSize === undefined || pagination.pageSize === '') ? data[step] : get(data[step], pagination.pageSize, 10)) -- Gitee From 25be20f14c54ab60596b9f4c2fff2c39b81eecc5 Mon Sep 17 00:00:00 2001 From: "ext.pangzhaoqun1" Date: Wed, 26 Jan 2022 16:33:54 +0800 Subject: [PATCH 05/17] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E5=86=85=E5=AE=B9=E7=B1=BB=E5=9E=8Bstatementconfig?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/steps/table/index.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/steps/table/index.tsx b/src/steps/table/index.tsx index bee726d..78b0b32 100644 --- a/src/steps/table/index.tsx +++ b/src/steps/table/index.tsx @@ -38,7 +38,7 @@ export interface TableConfig extends StepConfig { type: 'text' | 'tooltip' | 'modal' label?: StatementConfig mode: 'plain' | 'markdown' | 'html' - content?: string | undefined + content?: StatementConfig showIcon: boolean } } @@ -603,13 +603,13 @@ export default class TableStep extends Step { const descriptionType = description.mode switch (descriptionType) { case 'plain': - props.description && (props.description.content = description.content) + props.description && (props.description.content = StatementHelper(description.content, { data: this.props.data, step: this.props.step })) break case 'markdown': - props.description && (props.description.content =
) + props.description && (props.description.content =
) break case 'html': - props.description && (props.description.content =
) + props.description && (props.description.content =
) break } } -- Gitee From a77672d8d893b7e594bc6476bb5f6e3b5a187cff Mon Sep 17 00:00:00 2001 From: "ext.pangzhaoqun1" Date: Thu, 27 Jan 2022 16:47:15 +0800 Subject: [PATCH 06/17] =?UTF-8?q?=E8=AF=A6=E6=83=85=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=AF=A6=E6=83=85=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/detail/detailInfo/index.tsx | 85 ++++++++++++++++++++++ src/components/detail/index.tsx | 11 ++- src/index.tsx | 1 + 3 files changed, 94 insertions(+), 3 deletions(-) create mode 100644 src/components/detail/detailInfo/index.tsx diff --git a/src/components/detail/detailInfo/index.tsx b/src/components/detail/detailInfo/index.tsx new file mode 100644 index 0000000..912c664 --- /dev/null +++ b/src/components/detail/detailInfo/index.tsx @@ -0,0 +1,85 @@ +import React from 'react' +import { DetailField, DetailFieldConfig, DetailFieldError, IDetailField } from '../common' +import StatementHelper, { StatementConfig } from '../../../util/statement' +import marked from 'marked' + +export interface InfoDetailConfig extends DetailFieldConfig { + type: 'detail_info' + description?: { + descType: 'text' | 'tooltip' | 'modal' + label?: StatementConfig + mode: 'plain' | 'markdown' | 'html' + content?: StatementConfig + showIcon: boolean + }, +} + +export interface IInfoProps { + description?: { + descType: 'text' | 'tooltip' | 'modal' + label: string | undefined + content: React.ReactNode + showIcon: boolean + } +} + +export default class InfoDetail extends DetailField implements IDetailField { + renderComponent = (props: IInfoProps) => { + return + 您当前使用的UI版本没有实现InfoDetail组件。 + + } + + render = () => { + const props: IInfoProps = {} + const { + config: { + description + } + } = this.props + if(description) { + if(description.descType === 'text') { + props.description = { + descType: 'text', + label: StatementHelper(description.label, { data: this.props.data, step: this.props.step }), + content: description.content, + showIcon: description.showIcon + } + } else if (description.descType === 'tooltip') { + props.description = { + descType: 'tooltip', + label: StatementHelper(description.label, { data: this.props.data, step: this.props.step }), + content: description.content, + showIcon: description.showIcon + } + } else { + props.description = { + descType: 'modal', + label: StatementHelper(description.label, { data: this.props.data, step: this.props.step }), + content: description.content, + showIcon: description.showIcon + } + } + if(description.content !== undefined) { + const descriptionType = description.mode + switch (descriptionType) { + case 'plain': + props.description && (props.description.content = StatementHelper(description.content, { data: this.props.data, step: this.props.step })) + break + case 'markdown': + props.description && (props.description.content =
) + break + case 'html': + props.description && (props.description.content =
) + break + } + } + } + + return ( + + {this.renderComponent(props)} + + ) + } +} diff --git a/src/components/detail/index.tsx b/src/components/detail/index.tsx index 24ae057..a6b7057 100644 --- a/src/components/detail/index.tsx +++ b/src/components/detail/index.tsx @@ -5,6 +5,7 @@ import StatementDetail, { StatementDetailConfig } from './statement' import GroupField, { GroupFieldConfig } from './group' import ImportSubformField, { ImportSubformFieldConfig } from './importSubform' +import InfoDetail, { InfoDetailConfig } from './detailInfo' /** * 详情步骤内详情项配置文件格式定义 - 枚举 @@ -14,19 +15,23 @@ export type DetailFieldConfigs = EnumDetailConfig | StatementDetailConfig | GroupFieldConfig | - ImportSubformFieldConfig + ImportSubformFieldConfig | + InfoDetailConfig + export type componentType = 'text' | 'group' | 'detail_enum' | 'statement' | - 'import_subform' + 'import_subform' | + 'detail_info' export default { group: GroupField, text: TextField, import_subform: ImportSubformField, detail_enum: EnumDetail, - statement: StatementDetail + statement: StatementDetail, + detail_info: InfoDetail } diff --git a/src/index.tsx b/src/index.tsx index b193a05..297d872 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 DetailInfoField } from './components/detail/detailInfo' export { default as HeaderStep } from './steps/header' -- Gitee From 7fc1598ca4c4a03e0c4ef8ff5589ba61e720f27f Mon Sep 17 00:00:00 2001 From: wangailin Date: Mon, 21 Feb 2022 14:40:10 +0800 Subject: [PATCH 07/17] 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 08/17] =?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 09/17] =?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 10/17] =?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 11/17] =?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 12/17] =?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 f597cd1d664e2317b9f4ea9b0e1fcf47e77c343a Mon Sep 17 00:00:00 2001 From: zjt Date: Thu, 24 Feb 2022 21:07:23 +0800 Subject: [PATCH 13/17] =?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 14/17] =?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 15/17] =?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 16/17] =?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 c7c483e1154660ea55303db29abe69d2970ee10b Mon Sep 17 00:00:00 2001 From: "ext.pangzhaoqun1" Date: Thu, 17 Mar 2022 17:31:28 +0800 Subject: [PATCH 17/17] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/detail/detailInfo/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/detail/detailInfo/index.tsx b/src/components/detail/detailInfo/index.tsx index 912c664..939662f 100644 --- a/src/components/detail/detailInfo/index.tsx +++ b/src/components/detail/detailInfo/index.tsx @@ -75,7 +75,7 @@ export default class InfoDetail extends DetailField {this.renderComponent(props)} -- Gitee