statistics.blade.php 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522
  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 || filterData.date_end">
  98. 时间区间:@{{ dateTime }}</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. dateTime:'',
  197. },
  198. computed:{
  199. isBeingFilterConditions:function(){
  200. for(let key in this.filterData){
  201. if(this.filterData[key]){
  202. return true
  203. }
  204. }
  205. if (this.selectedOwners.length>0||this.selectedLogistics.length>0){
  206. return true;
  207. }
  208. return false;
  209. },
  210. },
  211. watch:{
  212. checkData:{
  213. handler(){
  214. if (this.checkData.length === this.ownersModel.length){
  215. document.querySelector('#all').checked = true;
  216. }else {
  217. document.querySelector('#all').checked = false;
  218. }
  219. },
  220. deep:true
  221. }
  222. },
  223. mounted:function(){
  224. let _this=this;
  225. let owners=this.owners;
  226. this.packages.forEach(function (package){
  227. if (owners[package.owner_id]){
  228. package.owner_name=owners[package.owner_id];
  229. }
  230. let isEvery=true;
  231. if (_this.ownersModel) {
  232. isEvery=_this.ownersModel.every(function (ownerModel) {
  233. if (ownerModel.name==package.owner_name){
  234. ownerModel.logistics[package.logistic_id]=package.count;
  235. ownerModel.sum=parseInt(ownerModel.sum)+parseInt(package.count);
  236. return false;
  237. }
  238. return true;
  239. });
  240. }
  241. if (isEvery){
  242. let obj={};
  243. _this.logisticsAll.every(function (logistic) {
  244. if (logistic.id==package.logistic_id) {
  245. obj[package.logistic_id]=package.count;
  246. return false;
  247. }
  248. return true;
  249. });
  250. _this.ownersModel.push({'id':package.owner_id,'name':package.owner_name,'sum':package.count,'logistics':obj,});
  251. }
  252. });
  253. this.initInputs();
  254. $(".tooltipTarget").tooltip({'trigger':'hover'});
  255. $('#statistics').removeClass('d-none');
  256. let date=new Date();
  257. let thisDate=this.getDate(date);
  258. let startTime=this.inputtingAdd_start;
  259. let endTime=this.inputtingAdd_end;
  260. let endDate=this.filterData.date_end;
  261. let startDate=this.filterData.date_start;
  262. if (this.filterData.date_start && !this.inputtingAdd_start) startTime="00:00";
  263. if (this.filterData.date_end && !this.inputtingAdd_end) endTime="23:59";
  264. if (this.filterData.date_start && !this.filterData.date_end) endDate=thisDate;
  265. if (this.filterData.date_end && !this.filterData.date_start) startDate="2020-01-01 00:00";
  266. this.dateTime=startDate+" "+startTime+" - "+endDate+" "+endTime;
  267. },
  268. methods: {
  269. getDate(date){
  270. let da=[
  271. date.getFullYear(),
  272. date.getMonth()+1,
  273. date.getDate(),
  274. date.getHours(),
  275. date.getMinutes(),
  276. ]
  277. return da.slice(0,3).join("-")+" "+
  278. da.slice(3).join(":");
  279. },
  280. initInputs:function(){
  281. let data=this;
  282. let uriParts =decodeURI(location.href).split("?");
  283. let isLogistic=true;
  284. if(uriParts.length>1){
  285. let params = uriParts[1].split('&');
  286. params.every(function(paramPair){
  287. let pair=paramPair.split('=');
  288. let key = pair[0], val = pair[1];
  289. $('input[name="'+key+'"]').val(val);
  290. $('select[name="'+key+'"]').val(val);
  291. if (key!='owner_id'||key!='logistic_id') {
  292. decodeURI(data.filterData[key]=val);
  293. }
  294. let str=unescape(val);
  295. let strs=new Array();
  296. strs=str.split(",");
  297. if (key=='owner_id' && val){
  298. for (let i=0;i<strs.length;i++){
  299. data.selectedOwners.push(strs[i]);
  300. data.ownersCopy.every(function (ownerCopy) {
  301. if (strs[i]==ownerCopy.id){
  302. ownerCopy.style=true;
  303. return false;
  304. }
  305. return true;
  306. });
  307. }
  308. }
  309. if (key=='logistic_id' && val){
  310. for (let i=0;i<strs.length;i++){
  311. data.selectedLogistics.push(strs[i]);
  312. data.logisticsAll.every(function (logistic) {
  313. if (strs[i]==logistic.id){
  314. logistic.style=true;
  315. return false;
  316. }
  317. return true;
  318. });
  319. }
  320. {{--URL有参数且有logistic字段 --}}
  321. let logistics=data.selectedLogistics;
  322. if (logistics.length>0){
  323. for (let i=0;i<logistics.length;i++){
  324. data.logisticsAll.every(function (logistic) {
  325. if (logistic.id==logistics[i]){
  326. data.logistics[logistic.id]=logistic.name;
  327. return false;
  328. }
  329. return true;
  330. });
  331. }
  332. }else{
  333. data.logisticsAll.every(function (logistic) {
  334. data.logistics[logistic.id]=logistic.name;
  335. return true;
  336. });
  337. };
  338. isLogistic=false;
  339. }
  340. if (key=='date_start'){
  341. strs=str.split("+");
  342. if (strs.length!=2) return;
  343. data.filterData.date_start=strs[0];
  344. data.inputtingAdd_start=strs[1];
  345. }
  346. if (key=='date_end'){
  347. strs=str.split("+");
  348. if (strs.length!=2) return;
  349. data.filterData.date_end=strs[0];
  350. data.inputtingAdd_end=strs[1];
  351. }
  352. return true;
  353. });
  354. }
  355. {{--URL无参数以packages所存在物流公司为显示标准 --}}
  356. if (uriParts.length<=1 || isLogistic){
  357. data.packages.every(function (package) {
  358. data.logisticsAll.every(function (logistic) {
  359. if (package.logistic_id==logistic.id){
  360. data.logistics[logistic.id]=logistic.name;
  361. return false;
  362. }
  363. return true;
  364. });
  365. return true;
  366. });
  367. }
  368. },
  369. owner_seek:function (e) {
  370. let _this=this;
  371. let $val=e.target.value;
  372. if($val==='')_this.filterData.owner_id='';
  373. else{
  374. @foreach($owners as $owner)
  375. if ("{{ $owner->name }}".includes($val)){
  376. _this.filterData.owner_id="{{ $owner->id }}";
  377. location.href="#{{$owner->name}}";
  378. }
  379. @endforeach
  380. }
  381. $(e.target).focus();
  382. },
  383. logistic_seek:function(e){
  384. let _this=this;
  385. let $val=e.target.value;
  386. if($val){
  387. _this.logisticsAll.every(function (logistic) {
  388. let name=logistic.name;
  389. if (name.includes($val)){
  390. location.href="#"+logistic.name;
  391. return false;
  392. }
  393. return true;
  394. });
  395. }
  396. $(e.target).focus();
  397. },
  398. selectedOwner:function (e) {
  399. let selectedOwners=this.selectedOwners;
  400. let sign = true;
  401. for (let i=0;i<selectedOwners.length;i++){
  402. if (selectedOwners[i]==e.id){
  403. selectedOwners.splice(i,1);
  404. this.ownersCopy.every(function (ownerCopy) {
  405. if (ownerCopy.id==e.id) {
  406. ownerCopy.style=false;
  407. return false;
  408. }
  409. return true;
  410. });
  411. sign=false;
  412. break;
  413. }
  414. }
  415. if (sign) {
  416. this.selectedOwners.push(e.id);
  417. this.ownersCopy.every(function (ownerCopy) {
  418. if (ownerCopy.id==e.id) {
  419. ownerCopy.style=true;
  420. return false;
  421. }
  422. return true;
  423. });
  424. }
  425. },
  426. selectedLogistic:function (e) {
  427. let selectedLogistics=this.selectedLogistics;
  428. let sign = true;
  429. for (let i=0;i<selectedLogistics.length;i++){
  430. if (selectedLogistics[i]==e.id){
  431. selectedLogistics.splice(i,1);
  432. this.logisticsAll.every(function (logistic) {
  433. if (logistic.id==e.id) {
  434. logistic.style=false;
  435. return false;
  436. }
  437. return true;
  438. });
  439. sign=false;
  440. break;
  441. }
  442. }
  443. if (sign) {
  444. this.selectedLogistics.push(e.id);
  445. this.logisticsAll.every(function (logistic) {
  446. if (logistic.id==e.id) {
  447. logistic.style=true;
  448. return false;
  449. }
  450. return true;
  451. });
  452. }
  453. },
  454. checkAll(e){
  455. if (e.target.checked){
  456. this.ownersModel.forEach((el,i)=>{
  457. if (this.checkData.indexOf(el.id) == '-1'){
  458. this.checkData.push(el.id);
  459. }
  460. });
  461. }else {
  462. this.checkData = [];
  463. }
  464. },
  465. statisticExport:function (e) {
  466. if (e==1){
  467. if (this.checkData&&this.checkData.length<=0){
  468. tempTip.setDuration(4000);
  469. tempTip.showSuccess('没有勾选任何记录');
  470. return;
  471. }
  472. location.href="{{url('package/statistics?checkSign=')}}"+this.checkData;
  473. }else{
  474. /* let formData=new FormData();
  475. formData.append('owner_id',this.selectedOwners);
  476. formData.append('logistic_id',this.selectedLogistics);
  477. formData.append('date_start',this.filterData.date_start);
  478. formData.append('date_end',this.filterData.date_end);
  479. formData.append('checkSign','-1');*/
  480. location.href="{{url('package/statistics?owner_id=')}}"+this.selectedOwners+
  481. "&logistic_id="+this.selectedLogistics+"&date_start="+this.filterData.date_start
  482. +"&date_end="+this.filterData.date_end+"&checkSign=-1";
  483. }
  484. },
  485. hourFilter:function(e){
  486. setTimeout(function(){
  487. e.target.value=e.target.value.replace(':',':');
  488. e.target.value=e.target.value.replace(/[a-zA-Z]/,'');
  489. e.target.value=e.target.value.replace(/^([\d]{1})([\s]{1})/,"$1:");
  490. e.target.value=e.target.value.replace(/^([\d]{1})([\d]{1})([\s]{1})/,"$1$2:");
  491. //e.target.value=e.target.value.replace(/^([3-9]{1})([\d]{1})/,"$1:$2");
  492. e.target.value=e.target.value.replace(/^([\d]{1})([\d]{1})([\d]{1})/,"$1$2:$3");
  493. e.target.value=e.target.value.replace(/^([\d]{1})([\d]{1})([\d]{1})([\d]{1})(.*?)/,"$1$2$3$4");
  494. e.target.value=e.target.value.replace(/^([\d]{1})([\d]{1})([\d]{1})([\d]{1})/,"$1$2:$3$4");
  495. e.target.value=e.target.value.replace(/^([\d]{1})([\d]{1}):([\d]{1})([\d]{1})([\s\S]{1})/,"$1$2:$3$4");
  496. e.target.value=e.target.value.replace(/^([\d]{1})([\d]{1}):([\D]{1,99})/,"$1$2:");
  497. e.target.value=e.target.value.replace(/^([\d]{1})([\d]{1})([\d]{1})\./,"$1:$2$3");
  498. e.target.value=e.target.value.replace(/^([\d]{1})\.([\d]{1})([\d]{1})/,"$1:$2$3");
  499. e.target.value=e.target.value.replace(/^([\d]{1})([\d]{2})([\S\s]{1,99})/,"$1$2:$3");
  500. e.target.value=e.target.value.replace(/^([\d]{1}):([\d]{2})([\S\s]{1,99})/,"$1:$2");
  501. e.target.value=e.target.value.replace(/^([\d])/,"$1");
  502. e.target.value=e.target.value.replace(/^([1])([\d]{1})/,"$1$2");
  503. e.target.value=e.target.value.replace(/^([3-9])([\d]{1})/,"2$2");
  504. e.target.value=e.target.value.replace(/^([2-9]{1})([4-9]{1})/,"$13");
  505. e.target.value=e.target.value.replace(/^([\d]{1})([\d]{1}):([6-9]{1})/,"$1$2:5");
  506. },1);
  507. },
  508. }
  509. });
  510. </script>
  511. @endsection