This commit is contained in:
冯辉
2026-05-01 04:02:50 +08:00
parent 57b18c0a65
commit 7ad59aeeab
4 changed files with 31 additions and 20 deletions

View File

@@ -29,6 +29,7 @@ function buildIndex(tree) {
const useDictStore = defineStore("dict", () => {
// 定义状态
const complete = ref(false)
const dictLoading = ref(false)
const state = reactive({
education: [],
experience: [],
@@ -43,13 +44,16 @@ const useDictStore = defineStore("dict", () => {
})
// political_affiliation
const getDictData = async (dictType, dictName) => {
if (dictType && dictName) {
return getDictSelectOption(dictType).then((data) => {
state[dictName] = data
return data
})
}
if (complete.value) return
if (dictLoading.value) return
dictLoading.value = true
try {
if (dictType && dictName) {
return getDictSelectOption(dictType).then((data) => {
state[dictName] = data
return data
})
}
const [education, experience, area, scale, sex, affiliation, nature, noticeType] =
await Promise.all([
getDictSelectOption('education'),
@@ -75,16 +79,16 @@ const useDictStore = defineStore("dict", () => {
} catch (error) {
console.error('Error fetching dictionary data:', error);
// 确保即使出错也能返回空数组
if (!dictType && !dictName) {
state.education = [];
state.experience = [];
state.area = [];
state.scale = [];
state.sex = [];
state.affiliation = [];
state.nature = [];
state.noticeType = [];
}
state.education = [];
state.experience = [];
state.area = [];
state.scale = [];
state.sex = [];
state.affiliation = [];
state.nature = [];
state.noticeType = [];
} finally {
dictLoading.value = false
}
};