From 9c3741562d1dc80b8dd8ca81249fc5dcb4d5dd44 Mon Sep 17 00:00:00 2001 From: zlwu <704541015@qq.com> Date: Sun, 7 Sep 2025 20:32:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 +- .../XgStudentStatisticsController.java | 82 +++ .../xg/domain/bo/XgStudentStatisticsBo.java | 48 ++ .../xg/domain/vo/XgCascadeOptionVo.java | 34 ++ .../xg/domain/vo/XgStudentStatisticsVo.java | 117 ++++ .../xg/mapper/XgStudentStatisticsMapper.java | 63 +++ .../service/IXgStudentStatisticsService.java | 56 ++ .../impl/XgStudentStatisticsServiceImpl.java | 117 ++++ .../mapper/xg/XgStudentStatisticsMapper.xml | 504 ++++++++++++++++++ web/package.json | 2 +- web/src/api/xg/studentStatistics.ts | 86 +++ web/src/views/xg/studentStatistics/index.vue | 426 +++++++++++++++ .../disciplineRecord/DisciplineRecordForm.vue | 45 +- 13 files changed, 1574 insertions(+), 9 deletions(-) create mode 100644 backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/controller/XgStudentStatisticsController.java create mode 100644 backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/domain/bo/XgStudentStatisticsBo.java create mode 100644 backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/domain/vo/XgCascadeOptionVo.java create mode 100644 backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/domain/vo/XgStudentStatisticsVo.java create mode 100644 backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/mapper/XgStudentStatisticsMapper.java create mode 100644 backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/service/IXgStudentStatisticsService.java create mode 100644 backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/service/impl/XgStudentStatisticsServiceImpl.java create mode 100644 backend/ruoyi-modules/ruoyi-xg/src/main/resources/mapper/xg/XgStudentStatisticsMapper.xml create mode 100644 web/src/api/xg/studentStatistics.ts create mode 100644 web/src/views/xg/studentStatistics/index.vue diff --git a/.gitignore b/.gitignore index fd624ea9..03ef4a45 100644 --- a/.gitignore +++ b/.gitignore @@ -326,4 +326,5 @@ docs/变更管理/ 查找界面中涉及到的权限字符.md docs/部署文档/nginx配置/hzdyjsweb.camasort.com.conf 首页完善的提示词.md -scripts/ \ No newline at end of file +scripts/ +学生宿舍卫生检查、学生违纪记录统计.md diff --git a/backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/controller/XgStudentStatisticsController.java b/backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/controller/XgStudentStatisticsController.java new file mode 100644 index 00000000..a6de5c51 --- /dev/null +++ b/backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/controller/XgStudentStatisticsController.java @@ -0,0 +1,82 @@ +package org.dromara.xg.controller; + +import java.util.List; + +import lombok.RequiredArgsConstructor; +import jakarta.validation.constraints.*; +import cn.dev33.satoken.annotation.SaCheckPermission; +import org.springframework.web.bind.annotation.*; +import org.springframework.validation.annotation.Validated; +import org.dromara.common.log.annotation.Log; +import org.dromara.common.web.core.BaseController; +import org.dromara.common.core.domain.R; +import org.dromara.common.log.enums.BusinessType; +import org.dromara.xg.domain.bo.XgStudentStatisticsBo; +import org.dromara.xg.domain.vo.XgStudentStatisticsVo; +import org.dromara.xg.domain.vo.XgCascadeOptionVo; +import org.dromara.xg.service.IXgStudentStatisticsService; + +/** + * 学生宿舍卫生检查、违纪记录统计 + * + * @author zlwu + * @date 2025-01-14 + */ +@Validated +@RequiredArgsConstructor +@RestController +@RequestMapping("/xg/studentStatistics") +public class XgStudentStatisticsController extends BaseController { + + private final IXgStudentStatisticsService studentStatisticsService; + + /** + * 查询学生宿舍卫生检查、违纪记录统计数据 + */ + @SaCheckPermission("xg:studentStatistics:query") + @PostMapping("/statistics") + public R getStatistics(@Validated @RequestBody XgStudentStatisticsBo bo) { + return R.ok(studentStatisticsService.getStatistics(bo)); + } + + /** + * 导出学生宿舍卫生检查、违纪记录统计数据 + */ + @SaCheckPermission("xg:studentStatistics:export") + @Log(title = "学生统计数据", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void exportStatistics(@Validated @RequestBody XgStudentStatisticsBo bo, + jakarta.servlet.http.HttpServletResponse response) { + studentStatisticsService.exportStatistics(bo, response); + } + + /** + * 获取二级学院列表 + */ + @SaCheckPermission("xg:studentStatistics:query") + @GetMapping("/colleges") + public R> getColleges() { + return R.ok(studentStatisticsService.getColleges()); + } + + /** + * 根据学院ID获取专业列表 + */ + @SaCheckPermission("xg:studentStatistics:query") + @GetMapping("/majors/{collegeId}") + public R> getMajorsByCollegeId( + @NotNull(message = "学院ID不能为空") @PathVariable Long collegeId) { + return R.ok(studentStatisticsService.getMajorsByCollegeId(collegeId)); + } + + /** + * 根据专业ID获取班级列表 + */ + @SaCheckPermission("xg:studentStatistics:query") + @GetMapping("/classes/{majorId}") + public R> getClassesByMajorId( + @NotNull(message = "专业ID不能为空") @PathVariable Long majorId) { + return R.ok(studentStatisticsService.getClassesByMajorId(majorId)); + } + +} diff --git a/backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/domain/bo/XgStudentStatisticsBo.java b/backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/domain/bo/XgStudentStatisticsBo.java new file mode 100644 index 00000000..8b6d3f91 --- /dev/null +++ b/backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/domain/bo/XgStudentStatisticsBo.java @@ -0,0 +1,48 @@ +package org.dromara.xg.domain.bo; + +import org.dromara.common.core.validate.AddGroup; +import org.dromara.common.core.validate.EditGroup; +import org.dromara.common.mybatis.core.domain.BaseEntity; +import jakarta.validation.constraints.*; +import lombok.Data; +import lombok.EqualsAndHashCode; +import java.time.LocalDateTime; + +/** + * 学生宿舍卫生检查、违纪记录统计查询业务对象 + * + * @author zlwu + * @date 2025-01-14 + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class XgStudentStatisticsBo extends BaseEntity { + + /** + * 统计开始时间 + */ + @NotNull(message = "统计开始时间不能为空") + private LocalDateTime startTime; + + /** + * 统计结束时间 + */ + @NotNull(message = "统计结束时间不能为空") + private LocalDateTime endTime; + + /** + * 二级学院ID + */ + private Long collegeId; + + /** + * 专业ID + */ + private Long majorId; + + /** + * 班级ID + */ + private Long classId; + +} diff --git a/backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/domain/vo/XgCascadeOptionVo.java b/backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/domain/vo/XgCascadeOptionVo.java new file mode 100644 index 00000000..9752cdd4 --- /dev/null +++ b/backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/domain/vo/XgCascadeOptionVo.java @@ -0,0 +1,34 @@ +package org.dromara.xg.domain.vo; + +import lombok.Data; + +/** + * 级联选择器选项视图对象 + * + * @author zlwu + * @date 2025-01-14 + */ +@Data +public class XgCascadeOptionVo { + + /** + * ID + */ + private Long id; + + /** + * 显示名称 + */ + private String label; + + /** + * 值 + */ + private String value; + + /** + * 排序 + */ + private Integer sort; + +} diff --git a/backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/domain/vo/XgStudentStatisticsVo.java b/backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/domain/vo/XgStudentStatisticsVo.java new file mode 100644 index 00000000..ed59ba95 --- /dev/null +++ b/backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/domain/vo/XgStudentStatisticsVo.java @@ -0,0 +1,117 @@ +package org.dromara.xg.domain.vo; + +import lombok.Data; +import java.util.List; + +/** + * 学生宿舍卫生检查、违纪记录统计视图对象 + * + * @author zlwu + * @date 2025-01-14 + */ +@Data +public class XgStudentStatisticsVo { + + /** + * 统计维度 (college-学院, major-专业, class-班级, classDetail-班级详情) + */ + private String dimension; + + /** + * 统计图表数据 + */ + private List chartData; + + /** + * 明细数据 + */ + private List detailData; + + /** + * 图表数据内部类 + */ + @Data + public static class StatisticsChartData { + /** + * 名称 (学院名、专业名、班级名) + */ + private String name; + + /** + * 宿舍扣分总数 + */ + private Integer dormDeductionCount; + + /** + * 宿舍违纪记录总数 + */ + private Integer dormViolationCount; + + /** + * 宿舍违纪记录扣分总数 + */ + private Double dormViolationDeduction; + + /** + * 教学区违纪记录总数 + */ + private Integer teachingViolationCount; + + /** + * 教学区违纪记录扣分总数 + */ + private Double teachingViolationDeduction; + } + + /** + * 明细数据内部类 + */ + @Data + public static class StatisticsDetailData { + /** + * ID + */ + private Long id; + + /** + * 名称 + */ + private String name; + + /** + * 上级名称(如学院下的专业名称显示学院名) + */ + private String parentName; + + /** + * 宿舍扣分总数 + */ + private Integer dormDeductionCount; + + /** + * 宿舍违纪记录总数 + */ + private Integer dormViolationCount; + + /** + * 宿舍违纪记录扣分总数 + */ + private Double dormViolationDeduction; + + /** + * 教学区违纪记录总数 + */ + private Integer teachingViolationCount; + + /** + * 教学区违纪记录扣分总数 + */ + private Double teachingViolationDeduction; + + /** + * 合计扣分 + */ + private Double totalDeduction; + } + +} diff --git a/backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/mapper/XgStudentStatisticsMapper.java b/backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/mapper/XgStudentStatisticsMapper.java new file mode 100644 index 00000000..d9ad2a16 --- /dev/null +++ b/backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/mapper/XgStudentStatisticsMapper.java @@ -0,0 +1,63 @@ +package org.dromara.xg.mapper; + +import org.apache.ibatis.annotations.Param; +import org.dromara.xg.domain.bo.XgStudentStatisticsBo; +import org.dromara.xg.domain.vo.XgStudentStatisticsVo; +import org.dromara.xg.domain.vo.XgCascadeOptionVo; + +import java.util.List; + +/** + * 学生宿舍卫生检查、违纪记录统计Mapper接口 + * + * @author zlwu + * @date 2025-01-14 + */ +public interface XgStudentStatisticsMapper { + + /** + * 按学院维度统计图表数据 + */ + List getCollegeStatistics(@Param("bo") XgStudentStatisticsBo bo); + + /** + * 按学院维度统计明细数据 + */ + List getCollegeDetailStatistics(@Param("bo") XgStudentStatisticsBo bo); + + /** + * 按专业维度统计图表数据 + */ + List getMajorStatistics(@Param("bo") XgStudentStatisticsBo bo); + + /** + * 按专业维度统计明细数据 + */ + List getMajorDetailStatistics(@Param("bo") XgStudentStatisticsBo bo); + + /** + * 按班级维度统计图表数据 + */ + List getClassStatistics(@Param("bo") XgStudentStatisticsBo bo); + + /** + * 按班级维度统计明细数据 + */ + List getClassDetailStatistics(@Param("bo") XgStudentStatisticsBo bo); + + /** + * 获取二级学院列表 + */ + List getColleges(); + + /** + * 根据学院ID获取专业列表 + */ + List getMajorsByCollegeId(@Param("collegeId") Long collegeId); + + /** + * 根据专业ID获取班级列表 + */ + List getClassesByMajorId(@Param("majorId") Long majorId); + +} diff --git a/backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/service/IXgStudentStatisticsService.java b/backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/service/IXgStudentStatisticsService.java new file mode 100644 index 00000000..14059e07 --- /dev/null +++ b/backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/service/IXgStudentStatisticsService.java @@ -0,0 +1,56 @@ +package org.dromara.xg.service; + +import java.util.List; +import jakarta.servlet.http.HttpServletResponse; +import org.dromara.xg.domain.bo.XgStudentStatisticsBo; +import org.dromara.xg.domain.vo.XgStudentStatisticsVo; +import org.dromara.xg.domain.vo.XgCascadeOptionVo; + +/** + * 学生宿舍卫生检查、违纪记录统计Service接口 + * + * @author zlwu + * @date 2025-01-14 + */ +public interface IXgStudentStatisticsService { + + /** + * 获取统计数据 + * + * @param bo 查询条件 + * @return 统计结果 + */ + XgStudentStatisticsVo getStatistics(XgStudentStatisticsBo bo); + + /** + * 导出统计数据 + * + * @param bo 查询条件 + * @param response HTTP响应 + */ + void exportStatistics(XgStudentStatisticsBo bo, HttpServletResponse response); + + /** + * 获取二级学院列表 + * + * @return 学院列表 + */ + List getColleges(); + + /** + * 根据学院ID获取专业列表 + * + * @param collegeId 学院ID + * @return 专业列表 + */ + List getMajorsByCollegeId(Long collegeId); + + /** + * 根据专业ID获取班级列表 + * + * @param majorId 专业ID + * @return 班级列表 + */ + List getClassesByMajorId(Long majorId); + +} diff --git a/backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/service/impl/XgStudentStatisticsServiceImpl.java b/backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/service/impl/XgStudentStatisticsServiceImpl.java new file mode 100644 index 00000000..7c11c5a3 --- /dev/null +++ b/backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/service/impl/XgStudentStatisticsServiceImpl.java @@ -0,0 +1,117 @@ +package org.dromara.xg.service.impl; + +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import jakarta.servlet.http.HttpServletResponse; +import org.dromara.common.excel.utils.ExcelUtil; +import org.dromara.xg.service.IXgStudentStatisticsService; +import org.dromara.xg.domain.bo.XgStudentStatisticsBo; +import org.dromara.xg.domain.vo.XgStudentStatisticsVo; +import org.dromara.xg.domain.vo.XgCascadeOptionVo; +import org.dromara.xg.mapper.XgStudentStatisticsMapper; + +import java.util.List; +import java.util.Map; + +/** + * 学生宿舍卫生检查、违纪记录统计Service业务层处理 + * + * @author zlwu + * @date 2025-01-14 + */ +@RequiredArgsConstructor +@Service +public class XgStudentStatisticsServiceImpl implements IXgStudentStatisticsService { + + private final XgStudentStatisticsMapper statisticsMapper; + + @Override + public XgStudentStatisticsVo getStatistics(XgStudentStatisticsBo bo) { + XgStudentStatisticsVo result = new XgStudentStatisticsVo(); + + // 确定统计维度 + String dimension = determineDimension(bo); + result.setDimension(dimension); + + // 获取图表数据和明细数据 + switch (dimension) { + case "college": + result.setChartData(statisticsMapper.getCollegeStatistics(bo)); + result.setDetailData(statisticsMapper.getCollegeDetailStatistics(bo)); + break; + case "major": + result.setChartData(statisticsMapper.getMajorStatistics(bo)); + result.setDetailData(statisticsMapper.getMajorDetailStatistics(bo)); + break; + case "class": + result.setChartData(statisticsMapper.getClassStatistics(bo)); + result.setDetailData(statisticsMapper.getClassDetailStatistics(bo)); + break; + case "classDetail": + // 班级详情统计:图表数据和明细数据都只显示指定班级 + List detailData = statisticsMapper + .getClassDetailStatistics(bo); + result.setDetailData(detailData); + // 将明细数据转换为图表数据格式 + result.setChartData(convertDetailToChartData(detailData)); + break; + } + + return result; + } + + @Override + public void exportStatistics(XgStudentStatisticsBo bo, HttpServletResponse response) { + XgStudentStatisticsVo statistics = getStatistics(bo); + ExcelUtil.exportExcel(statistics.getDetailData(), "学生统计数据", XgStudentStatisticsVo.StatisticsDetailData.class, + response); + } + + @Override + public List getColleges() { + return statisticsMapper.getColleges(); + } + + @Override + public List getMajorsByCollegeId(Long collegeId) { + return statisticsMapper.getMajorsByCollegeId(collegeId); + } + + @Override + public List getClassesByMajorId(Long majorId) { + return statisticsMapper.getClassesByMajorId(majorId); + } + + /** + * 确定统计维度 + */ + private String determineDimension(XgStudentStatisticsBo bo) { + if (bo.getClassId() != null) { + return "classDetail"; + } else if (bo.getMajorId() != null) { + return "class"; + } else if (bo.getCollegeId() != null) { + return "major"; + } else { + return "college"; + } + } + + /** + * 将明细数据转换为图表数据格式 + */ + private List convertDetailToChartData( + List detailData) { + return detailData.stream().map(detail -> { + XgStudentStatisticsVo.StatisticsChartData chartData = new XgStudentStatisticsVo.StatisticsChartData(); + chartData.setName(detail.getName()); + chartData.setDormDeductionCount(detail.getDormDeductionCount()); + chartData.setDormViolationCount(detail.getDormViolationCount()); + chartData.setDormViolationDeduction(detail.getDormViolationDeduction()); + chartData.setTeachingViolationCount(detail.getTeachingViolationCount()); + chartData.setTeachingViolationDeduction(detail.getTeachingViolationDeduction()); + return chartData; + }).collect(java.util.stream.Collectors.toList()); + } + +} diff --git a/backend/ruoyi-modules/ruoyi-xg/src/main/resources/mapper/xg/XgStudentStatisticsMapper.xml b/backend/ruoyi-modules/ruoyi-xg/src/main/resources/mapper/xg/XgStudentStatisticsMapper.xml new file mode 100644 index 00000000..3585dcf8 --- /dev/null +++ b/backend/ruoyi-modules/ruoyi-xg/src/main/resources/mapper/xg/XgStudentStatisticsMapper.xml @@ -0,0 +1,504 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/web/package.json b/web/package.json index 68f51ada..5e29e2d3 100644 --- a/web/package.json +++ b/web/package.json @@ -34,7 +34,7 @@ "await-to-js": "3.0.0", "axios": "1.8.4", "crypto-js": "4.2.0", - "echarts": "5.6.0", + "echarts": "^5.6.0", "element-plus": "2.9.8", "file-saver": "2.0.5", "highlight.js": "11.9.0", diff --git a/web/src/api/xg/studentStatistics.ts b/web/src/api/xg/studentStatistics.ts new file mode 100644 index 00000000..6531e785 --- /dev/null +++ b/web/src/api/xg/studentStatistics.ts @@ -0,0 +1,86 @@ +import request from '@/utils/request' + +export interface StudentStatisticsBo { + startTime: string + endTime: string + collegeId?: number + majorId?: number + classId?: number +} + +export interface StatisticsChartData { + name: string + dormDeductionCount: number + dormViolationCount: number + dormViolationDeduction: number + teachingViolationCount: number + teachingViolationDeduction: number +} + +export interface StatisticsDetailData { + id: number + name: string + parentName: string + dormDeductionCount: number + dormViolationCount: number + dormViolationDeduction: number + teachingViolationCount: number + teachingViolationDeduction: number + totalDeduction: number +} + +export interface StudentStatisticsVo { + dimension: string + chartData: StatisticsChartData[] + detailData: StatisticsDetailData[] +} + +export interface CascadeOptionVo { + id: number + label: string + value: string + sort: number +} + +// 获取统计数据 +export function getStatistics(data: StudentStatisticsBo) { + return request({ + url: '/xg/studentStatistics/statistics', + method: 'post', + data: data + }) +} + +// 导出统计数据 +export function exportStatistics(data: StudentStatisticsBo) { + return request({ + url: '/xg/studentStatistics/export', + method: 'post', + data: data, + responseType: 'blob' + }) +} + +// 获取二级学院列表 +export function getColleges() { + return request({ + url: '/xg/studentStatistics/colleges', + method: 'get' + }) +} + +// 根据学院ID获取专业列表 +export function getMajorsByCollegeId(collegeId: number) { + return request({ + url: `/xg/studentStatistics/majors/${collegeId}`, + method: 'get' + }) +} + +// 根据专业ID获取班级列表 +export function getClassesByMajorId(majorId: number) { + return request({ + url: `/xg/studentStatistics/classes/${majorId}`, + method: 'get' + }) +} diff --git a/web/src/views/xg/studentStatistics/index.vue b/web/src/views/xg/studentStatistics/index.vue new file mode 100644 index 00000000..c9223a15 --- /dev/null +++ b/web/src/views/xg/studentStatistics/index.vue @@ -0,0 +1,426 @@ + + + + + diff --git a/web/src/views/xskh/disciplineRecord/DisciplineRecordForm.vue b/web/src/views/xskh/disciplineRecord/DisciplineRecordForm.vue index 0928dd69..b0257927 100644 --- a/web/src/views/xskh/disciplineRecord/DisciplineRecordForm.vue +++ b/web/src/views/xskh/disciplineRecord/DisciplineRecordForm.vue @@ -51,6 +51,12 @@ + + +
+ {{ selectedDisciplineType.remark }} +
+
import { ref, reactive, computed, toRefs, getCurrentInstance } from 'vue'; import { UploadFilled, Document, Loading, Download, Delete } from '@element-plus/icons-vue'; -import { ElMessage, ElMessageBox, ElLoading, FormInstance } from 'element-plus'; +import { ElMessage, ElMessageBox, ElLoading } from 'element-plus'; import { getToken } from '@/utils/auth'; import { globalHeaders } from '@/utils/request'; import ImagePreview from '@/components/ImagePreview/index.vue'; @@ -271,7 +277,7 @@ const emit = defineEmits(['success']); const { proxy } = getCurrentInstance() as any; const { student_discipline_status } = toRefs(proxy?.useDict('student_discipline_status')); -const disciplineRecordFormRef = ref(); +const disciplineRecordFormRef = ref(); const buttonLoading = ref(false); // 学生选择器相关状态 @@ -281,6 +287,9 @@ const studentLoading = ref(false); // 违纪处分类型选项 const disciplineTypeOptions = ref([]); +// 选中的违纪处分类型信息 +const selectedDisciplineType = ref(null); + // 附件上传相关状态 const attachmentList = ref([]); @@ -307,16 +316,12 @@ const initFormData: DisciplineRecordFormType = { disciplineContent: undefined, scoreDeduction: undefined, status: '1', // 默认生效 - approvalStatus: undefined, - approvalBy: undefined, - approvalTime: undefined, - approvalRemark: undefined, attachmentOssIds: undefined }; const form = ref({ ...initFormData }); -const rules = reactive({ +const rules = reactive({ studentId: [{ required: true, message: '学生不能为空', trigger: 'change' }], disciplineTypeId: [{ required: true, message: '违纪处分类型不能为空', trigger: 'change' }], disciplineDate: [{ required: true, message: '违纪处分日期不能为空', trigger: 'blur' }], @@ -383,6 +388,14 @@ const openDialog = async (id?: string | number, title?: string) => { // 处理附件数据 await handleAttachmentData(); + + // 设置选中的违纪处分类型(用于显示类型说明) + if (form.value.disciplineTypeId) { + const selectedType = disciplineTypeOptions.value.find((type) => type.id === form.value.disciplineTypeId); + if (selectedType) { + selectedDisciplineType.value = selectedType; + } + } } }; @@ -390,6 +403,7 @@ const openDialog = async (id?: string | number, title?: string) => { const resetForm = () => { form.value = { ...initFormData }; attachmentList.value = []; + selectedDisciplineType.value = null; disciplineRecordFormRef.value?.resetFields(); }; @@ -478,12 +492,18 @@ const loadDisciplineTypes = async () => { const handleDisciplineTypeChange = (typeId: string | number) => { if (!typeId) { form.value.disciplineTypeName = undefined; + selectedDisciplineType.value = null; return; } const selectedType = disciplineTypeOptions.value.find((type) => type.id === typeId); if (selectedType) { form.value.disciplineTypeName = selectedType.typeName; + selectedDisciplineType.value = selectedType; + // 自动填充最低扣分(如果有的话) + if (selectedType.minScore !== undefined && selectedType.minScore !== null) { + form.value.scoreDeduction = Number(selectedType.minScore); + } } }; @@ -972,6 +992,17 @@ defineExpose({ box-sizing: border-box; } +/* 违纪处分类型说明显示 */ +.discipline-type-remark { + padding: 8px 12px; + background: #f0f9ff; + border: 1px solid #bfdbfe; + border-radius: 4px; + font-size: 13px; + line-height: 1.5; + color: #1e40af; +} + .student-name-text { font-weight: 500; color: #303133;