Pārlūkot izejas kodu

Merge branch 'Haozi'

# Conflicts:
#	resources/views/waybill/edit.blade.php
#	resources/views/waybill/index.blade.php
LD 6 gadi atpakaļ
vecāks
revīzija
ba9383d6b1

+ 1 - 1
app/City.php

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

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

@@ -641,11 +641,11 @@ class WaybillsController extends Controller
                 'type'=>isset($waybill->type)?$waybill->type:'',
                 'type'=>isset($waybill->type)?$waybill->type:'',
                 'waybill_number'=>isset($waybill->waybill_number)?$waybill->waybill_number:'',
                 'waybill_number'=>isset($waybill->waybill_number)?$waybill->waybill_number:'',
                 'owner'=>isset($waybill->owner->name)?$waybill->owner->name:'',
                 '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:'',
                 'origination'=>isset($waybill->origination)?$waybill->origination:'',
                 'destination'=>isset($waybill->destination)?$waybill->destination:'',
                 '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:'',
                 //'charge'=>isset($waybill->charge)?$waybill->charge:'',
                 //'ordering_remark'=>isset($waybill->ordering_remark)?$waybill->ordering_remark:'',
                 //'ordering_remark'=>isset($waybill->ordering_remark)?$waybill->ordering_remark:'',
                 'carrier'=>isset($waybill->carrier_name)?$waybill->carrier_name:'',
                 'carrier'=>isset($waybill->carrier_name)?$waybill->carrier_name:'',
@@ -779,4 +779,24 @@ class WaybillsController extends Controller
         ]);
         ]);
         return $validator;
         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;
+    }
 }
 }

+ 1 - 1
app/WMSWaybill.php

@@ -10,6 +10,6 @@ class WMSWaybill extends Model
     use ModelTimeFormat;
     use ModelTimeFormat;
     //
     //
     protected $fillable=['OrderNo','CustomerID','CarrierID','ConsigneeName',
     protected $fillable=['OrderNo','CustomerID','CarrierID','ConsigneeName',
-        'C_Tel1','C_Address1','C_Province','C_City','C_District'];
+        'C_Tel1','C_Address1','C_Province','C_City','C_District','ReservedField01'];
 
 
 }
 }

+ 1 - 1
app/Waybill.php

@@ -13,7 +13,7 @@ class Waybill extends Model
         'status','type','waybill_number','owner_id','wms_bill_number','origination','destination','recipient','recipient_mobile','charge','ordering_remark',
         'status','type','waybill_number','owner_id','wms_bill_number','origination','destination','recipient','recipient_mobile','charge','ordering_remark',
         'carrier_id','carrier_bill','origination_city_id','destination_city_id','warehouse_weight','warehouse_weight_unit_id','carrier_weight','carrier_weight_unit_id','carType_id',
         'carrier_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'
         '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',
+        ,'carrier_weight_other','carrier_weight_unit_id_other','source_bill',
     ];
     ];
     protected $appends=[
     protected $appends=[
         'origination_city_name',
         'origination_city_name',

+ 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');
+        });
+    }
+}

+ 81 - 50
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%; " >
                                 <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>
                                     <option v-for="city in cities" :value="city.id">@{{city.name}}</option>
                                 </select>
                                 </select>
-                                <input class="form-control-sm" placeholder="输入关键字定位" @input="destination_city_id">
+                                <input class="form-control-sm tooltipTarget" placeholder="输入关键字定位" @input="destination_city_id" v-model="destination_city" title="若无法显示县级市,可点击后方按钮手动添加" style="vertical-align: middle">
+                                <button type="button" class="btn btn-outline-info btn-sm" @click="addCounty" style="transform: scale(0.9)">添加市/县</button>
                             </div>
                             </div>
                         </div>
                         </div>
                         <div class="form-group row">
                         <div class="form-group row">
@@ -157,7 +158,7 @@
                             </div>
                             </div>
 
 
                             &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                             &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-                            <label for="warehouse_weight_other" class="col-form-label text-right ">&nbsp;&nbsp;&nbsp;仓库重</label>
+                            <label for="warehouse_weight_other" class="col-form-label text-right ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;仓库重</label>
                             <div class="col-2">
                             <div class="col-2">
                                 <input type="text" class="form-control @error('warehouse_weight_other') is-invalid @enderror"
                                 <input type="text" class="form-control @error('warehouse_weight_other') is-invalid @enderror"
                                        name="warehouse_weight_other" autocomplete="off" value="@if(old('warehouse_weight_other')){{ old('warehouse_weight_other') }}@else{{$waybill->warehouse_weight_other}}@endif"  >
                                        name="warehouse_weight_other" autocomplete="off" value="@if(old('warehouse_weight_other')){{ old('warehouse_weight_other') }}@else{{$waybill->warehouse_weight_other}}@endif"  >
@@ -317,7 +318,7 @@
                 cities:[
                 cities:[
                         @foreach($cities as $city)
                         @foreach($cities as $city)
                     {
                     {
-                        id:'{{$city->id}}',name:'{{$city->name}}'
+                        id:'{{$city->id}}',name:'{{$city->name}}',type:'{{$city->type}}',
                     },
                     },
                     @endforeach
                     @endforeach
                 ],
                 ],
@@ -329,45 +330,25 @@
                 ],
                 ],
                 errors:[],
                 errors:[],
                 origination:'{{$waybill->origination}}',
                 origination:'{{$waybill->origination}}',
+                destination_city:'',
             },
             },
             mounted:function(){
             mounted:function(){
                 let _this=this;
                 let _this=this;
-                if (!this.waybillPriceModel.carrier_weight_unit_id_other){
-                    this.units.every(function (unit) {
-                        if (unit.name=="kg"){
-                            _this.waybillPriceModel.carrier_weight_unit_id_other=unit.id;
-                            return false;
-                        }
-                        return  true;
-                    });
-                }
-                if (!this.waybillPriceModel.carrier_weight_unit_id){
-                    this.units.every(function (unit) {
-                        if (unit.name=="m³"){
-                            _this.waybillPriceModel.carrier_weight_unit_id=unit.id;
-                            return false;
-                        }
-                        return  true;
-                    });
-                }
-                if (!this.waybillPriceModel.warehouse_weight_unit_id_other){
-                    this.units.every(function (unit) {
-                        if (unit.name=="kg"){
-                            _this.waybillPriceModel.warehouse_weight_unit_id_other=unit.id;
-                            return false;
-                        }
-                        return  true;
-                    });
-                }
-                if (!this.waybillPriceModel.warehouse_weight_unit_id){
-                    this.units.every(function (unit) {
-                        if (unit.name=="m³"){
-                            _this.waybillPriceModel.warehouse_weight_unit_id=unit.id;
-                            return false;
-                        }
-                        return  true;
-                    });
-                }
+                this.units.every(function (unit) {
+                    switch (unit.name) {
+                        case "kg":
+                            if (!_this.waybillPriceModel.warehouse_weight_unit_id_other)_this.waybillPriceModel.warehouse_weight_unit_id_other=unit.id;
+                            if (!_this.waybillPriceModel.carrier_weight_unit_id_other)_this.waybillPriceModel.carrier_weight_unit_id_other=unit.id;
+                            break;
+                        case "m³":
+                            if (!_this.waybillPriceModel.carrier_weight_unit_id)_this.waybillPriceModel.carrier_weight_unit_id=unit.id;
+                            if (!_this.waybillPriceModel.warehouse_weight_unit_id)_this.waybillPriceModel.warehouse_weight_unit_id=unit.id;
+                            break;
+                    }
+
+                    return  true;
+                });
+
                 if (!this.origination){
                 if (!this.origination){
                     $("#btn").removeAttr("hidden");
                     $("#btn").removeAttr("hidden");
                     $("#ordering_remark").after($("#origination"));
                     $("#ordering_remark").after($("#origination"));
@@ -400,21 +381,50 @@
                     }
                     }
                     this.waybillPriceModel.origination_city_id=origination_id;
                     this.waybillPriceModel.origination_city_id=origination_id;
                 }
                 }
+
                 if (!this.waybillPriceModel.destination_city_id) {
                 if (!this.waybillPriceModel.destination_city_id) {
                     let destination=document.getElementById('destination_seek').value;
                     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:{
             methods:{
@@ -478,6 +488,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>
     </script>

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

@@ -139,7 +139,10 @@
                     <th>创建时间</th>
                     <th>创建时间</th>
                     <th>运单类型</th>
                     <th>运单类型</th>
                     <th>货主</th>
                     <th>货主</th>
+                    <th>WMS订单号</th>
                     <th>运单号</th>
                     <th>运单号</th>
+                    <th>收件人</th>
+                    <th>收件人电话</th>
                     <th>始发地</th>
                     <th>始发地</th>
                     <th>目的地</th>
                     <th>目的地</th>
                     <th>承运商</th>
                     <th>承运商</th>
@@ -200,6 +203,9 @@
                     <td>@{{waybill.type}}</td>
                     <td>@{{waybill.type}}</td>
                     <td>@{{waybill.owner}}</td>
                     <td>@{{waybill.owner}}</td>
                     <td>@{{waybill.wms_bill_number}}</td>
                     <td>@{{waybill.wms_bill_number}}</td>
+                    <td>@{{waybill.waybill_number}}</td>
+                    <td>@{{waybill.recipient}}</td>
+                    <td>@{{waybill.recipient_mobile}}</td>
                     <td class="text-muted">@{{waybill.origination}}</td>
                     <td class="text-muted">@{{waybill.origination}}</td>
                     <td class="text-muted">@{{waybill.destination}}</td>
                     <td class="text-muted">@{{waybill.destination}}</td>
                     <td>@{{waybill.carrier}}</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/ZF','WaybillsController@indexZF');
 Route::get('waybill/index/ZX','WaybillsController@indexZX');
 Route::get('waybill/index/ZX','WaybillsController@indexZX');
 Route::post('waybill/is/waybillPriceModel','WaybillsController@isWaybillPriceModel');
 Route::post('waybill/is/waybillPriceModel','WaybillsController@isWaybillPriceModel');
+Route::post('waybill/addCounty','WaybillsController@addCounty');
 Route::any('waybill/waybillAudit','WaybillsController@waybillAudit');
 Route::any('waybill/waybillAudit','WaybillsController@waybillAudit');
 Route::any('waybill/waybillEdit/{id}','WaybillsController@waybillEdit');
 Route::any('waybill/waybillEdit/{id}','WaybillsController@waybillEdit');
 Route::any('waybill/waybillRetreatAudit','WaybillsController@waybillRetreatAudit');
 Route::any('waybill/waybillRetreatAudit','WaybillsController@waybillRetreatAudit');