putaway.blade.php 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. @extends('layouts.app')
  2. @section('title')手持入库-上架@endsection
  3. @section('content')
  4. <div class="d-none" id="container">
  5. <div class="card offset-md-3 col-md-6">
  6. <div class="card-header text-center mt-2 bg-transparent" id="header_title">
  7. <span class="font-weight-bold h4">上架</span>
  8. </div>
  9. <div class="card-body">
  10. <div class="form-group row m-1">
  11. <span class="text-right">
  12. <label for="trackNumber" class="text-right font-weight-bold">容器号:</label>
  13. </span>
  14. <input type="text" class="form-control form-control-sm col-8" id="trackNumber" autocomplete="off"
  15. :class="errors.trackNumber ? 'is-invalid' : ''" @keydown.enter="enterVal($event)"
  16. v-model="info.trackNumber">
  17. <span class="invalid-feedback offset-3" role="alert" v-if="errors.trackNumber">
  18. <strong>@{{ errors.trackNumber[0] }}</strong>
  19. </span>
  20. </div>
  21. <div class="form-group row m-1">
  22. <span class="text-right">
  23. <label for="barCode" class="text-right font-weight-bold">商品条码:</label>
  24. </span>
  25. <input type="text" class="form-control form-control-sm col-8" id="barCode" autocomplete="off"
  26. :class="errors.barCode ? 'is-invalid' : ''" @keydown.enter="enterVal($event)"
  27. v-model="info.barCode" @blur="getTsk()">
  28. <span class="invalid-feedback offset-3" role="alert" v-if="errors.barCode">
  29. <strong>@{{ errors.barCode[0] }}</strong>
  30. </span>
  31. </div>
  32. <div class="card border-bottom-0">
  33. <div class="card-body">
  34. <div class="form-group row m-1">
  35. <label for="name" class="text-right">商品品名:</label>
  36. <span id="name">@{{ info.name }}</span>
  37. </div>
  38. <div class="form-group row m-1">
  39. <label for="amount" class="text-right">上架总数:</label>
  40. <input type="text" class="form-control form-control-sm col-4" style="width: 10px"
  41. id="amount" autocomplete="off"
  42. :class="errors.amount ? 'is-invalid' : ''"
  43. @keydown.enter="enterVal($event)" v-model="info.amount"><span id="paTotal"
  44. v-if="info.paTotal">&nbsp;&nbsp;/&nbsp;&nbsp;@{{ info.paTotal }}</span>
  45. <span class="invalid-feedback offset-3" role="alert" v-if="errors.amount">
  46. <strong>@{{ errors.amount[0] }}</strong>
  47. </span>
  48. </div>
  49. <div class="form-group row m-1">
  50. <label for="location" class="text-right">目标库位:</label>
  51. <input type="text" class="form-control form-control-sm col-8" id="location"
  52. autocomplete="off"
  53. :class="errors.location ? 'is-invalid' : ''"
  54. @keydown.enter="enterVal($event)" v-model="info.location">
  55. <span class="invalid-feedback offset-3" role="alert" v-if="errors.location">
  56. <strong>@{{ errors.location[0] }}</strong>
  57. </span>
  58. </div>
  59. </div>
  60. </div>
  61. <div style="overflow: auto;overflow-x: hidden" id="cardTable" v-if="tasks.length>0">
  62. <table class="table-sm table-striped table-bordered table-hover mb-3"
  63. style="background: rgb(255, 255, 255);">
  64. <tr v-for="(task,i) in tasks">
  65. <td style="filter:grayscale(30%);">
  66. <div>
  67. <div style="transform:scale(1)" class="pl-0">
  68. <span><span class="text-black">货主:</span><span
  69. class="text-black font-weight-bold">@{{ task.customerid }}</span></span>
  70. <span><span class="text-black">批次:</span><span
  71. class="text-danger">@{{ task.plantolotnum }}</span></span>
  72. <span class="text-right float-right">选中:<input type="checkbox" :id="'task_'+i"
  73. @click="checked($event,task)"></span>
  74. <br>
  75. <span><span>容器号:</span><span class="">@{{ task.plantoid }} </span></span>
  76. <span><span class="text-lowercase">数量:</span><span
  77. class="text-lowercase">@{{ task.qty }} </span></span>
  78. <span>&nbsp;&nbsp;&nbsp;&nbsp;</span>
  79. <span><span class="text-black">商品名:</span><span class="text-black">@{{ task.skudescrc }}</span></span>
  80. </div>
  81. </div>
  82. </td>
  83. </tr>
  84. </table>
  85. </div>
  86. <div class="card-footer bg-transparent">
  87. <button type="button" id="confirm" class="btn btn-md btn-outline-success float-right"
  88. @click="ensure()">确定
  89. </button>
  90. <button type="button" id="cancel" class="btn btn-md btn-outline-info float-left" @click="cancel()">
  91. 取消
  92. </button>
  93. </div>
  94. </div>
  95. </div>
  96. @stop
  97. @section('lastScript')
  98. <script type="text/javascript">
  99. new Vue({
  100. el: "#container",
  101. data: {
  102. height: 0,//屏幕高度
  103. info: {},
  104. errors: {},
  105. tasks: [],
  106. checkData: [],
  107. selectTr: '',
  108. isAndroid: false,
  109. element: [
  110. "trackNumber","barCode", "amount", "location",
  111. ],
  112. },
  113. mounted() {
  114. if (navigator.userAgent.indexOf("Android") !== -1) this.isAndroid = true;
  115. this.pageInit();
  116. $("#container").removeClass("d-none");
  117. document.getElementById("trackNumber").focus();
  118. },
  119. methods: {
  120. //页面初始化
  121. pageInit() {
  122. if (!this.isAndroid) return;
  123. let element = document.getElementById("navbarSupportedContent").parentElement;
  124. element.className = "row";
  125. element.children[0].className += " col-5";
  126. element.innerHTML = element.children[0].outerHTML;
  127. let e1 = document.getElementById("menu");
  128. let e2 = document.getElementById("demand-div");
  129. if (e1) e1.remove();
  130. if (e2) e2.remove();
  131. },
  132. checked(e, task, element = undefined) {
  133. if (!element)element = e.target;
  134. let _this = this;
  135. if (element.checked) {
  136. if (_this.checkData.length === 0) {
  137. _this.checkData.push(task);
  138. _this.fillInfo(task);
  139. } else if (_this.checkData.length > 0) {
  140. this.checkData.some(function (item, i) {
  141. if (item.customerid == task.customerid
  142. && item.plantolotnum == task.plantolotnum
  143. && item.sku == task.sku) {
  144. _this.checkData.push(task)
  145. _this.fillInfo(task);
  146. return true;
  147. } else {
  148. $('#'+element.id).prop('checked', false);
  149. window.tempTip.setDuration(3000);
  150. window.tempTip.show('货主,批次不同,不可同时上架');
  151. }
  152. });
  153. }
  154. }else {
  155. _this.checkData.some(function (item, i) {
  156. if (item.taskid == task.taskid
  157. && item.taskid_sequence == task.taskid_sequence) {
  158. _this.checkData.splice(i, 1);
  159. _this.updateInfo(task);
  160. return true;
  161. }
  162. });
  163. }
  164. _this.$forceUpdate();
  165. },
  166. fillInfo(task){
  167. this.info.name=task.skudescrc;
  168. if (this.info.paTotal==''||this.info.paTotal==null||this.info.paTotal==undefined){this.info.paTotal=0;}
  169. this.info.paTotal+=Number(task.qty);
  170. // this.info.location=task.plantolocation;
  171. },
  172. updateInfo(task){
  173. this.info.name=task.skudescrc;
  174. this.info.paTotal-=Number(task.qty);
  175. // this.info.location=task.plantolocation;
  176. },
  177. getTsk() {
  178. let _this=this;
  179. _this.clearChecked();
  180. if (!this.info.barCode)return;
  181. let url = '{{url('store/handInStorage/getTsk')}}';
  182. window.axios.post(url, {trackNumber:this.info.trackNumber,barCode: this.info.barCode})
  183. .then(res => {
  184. if (res.data.success) {
  185. this.tasks = res.data.data;
  186. this.$forceUpdate();
  187. setTimeout(function () {
  188. document.getElementById("task_0").checked=true;
  189. let element={};
  190. element.checked=true;
  191. _this.checked(1,_this.tasks[0],element)
  192. }, 100);
  193. return;
  194. }
  195. window.tempTip.setDuration(3000);
  196. window.tempTip.show(res.data.data);
  197. }).catch(err => {
  198. window.tempTip.setDuration(3000);
  199. window.tempTip.show("网络错误:" + err);
  200. })
  201. },
  202. clearChecked(){
  203. this.checkData=[];
  204. this.info.paTotal=0;//设置上架总数
  205. $('input[type=checkbox]').each(function() {
  206. let self = $(this);
  207. self.prop('checked', false);
  208. });
  209. },
  210. ensure() {
  211. this.errors={};//初始errors状态
  212. this.verifyInfoAndCheckData();
  213. let url = '{{url('store/handInStorage/handFluxPa')}}';
  214. if (JSON.stringify(this.errors)==='{}') window.axios.post(url,{info:this.info,checkData:this.checkData})
  215. .then(res=>{
  216. if (res.data.success){
  217. window.tempTip.setDuration(3000);
  218. window.tempTip.showSuccess(res.data.data);
  219. this.info={};
  220. this.checkData=[];
  221. this.tasks=[];
  222. this.$forceUpdate()
  223. document.getElementById("trackNumber").focus();
  224. return;
  225. }
  226. window.tempTip.setDuration(3000);
  227. window.tempTip.show(res.data.data);
  228. }).catch(err=>{
  229. window.tempTip.setDuration(3000);
  230. window.tempTip.show("网络错误:"+err);
  231. })
  232. },
  233. cancel() {
  234. setTimeout(function () {
  235. window.location.reload();
  236. document.getElementById("trackNumber").focus();
  237. }, 100);
  238. },
  239. enterVal(e) {
  240. let index = this.element.indexOf(e.target.id) + 1;
  241. let element = document.getElementById(this.element[index]);
  242. if (element) element.focus();
  243. e.preventDefault();
  244. return false;
  245. },
  246. verifyInfoAndCheckData(){
  247. let error = {};
  248. if (!this.info.trackNumber) error.trackNumber = ["容器号必填"];
  249. if (!this.info.barCode) error.barCode = ["条码必填"];
  250. if (!this.info.amount) error.amount = ["上架数量必填"];
  251. if (Number(this.info.paTotal)!==0 && Number(this.info.amount)>Number(this.info.paTotal)) error.amount = ["上架数量不能超过上架总数必填"];
  252. if (!this.info.location) error.location = ["目标库位必填"];
  253. if (JSON.stringify(error) !== '{}') {this.errors = error;return;}
  254. },
  255. },
  256. });
  257. </script>
  258. @stop