No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

report-index.js 5.6KB

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