402 lines
13 KiB
Vue
402 lines
13 KiB
Vue
<template>
|
|
<div class="pending-applications">
|
|
<!-- 搜索表单 -->
|
|
<el-form :model="queryParams" ref="queryRef" :inline="true" class="search-form">
|
|
<el-form-item label="岗位名称" prop="positionName">
|
|
<el-input v-model="queryParams.positionName" placeholder="请输入岗位名称" clearable style="width: 200px" @keyup.enter="handleQuery" />
|
|
</el-form-item>
|
|
<el-form-item label="学生姓名" prop="studentName">
|
|
<el-input v-model="queryParams.studentName" placeholder="请输入学生姓名" clearable style="width: 200px" @keyup.enter="handleQuery" />
|
|
</el-form-item>
|
|
<el-form-item label="学号" prop="studentNo">
|
|
<el-input v-model="queryParams.studentNo" placeholder="请输入学号" clearable style="width: 200px" @keyup.enter="handleQuery" />
|
|
</el-form-item>
|
|
<el-form-item label="申请日期" prop="applicationDate">
|
|
<el-date-picker
|
|
v-model="queryParams.applicationDate"
|
|
type="date"
|
|
placeholder="选择申请日期"
|
|
format="YYYY-MM-DD"
|
|
value-format="YYYY-MM-DD"
|
|
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-row :gutter="10" class="mb-8">
|
|
<el-col :span="1.5">
|
|
<el-button type="success" plain icon="Check" :disabled="multiple" @click="handleBatchReview('approved')"> 批量通过 </el-button>
|
|
</el-col>
|
|
<el-col :span="1.5">
|
|
<el-button type="danger" plain icon="Close" :disabled="multiple" @click="handleBatchReview('rejected')"> 批量拒绝 </el-button>
|
|
</el-col>
|
|
</el-row>
|
|
|
|
<!-- 数据表格 -->
|
|
<el-table v-loading="loading" :data="applicationList" @selection-change="handleSelectionChange" row-key="id">
|
|
<el-table-column type="selection" width="50" align="center" />
|
|
<el-table-column label="序号" type="index" width="60" align="center" />
|
|
<el-table-column label="岗位名称" prop="positionName" min-width="120" show-overflow-tooltip />
|
|
<el-table-column label="学生信息" min-width="160">
|
|
<template #default="{ row }">
|
|
<div class="student-info">
|
|
<div class="name">{{ row.studentName }}</div>
|
|
<div class="detail">{{ row.studentNo }} | {{ row.className }}</div>
|
|
</div>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column label="专业年级" min-width="140">
|
|
<template #default="{ row }">
|
|
<div>{{ row.majorName }}</div>
|
|
<div class="text-gray">{{ row.grade }}</div>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column label="联系方式" min-width="120">
|
|
<template #default="{ row }">
|
|
<div>{{ row.contactPhone }}</div>
|
|
<div class="text-gray">{{ row.email }}</div>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column label="申请理由" prop="applicationReason" min-width="200" show-overflow-tooltip />
|
|
<el-table-column label="申请时间" prop="applicationDate" width="110" align="center" />
|
|
<el-table-column label="操作" fixed="right" width="240" align="center" class-name="small-padding fixed-width">
|
|
<template #default="{ row }">
|
|
<div class="operation-buttons">
|
|
<el-tooltip content="查看详情" placement="top">
|
|
<el-button link type="primary" icon="View" size="small" @click="handleDetail(row)"> 详情 </el-button>
|
|
</el-tooltip>
|
|
<el-tooltip content="审核通过" placement="top">
|
|
<el-button link type="success" icon="Check" size="small" @click="handleReview(row, 'approved')"> 通过 </el-button>
|
|
</el-tooltip>
|
|
<el-tooltip content="审核拒绝" placement="top">
|
|
<el-button link type="danger" icon="Close" size="small" @click="handleReview(row, 'rejected')"> 拒绝 </el-button>
|
|
</el-tooltip>
|
|
</div>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table>
|
|
|
|
<!-- 分页 -->
|
|
<pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
|
|
|
|
<!-- 审核对话框 -->
|
|
<el-dialog v-model="reviewDialog.visible" :title="reviewDialog.title" width="600px" append-to-body>
|
|
<el-form ref="reviewFormRef" :model="reviewDialog.form" :rules="reviewRules" label-width="100px">
|
|
<el-form-item label="审核结果" prop="reviewResult">
|
|
<el-radio-group v-model="reviewDialog.form.reviewResult">
|
|
<el-radio value="approved">通过</el-radio>
|
|
<el-radio value="rejected">拒绝</el-radio>
|
|
</el-radio-group>
|
|
</el-form-item>
|
|
<el-form-item label="审核意见" prop="reviewComment">
|
|
<el-input v-model="reviewDialog.form.reviewComment" type="textarea" :rows="4" placeholder="请输入审核意见" />
|
|
</el-form-item>
|
|
</el-form>
|
|
<template #footer>
|
|
<div class="dialog-footer">
|
|
<el-button @click="reviewDialog.visible = false">取消</el-button>
|
|
<el-button type="primary" @click="submitReview">确认</el-button>
|
|
</div>
|
|
</template>
|
|
</el-dialog>
|
|
|
|
<!-- 详情对话框 -->
|
|
<ApplicationDetail v-model:visible="detailDialog.visible" :application-id="detailDialog.applicationId" @refresh="getList" />
|
|
</div>
|
|
</template>
|
|
|
|
<script setup lang="ts" name="PendingApplications">
|
|
import { ref, reactive, onMounted } from 'vue';
|
|
import { ElMessage, ElMessageBox } from 'element-plus';
|
|
import { Search } from '@element-plus/icons-vue';
|
|
import {
|
|
listPendingApplications,
|
|
reviewApplication,
|
|
batchReviewApplications,
|
|
type WorkStudyApplicationVO,
|
|
type WorkStudyApplicationQuery,
|
|
type ReviewForm
|
|
} from '@/api/jcbt/workStudyApplicationCollegeReview';
|
|
import ApplicationDetail from './ApplicationDetail.vue';
|
|
|
|
const emit = defineEmits(['refresh-statistics']);
|
|
|
|
// 响应式数据
|
|
const loading = ref(false);
|
|
const applicationList = ref<WorkStudyApplicationVO[]>([]);
|
|
const total = ref(0);
|
|
const ids = ref<Array<string | number>>([]);
|
|
const multiple = ref(true);
|
|
|
|
// 查询参数
|
|
const queryParams = reactive<WorkStudyApplicationQuery>({
|
|
pageNum: 1,
|
|
pageSize: 10,
|
|
positionName: '',
|
|
studentName: '',
|
|
studentNo: '',
|
|
applicationDate: ''
|
|
});
|
|
|
|
// 审核对话框
|
|
const reviewDialog = reactive({
|
|
visible: false,
|
|
title: '',
|
|
type: 'single' as 'single' | 'batch',
|
|
form: {
|
|
applicationId: '',
|
|
reviewResult: 'approved',
|
|
reviewComment: ''
|
|
} as ReviewForm
|
|
});
|
|
|
|
// 详情对话框
|
|
const detailDialog = reactive({
|
|
visible: false,
|
|
applicationId: '' as string | number
|
|
});
|
|
|
|
// 表单验证规则
|
|
const reviewRules = {
|
|
reviewResult: [{ required: true, message: '请选择审核结果', trigger: 'change' }],
|
|
reviewComment: [
|
|
{ required: true, message: '请输入审核意见', trigger: 'blur' },
|
|
{ min: 5, max: 500, message: '审核意见长度在 5 到 500 个字符', trigger: 'blur' }
|
|
]
|
|
};
|
|
|
|
// 表单引用
|
|
const queryRef = ref();
|
|
const reviewFormRef = ref();
|
|
|
|
// 获取列表数据
|
|
const getList = async () => {
|
|
loading.value = true;
|
|
try {
|
|
console.log('🔍 [调试] 开始获取待审核申请列表');
|
|
console.log('🔍 [调试] 查询参数:', queryParams);
|
|
|
|
// 添加时间戳防止缓存
|
|
const queryParamsWithTimestamp = {
|
|
...queryParams,
|
|
_t: Date.now()
|
|
};
|
|
|
|
const response = await listPendingApplications(queryParamsWithTimestamp);
|
|
console.log('🔍 [调试] API原始响应:', response);
|
|
|
|
// 根据实际响应格式处理数据
|
|
// 从调试输出看,response直接包含{total: 1, rows: Array(1), code: 200, msg: '查询成功'}
|
|
if (response && typeof response === 'object') {
|
|
console.log('🔍 [调试] 响应对象键名:', Object.keys(response));
|
|
|
|
if (response.rows !== undefined && response.total !== undefined) {
|
|
console.log('🔍 [调试] ✅ 识别为TableDataInfo格式');
|
|
console.log('🔍 [调试] rows数据:', response.rows);
|
|
console.log('🔍 [调试] total数量:', response.total);
|
|
applicationList.value = response.rows || [];
|
|
total.value = response.total || 0;
|
|
} else {
|
|
console.warn('🔍 [调试] ❌ 响应格式不匹配,缺少rows或total字段');
|
|
applicationList.value = [];
|
|
total.value = 0;
|
|
}
|
|
} else {
|
|
console.warn('🔍 [调试] ❌ 响应不是对象类型');
|
|
applicationList.value = [];
|
|
total.value = 0;
|
|
}
|
|
|
|
console.log('🔍 [调试] 最终设置的applicationList长度:', applicationList.value.length);
|
|
console.log('🔍 [调试] 最终设置的total:', total.value);
|
|
|
|
if (applicationList.value.length > 0) {
|
|
console.log('🔍 [调试] 第一条数据示例:', applicationList.value[0]);
|
|
} else {
|
|
console.log('🔍 [调试] ⚠️ 列表为空!');
|
|
}
|
|
} catch (error: any) {
|
|
console.error('🔍 [调试] 获取待审核申请列表失败:', error);
|
|
if (error?.response?.data) {
|
|
console.error('🔍 [调试] 错误详情:', error.response.data);
|
|
}
|
|
|
|
if (error?.message?.includes('404')) {
|
|
ElMessage.error('无法获取待审核申请列表,请检查您是否有学院审核权限');
|
|
} else if (error?.message?.includes('403')) {
|
|
ElMessage.error('权限不足,无法访问学院审核功能');
|
|
} else {
|
|
ElMessage.error('获取待审核申请列表失败,请稍后重试');
|
|
}
|
|
} finally {
|
|
loading.value = false;
|
|
}
|
|
};
|
|
|
|
// 搜索
|
|
const handleQuery = () => {
|
|
queryParams.pageNum = 1;
|
|
getList();
|
|
};
|
|
|
|
// 重置搜索
|
|
const resetQuery = () => {
|
|
queryRef.value?.resetFields();
|
|
handleQuery();
|
|
};
|
|
|
|
// 多选框选中数据
|
|
const handleSelectionChange = (selection: WorkStudyApplicationVO[]) => {
|
|
ids.value = selection.map((item) => item.id!);
|
|
multiple.value = !selection.length;
|
|
};
|
|
|
|
// 查看详情
|
|
const handleDetail = (row: WorkStudyApplicationVO) => {
|
|
detailDialog.applicationId = row.id!;
|
|
detailDialog.visible = true;
|
|
};
|
|
|
|
// 单个审核
|
|
const handleReview = (row: WorkStudyApplicationVO, result: string) => {
|
|
reviewDialog.visible = true;
|
|
reviewDialog.title = `审核申请 - ${row.studentName}`;
|
|
reviewDialog.type = 'single';
|
|
reviewDialog.form = {
|
|
applicationId: row.id!,
|
|
reviewResult: result,
|
|
reviewComment: ''
|
|
};
|
|
};
|
|
|
|
// 批量审核
|
|
const handleBatchReview = (result: string) => {
|
|
if (!ids.value.length) {
|
|
ElMessage.warning('请选择要审核的申请');
|
|
return;
|
|
}
|
|
|
|
reviewDialog.visible = true;
|
|
reviewDialog.title = `批量${result === 'approved' ? '通过' : '拒绝'}申请`;
|
|
reviewDialog.type = 'batch';
|
|
reviewDialog.form = {
|
|
applicationId: '',
|
|
reviewResult: result,
|
|
reviewComment: ''
|
|
};
|
|
};
|
|
|
|
// 提交审核
|
|
const submitReview = async () => {
|
|
if (!reviewFormRef.value) return;
|
|
|
|
const valid = await reviewFormRef.value.validate();
|
|
if (!valid) return;
|
|
|
|
try {
|
|
console.log('🔍 [前端调试] 开始提交审核');
|
|
console.log('🔍 [前端调试] 审核类型:', reviewDialog.type);
|
|
console.log('🔍 [前端调试] 审核表单:', reviewDialog.form);
|
|
|
|
if (reviewDialog.type === 'single') {
|
|
const result = await reviewApplication(reviewDialog.form);
|
|
console.log('🔍 [前端调试] 单个审核API响应:', result);
|
|
} else {
|
|
const result = await batchReviewApplications(ids.value, reviewDialog.form.reviewResult, reviewDialog.form.reviewComment);
|
|
console.log('🔍 [前端调试] 批量审核API响应:', result);
|
|
}
|
|
|
|
ElMessage.success('审核成功');
|
|
reviewDialog.visible = false;
|
|
|
|
console.log('🔍 [前端调试] 审核成功,开始刷新列表');
|
|
await getList(); // 等待列表刷新完成
|
|
console.log('🔍 [前端调试] 列表刷新完成');
|
|
|
|
emit('refresh-statistics');
|
|
} catch (error) {
|
|
console.error('🔍 [前端调试] 审核失败:', error);
|
|
ElMessage.error('审核失败');
|
|
}
|
|
};
|
|
|
|
// 暴露方法给父组件调用
|
|
defineExpose({
|
|
getList
|
|
});
|
|
|
|
// 初始化
|
|
onMounted(() => {
|
|
getList();
|
|
});
|
|
</script>
|
|
|
|
<style scoped lang="scss">
|
|
.pending-applications {
|
|
.search-form {
|
|
background: #f8f9fa;
|
|
padding: 20px;
|
|
border-radius: 8px;
|
|
margin-bottom: 16px;
|
|
}
|
|
|
|
.student-info {
|
|
.name {
|
|
font-weight: 500;
|
|
color: #333;
|
|
}
|
|
|
|
.detail {
|
|
font-size: 12px;
|
|
color: #666;
|
|
margin-top: 4px;
|
|
}
|
|
}
|
|
|
|
.text-gray {
|
|
color: #666;
|
|
font-size: 12px;
|
|
}
|
|
|
|
.mb-8 {
|
|
margin-bottom: 8px;
|
|
}
|
|
|
|
.operation-buttons {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
gap: 8px;
|
|
flex-wrap: wrap;
|
|
|
|
.el-button {
|
|
margin: 0;
|
|
padding: 4px 8px;
|
|
font-size: 12px;
|
|
|
|
&.is-link {
|
|
&:hover {
|
|
background-color: rgba(var(--el-color-primary-rgb), 0.1);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// 确保操作列的样式
|
|
:deep(.el-table .small-padding .cell) {
|
|
padding: 8px 4px;
|
|
}
|
|
|
|
:deep(.el-table .fixed-width) {
|
|
.el-button + .el-button {
|
|
margin-left: 0;
|
|
}
|
|
}
|
|
}
|
|
</style>
|