Procházet zdrojové kódy

Merge branches 'master' and 'zzd-waybill' of ssh://was.baoshi56.com:10022/var/git/bswas

 Conflicts:
	resources/views/package/weigh/index.blade.php
LD před 5 roky
rodič
revize
45f111dd9c
29 změnil soubory, kde provedl 623 přidání a 987 odebrání
  1. 2 0
      app/Events/WaybillPriceModelEvent.php
  2. 75 4
      app/Http/Controllers/TestController.php
  3. 44 26
      app/Http/Controllers/WaybillController.php
  4. 15 22
      app/Http/Controllers/WaybillPriceModelController.php
  5. 1 0
      app/Http/Controllers/WeighController.php
  6. 10 14
      app/Imports/WaybillPriceModelsImport.php
  7. 66 44
      app/Listeners/WaybillPriceModelListener.php
  8. 20 5
      app/Order.php
  9. 1 1
      app/Services/PackageService.php
  10. 7 0
      app/Services/RegionService.php
  11. 56 12
      app/Services/WaybillService.php
  12. 71 14
      app/Waybill.php
  13. 6 4
      app/WaybillPriceModel.php
  14. 40 0
      database/migrations/2021_02_23_175630_change_waybills_table_add_order_id_column.php
  15. 15 30
      resources/views/maintenance/priceModel/waybillPriceModel/create.blade.php
  16. 7 23
      resources/views/maintenance/priceModel/waybillPriceModel/edit.blade.php
  17. 7 5
      resources/views/package/weigh/index.blade.php
  18. 55 27
      resources/views/waybill/create.blade.php
  19. 2 2
      resources/views/waybill/delivering.blade.php
  20. 49 58
      resources/views/waybill/edit.blade.php
  21. 8 14
      resources/views/waybill/index.blade.php
  22. 6 7
      resources/views/waybill/recycle.blade.php
  23. 56 41
      resources/views/waybill/waybillEdit.blade.php
  24. 0 189
      resources/views/waybill/waybillPriceModel/create.blade.php
  25. 0 200
      resources/views/waybill/waybillPriceModel/edit.blade.php
  26. 0 57
      resources/views/waybill/waybillPriceModel/import.blade.php
  27. 0 166
      resources/views/waybill/waybillPriceModel/index.blade.php
  28. 0 19
      resources/views/waybill/waybillPriceModel/menu.blade.php
  29. 4 3
      routes/web.php

+ 2 - 0
app/Events/WaybillPriceModelEvent.php

@@ -15,6 +15,8 @@ class WaybillPriceModelEvent
     /**
      * Create a new event instance.
      *
+     * @param WaybillPriceModel $waybillPriceModel
+     *
      * @return void
      */
     public function __construct(WaybillPriceModel $waybillPriceModel)

+ 75 - 4
app/Http/Controllers/TestController.php

@@ -83,6 +83,7 @@ use App\Services\OrderTrackingOwnerService;
 use App\Services\OrderTrackingService;
 use App\Services\OwnerPriceOperationService;
 use App\Services\OwnerService;
+use App\Services\RegionService;
 use App\Services\RejectedBillService;
 use App\Services\ShopService;
 use App\Services\StoreService;
@@ -135,11 +136,81 @@ class TestController extends Controller
         return call_user_func([$this, $method], $request);
     }
     public function zzd(){
-        $str = "1,2,3,4,5";
-        foreach (array_reverse(explode(",",$str),true) as $index=>$discount){
-            dump($index,$discount);
+        ini_set('max_execution_time',2500);
+        ini_set('memory_limit','1526M');
+        $models = WaybillPriceModel::query()->get();
+        foreach ($models as $model){
+            if ($model->city_name == '汕头/汕尾'){
+                $region1 = Region::query()->where("name","汕头")->first();
+                $region2 = Region::query()->where("name","汕尾")->first();
+                $model->update([
+                    "province_id" =>$region1->parent_id,
+                    "city_id" =>$region1->id,
+                ]);
+                WaybillPriceModel::query()->create([
+                    'logistic_id'=> $model->logistic_id,
+                    'province_id' => $region2->parent_id,
+                    'city_id' => $region2->id,
+                    'unit_id' => $model->unit_id,
+                    'range_min' => $model->range_min,
+                    'range_max'=> $model->range_max,
+                    'unit_price'=> $model->unit_price,
+                    'base_fee'=> $model->base_fee,
+                    'initial_weight'=> $model->initial_weight
+                ]);
+                LogService::log(__CLASS__,"修改运输计费",$model->toJson());
+                continue;
+            }
+            $obj = [];
+            if ($model->province_id){
+                $obj["province_id"] = app(RegionService::class)->getProvince($model->province_name);
+            }
+            if ($model->city_id){
+                $obj["city_id"] = app(RegionService::class)->getCity($model->city_name);;
+            }
+            if (count($obj)>0){
+                $model->update($obj);
+                LogService::log(__CLASS__,"修改运输计费",$model->toJson());
+            }
         }
-        dd();
+        dd("OK");
+    }
+
+    public function zzd1()
+    {
+        ini_set('max_execution_time',2500);
+        ini_set('memory_limit','1526M');
+        $models = Waybill::query()->whereNotNull("origination_city_id")
+            ->orWhereNotNull("destination_city_id")->get();
+        foreach ($models as $model){
+            $obj = [];
+            if ($model->origination_city_id){
+                $city = City::query()->find($model->origination_city_id)->name ?? null;
+                if ($city)$obj["origination_city_id"] = app(RegionService::class)->getCity($city);
+            }
+            if ($model->destination_city_id){
+                $city = City::query()->find($model->destination_city_id)->name ?? null;
+                if ($city)$obj["destination_city_id"] = app(RegionService::class)->getCity($city);
+            }
+            if (count($obj)>0){
+                $model->update($obj);
+                LogService::log(__CLASS__,"修改运输单",$model->toJson());
+            }
+        }
+        dd("OK");
+    }
+
+    public function test1(){
+        $cityIds = [2];
+        $parovince = "北京";
+        $waybills = Waybill::query()->where(function ($query)use($cityIds,$parovince){
+            /** @var Builder $query */
+            $query->whereIn('destination_city_id',$cityIds)->orWhereHas("order",function ($query)use($province){
+                /** @var Builder $query */
+                $query->where("province","like",$province."%");
+            });
+        })->get();
+        dd($waybills);
     }
 
     public function syncWeight()

+ 44 - 26
app/Http/Controllers/WaybillController.php

@@ -5,7 +5,6 @@ namespace App\Http\Controllers;
 
 use App\Components\AsyncResponse;
 use App\Services\CarTypeService;
-use App\Services\CityService;
 use App\Services\LogisticService;
 use App\Services\OwnerService;
 use App\Services\UnitService;
@@ -17,7 +16,6 @@ use App\WaybillAuditLog;
 use App\WaybillOnTop;
 use App\WaybillPriceModel;
 use App\City;
-use App\Owner;
 use App\Unit;
 use App\Waybill;
 use App\WaybillPayoff;
@@ -28,7 +26,6 @@ use Exception;
 use Illuminate\Database\Eloquent\Builder;
 use Illuminate\Database\Eloquent\Collection;
 use Illuminate\Http\Request;
-use Illuminate\Http\UploadedFile;
 use Illuminate\Support\Facades\Auth;
 use Illuminate\Support\Facades\DB;
 use Illuminate\Support\Facades\Gate;
@@ -79,26 +76,32 @@ class WaybillController extends Controller
     public function store(Request $request)
     {
         if(!Gate::allows('运输管理-录入')){ return redirect(url('/'));  }
-        $id=false;
-        $this->validatorWaybill($request,$id)->validate();
+        $this->validatorWaybill($request,false)->validate();
         /** @var WaybillService */
         $waybill=app('waybillService')->store($request);
         app('LogService')->log(__METHOD__,__FUNCTION__,json_encode($request->toArray()),Auth::user()['id']);
         return redirect('waybill/index')->with('successTip','新运单“'.$waybill->waybill_number.'”录入成功');
     }
 
-    public function edit($id,LogisticService $logisticService,CarTypeService $carTypeService,
-                         CityService $cityService,UnitService $unitService)
+    public function edit($id,LogisticService $logisticService,CarTypeService $carTypeService,UnitService $unitService)
     {
         if(!Gate::allows('运输管理-编辑')){ return redirect(url('/'));  }
-        /** @var WaybillService */
         $waybill = app('waybillService')->find($id);
+        if ($waybill->order_id){
+            /** @var Waybill $waybill */
+            $waybill->load("order.owner");
+            $waybill->destination_city_id = app("RegionService")->getCity($waybill->order->city ?? '',$waybill->order->province ?? '');
+        }else{
+            /** @var Waybill $waybill */
+            $waybill->load("owner");
+        }
+        /** @var \stdClass $waybill */
         if (!$waybill)return view("exception.default",["code"=>"500","message"=>"数据已被删除或丢失"]);
         if ($waybill->deliver_at){
             $waybill->deliver_at_date=Carbon::parse($waybill->deliver_at)->format('Y-m-d');
             $waybill->deliver_at_time=Carbon::parse($waybill->deliver_at)->format('H:i:s');
         }
-        $cities=$cityService->getSelection();
+        $cities=app("RegionService")->getSelection(2);
         $units=$unitService->getSelection();
         $carTypes=$carTypeService->getSelection();
         return view('waybill/edit',['waybill'=>$waybill,'logistics'=>$logisticService->getSelection(["id","name"],"物流"),'cities'=>$cities,'units'=>$units,'carTypes'=>$carTypes]);
@@ -134,7 +137,7 @@ class WaybillController extends Controller
             if ($waybillPriceModel_id){
                 $carrier_weight=$request->input('carrier_weight');
                 $waybillPriceModel=$waybillPriceModelService->find($waybillPriceModel_id);
-                $logistic=$logisticService->find($waybill->logistic_id);
+                $logistic=$logisticService->find($waybill->order->logistic_id ?? $waybill->logistic_id);
                 if ($carrier_weight<$waybillPriceModel->initial_weight){
                     $fee=(($waybillPriceModel->unit_price)*($waybillPriceModel->initial_weight))+$logistic->delivery_fee;
                 }else{
@@ -368,14 +371,14 @@ class WaybillController extends Controller
     public function waybillEdit($id){
         if(!Gate::allows('运输管理-编辑')){ return redirect(url('/'));  }
         $waybill=app('waybillService')->find($id);
-        $owners=Owner::get();
+        $owners=app("OwnerService")->getIntersectPermitting();
         return view('waybill.waybillEdit',['waybill'=>$waybill,'owners'=>$owners]);
     }
     public function waybillRetreatAudit(Request $request){
         if(!Gate::allows('运输管理-调度')){ return redirect(url('/'));  }
         $id=$request->input('id');
         $waybill=app('waybillService')->find($id);
-        WaybillAuditLog::whereRaw('waybill_id = ? and audit_stage = ?',[$id,"运单阶段"])->delete();
+        WaybillAuditLog::query()->whereRaw('waybill_id = ? and audit_stage = ?',[$id,"运单阶段"])->delete();
         $waybill->status='待重审';
         $result=$waybill->save();
         app('LogService')->log(__METHOD__,__FUNCTION__,json_encode($waybill),Auth::user()['id']);
@@ -430,23 +433,25 @@ class WaybillController extends Controller
 
     //生成报表数据
     private function createReportData($waybill,$waybillPayoff){
+        /** @var Waybill $waybill */
+        $waybill->loadMissing(["order.owner",'order.logistic']);
         return [
             "type"=>$waybill->type,
             "waybill_number"=>$waybill->waybill_number,
-            "owner_name"=>$waybill->owner ? $waybill->owner->name : null,
+            "owner_name"=>$waybill->order->owner->name ?? ($waybill->owner->name ?? null),
             "wms_bill_number"=>$waybill->wms_bill_number,
             "source_bill"=>$waybill->source_bill,
             "origination"=>$waybill->origination,
-            "destination"=>$waybill->destination,
-            "recipient"=>$waybill->recipient,
-            "recipient_mobile"=>$waybill->recipient_mobile,
+            "destination"=>$waybill->order->address ?? $waybill->destination,
+            "recipient"=>$waybill->order->consignee_name ?? $waybill->recipient,
+            "recipient_mobile"=>$waybill->order->consignee_phone ?? $waybill->recipient_mobile,
             "charge"=>$waybill->charge,
             "collect_fee"=>$waybill->collect_fee,
             "ordering_remark"=>$waybill->ordering_remark,
-            "carrier_name"=>$waybill->logistic ? $waybill->logistic->name : null,
+            "carrier_name"=>$waybill->order->logistic->name ?? ($waybill->logistic->name ?? null),
             "carrier_bill"=>$waybill->carrier_bill,
             "origination_city_name"=>$waybill->originationCity ? $waybill->originationCity->name : null,
-            "destination_city_name"=>$waybill->destinationCity ? $waybill->destinationCity->name : null,
+            "destination_city_name"=>$waybill->order->city ?? ($waybill->destinationCity->name ?? null),
             "warehouse_weight"=>$waybill->warehouse_weight.($waybill->warehouseWeightUnit ? $waybill->warehouseWeightUnit->name : ''),
             "carrier_weight"=>$waybill->carrier_weight.($waybill->carrierWeightUnit ? $waybill->carrierWeightUnit->name : ''),
             "warehouse_weight_other"=>$waybill->warehouse_weight_other.($waybill->warehouseWeightUnitOther ? $waybill->warehouseWeightUnitOther->name : ''),
@@ -685,16 +690,17 @@ class WaybillController extends Controller
     protected function validatorWaybill(Request $request,$id){
         if ($id){$wms_bill_number=$id;};
         $validator=Validator::make($request->input(),[
-            'owner_id'=>'required',
+            'owner_id'=>'required_without:order_id',
             'wms_bill_number'=>['nullable','max:50',isset($wms_bill_number)?"unique:waybills,wms_bill_number,$wms_bill_number":'unique:waybills,wms_bill_number'],
             'origination'=>'required|max:255',
-            'destination'=>'required|max:255',
-            'recipient'=>'required|max:50',
-            'recipient_mobile'=>['required','regex:/^(\d{7,11})|(1[3|4|5|7|8][0-9]\d{4,8})$/'],
+            'destination'=>'required_without:order_id|max:255',
+            'recipient'=>'required_without:order_id|max:50',
+            'recipient_mobile'=>['required_without:order_id','regex:/^(\d{7,11})|(1[3|4|5|7|8][0-9]\d{4,8})$/'],
             'charge'=>'nullable|min:0|max:999999|numeric',
             'collect_fee'=>'nullable|min:0|numeric',
         ],[
             'required'=>':attribute 为必填项',
+            'required_without'=>':attribute 为必填项',
             'alpha_num'=>':attribute 应为字母或数字',
             'max'=>':attribute 字符过多或输入值过大',
             'regex'=>':attribute 输入有误',
@@ -716,7 +722,7 @@ class WaybillController extends Controller
     }
     protected function validatorWaybillDispatch(Request $request,$id){
         $rule=[
-            'logistic_id'=>'required|integer',
+            'logistic_id'=>'required_without:order_id|integer',
             'carrier_bill'=>"sometimes|nullable|max:50|unique:waybills,carrier_bill,$id",
             'fee'=>'sometimes|nullable|min:0|numeric|max:999999',
             'other_fee'=>'sometimes|nullable|min:0|numeric|max:999999',
@@ -725,7 +731,7 @@ class WaybillController extends Controller
             'amount'=>'nullable|numeric|min:0',
             'amount_unit_id'=>'required',
             'origination_city_id'=>'sometimes|required|integer',
-            'destination_city_id'=>'sometimes|required|integer',
+            'destination_city_id'=>'sometimes|required_without:order_id|integer',
             'warehouse_weight_other'=>'sometimes|nullable|min:0|numeric|max:999999',
             'warehouse_weight_unit_id_other'=>'sometimes|required_with:warehouse_weight_other|nullable|integer',
             'pick_up_fee'=>'sometimes|nullable|min:0|numeric|max:999999',
@@ -738,10 +744,11 @@ class WaybillController extends Controller
         ];
         if ($request->type == '专线'){
             $rule['origination_city_id']='required|integer';
-            $rule['destination_city_id']='required|integer';
+            $rule['destination_city_id']='required_without:order_id|integer';
         }
         $validator=Validator::make($request->input(),$rule,[
             'required'=>':attribute 为必填项',
+            'required_without'=>':attribute 为必填项',
             'alpha_num'=>':attribute 应为字母或数字',
             'max'=>':attribute 字符过多或输入值过大',
             'min'=>':attribute 不得为负',
@@ -806,7 +813,7 @@ class WaybillController extends Controller
         if(!Gate::allows('运输管理-删除')){return redirect('/');}
         $paginate = $request->input('paginate')??50;
         /** @var Collection $waybills */
-        $waybills = Waybill::query()->with(['owner','logistic','amountUnit','warehouseWeightUnit','carrierWeightUnit',
+        $waybills = Waybill::query()->with(['owner','order.owner','order.logistic','logistic','amountUnit','warehouseWeightUnit','carrierWeightUnit',
             'warehouseWeightUnitOther','carrierWeightUnitOther','carType','waybillAuditLogs' => function ($query) {
             /** @var Builder $query */
             $query->with('user');
@@ -905,4 +912,15 @@ class WaybillController extends Controller
         return ['success'=>true,'warehouseWeight'=>$warehouseWeight];
     }
 
+    //寻找订单
+    public function seekOrder()
+    {
+        $this->gate("运输管理");
+        $code = request("code");
+        if (!$code)$this->error("暂无绑定订单");
+        $order = app("OrderService")->first(["code"=>$code]);
+        if (!$order)$this->error("暂无绑定订单");
+        $this->success($order);
+    }
+
 }

+ 15 - 22
app/Http/Controllers/WaybillPriceModelsController.php → app/Http/Controllers/WaybillPriceModelController.php

@@ -2,13 +2,12 @@
 
 namespace App\Http\Controllers;
 
+use App\Region;
 use App\WaybillPriceModel;
-use App\City;
 use App\Events\WaybillPriceModelEvent;
 use App\Imports\WaybillPriceModelsImport;
 use App\Province;
 use App\Unit;
-use function GuzzleHttp\Psr7\str;
 use Illuminate\Http\Request;
 use Illuminate\Support\Facades\Auth;
 use Illuminate\Support\Facades\Cache;
@@ -16,7 +15,7 @@ use Illuminate\Support\Facades\Gate;
 use Illuminate\Support\Facades\Validator;
 use Maatwebsite\Excel\Facades\Excel;
 
-class WaybillPriceModelsController extends Controller
+class WaybillPriceModelController extends Controller
 {
     public function index(Request $request)
     {
@@ -24,7 +23,7 @@ class WaybillPriceModelsController extends Controller
         $logistics=app('LogisticService')->getSelection(["id","name"],"物流");
         $provinces=Province::query()->get();
         $data=$request->input();
-        $waybillPriceModels= WaybillPriceModel::query()->orderBy('id', 'DESC');
+        $waybillPriceModels= WaybillPriceModel::query()->with(["logistic","province","city","unit"])->orderBy('id', 'DESC');
         if ($data){
             if ($request->input('logistic_id')){
                 $waybillPriceModels=$waybillPriceModels->where('logistic_id',$request->input('logistic_id'));
@@ -45,14 +44,9 @@ class WaybillPriceModelsController extends Controller
     {
         if(!Gate::allows('计费模型-录入')){ return redirect(url('/'));  }
         $logistics=app('LogisticService')->getSelection(["id","name"],"物流");
-        $provinces=Province::get();
-        $units=Unit::get();
-        return view('maintenance.priceModel.waybillPriceModel.create',['logistics'=>$logistics,'provinces'=>$provinces,'units'=>$units]);
-    }
-
-    public function getCities($province_id){
-        $cities=City::where('province_id',$province_id)->get();
-        return ['cities'=>$cities];
+        $regions=Region::query()->whereIn("type",[1,2])->get();
+        $units=Unit::query()->get();
+        return view('maintenance.priceModel.waybillPriceModel.create',['logistics'=>$logistics,'regions'=>$regions,'units'=>$units]);
     }
 
 
@@ -61,7 +55,7 @@ class WaybillPriceModelsController extends Controller
         if(!Gate::allows('计费模型-录入')){ return redirect(url('/'));  }
         $this->validateWaybillPriceModel($request)->validate();
         $waybillPriceModel=$request->input('WaybillPriceModel');
-        $waybillPriceModelIs=WaybillPriceModel::where('logistic_id',$waybillPriceModel['logistic_id'])->where('province_id',$waybillPriceModel['province_id'])->where('unit_id',$waybillPriceModel['unit_id']);
+        $waybillPriceModelIs=WaybillPriceModel::query()->where('logistic_id',$waybillPriceModel['logistic_id'])->where('province_id',$waybillPriceModel['province_id'])->where('unit_id',$waybillPriceModel['unit_id']);
         if (isset($waybillPriceModel['city_id'])){
             $waybillPriceModelIs=$waybillPriceModelIs->where('city_id',$waybillPriceModel['city_id']);
         }
@@ -74,19 +68,19 @@ class WaybillPriceModelsController extends Controller
         $waybillPriceModelIs=$waybillPriceModelIs->first();
         if (!$waybillPriceModelIs){
             if (isset($waybillPriceModel['city_id'])){
-                $waybillPriceModelProvince=WaybillPriceModel::whereRaw('logistic_id = ? AND province_id = ? AND city_id IS NULL',[$waybillPriceModel['logistic_id'],$waybillPriceModel['province_id']])->first();
+                $waybillPriceModelProvince=WaybillPriceModel::query()->whereRaw('logistic_id = ? AND province_id = ? AND city_id IS NULL',[$waybillPriceModel['logistic_id'],$waybillPriceModel['province_id']])->first();
                 if ($waybillPriceModelProvince){
                     return redirect()->back()->with('successTip','已存在省份模型,无需录入城市模型');
                 }
             }else{
-                $waybillPriceModelProvince=WaybillPriceModel::whereRaw('logistic_id = ? AND province_id = ? AND city_id IS NOT NULL',[$waybillPriceModel['logistic_id'],$waybillPriceModel['province_id']])->first();
+                $waybillPriceModelProvince=WaybillPriceModel::query()->whereRaw('logistic_id = ? AND province_id = ? AND city_id IS NOT NULL',[$waybillPriceModel['logistic_id'],$waybillPriceModel['province_id']])->first();
                 if ($waybillPriceModelProvince){
                     return redirect()->back()->with('successTip','已存在城市模型,无法录入省份模型');
                 }
             }
             if ($waybillPriceModel['base_fee']==null){ unset($waybillPriceModel['base_fee']);}
             if ($waybillPriceModel['initial_weight']==null){unset($waybillPriceModel['initial_weight']);}
-            $waybillPriceModel=WaybillPriceModel::create($waybillPriceModel);
+            $waybillPriceModel=WaybillPriceModel::query()->create($waybillPriceModel);
             event(new WaybillPriceModelEvent($waybillPriceModel));
             app('LogService')->log(__METHOD__,__FUNCTION__,json_encode($request->toArray()),Auth::user()['id']);
             return redirect('maintenance/priceModel/waybillPriceModel')->with('successTip','新计费模型录入成功');
@@ -100,12 +94,11 @@ class WaybillPriceModelsController extends Controller
     public function edit($id)
     {
         if(!Gate::allows('计费模型-编辑')){ return redirect(url('/'));  }
-        $waybillPriceModel=WaybillPriceModel::find($id);
+        $waybillPriceModel=WaybillPriceModel::query()->find($id);
         $logistics=app('LogisticService')->getSelection(["id","name"],"物流");
-        $provinces=Province::get();
-        $cities=City::where('province_id',$waybillPriceModel->province_id)->get();
-        $units=Unit::get();
-        return view('maintenance.priceModel.waybillPriceModel.edit',['waybillPriceModel'=>$waybillPriceModel,'logistics'=>$logistics,'provinces'=>$provinces,'units'=>$units,'cities'=>$cities]);
+        $regions=Region::query()->whereIn("type",[1,2])->get();
+        $units=Unit::query()->get();
+        return view('maintenance.priceModel.waybillPriceModel.edit',['waybillPriceModel'=>$waybillPriceModel,'logistics'=>$logistics,'regions'=>$regions,'units'=>$units]);
     }
 
 
@@ -113,7 +106,7 @@ class WaybillPriceModelsController extends Controller
     {
         if(!Gate::allows('计费模型-编辑')){ return redirect(url('/'));  }
         $this->validateWaybillPriceModel($request)->validate();
-        $waybillPriceModel=WaybillPriceModel::find($id);
+        $waybillPriceModel=WaybillPriceModel::query()->find($id);
         $data=$request->input('WaybillPriceModel');
         if ($data['base_fee']==null){ unset($data['base_fee']);}
         if ($data['initial_weight']==null){unset($data['initial_weight']);}

+ 1 - 0
app/Http/Controllers/WeighController.php

@@ -41,6 +41,7 @@ class WeighController extends Controller
      *
      * @param Request $request
      * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|void
+     * @throws
      */
     public function store(Request $request)
     {

+ 10 - 14
app/Imports/WaybillPriceModelsImport.php

@@ -45,14 +45,14 @@ class WaybillPriceModelsImport implements ToCollection,WithHeadingRow
                     if (strstr($row['省份'], '省')){$row['省份']=str_replace('省','',$row['省份']);};
                     $logistic = Logistic::query()->where('name', $row['承运商'])->first();
                     $unit = Unit::query()->where('name', $row['计数单位'])->first();
-                    $province = Province::query()->where('name', $row['省份'])->first();
-                    $city = City::query()->where('name', $row['市'])->first();
+                    $province = app("RegionService")->getProvince($row['省份']);
+                    $city = app("RegionService")->getCity($row['市'],$province);
                     if ($logistic && $unit && $province) {
                         $billing = WaybillPriceModel::query()->where('logistic_id', $logistic->id);
                         $billing = $billing->where('unit_id', $unit->id);
-                        $billing = $billing->where('province_id', $province->id);
+                        $billing = $billing->where('province_id', $province);
                         if ($row['市']) {
-                            if ($city) $billing = $billing->where('city_id', $city->id);
+                            if ($city) $billing = $billing->where('city_id', $city);
                             else $billing->whereNull("city_id");
                         }
                         if ($row['计数区间'] && !strstr($row['计数区间'], '∞')) {
@@ -65,20 +65,20 @@ class WaybillPriceModelsImport implements ToCollection,WithHeadingRow
                         $billing = $billing->first();
                         if (!$billing) {
                             if ($row['市']){
-                                $waybillPriceModelProvince=WaybillPriceModel::query()->whereRaw('logistic_id = ? AND province_id = ? AND city_id IS NULL',[$logistic->id,$province->id])->first();
+                                $waybillPriceModelProvince=WaybillPriceModel::query()->whereRaw('logistic_id = ? AND province_id = ? AND city_id IS NULL',[$logistic->id,$province])->first();
                                 if ($waybillPriceModelProvince){
                                     $cityIs=false;
                                     array_push($exception, ['第' . $sum . '行数据已存在省份模型,无需录入城市模型']);
                                 }
                             }else{
-                                $waybillPriceModelProvince=WaybillPriceModel::query()->whereRaw('logistic_id = ? AND province_id = ? AND city_id IS NOT NULL',[$logistic->id,$province->id])->first();
+                                $waybillPriceModelProvince=WaybillPriceModel::query()->whereRaw('logistic_id = ? AND province_id = ? AND city_id IS NOT NULL',[$logistic->id,$province])->first();
                                 if ($waybillPriceModelProvince){
                                     $cityIs=false;
                                     array_push($exception, ['第' . $sum . '行数据已存在城市模型,无法录入省份模型']);
                                 }
                             }
                             if ($cityIs){
-                                $waybillPriceModel = ['logistic_id' => $logistic->id, 'unit_id' => $unit->id, 'province_id' => $province->id, 'unit_price' => $row['单价']];
+                                $waybillPriceModel = ['logistic_id' => $logistic->id, 'unit_id' => $unit->id, 'province_id' => $province, 'unit_price' => $row['单价']];
                                 if ($row['计数区间']) {
                                     $str = explode('-', $row['计数区间']);
                                     if (preg_match('/^[1-9]\d*\,\d*|[1-9]\d*$/', $str[0]) >= 0
@@ -91,9 +91,7 @@ class WaybillPriceModelsImport implements ToCollection,WithHeadingRow
                                     }
                                 }
                                 if ($row['市']) {
-                                    if ($city) {
-                                        $waybillPriceModel = array_merge($waybillPriceModel, ['city_id' => $city->id]);
-                                    }
+                                    if ($city) $waybillPriceModel = array_merge($waybillPriceModel, ['city_id' => $city]);
                                 }
                                 if ($row['起步费'] && preg_match('/^[1-9]\d*\,\d*|[1-9]\d*$/', $row['起步费']) > 0) {
                                     $waybillPriceModel = array_merge($waybillPriceModel, ['base_fee' => $row['起步费']]);
@@ -113,7 +111,7 @@ class WaybillPriceModelsImport implements ToCollection,WithHeadingRow
                             }
                         } else {
                             if ($this->isOverride) {
-                                $waybillPriceModel = ['logistic_id' => $logistic->id, 'unit_id' => $unit->id, 'province_id' => $province->id, 'unit_price' => $row['单价']];
+                                $waybillPriceModel = ['logistic_id' => $logistic->id, 'unit_id' => $unit->id, 'province_id' => $province, 'unit_price' => $row['单价']];
                                 if ($row['计数区间']&& !strstr($row['计数区间'], '∞')) {
                                     $str = explode('-', $row['计数区间']);
                                     if (preg_match('/^[1-9]\d*\,\d*|[1-9]\d*$/', $str[0]) > 0
@@ -126,9 +124,7 @@ class WaybillPriceModelsImport implements ToCollection,WithHeadingRow
                                     }
                                 }
                                 if ($row['市']) {
-                                    if ($city) {
-                                        $waybillPriceModel = array_merge($waybillPriceModel, ['city_id' => $city->id]);
-                                    }
+                                    if ($city) $waybillPriceModel = array_merge($waybillPriceModel, ['city_id' => $city]);
                                 }
                                 if ($row['起步费'] && preg_match('/^[1-9]\d*\,\d*|[1-9]\d*$/', $row['起步费']) > 0) {
                                     $waybillPriceModel = array_merge($waybillPriceModel, ['base_fee' => $row['起步费']]);

+ 66 - 44
app/Listeners/WaybillPriceModelListener.php

@@ -3,80 +3,102 @@
 namespace App\Listeners;
 
 use App\Logistic;
-use App\City;
 use App\Events\WaybillPriceModelEvent;
+use App\Region;
 use App\Waybill;
 use App\WaybillFinancialSnapshot;
 use App\WaybillPayoff;
 use App\WaybillFinancialExcepted;
 use App\WaybillPriceModel;
+use Illuminate\Database\Eloquent\Builder;
 
 class WaybillPriceModelListener
 {
-    /**
-     * Create the event listener.
-     *
-     * @return void
-     */
-    public function __construct()
-    {
-        //
-    }
-
     public function waybillPriceModel_check_waybill(WaybillPriceModel $waybillPriceModel){
-        $cityIds=[$waybillPriceModel->city_id];
-        //取省下所有市
+
+        $waybills=Waybill::query()->with(["logistic","order.logistic"])->where('type','专线')
+            ->where('status','!=','已完结');
+
+        //条件携带承运商
+        /** @var \stdClass $waybillPriceModel */
+        $logisticId = $waybillPriceModel->logistic_id;
+        $waybills->where(function ($query)use($logisticId){
+            /** @var Builder $query */
+            $query->where('logistic_id',$logisticId)->orWhereHas("order",function ($query)use($logisticId){
+                /** @var Builder $query */
+                $query->where("logistic_id",$logisticId);
+            });
+        });
+        //市不存在
         if(!$waybillPriceModel->city_id){
-            $cities=City::select('id')->where('province_id',$waybillPriceModel['province_id'])->get();
+            $cities=Region::query()->select('id')->where('parent_id',$waybillPriceModel['province_id'])->get();
+            $province = Region::query()->find($waybillPriceModel['province_id']);
             $cityIds=$cities->map(function ($city){
                 return $city['id'];
             });
+            //条件携带省
+            $waybills->where(function ($query)use($cityIds,$province){
+                    $province = $province->name ?? "";
+                    /** @var Builder $query */
+                    $query->whereIn('destination_city_id',$cityIds)->orWhereHas("order",function ($query)use($province){
+                        /** @var Builder $query */
+                        $query->where("province","like",$province."%");
+                    });
+                });
             //市不存在,价格区间不存在
             if (!$waybillPriceModel->range_max){
-                $waybills=Waybill::query()->where('logistic_id',$waybillPriceModel->logistic_id)->whereIn('destination_city_id',$cityIds)
-                    ->where('type','专线')->where('status','!=','已完结')->where('carrier_weight_unit_id',$waybillPriceModel->unit_id)
-                    ->orWhere('carrier_weight_unit_id_other',$waybillPriceModel->unit_id)->get();
+                $waybills->where('carrier_weight_unit_id',$waybillPriceModel->unit_id)
+                    ->orWhere('carrier_weight_unit_id_other',$waybillPriceModel->unit_id);
+            }else{
+                //市不存在,价格区间存在
+                $waybills->whereRaw('carrier_weight <= ? AND carrier_weight > ? AND carrier_weight_unit_id = ?',[$waybillPriceModel->range_max,$waybillPriceModel->range_min,$waybillPriceModel->unit_id])
+                    ->orWhereRaw('carrier_weight_other <= ? AND carrier_weight_other > ? AND carrier_weight_unit_id_other = ?',[$waybillPriceModel->range_max,$waybillPriceModel->range_min,$waybillPriceModel->unit_id]);
             }
-            //市不存在,价格区间存在
+        }else{
+            //市存在
+            //携带城市条件
+            $city = Region::query()->find($waybillPriceModel->city_id);
+            $id = $city->id ?? "";
+            $name = $city->name ?? "";
+            $waybills->where(function ($query)use($id,$name){
+                /** @var Builder $query */
+                $query->where("destination_city_id",$id)->orWhereHas("order",function($query)use($name){
+                    /** @var Builder $query */
+                    $query->where("city",'like',$name."%");
+                });
+            });
             if ($waybillPriceModel->range_max){
-                $waybills=Waybill::where('logistic_id',$waybillPriceModel->logistic_id)->whereIn('destination_city_id',$cityIds)
-                    ->whereRaw('carrier_weight <= ? AND carrier_weight > ? AND carrier_weight_unit_id = ?',[$waybillPriceModel->range_max,$waybillPriceModel->range_min,$waybillPriceModel->unit_id])
-                    ->orWhereRaw('carrier_weight_other <= ? AND carrier_weight_other > ? AND carrier_weight_unit_id_other = ?',[$waybillPriceModel->range_max,$waybillPriceModel->range_min,$waybillPriceModel->unit_id])
-                    ->where('type','专线')->where('status','!=','已完结')->get();
+                //价格区间存在
+                $waybills->whereRaw('carrier_weight <= ? AND carrier_weight > ? AND carrier_weight_unit_id = ?',[$waybillPriceModel->range_max,$waybillPriceModel->range_min,$waybillPriceModel->unit_id])
+                    ->orWhereRaw('carrier_weight_other <= ? AND carrier_weight_other > ? AND carrier_weight_unit_id_other = ?',[$waybillPriceModel->range_max,$waybillPriceModel->range_min,$waybillPriceModel->unit_id]);
+            }else{
+                //价格区间不存在
+                $waybills->where('carrier_weight_unit_id',$waybillPriceModel->unit_id)
+                    ->orWhere('carrier_weight_unit_id_other',$waybillPriceModel->unit_id);
             }
         }
-
-        //市存在,价格区间存在
-        if ($waybillPriceModel->city_id&&$waybillPriceModel->range_max){
-            $waybills=Waybill::where('logistic_id',$waybillPriceModel->logistic_id)->where('destination_city_id',$waybillPriceModel->city_id)
-                ->whereRaw('carrier_weight <= ? AND carrier_weight > ? AND carrier_weight_unit_id = ?',[$waybillPriceModel->range_max,$waybillPriceModel->range_min,$waybillPriceModel->unit_id])
-                ->orWhereRaw('carrier_weight_other <= ? AND carrier_weight_other > ? AND carrier_weight_unit_id_other = ?',[$waybillPriceModel->range_max,$waybillPriceModel->range_min,$waybillPriceModel->unit_id])
-                ->where('type','专线')->where('status','!=','完结')->get();
-        }
-
-        //市存在,价格区间不存在
-        if ($waybillPriceModel->city_id&&!$waybillPriceModel->range_max){
-            $waybills=Waybill::where('logistic_id',$waybillPriceModel->logistic_id)->where('destination_city_id',$waybillPriceModel->city_id)
-                ->where('type','专线')->where('status','!=','完结')->where('carrier_weight_unit_id',$waybillPriceModel->unit_id)
-                ->orWhere('carrier_weight_unit_id_other',$waybillPriceModel->unit_id)->get();
-        }
-        return $waybills;
+        return $waybills->get();
     }
 
     /**
      * Handle the event.
      *
      * @param  WaybillPriceModelEvent  $event
+     *
      * @return void
+     *
+     * @throws
      */
     public function handle(WaybillPriceModelEvent $event)
     {
         $waybillPriceModel=$event->waybillPriceModel;
         $waybills=$this->waybillPriceModel_check_waybill($waybillPriceModel);
+        /** @var \stdClass $waybillPriceModel */
         if ($waybills){
             foreach ($waybills as $waybill){
                 //修改运单表运费
-                $carrier=Carrier::find($waybill->logistic_id);
+                /** @var \stdClass $carrier */
+                $carrier=$waybill->order->logistic ?? $waybill->logistic;
                 if ($waybill->carrier_weight<$waybillPriceModel->initial_weight){
                     $fee=(($waybillPriceModel->unit_price)*($waybillPriceModel->initial_weight))+$carrier->delivery_fee;
                 }else{
@@ -89,7 +111,7 @@ class WaybillPriceModelListener
 
                 //修改财务表信息
                 if ($total_receivable){
-                    $waybillPayoff=WaybillPayoff::where('waybill_id','=',$waybill->id)->first();
+                    $waybillPayoff=WaybillPayoff::query()->where('waybill_id','=',$waybill->id)->first();
                     if ($waybillPayoff){
                         $waybillPayoff->total_expense=$total_expense;
                         $waybillPayoff->total_receivable=$total_receivable;
@@ -97,7 +119,7 @@ class WaybillPriceModelListener
                         $waybillPayoff->gross_profit_rate=(($total_receivable-$total_expense)/$total_receivable);
                         $waybillPayoff->save();
                     }else{
-                        WaybillPayoff::create([
+                        WaybillPayoff::query()->create([
                             'waybill_id'=>$waybill->id,
                             'total_expense'=>$total_expense,
                             'total_receivable'=>$total_receivable,
@@ -105,16 +127,16 @@ class WaybillPriceModelListener
                             'gross_profit_rate'=>(($total_receivable-$total_expense)/$total_receivable),
                         ]);
                     };
-                    $waybillFinancialExcepted=WaybillFinancialExcepted::where('waybill_id',$waybill->id)->first();
+                    $waybillFinancialExcepted=WaybillFinancialExcepted::query()->where('waybill_id',$waybill->id)->first();
                     if ($waybillFinancialExcepted){
                         $waybillFinancialExcepted->delete();
                         $waybill->status='完结';
-                        $waybillPayoff=WaybillPayoff::where('waybill_id','=',$waybillFinancialExcepted->waybill_id)->first();
+                        $waybillPayoff=WaybillPayoff::query()->where('waybill_id','=',$waybillFinancialExcepted->waybill_id)->first();
                         $waybillPayoff->load(["waybill"]);
                         $waybillPayoff->waybill->load(["owner","carrier","origination_city","destination_city","warehouse_weight_unit","carrier_weight_unit","carType","waybillAuditLogs"]);
                         $waybillPayoff->waybill->waybillAuditLogs->load(["user"]);
                         $waybillPayoffJson=json_encode($waybillPayoff,JSON_UNESCAPED_UNICODE);
-                        WaybillFinancialSnapshot::create([
+                        WaybillFinancialSnapshot::query()->create([
                             'waybill_id'=>$waybillFinancialExcepted->waybill_id,
                             'json_content'=>$waybillPayoffJson,
                         ]);

+ 20 - 5
app/Order.php

@@ -15,11 +15,26 @@ class Order extends Model
     use ModelTimeFormat;
 
     protected $fillable = [
-        'id', 'batch_id',  'owner_id', 'status',
-        'created_at', 'code', 'shop_id',  'client_code',
-        'logistic_id', 'consignee_name', 'consignee_phone', 'province',
-        'city', 'district', 'address','warehouse_id',
-        'wms_edittime', 'wms_status','order_type','frozen'
+        'id',
+        'batch_id',
+        'owner_id',
+        'status',
+        'created_at',
+        'code',
+        'shop_id',
+        'client_code',
+        'logistic_id',
+        'consignee_name',
+        'consignee_phone',
+        'province',
+        'city',
+        'district',
+        'address',
+        'warehouse_id',
+        'wms_edittime',
+        'wms_status',
+        'order_type',
+        'frozen'
     ];
 
     /*

+ 1 - 1
app/Services/PackageService.php

@@ -19,7 +19,7 @@ class PackageService
     private function conditionQuery($params){
         $ownerIds=app('UserService')->getPermittingOwnerIds(Auth::user());
         $packages = OrderPackage::query()->with(['order'=>function($query){
-            return  $query->with(['owner','logistic']);
+            return  $query->with(['owner','logistic','batch']);
         },'paperBox','measuringMachine'])
         ->whereIn('order_packages.owner_id',$ownerIds)->orderBy(TABLE.'id','DESC');
         if ($params['owner_id'] ?? false){

+ 7 - 0
app/Services/RegionService.php

@@ -128,4 +128,11 @@ class RegionService
         }
         return $name;
     }
+
+    public function getSelection($type = null, $columns = ["id","name"])
+    {
+        $regions = Region::query()->select($columns);
+        if ($type)$regions->where("type",$type);
+        return $regions->get();
+    }
 }

+ 56 - 12
app/Services/WaybillService.php

@@ -21,7 +21,7 @@ class WaybillService
      * @return Builder
      */
     private function conditionQuery(array $param){
-        $waybills = Waybill::filterAuthorities()->with(['owner','logistic','originationCity','destinationCity.province',
+        $waybills = Waybill::filterAuthorities()->with(['owner','logistic','originationCity','destinationCity.parent',
             'uploadFile','amountUnit','warehouseWeightUnit','carrierWeightUnit','district',
             'warehouseWeightUnitOther','carrierWeightUnitOther','carType','uploadFile','waybillAuditLogs.user'])
             ->selectRaw('waybills.* ,waybill_on_tops.id top_id ,waybill_on_tops.remark,waybill_on_tops.updated_at top_update')
@@ -29,21 +29,72 @@ class WaybillService
             ->whereNull('waybill_on_tops.deleted_at')
             ->orderBy('waybill_on_tops.updated_at','desc')
             ->orderBy('waybills.id','desc');
+        if ($param["owner_id"] ?? false){
+            $ownerIds = explode(",",$param["owner_id"]);
+            $waybills->where(function ($query)use($ownerIds){
+                /** @var Builder $query */
+                $query->whereIn("owner_id",$ownerIds)->orWhereHas("order",function ($query)use($ownerIds){
+                    /** @var Builder $query */
+                    $query->whereIn("owner_id",$ownerIds);
+                });
+            });
+            unset($param["owner_id"]);
+        }
+        if ($param["destination"] ?? false){
+            $destination = $param["destination"];
+            $waybills->where(function ($query)use($destination){
+                /** @var Builder $query */
+                $query->where("destination","like",$destination."%")->orWhereHas("order",function ($query)use($destination){
+                    /** @var Builder $query */
+                    $query->where("address",'like',$destination."%");
+                });
+            });
+            unset($param["destination"]);
+        }
+        if ($param["recipient"] ?? false){
+            $recipient = $param["recipient"];
+            $waybills->where(function ($query)use($recipient){
+                /** @var Builder $query */
+                $query->where("recipient","like",$recipient."%")->orWhereHas("order",function ($query)use($recipient){
+                    /** @var Builder $query */
+                    $query->where("consignee_name",'like',$recipient."%");
+                });
+            });
+            unset($param["recipient"]);
+        }
+        if ($param["recipient_mobile"] ?? false){
+            $recipientMobile = $param["recipient_mobile"];
+            $waybills->where(function ($query)use($recipientMobile){
+                /** @var Builder $query */
+                $query->where("recipient_mobile","like",$recipientMobile."%")->orWhereHas("order",function ($query)use($recipientMobile){
+                    /** @var Builder $query */
+                    $query->where("consignee_phone",'like',$recipientMobile."%");
+                });
+            });
+            unset($param["recipient_mobile"]);
+        }
+        if ($param["logistic_id"] ?? false){
+            $logisticId = $param["logistic_id"];
+            $waybills->where(function ($query)use($logisticId){
+                /** @var Builder $query */
+                $query->where("logistic_id",$logisticId)->orWhereHas("order",function ($query)use($logisticId){
+                    /** @var Builder $query */
+                    $query->where("logistic_id",$logisticId);
+                });
+            });
+            unset($param["logistic_id"]);
+        }
         $columnQueryRules=[
             'waybill_number' => ['like' => ''],
             'carrier_bill' => ['like' => ''],
-            'owner_id' => ['multi' => ','],
             'wms_bill_number' => ['like' => ''],
             'origination' => ['like' => ''],
-            'destination' => ['like' => ''],
             'source_bill' => ['like' => ''],
             'car_owner_info' => ['like' => ''],
             'created_at_start' => ['alias' => 'created_at' , 'startDate' => ':00'],
             'created_at_end' => ['alias' => 'created_at' , 'endDate' => ':59'],
             'uriType' => ['alias' => 'type'],
             'id' => ['multi' => ','],
-            'recipient' => ['timeLimit' => 15],
-            'recipient_mobile' => ['timeLimit' => 15],
         ];
         $waybills = app(QueryService::class)->query($param,$waybills,$columnQueryRules,"waybills");
         return $waybills;
@@ -83,13 +134,6 @@ class WaybillService
         return DB::transaction(function ()use($request){
             $waybill=new Waybill();
             $inputs = $request->all();
-            if ($inputs["wms_bill_number"]){
-                $order = app("OrderService")->first(["code"=>$inputs["wms_bill_number"]]);
-                if ($order){
-                    $inputs["destination_city_id"] = app("RegionService")->getCity($order->city,$order->province);
-                    $inputs["district_id"] = app("RegionService")->getDistrict($order->district,$order->city);
-                }
-            }
             $inputs['status']='未审核';
             $inputs['waybill_number']=Uuid::uuid1();
             $waybill->fill($inputs);

+ 71 - 14
app/Waybill.php

@@ -18,11 +18,47 @@ class Waybill extends Model
     use ModelTimeFormat;
     use SoftDeletes;
     protected $fillable=[
-        'status','type','waybill_number','owner_id','wms_bill_number','origination','destination','recipient','recipient_mobile','charge','ordering_remark',
-        'logistic_id','carrier_bill','origination_city_id','destination_city_id','warehouse_weight','warehouse_weight_unit_id','carrier_weight','carrier_weight_unit_id','carType_id',
-        'car_owner_info','fee','pick_up_fee','other_fee','collect_fee','dispatch_remark','waybill_price_model_id','warehouse_weight_other','warehouse_weight_unit_id_other'
-        ,'carrier_weight_other','carrier_weight_unit_id_other','source_bill','mileage','amount','inquire_tel','amount_unit_id','other_charge','other_charge_remark','deliver_at',
-        "district_id"
+        'status',
+        'type',
+        'waybill_number',
+        'owner_id',
+        'wms_bill_number',
+        'origination',
+        'destination',
+        'recipient',
+        'recipient_mobile',
+        'charge',
+        'ordering_remark',
+        'logistic_id',
+        'carrier_bill',
+        'origination_city_id',
+        'destination_city_id',
+        'warehouse_weight',
+        'warehouse_weight_unit_id',
+        'carrier_weight',
+        'carrier_weight_unit_id',
+        'carType_id',
+        'car_owner_info',
+        'fee',
+        'pick_up_fee',
+        'other_fee',
+        'collect_fee',
+        'dispatch_remark',
+        'waybill_price_model_id',
+        'warehouse_weight_other',
+        'warehouse_weight_unit_id_other',
+        'carrier_weight_other',
+        'carrier_weight_unit_id_other',
+        'source_bill',
+        'mileage',
+        'amount',
+        'inquire_tel',
+        'amount_unit_id',
+        'other_charge',
+        'other_charge_remark',
+        'deliver_at',
+        "district_id",
+        "order_id"
     ];
 
     public function district()
@@ -35,11 +71,13 @@ class Waybill extends Model
     public function logistic(){
         return $this->hasOne('App\Logistic','id','logistic_id');
     }
-    public function originationCity(){
-        return $this->hasOne('App\City','id','origination_city_id');
+    public function originationCity()
+    {   //始发市
+        return $this->hasOne(Region::class,'id','origination_city_id');
     }
-    public function destinationCity(){
-        return $this->hasOne('App\City','id','destination_city_id');
+    public function destinationCity()
+    {   //目的市
+        return $this->hasOne(Region::class,'id','destination_city_id');
     }
     public function wmsCommodities(){
         return $this->hasMany('App\WMSWaybillOrder','OrderNo','wms_bill_number');
@@ -71,9 +109,11 @@ class Waybill extends Model
     public function uploadFile(){
         return $this->hasOne('App\UploadFile','table_id','id')->where('table_name','waybills');
     }
-//    public function getOrderingRemarkAttribute($val){
-//        return
-//    }
+    public function order()
+    {   //订单
+        return $this->belongsTo(Order::class);
+    }
+
 
 
     static public function setWeightByOrderCode($orderCode,$weight){
@@ -92,8 +132,25 @@ class Waybill extends Model
      * @return Builder
      */
     public static function filterAuthorities(){
-        $owner_ids=app('UserService')->getPermittingOwnerIds(auth()->user());
-        return (new static)->newQuery()->whereIn('owner_id',$owner_ids);
+        $ids=app('UserService')->getPermittingOwnerIds(auth()->user());
+        return (new static)->newQuery()->leftJoin("orders","waybills.wms_bill_number","orders.code")
+            ->leftJoin("owners","orders.owner_id","owners.id")
+            ->leftJoin("logistics","orders.logistic_id","logistics.id")
+            ->selectRaw(<<<column
+            owners.name as owner_name,
+            logistics.name as logistic_name,
+            orders.consignee_name as order_consignee_name,
+            orders.consignee_phone as order_consignee_phone,
+            orders.province as order_province,
+            orders.city as order_city,
+            orders.district as order_district,
+            orders.address as order_address
+column
+)
+            ->where(function ($query)use($ids){
+            /** @var Builder  $query */
+            $query->whereIn('waybills.owner_id',$ids)->orWhereIn("orders.owner_id",$ids);
+        });
     }
 
 

+ 6 - 4
app/WaybillPriceModel.php

@@ -28,12 +28,14 @@ class WaybillPriceModel extends Model
         return $this->belongsTo('App\Logistic','logistic_id','id');
     }
 
-    public  function province(){
-        return $this->belongsTo('App\Province','province_id','id');
+    public  function province()
+    {   //省份
+        return $this->belongsTo(Region::class,'province_id','id');
     }
 
-    public  function city(){
-        return $this->belongsTo('App\City','city_id','id');
+    public  function city()
+    {   //城市
+        return $this->belongsTo(Region::class,'city_id','id');
     }
 
     public function unit(){

+ 40 - 0
database/migrations/2021_02_23_175630_change_waybills_table_add_order_id_column.php

@@ -0,0 +1,40 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class ChangeWaybillsTableAddOrderIdColumn extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('waybills', function (Blueprint $table) {
+            $table->bigInteger("order_id")->index()->nullable()->comment("订单");
+            $table->bigInteger('owner_id')->nullable()->comment('货主')->change();
+            $table->string('destination',50)->nullable()->comment('目的地')->change();
+            $table->string('recipient',50)->nullable()->comment('收件人')->change();
+            $table->string('recipient_mobile',50)->nullable()->comment('收件人电话')->change();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('waybills', function (Blueprint $table) {
+            $table->dropColumn("order_id");
+            $table->bigInteger('owner_id')->comment('货主')->change();
+            $table->string('destination',50)->comment('目的地')->change();
+            $table->string('recipient',50)->comment('收件人')->change();
+            $table->string('recipient_mobile',50)->comment('收件人电话')->change();
+        });
+    }
+}

+ 15 - 30
resources/views/maintenance/priceModel/waybillPriceModel/create.blade.php

@@ -1,15 +1,13 @@
 @extends('layouts.app')
-@section('title')录入-价格模型@endsection
 
 @section('content')
     <div id="nav2">
-        @component('maintenance.menu')@endcomponent
         @component('maintenance.priceModel.waybillPriceModel.menu')@endcomponent
     </div>
     <div class="container-fluid" id="list">
         <div class="card col-md-8 offset-md-2">
             <div class="card-body">
-                <form method="POST" action="{{ url('maintenance/priceModel/waybillPriceModel') }}">
+                <form method="POST" action="{{ url('waybill/waybillPriceModel') }}">
                     @if(Session::has('successTip'))
                         <div class="alert alert-success h1">{{Session::get('successTip')}}</div>
                     @endif
@@ -18,7 +16,7 @@
                         <label for="logistic_id" class="col-2 col-form-label text-right">承运商</label>
                         <div class="col-8">
                             <select class="form-control" name="WaybillPriceModel[logistic_id]" style="width: 30%;" v-model="inputting.WaybillPriceModel.logistic_id">
-                                    <option v-for="logistic in logistics" :value="logistic.id">@{{logistic.name}}</option>
+                                <option v-for="logistic in logistics" :value="logistic.id">@{{logistic.name}}</option>
                             </select>
                             <div class="col-sm-5">
                                 <p class="form-control-static text-danger small font-weight-bold">{{ $errors->first('WaybillPriceModel.logistic_id') }}</p>
@@ -28,8 +26,8 @@
                     <div class="form-group row">
                         <label for="province_id"  class="col-2 col-form-label text-right">选择省份</label>
                         <div class="col-8" >
-                            <select class="form-control" name="WaybillPriceModel[province_id]" style="width: 30%;" v-model="inputting.WaybillPriceModel.province_id" @change="changeProvince($event)">
-                                <option v-for="province in provinces" :value="province.id">@{{province.name}}</option>
+                            <select id="province_id" class="form-control" name="WaybillPriceModel[province_id]" style="width: 30%;" v-model="inputting.WaybillPriceModel.province_id">
+                                <option v-for="province in regions" v-if="province.type == 1" :value="province.id">@{{province.name}}</option>
                             </select>
                             <div class="col-sm-5">
                                 <p class="form-control-static text-danger small font-weight-bold">{{ $errors->first('WaybillPriceModel.province_id') }}</p>
@@ -40,7 +38,7 @@
                         <label for="city_id"  class="col-2 col-form-label text-right">选择城市</label>
                         <div class="col-8" >
                             <select class="form-control" name="WaybillPriceModel[city_id]" style="width: 30%;" v-model="inputting.WaybillPriceModel.city_id">
-                                <option v-for="city in cities" :value="city.id">@{{city.name}}</option>
+                                <option v-for="city in regions" v-if="city.type == 2 && city.parent_id == inputting.WaybillPriceModel.province_id" :value="city.id">@{{city.name}}</option>
                             </select>
 
                             <div class="col-sm-5">
@@ -63,7 +61,7 @@
                         <label for="range_min" class="col-2 col-form-label text-right">计价区间</label>
                         <div class="col-8 form-inline">
                             <input  type="text" style="width: 20%" class="form-control @error('WaybillPriceModel.range_min') is-invalid @enderror"
-                                   name="WaybillPriceModel[range_min]" autocomplete="off" value="{{ old('WaybillPriceModel')['range_min'] }}" >&nbsp;&nbsp;--&nbsp;&nbsp;
+                                    name="WaybillPriceModel[range_min]" autocomplete="off" value="{{ old('WaybillPriceModel')['range_min'] }}" >&nbsp;&nbsp;--&nbsp;&nbsp;
                             <input type="text" style="width: 20%" class="form-control @error('WaybillPriceModel.range_max') is-invalid @enderror"
                                    name="WaybillPriceModel[range_max]" autocomplete="off" value="{{ old('WaybillPriceModel')['range_max'] }}" >
                             @error('WaybillPriceModel.range_min')
@@ -135,46 +133,33 @@
                         @if(isset(old('WaybillPriceModel')['province_id']))
                         province_id:'{{old('WaybillPriceModel')['province_id']}}',
                         @endif
-                        @if(isset(old('WaybillPriceModel')['city_id']))
+                                @if(isset(old('WaybillPriceModel')['city_id']))
                         city_id:'{{old('WaybillPriceModel')['city_id']}}',
                         @endif
-                        @if(isset(old('WaybillPriceModel')['logistic_id']))
+                                @if(isset(old('WaybillPriceModel')['logistic_id']))
                         logistic_id:'{{old('WaybillPriceModel')['logistic_id']}}',
                         @endif
-                        @if(isset(old('WaybillPriceModel')['unit_id']))
+                                @if(isset(old('WaybillPriceModel')['unit_id']))
                         unit_id:'{{old('WaybillPriceModel')['unit_id']}}',
                         @endif
                     }
                 },
-                provinces:[
-                    @foreach($provinces as $province)
-                        {id:'{{$province->id}}',name:'{{$province->name}}' },
+                regions:[
+                        @foreach($regions as $region)
+                    {id:"{{$region->id}}",parent_id:"{{$region->parent_id}}",type:"{{$region->type}}",name:"{{$region->name}}"},
                     @endforeach
                 ],
-                cities:[
-                ],
                 logistics:[
-                    @foreach($logistics as $logistic)
-                        {id:'{{$logistic->id}}',name:'{{$logistic->name}}'},
+                        @foreach($logistics as $logistic)
+                    {id:'{{$logistic->id}}',name:'{{$logistic->name}}'},
                     @endforeach
                 ],
                 units:[
-                    @foreach($units as $unit)
+                        @foreach($units as $unit)
                     {id:'{{$unit->id}}',name:'{{$unit->name}}'},
                     @endforeach
                 ],
             },
-           methods:{
-               changeProvince(e){
-                   let _this=this;
-                   let val=e.target.value;
-                   axios.get('cities/'+val).then(
-                        function (response) {
-                            _this.cities=response.data.cities;
-                        }
-                   );
-               }
-           },
         });
 
     </script>

+ 7 - 23
resources/views/maintenance/priceModel/waybillPriceModel/edit.blade.php

@@ -30,9 +30,9 @@
                     <div class="form-group row">
                         <label for="province_id"  class="col-2 col-form-label text-right">选择省份</label>
                         <div class="col-8" >
-                            <select name="WaybillPriceModel[province_id]" v-model="inputting.WaybillPriceModel.province_id" @change="changeProvince($event)" style="width: 30%;"
+                            <select id="province_id" name="WaybillPriceModel[province_id]" v-model="inputting.WaybillPriceModel.province_id" style="width: 30%;"
                             class="form-control">
-                                <option v-for="province in provinces" :value="province.id">@{{province.name}}</option>
+                                <option v-for="province in regions" :value="province.id" v-if="province.type==1">@{{province.name}}</option>
                             </select>
 
                             <div class="col-sm-5">
@@ -43,8 +43,8 @@
                     <div class="form-group row">
                         <label for="city_id"  class="col-2 col-form-label text-right">选择城市</label>
                         <div class="col-8" >
-                            <select name="WaybillPriceModel[city_id]" v-model="inputting.WaybillPriceModel.city_id" style="width: 30%;" class="form-control">
-                                <option v-for="city in cities" :value="city.id">@{{city.name}}</option>
+                            <select id="city_id" name="WaybillPriceModel[city_id]" v-model="inputting.WaybillPriceModel.city_id" style="width: 30%;" class="form-control">
+                                <option v-for="city in regions" :value="city.id" v-if="city.type==2 && city.parent_id == inputting.WaybillPriceModel.province_id">@{{city.name}}</option>
                             </select>
 
                             <div class="col-sm-5">
@@ -143,14 +143,9 @@
                         unit_id:'{{old('WaybillPriceModel')['unit_id']?old('WaybillPriceModel')['unit_id']:$waybillPriceModel->unit_id}}',
                     }
                 },
-                provinces:[
-                    @foreach($provinces as $province)
-                    {id:'{{$province->id}}',name:'{{$province->name}}' },
-                    @endforeach
-                ],
-                cities:[
-                    @foreach($cities as $city)
-                    {id:'{{$city->id}}',name:'{{$city->name}}'},
+                regions:[
+                    @foreach($regions as $region)
+                    {id:"{{$region->id}}",parent_id:"{{$region->parent_id}}",type:"{{$region->type}}",name:"{{$region->name}}"},
                     @endforeach
                 ],
                 logistics:[
@@ -173,17 +168,6 @@
             mounted:function(){
                 this.inputting.WaybillPriceModel.city_id='{{$waybillPriceModel->city_id}}';
             },
-            methods:{
-                changeProvince(e){
-                    let _this=this;
-                    let val=e.target.value;
-                    axios.get('../cities/'+val).then(
-                        function (response) {
-                            _this.cities=response.data.cities;
-                        }
-                    );
-                }
-            },
         });
 
     </script>

+ 7 - 5
resources/views/package/weigh/index.blade.php

@@ -72,11 +72,13 @@
                         @foreach($packages as $package)
                     {id:'{{$package->id}}',ownerName:'{{$package->order ? ($package->order->owner ? $package->order->owner->name : '') : ''}}',
                         orderCode:'{{$package->order ? $package->order->code : ''}}',
-                        logisticName:'{{$package->order ? ($package->order->logistic ? $package->order->logistic->name : '') : ''}}'
-                        ,batchNumber:'{{$package->batch_number}}',batchRule:'{{$package->batch_rule}}',
-                        recipient:'{{$package->order ? preg_replace('/[\s\n]/','',$package->order->consignee_name) : ''}}',recipientMobile:'{{$package->order ? $package->order->consignee_phone : ''}}'
-                        ,logisticNumber:'{{$package->logistic_number}}'
-                        ,measuringMachineName:'{{$package->measuringMachine ? $package->measuringMachine->name : ''}}',
+                        logisticName:'{{$package->order ? ($package->order->logistic ? $package->order->logistic->name : '') : ''}}',
+                        batchNumber:'{{$package->order ? ($package->order->batch ? $package->order->batch->code : '') : ''}}',
+                        batchRule:'{{$package->order ? ($package->order->batch ? $package->order->batch->wms_type : '') : ''}}',
+                        recipient:'{{$package->order ? preg_replace('/[\s\n]/','',$package->order->consignee_name) : ''}}',
+                        recipientMobile:'{{$package->order ? $package->order->consignee_phone : ''}}',
+                        logisticNumber:'{{$package->logistic_number}}',
+                        measuringMachineName:'{{$package->measuringMachine ? $package->measuringMachine->name : ''}}',
                         weight:'{{$package->weight}}', length:'{{$package->length}}',width:'{{$package->width}}',height:'{{$package->height}}',
                         bulk:'{{$package->bulk}}',paperBoxName:'{{$package->paperBox ? $package->paperBox->name : ''}}',
                         status:'{{$package->status}}',created_at:'{{$package->created_at}}',weighed_at:'{{$package->weighed_at}}',

+ 55 - 27
resources/views/waybill/create.blade.php

@@ -23,7 +23,7 @@
             <div class="card-body">
                 <form method="POST" action="{{ url('waybill') }}">
                     @csrf
-                    <input name="type" hidden value="{{$type}}">
+                    <label hidden><input name="type" value="{{$type}}"></label>
                     <div class="h5 text-center mb-3">
                         <ul class="nav nav-tabs">
                             <li class="nav-item offset-5"><a class="nav-link @if($type=='专线') active @endif" href="{{url('waybill/create?type=ZX')}}">专线</a></li>
@@ -31,12 +31,12 @@
                         </ul>
                     </div>
                     <div class="form-group row">
-                        <label for="owner_id" class="col-2 col-form-label text-right text-primary">货主{{old('owner_id')}} *</label>
+                        <label for="owner_id" class="col-2 col-form-label text-right text-primary">货主 *</label>
                         <div class="col-8 form-inline">
-                            <select id="owner_id" name="owner_id" class="form-control @error('owner_id') is-invalid @enderror" v-model="owner_id"  style="width: 30%" required>
+                            <select id="owner_id" :disabled="!!model.order_id" :name="model.order_id ? '' : 'owner_id'" class="form-control @error('owner_id') is-invalid @enderror" v-model="model.owner_id"  style="width: 30%" required>
                                 <option v-for="owner in owners" :value="owner.id">@{{owner.name}}</option>
                             </select>
-                            <input class="form-control-sm ml-2" placeholder="输入关键字定位" @input="owner_seek">
+                            <label v-if="!model.order_id"><input class="form-control-sm ml-2" placeholder="输入关键字定位" @input="owner_seek"></label>
                         </div>
                         <div class="col-sm-5">
                             <p class="form-control-static text-danger small font-weight-bold" style="margin-left: 50%">{{ $errors->first('owner_id') }}</p>
@@ -45,15 +45,16 @@
                     <div class="form-group row">
                         <label for="wms_bill_number" class="col-2 col-form-label text-right text-muted">WMS单号</label>
                         <div class="col-8">
-                            <input type="text" class="form-control @error('wms_bill_number') is-invalid @enderror"
+                            <input id="wms_bill_number" @change="bindOrder($event)" type="text" class="form-control @error('wms_bill_number') is-invalid @enderror"
                                    name="wms_bill_number" autocomplete="off" value="{{ old('wms_bill_number') }}"  >
                             @error('wms_bill_number')
                             <span class="invalid-feedback" role="alert">
-                                        <strong>{{ $message }}</strong>
-                                    </span>
+                                <strong>{{ $message }}</strong>
+                            </span>
                             @enderror
                         </div>
                     </div>
+                    <label hidden><input :value="model.order_id" name="order_id"></label>
                     <div class="col-8" style="margin-left: 15%">
                         <button type="button" class="btn btn-outline-primary btn-sm" @click="origination='松江区泗砖仓'" style="transform: scale(0.9)">松江泗砖仓</button>
                         <button type="button" class="btn btn-outline-primary btn-sm" @click="origination='松江区九干仓'" style="transform: scale(0.9)">松江九干仓</button>
@@ -62,7 +63,7 @@
                     <div class="form-group row">
                         <label for="origination" class="col-2 col-form-label text-right text-primary">始发地址 *</label>
                         <div class="col-8">
-                            <input type="text" class="form-control @error('origination') is-invalid @enderror"
+                            <input id="origination" type="text" class="form-control @error('origination') is-invalid @enderror"
                                    name="origination" autocomplete="off" value="{{ old('origination') }}"  v-model="origination" required>
                             @error('origination')
                             <span class="invalid-feedback" role="alert">
@@ -74,20 +75,22 @@
                     <div class="form-group row">
                         <label for="destination" class="col-2 col-form-label text-right text-primary">目的地址 *</label>
                         <div class="col-8">
-                            <input type="text" class="form-control @error('destination') is-invalid @enderror"
-                                   name="destination" autocomplete="off" value="{{ old('destination') }}"  required>
+                            <input id="destination" type="text" class="form-control @error('destination') is-invalid @enderror" autocomplete="off"
+                                   :readonly="!!model.order_id" required
+                                   :name="model.order_id ? '' : 'destination'" :value="model.order_id ? order.address : '{{ old('destination') }}'" >
                             @error('destination')
                             <span class="invalid-feedback" role="alert">
-                                        <strong>{{ $message }}</strong>
-                                    </span>
+                                <strong>{{ $message }}</strong>
+                            </span>
                             @enderror
                         </div>
                     </div>
                     <div class="form-group row">
                         <label for="recipient" class="col-2 col-form-label text-right text-primary">收件人 *</label>
                         <div class="col-8">
-                            <input type="text" class="form-control @error('recipient') is-invalid @enderror"
-                                   name="recipient" autocomplete="off" value="{{ old('recipient') }}"  required>
+                            <input id="recipient" type="text" class="form-control @error('recipient') is-invalid @enderror"
+                                   :readonly="!!model.order_id" autocomplete="off"  required
+                                   :name="model.order_id ? '' : 'recipient'" :value="model.order_id ? order.consignee_name : '{{ old('recipient') }}'">
                             @error('recipient')
                             <span class="invalid-feedback" role="alert">
                                         <strong>{{ $message }}</strong>
@@ -98,12 +101,13 @@
                     <div class="form-group row">
                         <label for="recipient_mobile" class="col-2 col-form-label text-right text-primary">收件人电话 *</label>
                         <div class="col-8">
-                            <input type="text" class="form-control @error('recipient_mobile') is-invalid @enderror"
-                                   name="recipient_mobile" autocomplete="off" value="{{ old('recipient_mobile') }}"  required>
+                            <input id="recipient_mobile" type="text" class="form-control @error('recipient_mobile') is-invalid @enderror"
+                                   :readonly="!!model.order_id" autocomplete="off"  required
+                                   :name="model.order_id ? '' : 'recipient_mobile'" :value="model.order_id ? order.consignee_phone : '{{ old('recipient_mobile') }}'">
                             @error('recipient_mobile')
                             <span class="invalid-feedback" role="alert">
-                                        <strong>{{ $message }}</strong>
-                                    </span>
+                                <strong>{{ $message }}</strong>
+                            </span>
                             @enderror
                         </div>
                     </div>
@@ -190,24 +194,48 @@
             el:'#list',
             data:{
                 owners:[
-                        @foreach($owners as $owner)
+                    @foreach($owners as $owner)
                     {id:'{{$owner->id}}',name:'{{$owner->name}}'},
                     @endforeach
                 ],
-                owner_id:'{{old('owner_id')}}',
                 origination:'{{old('origination')}}',
+                model:{
+                    order_id : "{{old("order_id")}}",
+                    owner_id:'{{old('owner_id')}}',
+                },
+                order:{},
+            },
+            mounted(){
+                if (this.model.order_id)this._codeGetOrder("{{ old('wms_bill_number') }}");
             },
             methods:{
                 owner_seek:function (e) {
-                    let _this=this;
-                    let $val=e.target.value;
-                    if($val==='')_this.owner_id='';
-                    else
-                        _this.owners.forEach(function (owner) {
-                            if (owner.name.includes($val)){
-                                _this.owner_id=owner.id;
+                    if (model.order_id)return;
+                    let val=e.target.value;
+                    if(!val)this.model.owner_id='';
+                    else{
+                        this.owners.every(owner=> {
+                            if (owner.name.includes(val)){
+                                this.model.owner_id=owner.id;
+                                return false;
                             }
+                            return true;
                         });
+                    }
+                },
+                bindOrder(e){
+                    this.model.order_id = "";
+                    this.model.owner_id = "";
+                    let val = e.target.value;
+                    this._codeGetOrder(val);
+                },
+                _codeGetOrder(val){
+                    let url = "{{url('waybill/seekOrder')}}";
+                    window.tempTip.postBasicRequest(url,{code:val},res=>{
+                        this.order = res;
+                        this.model.order_id = res.id;
+                        this.model.owner_id = res.owner_id;
+                    });
                 },
             },
         });

+ 2 - 2
resources/views/waybill/delivering.blade.php

@@ -193,8 +193,8 @@
                     amount_unit_id:'{{$waybill->amount_unit_id}}',
                     amount_unit_name:'{{$waybill->amount_unit ? $waybill->amount_unit->name : ''}}',
                     inquire_tel:'{{$waybill->inquire_tel}}',
-                    carrier_name:'{{$waybill->logistic ? $waybill->logistic->name : ''}}',
-                    owner_name:'{{$waybill->owner ? $waybill->owner->name : ''}}',
+                    carrier_name:'{{$waybill->logistic_name ?? ($waybill->logistic->name ?? '')}}',
+                    owner_name:'{{$waybill->owner_name ?? ($waybill->owner->name ?? '')}}',
                     warehouse_weight_unit_name:'{{$waybill->warehouse_weight_unit ? $waybill->warehouse_weight_unit->name : ''}}',
                     carrier_weight_unit_name:'{{$waybill->carrier_weight_unit ? $waybill->carrier_weight_unit->name : ''}}',
                     warehouse_weight_unit_other_name:'{{$waybill->warehouse_weight_unit_other ? $waybill->warehouse_weight_unit_other->name : ''}}',

+ 49 - 58
resources/views/waybill/edit.blade.php

@@ -15,7 +15,7 @@
                     @csrf
                     @method('PUT')
                     <div class="form-group row">
-                        <label class="col-2 col-form-label text-right text-secondary">运单类型</label>
+                        <label for="type" class="col-2 col-form-label text-right text-secondary">运单类型</label>
                         <div class="col-8">
                             <div class="h5 mb-3 col-8">
                                 <button type="button" @click="waybill.type='专线'" class="btn" :class="waybill.type=='专线'?'btn-primary':'btn-outline-primary'">专线</button>
@@ -25,9 +25,9 @@
                         </div>
                     </div>
                     <div class="form-group row">
-                        <label class="col-2 col-form-label text-right text-secondary">运单号</label>
+                        <label for="waybill_number" class="col-2 col-form-label text-right text-secondary">运单号</label>
                         <div class="col-8">
-                            <input type="text" class="form-control" disabled="disabled" :value="waybill.waybill_number" >
+                            <input id="waybill_number" type="text" class="form-control" disabled="disabled" :value="waybill.waybill_number" >
                         </div>
                     </div>
                     <div class="form-group row">
@@ -127,8 +127,9 @@
                     <div class="form-group row" style="margin-bottom: 20px">
                         <label for="logistic_id" class="col-2 col-form-label text-right text-primary">承运商 *</label>
                         <div class="col-8" style="position: relative">
-                            <select name="logistic_id" class="form-control @error('logistic_id') is-invalid @enderror"
-                                    :class="errors['logistic_id'] ? 'is-invalid' :''" id="logistic_id" v-model="waybill.logistic_id" style="width: 30%; ">
+                            <select class="form-control @error('logistic_id') is-invalid @enderror" id="logistic_id" style="width: 30%; "
+                                    :name="waybill.order_id ? '' : 'logistic_id'" :disabled="!!waybill.order_id"
+                                    :class="errors['logistic_id'] ? 'is-invalid' :''"  v-model="waybill.logistic_id">
                                 <option v-for="logistic in logistics" :value="logistic.id">@{{logistic.name}}</option>
                             </select>
                             <div v-if="errors['logistic_id'] && errors['logistic_id'].length>0" class="invalid-feedback" role="alert" style="position: relative">
@@ -166,8 +167,9 @@
                         <div class="form-group row">
                             <label for="destination_city_id" class="col-2 col-form-label text-right text-primary">目的市 *</label>
                             <div class="col-8 form-inline">
-                                <select class="form-control @error('destination_city_id') is-invalid @enderror" name="destination_city_id"
-                                        :class="errors['destination_city_id'] ? 'is-invalid' :''" id="destination_city_id" v-model="waybill.destination_city_id" style="width: 30%; " >
+                                <select class="form-control @error('destination_city_id') is-invalid @enderror" id="destination_city_id" style="width: 30%; "
+                                        :name="waybill.order_id ? '' : 'destination_city_id'" :disabled="!!waybill.order_id"
+                                        :class="errors['destination_city_id'] ? 'is-invalid' :''"  v-model="waybill.destination_city_id">
                                     <option v-for="city in cities" :value="city.id">@{{city.name}}</option>
                                 </select>
                                 <input type="text" class="form-control-sm  form-control tooltipTarget" style="vertical-align: middle"
@@ -376,6 +378,7 @@
                     </div>
                     <input type="hidden" name="status" value="待终审">
                     <input type="hidden" name="waybillPriceModel" id="waybillPriceModel">
+                    <input type="hidden" name="order_id" :value="waybill.order_id">
                     <div class="form-group row">
                         <div class="col-8 offset-2">
                             <input type="button" @click="submitForm" class="btn btn-outline-dark form-control" value="提交">
@@ -392,48 +395,52 @@
         let vueList=new Vue({
             el:'#list',
             data:{
-                cities:[
-                        @foreach($cities as $city)
-                    {
-                        id:'{{$city->id}}',name:'{{$city->name}}',type:'{{$city->type}}',
-                    },
-                    @endforeach
-                ],
-                units:[
-                        @foreach($units as $unit){
-                        id:'{{$unit->id}}',name:'{{$unit->name}}',
-                    },
-                    @endforeach
-                ],
-                logistics:[
-                    @foreach($logistics as $logistic)
-                        {id:'{{$logistic->id}}',name:'{{$logistic->name}}',},
-                    @endforeach
-                ],
-                carTypes:[
-                    @foreach($carTypes as $carType)
-                    {!! $carType !!},
-                    @endforeach
-                ],
+                cities:[@foreach($cities as $city){id:'{{$city->id}}',name:'{{$city->name}}',type:'{{$city->type}}',},@endforeach],
+                units:[@foreach($units as $unit){id:'{{$unit->id}}',name:'{{$unit->name}}',},@endforeach],
+                logistics:[@foreach($logistics as $logistic){id:'{{$logistic->id}}',name:'{{$logistic->name}}',},@endforeach],
+                carTypes:[@foreach($carTypes as $carType){!! $carType !!},@endforeach],
                 errors:[],
                 waybill:{
-                    id:'{{$waybill->id}}',type:'{{$waybill->type}}',waybill_number:'{{$waybill->waybill_number}}',owner_name:'{{$waybill->owner_name}}',
-                    wms_bill_number:'{{$waybill->wms_bill_number}}',origination:'{{$waybill->origination}}',destination:'{{$waybill->destination}}',
-                    recipient:'{{$waybill->recipient}}',recipient_mobile:'{{$waybill->recipient_mobile}}',ordering_remark:'{{$waybill->ordering_remark}}',
-                    charge:'{{$waybill->charge}}',logistic_id:'{{$waybill->logistic_id}}',carrier_bill:'{{$waybill->carrier_bill}}',
-                    warehouse_weight_other:'{{$waybill->warehouse_weight_other}}',warehouse_weight_unit_id_other:'{{$waybill->warehouse_weight_unit_id_other}}',amount:'{{$waybill->amount}}',
-                    amount_unit_id:'{{$waybill->amount_unit_id}}',mileage:'{{$waybill->mileage}}',carType_id:'{{$waybill->carType_id}}',
-                    car_owner_info:'{{$waybill->car_owner_info}}',fee:'{{$waybill->fee}}',other_fee:'{{$waybill->other_fee}}',
-                    other_charge:'{{$waybill->other_charge}}',other_charge_remark:'{{$waybill->other_charge_remark}}',dispatch_remark:'{{$waybill->dispatch_remark}}',
-                    origination_city_id:'{{$waybill->origination_city_id}}',destination_city_id:'{{$waybill->destination_city_id}}',warehouse_weight:'{{$waybill->warehouse_weight}}',
-                    warehouse_weight_unit_id:'{{$waybill->warehouse_weight_unit_id}}',carrier_weight:'{{$waybill->carrier_weight}}',carrier_weight_unit_id:'{{$waybill->carrier_weight_unit_id}}',
-                    carrier_weight_other:'{{$waybill->carrier_weight_other}}',carrier_weight_unit_id_other:'{{$waybill->carrier_weight_unit_id_other}}',pick_up_fee:'{{$waybill->pick_up_fee}}',
+                    id:'{{$waybill->id}}',
+                    waybill_number:'{{$waybill->waybill_number}}',
+                    order_id:'{{$waybill->order_id}}',
+                    owner_name:'{{$waybill->order->owner->name ?? $waybill->owner->name}}',
+                    wms_bill_number:'{{$waybill->wms_bill_number}}',origination:'{{$waybill->origination}}',
+                    destination:'{{$waybill->order->address ?? $waybill->destination}}',
+                    recipient:'{{$waybill->order->consignee_name ?? $waybill->recipient}}',
+                    recipient_mobile:'{{$waybill->order->consignee_phone ?? $waybill->recipient_mobile}}',ordering_remark:'{{$waybill->ordering_remark}}',
+
+                    charge:'{{ old("charge") ?? $waybill->charge}}',
+                    logistic_id:'{{ $waybill->order->logistic_id ?? (old("logistic_id") ?? $waybill->logistic_id)}}',
+                    carrier_bill:'{{ old("carrier_bill") ?? $waybill->carrier_bill}}',
+                    type:'{{ old("type") ?? $waybill->type}}',
+                    warehouse_weight_other:'{{ old("warehouse_weight_other") ?? $waybill->warehouse_weight_other}}',
+                    warehouse_weight_unit_id_other:'{{ old("warehouse_weight_unit_id_other") ?? $waybill->warehouse_weight_unit_id_other }}',
+                    amount:'{{ old('amount') ?? $waybill->amount}}',
+                    amount_unit_id:'{{ old('amount_unit_id') ?? $waybill->amount_unit_id}}',
+                    mileage:'{{ old("mileage") ?? $waybill->mileage}}',
+                    carType_id:'{{ old("carType_id") ?? $waybill->carType_id}}',
+                    car_owner_info:'{{ old("car_owner_info") ?? $waybill->car_owner_info}}',
+                    fee:'{{ old("fee") ?? $waybill->fee}}',
+                    other_fee:'{{ old("other_fee") ?? $waybill->other_fee}}',
+                    other_charge:'{{ old("other_charge") ?? $waybill->other_charge}}',
+                    other_charge_remark:'{{ old("other_charge_remark") ?? $waybill->other_charge_remark}}',
+                    dispatch_remark:'{{ old("dispatch_remark") ?? $waybill->dispatch_remark}}',
+                    origination_city_id:'{{ old("origination_city_id") ?? $waybill->origination_city_id}}',
+                    destination_city_id:'{{ old("destination_city_id") ?? $waybill->destination_city_id}}',
+                    warehouse_weight:'{{ old("warehouse_weight") ?? $waybill->warehouse_weight}}',
+                    warehouse_weight_unit_id:'{{ old("warehouse_weight_unit_id") ?? $waybill->warehouse_weight_unit_id}}',
+                    carrier_weight:'{{ old("carrier_weight") ?? $waybill->carrier_weight}}',
+                    carrier_weight_unit_id:'{{$waybill->carrier_weight_unit_id}}',
+                    carrier_weight_other:'{{$waybill->carrier_weight_other}}',
+                    carrier_weight_unit_id_other:'{{$waybill->carrier_weight_unit_id_other}}',
+                    pick_up_fee:'{{$waybill->pick_up_fee}}',
                 },
+                order:{!! $waybill->order ?? '{}' !!},
                 waybillTemp:{!! $waybill !!}
             },
             mounted:function(){
                 let _this=this;
-                //console.log(_this.waybillPriceModel.amount_unit_id)
                 $(".tooltipTarget").tooltip({'trigger':'hover'});
                 this.units.every(function (unit) {
                     switch (unit.name) {
@@ -547,7 +554,6 @@
                                     tempTip.confirm('该目的地与计量单位对应的计费模型不存在,如录入将会标为异常记录,请通知相关负责人添加计费模型,点击'+'<b class="text-primary">"确定"</b>'+'则确认提交 ',
                                         function () {
                                             document.getElementById('deliver_at').value= document.getElementById('deliver_at_date').value+' '+ document.getElementById('deliver_at_time').value;
-                                            // document.getElementById('waybillForm').submit();
                                             _this.executeSubmit();
                                         });
                                 }else{
@@ -560,20 +566,6 @@
                 },
                 executeSubmit(){
                     document.getElementById('waybillForm').submit();
-         /*           let data=['origination','charge','carrier_bill', 'warehouse_weight','warehouse_weight_unit_id',
-                        'warehouse_weight_other','warehouse_weight_unit_id_other','carrier_weight','carrier_weight_unit_id'
-                        ,'carrier_weight_other','carrier_weight_unit_id_other','mileage','carType_id'
-                        ,'car_owner_info','pick_up_fee','fee','other_fee','other_charge','other_charge_remark','dispatch_remark'];
-                    let waybill=this.waybill;
-                    let waybillTemp=this.waybillTemp;
-                    data.forEach(function (name) {
-                        if (waybill[name] === waybillTemp[name]){
-                            if (document.getElementById(name))document.getElementById(name).removeAttribute('name');
-                        }
-                    });*/
-                    /*setTimeout(function () {
-                        document.getElementById('waybillForm').submit();
-                    },1);*/
                 },
                 spliceDeliverAt:function () {
                         document.getElementById('deliver_at').value= document.getElementById('deliver_at_date').value+' '+ document.getElementById('deliver_at_time').value;
@@ -590,7 +582,6 @@
                         this.is_waybillPriceModel(logistic_id,carrier_weight,carrier_weight_unit_id,destination_city_id,carrier_weight_other,carrier_weight_unit_id_other);
                     }else {
                         document.getElementById('deliver_at').value= document.getElementById('deliver_at_date').value+' '+ document.getElementById('deliver_at_time').value;
-                        // document.getElementById('waybillForm').submit();
                         this.executeSubmit();
                     }
                 },

+ 8 - 14
resources/views/waybill/index.blade.php

@@ -290,23 +290,17 @@
                         status:'{{$waybill->status}}',
                         type:'{{$waybill->type}}',
                         waybill_number:'{{$waybill->waybill_number}}',
-                        owner:'{{$waybill->owner ? $waybill->owner->name : ''}}',
+                        owner:'{{$waybill->owner_name ?? ($waybill->owner->name ?? '')}}',
                         source_bill:'{{$waybill->source_bill}}',
                         wms_bill_number:'{{$waybill->wms_bill_number}}',
                         origination:'{{$waybill->origination}}',
-                        destination:'{{--{{$waybill->destination_city_id}}'?
-                            (('{{$waybill->destination}}'.indexOf('{{$waybill->destinationCity ? $waybill->destinationCity->name : ''}}')===-1 &&
-                                '{{$waybill->destination}}'.indexOf('{{$waybill->destinationCity ? ($waybill->destinationCity->province ? $waybill->destinationCity->province->name : '') : ''}}')===-1)?
-                                '{{($waybill->destinationCity ? ($waybill->destinationCity->province ? $waybill->destinationCity->province->name : '') : '').($waybill->destinationCity ? $waybill->destinationCity->name : '').($waybill->destination)}}'
-                                :'{{$waybill->destination}}')
-                            :'{{$waybill->destination}}--}}{{$waybill->destination}}',
-                        recipient:'{{$waybill->recipient}}',
-                        recipient_mobile:'{{$waybill->recipient_mobile}}',
+                        destination:'{{$waybill->order_address ?? $waybill->destination}}',
+                        recipient:'{{$waybill->order_consignee_name ?? $waybill->recipient}}',
+                        recipient_mobile:'{{$waybill->order_consignee_phone ?? $waybill->recipient_mobile}}',
                         charge:'{{$waybill->charge}}',
                         ordering_remark:'{{preg_replace("/[\n\s]/",' ',($waybill->ordering_remark??""))}}',
-                        carrier:'{{$waybill->logistic ? $waybill->logistic->name : ''}}',
+                        carrier:'{{$waybill->logistic_name ?? ($waybill->logistic->name ?? '')}}',
                         carrier_bill:'{{$waybill->carrier_bill}}',
-                        destination_city:'{{$waybill->destinationCity ? $waybill->destinationCity->name : ''}}',
                         warehouse_weight:'{{$waybill->warehouse_weight}}',
                         warehouse_weight_unit:'{{$waybill->warehouse_weight_unit ? $waybill->warehouse_weight_unit->name : ''}}',
                         carrier_weight:'{{$waybill->carrier_weight}}',
@@ -330,9 +324,9 @@
                         waybillAuditLogs:{!! $waybill->waybillAuditLogs !!},
                         btn_refresh_weight:'zoomIn',
                         remark:'{{$waybill->remark ?? ''}}',
-                        province:'{{$waybill->destinationCity->province->name ?? ''}}',
-                        city:'{{$waybill->destinationCity->name ?? ''}}',
-                        district:'{{$waybill->district->name ?? ''}}',
+                        province:'{{$waybill->order_province ?? ($waybill->destinationCity->parent->name ?? '')}}',
+                        city:'{{$waybill->order_city ?? ($waybill->destinationCity->name ?? '')}}',
+                        district:'{{$waybill->order_district ?? ($waybill->district->name ?? '')}}',
                     },
                     @endforeach
                 ],

+ 6 - 7
resources/views/waybill/recycle.blade.php

@@ -138,21 +138,20 @@
                         status:'{{$waybill->status}}',
                         type:'{{$waybill->type}}',
                         waybill_number:'{{$waybill->waybill_number}}',
-                        owner:'{{$waybill->owner ? $waybill->owner->name : ''}}',
+                        owner:'{{ $waybill->order->owner->name ?? ($waybill->owner->name ?? '') }}',
                         source_bill:'{{$waybill->source_bill}}',
                         wms_bill_number:'{{$waybill->wms_bill_number}}',
                         origination:'{{$waybill->origination}}',
-                        destination:'{{$waybill->destination}}',
-                        recipient:'{{$waybill->recipient}}',
-                        recipient_mobile:'{{$waybill->recipient_mobile}}',
+                        destination:'{{$waybill->order->address ?? $waybill->destination}}',
+                        recipient:'{{$waybill->order->consignee_name ?? $waybill->recipient}}',
+                        recipient_mobile:'{{$waybill->order->consignee_phone ?? $waybill->recipient_mobile}}',
                         charge:'{{$waybill->charge}}',
                         ordering_remark:'{{preg_replace("/[\n\s]/",' ',($waybill->ordering_remark??""))}}',
-                        carrier:'{{$waybill->carrier ? $waybill->carrier->name : ''}}',
+                        carrier:'{{$waybill->order->logistic->name ?? ($waybill->logistic->name ?? '')}}',
                         carrier_bill:'{{$waybill->carrier_bill}}',
                         origination_city:'{{$waybill->origination_city ? $waybill->origination_city->name : ''}}',
-                        destination_city:'{{$waybill->destination_city ? $waybill->destination_city->name : ''}}',
+                        destination_city:'{{$waybill->order->city ?? ($waybill->destination_city->name ?? '')}}',
                         warehouse_weight:'{{$waybill->warehouse_weight}}',
-                        destination_province_name:'{{$waybill->destination_city ? ($waybill->destination_city->province ? $waybill->destination_city->province->name : '') : ''}}',
                         warehouse_weight_unit:'{{$waybill->warehouse_weight_unit ? $waybill->warehouse_weight_unit->name : ''}}',
                         carrier_weight:'{{$waybill->carrier_weight}}',
                         carrier_weight_unit:'{{$waybill->carrier_weight_unit ? $waybill->carrier_weight_unit->name : ''}}',

+ 56 - 41
resources/views/waybill/waybillEdit.blade.php

@@ -8,7 +8,7 @@
             </li>
         @endcomponent
     </div>
-    <div class="container-fluid mt-3" id="update">
+    <div class="container-fluid mt-3" id="container">
         <div class="card">
             <div class="card-body">
                 <form method="POST" action='{{url("waybill/waybillUpdate/{$waybill->id}")}}'>
@@ -16,15 +16,16 @@
                     <div class="form-group row">
                         <label for="type" class="col-2 col-form-label text-right text-primary">运单类型 *</label>
                         <div class="h5 mb-3 col-8">
-                            <button type="button" @click="type='专线'" class="btn" :class="type=='专线'?'btn-primary':'btn-outline-primary'">专线</button>
-                            <button type="button" @click="type='直发车'" class="btn ml-2" :class="type!='专线'?'btn-primary':'btn-outline-primary'">直发车</button>
+                            <button type="button" @click="model.type='专线'" class="btn" :class="model.type=='专线'?'btn-primary':'btn-outline-primary'">专线</button>
+                            <button type="button" @click="model.type='直发车'" class="btn ml-2" :class="model.type!='专线'?'btn-primary':'btn-outline-primary'">直发车</button>
                         </div>
                     </div>
-                    <input hidden type="text" name="type" :value="type">
+                    <label hidden><input type="text" name="type" :value="model.type"></label>
                     <div class="form-group row">
-                        <label for="province_id" class="col-2 col-form-label text-right text-primary">货主 *</label>
+                        <label for="owner_id" class="col-2 col-form-label text-right text-primary">货主 *</label>
                         <div class="col-8">
-                            <select name="owner_id" class="form-control" style="width: 30%;">
+                            <select id="owner_id" class="form-control" style="width: 30%;" v-model="model.owner_id"
+                                    :name="model.order_id ? '' : 'owner_id'" :disabled="!!model.order_id">
                                 @foreach($owners as $owner)
                                     @if($owner->id==$waybill->owner_id)
                                         <option value="{{$owner->id}}" selected>{{$owner->name}}</option>
@@ -38,72 +39,62 @@
                     <div class="form-group row">
                         <label for="wms_bill_number" class="col-2 col-form-label text-right text-muted">WMS单号</label>
                         <div class="col-8">
-                            <input type="text" class="form-control @error('wms_bill_number') is-invalid @enderror"
-                                   name="wms_bill_number" autocomplete="off" value="@if(old('wms_bill_number')){{ old('wms_bill_number') }}@else{{$waybill->wms_bill_number}}@endif"  >
+                            <input id="wms_bill_number" type="text" class="form-control @error('wms_bill_number') is-invalid @enderror"
+                                name="wms_bill_number" autocomplete="off" value="@if(old('wms_bill_number')){{ old('wms_bill_number') }}@else{{$waybill->wms_bill_number}}@endif"
+                                @change="bindOrder($event)">
                             @error('wms_bill_number')
-                            <span class="invalid-feedback" role="alert">
-                                        <strong>{{ $message }}</strong>
-                                    </span>
+                            <span class="invalid-feedback" role="alert"><strong>{{ $message }}</strong></span>
                             @enderror
                         </div>
                     </div>
+                    <label hidden><input :value="model.order_id" name="order_id"></label>
                     <div class="form-group row">
                         <label for="origination" class="col-2 col-form-label text-right text-primary">始发地 *</label>
                         <div class="col-8">
-                            <input type="text" class="form-control @error('origination') is-invalid @enderror"
+                            <input id="origination" type="text" class="form-control @error('origination') is-invalid @enderror"
                                    name="origination" autocomplete="off" value="@if(old('origination')){{ old('origination') }}@else{{$waybill->origination}}@endif"  >
                             @error('origination')
-                            <span class="invalid-feedback" role="alert">
-                                        <strong>{{ $message }}</strong>
-                                    </span>
+                            <span class="invalid-feedback" role="alert"><strong>{{ $message }}</strong></span>
                             @enderror
                         </div>
                     </div>
                     <div class="form-group row">
                         <label for="destination" class="col-2 col-form-label text-right text-primary">目的地 *</label>
                         <div class="col-8">
-                            <input type="text" class="form-control @error('destination') is-invalid @enderror"
-                                   name="destination" autocomplete="off" value="@if(old('destination')){{ old('destination') }}@else{{$waybill->destination}}@endif"  >
+                            <input id="destination" type="text" class="form-control @error('destination') is-invalid @enderror" autocomplete="off" required
+                                   :readonly="!!model.order_id" :name="model.order_id ? '' : 'destination'"  :value="model.order_id ? order.address : '{{old('destination') ?? $waybill->destination}}'"  >
                             @error('origination')
-                            <span class="invalid-feedback" role="alert">
-                                        <strong>{{ $message }}</strong>
-                                    </span>
+                            <span class="invalid-feedback" role="alert"><strong>{{ $message }}</strong></span>
                             @enderror
                         </div>
                     </div>
                     <div class="form-group row">
                         <label for="recipient" class="col-2 col-form-label text-right text-primary">收件人 *</label>
                         <div class="col-8">
-                            <input type="text" class="form-control @error('recipient') is-invalid @enderror"
-                                   name="recipient" autocomplete="off" value="@if(old('recipient')){{ old('recipient') }}@else{{$waybill->recipient}}@endif"  >
+                            <input id="recipient" type="text" class="form-control @error('recipient') is-invalid @enderror" autocomplete="off" required
+                                   :readonly="!!model.order_id" :name="model.order_id ? '' : 'recipient'"  :value="model.order_id ? order.consignee_name : '{{old('recipient') ?? $waybill->recipient}}'">
                             @error('recipient')
-                            <span class="invalid-feedback" role="alert">
-                                        <strong>{{ $message }}</strong>
-                                    </span>
+                            <span class="invalid-feedback" role="alert"><strong>{{ $message }}</strong></span>
                             @enderror
                         </div>
                     </div>
                     <div class="form-group row">
                         <label for="recipient_mobile" class="col-2 col-form-label text-right text-primary">收件人电话 *</label>
                         <div class="col-8">
-                            <input type="text" class="form-control @error('recipient_mobile') is-invalid @enderror"
-                                   name="recipient_mobile" autocomplete="off" value="@if(old('recipient_mobile')){{ old('recipient_mobile') }}@else{{$waybill->recipient_mobile}}@endif"  >
+                            <input id="recipient_mobile" type="text" class="form-control @error('recipient_mobile') is-invalid @enderror" autocomplete="off" required
+                                   :readonly="!!model.order_id" :name="model.order_id ? '' : 'recipient_mobile'"  :value="model.order_id ? order.consignee_phone : '{{old('recipient_mobile') ?? $waybill->recipient_mobile}}'">
                             @error('recipient_mobile')
-                            <span class="invalid-feedback" role="alert">
-                                        <strong>{{ $message }}</strong>
-                                    </span>
+                            <span class="invalid-feedback" role="alert"><strong>{{ $message }}</strong></span>
                             @enderror
                         </div>
                     </div>
                     <div class="form-group row">
-                        <label for="charge" class="col-2 col-form-label text-right text-primary">运输收费(元) *</label>
+                        <label for="charge" class="col-2 col-form-label text-right text-muted">运输收费(元)</label>
                         <div class="col-8">
-                            <input type="text" class="form-control @error('charge') is-invalid @enderror"
+                            <input id="charge" type="text" class="form-control @error('charge') is-invalid @enderror"
                                    name="charge" autocomplete="off" value="@if(old('charge')){{ old('charge') }}@else{{$waybill->charge}}@endif"  >
                             @error('charge')
-                            <span class="invalid-feedback" role="alert">
-                                        <strong>{{ $message }}</strong>
-                                    </span>
+                            <span class="invalid-feedback" role="alert"><strong>{{ $message }}</strong></span>
                             @enderror
                         </div>
                     </div>
@@ -111,7 +102,7 @@
                     <div class="form-group row">
                         <label for="other_charge" class="col-2 col-form-label text-right text-muted">其他收费(元)</label>
                         <div class="col-8">
-                            <input type="text" class="form-control @error('other_charge') is-invalid @enderror"
+                            <input id="other_charge" type="text" class="form-control @error('other_charge') is-invalid @enderror"
                                    name="other_charge" autocomplete="off" value="@if(old('other_charge')){{ old('other_charge') }}@else{{$waybill->other_charge}}@endif"  >
                             @error('other_charge')
                             <span class="invalid-feedback" role="alert">
@@ -123,7 +114,7 @@
                     <div class="form-group row">
                         <label for="other_charge_remark" class="col-2 col-form-label text-right text-muted">其他收费备注</label>
                         <div class="col-8">
-                            <input type="text" class="form-control @error('other_charge') is-invalid @enderror"
+                            <input id="other_charge_remark" type="text" class="form-control @error('other_charge') is-invalid @enderror"
                                    name="other_charge_remark" autocomplete="off" value="@if(old('other_charge_remark')){{ old('other_charge_remark') }}@else{{$waybill->other_charge_remark}}@endif"  >
                             @error('other_charge_remark')
                             <span class="invalid-feedback" role="alert">
@@ -136,7 +127,7 @@
                     <div class="form-group row">
                         <label for="collect_fee" class="col-2 col-form-label text-right text-muted">到付金额(元)</label>
                         <div class="col-8">
-                            <input type="text" class="form-control @error('collect_fee') is-invalid @enderror"
+                            <input id="collect_fee" type="text" class="form-control @error('collect_fee') is-invalid @enderror"
                                    name="collect_fee" autocomplete="off" value="@if(old('collect_fee')){{ old('collect_fee') }}@else{{$waybill->collect_fee}}@endif"  >
                             @error('collect_fee')
                             <span class="invalid-feedback" role="alert">
@@ -148,7 +139,7 @@
                     <div class="form-group row">
                         <label for="ordering_remark" class="col-2 col-form-label text-right text-muted">下单备注</label>
                         <div class="col-8">
-                            <textarea class="form-control @error('ordering_remark') is-invalid @enderror"
+                            <textarea id="ordering_remark" class="form-control @error('ordering_remark') is-invalid @enderror"
                                       name="ordering_remark" autocomplete="off"  >@if(old('ordering_remark')){{ old('ordering_remark') }}@else{{$waybill->ordering_remark}}@endif</textarea>
                             @error('ordering_remark')
                             <span class="invalid-feedback" role="alert">
@@ -171,9 +162,33 @@
 @section('lastScript')
 <script>
     new Vue({
-        el:"#update",
+        el:"#container",
         data:{
-            type:"{{$waybill->type}}",
+            model:{
+                order_id : "{{old('order_id') ?? $waybill->order_id}}",
+                owner_id : "{{old('owner_id') ?? $waybill->owner_id}}",
+                type:"{{old('type') ?? $waybill->type}}",
+            },
+            order:{},
+        },
+        mounted(){
+            if (this.model.order_id)this._codeGetOrder("{{ old('wms_bill_number') ?? $waybill->wms_bill_number }}");
+        },
+        methods:{
+            bindOrder(e){
+                this.model.order_id = "";
+                this.model.owner_id = "";
+                let val = e.target.value;
+                this._codeGetOrder(val);
+            },
+            _codeGetOrder(val){
+                let url = "{{url('waybill/seekOrder')}}";
+                window.tempTip.postBasicRequest(url,{code:val},res=>{
+                    this.order = res;
+                    this.model.order_id = res.id;
+                    this.model.owner_id = res.owner_id;
+                });
+            },
         },
     });
 </script>

+ 0 - 189
resources/views/waybill/waybillPriceModel/create.blade.php

@@ -1,189 +0,0 @@
-@extends('layouts.app')
-
-@section('content')
-    <div id="nav2">
-        @component('waybill.menu')@endcomponent
-        @component('waybill.waybillPriceModel.menu')@endcomponent
-    </div>
-    <div class="container-fluid" id="list">
-        <div class="card col-md-8 offset-md-2">
-            <div class="card-body">
-                <form method="POST" action="{{ url('waybill/waybillPriceModel') }}">
-                    @if(Session::has('successTip'))
-                        <div class="alert alert-success h1">{{Session::get('successTip')}}</div>
-                    @endif
-                    @csrf
-                    <div class="form-group row">
-                        <label for="logistic_id" class="col-2 col-form-label text-right">承运商</label>
-                        <div class="col-8">
-                            <select class="form-control" name="WaybillPriceModel[logistic_id]" style="width: 30%;" v-model="inputting.WaybillPriceModel.logistic_id">
-                                    <option v-for="logistic in logistics" :value="logistic.id">@{{logistic.name}}</option>
-                            </select>
-                            <div class="col-sm-5">
-                                <p class="form-control-static text-danger small font-weight-bold">{{ $errors->first('WaybillPriceModel.logistic_id') }}</p>
-                            </div>
-                        </div>
-                    </div>
-                    <div class="form-group row">
-                        <label for="province_id"  class="col-2 col-form-label text-right">选择省份</label>
-                        <div class="col-8" >
-                            <select class="form-control" name="WaybillPriceModel[province_id]" style="width: 30%;" v-model="inputting.WaybillPriceModel.province_id" @change="changeProvince($event)">
-                                <option v-for="province in provinces" :value="province.id">@{{province.name}}</option>
-                            </select>
-                            <div class="col-sm-5">
-                                <p class="form-control-static text-danger small font-weight-bold">{{ $errors->first('WaybillPriceModel.province_id') }}</p>
-                            </div>
-                        </div>
-                    </div>
-                    <div class="form-group row">
-                        <label for="city_id"  class="col-2 col-form-label text-right">选择城市</label>
-                        <div class="col-8" >
-                            <select class="form-control" name="WaybillPriceModel[city_id]" style="width: 30%;" v-model="inputting.WaybillPriceModel.city_id">
-                                <option v-for="city in cities" :value="city.id">@{{city.name}}</option>
-                            </select>
-
-                            <div class="col-sm-5">
-                                <p class="form-control-static text-danger small font-weight-bold">{{ $errors->first('WaybillPriceModel.city_id') }}</p>
-                            </div>
-                        </div>
-                    </div>
-                    <div class="form-group row">
-                        <label for="unit_id"  class="col-2 col-form-label text-right">货物单位</label>
-                        <div class="col-8" >
-                            <select class="form-control" name="WaybillPriceModel[unit_id]" style="width: 30%;" v-model="inputting.WaybillPriceModel.unit_id">
-                                <option v-for="unit in units" :value="unit.id">@{{unit.name}}</option>
-                            </select>
-                            <div class="col-sm-5">
-                                <p class="form-control-static text-danger small font-weight-bold">{{ $errors->first('WaybillPriceModel.unit_id') }}</p>
-                            </div>
-                        </div>
-                    </div>
-                    <div class="form-group row">
-                        <label for="range_min" class="col-2 col-form-label text-right">计价区间</label>
-                        <div class="col-8 form-inline">
-                            <input  type="text" style="width: 20%" class="form-control @error('WaybillPriceModel.range_min') is-invalid @enderror"
-                                   name="WaybillPriceModel[range_min]" autocomplete="off" value="{{ old('WaybillPriceModel')['range_min'] }}" >&nbsp;&nbsp;--&nbsp;&nbsp;
-                            <input type="text" style="width: 20%" class="form-control @error('WaybillPriceModel.range_max') is-invalid @enderror"
-                                   name="WaybillPriceModel[range_max]" autocomplete="off" value="{{ old('WaybillPriceModel')['range_max'] }}" >
-                            @error('WaybillPriceModel.range_min')
-                            <span class="invalid-feedback" role="alert">
-                                        <strong>{{ $message }}</strong>
-                                    </span>
-                            @enderror
-                            @error('WaybillPriceModel.range_max')
-                            <span class="invalid-feedback" role="alert">
-                                        <strong>{{ $message }}</strong>
-                                    </span>
-                            @enderror
-                        </div>
-                    </div>
-                    <div class="form-group row">
-                        <label for="unit_price" class="col-2 col-form-label text-right">单价</label>
-                        <div class="col-8">
-                            <input type="text" class="form-control @error('WaybillPriceModel.unit_price') is-invalid @enderror"
-                                   name="WaybillPriceModel[unit_price]" autocomplete="off" value="{{ old('WaybillPriceModel')['unit_price'] }}" >
-                            @error('WaybillPriceModel.unit_price')
-                            <span class="invalid-feedback" role="alert">
-                                        <strong>{{ $message }}</strong>
-                                    </span>
-                            @enderror
-                        </div>
-                    </div>
-                    <div class="form-group row">
-                        <label for="base_fee" class="col-2 col-form-label text-right">起步费(元)</label>
-                        <div class="col-8">
-                            <input type="text" class="form-control @error('WaybillPriceModel.base_fee') is-invalid @enderror"
-                                   name="WaybillPriceModel[base_fee]" autocomplete="off" value="{{ old('WaybillPriceModel')['base_fee'] }}" >
-                            @error('WaybillPriceModel.base_fee')
-                            <span class="invalid-feedback" role="alert">
-                                        <strong>{{ $message }}</strong>
-                                    </span>
-                            @enderror
-                        </div>
-                    </div>
-                    <div class="form-group row">
-                        <label for="initial_weight" class="col-2 col-form-label text-right">最低计数</label>
-                        <div class="col-8">
-                            <input type="text" class="form-control @error('WaybillPriceModel.initial_weight') is-invalid @enderror"
-                                   name="WaybillPriceModel[initial_weight]" autocomplete="off" value="{{ old('WaybillPriceModel')['initial_weight'] }}" >
-                            @error('WaybillPriceModel.initial_weight')
-                            <span class="invalid-feedback" role="alert">
-                                        <strong>{{ $message }}</strong>
-                                    </span>
-                            @enderror
-                        </div>
-                    </div>
-                    <div class="form-group row">
-                        <div class="col-8 offset-2">
-                            <input type="submit" class="btn btn-success form-control">
-                        </div>
-                    </div>
-                </form>
-            </div>
-        </div>
-    </div>
-@endsection
-
-@section('lastScript')
-    <script>
-        let insertVue=new Vue({
-            el:'#list',
-            data:{
-                inputting:{
-                    WaybillPriceModel:{
-                        @if(isset(old('WaybillPriceModel')['province_id']))
-                        province_id:'{{old('WaybillPriceModel')['province_id']}}',
-                        @endif
-                        @if(isset(old('WaybillPriceModel')['city_id']))
-                        city_id:'{{old('WaybillPriceModel')['city_id']}}',
-                        @endif
-                        @if(isset(old('WaybillPriceModel')['logistic_id']))
-                        logistic_id:'{{old('WaybillPriceModel')['logistic_id']}}',
-                        @endif
-                        @if(isset(old('WaybillPriceModel')['unit_id']))
-                        unit_id:'{{old('WaybillPriceModel')['unit_id']}}',
-                        @endif
-                    }
-                },
-                provinces:[
-                    @foreach($provinces as $province)
-                        {id:'{{$province->id}}',name:'{{$province->name}}' },
-                    @endforeach
-                ],
-                cities:[
-                ],
-                logistics:[
-                    @foreach($logistics as $logistic)
-                        {id:'{{$logistic->id}}',name:'{{$logistic->name}}'},
-                    @endforeach
-                ],
-                units:[
-                    @foreach($units as $unit)
-                    {id:'{{$unit->id}}',name:'{{$unit->name}}'},
-                    @endforeach
-                ],
-            },
-           methods:{
-               changeProvince(e){
-                   let _this=this;
-                   let val=e.target.value;
-                   axios.get('cities/'+val).then(
-                        function (response) {
-                            _this.cities=response.data.cities;
-                        }
-                   );
-                   /*let _this=this;
-                   let province_id=this.inputting.WaybillPriceModel.province_id;
-                   this.provinces.forEach(function (province) {
-                       if(province.id+''===province_id+''){
-                           _this.cities=province.cities;
-                           return
-                       }
-                       return null
-                   })*/
-               }
-           },
-        });
-
-    </script>
-@endsection

+ 0 - 200
resources/views/waybill/waybillPriceModel/edit.blade.php

@@ -1,200 +0,0 @@
-@extends('layouts.app')
-
-@section('content')
-    <div id="nav2">
-        @component('waybill.waybillPriceModel.menu')
-                <li class="nav-item">
-                    <a class="nav-link" href="{{URL::current()}}" :class="{active:isActive('edit',4)}">修改</a>
-                </li>
-        @endcomponent
-    </div>
-    <div class="container-fluid" id="list">
-        <div class="card">
-            <div class="card-body">
-                <form method="POST" action='{{url("waybill/waybillPriceModel/{$waybillPriceModel->id}")}}'>
-                    @csrf
-                    @method('PUT')
-                    <div class="form-group row">
-                        <label for="logistic_id" class="col-2 col-form-label text-right">承运商</label>
-                        <div class="col-8">
-                            <select name="WaybillPriceModel[logistic_id]" v-model="inputting.WaybillPriceModel.logistic_id" style="width: 30%;" class="form-control">
-                                <option v-for="logistic in logistics" :value="logistic.id">@{{logistic.name}}</option>
-                            </select>
-
-                            <div class="col-sm-5">
-                                <p class="form-control-static text-danger small font-weight-bold">{{ $errors->first('WaybillPriceModel.logistic_id') }}</p>
-                            </div>
-                        </div>
-                    </div>
-                    <div class="form-group row">
-                        <label for="province_id"  class="col-2 col-form-label text-right">选择省份</label>
-                        <div class="col-8" >
-                            <select name="WaybillPriceModel[province_id]" v-model="inputting.WaybillPriceModel.province_id" @change="changeProvince($event)" style="width: 30%;"
-                            class="form-control">
-                                <option v-for="province in provinces" :value="province.id">@{{province.name}}</option>
-                            </select>
-
-                            <div class="col-sm-5">
-                                <p class="form-control-static text-danger small font-weight-bold">{{ $errors->first('WaybillPriceModel.province_id') }}</p>
-                            </div>
-                        </div>
-                    </div>
-                    <div class="form-group row">
-                        <label for="city_id"  class="col-2 col-form-label text-right">选择城市</label>
-                        <div class="col-8" >
-                            <select name="WaybillPriceModel[city_id]" v-model="inputting.WaybillPriceModel.city_id" style="width: 30%;" class="form-control">
-                                <option v-for="city in cities" :value="city.id">@{{city.name}}</option>
-                            </select>
-
-                            <div class="col-sm-5">
-                                <p class="form-control-static text-danger small font-weight-bold">{{ $errors->first('WaybillPriceModel.city_id') }}</p>
-                            </div>
-                        </div>
-                    </div>
-                    <div class="form-group row">
-                        <label for="unit_id"  class="col-2 col-form-label text-right">货物单位</label>
-                        <div class="col-8" >
-                            <select name="WaybillPriceModel[unit_id]" v-model="inputting.WaybillPriceModel.unit_id" style="width: 30%;" class="form-control">
-                                <option v-for="unit in units" :value="unit.id" >@{{unit.name}}</option>
-                            </select>
-
-                            <div class="col-sm-5">
-                                <p class="form-control-static text-danger small font-weight-bold">{{ $errors->first('WaybillPriceModel.unit_id') }}</p>
-                            </div>
-                        </div>
-                    </div>
-                    <div class="form-group row">
-                        <label for="range_min" class="col-2 col-form-label text-right">计价区间</label>
-                        <div class="col-8 form-inline">
-                            <input type="text" style="width: 20%" class="form-control @error('WaybillPriceModel.range_min') is-invalid @enderror"
-                                   name="WaybillPriceModel[range_min]" autocomplete="off" value="{{old('WaybillPriceModel')['range_min']?old('WaybillPriceModel')['range_min']:$waybillPriceModel->range_min}}" >&nbsp;&nbsp;--&nbsp;&nbsp;
-                            <input type="text"  style="width: 20%" class="form-control @error('WaybillPriceModel.range_max') is-invalid @enderror"
-                                   name="WaybillPriceModel[range_max]" autocomplete="off" value="{{old('WaybillPriceModel')['range_max']?old('WaybillPriceModel')['range_max']:$waybillPriceModel->range_max}}" >
-                            @error('WaybillPriceModel.range_min')
-                            <span class="invalid-feedback" role="alert">
-                                        <strong>{{ $message }}</strong>
-                                    </span>
-                            @enderror
-                            @error('WaybillPriceModel.range_max')
-                            <span class="invalid-feedback" role="alert">
-                                        <strong>{{ $message }}</strong>
-                                    </span>
-                            @enderror
-                        </div>
-                    </div>
-                    <div class="form-group row">
-                        <label for="unit_price" class="col-2 col-form-label text-right">单价</label>
-                        <div class="col-8">
-                            <input type="text"  class="form-control @error('WaybillPriceModel.unit_price') is-invalid @enderror"
-                                   name="WaybillPriceModel[unit_price]" autocomplete="off" value="{{old('WaybillPriceModel')['unit_price']?old('WaybillPriceModel')['unit_price']:$waybillPriceModel->unit_price}}" >
-                            @error('WaybillPriceModel.unit_price')
-                            <span class="invalid-feedback" role="alert">
-                                        <strong>{{ $message }}</strong>
-                                    </span>
-                            @enderror
-                        </div>
-                    </div>
-                    <div class="form-group row">
-                        <label for="base_fee" class="col-2 col-form-label text-right">起步费(元)</label>
-                        <div class="col-8">
-                            <input type="text" class="form-control @error('WaybillPriceModel.base_fee') is-invalid @enderror"
-                                   name="WaybillPriceModel[base_fee]" autocomplete="off" value="{{old('WaybillPriceModel')['base_fee']?old('WaybillPriceModel')['base_fee']:$waybillPriceModel->base_fee}}" >
-                            @error('WaybillPriceModel.base_fee')
-                            <span class="invalid-feedback" role="alert">
-                                        <strong>{{ $message }}</strong>
-                                    </span>
-                            @enderror
-                        </div>
-                    </div>
-                    <div class="form-group row">
-                        <label for="initial_weight" class="col-2 col-form-label text-right">最低计数</label>
-                        <div class="col-8">
-                            <input type="text" class="form-control @error('WaybillPriceModel.initial_weight') is-invalid @enderror"
-                                   name="WaybillPriceModel[initial_weight]" autocomplete="off" value="{{old('WaybillPriceModel')['initial_weight']?old('WaybillPriceModel')['initial_weight']:$waybillPriceModel->initial_weight}}" >
-                            @error('WaybillPriceModel.initial_weight')
-                            <span class="invalid-feedback" role="alert">
-                                        <strong>{{ $message }}</strong>
-                                    </span>
-                            @enderror
-                        </div>
-                    </div>
-                    <div class="form-group row">
-                        <div class="col-8 offset-2">
-                            <input type="submit" class="btn btn-outline-dark form-control">
-                        </div>
-                    </div>
-                </form>
-            </div>
-        </div>
-    </div>
-@endsection
-
-@section('lastScript')
-    <script>
-        let insertVue=new Vue({
-            el:'#list',
-            data:{
-                inputting:{
-                    WaybillPriceModel:{
-                        logistic_id:'{{old('WaybillPriceModel')['logistic_id']?old('WaybillPriceModel')['logistic_id']:$waybillPriceModel->logistic_id}}',
-                        province_id:'{{old('WaybillPriceModel')['province_id']?old('WaybillPriceModel')['province_id']:$waybillPriceModel->province_id}}',
-                        city_id:'{{old('WaybillPriceModel')['city_id']?old('WaybillPriceModel')['city_id']:$waybillPriceModel->city_id}}',
-                        unit_id:'{{old('WaybillPriceModel')['unit_id']?old('WaybillPriceModel')['unit_id']:$waybillPriceModel->unit_id}}',
-                    }
-                },
-                provinces:[
-                    @foreach($provinces as $province)
-                    {id:'{{$province->id}}',name:'{{$province->name}}' },
-                    @endforeach
-                ],
-                cities:[
-                    @foreach($cities as $city)
-                    {id:'{{$city->id}}',name:'{{$city->name}}'},
-                    @endforeach
-                ],
-                logistics:[
-                     @foreach($logistics as $logistic)
-                    {id:'{{$logistic->id}}',name:'{{$logistic->name}}'},
-                    @endforeach
-                ],
-                units:[
-                    @foreach($units as $unit)
-                    {id:'{{$unit->id}}',name:'{{$unit->name}}'},
-                    @endforeach
-                ],
-                waybillPriceModel:[
-                        {id:'{{$waybillPriceModel->id}}',created_at:'{{$waybillPriceModel->created_at}}',
-                            logistic_id:'{{$waybillPriceModel->logistic_id}}',province_id:'{{$waybillPriceModel->province_id}}',
-                        city_id:'{{$waybillPriceModel->city_id}}',unit_id:'{{$waybillPriceModel->unit_id}}',
-                        section:'{{$waybillPriceModel->section}}',unit_price:'{{$waybillPriceModel->unit_price}}',initial_weight:'{{$waybillPriceModel->initial_weight}}'},
-                ]
-            },
-            mounted:function(){
-                this.inputting.WaybillPriceModel.city_id='{{$waybillPriceModel->city_id}}';
-            },
-            methods:{
-                changeProvince(e){
-                    let _this=this;
-                    let val=e.target.value;
-                    axios.get('../cities/'+val).then(
-                        function (response) {
-                            _this.cities=response.data.cities;
-                        }
-                    );
-                }
-            },
-/*                changeProvince(){
-                    let _this=this;
-                    let province_id=this.inputting.WaybillPriceModel.province_id;
-                    this.provinces.forEach(function (province) {
-                        if(province.id+''===province_id+''){
-                            _this.cities=province.cities;
-                            return
-                        }
-                        return null
-                    })
-                }*/
-        });
-
-    </script>
-@endsection

+ 0 - 57
resources/views/waybill/waybillPriceModel/import.blade.php

@@ -1,57 +0,0 @@
-@extends('layouts.app')
-
-@section('content')
-    <div id="nav2">
-        @component('waybill.menu')@endcomponent
-        @component('waybill.waybillPriceModel.menu')@endcomponent
-    </div>
-    <div class="container-fluid">
-        <div class="card col-md-8 offset-md-2">
-            <div class="card-body">
-                <form method="POST" action="{{ url('waybillPriceModel/excel/import') }}" enctype="multipart/form-data" target="_blank">
-                    @csrf
-                    <div class="form-group row text-center">
-                        <div class="col-12 text-danger">
-
-                            注意:请保证表第一行有以下对应的字段名<br>(可不按顺序,承运商,计数单位,省份,单价为必填项,其余字段不填或填入错误数据则导入默认值0):<br>
-                            承运商,计数单位,计数区间,省份,单价,市,起步费,最低计数<br>
-                        </div>
-                        <div class="col-12 text-info ">
-                            导入时间随文件大小可能达数十分钟以上,请耐心等候
-                            <hr>
-                        </div>
-                    </div>
-                    <div class="form-group row">
-                        <label for="sku" class="col-2 col-form-label text-right">选择EXCEL</label>
-                        <div class="col-8">
-                            <div class="form-control">
-                                <input type="file" class="form-control-file @error('file') is-invalid @enderror"
-                                       name="file" value="{{ old('file') }}" required>
-                                @error('file')
-                                <span class="invalid-feedback" role="alert">
-                                <strong>{{ $message }}</strong>
-                            </span>
-                                @enderror
-                            </div>
-                        </div>
-                    </div>
-                    <div class="form-group row">
-                        <label for="sku" class="col-2 col-form-label text-right">是否覆盖</label>
-                        <div class="col-8">
-                            <select name="isOverride" id="isOverride" class="form-control" >
-                                <option value="0">仅新增</option>
-                                <option value="1">新增且覆盖</option>
-                            </select>
-                            <p class="text-muted">覆盖会以承运商,计数单位,计数区间,省份为依据,覆盖其余字段</p>
-                        </div>
-                    </div>
-                    <div class="form-group row">
-                        <div class="col-8 offset-2">
-                            <input type="submit" class="btn btn-success form-control" value="执行导入">
-                        </div>
-                    </div>
-                </form>
-            </div>
-        </div>
-    </div>
-@endsection

+ 0 - 166
resources/views/waybill/waybillPriceModel/index.blade.php

@@ -1,166 +0,0 @@
-
-@extends('layouts.app')
-
-@section('content')
-    <span id="nav2">
-        @component('waybill.menu')@endcomponent
-        @component('waybill.waybillPriceModel.menu')@endcomponent
-    </span>
-    <div id="list">
-    <div class="container-fluid">
-        <div class="card">
-            <div>
-                <form  method="GET" action="{{url('waybill/waybillPriceModel')}}" id="optionSubmit">
-                    <table class="table  table-sm table-bordered table-hover text-nowrap ">
-                        <tr>
-                            <td  > <label style="margin-left: 2%" class="form-inline">页显示条数:
-                                <select name="paginate" v-model="filterData.paginate" class="form-control" @change="setPaginate">
-                                    <option value="50">50行</option>
-                                    <option value="100">100行</option>
-                                    <option value="200">200行</option>
-                                    <option value="500">500行</option>
-                                    <option value="1000">1000行</option>
-                                </select></label></td>
-                            <td > <label class="form-inline" style="margin-left: 2%">承运商:
-                                <select name="logistic_id" v-model="filterData.logistic_id" class="form-control"  @change="setCarrier">
-                                    <option >    </option>
-                                    @foreach($logistics as $logistic)
-                                        <option value="{{$logistic->id}}">{{$logistic->name}}</option>
-                                    @endforeach
-                                </select></label></td>
-                            <td><label class="form-inline" style="margin-left: 2%">省份:
-                                <select name="province_id" v-model="filterData.province_id" class="form-control" @change="setProvince">
-                                    <option>    </option>
-                                    @foreach($provinces as $province)
-                                        <option value="{{$province->id}}">{{$province->name}}</option>
-                                    @endforeach
-                                </select><input hidden type="submit" ></label></td>
-                        </tr>
-                    </table>
-                </form>
-            </div>
-            <div class="card-body">
-                @if(Session::has('successTip'))
-                    <div class="alert alert-success h1">{{Session::get('successTip')}}</div>
-                @endif
-                <table class="table table-striped table-sm">
-                    <tr>
-                        <th>代码</th>
-                        <th>承运商名称</th>
-                        <th>省份</th>
-                        <th>城市</th>
-                        <th>计重单位</th>
-                        <th>区间</th>
-                        <th>单价(元)</th>
-                        <th>起步费(元)</th>
-                        <th>最低计数</th>
-                        <th>录入时间</th>
-                    </tr>
-                    <tr v-for="waybillPriceModel in waybillPriceModels">
-                        <td class="text-muted">@{{waybillPriceModel.id}}</td>
-                        <td>@{{waybillPriceModel.carrier}}</td>
-                        <td>@{{waybillPriceModel.province}}</td>
-                        <td>@{{waybillPriceModel.city}}</td>
-                        <td>@{{waybillPriceModel.unit}}</td>
-                        <td>@{{waybillPriceModel.range_min}}<a v-if="waybillPriceModel.range_min&&waybillPriceModel.range_max">&nbsp;&nbsp;--&nbsp;&nbsp;</a> @{{waybillPriceModel.range_max}}</td>
-                        <td>@{{waybillPriceModel.unit_price}}</td>
-                        <td>@{{waybillPriceModel.base_fee}}</td>
-                        <td>@{{waybillPriceModel.initial_weight}}</td>
-                        <td class="text-muted">@{{waybillPriceModel.created_at}}</td>
-                        <td>
-                            @can('计费模型-编辑')
-                                <button class="btn btn-sm btn-outline-primary" @click="edit(waybillPriceModel.id)">改</button> @endcan
-                            @can('计费模型-删除')
-                                <button class="btn btn-sm btn-outline-dark" @click="destroy(waybillPriceModel)">删</button> @endcan
-                        </td>
-                    </tr>
-                </table>
-                {{$waybillPriceModels->appends($filterData)->links()}}
-            </div>
-        </div>
-    </div>
-    </div>
-@endsection
-
-@section('lastScript')
-    <script>
-        new Vue({
-            el:"#list",
-            data:{
-                waybillPriceModels:[
-                    @foreach( $waybillPriceModels as $waybillPriceModel )
-                        {id:'{{$waybillPriceModel->id}}',carrier:'{{$waybillPriceModel->carrier_name}}',
-                        province:'{{$waybillPriceModel->province_name}}',city:'{{$waybillPriceModel->city_name}}',
-                        unit:'{{$waybillPriceModel->unit_name}}',range_min:'{{$waybillPriceModel->range_min}}',range_max:'{{$waybillPriceModel->range_max}}',
-                        unit_price:'{{$waybillPriceModel->unit_price}}',base_fee:'{{$waybillPriceModel->base_fee}}',initial_weight:'{{$waybillPriceModel->initial_weight}}',
-                        created_at:'{{$waybillPriceModel->created_at}}'},
-                    @endforeach
-                ],
-                filterData:
-                    {paginate:'50',logistic_id:'',province_id: ''},
-            },
-            mounted:function(){
-                this.initInputs();
-            },
-            methods:{
-                edit:function(id){
-                    location.href = "{{url('waybill/waybillPriceModel')}}/"+id+"/edit";
-                },
-                destroy:function(waybillPriceModel){
-                    if(!confirm('确定要删除该计费模型吗?')){return};
-                    let data=this;
-                    let url = "{{url('waybill/waybillPriceModel')}}/"+waybillPriceModel.id;
-                    axios.delete(url,{id:waybillPriceModel.id})
-                        .then(function (response) {
-                            if(response.data.success){
-                                for (let i = 0; i < data.waybillPriceModels.length; i++) {
-                                    if (data.waybillPriceModels[i].id===waybillPriceModel.id){
-                                        data.waybillPriceModels.splice(i,1);
-                                        break;
-                                    }
-                                }
-                                tempTip.setDuration(1000);
-                                tempTip.showSuccess('删除计费模型成功!')
-                            }else{
-                                tempTip.setDuration(1000);
-                                tempTip.show('删除计费模型失败!')
-                            }
-                        })
-                        .catch(function (err) {
-                            tempTip.setDuration(3000);
-                            tempTip.show('删除计费模型失败!'+'网络错误:' + err);
-                        });
-                },
-                initInputs:function(){
-                    let data=this;
-                    let uriParts =decodeURI(location.href).split("?");
-                    if(uriParts.length>1){
-                        let params = uriParts[1].split('&');
-                        params.forEach(function(paramPair){
-                            let pair=paramPair.split('=');
-                            let key = pair[0], val = pair[1];
-                            $('input[name="'+key+'"]').val(val);
-                            $('select[name="'+key+'"]').val(val);
-                            decodeURI(data.filterData[key]=val);
-                        });
-                    }
-                },
-                setPaginate:function(e){
-                    this.filterData.paginate=e.target.value;
-                    var form = document.getElementById("optionSubmit");
-                    form.submit();
-                },
-                setCarrier:function (e){
-                    this.filterData.logistic_id=e.target.value;
-                    var form = document.getElementById("optionSubmit");
-                    form.submit();
-                },
-                setProvince:function (e){
-                    this.filterData.province_id=e.target.value;
-                    var form = document.getElementById("optionSubmit");
-                    form.submit();
-                },
-            }
-        });
-    </script>
-@endsection

+ 0 - 19
resources/views/waybill/waybillPriceModel/menu.blade.php

@@ -1,19 +0,0 @@
-<div class="container-fluid nav3">
-    <div class="card menu-third" >
-        <ul class="nav nav-pills">
-            @can('计费模型-查询')
-                <li class="nav-item">
-                    <a target="waybill/waybillPriceModel" class="nav-link" href="{{url('waybill/waybillPriceModel')}}" :class="{active:isActive('',3)}">查询</a>
-                </li> @endcan
-            @can('计费模型-录入')
-                <li class="nav-item">
-                    <a target="waybill/waybillPriceModel/create" class="nav-link" href="{{url('waybill/waybillPriceModel/create')}}" :class="{active:isActive('create',3)}">录入</a>
-                </li> @endcan
-            @can('计费模型-录入')
-                <li class="nav-item">
-                    <a target="waybill/waybillPriceModel/excel/goImport" class="nav-link" href="{{url('waybill/waybillPriceModel/excel/goImport')}}" :class="{active:isActive('goImport',4)}">导入</a>
-                </li> @endcan
-            {{$slot}}
-        </ul>
-    </div>
-</div>

+ 4 - 3
routes/web.php

@@ -83,9 +83,9 @@ Route::group(['prefix'=>'maintenance'],function(){
             Route::group(['prefix'=>'excel'],function(){
                 Route::get('goImport',function (){return view('maintenance.priceModel.waybillPriceModel.import');});
             });
-            Route::get('cities/{province_id}','WaybillPriceModelsController@getCities');
+            Route::get('cities/{province_id}','WaybillPriceModelController@getCities');
         });
-        Route::resource('waybillPriceModel','WaybillPriceModelsController');
+        Route::resource('waybillPriceModel','WaybillPriceModelController');
 
         Route::group(['prefix'=>'storage'],function(){
             Route::get('create','PriceModelController@storageCreate');
@@ -257,6 +257,7 @@ Route::group(['prefix'=>'waybill'],function(){
         Route::post('waybillPriceModel','WaybillController@isWaybillPriceModel');
     });
     Route::post('deleteImg','WaybillController@deleteImg');
+    Route::post('seekOrder','WaybillController@seekOrder');
     Route::post('upload','WaybillController@upload');
     Route::get('relating',function (){return view('waybill.menuWaybill');});
     Route::get('recycle', 'WaybillController@recycle');
@@ -288,7 +289,7 @@ Route::group(['prefix'=>'waybillFinancialSnapshot'],function(){
 Route::group(['prefix'=>'waybillPriceModel'],function(){
     /** excel */
     Route::group(['prefix'=>'excel'],function(){
-        Route::post('import','WaybillPriceModelsController@import');
+        Route::post('import','WaybillPriceModelController@import');
     });
 });