Ver código fonte

专线直发需要区分物流方式

Zhouzhendong 4 anos atrás
pai
commit
68e5e79f08

+ 1 - 11
app/Http/Controllers/LogisticController.php

@@ -24,23 +24,13 @@ class LogisticController extends Controller
         return view('maintenance.logistic.index',['logistics'=>$logistics]);
     }
 
-    /**
-     * Show the form for creating a new resource.
-     *
-     * @return Response
-     */
     public function create()
     {
         if(!Gate::allows('承运商-录入')){ return view("exception.authority");  }
         return view('maintenance.logistic.create');
     }
 
-    /**
-     * Store a newly created resource in storage.
-     *
-     * @param Request $request
-     * @return Response
-     */
+
     public function store(Request $request)
     {
         if(!Gate::allows('承运商-录入')){ return view("exception.authority");  }

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

@@ -149,8 +149,7 @@ class TestController extends Controller
     }
     public function test()
     {
-        $a = MaterialBoxModel::query()->withCount("commodities")->get();
-        dd($a);
+        dd(Cache::flush());
     }
     public function orderCreateBill()
     {

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

@@ -88,7 +88,6 @@ class WaybillController extends Controller
 
     public function edit($id,LogisticService $logisticService,CarTypeService $carTypeService,UnitService $unitService)
     {
-        //if(!Gate::allows('运输管理-编辑')){ return redirect(url('denied'));  }
         $waybill = app('waybillService')->find($id);
         if ($waybill->order_id){
             /** @var Waybill $waybill */
@@ -109,7 +108,7 @@ class WaybillController extends Controller
         $units=$unitService->getSelection();
         $carTypes=$carTypeService->getSelection();
         $deliveryType = app('DeliveryTypeService')->getSelection();
-        return view('transport.waybill.edit',['waybill'=>$waybill,'logistics'=>$logisticService->getSelection(["id","name"],"物流"),'cities'=>$cities,'units'=>$units,'carTypes'=>$carTypes,'deliveryTypes'=>$deliveryType]);
+        return view('transport.waybill.edit',['waybill'=>$waybill,'logistics'=>$logisticService->getSelection(["id","name","tag"],"物流"),'cities'=>$cities,'units'=>$units,'carTypes'=>$carTypes,'deliveryTypes'=>$deliveryType]);
     }
 
     public function update(Request $request, $id,WaybillPriceModelService $waybillPriceModelService,

+ 14 - 1
app/Logistic.php

@@ -17,8 +17,13 @@ class Logistic extends Model
     use ModelLogChanging;
     use SoftDeletes;
     use ModelTimeFormat;
-    protected $fillable = ['name','code',"type","mobile","remark","delivery_fee","is_bunched","english_name",'belong_company'];
+    protected $fillable = ['name','code',"type","mobile","remark","delivery_fee","is_bunched","english_name",'belong_company',"tag"];
 
+    const TAGS=[
+        0 => "专线",
+        1 => "直发车",
+        2 => "德邦",
+    ];
 
     static function nameById($id){
         $logistic=Logistic::where('id',$id)->first();
@@ -29,4 +34,12 @@ class Logistic extends Model
     {
         return $this->belongsToMany(OwnerPriceExpress::class,"owner_price_express_logistic","logistic_id","owner_price_express_id");
     }
+
+    public function getTagAttribute($value):string
+    {
+        if ($value==="" || $value===null)return "";
+        $tag = explode(",",$value);
+        foreach ($tag as &$t)$t = self::TAGS[$t];
+        return implode(",",$tag);
+    }
 }

+ 32 - 0
database/migrations/2021_07_19_165143_change_logistics_table_add_tag_column.php

@@ -0,0 +1,32 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class ChangeLogisticsTableAddTagColumn extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('logistics', function (Blueprint $table) {
+            $table->string("tag")->nullable()->comment("标签");
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('logistics', function (Blueprint $table) {
+            $table->dropColumn("tag");
+        });
+    }
+}

+ 21 - 1
resources/views/maintenance/logistic/create.blade.php

@@ -2,7 +2,7 @@
 @section('title')录入-承运商@endsection
 
 @section('content')
-    <div class="container-fluid">
+    <div class="container-fluid" id="container">
         <div class="card col-md-8 offset-md-2">
             <div class="card-body">
                 @if(Session::has('successTip'))
@@ -93,6 +93,15 @@
                                    name="belong_company" autocomplete="off" value="{{ old('belong_company') }}" >
                         </div>
                     </div>
+                    <div class="form-group row">
+                        <label for="tag" class="col-2 col-form-label text-right">标签</label>
+                        <div class="col-8">
+                            <select id="tag" class="selectpicker" multiple title="标签(多选)" v-model="tag">
+                                @foreach(\App\Logistic::TAGS as $key=>$tag)<option value="{{$key}}">{{$tag}}</option>@endforeach
+                            </select>
+                            <input hidden name="tag" :value="tag"></input>
+                        </div>
+                    </div>
                     <div class="form-group row">
                         <label for="remark" class="col-2 col-form-label text-right">备注</label>
                         <div class="col-8">
@@ -110,3 +119,14 @@
         </div>
     </div>
 @endsection
+
+@section("lastScript")
+    <script>
+        new Vue({
+            el:"#container",
+            data:{
+                tag:[]
+            },
+        });
+    </script>
+@endsection

+ 3 - 0
resources/views/maintenance/logistic/index.blade.php

@@ -18,6 +18,7 @@
                         <th>承运商类型</th>
                         <th>承运商送货费</th>
                         <th>隶属公司</th>
+                        <th>标签</th>
                         <th>备注</th>
                         <th>创建时间</th>
                         <th>操作</th>
@@ -31,6 +32,7 @@
                         <td>@{{logistic.type}}</td>
                         <td>@{{logistic.delivery_fee}}</td>
                         <td>@{{logistic.belong_company}}</td>
+                        <td>@{{logistic.tag}}</td>
                         <td>@{{logistic.remark}}</td>
                         <td class="text-muted">@{{logistic.created_at}}</td>
                         <td>
@@ -56,6 +58,7 @@
                     @foreach( $logistics as $logistic )
                     {id:'{{$logistic->id}}',name:'{{$logistic->name}}',code:'{{$logistic->code}}',
                         mobile:"{{$logistic->mobile}}",type:"{{$logistic->type}}",delivery_fee:"{{$logistic->delivery_fee}}",
+                        tag:"{{$logistic->tag}}",
                         remark:"{{$logistic->remark}}",belong_company:"{{$logistic->belong_company}}",created_at:'{{$logistic->created_at}}',is_bunched:"{{$logistic->is_bunched}}"},
                     @endforeach
                 ],

+ 2 - 2
resources/views/transport/waybill/edit.blade.php

@@ -44,7 +44,7 @@
                                 <div class="col-3" style="position: relative">
                                     <select class="form-control @error('logistic_id') is-invalid @enderror" id="logistic_id" name="logistic_id"
                                             :class="errors['logistic_id'] ? 'is-invalid' :''"  v-model="waybill.logistic_id">
-                                        <option v-for="logistic in logistics" :value="logistic.id">@{{logistic.name}}</option>
+                                        <option v-for="logistic in logistics" :value="logistic.id" v-if="logistic.tag.indexOf(waybill.type)!==-1">@{{logistic.name}}</option>
                                     </select>
                                 </div>
                                 <label for="carrier_bill" class="col-2 col-form-label text-right">承运商单号</label>
@@ -407,7 +407,7 @@
             data:{
                 cities:[@foreach($cities as $city){id:'{{$city->id}}',name:'{{$city->name}}'},@endforeach],
                 units:[@foreach($units as $unit){id:'{{$unit->id}}',name:'{{$unit->name}}',},@endforeach],
-                logistics:[@foreach($logistics as $logistic){id:'{{$logistic->id}}',name:'{{$logistic->name}}',},@endforeach],
+                logistics:[@foreach($logistics as $logistic){id:'{{$logistic->id}}',name:'{{$logistic->name}}',tag:"{{$logistic->tag}}"},@endforeach],
                 carTypes:[@foreach($carTypes as $carType){!! $carType !!},@endforeach],
                 deliveryTypes:[@foreach($deliveryTypes as $deliveryType){!! $deliveryType !!},@endforeach],
                 errors:[],