statistics.blade.php 25 KB

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