编辑页
parent
701d7fbb62
commit
c998088bec
|
@ -32,6 +32,9 @@ public class DepartmentController extends BaseController{
|
|||
@Autowired
|
||||
private DeptRepository deptRepository;
|
||||
|
||||
@Autowired
|
||||
private AdminRepository adminRepository;
|
||||
|
||||
/**
|
||||
* 列表查询
|
||||
* @param keywords
|
||||
|
@ -57,6 +60,8 @@ public class DepartmentController extends BaseController{
|
|||
}
|
||||
}
|
||||
model.put("pager", page);
|
||||
List<Dept> deptList = deptRepository.findEnableParent();
|
||||
model.put("parentList", deptList);
|
||||
return "/admin/department_list";
|
||||
}
|
||||
|
||||
|
@ -70,6 +75,10 @@ public class DepartmentController extends BaseController{
|
|||
Dept department = new Dept();
|
||||
model.put("deptId",-1);
|
||||
model.put("department",department);
|
||||
List<Admin> adminList = adminRepository.getAllEnableWoAdmin();
|
||||
model.put("userList", adminList);
|
||||
List<Dept> deptList = deptRepository.findEnableParent();
|
||||
model.put("parentList", deptList);
|
||||
return "/admin/department_input";
|
||||
}
|
||||
|
||||
|
@ -83,6 +92,10 @@ public class DepartmentController extends BaseController{
|
|||
Dept dept = deptRepository.findOne(id);
|
||||
model.put("deptId", id);
|
||||
model.put("department", dept);
|
||||
List<Admin> adminList = adminRepository.getAllEnableWoAdmin();
|
||||
model.put("userList", adminList);
|
||||
List<Dept> deptList = deptRepository.findEnableParent();
|
||||
model.put("parentList", deptList);
|
||||
return "/admin/department_input";
|
||||
}
|
||||
|
||||
|
@ -142,8 +155,8 @@ public class DepartmentController extends BaseController{
|
|||
public void export(@RequestParam(value = "keywords",required = false) String keywords, HttpServletResponse httpServletResponse) throws IOException {
|
||||
Map<String, String> searchInfo = getSearchInfo(keywords);
|
||||
downloadHeader(httpServletResponse , Utils.generateExcelName("部门表"), "application/octet-stream");
|
||||
String[] headers = {"部门名称","创建人","创建时间", "状态"};
|
||||
String[] exportColumns = {"name","createdBy","createdTime", "status"};
|
||||
String[] headers = {"部门名称", "部门领导", "所属上级", "创建人","创建时间", "状态"};
|
||||
String[] exportColumns = {"name", "realName", "parentName", "createdBy","createdTime", "status"};
|
||||
ExportUtils.exportToExcel(headers, exportColumns, 1, 10000,
|
||||
httpServletResponse.getOutputStream(), (pN, pS) -> deptService.list(searchInfo, pN, pS).getList());
|
||||
}
|
||||
|
|
|
@ -46,6 +46,9 @@ public interface AdminRepository extends JpaRepository<Admin, Integer> {
|
|||
@Query("from Admin where isDeleted=0 AND enabled=1")
|
||||
List<Admin> getAllEnable();
|
||||
|
||||
@Query("from Admin where isDeleted=0 AND enabled=1 AND id>1")
|
||||
List<Admin> getAllEnableWoAdmin();
|
||||
|
||||
@Query("from Admin where isDeleted=0 AND enabled=1 AND roleId=?1")
|
||||
List<Admin> findByRoleId(int roleId);
|
||||
|
||||
|
|
|
@ -24,12 +24,12 @@ public class Dept {
|
|||
private String name;
|
||||
|
||||
@Column(name = "manager_id")
|
||||
private Integer managerId;
|
||||
private Integer managerId = 0;
|
||||
|
||||
private Integer level;
|
||||
|
||||
@Column(name = "parent_id")
|
||||
private Integer parentId;
|
||||
private Integer parentId = 0;
|
||||
|
||||
private int enabled;
|
||||
|
||||
|
|
|
@ -11,4 +11,7 @@ public interface DeptRepository extends JpaRepository<Dept,Integer> {
|
|||
|
||||
@Query(value = "select * from dept where enabled = 1", nativeQuery = true)
|
||||
List<Dept> findEnable();
|
||||
|
||||
@Query(value = "select * from dept where enabled = 1 and level <= 2", nativeQuery = true)
|
||||
List<Dept> findEnableParent();
|
||||
}
|
||||
|
|
|
@ -43,6 +43,8 @@ public class DeptService {
|
|||
searchInfo.get("name") + "%");
|
||||
queryHelper.addCondition(searchInfo.containsKey("enabled") && !"-1".equals(searchInfo.get("enabled")),
|
||||
"d.enabled=" + searchInfo.get("enabled"));
|
||||
queryHelper.addCondition(searchInfo.containsKey("parentId") && !"-1".equals(searchInfo.get("parentId")),
|
||||
"d.parent_id=" + searchInfo.get("parentId"));
|
||||
queryHelper.addCondition(searchInfo.containsKey("startTime"), "d.created_time >= ?", searchInfo.get("startTime") + " 00:00:00");
|
||||
queryHelper.addCondition(searchInfo.containsKey("endTime"), "d.created_time <= ?", searchInfo.get("endTime") + " 23:59:59");
|
||||
queryHelper.addOrderProperty("d.id", false);
|
||||
|
@ -59,11 +61,27 @@ public class DeptService {
|
|||
if(null == obj){
|
||||
obj = new Dept();
|
||||
obj.setName(dept.getName());
|
||||
obj.setManagerId(dept.getManagerId());
|
||||
obj.setParentId(dept.getParentId());
|
||||
if (obj.getParentId() == 0) {
|
||||
obj.setLevel(0);
|
||||
} else {
|
||||
Dept one = deptRepository.findOne(obj.getParentId());
|
||||
obj.setLevel(one.getLevel() + 1);
|
||||
}
|
||||
obj.setEnabled(dept.getEnabled());
|
||||
obj.setCreatedBy(InterfaceUtil.getAdmin().getRealName());
|
||||
obj.setCreatedTime(new Date());
|
||||
}else {
|
||||
obj.setName(dept.getName());
|
||||
obj.setManagerId(dept.getManagerId());
|
||||
obj.setParentId(dept.getParentId());
|
||||
if (obj.getParentId() == 0) {
|
||||
obj.setLevel(0);
|
||||
} else {
|
||||
Dept one = deptRepository.findOne(obj.getParentId());
|
||||
obj.setLevel(one.getLevel() + 1);
|
||||
}
|
||||
obj.setEnabled(dept.getEnabled());
|
||||
}
|
||||
deptRepository.saveAndFlush(obj);
|
||||
|
|
|
@ -33,6 +33,46 @@
|
|||
<div class="am-u-sm-2 am-u-md-4 input-msg"></div>
|
||||
</div>
|
||||
|
||||
<div class="am-g am-form-group am-margin-top">
|
||||
<div class="am-u-sm-4 am-u-md-2 am-text-right">
|
||||
<span style="color: red;">*</span>
|
||||
所属上级
|
||||
</div>
|
||||
<div class="am-u-sm-8 am-u-md-10">
|
||||
<select id="parentId" name="parentId"
|
||||
data-am-selected="{btnSize: 'sm',maxHeight: 200,searchBox: 1}" required>
|
||||
<option value="0">无</option>
|
||||
<#if parentList??>
|
||||
<#list parentList as parent>
|
||||
<option value="${parent.id!}" <#if department.parentId == parent.id >
|
||||
selected </#if>>${parent.name}</option>
|
||||
</#list>
|
||||
</#if>
|
||||
</select>
|
||||
</div>
|
||||
<div class="am-u-sm-2 am-u-md-4 input-msg"></div>
|
||||
</div>
|
||||
|
||||
<div class="am-g am-form-group am-margin-top">
|
||||
<div class="am-u-sm-4 am-u-md-2 am-text-right">
|
||||
<span style="color: red;">*</span>
|
||||
部门领导
|
||||
</div>
|
||||
<div class="am-u-sm-8 am-u-md-10">
|
||||
<select id="managerId" name="managerId"
|
||||
data-am-selected="{btnSize: 'sm',maxHeight: 200,searchBox: 1}" required>
|
||||
<option value="0">无</option>
|
||||
<#if userList??>
|
||||
<#list userList as user>
|
||||
<option value="${user.id!}" <#if department.managerId == user.id >
|
||||
selected </#if>>${user.realName}</option>
|
||||
</#list>
|
||||
</#if>
|
||||
</select>
|
||||
</div>
|
||||
<div class="am-u-sm-2 am-u-md-4 input-msg"></div>
|
||||
</div>
|
||||
|
||||
<div class="am-g am-form-group am-margin-top">
|
||||
<div class="am-u-sm-4 am-u-md-2 am-text-right">启用/禁用</div>
|
||||
|
||||
|
|
|
@ -33,10 +33,25 @@
|
|||
</select>
|
||||
</div>
|
||||
</td>
|
||||
<th class="am-text-middle">所属上级</th>
|
||||
<td>
|
||||
<div class="am-u-sm-10">
|
||||
<select data-am-selected="{btnWidth: '40%', btnSize: 'sm'" id="parentId">
|
||||
<option value="-1">全部</option>
|
||||
<option value="0" <#if parentId! == "0">selected</#if>>无</option>
|
||||
<#if parentList??>
|
||||
<#list parentList as parent>
|
||||
<option value="${parent.id!}" <#if parentId! == parent.id + "" >
|
||||
selected </#if>>${parent.name}</option>
|
||||
</#list>
|
||||
</#if>
|
||||
</select>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="am-text-middle">创建时间</th>
|
||||
<td>
|
||||
<td colspan="3">
|
||||
<div class="am-u-sm-10">
|
||||
<div class="am-form am-form-inline">
|
||||
<div class="am-form-group am-form-icon">
|
||||
|
@ -169,6 +184,8 @@
|
|||
keywordsObj.name = $("#name").val();
|
||||
if ($("#type").val())
|
||||
keywordsObj.type = $("#type").val();
|
||||
if ($("#parentId").val())
|
||||
keywordsObj.parentId = $("#parentId").val();
|
||||
if ($("#enabled").val())
|
||||
keywordsObj.enabled = $("#enabled").val();
|
||||
if ($("#startTime").val())
|
||||
|
|
Loading…
Reference in New Issue