statistics.blade.php 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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 id="form_div"></div>
  10. <span class="dropdown">
  11. <button class="btn btn-outline-dark btn-sm form-control-sm dropdown-toggle tooltipTarget"
  12. data-toggle="dropdown" title="导出所有页将会以搜索条件得到的筛选结果,将其全部记录(每一页)导出">
  13. 导出Excel
  14. </button>
  15. <div class="dropdown-menu">
  16. <a class="dropdown-item" @click="statisticExport(false)" href="javascript:">导出勾选内容</a>
  17. <a class="dropdown-item" @click="statisticExport(true)" href="javascript:">导出所有页</a>
  18. </div>
  19. </span>
  20. <table class="table table-striped table-sm text-nowrap table-hover">
  21. <tr>
  22. <th>
  23. <label for="all">
  24. <input id="all" type="checkbox" @click="checkAll($event)">全选
  25. </label>
  26. </th>
  27. <th>货主</th>
  28. <th>总计</th>
  29. <th v-for="logistic in logistics">@{{ logistic.value }}</th>
  30. </tr>
  31. <tr v-for="package in packages">
  32. <td>
  33. <input class="checkItem" type="checkbox" :value="package.owner_id" v-model="checkData">
  34. </td>
  35. <th class="text-muted">@{{ package.owner_name }}</th>
  36. <td><p v-if="package.sum">@{{ package.sum }}</p><p v-else>0</p></td>
  37. <td class="text-muted" v-for="logistic in logistics"><span v-if="package[logistic.name]">@{{ package[logistic.name] }}</span><span v-else>0</span></td>
  38. </tr>
  39. </table>
  40. </div>
  41. </div>
  42. @endsection
  43. @section('lastScript')
  44. <script type="text/javascript" src="{{asset('js/queryForm/queryForm.js')}}"></script>
  45. <script type="text/javascript" src="{{asset('js/queryForm/export.js')}}"></script>
  46. <script>
  47. new Vue({
  48. el:"#statistics",
  49. data:{
  50. packages : [
  51. @foreach($packages as $package)
  52. {!! $package !!},
  53. @endforeach
  54. ],
  55. owners:[
  56. @foreach($owners as $owner)
  57. {name:'{{$owner->id}}', value: '{{$owner->name}}'},
  58. @endforeach
  59. ],
  60. logistics:[
  61. @foreach($logistics as $logistic)
  62. {name:'{{$logistic->id}}', value: '{{$logistic->name}}'},
  63. @endforeach
  64. ],
  65. checkData:[],
  66. },
  67. watch:{
  68. checkData:{
  69. handler(){
  70. if (this.checkData.length === this.packages.length){
  71. document.querySelector('#all').checked = true;
  72. }else {
  73. document.querySelector('#all').checked = false;
  74. }
  75. },
  76. deep:true
  77. }
  78. },
  79. mounted:function(){
  80. $(".tooltipTarget").tooltip({'trigger':'hover'});
  81. $('#statistics').removeClass('d-none');
  82. let data = [[
  83. {name:'logistic_id',type:'select_multiple_select',tip:['输入关键词快速定位下拉列表,回车确定','选择要显示的物流公司'],
  84. placeholder:['物流公司','定位或多选物流公司'],data:this.logistics},
  85. {name:'owner_id',type:'select_multiple_select',tip:['输入关键词快速定位下拉列表,回车确定','选择要显示的客户'],
  86. placeholder:['货主','定位或多选货主'],data:this.owners},
  87. {name:'created_at_start',type:'time',tip:['选择显示指定日期的起始时间','选择显示指定日期的起始时间']},
  88. {name:'created_at_end',type:'time',tip:['选择显示指定日期的结束时间','选择显示指定日期的结束时间']},
  89. ]];
  90. this.form = new query({
  91. el:'#form_div',
  92. condition:data,
  93. isPaginations:false,
  94. });
  95. this.form.init();
  96. },
  97. methods: {
  98. checkAll(e){
  99. if (e.target.checked){
  100. this.packages.forEach((el)=>{
  101. if (this.checkData.indexOf(el.owner_id) === '-1'){
  102. this.checkData.push(el.owner_id);
  103. }
  104. });
  105. }else {
  106. this.checkData = [];
  107. }
  108. },
  109. statisticExport:function (checkAllSign) {
  110. let url = '{{url('package/statistics/export')}}';
  111. let token='{{ csrf_token() }}';
  112. //excelExport 定义在 js/queryForm/export200918.js
  113. excelExport(checkAllSign,this.checkData,url,this.sum,token);
  114. },
  115. }
  116. });
  117. </script>
  118. @endsection