0
0
Fork 0
This commit is contained in:
William Buezas 2024-06-27 11:46:31 -03:00
parent a57df459a6
commit db4c3a6799
3 changed files with 97 additions and 73 deletions

View File

@ -441,7 +441,7 @@ ticket:
sms: Sms
notes: Notas
sale: Lineas del pedido
service: Servicios
services: Servicios
list:
nickname: Alias
state: Estado

View File

@ -1,5 +1,5 @@
<script setup>
import { ref, watch, computed } from 'vue';
import { ref, watch, computed, onMounted } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import { useI18n } from 'vue-i18n';
@ -26,6 +26,7 @@ const { store } = arrayData;
const { notify } = useNotify();
const selectedServices = ref(new Set());
const defaultTaxClass = ref(null);
const toggleCheckSelection = (id) => {
if (selectedServices.value.has(id)) selectedServices.value.delete(id);
@ -36,7 +37,10 @@ const crudModelFilter = computed(() => ({
where: { ticketFk: route.params.id },
}));
const crudModelRequiredData = computed(() => ({ ticketFk: route.params.id }));
const crudModelRequiredData = computed(() => ({
ticketFk: route.params.id,
taxClassFk: defaultTaxClass.value?.id,
}));
watch(
() => route.params.id,
@ -68,6 +72,23 @@ const createRefund = async () => {
console.error(error);
}
};
const getDefaultTaxClass = async () => {
try {
let filter = {
where: { code: 'G' },
};
const { data } = await axios.get('TaxClasses/findOne', {
params: { filter: JSON.stringify(filter) },
});
defaultTaxClass.value = data;
console.log('defaultTaxClass', defaultTaxClass.value);
} catch (error) {
console.error(error);
}
};
onMounted(async () => await getDefaultTaxClass());
</script>
<template>
@ -85,80 +106,83 @@ const createRefund = async () => {
@click.stop="createRefund()"
/>
</Teleport>
<CrudModel
ref="ticketServiceCrudRef"
data-key="TicketService"
url="TicketServices"
model="TicketService"
:filter="crudModelFilter"
:data-required="crudModelRequiredData"
:default-remove="false"
auto-load
>
<template #body="{ rows }">
<QCard class="q-px-lg q-py-md">
<div
v-for="(row, index) in rows"
:key="index"
class="q-mb-md row items-center q-gutter-x-md"
>
<QCheckbox
size="sm"
@update:model-value="toggleCheckSelection(row.id)"
:model-value="selectedServices.has(row.id)"
:toggle-indeterminate="false"
/>
<VnSelectDialog
:label="t('service.description')"
v-model="row.ticketServiceTypeFk"
:options="ticketServiceOptions"
option-label="name"
option-value="id"
hide-selected
<div class="flex justify-center">
<CrudModel
ref="ticketServiceCrudRef"
data-key="TicketService"
url="TicketServices"
model="TicketService"
:filter="crudModelFilter"
:data-required="crudModelRequiredData"
:default-remove="false"
auto-load
style="max-width: 800px"
>
<template #body="{ rows }">
<QCard class="q-px-lg q-py-md">
<div
v-for="(row, index) in rows"
:key="index"
class="q-mb-md row items-center q-gutter-x-md"
>
<template #form>
<TicketCreateServiceType
@on-data-saved="ticketServiceTypeFetchRef.fetch()"
/>
</template>
</VnSelectDialog>
<VnInput
:label="t('service.quantity')"
v-model="row.quantity"
type="number"
min="0"
:info="t('service.quantityInfo')"
/>
<VnInput
:label="t('service.price')"
v-model="row.price"
type="number"
min="0"
/>
<QCheckbox
size="sm"
@update:model-value="toggleCheckSelection(row.id)"
:model-value="selectedServices.has(row.id)"
:toggle-indeterminate="false"
/>
<VnSelectDialog
:label="t('service.description')"
v-model="row.ticketServiceTypeFk"
:options="ticketServiceOptions"
option-label="name"
option-value="id"
hide-selected
>
<template #form>
<TicketCreateServiceType
@on-data-saved="ticketServiceTypeFetchRef.fetch()"
/>
</template>
</VnSelectDialog>
<VnInput
:label="t('service.quantity')"
v-model.number="row.quantity"
type="number"
min="0"
:info="t('service.quantityInfo')"
/>
<VnInput
:label="t('service.price')"
v-model.number="row.price"
type="number"
min="0"
/>
<QIcon
name="delete"
size="sm"
class="cursor-pointer"
color="primary"
@click="ticketServiceCrudRef.remove([row])"
>
<QTooltip>
{{ t('service.removeNote') }}
</QTooltip>
</QIcon>
</div>
<QIcon
name="delete"
name="add_circle"
class="fill-icon-on-hover q-ml-md"
size="sm"
class="cursor-pointer"
color="primary"
@click="ticketServiceCrudRef.remove([row])"
@click="ticketServiceCrudRef.insert()"
>
<QTooltip>
{{ t('service.removeNote') }}
{{ t('service.addService') }}
</QTooltip>
</QIcon>
</div>
<QIcon
name="add_circle"
class="fill-icon-on-hover q-ml-md"
size="sm"
color="primary"
@click="ticketServiceCrudRef.insert()"
>
<QTooltip>
{{ t('service.addService') }}
</QTooltip>
</QIcon>
</QCard>
</template>
</CrudModel>
</QCard>
</template>
</CrudModel>
</div>
</template>

View File

@ -98,8 +98,8 @@ export default {
path: 'service',
name: 'TicketService',
meta: {
title: 'service',
icon: 'cloud_upload',
title: 'services',
icon: 'vn:services',
},
component: () => import('src/pages/Ticket/Card/TicketService.vue'),
},