forked from verdnatura/salix-front
Compare commits
2 Commits
dev
...
8087-nuevo
Author | SHA1 | Date |
---|---|---|
Carlos Andrés | 12c236276d | |
Carlos Andrés | 64f36c7d4b |
|
@ -39,7 +39,37 @@ const onResponse = (response) => {
|
|||
const onResponseError = (error) => {
|
||||
stateQuery.remove(error.config);
|
||||
|
||||
if (session.isLoggedIn() && error.response?.status === 401) {
|
||||
let message = '';
|
||||
|
||||
const response = error.response;
|
||||
const responseData = response && response.data;
|
||||
const responseError = responseData && response.data.error;
|
||||
if (responseError) {
|
||||
message = responseError.message;
|
||||
}
|
||||
|
||||
switch (response?.status) {
|
||||
case 422:
|
||||
if (error.name == 'ValidationError')
|
||||
message +=
|
||||
' "' +
|
||||
responseError.details.context +
|
||||
'.' +
|
||||
Object.keys(responseError.details.codes).join(',') +
|
||||
'"';
|
||||
break;
|
||||
case 500:
|
||||
message = 'errors.statusInternalServerError';
|
||||
break;
|
||||
case 502:
|
||||
message = 'errors.statusBadGateway';
|
||||
break;
|
||||
case 504:
|
||||
message = 'errors.statusGatewayTimeout';
|
||||
break;
|
||||
}
|
||||
|
||||
if (session.isLoggedIn() && response?.status === 401) {
|
||||
session.destroy(false);
|
||||
const hash = window.location.hash;
|
||||
const url = hash.slice(1);
|
||||
|
@ -48,6 +78,8 @@ const onResponseError = (error) => {
|
|||
return Promise.reject(error);
|
||||
}
|
||||
|
||||
notify(message, 'negative');
|
||||
|
||||
return Promise.reject(error);
|
||||
};
|
||||
|
||||
|
|
|
@ -3,51 +3,14 @@ import qFormMixin from './qformMixin';
|
|||
import mainShortcutMixin from './mainShortcutMixin';
|
||||
import keyShortcut from './keyShortcut';
|
||||
import useNotify from 'src/composables/useNotify.js';
|
||||
import { CanceledError } from 'axios';
|
||||
|
||||
const { notify } = useNotify();
|
||||
|
||||
export default boot(({ app }) => {
|
||||
app.mixin(qFormMixin);
|
||||
app.mixin(mainShortcutMixin);
|
||||
app.directive('shortcut', keyShortcut);
|
||||
app.config.errorHandler = (error) => {
|
||||
let message;
|
||||
const response = error.response;
|
||||
const responseData = response?.data;
|
||||
const responseError = responseData && response.data.error;
|
||||
if (responseError) {
|
||||
message = responseError.message;
|
||||
}
|
||||
|
||||
switch (response?.status) {
|
||||
case 422:
|
||||
if (error.name == 'ValidationError')
|
||||
message +=
|
||||
' "' +
|
||||
responseError.details.context +
|
||||
'.' +
|
||||
Object.keys(responseError.details.codes).join(',') +
|
||||
'"';
|
||||
break;
|
||||
case 500:
|
||||
message = 'errors.statusInternalServerError';
|
||||
break;
|
||||
case 502:
|
||||
message = 'errors.statusBadGateway';
|
||||
break;
|
||||
case 504:
|
||||
message = 'errors.statusGatewayTimeout';
|
||||
break;
|
||||
}
|
||||
|
||||
console.error(error);
|
||||
if (error instanceof CanceledError) {
|
||||
const env = process.env.NODE_ENV;
|
||||
if (env && env !== 'development') return;
|
||||
message = 'Duplicate request';
|
||||
}
|
||||
|
||||
notify(message ?? 'globals.error', 'negative', 'error');
|
||||
app.config.errorHandler = function (err) {
|
||||
console.error(err);
|
||||
notify('globals.error', 'negative', 'error');
|
||||
};
|
||||
});
|
||||
|
|
|
@ -217,6 +217,9 @@ async function save() {
|
|||
updateAndEmit('onDataSaved', formData.value, response?.data);
|
||||
if ($props.reload) await arrayData.fetch({});
|
||||
hasChanges.value = false;
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
notify('errors.writeRequest', 'negative');
|
||||
} finally {
|
||||
isLoading.value = false;
|
||||
}
|
||||
|
|
|
@ -61,7 +61,6 @@ defineExpose({
|
|||
:loading="isLoading"
|
||||
@click="emit('onDataCanceled')"
|
||||
v-close-popup
|
||||
data-cy="FormModelPopup_cancel"
|
||||
/>
|
||||
<QBtn
|
||||
:label="t('globals.save')"
|
||||
|
@ -71,7 +70,6 @@ defineExpose({
|
|||
class="q-ml-sm"
|
||||
:disabled="isLoading"
|
||||
:loading="isLoading"
|
||||
data-cy="FormModelPopup_save"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<script setup>
|
||||
import { ref } from 'vue';
|
||||
import { ref, watch } from 'vue';
|
||||
import { useValidator } from 'src/composables/useValidator';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
|
|
|
@ -417,7 +417,6 @@ function handleScroll() {
|
|||
ref="tableRef"
|
||||
v-bind="table"
|
||||
class="vnTable"
|
||||
:class="{ 'last-row-sticky': $props.footer }"
|
||||
:columns="splittedColumns.columns"
|
||||
:rows="rows"
|
||||
v-model:selected="selected"
|
||||
|
@ -457,11 +456,7 @@ function handleScroll() {
|
|||
/>
|
||||
</template>
|
||||
<template #header-cell="{ col }">
|
||||
<QTh
|
||||
v-if="col.visible ?? true"
|
||||
:style="col.headerStyle"
|
||||
:class="col.headerClass"
|
||||
>
|
||||
<QTh v-if="col.visible ?? true">
|
||||
<div
|
||||
class="column self-start q-ml-xs ellipsis"
|
||||
:class="`text-${col?.align ?? 'left'}`"
|
||||
|
@ -860,9 +855,6 @@ es:
|
|||
table tbody th {
|
||||
position: relative;
|
||||
}
|
||||
}
|
||||
|
||||
.last-row-sticky {
|
||||
tbody:nth-last-child(1) {
|
||||
@extend .bg-header;
|
||||
position: sticky;
|
||||
|
|
|
@ -9,6 +9,10 @@ const $props = defineProps({
|
|||
type: Number, //Progress value (1.0 > x > 0.0)
|
||||
required: true,
|
||||
},
|
||||
showDialog: {
|
||||
type: Boolean,
|
||||
required: true,
|
||||
},
|
||||
cancelled: {
|
||||
type: Boolean,
|
||||
required: false,
|
||||
|
@ -20,22 +24,30 @@ const emit = defineEmits(['cancel', 'close']);
|
|||
|
||||
const dialogRef = ref(null);
|
||||
|
||||
const showDialog = defineModel('showDialog', {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
const _showDialog = computed({
|
||||
get: () => $props.showDialog,
|
||||
set: (value) => {
|
||||
if (value) dialogRef.value.show();
|
||||
},
|
||||
});
|
||||
|
||||
const _progress = computed(() => $props.progress);
|
||||
|
||||
const progressLabel = computed(() => `${Math.round($props.progress * 100)}%`);
|
||||
|
||||
const cancel = () => {
|
||||
dialogRef.value.hide();
|
||||
emit('cancel');
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<QDialog ref="dialogRef" v-model="showDialog" @hide="emit('close')">
|
||||
<QDialog ref="dialogRef" v-model="_showDialog" @hide="onDialogHide">
|
||||
<QCard class="full-width dialog">
|
||||
<QCardSection class="row">
|
||||
<span class="text-h6">{{ t('Progress') }}</span>
|
||||
<QSpace />
|
||||
<QBtn icon="close" flat round dense v-close-popup />
|
||||
<QBtn icon="close" flat round dense @click="emit('close')" />
|
||||
</QCardSection>
|
||||
<QCardSection>
|
||||
<div class="column">
|
||||
|
@ -68,7 +80,7 @@ const progressLabel = computed(() => `${Math.round($props.progress * 100)}%`);
|
|||
type="button"
|
||||
flat
|
||||
class="text-primary"
|
||||
v-close-popup
|
||||
@click="cancel()"
|
||||
>
|
||||
{{ t('globals.cancel') }}
|
||||
</QBtn>
|
||||
|
|
|
@ -312,6 +312,7 @@ globals:
|
|||
changePass: Change password
|
||||
deleteConfirmTitle: Delete selected elements
|
||||
changeState: Change state
|
||||
raid: 'Raid {daysInForward} days'
|
||||
errors:
|
||||
statusUnauthorized: Access denied
|
||||
statusInternalServerError: An internal server error has ocurred
|
||||
|
@ -369,7 +370,6 @@ entry:
|
|||
companyFk: Company
|
||||
travelFk: Travel
|
||||
isExcludedFromAvailable: Inventory
|
||||
isRaid: Raid
|
||||
invoiceAmount: Import
|
||||
summary:
|
||||
commission: Commission
|
||||
|
@ -380,7 +380,6 @@ entry:
|
|||
ordered: Ordered
|
||||
confirmed: Confirmed
|
||||
booked: Booked
|
||||
raid: Raid
|
||||
excludedFromAvailable: Inventory
|
||||
travelReference: Reference
|
||||
travelAgency: Agency
|
||||
|
@ -413,7 +412,6 @@ entry:
|
|||
ordered: Ordered
|
||||
confirmed: Confirmed
|
||||
booked: Booked
|
||||
raid: Raid
|
||||
excludedFromAvailable: Inventory
|
||||
agency: Agency
|
||||
warehouseOut: Warehouse Out
|
||||
|
@ -476,7 +474,6 @@ entry:
|
|||
packingOut: Package out
|
||||
landing: Landing
|
||||
isExcludedFromAvailable: Es inventory
|
||||
isRaid: Raid
|
||||
ticket:
|
||||
pageTitles:
|
||||
tickets: Tickets
|
||||
|
@ -1042,6 +1039,7 @@ travel:
|
|||
warehouseIn: Warehouse In
|
||||
delivered: Delivered
|
||||
received: Received
|
||||
daysInForward: Days in forward
|
||||
thermographs:
|
||||
code: Code
|
||||
temperature: Temperature
|
||||
|
|
|
@ -316,6 +316,7 @@ globals:
|
|||
changePass: Cambiar contraseña
|
||||
deleteConfirmTitle: Eliminar los elementos seleccionados
|
||||
changeState: Cambiar estado
|
||||
raid: 'Redada {daysInForward} días'
|
||||
errors:
|
||||
statusUnauthorized: Acceso denegado
|
||||
statusInternalServerError: Ha ocurrido un error interno del servidor
|
||||
|
@ -371,7 +372,6 @@ entry:
|
|||
companyFk: Empresa
|
||||
travelFk: Envio
|
||||
isExcludedFromAvailable: Inventario
|
||||
isRaid: Redada
|
||||
invoiceAmount: Importe
|
||||
summary:
|
||||
commission: Comisión
|
||||
|
@ -382,7 +382,6 @@ entry:
|
|||
ordered: Pedida
|
||||
confirmed: Confirmada
|
||||
booked: Contabilizada
|
||||
raid: Redada
|
||||
excludedFromAvailable: Inventario
|
||||
travelReference: Referencia
|
||||
travelAgency: Agencia
|
||||
|
@ -415,7 +414,6 @@ entry:
|
|||
ordered: Pedida
|
||||
confirmed: Confirmado
|
||||
booked: Asentado
|
||||
raid: Redada
|
||||
excludedFromAvailable: Inventario
|
||||
agency: Agencia
|
||||
warehouseOut: Alm. salida
|
||||
|
@ -478,7 +476,6 @@ entry:
|
|||
packingOut: Embalaje envíos
|
||||
landing: Llegada
|
||||
isExcludedFromAvailable: Es inventario
|
||||
isRaid: Redada
|
||||
ticket:
|
||||
pageTitles:
|
||||
tickets: Tickets
|
||||
|
@ -1040,6 +1037,7 @@ travel:
|
|||
warehouseIn: Alm. entrada
|
||||
delivered: Enviada
|
||||
received: Recibida
|
||||
daysInForward: Días redada
|
||||
thermographs:
|
||||
code: Código
|
||||
temperature: Temperatura
|
||||
|
|
|
@ -46,9 +46,13 @@ const columns = computed(() => [
|
|||
]);
|
||||
|
||||
const deleteAlias = async (row) => {
|
||||
await axios.delete(`${urlPath.value}/${row.id}`);
|
||||
notify(t('User removed'), 'positive');
|
||||
fetchAliases();
|
||||
try {
|
||||
await axios.delete(`${urlPath.value}/${row.id}`);
|
||||
notify(t('User removed'), 'positive');
|
||||
fetchAliases();
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
|
||||
watch(
|
||||
|
|
|
@ -61,15 +61,23 @@ const fetchAccountExistence = async () => {
|
|||
};
|
||||
|
||||
const deleteMailAlias = async (row) => {
|
||||
await axios.delete(`${urlPath}/${row.id}`);
|
||||
fetchMailAliases();
|
||||
notify(t('Unsubscribed from alias!'), 'positive');
|
||||
try {
|
||||
await axios.delete(`${urlPath}/${row.id}`);
|
||||
fetchMailAliases();
|
||||
notify(t('Unsubscribed from alias!'), 'positive');
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
|
||||
const createMailAlias = async (mailAliasFormData) => {
|
||||
await axios.post(urlPath, mailAliasFormData);
|
||||
notify(t('Subscribed to alias!'), 'positive');
|
||||
fetchMailAliases();
|
||||
try {
|
||||
await axios.post(urlPath, mailAliasFormData);
|
||||
notify(t('Subscribed to alias!'), 'positive');
|
||||
fetchMailAliases();
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
|
||||
const fetchMailAliases = async () => {
|
||||
|
|
|
@ -46,15 +46,29 @@ const columns = computed(() => [
|
|||
]);
|
||||
|
||||
const deleteSubRole = async (row) => {
|
||||
await axios.delete(`${urlPath.value}/${row.id}`);
|
||||
fetchSubRoles();
|
||||
notify(t('Role removed. Changes will take a while to fully propagate.'), 'positive');
|
||||
try {
|
||||
await axios.delete(`${urlPath.value}/${row.id}`);
|
||||
fetchSubRoles();
|
||||
notify(
|
||||
t('Role removed. Changes will take a while to fully propagate.'),
|
||||
'positive'
|
||||
);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
|
||||
const createSubRole = async (subRoleFormData) => {
|
||||
await axios.post(urlPath.value, subRoleFormData);
|
||||
notify(t('Role added! Changes will take a while to fully propagate.'), 'positive');
|
||||
fetchSubRoles();
|
||||
try {
|
||||
await axios.post(urlPath.value, subRoleFormData);
|
||||
notify(
|
||||
t('Role added! Changes will take a while to fully propagate.'),
|
||||
'positive'
|
||||
);
|
||||
fetchSubRoles();
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
|
||||
watch(
|
||||
|
|
|
@ -168,12 +168,6 @@ const onFilterTravelSelected = (formData, id) => {
|
|||
v-model="data.isExcludedFromAvailable"
|
||||
:label="t('entry.basicData.excludedFromAvailable')"
|
||||
/>
|
||||
<QCheckbox v-model="data.isRaid" :label="t('entry.basicData.raid')" />
|
||||
<QCheckbox
|
||||
v-if="isAdministrative()"
|
||||
v-model="data.isBooked"
|
||||
:label="t('entry.basicData.booked')"
|
||||
/>
|
||||
</VnRow>
|
||||
</template>
|
||||
</FormModel>
|
||||
|
|
|
@ -7,7 +7,6 @@ import CardDescriptor from 'components/ui/CardDescriptor.vue';
|
|||
import VnLv from 'src/components/ui/VnLv.vue';
|
||||
import useCardDescription from 'src/composables/useCardDescription';
|
||||
|
||||
import { useState } from 'src/composables/useState';
|
||||
import { toDate } from 'src/filters';
|
||||
import { usePrintService } from 'composables/usePrintService';
|
||||
import { getUrl } from 'src/composables/getUrl';
|
||||
|
@ -23,7 +22,6 @@ const $props = defineProps({
|
|||
const route = useRoute();
|
||||
const { t } = useI18n();
|
||||
const { openReport } = usePrintService();
|
||||
const state = useState();
|
||||
const entryDescriptorRef = ref(null);
|
||||
const url = ref();
|
||||
|
||||
|
@ -32,7 +30,6 @@ const entryFilter = {
|
|||
{
|
||||
relation: 'travel',
|
||||
scope: {
|
||||
fields: ['id', 'landed', 'shipped', 'agencyModeFk', 'warehouseOutFk'],
|
||||
include: [
|
||||
{
|
||||
relation: 'agency',
|
||||
|
@ -75,8 +72,6 @@ const data = ref(useCardDescription());
|
|||
const setData = (entity) =>
|
||||
(data.value = useCardDescription(entity.supplier?.nickname, entity.id));
|
||||
|
||||
const currentEntry = computed(() => state.get('entry'));
|
||||
|
||||
const getEntryRedirectionFilter = (entry) => {
|
||||
let entryTravel = entry && entry.travel;
|
||||
|
||||
|
@ -133,10 +128,10 @@ watch;
|
|||
:value="entity.travel?.warehouseOut?.name"
|
||||
/>
|
||||
</template>
|
||||
<template #icons>
|
||||
<template #icons="{ entity }">
|
||||
<QCardActions class="q-gutter-x-md">
|
||||
<QIcon
|
||||
v-if="currentEntry?.isExcludedFromAvailable"
|
||||
v-if="entity?.isExcludedFromAvailable"
|
||||
name="vn:inventory"
|
||||
color="primary"
|
||||
size="xs"
|
||||
|
@ -144,12 +139,18 @@ watch;
|
|||
<QTooltip>{{ t('Inventory entry') }}</QTooltip>
|
||||
</QIcon>
|
||||
<QIcon
|
||||
v-if="currentEntry?.isRaid"
|
||||
v-if="entity?.travel?.daysInForward"
|
||||
name="vn:net"
|
||||
color="primary"
|
||||
size="xs"
|
||||
>
|
||||
<QTooltip>{{ t('Virtual entry') }}</QTooltip>
|
||||
<QTooltip>
|
||||
{{
|
||||
t('globals.raid', {
|
||||
daysInForward: entity?.travel?.daysInForward,
|
||||
})
|
||||
}}</QTooltip
|
||||
>
|
||||
</QIcon>
|
||||
</QCardActions>
|
||||
</template>
|
||||
|
|
|
@ -259,11 +259,6 @@ const fetchEntryBuys = async () => {
|
|||
v-model="entry.isBooked"
|
||||
:disable="true"
|
||||
/>
|
||||
<QCheckbox
|
||||
:label="t('entry.summary.raid')"
|
||||
v-model="entry.isRaid"
|
||||
:disable="true"
|
||||
/>
|
||||
<QCheckbox
|
||||
:label="t('entry.summary.excludedFromAvailable')"
|
||||
v-model="entry.isExcludedFromAvailable"
|
||||
|
|
|
@ -41,6 +41,10 @@ const entryFilter = {
|
|||
};
|
||||
|
||||
const columns = computed(() => [
|
||||
{
|
||||
name: 'status',
|
||||
hidden: true,
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
label: t('entry.list.tableVisibleColumns.id'),
|
||||
|
@ -154,27 +158,8 @@ const columns = computed(() => [
|
|||
cardVisible: true,
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
label: t('entry.list.tableVisibleColumns.isExcludedFromAvailable'),
|
||||
name: 'isExcludedFromAvailable',
|
||||
chip: {
|
||||
color: null,
|
||||
condition: (value) => value,
|
||||
icon: 'vn:inventory',
|
||||
},
|
||||
columnFilter: {
|
||||
inWhere: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
label: t('entry.list.tableVisibleColumns.isRaid'),
|
||||
name: 'isRaid',
|
||||
chip: {
|
||||
color: null,
|
||||
condition: (value) => value,
|
||||
icon: 'vn:net',
|
||||
},
|
||||
columnFilter: {
|
||||
inWhere: true,
|
||||
},
|
||||
|
@ -225,6 +210,26 @@ onMounted(async () => {
|
|||
auto-load
|
||||
:right-search="false"
|
||||
>
|
||||
<template #column-status="{ row }">
|
||||
<div class="row q-gutter-xs">
|
||||
<QIcon
|
||||
v-if="!!row.isExcludedFromAvailable"
|
||||
name="vn:inventory"
|
||||
color="primary"
|
||||
>
|
||||
<QTooltip>{{
|
||||
t('entry.list.tableVisibleColumns.isExcludedFromAvailable')
|
||||
}}</QTooltip>
|
||||
</QIcon>
|
||||
<QIcon v-if="!!row.daysInForward" name="vn:net" color="primary">
|
||||
<QTooltip>
|
||||
{{
|
||||
t('globals.raid', { daysInForward: row.daysInForward })
|
||||
}}</QTooltip
|
||||
>
|
||||
</QIcon>
|
||||
</div>
|
||||
</template>
|
||||
<template #column-supplierFk="{ row }">
|
||||
<span class="link" @click.stop>
|
||||
{{ row.supplierName }}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
entryList:
|
||||
list:
|
||||
inventoryEntry: Inventory entry
|
||||
virtualEntry: Virtual entry
|
||||
entryFilter:
|
||||
filter:
|
||||
search: General search
|
||||
|
|
|
@ -4,7 +4,6 @@ You can search by entry reference: Puedes buscar por referencia de la entrada
|
|||
entryList:
|
||||
list:
|
||||
inventoryEntry: Es inventario
|
||||
virtualEntry: Es una redada
|
||||
entryFilter:
|
||||
filter:
|
||||
search: Búsqueda general
|
||||
|
|
|
@ -258,28 +258,15 @@ onBeforeMount(() => {
|
|||
<template #body-cell-attender="{ row }">
|
||||
<QTd>
|
||||
<VnSelect
|
||||
url="Workers/search"
|
||||
v-model="row.attenderFk"
|
||||
:params="{ departmentCodes: ['shopping'] }"
|
||||
:fields="['id', 'nickname']"
|
||||
sort-by="nickname ASC"
|
||||
:where="{ role: 'buyer' }"
|
||||
sort-by="id"
|
||||
url="Workers"
|
||||
hide-selected
|
||||
option-label="nickname"
|
||||
option-label="firstName"
|
||||
option-value="id"
|
||||
dense
|
||||
>
|
||||
<template #option="scope">
|
||||
<QItem v-bind="scope.itemProps">
|
||||
<QItemSection>
|
||||
<QItemLabel>{{ scope.opt?.name }}</QItemLabel>
|
||||
<QItemLabel caption
|
||||
>{{ scope.opt?.nickname }},
|
||||
{{ scope.opt?.code }}</QItemLabel
|
||||
>
|
||||
</QItemSection>
|
||||
</QItem>
|
||||
</template>
|
||||
</VnSelect>
|
||||
/>
|
||||
</QTd>
|
||||
</template>
|
||||
<template #body-cell-item="{ row }">
|
||||
|
|
|
@ -52,27 +52,15 @@ const redirectToItemTypeBasicData = (_, { id }) => {
|
|||
</VnRow>
|
||||
<VnRow>
|
||||
<VnSelect
|
||||
url="Workers/search"
|
||||
v-model="data.workerFk"
|
||||
:label="t('shared.worker')"
|
||||
sort-by="nickname ASC"
|
||||
:fields="['id', 'nickname']"
|
||||
:params="{ departmentCodes: ['shopping'] }"
|
||||
option-label="nickname"
|
||||
:label="t('itemType.shared.worker')"
|
||||
url="Workers"
|
||||
sort-by="firstName ASC"
|
||||
:fields="['id', 'firstName']"
|
||||
option-value="id"
|
||||
option-label="firstName"
|
||||
hide-selected
|
||||
><template #option="scope">
|
||||
<QItem v-bind="scope.itemProps">
|
||||
<QItemSection>
|
||||
<QItemLabel>{{ scope.opt?.name }}</QItemLabel>
|
||||
<QItemLabel caption
|
||||
>{{ scope.opt?.nickname }},
|
||||
{{ scope.opt?.code }}</QItemLabel
|
||||
>
|
||||
</QItemSection>
|
||||
</QItem>
|
||||
</template>
|
||||
</VnSelect>
|
||||
/>
|
||||
<VnSelect
|
||||
v-model="data.categoryFk"
|
||||
:label="t('itemType.shared.category')"
|
||||
|
|
|
@ -41,27 +41,15 @@ const temperaturesOptions = ref([]);
|
|||
</VnRow>
|
||||
<VnRow>
|
||||
<VnSelect
|
||||
url="Workers/search"
|
||||
v-model="data.workerFk"
|
||||
:label="t('shared.worker')"
|
||||
sort-by="nickname ASC"
|
||||
:fields="['id', 'nickname']"
|
||||
:params="{ departmentCodes: ['shopping'] }"
|
||||
option-label="nickname"
|
||||
url="Workers"
|
||||
sort-by="firstName ASC"
|
||||
:fields="['id', 'firstName']"
|
||||
option-value="id"
|
||||
option-label="firstName"
|
||||
hide-selected
|
||||
><template #option="scope">
|
||||
<QItem v-bind="scope.itemProps">
|
||||
<QItemSection>
|
||||
<QItemLabel>{{ scope.opt?.name }}</QItemLabel>
|
||||
<QItemLabel caption
|
||||
>{{ scope.opt?.nickname }},
|
||||
{{ scope.opt?.code }}</QItemLabel
|
||||
>
|
||||
</QItemSection>
|
||||
</QItem>
|
||||
</template></VnSelect
|
||||
>
|
||||
/>
|
||||
<VnSelect
|
||||
v-model="data.categoryFk"
|
||||
:label="t('shared.category')"
|
||||
|
|
|
@ -112,20 +112,32 @@ const getShipped = async (params) => {
|
|||
};
|
||||
|
||||
const onChangeZone = async (zoneId) => {
|
||||
formData.value.agencyModeFk = null;
|
||||
const { data } = await axios.get(`Zones/${zoneId}`);
|
||||
formData.value.agencyModeFk = data.agencyModeFk;
|
||||
try {
|
||||
formData.value.agencyModeFk = null;
|
||||
const { data } = await axios.get(`Zones/${zoneId}`);
|
||||
formData.value.agencyModeFk = data.agencyModeFk;
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
|
||||
const onChangeAddress = async (addressId) => {
|
||||
formData.value.nickname = null;
|
||||
const { data } = await axios.get(`Addresses/${addressId}`);
|
||||
formData.value.nickname = data.nickname;
|
||||
try {
|
||||
formData.value.nickname = null;
|
||||
const { data } = await axios.get(`Addresses/${addressId}`);
|
||||
formData.value.nickname = data.nickname;
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
|
||||
const getClientDefaultAddress = async (clientId) => {
|
||||
const { data } = await axios.get(`Clients/${clientId}`);
|
||||
if (data) addressId.value = data.defaultAddressFk;
|
||||
try {
|
||||
const { data } = await axios.get(`Clients/${clientId}`);
|
||||
if (data) addressId.value = data.defaultAddressFk;
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
|
||||
const clientAddressesList = async (value) => {
|
||||
|
|
|
@ -70,51 +70,60 @@ const isFormInvalid = () => {
|
|||
};
|
||||
|
||||
const getPriceDifference = async () => {
|
||||
const params = {
|
||||
landed: formData.value.landed,
|
||||
addressId: formData.value.addressFk,
|
||||
agencyModeId: formData.value.agencyModeFk,
|
||||
zoneId: formData.value.zoneFk,
|
||||
warehouseId: formData.value.warehouseFk,
|
||||
shipped: formData.value.shipped,
|
||||
};
|
||||
const { data } = await axios.post(
|
||||
`tickets/${formData.value.id}/priceDifference`,
|
||||
params
|
||||
);
|
||||
formData.value.sale = data;
|
||||
try {
|
||||
const params = {
|
||||
landed: formData.value.landed,
|
||||
addressId: formData.value.addressFk,
|
||||
agencyModeId: formData.value.agencyModeFk,
|
||||
zoneId: formData.value.zoneFk,
|
||||
warehouseId: formData.value.warehouseFk,
|
||||
shipped: formData.value.shipped,
|
||||
};
|
||||
const { data } = await axios.post(
|
||||
`tickets/${formData.value.id}/priceDifference`,
|
||||
params
|
||||
);
|
||||
formData.value.sale = data;
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
|
||||
const submit = async () => {
|
||||
if (!formData.value.option) return notify(t('basicData.chooseAnOption'), 'negative');
|
||||
try {
|
||||
if (!formData.value.option)
|
||||
return notify(t('basicData.chooseAnOption'), 'negative');
|
||||
|
||||
const params = {
|
||||
clientFk: formData.value.clientFk,
|
||||
nickname: formData.value.nickname,
|
||||
agencyModeFk: formData.value.agencyModeFk,
|
||||
addressFk: formData.value.addressFk,
|
||||
zoneFk: formData.value.zoneFk,
|
||||
warehouseFk: formData.value.warehouseFk,
|
||||
companyFk: formData.value.companyFk,
|
||||
shipped: formData.value.shipped,
|
||||
landed: formData.value.landed,
|
||||
isDeleted: formData.value.isDeleted,
|
||||
option: formData.value.option,
|
||||
isWithoutNegatives: formData.value.withoutNegatives,
|
||||
withWarningAccept: formData.value.withWarningAccept,
|
||||
keepPrice: false,
|
||||
};
|
||||
const params = {
|
||||
clientFk: formData.value.clientFk,
|
||||
nickname: formData.value.nickname,
|
||||
agencyModeFk: formData.value.agencyModeFk,
|
||||
addressFk: formData.value.addressFk,
|
||||
zoneFk: formData.value.zoneFk,
|
||||
warehouseFk: formData.value.warehouseFk,
|
||||
companyFk: formData.value.companyFk,
|
||||
shipped: formData.value.shipped,
|
||||
landed: formData.value.landed,
|
||||
isDeleted: formData.value.isDeleted,
|
||||
option: formData.value.option,
|
||||
isWithoutNegatives: formData.value.withoutNegatives,
|
||||
withWarningAccept: formData.value.withWarningAccept,
|
||||
keepPrice: false,
|
||||
};
|
||||
|
||||
const { data } = await axios.post(
|
||||
`tickets/${formData.value.id}/componentUpdate`,
|
||||
params
|
||||
);
|
||||
const { data } = await axios.post(
|
||||
`tickets/${formData.value.id}/componentUpdate`,
|
||||
params
|
||||
);
|
||||
|
||||
if (!data) return;
|
||||
if (!data) return;
|
||||
|
||||
const ticketToMove = data.id;
|
||||
notify(t('basicData.unroutedTicket'), 'positive');
|
||||
router.push({ name: 'TicketSummary', params: { id: ticketToMove } });
|
||||
const ticketToMove = data.id;
|
||||
notify(t('basicData.unroutedTicket'), 'positive');
|
||||
router.push({ name: 'TicketSummary', params: { id: ticketToMove } });
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
|
||||
const submitWithNegatives = async () => {
|
||||
|
|
|
@ -34,20 +34,26 @@ const newTicketFormData = reactive({});
|
|||
const date = new Date();
|
||||
|
||||
const createTicket = async () => {
|
||||
const expeditionIds = $props.selectedExpeditions.map((expedition) => expedition.id);
|
||||
const params = {
|
||||
clientId: $props.ticket.clientFk,
|
||||
landed: newTicketFormData.landed,
|
||||
warehouseId: $props.ticket.warehouseFk,
|
||||
addressId: $props.ticket.addressFk,
|
||||
agencyModeId: $props.ticket.agencyModeFk,
|
||||
routeId: newTicketFormData.routeFk,
|
||||
expeditionIds: expeditionIds,
|
||||
};
|
||||
try {
|
||||
const expeditionIds = $props.selectedExpeditions.map(
|
||||
(expedition) => expedition.id
|
||||
);
|
||||
const params = {
|
||||
clientId: $props.ticket.clientFk,
|
||||
landed: newTicketFormData.landed,
|
||||
warehouseId: $props.ticket.warehouseFk,
|
||||
addressId: $props.ticket.addressFk,
|
||||
agencyModeId: $props.ticket.agencyModeFk,
|
||||
routeId: newTicketFormData.routeFk,
|
||||
expeditionIds: expeditionIds,
|
||||
};
|
||||
|
||||
const { data } = await axios.post('Expeditions/moveExpeditions', params);
|
||||
notify(t('globals.dataSaved'), 'positive');
|
||||
router.push({ name: 'TicketSummary', params: { id: data.id } });
|
||||
const { data } = await axios.post('Expeditions/moveExpeditions', params);
|
||||
notify(t('globals.dataSaved'), 'positive');
|
||||
router.push({ name: 'TicketSummary', params: { id: data.id } });
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
|
|
|
@ -150,19 +150,31 @@ const getTotal = computed(() => {
|
|||
});
|
||||
|
||||
const getComponentsSum = async () => {
|
||||
const { data } = await axios.get(`Tickets/${route.params.id}/getComponentsSum`);
|
||||
componentsList.value = data;
|
||||
try {
|
||||
const { data } = await axios.get(`Tickets/${route.params.id}/getComponentsSum`);
|
||||
componentsList.value = data;
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
|
||||
const getTheoricalCost = async () => {
|
||||
const { data } = await axios.get(`Tickets/${route.params.id}/freightCost`);
|
||||
theoricalCost.value = data;
|
||||
try {
|
||||
const { data } = await axios.get(`Tickets/${route.params.id}/freightCost`);
|
||||
theoricalCost.value = data;
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
|
||||
const getTicketVolume = async () => {
|
||||
if (!ticketData.value) return;
|
||||
const { data } = await axios.get(`Tickets/${ticketData.value.id}/getVolume`);
|
||||
ticketVolume.value = data[0].volume;
|
||||
try {
|
||||
if (!ticketData.value) return;
|
||||
const { data } = await axios.get(`Tickets/${ticketData.value.id}/getVolume`);
|
||||
ticketVolume.value = data[0].volume;
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
|
|
|
@ -163,12 +163,16 @@ const showNewTicketDialog = (withRoute = false) => {
|
|||
};
|
||||
|
||||
const deleteExpedition = async () => {
|
||||
const expeditionIds = selectedRows.value.map((expedition) => expedition.id);
|
||||
const params = { expeditionIds };
|
||||
await axios.post('Expeditions/deleteExpeditions', params);
|
||||
vnTableRef.value.reload();
|
||||
selectedExpeditions.value = [];
|
||||
notify(t('expedition.expeditionRemoved'), 'positive');
|
||||
try {
|
||||
const expeditionIds = selectedRows.value.map((expedition) => expedition.id);
|
||||
const params = { expeditionIds };
|
||||
await axios.post('Expeditions/deleteExpeditions', params);
|
||||
vnTableRef.value.reload();
|
||||
selectedExpeditions.value = [];
|
||||
notify(t('expedition.expeditionRemoved'), 'positive');
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
|
||||
const showLog = async (expedition) => {
|
||||
|
@ -177,19 +181,29 @@ const showLog = async (expedition) => {
|
|||
};
|
||||
|
||||
const getExpeditionState = async (expedition) => {
|
||||
const filter = {
|
||||
where: { expeditionFk: expedition.id },
|
||||
order: ['created DESC'],
|
||||
};
|
||||
try {
|
||||
const filter = {
|
||||
where: { expeditionFk: expedition.id },
|
||||
order: ['created DESC'],
|
||||
};
|
||||
|
||||
const { data: expeditionStates } = await axios.get(`ExpeditionStates/filter`, {
|
||||
params: { filter: JSON.stringify(filter) },
|
||||
});
|
||||
const { data: expeditionStates } = await axios.get(`ExpeditionStates/filter`, {
|
||||
params: { filter: JSON.stringify(filter) },
|
||||
});
|
||||
const { data: scannedStates } = await axios.get(`ExpeditionStates`, {
|
||||
params: { filter: JSON.stringify(filter), fields: ['id', 'isScanned'] },
|
||||
});
|
||||
|
||||
expeditionsLogsData.value = expeditionStates.map((state) => ({
|
||||
...state,
|
||||
isScanned: !!state.isScanned,
|
||||
}));
|
||||
expeditionsLogsData.value = expeditionStates.map((state) => {
|
||||
const scannedState = scannedStates.find((s) => s.id === state.id);
|
||||
return {
|
||||
...state,
|
||||
isScanned: scannedState ? scannedState.isScanned : false,
|
||||
};
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
|
||||
onMounted(async () => {
|
||||
|
@ -217,17 +231,16 @@ onUnmounted(() => (stateStore.rightDrawer = false));
|
|||
:select-props="{
|
||||
options: expeditionStateTypes,
|
||||
optionLabel: 'description',
|
||||
optionValue: 'code',
|
||||
}"
|
||||
:promise="
|
||||
async (stateCode) => {
|
||||
await axios.post('ExpeditionStates/addExpeditionState', {
|
||||
expeditions: selectedRows.map(({ id }) => {
|
||||
return { expeditionFk: id, stateCode };
|
||||
}),
|
||||
async (stateTypeFk) => {
|
||||
await vnTableRef.CrudModelRef.saveChanges({
|
||||
updates: selectedRows.map(({ id }) => ({
|
||||
data: { stateTypeFk },
|
||||
where: { id },
|
||||
})),
|
||||
});
|
||||
vnTableRef.tableRef.clearSelection();
|
||||
vnTableRef.reload();
|
||||
}
|
||||
"
|
||||
/>
|
||||
|
@ -296,6 +309,7 @@ onUnmounted(() => (stateStore.rightDrawer = false));
|
|||
'row-key': 'id',
|
||||
selection: 'multiple',
|
||||
}"
|
||||
save-url="Expeditions/crud"
|
||||
auto-load
|
||||
:expr-builder="
|
||||
(param, value) => {
|
||||
|
@ -341,7 +355,11 @@ onUnmounted(() => (stateStore.rightDrawer = false));
|
|||
</template>
|
||||
<template #body-cell-isScanned="{ row }">
|
||||
<QTd style="text-align: center">
|
||||
<QCheckbox disable v-model="row.isScanned" />
|
||||
<QCheckbox disable v-model="row.isScanned">
|
||||
{{
|
||||
row.isScanned === 1 ? t('expedition.yes') : t('expedition.no')
|
||||
}}
|
||||
</QCheckbox>
|
||||
</QTd>
|
||||
</template>
|
||||
</QTable>
|
||||
|
|
|
@ -165,10 +165,14 @@ const createRefund = async (withWarehouse) => {
|
|||
negative: true,
|
||||
};
|
||||
|
||||
const { data } = await axios.post('Tickets/cloneAll', params);
|
||||
const [refundTicket] = data;
|
||||
notify(t('refundTicketCreated', { ticketId: refundTicket.id }), 'positive');
|
||||
push({ name: 'TicketSale', params: { id: refundTicket.id } });
|
||||
try {
|
||||
const { data } = await axios.post('Tickets/cloneAll', params);
|
||||
const [refundTicket] = data;
|
||||
notify(t('refundTicketCreated', { ticketId: refundTicket.id }), 'positive');
|
||||
push({ name: 'TicketSale', params: { id: refundTicket.id } });
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
|
|
|
@ -150,14 +150,18 @@ const shelvingsTableColumns = computed(() => [
|
|||
]);
|
||||
|
||||
const getSaleTrackings = async (sale) => {
|
||||
const filter = {
|
||||
where: { saleFk: sale.saleFk },
|
||||
order: ['itemFk DESC'],
|
||||
};
|
||||
const { data } = await axios.get(`SaleTrackings/listSaleTracking`, {
|
||||
params: { filter: JSON.stringify(filter) },
|
||||
});
|
||||
saleTrackings.value = data;
|
||||
try {
|
||||
const filter = {
|
||||
where: { saleFk: sale.saleFk },
|
||||
order: ['itemFk DESC'],
|
||||
};
|
||||
const { data } = await axios.get(`SaleTrackings/listSaleTracking`, {
|
||||
params: { filter: JSON.stringify(filter) },
|
||||
});
|
||||
saleTrackings.value = data;
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
|
||||
const showLog = async (sale) => {
|
||||
|
@ -166,13 +170,17 @@ const showLog = async (sale) => {
|
|||
};
|
||||
|
||||
const getItemShelvingSales = async (sale) => {
|
||||
const filter = {
|
||||
where: { saleFk: sale.saleFk },
|
||||
};
|
||||
const { data } = await axios.get(`ItemShelvingSales/filter`, {
|
||||
params: { filter: JSON.stringify(filter) },
|
||||
});
|
||||
itemShelvingsSales.value = data;
|
||||
try {
|
||||
const filter = {
|
||||
where: { saleFk: sale.saleFk },
|
||||
};
|
||||
const { data } = await axios.get(`ItemShelvingSales/filter`, {
|
||||
params: { filter: JSON.stringify(filter) },
|
||||
});
|
||||
itemShelvingsSales.value = data;
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
|
||||
const showShelving = async (sale) => {
|
||||
|
@ -181,28 +189,36 @@ const showShelving = async (sale) => {
|
|||
};
|
||||
|
||||
const updateQuantity = async (sale) => {
|
||||
if (oldQuantity.value === sale.quantity) return;
|
||||
const params = {
|
||||
quantity: sale.quantity,
|
||||
};
|
||||
await axios.patch(`ItemShelvingSales/${sale.id}`, params);
|
||||
oldQuantity.value = null;
|
||||
try {
|
||||
if (oldQuantity.value === sale.quantity) return;
|
||||
const params = {
|
||||
quantity: sale.quantity,
|
||||
};
|
||||
await axios.patch(`ItemShelvingSales/${sale.id}`, params);
|
||||
oldQuantity.value = null;
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
|
||||
const updateParking = async (sale) => {
|
||||
const filter = {
|
||||
fields: ['id'],
|
||||
where: {
|
||||
code: sale.shelvingFk,
|
||||
},
|
||||
};
|
||||
const { data } = await axios.get(`Shelvings/findOne`, {
|
||||
params: { filter: JSON.stringify(filter) },
|
||||
});
|
||||
const params = {
|
||||
parkingFk: sale.parkingFk,
|
||||
};
|
||||
await axios.patch(`Shelvings/${data.id}`, params);
|
||||
try {
|
||||
const filter = {
|
||||
fields: ['id'],
|
||||
where: {
|
||||
code: sale.shelvingFk,
|
||||
},
|
||||
};
|
||||
const { data } = await axios.get(`Shelvings/findOne`, {
|
||||
params: { filter: JSON.stringify(filter) },
|
||||
});
|
||||
const params = {
|
||||
parkingFk: sale.parkingFk,
|
||||
};
|
||||
await axios.patch(`Shelvings/${data.id}`, params);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
|
||||
const updateShelving = async (sale) => {
|
||||
|
@ -225,41 +241,61 @@ const updateShelving = async (sale) => {
|
|||
};
|
||||
|
||||
const saleTrackingNew = async (sale, stateCode, isChecked) => {
|
||||
const params = {
|
||||
saleFk: sale.saleFk,
|
||||
isChecked,
|
||||
quantity: sale.quantity,
|
||||
stateCode,
|
||||
};
|
||||
await axios.post(`SaleTrackings/new`, params);
|
||||
notify(t('globals.dataSaved'), 'positive');
|
||||
try {
|
||||
const params = {
|
||||
saleFk: sale.saleFk,
|
||||
isChecked,
|
||||
quantity: sale.quantity,
|
||||
stateCode,
|
||||
};
|
||||
await axios.post(`SaleTrackings/new`, params);
|
||||
notify(t('globals.dataSaved'), 'positive');
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
|
||||
const saleTrackingDel = async ({ saleFk }, stateCode) => {
|
||||
const params = {
|
||||
saleFk,
|
||||
stateCodes: [stateCode],
|
||||
};
|
||||
await axios.post(`SaleTrackings/delete`, params);
|
||||
notify(t('globals.dataSaved'), 'positive');
|
||||
try {
|
||||
const params = {
|
||||
saleFk,
|
||||
stateCodes: [stateCode],
|
||||
};
|
||||
await axios.post(`SaleTrackings/delete`, params);
|
||||
notify(t('globals.dataSaved'), 'positive');
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
|
||||
const clickSaleGroupDetail = async (sale) => {
|
||||
if (!sale.saleGroupDetailFk) return;
|
||||
try {
|
||||
if (!sale.saleGroupDetailFk) return;
|
||||
|
||||
await axios.delete(`SaleGroupDetails/${sale.saleGroupDetailFk}`);
|
||||
sale.hasSaleGroupDetail = false;
|
||||
notify(t('globals.dataSaved'), 'positive');
|
||||
await axios.delete(`SaleGroupDetails/${sale.saleGroupDetailFk}`);
|
||||
sale.hasSaleGroupDetail = false;
|
||||
notify(t('globals.dataSaved'), 'positive');
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
|
||||
const clickPreviousSelected = (sale) => {
|
||||
qCheckBoxController(sale, 'isPreviousSelected');
|
||||
if (!sale.isPreviousSelected) sale.isPrevious = false;
|
||||
try {
|
||||
qCheckBoxController(sale, 'isPreviousSelected');
|
||||
if (!sale.isPreviousSelected) sale.isPrevious = false;
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
|
||||
const clickPrevious = (sale) => {
|
||||
qCheckBoxController(sale, 'isPrevious');
|
||||
if (sale.isPrevious) sale.isPreviousSelected = true;
|
||||
try {
|
||||
qCheckBoxController(sale, 'isPrevious');
|
||||
if (sale.isPrevious) sale.isPreviousSelected = true;
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
|
||||
const qCheckBoxController = (sale, action) => {
|
||||
|
@ -270,12 +306,16 @@ const qCheckBoxController = (sale, action) => {
|
|||
isPreviousSelected: 'PREVIOUS_PREPARATION',
|
||||
};
|
||||
const stateCode = STATE_CODES[action];
|
||||
if (!sale[action]) {
|
||||
saleTrackingNew(sale, stateCode, true);
|
||||
sale[action] = true;
|
||||
} else {
|
||||
saleTrackingDel(sale, stateCode);
|
||||
sale[action] = false;
|
||||
try {
|
||||
if (!sale[action]) {
|
||||
saleTrackingNew(sale, stateCode, true);
|
||||
sale[action] = true;
|
||||
} else {
|
||||
saleTrackingDel(sale, stateCode);
|
||||
sale[action] = false;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
|
|
@ -46,32 +46,40 @@ watch(
|
|||
onMounted(async () => await getDefaultTaxClass());
|
||||
|
||||
const createRefund = async () => {
|
||||
if (!selected.value.length) return;
|
||||
try {
|
||||
if (!selected.value.length) return;
|
||||
|
||||
const params = {
|
||||
servicesIds: selected.value.map((s) => +s.id),
|
||||
withWarehouse: false,
|
||||
negative: true,
|
||||
};
|
||||
const { data } = await axios.post('Sales/clone', params);
|
||||
const [refundTicket] = data;
|
||||
notify(
|
||||
t('service.createRefundSuccess', {
|
||||
ticketId: refundTicket.id,
|
||||
}),
|
||||
'positive'
|
||||
);
|
||||
router.push({ name: 'TicketSale', params: { id: refundTicket.id } });
|
||||
const params = {
|
||||
servicesIds: selected.value.map((s) => +s.id),
|
||||
withWarehouse: false,
|
||||
negative: true,
|
||||
};
|
||||
const { data } = await axios.post('Sales/clone', params);
|
||||
const [refundTicket] = data;
|
||||
notify(
|
||||
t('service.createRefundSuccess', {
|
||||
ticketId: refundTicket.id,
|
||||
}),
|
||||
'positive'
|
||||
);
|
||||
router.push({ name: 'TicketSale', params: { id: refundTicket.id } });
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
|
||||
const getDefaultTaxClass = async () => {
|
||||
let filter = {
|
||||
where: { code: 'G' },
|
||||
};
|
||||
const { data } = await axios.get('TaxClasses/findOne', {
|
||||
params: { filter: JSON.stringify(filter) },
|
||||
});
|
||||
defaultTaxClass.value = data;
|
||||
try {
|
||||
let filter = {
|
||||
where: { code: 'G' },
|
||||
};
|
||||
const { data } = await axios.get('TaxClasses/findOne', {
|
||||
params: { filter: JSON.stringify(filter) },
|
||||
});
|
||||
defaultTaxClass.value = data;
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
|
||||
const columns = computed(() => [
|
||||
|
|
|
@ -75,18 +75,22 @@ const columns = computed(() => [
|
|||
]);
|
||||
|
||||
const applyVolumes = async (salesData) => {
|
||||
if (!salesData.length) return;
|
||||
try {
|
||||
if (!salesData.length) return;
|
||||
|
||||
sales.value = salesData;
|
||||
const ticket = sales.value[0].ticketFk;
|
||||
const { data } = await axios.get(`Tickets/${ticket}/getVolume`);
|
||||
const volumes = new Map(data.saleVolume.map((volume) => [volume.saleFk, volume]));
|
||||
sales.value = salesData;
|
||||
const ticket = sales.value[0].ticketFk;
|
||||
const { data } = await axios.get(`Tickets/${ticket}/getVolume`);
|
||||
const volumes = new Map(data.saleVolume.map((volume) => [volume.saleFk, volume]));
|
||||
|
||||
sales.value.forEach((sale) => {
|
||||
sale.saleVolume = volumes.get(sale.id);
|
||||
});
|
||||
sales.value.forEach((sale) => {
|
||||
sale.saleVolume = volumes.get(sale.id);
|
||||
});
|
||||
|
||||
packingTypeVolume.value = data.packingTypeVolume;
|
||||
packingTypeVolume.value = data.packingTypeVolume;
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
|
||||
onMounted(() => (stateStore.rightDrawer = true));
|
||||
|
|
|
@ -1,20 +1,24 @@
|
|||
<script setup>
|
||||
import { ref, computed, reactive, watch } from 'vue';
|
||||
import { onMounted, ref, computed, reactive } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
import FetchData from 'components/FetchData.vue';
|
||||
import VnInput from 'src/components/common/VnInput.vue';
|
||||
import VnSelect from 'src/components/common/VnSelect.vue';
|
||||
import TicketDescriptorProxy from 'src/pages/Ticket/Card/TicketDescriptorProxy.vue';
|
||||
import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
|
||||
import VnSearchbar from 'src/components/ui/VnSearchbar.vue';
|
||||
import VnProgress from 'src/components/common/VnProgressModal.vue';
|
||||
import RightMenu from 'src/components/common/RightMenu.vue';
|
||||
import TicketAdvanceFilter from './TicketAdvanceFilter.vue';
|
||||
|
||||
import { dashIfEmpty, toCurrency } from 'src/filters';
|
||||
import { useVnConfirm } from 'composables/useVnConfirm';
|
||||
import { useArrayData } from 'composables/useArrayData';
|
||||
import useNotify from 'src/composables/useNotify.js';
|
||||
import { useState } from 'src/composables/useState';
|
||||
import { toDateFormat } from 'src/filters/date.js';
|
||||
import axios from 'axios';
|
||||
import VnTable from 'src/components/VnTable/VnTable.vue';
|
||||
|
||||
const state = useState();
|
||||
const { t } = useI18n();
|
||||
|
@ -25,58 +29,109 @@ const user = state.getUser();
|
|||
const itemPackingTypesOptions = ref([]);
|
||||
const zonesOptions = ref([]);
|
||||
const selectedTickets = ref([]);
|
||||
const vnTableRef = ref({});
|
||||
const originElRef = ref(null);
|
||||
const destinationElRef = ref(null);
|
||||
let today = Date.vnNew().toISOString();
|
||||
const tomorrow = new Date(today);
|
||||
tomorrow.setDate(tomorrow.getDate() + 1);
|
||||
const userParams = reactive({
|
||||
dateFuture: tomorrow,
|
||||
dateToAdvance: today,
|
||||
warehouseFk: user.value.warehouseFk,
|
||||
ipt: 'H',
|
||||
futureIpt: 'H',
|
||||
isFullMovable: true,
|
||||
|
||||
const exprBuilder = (param, value) => {
|
||||
switch (param) {
|
||||
case 'id':
|
||||
case 'futureId':
|
||||
case 'liters':
|
||||
case 'futureLiters':
|
||||
case 'lines':
|
||||
case 'futureLines':
|
||||
case 'totalWithVat':
|
||||
case 'futureTotalWithVat':
|
||||
case 'futureZone':
|
||||
case 'notMovableLines':
|
||||
case 'futureZoneFk':
|
||||
return { [param]: value };
|
||||
case 'iptColFilter':
|
||||
return { ipt: { like: `%${value}%` } };
|
||||
case 'futureIptColFilter':
|
||||
return { futureIpt: { like: `%${value}%` } };
|
||||
}
|
||||
};
|
||||
|
||||
const userParams = reactive({});
|
||||
|
||||
const arrayData = useArrayData('AdvanceTickets', {
|
||||
url: 'Tickets/getTicketsAdvance',
|
||||
userParams: userParams,
|
||||
exprBuilder: exprBuilder,
|
||||
limit: 0,
|
||||
});
|
||||
const { store } = arrayData;
|
||||
const tickets = computed(() =>
|
||||
(store.data || []).map((ticket, index) => ({ ...ticket, index: index }))
|
||||
);
|
||||
|
||||
const applyColumnFilter = async (col) => {
|
||||
try {
|
||||
const paramKey = col.columnFilter?.filterParamKey || col.field;
|
||||
userParams[paramKey] = col.columnFilter.filterValue;
|
||||
await arrayData.addFilter({ params: userParams });
|
||||
} catch (err) {
|
||||
console.error('Error applying column filter', err);
|
||||
}
|
||||
};
|
||||
|
||||
const getInputEvents = (col) => {
|
||||
return col.columnFilter.type === 'select'
|
||||
? { 'update:modelValue': () => applyColumnFilter(col) }
|
||||
: {
|
||||
'keyup.enter': () => applyColumnFilter(col),
|
||||
};
|
||||
};
|
||||
|
||||
const ticketColumns = computed(() => [
|
||||
{
|
||||
label: '',
|
||||
name: 'icons',
|
||||
hidden: true,
|
||||
headerClass: 'horizontal-separator',
|
||||
},
|
||||
{
|
||||
align: 'center',
|
||||
label: t('advanceTickets.ticketId'),
|
||||
name: 'id',
|
||||
headerClass: 'horizontal-separator',
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
label: t('advanceTickets.ipt'),
|
||||
name: 'ipt',
|
||||
columnFilter: null,
|
||||
},
|
||||
{
|
||||
label: t('advanceTickets.ticketId'),
|
||||
name: 'ticketId',
|
||||
align: 'center',
|
||||
sortable: true,
|
||||
columnFilter: {
|
||||
component: 'select',
|
||||
component: VnInput,
|
||||
type: 'text',
|
||||
filterValue: null,
|
||||
filterParamKey: 'id',
|
||||
event: getInputEvents,
|
||||
attrs: {
|
||||
url: 'itemPackingTypes',
|
||||
fields: ['code', 'description'],
|
||||
where: { isActive: true },
|
||||
optionValue: 'code',
|
||||
optionLabel: 'description',
|
||||
inWhere: false,
|
||||
dense: true,
|
||||
},
|
||||
},
|
||||
format: (row, dashIfEmpty) => dashIfEmpty(row.ipt),
|
||||
headerClass: 'horizontal-separator',
|
||||
},
|
||||
{
|
||||
label: t('advanceTickets.ipt'),
|
||||
name: 'ipt',
|
||||
field: 'ipt',
|
||||
align: 'left',
|
||||
sortable: true,
|
||||
columnFilter: {
|
||||
component: VnSelect,
|
||||
filterParamKey: 'iptColFilter',
|
||||
type: 'select',
|
||||
filterValue: null,
|
||||
event: getInputEvents,
|
||||
attrs: {
|
||||
options: itemPackingTypesOptions.value,
|
||||
'option-value': 'code',
|
||||
'option-label': 'description',
|
||||
dense: true,
|
||||
},
|
||||
},
|
||||
format: (val) => dashIfEmpty(val),
|
||||
},
|
||||
{
|
||||
label: t('advanceTickets.state'),
|
||||
name: 'state',
|
||||
headerClass: 'horizontal-separator',
|
||||
hidden: true,
|
||||
align: 'left',
|
||||
sortable: true,
|
||||
columnFilter: null,
|
||||
},
|
||||
{
|
||||
label: t('advanceTickets.preparation'),
|
||||
|
@ -84,105 +139,171 @@ const ticketColumns = computed(() => [
|
|||
field: 'preparation',
|
||||
align: 'left',
|
||||
sortable: true,
|
||||
headerClass: 'horizontal-separator',
|
||||
columnFilter: false,
|
||||
columnFilter: null,
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
label: t('advanceTickets.liters'),
|
||||
headerClass: 'horizontal-separator',
|
||||
name: 'liters',
|
||||
field: 'liters',
|
||||
align: 'left',
|
||||
sortable: true,
|
||||
columnFilter: {
|
||||
component: VnInput,
|
||||
type: 'text',
|
||||
filterValue: null,
|
||||
event: getInputEvents,
|
||||
attrs: {
|
||||
dense: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
label: t('advanceTickets.lines'),
|
||||
name: 'lines',
|
||||
headerClass: 'horizontal-separator',
|
||||
format: (row, dashIfEmpty) => dashIfEmpty(row.lines),
|
||||
field: 'lines',
|
||||
align: 'left',
|
||||
sortable: true,
|
||||
columnFilter: {
|
||||
component: VnInput,
|
||||
type: 'text',
|
||||
filterValue: null,
|
||||
event: getInputEvents,
|
||||
attrs: {
|
||||
dense: true,
|
||||
},
|
||||
},
|
||||
format: (val) => dashIfEmpty(val),
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
label: t('advanceTickets.import'),
|
||||
name: 'totalWithVat',
|
||||
hidden: true,
|
||||
headerClass: 'horizontal-separator',
|
||||
format: (row) => toCurrency(row.totalWithVat),
|
||||
field: 'import',
|
||||
name: 'import',
|
||||
align: 'left',
|
||||
sortable: true,
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
label: t('advanceTickets.futureId'),
|
||||
name: 'futureId',
|
||||
headerClass: 'vertical-separator horizontal-separator',
|
||||
columnClass: 'vertical-separator',
|
||||
align: 'left',
|
||||
sortable: true,
|
||||
columnFilter: {
|
||||
component: VnInput,
|
||||
type: 'text',
|
||||
filterValue: null,
|
||||
filterParamKey: 'futureId',
|
||||
event: getInputEvents,
|
||||
attrs: {
|
||||
dense: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
label: t('advanceTickets.futureIpt'),
|
||||
name: 'futureIpt',
|
||||
field: 'futureIpt',
|
||||
align: 'left',
|
||||
sortable: true,
|
||||
columnFilter: {
|
||||
component: 'select',
|
||||
component: VnSelect,
|
||||
filterParamKey: 'futureIptColFilter',
|
||||
type: 'select',
|
||||
filterValue: null,
|
||||
event: getInputEvents,
|
||||
attrs: {
|
||||
url: 'itemPackingTypes',
|
||||
fields: ['code', 'description'],
|
||||
where: { isActive: true },
|
||||
optionValue: 'code',
|
||||
optionLabel: 'description',
|
||||
options: itemPackingTypesOptions.value,
|
||||
'option-value': 'code',
|
||||
'option-label': 'description',
|
||||
dense: true,
|
||||
},
|
||||
},
|
||||
headerClass: 'horizontal-separator',
|
||||
format: (row, dashIfEmpty) => dashIfEmpty(row.futureIpt),
|
||||
format: (val) => dashIfEmpty(val),
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
label: t('advanceTickets.futureState'),
|
||||
name: 'futureState',
|
||||
headerClass: 'horizontal-separator',
|
||||
hidden: true,
|
||||
align: 'left',
|
||||
sortable: true,
|
||||
columnFilter: null,
|
||||
format: (val) => dashIfEmpty(val),
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
label: t('advanceTickets.futureLiters'),
|
||||
headerClass: 'horizontal-separator',
|
||||
name: 'futureLiters',
|
||||
},
|
||||
{
|
||||
field: 'futureLiters',
|
||||
align: 'left',
|
||||
label: t('advanceTickets.futureZone'),
|
||||
name: 'futureZoneFk',
|
||||
columnClass: 'expand',
|
||||
sortable: true,
|
||||
columnFilter: {
|
||||
component: 'select',
|
||||
inWhere: true,
|
||||
component: VnInput,
|
||||
type: 'text',
|
||||
filterValue: null,
|
||||
event: getInputEvents,
|
||||
attrs: {
|
||||
url: 'Zones',
|
||||
fields: ['id', 'name'],
|
||||
dense: true,
|
||||
},
|
||||
},
|
||||
columnField: {
|
||||
component: null,
|
||||
format: (val) => dashIfEmpty(val),
|
||||
},
|
||||
{
|
||||
label: t('advanceTickets.futureZone'),
|
||||
name: 'futureZoneName',
|
||||
field: 'futureZoneName',
|
||||
align: 'left',
|
||||
sortable: true,
|
||||
columnFilter: {
|
||||
component: VnSelect,
|
||||
type: 'select',
|
||||
filterValue: null,
|
||||
filterParamKey: 'futureZoneFk',
|
||||
event: getInputEvents,
|
||||
attrs: {
|
||||
options: zonesOptions.value,
|
||||
'option-value': 'id',
|
||||
'option-label': 'name',
|
||||
dense: true,
|
||||
},
|
||||
},
|
||||
headerClass: 'horizontal-separator',
|
||||
format: (row, dashIfEmpty) => dashIfEmpty(row.futureZoneName),
|
||||
format: (val) => dashIfEmpty(val),
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
label: t('advanceTickets.notMovableLines'),
|
||||
headerClass: 'horizontal-separator',
|
||||
name: 'notMovableLines',
|
||||
field: 'notMovableLines',
|
||||
align: 'left',
|
||||
sortable: true,
|
||||
columnFilter: {
|
||||
component: VnInput,
|
||||
type: 'text',
|
||||
filterValue: null,
|
||||
event: getInputEvents,
|
||||
attrs: {
|
||||
dense: true,
|
||||
},
|
||||
},
|
||||
format: (val) => dashIfEmpty(val),
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
label: t('advanceTickets.futureLines'),
|
||||
headerClass: 'horizontal-separator',
|
||||
name: 'futureLines',
|
||||
field: 'futureLines',
|
||||
align: 'left',
|
||||
sortable: true,
|
||||
columnFilter: {
|
||||
component: VnInput,
|
||||
type: 'text',
|
||||
filterValue: null,
|
||||
event: getInputEvents,
|
||||
attrs: {
|
||||
dense: true,
|
||||
},
|
||||
},
|
||||
format: (val) => dashIfEmpty(val),
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
label: t('advanceTickets.futureImport'),
|
||||
name: 'futureTotalWithVat',
|
||||
hidden: true,
|
||||
headerClass: 'horizontal-separator',
|
||||
format: (row) => toCurrency(row.futureTotalWithVat),
|
||||
name: 'futureImport',
|
||||
align: 'left',
|
||||
sortable: true,
|
||||
columnFilter: null,
|
||||
},
|
||||
]);
|
||||
|
||||
|
@ -208,7 +329,7 @@ const requestComponentUpdate = async (ticket, isWithoutNegatives) => {
|
|||
const query = `tickets/${ticket.futureId}/componentUpdate`;
|
||||
if (!ticket.landed) {
|
||||
const newLanded = await getLanded({
|
||||
shipped: vnTableRef.value.params.dateToAdvance,
|
||||
shipped: userParams.dateToAdvance,
|
||||
addressFk: ticket.futureAddressFk,
|
||||
agencyModeFk: ticket.agencyModeFk ?? ticket.futureAgencyModeFk,
|
||||
warehouseFk: ticket.futureWarehouseFk,
|
||||
|
@ -231,7 +352,7 @@ const requestComponentUpdate = async (ticket, isWithoutNegatives) => {
|
|||
zoneFk: ticket.zoneFk ?? ticket.futureZoneFk,
|
||||
warehouseFk: ticket.futureWarehouseFk,
|
||||
companyFk: ticket.futureCompanyFk,
|
||||
shipped: vnTableRef.value.params.dateToAdvance,
|
||||
shipped: userParams.dateToAdvance,
|
||||
landed: ticket.landed,
|
||||
isDeleted: false,
|
||||
isWithoutNegatives,
|
||||
|
@ -243,31 +364,36 @@ const requestComponentUpdate = async (ticket, isWithoutNegatives) => {
|
|||
};
|
||||
|
||||
const moveTicketsAdvance = async () => {
|
||||
let ticketsToMove = [];
|
||||
for (const ticket of selectedTickets.value) {
|
||||
if (!ticket.id) {
|
||||
try {
|
||||
const { query, params } = await requestComponentUpdate(ticket, false);
|
||||
axios.post(query, params);
|
||||
} catch (e) {
|
||||
console.error('Error moving ticket', e);
|
||||
try {
|
||||
let ticketsToMove = [];
|
||||
for (const ticket of selectedTickets.value) {
|
||||
if (!ticket.id) {
|
||||
try {
|
||||
const { query, params } = await requestComponentUpdate(ticket, false);
|
||||
axios.post(query, params);
|
||||
} catch (e) {
|
||||
console.error('Error moving ticket', e);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
continue;
|
||||
ticketsToMove.push({
|
||||
originId: ticket.futureId,
|
||||
destinationId: ticket.id,
|
||||
originShipped: ticket.futureShipped,
|
||||
destinationShipped: ticket.shipped,
|
||||
workerFk: ticket.workerFk,
|
||||
});
|
||||
}
|
||||
ticketsToMove.push({
|
||||
originId: ticket.futureId,
|
||||
destinationId: ticket.id,
|
||||
originShipped: ticket.futureShipped,
|
||||
destinationShipped: ticket.shipped,
|
||||
workerFk: ticket.workerFk,
|
||||
});
|
||||
}
|
||||
|
||||
const params = { tickets: ticketsToMove };
|
||||
await axios.post('Tickets/merge', params);
|
||||
vnTableRef.value.reload();
|
||||
selectedTickets.value = [];
|
||||
if (ticketsToMove.length) notify(t('advanceTickets.moveTicketSuccess'), 'positive');
|
||||
const params = { tickets: ticketsToMove };
|
||||
await axios.post('Tickets/merge', params);
|
||||
arrayData.fetch({ append: false });
|
||||
selectedTickets.value = [];
|
||||
if (ticketsToMove.length)
|
||||
notify(t('advanceTickets.moveTicketSuccess'), 'positive');
|
||||
} catch (error) {
|
||||
console.error('Error moving tickets', error);
|
||||
}
|
||||
};
|
||||
|
||||
const progressLength = ref(0);
|
||||
|
@ -308,8 +434,10 @@ const splitTickets = async () => {
|
|||
progressAdd(ticket.futureId);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error splitting tickets', error);
|
||||
} finally {
|
||||
vnTableRef.value.reload();
|
||||
arrayData.fetch({ append: false });
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -327,52 +455,22 @@ const handleCloseProgressDialog = () => {
|
|||
|
||||
const handleCancelProgress = () => (cancelProgress.value = true);
|
||||
|
||||
watch(
|
||||
() => vnTableRef.value.tableRef?.$el,
|
||||
($el) => {
|
||||
if (!$el) return;
|
||||
const head = $el.querySelector('thead');
|
||||
const firstRow = $el.querySelector('thead > tr');
|
||||
|
||||
const newRow = document.createElement('tr');
|
||||
destinationElRef.value = document.createElement('th');
|
||||
originElRef.value = document.createElement('th');
|
||||
|
||||
newRow.classList.add('bg-header');
|
||||
destinationElRef.value.classList.add('text-uppercase', 'color-vn-label');
|
||||
originElRef.value.classList.add('text-uppercase', 'color-vn-label');
|
||||
|
||||
destinationElRef.value.setAttribute('colspan', '7');
|
||||
originElRef.value.setAttribute('colspan', '9');
|
||||
|
||||
destinationElRef.value.textContent = `${t(
|
||||
'advanceTickets.destination'
|
||||
)} ${toDateFormat(vnTableRef.value.params.dateToAdvance)}`;
|
||||
originElRef.value.textContent = `${t('advanceTickets.origin')} ${toDateFormat(
|
||||
vnTableRef.value.params.dateFuture
|
||||
)}`;
|
||||
|
||||
newRow.append(destinationElRef.value, originElRef.value);
|
||||
head.insertBefore(newRow, firstRow);
|
||||
},
|
||||
{ once: true, inmmediate: true }
|
||||
);
|
||||
|
||||
watch(
|
||||
() => vnTableRef.value.params,
|
||||
() => {
|
||||
if (originElRef.value && destinationElRef.value) {
|
||||
destinationElRef.value.textContent = `${t(
|
||||
'advanceTickets.destination'
|
||||
)} ${toDateFormat(vnTableRef.value.params.dateToAdvance)}`;
|
||||
originElRef.value.textContent = `${t('advanceTickets.origin')} ${toDateFormat(
|
||||
vnTableRef.value.params.dateFuture
|
||||
)}`;
|
||||
}
|
||||
},
|
||||
{ deep: true }
|
||||
);
|
||||
onMounted(async () => {
|
||||
let today = Date.vnNew();
|
||||
const tomorrow = new Date(today);
|
||||
tomorrow.setDate(tomorrow.getDate() + 1);
|
||||
userParams.dateFuture = tomorrow;
|
||||
userParams.dateToAdvance = today;
|
||||
userParams.scopeDays = 1;
|
||||
userParams.warehouseFk = user.value.warehouseFk;
|
||||
userParams.ipt = 'H';
|
||||
userParams.futureIpt = 'H';
|
||||
userParams.isFullMovable = true;
|
||||
const filter = { limit: 0 };
|
||||
await arrayData.addFilter({ filter, userParams });
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<FetchData
|
||||
url="itemPackingTypes"
|
||||
|
@ -393,6 +491,11 @@ watch(
|
|||
auto-load
|
||||
@on-fetch="(data) => (zonesOptions = data)"
|
||||
/>
|
||||
<VnSearchbar
|
||||
data-key="WeeklyTickets"
|
||||
:label="t('weeklyTickets.search')"
|
||||
:info="t('weeklyTickets.searchInfo')"
|
||||
/>
|
||||
<VnSubToolbar>
|
||||
<template #st-data>
|
||||
<QBtn
|
||||
|
@ -436,109 +539,174 @@ watch(
|
|||
</VnSubToolbar>
|
||||
<RightMenu>
|
||||
<template #right-panel>
|
||||
<TicketAdvanceFilter data-key="advanceTickets" />
|
||||
<TicketAdvanceFilter data-key="AdvanceTickets" />
|
||||
</template>
|
||||
</RightMenu>
|
||||
<QPage class="column items-center q-pa-md">
|
||||
<VnTable
|
||||
data-key="advanceTickets"
|
||||
ref="vnTableRef"
|
||||
url="Tickets/getTicketsAdvance"
|
||||
search-url="advanceTickets"
|
||||
:user-params="userParams"
|
||||
:limit="0"
|
||||
<QTable
|
||||
:rows="tickets"
|
||||
:columns="ticketColumns"
|
||||
:table="{
|
||||
'row-key': '$index',
|
||||
selection: 'multiple',
|
||||
}"
|
||||
row-key="index"
|
||||
selection="multiple"
|
||||
v-model:selected="selectedTickets"
|
||||
:pagination="{ rowsPerPage: 0 }"
|
||||
:no-data-label="t('globals.noResults')"
|
||||
:right-search="false"
|
||||
auto-load
|
||||
:disable-option="{ card: true }"
|
||||
style="max-width: 99%"
|
||||
>
|
||||
<template #column-icons="{ row }">
|
||||
<QIcon
|
||||
v-if="row.futureAgency !== row.agency && row.agency"
|
||||
color="primary"
|
||||
name="vn:agency-term"
|
||||
size="xs"
|
||||
>
|
||||
<QTooltip class="column">
|
||||
<span>
|
||||
{{
|
||||
t('advanceTickets.originAgency', {
|
||||
agency: row.futureAgency,
|
||||
})
|
||||
}}
|
||||
</span>
|
||||
<span>
|
||||
{{
|
||||
t('advanceTickets.destinationAgency', {
|
||||
agency: row.agency,
|
||||
})
|
||||
}}
|
||||
</span>
|
||||
</QTooltip>
|
||||
</QIcon>
|
||||
<template #header="props">
|
||||
{{ userParams.scopeDays }}
|
||||
<QTr :props="props">
|
||||
<QTh
|
||||
class="horizontal-separator text-uppercase color-vn-label"
|
||||
colspan="7"
|
||||
translate
|
||||
>
|
||||
{{ t('advanceTickets.destination') }}
|
||||
{{ toDateFormat(userParams.dateToAdvance) }}
|
||||
</QTh>
|
||||
<QTh
|
||||
class="horizontal-separator text-uppercase color-vn-label"
|
||||
colspan="9"
|
||||
translate
|
||||
>
|
||||
{{ t('advanceTickets.origin') }}
|
||||
{{ toDateFormat(userParams.dateFuture) }}
|
||||
</QTh>
|
||||
</QTr>
|
||||
<QTr>
|
||||
<QTh>
|
||||
<QCheckbox v-model="props.selected" />
|
||||
</QTh>
|
||||
<QTh
|
||||
v-for="(col, index) in ticketColumns"
|
||||
:key="index"
|
||||
:class="{ 'vertical-separator': col.name === 'futureId' }"
|
||||
>
|
||||
{{ col.label }}
|
||||
</QTh>
|
||||
</QTr>
|
||||
</template>
|
||||
<template #column-id="{ row }">
|
||||
<QBtn flat class="link">
|
||||
{{ row.id }}
|
||||
<TicketDescriptorProxy :id="row.id" />
|
||||
</QBtn>
|
||||
<template #top-row="{ cols }">
|
||||
<QTr>
|
||||
<QTd />
|
||||
<QTd
|
||||
v-for="(col, index) in cols"
|
||||
:key="index"
|
||||
style="max-width: 100px"
|
||||
>
|
||||
<component
|
||||
:is="col.columnFilter.component"
|
||||
v-if="col.columnFilter"
|
||||
v-model="col.columnFilter.filterValue"
|
||||
v-bind="col.columnFilter.attrs"
|
||||
v-on="col.columnFilter.event(col)"
|
||||
dense
|
||||
/>
|
||||
</QTd>
|
||||
</QTr>
|
||||
</template>
|
||||
<template #column-state="{ row }">
|
||||
<QBadge
|
||||
v-if="row.state"
|
||||
text-color="black"
|
||||
:color="row.classColor"
|
||||
class="q-ma-none"
|
||||
dense
|
||||
>
|
||||
{{ row.state }}
|
||||
</QBadge>
|
||||
<span v-else> {{ dashIfEmpty(row.state) }}</span>
|
||||
<template #header-cell-availableLines="{ col }">
|
||||
<QTh class="vertical-separator">
|
||||
{{ col.label }}
|
||||
</QTh>
|
||||
</template>
|
||||
<template #column-import="{ row }">
|
||||
<QBadge
|
||||
:text-color="isLessThan50(row.totalWithVat) ? 'black' : 'white'"
|
||||
:color="totalPriceColor(row.totalWithVat)"
|
||||
class="q-ma-none"
|
||||
dense
|
||||
>
|
||||
{{ toCurrency(row.totalWithVat || 0) }}
|
||||
</QBadge>
|
||||
<template #body-cell-icons="{ row }">
|
||||
<QTd class="q-gutter-x-xs">
|
||||
<QIcon
|
||||
v-if="row.futureAgency !== row.agency && row.agency"
|
||||
color="primary"
|
||||
name="vn:agency-term"
|
||||
size="xs"
|
||||
>
|
||||
<QTooltip class="column">
|
||||
<span>
|
||||
{{
|
||||
t('advanceTickets.originAgency', {
|
||||
agency: row.futureAgency,
|
||||
})
|
||||
}}
|
||||
</span>
|
||||
<span>
|
||||
{{
|
||||
t('advanceTickets.destinationAgency', {
|
||||
agency: row.agency,
|
||||
})
|
||||
}}
|
||||
</span>
|
||||
</QTooltip>
|
||||
</QIcon>
|
||||
</QTd>
|
||||
</template>
|
||||
<template #column-futureId="{ row }">
|
||||
<QBtn flat class="link" dense>
|
||||
{{ row.futureId }}
|
||||
<TicketDescriptorProxy :id="row.futureId" />
|
||||
</QBtn>
|
||||
|
||||
<template #body-cell-ticketId="{ row }">
|
||||
<QTd>
|
||||
<QBtn flat class="link">
|
||||
{{ row.id }}
|
||||
<TicketDescriptorProxy :id="row.id" />
|
||||
</QBtn>
|
||||
</QTd>
|
||||
</template>
|
||||
<template #column-futureState="{ row }">
|
||||
<QBadge
|
||||
text-color="black"
|
||||
:color="row.futureClassColor"
|
||||
class="q-ma-none"
|
||||
dense
|
||||
>
|
||||
{{ row.futureState }}
|
||||
</QBadge>
|
||||
<template #body-cell-state="{ row }">
|
||||
<QTd>
|
||||
<QBadge
|
||||
v-if="row.state"
|
||||
text-color="black"
|
||||
:color="row.classColor"
|
||||
class="q-ma-none"
|
||||
dense
|
||||
>
|
||||
{{ row.state }}
|
||||
</QBadge>
|
||||
<span v-else> {{ dashIfEmpty(row.state) }}</span>
|
||||
</QTd>
|
||||
</template>
|
||||
<template #column-futureImport="{ row }">
|
||||
<QBadge
|
||||
:text-color="isLessThan50(row.futureTotalWithVat) ? 'black' : 'white'"
|
||||
:color="totalPriceColor(row.futureTotalWithVat)"
|
||||
class="q-ma-none"
|
||||
dense
|
||||
>
|
||||
{{ toCurrency(row.futureTotalWithVat || 0) }}
|
||||
</QBadge>
|
||||
<template #body-cell-import="{ row }">
|
||||
<QTd>
|
||||
<QBadge
|
||||
:text-color="isLessThan50(row.totalWithVat) ? 'black' : 'white'"
|
||||
:color="totalPriceColor(row.totalWithVat)"
|
||||
class="q-ma-none"
|
||||
dense
|
||||
>
|
||||
{{ toCurrency(row.totalWithVat || 0) }}
|
||||
</QBadge>
|
||||
</QTd>
|
||||
</template>
|
||||
</VnTable>
|
||||
<template #body-cell-futureId="{ row }">
|
||||
<QTd class="vertical-separator">
|
||||
<QBtn flat class="link" dense>
|
||||
{{ row.futureId }}
|
||||
<TicketDescriptorProxy :id="row.futureId" />
|
||||
</QBtn>
|
||||
</QTd>
|
||||
</template>
|
||||
<template #body-cell-futureState="{ row }">
|
||||
<QTd>
|
||||
<QBadge
|
||||
text-color="black"
|
||||
:color="row.futureClassColor"
|
||||
class="q-ma-none"
|
||||
dense
|
||||
>
|
||||
{{ row.futureState }}
|
||||
</QBadge>
|
||||
</QTd>
|
||||
</template>
|
||||
<template #body-cell-futureImport="{ row }">
|
||||
<QTd>
|
||||
<QBadge
|
||||
:text-color="
|
||||
isLessThan50(row.futureTotalWithVat) ? 'black' : 'white'
|
||||
"
|
||||
:color="totalPriceColor(row.futureTotalWithVat)"
|
||||
class="q-ma-none"
|
||||
dense
|
||||
>
|
||||
{{ toCurrency(row.futureTotalWithVat || 0) }}
|
||||
</QBadge>
|
||||
</QTd>
|
||||
</template>
|
||||
</QTable>
|
||||
<VnProgress
|
||||
:progress="progressPercentage"
|
||||
:cancelled="cancelProgress"
|
||||
|
@ -557,11 +725,11 @@ watch(
|
|||
</template>
|
||||
|
||||
<style scoped lang="scss">
|
||||
:deep(.vertical-separator) {
|
||||
.vertical-separator {
|
||||
border-left: 4px solid white !important;
|
||||
}
|
||||
|
||||
:deep(.horizontal-separator) {
|
||||
border-top: 4px solid white !important;
|
||||
.horizontal-separator {
|
||||
border-bottom: 4px solid white !important;
|
||||
}
|
||||
</style>
|
||||
|
|
|
@ -27,16 +27,20 @@ const warehousesOptions = ref([]);
|
|||
const itemPackingTypes = ref([]);
|
||||
|
||||
const getItemPackingTypes = async () => {
|
||||
const filter = {
|
||||
where: { isActive: true },
|
||||
};
|
||||
const { data } = await axios.get('ItemPackingTypes', {
|
||||
params: { filter: JSON.stringify(filter) },
|
||||
});
|
||||
itemPackingTypes.value = data.map((ipt) => ({
|
||||
description: t(ipt.description),
|
||||
code: ipt.code,
|
||||
}));
|
||||
try {
|
||||
const filter = {
|
||||
where: { isActive: true },
|
||||
};
|
||||
const { data } = await axios.get('ItemPackingTypes', {
|
||||
params: { filter: JSON.stringify(filter) },
|
||||
});
|
||||
itemPackingTypes.value = data.map((ipt) => ({
|
||||
description: t(ipt.description),
|
||||
code: ipt.code,
|
||||
}));
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
|
||||
const getLocale = (val) => {
|
||||
|
@ -54,7 +58,6 @@ onMounted(async () => await getItemPackingTypes());
|
|||
auto-load
|
||||
/>
|
||||
<VnFilterPanel
|
||||
search-url="advanceTickets"
|
||||
:data-key="props.dataKey"
|
||||
:search-button="true"
|
||||
:hidden-tags="['search']"
|
||||
|
@ -98,7 +101,6 @@ onMounted(async () => await getItemPackingTypes());
|
|||
dense
|
||||
outlined
|
||||
rounded
|
||||
:use-like="false"
|
||||
>
|
||||
</VnSelect>
|
||||
</QItemSection>
|
||||
|
@ -116,7 +118,6 @@ onMounted(async () => await getItemPackingTypes());
|
|||
dense
|
||||
outlined
|
||||
rounded
|
||||
:use-like="false"
|
||||
>
|
||||
</VnSelect>
|
||||
</QItemSection>
|
||||
|
|
|
@ -24,25 +24,33 @@ const itemPackingTypes = ref([]);
|
|||
const stateOptions = ref([]);
|
||||
|
||||
const getItemPackingTypes = async () => {
|
||||
const filter = {
|
||||
where: { isActive: true },
|
||||
};
|
||||
const { data } = await axios.get('ItemPackingTypes', {
|
||||
params: { filter: JSON.stringify(filter) },
|
||||
});
|
||||
itemPackingTypes.value = data.map((ipt) => ({
|
||||
description: t(ipt.description),
|
||||
code: ipt.code,
|
||||
}));
|
||||
try {
|
||||
const filter = {
|
||||
where: { isActive: true },
|
||||
};
|
||||
const { data } = await axios.get('ItemPackingTypes', {
|
||||
params: { filter: JSON.stringify(filter) },
|
||||
});
|
||||
itemPackingTypes.value = data.map((ipt) => ({
|
||||
description: t(ipt.description),
|
||||
code: ipt.code,
|
||||
}));
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
|
||||
const getGroupedStates = async () => {
|
||||
const { data } = await axios.get('AlertLevels');
|
||||
stateOptions.value = data.map((state) => ({
|
||||
id: state.id,
|
||||
name: t(`futureTickets.${state.code}`),
|
||||
code: state.code,
|
||||
}));
|
||||
try {
|
||||
const { data } = await axios.get('AlertLevels');
|
||||
stateOptions.value = data.map((state) => ({
|
||||
id: state.id,
|
||||
name: t(`futureTickets.${state.code}`),
|
||||
code: state.code,
|
||||
}));
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
|
||||
onMounted(async () => {
|
||||
|
|
|
@ -72,6 +72,16 @@ const agenciesOptions = ref([]);
|
|||
</VnRow>
|
||||
<VnRow>
|
||||
<VnInput v-model="data.m3" label="m3" />
|
||||
<VnInput
|
||||
:label="t('travel.basicData.daysInForward')"
|
||||
v-model="data.daysInForward"
|
||||
>
|
||||
<template #append>
|
||||
<QIcon name="info" class="cursor-info">
|
||||
<QTooltip>{{ t('raidDays') }}</QTooltip>
|
||||
</QIcon>
|
||||
</template>
|
||||
</VnInput>
|
||||
</VnRow>
|
||||
<VnRow>
|
||||
<QCheckbox
|
||||
|
@ -86,3 +96,10 @@ const agenciesOptions = ref([]);
|
|||
</template>
|
||||
</FormModel>
|
||||
</template>
|
||||
|
||||
<i18n>
|
||||
es:
|
||||
raidDays: Al rellenarlo, generamos una redada. Indica los días que un travel se moverá automáticamente en el tiempo
|
||||
en:
|
||||
raidDays: When filling, a raid is generated. Enter the number of days the travel will automatically forward in time
|
||||
</i18n>
|
||||
|
|
|
@ -32,6 +32,7 @@ const filter = {
|
|||
'warehouseOutFk',
|
||||
'cargoSupplierFk',
|
||||
'agencyModeFk',
|
||||
'daysInForward',
|
||||
],
|
||||
include: [
|
||||
{
|
||||
|
@ -77,6 +78,22 @@ const setData = (entity) => (data.value = useCardDescription(entity.ref, entity.
|
|||
<VnLv :label="t('globals.landed')" :value="toDate(entity.landed)" />
|
||||
<VnLv :label="t('globals.totalEntries')" :value="entity.totalEntries" />
|
||||
</template>
|
||||
<template #icons="{ entity }">
|
||||
<QCardActions class="q-gutter-x-md">
|
||||
<QIcon
|
||||
v-if="entity.daysInForward"
|
||||
name="vn:net"
|
||||
color="primary"
|
||||
size="xs"
|
||||
>
|
||||
<QTooltip>
|
||||
{{
|
||||
t('globals.raid', { daysInForward: entity.daysInForward })
|
||||
}}</QTooltip
|
||||
>
|
||||
</QIcon>
|
||||
</QCardActions>
|
||||
</template>
|
||||
<template #actions="{ entity }">
|
||||
<QCardActions>
|
||||
<QBtn
|
||||
|
|
|
@ -303,6 +303,10 @@ const getLink = (param) => `#/travel/${entityId.value}/${param}`;
|
|||
<VnLv :label="t('globals.reference')" :value="travel.ref" />
|
||||
<VnLv label="m³" :value="travel.m3" />
|
||||
<VnLv :label="t('globals.totalEntries')" :value="travel.totalEntries" />
|
||||
<VnLv
|
||||
:label="t('travel.basicData.daysInForward')"
|
||||
:value="travel?.daysInForward"
|
||||
/>
|
||||
</QCard>
|
||||
<QCard class="full-width">
|
||||
<VnTitle :text="t('travel.summary.entries')" />
|
||||
|
|
|
@ -45,6 +45,10 @@ const redirectCreateEntryView = (travelData) => {
|
|||
};
|
||||
|
||||
const columns = computed(() => [
|
||||
{
|
||||
name: 'status',
|
||||
hidden: true,
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
name: 'id',
|
||||
|
@ -221,6 +225,17 @@ const columns = computed(() => [
|
|||
:is-editable="false"
|
||||
:use-model="true"
|
||||
>
|
||||
<template #column-status="{ row }">
|
||||
<div class="row">
|
||||
<QIcon v-if="!!row.daysInForward" name="vn:net" color="primary">
|
||||
<QTooltip>
|
||||
{{
|
||||
t('globals.raid', { daysInForward: row.daysInForward })
|
||||
}}</QTooltip
|
||||
>
|
||||
</QIcon>
|
||||
</div>
|
||||
</template>
|
||||
<template #column-shipped="{ row }">
|
||||
<QBadge
|
||||
text-color="black"
|
||||
|
|
|
@ -17,11 +17,6 @@ const $props = defineProps({
|
|||
required: false,
|
||||
default: null,
|
||||
},
|
||||
dataKey: {
|
||||
type: String,
|
||||
required: false,
|
||||
default: 'workerData',
|
||||
},
|
||||
});
|
||||
const image = ref(null);
|
||||
|
||||
|
@ -70,7 +65,7 @@ const handlePhotoUpdated = (evt = false) => {
|
|||
<CardDescriptor
|
||||
ref="cardDescriptorRef"
|
||||
module="Worker"
|
||||
:data-key="dataKey"
|
||||
data-key="workerData"
|
||||
url="Workers/descriptor"
|
||||
:filter="{ where: { id: entityId } }"
|
||||
title="user.nickname"
|
||||
|
|
|
@ -12,11 +12,6 @@ const $props = defineProps({
|
|||
|
||||
<template>
|
||||
<QPopupProxy>
|
||||
<WorkerDescriptor
|
||||
v-if="$props.id"
|
||||
:id="$props.id"
|
||||
:summary="WorkerSummary"
|
||||
data-key="workerDescriptorProxy"
|
||||
/>
|
||||
<WorkerDescriptor v-if="$props.id" :id="$props.id" :summary="WorkerSummary" />
|
||||
</QPopupProxy>
|
||||
</template>
|
||||
|
|
|
@ -44,9 +44,8 @@ async function toggleNotification(notification) {
|
|||
`worker.notificationsManager.${notification.active ? '' : 'un'}subscribed`
|
||||
),
|
||||
});
|
||||
} catch (e) {
|
||||
} catch {
|
||||
notification.active = !notification.active;
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -34,13 +34,21 @@ const columns = computed(() => [
|
|||
]);
|
||||
|
||||
const deleteWarehouse = async (row) => {
|
||||
await axios.delete(`${urlPath.value}/${row.id}`);
|
||||
fetchWarehouses();
|
||||
try {
|
||||
await axios.delete(`${urlPath.value}/${row.id}`);
|
||||
fetchWarehouses();
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
|
||||
const createZoneWarehouse = async (ZoneWarehouseFormData) => {
|
||||
await axios.post(urlPath.value, ZoneWarehouseFormData);
|
||||
fetchWarehouses();
|
||||
try {
|
||||
await axios.post(urlPath.value, ZoneWarehouseFormData);
|
||||
fetchWarehouses();
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
|
||||
watch(
|
||||
|
|
|
@ -13,7 +13,7 @@ describe('Logout', () => {
|
|||
});
|
||||
describe('not user', () => {
|
||||
beforeEach(() => {
|
||||
cy.intercept('GET', '**DefaultViewConfigs**', {
|
||||
cy.intercept('GET', '**/VnUsers/acl', {
|
||||
statusCode: 401,
|
||||
body: {
|
||||
error: {
|
||||
|
@ -24,11 +24,10 @@ describe('Logout', () => {
|
|||
},
|
||||
},
|
||||
statusMessage: 'AUTHORIZATION_REQUIRED',
|
||||
});
|
||||
}).as('someRoute');
|
||||
});
|
||||
|
||||
it('when token not exists', () => {
|
||||
cy.get('.q-list > [href="#/item"]').click();
|
||||
cy.reload();
|
||||
cy.get('.q-notification__message').should(
|
||||
'have.text',
|
||||
'Authorization Required'
|
||||
|
|
|
@ -7,20 +7,31 @@ describe('AgencyWorkCenter', () => {
|
|||
const createButton = '.q-page-sticky > div > .q-btn > .q-btn__content > .q-icon';
|
||||
const workCenterCombobox = 'input[role="combobox"]';
|
||||
|
||||
it('check workCenter crud', () => {
|
||||
// create
|
||||
it('assign workCenter', () => {
|
||||
cy.get(createButton).click();
|
||||
cy.get(workCenterCombobox).type('workCenterOne{enter}');
|
||||
cy.hasNotify('Data created');
|
||||
cy.get('.q-notification__message').should('have.text', 'Data created');
|
||||
});
|
||||
|
||||
// expect error when duplicate
|
||||
cy.get(createButton).click();
|
||||
cy.get('[data-cy="FormModelPopup_save"]').click();
|
||||
cy.hasNotify('This workCenter is already assigned to this agency');
|
||||
cy.get('[data-cy="FormModelPopup_cancel"]').click();
|
||||
|
||||
// delete
|
||||
it('delete workCenter', () => {
|
||||
cy.get('.q-item__section--side > .q-btn > .q-btn__content > .q-icon').click();
|
||||
cy.hasNotify('WorkCenter removed successfully');
|
||||
cy.get('.q-notification__message').should(
|
||||
'have.text',
|
||||
'WorkCenter removed successfully'
|
||||
);
|
||||
});
|
||||
|
||||
it('error on duplicate workCenter', () => {
|
||||
cy.get(createButton).click();
|
||||
cy.get(workCenterCombobox).type('workCenterOne{enter}');
|
||||
cy.get('.q-notification__message').should('have.text', 'Data created');
|
||||
cy.get(createButton).click();
|
||||
cy.get(
|
||||
'.vn-row > .q-field > .q-field__inner > .q-field__control > .q-field__control-container'
|
||||
).type('workCenterOne{enter}');
|
||||
|
||||
cy.get(
|
||||
':nth-child(2) > .q-notification__wrapper > .q-notification__content > .q-notification__message'
|
||||
).should('have.text', 'This workCenter is already assigned to this agency');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -17,7 +17,10 @@ describe('WorkerNotificationsManager', () => {
|
|||
cy.login('developer');
|
||||
cy.visit(`/#/worker/${salesPersonId}/notifications`);
|
||||
cy.get(firstAvailableNotification).click();
|
||||
cy.hasNotify('The notification subscription of this worker cant be modified');
|
||||
cy.notificationHas(
|
||||
'.q-notification__message',
|
||||
'The notification subscription of this worker cant be modified'
|
||||
);
|
||||
});
|
||||
|
||||
it('should active a notification that is yours', () => {
|
||||
|
|
|
@ -262,14 +262,3 @@ Cypress.Commands.add('openUserPanel', () => {
|
|||
'.column > .q-avatar > .q-avatar__content > .q-img > .q-img__container > .q-img__image'
|
||||
).click();
|
||||
});
|
||||
|
||||
Cypress.Commands.add('hasNotify', (text) => {
|
||||
//last
|
||||
cy.get('.q-notification')
|
||||
.should('be.visible')
|
||||
.last()
|
||||
.then(($lastNotification) => {
|
||||
if (!Cypress.$($lastNotification).text().includes(text))
|
||||
throw new Error(`Notification not found: "${text}"`);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -36,6 +36,8 @@ describe('Axios boot', () => {
|
|||
|
||||
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,
|
||||
|
@ -43,10 +45,19 @@ describe('Axios boot', () => {
|
|||
};
|
||||
|
||||
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,
|
||||
|
@ -59,7 +70,14 @@ describe('Axios boot', () => {
|
|||
};
|
||||
|
||||
const result = onResponseError(error);
|
||||
|
||||
expect(result).rejects.toEqual(expect.objectContaining(error));
|
||||
expect(Notify.create).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
message: 'Invalid user or password',
|
||||
type: 'negative',
|
||||
})
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue