halfChestStorage.blade.php 12 KB

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