增加角色多选树,职位多选树,增加接口
This commit is contained in:
parent
538f85eeb4
commit
7b8e31d981
@ -24,10 +24,10 @@ public interface IPositionBaseService {
|
||||
/**
|
||||
* 全部职位JSON列表
|
||||
*
|
||||
* @param groupParentId
|
||||
* @param positionParentId
|
||||
* @return
|
||||
*/
|
||||
List<PositionDTO> listAllByParentId(String groupParentId);
|
||||
List<PositionDTO> listAllByParentId(String positionParentId);
|
||||
|
||||
/**
|
||||
* 职位列表,递归获取全部内容
|
||||
@ -80,10 +80,10 @@ public interface IPositionBaseService {
|
||||
/**
|
||||
* 职位列表
|
||||
*
|
||||
* @param groupIds 用户ID列表
|
||||
* @param positionIds 用户ID列表
|
||||
* @return
|
||||
*/
|
||||
List<PositionDTO> list(List<String> groupIds);
|
||||
List<PositionDTO> listByPositionIds(List<String> positionIds);
|
||||
|
||||
/**
|
||||
* 职位列表
|
||||
|
@ -45,6 +45,14 @@ public interface IRoleBaseService {
|
||||
*/
|
||||
List<RoleDTO> list(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 角色列表
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
List<RoleDTO> listByRoleIds(List<String> roleIds);
|
||||
|
||||
/**
|
||||
* 角色列表
|
||||
*
|
||||
|
@ -42,14 +42,14 @@ public interface IPositionRemoteService {
|
||||
@RemoteGetMethod("/list")
|
||||
List<PositionDTO> list(@RemoteServerParams String userCenter, @RemoteQueryParams("access_token") String accessToken, @RemoteQueryParamsMap Map<String, Object> params);
|
||||
|
||||
@RemotePostMethod("/list/ids")
|
||||
List<PositionDTO> listByIds(@RemoteServerParams String userCenter, @RemoteQueryParams("access_token") String accessToken, @RemoteJsonBodyParams IdsVO idsVO);
|
||||
@RemotePostMethod("/list/position-ids")
|
||||
List<PositionDTO> listByPositionIds(@RemoteServerParams String userCenter, @RemoteQueryParams("access_token") String accessToken, @RemoteJsonBodyParams IdsVO idsVO);
|
||||
|
||||
@RemoteGetMethod("/list-po")
|
||||
List<PositionPO> listPO(@RemoteServerParams String userCenter, @RemoteQueryParams("access_token") String accessToken, @RemoteQueryParamsMap Map<String, Object> params);
|
||||
|
||||
@RemotePostMethod("/list-po/ids")
|
||||
List<PositionPO> listPOByIds(@RemoteServerParams String userCenter, @RemoteQueryParams("access_token") String accessToken, @RemoteJsonBodyParams IdsVO idsVO);
|
||||
List<PositionPO> listPOByPositionIds(@RemoteServerParams String userCenter, @RemoteQueryParams("access_token") String accessToken, @RemoteJsonBodyParams IdsVO idsVO);
|
||||
|
||||
@RemoteGetMethod("/count")
|
||||
SuccessResultData<Integer> count(@RemoteServerParams String userCenter, @RemoteQueryParams("access_token") String accessToken, @RemoteQueryParamsMap Map<String, Object> params);
|
||||
|
@ -50,4 +50,7 @@ public interface IRoleRemoteService {
|
||||
|
||||
@RemoteGetMethod("/count")
|
||||
SuccessResultData<Integer> count(@RemoteServerParams String userCenter, @RemoteQueryParams("access_token") String accessToken, @RemoteQueryParamsMap Map<String, Object> params);
|
||||
|
||||
@RemotePostMethod("/list/role-ids")
|
||||
List<RoleDTO> listByRoleIds(@RemoteServerParams String userCenter, @RemoteQueryParams("access_token") String accessToken, @RemoteJsonBodyParams IdsVO idsVO);
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ import ink.wgink.properties.ApiPathProperties;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ -34,9 +35,9 @@ public class PositionServiceImpl extends DefaultBaseService implements IPosition
|
||||
private ApiPathProperties apiPathProperties;
|
||||
|
||||
@Override
|
||||
public List<PositionDTO> listAllByParentId(String groupParentId) {
|
||||
public List<PositionDTO> listAllByParentId(String positionParentId) {
|
||||
Map<String, Object> params = getHashMap(2);
|
||||
params.put("parentId", groupParentId);
|
||||
params.put("parentId", positionParentId);
|
||||
return listAll(params);
|
||||
}
|
||||
|
||||
@ -71,10 +72,13 @@ public class PositionServiceImpl extends DefaultBaseService implements IPosition
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionDTO> list(List<String> positionIds) {
|
||||
public List<PositionDTO> listByPositionIds(List<String> positionIds) {
|
||||
if (positionIds == null && positionIds.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
IdsVO idsVO = new IdsVO();
|
||||
idsVO.setIds(positionIds);
|
||||
return positionRemoteService.listByIds(apiPathProperties.getUserCenter(), OAuth2ClientTokenManager.getInstance().getToken().getAccessToken(), idsVO);
|
||||
return positionRemoteService.listByPositionIds(apiPathProperties.getUserCenter(), OAuth2ClientTokenManager.getInstance().getToken().getAccessToken(), idsVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -86,7 +90,7 @@ public class PositionServiceImpl extends DefaultBaseService implements IPosition
|
||||
public List<PositionPO> listPO(List<String> positionIds) {
|
||||
IdsVO idsVO = new IdsVO();
|
||||
idsVO.setIds(positionIds);
|
||||
return positionRemoteService.listPOByIds(apiPathProperties.getUserCenter(), OAuth2ClientTokenManager.getInstance().getToken().getAccessToken(), idsVO);
|
||||
return positionRemoteService.listPOByPositionIds(apiPathProperties.getUserCenter(), OAuth2ClientTokenManager.getInstance().getToken().getAccessToken(), idsVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -15,6 +15,7 @@ import ink.wgink.properties.ApiPathProperties;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ -48,6 +49,16 @@ public class RoleServiceImpl extends DefaultBaseService implements IRoleService
|
||||
return roleRemoteService.list(apiPathProperties.getUserCenter(), OAuth2ClientTokenManager.getInstance().getToken().getAccessToken(), params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RoleDTO> listByRoleIds(List<String> roleIds) {
|
||||
if(roleIds == null || roleIds.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
IdsVO idsVO = new IdsVO();
|
||||
idsVO.setIds(roleIds);
|
||||
return roleRemoteService.listByRoleIds(apiPathProperties.getUserCenter(), OAuth2ClientTokenManager.getInstance().getToken().getAccessToken(), idsVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RolePO> listPO(Map<String, Object> params) {
|
||||
return roleRemoteService.listPO(apiPathProperties.getUserCenter(), OAuth2ClientTokenManager.getInstance().getToken().getAccessToken(), params);
|
||||
|
@ -221,12 +221,12 @@ public class DepartmentController extends DefaultBaseController {
|
||||
}
|
||||
|
||||
@ApiOperation(value = "组织部门列表", notes = "组织部门列表接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "departmentId", value = "部门ID", paramType = "path")
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@PostMapping("list/ids")
|
||||
public List<DepartmentDTO> list(@RequestBody IdsVO idsVO) {
|
||||
if (idsVO.getIds().isEmpty()) {
|
||||
throw new ParamsException("id列表不能为空");
|
||||
}
|
||||
return departmentService.listByIds(idsVO.getIds());
|
||||
}
|
||||
|
||||
|
@ -52,8 +52,8 @@
|
||||
var $win = $(window);
|
||||
var resizeTimeout = null;
|
||||
var zTree;
|
||||
var checkedIds = top.dialog.dialogData.checkedIds ? top.dialog.dialogData.checkedIds : [];
|
||||
var checkedNodes = [];
|
||||
var checkedDepartmentIds = top.dialog.dialogData.checkedDepartmentIds ? [].concat(top.dialog.dialogData.checkedDepartmentIds) : [];
|
||||
var checkedDepartmentNodes = [];
|
||||
var checkedDepartmentMap = new Map();
|
||||
|
||||
function closeBox() {
|
||||
@ -86,23 +86,23 @@
|
||||
* 初始化勾选节点
|
||||
*/
|
||||
function initCheckNodes(callback) {
|
||||
if(!checkedIds || checkedIds.length == 0) {
|
||||
if(!checkedDepartmentIds || checkedDepartmentIds.length == 0) {
|
||||
callback ? callback() : '';
|
||||
return;
|
||||
}
|
||||
top.restAjax.post(top.restAjax.path('api/department/list/ids', []), {
|
||||
ids: [].concat(checkedIds)
|
||||
ids: checkedDepartmentIds
|
||||
}, null, function(code, data) {
|
||||
$('#checkedNodeBox').empty();
|
||||
var checkedNodes = '';
|
||||
var checkedDepartmentNodes = '';
|
||||
for(var i = 0, item; item = data[i++];) {
|
||||
checkedNodes += getCheckedNode(item.departmentId, item.departmentName);
|
||||
checkedDepartmentNodes += getCheckedNode(item.departmentId, item.departmentName);
|
||||
checkedDepartmentMap.set(item.departmentId, {
|
||||
id: item.departmentId,
|
||||
name: item.departmentName
|
||||
});
|
||||
}
|
||||
$('#checkedNodeBox').append(checkedNodes);
|
||||
$('#checkedNodeBox').append(checkedDepartmentNodes);
|
||||
callback ? callback() : '';
|
||||
}, function(code, data) {
|
||||
top.dialog.msg(data.msg);
|
||||
@ -113,11 +113,11 @@
|
||||
function refreshCheckedNodes() {
|
||||
var nodes = zTree.getCheckedNodes(true);
|
||||
$('#checkedNodeBox').empty();
|
||||
var checkedNodes = '';
|
||||
for(var i = 0, item; item = nodes[i++];) {
|
||||
checkedNodes += getCheckedNode(item.id, item.name);
|
||||
var checkedDepartmentNodes = '';
|
||||
for(var [k, v] of checkedDepartmentMap) {
|
||||
checkedDepartmentNodes += getCheckedNode(v.id, v.name);
|
||||
}
|
||||
$('#checkedNodeBox').append(checkedNodes);
|
||||
$('#checkedNodeBox').append(checkedDepartmentNodes);
|
||||
}
|
||||
// 初始化树
|
||||
function initThree() {
|
||||
@ -169,7 +169,7 @@
|
||||
}
|
||||
|
||||
function initCheckedDepartmentMap() {
|
||||
var checkedDepartments = checkedNodes;
|
||||
var checkedDepartments = checkedDepartmentNodes;
|
||||
if(!checkedDepartments) {
|
||||
return;
|
||||
}
|
||||
@ -201,15 +201,18 @@
|
||||
var departmentId = this.dataset.departmentId;
|
||||
checkedDepartmentMap.delete(departmentId);
|
||||
var node = zTree.getNodeByParam('id', departmentId);
|
||||
zTree.checkNode(node, false, false);
|
||||
// 未加载不删除
|
||||
if(node) {
|
||||
zTree.checkNode(node, false, false);
|
||||
}
|
||||
refreshCheckedNodes();
|
||||
})
|
||||
|
||||
$('.submit').on('click', function() {
|
||||
checkedDepartmentMap.forEach(function(item) {
|
||||
checkedNodes.push(item);
|
||||
checkedDepartmentNodes.push(item);
|
||||
});
|
||||
top.dialog.dialogData.checkedNodes = checkedNodes;
|
||||
top.dialog.dialogData.checkedDepartmentNodes = checkedDepartmentNodes;
|
||||
closeBox();
|
||||
});
|
||||
});
|
||||
|
@ -2,6 +2,7 @@ package ink.wgink.service.position.controller.api;
|
||||
|
||||
import ink.wgink.annotation.CheckRequestBodyAnnotation;
|
||||
import ink.wgink.common.base.DefaultBaseController;
|
||||
import ink.wgink.exceptions.ParamsException;
|
||||
import ink.wgink.interfaces.consts.ISystemConstant;
|
||||
import ink.wgink.pojo.ListPage;
|
||||
import ink.wgink.pojo.dtos.ZTreeDTO;
|
||||
@ -58,35 +59,35 @@ public class PositionController extends DefaultBaseController {
|
||||
|
||||
@ApiOperation(value = "职位修改", notes = "职位修改接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "groupId", value = "职位ID", paramType = "path")
|
||||
@ApiImplicitParam(name = "positionId", value = "职位ID", paramType = "path")
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@PutMapping("update/{groupId}")
|
||||
@PutMapping("update/{positionId}")
|
||||
@CheckRequestBodyAnnotation
|
||||
public SuccessResult update(@PathVariable("groupId") String groupId, @RequestBody PositionVO positionVO) {
|
||||
positionService.update(groupId, positionVO);
|
||||
public SuccessResult update(@PathVariable("positionId") String positionId, @RequestBody PositionVO positionVO) {
|
||||
positionService.update(positionId, positionVO);
|
||||
return new SuccessResult();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "职位列表", notes = "职位列表接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "groupParentId", value = "职位上级ID", paramType = "path")
|
||||
@ApiImplicitParam(name = "positionParentId", value = "职位上级ID", paramType = "path")
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@GetMapping("listallbyparentid/{groupParentId}")
|
||||
public List<PositionDTO> listAllByParentId(@PathVariable("groupParentId") String groupParentId) {
|
||||
return positionService.listAllByParentId(groupParentId);
|
||||
@GetMapping("listallbyparentid/{positionParentId}")
|
||||
public List<PositionDTO> listAllByParentId(@PathVariable("positionParentId") String positionParentId) {
|
||||
return positionService.listAllByParentId(positionParentId);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "职位详情", notes = "职位详情接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "groupId", value = "职位ID", paramType = "path")
|
||||
@ApiImplicitParam(name = "positionId", value = "职位ID", paramType = "path")
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@GetMapping("get/{groupId}")
|
||||
public PositionDTO get(@PathVariable("groupId") String groupId) {
|
||||
@GetMapping("get/{positionId}")
|
||||
public PositionDTO get(@PathVariable("positionId") String positionId) {
|
||||
Map<String, Object> params = getParams();
|
||||
params.put("groupId", groupId);
|
||||
params.put("positionId", positionId);
|
||||
return positionService.get(params);
|
||||
}
|
||||
|
||||
@ -98,11 +99,11 @@ public class PositionController extends DefaultBaseController {
|
||||
@GetMapping("listztree")
|
||||
public List<ZTreeDTO> listZTree() {
|
||||
Map<String, Object> params = requestParams();
|
||||
String groupParentId = "0";
|
||||
String positionParentId = "0";
|
||||
if (!StringUtils.isBlank(params.get(ISystemConstant.PARAMS_ID) == null ? null : params.get(ISystemConstant.PARAMS_ID).toString())) {
|
||||
groupParentId = params.get(ISystemConstant.PARAMS_ID).toString();
|
||||
positionParentId = params.get(ISystemConstant.PARAMS_ID).toString();
|
||||
}
|
||||
params.put("groupParentId", groupParentId);
|
||||
params.put("positionParentId", positionParentId);
|
||||
return positionService.listZTree(params);
|
||||
}
|
||||
|
||||
@ -119,20 +120,23 @@ public class PositionController extends DefaultBaseController {
|
||||
@GetMapping("listpage")
|
||||
public SuccessResultList<List<PositionDTO>> listPage(ListPage page) {
|
||||
Map<String, Object> params = requestParams();
|
||||
String groupParentId = "0";
|
||||
String positionParentId = "0";
|
||||
if (!StringUtils.isBlank(params.get("parentId") == null ? null : params.get("parentId").toString())) {
|
||||
groupParentId = params.get("parentId").toString();
|
||||
positionParentId = params.get("parentId").toString();
|
||||
}
|
||||
params.put("groupParentId", groupParentId);
|
||||
params.put("positionParentId", positionParentId);
|
||||
page.setParams(params);
|
||||
return positionService.listPage(page);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "通过ID列表获取职位列表", notes = "通过ID列表获取用户职位接口")
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@PostMapping("listbyids")
|
||||
@PostMapping("list/position-ids")
|
||||
public List<PositionDTO> listByIds(@RequestBody IdsVO idsVO) {
|
||||
return positionService.list(idsVO.getIds());
|
||||
if (idsVO.getIds().isEmpty()) {
|
||||
throw new ParamsException("id列表不能为空");
|
||||
}
|
||||
return positionService.listByPositionIds(idsVO.getIds());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -123,9 +123,9 @@ public class PositionResourceController extends DefaultBaseController {
|
||||
|
||||
@ApiOperation(value = "通过ID列表获取职位列表", notes = "通过ID列表获取用户职位接口")
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@PostMapping("list/ids")
|
||||
@PostMapping("list/position-ids")
|
||||
public List<PositionDTO> listByIds(@RequestBody IdsVO idsVO) {
|
||||
return positionService.list(idsVO.getIds());
|
||||
return positionService.listByPositionIds(idsVO.getIds());
|
||||
}
|
||||
|
||||
@ApiOperation(value = "取职位列表", notes = "用户职位接口")
|
||||
|
@ -41,4 +41,9 @@ public class PositionRouteController {
|
||||
public ModelAndView listTree() {
|
||||
return new ModelAndView("position/list-tree");
|
||||
}
|
||||
|
||||
@GetMapping("list-tree-check")
|
||||
public ModelAndView listTreeCheck() {
|
||||
return new ModelAndView("position/list-tree-check");
|
||||
}
|
||||
}
|
||||
|
@ -34,9 +34,9 @@ public interface IPositionService extends IPositionBaseService, IPositionCheckSe
|
||||
/**
|
||||
* 修改职位
|
||||
*
|
||||
* @param groupId
|
||||
* @param positionId
|
||||
* @param positionVO
|
||||
* @return
|
||||
*/
|
||||
void update(String groupId, PositionVO positionVO);
|
||||
void update(String positionId, PositionVO positionVO);
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ public class PositionServiceImpl extends DefaultBaseService implements IPosition
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionDTO> list(List<String> positionIds) {
|
||||
public List<PositionDTO> listByPositionIds(List<String> positionIds) {
|
||||
Map<String, Object> params = getHashMap(2);
|
||||
params.put("positionIds", positionIds);
|
||||
return list(params);
|
||||
|
@ -0,0 +1,220 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<base th:href="${#request.getContextPath() + '/'}">
|
||||
<meta charset="utf-8">
|
||||
<meta name="renderer" content="webkit">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
|
||||
<link rel="stylesheet" href="assets/fonts/font-awesome/css/font-awesome.css"/>
|
||||
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
|
||||
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
|
||||
<link rel="stylesheet" href="assets/js/vendor/zTree3/css/metroStyle/metroStyle.css"/>
|
||||
<link rel="stylesheet" href="assets/layuiadmin/style/common.css" media="all">
|
||||
<style>
|
||||
.card-body-left {border-right: 1px dotted silver;}
|
||||
.card-body-right {padding: 5px;}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="layui-anim layui-anim-fadein">
|
||||
<div class="layui-row" style="padding-right: 0px;">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-body left-tree-wrap">
|
||||
<div id="treeBox" class="layui-col-xs6 card-body-left">
|
||||
<ul id="tree" class="ztree"></ul>
|
||||
</div>
|
||||
<div id="checkedNodeBox" class="layui-col-xs6 card-body-right layui-btn-container"></div>
|
||||
</div>
|
||||
<div class="layui-form-item layui-layout-admin">
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-footer" style="padding: 0px;">
|
||||
<div class="layui-btn-group">
|
||||
<button type="button" class="layui-btn layui-btn-sm submit">确定</button>
|
||||
<button type="button" class="layui-btn layui-btn-sm layui-btn-primary close">返回</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="assets/layuiadmin/layui/layui.js"></script>
|
||||
<script>
|
||||
var common;
|
||||
layui.config({
|
||||
base: 'assets/layuiadmin/'
|
||||
}).extend({
|
||||
index: 'lib/index'
|
||||
}).use(['index', 'ztree', 'common'], function() {
|
||||
common = layui.common;
|
||||
var $ = layui.$;
|
||||
var $win = $(window);
|
||||
var resizeTimeout = null;
|
||||
var zTree;
|
||||
var checkedPositionIds = top.dialog.dialogData.checkedPositionIds ? [].concat(top.dialog.dialogData.checkedPositionIds) : [];
|
||||
var checkedPositionNodes = [];
|
||||
var checkedPositionMap = new Map();
|
||||
|
||||
function closeBox() {
|
||||
parent.layer.close(parent.layer.getFrameIndex(window.name));
|
||||
}
|
||||
|
||||
// 初始化大小
|
||||
function initSize() {
|
||||
$('#treeBox').css({
|
||||
height: $win.height() - 52,
|
||||
overflow: 'auto'
|
||||
});
|
||||
$('#checkedNodeBox').css({
|
||||
height: $win.height() - 52,
|
||||
overflow: 'auto'
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 勾选节点
|
||||
* @param id
|
||||
* @param name
|
||||
* @returns {string}
|
||||
*/
|
||||
function getCheckedNode(id, name) {
|
||||
return '<button type="button" class="layui-btn layui-btn-xs">'+ name +' <i class="fa fa-times remove-checked-position" data-position-id="'+ id +'"></i></button>'
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化勾选节点
|
||||
*/
|
||||
function initCheckNodes(callback) {
|
||||
if(!checkedPositionIds || checkedPositionIds.length == 0) {
|
||||
callback ? callback() : '';
|
||||
return;
|
||||
}
|
||||
top.restAjax.post(top.restAjax.path('api/position/list/position-ids', []), {
|
||||
ids: [].concat(checkedPositionIds)
|
||||
}, null, function(code, data) {
|
||||
$('#checkedNodeBox').empty();
|
||||
var checkedPositionNodes = '';
|
||||
for(var i = 0, item; item = data[i++];) {
|
||||
checkedPositionNodes += getCheckedNode(item.positionId, item.positionName);
|
||||
checkedPositionMap.set(item.positionId, {
|
||||
id: item.positionId,
|
||||
name: item.positionName
|
||||
});
|
||||
}
|
||||
$('#checkedNodeBox').append(checkedPositionNodes);
|
||||
callback ? callback() : '';
|
||||
}, function(code, data) {
|
||||
top.dialog.msg(data.msg);
|
||||
});
|
||||
}
|
||||
|
||||
// 刷新选择的节点
|
||||
function refreshCheckedNodes() {
|
||||
$('#checkedNodeBox').empty();
|
||||
var checkedPositionNodes = '';
|
||||
for(var [k, v] of checkedPositionMap) {
|
||||
checkedPositionNodes += getCheckedNode(v.id, v.name);
|
||||
}
|
||||
$('#checkedNodeBox').append(checkedPositionNodes);
|
||||
}
|
||||
// 初始化树
|
||||
function initThree() {
|
||||
var setting = {
|
||||
check: {
|
||||
enable: true,
|
||||
chkboxType : {'Y': '', 'N': ''},
|
||||
},
|
||||
async: {
|
||||
enable: true,
|
||||
autoLoad: true,
|
||||
type: 'get',
|
||||
url: top.restAjax.path('api/position/listztree', []),
|
||||
autoParam: ['id'],
|
||||
otherParam: {},
|
||||
dataFilter: function (treeId, parentNode, childNodes) {
|
||||
if (!childNodes) return null;
|
||||
for (var i = 0, l = childNodes.length; i < l; i++) {
|
||||
childNodes[i].name = childNodes[i].name.replace(/\.n/g, '.');
|
||||
}
|
||||
return childNodes;
|
||||
}
|
||||
},
|
||||
callback: {
|
||||
onAsyncSuccess: function(event, treeId, treeNode) {
|
||||
// 初始化已选则数据
|
||||
checkedPositionMap.forEach(function(item) {
|
||||
var node = zTree.getNodeByParam('id', item.id);
|
||||
if(!node) {
|
||||
return;
|
||||
}
|
||||
zTree.checkNode(node, true, false);
|
||||
})
|
||||
},
|
||||
onCheck: function(event, treeId, treeNode) {
|
||||
if(treeNode.checked) {
|
||||
checkedPositionMap.set(treeNode.id, {
|
||||
id: treeNode.id,
|
||||
name: treeNode.name
|
||||
});
|
||||
} else {
|
||||
checkedPositionMap.delete(treeNode.id);
|
||||
}
|
||||
refreshCheckedNodes();
|
||||
}
|
||||
},
|
||||
};
|
||||
zTree = $.fn.zTree.init($("#tree"), setting);
|
||||
}
|
||||
|
||||
function initCheckedPositionMap() {
|
||||
var checkedPositions = checkedPositionNodes;
|
||||
if(!checkedPositions) {
|
||||
return;
|
||||
}
|
||||
for(var i = 0, item; item = checkedPositions[i++];){
|
||||
checkedPositionMap.set(item.positionId, item);
|
||||
}
|
||||
}
|
||||
|
||||
initSize();
|
||||
initCheckNodes(function() {
|
||||
initCheckedPositionMap();
|
||||
initThree();
|
||||
});
|
||||
|
||||
// 事件 - 页面变化
|
||||
$win.on('resize', function() {
|
||||
clearTimeout(resizeTimeout);
|
||||
resizeTimeout = setTimeout(function() {
|
||||
initSize();
|
||||
}, 500);
|
||||
});
|
||||
|
||||
$('.close').on('click', function() {
|
||||
closeBox();
|
||||
});
|
||||
|
||||
// 删除
|
||||
$(document).on('click', '.remove-checked-position', function() {
|
||||
var positionId = this.dataset.positionId;
|
||||
checkedPositionMap.delete(positionId);
|
||||
var node = zTree.getNodeByParam('id', positionId);
|
||||
// 未加载不删除
|
||||
if(node) {
|
||||
zTree.checkNode(node, false, false);
|
||||
}
|
||||
refreshCheckedNodes();
|
||||
})
|
||||
|
||||
$('.submit').on('click', function() {
|
||||
checkedPositionMap.forEach(function(item) {
|
||||
checkedPositionNodes.push(item);
|
||||
});
|
||||
top.dialog.dialogData.checkedPositionNodes = checkedPositionNodes;
|
||||
closeBox();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -10,6 +10,7 @@ import ink.wgink.pojo.dtos.role.RoleDTO;
|
||||
import ink.wgink.pojo.result.ErrorResult;
|
||||
import ink.wgink.pojo.result.SuccessResult;
|
||||
import ink.wgink.pojo.result.SuccessResultList;
|
||||
import ink.wgink.pojo.vos.IdsVO;
|
||||
import ink.wgink.service.role.pojo.vos.RoleVO;
|
||||
import ink.wgink.service.role.service.IRoleService;
|
||||
import io.swagger.annotations.*;
|
||||
@ -129,4 +130,14 @@ public class RoleController extends DefaultBaseController {
|
||||
return roleService.listPage(page);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "角色列表", notes = "角色列表接口")
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@PostMapping("list/role-ids")
|
||||
public List<RoleDTO> listByRoleIds(@RequestBody IdsVO idsVO) {
|
||||
if (idsVO.getIds().isEmpty()) {
|
||||
throw new ParamsException("id列表不能为空");
|
||||
}
|
||||
return roleService.listByRoleIds(idsVO.getIds());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package ink.wgink.service.role.controller.resources;
|
||||
|
||||
import ink.wgink.common.base.DefaultBaseController;
|
||||
import ink.wgink.exceptions.ParamsException;
|
||||
import ink.wgink.exceptions.SearchException;
|
||||
import ink.wgink.interfaces.consts.ISystemConstant;
|
||||
import ink.wgink.pojo.ListPage;
|
||||
@ -151,4 +152,14 @@ public class RoleResourceController extends DefaultBaseController {
|
||||
return new SuccessResultData<>(count);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "角色列表", notes = "角色列表接口")
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@PostMapping("list/role-ids")
|
||||
public List<RoleDTO> listByRoleIds(@RequestBody IdsVO idsVO) {
|
||||
if (idsVO.getIds().isEmpty()) {
|
||||
throw new ParamsException("id列表不能为空");
|
||||
}
|
||||
return roleService.listByRoleIds(idsVO.getIds());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,8 +2,6 @@ package ink.wgink.service.role.controller.route;
|
||||
|
||||
import ink.wgink.interfaces.consts.ISystemConstant;
|
||||
import ink.wgink.properties.AccessControlProperties;
|
||||
import ink.wgink.properties.BaseProperties;
|
||||
import ink.wgink.properties.ServerProperties;
|
||||
import io.swagger.annotations.Api;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
@ -44,6 +42,11 @@ public class RoleRouteController {
|
||||
return new ModelAndView("role/list-tree");
|
||||
}
|
||||
|
||||
@GetMapping("list-tree-check")
|
||||
public ModelAndView listTreeCheck() {
|
||||
return new ModelAndView("role/list-tree-check");
|
||||
}
|
||||
|
||||
@GetMapping("list")
|
||||
public ModelAndView list() {
|
||||
ModelAndView mv = new ModelAndView("role/list");
|
||||
|
@ -1,16 +1,10 @@
|
||||
package ink.wgink.service.role.service;
|
||||
|
||||
import ink.wgink.exceptions.SearchException;
|
||||
import ink.wgink.interfaces.role.IRoleBaseService;
|
||||
import ink.wgink.interfaces.role.IRoleCheckService;
|
||||
import ink.wgink.pojo.ListPage;
|
||||
import ink.wgink.pojo.dtos.ZTreeDTO;
|
||||
import ink.wgink.pojo.dtos.role.RoleDTO;
|
||||
import ink.wgink.pojo.result.SuccessResultList;
|
||||
import ink.wgink.service.role.pojo.vos.RoleVO;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
@ -103,5 +97,4 @@ public interface IRoleService extends IRoleBaseService, IRoleCheckService {
|
||||
void updateRoleDataRight(String roleId, String roleDataRight);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -108,6 +108,13 @@ public class RoleServiceImpl extends DefaultBaseService implements IRoleService
|
||||
return destRoleDTO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RoleDTO> listByRoleIds(List<String> roleIds) {
|
||||
Map<String, Object> params = getHashMap(2);
|
||||
params.put("roleIds", roleIds);
|
||||
return list(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RolePO> listPO(Map<String, Object> params) {
|
||||
return roleDao.listPO(params);
|
||||
|
@ -137,6 +137,13 @@
|
||||
sys_role
|
||||
WHERE
|
||||
is_delete = 0
|
||||
<if test="roleIds != null and roleIds.size > 0">
|
||||
AND
|
||||
role_id IN
|
||||
<foreach collection="roleIds" index="index" open="(" separator="," close=")">
|
||||
#{roleIds[${index}]}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="roleParentId != null and roleParentId != ''">
|
||||
AND
|
||||
role_parent_id = #{roleParentId}
|
||||
|
@ -0,0 +1,220 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<base th:href="${#request.getContextPath() + '/'}">
|
||||
<meta charset="utf-8">
|
||||
<meta name="renderer" content="webkit">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
|
||||
<link rel="stylesheet" href="assets/fonts/font-awesome/css/font-awesome.css"/>
|
||||
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
|
||||
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
|
||||
<link rel="stylesheet" href="assets/js/vendor/zTree3/css/metroStyle/metroStyle.css"/>
|
||||
<link rel="stylesheet" href="assets/layuiadmin/style/common.css" media="all">
|
||||
<style>
|
||||
.card-body-left {border-right: 1px dotted silver;}
|
||||
.card-body-right {padding: 5px;}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="layui-anim layui-anim-fadein">
|
||||
<div class="layui-row" style="padding-right: 0px;">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-body left-tree-wrap">
|
||||
<div id="treeBox" class="layui-col-xs6 card-body-left">
|
||||
<ul id="tree" class="ztree"></ul>
|
||||
</div>
|
||||
<div id="checkedNodeBox" class="layui-col-xs6 card-body-right layui-btn-container"></div>
|
||||
</div>
|
||||
<div class="layui-form-item layui-layout-admin">
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-footer" style="padding: 0px;">
|
||||
<div class="layui-btn-group">
|
||||
<button type="button" class="layui-btn layui-btn-sm submit">确定</button>
|
||||
<button type="button" class="layui-btn layui-btn-sm layui-btn-primary close">返回</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="assets/layuiadmin/layui/layui.js"></script>
|
||||
<script>
|
||||
var common;
|
||||
layui.config({
|
||||
base: 'assets/layuiadmin/'
|
||||
}).extend({
|
||||
index: 'lib/index'
|
||||
}).use(['index', 'ztree', 'common'], function() {
|
||||
common = layui.common;
|
||||
var $ = layui.$;
|
||||
var $win = $(window);
|
||||
var resizeTimeout = null;
|
||||
var zTree;
|
||||
var checkedRoleIds = top.dialog.dialogData.checkedRoleIds ? [].concat(top.dialog.dialogData.checkedRoleIds) : [];
|
||||
var checkedRoleNodes = [];
|
||||
var checkedRoleMap = new Map();
|
||||
|
||||
function closeBox() {
|
||||
parent.layer.close(parent.layer.getFrameIndex(window.name));
|
||||
}
|
||||
|
||||
// 初始化大小
|
||||
function initSize() {
|
||||
$('#treeBox').css({
|
||||
height: $win.height() - 52,
|
||||
overflow: 'auto'
|
||||
});
|
||||
$('#checkedNodeBox').css({
|
||||
height: $win.height() - 52,
|
||||
overflow: 'auto'
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 勾选节点
|
||||
* @param id
|
||||
* @param name
|
||||
* @returns {string}
|
||||
*/
|
||||
function getCheckedNode(id, name) {
|
||||
return '<button type="button" class="layui-btn layui-btn-xs">'+ name +' <i class="fa fa-times remove-checked-role" data-role-id="'+ id +'"></i></button>'
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化勾选节点
|
||||
*/
|
||||
function initCheckNodes(callback) {
|
||||
if(!checkedRoleIds || checkedRoleIds.length == 0) {
|
||||
callback ? callback() : '';
|
||||
return;
|
||||
}
|
||||
top.restAjax.post(top.restAjax.path('api/role/list/role-ids', []), {
|
||||
ids: [].concat(checkedRoleIds)
|
||||
}, null, function(code, data) {
|
||||
$('#checkedNodeBox').empty();
|
||||
var checkedRoleNodes = '';
|
||||
for(var i = 0, item; item = data[i++];) {
|
||||
checkedRoleNodes += getCheckedNode(item.roleId, item.roleName);
|
||||
checkedRoleMap.set(item.roleId, {
|
||||
id: item.roleId,
|
||||
name: item.roleName
|
||||
});
|
||||
}
|
||||
$('#checkedNodeBox').append(checkedRoleNodes);
|
||||
callback ? callback() : '';
|
||||
}, function(code, data) {
|
||||
top.dialog.msg(data.msg);
|
||||
});
|
||||
}
|
||||
|
||||
// 刷新选择的节点
|
||||
function refreshCheckedNodes() {
|
||||
$('#checkedNodeBox').empty();
|
||||
var checkedRoleNodes = '';
|
||||
for(var [k, v] of checkedRoleMap) {
|
||||
checkedRoleNodes += getCheckedNode(v.id, v.name);
|
||||
}
|
||||
$('#checkedNodeBox').append(checkedRoleNodes);
|
||||
}
|
||||
// 初始化树
|
||||
function initThree() {
|
||||
var setting = {
|
||||
check: {
|
||||
enable: true,
|
||||
chkboxType : {'Y': '', 'N': ''},
|
||||
},
|
||||
async: {
|
||||
enable: true,
|
||||
autoLoad: true,
|
||||
type: 'get',
|
||||
url: top.restAjax.path('api/role/listztree', []),
|
||||
autoParam: ['id'],
|
||||
otherParam: {},
|
||||
dataFilter: function (treeId, parentNode, childNodes) {
|
||||
if (!childNodes) return null;
|
||||
for (var i = 0, l = childNodes.length; i < l; i++) {
|
||||
childNodes[i].name = childNodes[i].name.replace(/\.n/g, '.');
|
||||
}
|
||||
return childNodes;
|
||||
}
|
||||
},
|
||||
callback: {
|
||||
onAsyncSuccess: function(event, treeId, treeNode) {
|
||||
// 初始化已选则数据
|
||||
checkedRoleMap.forEach(function(item) {
|
||||
var node = zTree.getNodeByParam('id', item.id);
|
||||
if(!node) {
|
||||
return;
|
||||
}
|
||||
zTree.checkNode(node, true, false);
|
||||
})
|
||||
},
|
||||
onCheck: function(event, treeId, treeNode) {
|
||||
if(treeNode.checked) {
|
||||
checkedRoleMap.set(treeNode.id, {
|
||||
id: treeNode.id,
|
||||
name: treeNode.name
|
||||
});
|
||||
} else {
|
||||
checkedRoleMap.delete(treeNode.id);
|
||||
}
|
||||
refreshCheckedNodes();
|
||||
}
|
||||
},
|
||||
};
|
||||
zTree = $.fn.zTree.init($("#tree"), setting);
|
||||
}
|
||||
|
||||
function initCheckedRoleMap() {
|
||||
var checkedRoles = checkedRoleNodes;
|
||||
if(!checkedRoles) {
|
||||
return;
|
||||
}
|
||||
for(var i = 0, item; item = checkedRoles[i++];){
|
||||
checkedRoleMap.set(item.roleId, item);
|
||||
}
|
||||
}
|
||||
|
||||
initSize();
|
||||
initCheckNodes(function() {
|
||||
initCheckedRoleMap();
|
||||
initThree();
|
||||
});
|
||||
|
||||
// 事件 - 页面变化
|
||||
$win.on('resize', function() {
|
||||
clearTimeout(resizeTimeout);
|
||||
resizeTimeout = setTimeout(function() {
|
||||
initSize();
|
||||
}, 500);
|
||||
});
|
||||
|
||||
$('.close').on('click', function() {
|
||||
closeBox();
|
||||
});
|
||||
|
||||
// 删除
|
||||
$(document).on('click', '.remove-checked-role', function() {
|
||||
var roleId = this.dataset.roleId;
|
||||
checkedRoleMap.delete(roleId);
|
||||
var node = zTree.getNodeByParam('id', roleId);
|
||||
// 未加载不删除
|
||||
if(node) {
|
||||
zTree.checkNode(node, false, false);
|
||||
}
|
||||
refreshCheckedNodes();
|
||||
})
|
||||
|
||||
$('.submit').on('click', function() {
|
||||
checkedRoleMap.forEach(function(item) {
|
||||
checkedRoleNodes.push(item);
|
||||
});
|
||||
top.dialog.dialogData.checkedRoleNodes = checkedRoleNodes;
|
||||
closeBox();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user