“培训申请模块完成版(后续测试)”
This commit is contained in:
1 parent
bbfab6d5b6
commit
3ac3f6423c
1 file changed
+239
-250
+239
-250
@@ -403,14 +403,16 @@
|
||||
<el-descriptions-item label="现岗位">{{ applicationDetail.currentPosition || '暂无' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="参加工作时间">{{ parseTime(applicationDetail.workStartTime) || '暂无' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="联系电话">{{ applicationDetail.phone || '暂无' }}</el-descriptions-item>
|
||||
|
||||
|
||||
<!-- 培训情况信息 -->
|
||||
<el-descriptions-item label="主办单位">{{ applicationDetail.organizerUnit || applicationDetail.courseName || '暂无' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="培训地点">{{ applicationDetail.location }}</el-descriptions-item>
|
||||
<el-descriptions-item label="开始时间">{{ parseTime(applicationDetail.startTime) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="结束时间">{{ parseTime(applicationDetail.endTime) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="培训类型">{{ applicationDetail.trainingType || '暂无' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="培训费用">{{ applicationDetail.trainingFee ? `${applicationDetail.trainingFee}元` : '暂无' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="培训费用">{{
|
||||
applicationDetail.trainingFee ? `${applicationDetail.trainingFee}元` : '暂无'
|
||||
}}</el-descriptions-item>
|
||||
<el-descriptions-item label="申请状态">
|
||||
<el-tag
|
||||
:type="
|
||||
@@ -428,7 +430,9 @@
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="申请时间">{{ parseTime(applicationDetail.applyTime) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="同行人" :span="2">{{ getCompanionNames(applicationDetail.companions) || '无' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="培训目的" :span="2">{{ applicationDetail.trainingPurpose || applicationDetail.reason || '暂无' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="培训目的" :span="2">{{
|
||||
applicationDetail.trainingPurpose || applicationDetail.reason || '暂无'
|
||||
}}</el-descriptions-item>
|
||||
<el-descriptions-item label="备注" :span="2">{{ applicationDetail.remark || '无' }}</el-descriptions-item>
|
||||
|
||||
<!-- 显示拒绝原因,如果申请被拒绝 -->
|
||||
@@ -448,9 +452,9 @@
|
||||
</el-descriptions>
|
||||
|
||||
<!-- 申请附件显示区域 -->
|
||||
<div v-if="applicationDetailAttachmentList.length > 0" class="attachment-section" style="margin-top: 20px;">
|
||||
<div class="section-title" style="margin-bottom: 15px; padding: 10px; border-left: 4px solid #409eff; background-color: #f5f7fa;">
|
||||
<el-icon style="margin-right: 8px;"><Paperclip /></el-icon>
|
||||
<div v-if="applicationDetailAttachmentList.length > 0" class="attachment-section" style="margin-top: 20px">
|
||||
<div class="section-title" style="margin-bottom: 15px; padding: 10px; border-left: 4px solid #409eff; background-color: #f5f7fa">
|
||||
<el-icon style="margin-right: 8px"><Paperclip /></el-icon>
|
||||
<strong>申请附件</strong>
|
||||
</div>
|
||||
<el-table :data="applicationDetailAttachmentList" border size="small">
|
||||
@@ -463,9 +467,7 @@
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="100" align="center">
|
||||
<template #default="scope">
|
||||
<el-button type="primary" link icon="Download" @click="handleDownloadApplicationAttachment(scope.row)" size="small">
|
||||
下载
|
||||
</el-button>
|
||||
<el-button type="primary" link icon="Download" @click="handleDownloadApplicationAttachment(scope.row)" size="small"> 下载 </el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
@@ -512,9 +514,9 @@
|
||||
<el-form ref="applicationFormRef" :model="applicationForm" :rules="applicationRules" label-width="140px">
|
||||
<!-- 基本情况信息 -->
|
||||
<el-divider content-position="left">
|
||||
<span style="font-weight: bold; color: #409eff;">基本情况</span>
|
||||
<span style="font-weight: bold; color: #409eff">基本情况</span>
|
||||
</el-divider>
|
||||
|
||||
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="姓名" prop="userName">
|
||||
@@ -536,9 +538,9 @@
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="现岗位" prop="currentPosition">
|
||||
<el-radio-group v-model="applicationForm.currentPosition" style="display: flex; flex-wrap: nowrap; align-items: center;">
|
||||
<el-radio label="教学" style="margin-right: 20px;">教学</el-radio>
|
||||
<el-radio label="管理" style="margin-right: 20px;">管理</el-radio>
|
||||
<el-radio-group v-model="applicationForm.currentPosition" style="display: flex; flex-wrap: nowrap; align-items: center">
|
||||
<el-radio label="教学" style="margin-right: 20px">教学</el-radio>
|
||||
<el-radio label="管理" style="margin-right: 20px">管理</el-radio>
|
||||
<el-radio label="其他">其他</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
@@ -566,7 +568,7 @@
|
||||
|
||||
<!-- 培训情况信息 -->
|
||||
<el-divider content-position="left">
|
||||
<span style="font-weight: bold; color: #409eff;">培训情况</span>
|
||||
<span style="font-weight: bold; color: #409eff">培训情况</span>
|
||||
</el-divider>
|
||||
|
||||
<el-row :gutter="20">
|
||||
@@ -585,13 +587,7 @@
|
||||
<el-form-item label="培训时间" required>
|
||||
<el-col :span="11">
|
||||
<el-form-item prop="startTime">
|
||||
<el-date-picker
|
||||
v-model="applicationForm.startTime"
|
||||
type="date"
|
||||
placeholder="开始日期"
|
||||
style="width: 100%"
|
||||
value-format="YYYY-MM-DD"
|
||||
/>
|
||||
<el-date-picker v-model="applicationForm.startTime" type="date" placeholder="开始日期" style="width: 100%" value-format="YYYY-MM-DD" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="2" class="text-center">
|
||||
@@ -599,31 +595,25 @@
|
||||
</el-col>
|
||||
<el-col :span="11">
|
||||
<el-form-item prop="endTime">
|
||||
<el-date-picker
|
||||
v-model="applicationForm.endTime"
|
||||
type="date"
|
||||
placeholder="结束日期"
|
||||
style="width: 100%"
|
||||
value-format="YYYY-MM-DD"
|
||||
/>
|
||||
<el-date-picker v-model="applicationForm.endTime" type="date" placeholder="结束日期" style="width: 100%" value-format="YYYY-MM-DD" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="培训类型" prop="trainingType">
|
||||
<div style="display: flex; flex-wrap: wrap; gap: 20px; align-items: center;">
|
||||
<el-radio-group v-model="applicationForm.trainingType" style="display: flex; flex-wrap: nowrap; gap: 20px;">
|
||||
<el-radio label="教学">教学</el-radio>
|
||||
<el-radio label="德育">德育</el-radio>
|
||||
<el-radio label="行政">行政</el-radio>
|
||||
<el-radio label="管理">管理</el-radio>
|
||||
<el-radio label="其他">其他</el-radio>
|
||||
</el-radio-group>
|
||||
<el-form-item label="培训类型" prop="trainingType">
|
||||
<div style="display: flex; flex-wrap: wrap; gap: 20px; align-items: center">
|
||||
<el-radio-group v-model="applicationForm.trainingType" style="display: flex; flex-wrap: nowrap; gap: 20px">
|
||||
<el-radio label="教学">教学</el-radio>
|
||||
<el-radio label="德育">德育</el-radio>
|
||||
<el-radio label="行政">行政</el-radio>
|
||||
<el-radio label="管理">管理</el-radio>
|
||||
<el-radio label="其他">其他</el-radio>
|
||||
</el-radio-group>
|
||||
<el-input
|
||||
v-if="applicationForm.trainingType === '其他'"
|
||||
v-model="applicationForm.trainingTypeOther"
|
||||
placeholder="请输入具体培训类型"
|
||||
style="width: 200px; margin-left: 10px;"
|
||||
style="width: 200px; margin-left: 10px"
|
||||
clearable
|
||||
/>
|
||||
</div>
|
||||
@@ -632,22 +622,12 @@
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="同行人" prop="companions">
|
||||
<TeacherMultiSelector
|
||||
v-model="selectedCompanions"
|
||||
placeholder="请选择同行人员"
|
||||
@change="handleCompanionsChange"
|
||||
/>
|
||||
<TeacherMultiSelector v-model="selectedCompanions" placeholder="请选择同行人员" @change="handleCompanionsChange" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="培训费用" prop="trainingFee">
|
||||
<el-input-number
|
||||
v-model="applicationForm.trainingFee"
|
||||
:min="0"
|
||||
:precision="2"
|
||||
style="width: 100%"
|
||||
placeholder="请输入培训费用"
|
||||
>
|
||||
<el-input-number v-model="applicationForm.trainingFee" :min="0" :precision="2" style="width: 100%" placeholder="请输入培训费用">
|
||||
<template #append>元</template>
|
||||
</el-input-number>
|
||||
</el-form-item>
|
||||
@@ -683,10 +663,10 @@
|
||||
accept=".pdf,.doc,.docx,.jpg,.jpeg,.png,.xls,.xlsx"
|
||||
>
|
||||
<!-- 拖拽上传区域 -->
|
||||
<div class="el-upload-dragger-attachment">
|
||||
<el-icon class="el-icon--upload"><Upload /></el-icon>
|
||||
<div class="el-upload__text">将附件文件拖到此处,或<em>点击上传</em></div>
|
||||
</div>
|
||||
<div class="el-upload-dragger-attachment">
|
||||
<el-icon class="el-icon--upload"><Upload /></el-icon>
|
||||
<div class="el-upload__text">将附件文件拖到此处,或<em>点击上传</em></div>
|
||||
</div>
|
||||
|
||||
<!-- 自定义文件卡片 -->
|
||||
<template #file="{ file }">
|
||||
@@ -726,7 +706,12 @@
|
||||
<!-- 操作按钮区域 -->
|
||||
<div class="upload-file-card-actions" v-if="file.status && file.status !== 'ready'">
|
||||
<el-button-group size="small">
|
||||
<el-button type="success" @click.stop="handleDownloadApplicationAttachment(file)" title="下载" :disabled="file.status !== 'success'">
|
||||
<el-button
|
||||
type="success"
|
||||
@click.stop="handleDownloadApplicationAttachment(file)"
|
||||
title="下载"
|
||||
:disabled="file.status !== 'success'"
|
||||
>
|
||||
<el-icon><Download /></el-icon>
|
||||
</el-button>
|
||||
<el-button type="danger" @click.stop="confirmRemoveApplicationAttachment(file)" title="删除">
|
||||
@@ -880,7 +865,7 @@
|
||||
<el-descriptions-item label="现岗位">{{ recordDetail.currentPosition || '暂无' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="参加工作时间">{{ parseTime(recordDetail.workStartTime) || '暂无' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="联系电话">{{ recordDetail.phone || '暂无' }}</el-descriptions-item>
|
||||
|
||||
|
||||
<!-- 培训情况信息 -->
|
||||
<el-descriptions-item label="主办单位">{{ recordDetail.organizerUnit || recordDetail.courseName || '暂无' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="培训地点">{{ recordDetail.location || '暂无' }}</el-descriptions-item>
|
||||
@@ -900,9 +885,9 @@
|
||||
</el-descriptions>
|
||||
|
||||
<!-- 申请附件显示区域 -->
|
||||
<div v-if="recordDetailAttachmentList.length > 0" class="attachment-section" style="margin-top: 20px;">
|
||||
<div class="section-title" style="margin-bottom: 15px; padding: 10px; border-left: 4px solid #409eff; background-color: #f5f7fa;">
|
||||
<el-icon style="margin-right: 8px;"><Paperclip /></el-icon>
|
||||
<div v-if="recordDetailAttachmentList.length > 0" class="attachment-section" style="margin-top: 20px">
|
||||
<div class="section-title" style="margin-bottom: 15px; padding: 10px; border-left: 4px solid #409eff; background-color: #f5f7fa">
|
||||
<el-icon style="margin-right: 8px"><Paperclip /></el-icon>
|
||||
<strong>申请附件</strong>
|
||||
</div>
|
||||
<el-table :data="recordDetailAttachmentList" border size="small">
|
||||
@@ -915,9 +900,7 @@
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="100" align="center">
|
||||
<template #default="scope">
|
||||
<el-button type="primary" link icon="Download" @click="handleDownloadApplicationAttachment(scope.row)" size="small">
|
||||
下载
|
||||
</el-button>
|
||||
<el-button type="primary" link icon="Download" @click="handleDownloadApplicationAttachment(scope.row)" size="small"> 下载 </el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
@@ -1023,7 +1006,9 @@ import { getFilePreviewUrl } from '@/api/system/file';
|
||||
import { getToken } from '@/utils/auth';
|
||||
import { getInfo as getUserInfo } from '@/api/login';
|
||||
import { useUserStore } from '@/store/modules/user';
|
||||
import TeacherMultiSelector from '@/components/TeacherMultiSelector/index.vue';
|
||||
// 🔧 修复雪花ID精度丢失问题:使用培训申请模块的本地组件
|
||||
// 原因:公共组件不能修改,会影响其他模块。在本地复制并修复雪花ID转Number导致的精度丢失问题
|
||||
import TeacherMultiSelector from './components/TeacherMultiSelector.vue';
|
||||
import { TeacherVO } from '@/api/system/teacher/types';
|
||||
import { listTeacher } from '@/api/system/teacher';
|
||||
|
||||
@@ -1239,11 +1224,13 @@ const applicationStatusOptions = [
|
||||
];
|
||||
|
||||
// 教师列表数据
|
||||
const teacherList = ref<Array<{
|
||||
teacherId: string | number;
|
||||
teacherName: string;
|
||||
teacherType: string;
|
||||
}>>([]);
|
||||
const teacherList = ref<
|
||||
Array<{
|
||||
teacherId: string | number;
|
||||
teacherName: string;
|
||||
teacherType: string;
|
||||
}>
|
||||
>([]);
|
||||
|
||||
// 申请详情相关
|
||||
const applicationDetailOpen = ref(false);
|
||||
@@ -1455,15 +1442,15 @@ const applicationRules = reactive<any>({
|
||||
endTime: [{ required: true, message: '请选择结束时间', trigger: 'change' }],
|
||||
trainingType: [{ required: true, message: '请选择培训类型', trigger: 'change' }],
|
||||
trainingTypeOther: [
|
||||
{
|
||||
{
|
||||
validator: (rule: any, value: string, callback: Function) => {
|
||||
if (applicationForm.trainingType === '其他' && (!value || value.trim() === '')) {
|
||||
callback(new Error('请输入具体的培训类型'));
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
},
|
||||
trigger: 'blur'
|
||||
},
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
trainingFee: [{ required: true, message: '请输入培训费用', trigger: 'blur' }],
|
||||
@@ -1471,11 +1458,14 @@ const applicationRules = reactive<any>({
|
||||
});
|
||||
|
||||
// 监听培训类型变化,清空其他类型输入
|
||||
watch(() => applicationForm.trainingType, (newType) => {
|
||||
if (newType !== '其他') {
|
||||
applicationForm.trainingTypeOther = '';
|
||||
watch(
|
||||
() => applicationForm.trainingType,
|
||||
(newType) => {
|
||||
if (newType !== '其他') {
|
||||
applicationForm.trainingTypeOther = '';
|
||||
}
|
||||
}
|
||||
});
|
||||
);
|
||||
|
||||
// 部门选项 - 从数据库sys_dept表获取
|
||||
const departmentOptions = ref<Array<{ value: string; label: string }>>([]);
|
||||
@@ -1684,10 +1674,10 @@ function getApplicationList() {
|
||||
/** 获取完成状态的标签类型 */
|
||||
const getCompletionStatusType = (status: string) => {
|
||||
// 培训记录的完成状态逻辑
|
||||
if (status === '1') return 'success'; // 已完成 - 绿色
|
||||
if (status === '2') return 'danger'; // 未完成 - 红色
|
||||
if (status === '1') return 'success'; // 已完成 - 绿色
|
||||
if (status === '2') return 'danger'; // 未完成 - 红色
|
||||
// 对于空状态或其他状态,由于培训记录都是基于已通过审批的申请生成的,默认显示为已通过
|
||||
return 'success'; // 已通过 - 绿色
|
||||
return 'success'; // 已通过 - 绿色
|
||||
};
|
||||
|
||||
/** 获取完成状态的标签文本 */
|
||||
@@ -1736,7 +1726,10 @@ async function loadTeacherListForDisplay() {
|
||||
teacherType: '' // system/teacher 接口没有 teacherType 字段
|
||||
}));
|
||||
console.log('教师列表加载完成:', teacherList.value.length, '位教师');
|
||||
console.log('教师ID列表:', teacherList.value.map(t => t.teacherId));
|
||||
console.log(
|
||||
'教师ID列表:',
|
||||
teacherList.value.map((t) => t.teacherId)
|
||||
);
|
||||
} catch (error: any) {
|
||||
console.warn('获取教师列表失败(可能是权限不足),将使用备用查询方式:', error);
|
||||
// ⚠️ 不再抛出错误,允许使用备用的同行人查询接口
|
||||
@@ -1803,8 +1796,6 @@ async function handleApplicationDetailAttachmentData(attachmentIds: string | nul
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** 新增培训申请 */
|
||||
async function handleAddApplication() {
|
||||
resetApplicationForm();
|
||||
@@ -1927,7 +1918,7 @@ function resetApplicationForm() {
|
||||
/** 处理同行人变化 */
|
||||
function handleCompanionsChange(teachers: TeacherVO[]) {
|
||||
selectedCompanions.value = teachers;
|
||||
applicationForm.companions = teachers.map(teacher => teacher.userId);
|
||||
applicationForm.companions = teachers.map((teacher) => teacher.userId);
|
||||
}
|
||||
|
||||
/** 加载编辑时的同行人数据 */
|
||||
@@ -1941,7 +1932,7 @@ async function loadCompanionsForEdit() {
|
||||
try {
|
||||
// 这里需要调用获取教师详情的API
|
||||
// 暂时使用teacherList中的数据进行匹配
|
||||
const teacher = teacherList.value.find(t => t.teacherId === userId);
|
||||
const teacher = teacherList.value.find((t) => t.teacherId === userId);
|
||||
if (teacher) {
|
||||
return {
|
||||
userId: teacher.teacherId,
|
||||
@@ -1959,9 +1950,9 @@ async function loadCompanionsForEdit() {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
const teachers = await Promise.all(teacherPromises);
|
||||
selectedCompanions.value = teachers.filter(t => t !== null) as TeacherVO[];
|
||||
selectedCompanions.value = teachers.filter((t) => t !== null) as TeacherVO[];
|
||||
} catch (error) {
|
||||
console.error('加载同行人数据失败:', error);
|
||||
selectedCompanions.value = [];
|
||||
@@ -1985,7 +1976,7 @@ function submitApplicationForm() {
|
||||
console.log('[提交培训申请] 提交前检查');
|
||||
console.log('[提交培训申请] applicationForm.attachmentIds:', applicationForm.attachmentIds);
|
||||
console.log('[提交培训申请] applicationAttachmentFileList:', applicationAttachmentFileList.value);
|
||||
|
||||
|
||||
applicationDialogLoading.value = true;
|
||||
|
||||
// 创建符合API要求的数据结构
|
||||
@@ -2013,7 +2004,7 @@ function submitApplicationForm() {
|
||||
// 附件信息
|
||||
attachmentIds: applicationForm.attachmentIds.join(',')
|
||||
};
|
||||
|
||||
|
||||
console.log('[提交培训申请] 最终提交的API数据:', apiData);
|
||||
console.log('[提交培训申请] attachmentIds字段值:', apiData.attachmentIds);
|
||||
|
||||
@@ -2120,19 +2111,19 @@ function getStatusLabel(value: string): string {
|
||||
/** 格式化文件大小 */
|
||||
function formatFileSize(bytes: number | string | undefined): string {
|
||||
if (!bytes || bytes === 0) return '未知大小';
|
||||
|
||||
|
||||
// 如果是字符串且包含中文,直接返回
|
||||
if (typeof bytes === 'string' && /[\u4e00-\u9fa5]/.test(bytes)) {
|
||||
return bytes;
|
||||
}
|
||||
|
||||
|
||||
const size = typeof bytes === 'string' ? parseInt(bytes) : bytes;
|
||||
if (isNaN(size)) return '未知大小';
|
||||
|
||||
|
||||
const k = 1024;
|
||||
const sizes = ['B', 'KB', 'MB', 'GB', 'TB'];
|
||||
const i = Math.floor(Math.log(size) / Math.log(k));
|
||||
|
||||
|
||||
return parseFloat((size / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
|
||||
}
|
||||
|
||||
@@ -2141,57 +2132,60 @@ async function loadCompanionNames(companions: (string | number)[] | string | nul
|
||||
if (!companions) {
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
// 生成缓存key
|
||||
const cacheKey = typeof companions === 'string' ? companions : JSON.stringify(companions);
|
||||
|
||||
|
||||
// 如果已缓存,直接返回
|
||||
if (companionNamesCache.value[cacheKey]) {
|
||||
return companionNamesCache.value[cacheKey];
|
||||
}
|
||||
|
||||
|
||||
let companionArray: number[] = [];
|
||||
|
||||
|
||||
// 解析同行人ID列表
|
||||
if (typeof companions === 'string') {
|
||||
try {
|
||||
const parsed = JSON.parse(companions);
|
||||
if (Array.isArray(parsed)) {
|
||||
companionArray = parsed.map(id => Number(id));
|
||||
companionArray = parsed.map((id) => Number(id));
|
||||
}
|
||||
console.log('[同行人解析] JSON解析成功:', companionArray);
|
||||
} catch (e) {
|
||||
// 如果JSON解析失败,可能是逗号分隔的字符串
|
||||
companionArray = companions.split(',')
|
||||
.map(id => Number(id.trim()))
|
||||
.filter(id => !isNaN(id));
|
||||
companionArray = companions
|
||||
.split(',')
|
||||
.map((id) => Number(id.trim()))
|
||||
.filter((id) => !isNaN(id));
|
||||
console.log('[同行人解析] 使用逗号分隔解析:', companionArray);
|
||||
}
|
||||
} else if (Array.isArray(companions)) {
|
||||
companionArray = companions.map(id => Number(id));
|
||||
companionArray = companions.map((id) => Number(id));
|
||||
console.log('[同行人解析] 直接使用数组:', companionArray);
|
||||
}
|
||||
|
||||
|
||||
if (companionArray.length === 0) {
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
// 调用新的批量查询接口(不需要system:teacher:list权限)
|
||||
console.log('[同行人查询] 调用批量查询接口:', companionArray);
|
||||
const response: any = await batchQueryCompanions(companionArray);
|
||||
const users = response.data || [];
|
||||
|
||||
|
||||
console.log('[同行人查询] 查询结果:', users.length, '个用户');
|
||||
|
||||
|
||||
// 拼接姓名
|
||||
const names = companionArray.map(userId => {
|
||||
const user = users.find((u: any) => u.userId === userId);
|
||||
const name = user ? (user.nickName || user.userName) : `未知用户(ID:${userId})`;
|
||||
console.log(`[同行人查询] ID ${userId} -> ${name}`);
|
||||
return name;
|
||||
}).join('、');
|
||||
|
||||
const names = companionArray
|
||||
.map((userId) => {
|
||||
const user = users.find((u: any) => u.userId === userId);
|
||||
const name = user ? user.nickName || user.userName : `未知用户(ID:${userId})`;
|
||||
console.log(`[同行人查询] ID ${userId} -> ${name}`);
|
||||
return name;
|
||||
})
|
||||
.join('、');
|
||||
|
||||
// 缓存结果
|
||||
companionNamesCache.value[cacheKey] = names;
|
||||
console.log('[同行人查询] 最终结果:', names);
|
||||
@@ -2210,14 +2204,14 @@ function getCompanionNames(companions: (string | number)[] | string | null | und
|
||||
if (!companions) {
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
const cacheKey = typeof companions === 'string' ? companions : JSON.stringify(companions);
|
||||
|
||||
|
||||
// 从缓存返回
|
||||
if (companionNamesCache.value[cacheKey]) {
|
||||
return companionNamesCache.value[cacheKey];
|
||||
}
|
||||
|
||||
|
||||
// 如果缓存中没有,返回"加载中..."并异步加载
|
||||
loadCompanionNames(companions);
|
||||
return '加载中...';
|
||||
@@ -2231,7 +2225,7 @@ async function handleViewApplicant(row: any) {
|
||||
nickName: row.nickName,
|
||||
attachmentIds: row.attachmentIds // 添加附件ID日志
|
||||
});
|
||||
|
||||
|
||||
// 如果行数据中没有完整的课程名称,尝试从课程列表获取
|
||||
if (!row.courseName && row.courseId) {
|
||||
const course = courseList.value.find((c) => c.courseId === row.courseId);
|
||||
@@ -2239,26 +2233,26 @@ async function handleViewApplicant(row: any) {
|
||||
row.courseName = course.title;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 复制申请详情
|
||||
Object.assign(applicationDetail, row);
|
||||
|
||||
|
||||
console.log('[查看申请详情] 详情数据已设置:', {
|
||||
userName: applicationDetail.userName,
|
||||
nickName: applicationDetail.nickName,
|
||||
companions: applicationDetail.companions,
|
||||
attachmentIds: applicationDetail.attachmentIds
|
||||
});
|
||||
|
||||
|
||||
// 预加载同行人信息(使用新接口,不需要system:teacher:list权限)
|
||||
if (row.companions) {
|
||||
await loadCompanionNames(row.companions);
|
||||
console.log('[查看申请详情] 同行人信息已预加载');
|
||||
}
|
||||
|
||||
|
||||
// 加载申请详情的附件数据
|
||||
await handleApplicationDetailAttachmentData(row.attachmentIds);
|
||||
|
||||
|
||||
applicationDetailOpen.value = true;
|
||||
}
|
||||
|
||||
@@ -2279,7 +2273,7 @@ function handleEditApplication(row: any) {
|
||||
applicationForm.location = row.location;
|
||||
applicationForm.startTime = row.startTime;
|
||||
applicationForm.endTime = row.endTime;
|
||||
|
||||
|
||||
// 处理培训类型和其他类型描述
|
||||
const trainingType = row.trainingType || '';
|
||||
const predefinedTypes = ['教学', '德育', '行政', '管理', '其他'];
|
||||
@@ -2291,11 +2285,11 @@ function handleEditApplication(row: any) {
|
||||
applicationForm.trainingType = '其他';
|
||||
applicationForm.trainingTypeOther = trainingType;
|
||||
}
|
||||
|
||||
|
||||
applicationForm.trainingFee = row.trainingFee || 0;
|
||||
applicationForm.trainingPurpose = row.trainingPurpose || row.reason || '';
|
||||
applicationForm.remark = row.remark;
|
||||
|
||||
|
||||
// 处理同行人员字段 - 从JSON字符串解析为数组
|
||||
if (row.companions) {
|
||||
try {
|
||||
@@ -2313,14 +2307,14 @@ function handleEditApplication(row: any) {
|
||||
} else {
|
||||
applicationForm.companions = [];
|
||||
}
|
||||
|
||||
|
||||
// 处理附件ID列表 - 从逗号分隔字符串解析为数组
|
||||
if (row.attachmentIds) {
|
||||
applicationForm.attachmentIds = row.attachmentIds.split(',').filter(id => id.trim());
|
||||
applicationForm.attachmentIds = row.attachmentIds.split(',').filter((id) => id.trim());
|
||||
} else {
|
||||
applicationForm.attachmentIds = [];
|
||||
}
|
||||
|
||||
|
||||
// 兼容原有字段
|
||||
applicationForm.courseName = row.courseName || '';
|
||||
applicationForm.duration = row.duration || 0;
|
||||
@@ -2328,7 +2322,7 @@ function handleEditApplication(row: any) {
|
||||
|
||||
// 保存当前编辑的申请ID
|
||||
applicationForm.applicationId = row.applicationId;
|
||||
|
||||
|
||||
// 加载同行人数据到选择器
|
||||
loadCompanionsForEdit();
|
||||
}
|
||||
@@ -2376,7 +2370,7 @@ async function handleUpdateAndResubmitApplication(row: any) {
|
||||
applicationForm.trainingFee = data.trainingFee || 0;
|
||||
applicationForm.trainingPurpose = data.trainingPurpose || data.reason || '';
|
||||
applicationForm.remark = data.remark;
|
||||
|
||||
|
||||
// 兼容原有字段
|
||||
applicationForm.courseName = data.courseName || '';
|
||||
applicationForm.duration = data.duration || 0;
|
||||
@@ -2415,7 +2409,7 @@ function handleResubmitApplication(row: any) {
|
||||
applicationForm.location = row.location;
|
||||
applicationForm.startTime = row.startTime;
|
||||
applicationForm.endTime = row.endTime;
|
||||
|
||||
|
||||
// 处理培训类型和其他类型描述
|
||||
const trainingType = row.trainingType || '';
|
||||
const predefinedTypes = ['教学', '德育', '行政', '管理', '其他'];
|
||||
@@ -2427,11 +2421,11 @@ function handleResubmitApplication(row: any) {
|
||||
applicationForm.trainingType = '其他';
|
||||
applicationForm.trainingTypeOther = trainingType;
|
||||
}
|
||||
|
||||
|
||||
applicationForm.trainingFee = row.trainingFee || 0;
|
||||
applicationForm.trainingPurpose = row.trainingPurpose || row.reason || '';
|
||||
applicationForm.remark = row.remark;
|
||||
|
||||
|
||||
// 兼容原有字段
|
||||
applicationForm.courseName = row.courseName || '';
|
||||
applicationForm.duration = row.duration || 0;
|
||||
@@ -2650,7 +2644,7 @@ function getRecordList() {
|
||||
recordList.value = response.rows;
|
||||
recordTotal.value = response.total;
|
||||
recordLoading.value = false;
|
||||
|
||||
|
||||
// 确保教师列表已加载(用于同行人显示)
|
||||
if (teacherList.value.length === 0) {
|
||||
loadTeacherListForDisplay();
|
||||
@@ -2917,45 +2911,45 @@ async function handleViewRecord(row: RecordVO) {
|
||||
try {
|
||||
const applicationResponse = await getTrainingApplication(row.applicationId);
|
||||
const applicationData = applicationResponse.data;
|
||||
|
||||
// 合并申请数据中的详细信息到记录详情
|
||||
Object.assign(recordDetail, {
|
||||
// 保留记录的核心信息
|
||||
recordId: row.recordId,
|
||||
completionStatus: row.completionStatus,
|
||||
completionTime: row.completionTime,
|
||||
certificatePath: row.certificatePath,
|
||||
certificateNumber: row.certificateNumber,
|
||||
feedback: row.feedback,
|
||||
|
||||
// 从申请数据中获取详细信息
|
||||
department: applicationData.department || row.department,
|
||||
currentTitle: applicationData.currentTitle,
|
||||
currentPosition: applicationData.currentPosition,
|
||||
workStartTime: applicationData.workStartTime,
|
||||
phone: applicationData.phone,
|
||||
organizerUnit: applicationData.organizerUnit,
|
||||
trainingType: applicationData.trainingType,
|
||||
trainingFee: applicationData.trainingFee,
|
||||
companions: applicationData.companions,
|
||||
trainingPurpose: applicationData.trainingPurpose || applicationData.reason,
|
||||
location: applicationData.location || row.location,
|
||||
startTime: applicationData.startTime,
|
||||
endTime: applicationData.endTime,
|
||||
applyTime: applicationData.applyTime,
|
||||
|
||||
// 其他基本信息
|
||||
courseName: applicationData.courseName || recordDetail.courseName,
|
||||
userName: applicationData.userName || row.userName,
|
||||
duration: applicationData.duration || row.duration,
|
||||
remark: row.remark
|
||||
});
|
||||
|
||||
// 加载申请附件数据
|
||||
if (applicationData.attachmentIds) {
|
||||
await handleApplicationDetailAttachmentData(applicationData.attachmentIds);
|
||||
recordDetailAttachmentList.value = [...applicationDetailAttachmentList.value];
|
||||
}
|
||||
// 合并申请数据中的详细信息到记录详情
|
||||
Object.assign(recordDetail, {
|
||||
// 保留记录的核心信息
|
||||
recordId: row.recordId,
|
||||
completionStatus: row.completionStatus,
|
||||
completionTime: row.completionTime,
|
||||
certificatePath: row.certificatePath,
|
||||
certificateNumber: row.certificateNumber,
|
||||
feedback: row.feedback,
|
||||
|
||||
// 从申请数据中获取详细信息
|
||||
department: applicationData.department || row.department,
|
||||
currentTitle: applicationData.currentTitle,
|
||||
currentPosition: applicationData.currentPosition,
|
||||
workStartTime: applicationData.workStartTime,
|
||||
phone: applicationData.phone,
|
||||
organizerUnit: applicationData.organizerUnit,
|
||||
trainingType: applicationData.trainingType,
|
||||
trainingFee: applicationData.trainingFee,
|
||||
companions: applicationData.companions,
|
||||
trainingPurpose: applicationData.trainingPurpose || applicationData.reason,
|
||||
location: applicationData.location || row.location,
|
||||
startTime: applicationData.startTime,
|
||||
endTime: applicationData.endTime,
|
||||
applyTime: applicationData.applyTime,
|
||||
|
||||
// 其他基本信息
|
||||
courseName: applicationData.courseName || recordDetail.courseName,
|
||||
userName: applicationData.userName || row.userName,
|
||||
duration: applicationData.duration || row.duration,
|
||||
remark: row.remark
|
||||
});
|
||||
|
||||
// 加载申请附件数据
|
||||
if (applicationData.attachmentIds) {
|
||||
await handleApplicationDetailAttachmentData(applicationData.attachmentIds);
|
||||
recordDetailAttachmentList.value = [...applicationDetailAttachmentList.value];
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn('获取申请详情失败,使用记录基本信息:', error);
|
||||
// 如果获取申请详情失败,继续使用记录的基本信息
|
||||
@@ -3860,14 +3854,14 @@ function beforeApplicationAttachmentUpload(file: File) {
|
||||
type: file.type,
|
||||
size: `${(file.size / 1024 / 1024).toFixed(2)}MB`
|
||||
});
|
||||
|
||||
|
||||
const isValidType = [
|
||||
'application/pdf',
|
||||
'application/msword',
|
||||
'application/pdf',
|
||||
'application/msword',
|
||||
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
||||
'application/vnd.ms-excel',
|
||||
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||
'image/jpeg',
|
||||
'image/jpeg',
|
||||
'image/png'
|
||||
].includes(file.type);
|
||||
const isLt20M = file.size / 1024 / 1024 < 20;
|
||||
@@ -3892,7 +3886,7 @@ function beforeApplicationAttachmentUpload(file: File) {
|
||||
function handleApplicationAttachmentSuccess(response: any, file: any) {
|
||||
console.log('[申请培训附件上传成功] 响应数据:', response);
|
||||
console.log('[申请培训附件上传成功] 文件对象:', file);
|
||||
|
||||
|
||||
if (response.code === 200 && response.data) {
|
||||
file.url = response.data.url;
|
||||
file.ossId = response.data.ossId;
|
||||
@@ -3913,7 +3907,7 @@ function handleApplicationAttachmentSuccess(response: any, file: any) {
|
||||
function handleApplicationAttachmentError(error: any, file: any) {
|
||||
console.error('[申请培训附件上传失败] 错误对象:', error);
|
||||
console.error('[申请培训附件上传失败] 文件对象:', file);
|
||||
|
||||
|
||||
let errorMessage = '附件上传失败,请重试!';
|
||||
let errorDetails = '';
|
||||
|
||||
@@ -3924,7 +3918,7 @@ function handleApplicationAttachmentError(error: any, file: any) {
|
||||
statusText: error.response.statusText,
|
||||
data: error.response.data
|
||||
});
|
||||
|
||||
|
||||
if (error.response.data) {
|
||||
if (error.response.data.msg) {
|
||||
errorMessage = error.response.data.msg;
|
||||
@@ -3932,7 +3926,7 @@ function handleApplicationAttachmentError(error: any, file: any) {
|
||||
errorMessage = error.response.data.message;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 常见错误状态码处理
|
||||
if (error.response.status === 401) {
|
||||
errorDetails = '认证失败,请重新登录';
|
||||
@@ -3958,11 +3952,9 @@ function handleApplicationAttachmentError(error: any, file: any) {
|
||||
function updateApplicationFormAttachmentIds() {
|
||||
console.log('[更新附件IDs] 开始更新');
|
||||
console.log('[更新附件IDs] 文件列表:', applicationAttachmentFileList.value);
|
||||
|
||||
|
||||
// 提取所有成功上传的ossId
|
||||
const attachmentOssIds = applicationAttachmentFileList.value
|
||||
.filter((file) => file.status === 'success' && file.ossId)
|
||||
.map((file) => file.ossId);
|
||||
const attachmentOssIds = applicationAttachmentFileList.value.filter((file) => file.status === 'success' && file.ossId).map((file) => file.ossId);
|
||||
|
||||
// 更新applicationForm
|
||||
applicationForm.attachmentIds = attachmentOssIds;
|
||||
@@ -3979,9 +3971,10 @@ function handleRemoveApplicationAttachment(file: any) {
|
||||
|
||||
/** 确认移除申请培训附件 */
|
||||
function confirmRemoveApplicationAttachment(file: any) {
|
||||
proxy?.$modal.confirm('确定要删除这个附件吗?')
|
||||
proxy?.$modal
|
||||
.confirm('确定要删除这个附件吗?')
|
||||
.then(() => {
|
||||
const index = applicationAttachmentFileList.value.findIndex(f => f.uid === file.uid);
|
||||
const index = applicationAttachmentFileList.value.findIndex((f) => f.uid === file.uid);
|
||||
if (index > -1) {
|
||||
applicationAttachmentFileList.value.splice(index, 1);
|
||||
updateApplicationFormAttachmentIds();
|
||||
@@ -4004,7 +3997,7 @@ function handlePreviewApplicationAttachment(file: any) {
|
||||
async function handleDownloadApplicationAttachment(file: any) {
|
||||
console.log('[下载申请培训附件] 开始下载');
|
||||
console.log('[下载申请培训附件] 文件信息:', file);
|
||||
|
||||
|
||||
if (!file.ossId) {
|
||||
console.error('[下载申请培训附件] ossId为空,无法下载');
|
||||
proxy?.$modal.msgError('文件信息不完整,无法下载');
|
||||
@@ -4013,7 +4006,7 @@ async function handleDownloadApplicationAttachment(file: any) {
|
||||
|
||||
try {
|
||||
console.log('[下载申请培训附件] 请求下载接口:', `/resource/oss/download/${file.ossId}`);
|
||||
|
||||
|
||||
// 使用后端安全下载接口,通过request工具发送请求以包含认证头
|
||||
const response = await request({
|
||||
url: `/resource/oss/download/${file.ossId}`,
|
||||
@@ -4026,32 +4019,31 @@ async function handleDownloadApplicationAttachment(file: any) {
|
||||
// 创建blob URL并触发下载
|
||||
const blob = response instanceof Blob ? response : new Blob([response.data]);
|
||||
const url = window.URL.createObjectURL(blob);
|
||||
|
||||
|
||||
const link = document.createElement('a');
|
||||
link.href = url;
|
||||
link.download = file.name || '申请培训附件';
|
||||
|
||||
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
|
||||
|
||||
// 清理资源
|
||||
document.body.removeChild(link);
|
||||
window.URL.revokeObjectURL(url);
|
||||
|
||||
|
||||
console.log('[下载申请培训附件] 下载成功');
|
||||
proxy?.$modal.msgSuccess('文件下载成功');
|
||||
|
||||
} catch (error: any) {
|
||||
console.error('[下载申请培训附件] 下载失败:', error);
|
||||
|
||||
|
||||
let errorMessage = '下载附件失败,请稍后重试';
|
||||
|
||||
|
||||
if (error.response) {
|
||||
console.error('[下载申请培训附件] HTTP响应错误:', {
|
||||
status: error.response.status,
|
||||
statusText: error.response.statusText
|
||||
});
|
||||
|
||||
|
||||
if (error.response.status === 401) {
|
||||
errorMessage = '认证失败,请重新登录';
|
||||
} else if (error.response.status === 403) {
|
||||
@@ -4060,11 +4052,10 @@ async function handleDownloadApplicationAttachment(file: any) {
|
||||
errorMessage = '文件不存在或已被删除';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
proxy?.$modal.msgError(errorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
@@ -4091,70 +4082,68 @@ async function handleDownloadApplicationAttachment(file: any) {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.attachment-upload-container .attachment-upload-demo .el-upload {
|
||||
width: 100%;
|
||||
height: auto;
|
||||
background-color: transparent !important;
|
||||
border: none !important;
|
||||
}
|
||||
.attachment-upload-container .attachment-upload-demo .el-upload {
|
||||
width: 100%;
|
||||
height: auto;
|
||||
background-color: transparent !important;
|
||||
border: none !important;
|
||||
}
|
||||
|
||||
.attachment-upload-container .attachment-upload-demo .el-upload:hover {
|
||||
background-color: transparent !important;
|
||||
}
|
||||
.attachment-upload-container .attachment-upload-demo .el-upload:hover {
|
||||
background-color: transparent !important;
|
||||
}
|
||||
|
||||
.attachment-upload-container .el-upload-dragger {
|
||||
background-color: transparent !important;
|
||||
border: none !important;
|
||||
width: 100% !important;
|
||||
height: auto !important;
|
||||
padding: 0 !important;
|
||||
margin: 0 !important;
|
||||
}
|
||||
.attachment-upload-container .el-upload-dragger {
|
||||
background-color: transparent !important;
|
||||
border: none !important;
|
||||
width: 100% !important;
|
||||
height: auto !important;
|
||||
padding: 0 !important;
|
||||
margin: 0 !important;
|
||||
}
|
||||
|
||||
.attachment-upload-container .el-upload-dragger:hover {
|
||||
background-color: transparent !important;
|
||||
border: none !important;
|
||||
}
|
||||
.attachment-upload-container .el-upload-dragger:hover {
|
||||
background-color: transparent !important;
|
||||
border: none !important;
|
||||
}
|
||||
|
||||
.attachment-upload-container:hover {
|
||||
border-color: #409eff;
|
||||
}
|
||||
|
||||
.el-upload-dragger-attachment {
|
||||
padding: 0 !important;
|
||||
margin: 0 !important;
|
||||
text-align: center;
|
||||
background-color: transparent;
|
||||
border: none;
|
||||
min-height: 80px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 4px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.el-upload-dragger-attachment {
|
||||
padding: 0 !important;
|
||||
margin: 0 !important;
|
||||
text-align: center;
|
||||
background-color: transparent;
|
||||
border: none;
|
||||
min-height: 80px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 4px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.el-upload-dragger-attachment .el-icon--upload {
|
||||
font-size: 24px;
|
||||
color: #c0c4cc;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.el-upload-dragger-attachment .el-upload__text {
|
||||
color: #666666;
|
||||
font-size: 12px;
|
||||
line-height: 1.3;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.el-upload-dragger-attachment .el-upload__text em {
|
||||
color: #409eff;
|
||||
font-style: normal;
|
||||
font-weight: 500;
|
||||
}
|
||||
.el-upload-dragger-attachment .el-icon--upload {
|
||||
font-size: 24px;
|
||||
color: #c0c4cc;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.el-upload-dragger-attachment .el-upload__text {
|
||||
color: #666666;
|
||||
font-size: 12px;
|
||||
line-height: 1.3;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.el-upload-dragger-attachment .el-upload__text em {
|
||||
color: #409eff;
|
||||
font-style: normal;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.el-upload-dragger-attachment .el-upload__tip {
|
||||
font-size: 11px !important;
|
||||
|
||||
Reference in new issue
Block a user