部门数接口 isLoadUser 改进为(true: 一次性加载;lazy: 懒加载,点击再加载)

This commit is contained in:
thinkgem
2020-02-19 19:54:11 +08:00
parent acf6ea7738
commit 5df57a9f49

View File

@@ -217,7 +217,7 @@ public class OfficeController extends BaseController {
* @param companyCode 仅查询公司下的机构
* @param isShowCode 是否显示编码true or 1显示在左侧2显示在右侧false or null不显示
* @param isShowFullName 是否显示全机构名称
* @param isLoadUser 是否加载机构下的用户
* @param isLoadUser 是否加载机构下的用户true 一次性加载lazy 懒加载,点击再加载)
* @param postCode 机构下的用户过滤岗位
* @param roleCode 机构下的用户过滤角色
* @return
@@ -227,7 +227,7 @@ public class OfficeController extends BaseController {
@ResponseBody
public List<Map<String, Object>> treeData(String excludeCode, String parentCode, Boolean isAll,
String officeTypes, String companyCode, String isShowCode, String isShowFullName,
Boolean isLoadUser, String postCode, String roleCode, String ctrlPermi) {
String isLoadUser, String postCode, String roleCode, String ctrlPermi) {
List<Map<String, Object>> mapList = ListUtils.newArrayList();
Office where = new Office();
where.setStatus(Office.STATUS_NORMAL);
@@ -269,16 +269,26 @@ public class OfficeController extends BaseController {
}
map.put("name", StringUtils.getTreeNodeName(isShowCode, e.getViewCode(), name));
map.put("title", e.getFullName());
// 一次性后台加载用户,提高性能(推荐方法)
if (isLoadUser != null && isLoadUser) {
// 如果需要加载用户,则处理用户数据
if (StringUtils.inString(isLoadUser, "true", "lazy")) {
map.put("isParent", true);
List<Map<String, Object>> userList;
userList = empUserController.treeData("u_", e.getOfficeCode(), e.getOfficeCode(),
companyCode, postCode, roleCode, isAll, isShowCode, ctrlPermi);
mapList.addAll(userList);
// 一次性后台加载用户,若数据量比较大,建议使用懒加载
if (StringUtils.equals(isLoadUser, "true")) {
List<Map<String, Object>> userList =
empUserController.treeData("u_", e.getOfficeCode(), e.getOfficeCode(),
companyCode, postCode, roleCode, isAll, isShowCode, ctrlPermi);
mapList.addAll(userList);
}
}
mapList.add(map);
}
// 懒加载用户,点击叶子节点的时候再去加载部门(懒加载无法回显,数据量大时,建议使用 listselect 实现列表选择用户)
if (StringUtils.inString(isLoadUser, "lazy") && StringUtils.isNotBlank(parentCode)) {
List<Map<String, Object>> userList =
empUserController.treeData("u_", parentCode, parentCode,
companyCode, postCode, roleCode, isAll, isShowCode, ctrlPermi);
mapList.addAll(userList);
}
return mapList;
}