Index.vue 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <script setup>
  2. import { Inertia } from '@inertiajs/inertia'
  3. import { watch } from 'vue'
  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. expenses: Object,
  13. initialDateRange: Array,
  14. })
  15. const { dates, startDate, endDate } = useDateRangeFilter(props)
  16. watch(dates, () => {
  17. Inertia.get(
  18. '/expenses',
  19. pickBy({
  20. startDate: startDate.value,
  21. endDate: endDate.value,
  22. }),
  23. {
  24. preserveState: true,
  25. }
  26. )
  27. })
  28. const filterReset = () => {
  29. Inertia.get('/expenses')
  30. }
  31. </script>
  32. <template>
  33. <Head title="Pengeluaran" />
  34. <DashboardLayout>
  35. <DataTable
  36. responsive-layout="scroll"
  37. column-resize-mode="expand"
  38. :value="expenses.data"
  39. :row-hover="true"
  40. :striped-rows="true"
  41. >
  42. <template #header>
  43. <h1>Pengeluaran</h1>
  44. <div class="grid">
  45. <div class="col-12 md:col-8">
  46. <div class="grid">
  47. <div class="col-12 md:col-4">
  48. <Calendar
  49. touch-u-i
  50. class="w-full"
  51. v-model="dates"
  52. selection-mode="range"
  53. placeholder="filter waktu..."
  54. date-format="dd/mm/yy"
  55. :manual-input="false"
  56. />
  57. </div>
  58. <div class="col-auto mt-2 ml-2">
  59. <Button
  60. label="reset"
  61. class="p-button-link"
  62. @click="filterReset"
  63. />
  64. </div>
  65. </div>
  66. </div>
  67. <div
  68. class="col-12 md:col-4 flex flex-column md:flex-row justify-content-end"
  69. >
  70. <AppButtonLink
  71. label="Tambah Pengeluaran"
  72. class="p-button-outlined"
  73. icon="pi pi-pencil"
  74. :href="route('expenses.create')"
  75. />
  76. </div>
  77. </div>
  78. </template>
  79. <Column
  80. v-for="value in tableHeader"
  81. :field="value.field"
  82. :header="value.header"
  83. :key="value.field"
  84. />
  85. <Column>
  86. <template #body="{ data }">
  87. <AppButtonLink
  88. icon="pi pi-eye"
  89. class="p-button-text p-button-icon-only p-button-rounded p-button-text"
  90. v-tooltip.bottom="'Detail Pengeluaran'"
  91. :href="route('expenses.show', data.id)"
  92. />
  93. </template>
  94. </Column>
  95. </DataTable>
  96. <AppPagination :links="expenses.links" />
  97. </DashboardLayout>
  98. </template>