“人事修复更新weiz”
This commit is contained in:
1 parent
6bffe5fa08
commit
138b3e4d1f
18 files changed
+542
-330
No files matched your search
@@ -56,6 +56,7 @@ export interface ApplicationQuery {
|
||||
userName?: string;
|
||||
department?: string;
|
||||
status?: string;
|
||||
excludeStatus?: string; // 排除指定状态的数据
|
||||
params?: Record<string, any>;
|
||||
}
|
||||
|
||||
@@ -110,6 +111,7 @@ export interface RecordQuery {
|
||||
location?: string;
|
||||
department?: string;
|
||||
completionStatus?: string;
|
||||
includeApprovedApplications?: boolean; // 是否包含已通过审批的申请数据
|
||||
params?: Record<string, any>;
|
||||
}
|
||||
|
||||
@@ -158,66 +160,11 @@ export interface RecordForm {
|
||||
remark?: string;
|
||||
}
|
||||
|
||||
// 查询培训课程列表
|
||||
export function listTrainingCourse(query: CourseQuery) {
|
||||
return request({
|
||||
url: '/rs/training/course/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
});
|
||||
}
|
||||
|
||||
// 获取培训课程详情
|
||||
export function getTrainingCourse(courseId: string | number) {
|
||||
return request({
|
||||
url: `/rs/training/course/${courseId}`,
|
||||
method: 'get'
|
||||
});
|
||||
}
|
||||
|
||||
// 新增培训课程
|
||||
export function addTrainingCourse(data: CourseForm) {
|
||||
return request({
|
||||
url: '/rs/training/course',
|
||||
method: 'post',
|
||||
data: data
|
||||
});
|
||||
}
|
||||
|
||||
// 修改培训课程
|
||||
export function updateTrainingCourse(data: CourseForm) {
|
||||
return request({
|
||||
url: '/rs/training/course',
|
||||
method: 'put',
|
||||
data: data
|
||||
});
|
||||
}
|
||||
|
||||
// 删除培训课程
|
||||
export function delTrainingCourse(courseId: string | number | Array<string | number>) {
|
||||
return request({
|
||||
url: `/rs/training/course/${typeof courseId === 'object' ? courseId.join(',') : courseId}`,
|
||||
method: 'delete'
|
||||
});
|
||||
}
|
||||
|
||||
// 切换培训课程状态
|
||||
export function toggleCourseStatus(courseId: string | number) {
|
||||
return request({
|
||||
url: `/rs/training/course/toggle/${courseId}`,
|
||||
method: 'put'
|
||||
});
|
||||
}
|
||||
|
||||
// 导出培训课程
|
||||
export function exportTrainingCourse(query: CourseQuery) {
|
||||
return request({
|
||||
url: '/rs/training/course/export',
|
||||
method: 'get',
|
||||
params: query,
|
||||
responseType: 'blob'
|
||||
});
|
||||
}
|
||||
// ============================================
|
||||
// 注意:培训课程模块已废弃 (2025-01-03)
|
||||
// 课程信息现在直接存储在 rs_training_application 表中
|
||||
// 以下培训课程相关接口已移除,请使用培训申请相关接口
|
||||
// ============================================
|
||||
|
||||
// 查询培训申请列表
|
||||
export function listTrainingApplication(query: ApplicationQuery) {
|
||||
@@ -356,13 +303,10 @@ export function exportTrainingRecord(query: RecordQuery) {
|
||||
});
|
||||
}
|
||||
|
||||
// 提交培训申请(无需权限验证,供普通用户使用)
|
||||
// 提交培训申请(需要权限验证)
|
||||
export function submitTrainingApplication(data: ApplicationForm) {
|
||||
return request({
|
||||
url: '/rs/training/application/submit',
|
||||
headers: {
|
||||
isToken: false
|
||||
},
|
||||
method: 'post',
|
||||
data: data
|
||||
});
|
||||
|
||||
@@ -230,7 +230,7 @@
|
||||
<el-button icon="Download" @click="handleExportApplications" v-hasPermi="['rs:application:export']" style="display: none">导出</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button icon="Printer" @click="handlePrintApplications">打印</el-button>
|
||||
<el-button icon="Printer" @click="handlePrintApplications" style="display: none">打印</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button icon="Document" :disabled="applicationIds.length !== 1" @click="handleExportResume">导出简历</el-button>
|
||||
|
||||
@@ -83,9 +83,9 @@
|
||||
</template>
|
||||
|
||||
<!-- 待审批申请表格 -->
|
||||
<el-table v-loading="pendingLoading" border :data="pendingList" @row-dblclick="handleViewApplication">
|
||||
<el-table-column label="申请人" align="center" prop="applicantName" width="100" :show-overflow-tooltip="true" />
|
||||
<el-table-column label="所属部门" align="center" prop="department" width="140" :show-overflow-tooltip="true" />
|
||||
<el-table v-loading="pendingLoading" border :data="pendingList" @row-dblclick="handleViewApplication" v-hasPermi="['rs:overseas:list']">
|
||||
<el-table-column label="申请人" align="center" prop="applicantName" width="100" :show-overflow-tooltip="true" />
|
||||
<el-table-column label="所属部门" align="center" prop="department" width="140" :show-overflow-tooltip="true" />
|
||||
<el-table-column label="出国目的" align="center" prop="purposeText" width="100" :show-overflow-tooltip="true" />
|
||||
<el-table-column label="目的地" align="center" prop="destination" width="120" :show-overflow-tooltip="true" />
|
||||
<el-table-column label="出国时间" align="center" min-width="220" :show-overflow-tooltip="true">
|
||||
@@ -226,9 +226,9 @@
|
||||
</template>
|
||||
|
||||
<!-- 审批记录表格 -->
|
||||
<el-table v-loading="recordLoading" border :data="recordList" @row-dblclick="handleViewRecord">
|
||||
<el-table-column label="申请人" align="center" prop="applicantName" width="100" :show-overflow-tooltip="true" />
|
||||
<el-table-column label="所属部门" align="center" prop="department" width="140" :show-overflow-tooltip="true" />
|
||||
<el-table v-loading="recordLoading" border :data="recordList" @row-dblclick="handleViewRecord" v-hasPermi="['rs:overseas:list']">
|
||||
<el-table-column label="申请人" align="center" prop="applicantName" width="100" :show-overflow-tooltip="true" />
|
||||
<el-table-column label="所属部门" align="center" prop="department" width="140" :show-overflow-tooltip="true" />
|
||||
<el-table-column label="出国目的" align="center" prop="purposeText" width="100" :show-overflow-tooltip="true" />
|
||||
<el-table-column label="目的地" align="center" prop="destination" width="120" :show-overflow-tooltip="true" />
|
||||
<el-table-column label="出国时间" align="center" min-width="220" :show-overflow-tooltip="true">
|
||||
|
||||
@@ -328,7 +328,12 @@
|
||||
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button type="primary" :loading="state.submitLoading" @click="submitApplicationForm">确 定</el-button>
|
||||
<el-button
|
||||
type="primary"
|
||||
:loading="state.submitLoading"
|
||||
@click="submitApplicationForm"
|
||||
v-hasPermi="state.applicationForm.applicationId ? ['rs:overseas:edit'] : ['rs:overseas:add', 'rs:overseas:submit']"
|
||||
>确 定</el-button>
|
||||
<el-button @click="cancelApplicationForm">取 消</el-button>
|
||||
</div>
|
||||
</template>
|
||||
@@ -470,6 +475,7 @@ import {
|
||||
import { ElMessage, ElMessageBox } from 'element-plus';
|
||||
import animate from '@/animate';
|
||||
import { parseTime } from '@/utils/ruoyi';
|
||||
import { checkPermi } from '@/utils/permission';
|
||||
|
||||
// 响应式数据
|
||||
const { proxy } = getCurrentInstance() as any;
|
||||
@@ -759,6 +765,12 @@ const handleViewApplication = async (row: OverseasApplicationVO) => {
|
||||
|
||||
// 提交申请
|
||||
const handleSubmitApplication = (row: OverseasApplicationVO) => {
|
||||
// 权限检查
|
||||
if (!checkPermi(['rs:overseas:submit'])) {
|
||||
ElMessage.error('您没有提交权限');
|
||||
return;
|
||||
}
|
||||
|
||||
ElMessageBox.confirm(`确认重新提交申请"${row.applicationId}"?`, '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
@@ -965,6 +977,30 @@ const resetApplicationForm = () => {
|
||||
const submitApplicationForm = () => {
|
||||
applicationFormRef.value?.validate(async (valid: boolean) => {
|
||||
if (valid) {
|
||||
// 权限检查
|
||||
if (state.applicationForm.applicationId) {
|
||||
// 编辑模式:检查编辑权限
|
||||
if (!checkPermi(['rs:overseas:edit'])) {
|
||||
ElMessage.error('您没有编辑权限');
|
||||
return;
|
||||
}
|
||||
// 重新提交模式:额外检查提交权限
|
||||
if (state.isResubmitMode && !checkPermi(['rs:overseas:submit'])) {
|
||||
ElMessage.error('您没有提交权限');
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// 新增模式:检查新增和提交权限
|
||||
if (!checkPermi(['rs:overseas:add'])) {
|
||||
ElMessage.error('您没有新增权限');
|
||||
return;
|
||||
}
|
||||
if (!checkPermi(['rs:overseas:submit'])) {
|
||||
ElMessage.error('您没有提交权限');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
state.submitLoading = true;
|
||||
try {
|
||||
if (state.applicationForm.applicationId) {
|
||||
|
||||
@@ -80,6 +80,7 @@
|
||||
style="width: 100%"
|
||||
class="overseas-approval-table"
|
||||
empty-text="暂无数据"
|
||||
v-hasPermi="['rs:overseas:list']"
|
||||
>
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="申请人" align="center" prop="applicantName" width="100" show-overflow-tooltip />
|
||||
@@ -202,6 +203,7 @@
|
||||
@row-dblclick="handleViewRecord"
|
||||
style="width: 100%"
|
||||
empty-text="暂无数据"
|
||||
v-hasPermi="['rs:overseas:list']"
|
||||
>
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="申请人" align="center" prop="applicantName" width="100" show-overflow-tooltip />
|
||||
|
||||
+133
-130
@@ -3,7 +3,7 @@
|
||||
<el-card class="box-card">
|
||||
<!-- 培训申请子选项卡 -->
|
||||
<el-tabs v-model="trainingSubTab" @tab-click="handleTrainingSubTabClick">
|
||||
<el-tab-pane label="培训申请" name="application">
|
||||
<el-tab-pane label="培训申请" name="application" v-hasPermi="['rs:trainingapplication:list']">
|
||||
<!-- 搜索区域 -->
|
||||
<transition :enter-active-class="animate.searchAnimate.enter" :leave-active-class="animate.searchAnimate.leave">
|
||||
<div v-show="showApplicationSearch" class="mb-[10px]">
|
||||
@@ -148,7 +148,7 @@
|
||||
</el-card>
|
||||
</el-tab-pane>
|
||||
|
||||
<el-tab-pane label="培训记录" name="record">
|
||||
<el-tab-pane label="培训记录" name="record" v-hasPermi="['rs:trainingrecord:list']">
|
||||
<!-- 搜索区域 -->
|
||||
<transition :enter-active-class="animate.searchAnimate.enter" :leave-active-class="animate.searchAnimate.leave">
|
||||
<div v-show="showRecordSearch" class="mb-[10px]">
|
||||
@@ -190,7 +190,7 @@
|
||||
<template #header>
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button icon="Download" @click="handleExportRecord" v-hasPermi="['rs:training:record:export']" style="display: none">导出</el-button>
|
||||
<el-button icon="Download" @click="handleExportRecord" v-hasPermi="['rs:trainingrecord:export']" style="display: none">导出</el-button>
|
||||
</el-col>
|
||||
<right-toolbar v-model:showSearch="showRecordSearch" @queryTable="getRecordList"></right-toolbar>
|
||||
</el-row>
|
||||
@@ -227,7 +227,7 @@
|
||||
<el-table-column label="操作" align="center" width="200">
|
||||
<template #default="scope">
|
||||
<el-tooltip content="查看" placement="top">
|
||||
<el-button link type="primary" icon="View" @click.stop="handleViewRecord(scope.row)"></el-button>
|
||||
<el-button link type="primary" icon="View" @click.stop="handleViewRecord(scope.row)" v-hasPermi="['rs:trainingrecord:query']"></el-button>
|
||||
</el-tooltip>
|
||||
<el-tooltip content="编辑" placement="top">
|
||||
<el-button
|
||||
@@ -235,7 +235,7 @@
|
||||
type="primary"
|
||||
icon="Edit"
|
||||
@click.stop="handleUpdateRecord(scope.row)"
|
||||
v-hasPermi="['rs:training:record:edit']"
|
||||
v-hasPermi="['rs:trainingrecord:edit']"
|
||||
></el-button>
|
||||
</el-tooltip>
|
||||
<el-tooltip content="删除" placement="top">
|
||||
@@ -244,7 +244,7 @@
|
||||
type="danger"
|
||||
icon="Delete"
|
||||
@click.stop="handleDeleteRecord(scope.row)"
|
||||
v-hasPermi="['rs:training:record:remove']"
|
||||
v-hasPermi="['rs:trainingrecord:remove']"
|
||||
></el-button>
|
||||
</el-tooltip>
|
||||
</template>
|
||||
@@ -448,6 +448,14 @@
|
||||
<el-form-item label="学时" prop="duration">
|
||||
<el-input-number v-model="applicationForm.duration" :min="0" :max="1000" :step="0.5" style="width: 200px" />
|
||||
</el-form-item>
|
||||
<el-form-item label="申请人" prop="userName">
|
||||
<el-input
|
||||
v-model="applicationForm.userName"
|
||||
placeholder="申请人姓名"
|
||||
readonly
|
||||
class="readonly-input"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="所属部门" prop="department">
|
||||
<el-input
|
||||
v-model="applicationForm.department"
|
||||
@@ -744,13 +752,8 @@ import {
|
||||
} from '@element-plus/icons-vue';
|
||||
import ImagePreview from '@/components/ImagePreview/index.vue';
|
||||
import {
|
||||
listTrainingCourse,
|
||||
getTrainingCourse,
|
||||
addTrainingCourse,
|
||||
updateTrainingCourse,
|
||||
delTrainingCourse,
|
||||
toggleCourseStatus,
|
||||
exportTrainingCourse,
|
||||
// 培训课程相关接口已废弃 (2025-01-03)
|
||||
// listTrainingCourse, getTrainingCourse, addTrainingCourse, updateTrainingCourse, delTrainingCourse, toggleCourseStatus, exportTrainingCourse,
|
||||
listTrainingApplication,
|
||||
getTrainingApplication,
|
||||
addTrainingApplication,
|
||||
@@ -945,6 +948,7 @@ const applicationQueryParams = reactive({
|
||||
location: '',
|
||||
duration: undefined as number | undefined,
|
||||
status: '',
|
||||
excludeStatus: '1', // 默认排除已通过状态的数据
|
||||
params: {}
|
||||
});
|
||||
|
||||
@@ -992,6 +996,7 @@ const showRecordSearch = ref(true);
|
||||
userName: '',
|
||||
department: '',
|
||||
completionStatus: '',
|
||||
includeApprovedApplications: true, // 包含已通过审批的申请数据
|
||||
params: {}
|
||||
});
|
||||
|
||||
@@ -1073,6 +1078,7 @@ const applicationFormRef = ref<any>(null);
|
||||
const applicationForm = reactive<{
|
||||
applicationId?: number | string;
|
||||
courseName: string;
|
||||
userName: string; // 申请人姓名
|
||||
department: string;
|
||||
location: string;
|
||||
duration: number;
|
||||
@@ -1083,6 +1089,7 @@ const applicationForm = reactive<{
|
||||
}>({
|
||||
applicationId: undefined,
|
||||
courseName: '',
|
||||
userName: '', // 申请人姓名
|
||||
department: '',
|
||||
location: '',
|
||||
duration: 0,
|
||||
@@ -1106,14 +1113,14 @@ const applicationRules = reactive({
|
||||
// 部门选项 - 从数据库sys_dept表获取
|
||||
const departmentOptions = ref<Array<{ value: string; label: string }>>([]);
|
||||
|
||||
/** 查询培训课程列表 */
|
||||
/** 查询培训课程列表 - 已废弃 (2025-01-03) */
|
||||
function getTrainingList() {
|
||||
trainingLoading.value = true;
|
||||
listTrainingCourse(trainingQueryParams).then((response) => {
|
||||
courseList.value = response.rows;
|
||||
trainingTotal.value = response.total;
|
||||
trainingLoading.value = false;
|
||||
});
|
||||
// 培训课程模块已废弃,课程信息现在通过培训申请管理
|
||||
console.warn('培训课程模块已废弃,请使用培训申请功能');
|
||||
courseList.value = [];
|
||||
trainingTotal.value = 0;
|
||||
trainingLoading.value = false;
|
||||
}
|
||||
|
||||
/** 获取部门列表 */
|
||||
@@ -1199,11 +1206,9 @@ function handleUpdateCourse(row?: CourseVO) {
|
||||
return;
|
||||
}
|
||||
|
||||
getTrainingCourse(courseId).then((response) => {
|
||||
Object.assign(courseForm, response.data);
|
||||
courseDialogVisible.value = true;
|
||||
courseDialogTitle.value = '修改培训课程';
|
||||
});
|
||||
// 培训课程模块已废弃 (2025-01-03)
|
||||
console.warn('培训课程编辑功能已废弃,请使用培训申请功能');
|
||||
proxy?.$modal.msgWarning('培训课程模块已废弃,请使用培训申请功能');
|
||||
}
|
||||
|
||||
/** 提交按钮 */
|
||||
@@ -1211,27 +1216,10 @@ function submitCourseForm() {
|
||||
courseFormRef.value?.validate((valid: boolean) => {
|
||||
if (valid) {
|
||||
courseDialogLoading.value = true;
|
||||
if (courseForm.courseId) {
|
||||
updateTrainingCourse(courseForm)
|
||||
.then(() => {
|
||||
proxy?.$modal.msgSuccess('修改成功');
|
||||
courseDialogVisible.value = false;
|
||||
getTrainingList();
|
||||
})
|
||||
.finally(() => {
|
||||
courseDialogLoading.value = false;
|
||||
});
|
||||
} else {
|
||||
addTrainingCourse(courseForm)
|
||||
.then(() => {
|
||||
proxy?.$modal.msgSuccess('新增成功');
|
||||
courseDialogVisible.value = false;
|
||||
getTrainingList();
|
||||
})
|
||||
.finally(() => {
|
||||
courseDialogLoading.value = false;
|
||||
});
|
||||
}
|
||||
// 培训课程模块已废弃 (2025-01-03)
|
||||
console.warn('培训课程新增/编辑功能已废弃,请使用培训申请功能');
|
||||
proxy?.$modal.msgWarning('培训课程模块已废弃,请使用培训申请功能');
|
||||
courseDialogLoading.value = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -1259,11 +1247,9 @@ function handleDeleteCourse(row?: CourseVO) {
|
||||
proxy?.$modal
|
||||
.confirm(confirmMessage)
|
||||
.then(() => {
|
||||
return delTrainingCourse(courseIds);
|
||||
})
|
||||
.then(() => {
|
||||
getTrainingList();
|
||||
proxy?.$modal.msgSuccess('删除成功');
|
||||
// 培训课程模块已废弃 (2025-01-03)
|
||||
console.warn('培训课程删除功能已废弃,请使用培训申请功能');
|
||||
proxy?.$modal.msgWarning('培训课程模块已废弃,请使用培训申请功能');
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1278,26 +1264,16 @@ function handleExportCourse() {
|
||||
);
|
||||
}
|
||||
|
||||
/** 查看培训课程详情 */
|
||||
/** 查看培训课程详情 - 已废弃 (2025-01-03) */
|
||||
function handleViewCourse(row: CourseVO) {
|
||||
getTrainingCourse(row.courseId).then((response) => {
|
||||
Object.assign(courseDetail, response.data);
|
||||
courseDetailDialogVisible.value = true;
|
||||
});
|
||||
console.warn('培训课程查看功能已废弃,请使用培训申请功能');
|
||||
proxy?.$modal.msgWarning('培训课程模块已废弃,请使用培训申请功能');
|
||||
}
|
||||
|
||||
/** 切换课程状态 */
|
||||
/** 切换课程状态 - 已废弃 (2025-01-03) */
|
||||
function handleToggleStatus(row: CourseVO) {
|
||||
const text = row.status === '0' ? '结束' : '启用';
|
||||
proxy?.$modal
|
||||
.confirm(`确认要${text}该课程吗?`)
|
||||
.then(() => {
|
||||
return toggleCourseStatus(row.courseId);
|
||||
})
|
||||
.then(() => {
|
||||
getTrainingList();
|
||||
proxy?.$modal.msgSuccess(`${text}成功`);
|
||||
});
|
||||
console.warn('培训课程状态切换功能已废弃,请使用培训申请功能');
|
||||
proxy?.$modal.msgWarning('培训课程模块已废弃,请使用培训申请功能');
|
||||
}
|
||||
|
||||
/** 查看培训申请记录 */
|
||||
@@ -1313,13 +1289,25 @@ function handleViewApplications(row: CourseVO) {
|
||||
/** 培训申请管理相关 */
|
||||
function getApplicationList() {
|
||||
applicationLoading.value = true;
|
||||
|
||||
// 构建查询参数,自动过滤掉已通过的数据
|
||||
const queryParams = {
|
||||
...applicationQueryParams,
|
||||
// 排除已通过状态的数据,只显示待审核、已拒绝、已取消等状态
|
||||
excludeStatus: '1' // 1表示已通过状态
|
||||
};
|
||||
|
||||
// 调用API获取申请列表
|
||||
listTrainingApplication(applicationQueryParams)
|
||||
listTrainingApplication(queryParams)
|
||||
.then((response) => {
|
||||
// 获取申请列表数据
|
||||
const applications = response.rows || [];
|
||||
applicationList.value = applications;
|
||||
applicationTotal.value = response.total || 0;
|
||||
|
||||
// 前端二次过滤,确保不显示已通过的数据
|
||||
const filteredApplications = applications.filter(app => app.status !== '1');
|
||||
|
||||
applicationList.value = filteredApplications;
|
||||
applicationTotal.value = filteredApplications.length;
|
||||
applicationLoading.value = false;
|
||||
})
|
||||
.catch(() => {
|
||||
@@ -1339,68 +1327,82 @@ async function handleAddApplication() {
|
||||
loadCourseOptions();
|
||||
}
|
||||
|
||||
// 自动获取登录用户的部门信息
|
||||
try {
|
||||
// 确保用户信息已加载
|
||||
if (!userStore.userId) {
|
||||
await userStore.getInfo();
|
||||
}
|
||||
|
||||
console.log('开始自动填充用户部门信息:', {
|
||||
userId: userStore.userId,
|
||||
cachedDeptName: userStore.deptName
|
||||
});
|
||||
|
||||
// 重新获取用户信息以确保获取到deptId
|
||||
await userStore.getInfo();
|
||||
const userInfo = await getUserInfo();
|
||||
const userDeptId = userInfo.data.user.deptId;
|
||||
|
||||
console.log('用户信息详情:', {
|
||||
userId: userStore.userId,
|
||||
deptId: userDeptId,
|
||||
cachedDeptName: userStore.deptName
|
||||
});
|
||||
|
||||
// 如果有deptId,从数据库sys_dept表实时获取部门名称
|
||||
if (userDeptId) {
|
||||
console.log('开始从数据库sys_dept表获取部门信息 - deptId:', userDeptId);
|
||||
// 自动获取登录用户的部门信息和申请人信息
|
||||
try {
|
||||
// 确保用户信息已加载
|
||||
if (!userStore.userId) {
|
||||
await userStore.getInfo();
|
||||
}
|
||||
|
||||
try {
|
||||
const deptResponse = await getDept(userDeptId);
|
||||
if (deptResponse.code === 200 && deptResponse.data) {
|
||||
const realDeptName = deptResponse.data.deptName;
|
||||
applicationForm.department = realDeptName;
|
||||
|
||||
console.log('培训申请部门自动匹配成功:', {
|
||||
userId: userStore.userId,
|
||||
userDeptId: userDeptId,
|
||||
deptNameFromDatabase: realDeptName,
|
||||
关联逻辑: 'sys_user.dept_id -> sys_dept.dept_name'
|
||||
});
|
||||
} else {
|
||||
console.warn('从数据库获取部门信息失败,使用缓存的部门名称');
|
||||
console.log('开始自动填充用户信息:', {
|
||||
userId: userStore.userId,
|
||||
userName: userStore.name,
|
||||
nickname: userStore.nickname,
|
||||
cachedDeptName: userStore.deptName
|
||||
});
|
||||
|
||||
// 自动填充申请人姓名(使用用户名称)
|
||||
const displayName = userStore.name || `用户${userStore.userId}`;
|
||||
applicationForm.userName = displayName;
|
||||
|
||||
console.log('申请人姓名自动填充:', {
|
||||
userId: userStore.userId,
|
||||
displayName: displayName,
|
||||
userName: userStore.name
|
||||
});
|
||||
|
||||
// 重新获取用户信息以确保获取到deptId
|
||||
await userStore.getInfo();
|
||||
const userInfo = await getUserInfo();
|
||||
const userDeptId = userInfo.data.user.deptId;
|
||||
|
||||
console.log('用户信息详情:', {
|
||||
userId: userStore.userId,
|
||||
deptId: userDeptId,
|
||||
cachedDeptName: userStore.deptName
|
||||
});
|
||||
|
||||
// 如果有deptId,从数据库sys_dept表实时获取部门名称
|
||||
if (userDeptId) {
|
||||
console.log('开始从数据库sys_dept表获取部门信息 - deptId:', userDeptId);
|
||||
|
||||
try {
|
||||
const deptResponse = await getDept(userDeptId);
|
||||
if (deptResponse.code === 200 && deptResponse.data) {
|
||||
const realDeptName = deptResponse.data.deptName;
|
||||
applicationForm.department = realDeptName;
|
||||
|
||||
console.log('培训申请部门自动匹配成功:', {
|
||||
userId: userStore.userId,
|
||||
userDeptId: userDeptId,
|
||||
deptNameFromDatabase: realDeptName,
|
||||
关联逻辑: 'sys_user.dept_id -> sys_dept.dept_name'
|
||||
});
|
||||
} else {
|
||||
console.warn('从数据库获取部门信息失败,使用缓存的部门名称');
|
||||
applicationForm.department = userStore.deptName || '';
|
||||
}
|
||||
} catch (deptError) {
|
||||
console.error('查询部门信息API调用失败:', deptError);
|
||||
applicationForm.department = userStore.deptName || '';
|
||||
}
|
||||
} catch (deptError) {
|
||||
console.error('查询部门信息API调用失败:', deptError);
|
||||
} else {
|
||||
console.warn('用户deptId不存在,使用缓存的部门名称');
|
||||
applicationForm.department = userStore.deptName || '';
|
||||
}
|
||||
} else {
|
||||
console.warn('用户deptId不存在,使用缓存的部门名称');
|
||||
applicationForm.department = userStore.deptName || '';
|
||||
} catch (error) {
|
||||
console.error('获取用户信息失败:', error);
|
||||
// 如果获取失败,使用空字符串,用户可以手动输入
|
||||
applicationForm.department = '';
|
||||
applicationForm.userName = `用户${userStore.userId || '未知'}`;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取用户信息失败:', error);
|
||||
// 如果获取失败,使用空字符串,用户可以手动输入
|
||||
applicationForm.department = '';
|
||||
}
|
||||
}
|
||||
|
||||
/** 重置培训申请表单 */
|
||||
function resetApplicationForm() {
|
||||
applicationForm.applicationId = undefined;
|
||||
applicationForm.courseName = '';
|
||||
applicationForm.userName = ''; // 重置申请人字段
|
||||
applicationForm.department = '';
|
||||
applicationForm.location = '';
|
||||
applicationForm.duration = 0;
|
||||
@@ -1778,16 +1780,12 @@ function handleTrainingSubTabClick() {
|
||||
}
|
||||
}
|
||||
|
||||
// 加载课程选项
|
||||
// 加载课程选项 - 已废弃 (2025-01-03)
|
||||
function loadCourseOptions() {
|
||||
return listTrainingCourse({ pageNum: 1, pageSize: 100, status: '0' }).then((response) => {
|
||||
courseOptions.value = response.rows || [];
|
||||
return courseOptions.value;
|
||||
}).catch((error) => {
|
||||
console.error('加载课程选项失败:', error);
|
||||
courseOptions.value = [];
|
||||
throw error;
|
||||
});
|
||||
// 培训课程模块已废弃,现在课程信息通过申请时的自定义课程名称管理
|
||||
console.warn('培训课程选项已废弃,现在使用自定义课程名称');
|
||||
courseOptions.value = [];
|
||||
return Promise.resolve([]);
|
||||
}
|
||||
|
||||
// 远程搜索用户
|
||||
@@ -1818,10 +1816,13 @@ function remoteSearchUser(query: string) {
|
||||
/** 获取培训记录列表 */
|
||||
function getRecordList() {
|
||||
recordLoading.value = true;
|
||||
// 设置当前用户ID,只查询当前用户的培训记录
|
||||
|
||||
// 构建查询参数,包含已通过审批的申请数据
|
||||
const queryParams = {
|
||||
...recordQueryParams,
|
||||
userId: userStore.userId // 设置当前用户ID
|
||||
userId: userStore.userId, // 设置当前用户ID
|
||||
// 确保包含已通过状态的培训申请数据
|
||||
includeApprovedApplications: true
|
||||
};
|
||||
|
||||
// 调用培训记录接口,获取培训记录数据
|
||||
@@ -2973,6 +2974,8 @@ function resetApplicationQuery() {
|
||||
applicationQueryParams.location = '';
|
||||
applicationQueryParams.duration = undefined;
|
||||
applicationQueryParams.status = '';
|
||||
// 保持排除已通过状态的设置
|
||||
applicationQueryParams.excludeStatus = '1';
|
||||
handleApplicationQuery();
|
||||
}
|
||||
|
||||
|
||||
@@ -175,7 +175,7 @@
|
||||
<template #header>
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button icon="Download" @click="handleExportApprovalRecord" v-hasPermi="['rs:trainingapproval:export']">导出</el-button>
|
||||
<el-button icon="Download" @click="handleExportApprovalRecord" v-hasPermi="['rs:trainingapproval:export']" style="display: none">导出</el-button>
|
||||
</el-col>
|
||||
<right-toolbar v-model:showSearch="showApprovalRecordSearch" @queryTable="getApprovalRecordList"></right-toolbar>
|
||||
</el-row>
|
||||
@@ -551,6 +551,7 @@ const applicationQueryParams = reactive({
|
||||
courseName: '',
|
||||
location: '',
|
||||
status: '',
|
||||
excludeStatus: '1', // 默认排除已通过状态的数据
|
||||
params: {}
|
||||
});
|
||||
|
||||
@@ -600,6 +601,7 @@ const approvalRecordQueryParams = reactive({
|
||||
courseName: '',
|
||||
userName: '',
|
||||
status: '',
|
||||
includeApprovedApplications: true, // 包含已通过审批的申请数据
|
||||
params: {}
|
||||
});
|
||||
|
||||
@@ -665,9 +667,20 @@ const getStatusLabel = (status: string) => {
|
||||
const getApplicationList = async () => {
|
||||
applicationLoading.value = true;
|
||||
try {
|
||||
const response = await listTrainingApplication(applicationQueryParams);
|
||||
applicationList.value = response.rows;
|
||||
applicationTotal.value = response.total;
|
||||
// 构建查询参数,自动过滤掉已通过的数据
|
||||
const queryParams = {
|
||||
...applicationQueryParams,
|
||||
// 排除已通过状态的数据,只显示待审核、已拒绝、已取消等状态
|
||||
excludeStatus: '1' // 1表示已通过状态
|
||||
};
|
||||
|
||||
const response = await listTrainingApplication(queryParams);
|
||||
|
||||
// 前端二次过滤,确保不显示已通过的数据
|
||||
const filteredApplications = response.rows.filter(app => app.status !== '1');
|
||||
|
||||
applicationList.value = filteredApplications;
|
||||
applicationTotal.value = filteredApplications.length;
|
||||
} catch (error) {
|
||||
console.error('获取申请列表失败:', error);
|
||||
} finally {
|
||||
@@ -689,6 +702,7 @@ const resetApplicationQuery = () => {
|
||||
courseName: '',
|
||||
location: '',
|
||||
status: '',
|
||||
excludeStatus: '1', // 保持排除已通过状态的设置
|
||||
params: {}
|
||||
});
|
||||
getApplicationList();
|
||||
@@ -780,7 +794,8 @@ const getApprovalRecordList = async () => {
|
||||
// 获取所有审批记录(不限于当前用户审批过的)
|
||||
const queryParams = {
|
||||
...approvalRecordQueryParams,
|
||||
status: approvalRecordQueryParams.status || '1,2' // 默认获取已通过和已拒绝的记录
|
||||
status: approvalRecordQueryParams.status || '1,2', // 默认获取已通过和已拒绝的记录
|
||||
includeApprovedApplications: true // 确保包含已通过状态的培训申请数据
|
||||
};
|
||||
const response = await listAllApprovalRecords(queryParams);
|
||||
approvalRecordList.value = response.rows;
|
||||
@@ -809,6 +824,7 @@ const resetApprovalRecordQuery = () => {
|
||||
courseName: '',
|
||||
userName: '',
|
||||
status: '',
|
||||
includeApprovedApplications: true, // 保持包含已通过审批的申请数据
|
||||
params: {}
|
||||
});
|
||||
getApprovalRecordList();
|
||||
@@ -858,7 +874,8 @@ const handleExportApprovalRecord = async () => {
|
||||
try {
|
||||
const queryParams = {
|
||||
...approvalRecordQueryParams,
|
||||
status: approvalRecordQueryParams.status || '1,2' // 默认导出已通过和已拒绝的记录
|
||||
status: approvalRecordQueryParams.status || '1,2', // 默认导出已通过和已拒绝的记录
|
||||
includeApprovedApplications: true // 确保包含已通过状态的培训申请数据
|
||||
};
|
||||
const response = await exportApprovalRecord(queryParams);
|
||||
|
||||
|
||||
Reference in new issue
Block a user