修改管理员列表按钮和密码初始化
This commit is contained in:
1 parent
9539290f87
commit
1ecfffee55
5 files changed
+98
-55
No files matched your search
@@ -128,13 +128,10 @@ class Index extends Base
|
||||
|
||||
$msg = array();
|
||||
|
||||
if($data == 1)
|
||||
{
|
||||
$data =['msg'=>'添加成功','val'=>1];
|
||||
}else{
|
||||
$data =['msg'=>'数据处理错误','val'=>0];
|
||||
}
|
||||
// 根据更新结果设置返回提示信息
|
||||
$data ? $data=['msg'=>'添加成功','val'=>1] : $data=['msg'=>'数据处理错误','val'=>0];
|
||||
|
||||
// 返回信息
|
||||
return json($data);
|
||||
}
|
||||
|
||||
@@ -187,13 +184,10 @@ class Index extends Base
|
||||
|
||||
$data = $admin->save($list,['id'=>$id]);
|
||||
|
||||
if($data == 1)
|
||||
{
|
||||
$data =['msg'=>'更新成功','val'=>1];
|
||||
}else{
|
||||
$data =['msg'=>'数据处理错误','val'=>0];
|
||||
}
|
||||
// 根据更新结果设置返回提示信息
|
||||
$data ? $data=['msg'=>'更新成功','val'=>1] : $data=['msg'=>'数据处理错误','val'=>0];
|
||||
|
||||
// 返回信息
|
||||
return json($data);
|
||||
}
|
||||
|
||||
@@ -215,8 +209,10 @@ class Index extends Base
|
||||
|
||||
$data = $admin->destroy($id);
|
||||
|
||||
$data = ['msg'=>'删除成功','val'=>1];
|
||||
// 根据更新结果设置返回提示信息
|
||||
$data ? $data=['msg'=>'删除成功','val'=>1] : $data=['msg'=>'数据处理错误','val'=>0];
|
||||
|
||||
// 返回信息
|
||||
return json($data);
|
||||
}
|
||||
|
||||
@@ -241,9 +237,40 @@ class Index extends Base
|
||||
$data = $list->save();
|
||||
|
||||
// 根据更新结果设置返回提示信息
|
||||
$data ? $data=['msg'=>'操作成功'] : $data=['msg'=>'数据处理错误'];
|
||||
$data ? $data=['msg'=>'状态设置成功','val'=>1] : $data=['msg'=>'数据处理错误','val'=>0];
|
||||
|
||||
// 返回信息
|
||||
// 返回信息
|
||||
return json($data);
|
||||
}
|
||||
|
||||
|
||||
// 重置密码
|
||||
public function resetpassword($id)
|
||||
{
|
||||
|
||||
// 实例化管理员数据模型类
|
||||
$admin = new Admin();
|
||||
// 实例化加密类
|
||||
$md5 = new APR1_MD5();
|
||||
|
||||
// 生成密码
|
||||
$password = $md5->hash('123456');
|
||||
|
||||
// 查询用户信息
|
||||
$list = $admin->get($id);
|
||||
|
||||
// 设置管理员新信息
|
||||
$list->password = $password;
|
||||
|
||||
// 更新密码
|
||||
$data = $list->save();
|
||||
|
||||
// 根据更新结果设置返回提示信息
|
||||
$data ? $data=['msg'=>'密码重置成功','val'=>1] : $data=['msg'=>'数据处理错误','val'=>0];
|
||||
|
||||
// 返回信息
|
||||
return json($data);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,7 @@
|
||||
<div class="cl pd-5 bg-1 bk-gray mt-20">
|
||||
<span class="l">
|
||||
<!-- 删除按钮 -->
|
||||
<a href="javascript:;" onclick="dels()" class="btn btn-danger radius">
|
||||
<a href="javascript:;" onclick="dels('/admin/m')" class="btn btn-danger radius">
|
||||
<i class="Hui-iconfont"></i>
|
||||
批量删除
|
||||
</a>
|
||||
@@ -91,7 +91,7 @@
|
||||
"className":'.td-manage',
|
||||
"render": function(data, type, row, meta) {
|
||||
// 初始化密码
|
||||
resetpw = '<a style="text-decoration:none" onClick="stop(this,'+ row.id +')" href="javascript:;" title="重置密码"><i class="Hui-iconfont"></i></a>';
|
||||
resetpwbut = '<a style="text-decoration:none" onClick="resetpw(this,'+ row.id +')" href="javascript:;" title="重置密码"><i class="Hui-iconfont"></i></a>';
|
||||
// 停用按钮
|
||||
stopbut = '<a style="text-decoration:none" onClick="stop(this,'+ row.id +')" href="javascript:;" title="停用"><i class="Hui-iconfont"></i></a>';
|
||||
// 启用按钮
|
||||
@@ -100,12 +100,12 @@
|
||||
readbut = '<a title="详细信息" data-href="admin/'+ row.id +'" data-title="' + row.xingming + ' 信息" onClick="Hui_admin_tab(this)" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont"></i></a>';
|
||||
// 编辑按钮
|
||||
editbut = '<a title="编辑" href="javascript:void(0);" onclick=addfull("编辑","/admin/'+row.id+'/edit","500","300") class="ml-5" style="text-decoration:none"><i class="Hui-iconfont"></i></a>';
|
||||
delbut = '<a title="删除" href="javascript:void(0);" onclick=del(this,"'+row.id+'") class="ml-5" style="text-decoration:none"><i class="Hui-iconfont"></i></a>';
|
||||
delbut = '<a title="删除" href="javascript:void(0);" onclick=del(this,"/admin/'+row.id+'") class="ml-5" style="text-decoration:none"><i class="Hui-iconfont"></i></a>';
|
||||
if(row.status == '已停用')
|
||||
{
|
||||
buts = resetpw + startbut + readbut + editbut + delbut;
|
||||
buts = resetpwbut + startbut + readbut + editbut + delbut;
|
||||
}else{
|
||||
buts = resetpw + stopbut + readbut + editbut + delbut;
|
||||
buts = resetpwbut + stopbut + readbut + editbut + delbut;
|
||||
}
|
||||
|
||||
return buts;
|
||||
|
||||
@@ -141,12 +141,18 @@ function stop(obj,id){
|
||||
value: 0,
|
||||
},
|
||||
success: function(data){
|
||||
$(obj).html('<a style="text-decoration:none" onClick="start(this,id)" href="javascript:;" title="启用"><i class="Hui-iconfont"></i></a>');
|
||||
$(obj).parents("tr").find("span").parents("td").html('<span class="label label-error radius">已停用</span>');
|
||||
layer.msg('已停用!',{icon: 5,time:1000});
|
||||
if(data.val == 1 || data.val == 0)
|
||||
{
|
||||
$(obj).parents("tr").find("span").parents("td").html('<span class="label label-error radius">已停用</span>');
|
||||
$(obj).replaceWith('<a style="text-decoration:none" onClick="start(this,'+id+')" href="javascript:;" title="启用"><i class="Hui-iconfont"></i></a>')
|
||||
|
||||
layer.msg('已停用!',{icon: 5,time:1000});
|
||||
}else{
|
||||
layer.msg(data.msg);
|
||||
}
|
||||
},
|
||||
error:function(data) {
|
||||
console.log(data.msg);
|
||||
layer.msg('操作失败');
|
||||
},
|
||||
});
|
||||
});
|
||||
@@ -164,12 +170,18 @@ function start(obj,id){
|
||||
value: 1,
|
||||
},
|
||||
success: function(data){
|
||||
$(obj).html('<a style="text-decoration:none" onClick="start(this,id)" href="javascript:;" title="停用"><i class="Hui-iconfont"></i></a>');
|
||||
$(obj).parents("tr").find("span").parents("td").html('<span class="label label-success radius">已启用</span>');
|
||||
layer.msg('已启用!',{icon: 6,time:1000});
|
||||
if(data.val == 1 || data.val == 0)
|
||||
{
|
||||
$(obj).parents("tr").find("span").parents("td").html('<span class="label label-success radius">已启用</span>');
|
||||
$(obj).replaceWith('<a style="text-decoration:none" onClick="stop(this,'+id+')" href="javascript:;" title="停用"><i class="Hui-iconfont"></i></a>');
|
||||
layer.msg('已启用!',{icon: 6,time:1000});
|
||||
}else{
|
||||
layer.msg(data.msg);
|
||||
}
|
||||
|
||||
},
|
||||
error:function(data) {
|
||||
console.log(data.msg);
|
||||
layer.msg('操作失败');
|
||||
},
|
||||
});
|
||||
});
|
||||
@@ -183,24 +195,29 @@ function change_password(title,url,id,w,h){
|
||||
layer_show(title,url,w,h);
|
||||
}
|
||||
/*用户-删除*/
|
||||
function del(obj,id){
|
||||
function del(obj,url){
|
||||
layer.confirm('确认要删除吗?',function(index){
|
||||
$.ajax({
|
||||
type: 'DELETE',
|
||||
url: "/admin/" + id,
|
||||
url: url,
|
||||
dataType: 'json',
|
||||
success: function(data){
|
||||
$(obj).parents("tr").remove();
|
||||
layer.msg('已删除!',{icon:1,time:1000});
|
||||
if(data.val == 1)
|
||||
{
|
||||
$(obj).parents("tr").remove();
|
||||
// layer.alert(data.msg,{icon:1,time:1000});
|
||||
}
|
||||
layer.alert(data.msg);
|
||||
|
||||
},
|
||||
error:function(data) {
|
||||
console.log(data.msg);
|
||||
layer.alert('删除失败');
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
/*批量删除*/
|
||||
function dels(){
|
||||
function dels(url){
|
||||
//声明数组
|
||||
var chk_value =[];
|
||||
//获取所有被选中的值
|
||||
@@ -221,7 +238,7 @@ function dels(){
|
||||
layer.confirm('确认要删除选中的内容吗?',function(index){
|
||||
$.ajax({
|
||||
type: 'DELETE',
|
||||
url:'/admin/m',
|
||||
url:url,
|
||||
dataType: 'json',
|
||||
data: {
|
||||
ids:chk_value,
|
||||
@@ -229,21 +246,34 @@ function dels(){
|
||||
|
||||
success: function(data){
|
||||
if(data.val == 1){
|
||||
layer.alert('删除成功');
|
||||
$('input[name="test"]:checked').each(function(){
|
||||
$(this).parents("tr").remove();
|
||||
});
|
||||
|
||||
}else{
|
||||
layer.alert('数据处理失败');
|
||||
}
|
||||
layer.alert(data.msg);
|
||||
},
|
||||
error:function(data) {
|
||||
layer.msg('删除失败');
|
||||
layer.msg('操作失败');
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
/*用户-密码重置*/
|
||||
function resetpw(obj,id){
|
||||
layer.confirm('确认要重置密码吗?',function(index){
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: "/resetpassword/" + id,
|
||||
dataType: 'json',
|
||||
success: function(data){
|
||||
layer.alert(data.msg,{icon:1,time:1000});
|
||||
},
|
||||
error:function(data) {
|
||||
layer.alert('操作失败');
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Loaded 3 of 5 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user