1
0
mirror of synced 2026-04-03 06:28:35 +08:00

feat(editor): 数据源事件配置

This commit is contained in:
roymondchen
2023-09-21 10:58:39 +08:00
parent 36988cd3e0
commit 8b7a1e4e3c
5 changed files with 40 additions and 3 deletions

View File

@@ -52,6 +52,7 @@ import { computed, inject } from 'vue';
import { Delete } from '@element-plus/icons-vue';
import { has } from 'lodash-es';
import type { EventOption } from '@tmagic/core';
import { TMagicButton } from '@tmagic/design';
import type { FieldProps, FormState } from '@tmagic/form';
import { ActionType } from '@tmagic/schema';
@@ -75,11 +76,22 @@ const eventNameConfig = computed(() => {
text: '事件',
type: 'select',
labelWidth: '40px',
options: (mForm: FormState, { formValue }: any) =>
services?.eventsService.getEvent(formValue.type).map((option: any) => ({
options: (mForm: FormState, { formValue }: any) => {
let events: EventOption[] = [];
if (!services) return events;
if (props.config.src === 'component') {
events = services.eventsService.getEvent(formValue.type);
} else if (props.config.src === 'datasource') {
events = services.dataSourceService.getFormEvent(formValue.type);
}
return events.map((option) => ({
text: option.label,
value: option.value,
})),
}));
},
};
return { ...defaultEventNameConfig, ...props.config.eventNameConfig };
});