125 lines
5.4 KiB
Vue
125 lines
5.4 KiB
Vue
<script setup>
|
|
import { ref } from 'vue';
|
|
import { useI18n } from 'vue-i18n';
|
|
import { useRouter } from 'vue-router';
|
|
import Paginate from 'src/components/Paginate.vue';
|
|
import { toDate } from 'src/filters/index';
|
|
import ClaimSummary from './Card/ClaimSummary.vue';
|
|
|
|
const router = useRouter();
|
|
const { t } = useI18n();
|
|
|
|
const filter = {
|
|
include: [
|
|
{
|
|
relation: 'client',
|
|
},
|
|
{
|
|
relation: 'claimState',
|
|
},
|
|
{
|
|
relation: 'worker',
|
|
scope: {
|
|
include: { relation: 'user' },
|
|
},
|
|
},
|
|
],
|
|
};
|
|
|
|
function stateColor(code) {
|
|
if (code === 'pending') return 'green';
|
|
if (code === 'managed') return 'orange';
|
|
if (code === 'resolved') return 'red';
|
|
}
|
|
|
|
function navigate(id) {
|
|
router.push({ path: `/claim/${id}` });
|
|
}
|
|
|
|
const preview = ref({
|
|
shown: false,
|
|
});
|
|
|
|
function showPreview(id) {
|
|
preview.value.shown = true;
|
|
preview.value.data = {
|
|
claimId: id,
|
|
};
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<q-page class="q-pa-md">
|
|
<paginate url="/Claims" :filter="filter" sort-by="id DESC" auto-load>
|
|
<template #body="{ rows }">
|
|
<q-card class="card" v-for="row of rows" :key="row.id">
|
|
<q-item class="q-pa-none items-start cursor-pointer q-hoverable" v-ripple clickable>
|
|
<q-item-section class="q-pa-md" @click="navigate(row.id)">
|
|
<div class="text-h6">{{ row.name }}</div>
|
|
<q-item-label caption>#{{ row.id }}</q-item-label>
|
|
<q-list>
|
|
<q-item class="q-pa-none">
|
|
<q-item-section>
|
|
<q-item-label caption>{{ t('claim.list.customer') }}</q-item-label>
|
|
<q-item-label>{{ row.client.name }}</q-item-label>
|
|
</q-item-section>
|
|
<q-item-section>
|
|
<q-item-label caption>{{ t('claim.list.assignedTo') }}</q-item-label>
|
|
<q-item-label>{{ row.worker.user.name }}</q-item-label>
|
|
</q-item-section>
|
|
</q-item>
|
|
<q-item class="q-pa-none">
|
|
<q-item-section>
|
|
<q-item-label caption>{{ t('claim.list.created') }}</q-item-label>
|
|
<q-item-label>{{ toDate(row.created) }}</q-item-label>
|
|
</q-item-section>
|
|
<q-item-section>
|
|
<q-item-label caption>{{ t('claim.list.state') }}</q-item-label>
|
|
<q-item-label>
|
|
<q-chip :color="stateColor(row.claimState.code)" dense>
|
|
{{ row.claimState.description }}
|
|
</q-chip>
|
|
</q-item-label>
|
|
</q-item-section>
|
|
</q-item>
|
|
</q-list>
|
|
</q-item-section>
|
|
<q-separator vertical />
|
|
<q-card-actions vertical class="justify-between">
|
|
<!-- <q-btn color="grey-7" round flat icon="more_vert">
|
|
<q-tooltip>{{ t('customer.list.moreOptions') }}</q-tooltip>
|
|
<q-menu cover auto-close>
|
|
<q-list>
|
|
<q-item clickable>
|
|
<q-item-section avatar>
|
|
<q-icon name="add" />
|
|
</q-item-section>
|
|
<q-item-section>Add a note</q-item-section>
|
|
</q-item>
|
|
<q-item clickable>
|
|
<q-item-section avatar>
|
|
<q-icon name="logs" />
|
|
</q-item-section>
|
|
<q-item-section>Display claim logs</q-item-section>
|
|
</q-item>
|
|
</q-list>
|
|
</q-menu>
|
|
</q-btn> -->
|
|
|
|
<q-btn flat round color="orange" icon="arrow_circle_right" @click="navigate(row.id)">
|
|
<q-tooltip>{{ t('components.smartCard.openCard') }}</q-tooltip>
|
|
</q-btn>
|
|
<q-btn flat round color="grey-7" icon="preview" @click="showPreview(row.id)">
|
|
<q-tooltip>{{ t('components.smartCard.openSummary') }}</q-tooltip>
|
|
</q-btn>
|
|
</q-card-actions>
|
|
</q-item>
|
|
</q-card>
|
|
</template>
|
|
</paginate>
|
|
</q-page>
|
|
<q-dialog v-model="preview.shown">
|
|
<claim-summary :claim-id="preview.data.claimId" />
|
|
</q-dialog>
|
|
</template>
|