easyUI 树的创建

表字段 

前端dialog

<div id="scServiceChargeType-edit-dialog" class="easyui-dialog" data-options="closed:true,iconCls:'icon-save'"
     style="width:400px; padding:10px;">
    <form id="scServiceChargeType-edit-form" method="post">
        <input name="id" type="hidden"/>
        <table style="width: 100%">
            <tr>
                <td width="80px" align="right">服务编号:</td>
                <td><input class="easyui-validatebox" name="serviceCode" style="width: 80%"/></td>
            </tr>
            <tr>
                <td align="right">服务项目:</td>
                <td><input class="easyui-validatebox" name="serviceName" style="width: 80%"/></td>
            </tr>
            <tr>
                <td align="right">父服务编号:</td>
                <td><input class="easyui-validatebox" readonly="readonly" id="parentCode-add" name="parentCode"
                           style="width: 80%"/></td>
            </tr>

        </table>
    </form>
</div>

 

 

前端方法调用

 /**
     * Name 载入菜单树
     */
    $('#scServiceChargeType-category-tree').tree({
        url: '<%=path%>/scServiceChargeType/scServiceChargeTypeTreeManage',
        method: 'GET',
        onClick: function (node) {
//             alert(node.text);
            $('#scServiceChargeType-datagrid').datagrid("load", {
                    parentCode: node.id
                }
            );
        }
    });

controller 层

/**
     * 根据用service_code获取机构树形结构
     */
    @RequestMapping(value = "/scServiceChargeTypeTreeManage", method = RequestMethod.GET)
    public @ResponseBody
    Object scServiceChargeTypeTreeManage(
            Map<String, Object> model,
            HttpServletRequest request,
            HttpServletResponse response
    ) {
        List<BaseTreeVo> list = serviceScServiceChargeType.getTreeManage("root");
        return list;
    }

 

service实现类

 

/**
     * 根据父级code查询树形结构
     */
    @Override
    public List<BaseTreeVo> getTreeManage(String parentCode) {
        List<ScServiceChargeType> scServiceChargeTypes = selectScServiceChargeTypeByCode(parentCode);
        List<BaseTreeVo> list = new ArrayList<BaseTreeVo>();
        for (ScServiceChargeType scServiceChargeType : scServiceChargeTypes) {
            BaseTreeVo menuVoTemp = new BaseTreeVo();
            menuVoTemp.setId(scServiceChargeType.getServiceCode());
            menuVoTemp.setText(scServiceChargeType.getServiceName() + "-" + scServiceChargeType.getServiceCode());
            BaseTreeAttributesVo attributes = new BaseTreeAttributesVo();
            attributes.setUrl("");
            attributes.setIframe("closed");
            menuVoTemp.setAttributes(attributes);
            List<BaseTreeVo> listSon = getTreeManage(scServiceChargeType.getServiceCode());
            if (listSon.size() > 0) {
                if (scServiceChargeType.getServiceCode().equals("1001")) {
                    menuVoTemp.setState("open");
                } else {
                    menuVoTemp.setState("closed");
                }

            } else {
                menuVoTemp.setState("");
            }
            menuVoTemp.setChildren(listSon);
            list.add(menuVoTemp);
        }
        return list;
    }
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值