2025-12-08 09:27:34 +08:00
|
|
|
|
var example = null;
|
2025-12-16 18:22:03 +08:00
|
|
|
|
var layer, form;
|
2025-12-08 09:27:34 +08:00
|
|
|
|
$(function () {
|
2025-12-16 18:22:03 +08:00
|
|
|
|
layui.use(['form', 'layer'], function () {
|
2025-12-08 09:27:34 +08:00
|
|
|
|
layer = layui.layer;
|
|
|
|
|
|
form = layui.form; //只有执行了这一步,部分表单元素才会自动修饰成功
|
|
|
|
|
|
// 修复1:重新配置 layer,避免对话框出现在可视区域外
|
|
|
|
|
|
layer.config({
|
|
|
|
|
|
offset: '100px', // 默认距离顶部 100px
|
|
|
|
|
|
fixed: true, // 固定定位
|
|
|
|
|
|
move: false, // 禁止拖动(可选)
|
|
|
|
|
|
zIndex: 19891014 // 设置合理的 z-index
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
init();
|
2025-12-16 18:22:03 +08:00
|
|
|
|
$("#searchBt").click(function () {
|
2025-12-08 09:27:34 +08:00
|
|
|
|
example.ajax.reload();
|
|
|
|
|
|
});
|
|
|
|
|
|
})
|
|
|
|
|
|
|
2025-12-16 18:22:03 +08:00
|
|
|
|
function init() {
|
2025-12-08 09:27:34 +08:00
|
|
|
|
example =
|
|
|
|
|
|
$('#dt-table').DataTable({
|
|
|
|
|
|
"searching": false,
|
|
|
|
|
|
"processing": true, //加载数据时显示进度状态
|
2025-12-16 18:22:03 +08:00
|
|
|
|
"serverSide": true,
|
2025-12-08 09:27:34 +08:00
|
|
|
|
"pagingType": "full_numbers", //首页|尾页
|
|
|
|
|
|
"language": {
|
2025-12-16 18:22:03 +08:00
|
|
|
|
"url": "../login/js/plugin/datatables/Chinese.lang"
|
2025-12-08 09:27:34 +08:00
|
|
|
|
},
|
|
|
|
|
|
"ajax": {
|
2025-12-16 18:22:03 +08:00
|
|
|
|
"url": request_url + "/realname/publicLogin/getUserList",
|
|
|
|
|
|
"type": "POST",
|
2025-12-09 15:38:30 +08:00
|
|
|
|
"headers": {
|
|
|
|
|
|
"Authorization": "Bearer " + localStorage.getItem("public_token"),
|
|
|
|
|
|
},
|
2025-12-16 18:22:03 +08:00
|
|
|
|
"data": function (d) {
|
2025-12-09 15:38:30 +08:00
|
|
|
|
d.keyWord = $("#keyWord").val();
|
2025-12-08 09:27:34 +08:00
|
|
|
|
},
|
2025-12-16 18:22:03 +08:00
|
|
|
|
"error": function (xhr, textStatus, errorThrown) {
|
2025-12-08 09:27:34 +08:00
|
|
|
|
var msg = xhr.responseText;
|
|
|
|
|
|
console.log(msg);
|
|
|
|
|
|
var response = JSON.parse(msg);
|
|
|
|
|
|
var code = response.code;
|
|
|
|
|
|
var message = response.message;
|
|
|
|
|
|
if (code == 400) {
|
|
|
|
|
|
layer.msg(message);
|
|
|
|
|
|
} else if (code == 401) {
|
2025-12-09 15:38:30 +08:00
|
|
|
|
localStorage.removeItem("public_token");
|
2025-12-16 18:22:03 +08:00
|
|
|
|
layer.msg("token过期,请先登录", {shift: -1, time: 1000}, function () {
|
2025-12-09 15:38:30 +08:00
|
|
|
|
top.location.href = window.location.origin + contentPath + '/login.html';
|
2025-12-08 09:27:34 +08:00
|
|
|
|
});
|
|
|
|
|
|
} else if (code == 403) {
|
|
|
|
|
|
console.log("未授权:" + message);
|
|
|
|
|
|
layer.msg('未授权');
|
|
|
|
|
|
} else if (code == 500) {
|
|
|
|
|
|
console.log('系统错误:' + message);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2025-12-16 18:22:03 +08:00
|
|
|
|
"lengthMenu": [[10, 20, 50], [10, 20, 50]], // 设置每页显示数据量选项
|
|
|
|
|
|
"drawCallback": function () {
|
2025-12-08 09:27:34 +08:00
|
|
|
|
// alert( '表格重绘了' );
|
|
|
|
|
|
var thisDataTable = $('#dt-table').DataTable();
|
|
|
|
|
|
$(".pagination").append("<li>" +
|
|
|
|
|
|
"<a class='paginate_button' style='padding:4px;' href='#' tabindex='0'>到 <input style='margin:0px;width:40px;' id='changePage'> 页</a>" +
|
|
|
|
|
|
"<a class='paginate_button' style='margin-bottom:1px' href='#' tabindex='0' id='dataTable-btn'>确认</a></li>");
|
|
|
|
|
|
//点击按钮跳转指定页数
|
|
|
|
|
|
$('#dataTable-btn').click(function (e) {
|
|
|
|
|
|
if ($("#changePage").val() && $("#changePage").val() > 0) {
|
|
|
|
|
|
var redirectpage = $("#changePage").val() - 1;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
var redirectpage = 0;
|
|
|
|
|
|
}
|
2025-12-16 18:22:03 +08:00
|
|
|
|
thisDataTable.page(redirectpage).draw('page');
|
2025-12-08 09:27:34 +08:00
|
|
|
|
});
|
|
|
|
|
|
//敲击回车键跳转指定页数
|
|
|
|
|
|
$("#changePage").keypress(function (e) {
|
2025-12-16 18:22:03 +08:00
|
|
|
|
if (event.keyCode == 13) {
|
2025-12-08 09:27:34 +08:00
|
|
|
|
if ($("#changePage").val() && $("#changePage").val() > 0) {
|
|
|
|
|
|
var redirectpage = $("#changePage").val() - 1;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
var redirectpage = 0;
|
|
|
|
|
|
}
|
2025-12-16 18:22:03 +08:00
|
|
|
|
thisDataTable.page(redirectpage).draw('page');
|
2025-12-08 09:27:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
|
|
|
|
|
"dom": "<'dt-toolbar'r>t<'dt-toolbar-footer'<'col-sm-4 col-xs-4 hidden-xs'i><'col-xs-8 col-sm-8' p v>><'dt-table-length'l>",
|
|
|
|
|
|
"columns": [
|
|
|
|
|
|
{
|
2025-12-16 18:22:03 +08:00
|
|
|
|
width: '40px',
|
2025-12-08 09:27:34 +08:00
|
|
|
|
"orderable": false,
|
2025-12-16 18:22:03 +08:00
|
|
|
|
data: function (row, type, set, meta) {
|
2025-12-08 09:27:34 +08:00
|
|
|
|
var c = meta.settings._iDisplayStart + meta.row + 1;
|
|
|
|
|
|
return c;
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2025-12-16 18:22:03 +08:00
|
|
|
|
{"data": "userName", "defaultContent": ""},
|
|
|
|
|
|
{"data": "loginName", "defaultContent": ""},
|
|
|
|
|
|
{
|
|
|
|
|
|
"data": "", "defaultContent": "", "render": function (data, type, row) {
|
2025-12-09 15:38:30 +08:00
|
|
|
|
var dataType = row['dataType'];
|
2025-12-16 18:22:03 +08:00
|
|
|
|
// 如果 data 是空或 undefined,返回空
|
|
|
|
|
|
if (!dataType) return '';
|
|
|
|
|
|
|
|
|
|
|
|
// 定义映射关系
|
|
|
|
|
|
const labelMap = {
|
|
|
|
|
|
'1': '承载力后台',
|
|
|
|
|
|
'2': '承载力大屏',
|
|
|
|
|
|
'3': '领导履职',
|
|
|
|
|
|
'4': '自有人员',
|
|
|
|
|
|
'5': '自有人员大屏'
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// 分割字符串为数组,去空格并过滤无效值
|
|
|
|
|
|
const types = String(dataType).split(',').map(item => item.trim()).filter(item => item in labelMap);
|
|
|
|
|
|
// 转换为对应的中文标签
|
|
|
|
|
|
const labels = types.map(type => `<span>${labelMap[type]}</span>`);
|
|
|
|
|
|
// 用空格、逗号或其他方式拼接(这里用空格)
|
|
|
|
|
|
return labels.join(', ');
|
2025-12-09 15:38:30 +08:00
|
|
|
|
}
|
2025-12-16 18:22:03 +08:00
|
|
|
|
},
|
|
|
|
|
|
{"data": "userPhone", "defaultContent": ""},
|
|
|
|
|
|
{"data": "idCard", "defaultContent": ""},
|
|
|
|
|
|
{"data": "createTime", "defaultContent": ""},
|
|
|
|
|
|
{"data": "updateTime", "defaultContent": ""},
|
2025-12-08 09:27:34 +08:00
|
|
|
|
{
|
|
|
|
|
|
"data": "",
|
|
|
|
|
|
"defaultContent": "",
|
|
|
|
|
|
"orderable": false,
|
|
|
|
|
|
"render": function (data, type, row) {
|
|
|
|
|
|
var id = row['id'];
|
|
|
|
|
|
var html = '';
|
2025-12-09 15:38:30 +08:00
|
|
|
|
html += buttonEdits(id,);
|
2025-12-16 18:22:03 +08:00
|
|
|
|
html += buttonDel(id);
|
2025-12-16 19:02:57 +08:00
|
|
|
|
html += buttonReset(id);
|
|
|
|
|
|
html += buttonPassword(id);
|
2025-12-08 09:27:34 +08:00
|
|
|
|
return html;
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
],
|
2025-12-16 18:22:03 +08:00
|
|
|
|
"order": [[1, "desc"], [2, "desc"], [3, "desc"], [4, "desc"], [5, "desc"], [6, "desc"]] //在栏目列上显示排序功能
|
|
|
|
|
|
});
|
2025-12-08 09:27:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 新增页面
|
|
|
|
|
|
* */
|
|
|
|
|
|
function insertTeamManager() {
|
|
|
|
|
|
var height = '35%';
|
|
|
|
|
|
var width = '75%';
|
|
|
|
|
|
var index = layer.open({
|
|
|
|
|
|
title: '新增',
|
|
|
|
|
|
type: 2,
|
|
|
|
|
|
content: 'userForm.html',
|
|
|
|
|
|
area: [width, height],
|
|
|
|
|
|
maxmin: false,
|
2025-12-16 18:22:03 +08:00
|
|
|
|
btn: ['确定', '关闭'],
|
2025-12-08 09:27:34 +08:00
|
|
|
|
offset: '80px', // 固定偏移量,避免太靠下
|
|
|
|
|
|
fixed: true, // 固定定位
|
|
|
|
|
|
scrollbar: false, // 不锁定滚动条
|
|
|
|
|
|
success: function (layero, index) {
|
|
|
|
|
|
var myIframe = window[layero.find('iframe')[0]['name']];
|
|
|
|
|
|
},
|
2025-12-16 18:22:03 +08:00
|
|
|
|
yes: function (index, layero) {
|
2025-12-08 09:27:34 +08:00
|
|
|
|
// 获取弹出层中的form表单元素
|
2025-12-16 18:22:03 +08:00
|
|
|
|
var formSubmit = layer.getChildFrame('form', index);
|
2025-12-08 09:27:34 +08:00
|
|
|
|
var submited = formSubmit.find('button')[0];
|
|
|
|
|
|
// 触发点击事件,会对表单进行验证,验证成功则提交表单,失败则返回错误信息
|
|
|
|
|
|
submited.click();
|
|
|
|
|
|
},
|
2025-12-16 18:22:03 +08:00
|
|
|
|
btn2: function (index, layero) {
|
2025-12-08 09:27:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 删除班组
|
|
|
|
|
|
* */
|
|
|
|
|
|
function del(id) {
|
2025-12-16 18:22:03 +08:00
|
|
|
|
var data = {"id": id};
|
2025-12-16 19:02:57 +08:00
|
|
|
|
layer.confirm("确定删除吗?",function () {
|
2025-12-08 09:27:34 +08:00
|
|
|
|
$.ajax({
|
|
|
|
|
|
type: 'post',
|
|
|
|
|
|
contentType: "application/json; charset=utf-8",
|
2025-12-16 18:22:03 +08:00
|
|
|
|
url: request_url + '/realname/publicLogin/delUserData',
|
2025-12-08 09:27:34 +08:00
|
|
|
|
data: JSON.stringify(data),
|
|
|
|
|
|
dataType: 'json',
|
|
|
|
|
|
success: function (data) {
|
2025-12-16 18:22:03 +08:00
|
|
|
|
if (data.code == 200) {
|
2025-12-08 09:27:34 +08:00
|
|
|
|
layer.alert('删除成功', {icon: 1});
|
|
|
|
|
|
example.ajax.reload(null, false); // 刷新页面
|
|
|
|
|
|
} else {
|
|
|
|
|
|
layer.msg("删除失败", {icon: 2});
|
|
|
|
|
|
example.ajax.reload(null, false); // 刷新页面
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
2025-12-16 18:22:03 +08:00
|
|
|
|
|
2025-12-08 09:27:34 +08:00
|
|
|
|
// 删除按钮
|
2025-12-16 18:22:03 +08:00
|
|
|
|
function buttonDel(id) {
|
|
|
|
|
|
var btn = $("<button class='layui-btn layui-btn-xs' title='删除' onclick='del(\"" + id + "\")' style='background-color: transparent;color: #ff4d4f;'>删除</button>");
|
2025-12-08 09:27:34 +08:00
|
|
|
|
return btn.prop("outerHTML");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 编辑按钮
|
2025-12-09 15:38:30 +08:00
|
|
|
|
function buttonEdits(id) {
|
2025-12-08 09:27:34 +08:00
|
|
|
|
var btn = $("<button class='layui-btn layui-btn-xs' title='编辑' onclick='edit(\"" + id + "\")' style='background-color: transparent;color: #009688;'>编辑</button>");
|
|
|
|
|
|
return btn.prop("outerHTML");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-16 19:02:57 +08:00
|
|
|
|
// 重置密码
|
|
|
|
|
|
function buttonReset(id) {
|
|
|
|
|
|
var btn = $("<button class='layui-btn layui-btn-xs' title='重置密码' onclick='reset(\"" + id + "\")' style='background-color: transparent;color: #009688;'>重置密码</button>");
|
|
|
|
|
|
return btn.prop("outerHTML");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 修改密码
|
|
|
|
|
|
function buttonPassword(id) {
|
|
|
|
|
|
var btn = $("<button class='layui-btn layui-btn-xs' title='修改密码' onclick='updatePassword(\"" + id + "\")' style='background-color: transparent;color: #009688;'>修改密码</button>");
|
|
|
|
|
|
return btn.prop("outerHTML");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 修改密码
|
|
|
|
|
|
* @param id
|
|
|
|
|
|
*/
|
|
|
|
|
|
function updatePassword(id){
|
|
|
|
|
|
layer.prompt({
|
|
|
|
|
|
formType: 0,
|
|
|
|
|
|
value: '',
|
|
|
|
|
|
title: '请输入重置后密码',
|
|
|
|
|
|
btn:['确定','取消'],
|
|
|
|
|
|
btnAlign:'c',
|
|
|
|
|
|
}, function(value, index, elem){
|
|
|
|
|
|
if (!password_reg(value)){
|
|
|
|
|
|
layer.msg("您的密码复杂度太低(密码中必须包含大小字母、数字、特殊字符)!",{icon:0});
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}else{
|
|
|
|
|
|
$.ajax({
|
|
|
|
|
|
type: 'post',
|
|
|
|
|
|
url: request_url + '/realname/publicLogin/resetPassword',
|
|
|
|
|
|
contentType: "application/json; charset=utf-8",
|
|
|
|
|
|
data: JSON.stringify({"id": id,"password":value}),
|
|
|
|
|
|
success: function (data) {
|
|
|
|
|
|
// 无论成功失败都关闭弹窗
|
|
|
|
|
|
layer.close(index);
|
|
|
|
|
|
if (data.code == 200) {
|
|
|
|
|
|
layer.alert(data.msg, {icon: 1});
|
|
|
|
|
|
example.ajax.reload(); // 刷新页面
|
|
|
|
|
|
} else {
|
|
|
|
|
|
layer.msg("修改失败", {icon: 2});
|
|
|
|
|
|
example.ajax.reload(); // 刷新页面
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 重置密码
|
|
|
|
|
|
* @param id
|
|
|
|
|
|
*/
|
|
|
|
|
|
function reset(id) {
|
|
|
|
|
|
layer.confirm("确定重置密码吗?",function () {
|
|
|
|
|
|
$.ajax({
|
|
|
|
|
|
type: 'post',
|
|
|
|
|
|
url: request_url + '/realname/publicLogin/resetPassword',
|
|
|
|
|
|
contentType: "application/json; charset=utf-8",
|
|
|
|
|
|
data: JSON.stringify({"id": id}),
|
|
|
|
|
|
success: function (data) {
|
|
|
|
|
|
if (data.code == 200) {
|
|
|
|
|
|
layer.alert(data.msg, {icon: 1});
|
|
|
|
|
|
example.ajax.reload(); // 刷新页面
|
|
|
|
|
|
} else {
|
|
|
|
|
|
layer.msg("重置失败", {icon: 2});
|
|
|
|
|
|
example.ajax.reload(); // 刷新页面
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-08 09:27:34 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 编辑页面
|
|
|
|
|
|
*/
|
|
|
|
|
|
function edit(id) {
|
|
|
|
|
|
$.ajax({
|
|
|
|
|
|
type: 'POST',
|
|
|
|
|
|
contentType: "application/x-www-form-urlencoded",
|
|
|
|
|
|
url: ctxPath + '/TeamManager/getTeamById',
|
|
|
|
|
|
data: {"id": id},
|
|
|
|
|
|
dataType: 'json',
|
|
|
|
|
|
success: function (data) {
|
|
|
|
|
|
var height = '35%';
|
|
|
|
|
|
var width = '75%';
|
|
|
|
|
|
var index = layer.open({
|
|
|
|
|
|
title: ['修改', 'color:#3B70A1;background-color:#E8ECEB;font-size:20px'],
|
|
|
|
|
|
type: 2,
|
|
|
|
|
|
content: 'userForm.html',
|
|
|
|
|
|
area: [width, height],
|
|
|
|
|
|
maxmin: false,
|
|
|
|
|
|
offset: '80px', // 固定偏移量,避免太靠下
|
|
|
|
|
|
fixed: true, // 固定定位
|
|
|
|
|
|
scrollbar: false, // 不锁定滚动条
|
|
|
|
|
|
btn: ['确定', '关闭'],
|
|
|
|
|
|
success: function (layero, index) {
|
|
|
|
|
|
var myIframe = window[layero.find('iframe')[0]['name']];
|
|
|
|
|
|
var fnc = myIframe.setData(data); //aaa()为子页面的方法
|
|
|
|
|
|
},
|
|
|
|
|
|
yes: function (index, layero) {
|
|
|
|
|
|
// 获取弹出层中的form表单元素
|
|
|
|
|
|
var formSubmit = layer.getChildFrame('form', index);
|
|
|
|
|
|
var submited = formSubmit.find('button')[0];
|
|
|
|
|
|
// 触发点击事件,会对表单进行验证,验证成功则提交表单,失败则返回错误信息
|
|
|
|
|
|
submited.click();
|
|
|
|
|
|
},
|
|
|
|
|
|
btn2: function (index, layero) {
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
2025-12-16 19:02:57 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const password_reg = function (str) {
|
|
|
|
|
|
var str_reg = new RegExp('(?=.*[0-9])(?=.*[A-Z])(?=.*[a-z])(?=.*[^a-zA-Z0-9]).{8,20}');
|
|
|
|
|
|
if (!str_reg.test(str)) {
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|