From 86cb6baba2904cac2af24e48f2c3ec8595bdf360 Mon Sep 17 00:00:00 2001 From: zjt Date: Wed, 13 Apr 2022 12:16:55 +0800 Subject: [PATCH 1/3] =?UTF-8?q?feat:=20=E6=96=87=E6=9C=AC=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E5=80=BC=E6=94=AF=E6=8C=81=E9=A1=B5=E9=9D=A2=E4=BC=A0?= =?UTF-8?q?=E5=8F=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/detail/common.tsx | 10 ++++- src/components/detail/detailColor/index.tsx | 33 +++++++++++++--- src/components/detail/text/index.tsx | 42 +++++++++++++++++---- 3 files changed, 70 insertions(+), 15 deletions(-) diff --git a/src/components/detail/common.tsx b/src/components/detail/common.tsx index 57902c1..c095ba3 100644 --- a/src/components/detail/common.tsx +++ b/src/components/detail/common.tsx @@ -24,7 +24,7 @@ export interface DetailFieldConfig { columns?: ColumnsConfig childColumns?: ColumnsConfig display?: 'none' - defaultValue?: string, + defaultValue?: ParamConfig, condition?: DetailFieldConditionConfig layout?: 'horizontal' | 'vertical' styles?: object @@ -132,7 +132,13 @@ export class DetailField extends Reac config } = this.props - return config.defaultValue + if (typeof config.defaultValue === 'string') { + return config.defaultValue + } + if (config.defaultValue !== undefined) { + return ParamHelper(config.defaultValue, { record: this.props.record, data: this.props.data, step: this.props.step }) + } + return undefined } set: (value: T) => Promise = async (value) => { diff --git a/src/components/detail/detailColor/index.tsx b/src/components/detail/detailColor/index.tsx index d498ce1..f5b3c3e 100644 --- a/src/components/detail/detailColor/index.tsx +++ b/src/components/detail/detailColor/index.tsx @@ -10,13 +10,26 @@ export interface IColorProps { } export default class InfoDetail extends DetailField implements IDetailField { + reset: () => Promise = async () => { + const defaults = await this.defaultValue() + return (defaults === undefined) ? '' : defaults + } + + state = { + value: '' + } + renderComponent = (props: IColorProps) => { return 您当前使用的UI版本没有实现colorDetail组件。 } - getValue = () => { + componentDidMount() { + this.getValue() + } + + getValue = async () => { const { value, config: { @@ -24,14 +37,24 @@ export default class InfoDetail extends DetailField { - const value = this.getValue() + const { value } = this.state return ( diff --git a/src/components/detail/text/index.tsx b/src/components/detail/text/index.tsx index 6338ad6..d621a0a 100644 --- a/src/components/detail/text/index.tsx +++ b/src/components/detail/text/index.tsx @@ -1,6 +1,6 @@ import React from 'react' import { getBoolean } from '../../../util/value' -import { DetailField, DetailFieldConfig, DetailFieldError, IDetailField } from '../common' +import { DetailField, DetailFieldProps, DetailFieldConfig, DetailFieldError, IDetailField } from '../common' export interface TextFieldConfig extends DetailFieldConfig { type: 'text' @@ -11,6 +11,19 @@ export interface ITextField { } export default class TextField extends DetailField implements IDetailField { + reset: () => Promise = async () => { + const defaults = await this.defaultValue() + return (defaults === undefined) ? '' : defaults + } + + state = { + value: '' + } + + constructor(props: DetailFieldProps) { + super(props) + } + renderComponent = (props: ITextField) => { return 您当前使用的UI版本没有实现Text组件。 @@ -19,7 +32,11 @@ export default class TextField extends DetailField } - getValue = () => { + componentDidMount() { + this.getValue() + } + + getValue = async () => { const { value, config: { @@ -27,16 +44,25 @@ export default class TextField extends DetailField { - const value = this.getValue() - console.log(value, 'text value ') - + // console.log(value, 'text value ') + const { value } = this.state return ( {this.renderComponent({ -- Gitee From 81bfa51a199c399a5875667c5587721d0d020c74 Mon Sep 17 00:00:00 2001 From: zjt Date: Fri, 8 Apr 2022 17:11:07 +0800 Subject: [PATCH 2/3] =?UTF-8?q?feat:=20=E6=96=87=E6=9C=AC=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E6=95=B0=E7=BB=84=E5=92=8C=E6=95=B0=E5=AD=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/detail/enum/index.tsx | 2 +- src/components/detail/text/index.tsx | 21 +++++++++++++++------ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/components/detail/enum/index.tsx b/src/components/detail/enum/index.tsx index c79b2cf..658ff32 100644 --- a/src/components/detail/enum/index.tsx +++ b/src/components/detail/enum/index.tsx @@ -35,7 +35,7 @@ export interface IEnumProps { export default class EnumDetail extends DetailField implements IDetailField { reset: () => Promise = async () => { const defaults = await this.defaultValue() - return (defaults === undefined) ? '' : defaults + return (defaults === undefined) ? '/' : defaults } renderComponent = (props: IEnumProps) => { diff --git a/src/components/detail/text/index.tsx b/src/components/detail/text/index.tsx index d621a0a..6a424af 100644 --- a/src/components/detail/text/index.tsx +++ b/src/components/detail/text/index.tsx @@ -13,7 +13,7 @@ export interface ITextField { export default class TextField extends DetailField implements IDetailField { reset: () => Promise = async () => { const defaults = await this.defaultValue() - return (defaults === undefined) ? '' : defaults + return (defaults === undefined) ? '/' : defaults } state = { @@ -43,11 +43,20 @@ export default class TextField extends DetailField).join(',') + }) + } else { + return this.setState({ + value: '/' + }) + } } if (typeof defaultValue === 'string') { this.setState({ -- Gitee From 6a56a343bab500a5565faa3c4fc0b3b21b387343 Mon Sep 17 00:00:00 2001 From: zjt Date: Wed, 13 Apr 2022 14:29:08 +0800 Subject: [PATCH 3/3] =?UTF-8?q?perf:=20=E5=8E=BB=E6=8E=89log?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/detail/text/index.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/detail/text/index.tsx b/src/components/detail/text/index.tsx index 6a424af..15192b8 100644 --- a/src/components/detail/text/index.tsx +++ b/src/components/detail/text/index.tsx @@ -70,7 +70,6 @@ export default class TextField extends DetailField { - // console.log(value, 'text value ') const { value } = this.state return ( -- Gitee