statistics.blade.php 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499
  1. @extends('layouts.app')
  2. @section('title')入库管理@endsection
  3. @section('content')
  4. <span id="nav2">
  5. @component('weight.menu')@endcomponent
  6. </span>
  7. <div class="d-none" id="statistics">
  8. <div class="container-fluid mt-3">
  9. <div class="">
  10. <div>
  11. <form method="GET" action="{{url('package/statistics')}}" style="margin-top: 1%" id="optionSubmit">
  12. <table class="table table-sm table-bordered text-nowrap ">
  13. <tr v-if="isBeingFilterConditions">
  14. <td colspan="10"><div class="col" style="padding:0">
  15. <a href="{{url('package/statistics')}}"><span class="btn btn-warning text-dark">清除过滤条件</span></a>
  16. </div></td>
  17. </tr>
  18. <tr >
  19. <td rowspan="2" class="" style=" width: 150px">
  20. <div class="d-flex" style="height: 100px;">
  21. <span class="text-muted align-items-center d-flex">根据条件过滤:</span>
  22. </div>
  23. </td>
  24. <td>
  25. <div class="form-inline pl-3" style="height: 100px">
  26. <div class="align-items-center">
  27. <div class="text-right">货主:</div>
  28. <p>
  29. <input type="text" style="width: 100px;opacity: 0.6" class="form-control-sm tooltipTarget" placeholder="定位货主"
  30. @input="owner_seek"
  31. title="输入关键词快速定位下拉列表">
  32. </p>
  33. </div>
  34. <div style="max-height: 90px; overflow-y: scroll;border: solid 1px #ddd;border-radius:5px;text-align: center;transform:scale(0.9)" v-if="ownersCopy.length>0">
  35. <ul class="list-group tooltipTarget" id="seek" onselectstart="return false;">
  36. <li title="单击添加货主" v-for="ownerCopy in ownersCopy" :id="ownerCopy.name" class="list-group-item list-group-item-action pt-0 pb-0"
  37. @click="selectedOwner(ownerCopy)" :class="ownerCopy.style ? 'active' :''"><span style="cursor: default;" :id="ownerCopy.name">@{{ ownerCopy.name }}</span></li>
  38. </ul>
  39. <input hidden name="owner_id" :value="selectedOwners">
  40. </div>
  41. </div>
  42. </td>
  43. <td >
  44. <div class="form-inline pl-3" style="height: 100px">
  45. <div class="align-items-center">
  46. <div class="text-right">物流公司:</div>
  47. <p>
  48. <input type="text" style="width: 100px;opacity: 0.6" class="form-control-sm tooltipTarget" placeholder="定位物流公司"
  49. @input="logistic_seek"
  50. title="输入关键词快速定位下拉列表">
  51. </p>
  52. </div>
  53. <div style="max-height: 90px;overflow-y: scroll;border: solid 1px #ddd;border-radius:5px;text-align: center;transform:scale(0.9)" v-if="logisticsAll.length>0">
  54. <ul class="list-group tooltipTarget" onselectstart="return false;">
  55. <li title="单击添加物流公司" v-for="logistic in logisticsAll" class=" list-group-item list-group-item-action pt-0 pb-0"
  56. @click="selectedLogistic(logistic)" :class="logistic.style ? 'active' :''" >
  57. <span style="cursor: default;" :id="logistic.name">@{{ logistic.name }}</span></li>
  58. </ul>
  59. <input hidden name="logistic_id" :value="selectedLogistics">
  60. </div>
  61. </div>
  62. </td>
  63. <td style="position: relative">
  64. <table class="table table-sm table-borderless">
  65. <tr>
  66. <td class="text-right" style="line-height: 60px">
  67. 时间:
  68. </td>
  69. <td>
  70. <div class="form-inline">
  71. <div class="form-group">
  72. <input style="width: 170px;transform:scale(0.8)" type="date" v-model="filterData.date_start" class="form-control">
  73. <input id="hour_input" type="text" class="form-control" placeholder="00:00"
  74. @input="hourFilter($event)" v-model="inputtingAdd_start" style="transform:scale(0.8);width: 80px"
  75. @keypress="hourFilter($event)" >
  76. <input v-if="filterData.date_start" hidden name="date_start" :value="filterData.date_start+' '+inputtingAdd_start">
  77. </div>
  78. </div>
  79. <div class="form-inline">
  80. <div class="form-group">
  81. <input style="transform:scale(0.8);width: 170px" type="date" v-model="filterData.date_end" class="form-control" >
  82. <input id="hour_input" type="text" class="form-control" placeholder="00:00"
  83. @input="hourFilter($event)" v-model="inputtingAdd_end" style="transform:scale(0.8);width:80px"
  84. @keypress="hourFilter($event)" >
  85. <input v-if="filterData.date_end" hidden name="date_end" :value="filterData.date_end+' '+inputtingAdd_end">
  86. </div>
  87. </div>
  88. </td>
  89. </tr>
  90. <tr>
  91. <td class="text-center" colspan="2">
  92. <button class="btn btn-primary btn-sm pl-5 pr-5">提交</button>
  93. </td>
  94. </tr>
  95. </table>
  96. <span class="text-muted"
  97. style="position: absolute; bottom: 10px;left:calc(50% - 165px);transform: scale(0.65)" v-if="filterData.date_start">
  98. 时间区间:@{{ filterData.date_start }}&nbsp;@{{ inputtingAdd_start }} <b v-if="filterData.date_end">-</b> @{{ filterData.date_end }}&nbsp;@{{ inputtingAdd_end }}</span>
  99. <div class=" align-items-center d-flex pt-2">
  100. <div class="m-auto d-flex">
  101. </div>
  102. </div>
  103. </td>
  104. <td>
  105. </td>
  106. </tr>
  107. <tr></tr>
  108. <tr>
  109. <td>
  110. <div>
  111. <span class="text-muted">操作选定记录:</span>
  112. </div>
  113. </td>
  114. <td colspan="3">
  115. <span class="dropdown">
  116. <button class="btn btn-outline-dark btn-sm form-control-sm dropdown-toggle tooltipTarget" {{--:class="[rejectedBills_checkBoxes.length>0?'btn-dark text-light':'']"--}}
  117. data-toggle="dropdown" title="导出所有页将会以搜索条件得到的过滤结果,将其全部记录(每一页)导出">
  118. 导出Excel
  119. </button>
  120. <div class="dropdown-menu">
  121. <a class="dropdown-item" @click="statisticExport(1)" href="javascript:">导出勾选内容</a>
  122. <a class="dropdown-item" @click="statisticExport(2)" href="javascript:">导出所有页</a>
  123. </div>
  124. </span>
  125. </td>
  126. </tr>
  127. </table>
  128. </form>
  129. </div>
  130. <div class="">
  131. <table class="table table-striped table-sm text-nowrap table-hover">
  132. <tr>
  133. <th>
  134. <label for="all">
  135. <input id="all" type="checkbox" @click="checkAll($event)">全选
  136. </label>
  137. </th>
  138. <th>货主</th>
  139. <th>总计</th>
  140. <th v-for="logistic in logisticsAll" v-if="logistics[logistic.id]">@{{ logistic.name }}</th>
  141. </tr>
  142. <tr v-for="ownerModel in ownersModel">
  143. <td>
  144. <input class="checkItem" type="checkbox" :value="ownerModel.id" v-model="checkData">
  145. </td>
  146. <th class="text-muted">@{{ ownerModel.name }}</th>
  147. <td><p v-if="ownerModel.sum">@{{ ownerModel.sum }}</p><p v-else>0</p></td>
  148. <td class="text-muted" v-for="logistic in logisticsAll" v-if="logistics[logistic.id]"><p v-if="ownerModel.logistics[logistic.id]">@{{ ownerModel.logistics[logistic.id] }}</p>
  149. <p v-else>0</p></td>
  150. </tr>
  151. </table>
  152. </div>
  153. </div>
  154. </div>
  155. </div>
  156. @endsection
  157. @section('lastScript')
  158. <style>
  159. li a:hover{background-color: #4aa0e6;display: block;cursor:pointer}
  160. </style>
  161. <script>
  162. new Vue({
  163. el:"#statistics",
  164. data:{
  165. packages:[
  166. @foreach($packages as $package)
  167. {owner_id:'{{$package->owner_id}}',logistic_id:'{{$package->logistic_id}}',count:'{{$package->count}}',
  168. owner_name:'',logistic_name:''},
  169. @endforeach
  170. ],
  171. owners:{
  172. @foreach($owners as $owner)
  173. '{{$owner->id}}' : "{{$owner->name}}",
  174. @endforeach
  175. },
  176. logisticsAll:[
  177. @foreach($logistics as $logistic)
  178. {id:'{{$logistic->id}}', name: '{{$logistic->name}}',style:false},
  179. @endforeach
  180. ],
  181. ownersCopy:[
  182. @foreach($owners as $owner)
  183. {id:'{{$owner->id}}',name:"{{$owner->name}}",style:false},
  184. @endforeach
  185. ],
  186. logistics:[],
  187. ownersModel:[],
  188. filterData:
  189. {date_start:'',date_end:''},
  190. selectedOwners:[],
  191. selectedLogistics:[],
  192. checkData:[],
  193. checkSign:'',
  194. inputtingAdd_start:'',
  195. inputtingAdd_end:'',
  196. },
  197. computed:{
  198. isBeingFilterConditions:function(){
  199. for(let key in this.filterData){
  200. if(this.filterData[key]){
  201. return true
  202. }
  203. }
  204. if (this.selectedOwners.length>0||this.selectedLogistics.length>0){
  205. return true;
  206. }
  207. return false;
  208. },
  209. },
  210. watch:{
  211. checkData:{
  212. handler(){
  213. if (this.checkData.length === this.ownersModel.length){
  214. document.querySelector('#all').checked = true;
  215. }else {
  216. document.querySelector('#all').checked = false;
  217. }
  218. },
  219. deep:true
  220. }
  221. },
  222. mounted:function(){
  223. let _this=this;
  224. let owners=this.owners;
  225. this.packages.forEach(function (package){
  226. if (owners[package.owner_id]){
  227. package.owner_name=owners[package.owner_id];
  228. }
  229. let isEvery=true;
  230. if (_this.ownersModel) {
  231. isEvery=_this.ownersModel.every(function (ownerModel) {
  232. if (ownerModel.name==package.owner_name){
  233. ownerModel.logistics[package.logistic_id]=package.count;
  234. ownerModel.sum=parseInt(ownerModel.sum)+parseInt(package.count);
  235. return false;
  236. }
  237. return true;
  238. });
  239. }
  240. if (isEvery){
  241. let obj={};
  242. _this.logisticsAll.every(function (logistic) {
  243. if (logistic.id==package.logistic_id) {
  244. obj[package.logistic_id]=package.count;
  245. return false;
  246. }
  247. return true;
  248. });
  249. _this.ownersModel.push({'id':package.owner_id,'name':package.owner_name,'sum':package.count,'logistics':obj,});
  250. }
  251. });
  252. this.initInputs();
  253. $(".tooltipTarget").tooltip({'trigger':'hover'});
  254. $('#statistics').removeClass('d-none');
  255. },
  256. methods: {
  257. initInputs:function(){
  258. let data=this;
  259. let uriParts =decodeURI(location.href).split("?");
  260. let isLogistic=true;
  261. if(uriParts.length>1){
  262. let params = uriParts[1].split('&');
  263. params.every(function(paramPair){
  264. let pair=paramPair.split('=');
  265. let key = pair[0], val = pair[1];
  266. $('input[name="'+key+'"]').val(val);
  267. $('select[name="'+key+'"]').val(val);
  268. if (key!='owner_id'||key!='logistic_id') {
  269. decodeURI(data.filterData[key]=val);
  270. }
  271. let str=unescape(val);
  272. let strs=new Array();
  273. strs=str.split(",");
  274. if (key=='owner_id' && val){
  275. for (let i=0;i<strs.length;i++){
  276. data.selectedOwners.push(strs[i]);
  277. data.ownersCopy.every(function (ownerCopy) {
  278. if (strs[i]==ownerCopy.id){
  279. ownerCopy.style=true;
  280. return false;
  281. }
  282. return true;
  283. });
  284. }
  285. }
  286. if (key=='logistic_id' && val){
  287. for (let i=0;i<strs.length;i++){
  288. data.selectedLogistics.push(strs[i]);
  289. data.logisticsAll.every(function (logistic) {
  290. if (strs[i]==logistic.id){
  291. logistic.style=true;
  292. return false;
  293. }
  294. return true;
  295. });
  296. }
  297. {{--URL有参数且有logistic字段 --}}
  298. let logistics=data.selectedLogistics;
  299. if (logistics.length>0){
  300. for (let i=0;i<logistics.length;i++){
  301. data.logisticsAll.every(function (logistic) {
  302. if (logistic.id==logistics[i]){
  303. data.logistics[logistic.id]=logistic.name;
  304. return false;
  305. }
  306. return true;
  307. });
  308. }
  309. }else{
  310. data.logisticsAll.every(function (logistic) {
  311. data.logistics[logistic.id]=logistic.name;
  312. return true;
  313. });
  314. };
  315. isLogistic=false;
  316. }
  317. if (key=='date_start'){
  318. strs=str.split("+");
  319. if (strs.length!=2) return;
  320. data.filterData.date_start=strs[0];
  321. data.inputtingAdd_start=strs[1];
  322. }
  323. if (key=='date_end'){
  324. strs=str.split("+");
  325. if (strs.length!=2) return;
  326. data.filterData.date_end=strs[0];
  327. data.inputtingAdd_end=strs[1];
  328. }
  329. return true;
  330. });
  331. }
  332. {{--URL无参数以packages所存在物流公司为显示标准 --}}
  333. if (uriParts.length<=1 || isLogistic){
  334. data.packages.every(function (package) {
  335. data.logisticsAll.every(function (logistic) {
  336. if (package.logistic_id==logistic.id){
  337. data.logistics[logistic.id]=logistic.name;
  338. return false;
  339. }
  340. return true;
  341. });
  342. return true;
  343. });
  344. }
  345. },
  346. owner_seek:function (e) {
  347. let _this=this;
  348. let $val=e.target.value;
  349. if($val==='')_this.filterData.owner_id='';
  350. else{
  351. @foreach($owners as $owner)
  352. if ("{{ $owner->name }}".includes($val)){
  353. _this.filterData.owner_id="{{ $owner->id }}";
  354. location.href="#{{$owner->name}}";
  355. }
  356. @endforeach
  357. }
  358. $(e.target).focus();
  359. },
  360. logistic_seek:function(e){
  361. let _this=this;
  362. let $val=e.target.value;
  363. if($val){
  364. _this.logisticsAll.every(function (logistic) {
  365. let name=logistic.name;
  366. if (name.includes($val)){
  367. location.href="#"+logistic.name;
  368. return false;
  369. }
  370. return true;
  371. });
  372. }
  373. $(e.target).focus();
  374. },
  375. selectedOwner:function (e) {
  376. let selectedOwners=this.selectedOwners;
  377. let sign = true;
  378. for (let i=0;i<selectedOwners.length;i++){
  379. if (selectedOwners[i]==e.id){
  380. selectedOwners.splice(i,1);
  381. this.ownersCopy.every(function (ownerCopy) {
  382. if (ownerCopy.id==e.id) {
  383. ownerCopy.style=false;
  384. return false;
  385. }
  386. return true;
  387. });
  388. sign=false;
  389. break;
  390. }
  391. }
  392. if (sign) {
  393. this.selectedOwners.push(e.id);
  394. this.ownersCopy.every(function (ownerCopy) {
  395. if (ownerCopy.id==e.id) {
  396. ownerCopy.style=true;
  397. return false;
  398. }
  399. return true;
  400. });
  401. }
  402. },
  403. selectedLogistic:function (e) {
  404. let selectedLogistics=this.selectedLogistics;
  405. let sign = true;
  406. for (let i=0;i<selectedLogistics.length;i++){
  407. if (selectedLogistics[i]==e.id){
  408. selectedLogistics.splice(i,1);
  409. this.logisticsAll.every(function (logistic) {
  410. if (logistic.id==e.id) {
  411. logistic.style=false;
  412. return false;
  413. }
  414. return true;
  415. });
  416. sign=false;
  417. break;
  418. }
  419. }
  420. if (sign) {
  421. this.selectedLogistics.push(e.id);
  422. this.logisticsAll.every(function (logistic) {
  423. if (logistic.id==e.id) {
  424. logistic.style=true;
  425. return false;
  426. }
  427. return true;
  428. });
  429. }
  430. },
  431. checkAll(e){
  432. if (e.target.checked){
  433. this.ownersModel.forEach((el,i)=>{
  434. if (this.checkData.indexOf(el.id) == '-1'){
  435. this.checkData.push(el.id);
  436. }
  437. });
  438. }else {
  439. this.checkData = [];
  440. }
  441. },
  442. statisticExport:function (e) {
  443. if (e==1){
  444. if (this.checkData&&this.checkData.length<=0){
  445. tempTip.setDuration(4000);
  446. tempTip.showSuccess('没有勾选任何记录');
  447. return;
  448. }
  449. location.href="{{url('package/statistics?checkSign=')}}"+this.checkData;
  450. }else{
  451. /* let formData=new FormData();
  452. formData.append('owner_id',this.selectedOwners);
  453. formData.append('logistic_id',this.selectedLogistics);
  454. formData.append('date_start',this.filterData.date_start);
  455. formData.append('date_end',this.filterData.date_end);
  456. formData.append('checkSign','-1');*/
  457. location.href="{{url('package/statistics?owner_id=')}}"+this.selectedOwners+
  458. "&logistic_id="+this.selectedLogistics+"&date_start="+this.filterData.date_start
  459. +"&date_end="+this.filterData.date_end+"&checkSign=-1";
  460. }
  461. },
  462. hourFilter:function(e){
  463. setTimeout(function(){
  464. e.target.value=e.target.value.replace(':',':');
  465. e.target.value=e.target.value.replace(/[a-zA-Z]/,'');
  466. e.target.value=e.target.value.replace(/^([\d]{1})([\s]{1})/,"$1:");
  467. e.target.value=e.target.value.replace(/^([\d]{1})([\d]{1})([\s]{1})/,"$1$2:");
  468. //e.target.value=e.target.value.replace(/^([3-9]{1})([\d]{1})/,"$1:$2");
  469. e.target.value=e.target.value.replace(/^([\d]{1})([\d]{1})([\d]{1})/,"$1$2:$3");
  470. e.target.value=e.target.value.replace(/^([\d]{1})([\d]{1})([\d]{1})([\d]{1})(.*?)/,"$1$2$3$4");
  471. e.target.value=e.target.value.replace(/^([\d]{1})([\d]{1})([\d]{1})([\d]{1})/,"$1$2:$3$4");
  472. e.target.value=e.target.value.replace(/^([\d]{1})([\d]{1}):([\d]{1})([\d]{1})([\s\S]{1})/,"$1$2:$3$4");
  473. e.target.value=e.target.value.replace(/^([\d]{1})([\d]{1}):([\D]{1,99})/,"$1$2:");
  474. e.target.value=e.target.value.replace(/^([\d]{1})([\d]{1})([\d]{1})\./,"$1:$2$3");
  475. e.target.value=e.target.value.replace(/^([\d]{1})\.([\d]{1})([\d]{1})/,"$1:$2$3");
  476. e.target.value=e.target.value.replace(/^([\d]{1})([\d]{2})([\S\s]{1,99})/,"$1$2:$3");
  477. e.target.value=e.target.value.replace(/^([\d]{1}):([\d]{2})([\S\s]{1,99})/,"$1:$2");
  478. e.target.value=e.target.value.replace(/^([\d])/,"$1");
  479. e.target.value=e.target.value.replace(/^([1])([\d]{1})/,"$1$2");
  480. e.target.value=e.target.value.replace(/^([3-9])([\d]{1})/,"2$2");
  481. e.target.value=e.target.value.replace(/^([2-9]{1})([4-9]{1})/,"$13");
  482. e.target.value=e.target.value.replace(/^([\d]{1})([\d]{1}):([6-9]{1})/,"$1$2:5");
  483. },1);
  484. },
  485. }
  486. });
  487. </script>
  488. @endsection