Zhouzhendong 6 жил өмнө
parent
commit
86f4e190f8

+ 84 - 0
app/Http/Controllers/MeasureMonitorController.php

@@ -0,0 +1,84 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use Illuminate\Http\Request;
+
+class MeasureMonitorController extends Controller
+{
+    /**
+     * Display a listing of the resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function index()
+    {
+        return view('weigh.measureMonitor.index');
+    }
+
+    /**
+     * Show the form for creating a new resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function create()
+    {
+        //
+    }
+
+    /**
+     * Store a newly created resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return \Illuminate\Http\Response
+     */
+    public function store(Request $request)
+    {
+        //
+    }
+
+    /**
+     * Display the specified resource.
+     *
+     * @param  int  $id
+     * @return \Illuminate\Http\Response
+     */
+    public function show($id)
+    {
+        //
+    }
+
+    /**
+     * Show the form for editing the specified resource.
+     *
+     * @param  int  $id
+     * @return \Illuminate\Http\Response
+     */
+    public function edit($id)
+    {
+        //
+    }
+
+    /**
+     * Update the specified resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @param  int  $id
+     * @return \Illuminate\Http\Response
+     */
+    public function update(Request $request, $id)
+    {
+        //
+    }
+
+    /**
+     * Remove the specified resource from storage.
+     *
+     * @param  int  $id
+     * @return \Illuminate\Http\Response
+     */
+    public function destroy($id)
+    {
+        //
+    }
+}

+ 86 - 0
app/Http/Controllers/MeasuringMachineController.php

@@ -0,0 +1,86 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use App\MeasuringMachine;
+use Illuminate\Http\Request;
+
+class MeasuringMachineController extends Controller
+{
+    /**
+     * Display a listing of the resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function index()
+    {
+        $measuringMachines=MeasuringMachine::orderBy('id','DESC')->paginate(50);
+        return view('maintenance.measuringMachine.index',['measuringMachines'=>$measuringMachines]);
+    }
+
+    /**
+     * Show the form for creating a new resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function create()
+    {
+        //
+    }
+
+    /**
+     * Store a newly created resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return \Illuminate\Http\Response
+     */
+    public function store(Request $request)
+    {
+        //
+    }
+
+    /**
+     * Display the specified resource.
+     *
+     * @param  \App\MeasuringMachine  $measuringMachine
+     * @return \Illuminate\Http\Response
+     */
+    public function show(MeasuringMachine $measuringMachine)
+    {
+        //
+    }
+
+    /**
+     * Show the form for editing the specified resource.
+     *
+     * @param  \App\MeasuringMachine  $measuringMachine
+     * @return \Illuminate\Http\Response
+     */
+    public function edit(MeasuringMachine $measuringMachine)
+    {
+        //
+    }
+
+    /**
+     * Update the specified resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @param  \App\MeasuringMachine  $measuringMachine
+     * @return \Illuminate\Http\Response
+     */
+    public function update(Request $request, MeasuringMachine $measuringMachine)
+    {
+        //
+    }
+
+    /**
+     * Remove the specified resource from storage.
+     *
+     * @param  \App\MeasuringMachine  $measuringMachine
+     * @return \Illuminate\Http\Response
+     */
+    public function destroy(MeasuringMachine $measuringMachine)
+    {
+        //
+    }
+}

+ 178 - 0
app/Http/Controllers/PaperBoxController.php

@@ -0,0 +1,178 @@
+<?php
+
+namespace App\Http\Controllers;
+
+
+use App\Owner;
+use App\PaperBox;
+use Illuminate\Http\Request;
+use Illuminate\Support\Facades\Auth;
+use Illuminate\Support\Facades\Gate;
+use Illuminate\Support\Facades\Validator;
+
+class PaperBoxController extends Controller
+{
+    /**
+     * Display a listing of the resource.
+     * @param  \Illuminate\Http\Request
+     * @return \Illuminate\Http\Response
+     */
+    public function indexModel()
+    {
+        if(!Gate::allows('纸箱-查询')){ return redirect(url('/'));  }
+        $paperBoxes=PaperBox::with('owners')->orderBy('id','DESC')->paginate(50);
+        return view('maintenance.paperBox.index',['paperBoxes'=>$paperBoxes]);
+
+    }
+    public function indexOwner()
+    {
+        if(!Gate::allows('纸箱-查询')){ return redirect(url('/'));  }
+        $paperBoxes_owner=Owner::with('paperBoxes')->orderBy('id','DESC')->paginate(50);
+        return view('maintenance.paperBox.indexOwner',['paperBoxes_owner'=>$paperBoxes_owner]);
+
+    }
+
+    /**
+     * Show the form for creating a new resource.
+     *
+     * @return
+     */
+    public function create()
+    {
+        if(!Gate::allows('纸箱-录入')){ return redirect(url('/'));  }
+        $owners=Owner::get();
+        return view('maintenance.paperBox.create',['owners'=>$owners]);
+    }
+
+    /**
+     * Store a newly created resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return \Illuminate\Http\Response
+     */
+    public function store(Request $request)
+    {
+        if(!Gate::allows('纸箱-录入')){ return redirect(url('/'));  }
+        $id=false;
+        $this->validator($request,$id)->validate();
+        $length=$request->input('length');
+        $width=$request->input('width');
+        $height=$request->input('height');
+        $max=($length>=($width>=$height?$width:$height)?$length:($width>=$height?$width:$height));
+        if ($max==$length){
+            $centre=$width>=$height?$width:$height;
+            $min=$width<$height?$width:$height;
+        }elseif ($max==$width){
+            $centre=$length>=$height?$length:$height;
+            $min=$length<$height?$length:$height;
+        }else{
+            $centre=$width>=$length?$width:$length;
+            $min=$width<$length?$width:$length;
+        }
+        $paperBox=new PaperBox([
+            'model'=>$request->input('model'),
+            'length'=>$max,
+            'width'=>$centre,
+            'height'=>$min,
+        ]);
+        $paperBox->save();
+        $owner_id=$request->input('owner_id');
+        if ($owner_id){
+            $paperBox->owners()->sync($owner_id);
+        }
+        $this->log(__METHOD__,__FUNCTION__,json_encode($request->toArray()),Auth::user()['id']);
+        return redirect('maintenance/paperBox/index/model')->with('successTip','新纸箱'.$request->input('model').'录入成功');
+    }
+
+
+    /**
+     * Show the form for editing the specified resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function edit($id)
+    {
+        if(!Gate::allows('纸箱-编辑')){ return redirect(url('/'));  }
+        $paperBox=PaperBox::with('owners')->find($id);
+        $owners=Owner::get();
+        return view('maintenance/paperBox/edit',['paperBox'=>$paperBox,'owners'=>$owners]);
+    }
+
+    /**
+     * Update the specified resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return \Illuminate\Http\Response
+     */
+    public function update(Request $request,$id)
+    {
+        if(!Gate::allows('纸箱-编辑')){ return redirect(url('/'));  }
+        $this->validator($request,$id)->validate();
+        $length=$request->input('length');
+        $width=$request->input('width');
+        $height=$request->input('height');
+        $max=($length>=($width>=$height?$width:$height)?$length:($width>=$height?$width:$height));
+        if ($max==$length){
+            $centre=$width>=$height?$width:$height;
+            $min=$width<$height?$width:$height;
+        }elseif ($max==$width){
+            $centre=$length>=$height?$length:$height;
+            $min=$length<$height?$length:$height;
+        }else{
+            $centre=$width>=$length?$width:$length;
+            $min=$width<$length?$width:$length;
+        }
+        $paperBox=PaperBox::find($id);
+        $paperBox->model=$request->input('model');
+        $paperBox->length=$max;
+        $paperBox->width=$centre;
+        $paperBox->height=$min;
+        $paperBox->save();
+        $owner_id=$request->input('owner_id');
+        if ($owner_id){
+            $paperBox->owners()->sync($owner_id);
+        }
+        $this->log(__METHOD__,__FUNCTION__,json_encode($request->toArray()),Auth::user()['id']);
+        return redirect('maintenance/paperBox/index/model')->with('successTip','纸箱'.$request->input('model').'信息更新成功');
+    }
+
+    /**
+     * Remove the specified resource from storage.
+     *
+     */
+    public function destroy($id)
+    {
+        if(!Gate::allows('纸箱-删除')){ return redirect(url('/'));  }
+        $paperBox=PaperBox::find($id);
+        $this->log(__METHOD__,__FUNCTION__,json_encode($paperBox),Auth::user()['id']);
+        if ($paperBox->delete()){
+            $paperBox->owners()->detach();
+            $this->log(__METHOD__,__FUNCTION__,json_encode($paperBox),Auth::user()['id']);
+            return ['success'=>true];
+        }else{
+            return ['success'=>false];
+        }
+    }
+
+    public function validator(Request $request,$id){
+        if ($id){$model=$id;}
+        $validator=Validator::make($request->input(),[
+            'model'=>['max:50','required',isset($model)?"unique:paper_boxes,model,$model":'unique:paper_boxes,model'],
+            'length'=>'required|min:0|numeric|max:999999',
+            'width'=>'required|min:0|numeric|max:999999',
+            'height'=>'required|min:0|numeric|max:999999',
+        ],[
+            'required'=>':attribute 不应为空',
+            'min'=>':attribute 不得为0或为负',
+            'numeric'=>':attribute 必须为数字',
+            'unique'=>':attribute 已存在',
+            'max'=>':attribute 输入值过大',
+        ],[
+            'model'=>'型号',
+            'length'=>'长(cm)',
+            'width'=>'宽(cm)',
+            'height'=>'高(cm)',
+        ]);
+        return $validator;
+    }
+}

+ 12 - 0
app/MeasuringMachine.php

@@ -0,0 +1,12 @@
+<?php
+
+namespace App;
+
+use Illuminate\Database\Eloquent\Model;
+
+class MeasuringMachine extends Model
+{
+    protected $fillable=[
+        'name','code','status',
+    ];
+}

+ 12 - 0
database/factories/MeasuringMachineFactory.php

@@ -0,0 +1,12 @@
+<?php
+
+/** @var \Illuminate\Database\Eloquent\Factory $factory */
+
+use App\MeasuringMachine;
+use Faker\Generator as Faker;
+
+$factory->define(MeasuringMachine::class, function (Faker $faker) {
+    return [
+        //
+    ];
+});

+ 12 - 0
database/factories/PaperBoxFactory.php

@@ -0,0 +1,12 @@
+<?php
+
+/** @var \Illuminate\Database\Eloquent\Factory $factory */
+
+use App\PaperBox;
+use Faker\Generator as Faker;
+
+$factory->define(PaperBox::class, function (Faker $faker) {
+    return [
+        //
+    ];
+});

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

@@ -0,0 +1,65 @@
+@extends('layouts.app')
+
+@section('content')
+    <div id="nav2">
+        @component('maintenance.menu')@endcomponent
+        @component('maintenance.measuringMachine.menu')@endcomponent
+    </div>
+    <div class="container mt-3">
+        <div class="card col-md-8 offset-md-2">
+            <div class="card-body">
+                <form method="POST" action="{{ url('maintenance/measuringMachine') }}">
+                    @csrf
+                    <div class="form-group row">
+                        <label for="name" class="col-2 col-form-label text-right">设备名称</label>
+                        <div class="col-8">
+                            <input type="text" class="form-control @error('name') is-invalid @enderror"
+                                   name="name" autocomplete="off" value="{{ old('name') }}" >
+                            @error('name')
+                            <span class="invalid-feedback" role="alert">
+                                <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') }}" >
+                            @error('code')
+                            <span class="invalid-feedback" role="alert">
+                                <strong>{{ $errors->first('code') }}</strong>
+                            </span>
+                            @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">
+                        </div>
+                    </div>
+                </form>
+            </div>
+        </div>
+    </div>
+@endsection

+ 40 - 0
resources/views/maintenance/measuringMachine/edit.blade.php

@@ -0,0 +1,40 @@
+@extends('layouts.app')
+
+@section('content')
+    <div id="nav2">
+        @component('maintenance.menu')
+        @endcomponent
+        @component('maintenance.province.menu')
+                <li class="nav-item">
+                    <a class="nav-link" href="{{URL::current()}}" :class="{active:isActive('edit',4)}">修改</a>
+                </li>
+        @endcomponent
+    </div>
+    <div class="container mt-3">
+        <div class="card">
+            <div class="card-body">
+                <form method="POST" action='{{url("maintenance/province/{$province->id}")}}'>
+                    @csrf
+                    @method('PUT')
+                    <div class="form-group row">
+                        <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')
+                            <span class="invalid-feedback" role="alert">
+                                <strong>{{ $errors->first('Province.name') }}</strong>
+                            </span>
+                            @enderror
+                        </div>
+                    </div>
+                    <div class="form-group row">
+                        <div class="col-8 offset-2">
+                            <input type="submit" class="btn btn-outline-dark form-control">
+                        </div>
+                    </div>
+                </form>
+            </div>
+        </div>
+    </div>
+@endsection

+ 85 - 0
resources/views/maintenance/measuringMachine/index.blade.php

@@ -0,0 +1,85 @@
+@extends('layouts.app')
+
+@section('content')
+    <span id="nav2">
+        @component('maintenance.menu')@endcomponent
+        @component('maintenance.measuringMachine.menu')@endcomponent
+    </span>
+    <div class="container mt-3" id="list">
+        <div class="card">
+            <div class="card-body">
+                @if(Session::has('successTip'))
+                    <div class="alert alert-success h1">{{Session::get('successTip')}}</div>
+                @endif
+                <table class="table table-striped table-sm" id="list">
+                    <tr>
+                        <th>ID</th>
+                        <th>设备名</th>
+                        <th>设备代号</th>
+                        <th>运行状态</th>
+                        <th>操作</th>
+                    </tr>
+                    <tr v-for="measuringMachine in measuringMachines">
+                        <td class="text-muted">@{{measuringMachine.id}}</td>
+                        <td>@{{measuringMachine.name}}</td>
+                        <td class="text-muted">@{{measuringMachine.code}}</td>
+                        <td class="text-muted">@{{measuringMachine.status}}</td>
+                        <td>
+                            @can('测量设备-编辑')
+                                <button class="btn btn-sm btn-outline-primary" @click="edit(measuringMachine.id)">改</button> @endcan
+                            @can('测量设备-删除')
+                                <button class="btn btn-sm btn-outline-dark" @click="destroy(measuringMachine)">删</button> @endcan
+                        </td>
+                    </tr>
+                </table>
+                    {{$measuringMachines->links()}}
+            </div>
+        </div>
+    </div>
+@endsection
+
+@section('lastScript')
+    <script>
+        new Vue({
+            el:"#list",
+            data:{
+                measuringMachines:[
+                    @foreach($measuringMachines as $measuringMachine)
+                    {id:'{{$measuringMachine->id}}',name:'{{$measuringMachine->name}}',code:'{{$measuringMachine->code}}',status:'{{$measuringMachine->status}}'},
+                    @endforeach
+                ],
+            },
+            methods:{
+                edit:function(id){
+                    location.href = "{{url('maintenance/measuringMachine')}}/"+id+"/edit";
+                },
+                destroy:function(measuringMachine){
+                    if(!confirm('确定要删除设备“' + measuringMachine.name + '”吗?')){return};
+                    let data=this;
+                    let url = "{{url('maintenance/measuringMachine')}}/"+measuringMachine.id;
+                    axios.delete(url,{id:measuringMachine.id})
+                        .then(function (response) {
+                            if(response.data.success){
+                                for (let i = 0; i < data.measuringMachines.length; i++) {
+                                    if (data.measuringMachines[i].id===measuringMachine.id){
+                                        data.measuringMachines.splice(i,1);
+                                        break;
+                                    }
+                                }
+                                tempTip.setDuration(1000);
+                                tempTip.showSuccess('删除单位"'+measuringMachine.name+'"成功!')
+                            }else{
+                                tempTip.setDuration(1000);
+                                tempTip.show('删除单位"'+measuringMachine.name+'"失败!')
+                            }
+                        })
+                        .catch(function (err) {
+                            tempTip.setDuration(3000);
+                            tempTip.show('删除车辆失败!'+'网络错误:' + err);
+                            console.log(err);
+                        });
+                },
+            }
+        });
+    </script>
+@endsection

+ 16 - 0
resources/views/maintenance/measuringMachine/menu.blade.php

@@ -0,0 +1,16 @@
+
+<div class="container">
+    <div class="card" style="background: #f9f0f0;transform: scale(0.95)">
+        <ul class="nav nav-pills">
+            @can('测量设备-查询')
+            <li class="nav-item">
+                <a class="nav-link" href="{{url('maintenance/measuringMachine')}}" :class="{active:isActive('',3)}">查询</a>
+            </li> @endcan
+            @can('测量设备-录入')
+            <li class="nav-item">
+                <a class="nav-link" href="{{url('maintenance/measuringMachine/create')}}" :class="{active:isActive('create',3)}">录入</a>
+            </li> @endcan
+            {{$slot}}
+        </ul>
+    </div>
+</div>

+ 6 - 0
resources/views/weigh/index.blade.php

@@ -0,0 +1,6 @@
+@extends('layouts.app')
+
+@section('content')
+    @component('weigh.menu')@endcomponent
+@endsection
+

+ 63 - 0
resources/views/weigh/measureMonitor/index.blade.php

@@ -0,0 +1,63 @@
+@extends('layouts.app')
+
+@section('content')
+    @component('weigh.menu')@endcomponent
+    <div class="page-holder w-100 d-flex flex-wrap" id="list">
+        <div class="container-fluid px-xl-5">
+            <section class="py-5">
+                <div class="row" v-for="tests in test">
+                    <div class="col-lg-12 mb-4">
+                        <div class="card">
+                            <div class="card-header">
+                                <h6 class="text-uppercase mb-0"></h6>
+                            </div>
+                            <div class="card-body">
+                                <table class="table card-text">
+                                    <thead>
+                                    <tr>
+                                        <th>#</th>
+                                        <th>First Name</th>
+                                        <th>Last Name</th>
+                                        <th>Username</th>
+                                    </tr>
+                                    </thead>
+                                    <tbody>
+                                    <tr>
+                                        <th scope="row">1</th>
+                                        <td>Mark</td>
+                                        <td>Otto</td>
+                                        <td>@mdo</td>
+                                    </tr>
+                                    <tr>
+                                        <th scope="row">2</th>
+                                        <td>Jacob</td>
+                                        <td>Thornton</td>
+                                        <td>@fat</td>
+                                    </tr>
+                                    <tr>
+                                        <th scope="row">3</th>
+                                        <td>Larry</td>
+                                        <td>the Bird</td>
+                                        <td>@twitter</td>
+                                    </tr>
+                                    </tbody>
+                                </table>
+                            </div>
+                        </div>
+                    </div>
+                </div>
+            </section>
+        </div>
+    </div>
+@endsection
+
+@section('lastScript')
+    <script>
+        let vue=new Vue({
+            el:'#list',
+            data:{
+                test:[{a:'1'},{a:'1'},{a:'1'},{a:'1'}],
+            },
+        });
+    </script>
+@endsection

+ 20 - 0
resources/views/weigh/menu.blade.php

@@ -0,0 +1,20 @@
+
+<div class="container mt-3" id="nav2">
+    <div class="card">
+        <ul class="nav nav-pills">
+            @can('测量机监视界面-查询')
+                <li class="nav-item">
+                    <a class="nav-link" href="{{url('weigh/measureMonitor')}}" :class="{active:isActive('measureMonitor',2)}">测量机监视界面</a>
+                </li> @endcan
+            @can('测量记录管理-查询')
+                <li class="nav-item">
+                    <a class="nav-link" href="{{url('waybill/index')}}" :class="{active:isActive('index',2)}">测量记录管理</a>
+                </li>
+                <li class="nav-item">
+                    <a class="nav-link text-dark" href="{{url('weigh/relating')}}" :class="{active:isActive('relating',2)}">相关设置</a>
+                </li>
+                @endcan
+
+        </ul>
+    </div>
+</div>

+ 18 - 0
resources/views/weigh/menuWeigh.blade.php

@@ -0,0 +1,18 @@
+@extends('layouts.app')
+
+@section('content')
+    <div id="nav2">
+        @component('weigh.menu')
+        @endcomponent
+        <div class="container">
+            <div class="card menu-third" style="background: #f9f0f0;transform: scale(0.95)">
+                <ul class="nav nav-pills">
+                    @can('测量设备')
+                        <li class="nav-item">
+                            <a class="nav-link text-dark" href="{{url('maintenance/measuringMachine')}}" :class="{active:isActive('waybillPriceModel',2)}">测量设备</a>
+                        </li> @endcan
+                </ul>
+            </div>
+        </div>
+    </div>
+@endsection