参考 Organization
<div data-options="region:'west',split:true,border:false" style="width: 250px;"> <div class="TREE_COMMON_BOX_SPLIT_DIV"> <a id="examTypeTreeReload" href="javascript:void(0)" class="easyui-linkbutton" data-options="plain:true" iconCls="icon-reload">刷新</a> <a id="examTypeTreeOpenAll" href="javascript:void(0)" class="easyui-linkbutton" data-options="plain:true" iconCls="icon-sitemap">展开</a> </div> <ul id="examTypeTree"></ul> </div> <div class="easyui-layout" data-options="region:'center',border:false"> </div>
$('#examTypeTree').tree({ url : 'examtype/examtypeTree.do', onSelect : function(node) { $('#PARENTID_RULE').val(node.id); $('#PARENTTITLE_RULE').val(node.text); searchTypeTree.dosearch({ 'ruleText' : searchTypeTree.arrayStr() }); } }); $('#examTypeTreeReload').bind('click', function() { $('#examTypeTree').tree('reload'); }); $('#examTypeTreeOpenAll').bind('click', function() { $('#examTypeTree').tree('expandAll'); });
<tr> <td class="title">上级节点:</td> <td> <input id="PARENTTITLE_RULE" type="text" readonly="readonly" style="background: #F3F3E8"> <input id="PARENTID_RULE" name="PARENTID:=" type="hidden"> </td> </tr>
//新增 function addDataExamtype() { var parentID = $("#PARENTID_RULE").val(); var url = url_formActionExamtype + '?operateType=' + PAGETYPE.ADD +'&parentId='+parentID; $.farm.openWindow({ id : 'winExamtype', width : 600, height : 300, modal : true, url : url, title : '新增' }); }
<tr> <td class="title">上級分类:</td> <td><c:if test="${empty parent}">无</c:if>${parent.name}<input type="hidden" name="parentid" value="${parent.id}"></td> <td class="title"></td> <td></td> </tr>
<td class="title">排序:</td> <td colspan="3"> <input type="text" style="width: 120px;" class="easyui-validatebox" data-options="required:true,validType:['integer','maxLength[5]']" id="entity_sort" name="sort" value="${entity.sort}"> </td>
submitFormOrganization.postSubmit(submitEditActionOrganization,function() { $.messager.confirm('确认对话框', '数据更新,是否重新加载左侧组织机构树?',function(r) { if (r) { $('#OrganizationTree').tree('reload'); } }); return true; });
if (query.getQueryRule().size() == 0) { query.addRule(new DBRule("PARENTID", "NONE", "=")); }
/** * 组织机构节点 */ @RequestMapping("/examtypeTree") @ResponseBody public Object examtypeTree(String id) { try { if (id == null) { // 如果是未传入id,就是根节点,就构造一个虚拟的上级节点 id = "NONE"; List<EasyUiTreeNode> list = new ArrayList<>(); EasyUiTreeNode nodes = new EasyUiTreeNode("NONE", "考试分类", "open" , "icon-customers"); nodes.setChildren(EasyUiTreeNode.formatAsyncAjaxTree( EasyUiTreeNode.queryTreeNodeOne(id, "SORT", "WTS_EXAM_TYPE", "ID", "PARENTID", "NAME", "CTIME").getResultList(), EasyUiTreeNode.queryTreeNodeTow(id, "SORT", "WTS_EXAM_TYPE", "ID", "PARENTID", "NAME", "CTIME") .getResultList(),"PARENTID", "ID", "NAME", "CTIME")); list.add(nodes); return list; } return EasyUiTreeNode.formatAsyncAjaxTree( EasyUiTreeNode.queryTreeNodeOne(id, "SORT", "WTS_EXAM_TYPE", "ID", "PARENTID", "NAME", "CTIME").getResultList(), EasyUiTreeNode.queryTreeNodeTow(id, "SORT", "WTS_EXAM_TYPE", "ID", "PARENTID", "NAME", "CTIME").getResultList(), "PARENTID", "ID", "NAME", "CTIME"); } catch (Exception e) { log.error(e.getMessage()); return ViewMode.getInstance().setError(e.getMessage(), e).returnObjMode(); } }
@RequestMapping("/form") public ModelAndView view(RequestMode pageset, String ids, String parentId) { ...... case (1): {// 新增 ProjectType parent = null; if (StringUtils.isNotBlank(parentId)) { parent = projectTypeServiceImpl.getProjecttypeEntity(parentId); } return ViewMode.getInstance().putAttr("pageset", pageset).putAttr("parent", parent) .returnModelAndView("project/ProjectTypeForm"); } case (2): {// 修改 ProjectType type = projectTypeServiceImpl.getProjecttypeEntity(ids); ProjectType parent = null; if (StringUtils.isNotBlank(type.getParentid())) { parent = projectTypeServiceImpl.getProjecttypeEntity(type.getParentid()); } return ViewMode.getInstance().putAttr("pageset", pageset).putAttr("parent", parent) .putAttr("entity", projectTypeServiceImpl.getProjecttypeEntity(ids)) .returnModelAndView("project/ProjectTypeForm"); } ...... }
if (StringUtils.isBlank(entity.getParentid())) { entity.setParentid("NONE"); } entity.setTreecode("NONE"); entity = projecttypeDaoImpl.insertEntity(entity); initTreeCode(entity.getId()); return entity;
private void initTreeCode(String treeNodeId) { ProjectType node = getProjecttypeEntity(treeNodeId); if (node.getParentid().equals("NONE")) { node.setTreecode(node.getId()); } else { node.setTreecode(projecttypeDaoImpl.getEntity(node.getParentid()).getTreecode() + node.getId()); } projecttypeDaoImpl.editEntity(node); }
@Override @Transactional public void deleteProjecttypeEntity(String id, LoginUser user) { if (projecttypeDaoImpl.selectEntitys(DBRule.addRule(new ArrayList<DBRule>(), "parentid", id, "=")).size() > 0) { throw new RuntimeException("不能删除该节点,请先删除其子节点"); } projecttypeDaoImpl.deleteEntity(projecttypeDaoImpl.getEntity(id)); }
备注 | 修改日期 | 修改人 | |
格式调整 | 2019-12-01 20:55:08[当前版本] | 系统管理员 | |
格式调整 | 2019-12-01 19:00:18 | 系统管理员 | |
格式调整 | 2019-12-01 13:27:07 | 系统管理员 | |
格式调整 | 2019-12-01 13:26:10 | 系统管理员 | |
附件类型 | PNG |
|
|