mission.blade.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  1. @extends('layouts.app')
  2. @section('title')盘点任务-库存管理@endsection
  3. @section('content')
  4. <div class="text-center h5 mt-2" id="loadingPage">
  5. 载入中……
  6. </div>
  7. <div id="list" class="container-fluid d-none" {{--style="min-width: 1500px"--}}>
  8. <div class="card-header alert-info">
  9. <form class="form-inline">
  10. <span class="form-inline ml-5">
  11. <span class="btn btn-sm btn-outline-secondary tooltipTarget" @click="syncOwners">同步货主</span>
  12. <select class="form-control form-control-sm tooltipTarget" name="owner_id" id="owner_id" style="width: 150px;position: relative" title="选择指定货主" v-model="owner_id">
  13. <option value="">货主</option>
  14. <option v-for="owner in owners" :value="owner.name">@{{ owner.value }}</option>
  15. </select>
  16. <input placeholder="定位货主" id="ownerName" autocomplete="off" @input="定位货主($event)" class="form-control form-control-sm tooltipTarget" style="width: 100px" title="输入关键字定位货主" >
  17. </span>
  18. <span class="form-inline">
  19. <input type="date" @change="hasDateStart" class="form-control form-control-sm ml-5 tooltipTarget" name="date_start" id="date_start" title="选择创建日期的开始时间" style="width: 150px">
  20. <input type="date" @change="hasDateEnd" class="form-control form-control-sm ml-5 tooltipTarget" name="date_end" id="date_end" title="选择创建日期的结束时间" style="width: 150px">
  21. <input type="text" @change="hasLocation" class="form-control form-control-sm ml-5 tooltipTarget" name="location" id="location" title="选择创建盘点任务库位的前缀字母,支持多个,以空格或逗号分隔" placeholder="库位前缀字母,多个空格分隔" style="width: 150px" autocomplete="off">
  22. <input type="text" @change="hasBarcode" class="form-control form-control-sm ml-5 tooltipTarget" name="barcode" id="barcode" title="商品条码,糊模查找需要在左边打上%符号" placeholder="条码" style="width: 200px" autocomplete="off">
  23. </span>
  24. <span class="ml-5">
  25. @can('库存管理-盘点')
  26. <span v-if="date_start&&date_end&&!location&&!barcode" class="btn btn-sm btn-outline-secondary tooltipTarget" @click="createInventoryMission" title="选择单一指定货主生成盘点任务">生成动盘任务</span>
  27. <span v-else-if="location||barcode ||(date_start&&date_end&&location)||(date_start&&date_end&&barcode)" class="btn btn-sm btn-outline-secondary tooltipTarget" @click="createInventoryMission" title="选择单一指定货主生成盘点任务">生成局部盘点任务</span>
  28. <span v-else class="btn btn-sm btn-outline-secondary tooltipTarget" @click="createInventoryMission" title="选择单一指定货主生成盘点任务">生成全盘任务</span>
  29. @endcan
  30. </span>
  31. </form>
  32. </div>
  33. <div id="form_div" class="mt-2"></div>
  34. <div class="row mt-2">
  35. <span class="dropdown ml-3">
  36. <button class="btn btn-outline-dark btn-sm form-control-sm dropdown-toggle tooltipTarget"
  37. data-toggle="dropdown" title="导出所有页将会以搜索条件得到的筛选结果,将其全部记录(每一页)导出">
  38. 导出Excel
  39. </button>
  40. <div class="dropdown-menu">
  41. <a class="dropdown-item" @click="inventoryExport(false)" href="javascript:">导出勾选内容</a>
  42. <a class="dropdown-item" @click="inventoryExport(true)" href="javascript:">导出所有页</a>
  43. </div>
  44. </span>
  45. </div>
  46. <div class=" pt-1">
  47. <table class="table table-sm text-nowrap table-striped table-bordered m-0 td-min-width-80" id="table">
  48. <tr v-for="(inventory,i) in inventoryAccounts" @click="selectedColor(inventory.id,$event)" :style="{'font-weight': inventory.id===selectedStyle?'bold':''}" :class="selectedStyle === inventory.id ? 'focusing':''">
  49. <td>
  50. <input class="checkItem" type="checkbox" :value="inventory.id">
  51. </td>
  52. <td>
  53. @can('库存管理-盘点')
  54. <span class="btn btn-sm btn-outline-info" @click="enterStockInventory(inventory.id)" v-if="inventory.status!='已完成'&&inventory.status!='已审核'">盘点</span>
  55. @endcan
  56. @can('库存管理-盘点-查看')
  57. <a :href="'{{url('inventory/stockInventory/enterStockInventory')}}/'+inventory.id+'?listMode=true'"><button class="btn btn-sm btn-outline-dark">查看</button></a>
  58. @endcan
  59. </td>
  60. <td>
  61. @can('库存管理-盘点-项目审核')
  62. <span v-if="inventory.auditor" class="text-success">已审核</span>
  63. <span v-else class="btn btn-sm btn-outline-dark" @click="inventoryChecked(inventory.id)">审核</span>
  64. @else
  65. <span v-if="inventory.auditor" class="text-success">已审核</span>
  66. <span v-else>未审核</span>
  67. @endcan
  68. </td>
  69. <td ><span>@{{ i+1 }}</span></td>
  70. <td ><span>@{{ inventory.status }}</span></td>
  71. <td ><span>@{{ inventory.id }}</span></td>
  72. <td ><span>@{{ inventory.created_at }}</span></td>
  73. <td ><span>@{{ inventory.owner_name }}</span></td>
  74. <td style="width: 200px;word-wrap: break-word">
  75. <small>@{{ inventory.type }}</small>
  76. <span v-if="inventory.remark" class="text-wrap"><small>@{{ inventory.remark }}</small></span>
  77. </td>
  78. <td ><span>@{{ inventory.start_at }}</span></td>
  79. <td class="text-muted"><span>@{{ inventory.end_at }}</span></td>
  80. <td ><span>@{{ inventory.total }}</span></td>
  81. <td ><span>@{{ inventory.processed }}</span></td>
  82. <td ><span>@{{ inventory.surplus }}</span></td>
  83. <td ><span>@{{ inventory.ignored?inventory.ignored:0 }}</span></td>
  84. <td><span>@{{ inventory.difference }}</span></td>
  85. <td><span>@{{ inventory.returned }}</span></td>
  86. <td v-if="inventory.processed"><span>@{{ inventory.processed }}/@{{ inventory.total }}</span></td>
  87. <td><span>@{{ inventory.auditor }}</span></td>
  88. <td class="text-muted"><span>@{{ inventory.creator }}</span></td>
  89. <td>
  90. <span v-if="inventory.status!='已完成'&&inventory.status!='已审核'" class="btn btn-sm btn-outline-danger" @click="deleteStockInventoryMission(inventory.id)">删</span>
  91. </td>
  92. </tr>
  93. </table>
  94. <div class="text-info h5 btn btn">{{$inventoryAccounts->count()}}/@{{ sum }}</div>
  95. <div>{{$inventoryAccounts->appends($paginateParams)->links()}}</div>
  96. </div>
  97. </div>
  98. @endsection
  99. @section('lastScript')
  100. <script type="text/javascript" src="{{mix('js/queryForm/export.js')}}"></script>
  101. <script type="text/javascript" src="{{mix('js/queryForm/queryForm.js')}}"></script>
  102. <script type="text/javascript" src="{{mix('js/queryForm/header.js')}}"></script>{{--新版2--}}
  103. <script>
  104. let vue = new Vue({
  105. el: "#list",
  106. data: {
  107. inventoryAccounts : [
  108. @foreach($inventoryAccounts as $inventory)
  109. {id:'{{$inventory->id}}',owner_name:'{{$inventory->owner?$inventory->owner->name:''}}',
  110. creator:'{{$inventory->creator?$inventory->creator->mark:''}}',
  111. created_at:'{{$inventory->created_at}}', status:'{{$inventory->status}}', processed:'{{$inventory->processed}}',
  112. returned:'{{$inventory->returned}}', surplus:'{{$inventory->surplus}}',
  113. total:'{{$inventory->total}}',end_at:'{{$inventory->end_at}}',
  114. start_at:'{{$inventory->start_at}}',type:'{{$inventory->type}}',
  115. difference:'{{$inventory->difference}}',
  116. remark:'{{$inventory->remark}}',ignored:'{{$inventory->ignored}}',
  117. @if($inventory->userAuditor)auditor:'{{$inventory->userAuditor['name']}}',@endif
  118. },
  119. @endforeach
  120. ],
  121. owners:[
  122. @foreach($owners as $owner)
  123. {name:'{{$owner->id}}',value:'{{$owner->name}}'},
  124. @endforeach
  125. ],
  126. selectedStyle:'',
  127. sum:{!! $inventoryAccounts->total() !!},
  128. date_end:'',location:'',barcode:'', date_start:'',
  129. fakeOwners:'',
  130. owner_id:'',
  131. },
  132. mounted: function () {
  133. $(".tooltipTarget").tooltip({'trigger': 'hover'});
  134. (function 显示渲染后页面(){
  135. $('#loadingPage').remove();
  136. $('#list').removeClass('d-none');
  137. })()
  138. this.fakeOwners=this.owners;
  139. $('#list').removeClass('d-none');
  140. let data=[
  141. [
  142. {name:'date_start',type:'dateTime',tip:'选择显示指定日期的起始时间'},
  143. {name:'date_end',type:'dateTime',tip:'选择显示指定日期的结束时间'},
  144. {name:'owner',type:'select_multiple_select',tip:['输入关键词快速定位下拉列表,回车确定','选择要显示的货主'],
  145. placeholder:['货主','定位或多选货主'],data:this.owners},
  146. {name:'type',type:'select',placeholder: '任务类型',data:[{name:'全盘',value:'全盘'},{name:'动盘',value:'动盘'}, {name:'局部盘点',value:'局部盘点'}]},
  147. ],
  148. ];
  149. this.form = new query({
  150. el:"#form_div",
  151. condition:data,
  152. });
  153. this.form.init();
  154. let column = [
  155. {name:'operation',value: '操作', neglect: true},
  156. {name:'check',value: '审核', neglect: true},
  157. {name:'index',value: '序号', neglect: true},
  158. {name:'status',value: '盘点状态', neglect: true},
  159. {name:'id',value: '盘点单号', neglect: true},
  160. {name: 'created_at', value: '创建日期'},
  161. {name:'owner_name',value: '货主'},
  162. {name: 'type', value: '任务类型',neglect: true},
  163. {name:'start_at',value: '起始时间'},
  164. {name: 'end_at', value: '结束时间', neglect: true},
  165. {name: 'total', value: '盘点任务数', neglect: true},
  166. {name: 'processed', value: '盘点数量', neglect: true},
  167. {name: 'surplus',value: '未盘数量', neglect: true},
  168. {name: 'ignored',value: '跳过数量', neglect: true},
  169. {name: 'difference', value: '差异数量', neglect: true},
  170. {name: 'returned', value: '复盘归位', neglect: true},
  171. {name: '', value: '盘点比例', neglect: true},
  172. {name: 'auditor', value: '审核人', neglect: true},
  173. {name: 'creator', value: '创建人', neglect: true},
  174. {name:'remove',value: '操作', neglect: true},
  175. ];
  176. new Header({
  177. el: "table",
  178. name: "stockInventory",
  179. column: column,
  180. data: this.inventoryAccounts,
  181. fixedTop:($('#form').height())+2,
  182. }).init();
  183. },
  184. methods:{
  185. selectedColor(id,e){
  186. $('#headerParent tr[class=focusing]').removeClass('focusing')
  187. if (id===this.selectedStyle){
  188. this.selectedStyle='';
  189. return;
  190. }
  191. this.selectedStyle=id;
  192. },
  193. inventoryExport(selectAll){
  194. let url = '{{url('inventory/stockInventoryExport')}}';
  195. let token='{{ csrf_token() }}';
  196. excelExport(selectAll,checkData,url,this.sum,token);
  197. },
  198. //生成盘点任务
  199. createInventoryMission(){
  200. let _this=this;
  201. const date_end=document.getElementById('date_end').value;
  202. const date_start=document.getElementById('date_start').value;
  203. //const owner_id=$('#owner_id').val();
  204. const owner_id=_this.owner_id;
  205. const location=$('#location').val().trim();
  206. const barcode=$('#barcode').val();
  207. if(owner_id===''){
  208. tempTip.setDuration(2000);
  209. tempTip.show('生成盘点任务失败'+' '+'请先选择货主!');
  210. return;
  211. }
  212. if(!date_end && date_start){
  213. tempTip.setDuration(2000);
  214. tempTip.show('生成盘点任务失败'+' '+'请选择结束时间!');
  215. return;
  216. }
  217. if(date_end && !date_start){
  218. tempTip.setDuration(2000);
  219. tempTip.show('生成盘点任务失败'+' '+'请选择开始时间!');
  220. return;
  221. }
  222. tempTip.setDuration(999999);
  223. tempTip.waitingTip('生成任务中');
  224. // if (_this.formData.owner_id.length<=0){
  225. // tempTip.setDuration(1000);
  226. // tempTip.show('生成盘点任务失败'+' '+'请先选择货主!');
  227. // return;
  228. // }
  229. let url='{{url('inventory/stockInventory/createStockInventoryMission')}}';
  230. axios.post(url,{date_end:date_end,date_start:date_start,owner_id:owner_id,location:location,barcode:barcode}).then(function (response) {
  231. tempTip.setDuration(2000);
  232. tempTip.cancelWaitingTip();
  233. if(!response.data.success){
  234. tempTip.setDuration(1000);
  235. tempTip.show('生成盘点任务失败'+' '+response.data.data);
  236. return;
  237. }else{
  238. let inventory=response.data.data;
  239. //_this.inventories.push(inventory);
  240. tempTip.setDuration(2000);
  241. tempTip.showSuccess('生成盘点任务成功!');
  242. // tempTip.setDuration(99999);
  243. // tempTip.waitingTip('页面跳转中');
  244. window.location.href='{{url('inventory/stockInventory/enterStockInventory')}}/'+inventory.id;
  245. }
  246. }).catch(function (err) {
  247. tempTip.cancelWaitingTip();
  248. tempTip.setDuration(3000);
  249. tempTip.show('生成盘点任务失败!'+'网络错误:' + err);
  250. });
  251. },
  252. //进入盘点中页面 或者复盘页面
  253. enterStockInventory(id){
  254. location.href='{{url('inventory/stockInventory/enterStockInventory')}}/'+id;
  255. },
  256. deleteStockInventoryMission(id){
  257. let _this=this;
  258. if(!confirm('确定要删除盘点单号为:“'+id+'”的盘点任务吗?')){return};
  259. let url = '{{url('inventory/deleteStockInventoryMission')}}/'+id;
  260. axios.delete(url).then(
  261. function (response) {
  262. if(!response.data.success){
  263. tempTip.setDuration(3000);
  264. tempTip.show('盘点单号:'+id+'删除失败!');
  265. }else {
  266. _this.inventoryAccounts.every(function (inventoryAccount,i) {
  267. if (response.data.data>0&&inventoryAccount.id===id){
  268. _this.inventoryAccounts.splice(i,1);
  269. return false;
  270. }else {
  271. return true
  272. }
  273. });
  274. tempTip.setDuration(3000);
  275. tempTip.showSuccess('盘点单号:'+id+'删除成功!');
  276. }
  277. }
  278. ).catch(function (err) {
  279. tempTip.setDuration(3000);
  280. tempTip.show('删除失败,网络链接错误!'+err);
  281. });
  282. },
  283. inventoryChecked(id){
  284. let _this=this;
  285. let url = '{{url('inventory/inventoryChecked')}}';
  286. axios.post(url,{id:id}).then(
  287. function (response) {
  288. if(!response.data.success){
  289. tempTip.setDuration(3000);
  290. tempTip.show('盘点单号:'+id+'审核失败!');
  291. }else {
  292. _this.inventoryAccounts.every(function (inventoryAccount,i) {
  293. if (inventoryAccount.id===id){
  294. inventoryAccount.auditor=response.data.data.user_auditor.name;
  295. inventoryAccount.status=response.data.data.status;
  296. return false;
  297. }else {
  298. return true
  299. }
  300. });
  301. tempTip.setDuration(3000);
  302. tempTip.showSuccess('盘点单号:'+id+'审核成功!');
  303. }
  304. }
  305. ).catch(function (err) {
  306. tempTip.setDuration(3000);
  307. tempTip.show('审核失败,网络链接错误!'+err);
  308. });
  309. },
  310. syncOwners(){
  311. let _this=this;
  312. let url = '{{url('inventory/syncOwners')}}';
  313. axios.get(url).then(function (response) {
  314. if(!response.data.success){
  315. tempTip.setDuration(3000);
  316. tempTip.show(response.data.data);
  317. }else {
  318. _this.owners=response.data.data;
  319. tempTip.setDuration(2000);
  320. tempTip.showSuccess('同步货主成功!');
  321. }
  322. }).catch(function (err) {
  323. tempTip.setDuration(3000);
  324. tempTip.show('同步货主失败,网络链接错误!'+err);
  325. })
  326. },
  327. 定位货主(e){
  328. this.owners.some(owner => {
  329. if (owner.value.indexOf(e.target.value) !== -1){
  330. this.owner_id = owner.name;
  331. return true;
  332. }
  333. });
  334. if (e.target.value=== ''||e.target.value===null||e.target.value===undefined) {
  335. this.owner_id='';
  336. }
  337. },
  338. hasDateStart(){
  339. this.date_start=document.getElementById('date_start').value;
  340. },
  341. hasDateEnd(){
  342. this.date_end=document.getElementById('date_end').value;
  343. },
  344. hasLocation(){
  345. this.location=$('#location').val().trim();
  346. },
  347. hasBarcode(){
  348. this.barcode=$('#barcode').val();
  349. },
  350. }
  351. });
  352. </script>
  353. @endsection