選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

report-index.js 5.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. var app = new Vue({
  2. el: '#app-report-index',
  3. data: {
  4. loading: true,
  5. showLoading: true,
  6. showReport: false,
  7. tableReport: [],
  8. currentSection: 'users',
  9. sections: [
  10. {
  11. name: 'Utilisateurs',
  12. id: 'users',
  13. icon: 'fa-users',
  14. },
  15. {
  16. name: 'Points de vente',
  17. id: 'points-sale',
  18. icon: 'fa-map-marker',
  19. },
  20. {
  21. name: 'Distributions',
  22. id: 'distributions',
  23. icon: 'fa-calendar',
  24. }
  25. ],
  26. termSearchUser: '',
  27. usersArray: [],
  28. pointsSaleArray: [],
  29. distributionYearsArray: [],
  30. distributionYear: null,
  31. distributionsByMonthArray: []
  32. },
  33. mounted: function() {
  34. this.init() ;
  35. },
  36. methods: {
  37. init: function() {
  38. var app = this ;
  39. axios.get("ajax-init",{params: {}})
  40. .then(function(response) {
  41. app.usersArray = response.data.usersArray ;
  42. app.pointsSaleArray = response.data.pointsSaleArray ;
  43. app.distributionYearsArray = response.data.distributionYearsArray ;
  44. app.distributionYear = app.distributionYearsArray[app.distributionYearsArray.length - 1] ;
  45. app.distributionsByMonthArray = response.data.distributionsByMonthArray ;
  46. app.loading = false ;
  47. app.showLoading = false ;
  48. });
  49. },
  50. changeSection: function(section) {
  51. this.currentSection = section.id ;
  52. },
  53. countUsers: function() {
  54. var count = 0 ;
  55. for(var i = 0; i < this.usersArray.length; i++) {
  56. if(this.usersArray[i].checked) {
  57. count ++ ;
  58. }
  59. }
  60. return count ;
  61. },
  62. countPointsSale: function() {
  63. var count = 0 ;
  64. for(var i = 0; i < this.pointsSaleArray.length; i++) {
  65. if(this.pointsSaleArray[i].checked) {
  66. count ++ ;
  67. }
  68. }
  69. return count ;
  70. },
  71. countDistributions: function() {
  72. var count = 0 ;
  73. for(var i in this.distributionsByMonthArray) {
  74. for(var j = 0; j < this.distributionsByMonthArray[i].distributions.length; j++) {
  75. if(this.distributionsByMonthArray[i].distributions[j].checked) {
  76. count ++ ;
  77. }
  78. }
  79. }
  80. return count ;
  81. },
  82. countDistributionsByMonth: function(month) {
  83. var count = 0 ;
  84. for(var j = 0; j < this.distributionsByMonthArray[month].distributions.length; j++) {
  85. if(this.distributionsByMonthArray[month].distributions[j].checked) {
  86. count ++ ;
  87. }
  88. }
  89. return count ;
  90. },
  91. selectDistributions: function(month) {
  92. var countDistributions = this.countDistributionsByMonth(month) ;
  93. for(var j = 0; j < this.distributionsByMonthArray[month].distributions.length; j++) {
  94. Vue.set(this.distributionsByMonthArray[month].distributions[j], 'checked', countDistributions ? false : true);
  95. }
  96. this.reportChange();
  97. },
  98. generateReport: function() {
  99. var app = this ;
  100. app.showLoading = true ;
  101. var data = new FormData();
  102. var idsUsersArray = [] ;
  103. for(var i = 0; i < app.usersArray.length; i++) {
  104. if(app.usersArray[i].checked) {
  105. idsUsersArray.push(app.usersArray[i].user_id) ;
  106. }
  107. }
  108. var idsPointsSaleArray = [] ;
  109. for(var i = 0; i < app.pointsSaleArray.length; i++) {
  110. if(app.pointsSaleArray[i].checked) {
  111. idsPointsSaleArray.push(app.pointsSaleArray[i].id) ;
  112. }
  113. }
  114. var idsDistributionsArray = [] ;
  115. for(var i in this.distributionsByMonthArray) {
  116. for(var j = 0; j < this.distributionsByMonthArray[i].distributions.length; j++) {
  117. if(this.distributionsByMonthArray[i].distributions[j].checked) {
  118. idsDistributionsArray.push(app.distributionsByMonthArray[i].distributions[j].id) ;
  119. }
  120. }
  121. }
  122. data.append('users', idsUsersArray);
  123. data.append('pointsSale', idsPointsSaleArray);
  124. data.append('distributions', idsDistributionsArray);
  125. axios.post("ajax-report",data)
  126. .then(function(response) {
  127. app.tableReport = response.data ;
  128. app.showLoading = false ;
  129. app.showReport = true ;
  130. });
  131. },
  132. reportChange: function() {
  133. this.showReport = false;
  134. }
  135. }
  136. });