show.blade.php 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710
  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 position-relative">
  18. 宝时云仓
  19. </div>
  20. <div class="col text-center h3 py-2 text-muted">
  21. 智能分拣
  22. </div>
  23. </div>
  24. <div class="row pt-3">
  25. <div class="col-4">
  26. <div class="row">
  27. <div class="col py-3 h4">
  28. <div class="row">
  29. <div class="col">选择执行波次:</div>
  30. </div>
  31. <div class="row" v-if="current_stationTaskBatch">
  32. <div class="col font-weight-bold text-center position-relative"
  33. :style="[
  34. {opacity:
  35. current_stationTaskBatch.status==='完成'?'0.5':'1'
  36. },
  37. ]"
  38. :class="[
  39. (current_stationTaskBatch.runningStatus==='')?'text-info':'',
  40. (current_stationTaskBatch.runningStatus==='请求中')?'text-dark':'',
  41. (current_stationTaskBatch.runningStatus==='请求失败')?'text-danger':'',
  42. (current_stationTaskBatch.runningStatus==='请求成功')?'text-success':'',
  43. (current_stationTaskBatch.runningStatus==='请求异常')?'text-danger':'',
  44. ]"
  45. >
  46. <div class="text-center mt-2">@{{ current_stationTaskBatch.batch.code }}</div>
  47. <div class="text-center" style="font-size: 12px;">
  48. @{{ current_stationTaskBatch.batch.owner.name }}
  49. </div>
  50. <div class="col text-muted text-left">
  51. <img id="barcode" :alt="batchCode">
  52. </div>
  53. </div>
  54. <div class="col text-center">
  55. <button class="btn btn-lg mt-4" @click="runTheTaskBatch()"
  56. :class="[
  57. (current_stationTaskBatch.runningStatus==='')?'btn-info':'',
  58. (current_stationTaskBatch.runningStatus==='请求中')?'btn-dark':'',
  59. (current_stationTaskBatch.runningStatus==='请求失败')?'btn-danger':'',
  60. (current_stationTaskBatch.runningStatus==='请求成功')?'btn-success':'',
  61. (current_stationTaskBatch.runningStatus==='请求异常')?'btn-danger':'',
  62. ]"
  63. >
  64. <span v-if="!current_stationTaskBatch.runningStatus">执行</span>
  65. <span v-if="current_stationTaskBatch.runningStatus==='请求中'">请求中</span>
  66. <span v-if="current_stationTaskBatch.runningStatus==='请求失败'">(失败)重新执行</span>
  67. <span v-if="current_stationTaskBatch.runningStatus==='请求成功'">(请求成功)重新执行</span>
  68. <span v-if="current_stationTaskBatch.runningStatus==='请求异常'">(请求异常)重新执行</span>
  69. </button>
  70. </div>
  71. </div>
  72. <div class="text-center my-2" style="overflow-y: scroll;max-height:200px;">
  73. <div class="flex flex-column flex-wrap" v-if="stationTaskBatches">
  74. <button v-for="stationTaskBatch in stationTaskBatches"
  75. @click="selectBatch(stationTaskBatch)"
  76. class="btn"
  77. :class="[
  78. (current_stationTaskBatch&&current_stationTaskBatch.id===stationTaskBatch.id)?'btn-outline-info':'btn-outline-dark',
  79. ]"
  80. :style="[
  81. {opacity:
  82. stationTaskBatch.status==='完成'?'0.5':'1'
  83. },
  84. ]"
  85. >
  86. @{{stationTaskBatch.batch.code | simplifyBatchCode}}</button>
  87. </div>
  88. </div>
  89. </div>
  90. </div>
  91. <div class="row">
  92. <div class="col py-3 h4">
  93. 料箱号:
  94. <div v-if="task&&processingTaskMaterialBox">
  95. @{{processingTaskMaterialBox.material_box.code}}
  96. </div>
  97. </div>
  98. </div>
  99. <div class="row pt-2">
  100. <div class="col text-center">
  101. <svg class="box-display" width="300" height="160" viewBox="0 0 300 160">
  102. <rect x="0" y="80" width="300" height="80"
  103. style="fill:#ffffff;stroke-width:3;stroke:rgb(11,51,71)"/>
  104. <polygon points="0,80 50,0 250,0 300,80"
  105. style="fill:#ffffff;stroke:rgb(11,51,71);stroke-width:3;" />
  106. <polygon v-if="grids.single.status"
  107. class="spot single" points="0,80 50,0 250,0 300,80"
  108. :class="[
  109. grids.single.status==='启用'?'normal':'',
  110. grids.single.status==='处理中'?'box-spot-color n1':'',
  111. ]"
  112. style="stroke:rgb(11,51,71);stroke-width:3;" />
  113. <polygon v-if="grids.half.left.status"
  114. class="spot half-left" points="0,80 50,0 150,0 150,80"
  115. :class="[
  116. grids.half.left.status==='启用'?'normal':'',
  117. grids.half.left.status==='处理中'?'box-spot-color n1':'',
  118. ]"
  119. style="stroke:rgb(11,51,71);stroke-width:3;" />
  120. <polygon v-if="grids.half.right.status"
  121. class="spot half-right" points="150,0 150,80 300,80 250,0"
  122. :class="[
  123. grids.half.right.status==='启用'?'normal':'',
  124. grids.half.right.status==='处理中'?'box-spot-color n2':'',
  125. ]"
  126. style="stroke:rgb(11,51,71);stroke-width:3;" />
  127. <polygon v-if="grids.quarter.left.top.status"
  128. :class="[
  129. grids.quarter.left.top.status==='启用'?'normal':'',
  130. grids.quarter.left.top.status==='处理中'?'box-spot-color n1':'',
  131. ]"
  132. class="spot quarter-left-top" points="29.17,33.33 50,0 150,0 150,33.33"
  133. style="stroke:rgb(11,51,71);stroke-width:3;" />
  134. <polygon v-if="grids.quarter.left.bottom.status"
  135. :class="[
  136. grids.quarter.left.bottom.status==='启用'?'normal':'',
  137. grids.quarter.left.bottom.status==='处理中'?'box-spot-color n2':'',
  138. ]"
  139. class="spot quarter-left-bottom" points="0,80 29.17,33.33 150,33.33 150,80"
  140. style="stroke:rgb(11,51,71);stroke-width:3;" />
  141. <polygon v-if="grids.quarter.right.top.status"
  142. :class="[
  143. grids.quarter.right.top.status==='启用'?'normal':'',
  144. grids.quarter.right.top.status==='处理中'?'box-spot-color n3':'',
  145. ]"
  146. class="spot quarter-right-top" points="150,33.33 150,0 250,0 270.83,33.33"
  147. style="stroke:rgb(11,51,71);stroke-width:3;" />
  148. <polygon v-if="grids.quarter.right.bottom.status"
  149. :class="[
  150. grids.quarter.right.bottom.status==='启用'?'normal':'',
  151. grids.quarter.right.bottom.status==='处理中'?'box-spot-color n4':'',
  152. ]"
  153. class="spot quarter-right-bottom" points="150,33.33 150,80 300,80 270.83,33.33"
  154. style="stroke:rgb(11,51,71);stroke-width:3;" />
  155. <polygon v-if="grids.sixth.left.top.status"
  156. :class="[
  157. grids.sixth.left.top.status==='启用'?'normal':'',
  158. grids.sixth.left.top.status==='处理中'?'box-spot-color n1':'',
  159. ]"
  160. class="spot sixth-left-top" points="29.17,33.33 50,0 117,0 110.39,33.33"
  161. style="stroke:rgb(11,51,71);stroke-width:3;" />
  162. <polygon v-if="grids.sixth.left.bottom.status"
  163. :class="[
  164. grids.sixth.left.bottom.status==='启用'?'normal':'',
  165. grids.sixth.left.bottom.status==='处理中'?'box-spot-color n2':'',
  166. ]"
  167. class="spot sixth-left-bottom" points="0,80 29.17,33.33 110.39,33.33 100,80"
  168. style="stroke:rgb(11,51,71);stroke-width:3;" />
  169. <polygon v-if="grids.sixth.mid.top.status"
  170. :class="[
  171. grids.sixth.mid.top.status==='启用'?'normal':'',
  172. grids.sixth.mid.top.status==='处理中'?'box-spot-color n3':'',
  173. ]"
  174. class="spot sixth-mid-top" points="117,0 110.39,33.33 191.61,33.33 185.5,0"
  175. style="stroke:rgb(11,51,71);stroke-width:3;" />
  176. <polygon v-if="grids.sixth.mid.bottom.status"
  177. :class="[
  178. grids.sixth.mid.bottom.status==='启用'?'normal':'',
  179. grids.sixth.mid.bottom.status==='处理中'?'box-spot-color n4':'',
  180. ]"
  181. class="spot sixth-mid-bottom" points="110.39,33.33 100,80 200,80 191.61,33.33"
  182. style="stroke:rgb(11,51,71);stroke-width:3;" />
  183. <polygon v-if="grids.sixth.right.top.status"
  184. :class="[
  185. grids.sixth.right.top.status==='启用'?'normal':'',
  186. grids.sixth.right.top.status==='处理中'?'box-spot-color n5':'',
  187. ]"
  188. class="spot sixth-right-top" points="191.61,33.33 185.5,0 250,0 270.83,33.33"
  189. style="stroke:rgb(11,51,71);stroke-width:3;" />
  190. <polygon v-if="grids.sixth.right.bottom.status"
  191. :class="[
  192. grids.sixth.right.bottom.status==='启用'?'normal':'',
  193. grids.sixth.right.bottom.status==='处理中'?'box-spot-color n6':'',
  194. ]"
  195. class="spot sixth-right-bottom" points="200,80 191.61,33.33 270.83,33.33 300,80"
  196. style="stroke:rgb(11,51,71);stroke-width:3;" />
  197. </svg>
  198. <div class="text-left">
  199. <div >
  200. <div class="btn btn-outline-info" @click="
  201. (inputs.manuallyTakeBox.visible=!inputs.manuallyTakeBox.visible)
  202. &&(inputs.manuallyTakeBox.text='')">手动出库</div>
  203. <div class="position-relative bg-white" v-if="inputs.manuallyTakeBox.visible">
  204. <textarea name="" id="" cols="30" rows="3" class="form-control" v-model="inputs.manuallyTakeBox.text"
  205. placeholder="点选此处写入料箱号,可以省略IDE前缀和0,多个用空格分隔,例入:5121 156"></textarea>
  206. <button class="btn btn-info btn-lg" @click="manuallyTakeBoxOut">出库</button>
  207. </div>
  208. </div>
  209. </div>
  210. </div>
  211. </div>
  212. </div>
  213. <div class="col text-center">
  214. <div class="d-flex flex-row justify-content-between" style="gap: 10px;" v-if="taskCommoditiesListByWall.length">
  215. <div class="border h4 d-flex flex-column-reverse flex-grow-1" v-for="wall in taskCommoditiesListByWall">
  216. <div class="d-flex flex-row" v-for="row in wall">
  217. <div class="border p-1 flex-grow-1" v-for="column in row"
  218. :class="[
  219. column.status?'':'small text-muted',
  220. column.status==='待处理'?'small text-muted':'',
  221. column.status==='异常'?'bg-danger':'',
  222. column.status==='处理队列'?'font-weight-bold':'',
  223. column.status==='完成'?'small text-muted bg-success':'',
  224. column.status==='处理中' && !column.taskCommodity.material_box_position?'font-weight-bold bg-primary':'',
  225. column.status==='处理中' && column.taskCommodity.material_box_position===1?'font-weight-bold box-spot-color n1':'',
  226. column.status==='处理中' && column.taskCommodity.material_box_position===2?'font-weight-bold box-spot-color n2':'',
  227. column.status==='处理中' && column.taskCommodity.material_box_position===3?'font-weight-bold box-spot-color n3':'',
  228. column.status==='处理中' && column.taskCommodity.material_box_position===4?'font-weight-bold box-spot-color n4':'',
  229. column.status==='处理中' && column.taskCommodity.material_box_position===5?'font-weight-bold box-spot-color n5':'',
  230. column.status==='处理中' && column.taskCommodity.material_box_position===6?'font-weight-bold box-spot-color n6':'',
  231. ]"
  232. :style="{
  233. opacity:column.status?1:0.5,
  234. }">
  235. <span class="d-inline-block" style="width: 36px;">
  236. @{{column.number}}
  237. </span>
  238. </div>
  239. </div>
  240. </div>
  241. </div>
  242. <div class="row mb-1">
  243. <div class="col flex text-left">
  244. <span class="" style="opacity: 0.6"> 数量:</span>
  245. <span class="font-weight-bold">@{{ processedCommodities }}</span>
  246. /
  247. <span class="text-muted">@{{ totalCommodities }}</span>
  248. </div>
  249. <div class="col-1 offset-2 text-muted" v-if="error">异常:</div>
  250. <div class="col-6" v-if="error">@{{ error }}</div>
  251. </div>
  252. <div class="row">
  253. <div class="col py-1">
  254. <table class="table table-hover border table-sm" style="opacity: 0.85" v-if="taskCommodities">
  255. <tr class="text-muted">
  256. <th class="py-2">序号</th>
  257. <th class="py-2">商品</th>
  258. <th class="py-2">数量</th>
  259. <th class="py-2">条码</th>
  260. </tr>
  261. <tr class="" v-for="(taskCommodity,i) in taskCommodities" :class="[
  262. taskCommodity.status==='待处理'?'text-muted':'',
  263. taskCommodity.status==='挂起'?'bg-white':'',
  264. taskCommodity.status==='处理队列'?'font-weight-bold':'',
  265. taskCommodity.status==='完成'?'bg-success':'',
  266. taskCommodity.status==='异常'?'bg-danger':'',
  267. taskCommodity.status==='取消'?'text-muted':'',
  268. taskCommodity.status==='处理中' && !taskCommodity.material_box_position?'bg-primary':'',
  269. taskCommodity.status==='处理中' && taskCommodity.material_box_position===1?'box-spot-color n1':'',
  270. taskCommodity.status==='处理中' && taskCommodity.material_box_position===2?'box-spot-color n2':'',
  271. taskCommodity.status==='处理中' && taskCommodity.material_box_position===3?'box-spot-color n3':'',
  272. taskCommodity.status==='处理中' && taskCommodity.material_box_position===4?'box-spot-color n4':'',
  273. taskCommodity.status==='处理中' && taskCommodity.material_box_position===5?'box-spot-color n5':'',
  274. taskCommodity.status==='处理中' && taskCommodity.material_box_position===6?'box-spot-color n6':'',
  275. ]">
  276. <td style="opacity: 0.6">@{{ i+1 }}</td>
  277. <td>@{{ taskCommodity.commodity.name }}</td>
  278. <td>@{{ taskCommodity.amount }}</td>
  279. <td><small class="font-weight-bold" v-for="barcode in taskCommodity.commodity.barcodes">@{{ barcode.code }}</small><br></td>
  280. </tr>
  281. </table>
  282. </div>
  283. </div>
  284. </div>
  285. </div>
  286. </div>
  287. </div>
  288. </div>
  289. <style>
  290. .spot.normal{
  291. fill: #fff;
  292. }
  293. .box-spot-color{
  294. color: #fff;
  295. }
  296. .box-spot-color.n1{
  297. background: #d7e3ff;
  298. fill: #d7e3ff;
  299. }
  300. .box-spot-color.n2{
  301. background: #393409;
  302. fill: #393409;
  303. }
  304. .box-spot-color.n3{
  305. background: #391709;
  306. fill: #391709;
  307. }
  308. .box-spot-color.n4{
  309. background: #092039;
  310. fill: #092039;
  311. }
  312. .box-spot-color.n5{
  313. background: #390931;
  314. fill: #390931;
  315. }
  316. .box-spot-color.n6{
  317. background: #1a0106;
  318. fill: #1a0106;
  319. }
  320. </style>
  321. @endsection
  322. @section('lastScript')
  323. <script type="text/javascript" src="{{mix('js/utilities/barcode.js')}}"></script>
  324. <script>
  325. $vue=new Vue({
  326. el:"#container",
  327. data:{
  328. taskBroadcastName : "{{config('database.redis.options.prefix').'station-'.$station->id}}",
  329. allTaskBroadcastName : "{{config('database.redis.options.prefix').'station-0'}}",
  330. channelName : ".App\\Events\\BroadcastToStation",
  331. error:"",
  332. station:{!! $station !!},
  333. inputs:{
  334. manuallyTakeBox:{
  335. visible:false,
  336. text:'',
  337. }
  338. },
  339. current_stationTaskBatch: null,
  340. stationTask_indexByBatch: [],
  341. stationTaskBatch_index: [],
  342. grids:{
  343. single:{status:'',},
  344. half:{
  345. left:{status:'',},
  346. right:{status:'',}
  347. },
  348. quarter:{
  349. left:{top:{status:'',},bottom:{status:'',},},
  350. right:{top:{status:'',},bottom:{status:'',},},
  351. },
  352. sixth:{
  353. left:{top:{status:'',},bottom:{status:'',},},
  354. mid:{top:{status:'',},bottom:{status:'',},},
  355. right:{top:{status:'',},bottom:{status:'',},},
  356. },
  357. },
  358. },
  359. mounted() {
  360. this._makeMenuHiding();
  361. initEcho();
  362. this._listenTaskBroadcast();
  363. this._listenAllTaskBroadcast();
  364. },
  365. methods:{
  366. _makeMenuHiding(){
  367. $('.navbar,.nav1,.nav2').hide();
  368. $('.nav3').on('mouseenter', function () {
  369. $('.navbar,.nav1,.nav2').show();
  370. });
  371. $('.body').on('mouseenter', function () {
  372. $('.navbar,.nav1,.nav2').hide();
  373. });
  374. },
  375. _listenTaskBroadcast(){
  376. let _this=this;
  377. console.log(this.taskBroadcastName,this.channelName);
  378. window.Echo.channel(this.taskBroadcastName).listen(this.channelName,(msg)=> {
  379. console.log('1:',(new Date()).toTimeString(),msg);
  380. let taskIn = JSON.parse(msg.json);
  381. if(!taskIn||taskIn.length===0)return;
  382. taskIn['station_task_batches'].forEach(function(station_task_batch){
  383. let taskOld=_this.stationTask_indexByBatch[station_task_batch['batch_id']];
  384. if(typeof(taskOld)==='undefined')return;
  385. for(let key in taskIn){
  386. if(taskIn.hasOwnProperty(key)){
  387. if(taskOld[key].hasOwnProperty(key)){
  388. taskOld[key]=taskIn[key]
  389. }
  390. }
  391. }
  392. });
  393. });
  394. },
  395. _listenAllTaskBroadcast(){
  396. let _this=this;
  397. console.log(this.allTaskBroadcastName,this.channelName);
  398. window.Echo.channel(this.allTaskBroadcastName).listen(this.channelName,(msg)=> {
  399. console.log('2:',(new Date()).toTimeString(),msg);
  400. let stationTasksIn = JSON.parse(msg.json);
  401. if(!stationTasksIn||stationTasksIn.length===0)return;
  402. stationTasksIn.forEach(function(stationTaskIn){
  403. let stationTaskIn_toAdd=stationTaskIn;
  404. _this.stationTasks.forEach(function(stationTask){
  405. if(stationTask.id===stationTaskIn.id){
  406. for(let key in stationTaskIn){
  407. if(stationTaskIn.hasOwnProperty(key)){
  408. if(stationTask[key].hasOwnProperty(key)){
  409. stationTask[key]=stationTaskIn[key]
  410. }
  411. }
  412. }
  413. stationTaskIn_toAdd=null;
  414. }
  415. });
  416. if(stationTaskIn_toAdd){
  417. _this.station.station_tasks_today.push(stationTaskIn_toAdd);
  418. }
  419. })
  420. });
  421. },
  422. selectBatch(stationTaskBatch){
  423. this.current_stationTaskBatch=stationTaskBatch;
  424. if(typeof(this.current_stationTaskBatch.runningStatus)==='undefined')
  425. this.current_stationTaskBatch.runningStatus=''
  426. },
  427. manuallyTakeBoxOut(){
  428. let _this=this;
  429. if(typeof(window.manuallyHairouRequesting)==='undefined'
  430. ||window.manuallyHairouRequesting===false){
  431. window.manuallyHairouRequesting=true;
  432. }else{return;}
  433. let text = this.inputs.manuallyTakeBox.text.trim();
  434. if(!text){
  435. alert('请输入料箱号')
  436. return
  437. }
  438. axios.post('{{url('/api/thirdPart/haiq/storage/takeOutToULine')}}',{codes:text})
  439. .then(function(response){
  440. tempTip.okWindow(response.data.result,'确定')
  441. }).catch(function(err){
  442. tempTip.okWindow(err,'确定')
  443. }).finally(function(){
  444. _this.inputs.manuallyTakeBox.text='';
  445. window.manuallyHairouRequesting=false;
  446. })
  447. },
  448. runTheTaskBatch(){
  449. let _this=this;
  450. _this.current_stationTaskBatch.runningStatus='请求中';
  451. _this.$forceUpdate();
  452. axios.post('{{url('/api/thirdPart/haiq/runTaskBatch')}}',{station_task_batch_id:_this.current_stationTaskBatch.id})
  453. .then(function(response){
  454. if(!response.data.success){
  455. _this.current_stationTaskBatch.runningStatus='请求失败';
  456. return;
  457. }
  458. _this.current_stationTaskBatch.runningStatus='请求成功'
  459. }).catch(function(err){
  460. _this.current_stationTaskBatch.runningStatus='请求异常'
  461. tempTip.okWindow(err+': 服务器代码出错,请联系开发部门负责人','确定')
  462. }).finally(function(){
  463. _this.$forceUpdate();
  464. });
  465. },
  466. },
  467. computed:{
  468. task(){
  469. if(!this.current_stationTaskBatch||typeof(this.stationTask_indexByBatch['_'+this.current_stationTaskBatch.batch_id])==='undefined')return null;
  470. return this.stationTask_indexByBatch['_'+this.current_stationTaskBatch.batch_id];
  471. },
  472. stationTasks(){
  473. if(!this.station)return;
  474. return this.station.station_tasks_today;
  475. },
  476. stationTaskBatches(){
  477. if(!this.stationTasks)return;
  478. let _this=this;
  479. let stationTaskBatches=[];
  480. this.stationTasks.forEach(function(stationTask){
  481. if(!stationTask.station_task_batches)return;
  482. stationTask.station_task_batches.forEach(function(stationTaskBatch){
  483. if(typeof(_this.stationTaskBatch_index['_'+stationTaskBatch.batch_id])==='undefined'){
  484. // if(stationTaskBatch_index['_'+stationTaskBatch.batch_id]['status']==='完成')return;
  485. stationTaskBatches.push(stationTaskBatch)
  486. _this.stationTaskBatch_index['_'+stationTaskBatch.batch_id]=stationTaskBatch;
  487. _this.stationTask_indexByBatch['_'+stationTaskBatch.batch_id]=stationTask;
  488. }
  489. })
  490. });
  491. return stationTaskBatches;
  492. },
  493. batchCode(){
  494. let _this=this;
  495. if(!this.current_stationTaskBatch)return;
  496. if(typeof(this.current_stationTaskBatch)!=='undefined'
  497. && typeof(this.current_stationTaskBatch.batch)!=='undefined'
  498. ){
  499. setTimeout(function (){
  500. setBarcode(_this.current_stationTaskBatch.batch.code,"#barcode",1,50,false);
  501. })
  502. }
  503. return this.current_stationTaskBatch.batch.code;
  504. },
  505. taskCommodities(){
  506. if(!this.task)return [];
  507. return this.task['station_task_commodities'];
  508. },
  509. taskCommoditiesListByBin(){
  510. if(!this.task)return [];
  511. function reIndexByBin() {
  512. this.taskCommoditiesListByBinVar = [];
  513. this.taskCommoditiesListByBinVar.md5 = md5(JSON.stringify(this.task['station_task_commodities']));
  514. let _this=this;
  515. this.task['station_task_commodities']
  516. .forEach(function (taskCommodity) {
  517. if (typeof (_this.taskCommoditiesListByBinVar[taskCommodity['bin_number']]) === 'undefined') {
  518. _this.taskCommoditiesListByBinVar[taskCommodity['bin_number']] = null;
  519. }
  520. _this.taskCommoditiesListByBinVar[taskCommodity['bin_number']]=taskCommodity;
  521. })
  522. return this.taskCommoditiesListByBinVar;
  523. }
  524. if((typeof this.taskCommoditiesListByBinVar)==='undefined'||!this.taskCommoditiesListByBinVar){
  525. return reIndexByBin.call(this);
  526. }
  527. let md5Now = md5(JSON.stringify(this.task['station_task_commodities']));
  528. if(this.taskCommoditiesListByBinVar.md5!==md5Now){
  529. return reIndexByBin.call(this);
  530. }
  531. return this.taskCommoditiesListByBinVar;
  532. },
  533. taskCommoditiesListByWall(){
  534. if(!this.task)return [];
  535. let columnLength=this.station.station_type_bin_monitor.bin_column_length,
  536. rowLength=this.station.station_type_bin_monitor.bin_row_length,
  537. wallAmount=this.station.station_type_bin_monitor.bin_wall_amount,
  538. walls=[],
  539. wall,
  540. row;
  541. for(let wI=0;wI<wallAmount;wI++){
  542. wall=[];
  543. for(let rI=0;rI<rowLength;rI++){
  544. row=[];
  545. for(let cI=0;cI<columnLength;cI++){
  546. let number=((wI*rowLength+rI)*columnLength)+cI+1;
  547. let commoditiesInBin={
  548. taskCommodity:this.taskCommoditiesListByBin[number],
  549. number:number,
  550. status:''
  551. };
  552. if(typeof(commoditiesInBin.taskCommodity)==='undefined'
  553. ||!commoditiesInBin.taskCommodity){
  554. commoditiesInBin.taskCommodity={};
  555. }else{
  556. commoditiesInBin.status=commoditiesInBin.taskCommodity['status'];
  557. }
  558. row.push(commoditiesInBin);
  559. }
  560. wall.push(row);
  561. }
  562. walls.push(wall)
  563. }
  564. return walls
  565. },
  566. processedCommodities(){
  567. if(!this.task)return 0;
  568. let processedAmount=0;
  569. this.task['station_task_commodities'].forEach(function (taskCommodity) {
  570. if (taskCommodity.status === '完成') {
  571. processedAmount+=taskCommodity.amount;
  572. }
  573. })
  574. return processedAmount;
  575. },
  576. totalCommodities(){
  577. if(!this.task)return 0;
  578. let amount=0;
  579. this.task['station_task_commodities'].forEach(function (taskCommodity) {
  580. amount+=taskCommodity.amount;
  581. })
  582. return amount;
  583. },
  584. processingTaskMaterialBox(){
  585. if(!this.task)return [];
  586. let taskMaterialBox=null;
  587. this.task.station_task_material_boxes.some(function(taskMaterialBox_in){
  588. if(taskMaterialBox_in.status==='处理中'){
  589. taskMaterialBox=taskMaterialBox_in;
  590. }
  591. });
  592. return taskMaterialBox;
  593. },
  594. },
  595. watch:{
  596. 'station':{
  597. immediate:true,
  598. deep:true,
  599. handler:function(newStation){
  600. let grids={
  601. single:{status:'',amount:'',},
  602. half:{
  603. left:{status:'',amount:'',},
  604. right:{status:'',amount:'',}
  605. },
  606. quarter:{
  607. left:{top:{status:'',amount:'',},bottom:{status:'',amount:'',},},
  608. right:{top:{status:'',amount:'',},bottom:{status:'',amount:'',},},
  609. },
  610. sixth:{
  611. left:{top:{status:'',amount:'',},bottom:{status:'',amount:'',},},
  612. mid:{top:{status:'',amount:'',},bottom:{status:'',amount:'',},},
  613. right:{top:{status:'',amount:'',},bottom:{status:'',amount:'',},},
  614. },
  615. };
  616. if(!newStation.current_station_task||newStation.current_station_task.length===0) {
  617. this.grids=grids;
  618. return;
  619. }
  620. let gridsAmount=(function(){
  621. let taskMaterialBox=null;
  622. newStation.current_station_task.station_task_material_boxes.some(function(taskMaterialBox_in){
  623. if(taskMaterialBox_in.status==='处理中'){
  624. taskMaterialBox=taskMaterialBox_in;
  625. }
  626. });
  627. if(!taskMaterialBox)return 1;
  628. return taskMaterialBox.material_box.grid_amount;
  629. }
  630. )();
  631. let positions=(function(){
  632. let positions=[];
  633. newStation.current_station_task['station_task_commodities'].forEach(function(taskCommodity){
  634. if(taskCommodity.status==='处理中'){
  635. positions.push(taskCommodity.material_box_position)
  636. }
  637. });
  638. return positions;
  639. })();
  640. switch (gridsAmount){
  641. case 1:
  642. if(positions.length>0){
  643. grids.single.status='处理中';
  644. }break;
  645. case 2:
  646. positions.forEach(function(position){
  647. grids.half.left.status = '启用';
  648. grids.half.right.status = '启用';
  649. switch (position){
  650. case 1: grids.half.left.status = '处理中';break;
  651. case 2: grids.half.right.status = '处理中';break;
  652. }
  653. });break;
  654. case 4:
  655. positions.forEach(function(position){
  656. grids.quarter.left.top.status = '启用';
  657. grids.quarter.right.top.status = '启用';
  658. grids.quarter.left.bottom.status = '启用';
  659. grids.quarter.right.bottom.status = '启用';
  660. switch (position){
  661. case 1: grids.quarter.left.top.status = '处理中';break;
  662. case 2: grids.quarter.left.bottom.status = '处理中';break;
  663. case 3: grids.quarter.right.top.status = '处理中';break;
  664. case 4: grids.quarter.right.bottom.status = '处理中';break;
  665. }
  666. });break;
  667. case 6:
  668. positions.forEach(function(position){
  669. grids.sixth.left.top.status = '启用';
  670. grids.sixth.mid.top.status = '启用';
  671. grids.sixth.right.top.status = '启用';
  672. grids.sixth.left.bottom.status = '启用';
  673. grids.sixth.mid.bottom.status = '启用';
  674. grids.sixth.right.bottom.status = '启用';
  675. switch (position){
  676. case 1: grids.sixth.left.top.status = '处理中';break;
  677. case 2: grids.sixth.left.bottom.status = '处理中';break;
  678. case 3: grids.sixth.mid.top.status = '处理中';break;
  679. case 4: grids.sixth.mid.bottom.status = '处理中';break;
  680. case 5: grids.sixth.right.top.status = '处理中';break;
  681. case 6: grids.sixth.right.bottom.status = '处理中';break;
  682. }
  683. });break;
  684. }
  685. this.grids=grids;
  686. }
  687. },
  688. },
  689. filters:{
  690. simplifyBatchCode(val){
  691. if(!val){return ''}
  692. return val.replace(/W\d{6}0*/,'').trim()
  693. }
  694. }
  695. });
  696. </script>
  697. @endsection