217 lines
8.6 KiB
Vue
217 lines
8.6 KiB
Vue
<script setup>
|
|
import { onMounted, onUnmounted } from 'vue';
|
|
import { useI18n } from 'vue-i18n';
|
|
import { useQuasar } from 'quasar';
|
|
import { useRouter } from 'vue-router';
|
|
import { useStateStore } from 'stores/useStateStore';
|
|
import Paginate from 'src/components/PaginateData.vue';
|
|
import { toDate, toCurrency } from 'src/filters/index';
|
|
import TicketSummaryDialog from './Card/TicketSummaryDialog.vue';
|
|
|
|
import TeleportSlot from 'components/ui/TeleportSlot.vue';
|
|
import VnSearchbar from 'src/components/ui/VnSearchbar.vue';
|
|
import VnFilterPanel from 'src/components/ui/VnFilterPanel.vue';
|
|
// import FetchData from 'components/FetchData.vue';
|
|
|
|
const router = useRouter();
|
|
const quasar = useQuasar();
|
|
const { t } = useI18n();
|
|
const stateStore = useStateStore();
|
|
|
|
onMounted(() => stateStore.toggleRightDrawer());
|
|
onUnmounted(() => stateStore.toggleRightDrawer());
|
|
|
|
const filter = {
|
|
include: [
|
|
{
|
|
relation: 'client',
|
|
scope: {
|
|
include: {
|
|
relation: 'salesPersonUser',
|
|
scope: {
|
|
fields: ['name'],
|
|
},
|
|
},
|
|
},
|
|
},
|
|
{
|
|
relation: 'ticketState',
|
|
scope: {
|
|
fields: ['stateFk', 'code', 'alertLevel'],
|
|
include: {
|
|
relation: 'state',
|
|
scope: {
|
|
fields: ['name'],
|
|
},
|
|
},
|
|
},
|
|
},
|
|
],
|
|
};
|
|
|
|
function stateColor(row) {
|
|
if (row.alertLevelCode === 'OK') return 'green';
|
|
if (row.alertLevelCode === 'FREE') return 'blue-3';
|
|
if (row.alertLevel === 1) return 'orange';
|
|
if (row.alertLevel === 0) return 'red';
|
|
return 'red';
|
|
}
|
|
|
|
function navigate(id) {
|
|
router.push({ path: `/ticket/${id}` });
|
|
}
|
|
|
|
function viewSummary(id) {
|
|
quasar.dialog({
|
|
component: TicketSummaryDialog,
|
|
componentProps: {
|
|
id,
|
|
},
|
|
});
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<teleport-slot to="#searchbar">
|
|
<VnSearchbar data-key="TicketList" />
|
|
</teleport-slot>
|
|
<teleport-slot to="#rightPanel">
|
|
<VnFilterPanel data-key="TicketList">
|
|
<template #body="{ params }">
|
|
<q-list>
|
|
<q-item>
|
|
<q-item-section>
|
|
<q-input
|
|
v-model="params.search"
|
|
label="Search by id or name"
|
|
class="full-width"
|
|
lazy-rules
|
|
autofocus
|
|
/>
|
|
</q-item-section>
|
|
</q-item>
|
|
<q-item>
|
|
<q-item-section>
|
|
<q-input
|
|
v-model="params.clientFk"
|
|
label="Customer ID"
|
|
lazy-rules
|
|
autofocus
|
|
/>
|
|
</q-item-section>
|
|
</q-item>
|
|
</q-list>
|
|
</template>
|
|
</VnFilterPanel>
|
|
</teleport-slot>
|
|
<q-page class="q-pa-md">
|
|
<paginate
|
|
data-key="TicketList"
|
|
url="Tickets/filter"
|
|
: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('ticket.list.nickname') }}
|
|
</q-item-label>
|
|
<q-item-label>{{ row.nickname }}</q-item-label>
|
|
</q-item-section>
|
|
<q-item-section>
|
|
<q-item-label caption>
|
|
{{ t('ticket.list.state') }}
|
|
</q-item-label>
|
|
<q-item-label>
|
|
<q-chip
|
|
:color="stateColor(row)"
|
|
class="q-ma-none"
|
|
dense
|
|
>
|
|
{{ row.state }}
|
|
</q-chip>
|
|
</q-item-label>
|
|
</q-item-section>
|
|
</q-item>
|
|
<q-item class="q-pa-none">
|
|
<q-item-section>
|
|
<q-item-label caption>
|
|
{{ t('ticket.list.shipped') }}
|
|
</q-item-label>
|
|
<q-item-label>
|
|
{{ toDate(row.shipped) }}
|
|
</q-item-label>
|
|
</q-item-section>
|
|
<q-item-section>
|
|
<q-item-label caption>
|
|
{{ t('ticket.list.landed') }}
|
|
</q-item-label>
|
|
<q-item-label>
|
|
{{ toDate(row.landed) }}
|
|
</q-item-label>
|
|
</q-item-section>
|
|
</q-item>
|
|
<q-item class="q-pa-none">
|
|
<q-item-section>
|
|
<q-item-label caption>
|
|
{{ t('ticket.list.salesPerson') }}
|
|
</q-item-label>
|
|
<q-item-label>
|
|
{{ row.salesPerson }}
|
|
</q-item-label>
|
|
</q-item-section>
|
|
<q-item-section>
|
|
<q-item-label caption>
|
|
{{ t('ticket.list.total') }}
|
|
</q-item-label>
|
|
<q-item-label>{{
|
|
toCurrency(row.totalWithVat)
|
|
}}</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
|
|
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="viewSummary(row.id)"
|
|
>
|
|
<q-tooltip>{{
|
|
t('components.smartCard.openSummary')
|
|
}}</q-tooltip>
|
|
</q-btn>
|
|
</q-card-actions>
|
|
</q-item>
|
|
</q-card>
|
|
</template>
|
|
</paginate>
|
|
</q-page>
|
|
</template>
|