LD 4 лет назад
Родитель
Сommit
66ed2fbbe1

+ 6 - 5
app/Http/Controllers/StationController.php

@@ -54,12 +54,12 @@ class StationController extends Controller
     }
     public function monitorShow(Station $station)
     {
-        $stationTypeBinMonitor = StationTypeBinMonitor::query()->where("station_id",$station->id)->first();
+//        $stationTypeBinMonitor = StationTypeBinMonitor::query()->where("station_id",$station->id)->first();
         $station->loadMissing([
-            "stationTasks.stationTaskCommodities.commodity.barcodes",
-            "stationTasks.stationTaskCommodities.materialBox",
-            "stationTasks.stationTaskBatches.batch",
-            "stationTasks.stationTaskMaterialBoxes.materialBox",
+            "stationTasks_today.stationTaskCommodities.commodity.barcodes",
+            "stationTasks_today.stationTaskCommodities.materialBox",
+            "stationTasks_today.stationTaskBatches.batch",
+            "stationTasks_today.stationTaskMaterialBoxes.materialBox",
             "stationTypeBinMonitor",
         ]);
         if (!$station['stationTypeBinMonitor']){
@@ -71,6 +71,7 @@ class StationController extends Controller
             ]);
             $station->load("stationTypeBinMonitor");
         }
+        dd(data_get($station['stationTasks_today'],'*.id'),data_get($station['stationTasks_today'],'*.batch_id'));
         return view('station.monitor.show',compact('station'));
     }
 

+ 4 - 1
app/Station.php

@@ -30,7 +30,10 @@ class Station extends Model
     }
     public function stationTasks_today(){
         return $this->hasMany(StationTask::class)
-            ->where('created_at','>=',now()->format('Y-m-d'));
+            ->where('created_at','>=',now()->format('Y-m-d'))
+            ->orderByDesc('status')
+            ->orderBy('id')
+            ;
     }
     public function stationTypeBinMonitor(){
         return $this->hasOne(StationTypeBinMonitor::class);

+ 24 - 11
resources/views/station/monitor/show.blade.php

@@ -28,20 +28,19 @@
                             <div class="col py-3 h4">
                                 <div>波次列表:</div>
                                 <div class="text-center mt-2" style="overflow: scroll;height:200px;">
-                                    <div class="flex flex-column flex-wrap">
-                                        <button v-for="taskBatch in task.station_task_batches"
+                                    <div class="flex flex-column flex-wrap" v-if="stationTaskBatches">
+                                        <button v-for="stationTaskBatch in stationTaskBatches"
+                                                @click="current_stationTaskBatch=stationTaskBatch"
                                                 class="btn btn-outline-dark">
-                                            @{{taskBatch.batch.code | simplifyBatchCode}}</button>
+                                            @{{stationTaskBatch.batch.code | simplifyBatchCode}}</button>
                                     </div>
                                 </div>
                             </div>
                         </div>
                         <div class="row">
-                            <div class=" text-center">
-                                <b v-if="task&&task.station_task_batches">
-                                    <div v-for="taskBatch in task.station_task_batches">
-                                        @{{ taskBatch.batch.code }}
-                                    </div>
+                            <div class=" text-center" v-if="current_stationTaskBatch">
+                                <b class="text-center">
+                                        @{{ current_stationTaskBatch.batch.code }}
                                 </b>
                             </div>
                         </div>
@@ -305,9 +304,7 @@
                         text:'',
                     }
                 },
-                batch_tasks: [
-                    // {code:'',id:'',status:''},
-                ],
+                current_stationTaskBatch: null,
                 grids:{
                     single:{status:'',},
                     half:{
@@ -328,6 +325,7 @@
             mounted() {
                 this._makeMenuHiding();
                 this._listenBroadcast();
+                console.log(this.stationTaskBatches);
             },
             methods:{
                 _makeMenuHiding(){
@@ -369,6 +367,21 @@
                     if(!this.station['current_station_task'])return null;
                     return this.station['current_station_task'];
                 },
+                stationTasks(){
+                    if(!this.station)return;
+                    return this.station.station_tasks_today;
+                },
+                stationTaskBatches(){
+                    if(!this.stationTasks)return;
+                    let stationTaskBatches=[];
+                    this.stationTasks.forEach(function(stationTask){
+                        if(!stationTask.station_task_batches)return;
+                        stationTask.station_task_batches.forEach(function(stationTaskBatch){
+                            stationTaskBatches.push(stationTaskBatch)
+                        })
+                    });
+                    return stationTaskBatches;
+                },
                 batchCode(){
                     if(!this.task)return;
                     let batches = this.task.station_task_batches;