From e8714c96c9f3ae4644d830d232b2732adbcd05fa Mon Sep 17 00:00:00 2001 From: roymondchen Date: Fri, 20 Mar 2026 17:38:11 +0800 Subject: [PATCH] =?UTF-8?q?feat(form-schema,form,editor,table):=20?= =?UTF-8?q?=E5=AE=8C=E5=96=84=E8=A1=A8=E5=8D=95=E9=85=8D=E7=BD=AE=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../editor/src/components/CodeBlockEditor.vue | 138 ++++++++++-------- packages/editor/src/components/CodeParams.vue | 6 +- packages/editor/src/fields/CodeSelectCol.vue | 5 +- .../fields/DataSourceFieldSelect/Index.vue | 4 +- .../src/fields/DataSourceMethodSelect.vue | 5 +- packages/editor/src/fields/EventSelect.vue | 121 +++++++-------- .../fields/StyleSetter/components/Border.vue | 68 ++++----- .../src/fields/StyleSetter/pro/Background.vue | 8 +- .../src/fields/StyleSetter/pro/Border.vue | 6 +- .../src/fields/StyleSetter/pro/Font.vue | 6 +- .../src/fields/StyleSetter/pro/Layout.vue | 4 +- .../src/fields/StyleSetter/pro/Position.vue | 6 +- .../src/utils/data-source/formConfigs/base.ts | 4 +- .../editor/src/utils/data-source/index.ts | 12 +- packages/editor/src/utils/props.ts | 4 +- packages/form-schema/src/base.ts | 51 ++++--- packages/form-schema/src/editor.ts | 5 +- packages/form-schema/src/index.ts | 5 +- packages/form/src/FormDialog.vue | 20 ++- packages/form/src/containers/Col.vue | 8 +- packages/form/src/containers/Container.vue | 8 +- packages/form/src/table/useAdd.ts | 4 +- packages/form/src/table/useTableColumns.ts | 6 +- packages/form/src/utils/form.ts | 10 +- packages/table/src/TextColumn.vue | 4 +- 25 files changed, 278 insertions(+), 240 deletions(-) diff --git a/packages/editor/src/components/CodeBlockEditor.vue b/packages/editor/src/components/CodeBlockEditor.vue index 6d35e579..19d46f2a 100644 --- a/packages/editor/src/components/CodeBlockEditor.vue +++ b/packages/editor/src/components/CodeBlockEditor.vue @@ -63,7 +63,14 @@ import { computed, inject, nextTick, Ref, ref, useTemplateRef, watch } from 'vue import type { CodeBlockContent } from '@tmagic/core'; import { TMagicButton, TMagicDialog, tMagicMessage, tMagicMessageBox, TMagicTag } from '@tmagic/design'; -import { type ContainerChangeEventData, type FormConfig, type FormState, MFormBox } from '@tmagic/form'; +import { + type ContainerChangeEventData, + defineFormConfig, + defineFormItem, + type FormConfig, + MFormBox, + type TableColumnConfig, +} from '@tmagic/form'; import FloatingBox from '@editor/components/FloatingBox.vue'; import { useEditorContentHeight } from '@editor/hooks/use-editor-content-height'; @@ -112,7 +119,7 @@ const diffChange = () => { difVisible.value = false; }; -const defaultParamColConfig = { +const defaultParamColConfig = defineFormItem({ type: 'row', label: '参数类型', items: [ @@ -140,76 +147,79 @@ const defaultParamColConfig = { ], }, ], -}; +}); -const functionConfig = computed(() => [ - { - text: '名称', - name: 'name', - rules: [{ required: true, message: '请输入名称', trigger: 'blur' }], - }, - { - text: '描述', - name: 'desc', - }, - { - text: '执行时机', - name: 'timing', - type: 'select', - options: () => { - const options = [ - { text: '初始化前', value: 'beforeInit' }, - { text: '初始化后', value: 'afterInit' }, - ]; - if (props.dataSourceType !== 'base') { - options.push({ text: '请求前', value: 'beforeRequest' }); - options.push({ text: '请求后', value: 'afterRequest' }); - } - return options; - }, - display: () => props.isDataSource, - }, - { - type: 'table', - border: true, - text: '参数', - enableFullscreen: false, - enableToggleMode: false, - name: 'params', - dropSort: false, - items: [ +const functionConfig = computed( + () => + defineFormConfig([ { - type: 'text', - label: '参数名', + text: '名称', name: 'name', + rules: [{ required: true, message: '请输入名称', trigger: 'blur' }], }, { - type: 'text', - label: '描述', - name: 'extra', + text: '描述', + name: 'desc', }, - codeBlockService.getParamsColConfig() || defaultParamColConfig, - ], - }, - { - name: 'content', - type: 'vs-code', - options: inject('codeOptions', {}), - autosize: { minRows: 10, maxRows: 30 }, - onChange: (formState: FormState | undefined, code: string) => { - try { - // 检测js代码是否存在语法错误 - getEditorConfig('parseDSL')(code); + { + text: '执行时机', + name: 'timing', + type: 'select', + options: () => { + const options = [ + { text: '初始化前', value: 'beforeInit' }, + { text: '初始化后', value: 'afterInit' }, + ]; + if (props.dataSourceType !== 'base') { + options.push({ text: '请求前', value: 'beforeRequest' }); + options.push({ text: '请求后', value: 'afterRequest' }); + } + return options; + }, + display: () => props.isDataSource, + }, + { + type: 'table', + border: true, + text: '参数', + enableFullscreen: false, + enableToggleMode: false, + name: 'params', + dropSort: false, + items: [ + { + type: 'text', + label: '参数名', + name: 'name', + }, + { + type: 'text', + label: '描述', + name: 'extra', + }, + codeBlockService.getParamsColConfig() || defaultParamColConfig, + ], + }, + { + name: 'content', + type: 'vs-code', + options: inject('codeOptions', {}), + autosize: { minRows: 10, maxRows: 30 }, + onChange: (_formState, code: string) => { + try { + // 检测js代码是否存在语法错误 + getEditorConfig('parseDSL')(code); - return code; - } catch (error: any) { - tMagicMessage.error(error.message); + return code; + } catch (error: any) { + tMagicMessage.error(error.message); - throw error; - } - }, - }, -]); + throw error; + } + }, + }, + ]) as FormConfig, +); const parseContent = (content: any) => { if (typeof content === 'string') { diff --git a/packages/editor/src/components/CodeParams.vue b/packages/editor/src/components/CodeParams.vue index 2f095e8a..aac07fd9 100644 --- a/packages/editor/src/components/CodeParams.vue +++ b/packages/editor/src/components/CodeParams.vue @@ -13,7 +13,7 @@