增加按区域分级用户管理功能

This commit is contained in:
TS-QD1 2023-05-24 10:58:45 +08:00
parent 0e88090ed6
commit 5541d61203
4 changed files with 986 additions and 2 deletions

View File

@ -1,11 +1,18 @@
package cn.com.tenlion.usercenter.controller.route.area.user;
import cn.com.tenlion.usercenter.pojo.dtos.userexpand.UserExpandDTO;
import cn.com.tenlion.usercenter.pojo.pos.userexpand.UserExpandPO;
import ink.wgink.common.base.DefaultBaseController;
import ink.wgink.common.component.SecurityComponent;
import ink.wgink.exceptions.SearchException;
import ink.wgink.interfaces.consts.ISystemConstant;
import ink.wgink.interfaces.user.IUserExpandBaseService;
import ink.wgink.interfaces.user.IUserExpandOptionButton;
import ink.wgink.module.dictionary.pojo.dtos.AreaDTO;
import ink.wgink.module.dictionary.service.IAreaService;
import ink.wgink.service.user.util.UserUtil;
import io.swagger.annotations.Api;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
@ -21,6 +28,10 @@ public class AreaUserRouteController {
private IUserExpandBaseService userExpandBaseService;
@Autowired(required = false)
private IUserExpandOptionButton userExpandOptionButton;
@Autowired
private SecurityComponent securityComponent;
@Autowired
private IAreaService areaService;
@GetMapping("save-area-user")
public ModelAndView saveAreaUser() {
@ -40,6 +51,30 @@ public class AreaUserRouteController {
return mv;
}
@GetMapping("list-area-admin")
public ModelAndView listAreaAdmin() {
ModelAndView mv = new ModelAndView("area/user/list-area-admin");
if (securityComponent.isAdmin()) {
mv.addObject("baseParentId", "0");
} else {
UserExpandPO userExpandPO = securityComponent.getExpandData(UserExpandPO.class);
if (userExpandPO == null) {
throw new SearchException("未绑定拓展属性");
}
if (StringUtils.isBlank(userExpandPO.getAreaCode())) {
throw new SearchException("未绑定地区");
}
AreaDTO areaDTO = areaService.getByCode(userExpandPO.getAreaCode());
if (areaDTO == null) {
throw new SearchException("地区不存在");
}
mv.addObject("baseAreaId", areaDTO.getAreaId());
mv.addObject("baseAreaParentId", areaDTO.getAreaParentId());
mv.addObject("baseAreaCode", areaDTO.getAreaCode());
}
return mv;
}
@GetMapping("list-area-user")
public ModelAndView listAreaUser() {
ModelAndView mv = new ModelAndView("area/user/list-area-user");
@ -47,4 +82,11 @@ public class AreaUserRouteController {
return mv;
}
@GetMapping("list-area-user-admin")
public ModelAndView listAreaUserAdmin() {
ModelAndView mv = new ModelAndView("area/user/list-area-user-admin");
UserUtil.setUserListPageExpand(userExpandBaseService, userExpandOptionButton, mv);
return mv;
}
}

View File

@ -0,0 +1,187 @@
<!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>
.layui-table tr th {text-align: center;}
.layui-table tr td {text-align: center;}
.layui-table tr td a {text-align: center; text-decoration: underline;}
</style>
</head>
<body>
<div class="layui-fluid layui-anim layui-anim-fadein">
<div class="layui-row layui-col-space15">
<div class="layui-col-md3 layui-col-sm3 layui-col-xs3" id="areaTable" style="padding-right: 0px;">
<div class="layui-card">
<div class="layui-card-body">
<div id="goBackArea" style="display: none;">
<a href="javascript:void(0);" class="go-back-area">返回上级</a>
</div>
<div id="areaUserContainer"></div>
</div>
</div>
</div>
<div class="layui-col-md9 layui-col-sm9 layui-col-xs9" id="userTable" style="padding-left: 0px;">
<div class="layui-card">
<div id="listContentWrap" class="layui-card-body">
<iframe id="listContent" frameborder="0" class="layadmin-iframe"></iframe>
</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 selectedDepartmentId = 0;
var zTree;
var baseAreaId = '[[${baseAreaId}]]';
var baseAreaParentId = '[[${baseAreaParentId}]]';
var baseAreaCode = '[[${baseAreaCode}]]';
var parentId = baseAreaId;
var areaHistoryArray = [];
// 初始化IFrame
function initIFrame(areaId, areaParentId, areaCode) {
if(areaId === baseAreaId) {
$('#areaUserContainer').css({height: $win.height() - 50});
$('#goBackArea').hide();
} else {
$('#areaUserContainer').css({height: $win.height() - 74});
$('#goBackArea').show();
}
$('#listContent').attr('src', top.restAjax.path('route/area/user/list-area-user-admin?areaId={areaId}&areaParentId={areaParentId}&areaCode={areaCode}&baseAreaId={baseAreaId}', [areaId, areaParentId, areaCode, baseAreaId]));
}
// 初始化大小
function initSize() {
$('#areaUserContainer').css({
height: $win.height() - 50,
overflow: 'auto'
});
$('#listContentWrap').css({
height: $win.height() - 50,
});
}
// 初始化地区
function initAreaTable() {
function render(data) {
var trs = '';
$.each(data, function(index, item) {
trs += `
<tr>
<td>
<a href="javascript:void(0);" class="select-area" data-area-id="${item.areaId}" data-area-parent-id="${item.areaParentId}" data-area-code="${item.areaCode}">${item.areaName}</a>
</td>
<td>${item.userCount}</td>
<td>${item.gridMemberCount}</td>
</tr>
`
});
var dom = `
<table class="layui-table">
<colgroup>
<col>
<col width="80">
<col width="80">
</colgroup>
<thead>
<tr>
<th>地区</th>
<th>用户</th>
<th>网格员</th>
</tr>
</thead>
<tbody>${trs}</tbody>
</table>
`
var container = $('#areaUserContainer');
container.empty();
container.append(dom);
}
function init() {
top.restAjax.get(top.restAjax.path('api/area/user/list-area-user-count/area-parent-id/{parentId}', [parentId]), {}, null, function(code, data) {
render(data);
if(data.length === 0) {
$('#areaTable').hide();
$('#userTable').attr('class', 'layui-col-md12 layui-col-sm12 layui-col-xs12');
} else {
$('#areaTable').show();
$('#userTable').attr('class', 'layui-col-md9 layui-col-sm9 layui-col-xs9');
}
}, function(code, data) {
top.dialog.msg(data.msg);
})
}
function event() {
$(document).on('click', '.select-area', function() {
var dataset = this.dataset;
var areaId = dataset.areaId;
var areaParentId = dataset.areaParentId;
var areaCode =dataset.areaCode;
parentId = areaId;
areaHistoryArray.push(areaParentId);
init();
initIFrame(areaId, areaParentId, areaCode);
})
$(document).on('click', '.go-back-area', function() {
parentId = areaHistoryArray.length === 0 ? '0' : areaHistoryArray.pop();
initIFrame(parentId)
init();
})
}
event();
init();
initIFrame(baseAreaId, baseAreaParentId, baseAreaCode);
window['reInit'] = function(areaId, areaParentId, areaCode) {
parentId = areaId;
for(var i = 0; i < areaHistoryArray.length; i++) {
if(areaParentId === areaHistoryArray[i]) {
areaHistoryArray.splice(i + 1, areaHistoryArray.length - i - 1);
break;
}
}
init();
initIFrame(parentId, areaParentId, areaCode);
}
}
initAreaTable();
initSize();
// 事件 - 页面变化
$win.on('resize', function() {
clearTimeout(resizeTimeout);
resizeTimeout = setTimeout(function() {
initSize();
}, 500);
});
});
</script>
</body>
</html>

View File

@ -0,0 +1,748 @@
<!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/js/vendor/viewer/viewer.min.css">
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
<style>
.test-table-reload-btn {margin-bottom: 10px; display: flex;}
.test-table-reload-btn .layui-inline {margin-right: 5px; display: flex; align-items: center;}
.test-table-reload-btn .search-item .select-container {border: 1px solid silver; padding: 0 10px; height: 28px; display: flex; align-items: center}
.test-table-reload-btn .layui-inline .layui-form-checkbox[lay-skin=primary] span {padding-right: 0px;}
</style>
</head>
<body>
<div class="layui-anim layui-anim-fadein">
<div class="layui-row">
<div class="layui-col-md12">
<div class="layui-card">
<div class="layui-card-body">
<blockquote id="selectedAreaName" class="layui-elem-quote"></blockquote>
<div class="test-table-reload-btn">
<div class="layui-inline layui-form search-item">
<select id="searchLevel" name="searchLevel" lay-filter="searchLevelFilter">
<option value="this">本级</option>
<option value="part">局部</option>
<option value="global">全局</option>
</select>
</div>
<div id="noAreaContainer" class="layui-inline layui-form search-item">
<input type="checkbox" name="noArea" title="无地区" lay-skin="primary" lay-filter="noAreaFilter">
</div>
<div class="layui-inline layui-form search-item">
<input type="checkbox" name="noGrid" title="无网格" lay-skin="primary" lay-filter="noGridFilter">
</div>
<!-- 部门 start -->
<div class="layui-inline layui-form search-item">
<input type="checkbox" name="noDepartment" title="无部门" lay-skin="primary" lay-filter="noDepartmentFilter">
</div>
<div id="departmentContainer" class="layui-inline layui-form search-item">
<input type="hidden" id="departmentId" name="departmentId">
<div id="departmentIdContainer" class="select-container">请选择组织机构</div>
</div>
<!-- 部门 end -->
<!-- 角色 start -->
<div class="layui-inline layui-form search-item">
<input type="checkbox" name="noRole" title="无角色" lay-skin="primary" lay-filter="noRoleFilter">
</div>
<div id="roleContainer" class="layui-inline layui-form search-item">
<input type="hidden" id="roleId" name="roleId">
<div id="roleIdContainer" class="select-container">请选择角色</div>
</div>
<!-- 角色 end -->
<!-- 职位 start -->
<div class="layui-inline layui-form search-item">
<input type="checkbox" name="noPosition" title="无职位" lay-skin="primary" lay-filter="noPositionFilter">
</div>
<div id="positionContainer" class="layui-inline layui-form search-item">
<input type="hidden" id="positionId" name="roleId">
<div id="positionIdContainer" class="select-container">请选择职位</div>
</div>
<!-- 职位 end -->
<!-- 组 start -->
<div class="layui-inline layui-form search-item">
<input type="checkbox" name="noGroup" title="无组" lay-skin="primary" lay-filter="noGroupFilter">
</div>
<div id="groupContainer" class="layui-inline layui-form search-item">
<input type="hidden" id="groupId" name="roleId">
<div id="groupIdContainer" class="select-container">请选择组</div>
</div>
<!-- 组 end -->
</div>
<div class="test-table-reload-btn">
<input type="hidden" id="userExpand" th:value="${userExpand}" th:if="${userExpand}">
<div class="layui-inline">
<input type="text" id="keywords" class="layui-input search-item" placeholder="输入用户名、昵称">
</div>
<div class="layui-inline layui-form search-item">
<select id="userType" name="userType">
<option value="">选择类型</option>
<option value="1">系统用户</option>
<option value="2">普通用户</option>
<option value="3">公共用户</option>
</select>
</div>
<div class="layui-inline layui-form search-item">
<select id="userState" name="userState">
<option value="">选择状态</option>
<option value="0">正常</option>
<option value="1">锁定</option>
<option value="-1">未审核</option>
<option value="-2">审核不通过</option>
</select>
</div>
<div class="layui-btn-group">
<button type="button" id="search" class="layui-btn layui-btn-sm">
<i class="fa fa-lg fa-search"></i> 搜索
</button>
</div>
</div>
<table class="layui-hide" id="dataTable" lay-filter="dataTable"></table>
<!-- 表头按钮组 -->
<script type="text/html" id="headerToolBar">
<div class="layui-btn-group">
<button type="button" class="layui-btn layui-btn-sm" lay-event="saveEvent">
<i class="fa fa-lg fa-plus"></i> 新增
</button>
<button type="button" class="layui-btn layui-btn-normal layui-btn-sm" lay-event="updateEvent">
<i class="fa fa-lg fa-edit"></i> 编辑
</button>
</div>
</script>
</div>
</div>
</div>
</div>
</div>
<script src="assets/layuiadmin/layui/layui.js"></script>
<script th:inline="javascript">
layui.config({
base: 'assets/layuiadmin/'
}).extend({
index: 'lib/index',
treeselect: 'custom/treeselect'
}).use(['index', 'table', 'form', 'laydate', 'upload', 'treeselect'], function() {
var $ = layui.$;
var $win = $(window);
var table = layui.table;
var form = layui.form;
var admin = layui.admin;
var layer = layui.layer;
var laydate = layui.laydate;
var treeselect = layui.treeselect;
var resizeTimeout = null;
var expandOption = [[${expandOption}]];
var queryParams = top.restAjax.params(window.location.href);
var areaId = queryParams.areaId;
var areaParentId = queryParams.areaParentId;
var areaCode = queryParams.areaCode;
var baseAreaId = queryParams.baseAreaId;
var tableUserUrl = 'api/area/user/listpage-area-user';
var tableUrl = tableUserUrl + '?areaCode={areaCode}';
var noArea = false;
var noGrid = false;
var noDepartment = false;
var noRole = false;
var noPosition = false;
var noGroup = false;
// 初始化表格
function initTable() {
var colsArray = [
{type:'checkbox', fixed: 'left'},
{field:'rowNum', width:80, title: '序号', fixed: 'left', align:'center', templet: '<span>{{d.LAY_INDEX}}</span>'},
{field:'userUsername', width:140, title: '用户名', sort: true, align:'center',
templet: function(rowData) {
return '<a href="javascript:void(0);" lay-event="userUsernameEvent">'+ rowData.userUsername +'</a>';
}
},
{field:'userName', width:140, title: '昵称', sort: true, align:'center'},
{field:'userType', width:90, title: '类型', sort: true, align:'center',
templet: function(item) {
if(item.userType == 1) {
return '<span class="layui-badge layui-bg-green">系统用户</span>';
} else if(item.userType == 2) {
return '<span class="layui-badge layui-bg-orange">普通用户</span>';
} else if(item.userType == 3) {
return '<span class="layui-badge layui-bg-gray">公共用户</span>';
}
return '<span class="layui-badge">类型错误</span>';
}
},
{field:'areaName', width: 160, title: '地区', sort: true, align:'center',
templet: function(item) {
if(!item.areaName) {
return '-';
}
return item.areaName;
}
},
{field:'gridNames', width: 160, title: '网格', sort: true, align:'center',
templet: function(item) {
if(!item.gridNames) {
return '-';
}
return item.gridNames;
}
},
{field:'departmentNames', width: 160, title: '组织机构', sort: true, align:'center',
templet: function(item) {
if(!item.departmentNames) {
return '-';
}
return item.departmentNames;
}
},
{field:'roleNames', width: 160, title: '角色', sort: true, align:'center',
templet: function(item) {
if(!item.roleNames) {
return '-';
}
return item.roleNames;
}
},
{field:'positionNames', width: 160, title: '职位', sort: true, align:'center',
templet: function(item) {
if(!item.positionNames) {
return '-';
}
return item.positionNames;
}
},
{field:'userState', width:80, title: '状态', sort: true, align:'center',
templet: function(item) {
var value;
switch (item.userState) {
case 1:
value = '<span class="layui-badge layui-bg-blue">锁定</span>';
break;
case -1:
value = '<span class="layui-badge layui-bg-gray">未审核</span>';
break;
case -2:
value = '<span class="layui-badge">审核不通过</span>';
break;
default:
value = '<span class="layui-badge layui-bg-green">正常</span>';
}
return value;
}
},
{field:'userPhone', width:140, title: '手机', sort: true, align:'center',
templet: function(item) {
if(!item.userPhone) {
return '-';
}
return item.userPhone;
}
},
{field:'userEmail', width: 160, title: '邮箱', sort: true, align:'center',
templet: function(item) {
if(!item.userEmail) {
return '-';
}
return item.userEmail;
}
},
{field:'groupNames', width: 160, title: '组', sort: true, align:'center',
templet: function(item) {
if(!item.groupNames) {
return '-';
}
return item.groupNames;
}
},
{field:'userExpiredDate', width:180, title: '账号过期时间', align:'center',
templet: function(item) {
if(!item.userExpiredDate) {
return '<button type="button" class="layui-btn layui-btn-xs layui-btn-normal" lay-event="userExpiredDateEvent">' +
'<i class="fa fa-clock-o"></i> 设置时间' +
'</button>';
}
return item.userExpiredDate;
}
},
{field:'lastLoginAddress', width:140, title: '登录地址', align:'center',
templet: function(item) {
if(!item.lastLoginAddress) {
return '-';
}
return item.lastLoginAddress;
}
},
{field:'lastLoginTime', width:180, title: '最后登录系统时间', align:'center',
templet: function(item) {
if(!item.lastLoginTime) {
return '-';
}
return item.lastLoginTime;
}
},
{field:'gmtCreate', width:180, title: '创建时间', align:'center',
templet: function(item) {
if(!item.gmtCreate) {
return '-';
}
return item.gmtCreate;
}
},
];
if($('#userExpand') && $('#userExpand').val()) {
colsArray.push({
field:'opition', width:190, title: '操作', fixed:'right', align:'center', templet: function(item) {
return '<div class="layui-btn-group">' +
'<button type="button" class="layui-btn layui-btn-xs" lay-event="resetPasswordEvent"><i class="fa fa-key"></i> 重置密码</button>'+
'<button type="button" class="layui-btn layui-btn-xs layui-btn-primary" lay-event="userExpandEvent"><i class="fa fa-vcard"></i> 拓展属性</button>'+
'</div>';
}
});
} else {
colsArray.push({
field:'opition', width:110, title: '操作', fixed:'right', align:'center', templet: function(item) {
return '<button type="button" class="layui-btn layui-btn-xs" lay-event="resetPasswordEvent">' +
'<i class="fa fa-key"></i> 重置密码' +
'</button>';
}
});
}
if(expandOption) {
colsArray.push({
field:'expandOpition', width: expandOption.width, title: expandOption.title, fixed: expandOption.fixed, align: expandOption.align, templet: function(item) {
var btns = '<div class="layui-btn-group">';
for(var i = 0, item; item = expandOption.btns[i++];) {
btns += '<button type="button" class="layui-btn layui-btn-xs" lay-event="expandOpitionEvent" data-route="'+ item.route +'" data-title="'+ item.title +'">'+ item.title +'</button>';
}
btns += '</div>';
return btns;
}
});
}
table.render({
elem: '#dataTable',
id: 'dataTable',
url: top.restAjax.path(tableUrl, [areaCode]),
width: admin.screen() > 1 ? '100%' : '',
height: $win.height() - 162,
limit: 20,
limits: [20, 40, 60, 80, 100, 200],
toolbar: '#headerToolBar',
request: {
pageName: 'page',
limitName: 'rows'
},
cols: [
colsArray
],
page: true,
parseData: function(data) {
return {
'code': 0,
'msg': '',
'count': data.total,
'data': data.rows
};
}
});
}
// 重载表格
function reloadTable(currentPage) {
var reloadTableObj = {
where: {
keywords: $('#keywords').val(),
startTime: $('#startTime').val(),
endTime: $('#endTime').val(),
userType: $('#userType').val(),
userState: $('#userState').val(),
searchLevel: $('#searchLevel').val(),
noArea: noArea ? 1 : 0,
noGrid: noGrid ? 1 : 0,
noDepartment: noDepartment ? 1 : 0,
departmentId: noDepartment ? '' : $('#departmentId').val(),
noRole: noRole ? 1 : 0,
roleId: noRole ? '' : $('#roleId').val(),
noPosition: noPosition ? 1 : 0,
positionId: noPosition ? '' : $('#positionId').val(),
noGroup: noGroup ? 1 : 0,
groupId: noGroup ? '' : $('#groupId').val()
},
page: {
curr: currentPage
},
};
var searchLevel = $('#searchLevel').val();
if(searchLevel === 'global') {
reloadTableObj.url = top.restAjax.path(tableUserUrl, []);
} else {
reloadTableObj.url = top.restAjax.path(tableUrl, [areaCode]);
}
table.reload('dataTable', reloadTableObj);
}
// 初始化日期
function initDate() {
// 日期选择
laydate.render({
elem: '#startTime',
format: 'yyyy-MM-dd'
});
laydate.render({
elem: '#endTime',
format: 'yyyy-MM-dd'
});
}
// 初始化部门导航
function initDepartmentNav() {
top.restAjax.get(top.restAjax.path('api/area/user/list-area-nav-path/area-id/{areaId}', [areaId]), {}, null, function(code, data) {
var navs = '';
var isNav = false;
$.each(data, function(index, item) {
if(item.areaId === baseAreaId) {
isNav = true;
}
if(!isNav) {
return;
}
if(navs.length != '') {
navs += '<i class="fa fa-angle-right" aria-hidden="true" style="margin: 0 6px;"></i>'
}
navs += `<a href="javascript:void(0);" class="nav" data-area-id="${item.areaId}" data-area-parent-id="${item.areaParentId}" data-area-code="${item.areaCode}">${item.areaName}</a>`;
})
$('#selectedAreaName').append(navs);
}, function(code, data) {
top.dialog.msg(data.msg);
})
}
// 初始化下拉树
function initSelectInputTree() {
// 组织初始化
treeselect.init({
isSingle: true,
name: 'departmentId',
explain: '组织机构',
url: 'api/department/listztree',
idsUrl: 'api/department/list/ids',
key: {
id: 'id',
name: 'name',
title: 'title',
pId: 'pId',
checked: 'checked',
children: 'children',
isParent: 'isParent',
isHidden: 'isHidden',
url: 'url'
},
onInitSelectedDataFilter: function(selectedData) {
$.each(selectedData, function(i, item) {
item.id = item.departmentId;
item.name = item.departmentName;
});
},
onSelect: function(selectedNodeArray) {
},
onDelete: function(selectedNodeArray) {
}
})
// 角色初始化
treeselect.init({
isSingle: true,
name: 'roleId',
explain: '角色',
url: 'api/role/listztree',
idsUrl: 'api/role/list/role-ids',
key: {
id: 'id',
name: 'name',
title: 'title',
pId: 'pId',
checked: 'checked',
children: 'children',
isParent: 'isParent',
isHidden: 'isHidden',
url: 'url'
},
onInitSelectedDataFilter: function(selectedData) {
$.each(selectedData, function(i, item) {
item.id = item.roleId;
item.name = item.roleName;
});
},
onSelect: function(selectedNodeArray) {
},
onDelete: function(selectedNodeArray) {
}
})
// 职位下拉树选择
treeselect.init({
isSingle: true,
name: 'positionId',
explain: '职位',
url: 'api/position/listztree',
idsUrl: 'api/position/list/position-ids',
key: {
id: 'id',
name: 'name',
title: 'title',
pId: 'pId',
checked: 'checked',
children: 'children',
isParent: 'isParent',
isHidden: 'isHidden',
url: 'url'
},
onInitSelectedDataFilter: function(selectedData) {
$.each(selectedData, function(i, item) {
item.id = item.positionId;
item.name = item.positionName;
});
},
onSelect: function(selectedNodeArray) {
},
onDelete: function(selectedNodeArray) {
}
})
// 用户组下拉树选择
treeselect.init({
isSingle: true,
name: 'groupId',
explain: '组',
url: 'api/group/listztree',
idsUrl: 'api/group/list/group-ids',
key: {
id: 'id',
name: 'name',
title: 'title',
pId: 'pId',
checked: 'checked',
children: 'children',
isParent: 'isParent',
isHidden: 'isHidden',
url: 'url'
},
onInitSelectedDataFilter: function(selectedData) {
$.each(selectedData, function(i, item) {
item.id = item.groupId;
item.name = item.groupName;
});
},
onSelect: function(selectedNodeArray) {
},
onDelete: function(selectedNodeArray) {
}
})
}
// 删除
function removeData(ids) {
top.dialog.msg(top.dataMessage.delete, {
time: 0,
btn: [top.dataMessage.button.yes, top.dataMessage.button.no],
shade: 0.3,
yes: function (index) {
top.dialog.close(index);
var layIndex;
top.restAjax.delete(top.restAjax.path('api/core/manage/remove-user/{ids}', [ids]), {}, null, function (code, data) {
top.dialog.msg(top.dataMessage.deleteSuccess, {time: 1000});
reloadTable();
}, function (code, data) {
top.dialog.msg(data.msg);
}, function () {
layIndex = top.dialog.msg(top.dataMessage.deleting, {icon: 16, time: 0, shade: 0.3});
}, function () {
top.dialog.close(layIndex);
});
}
});
}
initTable();
initDate();
initDepartmentNav();
initSelectInputTree();
// 事件 - 页面变化
$win.on('resize', function() {
clearTimeout(resizeTimeout);
resizeTimeout = setTimeout(function() {
reloadTable();
}, 500);
});
// 事件 - 搜索
$(document).on('click', '#search', function() {
reloadTable(1);
});
$(document).on('click', '.nav', function() {
var dataset = this.dataset;
var areaId = dataset.areaId;
var areaParentId = dataset.areaParentId;
var areaCode = dataset.areaCode;
parent.reInit(areaId, areaParentId, areaCode);
});
// 事件 - 增删改
table.on('toolbar(dataTable)', function(obj) {
var layEvent = obj.event;
var checkStatus = table.checkStatus('dataTable');
var checkDatas = checkStatus.data;
if(layEvent === 'saveEvent') {
layer.open({
type: 2,
title: false,
closeBtn: 0,
area: ['100%', '100%'],
shadeClose: true,
anim: 2,
content: top.restAjax.path('route/area/user/save-area-user', []),
end: function() {
reloadTable();
}
});
} else if(layEvent === 'updateEvent') {
if(checkDatas.length === 0) {
top.dialog.msg(top.dataMessage.table.selectEdit);
} else if(checkDatas.length > 1) {
top.dialog.msg(top.dataMessage.table.selectOneEdit);
} else {
layer.open({
type: 2,
title: false,
closeBtn: 0,
area: ['100%', '100%'],
shadeClose: true,
anim: 2,
content: top.restAjax.path('route/area/user/update-area-user?userId={id}', [checkDatas[0].userId]),
end: function() {
reloadTable();
}
});
}
}
});
table.on('tool(dataTable)', function(obj) {
var layEvent = obj.event;
var data = obj.data;
if(layEvent === 'userUsernameEvent') {
top.dialog.open({
url: top.restAjax.path('route/user/update-username?userId={userId}', [data.userId]),
title: '【'+ data.userName +'】修改用户名',
width: '320px',
height: '430px',
onClose: function() {
reloadTable();
}
});
} else if(layEvent === 'resetPasswordEvent') {
top.dialog.open({
url: top.restAjax.path('route/user/rest-password?userId={userId}', [data.userId]),
title: '【'+ data.userName +'】重置密码',
width: '320px',
height: '280px',
onClose: function() {
reloadTable();
}
});
} else if(layEvent === 'userExpiredDateEvent') {
top.dialog.open({
url: top.restAjax.path('route/user/update-expired-date?userId={userId}', [data.userId]),
title: '【'+ data.userName +'】设置账号过期时间',
width: '274px',
height: '395px',
onClose: function() {
reloadTable();
}
});
} else if(layEvent === 'userExpandEvent') {
top.dialog.open({
url: top.restAjax.path('{userExpand}?userId={userId}', [$('#userExpand').val(), data.userId]),
title: '【'+ data.userName +'】拓展属性',
width: '60%',
height: '80%',
onClose: function() {
reloadTable();
}
});
} else if(layEvent === 'expandOpitionEvent') {
top.dialog.open({
url: top.restAjax.path('{userExpandOptionRoute}?userId={userId}', [this.dataset.route, data.userId]),
title: '【'+ data.userName +'】'+ this.dataset.title,
width: '60%',
height: '80%',
onClose: function() {
}
});
}
});
// 事件-排序
table.on('sort(dataTable)', function(obj) {
table.reload('dataTable', {
initSort: obj,
where: {
sort: obj.field,
order: obj.type
}
});
});
$('#noAreaContainer').hide();
form.on('select(searchLevelFilter)', function(data) {
if(data.value === 'this' || data.value === 'part') {
$('#noAreaContainer').hide();
$('input[name="noArea"]').prop('checked', false);
noArea = false;
} else {
$('#noAreaContainer').show();
}
form.render('checkbox');
});
form.on('checkbox(noAreaFilter)', function(data) {
noArea = data.elem.checked;
});
form.on('checkbox(noGridFilter)', function(data) {
noGrid = data.elem.checked;
});
form.on('checkbox(noDepartmentFilter)', function(data) {
noDepartment = data.elem.checked;
if(noDepartment) {
$('#departmentContainer').hide();
} else {
$('#departmentContainer').show();
}
});
form.on('checkbox(noRoleFilter)', function(data) {
noRole = data.elem.checked;
if(noRole) {
$('#roleContainer').hide();
} else {
$('#roleContainer').show();
}
});
form.on('checkbox(noPositionFilter)', function(data) {
noPosition = data.elem.checked;
if(noPosition) {
$('#positionContainer').hide();
} else {
$('#positionContainer').show();
}
});
form.on('checkbox(noGroupFilter)', function(data) {
noGroup = data.elem.checked;
if(noGroup) {
$('#groupContainer').hide();
} else {
$('#groupContainer').show();
}
});
});
</script>
</body>
</html>

View File

@ -20,7 +20,7 @@
<body>
<div class="layui-fluid layui-anim layui-anim-fadein">
<div class="layui-row layui-col-space15">
<div class="layui-col-md3 layui-col-sm3 layui-col-xs3" style="padding-right: 0px;">
<div class="layui-col-md3 layui-col-sm3 layui-col-xs3" id="areaTable" style="padding-right: 0px;">
<div class="layui-card">
<div class="layui-card-body">
<div id="goBackArea" style="display: none;">
@ -30,7 +30,7 @@
</div>
</div>
</div>
<div class="layui-col-md9 layui-col-sm9 layui-col-xs9" style="padding-left: 0px;">
<div class="layui-col-md9 layui-col-sm9 layui-col-xs9" id="userTable" style="padding-left: 0px;">
<div class="layui-card">
<div id="listContentWrap" class="layui-card-body">
<iframe id="listContent" frameborder="0" class="layadmin-iframe"></iframe>
@ -120,6 +120,13 @@
function init() {
top.restAjax.get(top.restAjax.path('api/area/user/list-area-user-count/area-parent-id/{parentId}', [parentId]), {}, null, function(code, data) {
render(data);
if(data.length === 0) {
$('#areaTable').hide();
$('#userTable').attr('class', 'layui-col-md12 layui-col-sm12 layui-col-xs12');
} else {
$('#areaTable').show();
$('#userTable').attr('class', 'layui-col-md9 layui-col-sm9 layui-col-xs9');
}
}, function(code, data) {
top.dialog.msg(data.msg);
})