Report.vue 4.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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. initialDateRage: Array,
  23. })
  24. const { dates, startDate, endDate } = useDateRangeFilter(props.initialDateRage)
  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 label="reset" class="p-button-link" @click="filterReset" />
  78. </div>
  79. </div>
  80. </div>
  81. <div class="col-12 md:col-4 flex flex-column md:flex-row justify-content-end">
  82. <AppButtonLink
  83. v-if="mutations.details.total"
  84. label="Export excel"
  85. class-button="p-button-outlined md:w-16rem"
  86. icon="pi pi-file-excel"
  87. :inertia-link="false"
  88. :href="exportExcelLink"
  89. />
  90. </div>
  91. </div>
  92. <div v-if="mutations.totalAmount" class="grid mt-5 ml-1">
  93. <div class="col-auto mr-7">
  94. <h2>
  95. <span class="text-base"> <i class="pi pi-wallet" /> Pendapatan</span>
  96. <br />
  97. <span class="text-xl font-bold">{{ mutations.totalIncome }}</span>
  98. </h2>
  99. </div>
  100. <div class="col-auto mr-7">
  101. <h2>
  102. <span class="text-base"> <i class="pi pi-wallet" /> Pengeluaran</span>
  103. <br />
  104. <span class="text-xl font-bold">{{ mutations.totalExpense }}</span>
  105. </h2>
  106. </div>
  107. <div class="col-auto">
  108. <h2>
  109. <span class="text-base"> <i class="pi pi-wallet" /> Total </span>
  110. <br />
  111. <span class="text-xl font-bold">{{ mutations.totalAmount }}</span>
  112. </h2>
  113. </div>
  114. </div>
  115. </template>
  116. <Column v-for="value in tableHeader" :field="value.field" :header="value.header" :key="value.field" />
  117. <Column>
  118. <template #body="{ data }">
  119. <AppButtonLink
  120. icon="pi pi-link"
  121. class="p-button-text p-button-icon-only p-button-rounded p-button-text"
  122. :href="linkReference(data)"
  123. />
  124. </template>
  125. </Column>
  126. </DataTable>
  127. <AppPagination :links="mutations.details.links" />
  128. </DashboardLayout>
  129. </template>