This commit is contained in:
William Buezas 2024-04-11 18:04:11 -03:00
parent a66ece1683
commit 98f273cb93
4 changed files with 280 additions and 1 deletions

View File

@ -1220,6 +1220,7 @@ export default {
diary: 'Diary',
tags: 'Tags',
create: 'Create',
buyRequest: 'Buy requests',
},
descriptor: {
item: 'Item',
@ -1250,6 +1251,18 @@ export default {
producer: 'Producer',
landed: 'Landed',
},
buyRequest: {
ticketId: 'Ticket ID',
shipped: 'Shipped',
requester: 'Requester',
requested: 'Requested',
price: 'Price',
attender: 'Atender',
item: 'Item',
achieved: 'Achieved',
concept: 'Concept',
state: 'State',
},
},
components: {
topbar: {},

View File

@ -1219,6 +1219,7 @@ export default {
diary: 'Histórico',
tags: 'Etiquetas',
create: 'Crear',
buyRequest: 'Peticiones de compra',
},
descriptor: {
item: 'Artículo',
@ -1249,6 +1250,18 @@ export default {
producer: 'Productor',
landed: 'F. entrega',
},
buyRequest: {
ticketId: 'ID Ticket',
shipped: 'F. envío',
requester: 'Solicitante',
requested: 'Solicitado',
price: 'Precio',
attender: 'Comprador',
item: 'Artículo',
achieved: 'Conseguido',
concept: 'Concepto',
state: 'Estado',
},
},
components: {
topbar: {},

View File

@ -0,0 +1,244 @@
<script setup>
import { onMounted, ref, computed } from 'vue';
import { useI18n } from 'vue-i18n';
import { useRouter } from 'vue-router';
import FetchData from 'components/FetchData.vue';
import TicketDescriptorProxy from 'src/pages/Ticket/Card/TicketDescriptorProxy.vue';
import WorkerDescriptorProxy from 'src/pages/Worker/Card/WorkerDescriptorProxy.vue';
import VnInput from 'src/components/common/VnInput.vue';
import { toDateFormat } from 'src/filters/date';
import { toCurrency } from 'filters/index';
import useNotify from 'src/composables/useNotify.js';
import axios from 'axios';
const { t } = useI18n();
const { notify } = useNotify();
const itemRequestsOptions = ref([]);
const columns = computed(() => [
{
label: t('item.buyRequest.ticketId'),
name: 'id',
field: 'id',
align: 'left',
sortable: true,
},
{
label: t('item.buyRequest.shipped'),
field: 'shipped',
name: 'shipped',
align: 'left',
sortable: true,
},
{
label: t('globals.description'),
field: 'description',
name: 'description',
align: 'left',
sortable: true,
},
{
label: t('item.buyRequest.requester'),
name: 'requester',
align: 'left',
sortable: true,
},
{
label: t('item.buyRequest.requested'),
field: 'quantity',
name: 'requested',
align: 'left',
sortable: true,
},
{
label: t('item.buyRequest.price'),
field: 'price',
name: 'price',
align: 'left',
sortable: true,
format: (val) => toCurrency(val),
},
{
label: t('item.buyRequest.attender'),
field: 'attender',
name: 'attender',
align: 'left',
sortable: true,
},
{
label: t('item.buyRequest.item'),
field: 'item',
name: 'item',
align: 'left',
sortable: true,
},
{
label: t('item.buyRequest.achieved'),
field: 'achieved',
name: 'achieved',
align: 'left',
sortable: true,
},
{
label: t('item.buyRequest.concept'),
field: 'concept',
name: 'concept',
align: 'left',
sortable: true,
},
{
label: t('item.buyRequest.state'),
field: 'state',
name: 'state',
align: 'left',
sortable: true,
},
{
label: '',
name: 'action',
align: 'left',
columnFilter: null,
},
]);
const getDateQBadgeColor = (date) => {
let today = Date.vnNew();
today.setHours(0, 0, 0, 0);
let timeTicket = new Date(date);
timeTicket.setHours(0, 0, 0, 0);
let comparation = today - timeTicket;
if (comparation == 0) return 'warning';
if (comparation < 0) return 'negative';
};
const changeQuantity = async (request) => {
console.log('change quantity request:: ', request);
try {
if (request.saleFk) {
const params = {
quantity: request.saleQuantity,
};
await axios.patch(`Sales/${request.saleFk}`, params);
notify(t('globals.dataSaved', 'positive'));
confirmRequest(request);
} else confirmRequest(request);
} catch (error) {
console.log('Error changing quantity:: ', error);
}
};
const confirmRequest = async (request) => {
console.log('confirm request:: ', request);
try {
if (request.itemFk && request.saleQuantity) {
const params = {
itemFk: request.itemFk,
quantity: request.saleQuantity,
};
const { data } = await axios.post(
`TicketRequests/${request.id}/confirm`,
params
);
request.itemDescription = data.concept;
request.isOk = true;
notify(t('globals.dataSaved', 'positive'));
}
} catch (error) {
console.log('Error confirming request:: ', error);
}
};
onMounted(async () => {});
</script>
<template>
<FetchData
url="TicketRequests/filter"
:filter="{ order: ['shippedDate ASC', 'isOk ASC'] }"
auto-load
@on-fetch="(data) => (itemRequestsOptions = data)"
/>
<!-- TODO:: ADD SEARCHBAR -->
<QPage class="column items-center q-pa-md">
<QTable
:rows="itemRequestsOptions"
:columns="columns"
row-key="id"
:pagination="{ rowsPerPage: 0 }"
class="full-width q-mt-md"
:no-data-label="t('globals.noResults')"
>
<template #body-cell-id="{ row }">
<QTd>
<QBtn flat color="primary"> {{ row.id }}</QBtn>
<TicketDescriptorProxy :id="row.id" />
</QTd>
</template>
<template #body-cell-shipped="{ row }">
<QTd>
<QBadge
v-if="getDateQBadgeColor(row.shipped)"
:color="getDateQBadgeColor(row.shipped)"
text-color="black"
class="q-ma-none"
dense
style="font-size: 14px"
>
{{ toDateFormat(row.shipped) }}
</QBadge>
<span v-else>{{ toDateFormat(row.shipped) }}</span>
</QTd>
</template>
<template #body-cell-requester="{ row }">
<QTd>
<QBtn flat dense color="primary"> {{ row.requesterName }}</QBtn>
<WorkerDescriptorProxy :id="row.requesterFk" />
</QTd>
</template>
<template #body-cell-attender="{ row }">
<QTd>
<QBtn flat dense color="primary"> {{ row.attenderName }}</QBtn>
<WorkerDescriptorProxy :id="row.attenderFk" />
</QTd>
</template>
<template #body-cell-item="{ row }">
<QTd>
<VnInput
class="dense"
v-focus
v-model.number="row.itemFk"
type="number"
:disable="row.isOk != null"
/>
</QTd>
</template>
<template #body-cell-achieved="{ row }">
<QTd>
<VnInput
class="dense"
v-focus
v-model.number="row.saleQuantity"
@change="changeQuantity(row)"
type="number"
:disable="!row.itemFk || row.isOk != null"
/>
</QTd>
</template>
</QTable>
</QPage>
</template>
<i18n>
</i18n>

View File

@ -10,7 +10,7 @@ export default {
component: RouterView,
redirect: { name: 'ItemMain' },
menus: {
main: ['ItemList'],
main: ['ItemList', 'ItemRequest'],
card: [],
},
children: [
@ -37,6 +37,15 @@ export default {
},
component: () => import('src/pages/Item/ItemCreate.vue'),
},
{
path: 'request',
name: 'ItemRequest',
meta: {
title: 'buyRequest',
icon: 'vn:buyrequest',
},
component: () => import('src/pages/Item/ItemRequest.vue'),
},
],
},
{