show.blade.php 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. @extends('layouts.app')
  2. @section('title'){{$station->name}} - 监视器 - 站@endsection
  3. @section('content')
  4. <div id="nav2">
  5. @component('station.menu')
  6. @endcomponent
  7. @component('station.monitor.menu')
  8. <li class="nav-item">
  9. <a class="nav-link" href="{{URL::current()}}" :class="{active:isActive('{{$station->id}}',3)}">显示:{{$station->name}}</a>
  10. </li>
  11. @endcomponent
  12. </div>
  13. <div class="container-fluid body" id="container">
  14. <div class="card">
  15. <div class="card-body">
  16. <div class="row border" style="opacity: 0.75">
  17. <div class="col-4 text-center h3 py-2 font-weight-bold text-info">宝时云仓</div>
  18. <div class="col text-center h3 py-2 text-muted">智能分拣</div>
  19. </div>
  20. <div class="row pt-3">
  21. <div class="col-4">
  22. <div class="row">
  23. <div class="col py-3 h4">
  24. 波次号:<b>@{{ task.taskBatch.batch.code }}</b>
  25. </div>
  26. <div class="col py-3 h4">
  27. </div>
  28. </div>
  29. <div class="row">
  30. <div class="py-3 text-muted">
  31. <img id="barcode" alt="">
  32. </div>
  33. </div>
  34. <div class="row">
  35. <div class="col py-3 h4">
  36. 料箱号:<b v-if="task.currentCommodityIndex!=-1">@{{task.taskCommodities[task.currentCommodityIndex]['materialBox']['code']}}</b>
  37. </div>
  38. </div>
  39. <div class="row pt-2">
  40. <div class="col">
  41. {{-- @include("station.monitor._svg")--}}
  42. <img src="{{asset('images/demoBin.png')}}" alt="" class="img">
  43. </div>
  44. </div>
  45. </div>
  46. <div class="col text-center">
  47. <div class="row">
  48. <div class="col py-3 h4" v-for="wall in walls">
  49. <table class="table border">
  50. <tr v-for="row in wall">
  51. <td class="border p-0" v-for="column in row"
  52. :class="task.currentCommodityIndex!=-1&&task.taskCommodities[task.currentCommodityIndex]['binNumber']==column ? 'bg-info' : ''">
  53. <span style="opacity:0.25">@{{ column }}</span></td>
  54. </tr>
  55. </table>
  56. </div>
  57. </div>
  58. <div class="row mb-1">
  59. <div class="col-1 text-left font-weight-bold">数量:</div>
  60. <div class="col-2 text-left">@{{ task.sum }}/@{{ task.currentSum }}</div>
  61. <div class="col-1 offset-2 text-muted" v-if="error">异常:</div>
  62. <div class="col-6" v-if="error">@{{ error }}</div>
  63. </div>
  64. <div class="row">
  65. <div class="col py-1">
  66. <table class="table table-hover border">
  67. <tr class="text-muted">
  68. <th class="py-2">序号</th>
  69. <th class="py-2">商品</th>
  70. <th class="py-2">数量</th>
  71. <th class="py-2">条码</th>
  72. </tr>
  73. <tr class="text-muted" v-for="(taskCommodity,i) in task.taskCommodities" :class="taskCommodity.bg">
  74. <td>@{{ i+1 }}</td>
  75. <td>@{{ taskCommodity.name }}</td>
  76. <td>@{{ taskCommodity.amount }}</td>
  77. <td><small v-for="barcode in taskCommodity.barcodes">@{{ barcode.code }}</small><br></td>
  78. </tr>
  79. </table>
  80. </div>
  81. </div>
  82. </div>
  83. </div>
  84. </div>
  85. </div>
  86. </div>
  87. @endsection
  88. @section('lastScript')
  89. <script type="text/javascript" src="{{mix('js/utilities/barcode.js')}}"></script>
  90. <script>
  91. new Vue({
  92. el:"#container",
  93. data:{
  94. broadcastName : "{{config('database.redis.options.prefix').'presence-station-'.$station->id}}",
  95. channelName : ".App\\Events\\BroadcastToStation",
  96. task : {
  97. currentCommodityIndex : -1,
  98. taskCommodities:[
  99. /*{amount:"",binNumber:"",name:"",barcodes:[]},*/
  100. ],
  101. taskBatch:{
  102. batch:{
  103. code:"",
  104. },
  105. },
  106. box:{},
  107. sum : 0,
  108. currentSum : 0,
  109. },
  110. boxes:[],
  111. walls:[],
  112. wall:{
  113. row:Number("{{$wall->bin_row_length}}"),
  114. column:Number("{{$wall->bin_column_length}}"),
  115. amount:Number("{{$wall->bin_wall_amount}}"),
  116. },
  117. color:"red",
  118. error:"",
  119. },
  120. mounted() {
  121. $('.navbar,.nav1,.nav2').hide();
  122. $('.nav3').on('mouseenter', function () {
  123. $('.navbar,.nav1,.nav2').show();
  124. });
  125. $('.body').on('mouseenter', function () {
  126. $('.navbar,.nav1,.nav2').hide();
  127. });
  128. this._broadcast();
  129. this._renderingWall(this.wall.amount,this.wall.row,this.wall.column);
  130. /* this._renderingBox(3,5);*/
  131. },
  132. methods:{
  133. _broadcast(){
  134. initEcho();
  135. window.Echo.channel(this.broadcastName).listen(this.channelName,(msg)=> {
  136. let json = JSON.parse(msg.json);
  137. this._refreshData(json);
  138. });
  139. },
  140. //刷新数据
  141. _refreshData(obj){
  142. let task={};
  143. task.taskCommodities = [];
  144. task.sum = 0;
  145. task.currentSum = 0;
  146. task.currentCommodityIndex = "";
  147. obj.task_commodities.forEach((taskCommodity,i)=> {
  148. task.sum += Number(taskCommodity.amount);
  149. if (taskCommodity.status === '完成') task.currentSum += Number(taskCommodity.amount);
  150. if (taskCommodity.status === '处理中') task.currentCommodityIndex = i;
  151. task.taskCommodities.push({
  152. bg:this._setColor(taskCommodity.status),
  153. amount:taskCommodity.amount,
  154. binNumber:taskCommodity.bin_number,
  155. name:taskCommodity.commodity?taskCommodity.commodity.name:'',
  156. barcodes:taskCommodity.commodity?taskCommodity.commodity.barcodes:[],
  157. materialBox:taskCommodity.material_box,
  158. });
  159. });
  160. task.taskBatch=obj.task_batches[0];
  161. setBarcode(task.taskBatch.batch.code,"#barcode",2,50,false);
  162. this.task = task;
  163. },
  164. //渲染墙格口
  165. _renderingWall(amount, row, column){
  166. for (let i=0;i<amount;i++){
  167. this.walls.push(this._createWall(row, column, i*(row*column)));
  168. }
  169. },
  170. _setColor(status){
  171. switch (status) {
  172. case "待处理":return "";
  173. case "挂起" :return "bg-white";
  174. case "处理中" :return "bg-primary";
  175. case "完成" :return "bg-success";
  176. case "异常" :return "bg-danger";
  177. case "取消" :return "bg-dark text-white";
  178. }
  179. return "";
  180. },
  181. //生成墙格口
  182. _createWall(row, column, increment){
  183. let wall = [];
  184. for (let i=1;i<=row;i++){
  185. let columns = [];
  186. for (let j=((i-1)*column)+1;j<=i*column;j++){
  187. columns.push(j+increment);
  188. }
  189. wall.unshift(columns);
  190. }
  191. return wall;
  192. },
  193. //渲染料箱格口
  194. _renderingBox(row, column, x=79, y=72, width=21, height=12){
  195. let boxes = [];
  196. for (let i=0;i<column;i++){
  197. for (let j=row-1;j>=0;j--){
  198. if (boxes.length===5) boxes.push({x:((i+j)*width)+x,y:(y+(i*height))-(j*height),sign:true});
  199. else boxes.push({x:((i+j)*width)+x,y:(y+(i*height))-(j*height),sign:false});
  200. }
  201. }
  202. this.boxes = boxes;
  203. },
  204. },
  205. });
  206. </script>
  207. @endsection