feat(organization): 添加科室管理查询过滤功能
- 修复api.js中params参数拼写错误 - 添加科室名称、类型、分类的查询表单 - 实现搜索和重置功能 - 集成分页组件并修正页码参数映射 - 在后端服务中添加查询条件过滤逻辑 - 支持按科室名称、类型、分类进行条件查询 - 实现动态排序功能并修复分页查询逻辑
This commit is contained in:
@@ -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);
|
||||
|
||||
/**
|
||||
* 机构信息详情
|
||||
|
||||
@@ -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();
|
||||
// 将机构列表转为树结构
|
||||
|
||||
@@ -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[] {"机构信息"}));
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ export function getList(queryParams) {
|
||||
return request({
|
||||
url: '/base-data-manage/organization/organization',
|
||||
method: 'get',
|
||||
param: queryParams
|
||||
params: queryParams
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,42 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<!-- 查询表单 -->
|
||||
<el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" class="query-form">
|
||||
<el-form-item label="科室名称" prop="name">
|
||||
<el-input
|
||||
v-model="queryParams.name"
|
||||
placeholder="请输入科室名称"
|
||||
clearable
|
||||
@keyup.enter="handleQuery"
|
||||
style="width: 200px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="科室类型" prop="typeEnum">
|
||||
<el-select v-model="queryParams.typeEnum" placeholder="请选择科室类型" clearable style="width: 200px">
|
||||
<el-option
|
||||
v-for="item in orgTypeOption"
|
||||
:key="item.value"
|
||||
:label="item.info"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="科室分类" prop="classEnum">
|
||||
<el-select v-model="queryParams.classEnum" placeholder="请选择科室分类" clearable style="width: 200px">
|
||||
<el-option
|
||||
v-for="item in classEnumOption"
|
||||
:key="item.value"
|
||||
:label="item.info"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item class="search-buttons">
|
||||
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button type="primary" plain icon="Plus" @click="handleAdd"> 新增 </el-button>
|
||||
@@ -67,13 +104,17 @@
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<!-- <pagination
|
||||
v-show="total > 0"
|
||||
:total="total"
|
||||
v-model:page="queryParams.pageNum"
|
||||
v-model:limit="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
/> -->
|
||||
|
||||
<!-- 分页 -->
|
||||
<div class="pagination-container">
|
||||
<pagination
|
||||
v-show="total > 0"
|
||||
:total="total"
|
||||
v-model:page="queryParams.pageNo"
|
||||
v-model:limit="queryParams.pageSize"
|
||||
@pagination="getPageList"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- 添加或修改参数配置对话框 -->
|
||||
<el-dialog :title="title" v-model="open" width="600px" @close="cancel" append-to-body>
|
||||
@@ -191,8 +232,15 @@ import {
|
||||
|
||||
const { proxy } = getCurrentInstance();
|
||||
const loading = ref(true);
|
||||
const showSearch = ref(true);
|
||||
const organization = ref([]);
|
||||
const queryParams = ref({});
|
||||
const queryParams = ref({
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
name: undefined,
|
||||
typeEnum: undefined,
|
||||
classEnum: undefined
|
||||
});
|
||||
const open = ref(false);
|
||||
const form = ref({
|
||||
id: undefined,
|
||||
@@ -305,6 +353,21 @@ function getDictLabel(value) {
|
||||
return dict ? dict.label : '';
|
||||
}
|
||||
|
||||
/** 搜索按钮操作 */
|
||||
function handleQuery() {
|
||||
queryParams.value.pageNo = 1;
|
||||
getPageList();
|
||||
}
|
||||
|
||||
/** 重置按钮操作 */
|
||||
function resetQuery() {
|
||||
queryParams.value.name = undefined;
|
||||
queryParams.value.typeEnum = undefined;
|
||||
queryParams.value.classEnum = undefined;
|
||||
queryParams.value.pageNo = 1;
|
||||
getPageList();
|
||||
}
|
||||
|
||||
function getPageList() {
|
||||
loading.value = true;
|
||||
getList(queryParams.value).then((res) => {
|
||||
|
||||
Reference in New Issue
Block a user