心理健康测评完成
This commit is contained in:
1 parent
75201841cd
commit
4b9be58b18
45 files changed
+2867
-332
No files matched your search
@@ -119,7 +119,7 @@ export const getSemesterOptions = () => {
|
||||
});
|
||||
};
|
||||
|
||||
// 发布测评
|
||||
// 发布测评(已废弃,改为提交功能)
|
||||
export const publishEvaluation = (id: string | number) => {
|
||||
return request({
|
||||
url: `/xljk/evaluation/${id}/publish`,
|
||||
@@ -127,7 +127,7 @@ export const publishEvaluation = (id: string | number) => {
|
||||
});
|
||||
};
|
||||
|
||||
// 完成测评
|
||||
// 提交测评
|
||||
export const completeEvaluation = (id: string | number) => {
|
||||
return request({
|
||||
url: `/xljk/evaluation/${id}/complete`,
|
||||
|
||||
@@ -45,7 +45,7 @@ export interface XljkEvaluationVO {
|
||||
semester: string;
|
||||
|
||||
/**
|
||||
* 状态(0-草稿,1-已发布,2-已完成)
|
||||
* 状态(0-草稿,2-已完成)
|
||||
*/
|
||||
status: string;
|
||||
|
||||
@@ -137,7 +137,7 @@ export interface XljkEvaluationForm extends BaseEntity {
|
||||
semester?: string;
|
||||
|
||||
/**
|
||||
* 状态(0-草稿,1-已发布,2-已完成)
|
||||
* 状态(0-草稿,2-已完成)
|
||||
*/
|
||||
status?: string;
|
||||
|
||||
@@ -443,6 +443,11 @@ export interface StudentInfo {
|
||||
}
|
||||
|
||||
export interface CollegeOption {
|
||||
/**
|
||||
* 院系ID
|
||||
*/
|
||||
id: number;
|
||||
|
||||
/**
|
||||
* 院系名称
|
||||
*/
|
||||
@@ -450,6 +455,11 @@ export interface CollegeOption {
|
||||
}
|
||||
|
||||
export interface MajorOption {
|
||||
/**
|
||||
* 专业ID
|
||||
*/
|
||||
id: number;
|
||||
|
||||
/**
|
||||
* 专业名称
|
||||
*/
|
||||
@@ -457,6 +467,11 @@ export interface MajorOption {
|
||||
}
|
||||
|
||||
export interface ClassOption {
|
||||
/**
|
||||
* 班级ID
|
||||
*/
|
||||
id: number;
|
||||
|
||||
/**
|
||||
* 班级名称
|
||||
*/
|
||||
|
||||
@@ -98,25 +98,25 @@ export const constantRoutes: RouteRecordRaw[] = [
|
||||
path: 'evaluation/detail/:id',
|
||||
component: () => import('@/views/xljk/evaluation/detail.vue'),
|
||||
name: 'XljkEvaluationDetail',
|
||||
meta: { title: '心理健康测评详情', icon: 'form', activeMenu: '/xljk/evaluation' }
|
||||
meta: { title: '心理健康测评详情', icon: 'form', activeMenu: '/xljk/evaluation', noCache: true }
|
||||
},
|
||||
{
|
||||
path: 'evaluation/add',
|
||||
component: () => import('@/views/xljk/evaluation/add.vue'),
|
||||
name: 'XljkEvaluationAdd',
|
||||
meta: { title: '新增心理健康测评', icon: 'form', activeMenu: '/xljk/evaluation' }
|
||||
meta: { title: '新增心理健康测评', icon: 'form', activeMenu: '/xljk/evaluation', noCache: true }
|
||||
},
|
||||
{
|
||||
path: 'evaluation/edit/:id',
|
||||
component: () => import('@/views/xljk/evaluation/edit.vue'),
|
||||
name: 'XljkEvaluationEdit',
|
||||
meta: { title: '编辑心理健康测评', icon: 'form', activeMenu: '/xljk/evaluation' }
|
||||
meta: { title: '编辑心理健康测评', icon: 'form', activeMenu: '/xljk/evaluation', noCache: true }
|
||||
},
|
||||
{
|
||||
path: 'evaluation/fill/:id',
|
||||
component: () => import('@/views/xljk/evaluation/fill.vue'),
|
||||
name: 'XljkEvaluationFill',
|
||||
meta: { title: '填写心理健康测评', icon: 'form', activeMenu: '/xljk/evaluation' }
|
||||
meta: { title: '填写心理健康测评', icon: 'form', activeMenu: '/xljk/evaluation', noCache: true }
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -134,7 +134,7 @@ export const dynamicRoutes: RouteRecordRaw[] = [
|
||||
path: 'evaluation',
|
||||
component: () => import('@/views/xljk/evaluation/index.vue'),
|
||||
name: 'XljkEvaluation',
|
||||
meta: { title: '心理健康测评', icon: 'heart', permissions: ['xljk:evaluation:list'] }
|
||||
meta: { title: '心理健康测评', icon: 'heart', permissions: ['xljk:evaluation:list'], noCache: true }
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
export const errorCode: any = {
|
||||
'401': '认证失败,无法访问系统资源',
|
||||
'403': '当前操作没有权限',
|
||||
'403': '无访问权限',
|
||||
'404': '访问资源不存在',
|
||||
default: '系统未知错误,请反馈给管理员'
|
||||
};
|
||||
|
||||
@@ -177,6 +177,17 @@ service.interceptors.response.use(
|
||||
console.log('404错误被静默处理,不显示用户提示');
|
||||
return Promise.reject(error);
|
||||
}
|
||||
|
||||
// 对心理健康测评详情页面的403错误进行特殊处理
|
||||
if (statusCode === '403') {
|
||||
const url = error.config.url;
|
||||
// 如果是心理健康测评详情相关的API,不显示错误提示
|
||||
if (url && (url.includes('/xljk/evaluation/') || url.includes('/xljk/evaluation/detail/'))) {
|
||||
console.log('心理健康测评详情页面403错误被静默处理,不显示用户提示');
|
||||
return Promise.reject(error);
|
||||
}
|
||||
}
|
||||
|
||||
message = '系统接口' + statusCode + '异常';
|
||||
}
|
||||
ElMessage({ message: message, type: 'error', duration: 5 * 1000 });
|
||||
|
||||
@@ -1,93 +1,112 @@
|
||||
<template>
|
||||
<div class="p-2 page-container">
|
||||
<el-card shadow="hover" class="mb-[10px]">
|
||||
<el-card shadow="hover" class="mb-[10px]" v-loading="formLoading">
|
||||
<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 ref="formRef" :model="form" :rules="rules" label-width="100px">
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="测评名称" prop="evaluationName">
|
||||
<el-input
|
||||
v-model="form.evaluationName"
|
||||
placeholder="请输入测评名称"
|
||||
style="width: 100%"
|
||||
maxlength="100"
|
||||
show-word-limit
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="学期" prop="semester">
|
||||
<el-input
|
||||
v-model="form.semester"
|
||||
placeholder="请输入学期,如:2024上学期"
|
||||
style="width: 100%"
|
||||
maxlength="50"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<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-row :gutter="20">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="院系" prop="departmentName">
|
||||
<el-select
|
||||
v-model="form.departmentName"
|
||||
placeholder="请选择院系"
|
||||
style="width: 100%"
|
||||
@change="handleCollegeChange"
|
||||
:loading="collegeLoading"
|
||||
>
|
||||
<el-option
|
||||
v-for="college in collegeOptions"
|
||||
:key="college.id"
|
||||
:label="college.name"
|
||||
:value="college.name"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="专业" prop="majorName">
|
||||
<el-select
|
||||
v-model="form.majorName"
|
||||
placeholder="请选择专业"
|
||||
style="width: 100%"
|
||||
@change="handleMajorChange"
|
||||
:disabled="!form.departmentName"
|
||||
:loading="majorLoading"
|
||||
>
|
||||
<el-option
|
||||
v-for="major in majorOptions"
|
||||
:key="major.id"
|
||||
:label="major.name"
|
||||
:value="major.name"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<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-row :gutter="20">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="班级" prop="className">
|
||||
<el-select
|
||||
v-model="form.className"
|
||||
placeholder="请选择班级"
|
||||
style="width: 100%"
|
||||
@change="handleClassChange"
|
||||
:disabled="!form.majorName"
|
||||
:loading="classLoading"
|
||||
>
|
||||
<el-option
|
||||
v-for="cls in classOptions"
|
||||
:key="cls.id"
|
||||
:label="cls.name"
|
||||
:value="cls.name"
|
||||
:data-id="cls.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input
|
||||
v-model="form.remark"
|
||||
type="textarea"
|
||||
placeholder="请输入备注信息"
|
||||
style="width: 100%"
|
||||
:rows="1"
|
||||
maxlength="500"
|
||||
show-word-limit
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-form-item>
|
||||
<div class="form-buttons">
|
||||
@@ -117,14 +136,36 @@
|
||||
:closable="false"
|
||||
/>
|
||||
|
||||
<!-- 批量操作区域 -->
|
||||
<div class="batch-actions" v-if="studentList.length > 0">
|
||||
<span class="batch-label">批量设置心理状态:</span>
|
||||
<el-radio-group v-model="batchMentalStatus">
|
||||
<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-button type="primary" size="small" @click="applyBatchMentalStatus" :disabled="selectedStudents.length === 0">
|
||||
应用到所选学生
|
||||
</el-button>
|
||||
<el-button type="info" size="small" @click="applyBatchMentalStatusToAll">
|
||||
应用到全部学生
|
||||
</el-button>
|
||||
<el-button type="warning" size="small" @click="resetAllMentalStatus">
|
||||
重置所有状态
|
||||
</el-button>
|
||||
<span class="batch-hint">已选择 {{ selectedStudents.length }} 名学生</span>
|
||||
</div>
|
||||
|
||||
<!-- 学生列表表格 -->
|
||||
<el-table
|
||||
v-else
|
||||
v-if="studentList.length > 0"
|
||||
:data="studentList"
|
||||
border
|
||||
stripe
|
||||
style="width: 100%"
|
||||
@selection-change="handleSelectionChange"
|
||||
>
|
||||
<el-table-column type="selection" width="55" />
|
||||
<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">
|
||||
@@ -195,13 +236,35 @@
|
||||
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';
|
||||
import { ElMessage, ElMessageBox } from 'element-plus';
|
||||
|
||||
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
||||
const { proxy } = getCurrentInstance() as any;
|
||||
|
||||
const router = useRouter();
|
||||
const formRef = ref<ElFormInstance>();
|
||||
const submitLoading = ref(false);
|
||||
const studentsLoading = ref(false);
|
||||
const formLoading = ref(false);
|
||||
const collegeLoading = ref(false);
|
||||
const majorLoading = ref(false);
|
||||
const classLoading = ref(false);
|
||||
const batchMentalStatus = ref('1'); // 默认批量设置为"健康"
|
||||
const selectedStudents = ref<StudentInfo[]>([]); // 选中的学生
|
||||
|
||||
/** 自动生成当前学期 */
|
||||
const generateCurrentSemester = () => {
|
||||
const now = new Date();
|
||||
const year = now.getFullYear();
|
||||
const month = now.getMonth() + 1; // 月份从0开始
|
||||
|
||||
// 上半年(1-7月)为下学期,下半年(8-12月)为上学期
|
||||
if (month >= 8) {
|
||||
return `${year}上学期`;
|
||||
} else if (month <= 7) {
|
||||
return `${year}下学期`;
|
||||
}
|
||||
return `${year}上学期`; // 默认返回上学期
|
||||
};
|
||||
|
||||
// 表单数据
|
||||
const form = ref<XljkEvaluationForm>({
|
||||
@@ -212,11 +275,29 @@ const form = ref<XljkEvaluationForm>({
|
||||
majorId: undefined, // 这里保留majorId字段,但实际使用majorName
|
||||
className: undefined,
|
||||
classId: undefined, // 这里保留classId字段,但实际使用className
|
||||
semester: undefined,
|
||||
semester: generateCurrentSemester(), // 自动生成当前学期
|
||||
status: '0', // 默认为草稿状态
|
||||
remark: undefined
|
||||
});
|
||||
|
||||
/** 自动生成测评名称 */
|
||||
const generateEvaluationName = () => {
|
||||
const semester = form.value.semester || '';
|
||||
const className = form.value.className || '';
|
||||
|
||||
if (semester && className) {
|
||||
return `${semester}${className}心理健康测评`;
|
||||
}
|
||||
return '';
|
||||
};
|
||||
|
||||
// 监听学期变化,自动更新测评名称
|
||||
watch(() => form.value.semester, (newSemester) => {
|
||||
if (newSemester && form.value.className) {
|
||||
form.value.evaluationName = generateEvaluationName();
|
||||
}
|
||||
});
|
||||
|
||||
// 表单验证规则
|
||||
const rules = {
|
||||
evaluationName: [{ required: true, message: '测评名称不能为空', trigger: 'blur' }],
|
||||
@@ -235,30 +316,72 @@ const studentList = ref<StudentInfo[]>([]);
|
||||
/** 获取院系选项 */
|
||||
const getColleges = async () => {
|
||||
try {
|
||||
collegeLoading.value = true;
|
||||
formLoading.value = true;
|
||||
const res = await getCollegeOptions();
|
||||
collegeOptions.value = res.data || [];
|
||||
|
||||
// 如果获取到院系选项,自动选择第一个
|
||||
if (collegeOptions.value.length > 0) {
|
||||
form.value.departmentName = collegeOptions.value[0].name;
|
||||
form.value.departmentId = collegeOptions.value[0].id;
|
||||
|
||||
// 获取对应的专业选项
|
||||
await getMajors(form.value.departmentName);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取院系选项失败', error);
|
||||
} finally {
|
||||
collegeLoading.value = false;
|
||||
formLoading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
/** 获取专业选项 */
|
||||
const getMajors = async (collegeName: string) => {
|
||||
try {
|
||||
majorLoading.value = true;
|
||||
formLoading.value = true;
|
||||
const res = await getMajorOptions(collegeName);
|
||||
majorOptions.value = res.data || [];
|
||||
|
||||
// 如果获取到专业选项,自动选择第一个
|
||||
if (majorOptions.value.length > 0) {
|
||||
form.value.majorName = majorOptions.value[0].name;
|
||||
form.value.majorId = majorOptions.value[0].id;
|
||||
|
||||
// 获取对应的班级选项
|
||||
await getClasses(form.value.departmentName, form.value.majorName);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取专业选项失败', error);
|
||||
} finally {
|
||||
majorLoading.value = false;
|
||||
formLoading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
/** 获取班级选项 */
|
||||
const getClasses = async (collegeName: string, majorName: string) => {
|
||||
try {
|
||||
classLoading.value = true;
|
||||
formLoading.value = true;
|
||||
const res = await getClassOptions(collegeName, majorName);
|
||||
classOptions.value = res.data || [];
|
||||
|
||||
// 如果获取到班级选项,自动选择第一个
|
||||
if (classOptions.value.length > 0) {
|
||||
form.value.className = classOptions.value[0].name;
|
||||
form.value.classId = classOptions.value[0].id;
|
||||
|
||||
// 获取班级学生列表
|
||||
await handleClassChange(form.value.className);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取班级选项失败', error);
|
||||
} finally {
|
||||
classLoading.value = false;
|
||||
formLoading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -297,11 +420,25 @@ const handleClassChange = async (className: string) => {
|
||||
return;
|
||||
}
|
||||
|
||||
// 设置班级ID
|
||||
const selectedClass = classOptions.value.find(c => c.name === className);
|
||||
if (selectedClass) {
|
||||
form.value.classId = selectedClass.id;
|
||||
}
|
||||
|
||||
// 自动生成测评名称
|
||||
form.value.evaluationName = generateEvaluationName();
|
||||
|
||||
// 获取班级学生列表
|
||||
try {
|
||||
studentsLoading.value = true;
|
||||
const res = await getStudentsByClass(form.value.departmentName, form.value.majorName, className);
|
||||
studentList.value = res.data || [];
|
||||
// 设置默认的心理状态为"健康"
|
||||
studentList.value = (res.data || []).map(student => ({
|
||||
...student,
|
||||
mentalStatus: '1', // 默认设置为"健康"
|
||||
remark: '' // 初始化备注为空字符串
|
||||
}));
|
||||
} catch (error) {
|
||||
console.error('获取班级学生列表失败', error);
|
||||
studentList.value = [];
|
||||
@@ -326,6 +463,60 @@ const countFocusStudents = () => {
|
||||
return studentList.value.filter(student => student.mentalStatus === '3').length;
|
||||
};
|
||||
|
||||
/** 批量设置心理状态 */
|
||||
const applyBatchMentalStatus = () => {
|
||||
const newStatus = batchMentalStatus.value;
|
||||
selectedStudents.value.forEach(student => {
|
||||
student.mentalStatus = newStatus;
|
||||
// 如果心理状态是"重点关注",设置默认分数
|
||||
if (newStatus === '3') {
|
||||
student.score = student.score || 70;
|
||||
} else {
|
||||
student.score = undefined;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/** 批量设置心理状态到全部学生 */
|
||||
const applyBatchMentalStatusToAll = () => {
|
||||
const newStatus = batchMentalStatus.value;
|
||||
studentList.value.forEach(student => {
|
||||
student.mentalStatus = newStatus;
|
||||
// 如果心理状态是"重点关注",设置默认分数
|
||||
if (newStatus === '3') {
|
||||
student.score = student.score || 70;
|
||||
} else {
|
||||
student.score = undefined;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/** 重置所有学生的心理状态 */
|
||||
const resetAllMentalStatus = () => {
|
||||
ElMessageBox.confirm('确认要将所有学生的心理状态重置为"健康"吗?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
studentList.value.forEach(student => {
|
||||
student.mentalStatus = '1'; // 重置为"健康"
|
||||
student.score = undefined; // 清空分数
|
||||
student.remark = ''; // 清空备注
|
||||
});
|
||||
ElMessage({
|
||||
type: 'success',
|
||||
message: '已重置所有学生的心理状态'
|
||||
});
|
||||
}).catch(() => {
|
||||
// 取消操作
|
||||
});
|
||||
};
|
||||
|
||||
/** 处理表格多选 */
|
||||
const handleSelectionChange = (selection: StudentInfo[]) => {
|
||||
selectedStudents.value = selection;
|
||||
};
|
||||
|
||||
/** 提交表单 */
|
||||
const submitForm = () => {
|
||||
formRef.value?.validate(async (valid: boolean) => {
|
||||
@@ -354,18 +545,22 @@ const submitForm = () => {
|
||||
return;
|
||||
}
|
||||
|
||||
// 确保ID字段有值,即使是临时值
|
||||
if (form.value.departmentName && !form.value.departmentId) {
|
||||
form.value.departmentId = 0; // 临时ID,后端会基于departmentName处理
|
||||
// 确保ID字段有值,使用从选项中获取的ID
|
||||
if (form.value.departmentName) {
|
||||
const selectedCollege = collegeOptions.value.find(c => c.name === form.value.departmentName);
|
||||
if (selectedCollege) {
|
||||
form.value.departmentId = selectedCollege.id;
|
||||
}
|
||||
}
|
||||
|
||||
if (form.value.majorName && !form.value.majorId) {
|
||||
form.value.majorId = 0; // 临时ID,后端会基于majorName处理
|
||||
if (form.value.majorName) {
|
||||
const selectedMajor = majorOptions.value.find(m => m.name === form.value.majorName);
|
||||
if (selectedMajor) {
|
||||
form.value.majorId = selectedMajor.id;
|
||||
}
|
||||
}
|
||||
|
||||
if (form.value.className && !form.value.classId) {
|
||||
form.value.classId = 0; // 临时ID,后端会基于className处理
|
||||
}
|
||||
// 班级ID已在handleClassChange中设置
|
||||
|
||||
// 先创建测评
|
||||
const res = await addEvaluation(form.value);
|
||||
@@ -386,9 +581,9 @@ const submitForm = () => {
|
||||
gender: student.gender,
|
||||
birthDate: student.birthDate,
|
||||
phone: student.phone,
|
||||
mentalStatus: student.mentalStatus || '1', // 默认健康
|
||||
mentalStatus: student.mentalStatus || '1', // 确保有默认值"健康"
|
||||
score: student.mentalStatus === '3' ? student.score : undefined,
|
||||
remark: student.remark
|
||||
remark: student.remark || '' // 确保备注有默认值
|
||||
};
|
||||
});
|
||||
|
||||
@@ -399,7 +594,7 @@ const submitForm = () => {
|
||||
// 注:这部分逻辑可能需要在后端自动处理
|
||||
|
||||
proxy?.$modal.msgSuccess('新增成功');
|
||||
router.push('/xljk/evaluation');
|
||||
router.replace('/xljk/evaluation');
|
||||
} else {
|
||||
proxy?.$modal.msgError('新增测评失败');
|
||||
}
|
||||
@@ -414,7 +609,7 @@ const submitForm = () => {
|
||||
|
||||
/** 取消按钮 */
|
||||
const cancel = () => {
|
||||
router.push('/xljk/evaluation');
|
||||
router.replace('/xljk/evaluation');
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
@@ -423,10 +618,12 @@ onMounted(() => {
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
/* 页面容器样式 */
|
||||
.page-container {
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
/* 表格卡片布局 */
|
||||
.card-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
@@ -445,7 +642,14 @@ onMounted(() => {
|
||||
}
|
||||
|
||||
.form-buttons {
|
||||
margin-top: 10px;
|
||||
margin-top: 0;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
/* 减小表单项之间的间距 */
|
||||
:deep(.el-form-item) {
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.student-count {
|
||||
@@ -454,4 +658,25 @@ onMounted(() => {
|
||||
color: #606266;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.batch-actions {
|
||||
margin-bottom: 10px;
|
||||
padding: 10px;
|
||||
background-color: #f5f7fa;
|
||||
border-radius: 4px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.batch-label {
|
||||
font-size: 14px;
|
||||
color: #303133;
|
||||
}
|
||||
|
||||
.batch-hint {
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
margin-left: 10px;
|
||||
}
|
||||
</style>
|
||||
@@ -26,7 +26,7 @@
|
||||
</el-card>
|
||||
|
||||
<!-- 统计信息卡片 -->
|
||||
<el-card shadow="hover" class="mb-[10px]" v-loading="statisticsLoading">
|
||||
<el-card shadow="hover" class="mb-[10px] statistics-card" v-loading="statisticsLoading">
|
||||
<template #header>
|
||||
<div class="card-header">
|
||||
<span class="header-title">测评统计</span>
|
||||
@@ -35,29 +35,37 @@
|
||||
|
||||
<div class="statistics-container">
|
||||
<div class="statistics-row">
|
||||
<el-statistic title="学生总数" :value="statistics.totalStudents">
|
||||
<template #suffix>
|
||||
<span class="suffix-label">人</span>
|
||||
</template>
|
||||
</el-statistic>
|
||||
<div class="statistic-item">
|
||||
<el-statistic title="学生总数" :value="statistics.totalStudents">
|
||||
<template #suffix>
|
||||
<span class="suffix-label">人</span>
|
||||
</template>
|
||||
</el-statistic>
|
||||
</div>
|
||||
|
||||
<el-statistic title="健康学生" :value="statistics.healthyCount">
|
||||
<template #suffix>
|
||||
<span class="suffix-label">人 ({{ formatPercent(statistics.healthyPercent) }})</span>
|
||||
</template>
|
||||
</el-statistic>
|
||||
<div class="statistic-item">
|
||||
<el-statistic title="健康学生" :value="statistics.healthyCount">
|
||||
<template #suffix>
|
||||
<span class="suffix-label">人 ({{ formatPercent(statistics.healthyPercent) }})</span>
|
||||
</template>
|
||||
</el-statistic>
|
||||
</div>
|
||||
|
||||
<el-statistic title="良好学生" :value="statistics.goodCount">
|
||||
<template #suffix>
|
||||
<span class="suffix-label">人 ({{ formatPercent(statistics.goodPercent) }})</span>
|
||||
</template>
|
||||
</el-statistic>
|
||||
<div class="statistic-item">
|
||||
<el-statistic title="良好学生" :value="statistics.goodCount">
|
||||
<template #suffix>
|
||||
<span class="suffix-label">人 ({{ formatPercent(statistics.goodPercent) }})</span>
|
||||
</template>
|
||||
</el-statistic>
|
||||
</div>
|
||||
|
||||
<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 class="statistic-item">
|
||||
<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>
|
||||
|
||||
<!-- 图表展示 -->
|
||||
@@ -92,6 +100,10 @@
|
||||
<el-icon class="el-input__icon" @click="handleSearch"><Search /></el-icon>
|
||||
</template>
|
||||
</el-input>
|
||||
|
||||
<el-button type="info" plain size="small" style="margin-left: 10px" @click="resetFilter">
|
||||
清除筛选
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -102,6 +114,7 @@
|
||||
:data="detailList"
|
||||
stripe
|
||||
style="width: 100%"
|
||||
:empty-text="filterStatus || searchKeyword ? '没有符合条件的数据' : '暂无数据'"
|
||||
>
|
||||
<el-table-column label="学号" align="center" prop="studentNo" width="120" />
|
||||
<el-table-column label="姓名" align="center" prop="studentName" width="100" />
|
||||
@@ -132,6 +145,11 @@
|
||||
</el-table>
|
||||
|
||||
<div class="pagination-container">
|
||||
<div class="filter-info">
|
||||
<span v-if="filterStatus">当前筛选:{{ filterStatus === '1' ? '健康' : filterStatus === '2' ? '良好' : '重点关注' }}</span>
|
||||
<span v-if="searchKeyword">搜索关键词:{{ searchKeyword }}</span>
|
||||
<span>共找到 {{ total }} 条记录</span>
|
||||
</div>
|
||||
<pagination
|
||||
v-show="total > 0"
|
||||
:total="total"
|
||||
@@ -152,6 +170,8 @@ import * as echarts from 'echarts/core';
|
||||
import { PieChart } from 'echarts/charts';
|
||||
import { TooltipComponent, LegendComponent, TitleComponent } from 'echarts/components';
|
||||
import { CanvasRenderer } from 'echarts/renderers';
|
||||
import { Search } from '@element-plus/icons-vue';
|
||||
import { ElLoading, ElMessage } from 'element-plus';
|
||||
|
||||
// 注册必要的组件
|
||||
echarts.use([PieChart, TooltipComponent, LegendComponent, TitleComponent, CanvasRenderer]);
|
||||
@@ -200,6 +220,16 @@ const getEvaluationInfo = async () => {
|
||||
evaluationInfo.value = res.data;
|
||||
} catch (error) {
|
||||
console.error('获取测评信息失败', error);
|
||||
// 显示友好的错误提示,而不是"无权限"
|
||||
if (error.response && error.response.status === 403) {
|
||||
proxy?.$modal.msgError('您没有查看该测评的权限');
|
||||
} else {
|
||||
proxy?.$modal.msgError('获取测评信息失败,请稍后再试');
|
||||
}
|
||||
// 返回列表页
|
||||
setTimeout(() => {
|
||||
router.push('/xljk/evaluation');
|
||||
}, 1500);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -223,12 +253,49 @@ const getStatistics = async () => {
|
||||
const getDetailList = async () => {
|
||||
try {
|
||||
loading.value = true;
|
||||
// 使用getEvaluationDetailsByEvaluationId替代listEvaluationDetail
|
||||
// 因为listEvaluationDetail需要分页参数,而我们需要的是获取指定测评ID的所有明细
|
||||
console.log('查询参数:', {
|
||||
filterStatus: filterStatus.value,
|
||||
searchKeyword: searchKeyword.value,
|
||||
studentNo: queryParams.value.studentNo,
|
||||
studentName: queryParams.value.studentName
|
||||
});
|
||||
|
||||
// 使用getEvaluationDetailsByEvaluationId获取所有数据
|
||||
const res = await getEvaluationDetailsByEvaluationId(evaluationId.value);
|
||||
if (res.data) {
|
||||
detailList.value = res.data;
|
||||
total.value = res.data.length;
|
||||
// 存储原始数据
|
||||
const allDetails = res.data;
|
||||
console.log('获取到的原始数据:', allDetails.length, '条');
|
||||
|
||||
// 根据过滤条件筛选数据
|
||||
let filteredData = [...allDetails];
|
||||
|
||||
// 按心理状态筛选
|
||||
if (filterStatus.value) {
|
||||
filteredData = filteredData.filter(item => item.mentalStatus === filterStatus.value);
|
||||
console.log('按心理状态筛选后:', filteredData.length, '条');
|
||||
}
|
||||
|
||||
// 按学号或姓名搜索
|
||||
if (searchKeyword.value) {
|
||||
const keyword = searchKeyword.value.toLowerCase();
|
||||
filteredData = filteredData.filter(item =>
|
||||
(item.studentNo && item.studentNo.toLowerCase().includes(keyword)) ||
|
||||
(item.studentName && item.studentName.toLowerCase().includes(keyword))
|
||||
);
|
||||
console.log('按关键词筛选后:', filteredData.length, '条');
|
||||
}
|
||||
|
||||
// 分页处理
|
||||
const pageSize = queryParams.value.pageSize;
|
||||
const pageNum = queryParams.value.pageNum;
|
||||
const startIndex = (pageNum - 1) * pageSize;
|
||||
const endIndex = startIndex + pageSize;
|
||||
|
||||
// 设置总数和当前页数据
|
||||
total.value = filteredData.length;
|
||||
detailList.value = filteredData.slice(startIndex, endIndex);
|
||||
console.log('最终显示数据:', detailList.value.length, '条');
|
||||
} else {
|
||||
detailList.value = [];
|
||||
total.value = 0;
|
||||
@@ -257,15 +324,26 @@ const initPieChart = () => {
|
||||
const option = {
|
||||
title: {
|
||||
text: '心理状态分布',
|
||||
left: 'center'
|
||||
left: 'center',
|
||||
textStyle: {
|
||||
fontSize: 14
|
||||
},
|
||||
top: 5,
|
||||
padding: 5
|
||||
},
|
||||
tooltip: {
|
||||
trigger: 'item',
|
||||
formatter: '{a} <br/>{b}: {c} ({d}%)'
|
||||
},
|
||||
legend: {
|
||||
orient: 'vertical',
|
||||
left: 'left',
|
||||
orient: 'horizontal',
|
||||
left: 'center',
|
||||
bottom: 0,
|
||||
itemWidth: 12,
|
||||
itemHeight: 8,
|
||||
textStyle: {
|
||||
fontSize: 12
|
||||
},
|
||||
data: ['健康', '良好', '重点关注']
|
||||
},
|
||||
color: ['#67C23A', '#E6A23C', '#F56C6C'],
|
||||
@@ -273,8 +351,23 @@ const initPieChart = () => {
|
||||
{
|
||||
name: '心理状态',
|
||||
type: 'pie',
|
||||
radius: '60%',
|
||||
radius: ['35%', '60%'], // 使用环形图,更节省空间
|
||||
center: ['50%', '50%'],
|
||||
avoidLabelOverlap: true,
|
||||
itemStyle: {
|
||||
borderRadius: 4,
|
||||
borderWidth: 1,
|
||||
borderColor: '#fff'
|
||||
},
|
||||
label: {
|
||||
show: true,
|
||||
formatter: '{b}: {c} ({d}%)',
|
||||
fontSize: 12
|
||||
},
|
||||
labelLine: {
|
||||
length: 10,
|
||||
length2: 5
|
||||
},
|
||||
data: [
|
||||
{ value: statistics.value.healthyCount, name: '健康' },
|
||||
{ value: statistics.value.goodCount, name: '良好' },
|
||||
@@ -282,9 +375,9 @@ const initPieChart = () => {
|
||||
],
|
||||
emphasis: {
|
||||
itemStyle: {
|
||||
shadowBlur: 10,
|
||||
shadowBlur: 5,
|
||||
shadowOffsetX: 0,
|
||||
shadowColor: 'rgba(0, 0, 0, 0.5)'
|
||||
shadowColor: 'rgba(0, 0, 0, 0.3)'
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -311,12 +404,13 @@ const goBack = () => {
|
||||
|
||||
/** 导出结果 */
|
||||
const handleExport = () => {
|
||||
console.log('导出测评明细,测评ID:', evaluationId.value);
|
||||
proxy?.download(
|
||||
'xljk/evaluationDetail/export',
|
||||
'xljk/evaluation/detail/export',
|
||||
{
|
||||
evaluationId: evaluationId.value
|
||||
},
|
||||
`evaluation_detail_${evaluationId.value}_${new Date().getTime()}.xlsx`
|
||||
`心理健康测评明细_${evaluationId.value}_${new Date().getTime()}.xlsx`
|
||||
);
|
||||
};
|
||||
|
||||
@@ -330,18 +424,15 @@ const handleFilterChange = () => {
|
||||
/** 处理搜索 */
|
||||
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 = '';
|
||||
}
|
||||
|
||||
// 不再需要设置queryParams,直接使用searchKeyword
|
||||
getDetailList();
|
||||
};
|
||||
|
||||
/** 重置过滤条件 */
|
||||
const resetFilter = () => {
|
||||
filterStatus.value = '';
|
||||
searchKeyword.value = '';
|
||||
queryParams.value.pageNum = 1;
|
||||
getDetailList();
|
||||
};
|
||||
|
||||
@@ -394,15 +485,22 @@ onBeforeUnmount(() => {
|
||||
|
||||
/* 统计样式 */
|
||||
.statistics-container {
|
||||
padding: 10px 0;
|
||||
padding: 5px 0;
|
||||
}
|
||||
|
||||
.statistics-row {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: space-around;
|
||||
gap: 20px;
|
||||
margin-bottom: 20px;
|
||||
gap: 10px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.statistic-item {
|
||||
flex: 1; /* 让统计项占据相同宽度 */
|
||||
min-width: 150px; /* 确保统计项有最小宽度 */
|
||||
text-align: center;
|
||||
padding: 0 5px;
|
||||
}
|
||||
|
||||
.suffix-label {
|
||||
@@ -414,13 +512,28 @@ onBeforeUnmount(() => {
|
||||
.chart-container {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
margin-top: 20px;
|
||||
margin-bottom: 10px;
|
||||
margin-top: 0;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.pie-chart {
|
||||
width: 600px;
|
||||
height: 400px;
|
||||
width: 500px;
|
||||
height: 280px;
|
||||
}
|
||||
|
||||
/* 统计卡片样式 */
|
||||
.statistics-card :deep(.el-card__body) {
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.statistics-card :deep(.el-statistic) {
|
||||
--el-statistic-content-font-size: 20px;
|
||||
--el-statistic-title-font-size: 14px;
|
||||
--el-statistic-title-margin-bottom: 2px;
|
||||
}
|
||||
|
||||
.statistics-card :deep(.el-card__header) {
|
||||
padding: 10px 15px;
|
||||
}
|
||||
|
||||
/* 分页容器样式 */
|
||||
@@ -432,6 +545,17 @@ onBeforeUnmount(() => {
|
||||
margin-top: 10px !important;
|
||||
}
|
||||
|
||||
.filter-info {
|
||||
display: flex;
|
||||
gap: 20px;
|
||||
align-items: center;
|
||||
margin-bottom: 10px;
|
||||
padding: 0 20px;
|
||||
font-size: 14px;
|
||||
color: #606266;
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.statistics-row {
|
||||
flex-direction: column;
|
||||
|
||||
@@ -82,13 +82,35 @@
|
||||
:closable="false"
|
||||
/>
|
||||
|
||||
<!-- 批量操作区域 -->
|
||||
<div class="batch-actions" v-if="studentList.length > 0">
|
||||
<span class="batch-label">批量设置心理状态:</span>
|
||||
<el-radio-group v-model="batchMentalStatus">
|
||||
<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-button type="primary" size="small" @click="applyBatchMentalStatus" :disabled="selectedStudents.length === 0">
|
||||
应用到所选学生
|
||||
</el-button>
|
||||
<el-button type="info" size="small" @click="applyBatchMentalStatusToAll">
|
||||
应用到全部学生
|
||||
</el-button>
|
||||
<el-button type="warning" size="small" @click="resetAllMentalStatus">
|
||||
重置所有状态
|
||||
</el-button>
|
||||
<span class="batch-hint">已选择 {{ selectedStudents.length }} 名学生</span>
|
||||
</div>
|
||||
|
||||
<el-table
|
||||
v-else
|
||||
v-if="studentList.length > 0"
|
||||
:data="studentList"
|
||||
border
|
||||
stripe
|
||||
style="width: 100%"
|
||||
@selection-change="handleSelectionChange"
|
||||
>
|
||||
<el-table-column type="selection" width="55" />
|
||||
<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">
|
||||
@@ -157,6 +179,7 @@
|
||||
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';
|
||||
import { ElMessage, ElMessageBox } from 'element-plus';
|
||||
|
||||
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
||||
const { sys_user_sex } = toRefs<any>(proxy?.useDict('sys_user_sex'));
|
||||
@@ -202,7 +225,7 @@ const getEvaluationInfo = async () => {
|
||||
|
||||
// 检查状态是否为草稿
|
||||
if (form.value.status !== '0') {
|
||||
proxy?.$modal.msgError('只能编辑草稿状态的测评');
|
||||
ElMessage.error('只能编辑草稿状态的测评');
|
||||
setTimeout(() => {
|
||||
router.push('/xljk/evaluation');
|
||||
}, 1500);
|
||||
@@ -234,12 +257,12 @@ const getStudents = async () => {
|
||||
// 打印返回结果
|
||||
console.log('获取学生列表的结果:', res);
|
||||
|
||||
studentList.value = res.data || [];
|
||||
|
||||
// 为每个学生初始化心理状态
|
||||
studentList.value.forEach(student => {
|
||||
student.mentalStatus = student.mentalStatus || '1'; // 默认健康
|
||||
});
|
||||
// 设置默认的心理状态为"健康"
|
||||
studentList.value = (res.data || []).map(student => ({
|
||||
...student,
|
||||
mentalStatus: '1', // 默认设置为"健康"
|
||||
remark: '' // 初始化备注为空字符串
|
||||
}));
|
||||
} catch (error) {
|
||||
console.error('获取班级学生列表失败', error);
|
||||
studentList.value = [];
|
||||
@@ -288,6 +311,99 @@ const countFocusStudents = () => {
|
||||
return studentList.value.filter(student => student.mentalStatus === '3').length;
|
||||
};
|
||||
|
||||
/** 批量设置心理状态 */
|
||||
const batchMentalStatus = ref('1'); // 默认健康
|
||||
const selectedStudents = ref<StudentInfo[]>([]); // 选中的学生列表
|
||||
|
||||
const handleSelectionChange = (selection: StudentInfo[]) => {
|
||||
selectedStudents.value = selection;
|
||||
};
|
||||
|
||||
const applyBatchMentalStatus = async () => {
|
||||
if (selectedStudents.value.length === 0) {
|
||||
ElMessage.error('请选择要批量设置的学生');
|
||||
return;
|
||||
}
|
||||
const status = batchMentalStatus.value;
|
||||
const detailsToUpdate = selectedStudents.value.map(student => {
|
||||
return {
|
||||
id: student.detailId,
|
||||
evaluationId: form.value.id,
|
||||
studentId: student.studentId,
|
||||
studentNo: student.studentNo,
|
||||
studentName: student.studentName,
|
||||
gender: student.gender,
|
||||
birthDate: student.birthDate,
|
||||
phone: student.phone,
|
||||
mentalStatus: status,
|
||||
score: status === '3' ? 70 : undefined, // 默认分数
|
||||
remark: student.remark
|
||||
} as XljkEvaluationDetailForm;
|
||||
});
|
||||
await batchUpdateMentalStatus(detailsToUpdate);
|
||||
ElMessage.success(`已批量设置 ${selectedStudents.value.length} 名学生的心理状态为 ${status}`);
|
||||
// 刷新学生列表以更新状态
|
||||
await getStudents();
|
||||
await getEvaluationDetails();
|
||||
};
|
||||
|
||||
const applyBatchMentalStatusToAll = async () => {
|
||||
const status = batchMentalStatus.value;
|
||||
const detailsToUpdate = studentList.value.map(student => {
|
||||
return {
|
||||
id: student.detailId,
|
||||
evaluationId: form.value.id,
|
||||
studentId: student.studentId,
|
||||
studentNo: student.studentNo,
|
||||
studentName: student.studentName,
|
||||
gender: student.gender,
|
||||
birthDate: student.birthDate,
|
||||
phone: student.phone,
|
||||
mentalStatus: status,
|
||||
score: status === '3' ? 70 : undefined, // 默认分数
|
||||
remark: student.remark
|
||||
} as XljkEvaluationDetailForm;
|
||||
});
|
||||
await batchUpdateMentalStatus(detailsToUpdate);
|
||||
ElMessage.success(`已批量设置 ${studentList.value.length} 名学生的心理状态为 ${status}`);
|
||||
// 刷新学生列表以更新状态
|
||||
await getStudents();
|
||||
await getEvaluationDetails();
|
||||
};
|
||||
|
||||
const resetAllMentalStatus = async () => {
|
||||
try {
|
||||
await ElMessageBox.confirm('确认要将所有学生的心理状态重置为"健康"吗?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
});
|
||||
|
||||
const detailsToUpdate = studentList.value.map(student => {
|
||||
return {
|
||||
id: student.detailId,
|
||||
evaluationId: form.value.id,
|
||||
studentId: student.studentId,
|
||||
studentNo: student.studentNo,
|
||||
studentName: student.studentName,
|
||||
gender: student.gender,
|
||||
birthDate: student.birthDate,
|
||||
phone: student.phone,
|
||||
mentalStatus: '1', // 重置为健康
|
||||
score: undefined,
|
||||
remark: student.remark
|
||||
} as XljkEvaluationDetailForm;
|
||||
});
|
||||
await batchUpdateMentalStatus(detailsToUpdate);
|
||||
ElMessage.success('已重置所有学生的心理状态');
|
||||
// 刷新学生列表以更新状态
|
||||
await getStudents();
|
||||
await getEvaluationDetails();
|
||||
} catch (error) {
|
||||
// 用户取消操作
|
||||
}
|
||||
};
|
||||
|
||||
/** 提交表单 */
|
||||
const submitForm = () => {
|
||||
formRef.value?.validate(async (valid: boolean) => {
|
||||
@@ -317,8 +433,8 @@ const submitForm = () => {
|
||||
// 批量更新学生心理状态
|
||||
await batchUpdateMentalStatus(detailsToUpdate);
|
||||
|
||||
proxy?.$modal.msgSuccess('修改成功');
|
||||
router.push('/xljk/evaluation');
|
||||
ElMessage.success('修改成功');
|
||||
router.replace('/xljk/evaluation');
|
||||
} catch (error) {
|
||||
console.error('修改测评失败', error);
|
||||
} finally {
|
||||
@@ -330,7 +446,7 @@ const submitForm = () => {
|
||||
|
||||
/** 取消按钮 */
|
||||
const cancel = () => {
|
||||
router.push('/xljk/evaluation');
|
||||
router.replace('/xljk/evaluation');
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
@@ -370,4 +486,22 @@ onMounted(() => {
|
||||
color: #606266;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.batch-actions {
|
||||
margin-bottom: 10px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.batch-label {
|
||||
font-size: 14px;
|
||||
color: #606266;
|
||||
}
|
||||
|
||||
.batch-hint {
|
||||
font-size: 14px;
|
||||
color: #909399;
|
||||
margin-left: 10px;
|
||||
}
|
||||
</style>
|
||||
@@ -109,7 +109,7 @@
|
||||
</template>
|
||||
|
||||
<script setup name="XljkEvaluationFill" lang="ts">
|
||||
import { getEvaluation, listEvaluationDetail, batchUpdateEvaluationDetail } from '@/api/xljk/evaluation';
|
||||
import { getEvaluation, listEvaluationDetail, batchUpdateMentalStatus } from '@/api/xljk/evaluation';
|
||||
import { XljkEvaluationVO, XljkEvaluationDetailVO, XljkEvaluationDetailForm } from '@/api/xljk/evaluation/types';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import { throttle } from 'lodash-es';
|
||||
@@ -143,7 +143,7 @@ const getEvaluationInfo = async () => {
|
||||
if (evaluationInfo.value.status !== '1') {
|
||||
proxy?.$modal.msgError('只能填写"已发布"状态的测评');
|
||||
setTimeout(() => {
|
||||
router.push('/xljk/evaluation');
|
||||
router.replace('/xljk/evaluation');
|
||||
}, 1500);
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -176,7 +176,7 @@ const filledCount = computed(() => {
|
||||
|
||||
/** 返回列表页 */
|
||||
const goBack = () => {
|
||||
router.push('/xljk/evaluation');
|
||||
router.replace('/xljk/evaluation');
|
||||
};
|
||||
|
||||
/** 处理心理状态变更 */
|
||||
@@ -248,7 +248,7 @@ const saveEvaluation = async () => {
|
||||
// 提交数据
|
||||
try {
|
||||
saveLoading.value = true;
|
||||
await batchUpdateEvaluationDetail(updateData);
|
||||
await batchUpdateMentalStatus(updateData);
|
||||
proxy?.$modal.msgSuccess('保存成功');
|
||||
} catch (error) {
|
||||
console.error('保存失败', error);
|
||||
|
||||
@@ -169,41 +169,15 @@
|
||||
></el-button>
|
||||
</el-tooltip>
|
||||
|
||||
<!-- 草稿状态可发布 -->
|
||||
<el-tooltip content="发布" placement="top" v-if="scope.row.status === '0'">
|
||||
<!-- 草稿状态可提交 -->
|
||||
<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)"
|
||||
@click="handleSubmit(scope.row)"
|
||||
v-hasPermi="['xljk:evaluation:edit']"
|
||||
></el-button>
|
||||
</el-tooltip>
|
||||
@@ -219,7 +193,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { listEvaluation, getEvaluation, delEvaluation, addEvaluation, updateEvaluation, publishEvaluation, completeEvaluation, getCollegeOptions, getMajorOptions, getClassOptions, getSemesterOptions } from '@/api/xljk/evaluation';
|
||||
import { listEvaluation, getEvaluation, delEvaluation, addEvaluation, updateEvaluation, completeEvaluation, getCollegeOptions, getMajorOptions, getClassOptions, getSemesterOptions } from '@/api/xljk/evaluation';
|
||||
import { XljkEvaluationVO, XljkEvaluationForm, XljkEvaluationQuery, CollegeOption, MajorOption, ClassOption, SemesterOption } from '@/api/xljk/evaluation/types';
|
||||
|
||||
// 基本变量
|
||||
@@ -376,10 +350,7 @@ const handleUpdate = (row?: XljkEvaluationVO) => {
|
||||
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) => {
|
||||
@@ -412,26 +383,13 @@ const handleDelete = async (row?: XljkEvaluationVO) => {
|
||||
}
|
||||
};
|
||||
|
||||
/** 发布按钮操作 */
|
||||
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}"?完成后将无法再修改测评结果。`);
|
||||
/** 提交按钮操作 */
|
||||
const handleSubmit = async (row: XljkEvaluationVO) => {
|
||||
await proxy?.$modal.confirm(`是否确认提交测评"${row.evaluationName}"?提交后将无法再修改测评结果。`);
|
||||
try {
|
||||
loading.value = true;
|
||||
await completeEvaluation(row.id);
|
||||
proxy?.$modal.msgSuccess('操作成功');
|
||||
proxy?.$modal.msgSuccess('提交成功');
|
||||
await getList();
|
||||
} finally {
|
||||
loading.value = false;
|
||||
@@ -449,11 +407,16 @@ const handleExport = () => {
|
||||
);
|
||||
};
|
||||
|
||||
// 初始化
|
||||
onMounted(() => {
|
||||
getList();
|
||||
getDepartments();
|
||||
getMajors();
|
||||
getSemesters();
|
||||
getList();
|
||||
});
|
||||
|
||||
// 监听路由变化,确保从其他页面返回时重新加载数据
|
||||
onActivated(() => {
|
||||
getList();
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
Reference in new issue
Block a user