diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/check/controller/CheckTypeController.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/check/controller/CheckTypeController.java index 24f17067..3dd4a911 100644 --- a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/check/controller/CheckTypeController.java +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/check/controller/CheckTypeController.java @@ -1,6 +1,8 @@ package com.openhis.web.check.controller; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.core.common.core.controller.BaseController; import com.core.common.core.domain.AjaxResult; import com.core.common.core.domain.R; @@ -20,7 +22,8 @@ import org.springframework.web.bind.annotation.*; import javax.validation.Valid; import java.time.LocalDate; -import java.util.List; +import java.util.*; +import java.util.stream.Collectors; /** * 检查类型管理Controller @@ -42,14 +45,59 @@ public class CheckTypeController extends BaseController { private final ICheckPackageAppService checkPackageAppService; /** - * 获取检查类型列表 + * 获取检查类型列表(支持分页) */ @GetMapping("/list") - public AjaxResult list() { - List list = checkTypeService.list(); - return AjaxResult.success(list); - } + public AjaxResult list( + @RequestParam(defaultValue = "1") Integer pageNo, + @RequestParam(defaultValue = "10") Integer pageSize) { + if (pageSize > 10) pageSize = 10; + + // 1. 分页查询父节点(NULL + 0 都算父) + Page parentPage = checkTypeService.page( + new Page<>(pageNo, pageSize), + new QueryWrapper() + .and(w -> w.isNull("parent_id").or().eq("parent_id", 0)) + .orderByAsc("id") + ); + + if (parentPage.getRecords().isEmpty()) { + return AjaxResult.success(parentPage); + } + + // 2. 父ID列表(注意类型) + List parentIds = parentPage.getRecords() + .stream() + .map(CheckType::getId) + .collect(Collectors.toList()); + + // 3. 查询子节点 + List children = checkTypeService.list( + new QueryWrapper().in("parent_id", parentIds) + ); + + // 4. 分组 + Map> childMap = + children.stream().collect(Collectors.groupingBy(CheckType::getParentId)); + + // 5. 拼接父 + 子 + List result = new ArrayList<>(); + for (CheckType parent : parentPage.getRecords()) { + result.add(parent); + List list = childMap.get(parent.getId()); + if (list != null && !list.isEmpty()) { + result.addAll(list); + } + } + + // 6. 返回(total 是父节点总数) + Page page = + new Page<>(pageNo, pageSize, parentPage.getTotal()); + page.setRecords(result); + + return AjaxResult.success(page); + } /** * 获取检查方法列表 */ diff --git a/openhis-ui-vue3/src/views/maintainSystem/checkprojectSettings/index.vue b/openhis-ui-vue3/src/views/maintainSystem/checkprojectSettings/index.vue index a3c676dd..2d04d308 100644 --- a/openhis-ui-vue3/src/views/maintainSystem/checkprojectSettings/index.vue +++ b/openhis-ui-vue3/src/views/maintainSystem/checkprojectSettings/index.vue @@ -554,7 +554,26 @@ -