Browse Source

单位列表增加上级单位查询。

zhengqiang 5 năm trước cách đây
mục cha
commit
35c2aca675

+ 4 - 2
common/src/main/resources/mapper/base/CompanyInfo.xml

@@ -119,13 +119,15 @@
             <if test="searchParams.name != null">
                 and a.name_ like #{searchParams.name}
             </if>
+            <if test="searchParams.parentCode != null">
+                and b.code_ like #{searchParams.parentCode}
+            </if>
             <if test="searchParams.bindCompanyId != null">
                 and (
                 a.id_ = #{searchParams.bindCompanyId} or
                 a.parent_id = #{searchParams.bindCompanyId}
                 )
             </if>
-
         </where>
         <foreach item="sort" collection="sortList" open="order by" separator=",">
             a.${sort.name} ${sort.order}
@@ -144,7 +146,7 @@
             )
             </if>
         )
-        order by a.id_ asc
+        order by a.sort_no asc,a.name_ asc
     </select>
     <select id="countByParentId" resultType="long">
         select count(*) from base_company_info

+ 15 - 1
web/src/main/java/com/jpsoft/smart/modules/base/controller/CompanyInfoController.java

@@ -351,7 +351,7 @@ public class CompanyInfoController {
     @ApiOperation(value="列表")
     @RequestMapping(value = "pageList",method = RequestMethod.POST)
     public MessageResult<Map> pageList(
-            String name,
+            String name,String parentId,Boolean subordinate,
             @RequestParam(value="pageIndex",defaultValue="1") int pageIndex,
             @RequestParam(value="pageSize",defaultValue="20") int pageSize,
             @RequestAttribute String subject){
@@ -369,11 +369,25 @@ public class CompanyInfoController {
 
         List<Sort> sortList = new ArrayList<>();
         sortList.add(new Sort("sort_no","asc"));
+        sortList.add(new Sort("name_","asc"));
 
         if (StringUtils.isNotEmpty(name)) {
             searchParams.put("name","%" + name + "%");
         }
 
+        if (StringUtils.isNotEmpty(parentId)) {
+            CompanyInfo parent = companyInfoService.get(parentId);
+
+            if (parent!=null){
+                if(subordinate!=null && subordinate){
+                    searchParams.put("parentCode",parent.getCode() + "%");
+                }
+                else{
+                    searchParams.put("parentCode",parent.getCode());
+                }
+            }
+        }
+
         Page<CompanyInfo> page = companyInfoService.pageSearch(searchParams,pageIndex,pageSize,sortList);
         Page<CompanyInfoDTO> pageDTO = PojoUtils.convertPage(page, CompanyInfoDTO.class);
         for(CompanyInfoDTO li : pageDTO.getResult()){