fix(editor): 节点未注册时回退使用 formValue 加载事件与动作选项

当 editorService.getNodeById 找不到节点时,使用 formValue 作为 fallback,避免事件名和动作选项为空。
This commit is contained in:
roymondchen 2026-08-07 17:01:52 +08:00
parent a7198e2731
commit 53c4763a59
2 changed files with 5 additions and 5 deletions

View File

@ -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) => ({

View File

@ -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) {