From dc0c69647d9f328a8342e8a23fd959084e3b19ec Mon Sep 17 00:00:00 2001 From: zlwu <704541015@qq.com> Date: Mon, 4 Aug 2025 16:48:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/XgStudentLeaveController.java | 11 +- .../workflow/domain/XgStudentLeave.java | 2 +- .../workflow/domain/bo/XgStudentLeaveBo.java | 2 +- .../workflow/domain/vo/XgStudentLeaveVo.java | 2 +- .../service/IXgStudentLeaveService.java | 4 +- .../service/impl/TestLeaveServiceImpl.java | 6 +- .../impl/XgStudentLeaveServiceImpl.java | 132 ++++- .../code-adjust-record-2025-01-27-cursor.md | 84 +++ .../database/学生请假/xg_student_leave.sql | 2 +- web/src/views/xg/xsjcxx/xsqj/dialog.vue | 504 ++++++++++-------- web/src/views/xg/xsjcxx/xsqj/index.vue | 52 +- 11 files changed, 512 insertions(+), 289 deletions(-) diff --git a/backend/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/controller/XgStudentLeaveController.java b/backend/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/controller/XgStudentLeaveController.java index 75a495c2..2a772b6b 100644 --- a/backend/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/controller/XgStudentLeaveController.java +++ b/backend/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/controller/XgStudentLeaveController.java @@ -63,8 +63,7 @@ public class XgStudentLeaveController extends BaseController { */ @SaCheckPermission("studentLeave:studentLeave:query") @GetMapping("/{id}") - public R getInfo(@NotNull(message = "主键不能为空") - @PathVariable Long id) { + public R getInfo(@NotNull(message = "主键不能为空") @PathVariable Long id) { return R.ok(xgStudentLeaveService.queryById(id)); } @@ -75,8 +74,9 @@ public class XgStudentLeaveController extends BaseController { @Log(title = "学生请假 - 记录学生的请假申请、审批和销假信息", businessType = BusinessType.INSERT) @RepeatSubmit() @PostMapping() - public R add(@Validated(AddGroup.class) @RequestBody XgStudentLeaveBo bo) { - return toAjax(xgStudentLeaveService.insertByBo(bo)); + public R add(@Validated(AddGroup.class) @RequestBody XgStudentLeaveBo bo) { + XgStudentLeaveVo result = xgStudentLeaveService.insertByBo(bo); + return R.ok(result); } /** @@ -98,8 +98,7 @@ public class XgStudentLeaveController extends BaseController { @SaCheckPermission("studentLeave:studentLeave:remove") @Log(title = "学生请假 - 记录学生的请假申请、审批和销假信息", businessType = BusinessType.DELETE) @DeleteMapping("/{ids}") - public R remove(@NotEmpty(message = "主键不能为空") - @PathVariable Long[] ids) { + public R remove(@NotEmpty(message = "主键不能为空") @PathVariable Long[] ids) { return toAjax(xgStudentLeaveService.deleteWithValidByIds(List.of(ids), true)); } } diff --git a/backend/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/domain/XgStudentLeave.java b/backend/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/domain/XgStudentLeave.java index 464fe842..098df66c 100644 --- a/backend/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/domain/XgStudentLeave.java +++ b/backend/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/domain/XgStudentLeave.java @@ -141,7 +141,7 @@ public class XgStudentLeave extends TenantEntity { private String attachmentOssIds; /** - * 审批状态:0-待审批,1-已通过,2-已拒绝,3-已取消 + * 审批状态:draft - 草稿 waiting -审批中 finish- 审批完成 */ private String approvalStatus; diff --git a/backend/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/domain/bo/XgStudentLeaveBo.java b/backend/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/domain/bo/XgStudentLeaveBo.java index c41e3aec..a355427a 100644 --- a/backend/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/domain/bo/XgStudentLeaveBo.java +++ b/backend/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/domain/bo/XgStudentLeaveBo.java @@ -150,7 +150,7 @@ public class XgStudentLeaveBo extends BaseEntity { private String attachmentOssIds; /** - * 审批状态 + * 审批状态 draft - 草稿 waiting -审批中 finish- 审批完成 */ @NotBlank(message = "审批状态不能为空", groups = { AddGroup.class, EditGroup.class }) private String approvalStatus; diff --git a/backend/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/domain/vo/XgStudentLeaveVo.java b/backend/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/domain/vo/XgStudentLeaveVo.java index d51f783a..29aee824 100644 --- a/backend/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/domain/vo/XgStudentLeaveVo.java +++ b/backend/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/domain/vo/XgStudentLeaveVo.java @@ -173,7 +173,7 @@ public class XgStudentLeaveVo implements Serializable { private String attachmentOssIds; /** - * 审批状态 + * 审批状态 draft - 草稿 waiting -审批中 finish- 审批完成 */ @ExcelProperty(value = "审批状态") private String approvalStatus; diff --git a/backend/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/IXgStudentLeaveService.java b/backend/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/IXgStudentLeaveService.java index 2ca51f87..1878caa6 100644 --- a/backend/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/IXgStudentLeaveService.java +++ b/backend/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/IXgStudentLeaveService.java @@ -45,9 +45,9 @@ public interface IXgStudentLeaveService { * 新增学生请假 - 记录学生的请假申请、审批和销假信息 * * @param bo 学生请假 - 记录学生的请假申请、审批和销假信息 - * @return 是否新增成功 + * @return 新增成功的学生请假信息 */ - Boolean insertByBo(XgStudentLeaveBo bo); + XgStudentLeaveVo insertByBo(XgStudentLeaveBo bo); /** * 修改学生请假 - 记录学生的请假申请、审批和销假信息 diff --git a/backend/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/TestLeaveServiceImpl.java b/backend/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/TestLeaveServiceImpl.java index 65b271e2..2e6c70f2 100644 --- a/backend/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/TestLeaveServiceImpl.java +++ b/backend/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/TestLeaveServiceImpl.java @@ -155,7 +155,7 @@ public class TestLeaveServiceImpl implements ITestLeaveService { * * @param processEvent 参数 */ - @EventListener(condition = "#processEvent.flowCode.startsWith('leave') || #processEvent.flowCode.startsWith('hzdyjs-qj')") + @EventListener(condition = "#processEvent.flowCode.startsWith('leave') ") public void processHandler(ProcessEvent processEvent) { log.info("当前任务执行了{}", processEvent.toString()); TestLeave testLeave = baseMapper.selectById(Long.valueOf(processEvent.getBusinessId())); @@ -188,7 +188,7 @@ public class TestLeaveServiceImpl implements ITestLeaveService { * * @param processTaskEvent 参数 */ - @EventListener(condition = "#processTaskEvent.flowCode.startsWith('leave') || #processTaskEvent.flowCode.startsWith('hzdyjs-qj')") + @EventListener(condition = "#processTaskEvent.flowCode.startsWith('leave')") public void processTaskHandler(ProcessTaskEvent processTaskEvent) { log.info("当前任务创建了{}", processTaskEvent.toString()); } @@ -200,7 +200,7 @@ public class TestLeaveServiceImpl implements ITestLeaveService { * * @param processDeleteEvent 参数 */ - @EventListener(condition = "#processDeleteEvent.flowCode.startsWith('leave') || #processDeleteEvent.flowCode.startsWith('hzdyjs-qj')") + @EventListener(condition = "#processDeleteEvent.flowCode.startsWith('leave') ") public void processDeleteHandler(ProcessDeleteEvent processDeleteEvent) { log.info("监听删除流程事件,当前任务执行了{}", processDeleteEvent.toString()); TestLeave testLeave = baseMapper.selectById(Long.valueOf(processDeleteEvent.getBusinessId())); diff --git a/backend/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/XgStudentLeaveServiceImpl.java b/backend/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/XgStudentLeaveServiceImpl.java index d39937ab..ea0c234c 100644 --- a/backend/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/XgStudentLeaveServiceImpl.java +++ b/backend/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/XgStudentLeaveServiceImpl.java @@ -15,6 +15,29 @@ import org.dromara.workflow.domain.vo.XgStudentLeaveVo; import org.dromara.workflow.domain.XgStudentLeave; import org.dromara.workflow.mapper.XgStudentLeaveMapper; import org.dromara.workflow.service.IXgStudentLeaveService; +import org.dromara.workflow.common.ConditionalOnEnable; +import org.dromara.workflow.domain.TestLeave; +import org.dromara.workflow.domain.bo.TestLeaveBo; +import org.dromara.workflow.domain.vo.TestLeaveVo; +import org.dromara.workflow.mapper.TestLeaveMapper; +import org.dromara.workflow.service.ITestLeaveService; +import org.springframework.context.event.EventListener; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.dromara.common.core.domain.event.ProcessTaskEvent; +import org.dromara.common.core.domain.event.ProcessDeleteEvent; +import org.dromara.common.core.domain.event.ProcessEvent; +import org.dromara.common.core.enums.BusinessStatusEnum; +import org.dromara.common.core.service.WorkflowService; +import org.dromara.common.core.utils.MapstructUtils; +import org.dromara.common.core.utils.StringUtils; +import org.dromara.common.mybatis.core.domain.BaseEntity; +import org.dromara.common.mybatis.core.page.PageQuery; +import org.dromara.common.mybatis.core.page.TableDataInfo; +import cn.hutool.core.convert.Convert; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.map.MapUtil; +import cn.hutool.core.util.ObjectUtil; import java.util.List; import java.util.Map; @@ -26,12 +49,14 @@ import java.util.Collection; * @author zlwu * @date 2025-08-03 */ +@ConditionalOnEnable @Slf4j @RequiredArgsConstructor @Service public class XgStudentLeaveServiceImpl implements IXgStudentLeaveService { private final XgStudentLeaveMapper baseMapper; + private final WorkflowService workflowService; /** * 查询学生请假 - 记录学生的请假申请、审批和销假信息 @@ -40,7 +65,7 @@ public class XgStudentLeaveServiceImpl implements IXgStudentLeaveService { * @return 学生请假 - 记录学生的请假申请、审批和销假信息 */ @Override - public XgStudentLeaveVo queryById(Long id){ + public XgStudentLeaveVo queryById(Long id) { return baseMapper.selectVoById(id); } @@ -85,26 +110,35 @@ public class XgStudentLeaveServiceImpl implements IXgStudentLeaveService { lqw.eq(bo.getCollegeId() != null, XgStudentLeave::getCollegeId, bo.getCollegeId()); lqw.like(StringUtils.isNotBlank(bo.getCollegeName()), XgStudentLeave::getCollegeName, bo.getCollegeName()); lqw.eq(StringUtils.isNotBlank(bo.getLeaveTypeCode()), XgStudentLeave::getLeaveTypeCode, bo.getLeaveTypeCode()); - lqw.like(StringUtils.isNotBlank(bo.getLeaveTypeName()), XgStudentLeave::getLeaveTypeName, bo.getLeaveTypeName()); + lqw.like(StringUtils.isNotBlank(bo.getLeaveTypeName()), XgStudentLeave::getLeaveTypeName, + bo.getLeaveTypeName()); lqw.eq(bo.getStartTime() != null, XgStudentLeave::getStartTime, bo.getStartTime()); lqw.eq(bo.getEndTime() != null, XgStudentLeave::getEndTime, bo.getEndTime()); lqw.eq(bo.getLeaveDuration() != null, XgStudentLeave::getLeaveDuration, bo.getLeaveDuration()); lqw.eq(StringUtils.isNotBlank(bo.getIsLeaveSchool()), XgStudentLeave::getIsLeaveSchool, bo.getIsLeaveSchool()); lqw.eq(StringUtils.isNotBlank(bo.getNeedCancel()), XgStudentLeave::getNeedCancel, bo.getNeedCancel()); - lqw.eq(StringUtils.isNotBlank(bo.getEmergencyContact()), XgStudentLeave::getEmergencyContact, bo.getEmergencyContact()); - lqw.eq(StringUtils.isNotBlank(bo.getEmergencyPhone()), XgStudentLeave::getEmergencyPhone, bo.getEmergencyPhone()); + lqw.eq(StringUtils.isNotBlank(bo.getEmergencyContact()), XgStudentLeave::getEmergencyContact, + bo.getEmergencyContact()); + lqw.eq(StringUtils.isNotBlank(bo.getEmergencyPhone()), XgStudentLeave::getEmergencyPhone, + bo.getEmergencyPhone()); lqw.eq(StringUtils.isNotBlank(bo.getLeaveReason()), XgStudentLeave::getLeaveReason, bo.getLeaveReason()); lqw.eq(StringUtils.isNotBlank(bo.getLeaveLocation()), XgStudentLeave::getLeaveLocation, bo.getLeaveLocation()); - lqw.eq(StringUtils.isNotBlank(bo.getAttachmentOssIds()), XgStudentLeave::getAttachmentOssIds, bo.getAttachmentOssIds()); - lqw.eq(StringUtils.isNotBlank(bo.getApprovalStatus()), XgStudentLeave::getApprovalStatus, bo.getApprovalStatus()); - lqw.eq(StringUtils.isNotBlank(bo.getApprovalOpinion()), XgStudentLeave::getApprovalOpinion, bo.getApprovalOpinion()); + lqw.eq(StringUtils.isNotBlank(bo.getAttachmentOssIds()), XgStudentLeave::getAttachmentOssIds, + bo.getAttachmentOssIds()); + lqw.eq(StringUtils.isNotBlank(bo.getApprovalStatus()), XgStudentLeave::getApprovalStatus, + bo.getApprovalStatus()); + lqw.eq(StringUtils.isNotBlank(bo.getApprovalOpinion()), XgStudentLeave::getApprovalOpinion, + bo.getApprovalOpinion()); lqw.eq(bo.getApprovalTime() != null, XgStudentLeave::getApprovalTime, bo.getApprovalTime()); lqw.eq(bo.getApprovalBy() != null, XgStudentLeave::getApprovalBy, bo.getApprovalBy()); - lqw.like(StringUtils.isNotBlank(bo.getApprovalByName()), XgStudentLeave::getApprovalByName, bo.getApprovalByName()); + lqw.like(StringUtils.isNotBlank(bo.getApprovalByName()), XgStudentLeave::getApprovalByName, + bo.getApprovalByName()); lqw.eq(StringUtils.isNotBlank(bo.getCancelStatus()), XgStudentLeave::getCancelStatus, bo.getCancelStatus()); lqw.eq(bo.getCancelTime() != null, XgStudentLeave::getCancelTime, bo.getCancelTime()); - lqw.eq(StringUtils.isNotBlank(bo.getCancelLocation()), XgStudentLeave::getCancelLocation, bo.getCancelLocation()); - lqw.eq(StringUtils.isNotBlank(bo.getCancelPhotoOssIds()), XgStudentLeave::getCancelPhotoOssIds, bo.getCancelPhotoOssIds()); + lqw.eq(StringUtils.isNotBlank(bo.getCancelLocation()), XgStudentLeave::getCancelLocation, + bo.getCancelLocation()); + lqw.eq(StringUtils.isNotBlank(bo.getCancelPhotoOssIds()), XgStudentLeave::getCancelPhotoOssIds, + bo.getCancelPhotoOssIds()); lqw.eq(StringUtils.isNotBlank(bo.getCancelRemark()), XgStudentLeave::getCancelRemark, bo.getCancelRemark()); return lqw; } @@ -113,17 +147,19 @@ public class XgStudentLeaveServiceImpl implements IXgStudentLeaveService { * 新增学生请假 - 记录学生的请假申请、审批和销假信息 * * @param bo 学生请假 - 记录学生的请假申请、审批和销假信息 - * @return 是否新增成功 + * @return 新增成功的学生请假信息 */ @Override - public Boolean insertByBo(XgStudentLeaveBo bo) { + public XgStudentLeaveVo insertByBo(XgStudentLeaveBo bo) { XgStudentLeave add = MapstructUtils.convert(bo, XgStudentLeave.class); validEntityBeforeSave(add); boolean flag = baseMapper.insert(add) > 0; if (flag) { bo.setId(add.getId()); + // 返回新增成功的记录信息 + return MapstructUtils.convert(add, XgStudentLeaveVo.class); } - return flag; + return null; } /** @@ -142,8 +178,8 @@ public class XgStudentLeaveServiceImpl implements IXgStudentLeaveService { /** * 保存前的数据校验 */ - private void validEntityBeforeSave(XgStudentLeave entity){ - //TODO 做一些数据校验,如唯一约束 + private void validEntityBeforeSave(XgStudentLeave entity) { + // TODO 做一些数据校验,如唯一约束 } /** @@ -155,9 +191,71 @@ public class XgStudentLeaveServiceImpl implements IXgStudentLeaveService { */ @Override public Boolean deleteWithValidByIds(Collection ids, Boolean isValid) { - if(isValid){ - //TODO 做一些业务上的校验,判断是否需要校验 + if (isValid) { + // TODO 做一些业务上的校验,判断是否需要校验 } return baseMapper.deleteByIds(ids) > 0; } + + /** + * 总体流程监听(例如: 草稿,撤销,退回,作废,终止,已完成,单任务完成等) + * 正常使用只需#processEvent.flowCode=='leave1' + * 示例为了方便则使用startsWith匹配了全部示例key + * + * @param processEvent 参数 + */ + @EventListener(condition = "#processEvent.flowCode.startsWith('hzdyjs-qj')") + public void processHandler(ProcessEvent processEvent) { + log.info("当前任务执行了{}", processEvent.toString()); + XgStudentLeave xgStudentLeave = baseMapper.selectById(Long.valueOf(processEvent.getBusinessId())); + xgStudentLeave.setApprovalStatus(processEvent.getStatus()); + // 用于例如审批附件 审批意见等 存储到业务表内 自行根据业务实现存储流程 + Map params = processEvent.getParams(); + if (MapUtil.isNotEmpty(params)) { + // 历史任务扩展(通常为附件) + String hisTaskExt = Convert.toStr(params.get("hisTaskExt")); + // 办理人 + String handler = Convert.toStr(params.get("handler")); + // 办理意见 + String message = Convert.toStr(params.get("message")); + } + if (processEvent.getSubmit()) { + xgStudentLeave.setApprovalStatus(BusinessStatusEnum.WAITING.getStatus()); + } + baseMapper.updateById(xgStudentLeave); + } + + /** + * 执行任务创建监听 + * 示例:也可通过 @EventListener(condition = + * "#processTaskEvent.flowCode=='leave1'")进行判断 + * 在方法中判断流程节点key + * if ("xxx".equals(processTaskEvent.getNodeCode())) { + * //执行业务逻辑 + * } + * + * @param processTaskEvent 参数 + */ + @EventListener(condition = "#processTaskEvent.flowCode.startsWith('hzdyjs-qj')") + public void processTaskHandler(ProcessTaskEvent processTaskEvent) { + log.info("当前任务创建了{}", processTaskEvent.toString()); + } + + /** + * 监听删除流程事件 + * 正常使用只需#processDeleteEvent.flowCode=='leave1' + * 示例为了方便则使用startsWith匹配了全部示例key + * + * @param processDeleteEvent 参数 + */ + @EventListener(condition = "#processDeleteEvent.flowCode.startsWith('hzdyjs-qj')") + public void processDeleteHandler(ProcessDeleteEvent processDeleteEvent) { + log.info("监听删除流程事件,当前任务执行了{}", processDeleteEvent.toString()); + XgStudentLeave xgStudentLeave = baseMapper.selectById(Long.valueOf(processDeleteEvent.getBusinessId())); + if (ObjectUtil.isNull(xgStudentLeave)) { + return; + } + baseMapper.deleteById(xgStudentLeave.getId()); + } + } diff --git a/docs/变更管理/code-adjust-record-2025-01-27-cursor.md b/docs/变更管理/code-adjust-record-2025-01-27-cursor.md index b485a581..cca43792 100644 --- a/docs/变更管理/code-adjust-record-2025-01-27-cursor.md +++ b/docs/变更管理/code-adjust-record-2025-01-27-cursor.md @@ -2636,3 +2636,87 @@ const url = window.URL.createObjectURL(response.data as Blob); **修复状态**: ✅ 已完成 **测试状态**: ✅ 通过 **部署状态**: ⏳ 待部署 + +# 代码调整记录 - 2025-01-27 + +## 修改内容 + +### 学生请假管理 - add接口返回值优化 + +**修改时间**: 2025-01-27 14:30:00 +**修改人**: cursor +**修改原因**: 用户需求 - 新增成功后返回新增成功的记录信息 + +#### 涉及文件 +1. `backend/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/controller/XgStudentLeaveController.java` +2. `backend/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/IXgStudentLeaveService.java` +3. `backend/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/XgStudentLeaveServiceImpl.java` + +#### 具体修改 + +**1. Controller层修改** +- 文件: `XgStudentLeaveController.java` +- 方法: `add()` 方法 +- 修改前: `public R add(...)` +- 修改后: `public R add(...)` +- 返回值: 从返回操作结果改为返回新增成功的记录信息 + +**2. Service接口修改** +- 文件: `IXgStudentLeaveService.java` +- 方法: `insertByBo()` 方法 +- 修改前: `Boolean insertByBo(XgStudentLeaveBo bo)` +- 修改后: `XgStudentLeaveVo insertByBo(XgStudentLeaveBo bo)` +- 注释更新: 从"是否新增成功"改为"新增成功的学生请假信息" + +**3. Service实现修改** +- 文件: `XgStudentLeaveServiceImpl.java` +- 方法: `insertByBo()` 方法 +- 修改前: 返回 `Boolean` 类型 +- 修改后: 返回 `XgStudentLeaveVo` 类型 +- 新增逻辑: 插入成功后,将实体对象转换为VO对象返回 + +#### 技术实现细节 + +```java +// 修改后的Service实现 +@Override +public XgStudentLeaveVo insertByBo(XgStudentLeaveBo bo) { + XgStudentLeave add = MapstructUtils.convert(bo, XgStudentLeave.class); + validEntityBeforeSave(add); + boolean flag = baseMapper.insert(add) > 0; + if (flag) { + bo.setId(add.getId()); + // 返回新增成功的记录信息 + return MapstructUtils.convert(add, XgStudentLeaveVo.class); + } + return null; +} +``` + +#### 修改效果 + +**修改前**: +- 新增接口返回: `R` - 只返回操作是否成功 +- 前端无法直接获取新增记录的信息 + +**修改后**: +- 新增接口返回: `R` - 返回新增成功的完整记录信息 +- 前端可以直接获取新增记录的ID、创建时间等完整信息 +- 便于前端后续操作,如跳转到详情页、刷新列表等 + +#### 兼容性说明 + +- ✅ **向后兼容**: 不影响现有功能 +- ✅ **数据完整性**: 返回的VO对象包含所有必要字段 +- ✅ **错误处理**: 插入失败时返回null,Controller层会正确处理 + +#### 测试建议 + +1. **功能测试**: 验证新增学生请假记录后能正确返回记录信息 +2. **数据验证**: 确认返回的VO对象包含正确的ID、创建时间等字段 +3. **异常测试**: 验证插入失败时的错误处理 + +--- + +**记录人**: cursor +**记录时间**: 2025-01-27 14:30:00 diff --git a/docs/设计文档/database/学生请假/xg_student_leave.sql b/docs/设计文档/database/学生请假/xg_student_leave.sql index b6700027..8e190886 100644 --- a/docs/设计文档/database/学生请假/xg_student_leave.sql +++ b/docs/设计文档/database/学生请假/xg_student_leave.sql @@ -42,7 +42,7 @@ CREATE TABLE `xg_student_leave` ( `attachment_oss_ids` text DEFAULT NULL COMMENT '附件OSS文件ID(逗号分隔)', -- 审批状态 - `approval_status` char(1) NOT NULL DEFAULT '0' COMMENT '审批状态:0-待审批,1-已通过,2-已拒绝,3-已取消', + `approval_status` char(1) NOT NULL DEFAULT '0' COMMENT '审批状态:draft - 草稿 waiting -审批中 finish- 审批完成', `approval_opinion` varchar(500) DEFAULT NULL COMMENT '审批意见', `approval_time` datetime DEFAULT NULL COMMENT '审批时间', `approval_by` bigint(20) DEFAULT NULL COMMENT '审批人ID', diff --git a/web/src/views/xg/xsjcxx/xsqj/dialog.vue b/web/src/views/xg/xsjcxx/xsqj/dialog.vue index 2f5b29a5..cc6f76ab 100644 --- a/web/src/views/xg/xsjcxx/xsqj/dialog.vue +++ b/web/src/views/xg/xsjcxx/xsqj/dialog.vue @@ -1,5 +1,5 @@ - - + diff --git a/web/src/views/xg/xsjcxx/xsqj/index.vue b/web/src/views/xg/xsjcxx/xsqj/index.vue index 3daff663..2751a030 100644 --- a/web/src/views/xg/xsjcxx/xsqj/index.vue +++ b/web/src/views/xg/xsjcxx/xsqj/index.vue @@ -210,7 +210,7 @@ - + - @@ -443,23 +433,39 @@ const handleSelectionChange = (selection: StudentLeaveVO[]) => { /** 新增按钮操作 */ const handleAdd = () => { - reset(); - dialog.visible = true; - dialog.title = '添加学生请假'; - // 传递type参数,标识为新增操作 - form.value.type = 'add'; + // reset(); + // dialog.visible = true; + // dialog.title = '添加学生请假'; + // // 传递type参数,标识为新增操作 + // form.value.type = 'add'; + // proxy.$tab.closePage(proxy.$route); + proxy.$router.push({ + path: `/xg/xsjcxx/xsqj/leaveEdit/index`, + query: { + type: 'add' + } + }); }; /** 修改按钮操作 */ const handleUpdate = async (row?: StudentLeaveVO) => { - reset(); + // reset(); const _id = row?.id || ids.value[0]; - const res = await getStudentLeave(_id); - Object.assign(form.value, res.data); - // 传递type参数,标识为修改操作 - form.value.type = 'update'; - dialog.visible = true; - dialog.title = '修改学生请假'; + // const res = await getStudentLeave(_id); + // Object.assign(form.value, res.data); + // // 传递type参数,标识为修改操作 + // form.value.type = 'update'; + // form.value.id = _id; + // dialog.visible = true; + // dialog.title = '修改学生请假'; + // proxy.$tab.closePage(proxy.$route); + proxy.$router.push({ + path: `/xg/xsjcxx/xsqj/leaveEdit/index`, + query: { + id: _id, + type: 'update' + } + }); }; /** 提交按钮 */