Parcourir la source

运输管理-合并运单放宽

zhouzhendong il y a 4 ans
Parent
commit
cf16a3cbaf

+ 8 - 5
app/Http/Controllers/WaybillController.php

@@ -779,7 +779,7 @@ SQL;
 
     private function deliveringQuery(Request $request): Builder
     {
-        $waybills= Waybill::query()->where("type","专线")->with(["order","logistic"])
+        $waybills= Waybill::query()->where("type","专线")->with(["order","logistic","amountUnit"])
         ->whereNotNull("logistic_id")->whereNotNull("deliver_at")->whereIn("status",["已审核","待终审"]);
         if (!Auth::user()->isSuperAdmin()){
             $carriersUsers=DB::table('logistic_user')->where('user_id',Auth::id())->get();
@@ -820,8 +820,9 @@ SQL;
         $errors=Validator::make($request->input(),[
             'id'=>'required|integer',
             'carrier_bill'=>'required',
-            'inquire_tel'=>'nullable',
-            'amount'=>'nullable|integer',
+            'inquire_tel'=>'required',
+            'amount'=>'required|integer',
+            'amount_unit_name'=>'required|string',
             'carrier_weight'=>'required_without:carrier_weight_other|nullable|numeric',
             'carrier_weight_other'=>'required_without:carrier_weight|nullable|numeric',
         ],[
@@ -832,14 +833,16 @@ SQL;
         ],[
             'carrier_bill'=>'运单号',
             'inquire_tel'=>'查件电话',
+            'amount_unit_name'=>'数量单位',
             'amount'=>'件数',
             'carrier_weight'=>'体积',
             'carrier_weight_other'=>'重量',
         ])->errors();
+        if ($request->input("amount_unit_name")!='件' && $request->input("amount_unit_name")!='托')$errors->add("amount_unit_name","非法参数");
+        if (count($errors)>0)return ["errors"=>$errors];
         $unit = app("UnitService")->getUnit("kg");
-        $unit1 = app("UnitService")->getUnit("件");
+        $unit1 = app("UnitService")->getUnit($request->input("amount_unit_name"));
         $unit2 = app("UnitService")->getUnit("m³");
-        if (count($errors)>0)return ["errors"=>$errors];
         $waybill=Waybill::query()->find($request->input('id'));
         if (!$waybill)return ["error"=>"未找到该运单!"];
         $request->offsetSet("carrier_weight_unit_id",$unit2->id);

+ 40 - 50
resources/views/transport/waybill/delivering.blade.php

@@ -36,26 +36,35 @@
                         <div style="transform:scale(0.9);color:#02346a" class="pl-0 form-inline">
                             <div class="mr-3 text-nowrap form-inline">
                                 <label :for="'carrier_bill'+waybill.id">专线运单号:</label>
-                                <input :id="'carrier_bill'+waybill.id" :class="errors['_'+waybill.id]&&errors['_'+waybill.id].carrier_bill?'is-invalid tooltipTargetError':''"
-                                       v-if="waybill.isBtn || updatePool[waybill.id]" type="text" :value="waybill.carrier_bill"
+                                <input :id="'carrier_bill'+waybill.id" :class="errors['_'+waybill.id]&&errors['_'+waybill.id].carrier_bill?'is-invalid':''"
+                                       v-if="waybill.isBtn || updatePool[waybill.id]" type="text" v-model="waybill.carrier_bill"
                                         class="form-control form-control-sm " @click="enlarge($event)"  style="width: 50px">
                                 <span v-else  class="text-muted">@{{ waybill.carrier_bill }}</span>
                             </div>
                             <div class="mr-3 text-nowrap form-inline">
                                 <label :for="'inquire_tel'+waybill.id">查&nbsp;件&nbsp;电&nbsp;&nbsp;话:</label>
-                                <input :id="'inquire_tel'+waybill.id" :class="errors['_'+waybill.id]&&errors['_'+waybill.id].inquire_tel?'is-invalid tooltipTargetError':''"
-                                       v-if="waybill.isBtn || updatePool[waybill.id]" :value="waybill.inquire_tel"  @click="enlarge($event)"
+                                <input :id="'inquire_tel'+waybill.id" :class="errors['_'+waybill.id]&&errors['_'+waybill.id].inquire_tel?'is-invalid':''"
+                                       v-if="waybill.isBtn || updatePool[waybill.id]" v-model="waybill.inquire_tel"  @click="enlarge($event)"
                                        class="form-control form-control-sm" type="text" style="width:50px">
                                 <span v-else  class="text-muted">@{{ waybill.inquire_tel }}</span>
                             </div>
                             <div class="mr-3 text-nowrap form-inline">
                                 <label :for="'amount'+waybill.id">数量:</label>
                                 <div class="input-group input-group-sm" v-if="waybill.isBtn || updatePool[waybill.id]">
-                                    <input :id="'amount'+waybill.id" :class="errors['_'+waybill.id]&&errors['_'+waybill.id].amount?'is-invalid tooltipTargetError':''"
-                                     :value="waybill.amount" @click="enlarge($event)"
+                                    <input :id="'amount'+waybill.id" :class="errors['_'+waybill.id]&&(errors['_'+waybill.id].amount || errors['_'+waybill.id].amount_unit_name)?'is-invalid':''"
+                                           v-model="waybill.amount" @click="enlarge($event)"
                                    class="form-control" type="text" style="width:50px">
                                     <span class="input-group-append">
-                                        <span class="input-group-text">件</span>
+                                        <span class="input-group-text">
+                                            <span class="custom-control custom-radio">
+                                                <input :name="'radio-'+waybill.id" type="radio" class="custom-control-input" :id="'radio-one'+waybill.id" v-model="waybill.amount_unit_name" value="件"/>
+                                                <label class="custom-control-label" :for="'radio-one'+waybill.id">件</label>
+                                            </span>
+                                            <span class="custom-control custom-radio">
+                                                <input :name="'radio-'+waybill.id" type="radio" class="custom-control-input" :id="'radio-two'+waybill.id" v-model="waybill.amount_unit_name" value="托"/>
+                                                <label class="custom-control-label" :for="'radio-two'+waybill.id">托</label>
+                                            </span>
+                                        </span>
                                     </span>
                                 </div>
                                 <span v-else class="text-muted"><span v-if="waybill.amount">@{{ waybill.amount }} @{{ waybill.amount_unit_name }}</span></span>
@@ -63,9 +72,9 @@
                             <div class="mr-3 text-nowrap form-inline">
                                 <label :for="'carrier_weight_other'+waybill.id">重量:</label>
                                 <div class="input-group input-group-sm" v-if="waybill.isBtn || updatePool[waybill.id]">
-                                <input :id="'carrier_weight_other'+waybill.id" :class="errors['_'+waybill.id]&&errors['_'+waybill.id].carrier_weight_other?'is-invalid tooltipTargetError':''"
-                                   :value="waybill.carrier_weight_other" @click="enlarge($event)"
-                                    type="text" class="form-control" style="width:50px">
+                                <input :id="'carrier_weight_other'+waybill.id" :class="errors['_'+waybill.id]&&errors['_'+waybill.id].carrier_weight_other?'is-invalid':''"
+                                       v-model="waybill.carrier_weight_other" @click="enlarge($event)"
+                                    type="number" step="0.01" min="0" class="form-control" style="width:50px">
                                 <span class="input-group-append">
                                   <span class="input-group-text">KG</span>
                                 </span>
@@ -75,9 +84,9 @@
                             <div class="mr-3 text-nowrap form-inline">
                                 <label :for="'carrier_weight'+waybill.id">体积:</label>
                                 <div class="input-group input-group-sm" v-if="waybill.isBtn || updatePool[waybill.id]">
-                                    <input :id="'carrier_weight'+waybill.id" :class="errors['_'+waybill.id]&&errors['_'+waybill.id].carrier_weight?'is-invalid tooltipTargetError':''"
-                                           :value="waybill.carrier_weight" @click="enlarge($event)"
-                                           type="text" class="form-control" style="width:50px">
+                                    <input :id="'carrier_weight'+waybill.id" :class="errors['_'+waybill.id]&&errors['_'+waybill.id].carrier_weight?'is-invalid':''"
+                                           v-model="waybill.carrier_weight" @click="enlarge($event)"
+                                           type="number" step="0.01" min="0" class="form-control" style="width:50px">
                                     <span class="input-group-append">
                                       <span class="input-group-text">M³</span>
                                     </span>
@@ -89,13 +98,10 @@
                                 <div class="input-group input-group-sm">
                                     <input :id="'subjoin_fee'+waybill.id" :value="waybill.subjoin_fee"
                                            class="form-control" style="width:150px">
-<!--                                    <span class="input-group-append">
-                                      <span class="input-group-text">元</span>
-                                    </span>-->
                                 </div>
                             </div>
                             <span class="mr-3 text-nowrap">
-                                <button class="btn btn-sm btn-outline-success" @click="submit(date,waybill.isBtn,waybill.id)">提交</button>
+                                <button class="btn btn-sm btn-outline-success" type="button" @click="submit(date,waybill)">提交</button>
                                 <button v-if="!waybill.isBtn && !updatePool[waybill.id]" class="btn btn-sm btn-outline-info" @click="$set(updatePool,waybill.id,true);">修改</button>
                             </span>
                         </div>
@@ -139,7 +145,6 @@
             slideStatus:{},
             dailyBilling:{screenDate:'', billing:''},
             error:{screenDate:'', billing:''},
-            // dailyReady:{},
         },
         mounted:function(){
             $(".tooltipTarget").tooltip({'trigger':'hover'});
@@ -214,6 +219,7 @@
                             carrier_weight_other:waybill.carrier_weight_other,
                             status:waybill.status,
                             amount:waybill.amount,
+                            amount_unit_name:waybill.amount_unit ? waybill.amount_unit.name : '',
                             inquire_tel:waybill.inquire_tel,
                             carrier_name:waybill.logistic ? waybill.logistic.name : '',
                             isBtn:!!!waybill.carrier_bill,
@@ -264,23 +270,18 @@
                     return !this.updatePool[waybillId] ? "附加费添加成功" : '';
                 });
             },
-            submit(date,isBtn,waybillId,id=null){
-                if(!isBtn){this.appendSubjoinFee(date,waybillId);if (!this.updatePool[waybillId])return;}
+            submit(date,waybill){
+                if(!waybill.isBtn){this.appendSubjoinFee(date,waybill.id);if (!this.updatePool[waybill.id])return;}
                 window.tempTip.confirm("确定要提交调配信息吗?",()=>{
                     let data={
-                        id           :  id ? id : waybillId,
-                        carrier_bill :  $("#carrier_bill"+waybillId).val(),
-                        inquire_tel  :  $("#inquire_tel"+waybillId).val(),
-                        amount  :  $("#amount"+waybillId).val(),
-                        carrier_weight  :  $("#carrier_weight"+waybillId).val(),
-                        carrier_weight_other  :  $("#carrier_weight_other"+waybillId).val(),
+                        id           :  waybill.id,
+                        carrier_bill :  waybill.carrier_bill,
+                        inquire_tel  :  waybill.inquire_tel,
+                        amount       :  waybill.amount,
+                        carrier_weight  :  waybill.carrier_weight,
+                        carrier_weight_other  :  waybill.carrier_weight_other,
+                        amount_unit_name : waybill.amount_unit_name
                     };
-                    if (!data["id"]){
-                        window.tempTip.setDuration(3000);
-                        window.tempTip.show("参数异常");
-                        return;
-                    }
-                    this.errors["_"+data['id']]={};
                     axios.post("{{url('transport/waybill/storeCarrierBill')}}",data)
                         .then(response=>{
                             if (response.data.error){
@@ -289,27 +290,16 @@
                                 return;
                             }
                             if (response.data.errors){
-                                this.$set(this.errors,"_"+data['id'],response.data.errors);
-                                setTimeout(function(){
-                                    $(".tooltipTargetError").tooltip('show');
-                                },1);
+                                let key = "_"+data['id']
+                                let errors = {};
+                                errors[key] = response.data.errors;
+                                this.errors = errors;
                                 return;
                             }
-                            this.groups[date].waybills.some(function (waybill) {
-                                if (waybill.id===data['id']){
-                                    waybill.carrier_bill=response.data.carrier_bill;
-                                    waybill.inquire_tel=response.data.inquire_tel;
-                                    waybill.amount=response.data.amount;
-                                    waybill.amount_unit_name=response.data.amount_unit_name;
-                                    waybill.carrier_weight=response.data.carrier_weight;
-                                    waybill.carrier_weight_other=response.data.carrier_weight_other;
-                                    if (waybill.carrier_bill)waybill.isBtn=false;
-                                    return true;
-                                }
-                            });
+                            waybill.isBtn=false;
                             tempTip.setDuration(2000);
-                            if (this.updatePool[waybillId]){
-                                tempTip.showSuccess('修改成功!');this.$set(this.updatePool,waybillId,false);
+                            if (this.updatePool[waybill.id]){
+                                tempTip.showSuccess('修改成功!');this.$set(this.updatePool,waybill.id,false);
                             }else tempTip.showSuccess('录入成功!');
                         }).catch(function (err) {
                             tempTip.setDuration(3000);