0
0
Fork 0
This commit is contained in:
Joan Sanchez 2023-03-16 11:47:52 +01:00
commit f4a4c68807
13 changed files with 380 additions and 203 deletions

View File

@ -73,3 +73,8 @@ const onResponseError = (error) => {
axios.interceptors.request.use(onRequest, onRequestError);
axios.interceptors.response.use(onResponse, onResponseError);
export {
onRequest,
onResponseError
}

View File

@ -4,7 +4,7 @@ import { useRoute } from 'vue-router';
import { useI18n } from 'vue-i18n';
import { toDate } from 'src/filters';
import TicketDescriptorPopover from 'pages/Ticket/Card/TicketDescriptorPopover.vue';
import TicketDescriptorProxy from 'pages/Ticket/Card/TicketDescriptorProxy.vue';
import ClaimDescriptorMenu from 'pages/Claim/Card/ClaimDescriptorMenu.vue';
import CardDescriptor from 'components/ui/CardDescriptor.vue';
@ -86,9 +86,8 @@ function stateColor(code) {
<q-item-label>
<span class="link">
{{ entity.ticketFk }}
<q-popup-proxy>
<ticket-descriptor-popover :id="entity.ticketFk" />
</q-popup-proxy>
<TicketDescriptorProxy :id="entity.ticketFk" />
</span>
</q-item-label>
</q-item-section>

View File

@ -4,6 +4,7 @@ import { useRoute } from 'vue-router';
import { useI18n } from 'vue-i18n';
import { toDate, toCurrency } from 'src/filters';
import CardSummary from 'components/ui/CardSummary.vue';
import WorkerDescriptorProxy from 'pages/Worker/Card/WorkerDescriptorProxy.vue';
const route = useRoute();
const { t } = useI18n();
@ -109,22 +110,30 @@ function stateColor(code) {
</q-item>
<q-item>
<q-item-section v-if="claim.worker && claim.worker.user">
<q-item-label caption>{{
t('claim.summary.assignedTo')
}}</q-item-label>
<q-item-label>{{
claim.worker.user.nickname
}}</q-item-label>
<q-item-label caption>
{{ t('claim.summary.assignedTo') }}
</q-item-label>
<q-item-label>
<span class="link">
{{ claim.worker.user.nickname }}
<WorkerDescriptorProxy :id="claim.workerFk" />
</span>
</q-item-label>
</q-item-section>
<q-item-section
v-if="claim.client && claim.client.salesPersonUser"
>
<q-item-label caption>{{
t('claim.summary.attendedBy')
}}</q-item-label>
<q-item-label>{{
claim.client.salesPersonUser.name
}}</q-item-label>
<q-item-label caption>
{{ t('claim.summary.attendedBy') }}
</q-item-label>
<q-item-label>
<span class="link">
{{ claim.client.salesPersonUser.name }}
<WorkerDescriptorProxy
:id="claim.client.salesPersonFk"
/>
</span>
</q-item-label>
</q-item-section>
</q-item>
</q-list>

View File

@ -6,7 +6,7 @@ import { useStateStore } from 'stores/useStateStore';
import { toDate } from 'filters/index';
import Paginate from 'components/PaginateData.vue';
import ClaimSummaryDialog from './Card/ClaimSummaryDialog.vue';
import CustomerDescriptorPopover from 'pages/Customer/Card/CustomerDescriptorPopover.vue';
import CustomerDescriptorProxy from 'pages/Customer/Card/CustomerDescriptorProxy.vue';
import VnSearchbar from 'components/ui/VnSearchbar.vue';
import ClaimFilter from './ClaimFilter.vue';
@ -173,9 +173,8 @@ function viewSummary(id) {
<q-tooltip>
{{ t('components.smartCard.viewDescription') }}
</q-tooltip>
<q-popup-proxy>
<CustomerDescriptorPopover :id="row.clientFk" />
</q-popup-proxy>
<CustomerDescriptorProxy :id="row.clientFk" />
</q-btn>
</q-card-actions>
</q-item>

View File

@ -9,7 +9,7 @@ const $props = defineProps({
});
</script>
<template>
<q-card>
<customer-descriptor v-if="$props.id" :id="$props.id" />
</q-card>
<q-popup-proxy>
<CustomerDescriptor v-if="$props.id" :id="$props.id" />
</q-popup-proxy>
</template>

View File

@ -3,8 +3,8 @@ import { ref, computed } from 'vue';
import { useRoute } from 'vue-router';
import { useI18n } from 'vue-i18n';
import { toCurrency, toDate } from 'src/filters';
import CardDescriptor from 'src/components/ui/CardDescriptor.vue';
import CustomerDescriptorPopover from 'src/pages/Customer/Card/CustomerDescriptorPopover.vue';
import CardDescriptor from 'components/ui/CardDescriptor.vue';
import CustomerDescriptorProxy from 'pages/Customer/Card/CustomerDescriptorProxy.vue';
const $props = defineProps({
id: {
@ -80,9 +80,7 @@ function ticketFilter(invoice) {
</q-item-label>
<q-item-label class="link">
{{ entity.client.name }}
<q-popup-proxy>
<customer-descriptor-popover :id="entity.client.id" />
</q-popup-proxy>
<CustomerDescriptorProxy :id="entity.client.id" />
</q-item-label>
</q-item-section>
<q-item-section v-if="entity.company">

View File

@ -9,7 +9,7 @@ const $props = defineProps({
});
</script>
<template>
<q-card>
<invoiceOut-descriptor v-if="$props.id" :id="$props.id" />
</q-card>
<q-popup-proxy>
<InvoiceOutDescriptor v-if="$props.id" :id="$props.id" />
</q-popup-proxy>
</template>

View File

@ -3,7 +3,7 @@ import { computed } from 'vue';
import { useRoute } from 'vue-router';
import { useI18n } from 'vue-i18n';
import { toDate } from 'src/filters';
import CustomerDescriptorPopover from 'src/pages/Customer/Card/CustomerDescriptorPopover.vue';
import CustomerDescriptorProxy from 'pages/Customer/Card/CustomerDescriptorProxy.vue';
import CardDescriptor from 'components/ui/CardDescriptor.vue';
import TicketDescriptorMenu from './TicketDescriptorMenu.vue';
@ -109,9 +109,7 @@ function stateColor(state) {
<q-item-label>
<span class="link">
{{ entity.clientFk }}
<q-popup-proxy>
<customer-descriptor-popover :id="entity.client.id" />
</q-popup-proxy>
<CustomerDescriptorProxy :id="entity.client.id" />
</span>
</q-item-label>
</q-item-section>

View File

@ -9,7 +9,7 @@ const $props = defineProps({
});
</script>
<template>
<q-card>
<ticket-descriptor v-if="$props.id" :id="$props.id" />
</q-card>
<q-popup-proxy>
<TicketDescriptor v-if="$props.id" :id="$props.id" />
</q-popup-proxy>
</template>

View File

@ -7,6 +7,8 @@ import { dashIfEmpty, toDate, toCurrency } from 'src/filters';
import SkeletonSummary from 'components/ui/SkeletonSummary.vue';
import FetchData from 'components/FetchData.vue';
import FetchedTags from 'components/ui/FetchedTags.vue';
import InvoiceOutDescriptorProxy from 'pages/InvoiceOut/Card/InvoiceOutDescriptorProxy.vue';
import WorkerDescriptorProxy from 'pages/Worker/Card/WorkerDescriptorProxy.vue';
onMounted(() => fetch());
onUpdated(() => fetch());
@ -79,14 +81,20 @@ async function changeState(value) {
</script>
<template>
<fetch-data url="States/editableStates" @on-fetch="(data) => (editableStates = data)" auto-load />
<fetch-data
url="States/editableStates"
@on-fetch="(data) => (editableStates = data)"
auto-load
/>
<div class="summary container">
<q-card>
<skeleton-summary v-if="!ticket" />
<template v-if="ticket">
<div class="header bg-primary q-pa-sm q-mb-md">
<span>
Ticket #{{ ticket.id }} - {{ ticket.client.name }} ({{ ticket.client.id }}) -
Ticket #{{ ticket.id }} - {{ ticket.client.name }} ({{
ticket.client.id
}}) -
{{ ticket.nickname }}
</span>
<q-btn-dropdown
@ -104,7 +112,13 @@ async function changeState(value) {
separator
v-slot="{ item, index }"
>
<q-item :key="index" dense clickable v-close-popup @click="changeState(item.code)">
<q-item
:key="index"
dense
clickable
v-close-popup
@click="changeState(item.code)"
>
<q-item-section>
<q-item-label>{{ item.name }}</q-item-label>
</q-item-section>
@ -118,40 +132,72 @@ async function changeState(value) {
<q-list>
<q-item>
<q-item-section>
<q-item-label caption>{{ t('ticket.summary.state') }}</q-item-label>
<q-item-label :class="stateColor(ticket.ticketState.state)">
<q-item-label caption>{{
t('ticket.summary.state')
}}</q-item-label>
<q-item-label
:class="stateColor(ticket.ticketState.state)"
>
{{ ticket.ticketState.state.name }}
</q-item-label>
</q-item-section>
</q-item>
<q-item>
<q-item-section>
<q-item-label caption>{{ t('ticket.summary.salesPerson') }}</q-item-label>
<q-item-label class="link">{{ ticket.client.salesPersonUser.name }}</q-item-label>
<q-item-label caption>{{
t('ticket.summary.salesPerson')
}}</q-item-label>
<q-item-label>
<span class="link">
{{ ticket.client.salesPersonUser.name }}
<WorkerDescriptorProxy
:id="ticket.client.salesPersonFk"
/>
</span>
</q-item-label>
</q-item-section>
</q-item>
<q-item>
<q-item-section>
<q-item-label caption>{{ t('ticket.summary.agency') }}</q-item-label>
<q-item-label>{{ ticket.agencyMode.name }}</q-item-label>
<q-item-label caption>{{
t('ticket.summary.agency')
}}</q-item-label>
<q-item-label>{{
ticket.agencyMode.name
}}</q-item-label>
</q-item-section>
</q-item>
<q-item>
<q-item-section>
<q-item-label caption>{{ t('ticket.summary.zone') }}</q-item-label>
<q-item-label class="link">{{ ticket.routeFk }}</q-item-label>
<q-item-label caption>{{
t('ticket.summary.zone')
}}</q-item-label>
<q-item-label class="link">{{
ticket.routeFk
}}</q-item-label>
</q-item-section>
</q-item>
<q-item>
<q-item-section>
<q-item-label caption>{{ t('ticket.summary.warehouse') }}</q-item-label>
<q-item-label>{{ ticket.warehouse.name }}</q-item-label>
<q-item-label caption>{{
t('ticket.summary.warehouse')
}}</q-item-label>
<q-item-label>{{
ticket.warehouse.name
}}</q-item-label>
</q-item-section>
</q-item>
<q-item>
<q-item-section>
<q-item-label caption>{{ t('ticket.summary.invoice') }}</q-item-label>
<q-item-label v-if="ticket.refFk" class="link">{{ ticket.refFk }}</q-item-label>
<q-item-label caption>{{
t('ticket.summary.invoice')
}}</q-item-label>
<q-item-label v-if="ticket.refFk">
<span class="link">
{{ ticket.refFk }}
<InvoiceOutDescriptorProxy :id="ticket.id" />
</span>
</q-item-label>
</q-item-section>
</q-item>
</q-list>
@ -160,49 +206,75 @@ async function changeState(value) {
<q-list>
<q-item>
<q-item-section>
<q-item-label caption>{{ t('ticket.summary.shipped') }}</q-item-label>
<q-item-label>{{ toDate(ticket.shipped) }}</q-item-label>
<q-item-label caption>{{
t('ticket.summary.shipped')
}}</q-item-label>
<q-item-label>{{
toDate(ticket.shipped)
}}</q-item-label>
</q-item-section>
</q-item>
<q-item>
<q-item-section>
<q-item-label caption>{{ t('ticket.summary.landed') }}</q-item-label>
<q-item-label>{{ toDate(ticket.landed) }}</q-item-label>
<q-item-label caption>{{
t('ticket.summary.landed')
}}</q-item-label>
<q-item-label>{{
toDate(ticket.landed)
}}</q-item-label>
</q-item-section>
</q-item>
<q-item>
<q-item-section>
<q-item-label caption>{{ t('ticket.summary.packages') }}</q-item-label>
<q-item-label caption>{{
t('ticket.summary.packages')
}}</q-item-label>
<q-item-label>{{ ticket.packages }}</q-item-label>
</q-item-section>
</q-item>
<q-item>
<q-item-section>
<q-item-label caption>{{ t('ticket.summary.consigneePhone') }}</q-item-label>
<q-item-label>{{ ticket.address.phone }}</q-item-label>
<q-item-label caption>{{
t('ticket.summary.consigneePhone')
}}</q-item-label>
<q-item-label>{{
ticket.address.phone
}}</q-item-label>
</q-item-section>
</q-item>
<q-item>
<q-item-section>
<q-item-label caption>{{ t('ticket.summary.consigneeMobile') }}</q-item-label>
<q-item-label>{{ ticket.address.mobile }}</q-item-label>
<q-item-label caption>{{
t('ticket.summary.consigneeMobile')
}}</q-item-label>
<q-item-label>{{
ticket.address.mobile
}}</q-item-label>
</q-item-section>
</q-item>
<q-item>
<q-item-section>
<q-item-label caption>{{ t('ticket.summary.clientPhone') }}</q-item-label>
<q-item-label caption>{{
t('ticket.summary.clientPhone')
}}</q-item-label>
<q-item-label>{{ ticket.client.phone }}</q-item-label>
</q-item-section>
</q-item>
<q-item>
<q-item-section>
<q-item-label caption>{{ t('ticket.summary.clientMobile') }}</q-item-label>
<q-item-label>{{ ticket.client.mobile }}</q-item-label>
<q-item-label caption>{{
t('ticket.summary.clientMobile')
}}</q-item-label>
<q-item-label>{{
ticket.client.mobile
}}</q-item-label>
</q-item-section>
</q-item>
<q-item>
<q-item-section>
<q-item-label caption>{{ t('ticket.summary.consignee') }}</q-item-label>
<q-item-label caption>{{
t('ticket.summary.consignee')
}}</q-item-label>
<q-item-label>{{ formattedAddress() }}</q-item-label>
</q-item-section>
</q-item>
@ -226,22 +298,34 @@ async function changeState(value) {
<q-list class="taxes">
<q-item>
<q-item-section>
<q-item-label caption>{{ t('ticket.summary.subtotal') }}</q-item-label>
<q-item-label>{{ toCurrency(ticket.totalWithoutVat) }}</q-item-label>
</q-item-section>
</q-item>
<q-item>
<q-item-section>
<q-item-label caption>{{ t('ticket.summary.vat') }}</q-item-label>
<q-item-label caption>{{
t('ticket.summary.subtotal')
}}</q-item-label>
<q-item-label>{{
toCurrency(ticket.totalWithVat - ticket.totalWithoutVat)
toCurrency(ticket.totalWithoutVat)
}}</q-item-label>
</q-item-section>
</q-item>
<q-item>
<q-item-section>
<q-item-label caption>{{ t('ticket.summary.total') }}</q-item-label>
<q-item-label>{{ toCurrency(ticket.totalWithVat) }}</q-item-label>
<q-item-label caption>{{
t('ticket.summary.vat')
}}</q-item-label>
<q-item-label>{{
toCurrency(
ticket.totalWithVat - ticket.totalWithoutVat
)
}}</q-item-label>
</q-item-section>
</q-item>
<q-item>
<q-item-section>
<q-item-label caption>{{
t('ticket.summary.total')
}}</q-item-label>
<q-item-label>{{
toCurrency(ticket.totalWithVat)
}}</q-item-label>
</q-item-section>
</q-item>
</q-list>
@ -253,7 +337,10 @@ async function changeState(value) {
<q-item-label header class="text-h6">
{{ t('ticket.summary.saleLines') }}
<router-link
:to="{ name: 'TicketBasicData', params: { id: entityId } }"
:to="{
name: 'TicketBasicData',
params: { id: entityId },
}"
target="_blank"
>
<q-icon name="open_in_new" />
@ -263,15 +350,33 @@ async function changeState(value) {
<template #header="props">
<q-tr :props="props">
<q-th auto-width></q-th>
<q-th auto-width>{{ t('ticket.summary.item') }}</q-th>
<q-th auto-width>{{ t('ticket.summary.visible') }}</q-th>
<q-th auto-width>{{ t('ticket.summary.available') }}</q-th>
<q-th auto-width>{{ t('ticket.summary.quantity') }}</q-th>
<q-th auto-width>{{ t('ticket.summary.description') }}</q-th>
<q-th auto-width>{{ t('ticket.summary.price') }}</q-th>
<q-th auto-width>{{ t('ticket.summary.discount') }}</q-th>
<q-th auto-width>{{ t('ticket.summary.amount') }}</q-th>
<q-th auto-width>{{ t('ticket.summary.packing') }}</q-th>
<q-th auto-width>{{
t('ticket.summary.item')
}}</q-th>
<q-th auto-width>{{
t('ticket.summary.visible')
}}</q-th>
<q-th auto-width>{{
t('ticket.summary.available')
}}</q-th>
<q-th auto-width>{{
t('ticket.summary.quantity')
}}</q-th>
<q-th auto-width>{{
t('ticket.summary.description')
}}</q-th>
<q-th auto-width>{{
t('ticket.summary.price')
}}</q-th>
<q-th auto-width>{{
t('ticket.summary.discount')
}}</q-th>
<q-th auto-width>{{
t('ticket.summary.amount')
}}</q-th>
<q-th auto-width>{{
t('ticket.summary.packing')
}}</q-th>
</q-tr>
</template>
<template #body="props">
@ -284,11 +389,18 @@ async function changeState(value) {
icon="vn:claims"
v-if="props.row.claim"
color="primary"
:to="{ name: 'ClaimCard', params: { id: props.row.claim.claimFk } }"
:to="{
name: 'ClaimCard',
params: {
id: props.row.claim.claimFk,
},
}"
>
<q-tooltip
>{{ t('ticket.summary.claim') }}:
{{ props.row.claim.claimFk }}</q-tooltip
{{
props.row.claim.claimFk
}}</q-tooltip
>
</q-btn>
<q-btn
@ -300,12 +412,17 @@ async function changeState(value) {
color="primary"
:to="{
name: 'ClaimCard',
params: { id: props.row.claimBeginning.claimFk },
params: {
id: props.row.claimBeginning
.claimFk,
},
}"
>
<q-tooltip
>{{ t('ticket.summary.claim') }}:
{{ props.row.claimBeginning.claimFk }}</q-tooltip
{{
props.row.claimBeginning.claimFk
}}</q-tooltip
>
</q-btn>
<q-icon
@ -325,7 +442,9 @@ async function changeState(value) {
size="xs"
color="primary"
>
<q-tooltip>{{ t('ticket.summary.reserved') }}</q-tooltip>
<q-tooltip>{{
t('ticket.summary.reserved')
}}</q-tooltip>
</q-icon>
<q-icon
name="vn:unavailable"
@ -333,7 +452,9 @@ async function changeState(value) {
size="xs"
color="primary"
>
<q-tooltip>{{ t('ticket.summary.itemShortage') }}</q-tooltip>
<q-tooltip>{{
t('ticket.summary.itemShortage')
}}</q-tooltip>
</q-icon>
<q-icon
name="vn:components"
@ -341,7 +462,9 @@ async function changeState(value) {
size="xs"
color="primary"
>
<q-tooltip>{{ t('ticket.summary.hasComponentLack') }}</q-tooltip>
<q-tooltip>{{
t('ticket.summary.hasComponentLack')
}}</q-tooltip>
</q-icon>
</q-td>
<q-td class="link">{{ props.row.itemFk }}</q-td>
@ -351,11 +474,16 @@ async function changeState(value) {
<q-td>
<div class="fetched-tags">
<span>{{ props.row.item.name }}</span>
<span v-if="props.row.item.subName" class="subName">{{
props.row.item.subName
}}</span>
<span
v-if="props.row.item.subName"
class="subName"
>{{ props.row.item.subName }}</span
>
</div>
<fetched-tags :item="props.row.item" :max-length="5"></fetched-tags>
<fetched-tags
:item="props.row.item"
:max-length="5"
></fetched-tags>
</q-td>
<q-td>{{ props.row.price }}</q-td>
<q-td>{{ props.row.discount }} %</q-td>
@ -368,14 +496,19 @@ async function changeState(value) {
)
}}
</q-td>
<q-td>{{ dashIfEmpty(props.row.item.itemPackingTypeFk) }}</q-td>
<q-td>{{
dashIfEmpty(props.row.item.itemPackingTypeFk)
}}</q-td>
</q-tr>
</template>
</q-table>
</q-list>
</div>
</div>
<div class="row q-pa-md" v-if="ticket.packagings.length > 0 || ticket.services.length > 0">
<div
class="row q-pa-md"
v-if="ticket.packagings.length > 0 || ticket.services.length > 0"
>
<div class="col" v-if="ticket.packagings.length > 0">
<q-list>
<q-item-label header class="text-h6">
@ -385,9 +518,15 @@ async function changeState(value) {
<q-table :rows="ticket.packagings" flat>
<template #header="props">
<q-tr :props="props">
<q-th auto-width>{{ t('ticket.summary.created') }}</q-th>
<q-th auto-width>{{ t('ticket.summary.package') }}</q-th>
<q-th auto-width>{{ t('ticket.summary.quantity') }}</q-th>
<q-th auto-width>{{
t('ticket.summary.created')
}}</q-th>
<q-th auto-width>{{
t('ticket.summary.package')
}}</q-th>
<q-th auto-width>{{
t('ticket.summary.quantity')
}}</q-th>
</q-tr>
</template>
<template #body="props">
@ -409,11 +548,21 @@ async function changeState(value) {
<q-table :rows="ticket.services" flat>
<template #header="props">
<q-tr :props="props">
<q-th auto-width>{{ t('ticket.summary.quantity') }}</q-th>
<q-th auto-width>{{ t('ticket.summary.description') }}</q-th>
<q-th auto-width>{{ t('ticket.summary.price') }}</q-th>
<q-th auto-width>{{ t('ticket.summary.taxClass') }}</q-th>
<q-th auto-width>{{ t('ticket.summary.amount') }}</q-th>
<q-th auto-width>{{
t('ticket.summary.quantity')
}}</q-th>
<q-th auto-width>{{
t('ticket.summary.description')
}}</q-th>
<q-th auto-width>{{
t('ticket.summary.price')
}}</q-th>
<q-th auto-width>{{
t('ticket.summary.taxClass')
}}</q-th>
<q-th auto-width>{{
t('ticket.summary.amount')
}}</q-th>
</q-tr>
</template>
<template #body="props">
@ -422,7 +571,11 @@ async function changeState(value) {
<q-td>{{ props.row.description }}</q-td>
<q-td>{{ toCurrency(props.row.price) }}</q-td>
<q-td>{{ props.row.taxClass.description }}</q-td>
<q-td>{{ toCurrency(props.row.quantity * props.row.price) }}</q-td>
<q-td>{{
toCurrency(
props.row.quantity * props.row.price
)
}}</q-td>
</q-tr>
</template>
</q-table>
@ -439,13 +592,27 @@ async function changeState(value) {
<q-table :rows="ticket.requests" flat>
<template #header="props">
<q-tr :props="props">
<q-th auto-width>{{ t('ticket.summary.description') }}</q-th>
<q-th auto-width>{{ t('ticket.summary.created') }}</q-th>
<q-th auto-width>{{ t('ticket.summary.requester') }}</q-th>
<q-th auto-width>{{ t('ticket.summary.atender') }}</q-th>
<q-th auto-width>{{ t('ticket.summary.quantity') }}</q-th>
<q-th auto-width>{{ t('ticket.summary.price') }}</q-th>
<q-th auto-width>{{ t('ticket.summary.item') }}</q-th>
<q-th auto-width>{{
t('ticket.summary.description')
}}</q-th>
<q-th auto-width>{{
t('ticket.summary.created')
}}</q-th>
<q-th auto-width>{{
t('ticket.summary.requester')
}}</q-th>
<q-th auto-width>{{
t('ticket.summary.atender')
}}</q-th>
<q-th auto-width>{{
t('ticket.summary.quantity')
}}</q-th>
<q-th auto-width>{{
t('ticket.summary.price')
}}</q-th>
<q-th auto-width>{{
t('ticket.summary.item')
}}</q-th>
<q-th auto-width>Ok</q-th>
</q-tr>
</template>
@ -458,8 +625,14 @@ async function changeState(value) {
<q-td>{{ props.row.quantity }}</q-td>
<q-td>{{ toCurrency(props.row.price) }}</q-td>
<q-td v-if="!props.row.sale">-</q-td>
<q-td v-if="props.row.sale" class="link">{{ props.row.sale.itemFk }}</q-td>
<q-td><q-checkbox v-model="props.row.isOk" :disable="true" /></q-td>
<q-td v-if="props.row.sale" class="link">{{
props.row.sale.itemFk
}}</q-td>
<q-td
><q-checkbox
v-model="props.row.isOk"
:disable="true"
/></q-td>
</q-tr>
</template>
</q-table>

View File

@ -1,84 +0,0 @@
import { vi, describe, expect, it, beforeAll } from 'vitest';
import { createWrapper } from 'app/test/vitest/helper';
import App from 'src/App.vue';
import { useSession } from 'src/composables/useSession';
const mockLoggedIn = vi.fn();
const mockDestroy = vi.fn();
const session = useSession();
vi.mock('src/composables/useSession', () => ({
useSession: () => ({
isLoggedIn: mockLoggedIn,
destroy: mockDestroy,
}),
}));
describe.skip('App', () => {
let vm;
beforeAll(() => {
const options = {
global: {
stubs: ['router-view'],
},
};
vm = createWrapper(App, options).vm;
});
it('should return a login error message', async () => {
vi.spyOn(vm.quasar, 'notify');
session.isLoggedIn.mockReturnValue(false);
const response = {
response: {
status: 401,
data: {
error: {
message: 'Invalid username or password',
},
},
},
};
expect(vm.onResponseError(response)).rejects.toEqual(
expect.objectContaining(response)
);
expect(vm.quasar.notify).toHaveBeenCalledWith(
expect.objectContaining({
message: 'Invalid username or password',
type: 'negative',
})
);
});
it('should return an unauthorized error message', async () => {
vi.spyOn(vm.quasar, 'notify');
session.isLoggedIn.mockReturnValue(true);
const response = {
response: {
status: 401,
data: {
error: {
message: 'Access denied',
},
},
},
};
expect(vm.responseError(response)).rejects.toEqual(
expect.objectContaining(response)
);
expect(vm.quasar.notify).toHaveBeenCalledWith(
expect.objectContaining({
message: 'Access denied',
type: 'negative',
})
);
expect(session.destroy).toHaveBeenCalled();
});
});

View File

@ -0,0 +1,81 @@
import { vi, describe, expect, it } from 'vitest';
import { onRequest, onResponseError } from 'src/boot/axios';
import { Notify } from 'quasar'
vi.mock('src/composables/useSession', () => ({
useSession: () => ({
getToken: () => 'DEFAULT_TOKEN'
}),
}));
vi.mock('src/router', () => ({}));
describe('Axios boot', () => {
describe('onRequest()', async () => {
it('should set the "Authorization" property on the headers', async () => {
const config = { headers: {} };
const resultConfig = onRequest(config);
expect(resultConfig).toEqual(expect.objectContaining({
headers: {
Authorization: 'DEFAULT_TOKEN'
}
}));
});
})
describe('onResponseError()', async () => {
it('should call to the Notify plugin with a message error for an status code "500"', async () => {
Notify.create = vi.fn()
const error = {
response: {
status: 500
}
};
const result = onResponseError(error);
expect(result).rejects.toEqual(
expect.objectContaining(error)
);
expect(Notify.create).toHaveBeenCalledWith(
expect.objectContaining({
message: 'An internal server error has ocurred',
type: 'negative',
})
);
});
it('should call to the Notify plugin with a message from the response property', async () => {
Notify.create = vi.fn()
const error = {
response: {
status: 401,
data: {
error: {
message: 'Invalid user or password'
}
}
}
};
const result = onResponseError(error);
expect(result).rejects.toEqual(
expect.objectContaining(error)
);
expect(Notify.create).toHaveBeenCalledWith(
expect.objectContaining({
message: 'Invalid user or password',
type: 'negative',
})
);
});
})
});

View File

@ -1,7 +1,6 @@
import { vi, describe, expect, it, beforeAll, afterEach } from 'vitest';
import { createWrapper, axios } from 'app/test/vitest/helper';
import Login from 'pages/Login/LoginMain.vue';
import { Notify } from 'quasar';
describe('Login', () => {
let vm;