Просмотр исходного кода

运输管理-提货费总计功能

hu hao 5 лет назад
Родитель
Сommit
adb96a254b

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

@@ -948,5 +948,13 @@ class WaybillController extends Controller
         if (!isset($waybills))return ['success'=>false,'message'=>'该日有记录未填写重量'];
         return ['success'=>true,'data'=>$waybills];
     }
+    public function countPickUpFee(Request $request)
+    {
+        if(!Gate::allows('运输管理-运单-查询')){ return ['success'=>false,'message'=>'没有权限'];  }
+        $param=$request->input('param');
+        $waybills=app('waybillService')->get($param);
+        $total_pick_up_fee=$waybills->sum('pick_up_fee');
+        return ['success'=>true,'data'=>$total_pick_up_fee];
+    }
 
 }

+ 2 - 2
app/Services/WaybillService.php

@@ -28,7 +28,7 @@ class WaybillService
      */
     private function conditionQuery(array $param){
         $waybills = Waybill::filterAuthorities()->with(['owner','logistic','originationCity','destinationCity.parent',
-            'uploadFile','amountUnit','warehouseWeightUnit','carrierWeightUnit','district',
+            'uploadFile','amountUnit','warehouseWeightUnit','carrierWeightUnit','district','order',
             'warehouseWeightUnitOther','carrierWeightUnitOther','carType','uploadFile','waybillAuditLogs.user'])
             ->selectRaw('waybills.* ,waybill_on_tops.id top_id ,waybill_on_tops.remark,waybill_on_tops.updated_at top_update')
             ->leftJoin('waybill_on_tops','waybill_on_tops.waybill_id','=','waybills.id')
@@ -148,7 +148,7 @@ class WaybillService
             ->where('waybills.type','专线')->exists();
         if ($isWeight)return null;
         $waybills = Waybill::query()->with(['owner','logistic','originationCity','destinationCity.parent',
-            'uploadFile','amountUnit','warehouseWeightUnit','carrierWeightUnit','district',
+            'uploadFile','amountUnit','warehouseWeightUnit','carrierWeightUnit','district','order',
             'warehouseWeightUnitOther','carrierWeightUnitOther','carType','uploadFile','waybillAuditLogs.user'])
             ->selectRaw('waybills.* ,waybill_on_tops.id top_id,waybill_on_tops.remark,waybill_on_tops.updated_at top_update')
             ->leftJoin('waybill_on_tops','waybill_on_tops.waybill_id','=','waybills.id')

+ 66 - 22
resources/views/transport/waybill/index.blade.php

@@ -16,17 +16,17 @@
                 <div class="card menu-third" >
                     <ul class="nav nav-pills">
                         @can('运输管理-运单-查询')
-                        <li class="nav-item">
-                            <a class="nav-link @if($uriType=='') active @endif" href="{{url('transport/waybill/index')}}">全部</a>
-                        </li> @endcan
+                            <li class="nav-item">
+                                <a class="nav-link @if($uriType=='') active @endif" href="{{url('transport/waybill/index')}}">全部</a>
+                            </li> @endcan
                         @can('运输管理-运单-查询')
-                        <li class="nav-item">
-                            <a class="nav-link @if($uriType=='专线') active @endif" href="{{url('transport/waybill/index?uriType=专线')}}">专线</a>
-                        </li> @endcan
+                            <li class="nav-item">
+                                <a class="nav-link @if($uriType=='专线') active @endif" href="{{url('transport/waybill/index?uriType=专线')}}">专线</a>
+                            </li> @endcan
                         @can('运输管理-运单-查询')
-                        <li class="nav-item">
-                            <a class="nav-link @if($uriType=='直发车') active @endif" href="{{url('transport/waybill/index?uriType=直发车')}}">直发车</a>
-                        </li> @endcan
+                            <li class="nav-item">
+                                <a class="nav-link @if($uriType=='直发车') active @endif" href="{{url('transport/waybill/index?uriType=直发车')}}">直发车</a>
+                            </li> @endcan
                     </ul>
                 </div>
             </div>
@@ -43,7 +43,7 @@
             </span>
             @can('运输管理-运单-图片上传')<button class="btn btn-sm btn-outline-info" data-target="#batchUploadImg" data-toggle="modal">批量上传图片</button>@endcan
             @if($uriType=='' || $uriType=='专线')
-            @can('运输管理-运单-按日计算专线费')
+                @can('运输管理-运单-按日计算专线费')
                     <button class="btn btn-sm btn-outline-success tooltipTarget" data-target="#dailyBilling" data-toggle="modal"
                             title="计算指定日期下的所有专线费,不考虑有无货主权限">按日输入专线费</button>@endcan
             @endif
@@ -129,11 +129,11 @@
                     <td class="td-warm"><span>@{{waybill.end_date}}</span></td>
                     <td class="td-warm"><span>@{{waybill.waybill_number}}</span></td>
                     @can('运输管理-运单-运单编辑')
-                    <td class="td-warm" >
-                        <span v-if="waybill.charge" class="btn-sm btn-outline-secondary btn" @click="waybillChargeCheck($event)" :data_id="waybill.id">@{{waybill.charge|money}}</span>
-                        <input v-else type="number" class="form-control form-control-sm" @blur="addWaybillCharge($event)" onfocus="$(this).css('width','85px')" :value="waybill.charge" :data_id="waybill.id" >
-                        <input type="number" class="form-control form-control-sm"  @blur="updateWaybillCharge($event)" :value="waybill.charge" :data_id="waybill.id" style="min-width:85px;display: none">
-                    </td>
+                        <td class="td-warm" >
+                            <span v-if="waybill.charge" class="btn-sm btn-outline-secondary btn" @click="waybillChargeCheck($event)" :data_id="waybill.id">@{{waybill.charge|money}}</span>
+                            <input v-else type="number" class="form-control form-control-sm" @blur="addWaybillCharge($event)" onfocus="$(this).css('width','85px')" :value="waybill.charge" :data_id="waybill.id" >
+                            <input type="number" class="form-control form-control-sm"  @blur="updateWaybillCharge($event)" :value="waybill.charge" :data_id="waybill.id" style="min-width:85px;display: none">
+                        </td>
                     @else
                         <td class="td-warm" ><span v-if="waybill.charge">@{{waybill.charge|money}}</span></td>
                     @endcan
@@ -142,7 +142,7 @@
                     <td class="td-warm">
                         <div align="center" @mouseleave="removeCommonImg('common_img_'+waybill.id)" @mouseenter="commonImg('img_'+waybill.id,waybill.url,waybill.suffix)">
                             <img v-if="waybill.url" :id="'img_'+waybill.id"  :src="waybill.url+'-thumbnail.'+waybill.suffix"
-                                    {{--:data-src="waybill.url+'-thumbnail.'+waybill.suffix" src="{{url('icon/img404-thumbnail.jpg')}}"--}}>
+                                {{--:data-src="waybill.url+'-thumbnail.'+waybill.suffix" src="{{url('icon/img404-thumbnail.jpg')}}"--}}>
                             @can('运输管理-运单-图片上传')<div v-if="!waybill.url">
                                 <input class="btn  btn-sm btn-outline-secondary" type="button" @click="certiimg(waybill.waybill_number)" value="上传照片 "/>
                                 <input type="file" @change="submitFile($event,waybill.waybill_number)" :id="waybill.waybill_number"
@@ -334,7 +334,7 @@
                         mileage:'{{$waybill->mileage}}',
                         amount:'{{$waybill->amount}}',
                         @if($waybill->carType)carType:{!! $waybill->carType !!},car_owner_info:'{{$waybill->car_owner_info}}',@endif
-                        @can('运输管理-运单-可见费用项') fee:'{{$waybill->fee}}',
+                            @can('运输管理-运单-可见费用项') fee:'{{$waybill->fee}}',
                         pick_up_fee:'{{$waybill->pick_up_fee}}',other_fee:'{{$waybill->other_fee}}',
                         collect_fee:'{{$waybill->collect_fee}}', @endcan
                         deliver_at:'{{$waybill->deliver_at}}',
@@ -418,12 +418,56 @@
                     param:param,
                 });
                 this.form.init();
+                console.log(this.form)
                 this.rendingHeader();
                 this.paginate = $("#paginate").val();
                 let waybill =  $('.table-header-layer-1')[1];
                 $('.top').css('min-width', waybill.scrollWidth);
+                this.rendingFloatBtn();
             },
             methods:{
+                rendingFloatBtn(){
+                    let parent = $('.pick-btn :visible');
+                    if (parent.length<1)return;
+                    parent = parent[0];
+                    let node = document.createElement("btn");
+                    parent.className += "position-relative";
+                    node.className = "position-absolute btn btn-sm btn-success total-fee";
+                    node.style.top=0;
+                    node.style.left=0;
+                    node.style.marginTop="-16%";
+                    node.innerText = '总计';
+                    parent.before(node);
+                    node.onclick=this.countPickUpFee;
+                },
+                countPickUpFee(){
+                    let url = '{{url('transport/waybill/countPickUpFee')}}';
+                    let urlRequest = location.search; //获取url中"?"符后的字串
+                    let theRequest = {};
+                    if (urlRequest.indexOf("?") != -1) {
+                        let str = urlRequest.substr(1);
+                        let strs = str.split("&");
+                        for(let i = 0; i < strs.length; i ++) {
+                            theRequest[strs[i].split("=")[0]] = decodeURIComponent(decodeURI(strs[i].split("=")[1]));
+                        }
+                    }
+                    window.axios.post(url,{param:theRequest})
+                        .then(response=> {
+                                if (!response.data.success){
+                                     tempTip.setDuration(2000);
+                                     tempTip.show(response.data.message);
+                                }else{
+                                    $('.total-fee').text('总计:'+response.data.data);
+                                     tempTip.setDuration(2000);
+                                     tempTip.showSuccess('根据当前筛选条件计算专线提货费成功')
+                                }
+
+                            }
+                        ).catch(function (err){
+                         tempTip.setDuration(2000);
+                         tempTip.show('根据当前筛选条件计算专线提货费失败,网络连接错误!'+err)
+                    })
+                },
                 dailyBillingCount(){
                     if (this.dailyBilling.screenDate==='')this.error.screenDate='请指定日期';
                     if (this.dailyBilling.billing==='')this.error.billing='专线费必填';
@@ -456,9 +500,9 @@
 
                             }
                         ).catch(function (err){
-                            tempTip.setDuration(3000);
-                            tempTip.show('按日输入专线费失败,网络连接错误!'+err)
-                        })
+                        tempTip.setDuration(3000);
+                        tempTip.show('按日输入专线费失败,网络连接错误!'+err)
+                    })
                 },
                 rendingHeader(){
                     let column = [
@@ -498,7 +542,7 @@
                         {name:'amount',value: '计件', neglect: true, class:"td-cool"},
                         {name:'mileage',value: '里程', neglect: true, class:"td-cool"},
                             @can('运输管理-运单-运费'){name:'fee',value: '运费', neglect: true, class:"td-helpful"},@endcan
-                        {name:'pick_up_fee',value: '提货费', neglect: true, class:"td-helpful"},
+                        {name:'pick_up_fee',value: '提货费', neglect: true, class:"td-helpful pick-btn"},
                         {name:'other_fee',value: '其他支出', neglect: true, class:"td-helpful"},
                         {name:'deliver_at',value: '发货时间', class:"td-helpful"},
                         {name:'dispatch_remark',value: '调度备注', class:"td-helpful"},
@@ -679,7 +723,7 @@
                         "<img src=\""+url+'-common.'+suffix+"\" style='position: relative;left:-50px;' >" +
                         "</a>" +
                         "</div>"+
-                            @can('运输管理-运单-图片删除')"<button type='button' class='btn btn-sm btn-danger' onclick='vue.btnDeleteImg(this)' value='"+id+"' style='position: relative;float: right;margin-right: 51px;margin-top: -30px;' >删除</button>" +@endcan
+                        @can('运输管理-运单-图片删除')"<button type='button' class='btn btn-sm btn-danger' onclick='vue.btnDeleteImg(this)' value='"+id+"' style='position: relative;float: right;margin-right: 51px;margin-top: -30px;' >删除</button>" +@endcan
                             "</div>"+
                         "</div>");
                 },

+ 1 - 0
routes/web.php

@@ -297,6 +297,7 @@ Route::group(['prefix'=>'transport'],function(){
         Route::any('waybillUpdate/{id}','WaybillController@waybillUpdate');
         Route::post('batchUploadImages','WaybillController@batchUploadImages');
         Route::post('dailyBilling','WaybillController@dailyBilling');
+        Route::post('countPickUpFee','WaybillController@countPickUpFee');
         Route::resource('waybillFinancialSnapshot','WaybillFinancialSnapshotsController');
         Route::resource('waybillFinancialExcepted','WaybillFinancialExceptedController');
     });