diff --git a/components/new-filter-page/new-filter-page.vue b/components/new-filter-page/new-filter-page.vue index 12c9550..cda9e06 100644 --- a/components/new-filter-page/new-filter-page.vue +++ b/components/new-filter-page/new-filter-page.vue @@ -78,6 +78,24 @@ + + + + + + + @@ -132,7 +150,8 @@ const tabs = [ { key: 'education', label: '学历要求' }, { key: 'experience', label: '工作经验' }, { key: 'scale', label: '公司规模' }, - { key: 'jobType', label: '岗位类型' } + { key: 'jobType', label: '岗位类型' }, + { key: 'area', label: '地区' } ]; // 当前激活的标签 @@ -143,6 +162,7 @@ const selectedValues = reactive({ education: '', experience: '', scale: '', + area: '', jobType: '' }); @@ -150,6 +170,7 @@ const selectedValues = reactive({ const educationOptions = ref([]); const experienceOptions = ref([]); const scaleOptions = ref([]); +const areaOptions = ref([]); const jobTypeOptions = ref([]); // 加载状态 @@ -164,6 +185,7 @@ onBeforeMount(async () => { educationOptions.value = getTransformChildren('education', '学历要求').options || []; experienceOptions.value = getTransformChildren('experience', '工作经验').options || []; scaleOptions.value = getTransformChildren('scale', '公司规模').options || []; + areaOptions.value = getTransformChildren('area', '地区').options || []; jobTypeOptions.value = getJobTypeData(); } catch (error) { console.error('获取字典数据失败:', error); diff --git a/stores/useDictStore.js b/stores/useDictStore.js index 622d3fc..f74bac9 100644 --- a/stores/useDictStore.js +++ b/stores/useDictStore.js @@ -42,50 +42,50 @@ const useDictStore = defineStore("dict", () => { noticeType: [] }) // political_affiliation - const getDictData = async (dictType, dictName) => { - 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'), - getDictSelectOption('experience'), - getDictSelectOption('area', true), - getDictSelectOption('scale'), - getDictSelectOption('app_sex'), - getDictSelectOption('political_affiliation'), - getDictSelectOption('company_nature'), - getDictSelectOption('sys_notice_type'), - ]); - - state.education = education; - state.experience = experience; - state.area = area; - state.scale = scale; - state.sex = sex; - state.affiliation = affiliation; - state.nature = nature - state.noticeType = noticeType - complete.value = true - getIndustryDict() // 获取行业 - } 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 = []; - } - } + const getDictData = async (dictType, dictName) => { + 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'), + getDictSelectOption('experience'), + getDictSelectOption('area', true), + getDictSelectOption('scale'), + getDictSelectOption('app_sex'), + getDictSelectOption('political_affiliation'), + getDictSelectOption('company_nature'), + getDictSelectOption('sys_notice_type'), + ]); + + state.education = education; + state.experience = experience; + state.area = area; + state.scale = scale; + state.sex = sex; + state.affiliation = affiliation; + state.nature = nature + state.noticeType = noticeType + complete.value = true + getIndustryDict() // 获取行业 + } 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 = []; + } + } }; async function getIndustryDict() { @@ -108,31 +108,31 @@ const useDictStore = defineStore("dict", () => { return null } - function dictLabel(dictType, value) { - if (state[dictType] && Array.isArray(state[dictType])) { - for (let i = 0; i < state[dictType].length; i++) { - let element = state[dictType][i]; - if (element.value === value) { - return element.label - } - } - } - return '' + function dictLabel(dictType, value) { + if (state[dictType] && Array.isArray(state[dictType])) { + for (let i = 0; i < state[dictType].length; i++) { + let element = state[dictType][i]; + if (element.value === value) { + return element.label + } + } + } + return '' } - function oneDictData(dictType, value) { - if (!value) { - return state[dictType] - } - if (state[dictType]) { - for (let i = 0; i < state[dictType].length; i++) { - let element = state[dictType][i]; - if (element.value === value) { - return element - } - } - } - return null + function oneDictData(dictType, value) { + if (!value) { + return state[dictType] + } + if (state[dictType]) { + for (let i = 0; i < state[dictType].length; i++) { + let element = state[dictType][i]; + if (element.value === value) { + return element + } + } + } + return null } function getTransformChildren(dictType, title = '', key = '') {