Browse Source

目的地城市自动维护+手动维护

haozi 5 năm trước cách đây
mục cha
commit
58f599a253

+ 1 - 1
app/City.php

@@ -9,7 +9,7 @@ class City extends Model
 {
     use ModelTimeFormat;
     protected $fillable=[
-        'province_id','name'
+        'province_id','name','type'
     ];
 
     protected $appends=[

+ 23 - 3
app/Http/Controllers/WaybillsController.php

@@ -644,11 +644,11 @@ class WaybillsController extends Controller
                 'type'=>isset($waybill->type)?$waybill->type:'',
                 'waybill_number'=>isset($waybill->waybill_number)?$waybill->waybill_number:'',
                 'owner'=>isset($waybill->owner->name)?$waybill->owner->name:'',
-                //'wms_bill_number'=>isset($waybill->wms_bill_number)?$waybill->wms_bill_number:'',
+                'wms_bill_number'=>isset($waybill->wms_bill_number)?$waybill->wms_bill_number:'',
                 'origination'=>isset($waybill->origination)?$waybill->origination:'',
                 'destination'=>isset($waybill->destination)?$waybill->destination:'',
-                //'recipient'=>isset($waybill->recipient)?$waybill->recipient:'',
-                //'recipient_mobile'=>isset($waybill->recipient_mobile)?$waybill->recipient_mobile:'',
+                'recipient'=>isset($waybill->recipient)?$waybill->recipient:'',
+                'recipient_mobile'=>isset($waybill->recipient_mobile)?$waybill->recipient_mobile:'',
                 //'charge'=>isset($waybill->charge)?$waybill->charge:'',
                 //'ordering_remark'=>isset($waybill->ordering_remark)?$waybill->ordering_remark:'',
                 'carrier'=>isset($waybill->carrier_name)?$waybill->carrier_name:'',
@@ -782,4 +782,24 @@ class WaybillsController extends Controller
         ]);
         return $validator;
     }
+    public function addCounty(Request $request){
+        $rule =[
+            'destination_city' => ['required', 'string','unique:cities,name'],
+        ];
+        $messages=[
+            'destination_city.required'=>'市/县不能为空',
+            'destination_city.string'=>'市/县必须是字符串',
+            'destination_city.unique'=>'市/县已存在',
+        ];
+        $validator = Validator::make($request->all(),$rule,$messages);
+        if ($validator->fails()) {
+            return $validator->errors();
+        }
+        $city=new City([
+            'name'=>$request->input('destination_city'),
+            'type'=>3,
+        ]);
+        $city->save();
+        return $city;
+    }
 }

+ 46 - 0
database/migrations/2020_05_18_105150_change_cities_table.php

@@ -0,0 +1,46 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class ChangeCitiesTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        //行政区划 一级省 二级市 三级县区 四级乡
+        Schema::table('cities', function (Blueprint $table) {
+            $table->bigInteger('type')->default(2)->comment('行政级别');
+        });
+        Schema::table('w_m_s_waybills', function (Blueprint $table) {
+            $table->string('ReservedField01 ')->nullable()->comment('预留字段1');
+        });
+        Schema::table('waybills', function (Blueprint $table) {
+            $table->string('source_bill')->nullable()->comment('上游单号');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+
+        Schema::table('cities', function (Blueprint $table) {
+            $table->dropColumn('type');
+        });
+        Schema::table('w_m_s_waybills', function (Blueprint $table) {
+            $table->dropColumn('ReservedField01');
+        });
+        Schema::table('waybills', function (Blueprint $table) {
+            $table->dropColumn('source_bill');
+        });
+    }
+}

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

@@ -135,7 +135,8 @@
                                 <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="waybillPriceModel.destination_city_id" style="width: 30%; " >
                                     <option v-for="city in cities" :value="city.id">@{{city.name}}</option>
                                 </select>
-                                <input class="form-control-sm" placeholder="输入关键字定位" @input="destination_city_id">
+                                <input class="form-control-sm" placeholder="输入关键字定位" @input="destination_city_id" v-model="destination_city">
+                                <button type="button" class="btn btn-outline-info btn-sm" @click="addCounty" style="transform: scale(0.9)">添加市/县</button>
                             </div>
                         </div>
                         <div class="form-group row">
@@ -313,11 +314,12 @@
                     carrier_weight_other:'{{old('carrier_weight_other')?old('carrier_weight_other'):$waybill->carrier_weight_other}}',
                     carrier_weight_unit_id_other:'{{old('carrier_weight_unit_id_other')?old('carrier_weight_unit_id_other'):$waybill->carrier_weight_unit_id_other}}',
                     warehouse_weight_unit_id_other:'{{old('warehouse_weight_unit_id_other')?old('warehouse_weight_unit_id_other'):$waybill->warehouse_weight_unit_id_other}}',
+
                 },
                 cities:[
                         @foreach($cities as $city)
                     {
-                        id:'{{$city->id}}',name:'{{$city->name}}'
+                        id:'{{$city->id}}',name:'{{$city->name}}',type:'{{$city->type}}',
                     },
                     @endforeach
                 ],
@@ -329,6 +331,7 @@
                 ],
                 errors:[],
                 origination:'{{$waybill->origination}}',
+                destination_city:'',
             },
             mounted:function(){
                 let _this=this;
@@ -400,22 +403,52 @@
                     }
                     this.waybillPriceModel.origination_city_id=origination_id;
                 }
+
                 if (!this.waybillPriceModel.destination_city_id) {
                     let destination=document.getElementById('destination_seek').value;
-                    let strDestination;
-                    let destination_id;
-                    if (destination){
-                        let arr=destination.split("");
-                        for (i=0;i<arr.length;i++){
-                            this.cities.some(function (city) {
-                                if (city.name.includes(strDestination)){ destination_id=city.id; return true;}
-                                strDestination=arr[i]+arr[i+1];
-                            });
-                            if (destination_id) {break;}
+                    let strDestination; //两字城市关键字
+                    let destination_id; //寻找到的城市id
+                    let sign=false;     //标记 用于for识别跳出
+                    if (destination){   //input有值
+                        let arr=destination.split("");//切分数组
+                        for (let i=0;i<arr.length;i++){
+                            if (!destination_id) { //城市不存在时找城市
+                                this.cities.some(function (city) {
+                                    if (city.name.includes(strDestination)) {
+                                        destination_id = city.id;
+                                        return true;
+                                    }
+                                    strDestination = arr[i] + arr[i + 1];
+                                });
+                            }
+                            if (destination_id) { //城市存在时找县区
+                                this.cities.some(function (city) {
+                                    if (city.type == 3 && city.name.includes(strDestination)) {
+                                        destination_id = city.id;
+                                        sign=true;
+                                        return true; //标记
+                                    }
+                                    strDestination = arr[i] + arr[i + 1];
+                                });
+                            }
+                            if (sign)break; //跳出
+                        }
+                        if (!destination_id){ //城市与城市下县区都未找到,直接找县区,忽略城市
+                            for (let i=0;i<arr.length;i++) {
+                                this.cities.some(function (city) {
+                                    if (city.type == 3 && city.name.includes(strDestination)) {
+                                        destination_id = city.id;
+                                        return true;
+                                    }
+                                    strDestination = arr[i] + arr[i + 1];
+                                });
+                            }
                         }
+                        //找到赋值 未找到置空
+                        if (destination_id)this.waybillPriceModel.destination_city_id=destination_id;
                     }
-                    this.waybillPriceModel.destination_city_id=destination_id;
                 }
+
             },
             methods:{
                 {{--计费模型阶段保留--}}
@@ -478,6 +511,27 @@
                             }
                         });
                 },
+                addCounty:function () {
+                    var add=window.confirm("您确认添加该市/县?");
+                    let _this=this;
+                    let url='{{url('waybill/addCounty?destination_city=')}}'+_this.destination_city;
+                    if(add){
+                        axios.post(url)
+                            .then(function (response) {
+                                if(response.data && response.data.destination_city){
+                                    tempTip.setDuration(3000);
+                                    tempTip.show(response.data.destination_city[0]);
+                                    return ;
+                                }
+                                _this.cities.push(response.data);
+                                _this.waybillPriceModel.destination_city_id=response.data.id;
+                            }).catch(function (err) {
+                            tempTip.setDuration(3000);
+                            tempTip.show("网络错误!"+err);
+                        });
+                    }
+
+                }
             },
         });
     </script>

+ 6 - 3
resources/views/waybill/index.blade.php

@@ -133,7 +133,10 @@
                     <th class="waybill_1">创建时间</th>
                     <th class="waybill_1">运单类型</th>
                     <th class="waybill_1">货主</th>
+                    <th class="waybill_1">WMS订单号</th>
                     <th class="waybill_1">运单号</th>
+                    <th class="waybill_1">收件人</th>
+                    <th class="waybill_1">收件人电话</th>
                     <th class="waybill_1">始发地</th>
                     <th class="waybill_1">目的地</th>
                     <th class="waybill_2">承运商</th>
@@ -146,9 +149,6 @@
                     <th class="waybill_3">提货费</th>
                     <th class="waybill_3">其他费用</th>
                     <th class="waybill_3">调度备注</th>
-                    {{--                    <th>WMS单号</th>--}}
-                    {{--                    <th>收件人</th>--}}
-                    {{--                    <th>收件人电话</th>--}}
                     {{--                    <th>收费(元)</th>--}}
                     {{--                    <th>到付金额(元)</th>--}}
                     {{--                    <th>下单备注</th>--}}
@@ -193,7 +193,10 @@
                     <td>@{{waybill.created_at}}</td>
                     <td>@{{waybill.type}}</td>
                     <td>@{{waybill.owner}}</td>
+                    <td>@{{waybill.wms_bill_number}}</td>
                     <td>@{{waybill.waybill_number}}</td>
+                    <td>@{{waybill.recipient}}</td>
+                    <td>@{{waybill.recipient_mobile}}</td>
                     <td>@{{waybill.origination}}</td>
                     <td>@{{waybill.destination}}</td>
                     <td>@{{waybill.carrier}}</td>

+ 1 - 0
routes/web.php

@@ -78,6 +78,7 @@ Route::resource('waybill','WaybillsController');
 Route::get('waybill/index/ZF','WaybillsController@indexZF');
 Route::get('waybill/index/ZX','WaybillsController@indexZX');
 Route::post('waybill/is/waybillPriceModel','WaybillsController@isWaybillPriceModel');
+Route::post('waybill/addCounty','WaybillsController@addCounty');
 Route::any('waybill/waybillAudit','WaybillsController@waybillAudit');
 Route::any('waybill/waybillEdit/{id}','WaybillsController@waybillEdit');
 Route::any('waybill/waybillRetreatAudit','WaybillsController@waybillRetreatAudit');