1、涉及技术:
EasyUI
Spring MVC
2、jsp前端代码:
<select id="workUser" class="easyui-combotree" style="width:200px;" data-options="url:‘/csmis/csmisEquadjust/wswatree.action‘,required:true" multiple> </select>
3、java后台代码
public Object getWsWaTree(HttpServletRequest request, String id) { try { id = id == null ? "1" : id;//默认加载为pid为‘1’的数据,展开树会传参数id,传的id做为pid继续查询值。 User user = User.getCurrUser(request); String depLevel = user.getOrgLevel();//机构级别 String depId = depLevel.equals(OrgLevelConstants.ORG_WORKSHOP) ? user.getVcOrgId() : user.getVcParOrgId();//机构id String sqlStr = "select pid,id,text,state from(select t1.vc_org$id pid,t1.vc_number id,t1.vc_name text,‘open‘ state " + " from sys_t_person t1 where t1.vc_org$id in ( " + " select t.vc_org$id from sys_t_org t start with t.vc_org$id = ‘" + depId + "‘ " + " connect by t.vc_par$org$id = prior t.vc_org$id) and t1.vc_del = ‘0‘ and t1.vc_server = ‘" + SystemConstants.SERVER_ID + "‘ " + " union all " + " select ‘1‘ pid,t.vc_org$id id,t.vc_name text,‘closed‘ state from sys_t_org t start with t.vc_org$id = ‘" + depId + "‘ " + " connect by t.vc_par$org$id = prior t.vc_org$id and t.vc_del = ‘0‘ and t.vc_server = ‘" + SystemConstants.SERVER_ID + "‘) " + " where pid = ‘" + id + "‘"; logger.info("sqlStr::: " + sqlStr); return jdbcTemplate.query(sqlStr, BeanPropertyRowMapper.newInstance(EasyUIComboTree.class)); } catch (Exception ex) { ex.printStackTrace(); } return null; }
4、封装实体类
private String id; private String pid; private String text; private List<EasyUIComboTree> children; private String state = "closed";
5、数据库表数据结构及SQL
1、人员表 VC_NUMBER 人员编号 VC_ORG$ID 人员所属机构 VC_NAME 人员名称 2、组织机构表 VC_ORG$ID 机构编号 VC_PAR$ORG$ID 父机构编号 VC_NAME 机构名称 3、具体SQL select pid, id, text, state from (select t1.vc_org$id pid, t1.vc_number id, t1.vc_name text, ‘open‘ state from sys_t_person t1 where t1.vc_org$id in (select t.vc_org$id from sys_t_org t start with t.vc_org$id = ‘WHBUR_WHSEG_ORG_26‘ connect by t.vc_par$org$id = prior t.vc_org$id) and t1.vc_del = ‘0‘ union all select ‘1‘ pid, t.vc_org$id id, t.vc_name text, ‘closed‘ state from sys_t_org t start with t.vc_org$id = ‘WHBUR_WHSEG_ORG_26‘ connect by t.vc_par$org$id = prior t.vc_org$id and t.vc_del = ‘0‘) where pid = ‘1‘ 4、sql解释 1级默认为‘1’,根据一个二级机构编号(WHBUR_WHSEG_ORG_26),获取二级子目录及自己的机 构信息; 获取以上机构的所有人员; 其中关系形成树形结构;
6、具体效果
时间: 2024-10-21 02:35:26