Explorar el Código

站管理-监视器页面

Zhouzhendong hace 5 años
padre
commit
7b269d9b5e

+ 4 - 1
app/Http/Controllers/StationController.php

@@ -3,6 +3,7 @@
 namespace App\Http\Controllers;
 
 use App\Station;
+use App\StationTypeBinMonitor;
 use Illuminate\Database\Eloquent\Builder;
 use Illuminate\Http\Request;
 
@@ -53,7 +54,9 @@ class StationController extends Controller
     }
     public function monitorShow(Station $station)
     {
-        return view('station.monitor.show',compact('station'));
+        $wall = StationTypeBinMonitor::query()->where("station_id",$station->id)->first();
+        if (!$wall)$wall = factory(StationTypeBinMonitor::class)->make(StationTypeBinMonitor::$default);
+        return view('station.monitor.show',compact('station',"wall"));
     }
 
     /**

+ 12 - 0
app/Http/Controllers/TestController.php

@@ -118,14 +118,26 @@ class TestController extends Controller
         $taskCommodity = factory(StationTaskCommodity::class)->create([
             'station_id' => 1,
             'material_box_id' => $materialBox->id,
+            "status"=>"处理中",
             'commodity_id' => $commodity->id,
             'order_id'=>1,
         ]);
+        $taskCommodity2 = factory(StationTaskCommodity::class)->create([
+            'station_id' => 1,
+            'material_box_id' => factory(MaterialBox::class),
+            'commodity_id' => factory(Commodity::class),
+            'order_id'=>1,
+        ]);
         factory(StationTaskChildren::class)->create([
             "station_task_id" => $task->id,
             "station_task_table_type" => "station_task_commodities",
             "station_task_table_id" => $taskCommodity->id,
         ]);
+        factory(StationTaskChildren::class)->create([
+            "station_task_id" => $task->id,
+            "station_task_table_type" => "station_task_commodities",
+            "station_task_table_id" => $taskCommodity2->id,
+        ]);
         $batch = factory(Batch::class)->create();
         $taskBatch = factory(StationTaskBatch::class)->create([
             'batch_id' => $batch->id,

+ 7 - 0
app/StationTypeBinMonitor.php

@@ -7,4 +7,11 @@ use Illuminate\Database\Eloquent\Model;
 class StationTypeBinMonitor extends Model
 {
     protected $fillable=['station_id','bin_row_length','bin_column_length','bin_wall_amount'];
+
+    public static $default=[
+        "station_id"        => null,
+        "bin_row_length"    => 2,
+        "bin_column_length" => 4,
+        "bin_wall_amount"   => 2,
+    ];
 }

+ 1 - 1
database/factories/BatchFactory.php

@@ -7,7 +7,7 @@ use Faker\Generator as Faker;
 
 $factory->define(Batch::class, function (Faker $faker) {
     return [
-        'code' => \Illuminate\Support\Str::random(8).md5(date('Ymd')),
+        'code' => \Illuminate\Support\Str::random(3).md5(date('Ymd')),
         'type' => "无",
         'wms_created_at' => $faker->dateTime,
         "remark" => \Illuminate\Support\Str::random(20),

+ 4 - 1
database/factories/StationTypeBinMonitorFactory.php

@@ -7,6 +7,9 @@ use Faker\Generator as Faker;
 
 $factory->define(StationTypeBinMonitor::class, function (Faker $faker) {
     return [
-        //
+        'station_id' => factory(\App\Station::class),
+        'bin_row_length' => rand(1,20),
+        'bin_column_length' => rand(1,20),
+        'bin_wall_amount' => rand(1,20),
     ];
 });

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

@@ -35,7 +35,7 @@
                         </div>
                         <div class="row">
                             <div class="col py-3 h4">
-                                料箱号:<b>@{{ task.currentCommodityIndex ? task.taskCommodities[task.currentCommodityIndex]['materialBox']['code'] : '' }}</b>
+                                料箱号:<b v-if="task.currentCommodityIndex!=-1">@{{task.taskCommodities[task.currentCommodityIndex]['materialBox']['code']}}</b>
                             </div>
                         </div>
                         <div class="row pt-2">
@@ -50,27 +50,29 @@
                             <div class="col py-3 h4" v-for="wall in walls">
                                 <table class="table border">
                                     <tr v-for="row in wall">
-                                        <td class="border p-0" v-for="column in row" :id="'bin-'+column"><span style="opacity:0.25">@{{ column }}</span></td>
+                                        <td class="border p-0" v-for="column in row"
+                                            :class="task.currentCommodityIndex!=-1&&task.taskCommodities[task.currentCommodityIndex]['binNumber']==column ? 'bg-info' : ''">
+                                            <span style="opacity:0.25">@{{ column }}</span></td>
                                     </tr>
                                 </table>
                             </div>
                         </div>
                         <div class="row mb-1">
                             <div class="col-1 text-left font-weight-bold">数量:</div>
-                            <div class="col-2 text-left">@{{ sum }}/@{{ currentSum }}</div>
+                            <div class="col-2 text-left">@{{ task.sum }}/@{{ task.currentSum }}</div>
                             <div class="col-1 offset-2 text-muted" v-if="error">异常:</div>
                             <div class="col-6" v-if="error">@{{ error }}</div>
                         </div>
                         <div class="row">
                             <div class="col py-1">
-                                <table class="table table-striped border">
+                                <table class="table table-hover border">
                                     <tr class="text-muted">
                                         <th class="py-2">序号</th>
                                         <th class="py-2">商品</th>
                                         <th class="py-2">数量</th>
                                         <th class="py-2">条码</th>
                                     </tr>
-                                    <tr class="text-muted" v-for="(taskCommodity,i) in task.taskCommodities">
+                                    <tr class="text-muted" v-for="(taskCommodity,i) in task.taskCommodities" :class="taskCommodity.bg">
                                         <td>@{{ i+1 }}</td>
                                         <td>@{{ taskCommodity.name }}</td>
                                         <td>@{{ taskCommodity.amount }}</td>
@@ -95,23 +97,27 @@
                 broadcastName : "{{config('database.redis.options.prefix').'presence-station-'.$station->id}}",
                 channelName : ".App\\Events\\BroadcastToStation",
                 task : {
-                    currentCommodityIndex : "",
+                    currentCommodityIndex : -1,
                     taskCommodities:[
-                        {amount:"",binNumber:"",name:"",barcodes:[]},
+                        /*{amount:"",binNumber:"",name:"",barcodes:[]},*/
                     ],
                     taskBatch:{
                         batch:{
                             code:"",
                         },
                     },
-                    wall:{},
                     box:{},
+                    sum : 0,
+                    currentSum : 0,
                 },
                 boxes:[],
                 walls:[],
+                wall:{
+                    row:Number("{{$wall->bin_row_length}}"),
+                    column:Number("{{$wall->bin_column_length}}"),
+                    amount:Number("{{$wall->bin_wall_amount}}"),
+                },
                 color:"red",
-                sum : 0,
-                currentSum : 0,
                 error:"",
             },
             mounted() {
@@ -123,9 +129,8 @@
                     $('.navbar,.nav1,.nav2').hide();
                 });
                 this._broadcast();
-                this._renderingWall(2,2,6);
+                this._renderingWall(this.wall.amount,this.wall.row,this.wall.column);
                 this._renderingBox(2,4);
-                setBarcode("W201209000056","#barcode",2,50,false);
             },
             methods:{
                 _broadcast(){
@@ -135,27 +140,28 @@
                         this._refreshData(json);
                     });
                 },
-                _changeTask(){
-
-                },
-                _replaceTask(){
-
-                },
+                //刷新数据
                 _refreshData(obj){
                     let task={};
                     task.taskCommodities = [];
                     task.sum = 0;
                     task.currentSum = 0;
                     task.currentCommodityIndex = "";
-                    obj.task_commodities.forEach(function (taskCommodity) {
+                    obj.task_commodities.forEach((taskCommodity,i)=> {
+                        task.sum += Number(taskCommodity.amount);
+                        if (taskCommodity.status === '完成') task.currentSum += Number(taskCommodity.amount);
+                        if (taskCommodity.status === '处理中') task.currentCommodityIndex = i;
                         task.taskCommodities.push({
+                            bg:this._setColor(taskCommodity.status),
                             amount:taskCommodity.amount,
-                            binNumber:taskCommodity.binNumber,
+                            binNumber:taskCommodity.bin_number,
                             name:taskCommodity.commodity?taskCommodity.commodity.name:'',
                             barcodes:taskCommodity.commodity?taskCommodity.commodity.barcodes:[],
+                            materialBox:taskCommodity.material_box,
                         });
                     });
-                    task.taskBatch=obj.task_batches.length>0?obj.task_batches[0]:{};
+                    task.taskBatch=obj.task_batches[0];
+                    setBarcode(task.taskBatch.batch.code,"#barcode",2,50,false);
                     this.task = task;
                 },
                 //渲染墙格口
@@ -164,6 +170,17 @@
                         this.walls.push(this._createWall(row, column, i*(row*column)));
                     }
                 },
+                _setColor(status){
+                    switch (status) {
+                        case "待处理":return "";
+                        case "挂起"  :return "bg-white";
+                        case "处理中"  :return "bg-primary";
+                        case "完成"  :return "bg-success";
+                        case "异常"  :return "bg-danger";
+                        case "取消"  :return "bg-dark text-white";
+                    }
+                    return "";
+                },
                 //生成墙格口
                 _createWall(row, column, increment){
                     let wall = [];