Bladeren bron

增加最大校验

Zhouzhendong 6 jaren geleden
bovenliggende
commit
ed1d0c3cf7

+ 3 - 2
app/Http/Controllers/CarriersController.php

@@ -67,9 +67,9 @@ class CarriersController extends Controller
 
     protected function validatorCarrier(Request $request){
         $validator=Validator::make($request->input(),[
-            'Carrier.name'=>'max:50|required|unique:carriers,name',
+            'Carrier.name'=>'digits_between:1,50|required|unique:carriers,name',
             'Carrier.mobile'=>['required','regex:/^(\d{7,11})|(1[3|4|5|7|8][0-9]\d{4,8})$/','unique:carriers,name'],
-            'Carrier.delivery_fee'=>'nullable|min:0|numeric',
+            'Carrier.delivery_fee'=>'nullable|min:0|numeric|max:999999',
         ],[
             'digits_between'=>':attribute 最小一位,最大五十位',
             'required'=>':attribute 不应为空',
@@ -78,6 +78,7 @@ class CarriersController extends Controller
             'min'=>':attribute 不得为0或为负',
             'numeric'=>':attribute 必须为数字',
             'unique'=>':attribute 已存在',
+            'max'=>':attribute 输入值过大',
         ],[
             'Carrier.name'=>'承运商名称',
             'Carrier.mobile'=>'承运商电话',

+ 5 - 5
app/Http/Controllers/WaybillPriceModelsController.php

@@ -167,11 +167,11 @@ class WaybillPriceModelsController extends Controller
             'WaybillPriceModel.carrier_id'=>'required|integer',
             'WaybillPriceModel.unit_id'=>'required|integer',
             'WaybillPriceModel.city_id'=>'nullable|Integer',
-            'WaybillPriceModel.range_min'=> 'nullable|min:0|numeric',
-            'WaybillPriceModel.range_max'=> "nullable|min:{$min}|numeric",
-            'WaybillPriceModel.unit_price'=>'required|min:0|numeric',
-            'WaybillPriceModel.base_fee'=>'nullable|min:0|numeric',
-            'WaybillPriceModel.initial_weight'=>'nullable|min:0|numeric',
+            'WaybillPriceModel.range_min'=> 'nullable|min:0|numeric|max:999999',
+            'WaybillPriceModel.range_max'=> "nullable|min:{$min}|numeric|max:999999",
+            'WaybillPriceModel.unit_price'=>'required|min:0|numeric|max:999999',
+            'WaybillPriceModel.base_fee'=>'nullable|min:0|numeric|max:999999',
+            'WaybillPriceModel.initial_weight'=>'nullable|min:0|numeric|max:999999',
         ],[
             'required'=>':attribute 为必填项',
             'min'     =>':attribute 数值过小',

+ 10 - 10
app/Http/Controllers/WaybillsController.php

@@ -513,12 +513,12 @@ class WaybillsController extends Controller
             'destination'=>'required|max:255',
             'recipient'=>'required|max:50',
             'recipient_mobile'=>['required','regex:/^(\d{7,11})|(1[3|4|5|7|8][0-9]\d{4,8})$/'],
-            'charge'=>'required|min:0|numeric',
+            'charge'=>'required|min:0|max:999999|numeric',
             'collect_fee'=>'nullable|min:0|numeric',
         ],[
             'required'=>':attribute 为必填项',
             'alpha_num'=>':attribute 应为字母或数字',
-            'max'=>':attribute 字符过多',
+            'max'=>':attribute 字符过多或输入值过大',
             'regex'=>':attribute 输入有误',
             'integer'=>':attribute 应为整数',
             'min'=>':attribute 不得为负',
@@ -540,12 +540,12 @@ class WaybillsController extends Controller
         if ($request->input('type')=='直发车'){
             $validator=Validator::make($request->input(),[
                 'carrier_bill'=>'required|alpha_num|max:50|unique:waybills,carrier_bill',
-                'fee'=>'required|min:0|numeric',
-                'other_fee'=>'nullable|min:0|numeric',
+                'fee'=>'required|min:0|numeric|max:999999',
+                'other_fee'=>'nullable|min:0|numeric|max:999999',
             ],[
                 'required'=>':attribute 为必填项',
                 'alpha_num'=>':attribute 应为字母或数字',
-                'max'=>':attribute 字符过多',
+                'max'=>':attribute 字符过多或输入值过大',
                 'min'=>':attribute 不得为负',
                 'numeric'=>':attribute 应为数字',
                 'unique'=>':attribute 已存在',
@@ -558,17 +558,17 @@ class WaybillsController extends Controller
         }else if ($request->input('type')=='专线'){
             $validator=Validator::make($request->input(),[
                 'carrier_bill'=>'required|alpha_num|max:50|unique:waybills,carrier_bill',
-                'warehouse_weight'=>'required|min:0|numeric',
-                'carrier_weight'=>'required|min:0|numeric',
-                'pick_up_fee'=>'required|min:0|numeric',
-                'other_fee'=>'nullable|min:0|numeric',
+                'warehouse_weight'=>'required|min:0|numeric|max:999999',
+                'carrier_weight'=>'required|min:0|numeric|max:999999',
+                'pick_up_fee'=>'required|min:0|numeric|max:999999',
+                'other_fee'=>'nullable|min:0|numeric|max:999999',
                 'carrier_id'=>'required|integer',
                 'destination_city_id'=>'required|integer',
                 'carrier_weight_unit_id'=>'required|integer',
             ],[
                 'required'=>':attribute 为必填项',
                 'alpha_num'=>':attribute 应为字母或数字',
-                'max'=>':attribute 字符过多',
+                'max'=>':attribute 字符过多或输入值过大',
                 'min'=>':attribute 不得为负',
                 'numeric'=>':attribute 应为数字',
                 'unique'=>':attribute 已存在',

+ 4 - 6
resources/views/waybill/create.blade.php

@@ -27,16 +27,14 @@
                     <div class="form-group row">
                         <label for="owner_id" class="col-2 col-form-label text-right text-primary">货主 *</label>
                         <div class="col-8 form-inline">
-                            <select name="owner_id" class="form-control" v-model="owner_name"  style="width: 30%">
+                            <select name="owner_id" class="form-control @error('owner_id') is-invalid @enderror" v-model="owner_name"  style="width: 30%">
                                    <option v-for="owner in owners" :value="owner.id">@{{owner.name}}</option>
                             </select>
                             <input class="form-control-sm" placeholder="输入关键字定位" @input="owner_id">
                         </div>
-                        @error('owner_id')
-                        <span class="invalid-feedback" role="alert">
-                                        <strong>{{ $message }}</strong>
-                                    </span>
-                        @enderror
+                        <div class="col-sm-5">
+                            <p class="form-control-static text-danger small font-weight-bold" style="margin-left: 50%">{{ $errors->first('owner_id') }}</p>
+                        </div>
                     </div>
                     <div class="form-group row">
                         <label for="wms_bill_number" class="col-2 col-form-label text-right text-muted">WMS单号</label>