cacheRackStorage.blade.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. @extends('layouts.app')
  2. @section('title')缓存架入库-入库管理@endsection
  3. @section('content')
  4. <div class="container-fluid" id="container">
  5. <div class="row">
  6. <div class="card offset-md-1 col-md-5 col-sm-12">
  7. <div class="card-body">
  8. <div class="form-group text-center font-weight-bold h4">
  9. 入库信息
  10. </div>
  11. <div class="form-group row">
  12. <label for="asn" class="col-sm-2 col-3 text-right">ASN号:</label>
  13. <input type="text" class="form-control col-8" :class="errors.asn ? 'is-invalid' : ''" id="asn" v-model="info.asn" @blur="checkAsn()" placeholder="只需填写后几位,自动补充">
  14. <span class="invalid-feedback offset-2" role="alert" v-if="errors.asn">
  15. <strong>@{{ errors.asn[0] }}</strong>
  16. </span>
  17. </div>
  18. <div class="form-group row">
  19. <label for="ide" class="col-sm-2 col-3 text-right">料箱号:</label>
  20. <input type="text" class="form-control col-8" :class="errors.ide ? 'is-invalid' : ''" id="ide" v-model="info.ide" @blur="checkIde()" placeholder="只需填写后几位,自动补充">
  21. <span class="invalid-feedback offset-2" role="alert" v-if="errors.ide">
  22. <strong>@{{ errors.ide[0] }}</strong>
  23. </span>
  24. </div>
  25. <div class="input-group row">
  26. <label for="barCode" class="col-sm-2 col-3 text-right">条码:</label>
  27. <input type="text" class="form-control rounded col-sm-5 col-8 ml-sm-1 ml-2" :class="errors.barCode ? 'is-invalid' : ''" id="barCode" @blur="codeBlur()" @keydown.enter="checkInfo()" v-model="info.barCode">
  28. <div class="input-group-append mt-sm-0 mt-4">
  29. <span class="input-group-text d-none d-sm-block">@数量</span>
  30. <label for="amount" class="d-sm-none col-4 text-right">数量:</label>
  31. <span class="input-group-text p-0 border-0">
  32. <input class="form-control" type="number" :class="errors.amount ? 'is-invalid' : ''" step="1" min="1" id="amount" v-model="info.amount">
  33. </span>
  34. </div>
  35. <span class="invalid-feedback offset-2" role="alert" v-if="errors.barCode">
  36. <strong>@{{ errors.barCode[0] }}</strong>
  37. </span>
  38. </div>
  39. <div class="input-group row mt-5">
  40. <button type="submit" class="btn btn-success offset-2 col-9" @click="checkInfo()">提交</button>
  41. </div>
  42. </div>
  43. </div>
  44. <div class="card col-md-5 col-sm-12">
  45. <div class="card-body">
  46. <div class="mt-1 text-center">
  47. <button class="btn btn-primary" @click="submitBox()">为选中格口手动补充料箱</button>
  48. </div>
  49. <div class="mt-2 h-75">
  50. <table class="table table-sm table-bordered border-dark w-100 h-100 text-center" style="cursor: pointer">
  51. <tr>
  52. <th :class="[shelfOccupy['HAIB1-03-03'] ? 'bg-danger' : 'bg-success',selectedBox['HAIB1-03-03'] ? 'box-shadow-dark' : '']"
  53. @click="fillingBox('HAIB1-03-03')">HAIB1-03-03</th>
  54. <th :class="[shelfOccupy['HAIB1-02-03'] ? 'bg-danger' : 'bg-success',selectedBox['HAIB1-02-03'] ? 'box-shadow-dark' : '']"
  55. @click="fillingBox('HAIB1-02-03')">HAIB1-02-03</th>
  56. <th :class="[shelfOccupy['HAIB1-01-03'] ? 'bg-danger' : 'bg-success',selectedBox['HAIB1-01-03'] ? 'box-shadow-dark' : '']"
  57. @click="fillingBox('HAIB1-01-03')">HAIB1-01-03</th>
  58. </tr>
  59. <tr>
  60. <th :class="[shelfOccupy['HAIB1-03-02'] ? 'bg-danger' : 'bg-success',selectedBox['HAIB1-03-02'] ? 'box-shadow-dark' : '']"
  61. @click="fillingBox('HAIB1-03-02')">HAIB1-03-02</th>
  62. <th :class="[shelfOccupy['HAIB1-02-02'] ? 'bg-danger' : 'bg-success',selectedBox['HAIB1-02-02'] ? 'box-shadow-dark' : '']"
  63. @click="fillingBox('HAIB1-02-02')">HAIB1-02-02</th>
  64. <th :class="[shelfOccupy['HAIB1-01-02'] ? 'bg-danger' : 'bg-success',selectedBox['HAIB1-01-02'] ? 'box-shadow-dark' : '']"
  65. @click="fillingBox('HAIB1-01-02')">HAIB1-01-02</th>
  66. </tr>
  67. <tr>
  68. <th :class="[shelfOccupy['HAIB1-03-01'] ? 'bg-danger' : 'bg-success',selectedBox['HAIB1-03-01'] ? 'box-shadow-dark' : '']"
  69. @click="fillingBox('HAIB1-03-01')">HAIB1-03-01</th>
  70. <th :class="[shelfOccupy['HAIB1-02-01'] ? 'bg-danger' : 'bg-success',selectedBox['HAIB1-02-01'] ? 'box-shadow-dark' : '']"
  71. @click="fillingBox('HAIB1-02-01')">HAIB1-02-01</th>
  72. <th :class="[shelfOccupy['HAIB1-01-01'] ? 'bg-danger' : 'bg-success',selectedBox['HAIB1-01-01'] ? 'box-shadow-dark' : '']"
  73. @click="fillingBox('HAIB1-01-01')">HAIB1-01-01</th>
  74. </tr>
  75. </table>
  76. </div>
  77. </div>
  78. </div>
  79. </div>
  80. </div>
  81. @stop
  82. @section('lastScript')
  83. <script type="text/javascript">
  84. new Vue({
  85. el:"#container",
  86. data:{
  87. permissionList:[ //允许聚焦许可列表
  88. "asn","ide","amount"
  89. ],
  90. info:{},
  91. mount:false,
  92. before:{
  93. asn:"",
  94. ide:"",
  95. },
  96. errors:{},
  97. shelfOccupy:{},
  98. selectedBox:{},
  99. },
  100. mounted(){
  101. @foreach($storages as $storage)this.$set(this.shelfOccupy,"{{$storage->station->code}}",true);@endforeach
  102. this.codeFocus();
  103. this.globalClick();
  104. this.createBefore();
  105. },
  106. methods:{
  107. //选中填充料箱
  108. fillingBox(ideCode){
  109. this.$set(this.selectedBox,ideCode,this.selectedBox[ideCode] ? !this.selectedBox[ideCode] : true);
  110. },
  111. //提交填充料箱
  112. submitBox(){
  113. window.tempTip.setDuration(3000);
  114. if (JSON.stringify(this.selectedBox)==='{}'){window.tempTip.show("未选中格口");return;}
  115. window.tempTip.confirm("确定选中格口已无料箱存在?",()=>{
  116. let boxes = [];
  117. for (let key in this.selectedBox)if (this.selectedBox[key]) boxes.push(key);
  118. window.tempTip.postBasicRequest("{{url('store/inStorage/resetCacheShelf')}}",{boxes:boxes},res=>{
  119. for (let i=0;i<res.boxes.length;i++){
  120. this.$set(this.shelfOccupy,res.boxes[i],true);
  121. this.$set(this.selectedBox,res.boxes[i],true);
  122. }
  123. if (res.data){
  124. window.tempTip.show(res.data);
  125. return;
  126. }
  127. return "手动补充成功";
  128. },true);
  129. })
  130. },
  131. //聚焦 白名单
  132. codeFocus(){
  133. if (!this.permissionList.includes(document.activeElement.id)) document.getElementById("barCode").focus();
  134. },
  135. //全局点击聚焦
  136. globalClick(turn = true){
  137. if (turn===this.mount)return;
  138. this.mount = turn;//防止重复挂载事件
  139. if (turn) window.addEventListener("click",this.codeFocus);
  140. else window.removeEventListener("click",this.codeFocus);
  141. },
  142. codeBlur(){
  143. if (this.info.asn && this.info.ide && !this.info.amount){
  144. this.globalClick(false);
  145. window.tempTip.inputVal('请输入数量:',(amount)=>{
  146. this.$set(this.info,'amount',amount);
  147. if (this.info.asn && this.info.ide && this.info.barCode && this.info.amount)this.checkInfo();
  148. this.globalClick();
  149. });
  150. }
  151. },
  152. checkInfo(){
  153. let error = {};
  154. if (!this.info.asn)error.asn = ["ASN号必填"];
  155. if (this.info.asn && this.info.asn.length!==13)error.asn = ["非法ASN号"];
  156. if (!this.info.ide)error.ide = ["料箱号必填"];
  157. if (this.info.ide && this.info.ide.length!==10)error.ide = ["非法料箱号"];
  158. if (!this.info.barCode)error.barCode = ["商品条码必填"];
  159. if (!this.info.amount)error.amount = ["数量必填"];
  160. if (JSON.stringify(error)!=='{}'){this.errors = error;return;}
  161. this._exeTask();
  162. },
  163. _exeTask(){
  164. window.tempTip.postBasicRequest("{{url('store/inStorage/putShelf')}}",this.info,res=>{
  165. if (!res.maximum){
  166. window.tempTip.inputVal('商品首入,请输入预估最大可放入数:',(maximum)=>{
  167. res.maximum = maximum;
  168. window.tempTip.postBasicRequest("{{url('store/inStorage/setMaximum')}}",res,()=>{});
  169. });
  170. }
  171. this.info = {};
  172. this.errors = {};
  173. return "缓存架上架成功!";
  174. });
  175. },
  176. createBefore(){
  177. let now = new Date();
  178. let yy = now.getFullYear().toString().substr(2, 2);
  179. let mm = now.getMonth() + 1;
  180. mm = mm <10 ? '0'+mm : mm.toString();
  181. let dd = now.getDate();
  182. dd = dd <10 ? '0'+dd : dd.toString();
  183. this.before.asn = 'ASN'+yy+mm+dd+'000';
  184. this.before.ide = 'IDE000000';
  185. },
  186. checkAsn(){
  187. if(!this.info.asn)return;
  188. let len = this.info.asn.length;
  189. if (len<13)this.info.asn = this.before.asn.substr(0,13-len)+this.info.asn;
  190. if (!this.info.ide)document.getElementById("ide").focus();
  191. },
  192. checkIde(){
  193. if(!this.info.ide)return;
  194. let len = this.info.ide.length;
  195. if (len<10)this.info.ide = this.before.ide.substr(0,10-len)+this.info.ide;
  196. }
  197. },
  198. });
  199. </script>
  200. @stop