feat(organization): 添加科室管理查询过滤功能

- 修复api.js中params参数拼写错误
- 添加科室名称、类型、分类的查询表单
- 实现搜索和重置功能
- 集成分页组件并修正页码参数映射
- 在后端服务中添加查询条件过滤逻辑
- 支持按科室名称、类型、分类进行条件查询
- 实现动态排序功能并修复分页查询逻辑
This commit is contained in:
2025-12-30 16:52:01 +08:00
parent 8f77fe8bc9
commit 1ac9b5ae0b
5 changed files with 111 additions and 18 deletions

View File

@@ -15,11 +15,16 @@ public interface IOrganizationAppService {
*
* @param pageNo 当前页码
* @param pageSize 查询条数
* @param name 科室名称
* @param typeEnum 科室类型
* @param classEnum 科室分类
* @param sortField 排序字段
* @param sortOrder 排序方向
* @param request 请求数据
* @return 机构树分页列表
*/
Page<OrganizationDto> getOrganizationTree(Integer pageNo, Integer pageSize, String sortField, String sortOrder,
HttpServletRequest request);
Page<OrganizationDto> getOrganizationTree(Integer pageNo, Integer pageSize, String name, Integer typeEnum, Integer classEnum,
String sortField, String sortOrder, HttpServletRequest request);
/**
* 机构信息详情

View File

@@ -1,5 +1,6 @@
package com.openhis.web.basedatamanage.appservice.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.core.common.core.domain.R;
@@ -38,11 +39,25 @@ public class OrganizationAppServiceImpl implements IOrganizationAppService {
private AssignSeqUtil assignSeqUtil;
@Override
public Page<OrganizationDto> getOrganizationTree(Integer pageNo, Integer pageSize, String sortField,
String sortOrder, HttpServletRequest request) {
// 查询机构列表
public Page<OrganizationDto> getOrganizationTree(Integer pageNo, Integer pageSize, String name, Integer typeEnum, Integer classEnum,
String sortField, String sortOrder, HttpServletRequest request) {
// 创建查询条件
LambdaQueryWrapper<Organization> queryWrapper = new LambdaQueryWrapper<>();
// 添加查询条件
if (StringUtils.isNotEmpty(name)) {
queryWrapper.like(Organization::getName, name);
}
if (typeEnum != null) {
queryWrapper.eq(Organization::getTypeEnum, typeEnum);
}
if (classEnum != null) {
queryWrapper.eq(Organization::getClassEnum, classEnum);
}
// 创建Page对象
Page<Organization> page = new Page<>(pageNo, pageSize);
// 处理动态排序(仅当排序字段有效时才添加排序条件)
if (sortField != null && !sortField.isEmpty()) {
// 校验排序字段是否为Organization实体中的有效字段防止非法字段
@@ -51,11 +66,12 @@ public class OrganizationAppServiceImpl implements IOrganizationAppService {
String underlineField = camelToUnderline(sortField);
// 默认为升序若指定desc则按降序
boolean isAsc = sortOrder == null || "asc".equalsIgnoreCase(sortOrder);
page.addOrder(isAsc ? OrderItem.asc(underlineField) : OrderItem.desc(underlineField));
queryWrapper.last("ORDER BY " + underlineField + " " + (isAsc ? "ASC" : "DESC"));
}
}
// 执行分页查询(此时排序条件会被应用)
page = organizationService.page(page);
// 执行分页查询
page = organizationService.page(page, queryWrapper);
List<Organization> organizationList = page.getRecords();
// 将机构列表转为树结构

View File

@@ -41,15 +41,24 @@ public class OrganizationController {
*
* @param pageNo 当前页码
* @param pageSize 查询条数
* @param name 科室名称
* @param typeEnum 科室类型
* @param classEnum 科室分类
* @param sortField 排序字段
* @param sortOrder 排序方向
* @param request 请求对象
* @return 机构分页列表
*/
@GetMapping(value = "/organization")
public R<?> getOrganizationPage(@RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(value = "pageSize", defaultValue = "100") Integer pageSize,
@RequestParam(value = "name", required = false) String name,
@RequestParam(value = "typeEnum", required = false) Integer typeEnum,
@RequestParam(value = "classEnum", required = false) Integer classEnum,
@RequestParam(value = "sortField", required = false) String sortField,
@RequestParam(value = "sortOrder", required = false) String sortOrder, HttpServletRequest request) {
Page<OrganizationDto> organizationTree =
iOrganizationAppService.getOrganizationTree(pageNo, pageSize, sortField, sortOrder, request);
iOrganizationAppService.getOrganizationTree(pageNo, pageSize, name, typeEnum, classEnum, sortField, sortOrder, request);
return R.ok(organizationTree,
MessageUtils.createMessage(PromptMsgConstant.Common.M00009, new Object[] {"机构信息"}));
}