Report.vue 4.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. <script setup>
  2. import { watch, ref } from 'vue'
  3. import { Inertia } from '@inertiajs/inertia'
  4. import { Head } from '@inertiajs/inertia-vue3'
  5. import { pickBy } from 'lodash'
  6. import tableHeader from './tableHeader'
  7. import { useDateRangeFilter } from '@/components/useDateRangeFilter'
  8. import DashboardLayout from '@/layouts/DashboardLayout.vue'
  9. import AppPagination from '@/components/AppPagination.vue'
  10. import AppButtonLink from '@/components/AppButtonLink.vue'
  11. const props = defineProps({
  12. mutations: {
  13. type: Object,
  14. default: {
  15. details: {
  16. data: [],
  17. links: [],
  18. total: 0,
  19. },
  20. },
  21. },
  22. initialDateRange: Array,
  23. })
  24. const { dates, startDate, endDate } = useDateRangeFilter(props)
  25. watch(dates, () => {
  26. Inertia.reload({
  27. data: pickBy({
  28. startDate: startDate.value,
  29. endDate: endDate.value,
  30. }),
  31. only: ['mutations'],
  32. })
  33. const params = window.location.search
  34. exportExcelLink.value = `/reports/mutations/export/excel${params}`
  35. })
  36. const filterReset = () => {
  37. Inertia.get('/reports/mutations')
  38. }
  39. const linkReference = (data) => {
  40. if (data.topUpId) {
  41. return route('top-ups.show', data.topUpId)
  42. } else if (data.expenseId) {
  43. return route('expenses.show', data.expenseId)
  44. } else {
  45. return route('out-transactions.show', data.outTransactionId)
  46. }
  47. }
  48. const exportExcelLink = ref('/reports/mutations/export/excel')
  49. </script>
  50. <template>
  51. <DashboardLayout>
  52. <Head title="Laporan Mutasi" />
  53. <DataTable
  54. responsive-layout="scroll"
  55. column-resize-mode="expand"
  56. :value="mutations.details.data"
  57. :row-hover="true"
  58. :striped-rows="true"
  59. >
  60. <template #header>
  61. <h1>Laporan Mutasi</h1>
  62. <div class="grid">
  63. <div class="col-12 md:col-8">
  64. <div class="grid">
  65. <div class="col-12 md:col-4">
  66. <Calendar
  67. touch-u-i
  68. class="w-full"
  69. v-model="dates"
  70. selection-mode="range"
  71. placeholder="filter waktu..."
  72. date-format="dd/mm/yy"
  73. :manual-input="false"
  74. />
  75. </div>
  76. <div class="col-auto mt-2 ml-2">
  77. <Button
  78. label="reset"
  79. class="p-button-link"
  80. @click="filterReset"
  81. />
  82. </div>
  83. </div>
  84. </div>
  85. <div
  86. class="col-12 md:col-4 flex flex-column md:flex-row justify-content-end"
  87. >
  88. <AppButtonLink
  89. v-if="mutations.details.total"
  90. label="Export excel"
  91. class-button="p-button-outlined md:w-16rem"
  92. icon="pi pi-file-excel"
  93. :inertia-link="false"
  94. :href="exportExcelLink"
  95. />
  96. </div>
  97. </div>
  98. <div v-if="mutations.totalAmount" class="grid mt-5 ml-1">
  99. <div class="col-auto mr-7">
  100. <h2>
  101. <span class="text-base">
  102. <i class="pi pi-wallet" /> Pendapatan</span
  103. >
  104. <br />
  105. <span class="text-xl font-bold">{{ mutations.totalIncome }}</span>
  106. </h2>
  107. </div>
  108. <div class="col-auto mr-7">
  109. <h2>
  110. <span class="text-base">
  111. <i class="pi pi-wallet" /> Pengeluaran</span
  112. >
  113. <br />
  114. <span class="text-xl font-bold">{{
  115. mutations.totalExpense
  116. }}</span>
  117. </h2>
  118. </div>
  119. <div class="col-auto">
  120. <h2>
  121. <span class="text-base"> <i class="pi pi-wallet" /> Total </span>
  122. <br />
  123. <span class="text-xl font-bold">{{ mutations.totalAmount }}</span>
  124. </h2>
  125. </div>
  126. </div>
  127. </template>
  128. <Column
  129. v-for="value in tableHeader"
  130. :field="value.field"
  131. :header="value.header"
  132. :key="value.field"
  133. />
  134. <Column>
  135. <template #body="{ data }">
  136. <AppButtonLink
  137. icon="pi pi-link"
  138. class="p-button-text p-button-icon-only p-button-rounded p-button-text"
  139. v-tooltip.bottom="'Detail Pengeluaran'"
  140. :href="linkReference(data)"
  141. />
  142. </template>
  143. </Column>
  144. </DataTable>
  145. <AppPagination :links="mutations.details.links" />
  146. </DashboardLayout>
  147. </template>