forked from verdnatura/salix-front
Compare commits
67 Commits
7346-manua
...
dev
Author | SHA1 | Date |
---|---|---|
Alex Moreno | fd72f4dd45 | |
Alex Moreno | 9daed096db | |
Alex Moreno | e86afd57a0 | |
Alex Moreno | d529676ab5 | |
Jorge Penadés | 4828e32c9e | |
Jorge Penadés | e26692fa51 | |
Jorge Penadés | 823c354ef1 | |
Jorge Penadés | f52b4c9a59 | |
Alex Moreno | cb2780fe6f | |
Jorge Penadés | c9cfb2b1cf | |
Alex Moreno | 48fdc9e624 | |
Jorge Penadés | f1350dece5 | |
Jorge Penadés | 2779e7ac8d | |
Jorge Penadés | d918b76010 | |
Jorge Penadés | 6f57d9e490 | |
Alex Moreno | de7f55c589 | |
Alex Moreno | 32b4636706 | |
Alex Moreno | f26976b744 | |
Javi Gallego | a0a37a68a0 | |
Jorge Penadés | 1bfede4a55 | |
Jorge Penadés | 4e31566ddd | |
Jorge Penadés | 33ee1ea01b | |
Jorge Penadés | 126bb3f039 | |
Jorge Penadés | 9673f7be1e | |
Alex Moreno | d1e4017869 | |
Alex Moreno | 5d4b5ad598 | |
Alex Moreno | 2420c6dee2 | |
Alex Moreno | 0528474250 | |
Alex Moreno | e7acdfd4f7 | |
Javi Gallego | 3cbd294168 | |
Javi Gallego | 1bf1844c8f | |
Javi Gallego | ae56c06628 | |
Alex Moreno | 735ee09ef8 | |
Alex Moreno | aaf749db6c | |
Alex Moreno | 81a55a9e7a | |
Jorge Penadés | 41509c60dd | |
Jorge Penadés | 033d6bddbe | |
Jorge Penadés | da4c1e9c12 | |
Jorge Penadés | 9f3c834ce4 | |
Jorge Penadés | b1a511ff6f | |
Alex Moreno | f9392464e5 | |
Alex Moreno | ee31bc8262 | |
Alex Moreno | 0d3e8bb5d2 | |
Alex Moreno | dd2dc86eea | |
Javi Gallego | 93025007f1 | |
Alex Moreno | cd00a3c67f | |
Alex Moreno | 0c9c01b6e9 | |
Alex Moreno | 2d81cffb33 | |
Jorge Penadés | f751408de2 | |
Alex Moreno | a732ec05fb | |
Alex Moreno | 9db1c4f721 | |
Alex Moreno | ffd4a402ab | |
Carlos Satorres | c799d17e19 | |
Alex Moreno | 36221121f5 | |
Alex Moreno | b4d4844100 | |
Jorge Penadés | 0fbd5f45e1 | |
Alex Moreno | c69f7af390 | |
Alex Moreno | 8478d89183 | |
Alex Moreno | 9780fe596f | |
Alex Moreno | 6f79275521 | |
Alex Moreno | 52981953f7 | |
Jorge Penadés | a4358ec0ed | |
Jorge Penadés | 2b2ccbc6a1 | |
Jon Elias | e47cdff4ca | |
Jon Elias | 98a380e026 | |
Jon Elias | 1183d86867 | |
Jon Elias | 0aab17becc |
|
@ -39,37 +39,7 @@ const onResponse = (response) => {
|
|||
const onResponseError = (error) => {
|
||||
stateQuery.remove(error.config);
|
||||
|
||||
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) {
|
||||
if (session.isLoggedIn() && error.response?.status === 401) {
|
||||
session.destroy(false);
|
||||
const hash = window.location.hash;
|
||||
const url = hash.slice(1);
|
||||
|
@ -78,8 +48,6 @@ const onResponseError = (error) => {
|
|||
return Promise.reject(error);
|
||||
}
|
||||
|
||||
notify(message, 'negative');
|
||||
|
||||
return Promise.reject(error);
|
||||
};
|
||||
|
||||
|
|
|
@ -3,14 +3,51 @@ 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 = function (err) {
|
||||
console.error(err);
|
||||
notify('globals.error', 'negative', 'error');
|
||||
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');
|
||||
};
|
||||
});
|
||||
|
|
|
@ -217,9 +217,6 @@ 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,6 +61,7 @@ defineExpose({
|
|||
:loading="isLoading"
|
||||
@click="emit('onDataCanceled')"
|
||||
v-close-popup
|
||||
data-cy="FormModelPopup_cancel"
|
||||
/>
|
||||
<QBtn
|
||||
:label="t('globals.save')"
|
||||
|
@ -70,6 +71,7 @@ defineExpose({
|
|||
class="q-ml-sm"
|
||||
:disabled="isLoading"
|
||||
:loading="isLoading"
|
||||
data-cy="FormModelPopup_save"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<script setup>
|
||||
import { ref, watch } from 'vue';
|
||||
import { ref } from 'vue';
|
||||
import { useValidator } from 'src/composables/useValidator';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
|
|
|
@ -316,6 +316,7 @@ defineExpose({
|
|||
selected,
|
||||
CrudModelRef,
|
||||
params,
|
||||
tableRef,
|
||||
});
|
||||
|
||||
function handleOnDataSaved(_) {
|
||||
|
@ -416,6 +417,7 @@ function handleScroll() {
|
|||
ref="tableRef"
|
||||
v-bind="table"
|
||||
class="vnTable"
|
||||
:class="{ 'last-row-sticky': $props.footer }"
|
||||
:columns="splittedColumns.columns"
|
||||
:rows="rows"
|
||||
v-model:selected="selected"
|
||||
|
@ -455,7 +457,11 @@ function handleScroll() {
|
|||
/>
|
||||
</template>
|
||||
<template #header-cell="{ col }">
|
||||
<QTh v-if="col.visible ?? true">
|
||||
<QTh
|
||||
v-if="col.visible ?? true"
|
||||
:style="col.headerStyle"
|
||||
:class="col.headerClass"
|
||||
>
|
||||
<div
|
||||
class="column self-start q-ml-xs ellipsis"
|
||||
:class="`text-${col?.align ?? 'left'}`"
|
||||
|
@ -815,6 +821,7 @@ es:
|
|||
top: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.vnTable {
|
||||
thead tr th {
|
||||
position: sticky;
|
||||
|
@ -853,6 +860,9 @@ es:
|
|||
table tbody th {
|
||||
position: relative;
|
||||
}
|
||||
}
|
||||
|
||||
.last-row-sticky {
|
||||
tbody:nth-last-child(1) {
|
||||
@extend .bg-header;
|
||||
position: sticky;
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
<script setup>
|
||||
import VnSelect from './VnSelect.vue';
|
||||
|
||||
defineProps({
|
||||
selectProps: { type: Object, required: true },
|
||||
promise: { type: Function, default: () => {} },
|
||||
});
|
||||
</script>
|
||||
<template>
|
||||
<QBtnDropdown v-bind="$attrs" color="primary">
|
||||
<VnSelect
|
||||
v-bind="selectProps"
|
||||
hide-selected
|
||||
hide-dropdown-icon
|
||||
focus-on-mount
|
||||
@update:model-value="promise"
|
||||
/>
|
||||
</QBtnDropdown>
|
||||
</template>
|
|
@ -9,10 +9,6 @@ const $props = defineProps({
|
|||
type: Number, //Progress value (1.0 > x > 0.0)
|
||||
required: true,
|
||||
},
|
||||
showDialog: {
|
||||
type: Boolean,
|
||||
required: true,
|
||||
},
|
||||
cancelled: {
|
||||
type: Boolean,
|
||||
required: false,
|
||||
|
@ -24,30 +20,22 @@ const emit = defineEmits(['cancel', 'close']);
|
|||
|
||||
const dialogRef = ref(null);
|
||||
|
||||
const _showDialog = computed({
|
||||
get: () => $props.showDialog,
|
||||
set: (value) => {
|
||||
if (value) dialogRef.value.show();
|
||||
},
|
||||
const showDialog = defineModel('showDialog', {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
});
|
||||
|
||||
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="onDialogHide">
|
||||
<QDialog ref="dialogRef" v-model="showDialog" @hide="emit('close')">
|
||||
<QCard class="full-width dialog">
|
||||
<QCardSection class="row">
|
||||
<span class="text-h6">{{ t('Progress') }}</span>
|
||||
<QSpace />
|
||||
<QBtn icon="close" flat round dense @click="emit('close')" />
|
||||
<QBtn icon="close" flat round dense v-close-popup />
|
||||
</QCardSection>
|
||||
<QCardSection>
|
||||
<div class="column">
|
||||
|
@ -80,7 +68,7 @@ const cancel = () => {
|
|||
type="button"
|
||||
flat
|
||||
class="text-primary"
|
||||
@click="cancel()"
|
||||
v-close-popup
|
||||
>
|
||||
{{ t('globals.cancel') }}
|
||||
</QBtn>
|
||||
|
|
|
@ -304,12 +304,14 @@ globals:
|
|||
from: From
|
||||
To: To
|
||||
stateFk: State
|
||||
departmentFk: Department
|
||||
email: Email
|
||||
SSN: SSN
|
||||
fi: FI
|
||||
myTeam: My team
|
||||
departmentFk: Department
|
||||
changePass: Change password
|
||||
deleteConfirmTitle: Delete selected elements
|
||||
changeState: Change state
|
||||
errors:
|
||||
statusUnauthorized: Access denied
|
||||
statusInternalServerError: An internal server error has ocurred
|
||||
|
@ -556,7 +558,6 @@ ticket:
|
|||
package: Package
|
||||
taxClass: Tax class
|
||||
services: Services
|
||||
changeState: Change state
|
||||
requester: Requester
|
||||
atender: Atender
|
||||
request: Request
|
||||
|
|
|
@ -312,8 +312,10 @@ globals:
|
|||
email: Correo
|
||||
SSN: NSS
|
||||
fi: NIF
|
||||
myTeam: Mi equipo
|
||||
changePass: Cambiar contraseña
|
||||
deleteConfirmTitle: Eliminar los elementos seleccionados
|
||||
changeState: Cambiar estado
|
||||
errors:
|
||||
statusUnauthorized: Acceso denegado
|
||||
statusInternalServerError: Ha ocurrido un error interno del servidor
|
||||
|
@ -565,7 +567,6 @@ ticket:
|
|||
package: Embalaje
|
||||
taxClass: Tipo IVA
|
||||
services: Servicios
|
||||
changeState: Cambiar estado
|
||||
requester: Solicitante
|
||||
atender: Comprador
|
||||
request: Petición de compra
|
||||
|
|
|
@ -46,13 +46,9 @@ const columns = computed(() => [
|
|||
]);
|
||||
|
||||
const deleteAlias = async (row) => {
|
||||
try {
|
||||
await axios.delete(`${urlPath.value}/${row.id}`);
|
||||
notify(t('User removed'), 'positive');
|
||||
fetchAliases();
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
await axios.delete(`${urlPath.value}/${row.id}`);
|
||||
notify(t('User removed'), 'positive');
|
||||
fetchAliases();
|
||||
};
|
||||
|
||||
watch(
|
||||
|
|
|
@ -61,23 +61,15 @@ const fetchAccountExistence = async () => {
|
|||
};
|
||||
|
||||
const deleteMailAlias = async (row) => {
|
||||
try {
|
||||
await axios.delete(`${urlPath}/${row.id}`);
|
||||
fetchMailAliases();
|
||||
notify(t('Unsubscribed from alias!'), 'positive');
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
await axios.delete(`${urlPath}/${row.id}`);
|
||||
fetchMailAliases();
|
||||
notify(t('Unsubscribed from alias!'), 'positive');
|
||||
};
|
||||
|
||||
const createMailAlias = async (mailAliasFormData) => {
|
||||
try {
|
||||
await axios.post(urlPath, mailAliasFormData);
|
||||
notify(t('Subscribed to alias!'), 'positive');
|
||||
fetchMailAliases();
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
await axios.post(urlPath, mailAliasFormData);
|
||||
notify(t('Subscribed to alias!'), 'positive');
|
||||
fetchMailAliases();
|
||||
};
|
||||
|
||||
const fetchMailAliases = async () => {
|
||||
|
|
|
@ -46,29 +46,15 @@ const columns = computed(() => [
|
|||
]);
|
||||
|
||||
const deleteSubRole = async (row) => {
|
||||
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);
|
||||
}
|
||||
await axios.delete(`${urlPath.value}/${row.id}`);
|
||||
fetchSubRoles();
|
||||
notify(t('Role removed. Changes will take a while to fully propagate.'), 'positive');
|
||||
};
|
||||
|
||||
const createSubRole = async (subRoleFormData) => {
|
||||
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);
|
||||
}
|
||||
await axios.post(urlPath.value, subRoleFormData);
|
||||
notify(t('Role added! Changes will take a while to fully propagate.'), 'positive');
|
||||
fetchSubRoles();
|
||||
};
|
||||
|
||||
watch(
|
||||
|
|
|
@ -204,7 +204,7 @@ function claimUrl(section) {
|
|||
top
|
||||
color="black"
|
||||
text-color="white"
|
||||
:label="t('ticket.summary.changeState')"
|
||||
:label="t('globals.changeState')"
|
||||
>
|
||||
<QList>
|
||||
<QVirtualScroll
|
||||
|
|
|
@ -78,7 +78,7 @@ const ticketsColumns = ref([
|
|||
align: 'left',
|
||||
},
|
||||
{
|
||||
name: 'quantity',
|
||||
name: 'nickname',
|
||||
label: t('invoiceOut.summary.nickname'),
|
||||
field: (row) => row.nickname,
|
||||
sortable: true,
|
||||
|
@ -172,11 +172,11 @@ const ticketsColumns = ref([
|
|||
</QBtn>
|
||||
</QTd>
|
||||
</template>
|
||||
<template #body-cell-quantity="{ value, row }">
|
||||
<template #body-cell-nickname="{ value, row }">
|
||||
<QTd>
|
||||
<QBtn class="no-uppercase link" flat dense>
|
||||
{{ value }}
|
||||
<CustomerDescriptorProxy :id="row.id" />
|
||||
<CustomerDescriptorProxy :id="row.clientFk" />
|
||||
</QBtn>
|
||||
</QTd>
|
||||
</template>
|
||||
|
|
|
@ -258,15 +258,28 @@ onBeforeMount(() => {
|
|||
<template #body-cell-attender="{ row }">
|
||||
<QTd>
|
||||
<VnSelect
|
||||
url="Workers/search"
|
||||
v-model="row.attenderFk"
|
||||
:where="{ role: 'buyer' }"
|
||||
sort-by="id"
|
||||
url="Workers"
|
||||
:params="{ departmentCodes: ['shopping'] }"
|
||||
:fields="['id', 'nickname']"
|
||||
sort-by="nickname ASC"
|
||||
hide-selected
|
||||
option-label="firstName"
|
||||
option-label="nickname"
|
||||
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,15 +52,27 @@ const redirectToItemTypeBasicData = (_, { id }) => {
|
|||
</VnRow>
|
||||
<VnRow>
|
||||
<VnSelect
|
||||
url="Workers/search"
|
||||
v-model="data.workerFk"
|
||||
:label="t('itemType.shared.worker')"
|
||||
url="Workers"
|
||||
sort-by="firstName ASC"
|
||||
:fields="['id', 'firstName']"
|
||||
:label="t('shared.worker')"
|
||||
sort-by="nickname ASC"
|
||||
:fields="['id', 'nickname']"
|
||||
:params="{ departmentCodes: ['shopping'] }"
|
||||
option-label="nickname"
|
||||
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,15 +41,27 @@ const temperaturesOptions = ref([]);
|
|||
</VnRow>
|
||||
<VnRow>
|
||||
<VnSelect
|
||||
url="Workers/search"
|
||||
v-model="data.workerFk"
|
||||
:label="t('shared.worker')"
|
||||
url="Workers"
|
||||
sort-by="firstName ASC"
|
||||
:fields="['id', 'firstName']"
|
||||
sort-by="nickname ASC"
|
||||
:fields="['id', 'nickname']"
|
||||
:params="{ departmentCodes: ['shopping'] }"
|
||||
option-label="nickname"
|
||||
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,32 +112,20 @@ const getShipped = async (params) => {
|
|||
};
|
||||
|
||||
const onChangeZone = async (zoneId) => {
|
||||
try {
|
||||
formData.value.agencyModeFk = null;
|
||||
const { data } = await axios.get(`Zones/${zoneId}`);
|
||||
formData.value.agencyModeFk = data.agencyModeFk;
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
formData.value.agencyModeFk = null;
|
||||
const { data } = await axios.get(`Zones/${zoneId}`);
|
||||
formData.value.agencyModeFk = data.agencyModeFk;
|
||||
};
|
||||
|
||||
const onChangeAddress = async (addressId) => {
|
||||
try {
|
||||
formData.value.nickname = null;
|
||||
const { data } = await axios.get(`Addresses/${addressId}`);
|
||||
formData.value.nickname = data.nickname;
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
formData.value.nickname = null;
|
||||
const { data } = await axios.get(`Addresses/${addressId}`);
|
||||
formData.value.nickname = data.nickname;
|
||||
};
|
||||
|
||||
const getClientDefaultAddress = async (clientId) => {
|
||||
try {
|
||||
const { data } = await axios.get(`Clients/${clientId}`);
|
||||
if (data) addressId.value = data.defaultAddressFk;
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
const { data } = await axios.get(`Clients/${clientId}`);
|
||||
if (data) addressId.value = data.defaultAddressFk;
|
||||
};
|
||||
|
||||
const clientAddressesList = async (value) => {
|
||||
|
|
|
@ -70,60 +70,51 @@ const isFormInvalid = () => {
|
|||
};
|
||||
|
||||
const getPriceDifference = async () => {
|
||||
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 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;
|
||||
};
|
||||
|
||||
const submit = async () => {
|
||||
try {
|
||||
if (!formData.value.option)
|
||||
return notify(t('basicData.chooseAnOption'), 'negative');
|
||||
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 } });
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
const ticketToMove = data.id;
|
||||
notify(t('basicData.unroutedTicket'), 'positive');
|
||||
router.push({ name: 'TicketSummary', params: { id: ticketToMove } });
|
||||
};
|
||||
|
||||
const submitWithNegatives = async () => {
|
||||
|
|
|
@ -34,26 +34,20 @@ const newTicketFormData = reactive({});
|
|||
const date = new Date();
|
||||
|
||||
const createTicket = async () => {
|
||||
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 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 } });
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
const { data } = await axios.post('Expeditions/moveExpeditions', params);
|
||||
notify(t('globals.dataSaved'), 'positive');
|
||||
router.push({ name: 'TicketSummary', params: { id: data.id } });
|
||||
};
|
||||
</script>
|
||||
|
||||
|
|
|
@ -150,31 +150,19 @@ const getTotal = computed(() => {
|
|||
});
|
||||
|
||||
const getComponentsSum = async () => {
|
||||
try {
|
||||
const { data } = await axios.get(`Tickets/${route.params.id}/getComponentsSum`);
|
||||
componentsList.value = data;
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
const { data } = await axios.get(`Tickets/${route.params.id}/getComponentsSum`);
|
||||
componentsList.value = data;
|
||||
};
|
||||
|
||||
const getTheoricalCost = async () => {
|
||||
try {
|
||||
const { data } = await axios.get(`Tickets/${route.params.id}/freightCost`);
|
||||
theoricalCost.value = data;
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
const { data } = await axios.get(`Tickets/${route.params.id}/freightCost`);
|
||||
theoricalCost.value = data;
|
||||
};
|
||||
|
||||
const getTicketVolume = async () => {
|
||||
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);
|
||||
}
|
||||
if (!ticketData.value) return;
|
||||
const { data } = await axios.get(`Tickets/${ticketData.value.id}/getVolume`);
|
||||
ticketVolume.value = data[0].volume;
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<script setup>
|
||||
import { onMounted, ref, computed, onUnmounted, watch } from 'vue';
|
||||
import { onMounted, ref, computed, onUnmounted } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRoute } from 'vue-router';
|
||||
|
||||
|
@ -15,6 +15,8 @@ import useNotify from 'src/composables/useNotify.js';
|
|||
import { toDateTimeFormat } from 'src/filters/date';
|
||||
import axios from 'axios';
|
||||
import VnTable from 'src/components/VnTable/VnTable.vue';
|
||||
import VnBtnSelect from 'src/components/common/VnBtnSelect.vue';
|
||||
import FetchData from 'src/components/FetchData.vue';
|
||||
|
||||
const route = useRoute();
|
||||
const stateStore = useStateStore();
|
||||
|
@ -23,50 +25,24 @@ const { notify } = useNotify();
|
|||
const { openConfirmationModal } = useVnConfirm();
|
||||
const newTicketDialogRef = ref(null);
|
||||
const logsTableDialogRef = ref(null);
|
||||
const tableRef = ref();
|
||||
const vnTableRef = ref();
|
||||
const expeditionsLogsData = ref([]);
|
||||
const selectedExpeditions = ref([]);
|
||||
const allColumnNames = ref([]);
|
||||
const newTicketWithRoute = ref(false);
|
||||
const selectedRows = ref([]);
|
||||
const hasSelectedRows = computed(() => selectedRows.value.length > 0);
|
||||
|
||||
const exprBuilder = (param, value) => {
|
||||
switch (param) {
|
||||
case 'expeditionFk':
|
||||
return { id: value };
|
||||
case 'packageItemName':
|
||||
return { packagingItemFk: value };
|
||||
}
|
||||
};
|
||||
const expeditionStateTypes = ref([]);
|
||||
|
||||
const expeditionsFilter = computed(() => ({
|
||||
where: { ticketFk: route.params.id },
|
||||
order: ['created DESC'],
|
||||
}));
|
||||
|
||||
const expeditionsArrayData = useArrayData('ticketExpeditions', {
|
||||
url: 'Expeditions/filter',
|
||||
filter: expeditionsFilter.value,
|
||||
exprBuilder: exprBuilder,
|
||||
});
|
||||
|
||||
const ticketArrayData = useArrayData('ticketData');
|
||||
const ticketStore = ticketArrayData.store;
|
||||
const ticketData = computed(() => ticketStore.data);
|
||||
|
||||
const refetchExpeditions = async () => {
|
||||
await expeditionsArrayData.applyFilter({
|
||||
filter: expeditionsFilter.value,
|
||||
});
|
||||
};
|
||||
|
||||
watch(
|
||||
() => route.params.id,
|
||||
async () => await refetchExpeditions(),
|
||||
{ immediate: true }
|
||||
);
|
||||
|
||||
const columns = computed(() => [
|
||||
{
|
||||
align: 'left',
|
||||
|
@ -187,18 +163,12 @@ const showNewTicketDialog = (withRoute = false) => {
|
|||
};
|
||||
|
||||
const deleteExpedition = async () => {
|
||||
try {
|
||||
const expeditionIds = selectedExpeditions.value.map(
|
||||
(expedition) => expedition.id
|
||||
);
|
||||
const params = { expeditionIds };
|
||||
await axios.post('Expeditions/deleteExpeditions', params);
|
||||
await refetchExpeditions();
|
||||
selectedExpeditions.value = [];
|
||||
notify(t('expedition.expeditionRemoved'), 'positive');
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
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');
|
||||
};
|
||||
|
||||
const showLog = async (expedition) => {
|
||||
|
@ -207,29 +177,19 @@ const showLog = async (expedition) => {
|
|||
};
|
||||
|
||||
const getExpeditionState = async (expedition) => {
|
||||
try {
|
||||
const filter = {
|
||||
where: { expeditionFk: expedition.id },
|
||||
order: ['created DESC'],
|
||||
};
|
||||
const filter = {
|
||||
where: { expeditionFk: expedition.id },
|
||||
order: ['created DESC'],
|
||||
};
|
||||
|
||||
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'] },
|
||||
});
|
||||
const { data: expeditionStates } = await axios.get(`ExpeditionStates/filter`, {
|
||||
params: { filter: JSON.stringify(filter) },
|
||||
});
|
||||
|
||||
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);
|
||||
}
|
||||
expeditionsLogsData.value = expeditionStates.map((state) => ({
|
||||
...state,
|
||||
isScanned: !!state.isScanned,
|
||||
}));
|
||||
};
|
||||
|
||||
onMounted(async () => {
|
||||
|
@ -242,9 +202,35 @@ onUnmounted(() => (stateStore.rightDrawer = false));
|
|||
</script>
|
||||
|
||||
<template>
|
||||
<FetchData
|
||||
url="expeditionStateTypes"
|
||||
@on-fetch="(data) => (expeditionStateTypes = data)"
|
||||
auto-load
|
||||
/>
|
||||
<VnSubToolbar>
|
||||
<template #st-actions>
|
||||
<QBtnGroup push class="q-gutter-x-sm" flat>
|
||||
<VnBtnSelect
|
||||
:disable="!hasSelectedRows"
|
||||
color="primary"
|
||||
:label="t('globals.changeState')"
|
||||
:select-props="{
|
||||
options: expeditionStateTypes,
|
||||
optionLabel: 'description',
|
||||
optionValue: 'code',
|
||||
}"
|
||||
:promise="
|
||||
async (stateCode) => {
|
||||
await axios.post('ExpeditionStates/addExpeditionState', {
|
||||
expeditions: selectedRows.map(({ id }) => {
|
||||
return { expeditionFk: id, stateCode };
|
||||
}),
|
||||
});
|
||||
vnTableRef.tableRef.clearSelection();
|
||||
vnTableRef.reload();
|
||||
}
|
||||
"
|
||||
/>
|
||||
<QBtnDropdown
|
||||
ref="btnDropdownRef"
|
||||
color="primary"
|
||||
|
@ -298,11 +284,11 @@ onUnmounted(() => (stateStore.rightDrawer = false));
|
|||
</QBtnGroup>
|
||||
</template>
|
||||
</VnSubToolbar>
|
||||
|
||||
<VnTable
|
||||
ref="tableRef"
|
||||
ref="vnTableRef"
|
||||
data-key="TicketExpedition"
|
||||
url="Expeditions/filter"
|
||||
search-url="expeditions"
|
||||
:columns="columns"
|
||||
:filter="expeditionsFilter"
|
||||
v-model:selected="selectedRows"
|
||||
|
@ -311,6 +297,16 @@ onUnmounted(() => (stateStore.rightDrawer = false));
|
|||
selection: 'multiple',
|
||||
}"
|
||||
auto-load
|
||||
:expr-builder="
|
||||
(param, value) => {
|
||||
switch (param) {
|
||||
case 'expeditionFk':
|
||||
return { id: value };
|
||||
case 'packageItemName':
|
||||
return { packagingItemFk: value };
|
||||
}
|
||||
}
|
||||
"
|
||||
order="created DESC"
|
||||
>
|
||||
<template #column-packagingItemFk="{ row }">
|
||||
|
@ -324,7 +320,7 @@ onUnmounted(() => (stateStore.rightDrawer = false));
|
|||
<ExpeditionNewTicket
|
||||
:ticket="ticketData"
|
||||
:with-route="newTicketWithRoute"
|
||||
:selected-expeditions="selectedExpeditions"
|
||||
:selected-expeditions="selectedRows"
|
||||
/>
|
||||
</QDialog>
|
||||
<QDialog ref="logsTableDialogRef" transition-show="scale" transition-hide="scale">
|
||||
|
@ -345,11 +341,7 @@ onUnmounted(() => (stateStore.rightDrawer = false));
|
|||
</template>
|
||||
<template #body-cell-isScanned="{ row }">
|
||||
<QTd style="text-align: center">
|
||||
<QCheckbox disable v-model="row.isScanned">
|
||||
{{
|
||||
row.isScanned === 1 ? t('expedition.yes') : t('expedition.no')
|
||||
}}
|
||||
</QCheckbox>
|
||||
<QCheckbox disable v-model="row.isScanned" />
|
||||
</QTd>
|
||||
</template>
|
||||
</QTable>
|
||||
|
|
|
@ -165,14 +165,10 @@ const createRefund = async (withWarehouse) => {
|
|||
negative: true,
|
||||
};
|
||||
|
||||
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);
|
||||
}
|
||||
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 } });
|
||||
};
|
||||
</script>
|
||||
|
||||
|
|
|
@ -150,18 +150,14 @@ const shelvingsTableColumns = computed(() => [
|
|||
]);
|
||||
|
||||
const getSaleTrackings = async (sale) => {
|
||||
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 filter = {
|
||||
where: { saleFk: sale.saleFk },
|
||||
order: ['itemFk DESC'],
|
||||
};
|
||||
const { data } = await axios.get(`SaleTrackings/listSaleTracking`, {
|
||||
params: { filter: JSON.stringify(filter) },
|
||||
});
|
||||
saleTrackings.value = data;
|
||||
};
|
||||
|
||||
const showLog = async (sale) => {
|
||||
|
@ -170,17 +166,13 @@ const showLog = async (sale) => {
|
|||
};
|
||||
|
||||
const getItemShelvingSales = async (sale) => {
|
||||
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 filter = {
|
||||
where: { saleFk: sale.saleFk },
|
||||
};
|
||||
const { data } = await axios.get(`ItemShelvingSales/filter`, {
|
||||
params: { filter: JSON.stringify(filter) },
|
||||
});
|
||||
itemShelvingsSales.value = data;
|
||||
};
|
||||
|
||||
const showShelving = async (sale) => {
|
||||
|
@ -189,36 +181,28 @@ const showShelving = async (sale) => {
|
|||
};
|
||||
|
||||
const updateQuantity = async (sale) => {
|
||||
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);
|
||||
}
|
||||
if (oldQuantity.value === sale.quantity) return;
|
||||
const params = {
|
||||
quantity: sale.quantity,
|
||||
};
|
||||
await axios.patch(`ItemShelvingSales/${sale.id}`, params);
|
||||
oldQuantity.value = null;
|
||||
};
|
||||
|
||||
const updateParking = async (sale) => {
|
||||
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 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);
|
||||
};
|
||||
|
||||
const updateShelving = async (sale) => {
|
||||
|
@ -241,61 +225,41 @@ const updateShelving = async (sale) => {
|
|||
};
|
||||
|
||||
const saleTrackingNew = async (sale, stateCode, isChecked) => {
|
||||
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 params = {
|
||||
saleFk: sale.saleFk,
|
||||
isChecked,
|
||||
quantity: sale.quantity,
|
||||
stateCode,
|
||||
};
|
||||
await axios.post(`SaleTrackings/new`, params);
|
||||
notify(t('globals.dataSaved'), 'positive');
|
||||
};
|
||||
|
||||
const saleTrackingDel = async ({ saleFk }, stateCode) => {
|
||||
try {
|
||||
const params = {
|
||||
saleFk,
|
||||
stateCodes: [stateCode],
|
||||
};
|
||||
await axios.post(`SaleTrackings/delete`, params);
|
||||
notify(t('globals.dataSaved'), 'positive');
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
const params = {
|
||||
saleFk,
|
||||
stateCodes: [stateCode],
|
||||
};
|
||||
await axios.post(`SaleTrackings/delete`, params);
|
||||
notify(t('globals.dataSaved'), 'positive');
|
||||
};
|
||||
|
||||
const clickSaleGroupDetail = async (sale) => {
|
||||
try {
|
||||
if (!sale.saleGroupDetailFk) return;
|
||||
if (!sale.saleGroupDetailFk) return;
|
||||
|
||||
await axios.delete(`SaleGroupDetails/${sale.saleGroupDetailFk}`);
|
||||
sale.hasSaleGroupDetail = false;
|
||||
notify(t('globals.dataSaved'), 'positive');
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
await axios.delete(`SaleGroupDetails/${sale.saleGroupDetailFk}`);
|
||||
sale.hasSaleGroupDetail = false;
|
||||
notify(t('globals.dataSaved'), 'positive');
|
||||
};
|
||||
|
||||
const clickPreviousSelected = (sale) => {
|
||||
try {
|
||||
qCheckBoxController(sale, 'isPreviousSelected');
|
||||
if (!sale.isPreviousSelected) sale.isPrevious = false;
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
qCheckBoxController(sale, 'isPreviousSelected');
|
||||
if (!sale.isPreviousSelected) sale.isPrevious = false;
|
||||
};
|
||||
|
||||
const clickPrevious = (sale) => {
|
||||
try {
|
||||
qCheckBoxController(sale, 'isPrevious');
|
||||
if (sale.isPrevious) sale.isPreviousSelected = true;
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
qCheckBoxController(sale, 'isPrevious');
|
||||
if (sale.isPrevious) sale.isPreviousSelected = true;
|
||||
};
|
||||
|
||||
const qCheckBoxController = (sale, action) => {
|
||||
|
@ -306,16 +270,12 @@ const qCheckBoxController = (sale, action) => {
|
|||
isPreviousSelected: 'PREVIOUS_PREPARATION',
|
||||
};
|
||||
const stateCode = STATE_CODES[action];
|
||||
try {
|
||||
if (!sale[action]) {
|
||||
saleTrackingNew(sale, stateCode, true);
|
||||
sale[action] = true;
|
||||
} else {
|
||||
saleTrackingDel(sale, stateCode);
|
||||
sale[action] = false;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
if (!sale[action]) {
|
||||
saleTrackingNew(sale, stateCode, true);
|
||||
sale[action] = true;
|
||||
} else {
|
||||
saleTrackingDel(sale, stateCode);
|
||||
sale[action] = false;
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
|
|
@ -46,40 +46,32 @@ watch(
|
|||
onMounted(async () => await getDefaultTaxClass());
|
||||
|
||||
const createRefund = async () => {
|
||||
try {
|
||||
if (!selected.value.length) return;
|
||||
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 } });
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
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 getDefaultTaxClass = async () => {
|
||||
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);
|
||||
}
|
||||
let filter = {
|
||||
where: { code: 'G' },
|
||||
};
|
||||
const { data } = await axios.get('TaxClasses/findOne', {
|
||||
params: { filter: JSON.stringify(filter) },
|
||||
});
|
||||
defaultTaxClass.value = data;
|
||||
};
|
||||
|
||||
const columns = computed(() => [
|
||||
|
|
|
@ -122,37 +122,23 @@ function isOnTicketCard() {
|
|||
</div>
|
||||
</template>
|
||||
<template #header-right>
|
||||
<div class="flex items-end">
|
||||
<QBtnDropdown
|
||||
ref="stateBtnDropdownRef"
|
||||
color="black"
|
||||
text-color="white"
|
||||
:label="t('ticket.summary.changeState')"
|
||||
:disable="!isEditable()"
|
||||
>
|
||||
<VnSelect
|
||||
:options="editableStates"
|
||||
hide-selected
|
||||
option-label="name"
|
||||
option-value="code"
|
||||
hide-dropdown-icon
|
||||
focus-on-mount
|
||||
@update:model-value="changeState"
|
||||
/>
|
||||
</QBtnDropdown>
|
||||
<QBtn
|
||||
v-if="!isOnTicketCard()"
|
||||
icon="more_vert"
|
||||
round
|
||||
size="md"
|
||||
flat
|
||||
color="white"
|
||||
>
|
||||
<QMenu>
|
||||
<TicketDescriptorMenu :ticket="entityId" />
|
||||
</QMenu>
|
||||
</QBtn>
|
||||
</div>
|
||||
<QBtnDropdown
|
||||
ref="stateBtnDropdownRef"
|
||||
color="black"
|
||||
text-color="white"
|
||||
:label="t('globals.changeState')"
|
||||
:disable="!isEditable()"
|
||||
>
|
||||
<VnSelect
|
||||
:options="editableStates"
|
||||
hide-selected
|
||||
option-label="name"
|
||||
option-value="code"
|
||||
hide-dropdown-icon
|
||||
focus-on-mount
|
||||
@update:model-value="changeState"
|
||||
/>
|
||||
</QBtnDropdown>
|
||||
</template>
|
||||
<template #body="{ entity }">
|
||||
<QCard class="vn-one">
|
||||
|
|
|
@ -75,22 +75,18 @@ const columns = computed(() => [
|
|||
]);
|
||||
|
||||
const applyVolumes = async (salesData) => {
|
||||
try {
|
||||
if (!salesData.length) return;
|
||||
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;
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
packingTypeVolume.value = data.packingTypeVolume;
|
||||
};
|
||||
|
||||
onMounted(() => (stateStore.rightDrawer = true));
|
||||
|
|
|
@ -1,24 +1,20 @@
|
|||
<script setup>
|
||||
import { onMounted, ref, computed, reactive } from 'vue';
|
||||
import { ref, computed, reactive, watch } 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();
|
||||
|
@ -29,109 +25,58 @@ const user = state.getUser();
|
|||
const itemPackingTypesOptions = ref([]);
|
||||
const zonesOptions = ref([]);
|
||||
const selectedTickets = ref([]);
|
||||
|
||||
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 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 { 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',
|
||||
align: 'left',
|
||||
columnFilter: null,
|
||||
hidden: true,
|
||||
headerClass: 'horizontal-separator',
|
||||
},
|
||||
{
|
||||
label: t('advanceTickets.ticketId'),
|
||||
name: 'ticketId',
|
||||
align: 'center',
|
||||
sortable: true,
|
||||
columnFilter: {
|
||||
component: VnInput,
|
||||
type: 'text',
|
||||
filterValue: null,
|
||||
filterParamKey: 'id',
|
||||
event: getInputEvents,
|
||||
attrs: {
|
||||
dense: true,
|
||||
},
|
||||
},
|
||||
label: t('advanceTickets.ticketId'),
|
||||
name: 'id',
|
||||
headerClass: 'horizontal-separator',
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
label: t('advanceTickets.ipt'),
|
||||
name: 'ipt',
|
||||
field: 'ipt',
|
||||
align: 'left',
|
||||
sortable: true,
|
||||
columnFilter: {
|
||||
component: VnSelect,
|
||||
filterParamKey: 'iptColFilter',
|
||||
type: 'select',
|
||||
filterValue: null,
|
||||
event: getInputEvents,
|
||||
component: 'select',
|
||||
attrs: {
|
||||
options: itemPackingTypesOptions.value,
|
||||
'option-value': 'code',
|
||||
'option-label': 'description',
|
||||
dense: true,
|
||||
url: 'itemPackingTypes',
|
||||
fields: ['code', 'description'],
|
||||
where: { isActive: true },
|
||||
optionValue: 'code',
|
||||
optionLabel: 'description',
|
||||
inWhere: false,
|
||||
},
|
||||
},
|
||||
format: (val) => dashIfEmpty(val),
|
||||
format: (row, dashIfEmpty) => dashIfEmpty(row.ipt),
|
||||
headerClass: 'horizontal-separator',
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
label: t('advanceTickets.state'),
|
||||
name: 'state',
|
||||
align: 'left',
|
||||
sortable: true,
|
||||
columnFilter: null,
|
||||
headerClass: 'horizontal-separator',
|
||||
hidden: true,
|
||||
},
|
||||
{
|
||||
label: t('advanceTickets.preparation'),
|
||||
|
@ -139,171 +84,105 @@ const ticketColumns = computed(() => [
|
|||
field: 'preparation',
|
||||
align: 'left',
|
||||
sortable: true,
|
||||
columnFilter: null,
|
||||
headerClass: 'horizontal-separator',
|
||||
columnFilter: false,
|
||||
},
|
||||
{
|
||||
label: t('advanceTickets.liters'),
|
||||
name: 'liters',
|
||||
field: 'liters',
|
||||
align: 'left',
|
||||
sortable: true,
|
||||
columnFilter: {
|
||||
component: VnInput,
|
||||
type: 'text',
|
||||
filterValue: null,
|
||||
event: getInputEvents,
|
||||
attrs: {
|
||||
dense: true,
|
||||
},
|
||||
},
|
||||
label: t('advanceTickets.liters'),
|
||||
headerClass: 'horizontal-separator',
|
||||
name: 'liters',
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
label: t('advanceTickets.lines'),
|
||||
name: 'lines',
|
||||
field: 'lines',
|
||||
align: 'left',
|
||||
sortable: true,
|
||||
columnFilter: {
|
||||
component: VnInput,
|
||||
type: 'text',
|
||||
filterValue: null,
|
||||
event: getInputEvents,
|
||||
attrs: {
|
||||
dense: true,
|
||||
},
|
||||
},
|
||||
format: (val) => dashIfEmpty(val),
|
||||
headerClass: 'horizontal-separator',
|
||||
format: (row, dashIfEmpty) => dashIfEmpty(row.lines),
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
label: t('advanceTickets.import'),
|
||||
field: 'import',
|
||||
name: 'import',
|
||||
align: 'left',
|
||||
sortable: true,
|
||||
name: 'totalWithVat',
|
||||
hidden: true,
|
||||
headerClass: 'horizontal-separator',
|
||||
format: (row) => toCurrency(row.totalWithVat),
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
label: t('advanceTickets.futureId'),
|
||||
name: 'futureId',
|
||||
align: 'left',
|
||||
sortable: true,
|
||||
columnFilter: {
|
||||
component: VnInput,
|
||||
type: 'text',
|
||||
filterValue: null,
|
||||
filterParamKey: 'futureId',
|
||||
event: getInputEvents,
|
||||
attrs: {
|
||||
dense: true,
|
||||
},
|
||||
},
|
||||
headerClass: 'vertical-separator horizontal-separator',
|
||||
columnClass: 'vertical-separator',
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
label: t('advanceTickets.futureIpt'),
|
||||
name: 'futureIpt',
|
||||
field: 'futureIpt',
|
||||
align: 'left',
|
||||
sortable: true,
|
||||
columnFilter: {
|
||||
component: VnSelect,
|
||||
filterParamKey: 'futureIptColFilter',
|
||||
type: 'select',
|
||||
filterValue: null,
|
||||
event: getInputEvents,
|
||||
component: 'select',
|
||||
attrs: {
|
||||
options: itemPackingTypesOptions.value,
|
||||
'option-value': 'code',
|
||||
'option-label': 'description',
|
||||
dense: true,
|
||||
url: 'itemPackingTypes',
|
||||
fields: ['code', 'description'],
|
||||
where: { isActive: true },
|
||||
optionValue: 'code',
|
||||
optionLabel: 'description',
|
||||
},
|
||||
},
|
||||
format: (val) => dashIfEmpty(val),
|
||||
headerClass: 'horizontal-separator',
|
||||
format: (row, dashIfEmpty) => dashIfEmpty(row.futureIpt),
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
label: t('advanceTickets.futureState'),
|
||||
name: 'futureState',
|
||||
align: 'left',
|
||||
sortable: true,
|
||||
columnFilter: null,
|
||||
format: (val) => dashIfEmpty(val),
|
||||
headerClass: 'horizontal-separator',
|
||||
hidden: true,
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
label: t('advanceTickets.futureLiters'),
|
||||
headerClass: 'horizontal-separator',
|
||||
name: 'futureLiters',
|
||||
field: 'futureLiters',
|
||||
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.futureZone'),
|
||||
name: 'futureZoneName',
|
||||
field: 'futureZoneName',
|
||||
align: 'left',
|
||||
sortable: true,
|
||||
name: 'futureZoneFk',
|
||||
columnClass: 'expand',
|
||||
columnFilter: {
|
||||
component: VnSelect,
|
||||
type: 'select',
|
||||
filterValue: null,
|
||||
filterParamKey: 'futureZoneFk',
|
||||
event: getInputEvents,
|
||||
component: 'select',
|
||||
inWhere: true,
|
||||
attrs: {
|
||||
options: zonesOptions.value,
|
||||
'option-value': 'id',
|
||||
'option-label': 'name',
|
||||
dense: true,
|
||||
url: 'Zones',
|
||||
fields: ['id', 'name'],
|
||||
},
|
||||
},
|
||||
format: (val) => dashIfEmpty(val),
|
||||
columnField: {
|
||||
component: null,
|
||||
},
|
||||
headerClass: 'horizontal-separator',
|
||||
format: (row, dashIfEmpty) => dashIfEmpty(row.futureZoneName),
|
||||
},
|
||||
{
|
||||
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),
|
||||
},
|
||||
{
|
||||
label: t('advanceTickets.futureImport'),
|
||||
name: 'futureImport',
|
||||
align: 'left',
|
||||
sortable: true,
|
||||
columnFilter: null,
|
||||
label: t('advanceTickets.futureImport'),
|
||||
name: 'futureTotalWithVat',
|
||||
hidden: true,
|
||||
headerClass: 'horizontal-separator',
|
||||
format: (row) => toCurrency(row.futureTotalWithVat),
|
||||
},
|
||||
]);
|
||||
|
||||
|
@ -329,7 +208,7 @@ const requestComponentUpdate = async (ticket, isWithoutNegatives) => {
|
|||
const query = `tickets/${ticket.futureId}/componentUpdate`;
|
||||
if (!ticket.landed) {
|
||||
const newLanded = await getLanded({
|
||||
shipped: userParams.dateToAdvance,
|
||||
shipped: vnTableRef.value.params.dateToAdvance,
|
||||
addressFk: ticket.futureAddressFk,
|
||||
agencyModeFk: ticket.agencyModeFk ?? ticket.futureAgencyModeFk,
|
||||
warehouseFk: ticket.futureWarehouseFk,
|
||||
|
@ -352,7 +231,7 @@ const requestComponentUpdate = async (ticket, isWithoutNegatives) => {
|
|||
zoneFk: ticket.zoneFk ?? ticket.futureZoneFk,
|
||||
warehouseFk: ticket.futureWarehouseFk,
|
||||
companyFk: ticket.futureCompanyFk,
|
||||
shipped: userParams.dateToAdvance,
|
||||
shipped: vnTableRef.value.params.dateToAdvance,
|
||||
landed: ticket.landed,
|
||||
isDeleted: false,
|
||||
isWithoutNegatives,
|
||||
|
@ -364,36 +243,31 @@ const requestComponentUpdate = async (ticket, isWithoutNegatives) => {
|
|||
};
|
||||
|
||||
const moveTicketsAdvance = async () => {
|
||||
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;
|
||||
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);
|
||||
}
|
||||
ticketsToMove.push({
|
||||
originId: ticket.futureId,
|
||||
destinationId: ticket.id,
|
||||
originShipped: ticket.futureShipped,
|
||||
destinationShipped: ticket.shipped,
|
||||
workerFk: ticket.workerFk,
|
||||
});
|
||||
continue;
|
||||
}
|
||||
|
||||
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);
|
||||
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 progressLength = ref(0);
|
||||
|
@ -434,10 +308,8 @@ const splitTickets = async () => {
|
|||
progressAdd(ticket.futureId);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error splitting tickets', error);
|
||||
} finally {
|
||||
arrayData.fetch({ append: false });
|
||||
vnTableRef.value.reload();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -455,19 +327,52 @@ const handleCloseProgressDialog = () => {
|
|||
|
||||
const handleCancelProgress = () => (cancelProgress.value = 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;
|
||||
const filter = { limit: 0 };
|
||||
await arrayData.addFilter({ filter, userParams });
|
||||
});
|
||||
</script>
|
||||
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 }
|
||||
);
|
||||
</script>
|
||||
<template>
|
||||
<FetchData
|
||||
url="itemPackingTypes"
|
||||
|
@ -488,11 +393,6 @@ onMounted(async () => {
|
|||
auto-load
|
||||
@on-fetch="(data) => (zonesOptions = data)"
|
||||
/>
|
||||
<VnSearchbar
|
||||
data-key="WeeklyTickets"
|
||||
:label="t('weeklyTickets.search')"
|
||||
:info="t('weeklyTickets.searchInfo')"
|
||||
/>
|
||||
<VnSubToolbar>
|
||||
<template #st-data>
|
||||
<QBtn
|
||||
|
@ -536,174 +436,109 @@ onMounted(async () => {
|
|||
</VnSubToolbar>
|
||||
<RightMenu>
|
||||
<template #right-panel>
|
||||
<TicketAdvanceFilter data-key="AdvanceTickets" />
|
||||
<TicketAdvanceFilter data-key="advanceTickets" />
|
||||
</template>
|
||||
</RightMenu>
|
||||
<QPage class="column items-center q-pa-md">
|
||||
<QTable
|
||||
:rows="tickets"
|
||||
<VnTable
|
||||
data-key="advanceTickets"
|
||||
ref="vnTableRef"
|
||||
url="Tickets/getTicketsAdvance"
|
||||
search-url="advanceTickets"
|
||||
:user-params="userParams"
|
||||
:limit="0"
|
||||
:columns="ticketColumns"
|
||||
row-key="index"
|
||||
selection="multiple"
|
||||
:table="{
|
||||
'row-key': '$index',
|
||||
selection: 'multiple',
|
||||
}"
|
||||
v-model:selected="selectedTickets"
|
||||
:pagination="{ rowsPerPage: 0 }"
|
||||
:no-data-label="t('globals.noResults')"
|
||||
style="max-width: 99%"
|
||||
:right-search="false"
|
||||
auto-load
|
||||
:disable-option="{ card: true }"
|
||||
>
|
||||
<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 #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>
|
||||
<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 #column-id="{ row }">
|
||||
<QBtn flat class="link">
|
||||
{{ row.id }}
|
||||
<TicketDescriptorProxy :id="row.id" />
|
||||
</QBtn>
|
||||
</template>
|
||||
<template #header-cell-availableLines="{ col }">
|
||||
<QTh class="vertical-separator">
|
||||
{{ col.label }}
|
||||
</QTh>
|
||||
<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>
|
||||
<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 #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>
|
||||
|
||||
<template #body-cell-ticketId="{ row }">
|
||||
<QTd>
|
||||
<QBtn flat class="link">
|
||||
{{ row.id }}
|
||||
<TicketDescriptorProxy :id="row.id" />
|
||||
</QBtn>
|
||||
</QTd>
|
||||
<template #column-futureId="{ row }">
|
||||
<QBtn flat class="link" dense>
|
||||
{{ row.futureId }}
|
||||
<TicketDescriptorProxy :id="row.futureId" />
|
||||
</QBtn>
|
||||
</template>
|
||||
<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 #column-futureState="{ row }">
|
||||
<QBadge
|
||||
text-color="black"
|
||||
:color="row.futureClassColor"
|
||||
class="q-ma-none"
|
||||
dense
|
||||
>
|
||||
{{ row.futureState }}
|
||||
</QBadge>
|
||||
</template>
|
||||
<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 #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>
|
||||
<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>
|
||||
</VnTable>
|
||||
<VnProgress
|
||||
:progress="progressPercentage"
|
||||
:cancelled="cancelProgress"
|
||||
|
@ -722,11 +557,11 @@ onMounted(async () => {
|
|||
</template>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.vertical-separator {
|
||||
:deep(.vertical-separator) {
|
||||
border-left: 4px solid white !important;
|
||||
}
|
||||
|
||||
.horizontal-separator {
|
||||
border-bottom: 4px solid white !important;
|
||||
:deep(.horizontal-separator) {
|
||||
border-top: 4px solid white !important;
|
||||
}
|
||||
</style>
|
||||
|
|
|
@ -11,7 +11,7 @@ import axios from 'axios';
|
|||
import { onMounted } from 'vue';
|
||||
import VnInputNumber from 'src/components/common/VnInputNumber.vue';
|
||||
|
||||
const { t } = useI18n();
|
||||
const { t, te } = useI18n();
|
||||
const props = defineProps({
|
||||
dataKey: {
|
||||
type: String,
|
||||
|
@ -27,20 +27,21 @@ const warehousesOptions = ref([]);
|
|||
const itemPackingTypes = ref([]);
|
||||
|
||||
const getItemPackingTypes = async () => {
|
||||
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 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,
|
||||
}));
|
||||
};
|
||||
|
||||
const getLocale = (val) => {
|
||||
const param = `params.${val}`;
|
||||
return te(param) ? t(param) : t(`globals.${param}`);
|
||||
};
|
||||
|
||||
onMounted(async () => await getItemPackingTypes());
|
||||
|
@ -53,6 +54,7 @@ onMounted(async () => await getItemPackingTypes());
|
|||
auto-load
|
||||
/>
|
||||
<VnFilterPanel
|
||||
search-url="advanceTickets"
|
||||
:data-key="props.dataKey"
|
||||
:search-button="true"
|
||||
:hidden-tags="['search']"
|
||||
|
@ -60,7 +62,7 @@ onMounted(async () => await getItemPackingTypes());
|
|||
>
|
||||
<template #tags="{ tag, formatFn }">
|
||||
<div class="q-gutter-x-xs">
|
||||
<strong>{{ t(`params.${tag.label}`) }}: </strong>
|
||||
<strong>{{ getLocale(tag.label) }}: </strong>
|
||||
<span>{{ formatFn(tag.value) }}</span>
|
||||
</div>
|
||||
</template>
|
||||
|
@ -96,6 +98,7 @@ onMounted(async () => await getItemPackingTypes());
|
|||
dense
|
||||
outlined
|
||||
rounded
|
||||
:use-like="false"
|
||||
>
|
||||
</VnSelect>
|
||||
</QItemSection>
|
||||
|
@ -113,6 +116,7 @@ onMounted(async () => await getItemPackingTypes());
|
|||
dense
|
||||
outlined
|
||||
rounded
|
||||
:use-like="false"
|
||||
>
|
||||
</VnSelect>
|
||||
</QItemSection>
|
||||
|
@ -136,6 +140,19 @@ onMounted(async () => await getItemPackingTypes());
|
|||
/>
|
||||
</QItemSection>
|
||||
</QItem>
|
||||
<QItem>
|
||||
<QItemSection>
|
||||
<VnSelect
|
||||
:label="t('globals.params.departmentFk')"
|
||||
v-model="params.departmentFk"
|
||||
url="Departments"
|
||||
:fields="['id', 'name']"
|
||||
dense
|
||||
outlined
|
||||
rounded
|
||||
/>
|
||||
</QItemSection>
|
||||
</QItem>
|
||||
<QItem>
|
||||
<QItemSection>
|
||||
<VnSelect
|
||||
|
|
|
@ -24,33 +24,25 @@ const itemPackingTypes = ref([]);
|
|||
const stateOptions = ref([]);
|
||||
|
||||
const getItemPackingTypes = async () => {
|
||||
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 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,
|
||||
}));
|
||||
};
|
||||
|
||||
const getGroupedStates = async () => {
|
||||
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);
|
||||
}
|
||||
const { data } = await axios.get('AlertLevels');
|
||||
stateOptions.value = data.map((state) => ({
|
||||
id: state.id,
|
||||
name: t(`futureTickets.${state.code}`),
|
||||
code: state.code,
|
||||
}));
|
||||
};
|
||||
|
||||
onMounted(async () => {
|
||||
|
|
|
@ -100,7 +100,7 @@ weeklyTickets:
|
|||
advanceTickets:
|
||||
preparation: Preparación
|
||||
origin: Origen
|
||||
destination: Destinatario
|
||||
destination: Destino
|
||||
originAgency: 'Agencia origen: {agency}'
|
||||
destinationAgency: 'Agencia destino: {agency}'
|
||||
ticketId: ID
|
||||
|
|
|
@ -17,6 +17,11 @@ const $props = defineProps({
|
|||
required: false,
|
||||
default: null,
|
||||
},
|
||||
dataKey: {
|
||||
type: String,
|
||||
required: false,
|
||||
default: 'workerData',
|
||||
},
|
||||
});
|
||||
const image = ref(null);
|
||||
|
||||
|
@ -65,7 +70,7 @@ const handlePhotoUpdated = (evt = false) => {
|
|||
<CardDescriptor
|
||||
ref="cardDescriptorRef"
|
||||
module="Worker"
|
||||
data-key="workerData"
|
||||
:data-key="dataKey"
|
||||
url="Workers/descriptor"
|
||||
:filter="{ where: { id: entityId } }"
|
||||
title="user.nickname"
|
||||
|
|
|
@ -12,6 +12,11 @@ const $props = defineProps({
|
|||
|
||||
<template>
|
||||
<QPopupProxy>
|
||||
<WorkerDescriptor v-if="$props.id" :id="$props.id" :summary="WorkerSummary" />
|
||||
<WorkerDescriptor
|
||||
v-if="$props.id"
|
||||
:id="$props.id"
|
||||
:summary="WorkerSummary"
|
||||
data-key="workerDescriptorProxy"
|
||||
/>
|
||||
</QPopupProxy>
|
||||
</template>
|
||||
|
|
|
@ -44,8 +44,9 @@ async function toggleNotification(notification) {
|
|||
`worker.notificationsManager.${notification.active ? '' : 'un'}subscribed`
|
||||
),
|
||||
});
|
||||
} catch {
|
||||
} catch (e) {
|
||||
notification.active = !notification.active;
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -34,21 +34,13 @@ const columns = computed(() => [
|
|||
]);
|
||||
|
||||
const deleteWarehouse = async (row) => {
|
||||
try {
|
||||
await axios.delete(`${urlPath.value}/${row.id}`);
|
||||
fetchWarehouses();
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
await axios.delete(`${urlPath.value}/${row.id}`);
|
||||
fetchWarehouses();
|
||||
};
|
||||
|
||||
const createZoneWarehouse = async (ZoneWarehouseFormData) => {
|
||||
try {
|
||||
await axios.post(urlPath.value, ZoneWarehouseFormData);
|
||||
fetchWarehouses();
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
await axios.post(urlPath.value, ZoneWarehouseFormData);
|
||||
fetchWarehouses();
|
||||
};
|
||||
|
||||
watch(
|
||||
|
|
|
@ -13,7 +13,7 @@ describe('Logout', () => {
|
|||
});
|
||||
describe('not user', () => {
|
||||
beforeEach(() => {
|
||||
cy.intercept('GET', '**/VnUsers/acl', {
|
||||
cy.intercept('GET', '**DefaultViewConfigs**', {
|
||||
statusCode: 401,
|
||||
body: {
|
||||
error: {
|
||||
|
@ -24,10 +24,11 @@ describe('Logout', () => {
|
|||
},
|
||||
},
|
||||
statusMessage: 'AUTHORIZATION_REQUIRED',
|
||||
}).as('someRoute');
|
||||
});
|
||||
});
|
||||
|
||||
it('when token not exists', () => {
|
||||
cy.reload();
|
||||
cy.get('.q-list > [href="#/item"]').click();
|
||||
cy.get('.q-notification__message').should(
|
||||
'have.text',
|
||||
'Authorization Required'
|
||||
|
|
|
@ -7,31 +7,20 @@ describe('AgencyWorkCenter', () => {
|
|||
const createButton = '.q-page-sticky > div > .q-btn > .q-btn__content > .q-icon';
|
||||
const workCenterCombobox = 'input[role="combobox"]';
|
||||
|
||||
it('assign workCenter', () => {
|
||||
it('check workCenter crud', () => {
|
||||
// create
|
||||
cy.get(createButton).click();
|
||||
cy.get(workCenterCombobox).type('workCenterOne{enter}');
|
||||
cy.get('.q-notification__message').should('have.text', 'Data created');
|
||||
});
|
||||
cy.hasNotify('Data created');
|
||||
|
||||
it('delete workCenter', () => {
|
||||
// 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
|
||||
cy.get('.q-item__section--side > .q-btn > .q-btn__content > .q-icon').click();
|
||||
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');
|
||||
cy.hasNotify('WorkCenter removed successfully');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
/// <reference types="cypress" />
|
||||
|
||||
describe('Ticket expedtion', () => {
|
||||
const tableContent = '.q-table .q-virtual-scroll__content';
|
||||
const stateTd = 'td:nth-child(9)';
|
||||
|
||||
beforeEach(() => {
|
||||
cy.login('developer');
|
||||
cy.viewport(1920, 1080);
|
||||
});
|
||||
|
||||
it('should change the state', () => {
|
||||
cy.visit('#/ticket/1/expedition');
|
||||
cy.intercept('GET', /\/api\/Expeditions\/filter/).as('expeditions');
|
||||
cy.intercept('POST', /\/api\/Expeditions\/crud/).as('crud');
|
||||
|
||||
cy.wait('@expeditions');
|
||||
|
||||
cy.selectRows([1, 2]);
|
||||
cy.get('#subToolbar [aria-controls]:nth-child(1)').click();
|
||||
cy.get('.q-menu .q-item').contains('Perdida').click();
|
||||
cy.wait('@crud');
|
||||
|
||||
cy.get(`${tableContent} tr:nth-child(-n+2) ${stateTd}`).each(($el) => {
|
||||
cy.wrap($el).contains('Perdida');
|
||||
});
|
||||
});
|
||||
});
|
|
@ -17,10 +17,7 @@ describe('WorkerNotificationsManager', () => {
|
|||
cy.login('developer');
|
||||
cy.visit(`/#/worker/${salesPersonId}/notifications`);
|
||||
cy.get(firstAvailableNotification).click();
|
||||
cy.notificationHas(
|
||||
'.q-notification__message',
|
||||
'The notification subscription of this worker cant be modified'
|
||||
);
|
||||
cy.hasNotify('The notification subscription of this worker cant be modified');
|
||||
});
|
||||
|
||||
it('should active a notification that is yours', () => {
|
||||
|
|
|
@ -152,6 +152,14 @@ Cypress.Commands.add('notificationHas', (selector, text) => {
|
|||
cy.get(selector).should('have.text', text);
|
||||
});
|
||||
|
||||
Cypress.Commands.add('selectRows', (rows) => {
|
||||
rows.forEach((row) => {
|
||||
cy.get('.q-table .q-virtual-scroll__content tr .q-checkbox__inner')
|
||||
.eq(row - 1)
|
||||
.click();
|
||||
});
|
||||
});
|
||||
|
||||
Cypress.Commands.add('fillRow', (rowSelector, data) => {
|
||||
// Usar el selector proporcionado para obtener la fila deseada
|
||||
cy.waitForElement('tbody');
|
||||
|
@ -254,3 +262,14 @@ 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,8 +36,6 @@ 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,
|
||||
|
@ -45,19 +43,10 @@ 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,
|
||||
|
@ -70,14 +59,7 @@ 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