Browse Source

用户启用禁用

sunhao 5 years ago
parent
commit
a73a62da18

+ 16 - 0
app/Http/Controllers/Admin/AdminController.php

@@ -60,6 +60,22 @@ class AdminController extends Controller
60 60
         return view('admin/admincreate', ['roles' => $roles, 'team'=>$team]);
61 61
     }
62 62
 
63
+    public function del($id){
64
+        if($id > 0 ){
65
+            Admin::where('id', $id)->update(['is_use'=> 0]);
66
+            exit('1');
67
+        }
68
+        exit('0');
69
+    }
70
+
71
+    public function up($id){
72
+        if($id > 0 ){
73
+            Admin::where('id', $id)->update(['is_use'=> 1]);
74
+            exit('1');
75
+        }
76
+        exit('0');
77
+    }
78
+
63 79
     /**
64 80
      * @param Request $request
65 81
      * @return \Illuminate\Http\RedirectResponse

+ 1 - 0
app/Http/Controllers/Admin/CustReportController.php

@@ -748,6 +748,7 @@ class custReportController extends Controller
748 748
         $today = date('Y-m-d');
749 749
         //销售列表
750 750
         $ids = DB::table('admin_role')->where('user_id','!=',3)->where('role_name', '销售')->lists('user_id');
751
+        $ids = DB::table('admin')->whereIn('id', $ids)->where('is_use', 1)->lists('id');
751 752
         //销售名字
752 753
         $salers = DB::table('admin')->whereIn('id', $ids)->lists('realname', 'id');
753 754
  

+ 2 - 0
app/Http/routes.php

@@ -36,6 +36,8 @@ Route::group(['prefix' => 'admin'], function(){
36 36
         Route::get('/admin/create',    'Admin\AdminController@create');
37 37
         Route::post('/admin/store',    'Admin\AdminController@store');
38 38
         Route::get('/admin/edit/{id}', 'Admin\AdminController@edit');
39
+        Route::get('/admin/del/{id}', 'Admin\AdminController@del');
40
+        Route::get('/admin/up/{id}', 'Admin\AdminController@up');
39 41
         Route::post('/admin/update',   'Admin\AdminController@update');
40 42
         //团队
41 43
         Route::get('/admin/teamindex',       'Admin\AdminController@teamindex');

+ 37 - 14
resources/views/admin/adminall.blade.php

@@ -19,6 +19,7 @@
19 19
                     <th width="15%">真实姓名</th>
20 20
                     <th width="15%">手机号</th>
21 21
                     <th width="15%">所属团队</th>
22
+                    <th width="10%">状态</th>
22 23
                     <th width="15%">操作</th>
23 24
                 </tr>
24 25
                 </thead>
@@ -33,7 +34,13 @@
33 34
                         <td class="text-c">{{$a['realname']}}</td>
34 35
                         <td class="text-c">{{$a['phone']}}</td>
35 36
                         <td class="text-c">{{$a['team_name']}}</td>
36
-                        <td class="f-14 product-brand-manage"><a style="text-decoration:none" onClick='admin_edit("编辑管理员","{{$a['id']}}")' href="javascript:;" title="编辑管理员"><span class="btn btn-primary radius">编辑</span></a> <a style="text-decoration:none" class="ml-5" onClick="admin_del(this, '{{$a['id']}}')" href="javascript:;" title="删除"><span class="btn btn-danger radius">删除</span></a></td>
37
+                        <td class="text-c">@if($a['is_use'] == 1) 启用 @else 禁用@endif</td>
38
+                        <td class="f-14 product-brand-manage"><a style="text-decoration:none" onClick='admin_edit("编辑管理员","{{$a['id']}}")' href="javascript:;" title="编辑管理员"><span class="btn btn-primary radius">编辑</span></a> 
39
+                            @if($a['is_use'] == 1)
40
+                            <a style="text-decoration:none" class="ml-5" onClick="admin_del(this, '{{$a['id']}}')" href="javascript:;" title="禁用"><span class="btn btn-danger radius">禁用</span></a>
41
+                            @else
42
+                            <a style="text-decoration:none" class="ml-5" onClick="admin_up(this, '{{$a['id']}}')" href="javascript:;" title="启用"><span class="btn btn-success radius">启用</span></a></td>
43
+                            @endif
37 44
                     </tr>
38 45
                 @endforeach
39 46
                 @endif
@@ -64,21 +71,37 @@
64 71
         }
65 72
         /*管理员-删除*/
66 73
         function admin_del(obj,id){
67
-            layer.confirm('确认要删除吗?',function(index){
68
-                layer.msg('请不要搞事情!!!',{icon:1,time:3000});
69
-//                $.ajax({
70
-//                    type: 'GET',
71
-//                    url: '/admin/admin/destory/'+id,
72
-//                    dataType: 'json',
73
-//                    success: function(data){
74
-//                        if(data == 1){
75
-//                            $(obj).parents("tr").remove();
76
-//                            layer.msg('已删除!',{icon:1,time:1000});
77
-//                        }
78
-//                    }
79
-//                });
74
+            layer.confirm('确认要禁用吗?',function(index){
75
+                //layer.msg('请不要搞事情!!!',{icon:1,time:3000});
76
+                $.ajax({
77
+                    type: 'GET',
78
+                    url: '/admin/admin/del/'+id,
79
+                    dataType: 'json',
80
+                    success: function(data){
81
+                        if(data == 1){
82
+                            location.reload()
83
+                            layer.msg('已禁用!',{icon:1,time:1000});
84
+                        }
85
+                    }
86
+                });
80 87
             });
81 88
         }
89
+        /*管理员-删除*/
90
+        function admin_up(obj,id){
91
+           
92
+                $.ajax({
93
+                    type: 'GET',
94
+                    url: '/admin/admin/up/'+id,
95
+                    dataType: 'json',
96
+                    success: function(data){
97
+                        if(data == 1){
98
+                            location.reload()
99
+                            layer.msg('已启用!',{icon:1,time:1000});
100
+                        }
101
+                    }
102
+                });
103
+          
104
+        }
82 105
 
83 106
     </script>
84 107
     </body>