Przeglądaj źródła

station monitor页面

LD 5 lat temu
rodzic
commit
a8f069b8c5

+ 8 - 8
app/Http/Controllers/StationController.php

@@ -10,7 +10,7 @@ class StationController extends Controller
     /**
      * Display a listing of the resource.
      *
-     * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Http\Response|\Illuminate\View\View
+     * @return void
      */
     public function index()
     {
@@ -18,7 +18,9 @@ class StationController extends Controller
     }
     public function monitorIndex()
     {
-        $stations = Station::query()->paginate(100);
+        $stations = Station::query()->with('type:name','parent:name')->whereHas('type',function($query){
+            $query->where('name','料箱监视器');
+        })->paginate(100);
         return view('station.monitor.index',compact('stations'));
     }
 
@@ -43,16 +45,14 @@ class StationController extends Controller
         //
     }
 
-    /**
-     * Display the specified resource.
-     *
-     * @param  \App\Station  $station
-     * @return \Illuminate\Http\Response
-     */
     public function show(Station $station)
     {
         //
     }
+    public function monitorShow(Station $station)
+    {
+        return view('station.monitor.show',compact('station'));
+    }
 
     /**
      * Show the form for editing the specified resource.

+ 3 - 3
app/Station.php

@@ -8,10 +8,10 @@ class Station extends Model
 {
     protected $fillable=['name', 'code', 'station_type_id','sequence','parent_id'];
 
-    function type(){
-        return $this->belongsTo(StationType::class);
+    public function type(){
+        return $this->belongsTo(StationType::class,'station_type_id');
     }
-    function parent(){
+    public function parent(){
         return $this->belongsTo(Station::class,'parent_id','id');
     }
 }

+ 7 - 9
resources/views/station/monitor/index.blade.php

@@ -24,17 +24,15 @@
                     </tr>
                     <tr v-for="station in stations">
                         <td class="text-muted">@{{station.id}}</td>
-                        <td>@{{station.name}}</td>
-                        <td>@{{station.parent.name}}</td>
+                        <td>
+                            <a :href="'{{url('station/monitor/')}}'+'/'+station.id" target="_blank">
+                                <button class="btn btn-outline-info" >@{{station.name}}</button>
+                            </a>
+                        </td>
+                        <td>@{{station.parent?station.parent.name:''}}</td>
                         <td>@{{station.code}}</td>
                         <td>@{{station.remark}}</td>
                         <td class="text-muted">@{{station.created_at}}</td>
-                        <td>
-                            @can('承运商-编辑')
-                                <button class="btn btn-sm btn-outline-primary" @click="edit(carrier.id)">改</button> @endcan
-                            @can('承运商-删除')
-                                <button class="btn btn-sm btn-outline-dark" @click="destroy(carrier)">删</button> @endcan
-                        </td>
                     </tr>
                 </table>
                 {{$stations->links()}}
@@ -48,7 +46,7 @@
         new Vue({
             el:"#list",
             data:{
-                stations:{!! $stations??'' !!},
+                stations:{!! json_encode($stations->toArray()['data'])??'""' !!},
             },
         });
     </script>

+ 21 - 0
resources/views/station/monitor/show.blade.php

@@ -0,0 +1,21 @@
+@extends('layouts.app')
+@section('title'){{$station->name}} - 监视器 - 站@endsection
+
+@section('content')
+    <div id="nav2">
+        @component('maintenance.menu')
+        @endcomponent
+        @component('maintenance.carrier.menu')
+                <li class="nav-item">
+                    <a class="nav-link" href="{{URL::current()}}" :class="{active:isActive('{{$station->id}}',3)}">显示:{{$station->name}}</a>
+                </li>
+        @endcomponent
+    </div>
+    <div class="container-fluid">
+        <div class="card">
+            <div class="card-body">
+
+            </div>
+        </div>
+    </div>
+@endsection

+ 1 - 0
routes/web.php

@@ -596,6 +596,7 @@ Route::group(['prefix'=>'station'],function(){
     Route::group(['prefix'=>'monitor'],function(){
         Route::get('/','StationController@monitorIndex');
         Route::get('/index','StationController@monitorIndex');
+        Route::get('/{id}','StationController@monitorShow');
     });
 });
 /** 控制台 */