前端点击编辑按钮,后端查询id对应的回显数据,返回页面
Controller层
@RequestMapping(path="/updateUI",method ={ RequestMethod.GET, RequestMethod.POST})
public String updateUI(Model model, String deptId){
String companyId =getLoginCompanyId();
l.info("toUpdate deptId="+deptId);
//查询部门
Dept dept = iDeptService.findById(deptId);
l.info("toUpdate dept="+dept);
List<Dept> list = iDeptService.findAllParent(companyId);
model.addAttribute("dept",dept);
model.addAttribute("list",list);
return "system/dept/dept-update";
}
Service层
@Override
public List<Dept> findAllParent(String loginCompanyId) {
List<Dept> all = iDeptDao.findAll(loginCompanyId);
return all;
}
Dao层
<select id="findAll" resultMap="findOneMap" parameterType="string">
select * from pe_dept where company_id =#{companyId}
</select>
下拉菜单回显
<select class="form-control" name="parentId">
<option value="">请选择</option>
<c:forEach items="${list}" var="item">
<c:if test="${dept.deptId != item.deptId}">
<option ${dept.parent.deptId == item.deptId ?'selected':''} value="${item.deptId}">${item.deptName}</option>
</c:if>
</c:forEach>
</select>
单选框的回显
<div class="form-group form-inline">
<div class="radio"><label><input type="radio" ${dept.state==0?'checked':''} name="state" value="0">停用</label></div>
<div class="radio"><label><input type="radio" ${dept.state==1?'checked':''} name="state" value="1">启用</label></div>
</div>
共有条评论 网友评论