Index.vue 2.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. initialDateRage: Array,
  14. })
  15. const { dates, startDate, endDate } = useDateRangeFilter(props.initialDateRage)
  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 label="reset" class="p-button-link" @click="filterReset" />
  60. </div>
  61. </div>
  62. </div>
  63. <div class="col-12 md:col-4 flex flex-column md:flex-row justify-content-end">
  64. <AppButtonLink
  65. label="Tambah Pengeluaran"
  66. class="p-button-outlined"
  67. icon="pi pi-pencil"
  68. :href="route('expenses.create')"
  69. />
  70. </div>
  71. </div>
  72. </template>
  73. <Column v-for="value in tableHeader" :field="value.field" :header="value.header" :key="value.field" />
  74. <Column>
  75. <template #body="{ data }">
  76. <AppButtonLink
  77. icon="pi pi-eye"
  78. class="p-button-text p-button-icon-only p-button-rounded p-button-text"
  79. :href="route('expenses.show', data.id)"
  80. />
  81. </template>
  82. </Column>
  83. </DataTable>
  84. <AppPagination :links="expenses.links" />
  85. </DashboardLayout>
  86. </template>