liugc 1 год назад
Родитель
Сommit
0978c0aaea

+ 3 - 1
app/adminapi/logic/works/ServiceWorkLogic.php

@@ -381,7 +381,9 @@ class ServiceWorkLogic extends BaseLogic
         ])->append(['id','work_status_text','service_status_text'])
             ->where($work_where)
             ->findOrEmpty()->toArray();
-
+        if(isset($params['user_id']) && $params['user_id'] && ($params['user_id'] != $result['master_worker_id'])){
+            throw new \Exception('您没有权限操作该工单');
+        }
         //工程师工单按钮状态
         $work_service_status = 0;
         $work_service_status_text = '待派单';

+ 15 - 10
app/workerapi/controller/WorksController.php

@@ -15,6 +15,7 @@ use app\workerapi\lists\ServiceWorkSparePartLists;
 use app\workerapi\lists\SparePartLists;
 use app\workerapi\validate\ServiceWorkValidate;
 use app\workerapi\validate\GoodsFeeStandardsValidate;
+use Exception;
 
 /**
  * 工单系统
@@ -95,17 +96,21 @@ class WorksController extends BaseApiController
      */
     public function detail()
     {
-        $params = (new ServiceWorkValidate())->goCheck('detail',[
-            'user_id' => $this->userId,
-        ]);
-        if(empty($params['id']) && empty($params['work_sn'])){
-            $this->fail('参数错误');
+        try {
+            $params = (new ServiceWorkValidate())->goCheck('detail',[
+                'user_id' => $this->userId,
+            ]);
+            if(empty($params['id']) && empty($params['work_sn'])){
+                $this->fail('参数错误');
+            }
+            $result = ServiceWorkLogic::detail($params);
+            if (false === $result) {
+                return $this->fail(ServiceWorkLogic::getError());
+            }
+            return $this->data($result);
+        } catch (Exception $e) {
+            return $this->fail($e->getMessage());
         }
-        $result = ServiceWorkLogic::detail($params);
-        if (false === $result) {
-            return $this->fail(ServiceWorkLogic::getError());
-        }
-        return $this->data($result);
     }
 
     /**

+ 10 - 1
app/workerapi/lists/GoodsCategoryLists.php

@@ -3,6 +3,7 @@ namespace app\workerapi\lists;
 
 use app\common\lists\ListsSearchInterface;
 use app\common\model\goods_category\GoodsCategory;
+use app\common\model\master_worker\MasterWorker;
 
 /**
  * GoodsCategory列表
@@ -26,7 +27,14 @@ class GoodsCategoryLists extends BaseWorkerDataLists implements ListsSearchInter
 
         ];
     }
-
+    public function queryWhere(){
+        $where = [];
+        if(!empty($this->userId)){
+            $ids = explode(',', MasterWorker::where('id', $this->userId)->value('category_ids'));
+            $ids && $where[] = ['id', 'in', $ids];
+        }
+        return $where;
+    }
 
     /**
      * @notes 获取列表
@@ -40,6 +48,7 @@ class GoodsCategoryLists extends BaseWorkerDataLists implements ListsSearchInter
     public function lists(): array
     {
         $lists = GoodsCategory::where($this->searchWhere)
+            //->where($this->queryWhere())
             ->field(['id', 'pid' ,'picture', 'name'])
             ->order(['weigh' => 'desc'])
             ->select()