inventoryMission.blade.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. @extends('layouts.app')
  2. @section('title')盘点-任务-{!! $inventory->id !!}@endsection
  3. @section('content')
  4. @component('inventory.stockInventory.menu')
  5. <li class="nav-item">
  6. <a class="nav-link" href="{{URL::current()}}" :class="{active:isActive('enterStockInventory',3)}">盘点中({!! $inventory->id !!})</a>
  7. </li>
  8. @endcomponent
  9. <div id="list" class="container-fluid" style="min-width: 1500px">
  10. <div class="mt-3 pl-5">
  11. <span class="form-group pl-5 shadow-sm p-2 mb-5 bg-white rounded">
  12. <label class="col-1 font-weight-bold">货主:</label><span>@{{ inventory.owner.name }}</span>
  13. </span>
  14. <span class="form-group pl-5 shadow-sm p-2 mb-5 bg-white rounded">
  15. <label class="col-1 font-weight-bold">盘点单号:</label><span>@{{ inventory.id }}</span>
  16. </span>
  17. </div>
  18. <div class="mt-3 pl-5">
  19. <span class="form-group pl-5 shadow-sm p-2 mb-5 bg-white rounded">
  20. <label class="col-1 font-weight-bold">时间范围:</label><span>@{{ inventory.start_at }}——@{{ inventory.end_at }}</span>
  21. </span>
  22. <span class="form-group pl-5 shadow-sm p-2 mb-5 bg-white rounded" v-if="inventory.surplus!=0">
  23. <label class="col-1 font-weight-bold">已盘点:</label><span>@{{ inventory.processed }}/总数:@{{ inventory.total }}</span>
  24. </span>
  25. <span class="form-group pl-5 shadow-sm p-2 mb-5 bg-white rounded" v-if="inventory.surplus!=0">
  26. <label class="col-1 font-weight-bold">剩余数:</label><span>@{{ inventory.surplus }}</span>
  27. </span>
  28. <span class="form-group pl-5 shadow-sm p-2 mb-5 bg-white rounded" v-if="inventory.surplus==0">
  29. <label class="col-1 font-weight-bold">盘点记录数:</label><span>@{{ inventory.total }}</span>
  30. </span>
  31. <span class="form-group pl-5 shadow-sm p-2 mb-5 bg-white rounded" v-if="inventory.surplus==0">
  32. <label class="col-1 font-weight-bold">复盘剩余数:</label><span>@{{ inventory.check_surplus }}/复盘总数:@{{ inventory.total }}</span>
  33. </span>
  34. </div>
  35. <div class="mt-4 ml-5" >
  36. <span class="btn col-1 font-weight-bold" style="cursor: default" :class="inventory.surplus!=0?'bg-info':'btn-outline-info disabled'">
  37. @{{ inventory.type }}
  38. </span>
  39. <span class="btn col-1 font-weight-bold" style="cursor: default" :class="inventory.surplus!=0?'btn-outline-info disabled':'bg-info'">复盘</span>
  40. </div>
  41. <form id="form" class="mt-3 pl-5">
  42. <div class="row" :class="inventory.surplus!=0?'row-cols-3':'row-cols-5'">
  43. <span>
  44. <label for="location" class="text-secondary font-weight-bold">请输入库位</label>
  45. <input id="inventoryInput" name="location" type="text" class="form-control col-6 input" autocomplete="off" value="@if(old('location')){{old('location')}}@endif">
  46. </span>
  47. <span>
  48. <label for="barcode" class="text-secondary font-weight-bold">请输入产品条码</label>
  49. <input id="barcode" name="barcode" type="text" value="@if(old('barcode')){{old('barcode')}}@endif" class="form-control col-6 input" autocomplete="off" @blur="searchBarcode">
  50. </span>
  51. <span>
  52. <label for="count" class="text-secondary font-weight-bold">请输入盘点数</label>
  53. <input type="text" id="count" name="count" class="form-control col-6 input" value="@if(old('count')){{old('count')}}@endif" autocomplete="off">
  54. </span>
  55. <span v-if="inventory.surplus==0">
  56. <label for="count" class="text-secondary font-weight-bold">上一次盘点数</label>
  57. <span v-if="!inventoryMissionRecord.re_checked_amount">
  58. <input type="text" id="count" name="count" v-model="inventoryMissionRecord.verified_amount" class="form-control col-6 input" readonly>
  59. </span>
  60. <span v-if="inventoryMissionRecord.re_checked_amount">
  61. <input type="text" id="count" name="count" v-model="inventoryMissionRecord.re_checked_amount" class="form-control col-6 input" readonly>
  62. </span>
  63. </span>
  64. <span v-if="inventory.surplus==0">
  65. <label for="count" class="text-secondary font-weight-bold">盘点差异数</label>
  66. <input type="text" id="count" name="count" v-model="inventoryMissionRecord.difference_amount" class="form-control col-6 input" readonly>
  67. </span>
  68. </div>
  69. </form>
  70. <table class="table table-sm table-striped table-bordered table-hover text-nowrap card-body mt-2">
  71. <tr>
  72. <th>序号</th>
  73. <th>库位</th>
  74. <th>产品名</th>
  75. <th>产品条码</th>
  76. <th>生产日期</th>
  77. <th>失效日期</th>
  78. <th>入库日期</th>
  79. <th>批号</th>
  80. <th>ERP属性仓</th>
  81. <th>质量状态</th>
  82. <th>库存数量</th>
  83. <th>可用数量</th>
  84. <th>盘点数量</th>
  85. <th>复盘数量</th>
  86. <th>盘点差异</th>
  87. <th>分配数量</th>
  88. </tr>
  89. {{-- v-if="inventoryMission.checked=='是'"--}}
  90. <tr v-for="(inventoryMission,i) in inventoryMissions" @click="selectedColor(inventoryMission.id)" :style="{'font-weight': inventory.id==selectedStyle?'bold':''}">
  91. <td>@{{ i+1 }}</td>
  92. <td>@{{ inventoryMission.location }}</td>
  93. <td v-if="inventoryMission.commodity">@{{ inventoryMission.commodity.name }}</td>
  94. <td v-if="inventoryMission.commodity">@{{ inventoryMission.commodity.barcode }}</td>
  95. <td >@{{ inventoryMission.produced_at }}</td>
  96. <td >@{{ inventoryMission.valid_at }}</td>
  97. <td >@{{ inventoryMission.stored_at }}</td>
  98. <td class="text-muted">@{{ inventoryMission.batch_number }}</td>
  99. <td >@{{ inventoryMission.erp_type_position }}</td>
  100. <td >@{{ inventoryMission.quality }}</td>
  101. <td >@{{ inventoryMission.stored_amount }}</td>
  102. <td >@{{ inventoryMission.valid_amount }}</td>
  103. <td>@{{ inventoryMission.verified_amount }}</td>
  104. <td>@{{ inventoryMission.re_checked_amount }}</td>
  105. <td>@{{ inventoryMission.difference_amount }}</td>
  106. <td>@{{ inventoryMission.occupied_amount }}</td>
  107. </tr>
  108. </table>
  109. </div>
  110. @endsection
  111. @section('lastScript')
  112. <script>
  113. let listVue = new Vue({
  114. el: "#list",
  115. data: {
  116. inventory:{!! $inventory!!},
  117. inventoryMissions:{!! $inventoryMissions !!},
  118. checkData: [],
  119. selectedStyle:'',
  120. inventoryMissionRecord:{},
  121. },
  122. mounted: function () {
  123. $(".tooltipTarget").tooltip({'trigger': 'hover'});
  124. $("#list").removeClass('d-none');
  125. document.getElementById('inventoryInput').focus();
  126. },
  127. methods:{
  128. selectedColor(id){
  129. if (id==this.selectedStyle){
  130. this.selectedStyle='';
  131. return;
  132. }
  133. this.selectedStyle=id;
  134. },
  135. //验证输入盘点产品条码对应是否有商品
  136. searchBarcode(){
  137. let _this=this;
  138. let barcode=document.getElementById('barcode').value;
  139. let location=document.getElementById('inventoryInput').value;
  140. let inventoryId=_this.inventory.id;
  141. let barcodes=[];
  142. _this.inventoryMissions.forEach(function (inventoryMission) {
  143. barcodes.push(inventoryMission.commodity.barcode);
  144. });
  145. if (!barcodes.includes(barcode)){
  146. tempTip.setDuration(2000);
  147. tempTip.show('输入的产品条码没有对应的产品!');
  148. }else {
  149. //根据该库存和产品条码查询该条盘点记录
  150. let url='{{url('inventory/searchStockInventoryRecord')}}';
  151. axios.post(url,{location:location,barcode:barcode,inventoryId:inventoryId}).then(function (response) {
  152. if (!response.data.success){
  153. tempTip.setDuration(2000);
  154. tempTip.show('复盘!'+' '+response.data.data);
  155. }else {
  156. _this.inventoryMissionRecord=response.data.data;
  157. }
  158. }).catch(function (err) {
  159. tempTip.setDuration(2000);
  160. tempTip.show('网络错误'+err);
  161. });
  162. }
  163. },
  164. //提交盘点
  165. submitStockInventory(){
  166. let _this=this;
  167. let url='{{url('inventory/stockInventory')}}';
  168. let location=document.getElementById('inventoryInput').value;
  169. let barcode=document.getElementById('barcode').value;
  170. let count=document.getElementById('count').value;
  171. let inventoryId=_this.inventory.id;
  172. axios.post(url,{location:location,barcode:barcode,count:count,inventoryId:inventoryId})
  173. .then(function (response) {
  174. if (!response.data.success){
  175. tempTip.setDuration(2000);
  176. tempTip.show('盘点失败!'+' '+response.data.data);
  177. }else {
  178. if (_this.inventory.id==response.data.inventory.id){
  179. _this.inventory.processed=response.data.inventory.processed;
  180. _this.inventory.surplus=response.data.inventory.surplus;
  181. _this.inventory.check_surplus=response.data.inventory.check_surplus;
  182. }
  183. _this.inventoryMissions.every(function (inventoryMission,i) {
  184. if (inventoryMission.id==response.data.inventoryMission.id){
  185. inventoryMission.checked=response.data.inventoryMission.checked;
  186. inventoryMission.verified_amount=response.data.inventoryMission.verified_amount;
  187. inventoryMission.difference_amount=response.data.inventoryMission.difference_amount;
  188. inventoryMission.re_checked_amount=response.data.inventoryMission.re_checked_amount;
  189. _this.inventoryMissions.splice(i,1)
  190. _this.inventoryMissions.unshift(inventoryMission);
  191. return false;
  192. }
  193. return true;
  194. });
  195. tempTip.setDuration(3000);
  196. tempTip.showSuccess('盘点成功!');
  197. }
  198. }).catch(function (err) {
  199. tempTip.setDuration(2000);
  200. tempTip.show('盘点失败!'+'网络错误'+err);
  201. })
  202. },
  203. }
  204. });
  205. $("#form").on("keydown","input",function(){
  206. let _this=this;
  207. let e = event || window.event;
  208. if(e && e.keyCode==13) {
  209. let inputs = $("#form .input");
  210. let idx = inputs.index(this); // 获取当前焦点输入框所处的位置
  211. let location=document.getElementById('inventoryInput').value;
  212. if (idx == 2) { // 判断是否是最后一个输入框
  213. if (location==''||location==undefined||location==null){
  214. document.getElementById('inventoryInput').focus();
  215. return;
  216. }
  217. listVue.submitStockInventory();
  218. $("#form .input").val(' ');
  219. document.getElementById('inventoryInput').focus();
  220. } else {
  221. inputs[idx + 1].focus(); // 设置焦点
  222. inputs[idx + 1].select(); // 选中文字
  223. }
  224. }
  225. });
  226. </script>
  227. @endsection