diff --git a/packages/editor/src/fields/EventSelect.vue b/packages/editor/src/fields/EventSelect.vue index 8ab8bd95..a19e63e9 100644 --- a/packages/editor/src/fields/EventSelect.vue +++ b/packages/editor/src/fields/EventSelect.vue @@ -85,7 +85,7 @@ import { Delete } from '@element-plus/icons-vue'; import { Plus } from '@element-plus/icons-vue'; import { has } from 'lodash-es'; -import { ActionType } from '@tmagic/core'; +import { ActionType, MNode } from '@tmagic/core'; import { TMagicButton } from '@tmagic/design'; import type { CodeSelectColConfig, @@ -327,8 +327,8 @@ const tableConfig = computed( name: 'method', label: '动作', type: compActionConfig.value.type, - options: (mForm: FormState, { model }: any) => { - const node = editorService.getNodeById(model.to); + options: (mForm: FormState, { model, formValue }: any) => { + const node = editorService.getNodeById(model.to) || (formValue as MNode); if (!node?.type) return []; return eventsService.getMethod(node.type, { targetId: model.to, node }).map((option: any) => ({ diff --git a/packages/editor/src/utils/event.ts b/packages/editor/src/utils/event.ts index 4725a547..285b928e 100644 --- a/packages/editor/src/utils/event.ts +++ b/packages/editor/src/utils/event.ts @@ -16,7 +16,7 @@ * limitations under the License. */ -import type { EventOption, Id, MComponent, MContainer } from '@tmagic/core'; +import type { EventOption, Id, MComponent, MContainer, MNode } from '@tmagic/core'; import type { CascaderOption } from '@tmagic/form'; import { DATA_SOURCE_FIELDS_CHANGE_EVENT_PREFIX, traverseNode } from '@tmagic/utils'; @@ -56,7 +56,7 @@ export const getEventNameOptions = ( } if (src === 'component') { - const sourceNode = editorService.getNodeById(formValue.id); + const sourceNode = editorService.getNodeById(formValue.id) || (formValue as MNode); let events: EventOption[] | CascaderOption[] = eventsService.getEvent(formValue.type, { node: sourceNode }) || []; if (formValue.type === 'page-fragment-container' && formValue.pageFragmentId) {