退出登录 首页点击无反修改,发布岗位增加岗位类型

This commit is contained in:
francis_fh
2026-01-05 00:21:24 +08:00
parent 2ab6253fad
commit 2b9663db53
3 changed files with 93 additions and 32 deletions

View File

@@ -132,6 +132,19 @@
<view class="picker-text" data-placeholder="请选择岗位分类">{{ selectedJobCategory || '请选择岗位分类' }}</view>
</picker>
</view>
<!-- 新增岗位类型 -->
<view class="form-group">
<view class="label">岗位类型</view>
<view
class="picker"
@click="openJobTypeSelector"
>
<view class="picker-text" :class="{ 'placeholder': !selectedJobTypeLabel }">
{{ selectedJobTypeLabel || '请选择岗位类型' }}
</view>
</view>
</view>
</view>
<!-- 图片上传区块 -->
@@ -253,6 +266,9 @@
<!-- 自定义tabbar -->
<CustomTabBar :currentPage="1" />
<!-- 岗位类型选择器 -->
<selectJobs ref="jobTypeSelector" />
</view>
</template>
@@ -265,6 +281,7 @@ import config from '@/config.js';
import useDictStore from '@/stores/useDictStore';
import useUserStore from '@/stores/useUserStore';
import UniIcons from '@/uni_modules/uni-icons/components/uni-icons/uni-icons.vue';
import selectJobs from '@/components/selectJobs/selectJobs.vue';
const userStore = useUserStore();
const cachedUserInfo = uni.getStorageSync('userInfo') || {};
// 表单数据
@@ -276,7 +293,8 @@ const formData = reactive({
vacancies: '', // 招聘人数
description: '', // 对应接口字段 description
jobRequirements: '',
jobCategory: '', // 新增:岗位分类
type: '', // 岗位分类用户指示使用type字段
jobCategory: '', // 岗位类型
companyId: '', // 新增企业id
latitude: '', // 新增:纬度
longitude: '', // 新增:经度
@@ -313,10 +331,15 @@ const selectedExperience = ref('');
const selectedWorkDistrict = ref('');
const selectedWorkLocation = ref('');
const selectedJobCategory = ref('');
const selectedJobTypeLabel = ref(''); // 新增:岗位类型显示文本
const selectedJobTypeIds = ref(''); // 新增岗位类型ID多个用逗号分隔
// 滚动视图高度
const scrollViewHeight = ref('calc(100vh - 200rpx)');
// 岗位类型选择器引用
const jobTypeSelector = ref(null);
// 计算滚动视图高度
const calculateScrollViewHeight = () => {
const systemInfo = uni.getSystemInfoSync();
@@ -413,19 +436,18 @@ const initFormData = async () => {
// 设置区县选项(从字典获取)
workDistricts.value = dictStore.state.area;
// 设置岗位分类选项
// 只有就业见习基地才能选择"实习实训"选项
// 设置岗位分类选项 - 从字典获取 position_type
const positionTypeDict = await dictStore.getDictSelectOption('position_type');
console.log('从字典获取的岗位类型数据:', positionTypeDict);
// 过滤岗位类型选项:只有就业见习基地才能选择"实习实训"选项
// 假设实习实训的 value 为 '3'
if (isInternshipBase.value) {
jobCategories.value = [
{ label: '普通', value: '1' },
{ label: '零工', value: '2' },
{ label: '实习实训', value: '3' }
];
// 如果是就业见习基地,显示所有选项
jobCategories.value = positionTypeDict;
} else {
jobCategories.value = [
{ label: '普通', value: '1' },
{ label: '零工', value: '2' }
];
// 如果不是就业见习基地,过滤掉实习实训选项
jobCategories.value = positionTypeDict.filter(item => item.dictSort !== 2);
}
console.log('岗位分类选项:', jobCategories.value);
@@ -487,7 +509,27 @@ const onJobCategoryChange = (e) => {
const index = e.detail.value;
const selectedItem = jobCategories.value[index];
selectedJobCategory.value = selectedItem.label;
formData.jobCategory = selectedItem.value;
formData.type = selectedItem.value; // 岗位分类保存到type字段
};
// 打开岗位类型选择器
const openJobTypeSelector = () => {
if (!jobTypeSelector.value) return;
jobTypeSelector.value.open({
title: '选择岗位类型',
success: (ids, labels) => {
// 保存选中的岗位类型
selectedJobTypeIds.value = ids;
selectedJobTypeLabel.value = labels;
// 将岗位类型ID保存到formData.jobCategory字段
formData.jobCategory = ids;
console.log('选择的岗位类型ID:', ids, '标签:', labels);
},
cancel: () => {
console.log('取消选择岗位类型');
}
});
};
// 选择位置
@@ -637,10 +679,10 @@ const handleCompanySelected = (company) => {
// 发布岗位
const publishJob = async () => {
// 表单验证
if (!validateForm()) {
return;
}
// 表单验证
if (!validateForm()) {
return;
}
try {
uni.showLoading({
@@ -660,7 +702,8 @@ const publishJob = async () => {
latitude: formData.latitude,
longitude: formData.longitude,
description: formData.description,
jobCategory: formData.jobCategory,
type: formData.type, // 岗位分类
jobCategory: formData.jobCategory, // 岗位类型
companyId: formData.companyId,
companyName: formData.companyName,
jobContactList: formData.contacts.filter(contact => contact.name.trim() && contact.phone.trim()).map(contact => ({
@@ -722,7 +765,8 @@ const validateForm = () => {
{ field: 'jobLocationAreaCode', message: '请选择工作区县' },
{ field: 'vacancies', message: '请输入招聘人数' },
{ field: 'description', message: '请输入岗位描述' },
{ field: 'jobCategory', message: '请选择岗位分类' }
{ field: 'type', message: '请选择岗位分类' },
{ field: 'jobCategory', message: '请选择岗位类型' }
];
for (const { field, message } of requiredFields) {