瀏覽代碼

数据应用部门选择树

wangzhe 2 年之前
父節點
當前提交
8f738d8ecf

+ 13 - 1
leiSP-admin/src/main/java/com/sooka/web/controller/system/SysDeptController.java

@@ -1,6 +1,9 @@
 package com.sooka.web.controller.system;
 
 import java.util.List;
+
+import com.sooka.system.domain.SysMenu;
+import com.sooka.system.service.ISysMenuService;
 import org.apache.shiro.authz.annotation.RequiresPermissions;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
@@ -36,6 +39,8 @@ public class SysDeptController extends BaseController
 
     @Autowired
     private ISysDeptService deptService;
+    @Autowired
+    private ISysMenuService menuService;
 
     @RequiresPermissions("system:dept:view")
     @GetMapping()
@@ -201,7 +206,14 @@ public class SysDeptController extends BaseController
     public String selectDeptDataTreeByShareType(@PathVariable("deptId") Long deptId,
                                             @PathVariable(value = "shareType", required = false) String shareType, ModelMap mmap)
     {
-        mmap.put("dept", deptService.selectDeptById(deptId));
+//        mmap.put("dept", deptService.selectDeptById(deptId));
+        SysDept dept = new SysDept();
+        SysMenu menu = menuService.selectMenuById(deptId);
+        dept.setStatus("0");
+        dept.setDeptId(deptId);
+        dept.setDeptName(menu.getMenuName());
+        dept.setParentId(menu.getParentId());
+        mmap.put("dept", dept);
         mmap.put("shareType", shareType);
         return "applyData/record" + "/provideDeptTree";
     }

+ 19 - 1
leiSP-system/src/main/java/com/sooka/system/service/impl/SysDeptServiceImpl.java

@@ -107,12 +107,30 @@ public class SysDeptServiceImpl implements ISysDeptService
         for (int m = 0; m < sysMenuList.size(); m++) {
             SysMenu menu = sysMenuList.get(m);
             SysDept dept = new SysDept();
-            dept.setStatus("0");
+            dept.setStatus("2");
             dept.setDeptId(menu.getMenuId());
             dept.setDeptName(menu.getMenuName());
             dept.setParentId(menu.getParentId());
             deptList.add(dept);
         }
+        List<SysDept> deptChildList = new ArrayList();
+        for (int i = 0; i < deptList.size(); i++) {
+            deptChildList.add(deptList.get(i));
+        }
+        //只选择到倒数第二层节点 排除根节点
+        for (int i = 0; i < deptList.size(); i++) {
+            for (int j = 0; j < deptChildList.size(); j++) {
+                if(String.valueOf(deptList.get(i).getDeptId()).equals(String.valueOf(deptChildList.get(j).getParentId()))){
+                    deptList.get(i).setStatus("0");
+                    break;
+                }
+            }
+        }
+        for (int i = 0; i < deptList.size(); i++) {
+            if(deptList.get(i).getStatus().equals("2")){
+                deptList.remove(i--);
+            }
+        }
 //        List<SysDept> deptList = deptMapper.selectProvideDeptDataList(shareType);//2088 省共享数据核验管理 2089 市共享数据核验管理
         List<Ztree> ztrees = initZtree(deptList);
         return ztrees;

+ 1 - 1
mybusiness/src/main/resources/templates/applyData/record/provideDeptTree.html

@@ -2,7 +2,7 @@
 <html lang="zh" xmlns:th="http://www.thymeleaf.org" >
 <head>
 	<th:block th:include="include :: header('部门树选择')" />
-	<th:block th:include="include :: ztree-css" />
+	<th:block th:include="include :: ztree-css" /a>
 </head>
 <style>
 	body{height:auto;font-family: "Microsoft YaHei";}