Index.vue 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <script setup>
  2. import CardCount from './Components/CardCount.vue'
  3. import CardProductFavorite from './Components/CardProductFavorite.vue'
  4. import DashboardLayout from '@/layouts/Dashboard/DashboardLayout.vue'
  5. import { computed } from '@vue/reactivity'
  6. const props = defineProps([
  7. 'productAmount',
  8. 'productFavorites',
  9. 'salePurchaseStatistic',
  10. ])
  11. const salePurchase = computed(() => {
  12. const data = {
  13. datasets: [
  14. {
  15. label: null,
  16. data: null,
  17. fill: false,
  18. backgroundColor: '#2f4860',
  19. borderColor: '#2f4860',
  20. tension: 0.4,
  21. },
  22. {
  23. label: null,
  24. data: null,
  25. fill: false,
  26. backgroundColor: '#00bb7e',
  27. borderColor: '#00bb7e',
  28. tension: 0.4,
  29. },
  30. ],
  31. }
  32. let index = 0
  33. for (const key in props.salePurchaseStatistic) {
  34. data.datasets[index].label = key
  35. data.datasets[index].data = props.salePurchaseStatistic[key]
  36. console.info(props.salePurchaseStatistic[key])
  37. index++
  38. }
  39. return data
  40. })
  41. const barData = {
  42. labels: [
  43. 'Jan',
  44. 'Feb',
  45. 'Mar',
  46. 'Apr',
  47. 'May',
  48. 'Jun',
  49. 'Jul',
  50. 'Aug',
  51. 'Sep',
  52. 'Oct',
  53. 'Nov',
  54. 'Dec',
  55. ],
  56. datasets: [
  57. {
  58. label: 'Bulan lalu',
  59. data: [
  60. 65_000_000, 59_000_000, 80_000_000, 81_000_000, 56_000_000, 55_000_000,
  61. 40_000_000,
  62. ],
  63. fill: false,
  64. backgroundColor: '#2f4860',
  65. borderColor: '#2f4860',
  66. tension: 0.4,
  67. },
  68. {
  69. label: 'Bulan ini',
  70. data: [
  71. 28_000_000, 48_000_000, 40_000_000, 19_000_000, 86_000_000, 27_000_000,
  72. 90_000_000,
  73. ],
  74. fill: false,
  75. backgroundColor: '#00bb7e',
  76. borderColor: '#00bb7e',
  77. tension: 0.4,
  78. },
  79. ],
  80. }
  81. </script>
  82. <template>
  83. <DashboardLayout title="Dashboard">
  84. <div class="grid">
  85. <div class="col-12">
  86. <div class="grid">
  87. <CardCount :products="productAmount" />
  88. </div>
  89. </div>
  90. <div class="col-12 xl:col-6">
  91. <div class="grid">
  92. <div class="col-12">
  93. <div class="card">
  94. <h5>Pembelian dan Penjualan</h5>
  95. <Chart type="line" :data="salePurchase" />
  96. </div>
  97. </div>
  98. <div class="col-12">
  99. <CardProductFavorite :products="productFavorites" />
  100. </div>
  101. </div>
  102. </div>
  103. <div class="col-12 xl:col-6">
  104. <div class="grid">
  105. <div class="col-12">
  106. <div class="card">
  107. <h5>Pembelian</h5>
  108. <Chart type="bar" :data="barData" />
  109. </div>
  110. </div>
  111. <div class="col-12">
  112. <div class="card">
  113. <h5>Pendapatan</h5>
  114. <Chart type="bar" :data="barData" />
  115. </div>
  116. </div>
  117. </div>
  118. </div>
  119. </div>
  120. </DashboardLayout>
  121. </template>