Ver código fonte

按货主权限限制可见记录

LD 5 anos atrás
pai
commit
01b7667349

+ 15 - 14
app/Http/Controllers/WaybillsController.php

@@ -105,18 +105,19 @@ class WaybillsController extends Controller
     {
         if(!Gate::allows('运输管理-查询')){ return redirect(url('/'));  }
         $data=$request->input();
+        $carries = Carrier::get();
+        $owners = Owner::filterAuthorities()->get();
+        $ownerIds = $owners->map(function ($owner){
+            return $owner['id'];
+        })->all();
+        $waybills = $this->getWaybills();
+        $waybills=$waybills->whereIn('owner_id',$ownerIds);
         if ($data != null ) {
-            $waybills = $this->getWaybills();
             $waybills=$this->conditionQuery($request,$waybills);
-            $carries = Carrier::get();
-            $owners = Owner::filterAuthorities()->get();
-            return view('waybill.index', ['waybills' => $waybills, 'carriers' => $carries, 'owners' => $owners,'filterData'=>$data,'uriType'=>'']);
         } else {
-            $waybills = $this->getWaybills()->paginate(50);
-            $carries = Carrier::get();
-            $owners = Owner::filterAuthorities()->get();
-            return view('waybill.index', ['waybills' => $waybills, 'carriers' => $carries, 'owners' => $owners,'filterData'=>$data,'uriType'=>'']);
+            $waybills = $waybills->paginate(50);
         }
+        return view('waybill.index', ['waybills' => $waybills, 'carriers' => $carries, 'owners' => $owners,'filterData'=>$data,'uriType'=>'']);
     }
 
     public function indexZF(Request $request){
@@ -230,16 +231,16 @@ class WaybillsController extends Controller
         $waybill=Waybill::find($id);
 
         if (!$waybill['warehouse_weight']&&$waybill['warehouse_weight_unit_id']){
-                    unset($waybill['warehouse_weight_unit_id']);
+            unset($waybill['warehouse_weight_unit_id']);
         }
         if (!$waybill['warehouse_weight_other']&&$waybill['warehouse_weight_unit_id_other']){
-                    unset($waybill['warehouse_weight_unit_id_other']);
+            unset($waybill['warehouse_weight_unit_id_other']);
         }
         if (!$waybill['carrier_weight']&&$waybill['carrier_weight_unit_id']){
-                    unset($waybill['carrier_weight_unit_id']);
+            unset($waybill['carrier_weight_unit_id']);
         }
         if (!$waybill['carrier_weight_other']&&$waybill['carrier_weight_unit_id_other']){
-                    unset($waybill['carrier_weight_unit_id_other']);
+            unset($waybill['carrier_weight_unit_id_other']);
         }
         $this->validatorWaybillDispatch($request,$id)->validate();
 
@@ -600,7 +601,7 @@ class WaybillsController extends Controller
         if ($result){
             $img=Image::make($bulkyName);
             if ($img->height() > $img->width())
-            $img->heighten(250)->save($commonName);
+                $img->heighten(250)->save($commonName);
             else $img->widen(250)->save($commonName);
             $img->heighten(28)->save($thumbnailName);
             $uploadFile=new UploadFile([
@@ -610,7 +611,7 @@ class WaybillsController extends Controller
                 "type"=>$fileExtension,
             ]);
             if ($uploadFile->save())
-            $this->log(__METHOD__,'图片上传',json_encode($request),Auth::user()['id']);
+                $this->log(__METHOD__,'图片上传',json_encode($request),Auth::user()['id']);
             $uploadFile->url=asset('/storage'.$uploadFile->url);
             return ['success'=>true,'data'=>$uploadFile];
         }

+ 1 - 1
resources/views/waybill/edit.blade.php

@@ -234,7 +234,7 @@
                         </div>
                         <label for="amount_unit_id" class=" col-form-label text-right ">单位:</label>
                         <div class="col-1.5 form-inline">
-                            {{--{{--:class="errors['amount_unit_id'] ? 'text-danger' :''"--}}--}}
+                            {{--:class="errors['amount_unit_id'] ? 'text-danger' :''"--}}
                             <label for="amount_unit_id1" class="ml-1  @error('amount_unit_id') text-danger @enderror"  >件</label><input id="amount_unit_id1" type="radio" value="4" class="form-control form-control-sm ml-1"
                                                          name="amount_unit_id" v-model="waybillPriceModel.amount_unit_id">
                             <label for="amount_unit_id1" class="ml-1 @error('amount_unit_id') text-danger @enderror"  >托</label><input id="amount_unit_id1" type="radio" value="5" class="form-control form-control-sm ml-1"