From 097a06c50cf3f86036bc8302a707ef74aa04734d Mon Sep 17 00:00:00 2001 From: Daly Huang Date: Mon, 4 Dec 2023 17:37:57 +0800 Subject: [PATCH 01/11] =?UTF-8?q?=E6=96=B0=E5=A2=9ETransferPicker=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E6=94=AF=E6=8C=81=E5=88=86=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../amis-ui/src/components/TransferPicker.tsx | 25 +++++++++++++++-- packages/amis/src/renderers/Form/Transfer.tsx | 4 +-- .../src/renderers/Form/TransferPicker.tsx | 28 ++++++++++++++++++- 3 files changed, 51 insertions(+), 6 deletions(-) diff --git a/packages/amis-ui/src/components/TransferPicker.tsx b/packages/amis-ui/src/components/TransferPicker.tsx index 784e5ac9b3d..9e17be9fab0 100644 --- a/packages/amis-ui/src/components/TransferPicker.tsx +++ b/packages/amis-ui/src/components/TransferPicker.tsx @@ -23,7 +23,17 @@ export interface TransferPickerProps extends Omit { popOverContainer?: any; } -export class TransferPicker extends React.Component { +export interface TransferPickerState { + tempValue?: any; +} + +export class TransferPicker extends React.Component< + TransferPickerProps, + TransferPickerState +> { + state: TransferPickerState = { + tempValue: null + }; optionModified = false; @autobind handleConfirm(value: any) { @@ -59,6 +69,15 @@ export class TransferPicker extends React.Component { ...rest } = this.props; + const tp = { + value: this.state.tempValue || value, + onChange: (value: any) => { + this.setState({ + tempValue: value + }); + } + }; + return ( { this.optionModified = true; setState({options, value}); } else { - onChange(value); + tp.onChange(value); } }} /> ); }} - value={value} + value={tp.value} onConfirm={this.handleConfirm} size={size} > diff --git a/packages/amis/src/renderers/Form/Transfer.tsx b/packages/amis/src/renderers/Form/Transfer.tsx index 70143a6988b..c6b4671c96b 100644 --- a/packages/amis/src/renderers/Form/Transfer.tsx +++ b/packages/amis/src/renderers/Form/Transfer.tsx @@ -175,9 +175,9 @@ export interface TransferControlSchema */ pagination?: { /** 是否左侧选项分页,默认不开启 */ - enable: SchemaExpression; + enable: boolean; /** 分页组件CSS类名 */ - className?: SchemaClassName; + className?: string; /** 是否开启前端分页 */ loadDataOnce?: boolean; } & Pick< diff --git a/packages/amis/src/renderers/Form/TransferPicker.tsx b/packages/amis/src/renderers/Form/TransferPicker.tsx index 7dd789e51c6..d45cf63002b 100644 --- a/packages/amis/src/renderers/Form/TransferPicker.tsx +++ b/packages/amis/src/renderers/Form/TransferPicker.tsx @@ -7,6 +7,7 @@ import {autobind, createObject} from 'amis-core'; import {ActionObject, toNumber} from 'amis-core'; import {supportStatic} from './StaticHoc'; import {isMobile} from 'amis-core'; +import pick from 'lodash/pick'; /** * TransferPicker 穿梭器的弹框形态 @@ -93,7 +94,10 @@ export class TransferPickerRenderer extends BaseTransferRenderer 0, + maxButtons: Number.isInteger(pagination?.maxButtons) + ? pagination?.maxButtons + : 5, + page: formItem?.sourcePageNum, + perPage: formItem?.sourcePerPageNum, + total: formItem?.sourceTotalNum, + popOverContainer: popOverContainer ?? env?.getModalContainer + }} + onPageChange={this.handlePageChange} /> Date: Thu, 7 Dec 2023 20:16:58 +0800 Subject: [PATCH 02/11] =?UTF-8?q?=E8=A7=A3=E5=86=B3transfer=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E5=BC=80=E5=90=AF=E5=88=86=E9=A1=B5=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E6=90=9C=E7=B4=A2=E4=B8=8D=E6=94=AF=E6=8C=81=E5=88=86=E9=A1=B5?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98=E3=80=82transferPicker=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E4=B8=B4=E6=97=B6=E9=80=89=E4=B8=AD=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E5=85=B3=E9=97=AD=E9=A1=B5=E9=9D=A2=E5=90=8E=E7=BC=93=E5=AD=98?= =?UTF-8?q?=E9=9C=80=E6=B8=85=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/amis-ui/src/components/Transfer.tsx | 115 +++++++++++++----- .../amis-ui/src/components/TransferPicker.tsx | 6 + packages/amis/src/renderers/Form/Transfer.tsx | 98 +++++++++------ 3 files changed, 154 insertions(+), 65 deletions(-) diff --git a/packages/amis-ui/src/components/Transfer.tsx b/packages/amis-ui/src/components/Transfer.tsx index 214a031e8ea..b070b5f8bce 100644 --- a/packages/amis-ui/src/components/Transfer.tsx +++ b/packages/amis-ui/src/components/Transfer.tsx @@ -79,8 +79,14 @@ export interface TransferProps onChange?: (value: Array