关于多项勾选 复选框
<div class="col-xs-6">
<div class="form-group">
<label class="control-label col-sm-4" title="">
<span class="required hide">*</span> ${text('用户管理区域')}:<i class="fa icon-question hide"></i></label>
<div class="col-sm-8">
<#form:treeselect id="employeeAreaList" title="${text('管理区域选择')}"
value="${@ListUtils.extractToString(areaList!, 'areaCode', ',')}"
labelValue="${@ListUtils.extractToString(areaList!, 'areaName', ',')}"
url="${ctx}/sys/area/treeData" checkbox="true"
class="" allowClear="true"/>
<#form:hidden name="employeeAreaListJson"/>
</div>
</div>
</div>
Controller:
// 查询用户所关联的权限管理地址信息
if (StringUtils.isNotBlank(employee.getEmpCode())){
Area area = new Area();
area.setAreaCode(employee.getEmpCode());
List<Area> areaList = areaService.findList(area);
model.addAttribute("areaList", areaList);
}
Entity:
private List<UserArea> employeeAreaList=ListUtils.newArrayList(); //用户包含的权限地区信息
public List<UserArea> getEmployeeAreaList() {
return employeeAreaList;
}
public void setEmployeeAreaListJson(String jsonString) {
//获取用户对应的权限地址集合
List<String> list = JsonMapper.fromJson(jsonString, List.class);
if (list != null){
//遍历该集合
for (String val : list){
if (StringUtils.isNotBlank(val)){
UserArea e = new UserArea();
e.setUserCode(this.getUserCode());
e.setAreaCode(val);
this.employeeAreaList.add(e);
}
}
}
}