From e5b340053e024f53f09b02b7923494a93be79ac1 Mon Sep 17 00:00:00 2001 From: hsm-lv Date: Fri, 19 Aug 2022 11:07:36 +0800 Subject: [PATCH] =?UTF-8?q?feat:picker=E6=94=AF=E6=8C=81=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=E5=8A=A8=E4=BD=9C=E5=8F=AF=E8=A7=86=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I2fa989a8c2dfc3703e636fa77f6b951b5e86a660 --- .../amis-editor/src/plugin/Form/Picker.tsx | 72 ++++++++++++++----- 1 file changed, 56 insertions(+), 16 deletions(-) diff --git a/packages/amis-editor/src/plugin/Form/Picker.tsx b/packages/amis-editor/src/plugin/Form/Picker.tsx index cdebc3f78..35d12d8f6 100644 --- a/packages/amis-editor/src/plugin/Form/Picker.tsx +++ b/packages/amis-editor/src/plugin/Form/Picker.tsx @@ -1,7 +1,7 @@ import React from 'react'; import {Button} from 'amis'; import omit from 'lodash/omit'; -import {getSchemaTpl} from 'amis-editor-core'; +import {getSchemaTpl, RendererPluginAction, RendererPluginEvent} from 'amis-editor-core'; import {registerEditorPlugin} from 'amis-editor-core'; import { BaseEventContext, @@ -11,6 +11,7 @@ import { ContextMenuItem } from 'amis-editor-core'; import {diff} from 'amis-editor-core'; +import {getEventControlConfig} from '../../renderer/event-control/helper'; export class PickerControlPlugin extends BasePlugin { // 关联渲染器名字 @@ -53,24 +54,51 @@ export class PickerControlPlugin extends BasePlugin { ] }; + // 事件定义 + events: RendererPluginEvent[] = [ + { + eventName: 'change', + eventLabel: '值变化', + description: '选中状态变化时触发', + dataSchema: [ + { + type: 'object', + properties: { + 'event.data.value': { + type: 'string', + title: '选中值' + }, + 'event.data.option': { + type: 'string', + title: '选中的行数据' + } + } + } + ] + } + ]; + panelTitle = '列表选取'; panelBodyCreator = (context: BaseEventContext) => { - return [ - getSchemaTpl('switch', { - name: 'embed', - label: '开启内嵌模式' - }), - - getSchemaTpl('switchDefaultValue'), - + return getSchemaTpl('tabs', [ { - type: 'input-text', - name: 'value', - label: '默认值', - visibleOn: 'typeof this.value !== "undefined"' - }, + title: '属性', + body: [ + getSchemaTpl('switch', { + name: 'embed', + label: '开启内嵌模式' + }), - getSchemaTpl('fieldSet', { + getSchemaTpl('switchDefaultValue'), + + { + type: 'input-text', + name: 'value', + label: '默认值', + visibleOn: 'typeof this.value !== "undefined"' + }, + + getSchemaTpl('fieldSet', { title: '选项', body: [ getSchemaTpl('options'), @@ -128,7 +156,19 @@ export class PickerControlPlugin extends BasePlugin { getSchemaTpl('autoFill') ] }) - ]; + ] + }, + { + title: '事件', + className: 'p-none', + body: [ + getSchemaTpl('eventControl', { + name: 'onEvent', + ...getEventControlConfig(this.manager, context) + }) + ] + } + ]); }; buildEditorToolbar(