ソースを参照

对当前已经存在的字段进行数据权限限制

liugc 1 年間 前
コミット
23c4816dde

+ 20 - 0
app/adminapi/lists/master_commission/MasterWorkerCommissionNoticeLists.php

@@ -69,7 +69,25 @@ class MasterWorkerCommissionNoticeLists extends BaseAdminDataLists implements Li
         }
         return $where;
     }
+    /**
+     * 获取数据权限
+     * $this->adminInfo['data_rules']
+     * province city admin_id sale_group_id sale_id  property_head_id
+     */
+    public function queryDataWhere(){
+        $where = [];
+        $data_rules = $this->adminInfo['data_rules'];
+        if (isset($data_rules['province']) && !empty($data_rules['province'])) {
+            $where[] = ['sw.province','in' ,$data_rules['province']];
+            $where[] = ['mw.province','in' ,$data_rules['province']];
 
+        }
+        if (isset($data_rules['city']) && !empty($data_rules['city'])) {
+            $where[] = ['sw.city','in' ,$data_rules['city']];
+            $where[] = ['mw.city','in' ,$data_rules['city']];
+        }
+        return $where;
+    }
     /**
      * @notes 获取列表
      * @return array
@@ -92,6 +110,7 @@ class MasterWorkerCommissionNoticeLists extends BaseAdminDataLists implements Li
             ])
             ->where($this->searchWhere)
             ->where($this->queryWhere())
+            ->where($this->queryDataWhere())
             ->group('n.master_worker_id, n.id')
             ->limit($this->limitOffset, $this->limitLength)
             ->select()->toArray();
@@ -118,6 +137,7 @@ class MasterWorkerCommissionNoticeLists extends BaseAdminDataLists implements Li
             ])
             ->where($this->searchWhere)
             ->where($this->queryWhere())
+            ->where($this->queryDataWhere())
             ->group('n.master_worker_id, n.id')
             ->count();
     }

+ 18 - 1
app/adminapi/lists/master_worker/MasterWorkerLists.php

@@ -51,7 +51,22 @@ class MasterWorkerLists extends BaseAdminDataLists implements ListsSearchInterfa
             //'in' => ['mw.time_period']
         ];
     }
-
+    /**
+     * 获取数据权限
+     * $this->adminInfo['data_rules']
+     * province city admin_id sale_group_id sale_id  property_head_id
+     */
+    public function queryDataWhere(){
+        $where = [];
+        $data_rules = $this->adminInfo['data_rules'];
+        if (isset($data_rules['province']) && !empty($data_rules['province'])) {
+            $where[] = ['mw.province','in' ,$data_rules['province']];
+        }
+        if (isset($data_rules['city']) && !empty($data_rules['city'])) {
+            $where[] = ['mw.city','in' ,$data_rules['city']];
+        }
+        return $where;
+    }
     public function queryWhere(){
         $where = [];
         $where[] = ['mw.team_role','in',[0,1]];
@@ -154,6 +169,7 @@ class MasterWorkerLists extends BaseAdminDataLists implements ListsSearchInterfa
             ->join('master_worker_register mwr', 'mwr.worker_id = mw.id')
             ->where($this->searchWhere)
             ->where($queryWhere)
+            ->where($this->queryDataWhere())
             ->field($fields)
             ->limit($this->limitOffset, $this->limitLength)
             ->having($having)
@@ -199,6 +215,7 @@ class MasterWorkerLists extends BaseAdminDataLists implements ListsSearchInterfa
             ->join('master_worker_register mwr', 'mwr.worker_id = mw.id')
             ->where($this->searchWhere)
             ->where($queryWhere)
+            ->where($this->queryDataWhere())
             ->field($fields)
             ->having($having)
             ->select()->toArray());

+ 18 - 0
app/adminapi/lists/master_worker/MasterWorkerServiceOrderLists.php

@@ -88,7 +88,25 @@ class MasterWorkerServiceOrderLists extends BaseAdminDataLists implements ListsS
         return $where;
     }
 
+    /**
+     * 获取数据权限
+     * $this->adminInfo['data_rules']
+     * province city admin_id sale_group_id sale_id  property_head_id
+     */
+    public function queryDataWhere(){
+        $where = [];
+        $data_rules = $this->adminInfo['data_rules'];
+        if (isset($data_rules['province']) && !empty($data_rules['province'])) {
+            $where[] = ['a.province','in' ,$data_rules['province']];
+            $where[] = ['b.province','in' ,$data_rules['province']];
 
+        }
+        if (isset($data_rules['city']) && !empty($data_rules['city'])) {
+            $where[] = ['a.city','in' ,$data_rules['city']];
+            $where[] = ['b.city','in' ,$data_rules['city']];
+        }
+        return $where;
+    }
     /**
      * @notes 获取列表
      * @return array

+ 18 - 2
app/adminapi/lists/master_worker_register/MasterWorkerRegisterLists.php

@@ -43,7 +43,22 @@ class MasterWorkerRegisterLists extends BaseAdminDataLists implements ListsSearc
             '<=' => ['age'],
         ];
     }
-
+    /**
+     * 获取数据权限
+     * $this->adminInfo['data_rules']
+     * province city admin_id sale_group_id sale_id  property_head_id
+     */
+    public function queryDataWhere(){
+        $where = [];
+        $data_rules = $this->adminInfo['data_rules'];
+        if (isset($data_rules['province']) && !empty($data_rules['province'])) {
+            $where[] = ['province','in' ,$data_rules['province']];
+        }
+        if (isset($data_rules['city']) && !empty($data_rules['city'])) {
+            $where[] = ['city','in' ,$data_rules['city']];
+        }
+        return $where;
+    }
     public function queryWhere(){
         $where = [];
         if(isset($this->params['range_update_time']) && !empty($this->params['range_update_time'])){
@@ -64,6 +79,7 @@ class MasterWorkerRegisterLists extends BaseAdminDataLists implements ListsSearc
     public function lists(): array
     {
         return MasterWorkerRegister::where($this->searchWhere)->where($this->queryWhere())
+            ->where($this->queryDataWhere())
             ->field(['*'])
             ->limit($this->limitOffset, $this->limitLength)
             ->order(['id' => 'desc'])
@@ -80,7 +96,7 @@ class MasterWorkerRegisterLists extends BaseAdminDataLists implements ListsSearc
      */
     public function count(): int
     {
-        return MasterWorkerRegister::where($this->searchWhere)->where($this->queryWhere())->count();
+        return MasterWorkerRegister::where($this->searchWhere)->where($this->queryWhere())->where($this->queryDataWhere())->count();
     }
 
 }

+ 31 - 2
app/adminapi/lists/orders/RechargeOrderLists.php

@@ -18,6 +18,7 @@ namespace app\adminapi\lists\orders;
 use app\adminapi\lists\BaseAdminDataLists;
 use app\common\model\orders\RechargeOrder;
 use app\common\lists\ListsSearchInterface;
+use app\common\model\property\PropertyOrder;
 use think\db\Query;
 
 
@@ -28,7 +29,34 @@ use think\db\Query;
  */
 class RechargeOrderLists extends BaseAdminDataLists implements ListsSearchInterface
 {
-
+    /**
+     * 获取数据权限
+     * $this->adminInfo['data_rules']
+     * province city admin_id sale_group_id sale_id  property_head_id
+     */
+    public function queryDataWhere(){
+        $where = [];
+        $data_rules = $this->adminInfo['data_rules'];
+        /*if (isset($data_rules['province']) && !empty($data_rules['province'])) {
+            $where[] = ['province','in' ,$data_rules['province']];
+        }
+        if (isset($data_rules['city']) && !empty($data_rules['city'])) {
+            $where[] = ['city','in' ,$data_rules['city']];
+        }*/
+        if (isset($data_rules['sale_group_id']) && !empty($data_rules['sale_group_id'])) {
+            $work_ids = PropertyOrder::where('sale_group_id','in',$data_rules['sale_group_id'])->column('work_id')??[];
+            $where[] = ['work_id','in' ,$work_ids];
+        }
+        if (isset($data_rules['sale_id']) && !empty($data_rules['sale_id'])) {
+            $work_ids = PropertyOrder::where('sale_id','in',$data_rules['sale_id'])->column('work_id')??[];
+            $where[] = ['work_id','in' ,$work_ids];
+        }
+        if (isset($data_rules['property_head_id']) && !empty($data_rules['property_head_id'])) {
+            $work_ids = PropertyOrder::where('property_head_id','in',$data_rules['property_head_id'])->column('work_id')??[];
+            $where[] = ['work_id','in' ,$work_ids];
+        }
+        return $where;
+    }
 
     /**
      * @notes 设置搜索条件
@@ -72,6 +100,7 @@ class RechargeOrderLists extends BaseAdminDataLists implements ListsSearchInterf
         return RechargeOrder::with(['orderGoods'=>function(Query $query){
             $query->field('id,sn,goods_id,goods_name,goods_image,goods_number,good_unit,goods_size,goods_type,goods_brand,base_service_fee,service_total,service_fee')->order(['id'=>'desc']);
         }])->where($this->searchWhere)
+            ->where($this->queryDataWhere())
             ->where($this->queryWhere())
             ->field(['id', 'sn', 'work_id', 'user_id', 'payment_type', 'pay_sn', 'pay_way', 'pay_status', 'pay_time', 'order_total', 'order_amount', 'order_terminal', 'transaction_id', 'refund_status', 'refund_transaction_id', 'create_time', 'update_time'])
             ->limit($this->limitOffset, $this->limitLength)
@@ -89,7 +118,7 @@ class RechargeOrderLists extends BaseAdminDataLists implements ListsSearchInterf
      */
     public function count(): int
     {
-        return RechargeOrder::where($this->searchWhere)->where($this->queryWhere())->count();
+        return RechargeOrder::where($this->searchWhere)->where($this->queryWhere())->where($this->queryDataWhere())->count();
     }
 
 }

+ 29 - 3
app/adminapi/lists/property/PropertyHeadLists.php

@@ -18,6 +18,7 @@ namespace app\adminapi\lists\property;
 use app\adminapi\lists\BaseAdminDataLists;
 use app\common\model\property\PropertyHead;
 use app\common\lists\ListsSearchInterface;
+use app\common\model\sale\Sale;
 
 
 /**
@@ -43,7 +44,32 @@ class PropertyHeadLists extends BaseAdminDataLists implements ListsSearchInterfa
         ];
     }
 
-
+    /**
+     * 获取数据权限
+     * $this->adminInfo['data_rules']
+     * province city admin_id sale_group_id sale_id  property_head_id
+     */
+    public function queryDataWhere(){
+        $where = [];
+        $data_rules = $this->adminInfo['data_rules'];
+        /*if (isset($data_rules['province']) && !empty($data_rules['province'])) {
+            $where[] = ['province','in' ,$data_rules['province']];
+        }
+        if (isset($data_rules['city']) && !empty($data_rules['city'])) {
+            $where[] = ['city','in' ,$data_rules['city']];
+        }*/
+        if (isset($data_rules['sale_group_id']) && !empty($data_rules['sale_group_id'])) {
+            $sale_ids = Sale::where('sale_group_id','in',$data_rules['sale_group_id'])->column('id')??[];
+            $where[] = ['sale_id','in' ,$sale_ids];
+        }
+        if (isset($data_rules['sale_id']) && !empty($data_rules['sale_id'])) {
+            $where[] = ['sale_id','in' ,$data_rules['sale_id']];
+        }
+        if (isset($data_rules['property_head_id']) && !empty($data_rules['property_head_id'])) {
+            $where[] = ['id','in' ,$data_rules['property_head_id']];
+        }
+        return $where;
+    }
     /**
      * @notes 获取列表
      * @return array
@@ -55,7 +81,7 @@ class PropertyHeadLists extends BaseAdminDataLists implements ListsSearchInterfa
      */
     public function lists(): array
     {
-        return PropertyHead::where($this->searchWhere)
+        return PropertyHead::where($this->searchWhere)->where($this->queryDataWhere())
             ->field(['id', 'property_name', 'village_name', 'address', 'head_name', 'head_mobile', 'ratio', 'head_bank_card', 'remark', 'user_id', 'all_profit_amount', 'surplus_profit_amount', 'extract_profit_amount','lon', 'lat','bind_date','sale_type','sale_id','is_cooperate'])
             ->limit($this->limitOffset, $this->limitLength)
             ->order(['id' => 'desc'])
@@ -72,7 +98,7 @@ class PropertyHeadLists extends BaseAdminDataLists implements ListsSearchInterfa
      */
     public function count(): int
     {
-        return PropertyHead::where($this->searchWhere)->count();
+        return PropertyHead::where($this->searchWhere)->where($this->queryDataWhere())->count();
     }
 
 }

+ 28 - 2
app/adminapi/lists/property/PropertyOrderLists.php

@@ -20,6 +20,7 @@ use app\common\model\property\PropertyHead;
 use app\common\model\property\PropertyOrder;
 use app\common\lists\ListsSearchInterface;
 use app\common\model\property\PropertyUser;
+use app\common\model\sale\Sale;
 
 
 /**
@@ -57,7 +58,31 @@ class PropertyOrderLists extends BaseAdminDataLists implements ListsSearchInterf
         }
         return $where;
     }
-
+    /**
+     * 获取数据权限
+     * $this->adminInfo['data_rules']
+     * province city admin_id sale_group_id sale_id  property_head_id
+     */
+    public function queryDataWhere(){
+        $where = [];
+        $data_rules = $this->adminInfo['data_rules'];
+        /*if (isset($data_rules['province']) && !empty($data_rules['province'])) {
+            $where[] = ['province','in' ,$data_rules['province']];
+        }
+        if (isset($data_rules['city']) && !empty($data_rules['city'])) {
+            $where[] = ['city','in' ,$data_rules['city']];
+        }*/
+        if (isset($data_rules['sale_group_id']) && !empty($data_rules['sale_group_id'])) {
+            $where[] = ['sale_group_id','in' ,$data_rules['sale_group_id']];
+        }
+        if (isset($data_rules['sale_id']) && !empty($data_rules['sale_id'])) {
+            $where[] = ['sale_id','in' ,$data_rules['sale_id']];
+        }
+        if (isset($data_rules['property_head_id']) && !empty($data_rules['property_head_id'])) {
+            $where[] = ['property_head_id','in' ,$data_rules['property_head_id']];
+        }
+        return $where;
+    }
     /**
      * @notes 获取列表
      * @return array
@@ -71,6 +96,7 @@ class PropertyOrderLists extends BaseAdminDataLists implements ListsSearchInterf
     {
         return PropertyOrder::with(['propertyHead','propertyUser','propertyOrderCustomerLog'])->where($this->searchWhere)->where($this->queryWhere())
             ->field(['id', 'property_head_id', 'property_user_id', 'remark', 'order_status', 'work_id','address','create_time'])
+            ->where($this->queryDataWhere())
             ->limit($this->limitOffset, $this->limitLength)
             ->order(['id' => 'desc'])
             ->select()
@@ -86,7 +112,7 @@ class PropertyOrderLists extends BaseAdminDataLists implements ListsSearchInterf
      */
     public function count(): int
     {
-        return PropertyOrder::where($this->searchWhere)->where($this->queryWhere())->count();
+        return PropertyOrder::where($this->searchWhere)->where($this->queryWhere())->where($this->queryDataWhere())->count();
     }
 
 }

+ 27 - 0
app/adminapi/lists/sale/PropertyHeadAnalysisLists.php

@@ -54,6 +54,31 @@ class PropertyHeadAnalysisLists extends BaseAdminDataLists implements ListsSearc
         }
         return $where;
     }
+    /**
+     * 获取数据权限
+     * $this->adminInfo['data_rules']
+     * province city admin_id sale_group_id sale_id  property_head_id
+     */
+    public function queryDataWhere(){
+        $where = [];
+        $data_rules = $this->adminInfo['data_rules'];
+        if (isset($data_rules['province']) && !empty($data_rules['province'])) {
+            $where[] = ['b.province','in' ,$data_rules['province']];
+        }
+        if (isset($data_rules['city']) && !empty($data_rules['city'])) {
+            $where[] = ['b.city','in' ,$data_rules['city']];
+        }
+        if (isset($data_rules['sale_group_id']) && !empty($data_rules['sale_group_id'])) {
+            $where[] = ['a.sale_group_id','in' ,$data_rules['sale_group_id']];
+        }
+        if (isset($data_rules['sale_id']) && !empty($data_rules['sale_id'])) {
+            $where[] = ['a.sale_id','in' ,$data_rules['sale_id']];
+        }
+        if (isset($data_rules['property_head_id']) && !empty($data_rules['property_head_id'])) {
+            $where[] = ['a.property_head_id','in' ,$data_rules['property_head_id']];
+        }
+        return $where;
+    }
     /**
      * @notes 获取列表
      * @return array
@@ -76,6 +101,7 @@ class PropertyHeadAnalysisLists extends BaseAdminDataLists implements ListsSearc
             ->where('a.sale_type', 'in', [1, 2])
             ->where($this->searchWhere)
             ->where($this->queryWhere())
+            ->where($this->queryDataWhere())
             ->where('b.service_status', 3)
             ->group('a.property_head_id')
             ->limit($this->limitOffset, $this->limitLength)
@@ -100,6 +126,7 @@ class PropertyHeadAnalysisLists extends BaseAdminDataLists implements ListsSearc
             ])
             ->where('a.sale_type', 'in', [1, 2])
             ->where('a.order_status', 3)
+            ->where($this->queryDataWhere())
             ->group('a.property_head_id')
             ->count();
     }

+ 27 - 1
app/adminapi/lists/sale/SaleAnalysisLists.php

@@ -54,7 +54,31 @@ class SaleAnalysisLists extends BaseAdminDataLists implements ListsSearchInterfa
         }
         return $where;
     }
-
+    /**
+     * 获取数据权限
+     * $this->adminInfo['data_rules']
+     * province city admin_id sale_group_id sale_id  property_head_id
+     */
+    public function queryDataWhere(){
+        $where = [];
+        $data_rules = $this->adminInfo['data_rules'];
+        if (isset($data_rules['province']) && !empty($data_rules['province'])) {
+            $where[] = ['b.province','in' ,$data_rules['province']];
+        }
+        if (isset($data_rules['city']) && !empty($data_rules['city'])) {
+            $where[] = ['b.city','in' ,$data_rules['city']];
+        }
+        if (isset($data_rules['sale_group_id']) && !empty($data_rules['sale_group_id'])) {
+            $where[] = ['a.sale_group_id','in' ,$data_rules['sale_group_id']];
+        }
+        if (isset($data_rules['sale_id']) && !empty($data_rules['sale_id'])) {
+            $where[] = ['a.sale_id','in' ,$data_rules['sale_id']];
+        }
+        if (isset($data_rules['property_head_id']) && !empty($data_rules['property_head_id'])) {
+            $where[] = ['a.property_head_id','in' ,$data_rules['property_head_id']];
+        }
+        return $where;
+    }
     /**
      * @notes 获取列表
      * @return array
@@ -75,6 +99,7 @@ class SaleAnalysisLists extends BaseAdminDataLists implements ListsSearchInterfa
             ])
             ->where($this->searchWhere)
             ->where($this->queryWhere())
+            ->where($this->queryDataWhere())
             ->where('a.sale_type', 'in', [1, 2])
             //->where('a.order_status', 3)
             ->where('b.service_status', 3)
@@ -102,6 +127,7 @@ class SaleAnalysisLists extends BaseAdminDataLists implements ListsSearchInterfa
                                 SUM(CASE WHEN a.sale_type = 2 THEN b.work_amount ELSE 0 END) AS amount_sales_individual")
             ])
             ->where($this->queryWhere())
+            ->where($this->queryDataWhere())
             ->where('a.sale_type', 'in', [1, 2])
             ->where('a.order_status', 3)
             ->group('a.sale_id')

+ 27 - 0
app/adminapi/lists/sale/SaleGroupAnalysisLists.php

@@ -54,6 +54,31 @@ class SaleGroupAnalysisLists extends BaseAdminDataLists implements ListsSearchIn
         }
         return $where;
     }
+    /**
+     * 获取数据权限
+     * $this->adminInfo['data_rules']
+     * province city admin_id sale_group_id sale_id  property_head_id
+     */
+    public function queryDataWhere(){
+        $where = [];
+        $data_rules = $this->adminInfo['data_rules'];
+        if (isset($data_rules['province']) && !empty($data_rules['province'])) {
+            $where[] = ['b.province','in' ,$data_rules['province']];
+        }
+        if (isset($data_rules['city']) && !empty($data_rules['city'])) {
+            $where[] = ['b.city','in' ,$data_rules['city']];
+        }
+        if (isset($data_rules['sale_group_id']) && !empty($data_rules['sale_group_id'])) {
+            $where[] = ['a.sale_group_id','in' ,$data_rules['sale_group_id']];
+        }
+        if (isset($data_rules['sale_id']) && !empty($data_rules['sale_id'])) {
+            $where[] = ['a.sale_id','in' ,$data_rules['sale_id']];
+        }
+        if (isset($data_rules['property_head_id']) && !empty($data_rules['property_head_id'])) {
+            $where[] = ['a.property_head_id','in' ,$data_rules['property_head_id']];
+        }
+        return $where;
+    }
     /**
      * @notes 获取列表
      * @return array
@@ -75,6 +100,7 @@ class SaleGroupAnalysisLists extends BaseAdminDataLists implements ListsSearchIn
             ->where('a.sale_type', 'in', [1, 2])
             ->where($this->searchWhere)
             ->where($this->queryWhere())
+            ->where($this->queryDataWhere())
             ->where('b.service_status', 3)
             ->group('a.sale_group_id')
             ->limit($this->limitOffset, $this->limitLength)
@@ -99,6 +125,7 @@ class SaleGroupAnalysisLists extends BaseAdminDataLists implements ListsSearchIn
             ])
             ->where('a.sale_type', 'in', [1, 2])
             ->where('a.order_status', 3)
+            ->where($this->queryDataWhere())
             ->group('a.sale_group_id')
             ->count();
     }

+ 21 - 2
app/adminapi/lists/sale/SaleGroupLists.php

@@ -43,7 +43,25 @@ class SaleGroupLists extends BaseAdminDataLists implements ListsSearchInterface
         ];
     }
 
-
+    /**
+     * 获取数据权限
+     * $this->adminInfo['data_rules']
+     * province city admin_id sale_group_id sale_id  property_head_id
+     */
+    public function queryDataWhere(){
+        $where = [];
+        $data_rules = $this->adminInfo['data_rules'];
+        /*if (isset($data_rules['province']) && !empty($data_rules['province'])) {
+            $where[] = ['province','in' ,$data_rules['province']];
+        }
+        if (isset($data_rules['city']) && !empty($data_rules['city'])) {
+            $where[] = ['city','in' ,$data_rules['city']];
+        }*/
+        if (isset($data_rules['sale_group_id']) && !empty($data_rules['sale_group_id'])) {
+            $where[] = ['sale_group_id','in' ,$data_rules['sale_group_id']];
+        }
+        return $where;
+    }
     /**
      * @notes 获取列表
      * @return array
@@ -57,6 +75,7 @@ class SaleGroupLists extends BaseAdminDataLists implements ListsSearchInterface
     {
         return SaleGroup::where($this->searchWhere)
             ->field(['id', 'sale_name'])
+            ->where($this->queryDataWhere())
             ->limit($this->limitOffset, $this->limitLength)
             ->order(['id' => 'desc'])
             ->select()
@@ -72,7 +91,7 @@ class SaleGroupLists extends BaseAdminDataLists implements ListsSearchInterface
      */
     public function count(): int
     {
-        return SaleGroup::where($this->searchWhere)->count();
+        return SaleGroup::where($this->searchWhere)->where($this->queryDataWhere())->count();
     }
 
 }

+ 24 - 2
app/adminapi/lists/sale/SaleLists.php

@@ -43,7 +43,28 @@ class SaleLists extends BaseAdminDataLists implements ListsSearchInterface
         ];
     }
 
-
+    /**
+     * 获取数据权限
+     * $this->adminInfo['data_rules']
+     * province city admin_id sale_group_id sale_id  property_head_id
+     */
+    public function queryDataWhere(){
+        $where = [];
+        $data_rules = $this->adminInfo['data_rules'];
+        /*if (isset($data_rules['province']) && !empty($data_rules['province'])) {
+            $where[] = ['province','in' ,$data_rules['province']];
+        }
+        if (isset($data_rules['city']) && !empty($data_rules['city'])) {
+            $where[] = ['city','in' ,$data_rules['city']];
+        }*/
+        if (isset($data_rules['sale_group_id']) && !empty($data_rules['sale_group_id'])) {
+            $where[] = ['sale_group_id','in' ,$data_rules['sale_group_id']];
+        }
+        if (isset($data_rules['sale_id']) && !empty($data_rules['sale_id'])) {
+            $where[] = ['sale_id','in' ,$data_rules['sale_id']];
+        }
+        return $where;
+    }
     /**
      * @notes 获取列表
      * @return array
@@ -56,6 +77,7 @@ class SaleLists extends BaseAdminDataLists implements ListsSearchInterface
     public function lists(): array
     {
         return Sale::with(['saleGroupInfo'])->where($this->searchWhere)
+            ->where($this->queryDataWhere())
             ->field(['id', 'sale_group_id', 'sale_name', 'mobile'])
             ->limit($this->limitOffset, $this->limitLength)
             ->order(['id' => 'desc'])
@@ -72,7 +94,7 @@ class SaleLists extends BaseAdminDataLists implements ListsSearchInterface
      */
     public function count(): int
     {
-        return Sale::where($this->searchWhere)->count();
+        return Sale::where($this->searchWhere)->where($this->queryDataWhere())->count();
     }
 
 }

+ 31 - 2
app/adminapi/lists/works/ServiceWorkLists.php

@@ -18,6 +18,7 @@ namespace app\adminapi\lists\works;
 use app\adminapi\lists\BaseAdminDataLists;
 use app\common\model\goods_category\GoodsCategory;
 use app\common\model\master_worker\MasterWorker;
+use app\common\model\property\PropertyOrder;
 use app\common\model\works\ServiceWork;
 use app\common\lists\ListsSearchInterface;
 use think\db\Query;
@@ -32,7 +33,34 @@ use think\facade\Log;
 class ServiceWorkLists extends BaseAdminDataLists implements ListsSearchInterface
 {
 
-
+    /**
+     * 获取数据权限
+     * $this->adminInfo['data_rules']
+     * province city admin_id sale_group_id sale_id  property_head_id
+     */
+    public function queryDataWhere(){
+        $where = [];
+        $data_rules = $this->adminInfo['data_rules'];
+        if (isset($data_rules['province']) && !empty($data_rules['province'])) {
+            $where[] = ['province','in' ,$data_rules['province']];
+        }
+        if (isset($data_rules['city']) && !empty($data_rules['city'])) {
+            $where[] = ['city','in' ,$data_rules['city']];
+        }
+        if (isset($data_rules['sale_group_id']) && !empty($data_rules['sale_group_id'])) {
+            $work_ids = PropertyOrder::where('sale_group_id','in',$data_rules['sale_group_id'])->column('work_id')??[];
+            $where[] = ['id','in' ,$work_ids];
+        }
+        if (isset($data_rules['sale_id']) && !empty($data_rules['sale_id'])) {
+            $work_ids = PropertyOrder::where('sale_id','in',$data_rules['sale_id'])->column('work_id')??[];
+            $where[] = ['id','in' ,$work_ids];
+        }
+        if (isset($data_rules['property_head_id']) && !empty($data_rules['property_head_id'])) {
+            $work_ids = PropertyOrder::where('property_head_id','in',$data_rules['property_head_id'])->column('work_id')??[];
+            $where[] = ['id','in' ,$work_ids];
+        }
+        return $where;
+    }
     /**
      * @notes 设置搜索条件
      * @return \string[][]
@@ -140,6 +168,7 @@ class ServiceWorkLists extends BaseAdminDataLists implements ListsSearchInterfac
         ])
             ->where($this->searchWhere)
             ->where($this->queryWhere())
+            ->where($this->queryDataWhere())
             ->field(['id', 'work_sn', 'real_name', 'mobile', 'address', 'title', 'category_type', 'goods_category_ids', 'goods_category_id', 'base_service_fee', 'service_fee', 'work_status','work_pay_status', 'service_status', 'dispatch_time', 'receive_time', 'appointment_time', 'finished_images', 'finished_time', 'master_worker_id', 'work_amount', 'work_type', 'create_time', 'update_time','lon', 'lat','appoint_approval','refund_approval','finally_door_time'])
             ->limit($this->limitOffset, $this->limitLength)
             ->order(['id' => 'desc'])
@@ -156,7 +185,7 @@ class ServiceWorkLists extends BaseAdminDataLists implements ListsSearchInterfac
      */
     public function count(): int
     {
-        return ServiceWork::where($this->searchWhere)->where($this->queryWhere())->count();
+        return ServiceWork::where($this->searchWhere)->where($this->queryWhere())->where($this->queryDataWhere())->count();
     }
 
 }

+ 9 - 1
app/adminapi/logic/auth/AdminLogic.php

@@ -25,6 +25,7 @@ use app\common\model\auth\AdminRole;
 use app\common\model\auth\AdminSession;
 use app\common\cache\AdminTokenCache;
 use app\common\model\dept\Jobs;
+use app\common\model\jobs_rules\JobsRules;
 use app\common\service\FileService;
 use think\facade\Config;
 use think\facade\Db;
@@ -346,6 +347,7 @@ class AdminLogic extends BaseLogic
     public static function getDataPermissions($adminId) : array
     {
         $jobsIds = AdminJobs::where('admin_id', $adminId)->column('jobs_id');
+        $jobs_rules = JobsRules::column('rule_term','id');
         $rules = [];
         if (!empty($jobsIds)) {
             $list = Jobs::whereIn('id', $jobsIds)->where('status', YesNoEnum::YES)->select()->toArray();
@@ -360,7 +362,13 @@ class AdminLogic extends BaseLogic
                     }
                 }
             }
-            $rules = JobsRulesLogic::ruleSelfValue($adminId,$rules);
+
+            //$rules = JobsRulesLogic::ruleSelfValue($adminId,$rules);
+
+            foreach ($rules as $rule_id => $value) {
+                $rules[$jobs_rules[$rule_id]] = $value;
+                unset($rules[$rule_id]);
+            }
         }
         return $rules??[];
     }

+ 0 - 21
app/adminapi/logic/jobs_rules/JobsRulesLogic.php

@@ -132,36 +132,15 @@ class JobsRulesLogic extends BaseLogic
         switch ($params['id']) {
             case 1:
                 $result = TableDataLogic::provinces();
-                // 数组的开始位置添加一个数组
-                array_unshift($result, [
-                    "id" => 'self',
-                    "name" => "管理员所属",
-                    "value" => "self",
-                    "type_value" => "data_table_provinces",
-                ]);
                 break;
             case 2:
                 $result = TableDataLogic::citys($province_ids);
-                // 数组的开始位置添加一个数组
-                array_unshift($result, [
-                    "id" => 'self',
-                    "name" => "管理员所属",
-                    "value" => "self",
-                    "type_value" => "data_table_citys",
-                ]);
                 break;
             case 3:
                 $result = TableDataLogic::saleGroup();
                 break;
             case 4:
                 $result = TableDataLogic::admins();
-                // 数组的开始位置添加一个数组
-                array_unshift($result, [
-                    "id" => 'self',
-                    "name" => "管理员所属",
-                    "value" => "self",
-                    "type_value" => "data_table_admins",
-                ]);
                 break;
             case 5:
                 $result = TableDataLogic::propertyHead();