mission.blade.php 22 KB

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