| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- <script setup>
- import { Inertia } from '@inertiajs/inertia'
- import { useConfirm } from 'primevue/useconfirm'
- import { indexTable } from './config'
- import AppSearchFilter from '@/components/AppSearchFilter.vue'
- import AppButtonLink from '@/components/AppButtonLink.vue'
- import AppPagination from '@/components/AppPagination.vue'
- import DashboardLayout from '@/layouts/Dashboard/DashboardLayout.vue'
-
- defineProps({
- initialFilters: Object,
- customers: Object,
- })
-
- const deleteConfirm = useConfirm()
-
- const onDelete = (data) => {
- deleteConfirm.require({
- message: `Yakin akan menghapus data (${data.name}) ?`,
- header: 'Hapus Pelanggan',
- acceptLabel: 'Iya',
- rejectLabel: 'Tidak',
- accept: () => {
- Inertia.delete(route('customers.destroy', data.id))
- },
- reject: () => {
- deleteConfirm.close()
- },
- })
- }
- </script>
-
- <template>
- <DashboardLayout title="Daftar Pelanggan">
- <DataTable
- responsiveLayout="scroll"
- :value="customers.data"
- :rowHover="true"
- :stripedRows="true"
- >
- <template #header>
- <h1>Pelanggan</h1>
-
- <div class="grid">
- <div class="col-12 md:col-8">
- <AppSearchFilter
- placeholder="nama, no hp, npwp"
- name-param="search"
- :initial-search="initialFilters"
- />
- </div>
-
- <div
- class="col-12 md:col-4 flex flex-column md:flex-row justify-content-end"
- >
- <AppButtonLink
- label="Tambah Pelanggan"
- icon="pi pi-pencil"
- class="p-button-outlined"
- :href="route('customers.create')"
- />
- </div>
- </div>
- </template>
-
- <Column
- v-for="value in indexTable"
- :field="value.field"
- :header="value.header"
- :key="value.field"
- />
-
- <Column>
- <template #body="{ data }">
- <div class="grid gap-2">
- <AppButtonLink
- icon="pi pi-pencil"
- class="p-button-icon-only p-button-rounded p-button-text"
- v-tooltip.bottom="'Ubah Pelanggan'"
- :href="route('customers.edit', data.id)"
- />
-
- <Button
- v-if="!data.isUsed"
- icon="pi pi-trash"
- class="p-button-icon-only p-button-rounded p-button-text"
- v-tooltip.bottom="'Hapus Pelanggan'"
- @click="onDelete(data)"
- />
-
- <AppButtonLink
- icon="pi pi-chevron-right"
- class="p-button-icon-only p-button-rounded p-button-text"
- v-tooltip.bottom="'History Pembelian'"
- :href="route('customers.show', data.id)"
- />
- </div>
- </template>
- </Column>
- </DataTable>
-
- <AppPagination :links="customers.links" />
- </DashboardLayout>
- </template>
|