123
This commit is contained in:
1 parent
225a268e32
commit
b49b6f8ec2
45 files changed
+11407
-13
No files matched your search
@@ -0,0 +1,191 @@
|
||||
import request from '@/utils/request';
|
||||
import {
|
||||
XljkEvaluationVO,
|
||||
XljkEvaluationForm,
|
||||
XljkEvaluationQuery,
|
||||
XljkEvaluationDetailVO,
|
||||
XljkEvaluationDetailForm,
|
||||
XljkEvaluationDetailQuery,
|
||||
CollegeOption,
|
||||
MajorOption,
|
||||
ClassOption,
|
||||
StudentInfo
|
||||
} from './types';
|
||||
|
||||
// 查询心理健康测评列表
|
||||
export const listEvaluation = (query: XljkEvaluationQuery) => {
|
||||
return request({
|
||||
url: '/xljk/evaluation/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
});
|
||||
};
|
||||
|
||||
// 查询心理健康测评详细信息
|
||||
export const getEvaluation = (id: string | number) => {
|
||||
return request({
|
||||
url: `/xljk/evaluation/${id}`,
|
||||
method: 'get'
|
||||
});
|
||||
};
|
||||
|
||||
// 新增心理健康测评
|
||||
export const addEvaluation = (data: XljkEvaluationForm) => {
|
||||
// 确保必填字段都有值,避免数据库插入错误
|
||||
if (data.departmentName && !data.departmentId) {
|
||||
data.departmentId = 0; // 使用临时ID,后端会根据名称处理
|
||||
}
|
||||
|
||||
if (data.majorName && !data.majorId) {
|
||||
data.majorId = 0; // 使用临时ID,后端会根据名称处理
|
||||
}
|
||||
|
||||
if (data.className && !data.classId) {
|
||||
data.classId = 0; // 使用临时ID,后端会根据名称处理
|
||||
}
|
||||
|
||||
return request({
|
||||
url: '/xljk/evaluation',
|
||||
method: 'post',
|
||||
data: data
|
||||
});
|
||||
};
|
||||
|
||||
// 修改心理健康测评
|
||||
export const updateEvaluation = (data: XljkEvaluationForm) => {
|
||||
return request({
|
||||
url: '/xljk/evaluation',
|
||||
method: 'put',
|
||||
data: data
|
||||
});
|
||||
};
|
||||
|
||||
// 删除心理健康测评
|
||||
export const delEvaluation = (ids: string | number | Array<string | number>) => {
|
||||
return request({
|
||||
url: `/xljk/evaluation/${typeof ids === 'object' ? ids.join(',') : ids}`,
|
||||
method: 'delete'
|
||||
});
|
||||
};
|
||||
|
||||
// 获取院系选项
|
||||
export const getDepartmentOptions = () => {
|
||||
return request({
|
||||
url: '/xljk/evaluation/options/department',
|
||||
method: 'get'
|
||||
});
|
||||
};
|
||||
|
||||
// 获取院系选项(新接口)
|
||||
export const getCollegeOptions = () => {
|
||||
return request({
|
||||
url: '/xljk/evaluation/options/colleges',
|
||||
method: 'get'
|
||||
});
|
||||
};
|
||||
|
||||
// 获取专业选项
|
||||
export const getMajorOptions = (collegeName?: string) => {
|
||||
return request({
|
||||
url: '/xljk/evaluation/options/majors',
|
||||
method: 'get',
|
||||
params: { collegeName }
|
||||
});
|
||||
};
|
||||
|
||||
// 获取班级选项
|
||||
export const getClassOptions = (collegeName?: string, majorName?: string) => {
|
||||
return request({
|
||||
url: '/xljk/evaluation/options/classes',
|
||||
method: 'get',
|
||||
params: { collegeName, majorName }
|
||||
});
|
||||
};
|
||||
|
||||
// 获取班级学生列表
|
||||
export const getStudentsByClass = (collegeName?: string, majorName?: string, className?: string) => {
|
||||
return request({
|
||||
url: '/xljk/evaluation/students',
|
||||
method: 'get',
|
||||
params: { collegeName, majorName, className }
|
||||
});
|
||||
};
|
||||
|
||||
// 获取学期选项
|
||||
export const getSemesterOptions = () => {
|
||||
return request({
|
||||
url: '/xljk/evaluation/options/semester',
|
||||
method: 'get'
|
||||
});
|
||||
};
|
||||
|
||||
// 发布测评
|
||||
export const publishEvaluation = (id: string | number) => {
|
||||
return request({
|
||||
url: `/xljk/evaluation/${id}/publish`,
|
||||
method: 'put'
|
||||
});
|
||||
};
|
||||
|
||||
// 完成测评
|
||||
export const completeEvaluation = (id: string | number) => {
|
||||
return request({
|
||||
url: `/xljk/evaluation/${id}/complete`,
|
||||
method: 'put'
|
||||
});
|
||||
};
|
||||
|
||||
// 获取测评统计数据
|
||||
export const getEvaluationStatistics = (id: string | number) => {
|
||||
return request({
|
||||
url: `/xljk/evaluation/${id}/statistics`,
|
||||
method: 'get'
|
||||
});
|
||||
};
|
||||
|
||||
// 获取重点关注学生统计
|
||||
export const getFocusStudentsStatistics = (query: XljkEvaluationQuery) => {
|
||||
return request({
|
||||
url: '/xljk/evaluation/statistics/focus',
|
||||
method: 'get',
|
||||
params: query
|
||||
});
|
||||
};
|
||||
|
||||
// 查询测评明细列表
|
||||
export const listEvaluationDetail = (query: XljkEvaluationDetailQuery) => {
|
||||
return request({
|
||||
url: '/xljk/evaluation/detail/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
});
|
||||
};
|
||||
|
||||
// 获取测评明细列表
|
||||
export const getEvaluationDetailsByEvaluationId = (evaluationId: string | number) => {
|
||||
return request({
|
||||
url: `/xljk/evaluation/detail/evaluation/${evaluationId}`,
|
||||
method: 'get'
|
||||
});
|
||||
};
|
||||
|
||||
// 批量新增测评明细
|
||||
export const batchAddEvaluationDetails = (data: XljkEvaluationDetailForm[]) => {
|
||||
return request({
|
||||
url: '/xljk/evaluation/detail/batch',
|
||||
method: 'post',
|
||||
data: data
|
||||
});
|
||||
};
|
||||
|
||||
// 批量更新学生心理状态
|
||||
export const batchUpdateMentalStatus = (data: XljkEvaluationDetailForm[]) => {
|
||||
// 确保数据中的ID字段保持原有格式,不做Number转换
|
||||
console.log('批量更新数据 - 第一条记录evaluationId:', data[0]?.evaluationId);
|
||||
|
||||
return request({
|
||||
url: '/xljk/evaluation/detail/batch/mentalStatus',
|
||||
method: 'put',
|
||||
data: data
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,513 @@
|
||||
export interface XljkEvaluationVO {
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
id: string | number;
|
||||
|
||||
/**
|
||||
* 院系ID
|
||||
*/
|
||||
departmentId: number;
|
||||
|
||||
/**
|
||||
* 院系名称
|
||||
*/
|
||||
departmentName: string;
|
||||
|
||||
/**
|
||||
* 测评名称
|
||||
*/
|
||||
evaluationName: string;
|
||||
|
||||
/**
|
||||
* 专业ID
|
||||
*/
|
||||
majorId: number;
|
||||
|
||||
/**
|
||||
* 专业名称
|
||||
*/
|
||||
majorName: string;
|
||||
|
||||
/**
|
||||
* 班级ID
|
||||
*/
|
||||
classId: number;
|
||||
|
||||
/**
|
||||
* 班级名称
|
||||
*/
|
||||
className: string;
|
||||
|
||||
/**
|
||||
* 学期
|
||||
*/
|
||||
semester: string;
|
||||
|
||||
/**
|
||||
* 状态(0-草稿,1-已发布,2-已完成)
|
||||
*/
|
||||
status: string;
|
||||
|
||||
/**
|
||||
* 创建者ID(班主任ID)
|
||||
*/
|
||||
createBy: number;
|
||||
|
||||
/**
|
||||
* 创建者姓名
|
||||
*/
|
||||
createName: string;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
createTime: string;
|
||||
|
||||
/**
|
||||
* 更新者
|
||||
*/
|
||||
updateBy: number;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
updateTime: string;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
remark: string;
|
||||
|
||||
/**
|
||||
* 学生总数
|
||||
*/
|
||||
studentCount?: number;
|
||||
|
||||
/**
|
||||
* 重点关注学生数
|
||||
*/
|
||||
focusCount?: number;
|
||||
}
|
||||
|
||||
export interface XljkEvaluationForm extends BaseEntity {
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
id?: string | number;
|
||||
|
||||
/**
|
||||
* 院系ID
|
||||
*/
|
||||
departmentId?: number;
|
||||
|
||||
/**
|
||||
* 院系名称
|
||||
*/
|
||||
departmentName?: string;
|
||||
|
||||
/**
|
||||
* 测评名称
|
||||
*/
|
||||
evaluationName?: string;
|
||||
|
||||
/**
|
||||
* 专业ID
|
||||
*/
|
||||
majorId?: number;
|
||||
|
||||
/**
|
||||
* 专业名称
|
||||
*/
|
||||
majorName?: string;
|
||||
|
||||
/**
|
||||
* 班级ID
|
||||
*/
|
||||
classId?: number;
|
||||
|
||||
/**
|
||||
* 班级名称
|
||||
*/
|
||||
className?: string;
|
||||
|
||||
/**
|
||||
* 学期
|
||||
*/
|
||||
semester?: string;
|
||||
|
||||
/**
|
||||
* 状态(0-草稿,1-已发布,2-已完成)
|
||||
*/
|
||||
status?: string;
|
||||
|
||||
/**
|
||||
* 创建者姓名
|
||||
*/
|
||||
createName?: string;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
remark?: string;
|
||||
}
|
||||
|
||||
export interface XljkEvaluationQuery extends PageQuery {
|
||||
/**
|
||||
* 院系ID
|
||||
*/
|
||||
departmentId?: number;
|
||||
|
||||
/**
|
||||
* 院系名称
|
||||
*/
|
||||
departmentName?: string;
|
||||
|
||||
/**
|
||||
* 测评名称
|
||||
*/
|
||||
evaluationName?: string;
|
||||
|
||||
/**
|
||||
* 专业ID
|
||||
*/
|
||||
majorId?: number;
|
||||
|
||||
/**
|
||||
* 专业名称
|
||||
*/
|
||||
majorName?: string;
|
||||
|
||||
/**
|
||||
* 班级ID
|
||||
*/
|
||||
classId?: number;
|
||||
|
||||
/**
|
||||
* 班级名称
|
||||
*/
|
||||
className?: string;
|
||||
|
||||
/**
|
||||
* 学期
|
||||
*/
|
||||
semester?: string;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
status?: string;
|
||||
|
||||
/**
|
||||
* 日期范围参数
|
||||
*/
|
||||
params?: any;
|
||||
}
|
||||
|
||||
export interface XljkEvaluationDetailVO {
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
id: string | number;
|
||||
|
||||
/**
|
||||
* 测评表ID
|
||||
*/
|
||||
evaluationId: number;
|
||||
|
||||
/**
|
||||
* 测评名称
|
||||
*/
|
||||
evaluationName?: string;
|
||||
|
||||
/**
|
||||
* 学生ID
|
||||
*/
|
||||
studentId: number;
|
||||
|
||||
/**
|
||||
* 学号
|
||||
*/
|
||||
studentNo: string;
|
||||
|
||||
/**
|
||||
* 学生姓名
|
||||
*/
|
||||
studentName: string;
|
||||
|
||||
/**
|
||||
* 性别(M-男,F-女)
|
||||
*/
|
||||
gender: string;
|
||||
|
||||
/**
|
||||
* 出生日期
|
||||
*/
|
||||
birthDate: string;
|
||||
|
||||
/**
|
||||
* 联系电话
|
||||
*/
|
||||
phone: string;
|
||||
|
||||
/**
|
||||
* 心理状态(1-健康,2-良好,3-重点关注)
|
||||
*/
|
||||
mentalStatus: string;
|
||||
|
||||
/**
|
||||
* 分数
|
||||
*/
|
||||
score?: number;
|
||||
|
||||
/**
|
||||
* 创建者
|
||||
*/
|
||||
createBy: number;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
createTime: string;
|
||||
|
||||
/**
|
||||
* 更新者
|
||||
*/
|
||||
updateBy: number;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
updateTime: string;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
remark: string;
|
||||
|
||||
/**
|
||||
* 班级名称
|
||||
*/
|
||||
className?: string;
|
||||
|
||||
/**
|
||||
* 专业名称
|
||||
*/
|
||||
majorName?: string;
|
||||
|
||||
/**
|
||||
* 学期
|
||||
*/
|
||||
semester?: string;
|
||||
}
|
||||
|
||||
export interface XljkEvaluationDetailForm extends BaseEntity {
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
id?: string | number;
|
||||
|
||||
/**
|
||||
* 测评表ID
|
||||
*/
|
||||
evaluationId?: string | number; // 支持字符串类型的ID
|
||||
|
||||
/**
|
||||
* 学生ID
|
||||
*/
|
||||
studentId?: number;
|
||||
|
||||
/**
|
||||
* 学号
|
||||
*/
|
||||
studentNo?: string;
|
||||
|
||||
/**
|
||||
* 学生姓名
|
||||
*/
|
||||
studentName?: string;
|
||||
|
||||
/**
|
||||
* 性别(M-男,F-女)
|
||||
*/
|
||||
gender?: string;
|
||||
|
||||
/**
|
||||
* 出生日期
|
||||
*/
|
||||
birthDate?: string;
|
||||
|
||||
/**
|
||||
* 联系电话
|
||||
*/
|
||||
phone?: string;
|
||||
|
||||
/**
|
||||
* 心理状态(1-健康,2-良好,3-重点关注)
|
||||
*/
|
||||
mentalStatus?: string;
|
||||
|
||||
/**
|
||||
* 分数
|
||||
*/
|
||||
score?: number;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
remark?: string;
|
||||
}
|
||||
|
||||
export interface XljkEvaluationDetailQuery extends PageQuery {
|
||||
/**
|
||||
* 测评表ID
|
||||
*/
|
||||
evaluationId?: number;
|
||||
|
||||
/**
|
||||
* 学生ID
|
||||
*/
|
||||
studentId?: number;
|
||||
|
||||
/**
|
||||
* 学号
|
||||
*/
|
||||
studentNo?: string;
|
||||
|
||||
/**
|
||||
* 学生姓名
|
||||
*/
|
||||
studentName?: string;
|
||||
|
||||
/**
|
||||
* 心理状态
|
||||
*/
|
||||
mentalStatus?: string;
|
||||
|
||||
/**
|
||||
* 日期范围参数
|
||||
*/
|
||||
params?: any;
|
||||
}
|
||||
|
||||
export interface StudentInfo {
|
||||
/**
|
||||
* 学生ID
|
||||
*/
|
||||
studentId: number;
|
||||
|
||||
/**
|
||||
* 学号
|
||||
*/
|
||||
studentNo: string;
|
||||
|
||||
/**
|
||||
* 学生姓名
|
||||
*/
|
||||
studentName: string;
|
||||
|
||||
/**
|
||||
* 性别(M-男,F-女)
|
||||
*/
|
||||
gender: string;
|
||||
|
||||
/**
|
||||
* 出生日期
|
||||
*/
|
||||
birthDate: string;
|
||||
|
||||
/**
|
||||
* 联系电话
|
||||
*/
|
||||
phone: string;
|
||||
|
||||
/**
|
||||
* 心理状态(1-健康,2-良好,3-重点关注)
|
||||
*/
|
||||
mentalStatus?: string;
|
||||
|
||||
/**
|
||||
* 分数,当心理状态为"重点关注"时需要填写
|
||||
*/
|
||||
score?: number;
|
||||
|
||||
/**
|
||||
* 测评明细ID,已有测评数据时存在
|
||||
*/
|
||||
detailId?: number;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
remark?: string;
|
||||
}
|
||||
|
||||
export interface CollegeOption {
|
||||
/**
|
||||
* 院系名称
|
||||
*/
|
||||
name: string;
|
||||
}
|
||||
|
||||
export interface MajorOption {
|
||||
/**
|
||||
* 专业名称
|
||||
*/
|
||||
name: string;
|
||||
}
|
||||
|
||||
export interface ClassOption {
|
||||
/**
|
||||
* 班级名称
|
||||
*/
|
||||
name: string;
|
||||
}
|
||||
|
||||
export interface SemesterOption {
|
||||
/**
|
||||
* 学期值
|
||||
*/
|
||||
value: string;
|
||||
|
||||
/**
|
||||
* 学期名称
|
||||
*/
|
||||
label: string;
|
||||
}
|
||||
|
||||
export interface EvaluationStatistics {
|
||||
/**
|
||||
* 学生总数
|
||||
*/
|
||||
totalStudents: number;
|
||||
|
||||
/**
|
||||
* 健康学生数
|
||||
*/
|
||||
healthyCount: number;
|
||||
|
||||
/**
|
||||
* 良好学生数
|
||||
*/
|
||||
goodCount: number;
|
||||
|
||||
/**
|
||||
* 重点关注学生数
|
||||
*/
|
||||
focusCount: number;
|
||||
|
||||
/**
|
||||
* 健康学生百分比
|
||||
*/
|
||||
healthyPercent: number;
|
||||
|
||||
/**
|
||||
* 良好学生百分比
|
||||
*/
|
||||
goodPercent: number;
|
||||
|
||||
/**
|
||||
* 重点关注学生百分比
|
||||
*/
|
||||
focusPercent: number;
|
||||
}
|
||||
+47
-1
@@ -89,10 +89,56 @@ export const constantRoutes: RouteRecordRaw[] = [
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
path: '/xljk',
|
||||
component: Layout,
|
||||
hidden: true,
|
||||
children: [
|
||||
{
|
||||
path: 'evaluation/detail/:id',
|
||||
component: () => import('@/views/xljk/evaluation/detail.vue'),
|
||||
name: 'XljkEvaluationDetail',
|
||||
meta: { title: '心理健康测评详情', icon: 'form', activeMenu: '/xljk/evaluation' }
|
||||
},
|
||||
{
|
||||
path: 'evaluation/add',
|
||||
component: () => import('@/views/xljk/evaluation/add.vue'),
|
||||
name: 'XljkEvaluationAdd',
|
||||
meta: { title: '新增心理健康测评', icon: 'form', activeMenu: '/xljk/evaluation' }
|
||||
},
|
||||
{
|
||||
path: 'evaluation/edit/:id',
|
||||
component: () => import('@/views/xljk/evaluation/edit.vue'),
|
||||
name: 'XljkEvaluationEdit',
|
||||
meta: { title: '编辑心理健康测评', icon: 'form', activeMenu: '/xljk/evaluation' }
|
||||
},
|
||||
{
|
||||
path: 'evaluation/fill/:id',
|
||||
component: () => import('@/views/xljk/evaluation/fill.vue'),
|
||||
name: 'XljkEvaluationFill',
|
||||
meta: { title: '填写心理健康测评', icon: 'form', activeMenu: '/xljk/evaluation' }
|
||||
}
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
// 动态路由,基于用户权限动态去加载
|
||||
export const dynamicRoutes: RouteRecordRaw[] = [];
|
||||
export const dynamicRoutes: RouteRecordRaw[] = [
|
||||
{
|
||||
path: '/xljk',
|
||||
component: Layout,
|
||||
name: 'Xljk',
|
||||
meta: { title: '学工管理', icon: 'education' },
|
||||
children: [
|
||||
{
|
||||
path: 'evaluation',
|
||||
component: () => import('@/views/xljk/evaluation/index.vue'),
|
||||
name: 'XljkEvaluation',
|
||||
meta: { title: '心理健康测评', icon: 'heart', permissions: ['xljk:evaluation:list'] }
|
||||
}
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
/**
|
||||
* 创建路由
|
||||
|
||||
@@ -0,0 +1,457 @@
|
||||
<template>
|
||||
<div class="p-2 page-container">
|
||||
<el-card shadow="hover" class="mb-[10px]">
|
||||
<template #header>
|
||||
<div class="card-header">
|
||||
<span class="header-title">新增心理健康测评</span>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<el-form ref="formRef" :model="form" :rules="rules" label-width="120px">
|
||||
<el-form-item label="测评名称" prop="evaluationName">
|
||||
<el-input
|
||||
v-model="form.evaluationName"
|
||||
placeholder="请输入测评名称"
|
||||
style="width: 500px"
|
||||
maxlength="100"
|
||||
show-word-limit
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="院系" prop="departmentName">
|
||||
<el-select
|
||||
v-model="form.departmentName"
|
||||
placeholder="请选择院系"
|
||||
style="width: 500px"
|
||||
@change="handleCollegeChange"
|
||||
>
|
||||
<el-option
|
||||
v-for="college in collegeOptions"
|
||||
:key="college.name"
|
||||
:label="college.name"
|
||||
:value="college.name"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="专业" prop="majorName">
|
||||
<el-select
|
||||
v-model="form.majorName"
|
||||
placeholder="请选择专业"
|
||||
style="width: 500px"
|
||||
@change="handleMajorChange"
|
||||
:disabled="!form.departmentName"
|
||||
>
|
||||
<el-option
|
||||
v-for="major in majorOptions"
|
||||
:key="major.name"
|
||||
:label="major.name"
|
||||
:value="major.name"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="班级" prop="className">
|
||||
<el-select
|
||||
v-model="form.className"
|
||||
placeholder="请选择班级"
|
||||
style="width: 500px"
|
||||
@change="handleClassChange"
|
||||
:disabled="!form.majorName"
|
||||
>
|
||||
<el-option
|
||||
v-for="cls in classOptions"
|
||||
:key="cls.name"
|
||||
:label="cls.name"
|
||||
:value="cls.name"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="学期" prop="semester">
|
||||
<el-input
|
||||
v-model="form.semester"
|
||||
placeholder="请输入学期,如:2024上学期"
|
||||
style="width: 500px"
|
||||
maxlength="50"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input
|
||||
v-model="form.remark"
|
||||
type="textarea"
|
||||
placeholder="请输入备注信息"
|
||||
style="width: 500px"
|
||||
:rows="4"
|
||||
maxlength="500"
|
||||
show-word-limit
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item>
|
||||
<div class="form-buttons">
|
||||
<el-button type="primary" @click="submitForm" :loading="submitLoading">确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
|
||||
<el-card shadow="hover" class="mb-[10px]" v-if="form.className">
|
||||
<template #header>
|
||||
<div class="card-header">
|
||||
<span class="header-title">班级学生信息</span>
|
||||
<div class="header-buttons">
|
||||
<el-tag type="success">创建测评后将自动加载这些学生信息</el-tag>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<div v-loading="studentsLoading">
|
||||
<el-alert
|
||||
v-if="studentList.length === 0 && !studentsLoading"
|
||||
title="未找到该班级的学生信息"
|
||||
type="warning"
|
||||
show-icon
|
||||
:closable="false"
|
||||
/>
|
||||
|
||||
<!-- 学生列表表格 -->
|
||||
<el-table
|
||||
v-else
|
||||
:data="studentList"
|
||||
border
|
||||
stripe
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-table-column label="学号" align="center" prop="studentNo" width="120" />
|
||||
<el-table-column label="姓名" align="center" prop="studentName" width="100" />
|
||||
<el-table-column label="性别" align="center" prop="gender" width="80">
|
||||
<template #default="scope">
|
||||
<el-tag type="info" v-if="scope.row.gender === 'M'">男</el-tag>
|
||||
<el-tag type="danger" v-else-if="scope.row.gender === 'F'">女</el-tag>
|
||||
<span v-else>未知</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="出生日期" align="center" prop="birthDate" width="120">
|
||||
<template #default="scope">
|
||||
{{ parseTime(scope.row.birthDate, '{y}-{m}-{d}') }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="联系电话" align="center" prop="phone" width="120" />
|
||||
|
||||
<!-- 心理状态选择 -->
|
||||
<el-table-column label="心理状态" align="center" width="180">
|
||||
<template #default="scope">
|
||||
<el-select
|
||||
v-model="scope.row.mentalStatus"
|
||||
placeholder="请选择心理状态"
|
||||
@change="handleMentalStatusChange(scope.row)"
|
||||
>
|
||||
<el-option label="健康" value="1" />
|
||||
<el-option label="良好" value="2" />
|
||||
<el-option label="重点关注" value="3" />
|
||||
</el-select>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<!-- 分数输入,仅当心理状态为"重点关注"时显示 -->
|
||||
<el-table-column label="分数" align="center" width="120">
|
||||
<template #default="scope">
|
||||
<el-input-number
|
||||
v-if="scope.row.mentalStatus === '3'"
|
||||
v-model="scope.row.score"
|
||||
:min="0"
|
||||
:max="100"
|
||||
size="small"
|
||||
/>
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<!-- 备注 -->
|
||||
<el-table-column label="备注" align="center">
|
||||
<template #default="scope">
|
||||
<el-input
|
||||
v-model="scope.row.remark"
|
||||
type="text"
|
||||
placeholder="备注信息"
|
||||
size="small"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<div class="student-count" v-if="studentList.length > 0">
|
||||
共 {{ studentList.length }} 名学生
|
||||
</div>
|
||||
</div>
|
||||
</el-card>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup name="XljkEvaluationAdd" lang="ts">
|
||||
import { addEvaluation, getCollegeOptions, getMajorOptions, getClassOptions, getStudentsByClass, batchAddEvaluationDetails } from '@/api/xljk/evaluation';
|
||||
import { XljkEvaluationForm, StudentInfo, CollegeOption, MajorOption, ClassOption } from '@/api/xljk/evaluation/types';
|
||||
import { useRouter } from 'vue-router';
|
||||
|
||||
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
||||
|
||||
const router = useRouter();
|
||||
const formRef = ref<ElFormInstance>();
|
||||
const submitLoading = ref(false);
|
||||
const studentsLoading = ref(false);
|
||||
|
||||
// 表单数据
|
||||
const form = ref<XljkEvaluationForm>({
|
||||
evaluationName: undefined,
|
||||
departmentName: undefined,
|
||||
departmentId: undefined, // 这里保留departmentId字段,但实际使用departmentName
|
||||
majorName: undefined,
|
||||
majorId: undefined, // 这里保留majorId字段,但实际使用majorName
|
||||
className: undefined,
|
||||
classId: undefined, // 这里保留classId字段,但实际使用className
|
||||
semester: undefined,
|
||||
status: '0', // 默认为草稿状态
|
||||
remark: undefined
|
||||
});
|
||||
|
||||
// 表单验证规则
|
||||
const rules = {
|
||||
evaluationName: [{ required: true, message: '测评名称不能为空', trigger: 'blur' }],
|
||||
departmentName: [{ required: true, message: '院系不能为空', trigger: 'change' }],
|
||||
majorName: [{ required: true, message: '专业不能为空', trigger: 'change' }],
|
||||
className: [{ required: true, message: '班级不能为空', trigger: 'change' }],
|
||||
semester: [{ required: true, message: '学期不能为空', trigger: 'blur' }]
|
||||
};
|
||||
|
||||
// 选项数据
|
||||
const collegeOptions = ref<CollegeOption[]>([]);
|
||||
const majorOptions = ref<MajorOption[]>([]);
|
||||
const classOptions = ref<ClassOption[]>([]);
|
||||
const studentList = ref<StudentInfo[]>([]);
|
||||
|
||||
/** 获取院系选项 */
|
||||
const getColleges = async () => {
|
||||
try {
|
||||
const res = await getCollegeOptions();
|
||||
collegeOptions.value = res.data || [];
|
||||
} catch (error) {
|
||||
console.error('获取院系选项失败', error);
|
||||
}
|
||||
};
|
||||
|
||||
/** 获取专业选项 */
|
||||
const getMajors = async (collegeName: string) => {
|
||||
try {
|
||||
const res = await getMajorOptions(collegeName);
|
||||
majorOptions.value = res.data || [];
|
||||
} catch (error) {
|
||||
console.error('获取专业选项失败', error);
|
||||
}
|
||||
};
|
||||
|
||||
/** 获取班级选项 */
|
||||
const getClasses = async (collegeName: string, majorName: string) => {
|
||||
try {
|
||||
const res = await getClassOptions(collegeName, majorName);
|
||||
classOptions.value = res.data || [];
|
||||
} catch (error) {
|
||||
console.error('获取班级选项失败', error);
|
||||
}
|
||||
};
|
||||
|
||||
/** 院系选择变化时更新专业选项 */
|
||||
const handleCollegeChange = async (collegeName: string) => {
|
||||
// 清空专业和班级选择
|
||||
form.value.majorName = undefined;
|
||||
form.value.className = undefined;
|
||||
majorOptions.value = [];
|
||||
classOptions.value = [];
|
||||
studentList.value = [];
|
||||
|
||||
if (collegeName) {
|
||||
// 获取该院系下的专业
|
||||
await getMajors(collegeName);
|
||||
}
|
||||
};
|
||||
|
||||
/** 专业选择变化时更新班级选项 */
|
||||
const handleMajorChange = async (majorName: string) => {
|
||||
// 清空班级选择
|
||||
form.value.className = undefined;
|
||||
classOptions.value = [];
|
||||
studentList.value = [];
|
||||
|
||||
if (majorName && form.value.departmentName) {
|
||||
// 获取专业下的班级
|
||||
await getClasses(form.value.departmentName, majorName);
|
||||
}
|
||||
};
|
||||
|
||||
/** 班级选择变化时获取学生列表 */
|
||||
const handleClassChange = async (className: string) => {
|
||||
if (!className) {
|
||||
studentList.value = [];
|
||||
return;
|
||||
}
|
||||
|
||||
// 获取班级学生列表
|
||||
try {
|
||||
studentsLoading.value = true;
|
||||
const res = await getStudentsByClass(form.value.departmentName, form.value.majorName, className);
|
||||
studentList.value = res.data || [];
|
||||
} catch (error) {
|
||||
console.error('获取班级学生列表失败', error);
|
||||
studentList.value = [];
|
||||
} finally {
|
||||
studentsLoading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
/** 处理心理状态变化 */
|
||||
const handleMentalStatusChange = (student: StudentInfo) => {
|
||||
// 如果心理状态不是"重点关注",清空分数
|
||||
if (student.mentalStatus !== '3') {
|
||||
student.score = undefined;
|
||||
} else {
|
||||
// 设置默认分数
|
||||
student.score = student.score || 70;
|
||||
}
|
||||
};
|
||||
|
||||
/** 统计重点关注学生数量 */
|
||||
const countFocusStudents = () => {
|
||||
return studentList.value.filter(student => student.mentalStatus === '3').length;
|
||||
};
|
||||
|
||||
/** 提交表单 */
|
||||
const submitForm = () => {
|
||||
formRef.value?.validate(async (valid: boolean) => {
|
||||
if (valid) {
|
||||
submitLoading.value = true;
|
||||
try {
|
||||
// 确保departmentName、majorName和className有值
|
||||
if (!form.value.departmentName && form.value.departmentId) {
|
||||
// 找不到departmentName但有departmentId的情况处理
|
||||
proxy?.$modal.msgError('院系名称不能为空');
|
||||
submitLoading.value = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!form.value.majorName && form.value.majorId) {
|
||||
// 找不到majorName但有majorId的情况处理
|
||||
proxy?.$modal.msgError('专业名称不能为空');
|
||||
submitLoading.value = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!form.value.className && form.value.classId) {
|
||||
// 找不到className但有classId的情况处理
|
||||
proxy?.$modal.msgError('班级名称不能为空');
|
||||
submitLoading.value = false;
|
||||
return;
|
||||
}
|
||||
|
||||
// 确保ID字段有值,即使是临时值
|
||||
if (form.value.departmentName && !form.value.departmentId) {
|
||||
form.value.departmentId = 0; // 临时ID,后端会基于departmentName处理
|
||||
}
|
||||
|
||||
if (form.value.majorName && !form.value.majorId) {
|
||||
form.value.majorId = 0; // 临时ID,后端会基于majorName处理
|
||||
}
|
||||
|
||||
if (form.value.className && !form.value.classId) {
|
||||
form.value.classId = 0; // 临时ID,后端会基于className处理
|
||||
}
|
||||
|
||||
// 先创建测评
|
||||
const res = await addEvaluation(form.value);
|
||||
const evaluationId = res.data;
|
||||
|
||||
if (evaluationId) {
|
||||
// 统计学生人数和重点关注学生数量
|
||||
const studentCount = studentList.value.length;
|
||||
const focusCount = countFocusStudents();
|
||||
|
||||
// 准备学生测评明细数据
|
||||
const detailList = studentList.value.map(student => {
|
||||
return {
|
||||
evaluationId,
|
||||
studentId: student.studentId,
|
||||
studentNo: student.studentNo,
|
||||
studentName: student.studentName,
|
||||
gender: student.gender,
|
||||
birthDate: student.birthDate,
|
||||
phone: student.phone,
|
||||
mentalStatus: student.mentalStatus || '1', // 默认健康
|
||||
score: student.mentalStatus === '3' ? student.score : undefined,
|
||||
remark: student.remark
|
||||
};
|
||||
});
|
||||
|
||||
// 批量创建测评明细
|
||||
await batchAddEvaluationDetails(detailList);
|
||||
|
||||
// 更新测评主表的学生数量和重点关注学生数量
|
||||
// 注:这部分逻辑可能需要在后端自动处理
|
||||
|
||||
proxy?.$modal.msgSuccess('新增成功');
|
||||
router.push('/xljk/evaluation');
|
||||
} else {
|
||||
proxy?.$modal.msgError('新增测评失败');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('新增测评失败', error);
|
||||
} finally {
|
||||
submitLoading.value = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/** 取消按钮 */
|
||||
const cancel = () => {
|
||||
router.push('/xljk/evaluation');
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
getColleges();
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.page-container {
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
.card-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.header-title {
|
||||
font-size: 16px;
|
||||
font-weight: bold;
|
||||
color: #303133;
|
||||
}
|
||||
|
||||
.header-buttons {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.form-buttons {
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.student-count {
|
||||
margin-top: 10px;
|
||||
text-align: right;
|
||||
color: #606266;
|
||||
font-size: 14px;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,446 @@
|
||||
<template>
|
||||
<div class="p-2 page-container">
|
||||
<el-card shadow="hover" class="mb-[10px]">
|
||||
<template #header>
|
||||
<div class="card-header">
|
||||
<span class="header-title">测评基本信息</span>
|
||||
<div class="header-buttons">
|
||||
<el-button @click="goBack">返回</el-button>
|
||||
<el-button type="primary" @click="handleExport" v-hasPermi="['xljk:evaluation:export']">导出结果</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<el-descriptions :column="3" border>
|
||||
<el-descriptions-item label="测评名称">{{ evaluationInfo.evaluationName }}</el-descriptions-item>
|
||||
<el-descriptions-item label="专业">{{ evaluationInfo.majorName }}</el-descriptions-item>
|
||||
<el-descriptions-item label="班级">{{ evaluationInfo.className }}</el-descriptions-item>
|
||||
<el-descriptions-item label="学期">{{ evaluationInfo.semester }}</el-descriptions-item>
|
||||
<el-descriptions-item label="状态">
|
||||
<dict-tag :options="evaluation_status" :value="evaluationInfo.status" />
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="创建人">{{ evaluationInfo.createName }}</el-descriptions-item>
|
||||
<el-descriptions-item label="创建时间">{{ parseTime(evaluationInfo.createTime) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="备注" :span="2">{{ evaluationInfo.remark || '无' }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</el-card>
|
||||
|
||||
<!-- 统计信息卡片 -->
|
||||
<el-card shadow="hover" class="mb-[10px]" v-loading="statisticsLoading">
|
||||
<template #header>
|
||||
<div class="card-header">
|
||||
<span class="header-title">测评统计</span>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<div class="statistics-container">
|
||||
<div class="statistics-row">
|
||||
<el-statistic title="学生总数" :value="statistics.totalStudents">
|
||||
<template #suffix>
|
||||
<span class="suffix-label">人</span>
|
||||
</template>
|
||||
</el-statistic>
|
||||
|
||||
<el-statistic title="健康学生" :value="statistics.healthyCount">
|
||||
<template #suffix>
|
||||
<span class="suffix-label">人 ({{ formatPercent(statistics.healthyPercent) }})</span>
|
||||
</template>
|
||||
</el-statistic>
|
||||
|
||||
<el-statistic title="良好学生" :value="statistics.goodCount">
|
||||
<template #suffix>
|
||||
<span class="suffix-label">人 ({{ formatPercent(statistics.goodPercent) }})</span>
|
||||
</template>
|
||||
</el-statistic>
|
||||
|
||||
<el-statistic title="重点关注" :value="statistics.focusCount" value-style="color: #f56c6c;">
|
||||
<template #suffix>
|
||||
<span class="suffix-label" style="color: #f56c6c;">人 ({{ formatPercent(statistics.focusPercent) }})</span>
|
||||
</template>
|
||||
</el-statistic>
|
||||
</div>
|
||||
|
||||
<!-- 图表展示 -->
|
||||
<div class="chart-container" v-if="statistics.totalStudents > 0">
|
||||
<div ref="pieChartRef" class="pie-chart"></div>
|
||||
</div>
|
||||
</div>
|
||||
</el-card>
|
||||
|
||||
<!-- 学生测评结果表格 -->
|
||||
<el-card shadow="hover" class="mb-[10px]">
|
||||
<template #header>
|
||||
<div class="card-header">
|
||||
<span class="header-title">学生测评结果</span>
|
||||
<div class="header-right">
|
||||
<el-radio-group v-model="filterStatus" size="small" @change="handleFilterChange">
|
||||
<el-radio-button label="">全部</el-radio-button>
|
||||
<el-radio-button label="1">健康</el-radio-button>
|
||||
<el-radio-button label="2">良好</el-radio-button>
|
||||
<el-radio-button label="3">重点关注</el-radio-button>
|
||||
</el-radio-group>
|
||||
|
||||
<el-input
|
||||
v-model="searchKeyword"
|
||||
placeholder="搜索学号/姓名"
|
||||
clearable
|
||||
style="width: 200px; margin-left: 10px"
|
||||
@keyup.enter="handleSearch"
|
||||
@clear="handleSearch"
|
||||
>
|
||||
<template #suffix>
|
||||
<el-icon class="el-input__icon" @click="handleSearch"><Search /></el-icon>
|
||||
</template>
|
||||
</el-input>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<el-table
|
||||
v-loading="loading"
|
||||
border
|
||||
:data="detailList"
|
||||
stripe
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-table-column label="学号" align="center" prop="studentNo" width="120" />
|
||||
<el-table-column label="姓名" align="center" prop="studentName" width="100" />
|
||||
<el-table-column label="性别" align="center" prop="gender" width="80">
|
||||
<template #default="scope">
|
||||
<dict-tag :options="sys_user_sex" :value="scope.row.gender" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="联系电话" align="center" prop="phone" width="120" />
|
||||
<el-table-column label="心理状态" align="center" prop="mentalStatus" width="100">
|
||||
<template #default="scope">
|
||||
<el-tag
|
||||
:type="scope.row.mentalStatus === '1' ? 'success' :
|
||||
scope.row.mentalStatus === '2' ? 'warning' : 'danger'"
|
||||
>
|
||||
{{ scope.row.mentalStatus === '1' ? '健康' :
|
||||
scope.row.mentalStatus === '2' ? '良好' : '重点关注' }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="分数" align="center" prop="score" width="80">
|
||||
<template #default="scope">
|
||||
<span v-if="scope.row.score">{{ scope.row.score }}</span>
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="备注" align="left" prop="remark" min-width="200" show-overflow-tooltip />
|
||||
</el-table>
|
||||
|
||||
<div class="pagination-container">
|
||||
<pagination
|
||||
v-show="total > 0"
|
||||
:total="total"
|
||||
v-model:page="queryParams.pageNum"
|
||||
v-model:limit="queryParams.pageSize"
|
||||
@pagination="getDetailList"
|
||||
/>
|
||||
</div>
|
||||
</el-card>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup name="XljkEvaluationDetail" lang="ts">
|
||||
import { getEvaluation, getEvaluationStatistics, listEvaluationDetail, getEvaluationDetailsByEvaluationId } from '@/api/xljk/evaluation';
|
||||
import { XljkEvaluationVO, XljkEvaluationDetailVO, XljkEvaluationDetailQuery, EvaluationStatistics } from '@/api/xljk/evaluation/types';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import * as echarts from 'echarts/core';
|
||||
import { PieChart } from 'echarts/charts';
|
||||
import { TooltipComponent, LegendComponent, TitleComponent } from 'echarts/components';
|
||||
import { CanvasRenderer } from 'echarts/renderers';
|
||||
|
||||
// 注册必要的组件
|
||||
echarts.use([PieChart, TooltipComponent, LegendComponent, TitleComponent, CanvasRenderer]);
|
||||
|
||||
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
||||
const { evaluation_status, sys_user_sex } = toRefs<any>(proxy?.useDict('evaluation_status', 'sys_user_sex'));
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const evaluationId = ref(route.params.id as string);
|
||||
|
||||
const loading = ref(false);
|
||||
const statisticsLoading = ref(false);
|
||||
const evaluationInfo = ref<XljkEvaluationVO>({} as XljkEvaluationVO);
|
||||
const statistics = ref<EvaluationStatistics>({
|
||||
totalStudents: 0,
|
||||
healthyCount: 0,
|
||||
goodCount: 0,
|
||||
focusCount: 0,
|
||||
healthyPercent: 0,
|
||||
goodPercent: 0,
|
||||
focusPercent: 0
|
||||
});
|
||||
|
||||
const detailList = ref<XljkEvaluationDetailVO[]>([]);
|
||||
const total = ref(0);
|
||||
const filterStatus = ref('');
|
||||
const searchKeyword = ref('');
|
||||
const pieChartRef = ref<HTMLElement | null>(null);
|
||||
let pieChart: echarts.ECharts | null = null;
|
||||
|
||||
const queryParams = ref<XljkEvaluationDetailQuery>({
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
evaluationId: Number(evaluationId.value),
|
||||
mentalStatus: '',
|
||||
studentName: '',
|
||||
studentNo: '',
|
||||
params: {}
|
||||
});
|
||||
|
||||
/** 获取测评基本信息 */
|
||||
const getEvaluationInfo = async () => {
|
||||
try {
|
||||
const res = await getEvaluation(evaluationId.value);
|
||||
evaluationInfo.value = res.data;
|
||||
} catch (error) {
|
||||
console.error('获取测评信息失败', error);
|
||||
}
|
||||
};
|
||||
|
||||
/** 获取测评统计信息 */
|
||||
const getStatistics = async () => {
|
||||
try {
|
||||
statisticsLoading.value = true;
|
||||
const res = await getEvaluationStatistics(evaluationId.value);
|
||||
statistics.value = res.data;
|
||||
|
||||
// 初始化饼图
|
||||
initPieChart();
|
||||
} catch (error) {
|
||||
console.error('获取测评统计信息失败', error);
|
||||
} finally {
|
||||
statisticsLoading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
/** 获取测评明细列表 */
|
||||
const getDetailList = async () => {
|
||||
try {
|
||||
loading.value = true;
|
||||
// 使用getEvaluationDetailsByEvaluationId替代listEvaluationDetail
|
||||
// 因为listEvaluationDetail需要分页参数,而我们需要的是获取指定测评ID的所有明细
|
||||
const res = await getEvaluationDetailsByEvaluationId(evaluationId.value);
|
||||
if (res.data) {
|
||||
detailList.value = res.data;
|
||||
total.value = res.data.length;
|
||||
} else {
|
||||
detailList.value = [];
|
||||
total.value = 0;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取测评明细失败', error);
|
||||
detailList.value = [];
|
||||
total.value = 0;
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
/** 初始化饼图 */
|
||||
const initPieChart = () => {
|
||||
if (!pieChartRef.value) return;
|
||||
|
||||
// 销毁之前的图表实例
|
||||
if (pieChart) {
|
||||
pieChart.dispose();
|
||||
}
|
||||
|
||||
// 创建新的图表实例
|
||||
pieChart = echarts.init(pieChartRef.value);
|
||||
|
||||
const option = {
|
||||
title: {
|
||||
text: '心理状态分布',
|
||||
left: 'center'
|
||||
},
|
||||
tooltip: {
|
||||
trigger: 'item',
|
||||
formatter: '{a} <br/>{b}: {c} ({d}%)'
|
||||
},
|
||||
legend: {
|
||||
orient: 'vertical',
|
||||
left: 'left',
|
||||
data: ['健康', '良好', '重点关注']
|
||||
},
|
||||
color: ['#67C23A', '#E6A23C', '#F56C6C'],
|
||||
series: [
|
||||
{
|
||||
name: '心理状态',
|
||||
type: 'pie',
|
||||
radius: '60%',
|
||||
center: ['50%', '50%'],
|
||||
data: [
|
||||
{ value: statistics.value.healthyCount, name: '健康' },
|
||||
{ value: statistics.value.goodCount, name: '良好' },
|
||||
{ value: statistics.value.focusCount, name: '重点关注' }
|
||||
],
|
||||
emphasis: {
|
||||
itemStyle: {
|
||||
shadowBlur: 10,
|
||||
shadowOffsetX: 0,
|
||||
shadowColor: 'rgba(0, 0, 0, 0.5)'
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
pieChart.setOption(option);
|
||||
|
||||
// 监听窗口大小变化,重新调整图表大小
|
||||
window.addEventListener('resize', () => {
|
||||
pieChart?.resize();
|
||||
});
|
||||
};
|
||||
|
||||
/** 格式化百分比 */
|
||||
const formatPercent = (value: number) => {
|
||||
return value ? `${value.toFixed(1)}%` : '0%';
|
||||
};
|
||||
|
||||
/** 返回列表页 */
|
||||
const goBack = () => {
|
||||
router.push('/xljk/evaluation');
|
||||
};
|
||||
|
||||
/** 导出结果 */
|
||||
const handleExport = () => {
|
||||
proxy?.download(
|
||||
'xljk/evaluationDetail/export',
|
||||
{
|
||||
evaluationId: evaluationId.value
|
||||
},
|
||||
`evaluation_detail_${evaluationId.value}_${new Date().getTime()}.xlsx`
|
||||
);
|
||||
};
|
||||
|
||||
/** 处理筛选变化 */
|
||||
const handleFilterChange = () => {
|
||||
queryParams.value.pageNum = 1;
|
||||
queryParams.value.mentalStatus = filterStatus.value;
|
||||
getDetailList();
|
||||
};
|
||||
|
||||
/** 处理搜索 */
|
||||
const handleSearch = () => {
|
||||
queryParams.value.pageNum = 1;
|
||||
|
||||
// 判断输入是否为数字(学号)或文本(姓名)
|
||||
const isNumeric = /^\d+$/.test(searchKeyword.value);
|
||||
|
||||
if (isNumeric) {
|
||||
queryParams.value.studentNo = searchKeyword.value;
|
||||
queryParams.value.studentName = '';
|
||||
} else {
|
||||
queryParams.value.studentName = searchKeyword.value;
|
||||
queryParams.value.studentNo = '';
|
||||
}
|
||||
|
||||
getDetailList();
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
getEvaluationInfo();
|
||||
getStatistics();
|
||||
getDetailList();
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
// 销毁图表实例
|
||||
if (pieChart) {
|
||||
pieChart.dispose();
|
||||
pieChart = null;
|
||||
}
|
||||
|
||||
// 移除事件监听
|
||||
window.removeEventListener('resize', () => {
|
||||
pieChart?.resize();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.page-container {
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
.card-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.header-title {
|
||||
font-size: 16px;
|
||||
font-weight: bold;
|
||||
color: #303133;
|
||||
}
|
||||
|
||||
.header-buttons {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.header-right {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
/* 统计样式 */
|
||||
.statistics-container {
|
||||
padding: 10px 0;
|
||||
}
|
||||
|
||||
.statistics-row {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: space-around;
|
||||
gap: 20px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.suffix-label {
|
||||
font-size: 12px;
|
||||
color: #606266;
|
||||
margin-left: 4px;
|
||||
}
|
||||
|
||||
.chart-container {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
margin-top: 20px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.pie-chart {
|
||||
width: 600px;
|
||||
height: 400px;
|
||||
}
|
||||
|
||||
/* 分页容器样式 */
|
||||
.pagination-container {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
padding: 16px 20px 0 0 !important;
|
||||
background-color: #fff;
|
||||
margin-top: 10px !important;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.statistics-row {
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.pie-chart {
|
||||
width: 100%;
|
||||
height: 300px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,373 @@
|
||||
<template>
|
||||
<div class="p-2 page-container">
|
||||
<el-card shadow="hover" class="mb-[10px]">
|
||||
<template #header>
|
||||
<div class="card-header">
|
||||
<span class="header-title">编辑心理健康测评</span>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<el-form ref="formRef" :model="form" :rules="rules" label-width="120px">
|
||||
<el-form-item label="测评名称" prop="evaluationName">
|
||||
<el-input
|
||||
v-model="form.evaluationName"
|
||||
placeholder="请输入测评名称"
|
||||
style="width: 500px"
|
||||
maxlength="100"
|
||||
show-word-limit
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="专业" prop="majorId">
|
||||
<el-input
|
||||
v-model="form.majorName"
|
||||
disabled
|
||||
style="width: 500px"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="班级" prop="classId">
|
||||
<el-input
|
||||
v-model="form.className"
|
||||
disabled
|
||||
style="width: 500px"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="学期" prop="semester">
|
||||
<el-input
|
||||
v-model="form.semester"
|
||||
disabled
|
||||
style="width: 500px"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input
|
||||
v-model="form.remark"
|
||||
type="textarea"
|
||||
placeholder="请输入备注信息"
|
||||
style="width: 500px"
|
||||
:rows="4"
|
||||
maxlength="500"
|
||||
show-word-limit
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item>
|
||||
<div class="form-buttons">
|
||||
<el-button type="primary" @click="submitForm" :loading="submitLoading">确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
|
||||
<el-card shadow="hover" class="mb-[10px]">
|
||||
<template #header>
|
||||
<div class="card-header">
|
||||
<span class="header-title">班级学生信息</span>
|
||||
<div class="header-buttons">
|
||||
<el-tag type="warning">专业、班级和学期不可修改</el-tag>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<div v-loading="studentsLoading">
|
||||
<el-alert
|
||||
v-if="studentList.length === 0 && !studentsLoading"
|
||||
title="未找到该班级的学生信息"
|
||||
type="warning"
|
||||
show-icon
|
||||
:closable="false"
|
||||
/>
|
||||
|
||||
<el-table
|
||||
v-else
|
||||
:data="studentList"
|
||||
border
|
||||
stripe
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-table-column label="学号" align="center" prop="studentNo" width="120" />
|
||||
<el-table-column label="姓名" align="center" prop="studentName" width="100" />
|
||||
<el-table-column label="性别" align="center" prop="gender" width="80">
|
||||
<template #default="scope">
|
||||
<dict-tag :options="sys_user_sex" :value="scope.row.gender" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="出生日期" align="center" prop="birthDate" width="120">
|
||||
<template #default="scope">
|
||||
{{ parseTime(scope.row.birthDate, '{y}-{m}-{d}') }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="联系电话" align="center" prop="phone" width="120" />
|
||||
|
||||
<!-- 心理状态选择 -->
|
||||
<el-table-column label="心理状态" align="center" width="180">
|
||||
<template #default="scope">
|
||||
<el-select
|
||||
v-model="scope.row.mentalStatus"
|
||||
placeholder="请选择心理状态"
|
||||
@change="handleMentalStatusChange(scope.row)"
|
||||
>
|
||||
<el-option label="健康" value="1" />
|
||||
<el-option label="良好" value="2" />
|
||||
<el-option label="重点关注" value="3" />
|
||||
</el-select>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<!-- 分数输入,仅当心理状态为"重点关注"时显示 -->
|
||||
<el-table-column label="分数" align="center" width="120">
|
||||
<template #default="scope">
|
||||
<el-input-number
|
||||
v-if="scope.row.mentalStatus === '3'"
|
||||
v-model="scope.row.score"
|
||||
:min="0"
|
||||
:max="100"
|
||||
size="small"
|
||||
/>
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<!-- 备注 -->
|
||||
<el-table-column label="备注" align="center">
|
||||
<template #default="scope">
|
||||
<el-input
|
||||
v-model="scope.row.remark"
|
||||
type="text"
|
||||
placeholder="备注信息"
|
||||
size="small"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<div class="student-count" v-if="studentList.length > 0">
|
||||
共 {{ studentList.length }} 名学生
|
||||
</div>
|
||||
</div>
|
||||
</el-card>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup name="XljkEvaluationEdit" lang="ts">
|
||||
import { getEvaluation, updateEvaluation, getStudentsByClass, getEvaluationDetailsByEvaluationId, batchUpdateMentalStatus } from '@/api/xljk/evaluation';
|
||||
import { XljkEvaluationForm, StudentInfo, XljkEvaluationDetailForm } from '@/api/xljk/evaluation/types';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
|
||||
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
||||
const { sys_user_sex } = toRefs<any>(proxy?.useDict('sys_user_sex'));
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const evaluationId = ref(route.params.id as string);
|
||||
const formRef = ref<ElFormInstance>();
|
||||
const submitLoading = ref(false);
|
||||
const studentsLoading = ref(false);
|
||||
const detailsLoaded = ref(false); // 标记是否已加载测评明细
|
||||
|
||||
// 表单数据
|
||||
const form = ref<XljkEvaluationForm>({
|
||||
id: undefined,
|
||||
evaluationName: undefined,
|
||||
departmentId: undefined,
|
||||
departmentName: undefined,
|
||||
majorId: undefined,
|
||||
majorName: undefined,
|
||||
classId: undefined,
|
||||
className: undefined,
|
||||
semester: undefined,
|
||||
status: undefined,
|
||||
remark: undefined
|
||||
});
|
||||
|
||||
// 表单验证规则
|
||||
const rules = {
|
||||
evaluationName: [{ required: true, message: '测评名称不能为空', trigger: 'blur' }]
|
||||
};
|
||||
|
||||
// 学生列表
|
||||
const studentList = ref<StudentInfo[]>([]);
|
||||
// 测评明细列表
|
||||
const detailList = ref<XljkEvaluationDetailForm[]>([]);
|
||||
|
||||
/** 获取测评信息 */
|
||||
const getEvaluationInfo = async () => {
|
||||
try {
|
||||
const res = await getEvaluation(evaluationId.value);
|
||||
form.value = res.data;
|
||||
|
||||
// 检查状态是否为草稿
|
||||
if (form.value.status !== '0') {
|
||||
proxy?.$modal.msgError('只能编辑草稿状态的测评');
|
||||
setTimeout(() => {
|
||||
router.push('/xljk/evaluation');
|
||||
}, 1500);
|
||||
} else {
|
||||
// 获取班级学生列表
|
||||
if (form.value.className) {
|
||||
await getStudents();
|
||||
// 加载测评明细数据
|
||||
await getEvaluationDetails();
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取测评信息失败', error);
|
||||
}
|
||||
};
|
||||
|
||||
/** 获取班级学生列表 */
|
||||
const getStudents = async () => {
|
||||
try {
|
||||
studentsLoading.value = true;
|
||||
// 打印参数信息
|
||||
console.log('获取学生列表的参数:', {
|
||||
className: form.value.className
|
||||
});
|
||||
|
||||
// 只使用班级名称作为参数,忽略院系和专业,因为数据可能不匹配
|
||||
const res = await getStudentsByClass(null, null, form.value.className);
|
||||
|
||||
// 打印返回结果
|
||||
console.log('获取学生列表的结果:', res);
|
||||
|
||||
studentList.value = res.data || [];
|
||||
|
||||
// 为每个学生初始化心理状态
|
||||
studentList.value.forEach(student => {
|
||||
student.mentalStatus = student.mentalStatus || '1'; // 默认健康
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('获取班级学生列表失败', error);
|
||||
studentList.value = [];
|
||||
} finally {
|
||||
studentsLoading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
/** 获取测评明细数据 */
|
||||
const getEvaluationDetails = async () => {
|
||||
try {
|
||||
const res = await getEvaluationDetailsByEvaluationId(evaluationId.value);
|
||||
detailList.value = res.data || [];
|
||||
|
||||
// 将测评明细数据合并到学生列表中
|
||||
if (detailList.value.length > 0) {
|
||||
studentList.value.forEach(student => {
|
||||
const detail = detailList.value.find(d => d.studentId === student.studentId);
|
||||
if (detail) {
|
||||
student.mentalStatus = detail.mentalStatus;
|
||||
student.score = detail.score;
|
||||
student.remark = detail.remark;
|
||||
student.detailId = detail.id as number;
|
||||
}
|
||||
});
|
||||
detailsLoaded.value = true;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取测评明细失败', error);
|
||||
}
|
||||
};
|
||||
|
||||
/** 处理心理状态变化 */
|
||||
const handleMentalStatusChange = (student: StudentInfo) => {
|
||||
// 如果心理状态不是"重点关注",清空分数
|
||||
if (student.mentalStatus !== '3') {
|
||||
student.score = undefined;
|
||||
} else {
|
||||
// 设置默认分数
|
||||
student.score = student.score || 70;
|
||||
}
|
||||
};
|
||||
|
||||
/** 统计重点关注学生数量 */
|
||||
const countFocusStudents = () => {
|
||||
return studentList.value.filter(student => student.mentalStatus === '3').length;
|
||||
};
|
||||
|
||||
/** 提交表单 */
|
||||
const submitForm = () => {
|
||||
formRef.value?.validate(async (valid: boolean) => {
|
||||
if (valid) {
|
||||
submitLoading.value = true;
|
||||
try {
|
||||
// 更新测评基本信息
|
||||
await updateEvaluation(form.value);
|
||||
|
||||
// 准备学生测评明细数据
|
||||
const detailsToUpdate = studentList.value.map(student => {
|
||||
return {
|
||||
id: student.detailId, // 已有记录的ID
|
||||
evaluationId: form.value.id, // 保持ID为原始类型,不做Number转换
|
||||
studentId: student.studentId,
|
||||
studentNo: student.studentNo,
|
||||
studentName: student.studentName,
|
||||
gender: student.gender,
|
||||
birthDate: student.birthDate,
|
||||
phone: student.phone,
|
||||
mentalStatus: student.mentalStatus || '1', // 默认健康
|
||||
score: student.mentalStatus === '3' ? student.score : undefined,
|
||||
remark: student.remark
|
||||
} as XljkEvaluationDetailForm;
|
||||
});
|
||||
|
||||
// 批量更新学生心理状态
|
||||
await batchUpdateMentalStatus(detailsToUpdate);
|
||||
|
||||
proxy?.$modal.msgSuccess('修改成功');
|
||||
router.push('/xljk/evaluation');
|
||||
} catch (error) {
|
||||
console.error('修改测评失败', error);
|
||||
} finally {
|
||||
submitLoading.value = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/** 取消按钮 */
|
||||
const cancel = () => {
|
||||
router.push('/xljk/evaluation');
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
getEvaluationInfo();
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.page-container {
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
.card-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.header-title {
|
||||
font-size: 16px;
|
||||
font-weight: bold;
|
||||
color: #303133;
|
||||
}
|
||||
|
||||
.header-buttons {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.form-buttons {
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.student-count {
|
||||
margin-top: 10px;
|
||||
text-align: right;
|
||||
color: #606266;
|
||||
font-size: 14px;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,343 @@
|
||||
<template>
|
||||
<div class="p-2 page-container">
|
||||
<el-card shadow="hover" class="mb-[10px]">
|
||||
<template #header>
|
||||
<div class="card-header">
|
||||
<span class="header-title">测评填写:{{ evaluationInfo.evaluationName }}</span>
|
||||
<div class="header-buttons">
|
||||
<el-button @click="goBack">返回</el-button>
|
||||
<el-button type="primary" @click="saveEvaluation" :loading="saveLoading">保存测评结果</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<el-descriptions :column="3" border>
|
||||
<el-descriptions-item label="专业">{{ evaluationInfo.majorName }}</el-descriptions-item>
|
||||
<el-descriptions-item label="班级">{{ evaluationInfo.className }}</el-descriptions-item>
|
||||
<el-descriptions-item label="学期">{{ evaluationInfo.semester }}</el-descriptions-item>
|
||||
<el-descriptions-item label="状态">
|
||||
<dict-tag :options="evaluation_status" :value="evaluationInfo.status" />
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="学生人数">{{ detailList.length }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</el-card>
|
||||
|
||||
<el-card shadow="hover" v-loading="loading">
|
||||
<template #header>
|
||||
<div class="card-header">
|
||||
<span class="header-title">学生测评结果</span>
|
||||
<div class="header-right">
|
||||
<span class="fill-stats">
|
||||
已填写:<el-tag type="success">{{ filledCount }}</el-tag> / {{ detailList.length }}
|
||||
</span>
|
||||
|
||||
<el-input
|
||||
v-model="searchKeyword"
|
||||
placeholder="搜索学号/姓名"
|
||||
clearable
|
||||
style="width: 200px; margin-left: 10px"
|
||||
@keyup.enter="searchStudents"
|
||||
@clear="searchStudents"
|
||||
>
|
||||
<template #suffix>
|
||||
<el-icon class="el-input__icon" @click="searchStudents"><Search /></el-icon>
|
||||
</template>
|
||||
</el-input>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<el-table
|
||||
ref="tableRef"
|
||||
:data="filteredDetailList"
|
||||
border
|
||||
stripe
|
||||
:max-height="tableMaxHeight"
|
||||
:header-cell-style="{ background: '#f5f7fa' }"
|
||||
>
|
||||
<el-table-column label="学号" prop="studentNo" width="120" align="center" fixed />
|
||||
<el-table-column label="姓名" prop="studentName" width="100" align="center" fixed />
|
||||
<el-table-column label="性别" prop="gender" width="60" align="center">
|
||||
<template #default="scope">
|
||||
<dict-tag :options="sys_user_sex" :value="scope.row.gender" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="联系电话" prop="phone" width="120" align="center" />
|
||||
|
||||
<el-table-column label="心理状态" width="200" align="center">
|
||||
<template #default="scope">
|
||||
<el-radio-group v-model="scope.row.mentalStatus" @change="handleStatusChange(scope.row)">
|
||||
<el-radio label="1">健康</el-radio>
|
||||
<el-radio label="2">良好</el-radio>
|
||||
<el-radio label="3">重点关注</el-radio>
|
||||
</el-radio-group>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column label="分数" width="150" align="center">
|
||||
<template #default="scope">
|
||||
<el-input-number
|
||||
v-model="scope.row.score"
|
||||
:disabled="scope.row.mentalStatus !== '3'"
|
||||
:min="1"
|
||||
:max="100"
|
||||
size="small"
|
||||
placeholder="分数"
|
||||
@change="handleScoreChange(scope.row)"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column label="备注" align="center">
|
||||
<template #default="scope">
|
||||
<el-input
|
||||
v-model="scope.row.remark"
|
||||
type="textarea"
|
||||
:rows="1"
|
||||
placeholder="请输入备注信息"
|
||||
@blur="handleRemarkChange(scope.row)"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<div class="fixed-bottom-bar" v-if="detailList.length > 0">
|
||||
<el-button type="primary" size="large" @click="saveEvaluation" :loading="saveLoading">保存测评结果</el-button>
|
||||
</div>
|
||||
</el-card>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup name="XljkEvaluationFill" lang="ts">
|
||||
import { getEvaluation, listEvaluationDetail, batchUpdateEvaluationDetail } from '@/api/xljk/evaluation';
|
||||
import { XljkEvaluationVO, XljkEvaluationDetailVO, XljkEvaluationDetailForm } from '@/api/xljk/evaluation/types';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import { throttle } from 'lodash-es';
|
||||
|
||||
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
||||
const { evaluation_status, sys_user_sex } = toRefs<any>(proxy?.useDict('evaluation_status', 'sys_user_sex'));
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const evaluationId = ref(route.params.id as string);
|
||||
|
||||
const loading = ref(false);
|
||||
const saveLoading = ref(false);
|
||||
const evaluationInfo = ref<XljkEvaluationVO>({} as XljkEvaluationVO);
|
||||
const detailList = ref<XljkEvaluationDetailVO[]>([]);
|
||||
const filteredDetailList = ref<XljkEvaluationDetailVO[]>([]);
|
||||
const searchKeyword = ref('');
|
||||
const tableMaxHeight = ref(500);
|
||||
const tableRef = ref();
|
||||
|
||||
// 监听搜索关键字变化
|
||||
// watch(searchKeyword, searchStudents);
|
||||
|
||||
/** 获取测评基本信息 */
|
||||
const getEvaluationInfo = async () => {
|
||||
try {
|
||||
const res = await getEvaluation(evaluationId.value);
|
||||
evaluationInfo.value = res.data;
|
||||
|
||||
// 检查状态是否为"已发布"
|
||||
if (evaluationInfo.value.status !== '1') {
|
||||
proxy?.$modal.msgError('只能填写"已发布"状态的测评');
|
||||
setTimeout(() => {
|
||||
router.push('/xljk/evaluation');
|
||||
}, 1500);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取测评信息失败', error);
|
||||
}
|
||||
};
|
||||
|
||||
/** 获取测评明细列表 */
|
||||
const getDetailList = async () => {
|
||||
try {
|
||||
loading.value = true;
|
||||
const res = await listEvaluationDetail({
|
||||
pageNum: 1,
|
||||
pageSize: 1000, // 获取所有学生
|
||||
evaluationId: Number(evaluationId.value)
|
||||
});
|
||||
detailList.value = res.rows;
|
||||
filteredDetailList.value = [...detailList.value]; // 初始显示所有数据
|
||||
} catch (error) {
|
||||
console.error('获取测评明细失败', error);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
/** 已填写的人数 */
|
||||
const filledCount = computed(() => {
|
||||
return detailList.value.filter(item => item.mentalStatus).length;
|
||||
});
|
||||
|
||||
/** 返回列表页 */
|
||||
const goBack = () => {
|
||||
router.push('/xljk/evaluation');
|
||||
};
|
||||
|
||||
/** 处理心理状态变更 */
|
||||
const handleStatusChange = (row: XljkEvaluationDetailVO) => {
|
||||
// 如果状态不是重点关注,则分数设为空
|
||||
if (row.mentalStatus !== '3') {
|
||||
row.score = undefined;
|
||||
}
|
||||
};
|
||||
|
||||
/** 处理分数变更 */
|
||||
const handleScoreChange = (row: XljkEvaluationDetailVO) => {
|
||||
// 空实现,仅用于触发视图更新
|
||||
};
|
||||
|
||||
/** 处理备注变更 */
|
||||
const handleRemarkChange = (row: XljkEvaluationDetailVO) => {
|
||||
// 空实现,仅用于触发视图更新
|
||||
};
|
||||
|
||||
/** 处理搜索 */
|
||||
const searchStudents = () => {
|
||||
if (!searchKeyword.value) {
|
||||
// 如果搜索关键字为空,显示所有数据
|
||||
filteredDetailList.value = [...detailList.value];
|
||||
return;
|
||||
}
|
||||
|
||||
const keyword = searchKeyword.value.toLowerCase();
|
||||
filteredDetailList.value = detailList.value.filter(item => {
|
||||
return item.studentNo?.toLowerCase().includes(keyword) ||
|
||||
item.studentName?.toLowerCase().includes(keyword);
|
||||
});
|
||||
};
|
||||
|
||||
/** 保存测评结果 */
|
||||
const saveEvaluation = async () => {
|
||||
// 检查是否有未填写的记录
|
||||
const unfilledRecords = detailList.value.filter(item => !item.mentalStatus);
|
||||
|
||||
// 如果有未填写的记录,询问是否继续
|
||||
if (unfilledRecords.length > 0) {
|
||||
try {
|
||||
await proxy?.$modal.confirm(`还有 ${unfilledRecords.length} 名学生未填写心理状态,是否确认保存?`);
|
||||
} catch {
|
||||
return; // 用户取消保存
|
||||
}
|
||||
}
|
||||
|
||||
// 检查重点关注学生是否都有分数
|
||||
const noScoreItems = detailList.value.filter(item =>
|
||||
item.mentalStatus === '3' && (!item.score || item.score <= 0)
|
||||
);
|
||||
|
||||
if (noScoreItems.length > 0) {
|
||||
proxy?.$modal.msgError(`有 ${noScoreItems.length} 名重点关注学生未填写分数,请填写`);
|
||||
return;
|
||||
}
|
||||
|
||||
// 准备提交数据
|
||||
const updateData: XljkEvaluationDetailForm[] = detailList.value.map(item => ({
|
||||
id: item.id,
|
||||
evaluationId: Number(evaluationId.value),
|
||||
mentalStatus: item.mentalStatus,
|
||||
score: item.score,
|
||||
remark: item.remark
|
||||
}));
|
||||
|
||||
// 提交数据
|
||||
try {
|
||||
saveLoading.value = true;
|
||||
await batchUpdateEvaluationDetail(updateData);
|
||||
proxy?.$modal.msgSuccess('保存成功');
|
||||
} catch (error) {
|
||||
console.error('保存失败', error);
|
||||
} finally {
|
||||
saveLoading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
/** 设置表格高度 */
|
||||
const setTableHeight = () => {
|
||||
// 预留底部操作栏和边距空间
|
||||
const windowHeight = window.innerHeight;
|
||||
const headerHeight = 160; // 估计上方卡片和间距的高度
|
||||
const footerHeight = 80; // 底部按钮区域高度
|
||||
const padding = 40; // 额外的边距
|
||||
|
||||
tableMaxHeight.value = windowHeight - headerHeight - footerHeight - padding;
|
||||
};
|
||||
|
||||
/** 窗口大小变化时重设表格高度 */
|
||||
const handleResize = throttle(() => {
|
||||
setTableHeight();
|
||||
}, 200);
|
||||
|
||||
onMounted(() => {
|
||||
getEvaluationInfo();
|
||||
getDetailList();
|
||||
setTableHeight();
|
||||
|
||||
// 添加窗口大小变化监听
|
||||
window.addEventListener('resize', handleResize);
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
// 移除事件监听
|
||||
window.removeEventListener('resize', handleResize);
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.page-container {
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
.card-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.header-title {
|
||||
font-size: 16px;
|
||||
font-weight: bold;
|
||||
color: #303133;
|
||||
}
|
||||
|
||||
.header-buttons {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.header-right {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.fill-stats {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
font-size: 14px;
|
||||
color: #606266;
|
||||
}
|
||||
|
||||
.fixed-bottom-bar {
|
||||
position: sticky;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
padding: 15px 0;
|
||||
background-color: rgba(255, 255, 255, 0.9);
|
||||
backdrop-filter: blur(8px);
|
||||
box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
z-index: 100;
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.fixed-bottom-bar .el-button {
|
||||
min-width: 150px;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,499 @@
|
||||
<template>
|
||||
<div class="p-2 page-container">
|
||||
<transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
|
||||
<div v-show="showSearch" class="mb-[10px]">
|
||||
<el-card shadow="hover">
|
||||
<el-form ref="queryFormRef" :model="queryParams" label-width="100px">
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="6">
|
||||
<el-form-item label="测评名称" prop="evaluationName">
|
||||
<el-input v-model="queryParams.evaluationName" placeholder="请输入测评名称" clearable @keyup.enter="handleQuery" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-form-item label="院系" prop="departmentName">
|
||||
<el-select v-model="queryParams.departmentName" placeholder="请选择院系" clearable style="width: 100%" @change="handleDepartmentChange">
|
||||
<el-option
|
||||
v-for="dept in departmentOptions"
|
||||
:key="dept.name"
|
||||
:label="dept.name"
|
||||
:value="dept.name"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-form-item label="专业" prop="majorName">
|
||||
<el-select v-model="queryParams.majorName" placeholder="请选择专业" clearable style="width: 100%" @change="handleMajorChange">
|
||||
<el-option
|
||||
v-for="major in majorOptions"
|
||||
:key="major.name"
|
||||
:label="major.name"
|
||||
:value="major.name"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-form-item label="班级" prop="className">
|
||||
<el-select v-model="queryParams.className" placeholder="请选择班级" clearable style="width: 100%">
|
||||
<el-option
|
||||
v-for="cls in classOptions"
|
||||
:key="cls.name"
|
||||
:label="cls.name"
|
||||
:value="cls.name"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="6">
|
||||
<el-form-item label="学期" prop="semester">
|
||||
<el-select v-model="queryParams.semester" placeholder="请选择学期" clearable style="width: 100%">
|
||||
<el-option
|
||||
v-for="semester in semesterOptions"
|
||||
:key="semester.value"
|
||||
:label="semester.label"
|
||||
:value="semester.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-form-item label="状态" prop="status">
|
||||
<el-select v-model="queryParams.status" placeholder="请选择状态" clearable style="width: 100%">
|
||||
<el-option v-for="dict in evaluation_status" :key="dict.value" :label="dict.label" :value="dict.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-row>
|
||||
<el-col :span="24" class="search-btn-container">
|
||||
<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-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
</el-card>
|
||||
</div>
|
||||
</transition>
|
||||
|
||||
<el-card shadow="never" class="button-card table-card">
|
||||
<template #header>
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['xljk:evaluation:add']">新增</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button icon="Edit" :disabled="single" @click="handleUpdate()" v-hasPermi="['xljk:evaluation:edit']">修改</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['xljk:evaluation:remove']">删除</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button icon="Download" @click="handleExport" v-hasPermi="['xljk:evaluation:export']">导出</el-button>
|
||||
</el-col>
|
||||
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
</template>
|
||||
|
||||
<el-table v-loading="loading" border :data="evaluationList" @selection-change="handleSelectionChange" @row-dblclick="handleView">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="测评名称" align="center" prop="evaluationName" min-width="160" show-overflow-tooltip />
|
||||
<el-table-column label="院系" align="center" prop="departmentName" min-width="120" show-overflow-tooltip />
|
||||
<el-table-column label="专业" align="center" prop="majorName" min-width="120" show-overflow-tooltip />
|
||||
<el-table-column label="班级" align="center" prop="className" min-width="140" show-overflow-tooltip />
|
||||
<el-table-column label="学期" align="center" prop="semester" width="80" />
|
||||
<el-table-column label="状态" align="center" prop="status" width="80">
|
||||
<template #default="scope">
|
||||
<dict-tag :options="evaluation_status" :value="scope.row.status" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="学生人数" align="center" prop="studentCount" width="90">
|
||||
<template #default="scope">
|
||||
{{ scope.row.studentCount || 0 }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="重点关注人数" align="center" prop="focusCount" width="110">
|
||||
<template #default="scope">
|
||||
{{ scope.row.focusCount || 0 }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="创建者" align="center" prop="createName" width="100" />
|
||||
<el-table-column label="创建时间" align="center" prop="createTime" width="150">
|
||||
<template #default="scope">
|
||||
<span>{{ parseTime(scope.row.createTime) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="220" fixed="right">
|
||||
<template #default="scope">
|
||||
<el-tooltip content="查看" placement="top">
|
||||
<el-button
|
||||
link
|
||||
type="info"
|
||||
icon="View"
|
||||
size="default"
|
||||
style="font-size: 16px; margin-right: 8px"
|
||||
@click="handleView(scope.row)"
|
||||
v-hasPermi="['xljk:evaluation:query']"
|
||||
></el-button>
|
||||
</el-tooltip>
|
||||
|
||||
<!-- 仅草稿状态可修改 -->
|
||||
<el-tooltip content="修改" placement="top" v-if="scope.row.status === '0'">
|
||||
<el-button
|
||||
link
|
||||
type="primary"
|
||||
icon="Edit"
|
||||
size="default"
|
||||
style="font-size: 16px; margin-right: 8px"
|
||||
@click="handleUpdate(scope.row)"
|
||||
v-hasPermi="['xljk:evaluation:edit']"
|
||||
></el-button>
|
||||
</el-tooltip>
|
||||
|
||||
<!-- 仅草稿状态可删除 -->
|
||||
<el-tooltip content="删除" placement="top" v-if="scope.row.status === '0'">
|
||||
<el-button
|
||||
link
|
||||
type="danger"
|
||||
icon="Delete"
|
||||
size="default"
|
||||
style="font-size: 16px; margin-right: 8px"
|
||||
@click="handleDelete(scope.row)"
|
||||
v-hasPermi="['xljk:evaluation:remove']"
|
||||
></el-button>
|
||||
</el-tooltip>
|
||||
|
||||
<!-- 草稿状态可发布 -->
|
||||
<el-tooltip content="发布" placement="top" v-if="scope.row.status === '0'">
|
||||
<el-button
|
||||
link
|
||||
type="success"
|
||||
icon="Check"
|
||||
size="default"
|
||||
style="font-size: 16px; margin-right: 8px"
|
||||
@click="handlePublish(scope.row)"
|
||||
v-hasPermi="['xljk:evaluation:edit']"
|
||||
></el-button>
|
||||
</el-tooltip>
|
||||
|
||||
<!-- 已发布状态可填写 -->
|
||||
<el-tooltip content="填写" placement="top" v-if="scope.row.status === '1'">
|
||||
<el-button
|
||||
link
|
||||
type="warning"
|
||||
icon="Edit"
|
||||
size="default"
|
||||
style="font-size: 16px; margin-right: 8px"
|
||||
@click="handleEdit(scope.row)"
|
||||
v-hasPermi="['xljk:evaluation:edit']"
|
||||
></el-button>
|
||||
</el-tooltip>
|
||||
|
||||
<!-- 已发布状态可完成 -->
|
||||
<el-tooltip content="完成" placement="top" v-if="scope.row.status === '1'">
|
||||
<el-button
|
||||
link
|
||||
type="success"
|
||||
icon="CircleCheck"
|
||||
size="default"
|
||||
style="font-size: 16px"
|
||||
@click="handleComplete(scope.row)"
|
||||
v-hasPermi="['xljk:evaluation:edit']"
|
||||
></el-button>
|
||||
</el-tooltip>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<div class="pagination-container">
|
||||
<pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
|
||||
</div>
|
||||
</el-card>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { listEvaluation, getEvaluation, delEvaluation, addEvaluation, updateEvaluation, publishEvaluation, completeEvaluation, getCollegeOptions, getMajorOptions, getClassOptions, getSemesterOptions } from '@/api/xljk/evaluation';
|
||||
import { XljkEvaluationVO, XljkEvaluationForm, XljkEvaluationQuery, CollegeOption, MajorOption, ClassOption, SemesterOption } from '@/api/xljk/evaluation/types';
|
||||
|
||||
// 基本变量
|
||||
const { proxy } = getCurrentInstance() as any;
|
||||
const { evaluation_status } = toRefs(proxy?.useDict('evaluation_status'));
|
||||
|
||||
const evaluationList = ref<XljkEvaluationVO[]>([]);
|
||||
const buttonLoading = ref(false);
|
||||
const loading = ref(true);
|
||||
const showSearch = ref(true);
|
||||
const ids = ref<Array<string | number>>([]);
|
||||
const single = ref(true);
|
||||
const multiple = ref(true);
|
||||
const total = ref(0);
|
||||
|
||||
// 选项数据
|
||||
const departmentOptions = ref<CollegeOption[]>([]);
|
||||
const majorOptions = ref<MajorOption[]>([]);
|
||||
const classOptions = ref<ClassOption[]>([]);
|
||||
const semesterOptions = ref<SemesterOption[]>([]);
|
||||
|
||||
const queryFormRef = ref();
|
||||
|
||||
// 查询参数
|
||||
const queryParams = ref<XljkEvaluationQuery>({
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
departmentName: undefined,
|
||||
evaluationName: undefined,
|
||||
majorName: undefined,
|
||||
className: undefined,
|
||||
semester: undefined,
|
||||
status: undefined,
|
||||
params: {}
|
||||
});
|
||||
|
||||
/** 获取院系选项 */
|
||||
const getDepartments = async () => {
|
||||
try {
|
||||
const res = await getCollegeOptions();
|
||||
departmentOptions.value = res.data || [];
|
||||
} catch (error) {
|
||||
console.error('获取院系选项失败', error);
|
||||
}
|
||||
};
|
||||
|
||||
/** 查询专业选项 */
|
||||
const getMajors = async (collegeName?: string) => {
|
||||
try {
|
||||
const res = await getMajorOptions(collegeName);
|
||||
majorOptions.value = res.data || [];
|
||||
} catch (error) {
|
||||
console.error('获取专业选项失败', error);
|
||||
}
|
||||
};
|
||||
|
||||
/** 查询班级选项 */
|
||||
const getClasses = async (collegeName?: string, majorName?: string) => {
|
||||
try {
|
||||
const res = await getClassOptions(collegeName, majorName);
|
||||
classOptions.value = res.data || [];
|
||||
} catch (error) {
|
||||
console.error('获取班级选项失败', error);
|
||||
}
|
||||
};
|
||||
|
||||
/** 获取学期选项 */
|
||||
const getSemesters = async () => {
|
||||
try {
|
||||
const res = await getSemesterOptions();
|
||||
semesterOptions.value = res.data || [];
|
||||
} catch (error) {
|
||||
console.error('获取学期选项失败', error);
|
||||
}
|
||||
};
|
||||
|
||||
/** 院系选择变化时更新专业选项 */
|
||||
const handleDepartmentChange = async (collegeName: string) => {
|
||||
// 清空专业和班级选择
|
||||
queryParams.value.majorName = undefined;
|
||||
queryParams.value.className = undefined;
|
||||
majorOptions.value = [];
|
||||
classOptions.value = [];
|
||||
|
||||
if (collegeName) {
|
||||
// 获取该院系下的专业
|
||||
await getMajors(collegeName);
|
||||
} else {
|
||||
// 如果清空院系,则获取所有专业
|
||||
await getMajors();
|
||||
}
|
||||
};
|
||||
|
||||
/** 专业选择变化时更新班级选项 */
|
||||
const handleMajorChange = async (majorName: string) => {
|
||||
queryParams.value.className = undefined; // 清空班级选择
|
||||
classOptions.value = [];
|
||||
|
||||
if (queryParams.value.departmentName && majorName) {
|
||||
// 获取该院系和专业下的班级
|
||||
await getClasses(queryParams.value.departmentName, majorName);
|
||||
}
|
||||
};
|
||||
|
||||
/** 查询心理健康测评列表 */
|
||||
const getList = async () => {
|
||||
loading.value = true;
|
||||
try {
|
||||
const res = await listEvaluation(queryParams.value);
|
||||
evaluationList.value = res.rows;
|
||||
total.value = res.total;
|
||||
} catch (error) {
|
||||
console.error('获取测评列表失败', error);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
/** 搜索按钮操作 */
|
||||
const handleQuery = () => {
|
||||
queryParams.value.pageNum = 1;
|
||||
getList();
|
||||
};
|
||||
|
||||
/** 重置按钮操作 */
|
||||
const resetQuery = () => {
|
||||
queryFormRef.value?.resetFields();
|
||||
handleQuery();
|
||||
};
|
||||
|
||||
/** 多选框选中数据 */
|
||||
const handleSelectionChange = (selection: XljkEvaluationVO[]) => {
|
||||
ids.value = selection.map((item) => item.id);
|
||||
|
||||
// 判断是否有非草稿状态
|
||||
const hasNonDraft = selection.some(item => item.status !== '0');
|
||||
single.value = selection.length !== 1 || hasNonDraft;
|
||||
multiple.value = !selection.length || hasNonDraft;
|
||||
};
|
||||
|
||||
/** 新增按钮操作 */
|
||||
const handleAdd = async () => {
|
||||
proxy?.$router.push({ path: '/xljk/evaluation/add' });
|
||||
};
|
||||
|
||||
/** 查看按钮操作 */
|
||||
const handleView = (row: XljkEvaluationVO) => {
|
||||
proxy?.$router.push({ path: `/xljk/evaluation/detail/${row.id}` });
|
||||
};
|
||||
|
||||
/** 修改按钮操作 */
|
||||
const handleUpdate = (row?: XljkEvaluationVO) => {
|
||||
const id = row?.id || ids.value[0];
|
||||
proxy?.$router.push({ path: `/xljk/evaluation/edit/${id}` });
|
||||
};
|
||||
|
||||
/** 填写评测 */
|
||||
const handleEdit = (row: XljkEvaluationVO) => {
|
||||
proxy?.$router.push({ path: `/xljk/evaluation/fill/${row.id}` });
|
||||
};
|
||||
|
||||
/** 删除按钮操作 */
|
||||
const handleDelete = async (row?: XljkEvaluationVO) => {
|
||||
const _ids = row?.id || ids.value;
|
||||
|
||||
// 检查是否有非草稿状态的记录
|
||||
if (!row) {
|
||||
const selectedRecords = evaluationList.value.filter(item => ids.value.includes(item.id));
|
||||
if (selectedRecords.some(item => item.status !== '0')) {
|
||||
proxy?.$modal.msgError('只能删除草稿状态的测评');
|
||||
return;
|
||||
}
|
||||
} else if (row.status !== '0') {
|
||||
proxy?.$modal.msgError('只能删除草稿状态的测评');
|
||||
return;
|
||||
}
|
||||
|
||||
const confirmMessage = row
|
||||
? `是否确认删除测评"${row.evaluationName}"?`
|
||||
: `是否确认删除选中的${ids.value.length}条数据?`;
|
||||
|
||||
await proxy?.$modal.confirm(confirmMessage);
|
||||
try {
|
||||
loading.value = true;
|
||||
await delEvaluation(_ids);
|
||||
proxy?.$modal.msgSuccess('删除成功');
|
||||
await getList();
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
/** 发布按钮操作 */
|
||||
const handlePublish = async (row: XljkEvaluationVO) => {
|
||||
await proxy?.$modal.confirm(`是否确认发布测评"${row.evaluationName}"?发布后将无法修改测评基本信息。`);
|
||||
try {
|
||||
loading.value = true;
|
||||
await publishEvaluation(row.id);
|
||||
proxy?.$modal.msgSuccess('发布成功');
|
||||
await getList();
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
/** 完成按钮操作 */
|
||||
const handleComplete = async (row: XljkEvaluationVO) => {
|
||||
await proxy?.$modal.confirm(`是否确认完成测评"${row.evaluationName}"?完成后将无法再修改测评结果。`);
|
||||
try {
|
||||
loading.value = true;
|
||||
await completeEvaluation(row.id);
|
||||
proxy?.$modal.msgSuccess('操作成功');
|
||||
await getList();
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
/** 导出按钮操作 */
|
||||
const handleExport = () => {
|
||||
proxy?.download(
|
||||
'xljk/evaluation/export',
|
||||
{
|
||||
...queryParams.value
|
||||
},
|
||||
`evaluation_${new Date().getTime()}.xlsx`
|
||||
);
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
getList();
|
||||
getDepartments();
|
||||
getMajors();
|
||||
getSemesters();
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
/* 页面容器样式 */
|
||||
.page-container {
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
/* 表格卡片布局 */
|
||||
.table-card {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.table-card :deep(.el-card__body) {
|
||||
padding: 0px 20px 20px 20px !important;
|
||||
}
|
||||
|
||||
/* 移除按钮栏底部边框 */
|
||||
.button-card :deep(.el-card__header) {
|
||||
border-bottom: none !important;
|
||||
}
|
||||
|
||||
/* 分页容器样式 */
|
||||
.pagination-container {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
padding: 16px 20px 0 0 !important;
|
||||
background-color: #fff;
|
||||
margin-top: 0px !important;
|
||||
}
|
||||
|
||||
/* 搜索按钮容器样式 */
|
||||
.search-btn-container {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
margin-top: 10px;
|
||||
|
||||
.el-form-item {
|
||||
margin-bottom: 0 !important;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user