refactor(dict): 重构字典数据管理模块,优化代码结构和可维护性

- 将字典类型和字典数据的获取、存储逻辑统一管理,减少重复代码
- 使用 `pinia-plugin-persistedstate` 实现字典数据的持久化存储
- 优化字典数据的展示逻辑,统一使用字典标签进行显示
- 修复字典数据查询接口的权限控制和参数传递问题
- 更新字典数据相关的测试用例,确保功能稳定
This commit is contained in:
zhangtao
2025-04-15 00:58:31 +08:00
parent 9291579197
commit 6e0e1303e1
30 changed files with 1525 additions and 574 deletions
+19 -5
View File
@@ -136,9 +136,10 @@
:rules="[{ required: true, message: '请选择性别' }]"
>
<a-radio-group v-model:value="infoFormState.gender" class="gender-group">
<a-radio :value="1">男</a-radio>
<a-radio :value="2">女</a-radio>
</a-radio-group>
<a-radio v-for="item in DictDataStore['sys_user_sex']" :value="item.dict_value">
{{ item.dict_label }}
</a-radio>
</a-radio-group>
</a-form-item>
</a-col>
@@ -282,7 +283,7 @@
<script lang="ts" setup>
import PageHeader from '@/components/PageHeader.vue';
import { ref, reactive, onMounted, h, watch } from 'vue';
import { ref, reactive, onMounted, h, watch, computed } from 'vue';
import { message } from 'ant-design-vue';
import type { UploadChangeParam } from "ant-design-vue";
import {
@@ -305,6 +306,18 @@ import { useUserStore } from "@/store/index";
import storage from 'store';
import { updateCurrentUserInfo, changeCurrentUserPassword, avatarHandleChange } from '@/api/system/user';
import type { InfoFormState, PasswordFormState } from './types';
import { useDictStore } from "@/store/index";
const dictStore = useDictStore();
const DictDataStore = computed(() => {
return dictStore.dictObj;
})
const getOptions = async () => {
const dictOptions = await dictStore.setDict(['sys_user_sex'])
return dictOptions
}
// 状态定义
const passwordChanging = ref(false);
@@ -466,7 +479,8 @@ const handleTabChange = (key: string) => {
}
};
onMounted(() => {
onMounted(async () => {
await getOptions();
initInfoForm();
});
</script>