Report.vue 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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. alert('under construction')
  46. // return route('out-transactions.show', data.outTransactionId)
  47. }
  48. }
  49. const exportExcelLink = ref('/reports/mutations/export/excel')
  50. </script>
  51. <template>
  52. <DashboardLayout>
  53. <Head title="Laporan Mutasi" />
  54. <DataTable
  55. responsive-layout="scroll"
  56. column-resize-mode="expand"
  57. :value="mutations.details.data"
  58. :row-hover="true"
  59. :striped-rows="true"
  60. >
  61. <template #header>
  62. <h1>Laporan Mutasi</h1>
  63. <div class="grid">
  64. <div class="col-12 md:col-8">
  65. <div class="grid">
  66. <div class="col-12 md:col-4">
  67. <Calendar
  68. touch-u-i
  69. class="w-full"
  70. v-model="dates"
  71. selection-mode="range"
  72. placeholder="filter waktu..."
  73. date-format="dd/mm/yy"
  74. :manual-input="false"
  75. />
  76. </div>
  77. <div class="col-auto mt-2 ml-2">
  78. <Button label="reset" class="p-button-link" @click="filterReset" />
  79. </div>
  80. </div>
  81. </div>
  82. <div class="col-12 md:col-4 flex flex-column md:flex-row justify-content-end">
  83. <AppButtonLink
  84. v-if="mutations.details.total"
  85. label="Export excel"
  86. class-button="p-button-outlined md:w-16rem"
  87. icon="pi pi-file-excel"
  88. :inertia-link="false"
  89. :href="exportExcelLink"
  90. />
  91. </div>
  92. </div>
  93. <div v-if="mutations.totalAmount" class="grid mt-5 ml-1">
  94. <div class="col-auto mr-7">
  95. <h2>
  96. <span class="text-base"> <i class="pi pi-wallet" /> Pendapatan</span>
  97. <br />
  98. <span class="text-xl font-bold">{{ mutations.totalIncome }}</span>
  99. </h2>
  100. </div>
  101. <div class="col-auto mr-7">
  102. <h2>
  103. <span class="text-base"> <i class="pi pi-wallet" /> Pengeluaran</span>
  104. <br />
  105. <span class="text-xl font-bold">{{ mutations.totalExpense }}</span>
  106. </h2>
  107. </div>
  108. <div class="col-auto">
  109. <h2>
  110. <span class="text-base"> <i class="pi pi-wallet" /> Total </span>
  111. <br />
  112. <span class="text-xl font-bold">{{ mutations.totalAmount }}</span>
  113. </h2>
  114. </div>
  115. </div>
  116. </template>
  117. <Column v-for="value in tableHeader" :field="value.field" :header="value.header" :key="value.field" />
  118. <Column>
  119. <template #body="{ data }">
  120. <AppButtonLink
  121. icon="pi pi-link"
  122. class="p-button-text p-button-icon-only p-button-rounded p-button-text"
  123. :href="linkReference(data)"
  124. />
  125. </template>
  126. </Column>
  127. </DataTable>
  128. <AppPagination :links="mutations.details.links" />
  129. </DashboardLayout>
  130. </template>