增加地区选项添加

This commit is contained in:
冯辉
2026-03-13 11:45:01 +08:00
parent 94439fddaa
commit 4078f2e543
2 changed files with 90 additions and 68 deletions

View File

@@ -78,6 +78,24 @@
</radio-group> </radio-group>
</view> </view>
<!-- 地区 -->
<view v-if="activeTab === 'area'" class="content-section">
<radio-group @change="(e) => handleSelect('area', e)">
<label
v-for="option in areaOptions"
:key="option.value"
class="radio-item"
:class="{ checked: selectedValues['area'] === String(option.value) }"
>
<radio
:value="String(option.value)"
:checked="selectedValues['area'] === String(option.value)"
/>
<text class="option-label">{{ option.label }}</text>
</label>
</radio-group>
</view>
<!-- 岗位类型 --> <!-- 岗位类型 -->
<view v-if="activeTab === 'jobType'" class="content-section"> <view v-if="activeTab === 'jobType'" class="content-section">
<radio-group @change="(e) => handleSelect('jobType', e)"> <radio-group @change="(e) => handleSelect('jobType', e)">
@@ -132,7 +150,8 @@ const tabs = [
{ key: 'education', label: '学历要求' }, { key: 'education', label: '学历要求' },
{ key: 'experience', label: '工作经验' }, { key: 'experience', label: '工作经验' },
{ key: 'scale', label: '公司规模' }, { key: 'scale', label: '公司规模' },
{ key: 'jobType', label: '岗位类型' } { key: 'jobType', label: '岗位类型' },
{ key: 'area', label: '地区' }
]; ];
// 当前激活的标签 // 当前激活的标签
@@ -143,6 +162,7 @@ const selectedValues = reactive({
education: '', education: '',
experience: '', experience: '',
scale: '', scale: '',
area: '',
jobType: '' jobType: ''
}); });
@@ -150,6 +170,7 @@ const selectedValues = reactive({
const educationOptions = ref([]); const educationOptions = ref([]);
const experienceOptions = ref([]); const experienceOptions = ref([]);
const scaleOptions = ref([]); const scaleOptions = ref([]);
const areaOptions = ref([]);
const jobTypeOptions = ref([]); const jobTypeOptions = ref([]);
// 加载状态 // 加载状态
@@ -164,6 +185,7 @@ onBeforeMount(async () => {
educationOptions.value = getTransformChildren('education', '学历要求').options || []; educationOptions.value = getTransformChildren('education', '学历要求').options || [];
experienceOptions.value = getTransformChildren('experience', '工作经验').options || []; experienceOptions.value = getTransformChildren('experience', '工作经验').options || [];
scaleOptions.value = getTransformChildren('scale', '公司规模').options || []; scaleOptions.value = getTransformChildren('scale', '公司规模').options || [];
areaOptions.value = getTransformChildren('area', '地区').options || [];
jobTypeOptions.value = getJobTypeData(); jobTypeOptions.value = getJobTypeData();
} catch (error) { } catch (error) {
console.error('获取字典数据失败:', error); console.error('获取字典数据失败:', error);

View File

@@ -42,50 +42,50 @@ const useDictStore = defineStore("dict", () => {
noticeType: [] noticeType: []
}) })
// political_affiliation // political_affiliation
const getDictData = async (dictType, dictName) => { const getDictData = async (dictType, dictName) => {
try { try {
if (dictType && dictName) { if (dictType && dictName) {
return getDictSelectOption(dictType).then((data) => { return getDictSelectOption(dictType).then((data) => {
state[dictName] = data state[dictName] = data
return data return data
}) })
} }
const [education, experience, area, scale, sex, affiliation, nature, noticeType] = const [education, experience, area, scale, sex, affiliation, nature, noticeType] =
await Promise.all([ await Promise.all([
getDictSelectOption('education'), getDictSelectOption('education'),
getDictSelectOption('experience'), getDictSelectOption('experience'),
getDictSelectOption('area', true), getDictSelectOption('area', true),
getDictSelectOption('scale'), getDictSelectOption('scale'),
getDictSelectOption('app_sex'), getDictSelectOption('app_sex'),
getDictSelectOption('political_affiliation'), getDictSelectOption('political_affiliation'),
getDictSelectOption('company_nature'), getDictSelectOption('company_nature'),
getDictSelectOption('sys_notice_type'), getDictSelectOption('sys_notice_type'),
]); ]);
state.education = education; state.education = education;
state.experience = experience; state.experience = experience;
state.area = area; state.area = area;
state.scale = scale; state.scale = scale;
state.sex = sex; state.sex = sex;
state.affiliation = affiliation; state.affiliation = affiliation;
state.nature = nature state.nature = nature
state.noticeType = noticeType state.noticeType = noticeType
complete.value = true complete.value = true
getIndustryDict() // 获取行业 getIndustryDict() // 获取行业
} catch (error) { } catch (error) {
console.error('Error fetching dictionary data:', error); console.error('Error fetching dictionary data:', error);
// 确保即使出错也能返回空数组 // 确保即使出错也能返回空数组
if (!dictType && !dictName) { if (!dictType && !dictName) {
state.education = []; state.education = [];
state.experience = []; state.experience = [];
state.area = []; state.area = [];
state.scale = []; state.scale = [];
state.sex = []; state.sex = [];
state.affiliation = []; state.affiliation = [];
state.nature = []; state.nature = [];
state.noticeType = []; state.noticeType = [];
} }
} }
}; };
async function getIndustryDict() { async function getIndustryDict() {
@@ -108,31 +108,31 @@ const useDictStore = defineStore("dict", () => {
return null return null
} }
function dictLabel(dictType, value) { function dictLabel(dictType, value) {
if (state[dictType] && Array.isArray(state[dictType])) { if (state[dictType] && Array.isArray(state[dictType])) {
for (let i = 0; i < state[dictType].length; i++) { for (let i = 0; i < state[dictType].length; i++) {
let element = state[dictType][i]; let element = state[dictType][i];
if (element.value === value) { if (element.value === value) {
return element.label return element.label
} }
} }
} }
return '' return ''
} }
function oneDictData(dictType, value) { function oneDictData(dictType, value) {
if (!value) { if (!value) {
return state[dictType] return state[dictType]
} }
if (state[dictType]) { if (state[dictType]) {
for (let i = 0; i < state[dictType].length; i++) { for (let i = 0; i < state[dictType].length; i++) {
let element = state[dictType][i]; let element = state[dictType][i];
if (element.value === value) { if (element.value === value) {
return element return element
} }
} }
} }
return null return null
} }
function getTransformChildren(dictType, title = '', key = '') { function getTransformChildren(dictType, title = '', key = '') {