From 9347a0393e6f62c81ed35b7bab3e272a2d01c934 Mon Sep 17 00:00:00 2001 From: wangailin Date: Thu, 10 Mar 2022 11:18:45 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20[form]=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E8=A1=A8=E5=8D=95=E9=A1=B9=E7=82=B9=E5=87=BB=E5=89=8D=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C[table]=E4=BF=AE=E5=A4=8D=E5=BC=B9=E7=AA=97=E5=AE=BD?= =?UTF-8?q?=E5=BA=A6=E6=9C=AA=E7=94=9F=E6=95=88,=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=8C=89=E9=92=AE=E8=B7=B3=E8=BD=AC=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/form/index.tsx | 14 +++++++++++-- src/steps/table/index.tsx | 44 +++++++++++++++++++++++++-------------- 2 files changed, 40 insertions(+), 18 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 ( diff --git a/src/steps/table/index.tsx b/src/steps/table/index.tsx index a3a5dbd..44071b1 100644 --- a/src/steps/table/index.tsx +++ b/src/steps/table/index.tsx @@ -62,7 +62,9 @@ export interface TableCCMSOperationConfig { type: 'ccms' page: any target: 'current' | 'page' | 'open' | 'handle' + historyTpye?: 'replace' targetURL: string + width: string data: { [key: string]: ParamConfig } params?: { field: string, data: ParamConfig }[] callback?: boolean @@ -98,6 +100,7 @@ interface TableOperationConfirmConfig { export interface ITable { title: string | null primary: string + width: string data: { [field: string]: any }[] columns: ITableColumn[] pagination?: { @@ -213,6 +216,7 @@ interface TableState { operation: { enable: boolean target: 'current' | 'handle' + width: string title: string visible: boolean config: CCMSConfig @@ -245,6 +249,7 @@ export default class TableStep extends Step { enable: false, target: 'current', title: '', + width: '400px', visible: false, config: {}, data: {}, @@ -322,6 +327,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, @@ -337,7 +343,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) @@ -502,6 +512,7 @@ export default class TableStep extends Step { operation: { enable: operationEnable, target: operationTarget, + width: operationWidth, title: operationTitle, visible: operationVisible, config: operationConfig, @@ -518,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) => { @@ -702,11 +714,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