diff --git a/apps/web-antd/src/adapter/form.ts b/apps/web-antd/src/adapter/form.ts index b6f32893..4fda8a81 100644 --- a/apps/web-antd/src/adapter/form.ts +++ b/apps/web-antd/src/adapter/form.ts @@ -115,3 +115,4 @@ export { useVbenForm, z }; export type VbenFormSchema = FormSchema; export type { VbenFormProps }; +export type FormSchemaGetter = () => VbenFormSchema[]; diff --git a/apps/web-antd/src/views/system/config/config-modal.vue b/apps/web-antd/src/views/system/config/config-modal.vue index 8601afa9..a8fdddd9 100644 --- a/apps/web-antd/src/views/system/config/config-modal.vue +++ b/apps/web-antd/src/views/system/config/config-modal.vue @@ -6,7 +6,8 @@ import { $t } from '@vben/locales'; import { useVbenForm } from '#/adapter'; import { configAdd, configUpdate } from '#/api/system/config'; -import { getDictOptions } from '#/utils/dict'; + +import { modalSchema } from './data'; const emit = defineEmits<{ reload: [] }>(); @@ -21,64 +22,7 @@ const title = computed(() => { }); const [BasicForm, formApi] = useVbenForm({ - schema: [ - { - component: 'Input', - dependencies: { - show: () => false, - triggerFields: [''], - }, - fieldName: 'configId', - label: '参数主键', - }, - { - component: 'Input', - componentProps: { - placeholder: '请输入', - }, - fieldName: 'configName', - label: '参数名称', - rules: 'required', - }, - { - component: 'Input', - componentProps: { - placeholder: '请输入', - }, - fieldName: 'configKey', - label: '参数键名', - rules: 'required', - }, - { - component: 'Input', - componentProps: { - placeholder: '请输入', - }, - fieldName: 'configValue', - label: '参数键值', - rules: 'required', - }, - { - component: 'RadioGroup', - componentProps: { - buttonStyle: 'solid', - options: getDictOptions('sys_yes_no'), - optionType: 'button', - }, - defaultValue: 'N', - fieldName: 'configType', - label: '是否内置', - rules: 'required', - }, - { - component: 'Textarea', - componentProps: { - placeholder: '请输入', - }, - fieldName: 'remark', - label: '备注', - }, - ], + schema: modalSchema(), showDefaultActions: false, }); diff --git a/apps/web-antd/src/views/system/config/data.ts b/apps/web-antd/src/views/system/config/data.ts new file mode 100644 index 00000000..8fd1fcb6 --- /dev/null +++ b/apps/web-antd/src/views/system/config/data.ts @@ -0,0 +1,64 @@ +import type { FormSchemaGetter } from '#/adapter'; + +import { DictEnum } from '@vben/constants'; + +import { getDictOptions } from '#/utils/dict'; + +export const modalSchema: FormSchemaGetter = () => [ + { + component: 'Input', + dependencies: { + show: () => false, + triggerFields: [''], + }, + fieldName: 'configId', + label: '参数主键', + }, + { + component: 'Input', + componentProps: { + placeholder: '请输入', + }, + fieldName: 'configName', + label: '参数名称', + rules: 'required', + }, + { + component: 'Input', + componentProps: { + placeholder: '请输入', + }, + fieldName: 'configKey', + label: '参数键名', + rules: 'required', + }, + { + component: 'Input', + componentProps: { + placeholder: '请输入', + }, + fieldName: 'configValue', + label: '参数键值', + rules: 'required', + }, + { + component: 'RadioGroup', + componentProps: { + buttonStyle: 'solid', + options: getDictOptions(DictEnum.SYS_YES_NO), + optionType: 'button', + }, + defaultValue: 'N', + fieldName: 'configType', + label: '是否内置', + rules: 'required', + }, + { + component: 'Textarea', + componentProps: { + placeholder: '请输入', + }, + fieldName: 'remark', + label: '备注', + }, +]; diff --git a/cspell.json b/cspell.json index 05d09ac8..3778dd4f 100644 --- a/cspell.json +++ b/cspell.json @@ -29,6 +29,7 @@ "noreferrer", "nprogress", "nuxt", + "oper", "pinia", "prefixs", "publint", diff --git a/packages/@core/base/shared/src/constants/dict-enum.ts b/packages/@core/base/shared/src/constants/dict-enum.ts new file mode 100644 index 00000000..b0976b46 --- /dev/null +++ b/packages/@core/base/shared/src/constants/dict-enum.ts @@ -0,0 +1,15 @@ +export enum DictEnum { + SYS_COMMON_STATUS = 'sys_common_status', + SYS_DEVICE_TYPE = 'sys_device_type', // 设备类型 + SYS_GRANT_TYPE = 'sys_grant_type', // 授权类型 + SYS_NORMAL_DISABLE = 'sys_normal_disable', + SYS_NOTICE_STATUS = 'sys_notice_status', // 通知状态 + SYS_NOTICE_TYPE = 'sys_notice_type', // 通知类型 + SYS_OPER_TYPE = 'sys_oper_type', // 操作类型 + SYS_OSS_ACCESS_POLICY = 'oss_access_policy', // oss权限桶类型 + SYS_SHOW_HIDE = 'sys_show_hide', // 显示状态 + SYS_USER_SEX = 'sys_user_sex', // 性别 + SYS_YES_NO = 'sys_yes_no', // 是否 + WF_BUSINESS_STATUS = 'wf_business_status', // 业务状态 + WF_FORM_TYPE = 'wf_form_type', // 表单类型 +} diff --git a/packages/@core/base/shared/src/constants/index.ts b/packages/@core/base/shared/src/constants/index.ts index 09e55f5b..6e818083 100644 --- a/packages/@core/base/shared/src/constants/index.ts +++ b/packages/@core/base/shared/src/constants/index.ts @@ -1,2 +1,3 @@ +export * from './dict-enum'; export * from './globals'; export * from './vben';