show.blade.php 54 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933
  1. @extends('layouts.app')
  2. @section('title'){{$station->name}} - 监视器 - 站@endsection
  3. @section('content')
  4. <div class="container-fluid body" id="container">
  5. <div class="card">
  6. <div class="card-body">
  7. <div class="row border" style="opacity: 0.75">
  8. <div class="col-4 text-center h3 py-2 font-weight-bold text-info position-relative">
  9. 宝时云仓
  10. </div>
  11. <div class="col h3 py-2 text-muted row">
  12. <select class="form-control col-2 offset-4" id="station" @change="listenerStation()">
  13. <option selected value=""></option>
  14. <option v-for="station in stations" :value="station.code">
  15. @{{ station.code }}
  16. </option>
  17. </select>
  18. <span class="col-2">智能分拣</span>
  19. </div>
  20. </div>
  21. <div class="row pt-3">
  22. <div class="col-4">
  23. <div class="row">
  24. <div class="col py-3 h4">
  25. <div class="row">
  26. <div class="col">选择执行波次:</div>
  27. </div>
  28. <div class="row" v-if="current_stationTaskBatch">
  29. <div class="col font-weight-bold text-center position-relative"
  30. :style="[
  31. {opacity:
  32. current_stationTaskBatch.status==='完成'?'0.5':'1'
  33. },
  34. ]"
  35. :class="[
  36. (current_stationTaskBatch.runningStatus==='')?'text-info':'',
  37. (current_stationTaskBatch.runningStatus==='请求中')?'text-dark':'',
  38. (current_stationTaskBatch.runningStatus==='请求失败')?'text-danger':'',
  39. (current_stationTaskBatch.runningStatus==='请求成功')?'text-success':'',
  40. (current_stationTaskBatch.runningStatus==='请求异常')?'text-danger':'',
  41. ]"
  42. >
  43. <div class="text-center mt-2">@{{ current_stationTaskBatch.batch.code }}</div>
  44. <div class="text-center" style="font-size: 12px;">
  45. @{{ current_stationTaskBatch.batch.owner.name }}
  46. </div>
  47. <div class="col text-muted text-left">
  48. <img id="barcode" :alt="batchCode">
  49. </div>
  50. </div>
  51. <div class="col text-center">
  52. <button class="btn btn-lg mt-4" @click="runTheTaskBatch()"
  53. :class="[
  54. (current_stationTaskBatch.runningStatus==='')?'btn-info':'',
  55. (current_stationTaskBatch.runningStatus==='请求中')?'btn-dark':'',
  56. (current_stationTaskBatch.runningStatus==='请求失败')?'btn-danger':'',
  57. (current_stationTaskBatch.runningStatus==='请求成功')?'btn-success':'',
  58. (current_stationTaskBatch.runningStatus==='请求异常')?'btn-danger':'',
  59. ]"
  60. >
  61. <span v-if="!current_stationTaskBatch.runningStatus">执行</span>
  62. <span v-if="current_stationTaskBatch.runningStatus==='请求中'">请求中</span>
  63. <span v-if="current_stationTaskBatch.runningStatus==='请求失败'">(失败)重新执行</span>
  64. <span v-if="current_stationTaskBatch.runningStatus==='请求成功'">(请求成功)重新执行</span>
  65. <span v-if="current_stationTaskBatch.runningStatus==='请求异常'">(请求异常)重新执行</span>
  66. </button>
  67. <label class="align-bottom mb-0 p-0">
  68. <input content="col-4" type="checkbox" class="switch" v-model="isCacheShelf"></input><br>
  69. <small class="mb-0 h6">缓存架</small>
  70. </label>
  71. </div>
  72. </div>
  73. <div class="text-center my-2" style="overflow-y: scroll;max-height:200px;">
  74. <div class="flex flex-column flex-wrap" v-if="stationTaskBatches">
  75. <button v-for="stationTaskBatch in stationTaskBatches"
  76. @click="selectBatch(stationTaskBatch)"
  77. class="btn"
  78. :class="[
  79. (current_stationTaskBatch&&current_stationTaskBatch.id===stationTaskBatch.id)?'btn-outline-info':'btn-outline-dark',
  80. ]"
  81. :style="[
  82. {opacity:
  83. stationTaskBatch.status==='完成'?'0.5':'1'
  84. },
  85. ]"
  86. >
  87. @{{stationTaskBatch.batch.code | simplifyBatchCode}}</button>
  88. </div>
  89. </div>
  90. </div>
  91. </div>
  92. <div class="row">
  93. <div class="col py-3 h4">
  94. 料箱号:
  95. <div v-if="task&&processingTaskMaterialBox">
  96. @{{processingTaskMaterialBox.material_box.code}}
  97. </div>
  98. </div>
  99. </div>
  100. <div class="row pt-2">
  101. <div class="col text-center">
  102. <svg class="box-display" width="300" height="160" viewBox="0 0 300 160">
  103. <g><rect x="0" y="80" width="300" height="80"
  104. style="fill:#ffffff;stroke-width:3;stroke:rgb(11,51,71)">
  105. </rect>
  106. <text x="10" y="135" font-family="Verdana" font-weight="bold" font-size="40" fill="green">
  107. @{{ box }}</text>
  108. </g>
  109. <polygon points="0,80 50,0 250,0 300,80"
  110. style="fill:#ffffff;stroke:rgb(11,51,71);stroke-width:3;" />
  111. <polygon v-if="grids.single.status"
  112. class="spot single" points="0,80 50,0 250,0 300,80"
  113. :class="[
  114. grids.single.status==='启用'?'normal':'',
  115. grids.single.status==='处理中'?'box-spot-color n1':'',
  116. ]"
  117. style="stroke:rgb(11,51,71);stroke-width:3;" />
  118. <polygon v-if="grids.half.left.status"
  119. class="spot half-left" points="0,80 50,0 150,0 150,80"
  120. :class="[
  121. grids.half.left.status==='启用'?'normal':'',
  122. grids.half.left.status==='处理中'?'box-spot-color n1':'',
  123. ]"
  124. style="stroke:rgb(11,51,71);stroke-width:3;" />
  125. <polygon v-if="grids.half.right.status"
  126. class="spot half-right" points="150,0 150,80 300,80 250,0"
  127. :class="[
  128. grids.half.right.status==='启用'?'normal':'',
  129. grids.half.right.status==='处理中'?'box-spot-color n2':'',
  130. ]"
  131. style="stroke:rgb(11,51,71);stroke-width:3;" />
  132. <polygon v-if="grids.quarter.left.top.status"
  133. :class="[
  134. grids.quarter.left.top.status==='启用'?'normal':'',
  135. grids.quarter.left.top.status==='处理中'?'box-spot-color n1':'',
  136. ]"
  137. class="spot quarter-left-top" points="29.17,33.33 50,0 150,0 150,33.33"
  138. style="stroke:rgb(11,51,71);stroke-width:3;" />
  139. <polygon v-if="grids.quarter.left.bottom.status"
  140. :class="[
  141. grids.quarter.left.bottom.status==='启用'?'normal':'',
  142. grids.quarter.left.bottom.status==='处理中'?'box-spot-color n2':'',
  143. ]"
  144. class="spot quarter-left-bottom" points="0,80 29.17,33.33 150,33.33 150,80"
  145. style="stroke:rgb(11,51,71);stroke-width:3;" />
  146. <polygon v-if="grids.quarter.right.top.status"
  147. :class="[
  148. grids.quarter.right.top.status==='启用'?'normal':'',
  149. grids.quarter.right.top.status==='处理中'?'box-spot-color n3':'',
  150. ]"
  151. class="spot quarter-right-top" points="150,33.33 150,0 250,0 270.83,33.33"
  152. style="stroke:rgb(11,51,71);stroke-width:3;" />
  153. <polygon v-if="grids.quarter.right.bottom.status"
  154. :class="[
  155. grids.quarter.right.bottom.status==='启用'?'normal':'',
  156. grids.quarter.right.bottom.status==='处理中'?'box-spot-color n4':'',
  157. ]"
  158. class="spot quarter-right-bottom" points="150,33.33 150,80 300,80 270.83,33.33"
  159. style="stroke:rgb(11,51,71);stroke-width:3;" />
  160. <polygon v-if="grids.sixth.left.top.status"
  161. :class="[
  162. grids.sixth.left.top.status==='启用'?'normal':'',
  163. grids.sixth.left.top.status==='处理中'?'box-spot-color n1':'',
  164. ]"
  165. class="spot sixth-left-top" points="29.17,33.33 50,0 117,0 110.39,33.33"
  166. style="stroke:rgb(11,51,71);stroke-width:3;" />
  167. <polygon v-if="grids.sixth.left.bottom.status"
  168. :class="[
  169. grids.sixth.left.bottom.status==='启用'?'normal':'',
  170. grids.sixth.left.bottom.status==='处理中'?'box-spot-color n2':'',
  171. ]"
  172. class="spot sixth-left-bottom" points="0,80 29.17,33.33 110.39,33.33 100,80"
  173. style="stroke:rgb(11,51,71);stroke-width:3;" />
  174. <polygon v-if="grids.sixth.mid.top.status"
  175. :class="[
  176. grids.sixth.mid.top.status==='启用'?'normal':'',
  177. grids.sixth.mid.top.status==='处理中'?'box-spot-color n3':'',
  178. ]"
  179. class="spot sixth-mid-top" points="117,0 110.39,33.33 191.61,33.33 185.5,0"
  180. style="stroke:rgb(11,51,71);stroke-width:3;" />
  181. <polygon v-if="grids.sixth.mid.bottom.status"
  182. :class="[
  183. grids.sixth.mid.bottom.status==='启用'?'normal':'',
  184. grids.sixth.mid.bottom.status==='处理中'?'box-spot-color n4':'',
  185. ]"
  186. class="spot sixth-mid-bottom" points="110.39,33.33 100,80 200,80 191.61,33.33"
  187. style="stroke:rgb(11,51,71);stroke-width:3;" />
  188. <polygon v-if="grids.sixth.right.top.status"
  189. :class="[
  190. grids.sixth.right.top.status==='启用'?'normal':'',
  191. grids.sixth.right.top.status==='处理中'?'box-spot-color n5':'',
  192. ]"
  193. class="spot sixth-right-top" points="191.61,33.33 185.5,0 250,0 270.83,33.33"
  194. style="stroke:rgb(11,51,71);stroke-width:3;" />
  195. <polygon v-if="grids.sixth.right.bottom.status"
  196. :class="[
  197. grids.sixth.right.bottom.status==='启用'?'normal':'',
  198. grids.sixth.right.bottom.status==='处理中'?'box-spot-color n6':'',
  199. ]"
  200. class="spot sixth-right-bottom" points="200,80 191.61,33.33 270.83,33.33 300,80"
  201. style="stroke:rgb(11,51,71);stroke-width:3;" />
  202. </svg>
  203. <div class="text-left">
  204. <div >
  205. <div class="btn btn-outline-info" @click="
  206. (inputs.manuallyTakeBox.visible=!inputs.manuallyTakeBox.visible)
  207. &&(inputs.manuallyTakeBox.text='')">手动出库</div>
  208. <div class="position-relative bg-white" v-if="inputs.manuallyTakeBox.visible">
  209. <textarea name="" id="" cols="30" rows="3" class="form-control" v-model="inputs.manuallyTakeBox.text"
  210. placeholder="点选此处写入料箱号,可以省略IDE前缀和0,多个用空格分隔,例入:5121 156"></textarea>
  211. <button class="btn btn-info btn-lg" @click="manuallyTakeBoxOut">出库</button>
  212. <button class="btn btn-success btn-lg" @click="manuallyTakeBoxOutTwo">二期出库</button>
  213. <button class="btn btn-success btn-lg" @click="manuallyTakeBoxInTwo">二期入库</button>
  214. <button class="btn btn-sm btn-primary btn-lg" @click="paddingEmptyBox">填充空箱</button>
  215. <div class="row mt-1">
  216. <select class="form-control ml-3" v-model="type" style="width:150px">
  217. <option v-for="strategy in strategies" :value="strategy.code">@{{ strategy.name }}</option>
  218. </select>
  219. <select class="form-control ml-1" v-model="stationCode" style="width:150px">
  220. <option v-for="st in stations" :value="st.code">@{{ st.code }}</option>
  221. </select>
  222. </div>
  223. </div>
  224. </div>
  225. </div>
  226. </div>
  227. </div>
  228. </div>
  229. <div class="col text-center">
  230. <div class="d-flex flex-row justify-content-between" style="gap: 10px;" v-if="taskCommoditiesListByWall.length">
  231. <div class="border h4 d-flex flex-column-reverse flex-grow-1" v-for="wall in taskCommoditiesListByWall">
  232. <div class="d-flex flex-row" v-for="row in wall">
  233. <div class="border p-1 flex-grow-1" v-for="column in row"
  234. :class="[
  235. column.status?'':'small text-muted',
  236. column.status==='待处理'?'small text-muted':'',
  237. column.status==='异常'?'bg-danger':'',
  238. column.status==='处理队列'?'font-weight-bold':'',
  239. column.status==='完成'?'small text-muted bg-success':'',
  240. column.status==='处理中' && !column.taskCommodity.material_box_position?'font-weight-bold bg-primary':'',
  241. column.status==='处理中' && column.taskCommodity.material_box_position===1?'font-weight-bold box-spot-color n1':'',
  242. column.status==='处理中' && column.taskCommodity.material_box_position===2?'font-weight-bold box-spot-color n2':'',
  243. column.status==='处理中' && column.taskCommodity.material_box_position===3?'font-weight-bold box-spot-color n3':'',
  244. column.status==='处理中' && column.taskCommodity.material_box_position===4?'font-weight-bold box-spot-color n4':'',
  245. column.status==='处理中' && column.taskCommodity.material_box_position===5?'font-weight-bold box-spot-color n5':'',
  246. column.status==='处理中' && column.taskCommodity.material_box_position===6?'font-weight-bold box-spot-color n6':'',
  247. ]"
  248. :style="{
  249. opacity:column.status?1:0.5,
  250. }">
  251. <span class="d-inline-block" style="width: 36px;">
  252. @{{column.number}}
  253. </span>
  254. </div>
  255. </div>
  256. </div>
  257. </div>
  258. <div class="row mb-1">
  259. <div class="col flex text-left">
  260. <span class="" style="opacity: 0.6"> 数量:</span>
  261. <span class="font-weight-bold">@{{ processedCommodities }}</span>
  262. /
  263. <span class="text-muted">@{{ totalCommodities }}</span>
  264. </div>
  265. <div class="col-1 offset-2 text-muted" v-if="error">异常:</div>
  266. <div class="col-6" v-if="error">@{{ error }}</div>
  267. </div>
  268. <div class="row">
  269. <div class="col py-1">
  270. <table class="table table-hover border table-sm" style="opacity: 0.85" v-if="taskCommodities">
  271. <tr class="text-muted">
  272. <th class="py-2">序号</th>
  273. <th class="py-2">商品</th>
  274. <th class="py-2">数量</th>
  275. <th class="py-2">条码</th>
  276. </tr>
  277. <tr class="" v-for="(taskCommodity,i) in taskCommodities" :class="[
  278. taskCommodity.status==='待处理'?'text-muted':'',
  279. taskCommodity.status==='挂起'?'bg-white':'',
  280. taskCommodity.status==='处理队列'?'font-weight-bold':'',
  281. taskCommodity.status==='完成'?'bg-success':'',
  282. taskCommodity.status==='异常'?'bg-danger':'',
  283. taskCommodity.status==='取消'?'text-muted':'',
  284. taskCommodity.status==='处理中' && !taskCommodity.material_box_position?'bg-primary':'',
  285. taskCommodity.status==='处理中' && taskCommodity.material_box_position===1?'box-spot-color n1':'',
  286. taskCommodity.status==='处理中' && taskCommodity.material_box_position===2?'box-spot-color n2':'',
  287. taskCommodity.status==='处理中' && taskCommodity.material_box_position===3?'box-spot-color n3':'',
  288. taskCommodity.status==='处理中' && taskCommodity.material_box_position===4?'box-spot-color n4':'',
  289. taskCommodity.status==='处理中' && taskCommodity.material_box_position===5?'box-spot-color n5':'',
  290. taskCommodity.status==='处理中' && taskCommodity.material_box_position===6?'box-spot-color n6':'',
  291. ]">
  292. <td style="opacity: 0.6">@{{ i+1 }}</td>
  293. <td>@{{ taskCommodity.commodity.name }}</td>
  294. <td>@{{ taskCommodity.amount }}</td>
  295. <td><small class="font-weight-bold" v-for="barcode in taskCommodity.commodity.barcodes">@{{ barcode.code }}</small><br></td>
  296. </tr>
  297. </table>
  298. </div>
  299. </div>
  300. </div>
  301. </div>
  302. </div>
  303. </div>
  304. </div>
  305. <style>
  306. .spot.normal{
  307. fill: #fff;
  308. }
  309. .box-spot-color{
  310. color: #fff;
  311. }
  312. .box-spot-color.n1{
  313. background: #d7e3ff;
  314. fill: #d7e3ff;
  315. }
  316. .box-spot-color.n2{
  317. background: #393409;
  318. fill: #393409;
  319. }
  320. .box-spot-color.n3{
  321. background: #391709;
  322. fill: #391709;
  323. }
  324. .box-spot-color.n4{
  325. background: #092039;
  326. fill: #092039;
  327. }
  328. .box-spot-color.n5{
  329. background: #390931;
  330. fill: #390931;
  331. }
  332. .box-spot-color.n6{
  333. background: #1a0106;
  334. fill: #1a0106;
  335. }
  336. </style>
  337. @endsection
  338. @section('lastScript')
  339. <script type="text/javascript" src="{{mix('js/utilities/barcode.js')}}"></script>
  340. <script>
  341. $vue=new Vue({
  342. el:"#container",
  343. data:{
  344. taskBroadcastName : "{{config('database.redis.options.prefix').'station-'.$station->id}}",
  345. allTaskBroadcastName : "{{config('database.redis.options.prefix').'station-0'}}",
  346. channelName : ".App\\Events\\BroadcastToStation",
  347. error:"",
  348. isCacheShelf:false,
  349. station:{!! $station !!},
  350. inputs:{
  351. manuallyTakeBox:{
  352. visible:false,
  353. text:'',
  354. }
  355. },
  356. current_stationTaskBatch: null,
  357. stationTask_indexByBatch: [],
  358. stationTaskBatch_index: [],
  359. grids:{
  360. single:{status:'',},
  361. half:{
  362. left:{status:'',},
  363. right:{status:'',}
  364. },
  365. quarter:{
  366. left:{top:{status:'',},bottom:{status:'',},},
  367. right:{top:{status:'',},bottom:{status:'',},},
  368. },
  369. sixth:{
  370. left:{top:{status:'',},bottom:{status:'',},},
  371. mid:{top:{status:'',},bottom:{status:'',},},
  372. right:{top:{status:'',},bottom:{status:'',},},
  373. },
  374. },
  375. stations:[],
  376. baseUrl:"https://swms.baoshi56.com/",
  377. stationWs:null,
  378. prodNum:null,
  379. box:"",
  380. list:[],
  381. type:"",
  382. stationCode:"",
  383. strategies:[],
  384. },
  385. mounted() {
  386. this._makeMenuHiding();
  387. //initEcho();
  388. //this._listenTaskBroadcast();
  389. //this._listenAllTaskBroadcast();
  390. this._loadStation();
  391. },
  392. methods:{
  393. // 加载站点
  394. _loadStation(){
  395. $.ajax({
  396. url : this.baseUrl+"equipment/getSortingStationList",
  397. type : "get",
  398. success : (res,status)=>{
  399. if (res.code === 200){
  400. this.stations = res.data;
  401. this.stationCode = this.stations[0].code;
  402. } else {
  403. window.tempTip.show(res.message);
  404. }
  405. },
  406. error : (err,status)=>{
  407. window.tempTip.show("分拣站信息获取失败");
  408. },
  409. timeout:3000,
  410. })
  411. $.ajax({
  412. url : this.baseUrl+"device/robot/hairou/getStrategies",
  413. type : "post",
  414. success : (res,status)=>{
  415. if (res.code === 200){
  416. this.strategies = res.data;
  417. this.type = this.strategies[0].code;
  418. } else {
  419. window.tempTip.show(res.message);
  420. }
  421. },
  422. error : (err,status)=>{
  423. window.tempTip.show("分配策略获取失败");
  424. },
  425. timeout:3000,
  426. })
  427. },
  428. listenerStation(){
  429. let val = document.getElementById("station").value;
  430. // 手动关闭不重试
  431. if (val === '' && this.stationWs != null){
  432. this.stationWs.close();
  433. window.clearInterval(this.prodNum);
  434. this.list = null;
  435. return;
  436. }
  437. this.stationWs = new WebSocket("wss://swms.baoshi56.com/ws/device/check/picking.info/"+val);
  438. this.stationWs.onopen = (event=> {
  439. console.info("Connection open success!");
  440. });
  441. this.stationWs.onmessage = (event => {
  442. let obj = JSON.parse(event.data);
  443. if(obj.dataType !== "heartbeat"){
  444. this.box = obj.code;
  445. let list = [];
  446. let arr = (JSON.parse(obj.list));
  447. if (arr && arr.length>0){
  448. arr.forEach(info => {
  449. list.push({
  450. status : "待处理",
  451. commodity : {
  452. name : "",
  453. barcodes : [
  454. {code : info.barcode},
  455. {code : info.barcodeAs},
  456. ],
  457. },
  458. amount : info.quantity
  459. })
  460. })
  461. }
  462. this.list = list;
  463. }
  464. });
  465. this.stationWs.onerror = function (event) {
  466. console.error(event);
  467. };
  468. this.prodNum = window.setInterval(()=>{
  469. if (this.stationWs != null){
  470. let obj = {
  471. "requestId" : "stationListener",
  472. "dataType" : "heartbeat",
  473. };
  474. this.stationWs.send(JSON.stringify(obj));
  475. }
  476. },15000);
  477. // 被关闭就五秒后重试
  478. this.stationWs.onclose = (event => {
  479. window.clearInterval(this.prodNum);
  480. setTimeout(()=>{
  481. this.listenerStation();
  482. },5000);
  483. });
  484. },
  485. _makeMenuHiding(){
  486. $('.navbar,.nav1,.nav2').hide();
  487. $('.nav3').on('mouseenter', function () {
  488. $('.navbar,.nav1,.nav2').show();
  489. });
  490. $('.body').on('mouseenter', function () {
  491. $('.navbar,.nav1,.nav2').hide();
  492. });
  493. },
  494. _listenTaskBroadcast(){
  495. let _this=this;
  496. window.Echo.channel(this.taskBroadcastName).listen(this.channelName,(msg)=> {
  497. console.log('1:',(new Date()).toTimeString(),msg);
  498. let taskIn = JSON.parse(msg.json);
  499. if(!taskIn||taskIn.length===0)return;
  500. taskIn['station_task_batches'].forEach(function(station_task_batch){
  501. let taskOld=_this.stationTask_indexByBatch[station_task_batch['batch_id']];
  502. if(typeof(taskOld)==='undefined')return;
  503. for(let key in taskIn){
  504. if(taskIn.hasOwnProperty(key)){
  505. if(taskOld[key].hasOwnProperty(key)){
  506. taskOld[key]=taskIn[key]
  507. }
  508. }
  509. }
  510. });
  511. });
  512. },
  513. _listenAllTaskBroadcast(){
  514. let _this=this;
  515. window.Echo.channel(this.allTaskBroadcastName).listen(this.channelName,(msg)=> {
  516. let stationTasksIn = JSON.parse(msg.json);
  517. if(!stationTasksIn||stationTasksIn.length===0)return;
  518. stationTasksIn.forEach(function(stationTaskIn){
  519. let stationTaskIn_toAdd=stationTaskIn;
  520. _this.stationTasks.forEach(function(stationTask){
  521. if(stationTask.id===stationTaskIn.id){
  522. for(let key in stationTaskIn){
  523. if(stationTaskIn.hasOwnProperty(key)){
  524. if(stationTask[key].hasOwnProperty(key)){
  525. stationTask[key]=stationTaskIn[key]
  526. }
  527. }
  528. }
  529. stationTaskIn_toAdd=null;
  530. }
  531. });
  532. if(stationTaskIn_toAdd){
  533. _this.station.station_tasks_today.unshift(stationTaskIn_toAdd);
  534. _this.$forceUpdate();
  535. }
  536. })
  537. });
  538. },
  539. selectBatch(stationTaskBatch){
  540. if (this.current_stationTaskBatch!==stationTaskBatch)this.isCacheShelf = false;
  541. this.current_stationTaskBatch=stationTaskBatch;
  542. if(typeof(this.current_stationTaskBatch.runningStatus)==='undefined')
  543. this.current_stationTaskBatch.runningStatus=''
  544. },
  545. manuallyTakeBoxOut(){
  546. let _this=this;
  547. if(typeof(window.manuallyHairouRequesting)==='undefined'
  548. ||window.manuallyHairouRequesting===false){
  549. window.manuallyHairouRequesting=true;
  550. }else{return;}
  551. let text = this.inputs.manuallyTakeBox.text.trim();
  552. if(!text){
  553. alert('请输入料箱号')
  554. return
  555. }
  556. axios.post('{{url('/api/thirdPart/haiq/storage/takeOutToULine')}}',{codes:text})
  557. .then(function(response){
  558. tempTip.okWindow(response.data.result,'确定')
  559. }).catch(function(err){
  560. tempTip.okWindow(err,'确定')
  561. }).finally(function(){
  562. _this.inputs.manuallyTakeBox.text='';
  563. window.manuallyHairouRequesting=false;
  564. })
  565. },
  566. _waveOutBound(waveCode){
  567. $.ajax({
  568. url: this.baseUrl+"device/robot/hairou/task/createOutBound/picking?code="+waveCode
  569. +"&strategy="+this.type+"&station="+this.stationCode,
  570. type: "get",
  571. success : (res,status)=>{
  572. if (res.code === 200 && res.data){
  573. window.tempTip.showSuccess("开始执行");
  574. } else {
  575. window.tempTip.show(res.message);
  576. }
  577. },
  578. error : (err,status)=>{
  579. window.tempTip.show("系统错误");
  580. },
  581. timeout:3000,
  582. })
  583. },
  584. _formatBoxes(){
  585. let arr = this.inputs.manuallyTakeBox.text.trim().split(/\s+/);
  586. if (arr.length===0){
  587. return;
  588. }
  589. let boxes = [];
  590. arr.forEach(box=>{
  591. if (box.length <= 10 && box.length > 0){
  592. let before = "IDE0000000";
  593. boxes.push(before.substring(0,before.length - box.length)+box);
  594. }
  595. });
  596. return boxes;
  597. },
  598. manuallyTakeBoxInTwo(){
  599. let boxes = this._formatBoxes();
  600. if (boxes.length===0){
  601. return;
  602. }
  603. window.tempTip.inputVal('请输入货主名称:',(code)=>{
  604. let obj = {
  605. "boxCodes":boxes,
  606. "toLocations":null,
  607. "owner":code,
  608. }
  609. $.ajax({
  610. url: this.baseUrl+"device/robot/hairou/task/createInBound/custom",
  611. type: "post",
  612. headers: {'Content-Type':'application/json;charset=utf8'},
  613. data: JSON.stringify(obj),
  614. success : (res,status)=>{
  615. if (res.code === 200 && res.data){
  616. window.tempTip.showSuccess("开始执行");
  617. } else {
  618. window.tempTip.show(res.message);
  619. }
  620. },
  621. error : (err,status)=>{
  622. window.tempTip.show("系统错误");
  623. },
  624. timeout:3000,
  625. })
  626. });
  627. },
  628. manuallyTakeBoxOutTwo(){
  629. if (this.inputs.manuallyTakeBox.text.length === 13 && this.inputs.manuallyTakeBox.text.substring(0,1) === "W"){
  630. this._waveOutBound(this.inputs.manuallyTakeBox.text);
  631. return;
  632. }
  633. let arr = this.inputs.manuallyTakeBox.text.trim().split(/\s+/);
  634. if (arr.length===0){
  635. return;
  636. }
  637. let boxes = this._formatBoxes();
  638. if (boxes.length===0){
  639. return;
  640. }
  641. let obj = {
  642. "boxCodes":boxes,
  643. "typeName":this.type,
  644. "toLocation":this.stationCode
  645. }
  646. $.ajax({
  647. url: this.baseUrl+"device/robot/hairou/task/createOutBound/custom",
  648. type: "post",
  649. headers: {'Content-Type':'application/json;charset=utf8'},
  650. data: JSON.stringify(obj),
  651. success : (res,status)=>{
  652. if (res.code === 200 && res.data){
  653. window.tempTip.showSuccess("开始执行");
  654. } else {
  655. window.tempTip.show(res.message);
  656. }
  657. },
  658. error : (err,status)=>{
  659. window.tempTip.show("系统错误");
  660. },
  661. timeout:3000,
  662. })
  663. },
  664. paddingEmptyBox(){
  665. window.tempTip.inputVal("调取数量",amount=>{
  666. window.tempTip.postBasicRequest("{{url('/api/thirdPart/haiq/storage/paddingEmptyBox')}}",{amount:amount},res=>{
  667. this.inputs.manuallyTakeBox.text = res;
  668. });
  669. });
  670. },
  671. runTheTaskBatch(){
  672. let _this=this;
  673. _this.current_stationTaskBatch.runningStatus='请求中';
  674. _this.$forceUpdate();
  675. axios.post('{{url('/api/thirdPart/haiq/runTaskBatch')}}',{station_task_batch_id:_this.current_stationTaskBatch.id,isCacheShelf:this.isCacheShelf})
  676. .then(function(response){
  677. if(!response.data.success){
  678. _this.current_stationTaskBatch.runningStatus='请求失败';
  679. return;
  680. }
  681. _this.current_stationTaskBatch.runningStatus='请求成功'
  682. }).catch(function(err){
  683. _this.current_stationTaskBatch.runningStatus='请求异常'
  684. tempTip.okWindow(err+': 服务器代码出错,请联系开发部门负责人','确定')
  685. }).finally(function(){
  686. _this.$forceUpdate();
  687. });
  688. },
  689. },
  690. computed:{
  691. task(){
  692. if(!this.current_stationTaskBatch||typeof(this.stationTask_indexByBatch['_'+this.current_stationTaskBatch.batch_id])==='undefined')return null;
  693. return this.stationTask_indexByBatch['_'+this.current_stationTaskBatch.batch_id];
  694. },
  695. stationTasks(){
  696. if(!this.station)return;
  697. return this.station.station_tasks_today;
  698. },
  699. stationTaskBatches(){
  700. if(!this.stationTasks)return;
  701. let _this=this;
  702. let stationTaskBatches=[];
  703. this.stationTasks.forEach(function(stationTask){
  704. if(!stationTask.station_task_batches)return;
  705. stationTask.station_task_batches.forEach(function(stationTaskBatch){
  706. if(typeof(_this.stationTaskBatch_index['_'+stationTaskBatch.batch_id])==='undefined'){
  707. // if(stationTaskBatch_index['_'+stationTaskBatch.batch_id]['status']==='完成')return;
  708. _this.stationTaskBatch_index['_'+stationTaskBatch.batch_id]=stationTaskBatch;
  709. _this.stationTask_indexByBatch['_'+stationTaskBatch.batch_id]=stationTask;
  710. }
  711. stationTaskBatches.push(stationTaskBatch)
  712. })
  713. });
  714. return stationTaskBatches;
  715. },
  716. batchCode(){
  717. let _this=this;
  718. if(!this.current_stationTaskBatch)return;
  719. if(typeof(this.current_stationTaskBatch)!=='undefined'
  720. && typeof(this.current_stationTaskBatch.batch)!=='undefined'
  721. ){
  722. setTimeout(function (){
  723. setBarcode(_this.current_stationTaskBatch.batch.code,"#barcode",1,50,false);
  724. })
  725. }
  726. return this.current_stationTaskBatch.batch.code;
  727. },
  728. taskCommodities(){
  729. if (this.list)return this.list;
  730. if(!this.task)return [];
  731. return this.task['station_task_commodities'];
  732. },
  733. taskCommoditiesListByBin(){
  734. if(!this.task)return [];
  735. function reIndexByBin() {
  736. this.taskCommoditiesListByBinVar = [];
  737. this.taskCommoditiesListByBinVar.md5 = md5(JSON.stringify(this.task['station_task_commodities']));
  738. let _this=this;
  739. this.task['station_task_commodities']
  740. .forEach(function (taskCommodity) {
  741. if (typeof (_this.taskCommoditiesListByBinVar[taskCommodity['bin_number']]) === 'undefined') {
  742. _this.taskCommoditiesListByBinVar[taskCommodity['bin_number']] = null;
  743. }
  744. _this.taskCommoditiesListByBinVar[taskCommodity['bin_number']]=taskCommodity;
  745. })
  746. return this.taskCommoditiesListByBinVar;
  747. }
  748. if((typeof this.taskCommoditiesListByBinVar)==='undefined'||!this.taskCommoditiesListByBinVar){
  749. return reIndexByBin.call(this);
  750. }
  751. let md5Now = md5(JSON.stringify(this.task['station_task_commodities']));
  752. if(this.taskCommoditiesListByBinVar.md5!==md5Now){
  753. return reIndexByBin.call(this);
  754. }
  755. return this.taskCommoditiesListByBinVar;
  756. },
  757. taskCommoditiesListByWall(){
  758. if(!this.task)return [];
  759. let columnLength=this.station.station_type_bin_monitor.bin_column_length,
  760. rowLength=this.station.station_type_bin_monitor.bin_row_length,
  761. wallAmount=this.station.station_type_bin_monitor.bin_wall_amount,
  762. walls=[],
  763. wall,
  764. row;
  765. for(let wI=0;wI<wallAmount;wI++){
  766. wall=[];
  767. for(let rI=0;rI<rowLength;rI++){
  768. row=[];
  769. for(let cI=0;cI<columnLength;cI++){
  770. let number=((wI*rowLength+rI)*columnLength)+cI+1;
  771. let commoditiesInBin={
  772. taskCommodity:this.taskCommoditiesListByBin[number],
  773. number:number,
  774. status:''
  775. };
  776. if(typeof(commoditiesInBin.taskCommodity)==='undefined'
  777. ||!commoditiesInBin.taskCommodity){
  778. commoditiesInBin.taskCommodity={};
  779. }else{
  780. commoditiesInBin.status=commoditiesInBin.taskCommodity['status'];
  781. }
  782. row.push(commoditiesInBin);
  783. }
  784. wall.push(row);
  785. }
  786. walls.push(wall)
  787. }
  788. return walls
  789. },
  790. processedCommodities(){
  791. if(!this.task)return 0;
  792. let processedAmount=0;
  793. this.task['station_task_commodities'].forEach(function (taskCommodity) {
  794. if (taskCommodity.status === '完成') {
  795. processedAmount+=taskCommodity.amount;
  796. }
  797. })
  798. return processedAmount;
  799. },
  800. totalCommodities(){
  801. if(!this.task)return 0;
  802. let amount=0;
  803. this.task['station_task_commodities'].forEach(function (taskCommodity) {
  804. amount+=taskCommodity.amount;
  805. })
  806. return amount;
  807. },
  808. processingTaskMaterialBox(){
  809. if(!this.task)return [];
  810. let taskMaterialBox=null;
  811. this.task.station_task_material_boxes.some(function(taskMaterialBox_in){
  812. if(taskMaterialBox_in.status==='处理中'){
  813. taskMaterialBox=taskMaterialBox_in;
  814. }
  815. });
  816. return taskMaterialBox;
  817. },
  818. },
  819. watch:{
  820. 'station':{
  821. immediate:true,
  822. deep:true,
  823. handler:function(newStation){
  824. let grids={
  825. single:{status:'',amount:'',},
  826. half:{
  827. left:{status:'',amount:'',},
  828. right:{status:'',amount:'',}
  829. },
  830. quarter:{
  831. left:{top:{status:'',amount:'',},bottom:{status:'',amount:'',},},
  832. right:{top:{status:'',amount:'',},bottom:{status:'',amount:'',},},
  833. },
  834. sixth:{
  835. left:{top:{status:'',amount:'',},bottom:{status:'',amount:'',},},
  836. mid:{top:{status:'',amount:'',},bottom:{status:'',amount:'',},},
  837. right:{top:{status:'',amount:'',},bottom:{status:'',amount:'',},},
  838. },
  839. };
  840. if(!newStation.current_station_task||newStation.current_station_task.length===0) {
  841. this.grids=grids;
  842. return;
  843. }
  844. let gridsAmount=(function(){
  845. let taskMaterialBox=null;
  846. newStation.current_station_task.station_task_material_boxes.some(function(taskMaterialBox_in){
  847. if(taskMaterialBox_in.status==='处理中'){
  848. taskMaterialBox=taskMaterialBox_in;
  849. }
  850. });
  851. if(!taskMaterialBox)return 1;
  852. return taskMaterialBox.material_box.grid_amount;
  853. }
  854. )();
  855. let positions=(function(){
  856. let positions=[];
  857. newStation.current_station_task['station_task_commodities'].forEach(function(taskCommodity){
  858. if(taskCommodity.status==='处理中'){
  859. positions.push(taskCommodity.material_box_position)
  860. }
  861. });
  862. return positions;
  863. })();
  864. switch (gridsAmount){
  865. case 1:
  866. if(positions.length>0){
  867. grids.single.status='处理中';
  868. }break;
  869. case 2:
  870. positions.forEach(function(position){
  871. grids.half.left.status = '启用';
  872. grids.half.right.status = '启用';
  873. switch (position){
  874. case 1: grids.half.left.status = '处理中';break;
  875. case 2: grids.half.right.status = '处理中';break;
  876. }
  877. });break;
  878. case 4:
  879. positions.forEach(function(position){
  880. grids.quarter.left.top.status = '启用';
  881. grids.quarter.right.top.status = '启用';
  882. grids.quarter.left.bottom.status = '启用';
  883. grids.quarter.right.bottom.status = '启用';
  884. switch (position){
  885. case 1: grids.quarter.left.top.status = '处理中';break;
  886. case 2: grids.quarter.left.bottom.status = '处理中';break;
  887. case 3: grids.quarter.right.top.status = '处理中';break;
  888. case 4: grids.quarter.right.bottom.status = '处理中';break;
  889. }
  890. });break;
  891. case 6:
  892. positions.forEach(function(position){
  893. grids.sixth.left.top.status = '启用';
  894. grids.sixth.mid.top.status = '启用';
  895. grids.sixth.right.top.status = '启用';
  896. grids.sixth.left.bottom.status = '启用';
  897. grids.sixth.mid.bottom.status = '启用';
  898. grids.sixth.right.bottom.status = '启用';
  899. switch (position){
  900. case 1: grids.sixth.left.top.status = '处理中';break;
  901. case 2: grids.sixth.left.bottom.status = '处理中';break;
  902. case 3: grids.sixth.mid.top.status = '处理中';break;
  903. case 4: grids.sixth.mid.bottom.status = '处理中';break;
  904. case 5: grids.sixth.right.top.status = '处理中';break;
  905. case 6: grids.sixth.right.bottom.status = '处理中';break;
  906. }
  907. });break;
  908. }
  909. this.grids=grids;
  910. }
  911. },
  912. },
  913. filters:{
  914. simplifyBatchCode(val){
  915. if(!val){return ''}
  916. return val.replace(/W\d{6}0*/,'').trim()
  917. }
  918. }
  919. });
  920. </script>
  921. @endsection