Sfoglia il codice sorgente

运输管理-调度时可以录入空市县的BUG修复

Zhouzhendong 5 anni fa
parent
commit
fb82224cf8

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

@@ -292,6 +292,7 @@ class TestController extends Controller
     /*1*/
     function test(Request $request)
     {/**/
+        return Unit::query()->updateOrCreate(['id' => 1],['name' => 'kg']);
     }
 
 }

+ 40 - 78
app/Http/Controllers/WaybillController.php

@@ -8,6 +8,8 @@ use App\Services\CarTypeService;
 use App\Services\CityService;
 use App\Services\OwnerService;
 use App\Services\UnitService;
+use App\Services\WaybillPayoffService;
+use App\Services\WaybillPriceModelService;
 use App\Services\WaybillService;
 use App\UploadFile;
 use App\WaybillAuditLog;
@@ -93,10 +95,10 @@ class WaybillController extends Controller
         return view('waybill/edit',['waybill'=>$waybill,'carriers'=>$carrierService->getSelection(),'cities'=>$cities,'units'=>$units,'carTypes'=>$carTypes]);
     }
 
-    public function update(Request $request, $id , CityService $cityService)
+    public function update(Request $request, $id,WaybillPriceModelService $waybillPriceModelService,
+                        CarrierService $carrierService,WaybillPayoffService $waybillPayoffService)
     {
         if(!Gate::allows('运输管理-调度')){ return redirect(url('/'));  }
-        $waybill=app('waybillService')->find($id);
         if (!$request->warehouse_weight && $request->warehouse_weight_unit_id){
             $request->offsetUnset('warehouse_weight_unit_id');
         }
@@ -110,86 +112,45 @@ class WaybillController extends Controller
             $request->offsetUnset('carrier_weight_unit_id_other');
         }
         $this->validatorWaybillDispatch($request,$id)->validate();
-        //替换换行符
-        if ($request->dispatch_remark){
-            $request->dispatch_remark = str_replace(PHP_EOL,' ',$request->dispatch_remark);
-        }
-        if (!$request->destination)$request->destination = $waybill->destination;
-        if ($request->destination_city_id && $waybill->destination_city_id != $request->destination_city_id){
-            $city=$cityService->find($request->destination_city_id);
-            if ($city && (mb_strpos($request->destination,$city->name)===false || mb_strpos($request->destination,$city->province_name)===false)){
-                if (mb_strpos($request->destination,$city->name)===false && mb_strpos($request->destination,$city->province_name)===false){
-                    $request->destination=$city->province_name.$city->name.$request->destination;
-                    goto sign;
-                }
-                if (mb_strpos($request->destination,$city->province_name)===false){
-                    $request->destination=$city->province_name.$request->destination;
+        $waybillPayoffParam = [];
+        $waybillPayoffParam['total_receivable']=0;
+        $waybill = app('waybillService')->update($request,$id);
+        if ($waybill->type=="直发车"){
+            if ($waybill->charge)$waybillPayoffParam['total_receivable'] = ($waybill->charge);
+            elseif ($waybill->collect_fee)$waybillPayoffParam['total_receivable'] = ($waybill->collect_fee);
+            $waybillPayoffParam['total_expense'] = ($waybill->fee)+($waybill->other_fee)-($waybill->collect_fee);
+        }else {
+            $waybillPriceModel_id=$request->input('waybillPriceModel');
+            if ($waybillPriceModel_id){
+                $carrier_weight=$request->input('carrier_weight');
+                $waybillPriceModel=$waybillPriceModelService->find($waybillPriceModel_id);
+                $carrier=$carrierService->find($waybill->carrier_id);
+                if ($carrier_weight<$waybillPriceModel->initial_weight){
+                    $fee=(($waybillPriceModel->unit_price)*($waybillPriceModel->initial_weight))+$carrier->delivery_fee;
+                }else{
+                    $fee=(($waybillPriceModel->unit_price)*$carrier_weight)+$carrier->delivery_fee;
                 }
-                if (mb_strpos($request->destination,$city->name)===false){
-                    $province_name=$city->province_name;
-                    $start_index=mb_strpos($request->destination,$city->province_name.'省');
-                    if ($start_index===false)$start_index=mb_strpos($request->destination,$city->province_name);
-                    else $province_name=$province_name.'省';
-                    $strBefore=mb_substr($request->destination,$start_index,mb_strlen($province_name));
-                    $strAfter=mb_substr($request->destination,$start_index+mb_strlen($province_name));
-                    $request->destination=$strBefore.$city->name.$strAfter;
+                if ($waybillPriceModel->base_fee&&$fee<$waybillPriceModel->base_fee){
+                    $fee=$waybillPriceModel->base_fee;
                 }
+                $waybill->fee=$fee;
+                $waybill->waybill_price_model_id=$waybillPriceModel_id;
             }
-        }
-        sign:
-        $total_receivable=0;
-        $waybill->fill($request->input());
-        if ($waybill->save()){
-            if ($waybill->type=="直发车"){
-                if ($waybill->charge)$total_receivable=($waybill->charge);
-                elseif ($waybill->collect_fee)$total_receivable=($waybill->collect_fee);
-                $total_expense=($waybill->fee)+($waybill->other_fee)-($waybill->collect_fee);
-            }else {
-                $waybillPriceModel_id=$request->input('waybillPriceModel');
-                if ($waybillPriceModel_id){
-                    $carrier_weight=$request->input('carrier_weight');
-                    $waybillPriceModel=WaybillPriceModel::find($waybillPriceModel_id);
-                    $carrier=Carrier::find($waybill->carrier_id);
-                    if ($carrier_weight<$waybillPriceModel->initial_weight){
-                        $fee=(($waybillPriceModel->unit_price)*($waybillPriceModel->initial_weight))+$carrier->delivery_fee;
-                    }else{
-                        $fee=(($waybillPriceModel->unit_price)*$carrier_weight)+$carrier->delivery_fee;
-                    }
-                    if ($waybillPriceModel->base_fee&&$fee<$waybillPriceModel->base_fee){
-                        $fee=$waybillPriceModel->base_fee;
-                    }
-                    $waybill->fee=$fee;
-                    $waybill->waybill_price_model_id=$waybillPriceModel_id;
-                }
-                $waybill->save();
-                if ($waybill->charge)$total_receivable=($waybill->charge);
-                elseif($waybill->collect_fee) {
-                    $total_receivable=($waybill->collect_fee);
-                }
-                $total_expense=($waybill->pick_up_fee)+($waybill->other_fee)+($waybill->fee);
+            $waybill->save();
+            if ($waybill->charge)$waybillPayoffParam['total_receivable'] = ($waybill->charge);
+            elseif($waybill->collect_fee) {
+                $waybillPayoffParam['total_receivable'] = $waybill->collect_fee;
             }
-            if ($total_receivable>0){
-                $waybillPayoff=WaybillPayoff::where('waybill_id','=',$id)->first();
-                if ($waybillPayoff){
-                    $waybillPayoff->waybill_id=$id;
-                    $waybillPayoff->total_expense=$total_expense;
-                    $waybillPayoff->total_receivable=$total_receivable;
-                    $waybillPayoff->gross_margin=$total_receivable-$total_expense;
-                    $waybillPayoff->gross_profit_rate=(($total_receivable-$total_expense)/$total_receivable);
-                    $waybillPayoff->save();
-                }else{
-                    WaybillPayoff::create([
-                        'waybill_id'=>$id,
-                        'total_expense'=>$total_expense,
-                        'total_receivable'=>$total_receivable,
-                        'gross_margin'=>$total_receivable-$total_expense,
-                        'gross_profit_rate'=>(($total_receivable-$total_expense)/$total_receivable),
-                    ]);
-                };
-            }
-            $this->log(__METHOD__,__FUNCTION__,json_encode($request->toArray()),Auth::user()['id']);
-            return redirect('waybill/index')->with('successTip','运单“'.$waybill->waybill_number.'”调度成功');
+            $waybillPayoffParam['total_expense'] = ($waybill->pick_up_fee)+($waybill->other_fee)+($waybill->fee);
+        }
+        if ($waybillPayoffParam['total_receivable'] > 0){
+            $waybillPayoffParam['waybill_id'] = $id;
+            $waybillPayoffParam['gross_margin'] = $waybillPayoffParam['total_receivable'] - $waybillPayoffParam['total_expense'];
+            $waybillPayoffParam['gross_profit_rate'] = $waybillPayoffParam['gross_margin']/$waybillPayoffParam['total_receivable'];
+            $waybillPayoffService->updateOrCreate($waybillPayoffParam);
         }
+        $this->log(__METHOD__,__FUNCTION__,json_encode($request->toArray()),Auth::user()['id']);
+        return redirect('waybill/index')->with('successTip','运单“'.$waybill->waybill_number.'”调度成功');
     }
 
     public function checkWaybillPriceModel($carrier_id,$destination_city_id,$carrier_weight,$carrier_weight_unit_id){
@@ -259,7 +220,7 @@ class WaybillController extends Controller
                 }
             }
             if ($waybillPriceModelProvinceRangeOne)return $waybillPriceModelProvinceRangeOne->id;
-            if ($waybillPriceModelProvinceRangeOne)return $waybillPriceModelProvinceRangeOne->id;
+            if ($waybillPriceModelProvinceRangeTwo)return $waybillPriceModelProvinceRangeTwo->id;
         };
         for ($i=0;$i<count($carrier_weight);$i++){
             if ($carrier_weight[$i]&&$carrier_weight_unit_id[$i]){
@@ -797,6 +758,7 @@ class WaybillController extends Controller
         return $validator;
     }
     public function addCounty(Request $request){
+        if ($request->destination_city =='undefined')$request->offsetUnset('destination_city');
         $rule =[
             'destination_city' => ['required', 'string','unique:cities,name'],
         ];

+ 3 - 0
app/Services/CarrierService.php

@@ -10,4 +10,7 @@ Class CarrierService
         return Carrier::query()->select('id','name')->get();
     }
 
+    public function find($id){
+        return Carrier::query()->find($id);
+    }
 }

+ 13 - 0
app/Services/WaybillPayoffService.php

@@ -0,0 +1,13 @@
+<?php 
+
+namespace App\Services; 
+
+use App\WaybillPayoff;
+
+Class WaybillPayoffService
+{ 
+    public function updateOrCreate(array $waybillPayoffParam){
+        return WaybillPayoff::query()->updateOrCreate(['waybill_id' => $waybillPayoffParam['waybill_id']],$waybillPayoffParam);
+    }
+
+}

+ 13 - 0
app/Services/WaybillPriceModelService.php

@@ -0,0 +1,13 @@
+<?php 
+
+namespace App\Services; 
+
+use App\WaybillPriceModel;
+
+Class WaybillPriceModelService
+{ 
+    public function find($id){
+        return WaybillPriceModel::query()->find($id);
+    }
+
+}

+ 34 - 0
app/Services/WaybillService.php

@@ -82,4 +82,38 @@ Class WaybillService
     public function find($id){
         return Waybill::query()->find($id);
     }
+
+    public function update(Request $request,$id)
+    {
+        $waybill = $this->find($id);
+        //替换换行符
+        if ($request->dispatch_remark) {
+            $request->offsetSet('dispatch_remark', str_replace(PHP_EOL, ' ', $request->dispatch_remark));
+        }
+        if (!$request->destination) $request->offsetSet('destination', $waybill->destination);
+        if ($request->destination_city_id && $waybill->destination_city_id != $request->destination_city_id) {
+            $city = app(CityService::class)->find($request->destination_city_id);
+            if ($city && (mb_strpos($request->destination, $city->name) === false || mb_strpos($request->destination, $city->province_name) === false)) {
+                if (mb_strpos($request->destination, $city->name) === false && mb_strpos($request->destination, $city->province_name) === false) {
+                    $request->offsetSet('destination', $city->province_name . $city->name . $request->destination);
+                    goto sign;
+                }
+                if (mb_strpos($request->destination, $city->province_name) === false) {
+                    $request->offsetSet('destination', $city->province_name . $request->destination);
+                }
+                if (mb_strpos($request->destination, $city->name) === false) {
+                    $province_name = $city->province_name;
+                    $start_index = mb_strpos($request->destination, $city->province_name . '省');
+                    if ($start_index === false) $start_index = mb_strpos($request->destination, $city->province_name);
+                    else $province_name = $province_name . '省';
+                    $strBefore = mb_substr($request->destination, $start_index, mb_strlen($province_name));
+                    $strAfter = mb_substr($request->destination, $start_index + mb_strlen($province_name));
+                    $request->offsetSet('destination', $strBefore . $city->name . $strAfter);
+                }
+            }
+        }
+        sign:
+        $waybill->fill($request->input());
+        return $waybill;
+    }
 }

+ 13 - 9
public/js/app.js

@@ -61856,6 +61856,10 @@ module.exports = scanner;
 var tempTip = {
   fadingDuration: 4500,
   inputType: 'input',
+  index: 99,
+  setIndex: function setIndex(index) {
+    this.index = parseInt(index);
+  },
   setDuration: function setDuration(milliSec) {
     this.fadingDuration = parseInt(milliSec);
   },
@@ -61872,7 +61876,7 @@ var tempTip = {
     $('body').append(tiper);
   },
   show: function show(text) {
-    var tiper = $("<div class='row' style='color:white;opacity:0.9;position:fixed;top:40%;transform:translateY(-50%);width:100%;'>" + "<div class='col-8 offset-2'><div class='card'><div class='card-body h2 bg-danger text-center'>" + text + "</div></div></div></div>");
+    var tiper = $("<div class='row' style='color:white;opacity:0.9;position:fixed;top:40%;transform:translateY(-50%);width:100%;z-index:" + this.index + ";'>" + "<div class='col-8 offset-2'><div class='card'><div class='card-body h2 bg-danger text-center'>" + text + "</div></div></div></div>");
     tiper.animate({
       opacity: '0'
     }, this.fadingDuration, 'swing', function () {
@@ -61881,9 +61885,9 @@ var tempTip = {
     $('body').append(tiper);
   },
   okWindow: function okWindow(text, okText) {
-    var bg = $("<div style='opacity:0.4;position:fixed;top:0;width:100%;height:100%;z-index:98;background-color:#000;'></div>");
+    var bg = $("<div style='opacity:0.4;position:fixed;top:0;width:100%;height:100%;z-index:" + this.index + ";background-color:#000;'></div>");
     if (typeof okText == 'undefined') okText = '确定';
-    var tiper = $("<div class='row' style='opacity:0.9;position:fixed;top:40%;transform:translateY(-50%);width:100%;z-index:99'>" + "<div class='col-8 offset-2'><div class='card'><div class='card-body h2 text-center'>" + text + "<p><button class='btn btn-success btn-lg okWindow'>" + okText + "</button></p><div>" + "</div></div></div>");
+    var tiper = $("<div class='row' style='opacity:0.9;position:fixed;top:40%;transform:translateY(-50%);width:100%;z-index:" + (this.index + 1) + "'>" + "<div class='col-8 offset-2'><div class='card'><div class='card-body h2 text-center'>" + text + "<p><button class='btn btn-success btn-lg okWindow'>" + okText + "</button></p><div>" + "</div></div></div>");
     tiper.find('.okWindow').on('click', function () {
       tiper.off('click');
       tiper.remove();
@@ -61893,8 +61897,8 @@ var tempTip = {
     $('body').append(tiper);
   },
   waitingTip: function waitingTip(text) {
-    var bg = $("<div style='opacity:0.4;position:fixed;top:0;width:100%;height:100%;z-index:98;background-color:#fff;' class='tipperBg'></div>");
-    var tipper = $("<div class='row tipper' style='color:white;opacity:0.9;position:fixed;top:40%;transform:translateY(-50%);width:100%;z-index:99;'>" + "<div class='col-8 offset-2'><div class='card-body h5 bg-dark text-center' style='border-radius: 50px'>" + text + "</div></div></div>");
+    var bg = $("<div style='opacity:0.4;position:fixed;top:0;width:100%;height:100%;z-index:" + this.index + ";background-color:#fff;' class='tipperBg'></div>");
+    var tipper = $("<div class='row tipper' style='color:white;opacity:0.9;position:fixed;top:40%;transform:translateY(-50%);width:100%;z-index:" + (this.index + 1) + ";'>" + "<div class='col-8 offset-2'><div class='card-body h5 bg-dark text-center' style='border-radius: 50px'>" + text + "</div></div></div>");
     tipper.animate({
       opacity: '0'
     }, this.fadingDuration, 'swing', function () {
@@ -61911,8 +61915,8 @@ var tempTip = {
     bg.remove();
   },
   confirm: function confirm(text, yesFunc, noFunc) {
-    var bg = $("<div style='opacity:0.4;position:fixed;top:0;width:100%;height:100%;z-index:98;background-color:#000;'></div>");
-    var tiper = $("<div class='row' style='color:#000;opacity:0.9;position:fixed;top:40%;transform:translateY(-50%);width:100%;z-index:99'>" + "<div class='col-8 offset-2'><div class='card'><div class='card-body'><div class='card-title h4'>" + text + "</div><div class='card-text'><button class='btn btn-dark btn-lg ok'>确定</button>" + "<button class='btn btn-success btn-lg cancel ml-4'>取消</button></div>" + "</div></div></div></div>");
+    var bg = $("<div style='opacity:0.4;position:fixed;top:0;width:100%;height:100%;z-index:" + this.index + ";background-color:#000;'></div>");
+    var tiper = $("<div class='row' style='color:#000;opacity:0.9;position:fixed;top:40%;transform:translateY(-50%);width:100%;z-index:" + (this.index + 1) + "'>" + "<div class='col-8 offset-2'><div class='card'><div class='card-body'><div class='card-title h4'>" + text + "</div><div class='card-text'><button class='btn btn-dark btn-lg ok'>确定</button>" + "<button class='btn btn-success btn-lg cancel ml-4'>取消</button></div>" + "</div></div></div></div>");
     var $ok = tiper.find('.ok');
     var $cancel = tiper.find('.cancel');
     $ok.on('click', function () {
@@ -61933,8 +61937,8 @@ var tempTip = {
     $('body').append(tiper);
   },
   inputVal: function inputVal(tipText, resultFunc) {
-    var bg = $("<div style='opacity:0.4;position:fixed;top:0;width:100%;height:100%;z-index:98;background-color:#000;'></div>");
-    var tiper = $("<div class='row' style='color:#000;opacity:0.9;position:fixed;top:40%;transform:translateY(-50%);width:100%;z-index:99'>" + "<div class='col-8 offset-2'><div class='card'><div class='card-body'><div class='card-title h5'>" + tipText + "</div><div><input type='" + this.inputType + "' class='input form-control mb-3'/></div>" + "<div class='card-text'><button class='btn btn-outline-success ok'>确定</button></div>" + "</div></div></div></div>");
+    var bg = $("<div style='opacity:0.4;position:fixed;top:0;width:100%;height:100%;z-index:" + this.index + ";background-color:#000;'></div>");
+    var tiper = $("<div class='row' style='color:#000;opacity:0.9;position:fixed;top:40%;transform:translateY(-50%);width:100%;z-index:" + this.index + "'>" + "<div class='col-8 offset-2'><div class='card'><div class='card-body'><div class='card-title h5'>" + tipText + "</div><div><input type='" + this.inputType + "' class='input form-control mb-3'/></div>" + "<div class='card-text'><button class='btn btn-outline-success ok'>确定</button></div>" + "</div></div></div></div>");
     var $ok = tiper.find('.ok');
     var $input = tiper.find('.input');
     $ok.on('click', function () {

+ 13 - 9
resources/js/utilities/tempTip.js

@@ -2,6 +2,10 @@
 const tempTip={
     fadingDuration:4500,
     inputType:'input',
+    index:99,
+    setIndex:function(index){
+        this.index=parseInt(index);
+    },
     setDuration:function(milliSec){
         this.fadingDuration=parseInt(milliSec);
     },
@@ -19,7 +23,7 @@ const tempTip={
         $('body').append(tiper)
     },
     show:function(text){
-        let tiper=$("<div class='row' style='color:white;opacity:0.9;position:fixed;top:40%;transform:translateY(-50%);width:100%;'>" +
+        let tiper=$("<div class='row' style='color:white;opacity:0.9;position:fixed;top:40%;transform:translateY(-50%);width:100%;z-index:"+this.index+";'>" +
             "<div class='col-8 offset-2'><div class='card'><div class='card-body h2 bg-danger text-center'>" +
             text +
             "</div></div></div></div>");
@@ -29,9 +33,9 @@ const tempTip={
         $('body').append(tiper)
     },
     okWindow:function(text,okText){
-        let bg=$("<div style='opacity:0.4;position:fixed;top:0;width:100%;height:100%;z-index:98;background-color:#000;'></div>" );
+        let bg=$("<div style='opacity:0.4;position:fixed;top:0;width:100%;height:100%;z-index:"+this.index+";background-color:#000;'></div>" );
         if(typeof(okText)=='undefined')okText='确定';
-        let tiper=$("<div class='row' style='opacity:0.9;position:fixed;top:40%;transform:translateY(-50%);width:100%;z-index:99'>" +
+        let tiper=$("<div class='row' style='opacity:0.9;position:fixed;top:40%;transform:translateY(-50%);width:100%;z-index:"+(this.index+1)+"'>" +
             "<div class='col-8 offset-2'><div class='card'><div class='card-body h2 text-center'>" +
             text +
             "<p><button class='btn btn-success btn-lg okWindow'>"+okText+"</button></p><div>" +
@@ -45,8 +49,8 @@ const tempTip={
         $('body').append(tiper)
     },
     waitingTip:function(text){
-        let bg=$("<div style='opacity:0.4;position:fixed;top:0;width:100%;height:100%;z-index:98;background-color:#fff;' class='tipperBg'></div>" );
-        let tipper=$("<div class='row tipper' style='color:white;opacity:0.9;position:fixed;top:40%;transform:translateY(-50%);width:100%;z-index:99;'>" +
+        let bg=$("<div style='opacity:0.4;position:fixed;top:0;width:100%;height:100%;z-index:"+this.index+";background-color:#fff;' class='tipperBg'></div>" );
+        let tipper=$("<div class='row tipper' style='color:white;opacity:0.9;position:fixed;top:40%;transform:translateY(-50%);width:100%;z-index:"+(this.index+1)+";'>" +
             "<div class='col-8 offset-2'><div class='card-body h5 bg-dark text-center' style='border-radius: 50px'>" +
             text +
             "</div></div></div>");
@@ -64,8 +68,8 @@ const tempTip={
         bg.remove();
     },
     confirm:function(text,yesFunc,noFunc){
-        let bg=$("<div style='opacity:0.4;position:fixed;top:0;width:100%;height:100%;z-index:98;background-color:#000;'></div>" );
-        let tiper=$("<div class='row' style='color:#000;opacity:0.9;position:fixed;top:40%;transform:translateY(-50%);width:100%;z-index:99'>" +
+        let bg=$("<div style='opacity:0.4;position:fixed;top:0;width:100%;height:100%;z-index:"+this.index+";background-color:#000;'></div>" );
+        let tiper=$("<div class='row' style='color:#000;opacity:0.9;position:fixed;top:40%;transform:translateY(-50%);width:100%;z-index:"+(this.index+1)+"'>" +
             "<div class='col-8 offset-2'><div class='card'><div class='card-body'><div class='card-title h4'>" +
             text +
             "</div><div class='card-text'><button class='btn btn-dark btn-lg ok'>确定</button>" +
@@ -92,8 +96,8 @@ const tempTip={
         $('body').append(tiper);
     },
     inputVal:function(tipText,resultFunc){
-        let bg=$("<div style='opacity:0.4;position:fixed;top:0;width:100%;height:100%;z-index:98;background-color:#000;'></div>" );
-        let tiper=$("<div class='row' style='color:#000;opacity:0.9;position:fixed;top:40%;transform:translateY(-50%);width:100%;z-index:99'>" +
+        let bg=$("<div style='opacity:0.4;position:fixed;top:0;width:100%;height:100%;z-index:"+this.index+";background-color:#000;'></div>" );
+        let tiper=$("<div class='row' style='color:#000;opacity:0.9;position:fixed;top:40%;transform:translateY(-50%);width:100%;z-index:"+this.index+"'>" +
             "<div class='col-8 offset-2'><div class='card'><div class='card-body'><div class='card-title h5'>" +
             tipText +
             "</div><div><input type='"+this.inputType+"' class='input form-control mb-3'/></div>" +

+ 13 - 11
resources/views/waybill/edit.blade.php

@@ -172,7 +172,7 @@
                                 </select>
                                 <input type="text" class="form-control-sm  form-control tooltipTarget" style="vertical-align: middle"
                                        placeholder="输入关键字定位" @input="destination_city_id" v-model="waybill.destination_city" id="destination_city" title="若无法显示区/县级市,可点击后方按钮手动添加" >
-                                <button type="button" class="btn btn-outline-info btn-sm" @click="addCounty" style="transform: scale(0.9)">添加市/县</button>
+                                <button type="button" class="btn btn-outline-info btn-sm" @click="addCounty()" style="transform: scale(0.9)">添加市/县</button>
                             </div>
                         </div>
                     </div>
@@ -604,7 +604,6 @@
                             }
                         });
                 },
-
                 destination_city_id:function (e) {
                     let _this=this;
                     let $val=e.target.value;
@@ -617,25 +616,28 @@
                         });
                 },
                 addCounty:function () {
-                    var add=window.confirm("您确认添加该市/县?");
                     let _this=this;
-                    let url='{{url('waybill/addCounty?destination_city=')}}'+_this.destination_city;
-                    if(add){
+                    if (!_this.waybill.destination_city) {
+                        tempTip.setDuration(2000);
+                        tempTip.show('您未输入市/县!');
+                        return;
+                    }
+                    tempTip.confirm("您确认添加该市/县?", function () {
+                        let url = '{{url('waybill/addCounty?destination_city=')}}' + _this.waybill.destination_city;
                         axios.post(url)
                             .then(function (response) {
-                                if(response.data && response.data.destination_city){
+                                if (response.data && response.data.destination_city) {
                                     tempTip.setDuration(3000);
                                     tempTip.show(response.data.destination_city[0]);
-                                    return ;
+                                    return;
                                 }
                                 _this.cities.push(response.data);
-                                _this.waybill.destination_city_id=response.data.id;
+                                _this.waybill.destination_city_id = response.data.id;
                             }).catch(function (err) {
                             tempTip.setDuration(3000);
-                            tempTip.show("网络错误!"+err);
+                            tempTip.show("网络错误!" + err);
                         });
-                    }
-
+                    })
                 }
             },
         });