岗位上下架功能开发
This commit is contained in:
@@ -305,7 +305,7 @@
|
|||||||
>
|
>
|
||||||
<view v-for="(job, index) in list" :key="index" :slot="`slot${index}`">
|
<view v-for="(job, index) in list" :key="index" :slot="`slot${index}`">
|
||||||
<view class="item btn-feel" v-if="!job.recommend">
|
<view class="item btn-feel" v-if="!job.recommend">
|
||||||
<view class="falls-card" @click="nextDetail(job)">
|
<view class="falls-card" :class="{ 'disabled-card': job.jobStatus === 1 }" @click="nextDetail(job)">
|
||||||
<view class="falls-card-pay">
|
<view class="falls-card-pay">
|
||||||
<view class="pay-text">
|
<view class="pay-text">
|
||||||
<Salary-Expectation
|
<Salary-Expectation
|
||||||
@@ -350,6 +350,17 @@
|
|||||||
{{ job.companyName }}
|
{{ job.companyName }}
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
<!-- 招聘者显示上下架开关 -->
|
||||||
|
<view class="falls-card-actions" v-if="isRecruiter">
|
||||||
|
<view class="job-status-switch" @click.stop="toggleJobStatus(job)">
|
||||||
|
<view class="switch-track" :class="{ 'active': job.jobStatus === 0 }">
|
||||||
|
<view class="switch-thumb" :class="{ 'active': job.jobStatus === 0 }"></view>
|
||||||
|
</view>
|
||||||
|
<view class="switch-label">
|
||||||
|
{{ job.jobStatus === 0 ? '已上架' : '已下架' }}
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
<!-- <view class="falls-card-matchingrate">
|
<!-- <view class="falls-card-matchingrate">
|
||||||
<view class=""><matchingDegree :job="job"></matchingDegree></view>
|
<view class=""><matchingDegree :job="job"></matchingDegree></view>
|
||||||
<uni-icons type="star" size="30"></uni-icons>
|
<uni-icons type="star" size="30"></uni-icons>
|
||||||
@@ -382,7 +393,7 @@
|
|||||||
>
|
>
|
||||||
<template v-slot:default="job">
|
<template v-slot:default="job">
|
||||||
<view class="item btn-feel" v-if="!job.recommend">
|
<view class="item btn-feel" v-if="!job.recommend">
|
||||||
<view class="falls-card" @click="nextDetail(job)">
|
<view class="falls-card" :class="{ 'disabled-card': job.jobStatus === 1 }" @click="nextDetail(job)">
|
||||||
<view class="falls-card-pay">
|
<view class="falls-card-pay">
|
||||||
<view class="pay-text">
|
<view class="pay-text">
|
||||||
<Salary-Expectation
|
<Salary-Expectation
|
||||||
@@ -427,6 +438,17 @@
|
|||||||
{{ job.companyName }}
|
{{ job.companyName }}
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
<!-- 招聘者显示上下架开关 -->
|
||||||
|
<view class="falls-card-actions" v-if="isRecruiter">
|
||||||
|
<view class="job-status-switch" @click.stop="toggleJobStatus(job)">
|
||||||
|
<view class="switch-track" :class="{ 'active': job.jobStatus === 0 }">
|
||||||
|
<view class="switch-thumb" :class="{ 'active': job.jobStatus === 0 }"></view>
|
||||||
|
</view>
|
||||||
|
<view class="switch-label">
|
||||||
|
{{ job.jobStatus === 0 ? '已上架' : '已下架' }}
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
<!-- <view class="falls-card-matchingrate">
|
<!-- <view class="falls-card-matchingrate">
|
||||||
<view class=""><matchingDegree :job="job"></matchingDegree></view>
|
<view class=""><matchingDegree :job="job"></matchingDegree></view>
|
||||||
<uni-icons type="star" size="30"></uni-icons>
|
<uni-icons type="star" size="30"></uni-icons>
|
||||||
@@ -556,6 +578,25 @@ const shouldShowCompanyContent = computed(() => {
|
|||||||
return userType === 0;
|
return userType === 0;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 判断当前用户是否为招聘者(企业用户)
|
||||||
|
const isRecruiter = computed(() => {
|
||||||
|
if (!hasLogin.value) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 优先从store获取,如果为空则从缓存获取
|
||||||
|
const storeIsCompanyUser = userInfo.value?.isCompanyUser;
|
||||||
|
const cachedUserInfo = uni.getStorageSync('userInfo') || {};
|
||||||
|
const cachedIsCompanyUser = cachedUserInfo.isCompanyUser;
|
||||||
|
|
||||||
|
// 获取用户类型:优先使用store中的isCompanyUser,如果store中没有,使用缓存中的isCompanyUser
|
||||||
|
// 缓存中的值可能是字符串,需要转换为数值类型
|
||||||
|
const userType = storeIsCompanyUser !== undefined ? Number(storeIsCompanyUser) : Number(cachedIsCompanyUser);
|
||||||
|
|
||||||
|
// 企业用户(isCompanyUser=0)是招聘者
|
||||||
|
return userType === 0;
|
||||||
|
});
|
||||||
|
|
||||||
import useDictStore from '@/stores/useDictStore';
|
import useDictStore from '@/stores/useDictStore';
|
||||||
const { getTransformChildren, oneDictData, dictLabel: getDictLabel, industryLabel } = useDictStore();
|
const { getTransformChildren, oneDictData, dictLabel: getDictLabel, industryLabel } = useDictStore();
|
||||||
import useLocationStore from '@/stores/useLocationStore';
|
import useLocationStore from '@/stores/useLocationStore';
|
||||||
@@ -1144,6 +1185,9 @@ function getJobRecommend(type = 'add') {
|
|||||||
// 只有企业用户(isCompanyUser=0)才添加current字段
|
// 只有企业用户(isCompanyUser=0)才添加current字段
|
||||||
if (userType === 0) {
|
if (userType === 0) {
|
||||||
params.current = pageNull.value;
|
params.current = pageNull.value;
|
||||||
|
} else {
|
||||||
|
// 求职者只显示已上架的岗位(jobStatus=0)
|
||||||
|
params.jobStatus = 0;
|
||||||
}
|
}
|
||||||
let comd = { recommend: true, jobCategory: '', tip: '确认你的兴趣,为您推荐更多合适的岗位' };
|
let comd = { recommend: true, jobCategory: '', tip: '确认你的兴趣,为您推荐更多合适的岗位' };
|
||||||
$api.createRequest('/app/job/recommend', params).then((resData) => {
|
$api.createRequest('/app/job/recommend', params).then((resData) => {
|
||||||
@@ -1217,6 +1261,18 @@ function getJobList(type = 'add') {
|
|||||||
if (pageState.search.order === 3 || pageState.search.order === 4) {
|
if (pageState.search.order === 3 || pageState.search.order === 4) {
|
||||||
params.order = 0;
|
params.order = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 判断用户类型,求职者只显示已上架的岗位(jobStatus=0)
|
||||||
|
// 优先从store获取,如果为空则从缓存获取
|
||||||
|
const storeIsCompanyUser = userInfo.value?.isCompanyUser;
|
||||||
|
const cachedUserInfo = uni.getStorageSync('userInfo') || {};
|
||||||
|
const cachedIsCompanyUser = cachedUserInfo.isCompanyUser;
|
||||||
|
const userType = storeIsCompanyUser !== undefined ? Number(storeIsCompanyUser) : Number(cachedIsCompanyUser);
|
||||||
|
|
||||||
|
// 如果不是企业用户(求职者),只显示已上架的岗位
|
||||||
|
if (userType !== 0) {
|
||||||
|
params.jobStatus = 0;
|
||||||
|
}
|
||||||
|
|
||||||
$api.createRequest('/app/job/list', params).then((resData) => {
|
$api.createRequest('/app/job/list', params).then((resData) => {
|
||||||
const { rows, total } = resData;
|
const { rows, total } = resData;
|
||||||
@@ -1240,6 +1296,93 @@ function getJobList(type = 'add') {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 上架岗位
|
||||||
|
const jobUp = (jobId) => {
|
||||||
|
if (!checkLogin()) return;
|
||||||
|
|
||||||
|
uni.showLoading({
|
||||||
|
title: '处理中...',
|
||||||
|
mask: true
|
||||||
|
});
|
||||||
|
|
||||||
|
$api.createRequest(`/app/job/jobUp/${jobId}`, {}, 'PUT', true).then((res) => {
|
||||||
|
uni.hideLoading();
|
||||||
|
$api.msg('上架成功');
|
||||||
|
// 刷新数据
|
||||||
|
if (state.tabIndex === 'all') {
|
||||||
|
getJobRecommend('refresh');
|
||||||
|
} else {
|
||||||
|
getJobList('refresh');
|
||||||
|
}
|
||||||
|
}).catch((err) => {
|
||||||
|
uni.hideLoading();
|
||||||
|
console.error('上架失败:', err);
|
||||||
|
$api.msg('上架失败,请重试');
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
// 下架岗位
|
||||||
|
const jobDown = (jobId) => {
|
||||||
|
if (!checkLogin()) return;
|
||||||
|
|
||||||
|
uni.showLoading({
|
||||||
|
title: '处理中...',
|
||||||
|
mask: true
|
||||||
|
});
|
||||||
|
|
||||||
|
$api.createRequest(`/app/job/jobDown/${jobId}`, {}, 'PUT', true).then((res) => {
|
||||||
|
uni.hideLoading();
|
||||||
|
$api.msg('下架成功');
|
||||||
|
// 刷新数据
|
||||||
|
if (state.tabIndex === 'all') {
|
||||||
|
getJobRecommend('refresh');
|
||||||
|
} else {
|
||||||
|
getJobList('refresh');
|
||||||
|
}
|
||||||
|
}).catch((err) => {
|
||||||
|
uni.hideLoading();
|
||||||
|
console.error('下架失败:', err);
|
||||||
|
$api.msg('下架失败,请重试');
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
// 切换岗位状态(上架/下架)
|
||||||
|
const toggleJobStatus = (job) => {
|
||||||
|
if (!checkLogin()) return;
|
||||||
|
|
||||||
|
uni.showLoading({
|
||||||
|
title: '处理中...',
|
||||||
|
mask: true
|
||||||
|
});
|
||||||
|
|
||||||
|
// 根据当前状态决定调用哪个接口
|
||||||
|
const isCurrentlyUp = job.jobStatus === 0; // 0: 已上架, 1: 已下架
|
||||||
|
const apiUrl = isCurrentlyUp ? `/app/job/jobDown/${job.jobId}` : `/app/job/jobUp/${job.jobId}`;
|
||||||
|
|
||||||
|
$api.createRequest(apiUrl, {}, 'PUT', true).then((res) => {
|
||||||
|
uni.hideLoading();
|
||||||
|
$api.msg(isCurrentlyUp ? '下架成功' : '上架成功');
|
||||||
|
|
||||||
|
// 更新本地数据状态,避免立即刷新整个列表
|
||||||
|
const jobIndex = list.value.findIndex(item => item.jobId === job.jobId);
|
||||||
|
if (jobIndex !== -1) {
|
||||||
|
// 更新状态
|
||||||
|
list.value[jobIndex].jobStatus = isCurrentlyUp ? 1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 也可以选择刷新数据
|
||||||
|
// if (state.tabIndex === 'all') {
|
||||||
|
// getJobRecommend('refresh');
|
||||||
|
// } else {
|
||||||
|
// getJobList('refresh');
|
||||||
|
// }
|
||||||
|
}).catch((err) => {
|
||||||
|
uni.hideLoading();
|
||||||
|
console.error('操作失败:', err);
|
||||||
|
$api.msg(isCurrentlyUp ? '下架失败,请重试' : '上架失败,请重试');
|
||||||
|
});
|
||||||
|
};
|
||||||
const isFourLevelLinkagePurview=ref(false)
|
const isFourLevelLinkagePurview=ref(false)
|
||||||
const getIsFourLevelLinkagePurview=()=>{
|
const getIsFourLevelLinkagePurview=()=>{
|
||||||
let userInfo = uni.getStorageSync('userInfo')
|
let userInfo = uni.getStorageSync('userInfo')
|
||||||
@@ -2273,4 +2416,54 @@ defineExpose({ loadData });
|
|||||||
color: #FFFFFF
|
color: #FFFFFF
|
||||||
text-align: center
|
text-align: center
|
||||||
white-space: nowrap
|
white-space: nowrap
|
||||||
|
|
||||||
|
// 上下架开关样式
|
||||||
|
.falls-card-actions
|
||||||
|
margin-top: 20rpx
|
||||||
|
.job-status-switch
|
||||||
|
display: flex
|
||||||
|
align-items: center
|
||||||
|
justify-content: space-between
|
||||||
|
padding: 8rpx 0
|
||||||
|
.switch-track
|
||||||
|
width: 80rpx
|
||||||
|
height: 40rpx
|
||||||
|
background: #e0e0e0
|
||||||
|
border-radius: 20rpx
|
||||||
|
position: relative
|
||||||
|
transition: all 0.3s ease
|
||||||
|
cursor: pointer
|
||||||
|
&.active
|
||||||
|
background: #52c41a
|
||||||
|
.switch-thumb
|
||||||
|
position: absolute
|
||||||
|
top: 4rpx
|
||||||
|
left: 4rpx
|
||||||
|
width: 32rpx
|
||||||
|
height: 32rpx
|
||||||
|
background: #ffffff
|
||||||
|
border-radius: 50%
|
||||||
|
box-shadow: 0 2rpx 4rpx rgba(0, 0, 0, 0.2)
|
||||||
|
transition: all 0.3s ease
|
||||||
|
&.active
|
||||||
|
left: 44rpx
|
||||||
|
.switch-label
|
||||||
|
font-family: 'PingFangSC-Medium', 'PingFang SC', 'Helvetica Neue', Helvetica, Arial, 'Microsoft YaHei', sans-serif
|
||||||
|
font-weight: 500
|
||||||
|
font-size: 24rpx
|
||||||
|
color: #666666
|
||||||
|
margin-left: 16rpx
|
||||||
|
min-width: 80rpx
|
||||||
|
text-align: center
|
||||||
|
|
||||||
|
// 下架后卡片置灰样式
|
||||||
|
.disabled-card
|
||||||
|
opacity: 0.6
|
||||||
|
filter: grayscale(50%)
|
||||||
|
background: #f8f8f8 !important
|
||||||
|
.falls-card-title,
|
||||||
|
.falls-card-company,
|
||||||
|
.falls-card-pepleNumber,
|
||||||
|
.falls-card-company2
|
||||||
|
color: #999999 !important
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user