Преглед изворни кода

运输管理--应收运费添加input编辑框,编辑,调度,改调度点击打开新窗口

haozi пре 5 година
родитељ
комит
307f403652

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

@@ -826,6 +826,18 @@ class WaybillController extends Controller
         $this->log(__METHOD__,__FUNCTION__,json_encode($request->toArray()),Auth::user()['id']);
         return ['success'=>$result,'status'=>$result];
     }
+    // 修改运输收费
+    public function changeCharge(Request $request){
+        if(!Gate::allows('运输管理-运单编辑')){return ['success'=>'false','fail_info'=>'没有权限'];}
+        $wayBillId = $request->id;
+        $waybillCharge = $request->input('charge');
+        if(is_null($wayBillId) or is_null($waybillCharge)){
+            return ['success'=>'false','fail_info'=>'参数异常'];
+        }
+        $result = Waybill::where('id',$wayBillId)->update(['charge'=>$waybillCharge]);
+        $this->log(__METHOD__,__FUNCTION__,json_encode($request->toArray()),Auth::user()['id']);
+        return ['success'=>$result,'status'=>$result];
+    }
     // 置顶
     public function waybillOnTop(Request $request){
         $id =  $request->input('id');

+ 0 - 2
resources/views/personnel/checking-in/getQRcode.blade.php

@@ -27,8 +27,6 @@
 
                 </div>
             </div>
-
-                <h3 v-else>还未录入仓库,请先录入仓库!</h3>
             </div>
         </div>
     </div>

+ 104 - 10
resources/views/waybill/index.blade.php

@@ -121,13 +121,15 @@
                                 <button class="btn btn-outline-primary btn-sm" @click="waybillAudit(waybill.id,waybill.waybill_number)">审核</button>
                             @endcan
                             @can('运输管理-编辑')
-                                <button class="btn btn-outline-secondary btn-sm" @click="waybillUpdate(waybill.id)">修改</button>
+{{--                                <button  class="btn btn-outline-secondary btn-sm" @click="waybillUpdate(waybill.id)">修改</button>--}}
+                                    <a target="_blank" class="btn btn-outline-secondary btn-sm" :href= "('{{url('waybill/waybillEdit')}}/'+waybill.id)">修改</a>
                             @endcan
                         </span>
                         <span v-if=waybill.status==="已审核">
                             @can('运输管理-调度')
                                 <button class="btn btn-outline-secondary btn-sm" @click="waybillRetreatAudit(waybill.id,waybill.waybill_number)">取消审核</button>
-                                <button class="btn btn-outline-secondary btn-sm" @click="job(waybill.id)">调度</button>
+{{--                                <button class="btn btn-outline-secondary btn-sm" @click="job(waybill.id)">调度</button>--}}
+                                <a target="_blank" class="btn btn-outline-secondary btn-sm" :href= "('{{url('waybill')}}/'+waybill.id+'/edit')">调度</a>
                             @endcan
                         </span>
                         <span v-if=waybill.status==="待终审">
@@ -135,7 +137,8 @@
                                 <button class="btn btn-outline-success btn-sm" @click="waybillEndAudit(waybill.id,waybill.waybill_number)">完结</button>
                             @endcan
                             @can('运输管理-调度')
-                                <button class="btn btn-outline-secondary btn-sm" @click="job(waybill.id)">改调度</button>
+{{--                                <button class="btn btn-outline-secondary btn-sm" @click="job(waybill.id)">改调度</button>--}}
+                                    <a target="_blank" class="btn btn-outline-secondary btn-sm" :href= "('{{url('waybill')}}/'+waybill.id+'/edit')">改调度</a>
                             @endcan
                         </span>
                     </td>
@@ -158,7 +161,19 @@
                     <td class="td-warm toptd" :title="waybill.remark? '置顶备注:'+waybill.remark :''">@{{waybill.source_bill}}</td>
                     <td class="td-warm" >@{{waybill.wms_bill_number}}</td>
                     <td class="td-warm">@{{waybill.waybill_number}}</td>
-                    <td class="td-warm">@{{waybill.charge}}</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>
+                        @else
+                        <td class="td-warm" ><span v-if="waybill.charge">@{{waybill.charge|money}}</span></td>
+                    @endcan
+{{--                    <td class="td-warm ">--}}
+{{--                        @{{waybill.charge}}--}}
+{{--                    </td>--}}
+
                     <td class="td-warm">@{{waybill.other_charge}}</td>
                     <td class="td-warm">@{{waybill.other_charge_remark}}</td>
                     <td class="td-warm">
@@ -534,9 +549,9 @@
                         tempTip.show('审核失败,网络连接错误!'+err);
                     });
                 },
-                waybillUpdate(id){
-                    location.href="{{url('waybill/waybillEdit')}}/"+id;
-                },
+                {{--waybillUpdate(id){--}}
+                {{--    location.href="{{url('waybill/waybillEdit')}}/"+id;--}}
+                {{--},--}}
                 // 软删除
                 waybillDestroy(id,waybill_number){
                     if(!confirm('确定要删除运单号为:“'+waybill_number+'”的运单吗?')){return};
@@ -590,9 +605,9 @@
                         tempTip.show('审核驳回失败,网络连接错误!'+err);
                     });
                 },
-                job(id){
-                    location.href="{{url('waybill')}}/"+id+"/edit";
-                },
+                {{--job(id){--}}
+                {{--    location.href="{{url('waybill')}}/"+id+"/edit";--}}
+                {{--},--}}
                 waybillEndAudit(id,waybill_number){
                     if(!confirm('确定要通过“'+waybill_number+'”的终审吗?')){return};
                     let _this=this;
@@ -781,6 +796,85 @@
                         tempTip.show("网络错误:"+err);
                     });
                 },
+                // 运输收费修改
+                waybillChargeCheck:function (e) {
+                    let target = $(e.target);
+                    target.hide();
+                    let input = target.next();
+                    input.show();
+                    input.focus();
+                },
+                // 运输收费失焦事件
+                updateWaybillCharge:function (e) {
+                    let target = $(e.target);
+                    let _this = this;
+                    let span = target.prev();
+                    let id = target.attr('data_id');
+                    let oldCharge = span.text();
+                    let charge = target.val();
+                    if(charge !== span.text()){
+                        let ajaxUrl= '{{url("apiLocal/waybill/changeCharge")}}';
+                        axios.post(ajaxUrl,{'id':id,'charge':charge}).then(function (response) {
+                            if(response.data.success){
+                                _this.updateWaybill(id,charge);
+                                tempTip.setDuration(2000);
+                                tempTip.showSuccess('运输收费修改成功');
+                            }else{
+                                tempTip.setDuration(3000);
+                                tempTip.show('运输收费修改失败!'+response.data.fail_info);
+                                _this.updateWaybill(id,oldCharge);
+                            }
+                        }).catch(function (err) {
+                            tempTip.setDuration(3000);
+                            tempTip.show('运输收费修改失败!网络异常:'+err);
+                            _this.updateWaybill(id,oldCharge);
+                        });
+                    }
+                    span.show();
+                    target.hide();
+                },
+                // 为运单添加运输收费
+                addWaybillCharge(e){
+                    let target = $(e.target);
+                    target.css('width','85px');
+                    let _this = this;
+                    let id = target.attr('data_id');
+                    let charge = target.val();
+                    console.log(charge);
+                    let ajaxUrl= '{{url("apiLocal/waybill/changeCharge")}}';
+                    if(charge === ''|| charge === null){
+                        target.css('width','75px');
+                        return;
+                    }else{
+                        axios.post(ajaxUrl,{'id':id,'charge':charge}).then(function (response) {
+                            if(response.data.success){
+                                tempTip.setDuration(2000);
+                                tempTip.showSuccess('运输收费添加成功');
+                                _this.updateWaybill(id,charge);
+                            }else{
+                                tempTip.setDuration(3000);
+                                tempTip.show('运输收费添加失败!'+response.data.fail_info);
+                            }
+                        }).catch(function (err) {
+                            tempTip.setDuration(3000);
+                            tempTip.show('运输收费添加失败!网络异常:'+err);
+                        });
+                        target.css('width','75px');
+                    }
+                },
+                // 修改运输收费更新表格数据
+                updateWaybill(id,newCharge){
+                    this.waybills.some(function(waybill){
+                        if(waybill.id === id){
+                            waybill.charge = newCharge;
+                            return true;
+                        }
+                    })
+                },
+
+
+
+
                 // 运费修改
                 waybillFeeCheck:function (e) {
                     let target = $(e.target);

+ 1 - 0
routes/apiLocal.php

@@ -27,4 +27,5 @@ Route::post('commodity/getCommodityByBarcode', 'CommodityController@apiGetCommod
 
 Route::post('waybill/recoverSelected', 'WaybillController@apiRestoreSelected');
 Route::post('waybill/changeFee', 'WaybillController@changeFee');
+Route::post('waybill/changeCharge', 'WaybillController@changeCharge');