Index.vue 3.1KB

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