Zhouzhendong 4 rokov pred
rodič
commit
cfda067015

+ 49 - 0
app/Http/Controllers/WaybillController.php

@@ -1214,9 +1214,11 @@ SQL;
      */
     public function shipmentAndMerge()
     {
+        $this->gate("运输管理-编辑");
         $waybill = Waybill::query()->where("waybill_number",\request("waybill"))->whereNull("deliver_at")
             ->whereNotIn("status",["已完结","无模型"])->first();
         if (!$waybill)$this->error("运单禁止操作");
+        if ($waybill->deliver_at)$this->error("运单已发货,请勿重复调配");
         $codes = explode("\n",\request("order"));
         $waybills = Waybill::query()->whereIn("wms_bill_number",$codes)
             ->where("id","!=",$waybill->id)
@@ -1273,4 +1275,51 @@ SQL;
     {
         return view("transport.waybill.android.dispatch");
     }
+
+    /**
+     * 搜索运单获取信息
+     */
+    public function searchWaybill()
+    {
+        $this->success($this->dispatchCheck(\request("bill")));
+    }
+
+    private function dispatchCheck($bill)
+    {
+        if (!$bill)$this->error("参数异常");
+        $waybill = Waybill::query()->select(["carrier_bill","inquire_tel","carrier_weight_other","carrier_weight","amount","deliver_at"])
+            ->where("code",$bill)->whereNotIn("status",["已完结","无模型"])->first();
+        if(!$waybill)$this->error("非法运单号");
+        if ($waybill->carrier_bill)$this->error("运单已发货,请勿重复调配");
+        if (!$waybill->deliver_at)$this->error("运单未发货,无法调配");
+        return $waybill;
+    }
+
+    /**
+     * 调配
+     *
+     */
+    public function dispatchSubmit()
+    {
+        $this->gate("运输管理-编辑");
+        $waybill = $this->dispatchCheck(\request("waybill"));
+        $unit = app("UnitService")->getUnit("kg");
+        $unit1 = app("UnitService")->getUnit("件");
+        $waybill->update([
+            "carrier_bill"  => \request("waybill"),
+            "inquire_tel"   => \request("phone"),
+            "carrier_weight_other" => \request("volume"),
+            "carrier_weight" => \request("weight"),
+            "amount" => \request("amount"),
+            "amount_unit_id" => $unit->id,
+            "carrier_weight_unit_id" => $unit->id,
+            "carrier_weight_unit_id_other" => $unit1->id,
+        ]);
+        WaybillAuditLog::query()->create([
+            'waybill_id'=>$waybill->id,
+            'audit_stage'=>'调度阶段',
+            'user_id'=>Auth::id(),
+        ]);
+        $this->success();
+    }
 }

+ 2 - 2
app/Services/UnitService.php

@@ -86,8 +86,8 @@ class UnitService
      */
     public function getUnit(?string $name = null):?Unit
     {
-        if (!$name)return Unit::query()->firstOrCreate(["name"=>"件"]);
-        return Unit::query()->where("name",$name)->first();
+        if (!$name)$name = "件";
+        return Unit::query()->where("name",$name)->firstOrCreate(["name"=>$name]);
     }
 
 }

+ 2 - 0
resources/views/store/inStorage/androidIndex.blade.php

@@ -27,6 +27,8 @@
                 <a href="{{url('store/inStorage/boxBindModel')}}"><button class="btn btn-info w-75 h-25 mt-3 text-white" style="height: 60px"><h4>料箱型号</h4></button></a>
                 <a href="{{url('store/inStorage/commodityBindModel')}}"><button class="btn btn-info w-75 h-25 mt-3 text-white" style="height: 60px"><h4>商品型号</h4></button></a>
                 <a href="{{url('store/blindReceive')}}"><button class="btn btn-info w-75 h-25 mt-3 text-white" style="height: 60px"><h4>盲收</h4></button></a>
+                @can("运输管理-编辑")<a href="{{url('transport/waybill/android/shipment')}}"><button class="btn btn-info w-75 h-25 mt-3 text-white" style="height: 60px"><h4>运单发货</h4></button></a>
+                <a href="{{url('transport/waybill/android/waybillDispatch')}}"><button class="btn btn-info w-75 h-25 mt-3 text-white" style="height: 60px"><h4>运单调配</h4></button></a>@endcan
 
     <a href="{{ route('logout') }}" onclick="event.preventDefault();
                                                      document.getElementById('logout-form').submit();">

+ 20 - 3
resources/views/transport/waybill/android/dispatch.blade.php

@@ -6,7 +6,7 @@
         <div class="mt-3 col-8 offset-2">
             <div class="form-group row">
                 <label for="waybill">运单号</label>
-                <input id="waybill" type="text" class="form-control" v-model="info.waybill" @keydown.enter="enterVal($event)"></input>
+                <input id="waybill" type="text" class="form-control" v-model="info.waybill" @keydown.enter="enterVal($event)" @blur="searchWaybill()"></input>
             </div>
             <div class="form-group row">
                 <label for="logistic">物流单号</label>
@@ -44,7 +44,7 @@
                 </div>
             </div>
             <div class="input-group row">
-                <button type="submit" id="submit" class="btn btn-success offset-2 col-10" @click="executeSubmit()">提交调配信息</button>
+                <button type="submit" id="submit" class="btn btn-success offset-2 col-10" @click="executeSubmit()" @keydown.enter="executeSubmit()">提交调配信息</button>
             </div>
         </div>
     </div>
@@ -57,7 +57,7 @@
             data:{
                 isAndroid:false,
                 info:{},
-                element:["waybill","logistic"],
+                element:["waybill","logistic","phone","amount","weight","volume","submit"],
                 counter:0,
             },
             mounted(){
@@ -90,6 +90,23 @@
                     e.preventDefault();
                     return false;
                 },
+                searchWaybill(){
+                    let bill = event.target.value;
+                    if (!bill)return;
+                    window.tempTip.postBasicRequest("{{url('transport/waybill/android/searchWaybill')}}",{bill:bill},res=>{
+                        if (!this.info.logistic)this.info.logistic = res.carrier_bill;
+                        if (!this.info.phone)this.info.phone = res.inquire_tel;
+                        if (!this.info.amount)this.info.amount = res.amount;
+                        if (!this.info.weight)this.info.weight = res.carrier_weight;
+                        if (!this.info.volume)this.info.volume = res.carrier_weight_other;
+                    });
+                },
+                executeSubmit(){
+                    window.tempTip.postBasicRequest("{{url('transport/waybill/android/waybillDispatch')}}",this.info,res=>{
+                        this.info = {};
+                        return "调配成功";
+                    });
+                },
             },
         });
     </script>

+ 2 - 0
routes/web.php

@@ -351,6 +351,8 @@ Route::group(['middleware'=>'auth'],function ($route){
                 Route::get("shipment",'WaybillController@shipment');
                 Route::post("shipment",'WaybillController@shipmentAndMerge');
                 Route::get("waybillDispatch",'WaybillController@waybillDispatch');
+                Route::post("searchWaybill",'WaybillController@searchWaybill');
+                Route::post("waybillDispatch",'WaybillController@dispatchSubmit');
             });
             /** 置顶 */
             Route::group(['prefix'=>'ontop'],function(){