499 lines
13 KiB
Vue
499 lines
13 KiB
Vue
<template>
|
|
<div class="app-container">
|
|
<!-- 搜索卡片 -->
|
|
<el-card class="search-card" shadow="never">
|
|
<template #header>
|
|
<div class="card-header">
|
|
<span class="search-title">
|
|
<el-icon><Search /></el-icon>
|
|
岗位搜索
|
|
</span>
|
|
</div>
|
|
</template>
|
|
|
|
<el-form ref="queryFormRef" :model="queryParams" :inline="true" label-width="auto">
|
|
<el-form-item label="岗位名称" prop="positionName">
|
|
<el-input v-model="queryParams.positionName" placeholder="请输入岗位名称" clearable @keyup.enter="handleQuery" style="width: 200px" />
|
|
</el-form-item>
|
|
|
|
<el-form-item label="发布范围" prop="positionScope">
|
|
<el-select v-model="queryParams.positionScope" placeholder="请选择发布范围" clearable style="width: 200px">
|
|
<el-option label="全校" value="UNIVERSITY" />
|
|
<el-option label="本学院" value="COLLEGE" />
|
|
</el-select>
|
|
</el-form-item>
|
|
|
|
<el-form-item label="联系老师" prop="contactTeacher">
|
|
<el-input v-model="queryParams.contactTeacher" placeholder="请输入联系老师" clearable @keyup.enter="handleQuery" style="width: 200px" />
|
|
</el-form-item>
|
|
|
|
<el-form-item>
|
|
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
|
|
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
|
</el-form-item>
|
|
</el-form>
|
|
</el-card>
|
|
|
|
<!-- 岗位列表卡片 -->
|
|
<el-card class="table-card" shadow="never">
|
|
<template #header>
|
|
<div class="card-header">
|
|
<span class="table-title">
|
|
<el-icon><List /></el-icon>
|
|
可申请岗位列表
|
|
</span>
|
|
<div class="header-actions">
|
|
<el-button type="primary" icon="RefreshRight" @click="handleQuery">刷新</el-button>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<el-table ref="tableRef" v-loading="loading" :data="positionList" :height="tableHeight" class="position-table" stripe border>
|
|
<el-table-column label="岗位名称" prop="positionName" min-width="150" show-overflow-tooltip>
|
|
<template #default="{ row }">
|
|
<div class="position-name">
|
|
<el-tag type="primary" size="small">{{ row.positionName }}</el-tag>
|
|
</div>
|
|
</template>
|
|
</el-table-column>
|
|
|
|
<el-table-column label="发布范围" prop="positionScopeName" width="100" align="center">
|
|
<template #default="{ row }">
|
|
<el-tag :type="row.positionScope === 'UNIVERSITY' ? 'success' : 'info'" size="small">
|
|
{{ row.positionScopeName }}
|
|
</el-tag>
|
|
</template>
|
|
</el-table-column>
|
|
|
|
<el-table-column label="需求人数" prop="requiredCount" width="100" align="center">
|
|
<template #default="{ row }">
|
|
<span class="number-display">{{ row.requiredCount }}</span>
|
|
</template>
|
|
</el-table-column>
|
|
|
|
<el-table-column label="当前人数" prop="currentCount" width="100" align="center">
|
|
<template #default="{ row }">
|
|
<span class="number-display" :class="{ 'text-success': row.currentCount >= row.requiredCount }">
|
|
{{ row.currentCount || 0 }}
|
|
</span>
|
|
</template>
|
|
</el-table-column>
|
|
|
|
<el-table-column label="工作时间" prop="workTime" min-width="150" show-overflow-tooltip />
|
|
|
|
<el-table-column label="薪资情况" prop="salaryInfo" min-width="120" show-overflow-tooltip>
|
|
<template #default="{ row }">
|
|
<div class="salary-info">
|
|
<el-icon><Money /></el-icon>
|
|
{{ row.salaryInfo }}
|
|
</div>
|
|
</template>
|
|
</el-table-column>
|
|
|
|
<el-table-column label="联系老师" prop="contactTeacher" width="100" show-overflow-tooltip />
|
|
|
|
<el-table-column label="联系电话" prop="contactPhone" width="120" show-overflow-tooltip />
|
|
|
|
<el-table-column label="有效期" min-width="160">
|
|
<template #default="{ row }">
|
|
<div class="date-range">
|
|
<div class="date-item">{{ row.startDate }}</div>
|
|
<div class="date-separator">至</div>
|
|
<div class="date-item">{{ row.endDate }}</div>
|
|
</div>
|
|
</template>
|
|
</el-table-column>
|
|
|
|
<el-table-column label="岗位状态" prop="statusName" width="100" align="center">
|
|
<template #default="{ row }">
|
|
<el-tag :type="getStatusType(row.status)" size="small">
|
|
{{ row.statusName }}
|
|
</el-tag>
|
|
</template>
|
|
</el-table-column>
|
|
|
|
<el-table-column label="操作" width="160" align="center" fixed="right">
|
|
<template #default="{ row }">
|
|
<div class="action-buttons">
|
|
<el-button type="primary" icon="View" size="small" @click="handleViewDetail(row)" title="查看详情"> 查看 </el-button>
|
|
<el-button type="success" icon="Plus" size="small" @click="handleApply(row)" :disabled="!canApply(row)" title="申请岗位">
|
|
申请
|
|
</el-button>
|
|
</div>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table>
|
|
|
|
<!-- 分页 -->
|
|
<div class="pagination-container">
|
|
<el-pagination
|
|
v-show="total > 0"
|
|
v-model:current-page="queryParams.pageNum"
|
|
v-model:page-size="queryParams.pageSize"
|
|
:total="total"
|
|
:page-sizes="[10, 20, 30, 50]"
|
|
layout="total, sizes, prev, pager, next, jumper"
|
|
@size-change="handleSizeChange"
|
|
@current-change="handleCurrentChange"
|
|
/>
|
|
</div>
|
|
</el-card>
|
|
|
|
<!-- 岗位详情对话框 -->
|
|
<el-dialog v-model="detailDialogVisible" title="岗位详情" width="80%" :close-on-click-modal="false" class="position-detail-dialog">
|
|
<PositionDetail v-if="detailDialogVisible && selectedPositionId" :position-id="selectedPositionId" @apply="handleApplyFromDetail" />
|
|
<template #footer>
|
|
<el-button @click="detailDialogVisible = false">关闭</el-button>
|
|
</template>
|
|
</el-dialog>
|
|
|
|
<!-- 申请表单对话框 -->
|
|
<el-dialog v-model="applyDialogVisible" title="申请岗位" width="70%" :close-on-click-modal="false" class="apply-dialog">
|
|
<ApplicationForm
|
|
v-if="applyDialogVisible && selectedPosition"
|
|
:position="selectedPosition"
|
|
@success="handleApplySuccess"
|
|
@cancel="applyDialogVisible = false"
|
|
/>
|
|
</el-dialog>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { ref, reactive, onMounted, computed } from 'vue';
|
|
import { ElMessage, ElMessageBox } from 'element-plus';
|
|
import { listVisiblePositions } from '@/api/jcbt/workStudyPosition';
|
|
import type { WorkStudyPositionVO } from '@/api/jcbt/workStudyPosition';
|
|
import PositionDetail from './detail.vue';
|
|
import ApplicationForm from './form.vue';
|
|
|
|
// 组件引用
|
|
const queryFormRef = ref();
|
|
const tableRef = ref();
|
|
|
|
// 响应式数据
|
|
const loading = ref(false);
|
|
const positionList = ref<WorkStudyPositionVO[]>([]);
|
|
const total = ref(0);
|
|
const detailDialogVisible = ref(false);
|
|
const applyDialogVisible = ref(false);
|
|
const selectedPositionId = ref<number>();
|
|
const selectedPosition = ref<WorkStudyPositionVO>();
|
|
|
|
// 查询参数
|
|
const queryParams = reactive({
|
|
pageNum: 1,
|
|
pageSize: 10,
|
|
positionName: '',
|
|
positionScope: '',
|
|
contactTeacher: ''
|
|
});
|
|
|
|
// 计算属性
|
|
const tableHeight = computed(() => {
|
|
return window.innerHeight - 400;
|
|
});
|
|
|
|
/** 获取状态类型 */
|
|
const getStatusType = (status: string) => {
|
|
const typeMap: Record<string, string> = {
|
|
DRAFT: 'info',
|
|
PUBLISHED: 'warning',
|
|
RECRUITING: 'success',
|
|
FULL: 'primary',
|
|
EXPIRED: 'danger',
|
|
SUSPENDED: 'warning',
|
|
CANCELLED: 'danger'
|
|
};
|
|
return typeMap[status] || 'info';
|
|
};
|
|
|
|
/** 判断是否可以申请 */
|
|
const canApply = (position: WorkStudyPositionVO) => {
|
|
// 检查岗位状态
|
|
if (!['PUBLISHED', 'RECRUITING'].includes(position.status || '')) {
|
|
return false;
|
|
}
|
|
|
|
// 检查是否还有空缺
|
|
const current = position.currentCount || 0;
|
|
const required = position.requiredCount || 0;
|
|
if (current >= required) {
|
|
return false;
|
|
}
|
|
|
|
// 检查有效期
|
|
if (position.endDate) {
|
|
const endDate = new Date(position.endDate);
|
|
if (endDate < new Date()) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
return true;
|
|
};
|
|
|
|
/** 查询岗位列表 */
|
|
const getPositionList = async () => {
|
|
loading.value = true;
|
|
try {
|
|
// 调用可见岗位接口,排除已申请的岗位
|
|
const response = await listVisiblePositions(queryParams, true);
|
|
// 后端返回 TableDataInfo 结构,响应拦截器已解包,直接使用 response.rows
|
|
positionList.value = response.rows || [];
|
|
total.value = response.total || 0;
|
|
} catch (error) {
|
|
console.error('获取岗位列表失败:', error);
|
|
ElMessage.error('获取岗位列表失败');
|
|
} finally {
|
|
loading.value = false;
|
|
}
|
|
};
|
|
|
|
/** 搜索按钮操作 */
|
|
const handleQuery = () => {
|
|
queryParams.pageNum = 1;
|
|
getPositionList();
|
|
};
|
|
|
|
/** 重置按钮操作 */
|
|
const resetQuery = () => {
|
|
queryFormRef.value?.resetFields();
|
|
handleQuery();
|
|
};
|
|
|
|
/** 分页大小变化 */
|
|
const handleSizeChange = (size: number) => {
|
|
queryParams.pageSize = size;
|
|
getPositionList();
|
|
};
|
|
|
|
/** 当前页变化 */
|
|
const handleCurrentChange = (page: number) => {
|
|
queryParams.pageNum = page;
|
|
getPositionList();
|
|
};
|
|
|
|
/** 查看详情 */
|
|
const handleViewDetail = (position: WorkStudyPositionVO) => {
|
|
selectedPositionId.value = position.id as number;
|
|
detailDialogVisible.value = true;
|
|
};
|
|
|
|
/** 申请岗位 */
|
|
const handleApply = (position: WorkStudyPositionVO) => {
|
|
if (!canApply(position)) {
|
|
ElMessage.warning('该岗位当前不可申请');
|
|
return;
|
|
}
|
|
|
|
selectedPosition.value = position;
|
|
applyDialogVisible.value = true;
|
|
};
|
|
|
|
/** 从详情页申请 */
|
|
const handleApplyFromDetail = (position: WorkStudyPositionVO) => {
|
|
detailDialogVisible.value = false;
|
|
selectedPosition.value = position;
|
|
applyDialogVisible.value = true;
|
|
};
|
|
|
|
/** 申请成功回调 */
|
|
const handleApplySuccess = () => {
|
|
applyDialogVisible.value = false;
|
|
ElMessage.success('申请提交成功!');
|
|
// 刷新列表
|
|
getPositionList();
|
|
};
|
|
|
|
// 生命周期
|
|
onMounted(() => {
|
|
getPositionList();
|
|
});
|
|
</script>
|
|
|
|
<style scoped>
|
|
.app-container {
|
|
padding: 20px;
|
|
background-color: #f5f7fa;
|
|
min-height: 100vh;
|
|
}
|
|
|
|
.search-card,
|
|
.table-card {
|
|
margin-bottom: 20px;
|
|
border-radius: 12px;
|
|
border: 1px solid #e4e7ed;
|
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
|
|
transition: all 0.3s ease;
|
|
}
|
|
|
|
.search-card:hover,
|
|
.table-card:hover {
|
|
border-color: rgba(93, 135, 255, 0.2);
|
|
box-shadow: 0 4px 16px rgba(93, 135, 255, 0.08);
|
|
}
|
|
|
|
.card-header {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
}
|
|
|
|
.search-title,
|
|
.table-title {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
font-weight: 600;
|
|
font-size: 16px;
|
|
color: #303133;
|
|
}
|
|
|
|
.search-title .el-icon,
|
|
.table-title .el-icon {
|
|
color: rgb(93, 135, 255);
|
|
}
|
|
|
|
.header-actions {
|
|
display: flex;
|
|
gap: 8px;
|
|
}
|
|
|
|
:deep(.el-card__header) {
|
|
background: linear-gradient(135deg, #fafbff 0%, #f8fafc 100%);
|
|
border-bottom: 1px solid rgba(93, 135, 255, 0.1);
|
|
padding: 16px 20px;
|
|
}
|
|
|
|
:deep(.el-card__body) {
|
|
padding: 20px;
|
|
}
|
|
|
|
/* 表格样式 */
|
|
.position-table {
|
|
border-radius: 8px;
|
|
overflow: hidden;
|
|
margin-bottom: 20px;
|
|
}
|
|
|
|
:deep(.el-table__header) {
|
|
th {
|
|
background: linear-gradient(135deg, #fafbff 0%, #f8fafc 100%);
|
|
color: #303133;
|
|
font-weight: 600;
|
|
border-color: rgba(93, 135, 255, 0.1);
|
|
}
|
|
}
|
|
|
|
:deep(.el-table__row:hover) {
|
|
background-color: rgba(93, 135, 255, 0.05) !important;
|
|
}
|
|
|
|
/* 内容样式 */
|
|
.position-name {
|
|
display: flex;
|
|
align-items: center;
|
|
}
|
|
|
|
.number-display {
|
|
font-weight: 600;
|
|
color: rgb(93, 135, 255);
|
|
|
|
&.text-success {
|
|
color: rgb(19, 222, 185);
|
|
}
|
|
}
|
|
|
|
.salary-info {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 4px;
|
|
color: rgb(255, 174, 31);
|
|
font-weight: 500;
|
|
|
|
.el-icon {
|
|
color: rgb(255, 174, 31);
|
|
}
|
|
}
|
|
|
|
.date-range {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 2px;
|
|
font-size: 12px;
|
|
|
|
.date-item {
|
|
color: #606266;
|
|
font-family: monospace;
|
|
}
|
|
|
|
.date-separator {
|
|
color: #909399;
|
|
text-align: center;
|
|
font-size: 10px;
|
|
}
|
|
}
|
|
|
|
.action-buttons {
|
|
display: flex;
|
|
gap: 8px;
|
|
justify-content: center;
|
|
align-items: center;
|
|
}
|
|
|
|
/* 分页样式 */
|
|
.pagination-container {
|
|
display: flex;
|
|
justify-content: flex-end;
|
|
padding: 16px 0 0 0;
|
|
margin-top: 16px;
|
|
border-top: 1px solid #f0f2f5;
|
|
}
|
|
|
|
/* 对话框样式 */
|
|
.position-detail-dialog :deep(.el-dialog),
|
|
.apply-dialog :deep(.el-dialog) {
|
|
border-radius: 12px;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.position-detail-dialog :deep(.el-dialog__header),
|
|
.apply-dialog :deep(.el-dialog__header) {
|
|
background: linear-gradient(135deg, rgb(93, 135, 255) 0%, rgb(73, 190, 255) 100%);
|
|
color: white;
|
|
padding: 20px 24px;
|
|
margin: 0;
|
|
}
|
|
|
|
.position-detail-dialog :deep(.el-dialog__title),
|
|
.apply-dialog :deep(.el-dialog__title) {
|
|
color: white;
|
|
font-size: 18px;
|
|
font-weight: 600;
|
|
}
|
|
|
|
.position-detail-dialog :deep(.el-dialog__headerbtn .el-dialog__close),
|
|
.apply-dialog :deep(.el-dialog__headerbtn .el-dialog__close) {
|
|
color: white;
|
|
font-size: 20px;
|
|
}
|
|
|
|
.position-detail-dialog :deep(.el-dialog__headerbtn .el-dialog__close):hover,
|
|
.apply-dialog :deep(.el-dialog__headerbtn .el-dialog__close):hover {
|
|
color: rgba(255, 255, 255, 0.8);
|
|
}
|
|
|
|
/* 响应式布局 */
|
|
@media (max-width: 1200px) {
|
|
.app-container {
|
|
padding: 10px;
|
|
}
|
|
|
|
:deep(.el-form--inline .el-form-item) {
|
|
margin-right: 10px;
|
|
margin-bottom: 10px;
|
|
}
|
|
}
|
|
</style>
|