refactor: 破坏性更新 dict 抽离

This commit is contained in:
xingyu4j
2025-09-05 12:00:24 +08:00
parent b79bebab18
commit 5ef57590e0
112 changed files with 397 additions and 518 deletions

View File

@@ -4,6 +4,8 @@ import type { Demo01ContactApi } from '#/api/infra/demo/demo01';
import { h, onMounted, reactive, ref } from 'vue';
import { Page, useVbenModal } from '@vben/common-ui';
import { DICT_TYPE } from '@vben/constants';
import { getDictOptions } from '@vben/hooks';
import { Download, Plus, Trash2 } from '@vben/icons';
import {
cloneDeep,
@@ -37,7 +39,6 @@ import { DictTag } from '#/components/dict-tag';
import { TableToolbar } from '#/components/table-toolbar';
import { useTableToolbar } from '#/hooks';
import { $t } from '#/locales';
import { DICT_TYPE, getDictOptions } from '#/utils';
import Demo01ContactForm from './modules/form.vue';
@@ -180,11 +181,11 @@ onMounted(() => {
class="!w-[240px]"
>
<ElOption
v-for="dict in getDictOptions(
v-for="(dict, index) in getDictOptions(
DICT_TYPE.SYSTEM_USER_SEX,
'number',
)"
:key="dict.value"
:key="index"
:value="dict.value"
:label="dict.label"
/>

View File

@@ -6,6 +6,8 @@ import type { Demo01ContactApi } from '#/api/infra/demo/demo01';
import { computed, reactive, ref } from 'vue';
import { useVbenModal } from '@vben/common-ui';
import { DICT_TYPE } from '@vben/constants';
import { getDictOptions } from '@vben/hooks';
import {
ElDatePicker,
@@ -25,7 +27,6 @@ import {
import { Tinymce as RichTextarea } from '#/components/tinymce';
import { ImageUpload } from '#/components/upload';
import { $t } from '#/locales';
import { DICT_TYPE, getDictOptions } from '#/utils';
const emit = defineEmits(['success']);
@@ -119,8 +120,11 @@ const [Modal, modalApi] = useVbenModal({
<ElFormItem label="性别" prop="sex">
<ElRadioGroup v-model="formData.sex">
<ElRadio
v-for="dict in getDictOptions(DICT_TYPE.SYSTEM_USER_SEX, 'number')"
:key="dict.value"
v-for="(dict, index) in getDictOptions(
DICT_TYPE.SYSTEM_USER_SEX,
'number',
)"
:key="index"
:label="dict.value"
>
{{ dict.label }}

View File

@@ -4,6 +4,8 @@ import type { Demo03StudentApi } from '#/api/infra/demo/demo03/erp';
import { h, onMounted, reactive, ref } from 'vue';
import { Page, useVbenModal } from '@vben/common-ui';
import { DICT_TYPE } from '@vben/constants';
import { getDictOptions } from '@vben/hooks';
import { Download, Plus, Trash2 } from '@vben/icons';
import {
cloneDeep,
@@ -39,7 +41,6 @@ import { DictTag } from '#/components/dict-tag';
import { TableToolbar } from '#/components/table-toolbar';
import { useTableToolbar } from '#/hooks';
import { $t } from '#/locales';
import { DICT_TYPE, getDictOptions } from '#/utils';
import Demo03CourseList from './modules/demo03-course-list.vue';
import Demo03GradeList from './modules/demo03-grade-list.vue';
@@ -192,11 +193,11 @@ onMounted(() => {
class="!w-[240px]"
>
<ElOption
v-for="dict in getDictOptions(
v-for="(dict, index) in getDictOptions(
DICT_TYPE.SYSTEM_USER_SEX,
'number',
)"
:key="dict.value"
:key="index"
:value="dict.value"
:label="dict.label"
/>

View File

@@ -6,6 +6,8 @@ import type { Demo03StudentApi } from '#/api/infra/demo/demo03/erp';
import { computed, reactive, ref } from 'vue';
import { useVbenModal } from '@vben/common-ui';
import { DICT_TYPE } from '@vben/constants';
import { getDictOptions } from '@vben/hooks';
import {
ElDatePicker,
@@ -24,7 +26,6 @@ import {
} from '#/api/infra/demo/demo03/erp';
import { Tinymce as RichTextarea } from '#/components/tinymce';
import { $t } from '#/locales';
import { DICT_TYPE, getDictOptions } from '#/utils';
const emit = defineEmits(['success']);

View File

@@ -4,6 +4,8 @@ import type { Demo03StudentApi } from '#/api/infra/demo/demo03/inner';
import { h, onMounted, reactive, ref } from 'vue';
import { Page, useVbenModal } from '@vben/common-ui';
import { DICT_TYPE } from '@vben/constants';
import { getDictOptions } from '@vben/hooks';
import { Download, Plus, Trash2 } from '@vben/icons';
import {
cloneDeep,
@@ -39,7 +41,6 @@ import { DictTag } from '#/components/dict-tag';
import { TableToolbar } from '#/components/table-toolbar';
import { useTableToolbar } from '#/hooks';
import { $t } from '#/locales';
import { DICT_TYPE, getDictOptions } from '#/utils';
import Demo03CourseList from './modules/demo03-course-list.vue';
import Demo03GradeList from './modules/demo03-grade-list.vue';
@@ -188,11 +189,11 @@ onMounted(() => {
class="!w-[240px]"
>
<ElOption
v-for="dict in getDictOptions(
v-for="(dict, index) in getDictOptions(
DICT_TYPE.SYSTEM_USER_SEX,
'number',
)"
:key="dict.value"
:key="index"
:value="dict.value"
:label="dict.label"
/>

View File

@@ -6,6 +6,8 @@ import type { Demo03StudentApi } from '#/api/infra/demo/demo03/inner';
import { computed, reactive, ref } from 'vue';
import { useVbenModal } from '@vben/common-ui';
import { DICT_TYPE } from '@vben/constants';
import { getDictOptions } from '@vben/hooks';
import {
ElDatePicker,
@@ -26,7 +28,6 @@ import {
} from '#/api/infra/demo/demo03/inner';
import { Tinymce as RichTextarea } from '#/components/tinymce';
import { $t } from '#/locales';
import { DICT_TYPE, getDictOptions } from '#/utils';
import Demo03CourseForm from './demo03-course-form.vue';
import Demo03GradeForm from './demo03-grade-form.vue';
@@ -84,8 +85,9 @@ const [Modal, modalApi] = useVbenModal({
// 提交表单
const data = formData.value as Demo03StudentApi.Demo03Student;
// 拼接子表的数据
data.demo03Courses = demo03CourseFormRef.value?.getData();
data.demo03Grade = demo03GradeFormRef.value?.getValues();
data.demo03courses = demo03CourseFormRef.value?.getData();
data.demo03grade =
demo03GradeFormRef.value?.getValues() as Demo03StudentApi.Demo03Grade;
try {
await (formData.value?.id
? updateDemo03Student(data)
@@ -136,8 +138,11 @@ const [Modal, modalApi] = useVbenModal({
<ElFormItem label="性别" prop="sex">
<ElRadioGroup v-model="formData.sex">
<ElRadio
v-for="dict in getDictOptions(DICT_TYPE.SYSTEM_USER_SEX, 'number')"
:key="dict.value"
v-for="(dict, index) in getDictOptions(
DICT_TYPE.SYSTEM_USER_SEX,
'number',
)"
:key="index"
:label="dict.value"
>
{{ dict.label }}

View File

@@ -4,6 +4,8 @@ import type { Demo03StudentApi } from '#/api/infra/demo/demo03/normal';
import { h, onMounted, reactive, ref } from 'vue';
import { Page, useVbenModal } from '@vben/common-ui';
import { DICT_TYPE } from '@vben/constants';
import { getDictOptions } from '@vben/hooks';
import { Download, Plus, Trash2 } from '@vben/icons';
import {
cloneDeep,
@@ -37,7 +39,6 @@ import { DictTag } from '#/components/dict-tag';
import { TableToolbar } from '#/components/table-toolbar';
import { useTableToolbar } from '#/hooks';
import { $t } from '#/locales';
import { DICT_TYPE, getDictOptions } from '#/utils';
import Demo03StudentForm from './modules/form.vue';
@@ -181,11 +182,11 @@ onMounted(() => {
class="!w-[240px]"
>
<ElOption
v-for="dict in getDictOptions(
v-for="(dict, index) in getDictOptions(
DICT_TYPE.SYSTEM_USER_SEX,
'number',
)"
:key="dict.value"
:key="index"
:value="dict.value"
:label="dict.label"
/>

View File

@@ -6,6 +6,8 @@ import type { Demo03StudentApi } from '#/api/infra/demo/demo03/normal';
import { computed, reactive, ref } from 'vue';
import { useVbenModal } from '@vben/common-ui';
import { DICT_TYPE } from '@vben/constants';
import { getDictOptions } from '@vben/hooks';
import {
ElDatePicker,
@@ -26,7 +28,6 @@ import {
} from '#/api/infra/demo/demo03/normal';
import { Tinymce as RichTextarea } from '#/components/tinymce';
import { $t } from '#/locales';
import { DICT_TYPE, getDictOptions } from '#/utils';
import Demo03CourseForm from './demo03-course-form.vue';
import Demo03GradeForm from './demo03-grade-form.vue';
@@ -84,8 +85,9 @@ const [Modal, modalApi] = useVbenModal({
// 提交表单
const data = formData.value as Demo03StudentApi.Demo03Student;
// 拼接子表的数据
data.demo03Courses = demo03CourseFormRef.value?.getData();
data.demo03Grade = demo03GradeFormRef.value?.getValues();
data.demo03courses = demo03CourseFormRef.value?.getData();
data.demo03grade =
demo03GradeFormRef.value?.getValues() as Demo03StudentApi.Demo03Grade;
try {
await (formData.value?.id
? updateDemo03Student(data)
@@ -136,8 +138,11 @@ const [Modal, modalApi] = useVbenModal({
<ElFormItem label="性别" prop="sex">
<ElRadioGroup v-model="formData.sex">
<ElRadio
v-for="dict in getDictOptions(DICT_TYPE.SYSTEM_USER_SEX, 'number')"
:key="dict.value"
v-for="(dict, index) in getDictOptions(
DICT_TYPE.SYSTEM_USER_SEX,
'number',
)"
:key="index"
:label="dict.value"
>
{{ dict.label }}

View File

@@ -3,9 +3,8 @@ import type { OnActionClickFn, VxeTableGridOptions } from '#/adapter/vxe-table';
import type { InfraJobApi } from '#/api/infra/job';
import { useAccess } from '@vben/access';
import { InfraJobStatusEnum } from '@vben/constants';
import { DICT_TYPE, getDictOptions } from '#/utils';
import { DICT_TYPE, InfraJobStatusEnum } from '@vben/constants';
import { getDictOptions } from '@vben/hooks';
const { hasAccessByCodes } = useAccess();

View File

@@ -3,12 +3,12 @@ import type { OnActionClickFn, VxeTableGridOptions } from '#/adapter/vxe-table';
import type { InfraJobLogApi } from '#/api/infra/job-log';
import { useAccess } from '@vben/access';
import { DICT_TYPE } from '@vben/constants';
import { getDictOptions } from '@vben/hooks';
import { formatDateTime } from '@vben/utils';
import dayjs from 'dayjs';
import { DICT_TYPE, getDictOptions } from '#/utils';
const { hasAccessByCodes } = useAccess();
/** 列表的搜索表单 */