Browse Source

运输管理-同时编辑互不覆盖-补充提交-2

Zhouzhendong 5 năm trước cách đây
mục cha
commit
5ea4d3912b

+ 13 - 7
app/Http/Controllers/WaybillsController.php

@@ -876,26 +876,32 @@ class WaybillsController extends Controller
         return $validator;
     }
     protected function validatorWaybillDispatch(Request $request,$id){
-        $validator=Validator::make($request->input(),[
-            'carrier_id'=>'sometimes|required|integer',
+        $rule=[
+            'carrier_id'=>'required|integer',
             'carrier_bill'=>"sometimes|nullable|max:50|unique:waybills,carrier_bill,$id",
             'fee'=>'sometimes|nullable|min:0|numeric|max:999999',
             'other_fee'=>'sometimes|nullable|min:0|numeric|max:999999',
             'charge'=>'sometimes|nullable|min:0|numeric|max:999999',
-            'mileage'=>'sometimes|nullable|numeric|min:0',
-            'amount'=>'sometimes|nullable|numeric|min:0',
-            'amount_unit_id'=>'sometimes|required',
+            'mileage'=>'nullable|numeric|min:0',
+            'amount'=>'nullable|numeric|min:0',
+            'amount_unit_id'=>'required',
+            'origination_city_id'=>'sometimes|required|integer',
+            'destination_city_id'=>'sometimes|required|integer',
             'warehouse_weight_other'=>'sometimes|nullable|min:0|numeric|max:999999',
             'warehouse_weight_unit_id_other'=>'sometimes|required_with:warehouse_weight_other|nullable|integer',
             'pick_up_fee'=>'sometimes|nullable|min:0|numeric|max:999999',
-            'destination_city_id'=>'sometimes|required|integer',
             'warehouse_weight'=>'sometimes|nullable|min:0|numeric|max:999999',
             'warehouse_weight_unit_id'=>'sometimes|required_with:warehouse_weight|nullable|integer',
             'carrier_weight'=>'sometimes|nullable|min:0|numeric|max:999999',
             'carrier_weight_unit_id'=>'sometimes|required_with:carrier_weight',
             'carrier_weight_other'=>'sometimes|nullable|min:0|numeric|max:999999',
             'carrier_weight_unit_id_other'=>'sometimes|required_with:carrier_weight_other',
-        ],[
+        ];
+        if ($request->type == '专线'){
+            $rule['origination_city_id']='required|integer';
+            $rule['destination_city_id']='required|integer';
+        }
+        $validator=Validator::make($request->input(),$rule,[
             'required'=>':attribute 为必填项',
             'alpha_num'=>':attribute 应为字母或数字',
             'max'=>':attribute 字符过多或输入值过大',

+ 4 - 4
resources/views/waybill/edit.blade.php

@@ -255,7 +255,7 @@
 
                     </div>
                     <div class="form-group row">
-                        <label for="carrier_id" class="col-2 col-form-label text-right text-primary">里程数</label>
+                        <label for="carrier_id" class="col-2 col-form-label text-right text-dark">里程数</label>
                         <div class="col-8">
                             <input type="number" class="form-control @error('mileage') is-invalid @enderror"
                                    name="mileage" autocomplete="off" v-model="waybill.mileage" id="mileage" >
@@ -541,9 +541,9 @@
                         );
                 },
                 executeSubmit(){
-                    let data=['type','origination','charge','carrier_id','carrier_bill','origination_city_id','destination_city_id'
-                        ,'warehouse_weight','warehouse_weight_unit_id','warehouse_weight_other','warehouse_weight_unit_id_other','carrier_weight','carrier_weight_unit_id'
-                        ,'carrier_weight_other','carrier_weight_unit_id_other','amount_unit_id','amount_unit_id1','amount','mileage','carType_id'
+                    let data=['origination','charge','carrier_bill', 'warehouse_weight','warehouse_weight_unit_id',
+                        'warehouse_weight_other','warehouse_weight_unit_id_other','carrier_weight','carrier_weight_unit_id'
+                        ,'carrier_weight_other','carrier_weight_unit_id_other','mileage','carType_id'
                         ,'car_owner_info','pick_up_fee','fee','other_fee','other_charge','other_charge_remark','dispatch_remark'];
                     let waybill=this.waybill;
                     let waybillTemp=this.waybillTemp;