halfChestStorage.blade.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. @extends('layouts.app')
  2. @section('title')缓存架入库-半箱入库@endsection
  3. @section('content')
  4. <div class="container-fluid d-none" id="container">
  5. <div class="row">
  6. <div class="card offset-md-3 col-md-6 col-sm-12">
  7. <div class="card-body">
  8. <div class="form-group text-center mt-2" id="header_title">
  9. <span class="font-weight-bold h4">入库信息</span>
  10. <a class="small" href="#" @click="openModal()">溢出减量</a>
  11. </div>
  12. <div class="form-group row">
  13. <label for="asn" class="col-sm-2 col-3 text-right">ASN号:</label>
  14. <div tabindex="0" @focus="()=>{this.focus='asn'}" @keydown="enterVal($event,'asn')" class="form-control col-8 overflow-hidden"
  15. :contenteditable="!isOnlyKeyboardEnter" :class="errors.asn ? 'is-invalid' : ''"
  16. id="asn" @blur="checkAsn($event,'asn')"><span>@{{ info.asn ? info.asn : (focus=='asn' ? '' : '只需填写后几位,自动补充') }}</span></div>
  17. <span class="invalid-feedback offset-2" role="alert" v-if="errors.asn">
  18. <strong>@{{ errors.asn[0] }}</strong>
  19. </span>
  20. </div>
  21. <div class="form-group row">
  22. <label for="station" class="col-sm-2 col-3 text-right">库位:</label>
  23. <div tabindex="0" @focus="()=>{this.focus='station'}" @keydown="enterVal($event,'station')" class="form-control col-8 overflow-hidden"
  24. :contenteditable="!isOnlyKeyboardEnter" :class="errors.station ? 'is-invalid' : ''"
  25. id="station" @blur="checkMaximum($event,'station')"><span>@{{ info.station ? info.station : (focus=='station' ? '' : '扫描货架条码') }}</span></div>
  26. <span class="invalid-feedback offset-2" role="alert" v-if="errors.station">
  27. <strong>@{{ errors.station[0] }}</strong>
  28. </span>
  29. </div>
  30. <div class="form-group row">
  31. <label for="barCode" class="col-sm-2 col-3 text-right">条码:</label>
  32. <div tabindex="0" @focus="()=>{this.focus='barCode'}" @keydown="enterVal($event,'barCode')" class="form-control col-8 overflow-hidden"
  33. :contenteditable="!isOnlyKeyboardEnter" :class="errors.barCode ? 'is-invalid' : ''"
  34. id="barCode" @blur="checkMaximum($event,'barCode')"><span>@{{ info.barCode ? info.barCode : (focus=='barCode' ? '' : '扫描商品条码') }}</span></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="form-group row">
  40. <label for="amount" class="col-sm-2 col-3 text-right">数量:</label>
  41. <div tabindex="0" @focus="()=>{this.focus='amount'}" @keydown="enterVal($event,'amount')" class="form-control col-8 overflow-hidden"
  42. :contenteditable="!isOnlyKeyboardEnter" :class="errors.amount ? 'is-invalid' : ''"
  43. id="amount" @blur="checkMaximum($event,'amount')"><span>@{{ info.amount ? info.amount : (focus=='amount' ? '' : (info.maximum!==undefined ? '最大可上:'+info.maximum : '')) }}</span></div>
  44. <span class="invalid-feedback offset-2" role="alert" v-if="errors.amount">
  45. <strong>@{{ errors.amount[0] }}</strong>
  46. </span>
  47. </div>
  48. <div class="input-group row mt-5">
  49. <button type="submit" class="btn btn-success offset-2 col-8" @click="checkInfo()">提交</button>
  50. </div>
  51. <div class="row offset-2 col-8">
  52. <div class="custom-control custom-checkbox mt-2 d-sm-none">
  53. <input type="checkbox" class="custom-control-input" id="customCheck" v-model="isOnlyKeyboardEnter">
  54. <label class="custom-control-label" for="customCheck">隐藏虚拟键盘</label>
  55. </div>
  56. </div>
  57. </div>
  58. </div>
  59. <div class="modal fade" tabindex="-1" role="dialog" id="modal">
  60. <div class="modal-dialog modal-lg modal-dialog-centered modal-dialog-scrollable">
  61. <div class="modal-content">
  62. <div class="modal-header">
  63. <div class="font-weight-bold h4">溢出减量</div>
  64. <button type="button" class="close" data-dismiss="modal">&times;</button>
  65. </div>
  66. <div class="modal-body">
  67. <div class="form-group">
  68. <label for="location">库位码</label>
  69. <input id="location" type="text" v-model="ov.station" class="form-control" placeholder="库位码">
  70. </div>
  71. <div class="form-group">
  72. <label for="ov_amount">溢出数量</label>
  73. <input id="ov_amount" type="number" v-model="ov.amount" min="1" step="1" class="form-control" placeholder="溢出数量">
  74. </div>
  75. </div>
  76. <div class="modal-footer">
  77. <button type="button" class="btn btn-success" @click="overflowRevision()">提交</button>
  78. </div>
  79. </div>
  80. </div>
  81. </div>
  82. </div>
  83. </div>
  84. @stop
  85. @section('lastScript')
  86. <script type="text/javascript">
  87. new Vue({
  88. el:"#container",
  89. data:{
  90. permissionList:[ //允许聚焦许可列表
  91. "asn","station","amount","location","ov_amount"
  92. ],
  93. info:{},
  94. mount:false,
  95. before:{
  96. asn:"",
  97. },
  98. focus:"",
  99. errors:{},
  100. ov:{},//溢出减量数值
  101. checkSign:false,
  102. isAndroid:true,
  103. isOnlyKeyboardEnter:true,
  104. },
  105. mounted(){
  106. //this.codeFocus();
  107. //this.globalClick();
  108. this.createBefore();
  109. this.pageInit();
  110. $("#container").removeClass("d-none");
  111. },
  112. methods:{
  113. //页面初始化
  114. pageInit(){
  115. if (!this.isAndroid)return;
  116. let element = document.getElementById("navbarSupportedContent").parentElement;
  117. element.className = "row";
  118. element.children[0].className += " col-5";
  119. element.innerHTML = element.children[0].outerHTML;
  120. let e1 = document.getElementById("menu");
  121. let e2 = document.getElementById("demand-div");
  122. if (e1)e1.remove();
  123. if (e2)e2.remove();
  124. },
  125. //提交溢出减量
  126. overflowRevision(){
  127. if (!this.ov.station || !this.ov.amount){
  128. window.tempTip.show("信息不完整");
  129. return;
  130. }
  131. window.tempTip.postBasicRequest("{{url('store/inStorage/overflowRevision')}}",this.ov,()=>{
  132. $("#modal").modal('hide');
  133. this.ov = {};
  134. return "溢出减量成功!";
  135. });
  136. },
  137. //打开溢出减量模态框
  138. openModal(){
  139. $("#modal").modal("show");
  140. setTimeout(function () {
  141. document.getElementById("location").focus();
  142. },500);
  143. },
  144. //聚焦 白名单
  145. codeFocus(){
  146. if (!this.permissionList.includes(document.activeElement.id)) document.getElementById("barCode").focus();
  147. },
  148. //全局点击聚焦
  149. globalClick(turn = true){
  150. if (turn===this.mount)return;
  151. this.mount = turn;//防止重复挂载事件
  152. if (turn) window.addEventListener("click",this.codeFocus);
  153. else window.removeEventListener("click",this.codeFocus);
  154. },
  155. checkInfo(){
  156. let error = {};
  157. if (!this.info.asn)error.asn = ["ASN号必填"];
  158. if (this.info.asn && this.info.asn.length!==13)error.asn = ["非法ASN号"];
  159. if (!this.info.barCode)error.barCode = ["商品条码必填"];
  160. if (!this.info.station)error.station = ["库位必填"];
  161. if (!this.info.amount && !this.info.maximum)error.amount = ["数量必填"];
  162. if (JSON.stringify(error)!=='{}'){this.errors = error;return;}
  163. if (!this.info.amount && this.info.maximum)this.info.amount = this.info.maximum;
  164. this._exeTask();
  165. },
  166. _exeTask(){
  167. window.tempTip.postBasicRequest("{{url('store/inStorage/acquireBox')}}",this.info,()=>{
  168. this.info = {};
  169. this.errors = {};
  170. return "上架成功!";
  171. });
  172. },
  173. createBefore(){
  174. let now = new Date();
  175. let yy = now.getFullYear().toString().substr(2, 2);
  176. let mm = now.getMonth() + 1;
  177. mm = mm <10 ? '0'+mm : mm.toString();
  178. let dd = now.getDate();
  179. dd = dd <10 ? '0'+dd : dd.toString();
  180. this.before.asn = 'ASN'+yy+mm+dd+'000';
  181. },
  182. changeInfo(e,type){
  183. if (this.isOnlyKeyboardEnter || !type)return;
  184. let str = e.target.innerText;
  185. if (e.target.firstChild.nodeType===3)e.target.firstChild.remove();
  186. this.$set(this.info,type,str);
  187. },
  188. checkAsn(e,type){
  189. this.changeInfo(e,type);
  190. this.focus = "";
  191. if(!this.info.asn)return;
  192. let len = this.info.asn.length;
  193. if (len<13)this.info.asn = this.before.asn.substr(0,13-len)+this.info.asn;
  194. if (!this.checkSign)this.checkMaximum(e,'');
  195. },
  196. downSign(){
  197. this.checkSign = false;
  198. },
  199. checkMaximum(e,type){
  200. this.changeInfo(e,type);
  201. this.focus = "";
  202. if (!this.info.asn || !this.info.barCode || this.checkSign)return;
  203. window.tempTip.postBasicRequest("{{url('store/inStorage/checkMaximum')}}",this.info,res=>{
  204. this.info.maximum = res.maximum;
  205. this.info.material_box_id = res.material_box_id;
  206. this.info.material_box_model_id = res.material_box_model_id;
  207. this.info.commodity_id = res.commodity_id;
  208. if(!this.info.amount)this.info.amount = res.maximum;
  209. return "该库位最大可上数为"+res.maximum;
  210. });
  211. this.checkSign = true;
  212. },
  213. enterVal(e,type){
  214. if (!this.isOnlyKeyboardEnter)return;
  215. if (e.keyCode === 8 && this.info[type]){this.$set(this.info,type,this.info[type].slice(0,-1));return;}
  216. if (e.key.length>1)return;
  217. if (e.key.match(/[a-zA-Z0-9\-]/g)===null)return;
  218. if (type === 'amount'){
  219. if (e.key.match(/[0-9]/g)===null)return;
  220. if (this.info.maximum && Number((this.info[type] ? this.info[type] : '0')+e.key)>this.info.maximum) return;
  221. }
  222. if (this.info[type])this.$set(this.info,type,this.info[type] += e.key);
  223. else this.$set(this.info,type,e.key);
  224. this.downSign();
  225. }
  226. },
  227. });
  228. </script>
  229. @stop