Quellcode durchsuchen

Merge branch 'zzd' of ssh://was.baoshi56.com:10022/var/git/bswas

LD vor 5 Jahren
Ursprung
Commit
1c174a2bbf

+ 6 - 0
app/DeliveryAppointmentCar.php

@@ -18,6 +18,12 @@ class DeliveryAppointmentCar extends Model
         "driver_phone",
         "appointment_number",
         "delivery_time",
+        "status",
+    ];
+    const STATUS = [
+        0 => "未送达",
+        1 => "作业中",
+        2 => "已完成",
     ];
     public $timestamps=false;
 

+ 11 - 3
app/Http/Controllers/DeliveryAppointmentController.php

@@ -306,10 +306,11 @@ class DeliveryAppointmentController extends Controller
             }
         }
         if ($index===null)$this->success([]);
-        DeliveryAppointmentCar::query()->whereHas("deliveryAppointment",function (Builder $query)use($index){
+        $query = DeliveryAppointmentCar::query()->whereHas("deliveryAppointment",function (Builder $query)use($index){
             $query->where("appointment_date",date("Y-m-d"))->whereIn("status",[0,2])
                 ->where("date_period",">=",$index);
-        })->orderByDesc("id")->limit(10)->get()->each(function ($car)use(&$list){
+        });
+        $query->orderByDesc("id")->limit(10)->get()->each(function ($car)use(&$list){
             $diff = $car->delivery_time ? (strtotime($car->delivery_time)+1799)-time() : 0;
             $list[] = [
                 "license_plate_number" => $car->license_plate_number,
@@ -318,7 +319,14 @@ class DeliveryAppointmentController extends Controller
                 "diff" => $diff>0 ? $diff*1000 : 0,
             ];
         });
-        $result = ["list"=>$list];
+        $counts = $query->selectRaw("(CASE WHEN delivery_time IS NOT NULL THEN 1 ELSE 2 END) AS time, COUNT(1) AS c")->groupByRaw("time")->get();
+        $count = 0;
+        $success = 0;
+        if ($counts)foreach ($counts as $c){
+            if ($c->time==1)$success = $c->c;
+            $count += $c->c;
+        }
+        $result = ["list"=>$list,"count"=>$count,"success"=>$success];
         $nextTime = DeliveryAppointment::PERIOD[$index+1] ?? null;
         if ($nextTime){
             $nextTime = explode("-",$nextTime)[0];

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

@@ -0,0 +1,32 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class ChangeAppointmentCarsAddStatusColumn extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('delivery_appointment_cars', function (Blueprint $table) {
+            $table->tinyInteger("status")->default(0)->comment("状态");
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('delivery_appointment_cars', function (Blueprint $table) {
+            $table->dropColumn("status");
+        });
+    }
+}

+ 24 - 7
resources/views/store/deliveryAppointment/exhibition.blade.php

@@ -15,11 +15,8 @@
             height: 100%;
             width: 100%;
         }
-        .h-20{
-            height: 20%;
-        }
-        .h-40{
-            height: 40%;
+        .h-90{
+            height: 90%;
         }
         .h-5{
             height: 5%;
@@ -77,14 +74,29 @@
             margin-right:15px;
             cursor:pointer;
         }
+        hr{
+            border: 2px solid #1b1e21;
+            border-radius: 2px;
+        }
     </style>
 </head>
 <body onload="initLoad()" class="h-100">
     <div class="container-fluid h-100 d-none" id="container">
         <div class="offset-1 h1 font-weight-bold h-100">
             <div class="h-5"></div>
-            <div class="w-100 h-40">
-                <div class="row h-20 mt-0" v-for="(data,i) in list" :class="data.is_delivery ? 'text-success' : 'text-primary'" {{--v-if="i<5"--}}>
+            <div class="h-5 h6">
+                <div class="font-weight-bold row">
+                    <div class="col-2"><span class="fa fa-diamond text-info"></span>&nbsp;当前时段预约车辆:</div>
+                    <div class="col-8 m-0">
+                        <div class="progress">
+                            <div class="progress-bar bg-success progress-bar-striped" :style="{width:(count>0 ? (success/count)*100 : 100)+'%'}">@{{ success }}/@{{ count }}</div>
+                        </div>
+                    </div>
+                </div>
+                <hr class="font-weight-bold">
+            </div>
+            <div class="w-100 h-90">
+                <div class="row h-10 mt-0" v-for="(data,i) in list" :class="data.is_delivery ? 'text-success' : 'text-primary'" {{--v-if="i<5"--}}>
                     <div class="col-3 text-line">@{{ data.license_plate_number }}</div>
                     <div class="col-2 text-line">@{{ data.driver_name }}</div>
                     <div class="col-3 text-line">@{{ data.driver_phone }}</div>
@@ -144,6 +156,8 @@
             key:"",
             baseUrl:"{{url('store/deliveryAppointment/delivery?k=')}}",
             QrCode : null,
+            count : 0,
+            success : 0,
         },
         mounted(){
             $("#container").removeClass("d-none");
@@ -184,6 +198,7 @@
                             }
                         });
                     },1800000);
+                    this.success++;
                 })
             },
             //初始化数据
@@ -206,6 +221,8 @@
                             }
                         });
                         this.list = data;
+                        this.count = res.count;
+                        this.success = res.success;
                     }
                     //判断下次刷新数据的时间
                     let refreshVal = res.refresh ? res.refresh : this._getDiffDate();

+ 3 - 0
resources/views/store/deliveryAppointment/menu.blade.php

@@ -13,6 +13,9 @@
                 <li class="nav-item">
                     <a target="_blank" class="nav-link" href="{{url('store/deliveryAppointment/exhibition')}}" :class="{active:isActive('exhibition',3)}">入库区终端</a>
                 </li>
+                <li class="nav-item">
+                    <a target="_blank" class="nav-link" href="{{url('store/deliveryAppointment/qrcode')}}" :class="{active:isActive('qrcode',3)}">二维码</a>
+                </li>
             </ul>
         </div>
     </div>

+ 127 - 0
resources/views/store/deliveryAppointment/qrcode.blade.php

@@ -0,0 +1,127 @@
+<!DOCTYPE html>
+<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
+<head>
+    <meta charset="utf-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1">
+    <link rel="icon" href="{{asset('icon/faviconc.ico')}}" type="image/x-icon"/>
+    <link href="{{ mix('css/app.css') }}" rel="stylesheet">
+    <!-- CSRF Token -->
+    <meta name="csrf-token" content="{{ csrf_token() }}">
+    <title>二维码-客户预约</title>
+    <style>
+        html{
+            background: white;
+            height: 100%;
+            width: 100%;
+        }
+    </style>
+</head>
+<body class="h-100">
+    <div class="container-fluid w-100 h-100" id="container">
+        <div class="h-25"></div>
+        <div class="w-50 h-50 m-auto">
+            <div id="code" class="ml-5"></div>
+        </div>
+    </div>
+</body>
+<script src="{{ mix('js/app.js') }}"></script>
+<script src="{{ mix('js/utilities/qrcode.js') }}"></script>
+<script type="text/javascript">
+    new Vue({
+        el:"#container",
+        data:{
+            list:[],
+            key:"",
+            baseUrl:"{{url('store/deliveryAppointment/delivery?k=')}}",
+            QrCode : null,
+        },
+        mounted(){
+            this._getKey();
+        },
+        methods:{
+            //获取密匙
+            _getKey(){
+                let url = "{{url('store/deliveryAppointment/getKey')}}";
+                window.tempTip.postBasicRequest(url,{},res=>{
+                    this.key = res;
+                    this._createQrCode(this.baseUrl+this.base64());
+                });
+            },
+            //生成二维码
+            _createQrCode(text){
+                let dom = document.getElementById("code");
+                let hei = dom.parentElement.offsetHeight;
+                new QRCode(dom,{
+                        text: text,
+                        width: hei*1.4,
+                        height: hei,
+                        colorDark : "#000000",
+                        colorLight : "#ffffff",
+                    }
+                );
+            },
+            //获取当前时间距离明天0点的时间差  毫秒
+            _getDiffDate(){
+                let now = new Date();
+                let dateTime = now.getTime();
+                let yy = now.getFullYear();
+                let mm = now.getMonth() + 1;
+                let dd = now.getDate();
+                let clock = yy + "-";
+                if(mm < 10) clock += "0";
+                clock += mm + "-";
+                if(dd < 10) clock += "0";
+                clock += dd+" 00:00:00";
+                let timestamp = new Date(clock).getTime()+(24*60*60*1000);
+                return timestamp-dateTime;
+            },
+            //加密
+            base64(){
+                let _keyStr= "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
+                let output = "";
+                let chr1, chr2, chr3, enc1, enc2, enc3, enc4;
+                let i = 0;
+                let str = Math.floor(new Date().getTime()/1000).toString();
+                str = str.slice(str.length-8);
+                let input = this._utf8_encode(this.key+str);
+                while (i < input.length) {
+                    chr1 = input.charCodeAt(i++);
+                    chr2 = input.charCodeAt(i++);
+                    chr3 = input.charCodeAt(i++);
+                    enc1 = chr1 >> 2;
+                    enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
+                    enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
+                    enc4 = chr3 & 63;
+                    if (isNaN(chr2)) {
+                        enc3 = enc4 = 64;
+                    } else if (isNaN(chr3)) {
+                        enc4 = 64;
+                    }
+                    output = output +
+                        _keyStr.charAt(enc1) + _keyStr.charAt(enc2) +
+                        _keyStr.charAt(enc3) + _keyStr.charAt(enc4);
+                }
+                return output;
+            },
+            _utf8_encode (string) {
+                string = string.replace(/\r\n/g,"\n");
+                let utftext = "";
+                for (let n = 0; n < string.length; n++) {
+                    let c = string.charCodeAt(n);
+                    if (c < 128) {
+                        utftext += String.fromCharCode(c);
+                    } else if((c > 127) && (c < 2048)) {
+                        utftext += String.fromCharCode((c >> 6) | 192);
+                        utftext += String.fromCharCode((c & 63) | 128);
+                    } else {
+                        utftext += String.fromCharCode((c >> 12) | 224);
+                        utftext += String.fromCharCode(((c >> 6) & 63) | 128);
+                        utftext += String.fromCharCode((c & 63) | 128);
+                    }
+                }
+                return utftext;
+            }
+        },
+    });
+</script>
+</html>

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

@@ -30,7 +30,7 @@
         </div>
         <div class="card">
             <div class="card-body">
-                <form method="POST" id="waybillForm" action='{{url("waybill/".$waybill->id)}}'>
+                <form method="POST" id="waybillForm" action='{{url("transport/waybill/".$waybill->id)}}'>
                     @csrf
                     @method('PUT')
                     <div class="form-group row">
@@ -558,7 +558,7 @@
                 {{--计费模型阶段保留--}}
                 is_waybillPriceModel(logistic_id,carrier_weight,carrier_weight_unit_id,destination_city_id,carrier_weight_other,carrier_weight_unit_id_other){
                     this.errors=[];
-                    let url='{{url('waybill/is/waybillPriceModel')}}';
+                    let url='{{url('transport/waybill/is/waybillPriceModel')}}';
 
                     let _this=this;
                     axios.post(url,{logistic_id:logistic_id,carrier_weight:[carrier_weight,carrier_weight_other],
@@ -640,7 +640,7 @@
                     });
                 },
                 addCounty:function () {
-                    window.tempTip.postBasicRequest("{{url('waybill/addCounty')}}",
+                    window.tempTip.postBasicRequest("{{url('transport/waybill/addCounty')}}",
                         {name:this.waybill.destination_city,province:this.waybill.province},res=>{
                         this.cities.push({
                             id:res.id,

+ 1 - 1
resources/views/transport/waybill/recycle.blade.php

@@ -202,7 +202,7 @@
                             tempTip.setDuration(2000);
                             tempTip.showSuccess('恢复勾选内容成功!');
                             window.setTimeout(function () {
-                                window.location.href='{{url('waybill/recycle')}}';
+                                window.location.href='{{url('transport/waybill/recycle')}}';
                             },2000);
                         }else{
                             tempTip.setDuration(2500);

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

@@ -11,7 +11,7 @@
     <div class="container-fluid mt-3" id="container">
         <div class="card">
             <div class="card-body">
-                <form method="POST" action='{{url("waybill/waybillUpdate/{$waybill->id}")}}'>
+                <form method="POST" action='{{url("transport/waybill/waybillUpdate/{$waybill->id}")}}'>
                     @csrf
                     <div class="form-group row">
                         <label for="type" class="col-2 col-form-label text-right text-primary">运单类型 *</label>
@@ -182,7 +182,7 @@
                 this._codeGetOrder(val);
             },
             _codeGetOrder(val){
-                let url = "{{url('waybill/seekOrder')}}";
+                let url = "{{url('transport/waybill/seekOrder')}}";
                 window.tempTip.postBasicRequest(url,{code:val},res=>{
                     this.order = res;
                     this.model.order_id = res.id;

+ 3 - 0
routes/web.php

@@ -457,6 +457,9 @@ Route::group(['prefix'=>'store'],function(){
         Route::get('exhibition',function (){
             return view("store.deliveryAppointment.exhibition");
         });
+        Route::get('qrcode',function (){
+            return view("store.deliveryAppointment.qrcode");
+        });
         Route::group(['prefix'=>'appointment'],function(){
             Route::post('import','DeliveryAppointmentController@import');
         });