fix(editor): 数据源方法编辑后content变成字符串

This commit is contained in:
roymondchen 2025-12-29 19:22:28 +08:00
parent 8150f042ff
commit 03b6180a02
2 changed files with 30 additions and 9 deletions

View File

@ -217,9 +217,38 @@ const functionConfig = computed<FormConfig>(() => [
},
]);
const parseContent = (content: any) => {
if (typeof content === 'string') {
//
const parseDSL = getEditorConfig('parseDSL');
return parseDSL<(..._args: any[]) => any>(content);
}
return content;
};
const submitForm = (values: CodeBlockContent, data: ContainerChangeEventData) => {
changedValue.value = undefined;
emit('submit', values, data);
emit(
'submit',
{
...values,
content: parseContent(values.content),
},
{
...data,
changeRecords: data.changeRecords?.map((record) => {
let { value } = record;
if (record.propPath === 'content' && typeof value === 'string') {
value = parseContent(value);
}
return {
...record,
value,
};
}),
},
);
};
const errorHandler = (error: any) => {

View File

@ -31,7 +31,6 @@ import { type ColumnConfig, MagicTable } from '@tmagic/table';
import CodeBlockEditor from '@editor/components/CodeBlockEditor.vue';
import type { CodeParamStatement } from '@editor/type';
import { getEditorConfig } from '@editor/utils/config';
defineOptions({
name: 'MFieldsDataSourceMethods',
@ -119,13 +118,6 @@ const createCodeHandler = () => {
};
const submitCodeHandler = (value: CodeBlockContent, data: ContainerChangeEventData) => {
if (value.content) {
//
const parseDSL = getEditorConfig('parseDSL');
if (typeof value.content === 'string') {
value.content = parseDSL<(..._args: any[]) => any>(value.content);
}
}
if (editIndex > -1) {
emit('change', value, {
modifyKey: editIndex,