Преглед на файлове

嘱托管理搜索优化

WANGJIALIANG преди 4 години
родител
ревизия
6ad2e6e215

+ 7 - 1
src/main/java/cn/hnthyy/thmz/controller/mz/MzZdInstructionCodeController.java

@@ -67,8 +67,14 @@ public class MzZdInstructionCodeController {
                 resultMap.put("message", "查询嘱托失败,参数为空");
                 return resultMap;
             }
+            if(mzZdInstructionCodePageDto.getSearchText() != null){
+                String searchText = mzZdInstructionCodePageDto.getSearchText();
+                if(searchText.matches("[a-zA-Z]+")){
+                    mzZdInstructionCodePageDto.setSearchText(searchText.toUpperCase());
+                }
+            }
             List<MzZdInstructionCode> list = mzZdInstructionCodeService.queryMzZdInstructionPage(mzZdInstructionCodePageDto);
-            int total = mzZdInstructionCodeService.queryMzZdInstructionCount(mzZdInstructionCodePageDto.getMzZdInstructionCode());
+            int total = mzZdInstructionCodeService.queryMzZdInstructionCount(mzZdInstructionCodePageDto);
             resultMap.put("code", 0);
             resultMap.put("message", "查询嘱托成功");
             resultMap.put("data", list);

+ 12 - 24
src/main/java/cn/hnthyy/thmz/mapper/his/zd/MzZdInstructionCodeMapper.java

@@ -33,17 +33,11 @@ public interface MzZdInstructionCodeMapper {
             "<when test='mzZdInstructionCode.code!=null'>",
             " and code = #{mzZdInstructionCode.code}",
             "</when>",
-            "<when test='mzZdInstructionCode.instructionText!=null'>",
-            " and instruction_text like '%${mzZdInstructionCode.instructionText}%'",
-            "</when>",
             "<when test='mzZdInstructionCode.delFlag!=null'>",
             " and del_flag = #{mzZdInstructionCode.delFlag}",
             "</when>",
-            "<when test='mzZdInstructionCode.pyCode!=null'>",
-            " and py_code = #{mzZdInstructionCode.pyCode}",
-            "</when>",
-            "<when test='mzZdInstructionCode.wbCode!=null'>",
-            " and d_code = #{mzZdInstructionCode.wbCode}",
+            "<when test='searchText!=null'>",
+            " and (py_code like '${searchText}%' or d_code like '${searchText}%' or instruction_text  like '%${searchText}%')",
             "</when>",
             "<when test='mzZdInstructionCode.instructionType!=null'>",
             " and instruction_type = #{mzZdInstructionCode.instructionType}",
@@ -56,31 +50,25 @@ public interface MzZdInstructionCodeMapper {
     /**
      * 统计嘱托数量
      *
-     * @param mzZdInstructionCode 嘱托查询条件
+     * @param mzZdInstructionCodePageDto 嘱托查询条件
      * @return
      */
     @Select({"<script>",
             "select count(1) from mz_zd_instruction_code where 1=1 ",
-            "<when test='code!=null'>",
-            " and code = #{code}",
-            "</when>",
-            "<when test='instructionText!=null'>",
-            " and instruction_text like '%${instructionText}%'",
-            "</when>",
-            "<when test='delFlag!=null'>",
-            " and del_flag = #{delFlag}",
+            "<when test='mzZdInstructionCode.code!=null'>",
+            " and code = #{mzZdInstructionCode.code}",
             "</when>",
-            "<when test='pyCode!=null'>",
-            " and py_code = #{pyCode}",
+            "<when test='mzZdInstructionCode.delFlag!=null'>",
+            " and del_flag = #{mzZdInstructionCode.delFlag}",
             "</when>",
-            "<when test='wbCode!=null'>",
-            " and d_code = #{wbCode}",
+            "<when test='mzZdInstructionCode.pyCode!=null'>",
+            " and (py_code like '${searchText}%' or d_code like '${searchText}%' or instruction_text  like '%${searchText}%')",
             "</when>",
-            "<when test='instructionType!=null'>",
-            " and instruction_type = #{instructionType}",
+            "<when test='mzZdInstructionCode.instructionType!=null'>",
+            " and instruction_type = #{mzZdInstructionCode.instructionType}",
             "</when>",
             "</script>"})
-    int selectMzZdInstructionCount(MzZdInstructionCode mzZdInstructionCode);
+    int selectMzZdInstructionCount(MzZdInstructionCodePageDto mzZdInstructionCodePageDto);
 
     /**
      * 修改嘱托

+ 2 - 0
src/main/java/cn/hnthyy/thmz/pageDto/MzZdInstructionCodePageDto.java

@@ -9,6 +9,8 @@ import lombok.Data;
 @Data
 public class MzZdInstructionCodePageDto {
     private MzZdInstructionCode mzZdInstructionCode;
+    //查询内容
+    private   String searchText;
     //默认页
     private   Integer pageIndex=0;
     //默认页面展示数

+ 2 - 2
src/main/java/cn/hnthyy/thmz/service/his/zd/MzZdInstructionCodeService.java

@@ -24,10 +24,10 @@ public interface MzZdInstructionCodeService {
     /**
      * 统计嘱托数量
      *
-     * @param mzZdInstructionCode 嘱托查询条件
+     * @param mzZdInstructionCodePageDto 嘱托查询条件
      * @return
      */
-    int queryMzZdInstructionCount(MzZdInstructionCode mzZdInstructionCode);
+    int queryMzZdInstructionCount(MzZdInstructionCodePageDto mzZdInstructionCodePageDto);
 
     /**
      * 修改嘱托

+ 2 - 2
src/main/java/cn/hnthyy/thmz/service/impl/his/zd/MzZdInstructionCodeServiceImpl.java

@@ -26,8 +26,8 @@ public class MzZdInstructionCodeServiceImpl implements MzZdInstructionCodeServic
     }
 
     @Override
-    public int queryMzZdInstructionCount(MzZdInstructionCode mzZdInstructionCode) {
-        return mzZdInstructionCodeMapper.selectMzZdInstructionCount(mzZdInstructionCode);
+    public int queryMzZdInstructionCount(MzZdInstructionCodePageDto mzZdInstructionCodePageDto) {
+        return mzZdInstructionCodeMapper.selectMzZdInstructionCount(mzZdInstructionCodePageDto);
     }
 
     @Override

+ 2 - 4
src/main/resources/static/js/mz/instruction_code.js

@@ -254,12 +254,10 @@ function queryParams(params) {
     var temp = {   //这里的键的名字和控制器的变量名必须一直,这边改动,控制器也需要改成一样的
         pageSize: params.limit,   //页面大小
         pageIndex: params.offset / params.limit,  //页码
+        searchText: $("#searchText").val() == "" ? null : $("#searchText").val(),
         mzZdInstructionCode: {
             delFlag: $("#delFlagSearch").val() == "" ? null : $("#delFlagSearch").val(),
-            instructionType: $("#instructionTypeSearch").val() == "" ? null : $("#instructionTypeSearch").val(),
-            wbCode: $("#wbCodeSearch").val() == "" ? null : $("#wbCodeSearch").val(),
-            pyCode: $("#pyCodeSearch").val() == "" ? null : $("#pyCodeSearch").val(),
-            instructionText: $("#instructionTextSearch").val() == "" ? null : $("#instructionTextSearch").val()
+            instructionType: $("#instructionTypeSearch").val() == "" ? null : $("#instructionTypeSearch").val()
         }
     };
     return temp;

+ 2 - 14
src/main/resources/templates/mz/instruction_code.html

@@ -8,20 +8,10 @@
             <div class="panel-body">
                 <form id="formSearch" class="form-horizontal" autocomplete="off">
                     <div class="item form-group ">
-                        <label class="control-label col-md-1 col-sm-1 col-xs-12" for="pyCodeSearch">拼音码
-                        </label>
-                        <div class="col-md-1 col-sm-1 col-xs-12">
-                            <input id="pyCodeSearch" class="form-control optional" type="text">
-                        </div>
-                        <label class="control-label col-md-1 col-sm-1 col-xs-12" for="wbCodeSearch">五笔码
-                        </label>
-                        <div class="col-md-1 col-sm-1 col-xs-12">
-                            <input id="wbCodeSearch" class="form-control optional" type="text">
-                        </div>
-                        <label class="control-label col-md-1 col-sm-1 col-xs-12" for="instructionTextSearch">内容
+                        <label class="control-label col-md-1 col-sm-1 col-xs-12" for="searchText">搜索
                         </label>
                         <div class="col-md-2 col-sm-2 col-xs-12">
-                            <input id="instructionTextSearch" class="form-control optional" type="text">
+                            <input id="searchText" class="form-control optional" type="text" placeholder="拼音码|五笔码|内容">
                         </div>
                         <div class="col-md-2 col-sm-2 col-xs-12 item">
                             <label class="control-label col-md-4 col-sm-4 col-xs-12"
@@ -52,8 +42,6 @@
                         <button type="button" id="btn_reset" class="btn btn-primary"
                                 title="重置" onclick="resetSearch()"><i class="fa fa-rotate-left"></i>
                         </button>
-                    </div>
-                    <div class="item form-group ">
                         <button type="button" id="btn_add" class="btn btn-primary"
                                 title="添加嘱托"><i class="fa fa-plus"></i>
                         </button>