-
- {{ filter(config.title) }}
-
-
+
+
+
+
+ {{ filter(config.title) }}
@@ -61,7 +61,7 @@
import { computed, inject, ref } from 'vue';
import { CaretBottom, CaretRight } from '@element-plus/icons-vue';
-import { TMagicCard, TMagicIcon } from '@tmagic/design';
+import { TMagicButton, TMagicCard } from '@tmagic/design';
import { FormState, PanelConfig } from '../schema';
import { filterFunction } from '../utils/form';
@@ -73,7 +73,7 @@ const props = defineProps<{
lastValues?: any;
isCompare?: boolean;
config: PanelConfig;
- name: string;
+ name?: string;
labelWidth?: string;
prop?: string;
size?: string;
diff --git a/packages/schema/src/index.ts b/packages/schema/src/index.ts
index fb96f5eb..c3d10091 100644
--- a/packages/schema/src/index.ts
+++ b/packages/schema/src/index.ts
@@ -24,15 +24,51 @@ export enum NodeType {
export type Id = string | number;
-export interface EventItemConfig {
+// 事件联动的动作类型
+export enum ActionType {
+ /** 联动组件 */
+ COMP = 'comp',
+ /** 联动代码 */
+ CODE = 'code',
+}
+
+/** 事件类型(已废弃,后续不建议继续使用) */
+export interface DeprecatedEventConfig {
+ /** 待触发的事件名称 */
+ name: string;
/** 被选中组件ID */
to: Id;
- /** 被选中组件名称 */
- name: string;
/** 触发事件后执行被选中组件的方法 */
method: string;
}
+export interface EventConfig {
+ /** 待触发的事件名称 */
+ name: string;
+ /** 动作响应配置 */
+ actions: EventActionItem[];
+}
+
+export interface CodeItemConfig {
+ /** 动作类型 */
+ actionType: ActionType;
+ /** 代码ID */
+ codeId: Id;
+ /** 代码参数 */
+ params?: object;
+}
+
+export interface CompItemConfig {
+ /** 动作类型 */
+ actionType: ActionType;
+ /** 被选中组件ID */
+ to: Id;
+ /** 触发事件后执行被选中组件的方法 */
+ method: string;
+}
+
+export type EventActionItem = CompItemConfig | CodeItemConfig;
+
export interface MComponent {
/** 组件ID,默认为${type}_${number}}形式, 如:page_123 */
id: Id;
@@ -43,7 +79,7 @@ export interface MComponent {
/** 组件根Dom上的class */
className?: string;
/* 关联事件集合 */
- events?: EventItemConfig[];
+ events?: EventConfig[] | DeprecatedEventConfig[];
/** 组件根Dom的style */
style?: {
[key: string]: any;
diff --git a/playground/src/configs/dsl.ts b/playground/src/configs/dsl.ts
index 183baca5..275c7bfe 100644
--- a/playground/src/configs/dsl.ts
+++ b/playground/src/configs/dsl.ts
@@ -28,9 +28,11 @@ export default {
params: [
{
name: 'age',
+ type: 'number',
},
{
name: 'studentName',
+ type: 'text',
},
],
},
@@ -64,7 +66,35 @@ export default {
fontSize: '',
fontWeight: '',
},
- events: [],
+ events: [
+ {
+ name: 'magic:common:events:click', // 事件名
+ actions: [
+ {
+ actionType: 'code', // 联动动作类型
+ codeId: 'code_5336', // 代码块id
+ params: {
+ age: 12,
+ }, // 参数
+ },
+ {
+ actionType: 'comp',
+ to: 'overlay_2159', // 联动组件id
+ method: 'openOverlay', // 联动组件方法
+ },
+ ],
+ },
+ {
+ name: 'magic:common:events:click', // 事件名
+ actions: [
+ {
+ actionType: 'code', // 联动动作类型
+ codeId: 'code_5316', // 代码块id
+ params: {},
+ },
+ ],
+ },
+ ],
created: {
hookType: 'code',
hookData: [