halfChestStorage.blade.php 11 KB

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