马铁龙 6 rokov pred
rodič
commit
022bff664c

+ 1 - 0
application/admin/controller/Intention.php

@@ -174,6 +174,7 @@ class Intention extends Backend
         $data = ['rows' => $searchlist];
         return $data;
     }
+
     /**
      * 放弃
      */

+ 3 - 14
application/admin/controller/Protector.php

@@ -65,22 +65,9 @@ class Protector extends Backend
             }
             list($where, $sort, $order, $offset, $limit) = $this->buildparams();
 
-            $rules = AuthGroup::getRulesByGroupId(Session::get('admin')['depart_id']);
 
+            $where_usr_id =  \app\admin\model\Protector::getGroupWhere();
 
-            if($rules == '*'){
-                $where_usr_id = false;      // 管理员可以看到所有
-            } else {
-                $auth_group = Db::table('auth_group')->select();        // 所有组别
-                $depart_id = Session::get('admin')['depart_id'];        // 所属组别
-
-                // 获取所有子级部门
-                $arr = AuthGroup::getSubs($auth_group,$depart_id);
-                array_push($arr,$depart_id);
-
-                // 只能查看自己和自己子级的保护客户和签单客户
-                $where_usr_id = ['depart_id'=>['in',$arr]];
-            }
 
             switch ($status){
                 case 'protect':                 //保护中
@@ -129,11 +116,13 @@ class Protector extends Backend
                 case 'giveup':                 //已放弃
                     $total = $this->model
                         ->where('status',$this->status['GIVEUP'])
+                        ->where($where_usr_id)
                         ->where($where)
                         ->order($sort, $order)
                         ->count();
                     $list = $this->model
                         ->where('status',$this->status['GIVEUP'])
+                        ->where($where_usr_id)
                         ->where($where)
                         ->order($sort, $order)
                         ->limit($offset, $limit)

+ 23 - 0
application/admin/model/Protector.php

@@ -2,7 +2,9 @@
 
 namespace app\admin\model;
 
+use think\Db;
 use think\Model;
+use think\Session;
 
 class Protector extends Model
 {
@@ -110,7 +112,28 @@ class Protector extends Model
     }
 
 
+    // 获取角色权限where条件
+    public static function getGroupWhere()
+    {
+
+        $rules = AuthGroup::getRulesByGroupId(Session::get('admin')['depart_id']);
+
+        if($rules == '*'){
+            $where = false;      // 管理员可以看到所有
+        } else {
+            $auth_group = Db::table('auth_group')->select();        // 所有组别
+            $depart_id = Session::get('admin')['depart_id'];        // 所属组别
+
+            // 获取所有子级部门
+            $arr = AuthGroup::getSubs($auth_group,$depart_id);
+            array_push($arr,$depart_id);
 
+            // 只能查看自己和自己子级的保护客户和签单客户
+            $where = ['depart_id'=>['in',$arr]];
+        }
+
+        return $where;
+    }
 
 
 

+ 1 - 1
public/assets/js/backend/protector.js

@@ -36,7 +36,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'selectpage', 'bootst
                                 return row.usr_depart;
                         }},
                         {field: 'pro_date', title: __('Pro_date'), operate:'RANGE', addclass:'datetimerange'},
-                        {field: 'ex_date', title: __('Ex_date'),searchable: false, visible: status == 'contract' ? false : true,operate:'RANGE', addclass:'datetimerange'},
+                        {field: 'ex_date', title: __('Ex_date'),searchable: false, visible: status == 'contract' ? false : true, operate:'RANGE', addclass:'datetimerange'},
                         {field: 'again_date', title: '签单到期时间',searchable: false, visible: status == 'contract' ? true : false},
                         {field: 'operate', title: __('Operate'),searchable: false,
                             table: table,