表字段
前端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;
}