Pārlūkot izejas kodu

区域录入完善,运输强制

Zhouzhendong 5 gadi atpakaļ
vecāks
revīzija
6190741321

+ 5 - 0
app/Http/Controllers/RegionController.php

@@ -41,4 +41,9 @@ class RegionController extends Controller
             "parent_id" => $parent
         ]));
     }
+
+    public function getProvinces()
+    {
+        $this->success(app("RegionService")->getSelection(1));
+    }
 }

+ 1 - 1
app/Http/Controllers/WaybillController.php

@@ -782,7 +782,7 @@ class WaybillController extends Controller
         $name = app("RegionService")->formatName(request("name"),2);
         if (!$name)$this->error("非法参数");
 
-        $region = Region::query()->firstOrCreate(["name"=>$name,"type"=>2]);
+        $region = Region::query()->firstOrCreate(["name"=>$name,"type"=>2,"parent_id"=>request("province")]);
         $this->success($region);
     }
 

+ 32 - 4
resources/views/waybill/edit.blade.php

@@ -9,6 +9,24 @@
         @endcomponent
     </div>
     <div class="container-fluid" id="list">
+        <div class="modal fade" tabindex="-1" role="dialog" id="selectedProvince">
+            <div class="modal-dialog modal-lg modal-dialog-centered">
+                <div class="modal-content">
+                    <div class="modal-header">
+                        <b>选择省份</b>
+                        <button type="button" class="close" data-dismiss="modal">&times;</button>
+                    </div>
+                    <div class="modal-body row">
+                        <label class="col-8 offset-2"><select class="form-control" v-model="waybill.province">
+                            <option v-for="province in provinces" :value="province.id">@{{ province.name }}</option>
+                        </select></label>
+                    </div>
+                    <div class="modal-footer">
+                        <button type="button" class="btn btn-success pull-right" @click="addCounty()">录入</button>
+                    </div>
+                </div>
+            </div>
+        </div>
         <div class="card">
             <div class="card-body">
                 <form method="POST" id="waybillForm" action='{{url("waybill/".$waybill->id)}}'>
@@ -173,7 +191,7 @@
                                 </select>
                                 <input v-if="!waybill.order_id" 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 v-if="!waybill.order_id" type="button" class="btn btn-outline-info btn-sm" @click="addCounty()" style="transform: scale(0.9)">添加市/县</button>
+                                <button v-if="!waybill.order_id" type="button" class="btn btn-outline-info btn-sm" @click="selectedProvince()" style="transform: scale(0.9)">添加城市</button>
                             </div>
                         </div>
                     </div>
@@ -434,9 +452,11 @@
                     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}}',
+                    province:"",
                 },
                 order:{!! $waybill->order ?? '{}' !!},
-                waybillTemp:{!! $waybill !!}
+                waybillTemp:{!! $waybill !!},
+                provinces : [],
             },
             mounted:function(){
                 let _this=this;
@@ -606,19 +626,27 @@
                             }
                         });
                 },
-                addCounty:function () {
+                selectedProvince(){
                     if (this.waybill.order_id)return;
                     if (!this.waybill.destination_city) {
                         window.tempTip.setDuration(2000);
                         window.tempTip.show('您未输入市/县!');
                         return;
                     }
-                    window.tempTip.postBasicRequest("{{url('waybill/addCounty')}}",{name:this.waybill.destination_city},res=>{
+                    window.tempTip.postBasicRequest("{{url('maintenance/region/getProvinces')}}",{},res=>{
+                       this.provinces = res;
+                        $("#selectedProvince").modal("show");
+                    });
+                },
+                addCounty:function () {
+                    window.tempTip.postBasicRequest("{{url('waybill/addCounty')}}",
+                        {name:this.waybill.destination_city,province:this.waybill.province},res=>{
                         this.cities.push({
                             id:res.id,
                             name:res.name,
                         });
                         this.waybill.destination_city_id = res.id;
+                        $("#selectedProvince").modal("hide");
                     });
                 }
             },

+ 1 - 0
routes/web.php

@@ -198,6 +198,7 @@ Route::group(['prefix'=>'maintenance'],function(){
     Route::group(['prefix'=>"region"],function (){
         Route::post("get",'RegionController@get');
         Route::post("store",'RegionController@store');
+        Route::post("getProvinces",'RegionController@getProvinces');
     });
     /** 耗材 */
     Route::get('material','MaterialController@index');;