cacheRackStorage.blade.php 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. @extends('layouts.app')
  2. @section('title')缓存架入库-入库管理@endsection
  3. @section('content')
  4. <span id="nav2">
  5. @component('store.menu')@endcomponent
  6. @component('store.inStorage.menu')@endcomponent
  7. </span>
  8. <div class="container-fluid" id="container">
  9. <div class="row">
  10. <div class="card offset-md-3 col-md-6 col-sm-12">
  11. <div class="card-body">
  12. <div class="form-group text-center font-weight-bold h4">
  13. 入库信息
  14. </div>
  15. <div class="form-group row">
  16. <label for="asn" class="col-sm-2 col-3 text-right">ASN号:</label>
  17. <input type="text" class="form-control col-8" :class="errors.asn ? 'is-invalid' : ''" id="asn" v-model="info.asn" @blur="checkAsn()" placeholder="只需填写后几位,自动补充">
  18. <span class="invalid-feedback offset-2" role="alert" v-if="errors.asn">
  19. <strong>@{{ errors.asn[0] }}</strong>
  20. </span>
  21. </div>
  22. <div class="form-group row">
  23. <label for="ide" class="col-sm-2 col-3 text-right">料箱号:</label>
  24. <input type="text" class="form-control col-8" :class="errors.ide ? 'is-invalid' : ''" id="ide" v-model="info.ide" @blur="checkIde()" placeholder="只需填写后几位,自动补充">
  25. <span class="invalid-feedback offset-2" role="alert" v-if="errors.ide">
  26. <strong>@{{ errors.ide[0] }}</strong>
  27. </span>
  28. </div>
  29. <div class="input-group row">
  30. <label for="barCode" class="col-sm-2 col-3 text-right">条码:</label>
  31. <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">
  32. <div class="input-group-append mt-sm-0 mt-4">
  33. <span class="input-group-text d-none d-sm-block">@数量</span>
  34. <label class="d-sm-none col-4 text-right">数量:</label>
  35. <span class="input-group-text p-0 border-0">
  36. <input class="form-control" type="number" :class="errors.amount ? 'is-invalid' : ''" step="1" min="1" id="amount" v-model="info.amount">
  37. </span>
  38. </div>
  39. <span class="invalid-feedback offset-2" role="alert" v-if="errors.barCode">
  40. <strong>@{{ errors.barCode[0] }}</strong>
  41. </span>
  42. </div>
  43. <div class="input-group row mt-5">
  44. <button type="submit" class="btn btn-success offset-2 col-9" @click="checkInfo()">提交</button>
  45. </div>
  46. </div>
  47. </div>
  48. </div>
  49. </div>
  50. @stop
  51. @section('lastScript')
  52. <script type="text/javascript">
  53. new Vue({
  54. el:"#container",
  55. data:{
  56. permissionList:[ //允许聚焦许可列表
  57. "asn","ide","amount"
  58. ],
  59. info:{},
  60. mount:false,
  61. before:{
  62. asn:"",
  63. ide:"",
  64. },
  65. errors:{},
  66. },
  67. mounted(){
  68. this.codeFocus();
  69. this.globalClick();
  70. this.createBefore();
  71. },
  72. methods:{
  73. //聚焦 白名单
  74. codeFocus(){
  75. if (!this.permissionList.includes(document.activeElement.id)) document.getElementById("barCode").focus();
  76. },
  77. //全局点击聚焦
  78. globalClick(turn = true){
  79. if (turn===this.mount)return;
  80. this.mount = turn;//防止重复挂载事件
  81. if (turn) window.addEventListener("click",this.codeFocus);
  82. else window.removeEventListener("click",this.codeFocus);
  83. },
  84. codeBlur(){
  85. if (this.info.asn && this.info.ide && !this.info.amount){
  86. this.globalClick(false);
  87. window.tempTip.inputVal('请输入数量:',(amount)=>{
  88. this.info.amount = amount;
  89. if (this.info.asn && this.info.ide && this.info.barCode && this.info.amount)this.checkInfo();
  90. this.globalClick();
  91. });
  92. }
  93. },
  94. checkInfo(){
  95. let error = {};
  96. if (!this.info.asn)error.asn = ["ASN号必填"];
  97. if (this.info.asn && this.info.asn.length!==13)error.asn = ["非法ASN号"];
  98. if (!this.info.ide)error.ide = ["料箱号必填"];
  99. if (this.info.ide && this.info.ide.length!==10)error.ide = ["非法料箱号"];
  100. if (!this.info.barCode)error.barCode = ["商品条码必填"];
  101. if (!this.info.amount)error.amount = ["数量必填"];
  102. if (JSON.stringify(error)!=='{}'){this.errors = error;return;}
  103. this._exeTask();
  104. },
  105. _exeTask(){
  106. console.log("ok");
  107. //入库成功
  108. this.info = {};
  109. this.errors = {};
  110. },
  111. createBefore(){
  112. let now = new Date();
  113. let yy = now.getFullYear().toString().substr(2, 2);
  114. let mm = now.getMonth() + 1;
  115. mm = mm <10 ? '0'+mm : mm.toString();
  116. let dd = now.getDate();
  117. dd = dd <10 ? '0'+dd : dd.toString();
  118. this.before.asn = 'ASN'+yy+mm+dd+'000';
  119. this.before.ide = 'IDE000000';
  120. },
  121. checkAsn(){
  122. if(!this.info.asn)return;
  123. let len = this.info.asn.length;
  124. if (len<13)this.info.asn = this.before.asn.substr(0,13-len)+this.info.asn;
  125. if (!this.info.ide)document.getElementById("ide").focus();
  126. },
  127. checkIde(){
  128. if(!this.info.ide)return;
  129. let len = this.info.ide.length;
  130. if (len<10)this.info.ide = this.before.ide.substr(0,10-len)+this.info.ide;
  131. }
  132. },
  133. });
  134. </script>
  135. @stop