From 1f644a47e620e3c66d35e12616046d03e63312ee Mon Sep 17 00:00:00 2001 From: yanglu19 Date: Wed, 9 Aug 2023 12:55:30 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20timeline=E7=BB=84=E4=BB=B6=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E9=9D=A2=E6=9D=BF=E5=A2=9E=E5=8A=A0=E5=85=B3=E8=81=94?= =?UTF-8?q?=E4=B8=8A=E4=B8=8B=E6=96=87=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/renderer/TimelineItemControl.tsx | 28 +++++++++++++++++-- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/packages/amis-editor/src/renderer/TimelineItemControl.tsx b/packages/amis-editor/src/renderer/TimelineItemControl.tsx index d3f970fd9..b5a8a700d 100644 --- a/packages/amis-editor/src/renderer/TimelineItemControl.tsx +++ b/packages/amis-editor/src/renderer/TimelineItemControl.tsx @@ -29,7 +29,7 @@ export interface TimelineItemProps extends FormControlProps { export interface TimelineItemState { items: Array>; - source: 'custom' | 'api'; + source: 'custom' | 'api' | 'variable'; api: SchemaApi; } @@ -54,7 +54,7 @@ export default class TimelineItemControl extends React.Component< * 切换选项类型 */ @autobind - handleSourceChange(source: 'custom' | 'api') { + handleSourceChange(source: 'custom' | 'api' | 'variable') { this.setState({source: source}, this.onChange); } @@ -80,6 +80,11 @@ export default class TimelineItemControl extends React.Component< data.items = items.map(item => ({...item})); data.source = api; } + if (source === 'variable') { + const {items, api} = this.state; + data.items = items.map(item => ({...item})); + data.source = api; + } onBulkChange && onBulkChange(data); } @@ -339,10 +344,14 @@ export default class TimelineItemControl extends React.Component< { label: '接口获取', value: 'api' + }, + { + label: '上下文变量', + value: 'variable' } ] as Array<{ label: string; - value: 'custom' | 'api'; + value: 'custom' | 'api' | 'variable'; }> ).map(item => ({ ...item, @@ -562,6 +571,19 @@ export default class TimelineItemControl extends React.Component< ) : null} + + {source === 'variable' + ? render( + 'variable', + getSchemaTpl('sourceBindControl', { + label: false, + className: 'ae-ExtendMore' + }), + { + onChange: this.handleAPIChange + } + ) + : null} {this.renderApiPanel()} );