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()} );