瀏覽代碼

Merge branch 'waybill_ZD'

LD 6 年之前
父節點
當前提交
646787e764

+ 1 - 1
app/Http/Controllers/CitiesController.php

@@ -71,7 +71,7 @@ class CitiesController extends Controller
     public function validatorCities(Request $request,$id){
         if ($id){$name=$id;}
         $validator=Validator::make($request->input(),[
-            'City.name'=>'||',['required','max:50',isset($name)?"unique:cities,name,$name":'unique:cities,name'],
+            'City.name'=>['required','max:50',isset($name)?"unique:cities,name,$name":'unique:cities,name'],
         ],[
             'required'=>':attribute 为必填项',
             'unique'=>':attribute 已存在',

+ 21 - 2
app/Http/Controllers/MeasuringMachineController.php

@@ -4,6 +4,7 @@ namespace App\Http\Controllers;
 
 use App\MeasuringMachine;
 use Illuminate\Http\Request;
+use Illuminate\Support\Facades\Validator;
 
 class MeasuringMachineController extends Controller
 {
@@ -25,7 +26,7 @@ class MeasuringMachineController extends Controller
      */
     public function create()
     {
-        //
+        return view('maintenance.measuringMachine.create');
     }
 
     /**
@@ -36,7 +37,10 @@ class MeasuringMachineController extends Controller
      */
     public function store(Request $request)
     {
-        //
+        $id=false;
+        $this->validator($request,$id)->validate();
+        MeasuringMachine::create($request->input());
+        return redirect('maintenance/measuringMachine')->with('successTip','新设备“'.$request->input('name').'”添加成功');
     }
 
     /**
@@ -83,4 +87,19 @@ class MeasuringMachineController extends Controller
     {
         //
     }
+
+    public function validator(Request $request,$id){
+        if ($id){$code=$id;}
+        $validator=Validator::make($request->input(),[
+            'name'=>['required','max:50'],
+            'code'=>['required','max:50',isset($code)?"unique:measuring_machines,code,$code":'unique:measuring_machines,code'],
+        ],[
+            'required'=>':attribute 为必填项',
+            'unique'=>':attribute 已存在',
+        ],[
+            'name'=>'设备名',
+            'code'=>'设备代码',
+        ]);
+        return $validator;
+    }
 }

+ 1 - 1
app/Http/Controllers/ProvincesController.php

@@ -68,7 +68,7 @@ class ProvincesController extends Controller
     protected function validatorProvinces(Request $request,$id){
         if ($id){$name=$id;}
         $validator=Validator::make($request->input(),[
-            'Province.name'=>'||',['required','max:50',isset($name)?"unique:provinces,name,$name":'unique:provinces,name'],
+            'Province.name'=>['required','max:50',isset($name)?"unique:provinces,name,$name":'unique:provinces,name'],
         ],[
             'required'=>':attribute 为必填项',
             'unique'=>':attribute 已存在',

+ 4 - 2
app/Http/Controllers/WaybillsController.php

@@ -498,8 +498,10 @@ class WaybillsController extends Controller
         $waybill=Waybill::find($id);
         if (!$waybill->charge&&!$waybill->collect_fee)return ['exception'=>'收费或到付费用未填!'];
         if ($waybill->charge==0&&$waybill->collect_fee==0)return ['exception'=>'收费与到付费用都为0!'];
-        if (!$waybill->carrier_weight||$waybill->carrier_weight==0)return ['exception'=>'承运商计重未填或为0!'];
-        if (!$waybill->carrier_weight_unit_id)return ['exception'=>'承运商计重单位未选!'];
+        if ($waybill->type=='专线'){
+            if (!$waybill->carrier_weight||$waybill->carrier_weight==0)return ['exception'=>'承运商计重未填或为0!'];
+            if (!$waybill->carrier_weight_unit_id)return ['exception'=>'承运商计重单位未选!'];
+        }
         $isAudit=WaybillAuditLog::whereRaw('waybill_id = ? and audit_stage = ?',[$id,"调度阶段"])->first();
         if (empty($isAudit)){
             $waybillAuditLog=new WaybillAuditLog([

+ 1 - 1
database/migrations/2019_12_30_143601_create_measuring_machines_table.php

@@ -17,7 +17,7 @@ class CreateMeasuringMachinesTable extends Migration
             $table->bigIncrements('id');
             $table->string('name')->comment('设备名');
             $table->string('code')->comment('设备ID');
-            $table->enum('status',['在线','离线'])->comment('设备状态');
+            $table->enum('status',['在线','离线'])->default('离线')->comment('设备状态');
             $table->timestamps();
         });
     }

+ 0 - 19
resources/views/maintenance/measuringMachine/create.blade.php

@@ -34,25 +34,6 @@
                             @enderror
                         </div>
                     </div>
-                    <div class="form-group row">
-                        <label for="delivery_fee" class="col-2 col-form-label text-right">送货费</label>
-                        <div class="col-8">
-                            <input type="text" class="form-control @error('Carrier.delivery_fee') is-invalid @enderror"
-                                   name="Carrier[delivery_fee]" autocomplete="off" value="{{ old('Carrier')['delivery_fee'] }}" >
-                            @error('Carrier.delivery_fee')
-                            <span class="invalid-feedback" role="alert">
-                                <strong>{{ $errors->first('Carrier.delivery_fee') }}</strong>
-                            </span>
-                            @enderror
-                        </div>
-                    </div>
-                    <div class="form-group row">
-                        <label for="remark" class="col-2 col-form-label text-right">备注</label>
-                        <div class="col-8">
-                            <textarea type="text" class="form-control "
-                                      name="Carrier[remark]" autocomplete="off" >{{ old('Carrier')['remark'] }}</textarea>
-                        </div>
-                    </div>
                     <div class="form-group row">
                         <div class="col-8 offset-2">
                             <input type="submit" class="btn btn-success form-control">

+ 17 - 5
resources/views/maintenance/measuringMachine/edit.blade.php

@@ -17,13 +17,25 @@
                     @csrf
                     @method('PUT')
                     <div class="form-group row">
-                        <label for="name" class="col-2 col-form-label text-right">省份名称</label>
+                        <label for="name" class="col-2 col-form-label text-right">设备名称</label>
                         <div class="col-8">
-                            <input type="text" class="form-control @error('Province.name') is-invalid @enderror"
-                                   name="Province[name]" autocomplete="off" value="{{old('Province')['name']?old('Province')['name']:$province->name}}" required>
-                            @error('Province.name')
+                            <input type="text" class="form-control @error('name') is-invalid @enderror"
+                                   name="name" autocomplete="off" value="{{ old('name')?old('name'):$measuringMachine->name}}" >
+                            @error('name')
                             <span class="invalid-feedback" role="alert">
-                                <strong>{{ $errors->first('Province.name') }}</strong>
+                                <strong>{{ $errors->first('name') }}</strong>
+                            </span>
+                            @enderror
+                        </div>
+                    </div>
+                    <div class="form-group row">
+                        <label for="code" class="col-2 col-form-label text-right">设备代码(ID)</label>
+                        <div class="col-8">
+                            <input type="text" class="form-control @error('code') is-invalid @enderror"
+                                   name="code" autocomplete="off" value="{{ old('code')?old('code'):$measuringMachine->code }}" >
+                            @error('code')
+                            <span class="invalid-feedback" role="alert">
+                                <strong>{{ $errors->first('code') }}</strong>
                             </span>
                             @enderror
                         </div>

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

@@ -176,7 +176,6 @@
                             <p class="form-control-static text-danger small font-weight-bold" style="margin-left: 50%">{{ $errors->first('warehouse_weight_unit_id') }}</p>
                             <p class="form-control-static text-danger small font-weight-bold" style="margin-left: 50%">{{ $errors->first('warehouse_weight_unit_id_other') }}</p>
                     </div>--}}
-                    @endif
                     {{--计费模型阶段保留--}}
                     <div class="form-group row">
                         <label for="carrier_weight" class="col-2 col-form-label text-right ">承运商计数(抛)</label>
@@ -219,6 +218,7 @@
                         </div>
 
                     </div>
+                    @endif
 {{--                    <div class="form-group row">
                         <div class="col-sm-5">
                             <p class="form-control-static text-danger small font-weight-bold" style="margin-left: 50%">{{ $errors->first('carrier_weight_unit_id') }}</p>