show.blade.php 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  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. <div>波次号:</div>
  25. <div class=" text-center">
  26. <b v-if="task&&task.station_task_batches">
  27. <div v-for="taskBatch in task.station_task_batches">
  28. @{{ taskBatch.batch.code }}
  29. </div>
  30. </b>
  31. </div>
  32. </div>
  33. </div>
  34. <div class="row">
  35. <div class="col py-3 text-muted text-center">
  36. <img id="barcode" alt="">
  37. </div>
  38. </div>
  39. <div class="row">
  40. <div class="col py-3 h4">
  41. 料箱号:
  42. <div v-if="task&&task.station_task_material_boxes">
  43. <div v-for="taskMaterialBox in task.station_task_material_boxes">
  44. <span v-if="taskMaterialBox.status==='处理中'">
  45. @{{taskMaterialBox.material_box.code}}
  46. </span>
  47. </div>
  48. </div>
  49. </div>
  50. </div>
  51. <div class="row pt-2">
  52. <div class="col">
  53. {{-- @include("station.monitor._svg")--}}
  54. <img src="{{asset('images/demoBin.png')}}" alt="" class="img">
  55. </div>
  56. </div>
  57. </div>
  58. <div class="col text-center">
  59. <div class="d-flex flex-row justify-content-around" v-if="station&&station.station_type_bin_monitor">
  60. <div class="border h4 d-flex flex-column-reverse flex-grow-1 m-1" v-for="(wIndex) in station.station_type_bin_monitor.bin_wall_amount">
  61. <div class="d-flex flex-row" v-for="(rIndex) in station.station_type_bin_monitor.bin_row_length">
  62. <div class="border p-1 flex-grow-1" v-for="(cIndex) in station.station_type_bin_monitor.bin_column_length">
  63. <span class="d-inline-block" style="width: 36px;">
  64. @{{ wIndex*rIndex*cIndex|iteratedIndex }}
  65. <span v-if="taskCommoditiesListByBin">
  66. <span v-for="taskCommodity in taskCommoditiesListByBin[5]">
  67. @{{ taskCommodity['commodity']['name'] }}
  68. </span>
  69. </span>
  70. </span>
  71. </div>
  72. </div>
  73. </div>
  74. </div>
  75. <div class="row mb-1">
  76. <div class="col-1 text-left font-weight-bold">数量:</div>
  77. <div class="col-2 text-left">@{{ processedCommodities }}/@{{ totalCommodities }}</div>
  78. <div class="col-1 offset-2 text-muted" v-if="error">异常:</div>
  79. <div class="col-6" v-if="error">@{{ error }}</div>
  80. </div>
  81. <div class="row">
  82. <div class="col py-1">
  83. <table class="table table-hover border" v-if="task&& task.taskCommodities">
  84. <tr class="text-muted">
  85. <th class="py-2">序号</th>
  86. <th class="py-2">商品</th>
  87. <th class="py-2">数量</th>
  88. <th class="py-2">条码</th>
  89. </tr>
  90. <tr class="text-muted" v-for="(taskCommodity,i) in task.taskCommodities" :class="taskCommodity.status| commodityBgClass">
  91. <td>@{{ i+1 }}</td>
  92. <td>@{{ taskCommodity.name }}</td>
  93. <td>@{{ taskCommodity.amount }}</td>
  94. <td><small class="text-dark font-weight-bold" v-for="barcode in taskCommodity.barcodes">@{{ barcode.code }}</small><br></td>
  95. </tr>
  96. </table>
  97. </div>
  98. </div>
  99. </div>
  100. </div>
  101. </div>
  102. </div>
  103. </div>
  104. @endsection
  105. @section('lastScript')
  106. <script type="text/javascript" src="{{mix('js/utilities/barcode.js')}}"></script>
  107. <script>
  108. $vue=new Vue({
  109. el:"#container",
  110. data:{
  111. {{--broadcastName : "{{config('database.redis.options.prefix').'presence-station-'.$station->id}}",--}}
  112. broadcastName : "{{config('database.redis.options.prefix').'station-'.$station->id}}",
  113. channelName : ".App\\Events\\BroadcastToStation",
  114. // task : {
  115. // currentCommodityIndex : -1,
  116. // taskCommodities:[
  117. // /*{amount:"",binNumber:"",name:"",barcodes:[]},*/
  118. // ],
  119. // taskBatch:{
  120. // batch:{
  121. // code:"",
  122. // },
  123. // },
  124. // box:{},
  125. // sum : 0,
  126. // currentSum : 0,
  127. // },
  128. // boxes:[],
  129. {{--stationTypeBinMonitors:[],--}}
  130. {{--stationTypeBinMonitor:{--}}
  131. {{-- row:Number("{{$stationTypeBinMonitor->bin_row_length}}"),--}}
  132. {{-- column:Number("{{$stationTypeBinMonitor->bin_column_length}}"),--}}
  133. {{-- amount:Number("{{$stationTypeBinMonitor->bin_wall_amount}}"),--}}
  134. {{--},--}}
  135. // color:"red",
  136. error:"",
  137. station:{!! $station??[] !!},
  138. {{--stationTypeBinMonitor:{!! $stationTypeBinMonitor !!},--}}
  139. },
  140. mounted() {
  141. this._makeMenuHiding();
  142. this._listenBroadcast();
  143. // this._renderingstationTypeBinMonitor(this.stationTypeBinMonitor.amount,this.stationTypeBinMonitor.row,this.stationTypeBinMonitor.column);
  144. },
  145. methods:{
  146. _makeMenuHiding(){
  147. $('.navbar,.nav1,.nav2').hide();
  148. $('.nav3').on('mouseenter', function () {
  149. $('.navbar,.nav1,.nav2').show();
  150. });
  151. $('.body').on('mouseenter', function () {
  152. $('.navbar,.nav1,.nav2').hide();
  153. });
  154. },
  155. _listenBroadcast(){
  156. initEcho();
  157. window.Echo.channel(this.broadcastName).listen(this.channelName,(msg)=> {
  158. console.log(1231,msg)
  159. let json = JSON.parse(msg.json);
  160. console.log(json)
  161. this._refreshData(json);
  162. });
  163. },
  164. //刷新数据
  165. _refreshData(obj){
  166. let task={};
  167. task.taskCommodities = [];
  168. task.sum = 0;
  169. task.currentSum = 0;
  170. task.currentCommodityIndex = "";
  171. obj.station_task_commodities.forEach((taskCommodity,i)=> {
  172. task.sum += Number(taskCommodity.amount);
  173. if (taskCommodity.status === '完成') task.currentSum += Number(taskCommodity.amount);
  174. if (taskCommodity.status === '处理中') task.currentCommodityIndex = i;
  175. task.taskCommodities.push({
  176. bg:this._setColor(taskCommodity.status),
  177. amount:taskCommodity.amount,
  178. binNumber:taskCommodity.bin_number,
  179. name:taskCommodity.commodity?taskCommodity.commodity.name:'',
  180. barcodes:taskCommodity.commodity?taskCommodity.commodity.barcodes:[],
  181. materialBox:taskCommodity.material_box,
  182. });
  183. });
  184. task.taskBatch=obj.station_task_batches[0];
  185. setBarcode(task.taskBatch.batch.code,"#barcode",1,50,false);
  186. console.log(task)
  187. this.task = task;
  188. },
  189. // //渲染墙格口
  190. // _renderingstationTypeBinMonitor(amount, row, column){
  191. // for (let i=0;i<amount;i++){
  192. // this.stationTypeBinMonitors.push(this._createstationTypeBinMonitor(row, column, i*(row*column)));
  193. // }
  194. // },
  195. _setColor(status){
  196. switch (status) {
  197. case "待处理":return "";
  198. case "挂起" :return "bg-white";
  199. case "处理中" :return "bg-primary";
  200. case "完成" :return "bg-success";
  201. case "异常" :return "bg-danger";
  202. case "取消" :return "bg-dark text-white";
  203. }
  204. return "";
  205. },
  206. //生成墙格口
  207. _createstationTypeBinMonitor(row, column, increment){
  208. let stationTypeBinMonitor = [];
  209. for (let i=1;i<=row;i++){
  210. let columns = [];
  211. for (let j=((i-1)*column)+1;j<=i*column;j++){
  212. columns.push(j+increment);
  213. }
  214. stationTypeBinMonitor.unshift(columns);
  215. }
  216. return stationTypeBinMonitor;
  217. },
  218. //渲染料箱格口
  219. _renderingBox(row, column, x=79, y=72, width=21, height=12){
  220. let boxes = [];
  221. for (let i=0;i<column;i++){
  222. for (let j=row-1;j>=0;j--){
  223. if (boxes.length===5) boxes.push({x:((i+j)*width)+x,y:(y+(i*height))-(j*height),sign:true});
  224. else boxes.push({x:((i+j)*width)+x,y:(y+(i*height))-(j*height),sign:false});
  225. }
  226. }
  227. this.boxes = boxes;
  228. },
  229. },
  230. computed:{
  231. task(){
  232. return this.station['current_station_task'];
  233. },
  234. taskCommoditiesListByBin(){
  235. function reIndexByBin() {
  236. this.taskCommoditiesListByBinVar = [];
  237. this.taskCommoditiesListByBinVar.md5 = md5(JSON.stringify(this.station['current_station_task']['station_task_commodities']));
  238. let _this=this;
  239. this.station['current_station_task']['station_task_commodities']
  240. .forEach(function (taskCommodity) {
  241. if (typeof (_this.taskCommoditiesListByBinVar[taskCommodity['bin_number']]) === 'undefined') {
  242. _this.taskCommoditiesListByBinVar[taskCommodity['bin_number']] = [];
  243. }
  244. _this.taskCommoditiesListByBinVar[taskCommodity['bin_number']].push(taskCommodity);
  245. })
  246. return this.taskCommoditiesListByBinVar;
  247. }
  248. if((typeof this.taskCommoditiesListByBinVar)==='undefined'||!this.taskCommoditiesListByBinVar){
  249. return reIndexByBin.call(this);
  250. }
  251. let md5Now = md5(JSON.stringify(this.station['current_station_task']['station_task_commodities']));
  252. if(this.taskCommoditiesListByBinVar.md5!==md5Now){
  253. return reIndexByBin.call(this);
  254. }
  255. return this.taskCommoditiesListByBinVar;
  256. },
  257. processedCommodities(){
  258. return 1;
  259. },
  260. totalCommodities(){
  261. return 2;
  262. },
  263. },
  264. filters:{
  265. commodityBgClass(status){
  266. switch (status){
  267. case '待处理':return "";
  268. case '挂起':return "bg-white";
  269. case '处理队列':return "bg-dark text-white";
  270. case '处理中':return "bg-primary";
  271. case '完成':return "bg-success";
  272. case '异常':return "bg-danger";
  273. case '取消':return "text-muted";
  274. }
  275. return '';
  276. },
  277. iteratedIndex(targetNumber){
  278. if(targetNumber===1||(typeof this.iteratedIndexVar)==='undefined'||!this.iteratedIndexVar){
  279. this.iteratedIndexVar=targetNumber;
  280. }else{
  281. this.iteratedIndexVar++;
  282. }
  283. return this.iteratedIndexVar;
  284. },
  285. binBgClass(targetNumber){
  286. if(targetNumber===1||(typeof this.iteratedIndexVar)==='undefined'||!this.iteratedIndexVar){
  287. this.iteratedIndexVar=targetNumber;
  288. }else{
  289. this.iteratedIndexVar++;
  290. }
  291. return this.iteratedIndexVar;
  292. },
  293. }
  294. });
  295. </script>
  296. @endsection