diff --git a/application/admin/controller/Index.php b/application/admin/controller/Index.php
index e1d54f4d..571fd661 100644
--- a/application/admin/controller/Index.php
+++ b/application/admin/controller/Index.php
@@ -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);
+
+
+ }
}
diff --git a/application/admin/view/index/index.html b/application/admin/view/index/index.html
index 3ba52b3c..666588fb 100644
--- a/application/admin/view/index/index.html
+++ b/application/admin/view/index/index.html
@@ -16,7 +16,7 @@
-
+
批量删除
@@ -91,7 +91,7 @@
"className":'.td-manage',
"render": function(data, type, row, meta) {
// 初始化密码
- resetpw = '';
+ resetpwbut = '';
// 停用按钮
stopbut = '';
// 启用按钮
@@ -100,12 +100,12 @@
readbut = '';
// 编辑按钮
editbut = '';
- delbut = '';
+ delbut = '';
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;
diff --git a/application/common/view/list.html b/application/common/view/list.html
index 50fa1835..ba088ce1 100644
--- a/application/common/view/list.html
+++ b/application/common/view/list.html
@@ -141,12 +141,18 @@ function stop(obj,id){
value: 0,
},
success: function(data){
- $(obj).html('');
- $(obj).parents("tr").find("span").parents("td").html('已停用');
- layer.msg('已停用!',{icon: 5,time:1000});
+ if(data.val == 1 || data.val == 0)
+ {
+ $(obj).parents("tr").find("span").parents("td").html('已停用');
+ $(obj).replaceWith('')
+
+ 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('');
- $(obj).parents("tr").find("span").parents("td").html('已启用');
- layer.msg('已启用!',{icon: 6,time:1000});
+ if(data.val == 1 || data.val == 0)
+ {
+ $(obj).parents("tr").find("span").parents("td").html('已启用');
+ $(obj).replaceWith('');
+ 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('操作失败');
+ },
+ });
+ });
+}