111
This commit is contained in:
@@ -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
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user