roymondchen 93dc0d2187 feat(form): 新增无渲染校验入口,支持 Node/CI 环境执行表单校验
将 submitForm/validateForm 改为无 DOM 的 headless 实现,并抽取字段登记与编辑器复合字段配置,便于脚本与 CI 批量校验。
2026-08-28 15:33:54 +08:00

47 lines
1.1 KiB
Vue

<template>
<MContainer
v-for="(item, index) in formConfig"
:prop="prop"
:key="index"
:config="item"
:model="values"
:last-values="lastValues"
:is-compare="isCompare"
:size="size"
:disabled="disabled"
@change="change"
@add-diff-count="onAddDiffCount"
></MContainer>
</template>
<script lang="ts" setup>
import { computed } from 'vue';
import { type ContainerChangeEventData, MContainer } from '@tmagic/form';
import type { StyleSchema } from '@tmagic/schema';
import { createPositionConfig } from '../configs';
const props = defineProps<{
values: Partial<StyleSchema>;
lastValues?: Partial<StyleSchema>;
isCompare?: boolean;
disabled?: boolean;
size?: 'large' | 'default' | 'small';
prop?: string;
}>();
const emit = defineEmits<{
change: [v: string | StyleSchema, eventData: ContainerChangeEventData];
addDiffCount: [];
}>();
const formConfig = computed(() => createPositionConfig(props.values));
const change = (value: string | StyleSchema, eventData: ContainerChangeEventData) => {
emit('change', value, eventData);
};
const onAddDiffCount = () => emit('addDiffCount');
</script>