更改实名制-施工人员管理页面代码

This commit is contained in:
lSun 2025-12-16 19:02:57 +08:00
parent eb586b564b
commit f5435e3837
1 changed files with 85 additions and 31 deletions

View File

@ -134,6 +134,8 @@ function init() {
var html = '';
html += buttonEdits(id,);
html += buttonDel(id);
html += buttonReset(id);
html += buttonPassword(id);
return html;
}
},
@ -179,37 +181,7 @@ function insertTeamManager() {
* */
function del(id) {
var data = {"id": id};
layer.confirm("确定删除吗?", {
title: '删除确认',
btn: ['确定', '取消'],
// 关键:固定位置在屏幕中央
offset: '200px', // 距离顶部的固定偏移
fixed: true, // 固定定位
scrollbar: false, // 不锁定滚动条
// 或者使用百分比
// offset: '30%',
// 或者自动计算
// offset: 'auto',
// 或者限制在可视区域内
success: function (layero) {
// 对话框创建后的回调,确保在可视区域内
var $layer = $(layero);
var top = $layer.css('top');
var topNum = parseInt(top);
// 如果 top 值太大,调整到合理位置
if (topNum > 500) {
$layer.css('top', '100px');
}
// 确保对话框可见
$layer.css({
'display': 'block',
'visibility': 'visible'
});
}
}, function (index) {
layer.close(index);
layer.confirm("确定删除吗?",function () {
$.ajax({
type: 'post',
contentType: "application/json; charset=utf-8",
@ -241,6 +213,79 @@ function buttonEdits(id) {
return btn.prop("outerHTML");
}
// 重置密码
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(); // 刷新页面
}
}
})
});
}
/**
* 编辑页面
*/
@ -281,3 +326,12 @@ function edit(id) {
}
})
}
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;
}