<!DOCTYPE html>
|
<html>
|
<head>
|
<meta charset="utf-8">
|
<title>用户信息列表</title>
|
<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="../../../layuiadmin/layui/css/layui.css" media="all">
|
<link rel="stylesheet" href="../../../layuiadmin/style/admin.css" media="all">
|
</head>
|
<body>
|
|
<div class="layui-fluid" style="padding-bottom: 0;">
|
<div class="layui-card">
|
<div class="layui-form layui-card-header layuiadmin-card-header-auto">
|
<div class="layui-form-item">
|
<div class="layui-inline">
|
<label class="layui-form-label" style="width: 45px;">登录名</label>
|
<div class="layui-input-inline">
|
<input type="text" id="UserCode" name="UserCode" placeholder="登录名" autocomplete="off"
|
class="layui-input">
|
</div>
|
</div>
|
<div class="layui-inline">
|
<label class="layui-form-label" style="width: 45px;">部门</label>
|
<div class="layui-input-inline">
|
<select name="DepartmentId" id="DepartmentId" lay-verify="" lay-search>
|
<option value=""></option>
|
</select>
|
</div>
|
</div>
|
<div class="layui-inline">
|
<label class="layui-form-label" style="width: 45px;">角色</label>
|
<div class="layui-input-inline">
|
<select name="UserRoleId" id="UserRoleId" lay-verify="" lay-search>
|
<option value=""></option>
|
</select>
|
</div>
|
</div>
|
<div class="layui-inline">
|
<label class="layui-form-label" style="width: 45px;">状态</label>
|
<div class="layui-input-inline">
|
<select name="UserStatus" id="UserStatus" lay-verify="" lay-search>
|
<option value=""></option>
|
<option value="0">启用</option>
|
<option value="1">禁用</option>
|
</select>
|
</div>
|
</div>
|
<div class="layui-inline">
|
<button class="layui-btn layui-btn-sm layuiadmin-btn-list" lay-submit
|
lay-filter="LAY-app-contlist-search">
|
<i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>搜索
|
</button>
|
</div>
|
</div>
|
</div>
|
<div class="layui-card-body">
|
<div style="padding-bottom: 5px; display: flex; flex-direction: row-reverse;">
|
<button class="layui-btn layui-btn-sm layuiadmin-btn-list layui-btn-danger approvalBtndel" data-type="batchdel"
|
id="approvalBtndel"><i class="layui-icon"></i>删除</button>
|
<button class="layui-btn layui-btn-sm layuiadmin-btn-list approvalBtn" style="margin-right: 10px;" data-type="add" id="approvalBtn"><i
|
class="layui-icon"></i>添加</button>
|
</div>
|
<table id="LAY-app-content-list" lay-filter="LAY-app-content-list"></table>
|
<script type="text/html" id="buttonStatus">
|
{{# if(d.UserStatus=='0'){ }}
|
<button class="layui-btn layui-btn-radius layui-btn-xs">启用</button>
|
{{# } else { }}
|
<button class="layui-btn layui-btn-radius layui-btn-danger layui-btn-xs">禁用</button>
|
{{# } }}
|
</script>
|
<script type="text/html" id="buttonTpl">
|
{{# if(d.UserShieldFlag=='0'){ }}
|
<button class="layui-btn layui-btn-radius layui-btn-xs">在职</button>
|
{{# } else { }}
|
<button class="layui-btn layui-btn-radius layui-btn-danger layui-btn-xs">离职</button>
|
{{# } }}
|
</script>
|
<script type="text/html" id="table-content-list">
|
{{# if(d.UserStatus=='0'){ }}
|
<a class="layui-btn layui-btn-danger layui-btn-xs qjBtn" style="display: none;" lay-event="lock"><i
|
class="layui-icon layui-icon-circle-dot"></i>禁用</a>
|
{{# } else { }}
|
<a class="layui-btn layui-btn-normal layui-btn-xs qjBtn" style="display: none;" lay-event="unlock"><i
|
class="layui-icon layui-icon-ok"></i>启用</a>
|
{{# } }}
|
<a class="layui-btn layui-btn-normal layui-btn-xs approvalBtn" style="display: none;" lay-event="edit"><i
|
class="layui-icon layui-icon-edit"></i>编辑</a>
|
<a class="layui-btn layui-btn-danger layui-btn-xs approvalBtndel" style="display: none;" lay-event="del"><i
|
class="layui-icon layui-icon-delete"></i>删除</a>
|
</script>
|
</div>
|
</div>
|
</div>
|
<script src="../../../layuiadmin/layui/layui.js"></script>
|
<script src="../../../js/public.js"></script>
|
<script src="../../../js/jquery-3.5.1.min.js"></script>
|
<script src="../../../js/jquery.cookie.js"></script>
|
<script>
|
layui.config({
|
base: '../../../layuiadmin/' //静态资源所在路径
|
}).extend({
|
index: 'lib/index' //主入口模块
|
}).use(['index', 'table', 'laypage', 'layer'], function() {
|
var table = layui.table,
|
form = layui.form,
|
laypage = layui.laypage,
|
layer = layui.layer;
|
|
sendData(IP + "/User/GetRole", {}, 'post', function(res) {
|
var html = '';
|
console.log(res);
|
if (res.code == 1) { //成功
|
var list = res.data;
|
for (var i = 0; i < list.length; i++) {
|
html += '<option value = "' + list[i].Id + '">' + list[i].RoleName + '</option>';
|
}
|
$("#UserRoleId").append(html);
|
form.render('select');
|
} else { //不成功
|
layer.msg('获取角色信息失败!', {
|
icon: 2,
|
time: 2000 //2秒关闭(如果不配置,默认是3秒)
|
}, function() {});
|
}
|
});
|
|
sendData(IP + "/User/GetDepartment", {}, 'post', function(res) {
|
var html = '';
|
console.log(res);
|
if (res.code == 1) { //成功
|
var list = res.data;
|
for (var i = 0; i < list.length; i++) {
|
html += '<option value = "' + list[i].Id + '">' + list[i].DepartmentName +
|
'</option>';
|
}
|
$("#DepartmentId").append(html);
|
form.render('select');
|
} else { //不成功
|
layer.msg('获取部门信息失败!', {
|
icon: 2,
|
time: 2000 //2秒关闭(如果不配置,默认是3秒)
|
}, function() {});
|
}
|
});
|
|
var tableIns;
|
|
function refreshTable(UserCode, DepartmentId, UserRoleId, UserStatus) {
|
var param = {
|
UserCode: UserCode,
|
DepartmentId: DepartmentId,
|
UserRoleId: UserRoleId,
|
UserStatus: UserStatus,
|
UserId: uid
|
};
|
var url = IP + "/User/GetUserViewList";
|
table.render({
|
elem: '#LAY-app-content-list',
|
url: url,
|
method: 'POST',
|
height: 'full-135',
|
where: param,
|
contentType: 'application/json',
|
id: 'LAY-app-content-list',
|
page: true,
|
limit: pageCnt,
|
limits: pageLimits,
|
cellMinWidth: 80, //全局定义常规单元格的最小宽度,layui 2.2.1 新增
|
even: true,
|
done:function(){
|
var param = {
|
Id: $.cookie('userId')
|
}
|
sendData(IP + "/Menu/GetPermission", param, 'post', function(res) {
|
if (res.code == 1) { //成功
|
for (var k = 0; k < res.data.length; k++) {
|
if (res.data[k].ModuleId == "d78b1cba4fa34c9198ee17195a14d57b") {
|
$(function() {
|
$(".approvalBtn").show();
|
});
|
}
|
if (res.data[k].ModuleId == "3eb6846364114ce39f4777e887a7422a") {
|
$(function() {
|
$(".approvalBtndel").show();
|
});
|
}
|
if (res.data[k].ModuleId == "3eb6846364114ce39f4777e887a7423a") {
|
$(function() {
|
$(".qjBtn").show();
|
});
|
}
|
}
|
} else { //不成功
|
layer.msg('获取信息失败', {
|
icon: 2,
|
time: 2000 //2秒关闭(如果不配置,默认是3秒)
|
}, function() {
|
//回调
|
});
|
}
|
});
|
},
|
cols: [
|
[{
|
field: 'Id',
|
title: 'Id',
|
type: 'checkbox',
|
width: 50,
|
fixed: 'left'
|
}, {
|
field: 'UserCode',
|
title: '登录名',
|
width: 120,
|
align: 'center',
|
fixed: 'left'
|
}, {
|
field: 'UserName',
|
title: '姓名',
|
align: 'center',
|
width: 150,
|
}, {
|
field: 'RoleName',
|
title: '角色',
|
align: 'center',
|
width: 120
|
}, {
|
field: 'UserStatusEx',
|
templet: '#buttonStatus',
|
title: '状态',
|
align: 'center',
|
width: 100
|
}, {
|
field: 'UserShieldFlag ',
|
templet: '#buttonTpl',
|
title: '是否离职',
|
align: 'center',
|
width: 100
|
}, {
|
field: 'DepartmentName',
|
title: '部门',
|
align: 'center',
|
width: 100
|
}, {
|
field: 'UserSexEx',
|
title: '性别',
|
align: 'center',
|
width: 100
|
}, {
|
field: 'UserIdentityCard',
|
title: '身份证',
|
align: 'center',
|
width: 100
|
}, {
|
field: 'UserPhone',
|
title: '手机号',
|
align: 'center',
|
width: 100
|
}, {
|
field: 'UserEmail',
|
title: '邮箱',
|
align: 'center',
|
width: 100
|
}, {
|
field: 'CreateUserName',
|
title: '创建人',
|
width: 120
|
}, {
|
field: 'CreateTime',
|
title: '创建时间',
|
width: 150,
|
templet: function(d) {
|
return formatDate(d.CreateTime);
|
}
|
}, {
|
field: 'UpdateUserName',
|
title: '修改人',
|
width: 120
|
}, {
|
field: 'UpdateTime',
|
title: '修改时间',
|
width: 150,
|
templet: function(d) {
|
return formatDate(d.UpdateTime);
|
}
|
}, {
|
field: 'UserNationalityName',
|
title: '国籍',
|
width: 150
|
}, {
|
field: 'UserRemark',
|
title: '备注',
|
width: 200
|
}, {
|
title: '操作',
|
fixed: 'right',
|
width: 240,
|
align: 'center',
|
toolbar: '#table-content-list'
|
}]
|
]
|
});
|
// sendData(IP + "/User/GetUserViewList", param, 'post', function(res) {
|
// console.log(res);
|
// if (res.code == 1) { //成功
|
// var list = res.data;
|
// $.extend(infoOptions, {
|
// data: list
|
// });
|
// infoOptions.page = {
|
// curr: 1
|
// }
|
// tableIns = table.render(infoOptions);
|
// } else { //不成功
|
// layer.msg(res.msg, {
|
// icon: 2,
|
// time: 2000 //2秒关闭(如果不配置,默认是3秒)
|
// }, function() {});
|
// }
|
// });
|
}
|
//监听搜索
|
form.on('submit(LAY-app-contlist-search)', function(data) {
|
var UserCode = data.field.UserCode;
|
var DepartmentId = data.field.DepartmentId;
|
var UserRoleId = data.field.UserRoleId;
|
var UserStatus = data.field.UserStatus;
|
refreshTable(UserCode, DepartmentId, UserRoleId, UserStatus);
|
});
|
var doing = true;
|
var $ = layui.$,
|
active = {
|
batchdel: function() {
|
var checkStatus = table.checkStatus('LAY-app-content-list'),
|
checkData = checkStatus.data; //得到选中的数据
|
if (checkData.length === 0) {
|
return layer.msg('请选择数据');
|
}
|
layer.confirm('确定删除吗?', function(index) {
|
console.log(checkData);
|
var arr = [];
|
for (var i = 0; i < checkData.length; i++) {
|
arr.push(checkData[i].Id); //属性
|
}
|
var param = {
|
Ids: arr
|
};
|
if(doing){
|
doing = false;
|
sendData(IP + "/User/DelUsers", param, 'post', function(res) {
|
console.log(res);
|
if (res.code == 1) { //成功
|
layer.msg(res.msg, {
|
icon: 1,
|
time: 2000 //2秒关闭(如果不配置,默认是3秒)
|
}, function() {
|
refreshTable($("#UserCode").val(), $(
|
"#DepartmentId").val(), $(
|
"#UserRoleId").val(), $(
|
"#UserStatus").val());
|
doing = true;
|
});
|
} else { //不成功
|
layer.msg(res.msg, {
|
icon: 2,
|
time: 2000 //2秒关闭(如果不配置,默认是3秒)
|
}, function() {doing = true;});
|
}
|
});
|
}
|
else{
|
console.log(123);
|
}
|
});
|
},
|
add: function() {
|
layer.open({
|
type: 2,
|
title: '添加用户信息',
|
content: 'UserEditForm.html',
|
maxmin: true,
|
area: ['640px', '580px'],
|
btn: ['确定', '取消'],
|
yes: function(index, layero) {
|
var iframeWindow = window['layui-layer-iframe' + index],
|
submitID = 'layuiadmin-app-form-submit',
|
submit = layero.find('iframe').contents().find('#' + submitID);
|
//监听提交
|
iframeWindow.layui.form.on('submit(' + submitID + ')', function(
|
data) {
|
var field = data.field; //获取提交的字段
|
console.log(field);
|
//提交 Ajax 成功后,静态更新表格中的数据
|
var param = {
|
Id: "",
|
UserCode: field.UserCode,
|
UserName: field.UserName,
|
UserRoleId: field.UserRoleId,
|
UserStatus: field.UserStatus,
|
UserType: '',
|
UserShieldFlag: field.UserShieldFlag,
|
DepartmentId: field.DepartmentId,
|
UserSex: field.UserSex,
|
UserIdentityCard: field.UserIdentityCard,
|
UserPhone: field.UserPhone,
|
UserEmail: field.UserEmail,
|
UserRemark: field.UserRemark,
|
UserNationality: field.UserNationality,
|
CreateUser: $.cookie('userId')
|
};
|
if(doing){
|
doing = false;
|
sendData(IP + "/User/SaveWmsSysUser", param, 'post',
|
function(res) {
|
console.log(res);
|
if (res.code == 1) { //成功
|
layer.msg(res.msg, {
|
icon: 1,
|
time: 2000 //2秒关闭(如果不配置,默认是3秒)
|
}, function() {
|
refreshTable($("#UserCode")
|
.val(), $(
|
"#DepartmentId")
|
.val(), $(
|
"#UserRoleId")
|
.val(), $(
|
"#UserStatus")
|
.val());
|
// table.reload('LAY-app-content-list'); //数据刷新
|
layer.close(index); //关闭弹层
|
doing = true;
|
});
|
} else { //不成功
|
layer.msg(res.msg, {
|
icon: 2,
|
time: 2000 //2秒关闭(如果不配置,默认是3秒)
|
}, function() {doing = true;});
|
}
|
});
|
//$.ajax({});
|
}
|
else{
|
console.log(123);
|
}
|
|
});
|
submit.trigger('click');
|
}
|
});
|
}
|
};
|
$('.layui-btn.layuiadmin-btn-list').on('click', function() {
|
var type = $(this).data('type');
|
active[type] ? active[type].call(this) : '';
|
});
|
|
|
|
|
$(function() {
|
$("#approvalBtn").hide();
|
});
|
$(function() {
|
$("#approvalBtndel").hide();
|
});
|
var element = layui.element;
|
var houseId = 0;
|
var param = {
|
Id: $.cookie('userId')
|
}
|
var xml = '';
|
function getchiled(data, mainId) {
|
if (data) {
|
var list = data.filter(item => item.ParentId == mainId);
|
if (list) {
|
for (var i = 0; i < list.length; i++) {
|
var id = list[i].Id;
|
//查询有无子菜单
|
var count = data.filter(item => item.ParentId == id).length;
|
if (count > 0) {
|
xml = xml +
|
'<dd>' +
|
'<a href="javascript:;">' + list[i].Name + '</a>' +
|
'<dl class="layui-nav-child">';
|
getchiled(data, id);
|
xml = xml +
|
'</dl></dd>';
|
|
} else {
|
xml = xml +
|
'<dd>' +
|
'<a lay-href="' + list[i].Url + '">' + list[i].Name + '</a>' +
|
'</dd>';
|
|
}
|
}
|
|
}
|
|
}
|
}
|
var menuList;
|
sendData(IP + "/Menu/GetPermission", param, 'post', function(res) {
|
if (res.code == 1) { //成功
|
var list = res.data.filter(item => item.Layer == 0);
|
if (list) {
|
for (var i = 0; i < list.length; i++) {
|
xml = xml +
|
'<li class="layui-nav-item">' +
|
'<a href="javascript:;" lay-tips=' + list[i].Icon + ' lay-direction="2">' +
|
// '<i class="layui-icon ' + list[i].Icon + '"></i>' +
|
'<span class="iconfont ' + list[i].Icon + '"></span>' +
|
'<cite>' + list[i].Name + '</cite>' +
|
'</a>';
|
var id = list[i].Id;
|
//查询有无子菜单
|
var count = res.data.filter(item => item.ParentId == id).length;
|
if (count > 0) {
|
xml = xml +
|
'<dl class="layui-nav-child">';
|
getchiled(res.data, id);
|
xml = xml +
|
'</dl>';
|
}
|
xml = xml +
|
'</li>'
|
}
|
}
|
$("#LAY-system-side-menu").append(xml);
|
element.render("#leftmenu");
|
for (var k = 0; k < res.data.length; k++) {
|
if (res.data[k].ModuleId == "d78b1cba4fa34c9198ee17195a14d57b") {
|
$(function() {
|
$(".approvalBtn").show();
|
});
|
}
|
if (res.data[k].ModuleId == "3eb6846364114ce39f4777e887a7422a") {
|
$(function() {
|
$(".approvalBtndel").show();
|
});
|
}
|
if (res.data[k].ModuleId == "3eb6846364114ce39f4777e887a7423a") {
|
$(function() {
|
$(".qjBtn").show();
|
});
|
}
|
// else{
|
// $("#approvalBtn").css({"display": "none"});
|
// }
|
}
|
} else { //不成功
|
layer.msg('获取信息失败', {
|
icon: 2,
|
time: 2000 //2秒关闭(如果不配置,默认是3秒)
|
}, function() {
|
//回调
|
});
|
}
|
});
|
var uid = $.cookie('userId');
|
refreshTable("", "", "", "");
|
table.on('tool(LAY-app-content-list)', function(obj) {
|
var data = obj.data;
|
if (obj.event === 'del') {
|
layer.confirm('确定删除选中的用户?', function(index) {
|
// console.log(data);
|
cusid = data.Id;
|
var arr = [];
|
arr.push(cusid); //属性
|
var param = {
|
Ids: arr
|
};
|
if(doing){
|
doing = false;
|
sendData(IP + "/User/DelUsers", param, 'post', function(res) {
|
console.log(res);
|
if (res.code == 1) { //成功
|
layer.msg(res.msg, {
|
icon: 1,
|
time: 2000 //2秒关闭(如果不配置,默认是3秒)
|
}, function() {
|
refreshTable($("#UserCode").val(), $(
|
"#DepartmentId").val(), $(
|
"#UserRoleId").val(), $(
|
"#UserStatus").val());
|
doing = true;
|
});
|
} else { //不成功
|
layer.msg(res.msg, {
|
icon: 2,
|
time: 2000 //2秒关闭(如果不配置,默认是3秒)
|
}, function() {doing = true;});
|
}
|
});
|
}
|
else{
|
console.log(123);
|
}
|
|
});
|
} else if (obj.event === 'edit') {
|
cusId = data.Id;
|
layer.open({
|
type: 2,
|
title: '编辑用户信息',
|
content: 'UserEditForm.html?id=' + cusId,
|
maxmin: true,
|
area: ['640px', '580px'],
|
btn: ['确定', '取消'],
|
yes: function(index, layero) {
|
var iframeWindow = window['layui-layer-iframe' + index],
|
submitID = 'layuiadmin-app-form-edit',
|
submit = layero.find('iframe').contents().find('#' + submitID);
|
//监听提交
|
iframeWindow.layui.form.on('submit(' + submitID + ')', function(
|
data) {
|
var field = data.field; //获取提交的字段
|
console.log(field);
|
//提交 Ajax 成功后,静态更新表格中的数据
|
var param = {
|
Id: cusId,
|
UserCode: field.UserCode,
|
UserName: field.UserName,
|
UserRoleId: field.UserRoleId,
|
UserStatus: field.UserStatus,
|
UserType: '',
|
UserShieldFlag: field.UserShieldFlag,
|
DepartmentId: field.DepartmentId,
|
UserSex: field.UserSex,
|
UserIdentityCard: field.UserIdentityCard,
|
UserPhone: field.UserPhone,
|
UserEmail: field.UserEmail,
|
UserRemark: field.UserRemark,
|
UserNationality: field.UserNationality,
|
UpdateUser: $.cookie('userId')
|
};
|
if(doing){
|
doing = false;
|
sendData(IP + "/User/SaveWmsSysUser", param, 'post',
|
function(res) {
|
console.log(res);
|
if (res.code == 1) { //成功
|
layer.msg("修改成功", {
|
icon: 1,
|
time: 1000 //2秒关闭(如果不配置,默认是3秒)
|
}, function() {
|
refreshTable($("#UserCode")
|
.val(), $(
|
"#DepartmentId")
|
.val(), $(
|
"#UserRoleId")
|
.val(), $(
|
"#UserStatus")
|
.val());
|
layer.close(index); //关闭弹层
|
doing = true;
|
});
|
} else { //不成功
|
layer.msg(res.msg, {
|
icon: 2,
|
time: 2000 //2秒关闭(如果不配置,默认是3秒)
|
}, function() {doing = true;});
|
}
|
});
|
//$.ajax({});
|
}
|
else{
|
console.log(123);
|
}
|
|
});
|
submit.trigger('click');
|
}
|
});
|
} else if (obj.event === 'lock') {
|
layer.confirm('确定禁用此用户吗?', function(index) {
|
var param = {
|
Id: data.Id,
|
Status: 1
|
};
|
if(doing){
|
doing = false;
|
sendData(IP + "/User/SaveUserState", param, 'post', function(res) {
|
console.log(res);
|
if (res.code == 1) { //成功
|
layer.msg(res.msg, {
|
icon: 1,
|
time: 1000 //2秒关闭(如果不配置,默认是3秒)
|
}, function() {
|
refreshTable($("#UserCode").val(), $(
|
"#DepartmentId").val(), $(
|
"#UserRoleId").val(), $(
|
"#UserStatus").val());
|
doing = true;
|
});
|
} else { //不成功
|
layer.msg(res.msg, {
|
icon: 2,
|
time: 2000 //2秒关闭(如果不配置,默认是3秒)
|
}, function() {doing = true;});
|
}
|
});
|
}
|
else{
|
console.log(123);
|
}
|
|
});
|
} else if (obj.event === 'unlock') {
|
layer.confirm('确定启用此用户吗?', function(index) {
|
var param = {
|
Id: data.Id,
|
UserId: 0
|
};
|
if(doing){
|
doing = false;
|
sendData(IP + "/User/SaveUserState", param, 'post', function(res) {
|
console.log(res);
|
if (res.code == 1) { //成功
|
layer.msg(res.msg, {
|
icon: 1,
|
time: 1000 //2秒关闭(如果不配置,默认是3秒)
|
}, function() {
|
refreshTable($("#UserCode").val(), $(
|
"#DepartmentId").val(), $(
|
"#UserRoleId").val(), $(
|
"#UserStatus").val());
|
doing = true;
|
});
|
} else { //不成功
|
layer.msg(res.msg, {
|
icon: 2,
|
time: 2000 //2秒关闭(如果不配置,默认是3秒)
|
}, function() {doing = true;});
|
}
|
});
|
}
|
else{
|
console.log(123);
|
}
|
|
});
|
}
|
});
|
});
|
</script>
|
</body>
|
</html>
|