0
0
Fork 0

Compare commits

..

61 Commits

Author SHA1 Message Date
Alex Moreno fd72f4dd45 Merge branch 'test' of https://gitea.verdnatura.es/verdnatura/salix-front into dev 2024-10-24 14:45:34 +02:00
Alex Moreno 9daed096db Merge branch 'master' of https://gitea.verdnatura.es/verdnatura/salix-front into test 2024-10-24 14:45:23 +02:00
Alex Moreno e86afd57a0 Merge pull request 'feat: refs #8039 canceledError not notify' (!850) from 8039-canceledError_not_notify into dev
Reviewed-on: verdnatura/salix-front#850
Reviewed-by: Jorge Penadés <jorgep@verdnatura.es>
2024-10-24 12:44:19 +00:00
Alex Moreno d529676ab5 Merge pull request 'fix: refs #7652 datakey' (!868) from 7652-hotfix-descriptorKey into master
Reviewed-on: verdnatura/salix-front#868
Reviewed-by: Alex Moreno <alexm@verdnatura.es>
2024-10-24 12:36:39 +00:00
Jorge Penadés 4828e32c9e fix: refs #7652 datakey 2024-10-24 14:26:16 +02:00
Jorge Penadés e26692fa51 Merge pull request '#7524 hotfix-vnProgressModal' (!866) from 7524-hotfix-vnProgressModal into master
Reviewed-on: verdnatura/salix-front#866
Reviewed-by: Javier Segarra <jsegarra@verdnatura.es>
2024-10-24 12:10:26 +00:00
Jorge Penadés 823c354ef1 fix: refs #7524 vnProgressModal 2024-10-24 13:27:08 +02:00
Jorge Penadés f52b4c9a59 fix: refs #7524 vnProgressModal 2024-10-24 13:24:45 +02:00
Alex Moreno cb2780fe6f Merge pull request 'refactor: refs #7524 use VnTable' (!861) from 7524-hotfix-useVnTable into master
Reviewed-on: verdnatura/salix-front#861
Reviewed-by: Alex Moreno <alexm@verdnatura.es>
2024-10-24 10:31:44 +00:00
Jorge Penadés c9cfb2b1cf fix: refs #7524 changes 2024-10-24 12:29:46 +02:00
Alex Moreno 48fdc9e624 Merge pull request '#7524 warmfix-useVnTable' (!862) from 7524-warmfix-useVnTable into test
Reviewed-on: verdnatura/salix-front#862
Reviewed-by: Alex Moreno <alexm@verdnatura.es>
2024-10-24 09:45:54 +00:00
Jorge Penadés f1350dece5 fix: refs #7524 changes 2024-10-24 11:43:29 +02:00
Jorge Penadés 2779e7ac8d Merge branch 'test' of https: refs #7524//gitea.verdnatura.es/verdnatura/salix-front into 7524-warmfix-useVnTable 2024-10-24 10:29:55 +02:00
Jorge Penadés d918b76010 chore: refs #7524 drop useless code 2024-10-24 10:24:28 +02:00
Jorge Penadés 6f57d9e490 refactor: refs #7524 use VnTable 2024-10-24 10:21:25 +02:00
Alex Moreno de7f55c589 Merge branch 'dev' of https: refs #8039//gitea.verdnatura.es/verdnatura/salix-front into 8039-canceledError_not_notify 2024-10-24 07:56:00 +02:00
Alex Moreno 32b4636706 Merge branch 'test' of https://gitea.verdnatura.es/verdnatura/salix-front into dev 2024-10-24 07:49:10 +02:00
Alex Moreno f26976b744 Merge branch 'master' of https://gitea.verdnatura.es/verdnatura/salix-front into test 2024-10-24 07:49:01 +02:00
Javi Gallego a0a37a68a0 Merge pull request '#8083 hotfix-insertRecord' (!859) from 8083-hotfix-insertRecord into master
Reviewed-on: verdnatura/salix-front#859
Reviewed-by: Javi Gallego <jgallego@verdnatura.es>
2024-10-23 14:25:00 +00:00
Jorge Penadés 1bfede4a55 fix: refs #8083 drop useless code 2024-10-23 16:13:32 +02:00
Jorge Penadés 4e31566ddd fix: refs #8083 drop useless code 2024-10-23 16:13:04 +02:00
Jorge Penadés 33ee1ea01b fix: refs #8083 drop useless code 2024-10-23 16:11:58 +02:00
Jorge Penadés 126bb3f039 feat: refs #8083 insert 2024-10-23 16:10:14 +02:00
Jorge Penadés 9673f7be1e fix: refs #8083 update rightly 2024-10-23 15:17:06 +02:00
Alex Moreno d1e4017869 Merge branch 'test' of https://gitea.verdnatura.es/verdnatura/salix-front into dev 2024-10-23 13:59:11 +02:00
Alex Moreno 5d4b5ad598 Merge pull request 'fix: refs #8010 footer class' (!857) from 8010-fix_vnTable_footer_class into test
Reviewed-on: verdnatura/salix-front#857
Reviewed-by: Pablo Natek <pablone@verdnatura.es>
2024-10-23 11:58:46 +00:00
Alex Moreno 2420c6dee2 Merge branch 'dev' of https: refs #8039//gitea.verdnatura.es/verdnatura/salix-front into 8039-canceledError_not_notify 2024-10-23 13:14:30 +02:00
Alex Moreno 0528474250 chore: refs #8010 kebab-case 2024-10-23 13:13:00 +02:00
Alex Moreno e7acdfd4f7 fix: refs #8010 footer class 2024-10-23 10:48:30 +02:00
Javi Gallego 3cbd294168 Merge pull request '#7943 -permisosWorker' (!855) from 7349-permisosWorker into dev
Reviewed-on: verdnatura/salix-front#855
Reviewed-by: Alex Moreno <alexm@verdnatura.es>
2024-10-23 05:52:48 +00:00
Javi Gallego 1bf1844c8f fix: refs #7349 dependencia no usada 2024-10-23 07:46:52 +02:00
Javi Gallego ae56c06628 feat: refs #7349 usa back con permisos 2024-10-23 07:45:00 +02:00
Alex Moreno 735ee09ef8 Merge branch 'master' of https://gitea.verdnatura.es/verdnatura/salix-front into test 2024-10-22 15:08:20 +02:00
Alex Moreno aaf749db6c Merge branch 'master' of https://gitea.verdnatura.es/verdnatura/salix-front into test 2024-10-22 15:08:11 +02:00
Alex Moreno 81a55a9e7a chore: test gitea 2024-10-22 14:55:47 +02:00
Jorge Penadés 41509c60dd Merge pull request '#8083 add change state btn' (!854) from 8083-hotfix-changeState into master
Reviewed-on: verdnatura/salix-front#854
Reviewed-by: Alex Moreno <alexm@verdnatura.es>
2024-10-22 12:47:58 +00:00
Jorge Penadés 033d6bddbe fix: refs #8083 move expeditions 2024-10-22 14:43:43 +02:00
Jorge Penadés da4c1e9c12 fix: refs #8083 add order 2024-10-22 14:36:30 +02:00
Jorge Penadés 9f3c834ce4 Merge branch 'master' of https: refs #8083//gitea.verdnatura.es/verdnatura/salix-front into 8083-hotfix-changeState 2024-10-22 14:24:41 +02:00
Jorge Penadés b1a511ff6f fix: refs #8083 delete btn & redirect 2024-10-22 14:21:03 +02:00
Alex Moreno f9392464e5 Merge branch '8039-canceledError_not_notify' of https://gitea.verdnatura.es/verdnatura/salix-front into 8039-canceledError_not_notify 2024-10-22 14:07:28 +02:00
Alex Moreno ee31bc8262 chore: refs #8039 not required 2024-10-22 14:07:27 +02:00
Alex Moreno 0d3e8bb5d2 Merge branch 'dev' into 8039-canceledError_not_notify 2024-10-22 12:06:41 +00:00
Alex Moreno dd2dc86eea fix: refs #8039 o not handle unnecessary errors 2024-10-22 14:05:15 +02:00
Javi Gallego 93025007f1 Merge pull request '#7524 add my team filter' (!849) from 7524-hotfix-myTeamFilter into master
Reviewed-on: verdnatura/salix-front#849
Reviewed-by: Javi Gallego <jgallego@verdnatura.es>
2024-10-22 12:00:03 +00:00
Alex Moreno cd00a3c67f test: refs #8039 fix WorkerNotification e2e 2024-10-22 13:55:35 +02:00
Alex Moreno 0c9c01b6e9 test: refs #8039 fix ZoneWarehouse e2e 2024-10-22 13:53:01 +02:00
Alex Moreno 2d81cffb33 feat: refs #8039 show duplicate request in local 2024-10-22 13:34:20 +02:00
Jorge Penadés f751408de2 feat: refs #8083 add change state btn 2024-10-22 13:22:43 +02:00
Alex Moreno a732ec05fb test: refs #8039 add hasNotify and, refactor: agencyWorkCenter test 2024-10-22 13:21:16 +02:00
Alex Moreno 9db1c4f721 fix: refs #8039 bad tests 2024-10-22 12:29:33 +02:00
Alex Moreno ffd4a402ab Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix-front into 8039-canceledError_not_notify 2024-10-22 12:14:09 +02:00
Carlos Satorres c799d17e19 Merge pull request '8144-devToTest_2444' (!852) from 8144-devToTest_2444 into test
Reviewed-on: verdnatura/salix-front#852
Reviewed-by: Carlos Satorres <carlossa@verdnatura.es>
2024-10-22 08:55:43 +00:00
Jorge Penadés 0fbd5f45e1 fix: refs #7524 select department 2024-10-21 14:29:29 +02:00
Alex Moreno c69f7af390 test: refs #8039 axios not notify 2024-10-21 13:38:35 +02:00
Alex Moreno 8478d89183 Merge branch '8039-canceledError_not_notify' of https://gitea.verdnatura.es/verdnatura/salix-front into 8039-canceledError_not_notify 2024-10-21 13:33:14 +02:00
Alex Moreno 9780fe596f feat: refs #8039 notify error unify 2024-10-21 13:33:12 +02:00
Alex Moreno 6f79275521 Merge branch 'dev' into 8039-canceledError_not_notify 2024-10-21 11:24:08 +00:00
Alex Moreno 52981953f7 feat(): refs #8039 canceledError not notify 2024-10-21 13:23:45 +02:00
Jorge Penadés a4358ec0ed chore: refs #7524 refactor order 2024-10-21 12:36:16 +02:00
Jorge Penadés 2b2ccbc6a1 feat: refs #7524 myTeam filter & default params 2024-10-21 12:14:54 +02:00
51 changed files with 774 additions and 3612 deletions

View File

@ -39,37 +39,7 @@ const onResponse = (response) => {
const onResponseError = (error) => { const onResponseError = (error) => {
stateQuery.remove(error.config); stateQuery.remove(error.config);
let message = ''; if (session.isLoggedIn() && error.response?.status === 401) {
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); session.destroy(false);
const hash = window.location.hash; const hash = window.location.hash;
const url = hash.slice(1); const url = hash.slice(1);
@ -78,8 +48,6 @@ const onResponseError = (error) => {
return Promise.reject(error); return Promise.reject(error);
} }
notify(message, 'negative');
return Promise.reject(error); return Promise.reject(error);
}; };

View File

@ -3,14 +3,51 @@ import qFormMixin from './qformMixin';
import mainShortcutMixin from './mainShortcutMixin'; import mainShortcutMixin from './mainShortcutMixin';
import keyShortcut from './keyShortcut'; import keyShortcut from './keyShortcut';
import useNotify from 'src/composables/useNotify.js'; import useNotify from 'src/composables/useNotify.js';
import { CanceledError } from 'axios';
const { notify } = useNotify(); const { notify } = useNotify();
export default boot(({ app }) => { export default boot(({ app }) => {
app.mixin(qFormMixin); app.mixin(qFormMixin);
app.mixin(mainShortcutMixin); app.mixin(mainShortcutMixin);
app.directive('shortcut', keyShortcut); app.directive('shortcut', keyShortcut);
app.config.errorHandler = function (err) { app.config.errorHandler = (error) => {
console.error(err); let message;
notify('globals.error', 'negative', 'error'); 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');
}; };
}); });

View File

@ -95,7 +95,6 @@ defineExpose({
getChanges, getChanges,
formData, formData,
vnPaginateRef, vnPaginateRef,
resetData,
}); });
onBeforeRouteLeave((to, from, next) => { onBeforeRouteLeave((to, from, next) => {

View File

@ -217,9 +217,6 @@ async function save() {
updateAndEmit('onDataSaved', formData.value, response?.data); updateAndEmit('onDataSaved', formData.value, response?.data);
if ($props.reload) await arrayData.fetch({}); if ($props.reload) await arrayData.fetch({});
hasChanges.value = false; hasChanges.value = false;
} catch (err) {
console.error(err);
notify('errors.writeRequest', 'negative');
} finally { } finally {
isLoading.value = false; isLoading.value = false;
} }

View File

@ -61,6 +61,7 @@ defineExpose({
:loading="isLoading" :loading="isLoading"
@click="emit('onDataCanceled')" @click="emit('onDataCanceled')"
v-close-popup v-close-popup
data-cy="FormModelPopup_cancel"
/> />
<QBtn <QBtn
:label="t('globals.save')" :label="t('globals.save')"
@ -70,6 +71,7 @@ defineExpose({
class="q-ml-sm" class="q-ml-sm"
:disabled="isLoading" :disabled="isLoading"
:loading="isLoading" :loading="isLoading"
data-cy="FormModelPopup_save"
/> />
</div> </div>
</template> </template>

View File

@ -1,5 +1,5 @@
<script setup> <script setup>
import { ref, watch } from 'vue'; import { ref } from 'vue';
import { useValidator } from 'src/composables/useValidator'; import { useValidator } from 'src/composables/useValidator';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';

View File

@ -183,12 +183,6 @@ watch(
{ immediate: true } { immediate: true }
); );
watch(
() => $props.create,
(value) => (createForm.value = value),
{ immediate: true }
);
watch( watch(
() => route.query[$props.searchUrl], () => route.query[$props.searchUrl],
(val) => setUserParams(val) (val) => setUserParams(val)
@ -322,6 +316,7 @@ defineExpose({
selected, selected,
CrudModelRef, CrudModelRef,
params, params,
tableRef,
}); });
function handleOnDataSaved(_) { function handleOnDataSaved(_) {
@ -422,6 +417,7 @@ function handleScroll() {
ref="tableRef" ref="tableRef"
v-bind="table" v-bind="table"
class="vnTable" class="vnTable"
:class="{ 'last-row-sticky': $props.footer }"
:columns="splittedColumns.columns" :columns="splittedColumns.columns"
:rows="rows" :rows="rows"
v-model:selected="selected" v-model:selected="selected"
@ -461,7 +457,11 @@ function handleScroll() {
/> />
</template> </template>
<template #header-cell="{ col }"> <template #header-cell="{ col }">
<QTh v-if="col.visible ?? true"> <QTh
v-if="col.visible ?? true"
:style="col.headerStyle"
:class="col.headerClass"
>
<div <div
class="column self-start q-ml-xs ellipsis" class="column self-start q-ml-xs ellipsis"
:class="`text-${col?.align ?? 'left'}`" :class="`text-${col?.align ?? 'left'}`"
@ -541,7 +541,6 @@ function handleScroll() {
<QBtn <QBtn
v-for="(btn, index) of col.actions" v-for="(btn, index) of col.actions"
v-show="btn.show ? btn.show(row) : true" v-show="btn.show ? btn.show(row) : true"
v-bind="row.attrs"
:key="index" :key="index"
:title="btn.title" :title="btn.title"
:icon="btn.icon" :icon="btn.icon"
@ -555,7 +554,6 @@ function handleScroll() {
(btn.show && btn.show(row)) ?? true ? 'visible' : 'hidden' (btn.show && btn.show(row)) ?? true ? 'visible' : 'hidden'
}`" }`"
@click="btn.action(row)" @click="btn.action(row)"
:disable="btn.disable ? btn.disable(row) : true"
/> />
</QTd> </QTd>
</template> </template>
@ -823,6 +821,7 @@ es:
top: 0; top: 0;
} }
} }
.vnTable { .vnTable {
thead tr th { thead tr th {
position: sticky; position: sticky;
@ -861,6 +860,9 @@ es:
table tbody th { table tbody th {
position: relative; position: relative;
} }
}
.last-row-sticky {
tbody:nth-last-child(1) { tbody:nth-last-child(1) {
@extend .bg-header; @extend .bg-header;
position: sticky; position: sticky;

View File

@ -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>

View File

@ -9,10 +9,6 @@ const $props = defineProps({
type: Number, //Progress value (1.0 > x > 0.0) type: Number, //Progress value (1.0 > x > 0.0)
required: true, required: true,
}, },
showDialog: {
type: Boolean,
required: true,
},
cancelled: { cancelled: {
type: Boolean, type: Boolean,
required: false, required: false,
@ -24,30 +20,22 @@ const emit = defineEmits(['cancel', 'close']);
const dialogRef = ref(null); const dialogRef = ref(null);
const _showDialog = computed({ const showDialog = defineModel('showDialog', {
get: () => $props.showDialog, type: Boolean,
set: (value) => { default: false,
if (value) dialogRef.value.show();
},
}); });
const _progress = computed(() => $props.progress); const _progress = computed(() => $props.progress);
const progressLabel = computed(() => `${Math.round($props.progress * 100)}%`); const progressLabel = computed(() => `${Math.round($props.progress * 100)}%`);
const cancel = () => {
dialogRef.value.hide();
emit('cancel');
};
</script> </script>
<template> <template>
<QDialog ref="dialogRef" v-model="_showDialog" @hide="onDialogHide"> <QDialog ref="dialogRef" v-model="showDialog" @hide="emit('close')">
<QCard class="full-width dialog"> <QCard class="full-width dialog">
<QCardSection class="row"> <QCardSection class="row">
<span class="text-h6">{{ t('Progress') }}</span> <span class="text-h6">{{ t('Progress') }}</span>
<QSpace /> <QSpace />
<QBtn icon="close" flat round dense @click="emit('close')" /> <QBtn icon="close" flat round dense v-close-popup />
</QCardSection> </QCardSection>
<QCardSection> <QCardSection>
<div class="column"> <div class="column">
@ -80,7 +68,7 @@ const cancel = () => {
type="button" type="button"
flat flat
class="text-primary" class="text-primary"
@click="cancel()" v-close-popup
> >
{{ t('globals.cancel') }} {{ t('globals.cancel') }}
</QBtn> </QBtn>

View File

@ -128,7 +128,7 @@ const addFilter = async (filter, params) => {
async function fetch(params) { async function fetch(params) {
useArrayData(props.dataKey, params); useArrayData(props.dataKey, params);
arrayData.reset(['filter.skip', 'skip', 'page']); arrayData.reset(['filter.skip', 'skip']);
await arrayData.fetch({ append: false }); await arrayData.fetch({ append: false });
if (!store.hasMoreData) isLoading.value = false; if (!store.hasMoreData) isLoading.value = false;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -277,7 +277,6 @@ globals:
medical: Mutual medical: Mutual
RouteExtendedList: Router RouteExtendedList: Router
wasteRecalc: Waste recaclulate wasteRecalc: Waste recaclulate
translations: Translations
operator: Operator operator: Operator
supplier: Supplier supplier: Supplier
created: Created created: Created
@ -305,12 +304,14 @@ globals:
from: From from: From
To: To To: To
stateFk: State stateFk: State
departmentFk: Department
email: Email email: Email
SSN: SSN SSN: SSN
fi: FI fi: FI
myTeam: My team
departmentFk: Department
changePass: Change password changePass: Change password
deleteConfirmTitle: Delete selected elements deleteConfirmTitle: Delete selected elements
changeState: Change state
errors: errors:
statusUnauthorized: Access denied statusUnauthorized: Access denied
statusInternalServerError: An internal server error has ocurred statusInternalServerError: An internal server error has ocurred
@ -557,7 +558,6 @@ ticket:
package: Package package: Package
taxClass: Tax class taxClass: Tax class
services: Services services: Services
changeState: Change state
requester: Requester requester: Requester
atender: Atender atender: Atender
request: Request request: Request

View File

@ -281,7 +281,6 @@ globals:
serial: Facturas por serie serial: Facturas por serie
medical: Mutua medical: Mutua
wasteRecalc: Recalcular mermas wasteRecalc: Recalcular mermas
translations: Traducciones
operator: Operario operator: Operario
supplier: Proveedor supplier: Proveedor
created: Fecha creación created: Fecha creación
@ -313,8 +312,10 @@ globals:
email: Correo email: Correo
SSN: NSS SSN: NSS
fi: NIF fi: NIF
myTeam: Mi equipo
changePass: Cambiar contraseña changePass: Cambiar contraseña
deleteConfirmTitle: Eliminar los elementos seleccionados deleteConfirmTitle: Eliminar los elementos seleccionados
changeState: Cambiar estado
errors: errors:
statusUnauthorized: Acceso denegado statusUnauthorized: Acceso denegado
statusInternalServerError: Ha ocurrido un error interno del servidor statusInternalServerError: Ha ocurrido un error interno del servidor
@ -566,7 +567,6 @@ ticket:
package: Embalaje package: Embalaje
taxClass: Tipo IVA taxClass: Tipo IVA
services: Servicios services: Servicios
changeState: Cambiar estado
requester: Solicitante requester: Solicitante
atender: Comprador atender: Comprador
request: Petición de compra request: Petición de compra

View File

@ -46,13 +46,9 @@ const columns = computed(() => [
]); ]);
const deleteAlias = async (row) => { const deleteAlias = async (row) => {
try { await axios.delete(`${urlPath.value}/${row.id}`);
await axios.delete(`${urlPath.value}/${row.id}`); notify(t('User removed'), 'positive');
notify(t('User removed'), 'positive'); fetchAliases();
fetchAliases();
} catch (error) {
console.error(error);
}
}; };
watch( watch(

View File

@ -61,23 +61,15 @@ const fetchAccountExistence = async () => {
}; };
const deleteMailAlias = async (row) => { const deleteMailAlias = async (row) => {
try { await axios.delete(`${urlPath}/${row.id}`);
await axios.delete(`${urlPath}/${row.id}`); fetchMailAliases();
fetchMailAliases(); notify(t('Unsubscribed from alias!'), 'positive');
notify(t('Unsubscribed from alias!'), 'positive');
} catch (error) {
console.error(error);
}
}; };
const createMailAlias = async (mailAliasFormData) => { const createMailAlias = async (mailAliasFormData) => {
try { await axios.post(urlPath, mailAliasFormData);
await axios.post(urlPath, mailAliasFormData); notify(t('Subscribed to alias!'), 'positive');
notify(t('Subscribed to alias!'), 'positive'); fetchMailAliases();
fetchMailAliases();
} catch (error) {
console.error(error);
}
}; };
const fetchMailAliases = async () => { const fetchMailAliases = async () => {

View File

@ -46,29 +46,15 @@ const columns = computed(() => [
]); ]);
const deleteSubRole = async (row) => { const deleteSubRole = async (row) => {
try { await axios.delete(`${urlPath.value}/${row.id}`);
await axios.delete(`${urlPath.value}/${row.id}`); fetchSubRoles();
fetchSubRoles(); notify(t('Role removed. Changes will take a while to fully propagate.'), 'positive');
notify(
t('Role removed. Changes will take a while to fully propagate.'),
'positive'
);
} catch (error) {
console.error(error);
}
}; };
const createSubRole = async (subRoleFormData) => { const createSubRole = async (subRoleFormData) => {
try { await axios.post(urlPath.value, subRoleFormData);
await axios.post(urlPath.value, subRoleFormData); notify(t('Role added! Changes will take a while to fully propagate.'), 'positive');
notify( fetchSubRoles();
t('Role added! Changes will take a while to fully propagate.'),
'positive'
);
fetchSubRoles();
} catch (error) {
console.error(error);
}
}; };
watch( watch(

View File

@ -204,7 +204,7 @@ function claimUrl(section) {
top top
color="black" color="black"
text-color="white" text-color="white"
:label="t('ticket.summary.changeState')" :label="t('globals.changeState')"
> >
<QList> <QList>
<QVirtualScroll <QVirtualScroll

View File

@ -93,14 +93,12 @@ const exprBuilder = (param, value) => {
:label="t('customer.basicData.phone')" :label="t('customer.basicData.phone')"
:rules="validate('client.phone')" :rules="validate('client.phone')"
clearable clearable
type="number"
v-model="data.phone" v-model="data.phone"
/> />
<VnInput <VnInput
:label="t('customer.basicData.mobile')" :label="t('customer.basicData.mobile')"
:rules="validate('client.mobile')" :rules="validate('client.mobile')"
clearable clearable
type="number"
v-model="data.mobile" v-model="data.mobile"
/> />
</VnRow> </VnRow>

View File

@ -258,15 +258,28 @@ onBeforeMount(() => {
<template #body-cell-attender="{ row }"> <template #body-cell-attender="{ row }">
<QTd> <QTd>
<VnSelect <VnSelect
url="Workers/search"
v-model="row.attenderFk" v-model="row.attenderFk"
:where="{ role: 'buyer' }" :params="{ departmentCodes: ['shopping'] }"
sort-by="id" :fields="['id', 'nickname']"
url="Workers" sort-by="nickname ASC"
hide-selected hide-selected
option-label="firstName" option-label="nickname"
option-value="id" option-value="id"
dense 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> </QTd>
</template> </template>
<template #body-cell-item="{ row }"> <template #body-cell-item="{ row }">

View File

@ -52,15 +52,27 @@ const redirectToItemTypeBasicData = (_, { id }) => {
</VnRow> </VnRow>
<VnRow> <VnRow>
<VnSelect <VnSelect
url="Workers/search"
v-model="data.workerFk" v-model="data.workerFk"
:label="t('itemType.shared.worker')" :label="t('shared.worker')"
url="Workers" sort-by="nickname ASC"
sort-by="firstName ASC" :fields="['id', 'nickname']"
:fields="['id', 'firstName']" :params="{ departmentCodes: ['shopping'] }"
option-label="nickname"
option-value="id" option-value="id"
option-label="firstName"
hide-selected 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 <VnSelect
v-model="data.categoryFk" v-model="data.categoryFk"
:label="t('itemType.shared.category')" :label="t('itemType.shared.category')"

View File

@ -41,15 +41,27 @@ const temperaturesOptions = ref([]);
</VnRow> </VnRow>
<VnRow> <VnRow>
<VnSelect <VnSelect
url="Workers/search"
v-model="data.workerFk" v-model="data.workerFk"
:label="t('shared.worker')" :label="t('shared.worker')"
url="Workers" sort-by="nickname ASC"
sort-by="firstName ASC" :fields="['id', 'nickname']"
:fields="['id', 'firstName']" :params="{ departmentCodes: ['shopping'] }"
option-label="nickname"
option-value="id" option-value="id"
option-label="firstName"
hide-selected 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 <VnSelect
v-model="data.categoryFk" v-model="data.categoryFk"
:label="t('shared.category')" :label="t('shared.category')"

View File

@ -112,32 +112,20 @@ const getShipped = async (params) => {
}; };
const onChangeZone = async (zoneId) => { const onChangeZone = async (zoneId) => {
try { formData.value.agencyModeFk = null;
formData.value.agencyModeFk = null; const { data } = await axios.get(`Zones/${zoneId}`);
const { data } = await axios.get(`Zones/${zoneId}`); formData.value.agencyModeFk = data.agencyModeFk;
formData.value.agencyModeFk = data.agencyModeFk;
} catch (error) {
console.error(error);
}
}; };
const onChangeAddress = async (addressId) => { const onChangeAddress = async (addressId) => {
try { formData.value.nickname = null;
formData.value.nickname = null; const { data } = await axios.get(`Addresses/${addressId}`);
const { data } = await axios.get(`Addresses/${addressId}`); formData.value.nickname = data.nickname;
formData.value.nickname = data.nickname;
} catch (error) {
console.error(error);
}
}; };
const getClientDefaultAddress = async (clientId) => { const getClientDefaultAddress = async (clientId) => {
try { const { data } = await axios.get(`Clients/${clientId}`);
const { data } = await axios.get(`Clients/${clientId}`); if (data) addressId.value = data.defaultAddressFk;
if (data) addressId.value = data.defaultAddressFk;
} catch (error) {
console.error(error);
}
}; };
const clientAddressesList = async (value) => { const clientAddressesList = async (value) => {

View File

@ -70,60 +70,51 @@ const isFormInvalid = () => {
}; };
const getPriceDifference = async () => { const getPriceDifference = async () => {
try { const params = {
const params = { landed: formData.value.landed,
landed: formData.value.landed, addressId: formData.value.addressFk,
addressId: formData.value.addressFk, agencyModeId: formData.value.agencyModeFk,
agencyModeId: formData.value.agencyModeFk, zoneId: formData.value.zoneFk,
zoneId: formData.value.zoneFk, warehouseId: formData.value.warehouseFk,
warehouseId: formData.value.warehouseFk, shipped: formData.value.shipped,
shipped: formData.value.shipped, };
}; const { data } = await axios.post(
const { data } = await axios.post( `tickets/${formData.value.id}/priceDifference`,
`tickets/${formData.value.id}/priceDifference`, params
params );
); formData.value.sale = data;
formData.value.sale = data;
} catch (error) {
console.error(error);
}
}; };
const submit = async () => { 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 = { const params = {
clientFk: formData.value.clientFk, clientFk: formData.value.clientFk,
nickname: formData.value.nickname, nickname: formData.value.nickname,
agencyModeFk: formData.value.agencyModeFk, agencyModeFk: formData.value.agencyModeFk,
addressFk: formData.value.addressFk, addressFk: formData.value.addressFk,
zoneFk: formData.value.zoneFk, zoneFk: formData.value.zoneFk,
warehouseFk: formData.value.warehouseFk, warehouseFk: formData.value.warehouseFk,
companyFk: formData.value.companyFk, companyFk: formData.value.companyFk,
shipped: formData.value.shipped, shipped: formData.value.shipped,
landed: formData.value.landed, landed: formData.value.landed,
isDeleted: formData.value.isDeleted, isDeleted: formData.value.isDeleted,
option: formData.value.option, option: formData.value.option,
isWithoutNegatives: formData.value.withoutNegatives, isWithoutNegatives: formData.value.withoutNegatives,
withWarningAccept: formData.value.withWarningAccept, withWarningAccept: formData.value.withWarningAccept,
keepPrice: false, keepPrice: false,
}; };
const { data } = await axios.post( const { data } = await axios.post(
`tickets/${formData.value.id}/componentUpdate`, `tickets/${formData.value.id}/componentUpdate`,
params params
); );
if (!data) return; if (!data) return;
const ticketToMove = data.id; const ticketToMove = data.id;
notify(t('basicData.unroutedTicket'), 'positive'); notify(t('basicData.unroutedTicket'), 'positive');
router.push({ name: 'TicketSummary', params: { id: ticketToMove } }); router.push({ name: 'TicketSummary', params: { id: ticketToMove } });
} catch (error) {
console.error(error);
}
}; };
const submitWithNegatives = async () => { const submitWithNegatives = async () => {

View File

@ -34,26 +34,20 @@ const newTicketFormData = reactive({});
const date = new Date(); const date = new Date();
const createTicket = async () => { const createTicket = async () => {
try { const expeditionIds = $props.selectedExpeditions.map((expedition) => expedition.id);
const expeditionIds = $props.selectedExpeditions.map( const params = {
(expedition) => expedition.id clientId: $props.ticket.clientFk,
); landed: newTicketFormData.landed,
const params = { warehouseId: $props.ticket.warehouseFk,
clientId: $props.ticket.clientFk, addressId: $props.ticket.addressFk,
landed: newTicketFormData.landed, agencyModeId: $props.ticket.agencyModeFk,
warehouseId: $props.ticket.warehouseFk, routeId: newTicketFormData.routeFk,
addressId: $props.ticket.addressFk, expeditionIds: expeditionIds,
agencyModeId: $props.ticket.agencyModeFk, };
routeId: newTicketFormData.routeFk,
expeditionIds: expeditionIds,
};
const { data } = await axios.post('Expeditions/moveExpeditions', params); const { data } = await axios.post('Expeditions/moveExpeditions', params);
notify(t('globals.dataSaved'), 'positive'); notify(t('globals.dataSaved'), 'positive');
router.push({ name: 'TicketSummary', params: { id: data.id } }); router.push({ name: 'TicketSummary', params: { id: data.id } });
} catch (error) {
console.error(error);
}
}; };
</script> </script>

View File

@ -150,31 +150,19 @@ const getTotal = computed(() => {
}); });
const getComponentsSum = async () => { const getComponentsSum = async () => {
try { const { data } = await axios.get(`Tickets/${route.params.id}/getComponentsSum`);
const { data } = await axios.get(`Tickets/${route.params.id}/getComponentsSum`); componentsList.value = data;
componentsList.value = data;
} catch (error) {
console.error(error);
}
}; };
const getTheoricalCost = async () => { const getTheoricalCost = async () => {
try { const { data } = await axios.get(`Tickets/${route.params.id}/freightCost`);
const { data } = await axios.get(`Tickets/${route.params.id}/freightCost`); theoricalCost.value = data;
theoricalCost.value = data;
} catch (error) {
console.error(error);
}
}; };
const getTicketVolume = async () => { const getTicketVolume = async () => {
try { if (!ticketData.value) return;
if (!ticketData.value) return; const { data } = await axios.get(`Tickets/${ticketData.value.id}/getVolume`);
const { data } = await axios.get(`Tickets/${ticketData.value.id}/getVolume`); ticketVolume.value = data[0].volume;
ticketVolume.value = data[0].volume;
} catch (error) {
console.error(error);
}
}; };
onMounted(() => { onMounted(() => {

View File

@ -1,5 +1,5 @@
<script setup> <script setup>
import { onMounted, ref, computed, onUnmounted, watch } from 'vue'; import { onMounted, ref, computed, onUnmounted } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
@ -15,6 +15,8 @@ import useNotify from 'src/composables/useNotify.js';
import { toDateTimeFormat } from 'src/filters/date'; import { toDateTimeFormat } from 'src/filters/date';
import axios from 'axios'; import axios from 'axios';
import VnTable from 'src/components/VnTable/VnTable.vue'; 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 route = useRoute();
const stateStore = useStateStore(); const stateStore = useStateStore();
@ -23,50 +25,24 @@ const { notify } = useNotify();
const { openConfirmationModal } = useVnConfirm(); const { openConfirmationModal } = useVnConfirm();
const newTicketDialogRef = ref(null); const newTicketDialogRef = ref(null);
const logsTableDialogRef = ref(null); const logsTableDialogRef = ref(null);
const tableRef = ref(); const vnTableRef = ref();
const expeditionsLogsData = ref([]); const expeditionsLogsData = ref([]);
const selectedExpeditions = ref([]); const selectedExpeditions = ref([]);
const allColumnNames = ref([]); const allColumnNames = ref([]);
const newTicketWithRoute = ref(false); const newTicketWithRoute = ref(false);
const selectedRows = ref([]); const selectedRows = ref([]);
const hasSelectedRows = computed(() => selectedRows.value.length > 0); const hasSelectedRows = computed(() => selectedRows.value.length > 0);
const expeditionStateTypes = ref([]);
const exprBuilder = (param, value) => {
switch (param) {
case 'expeditionFk':
return { id: value };
case 'packageItemName':
return { packagingItemFk: value };
}
};
const expeditionsFilter = computed(() => ({ const expeditionsFilter = computed(() => ({
where: { ticketFk: route.params.id }, where: { ticketFk: route.params.id },
order: ['created DESC'], order: ['created DESC'],
})); }));
const expeditionsArrayData = useArrayData('ticketExpeditions', {
url: 'Expeditions/filter',
filter: expeditionsFilter.value,
exprBuilder: exprBuilder,
});
const ticketArrayData = useArrayData('ticketData'); const ticketArrayData = useArrayData('ticketData');
const ticketStore = ticketArrayData.store; const ticketStore = ticketArrayData.store;
const ticketData = computed(() => ticketStore.data); 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(() => [ const columns = computed(() => [
{ {
align: 'left', align: 'left',
@ -187,18 +163,12 @@ const showNewTicketDialog = (withRoute = false) => {
}; };
const deleteExpedition = async () => { const deleteExpedition = async () => {
try { const expeditionIds = selectedRows.value.map((expedition) => expedition.id);
const expeditionIds = selectedExpeditions.value.map( const params = { expeditionIds };
(expedition) => expedition.id await axios.post('Expeditions/deleteExpeditions', params);
); vnTableRef.value.reload();
const params = { expeditionIds }; selectedExpeditions.value = [];
await axios.post('Expeditions/deleteExpeditions', params); notify(t('expedition.expeditionRemoved'), 'positive');
await refetchExpeditions();
selectedExpeditions.value = [];
notify(t('expedition.expeditionRemoved'), 'positive');
} catch (error) {
console.error(error);
}
}; };
const showLog = async (expedition) => { const showLog = async (expedition) => {
@ -207,29 +177,19 @@ const showLog = async (expedition) => {
}; };
const getExpeditionState = async (expedition) => { const getExpeditionState = async (expedition) => {
try { const filter = {
const filter = { where: { expeditionFk: expedition.id },
where: { expeditionFk: expedition.id }, order: ['created DESC'],
order: ['created DESC'], };
};
const { data: expeditionStates } = await axios.get(`ExpeditionStates/filter`, { const { data: expeditionStates } = await axios.get(`ExpeditionStates/filter`, {
params: { filter: JSON.stringify(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) => { expeditionsLogsData.value = expeditionStates.map((state) => ({
const scannedState = scannedStates.find((s) => s.id === state.id); ...state,
return { isScanned: !!state.isScanned,
...state, }));
isScanned: scannedState ? scannedState.isScanned : false,
};
});
} catch (error) {
console.error(error);
}
}; };
onMounted(async () => { onMounted(async () => {
@ -242,9 +202,35 @@ onUnmounted(() => (stateStore.rightDrawer = false));
</script> </script>
<template> <template>
<FetchData
url="expeditionStateTypes"
@on-fetch="(data) => (expeditionStateTypes = data)"
auto-load
/>
<VnSubToolbar> <VnSubToolbar>
<template #st-actions> <template #st-actions>
<QBtnGroup push class="q-gutter-x-sm" flat> <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 <QBtnDropdown
ref="btnDropdownRef" ref="btnDropdownRef"
color="primary" color="primary"
@ -298,11 +284,11 @@ onUnmounted(() => (stateStore.rightDrawer = false));
</QBtnGroup> </QBtnGroup>
</template> </template>
</VnSubToolbar> </VnSubToolbar>
<VnTable <VnTable
ref="tableRef" ref="vnTableRef"
data-key="TicketExpedition" data-key="TicketExpedition"
url="Expeditions/filter" url="Expeditions/filter"
search-url="expeditions"
:columns="columns" :columns="columns"
:filter="expeditionsFilter" :filter="expeditionsFilter"
v-model:selected="selectedRows" v-model:selected="selectedRows"
@ -311,6 +297,16 @@ onUnmounted(() => (stateStore.rightDrawer = false));
selection: 'multiple', selection: 'multiple',
}" }"
auto-load auto-load
:expr-builder="
(param, value) => {
switch (param) {
case 'expeditionFk':
return { id: value };
case 'packageItemName':
return { packagingItemFk: value };
}
}
"
order="created DESC" order="created DESC"
> >
<template #column-packagingItemFk="{ row }"> <template #column-packagingItemFk="{ row }">
@ -324,7 +320,7 @@ onUnmounted(() => (stateStore.rightDrawer = false));
<ExpeditionNewTicket <ExpeditionNewTicket
:ticket="ticketData" :ticket="ticketData"
:with-route="newTicketWithRoute" :with-route="newTicketWithRoute"
:selected-expeditions="selectedExpeditions" :selected-expeditions="selectedRows"
/> />
</QDialog> </QDialog>
<QDialog ref="logsTableDialogRef" transition-show="scale" transition-hide="scale"> <QDialog ref="logsTableDialogRef" transition-show="scale" transition-hide="scale">
@ -345,11 +341,7 @@ onUnmounted(() => (stateStore.rightDrawer = false));
</template> </template>
<template #body-cell-isScanned="{ row }"> <template #body-cell-isScanned="{ row }">
<QTd style="text-align: center"> <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> </QTd>
</template> </template>
</QTable> </QTable>

View File

@ -165,14 +165,10 @@ const createRefund = async (withWarehouse) => {
negative: true, negative: true,
}; };
try { const { data } = await axios.post('Tickets/cloneAll', params);
const { data } = await axios.post('Tickets/cloneAll', params); const [refundTicket] = data;
const [refundTicket] = data; notify(t('refundTicketCreated', { ticketId: refundTicket.id }), 'positive');
notify(t('refundTicketCreated', { ticketId: refundTicket.id }), 'positive'); push({ name: 'TicketSale', params: { id: refundTicket.id } });
push({ name: 'TicketSale', params: { id: refundTicket.id } });
} catch (error) {
console.error(error);
}
}; };
</script> </script>

View File

@ -150,18 +150,14 @@ const shelvingsTableColumns = computed(() => [
]); ]);
const getSaleTrackings = async (sale) => { const getSaleTrackings = async (sale) => {
try { const filter = {
const filter = { where: { saleFk: sale.saleFk },
where: { saleFk: sale.saleFk }, order: ['itemFk DESC'],
order: ['itemFk DESC'], };
}; const { data } = await axios.get(`SaleTrackings/listSaleTracking`, {
const { data } = await axios.get(`SaleTrackings/listSaleTracking`, { params: { filter: JSON.stringify(filter) },
params: { filter: JSON.stringify(filter) }, });
}); saleTrackings.value = data;
saleTrackings.value = data;
} catch (error) {
console.error(error);
}
}; };
const showLog = async (sale) => { const showLog = async (sale) => {
@ -170,17 +166,13 @@ const showLog = async (sale) => {
}; };
const getItemShelvingSales = async (sale) => { const getItemShelvingSales = async (sale) => {
try { const filter = {
const filter = { where: { saleFk: sale.saleFk },
where: { saleFk: sale.saleFk }, };
}; const { data } = await axios.get(`ItemShelvingSales/filter`, {
const { data } = await axios.get(`ItemShelvingSales/filter`, { params: { filter: JSON.stringify(filter) },
params: { filter: JSON.stringify(filter) }, });
}); itemShelvingsSales.value = data;
itemShelvingsSales.value = data;
} catch (error) {
console.error(error);
}
}; };
const showShelving = async (sale) => { const showShelving = async (sale) => {
@ -189,36 +181,28 @@ const showShelving = async (sale) => {
}; };
const updateQuantity = async (sale) => { const updateQuantity = async (sale) => {
try { if (oldQuantity.value === sale.quantity) return;
if (oldQuantity.value === sale.quantity) return; const params = {
const params = { quantity: sale.quantity,
quantity: sale.quantity, };
}; await axios.patch(`ItemShelvingSales/${sale.id}`, params);
await axios.patch(`ItemShelvingSales/${sale.id}`, params); oldQuantity.value = null;
oldQuantity.value = null;
} catch (error) {
console.error(error);
}
}; };
const updateParking = async (sale) => { const updateParking = async (sale) => {
try { const filter = {
const filter = { fields: ['id'],
fields: ['id'], where: {
where: { code: sale.shelvingFk,
code: sale.shelvingFk, },
}, };
}; const { data } = await axios.get(`Shelvings/findOne`, {
const { data } = await axios.get(`Shelvings/findOne`, { params: { filter: JSON.stringify(filter) },
params: { filter: JSON.stringify(filter) }, });
}); const params = {
const params = { parkingFk: sale.parkingFk,
parkingFk: sale.parkingFk, };
}; await axios.patch(`Shelvings/${data.id}`, params);
await axios.patch(`Shelvings/${data.id}`, params);
} catch (error) {
console.error(error);
}
}; };
const updateShelving = async (sale) => { const updateShelving = async (sale) => {
@ -241,61 +225,41 @@ const updateShelving = async (sale) => {
}; };
const saleTrackingNew = async (sale, stateCode, isChecked) => { const saleTrackingNew = async (sale, stateCode, isChecked) => {
try { const params = {
const params = { saleFk: sale.saleFk,
saleFk: sale.saleFk, isChecked,
isChecked, quantity: sale.quantity,
quantity: sale.quantity, stateCode,
stateCode, };
}; await axios.post(`SaleTrackings/new`, params);
await axios.post(`SaleTrackings/new`, params); notify(t('globals.dataSaved'), 'positive');
notify(t('globals.dataSaved'), 'positive');
} catch (error) {
console.error(error);
}
}; };
const saleTrackingDel = async ({ saleFk }, stateCode) => { const saleTrackingDel = async ({ saleFk }, stateCode) => {
try { const params = {
const params = { saleFk,
saleFk, stateCodes: [stateCode],
stateCodes: [stateCode], };
}; await axios.post(`SaleTrackings/delete`, params);
await axios.post(`SaleTrackings/delete`, params); notify(t('globals.dataSaved'), 'positive');
notify(t('globals.dataSaved'), 'positive');
} catch (error) {
console.error(error);
}
}; };
const clickSaleGroupDetail = async (sale) => { const clickSaleGroupDetail = async (sale) => {
try { if (!sale.saleGroupDetailFk) return;
if (!sale.saleGroupDetailFk) return;
await axios.delete(`SaleGroupDetails/${sale.saleGroupDetailFk}`); await axios.delete(`SaleGroupDetails/${sale.saleGroupDetailFk}`);
sale.hasSaleGroupDetail = false; sale.hasSaleGroupDetail = false;
notify(t('globals.dataSaved'), 'positive'); notify(t('globals.dataSaved'), 'positive');
} catch (error) {
console.error(error);
}
}; };
const clickPreviousSelected = (sale) => { const clickPreviousSelected = (sale) => {
try { qCheckBoxController(sale, 'isPreviousSelected');
qCheckBoxController(sale, 'isPreviousSelected'); if (!sale.isPreviousSelected) sale.isPrevious = false;
if (!sale.isPreviousSelected) sale.isPrevious = false;
} catch (error) {
console.error(error);
}
}; };
const clickPrevious = (sale) => { const clickPrevious = (sale) => {
try { qCheckBoxController(sale, 'isPrevious');
qCheckBoxController(sale, 'isPrevious'); if (sale.isPrevious) sale.isPreviousSelected = true;
if (sale.isPrevious) sale.isPreviousSelected = true;
} catch (error) {
console.error(error);
}
}; };
const qCheckBoxController = (sale, action) => { const qCheckBoxController = (sale, action) => {
@ -306,16 +270,12 @@ const qCheckBoxController = (sale, action) => {
isPreviousSelected: 'PREVIOUS_PREPARATION', isPreviousSelected: 'PREVIOUS_PREPARATION',
}; };
const stateCode = STATE_CODES[action]; const stateCode = STATE_CODES[action];
try { if (!sale[action]) {
if (!sale[action]) { saleTrackingNew(sale, stateCode, true);
saleTrackingNew(sale, stateCode, true); sale[action] = true;
sale[action] = true; } else {
} else { saleTrackingDel(sale, stateCode);
saleTrackingDel(sale, stateCode); sale[action] = false;
sale[action] = false;
}
} catch (error) {
console.error(error);
} }
}; };
</script> </script>

View File

@ -46,40 +46,32 @@ watch(
onMounted(async () => await getDefaultTaxClass()); onMounted(async () => await getDefaultTaxClass());
const createRefund = async () => { const createRefund = async () => {
try { if (!selected.value.length) return;
if (!selected.value.length) return;
const params = { const params = {
servicesIds: selected.value.map((s) => +s.id), servicesIds: selected.value.map((s) => +s.id),
withWarehouse: false, withWarehouse: false,
negative: true, negative: true,
}; };
const { data } = await axios.post('Sales/clone', params); const { data } = await axios.post('Sales/clone', params);
const [refundTicket] = data; const [refundTicket] = data;
notify( notify(
t('service.createRefundSuccess', { t('service.createRefundSuccess', {
ticketId: refundTicket.id, ticketId: refundTicket.id,
}), }),
'positive' 'positive'
); );
router.push({ name: 'TicketSale', params: { id: refundTicket.id } }); router.push({ name: 'TicketSale', params: { id: refundTicket.id } });
} catch (error) {
console.error(error);
}
}; };
const getDefaultTaxClass = async () => { const getDefaultTaxClass = async () => {
try { let filter = {
let filter = { where: { code: 'G' },
where: { code: 'G' }, };
}; const { data } = await axios.get('TaxClasses/findOne', {
const { data } = await axios.get('TaxClasses/findOne', { params: { filter: JSON.stringify(filter) },
params: { filter: JSON.stringify(filter) }, });
}); defaultTaxClass.value = data;
defaultTaxClass.value = data;
} catch (error) {
console.error(error);
}
}; };
const columns = computed(() => [ const columns = computed(() => [

View File

@ -122,37 +122,23 @@ function isOnTicketCard() {
</div> </div>
</template> </template>
<template #header-right> <template #header-right>
<div class="flex items-end"> <QBtnDropdown
<QBtnDropdown ref="stateBtnDropdownRef"
ref="stateBtnDropdownRef" color="black"
color="black" text-color="white"
text-color="white" :label="t('globals.changeState')"
:label="t('ticket.summary.changeState')" :disable="!isEditable()"
:disable="!isEditable()" >
> <VnSelect
<VnSelect :options="editableStates"
:options="editableStates" hide-selected
hide-selected option-label="name"
option-label="name" option-value="code"
option-value="code" hide-dropdown-icon
hide-dropdown-icon focus-on-mount
focus-on-mount @update:model-value="changeState"
@update:model-value="changeState" />
/> </QBtnDropdown>
</QBtnDropdown>
<QBtn
v-if="!isOnTicketCard()"
icon="more_vert"
round
size="md"
flat
color="white"
>
<QMenu>
<TicketDescriptorMenu :ticket="entityId" />
</QMenu>
</QBtn>
</div>
</template> </template>
<template #body="{ entity }"> <template #body="{ entity }">
<QCard class="vn-one"> <QCard class="vn-one">

View File

@ -75,22 +75,18 @@ const columns = computed(() => [
]); ]);
const applyVolumes = async (salesData) => { const applyVolumes = async (salesData) => {
try { if (!salesData.length) return;
if (!salesData.length) return;
sales.value = salesData; sales.value = salesData;
const ticket = sales.value[0].ticketFk; const ticket = sales.value[0].ticketFk;
const { data } = await axios.get(`Tickets/${ticket}/getVolume`); const { data } = await axios.get(`Tickets/${ticket}/getVolume`);
const volumes = new Map(data.saleVolume.map((volume) => [volume.saleFk, volume])); const volumes = new Map(data.saleVolume.map((volume) => [volume.saleFk, volume]));
sales.value.forEach((sale) => { sales.value.forEach((sale) => {
sale.saleVolume = volumes.get(sale.id); sale.saleVolume = volumes.get(sale.id);
}); });
packingTypeVolume.value = data.packingTypeVolume; packingTypeVolume.value = data.packingTypeVolume;
} catch (error) {
console.error(error);
}
}; };
onMounted(() => (stateStore.rightDrawer = true)); onMounted(() => (stateStore.rightDrawer = true));

View File

@ -1,24 +1,20 @@
<script setup> <script setup>
import { onMounted, ref, computed, reactive } from 'vue'; import { ref, computed, reactive, watch } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import FetchData from 'components/FetchData.vue'; 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 TicketDescriptorProxy from 'src/pages/Ticket/Card/TicketDescriptorProxy.vue';
import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue'; import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
import VnSearchbar from 'src/components/ui/VnSearchbar.vue'; import VnSearchbar from 'src/components/ui/VnSearchbar.vue';
import VnProgress from 'src/components/common/VnProgressModal.vue'; import VnProgress from 'src/components/common/VnProgressModal.vue';
import RightMenu from 'src/components/common/RightMenu.vue'; import RightMenu from 'src/components/common/RightMenu.vue';
import TicketAdvanceFilter from './TicketAdvanceFilter.vue'; import TicketAdvanceFilter from './TicketAdvanceFilter.vue';
import { dashIfEmpty, toCurrency } from 'src/filters'; import { dashIfEmpty, toCurrency } from 'src/filters';
import { useVnConfirm } from 'composables/useVnConfirm'; import { useVnConfirm } from 'composables/useVnConfirm';
import { useArrayData } from 'composables/useArrayData';
import useNotify from 'src/composables/useNotify.js'; import useNotify from 'src/composables/useNotify.js';
import { useState } from 'src/composables/useState'; import { useState } from 'src/composables/useState';
import { toDateFormat } from 'src/filters/date.js'; import { toDateFormat } from 'src/filters/date.js';
import axios from 'axios'; import axios from 'axios';
import VnTable from 'src/components/VnTable/VnTable.vue';
const state = useState(); const state = useState();
const { t } = useI18n(); const { t } = useI18n();
@ -29,109 +25,58 @@ const user = state.getUser();
const itemPackingTypesOptions = ref([]); const itemPackingTypesOptions = ref([]);
const zonesOptions = ref([]); const zonesOptions = ref([]);
const selectedTickets = ref([]); const selectedTickets = ref([]);
const vnTableRef = ref({});
const exprBuilder = (param, value) => { const originElRef = ref(null);
switch (param) { const destinationElRef = ref(null);
case 'id': let today = Date.vnNew().toISOString();
case 'futureId': const tomorrow = new Date(today);
case 'liters': tomorrow.setDate(tomorrow.getDate() + 1);
case 'futureLiters': const userParams = reactive({
case 'lines': dateFuture: tomorrow,
case 'futureLines': dateToAdvance: today,
case 'totalWithVat': warehouseFk: user.value.warehouseFk,
case 'futureTotalWithVat': ipt: 'H',
case 'futureZone': futureIpt: 'H',
case 'notMovableLines': isFullMovable: true,
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(() => [ const ticketColumns = computed(() => [
{ {
label: '', label: '',
name: 'icons', name: 'icons',
align: 'left', hidden: true,
columnFilter: null, headerClass: 'horizontal-separator',
}, },
{ {
label: t('advanceTickets.ticketId'),
name: 'ticketId',
align: 'center', align: 'center',
sortable: true, label: t('advanceTickets.ticketId'),
columnFilter: { name: 'id',
component: VnInput, headerClass: 'horizontal-separator',
type: 'text',
filterValue: null,
filterParamKey: 'id',
event: getInputEvents,
attrs: {
dense: true,
},
},
}, },
{ {
align: 'left',
label: t('advanceTickets.ipt'), label: t('advanceTickets.ipt'),
name: 'ipt', name: 'ipt',
field: 'ipt',
align: 'left',
sortable: true,
columnFilter: { columnFilter: {
component: VnSelect, component: 'select',
filterParamKey: 'iptColFilter',
type: 'select',
filterValue: null,
event: getInputEvents,
attrs: { attrs: {
options: itemPackingTypesOptions.value, url: 'itemPackingTypes',
'option-value': 'code', fields: ['code', 'description'],
'option-label': 'description', where: { isActive: true },
dense: 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'), label: t('advanceTickets.state'),
name: 'state', name: 'state',
align: 'left', headerClass: 'horizontal-separator',
sortable: true, hidden: true,
columnFilter: null,
}, },
{ {
label: t('advanceTickets.preparation'), label: t('advanceTickets.preparation'),
@ -139,171 +84,105 @@ const ticketColumns = computed(() => [
field: 'preparation', field: 'preparation',
align: 'left', align: 'left',
sortable: true, sortable: true,
columnFilter: null, headerClass: 'horizontal-separator',
columnFilter: false,
}, },
{ {
label: t('advanceTickets.liters'),
name: 'liters',
field: 'liters',
align: 'left', align: 'left',
sortable: true, label: t('advanceTickets.liters'),
columnFilter: { headerClass: 'horizontal-separator',
component: VnInput, name: 'liters',
type: 'text',
filterValue: null,
event: getInputEvents,
attrs: {
dense: true,
},
},
}, },
{ {
align: 'left',
label: t('advanceTickets.lines'), label: t('advanceTickets.lines'),
name: 'lines', name: 'lines',
field: 'lines', headerClass: 'horizontal-separator',
align: 'left', format: (row, dashIfEmpty) => dashIfEmpty(row.lines),
sortable: true,
columnFilter: {
component: VnInput,
type: 'text',
filterValue: null,
event: getInputEvents,
attrs: {
dense: true,
},
},
format: (val) => dashIfEmpty(val),
}, },
{ {
align: 'left',
label: t('advanceTickets.import'), label: t('advanceTickets.import'),
field: 'import', name: 'totalWithVat',
name: 'import', hidden: true,
align: 'left', headerClass: 'horizontal-separator',
sortable: true, format: (row) => toCurrency(row.totalWithVat),
}, },
{ {
align: 'left',
label: t('advanceTickets.futureId'), label: t('advanceTickets.futureId'),
name: 'futureId', name: 'futureId',
align: 'left', headerClass: 'vertical-separator horizontal-separator',
sortable: true, columnClass: 'vertical-separator',
columnFilter: {
component: VnInput,
type: 'text',
filterValue: null,
filterParamKey: 'futureId',
event: getInputEvents,
attrs: {
dense: true,
},
},
}, },
{ {
align: 'left',
label: t('advanceTickets.futureIpt'), label: t('advanceTickets.futureIpt'),
name: 'futureIpt', name: 'futureIpt',
field: 'futureIpt',
align: 'left',
sortable: true,
columnFilter: { columnFilter: {
component: VnSelect, component: 'select',
filterParamKey: 'futureIptColFilter',
type: 'select',
filterValue: null,
event: getInputEvents,
attrs: { attrs: {
options: itemPackingTypesOptions.value, url: 'itemPackingTypes',
'option-value': 'code', fields: ['code', 'description'],
'option-label': 'description', where: { isActive: true },
dense: true, optionValue: 'code',
optionLabel: 'description',
}, },
}, },
format: (val) => dashIfEmpty(val), headerClass: 'horizontal-separator',
format: (row, dashIfEmpty) => dashIfEmpty(row.futureIpt),
}, },
{ {
align: 'left',
label: t('advanceTickets.futureState'), label: t('advanceTickets.futureState'),
name: 'futureState', name: 'futureState',
align: 'left', headerClass: 'horizontal-separator',
sortable: true, hidden: true,
columnFilter: null,
format: (val) => dashIfEmpty(val),
}, },
{ {
align: 'left',
label: t('advanceTickets.futureLiters'), label: t('advanceTickets.futureLiters'),
headerClass: 'horizontal-separator',
name: 'futureLiters', 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'), label: t('advanceTickets.futureZone'),
name: 'futureZoneName', name: 'futureZoneFk',
field: 'futureZoneName', columnClass: 'expand',
align: 'left',
sortable: true,
columnFilter: { columnFilter: {
component: VnSelect, component: 'select',
type: 'select', inWhere: true,
filterValue: null,
filterParamKey: 'futureZoneFk',
event: getInputEvents,
attrs: { attrs: {
options: zonesOptions.value, url: 'Zones',
'option-value': 'id', fields: ['id', 'name'],
'option-label': 'name',
dense: true,
}, },
}, },
format: (val) => dashIfEmpty(val), columnField: {
component: null,
},
headerClass: 'horizontal-separator',
format: (row, dashIfEmpty) => dashIfEmpty(row.futureZoneName),
}, },
{ {
align: 'left',
label: t('advanceTickets.notMovableLines'), label: t('advanceTickets.notMovableLines'),
headerClass: 'horizontal-separator',
name: 'notMovableLines', 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'), label: t('advanceTickets.futureLines'),
headerClass: 'horizontal-separator',
name: 'futureLines', 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', align: 'left',
sortable: true, label: t('advanceTickets.futureImport'),
columnFilter: null, 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`; const query = `tickets/${ticket.futureId}/componentUpdate`;
if (!ticket.landed) { if (!ticket.landed) {
const newLanded = await getLanded({ const newLanded = await getLanded({
shipped: userParams.dateToAdvance, shipped: vnTableRef.value.params.dateToAdvance,
addressFk: ticket.futureAddressFk, addressFk: ticket.futureAddressFk,
agencyModeFk: ticket.agencyModeFk ?? ticket.futureAgencyModeFk, agencyModeFk: ticket.agencyModeFk ?? ticket.futureAgencyModeFk,
warehouseFk: ticket.futureWarehouseFk, warehouseFk: ticket.futureWarehouseFk,
@ -352,7 +231,7 @@ const requestComponentUpdate = async (ticket, isWithoutNegatives) => {
zoneFk: ticket.zoneFk ?? ticket.futureZoneFk, zoneFk: ticket.zoneFk ?? ticket.futureZoneFk,
warehouseFk: ticket.futureWarehouseFk, warehouseFk: ticket.futureWarehouseFk,
companyFk: ticket.futureCompanyFk, companyFk: ticket.futureCompanyFk,
shipped: userParams.dateToAdvance, shipped: vnTableRef.value.params.dateToAdvance,
landed: ticket.landed, landed: ticket.landed,
isDeleted: false, isDeleted: false,
isWithoutNegatives, isWithoutNegatives,
@ -364,36 +243,31 @@ const requestComponentUpdate = async (ticket, isWithoutNegatives) => {
}; };
const moveTicketsAdvance = async () => { const moveTicketsAdvance = async () => {
try { let ticketsToMove = [];
let ticketsToMove = []; for (const ticket of selectedTickets.value) {
for (const ticket of selectedTickets.value) { if (!ticket.id) {
if (!ticket.id) { try {
try { const { query, params } = await requestComponentUpdate(ticket, false);
const { query, params } = await requestComponentUpdate(ticket, false); axios.post(query, params);
axios.post(query, params); } catch (e) {
} catch (e) { console.error('Error moving ticket', e);
console.error('Error moving ticket', e);
}
continue;
} }
ticketsToMove.push({ continue;
originId: ticket.futureId,
destinationId: ticket.id,
originShipped: ticket.futureShipped,
destinationShipped: ticket.shipped,
workerFk: ticket.workerFk,
});
} }
ticketsToMove.push({
const params = { tickets: ticketsToMove }; originId: ticket.futureId,
await axios.post('Tickets/merge', params); destinationId: ticket.id,
arrayData.fetch({ append: false }); originShipped: ticket.futureShipped,
selectedTickets.value = []; destinationShipped: ticket.shipped,
if (ticketsToMove.length) workerFk: ticket.workerFk,
notify(t('advanceTickets.moveTicketSuccess'), 'positive'); });
} catch (error) {
console.error('Error moving tickets', error);
} }
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); const progressLength = ref(0);
@ -434,10 +308,8 @@ const splitTickets = async () => {
progressAdd(ticket.futureId); progressAdd(ticket.futureId);
} }
} }
} catch (error) {
console.error('Error splitting tickets', error);
} finally { } finally {
arrayData.fetch({ append: false }); vnTableRef.value.reload();
} }
}; };
@ -455,19 +327,52 @@ const handleCloseProgressDialog = () => {
const handleCancelProgress = () => (cancelProgress.value = true); const handleCancelProgress = () => (cancelProgress.value = true);
onMounted(async () => { watch(
let today = Date.vnNew(); () => vnTableRef.value.tableRef?.$el,
const tomorrow = new Date(today); ($el) => {
tomorrow.setDate(tomorrow.getDate() + 1); if (!$el) return;
userParams.dateFuture = tomorrow; const head = $el.querySelector('thead');
userParams.dateToAdvance = today; const firstRow = $el.querySelector('thead > tr');
userParams.scopeDays = 1;
userParams.warehouseFk = user.value.warehouseFk;
const filter = { limit: 0 };
await arrayData.addFilter({ filter, userParams });
});
</script>
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> <template>
<FetchData <FetchData
url="itemPackingTypes" url="itemPackingTypes"
@ -488,11 +393,6 @@ onMounted(async () => {
auto-load auto-load
@on-fetch="(data) => (zonesOptions = data)" @on-fetch="(data) => (zonesOptions = data)"
/> />
<VnSearchbar
data-key="WeeklyTickets"
:label="t('weeklyTickets.search')"
:info="t('weeklyTickets.searchInfo')"
/>
<VnSubToolbar> <VnSubToolbar>
<template #st-data> <template #st-data>
<QBtn <QBtn
@ -536,174 +436,109 @@ onMounted(async () => {
</VnSubToolbar> </VnSubToolbar>
<RightMenu> <RightMenu>
<template #right-panel> <template #right-panel>
<TicketAdvanceFilter data-key="AdvanceTickets" /> <TicketAdvanceFilter data-key="advanceTickets" />
</template> </template>
</RightMenu> </RightMenu>
<QPage class="column items-center q-pa-md"> <QPage class="column items-center q-pa-md">
<QTable <VnTable
:rows="tickets" data-key="advanceTickets"
ref="vnTableRef"
url="Tickets/getTicketsAdvance"
search-url="advanceTickets"
:user-params="userParams"
:limit="0"
:columns="ticketColumns" :columns="ticketColumns"
row-key="index" :table="{
selection="multiple" 'row-key': '$index',
selection: 'multiple',
}"
v-model:selected="selectedTickets" v-model:selected="selectedTickets"
:pagination="{ rowsPerPage: 0 }" :pagination="{ rowsPerPage: 0 }"
:no-data-label="t('globals.noResults')" :no-data-label="t('globals.noResults')"
style="max-width: 99%" :right-search="false"
auto-load
:disable-option="{ card: true }"
> >
<template #header="props"> <template #column-icons="{ row }">
{{ userParams.scopeDays }} <QIcon
<QTr :props="props"> v-if="row.futureAgency !== row.agency && row.agency"
<QTh color="primary"
class="horizontal-separator text-uppercase color-vn-label" name="vn:agency-term"
colspan="7" size="xs"
translate >
> <QTooltip class="column">
{{ t('advanceTickets.destination') }} <span>
{{ toDateFormat(userParams.dateToAdvance) }} {{
</QTh> t('advanceTickets.originAgency', {
<QTh agency: row.futureAgency,
class="horizontal-separator text-uppercase color-vn-label" })
colspan="9" }}
translate </span>
> <span>
{{ t('advanceTickets.origin') }} {{
{{ toDateFormat(userParams.dateFuture) }} t('advanceTickets.destinationAgency', {
</QTh> agency: row.agency,
</QTr> })
<QTr> }}
<QTh> </span>
<QCheckbox v-model="props.selected" /> </QTooltip>
</QTh> </QIcon>
<QTh
v-for="(col, index) in ticketColumns"
:key="index"
:class="{ 'vertical-separator': col.name === 'futureId' }"
>
{{ col.label }}
</QTh>
</QTr>
</template> </template>
<template #top-row="{ cols }"> <template #column-id="{ row }">
<QTr> <QBtn flat class="link">
<QTd /> {{ row.id }}
<QTd <TicketDescriptorProxy :id="row.id" />
v-for="(col, index) in cols" </QBtn>
: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>
<template #header-cell-availableLines="{ col }"> <template #column-state="{ row }">
<QTh class="vertical-separator"> <QBadge
{{ col.label }} v-if="row.state"
</QTh> text-color="black"
:color="row.classColor"
class="q-ma-none"
dense
>
{{ row.state }}
</QBadge>
<span v-else> {{ dashIfEmpty(row.state) }}</span>
</template> </template>
<template #body-cell-icons="{ row }"> <template #column-import="{ row }">
<QTd class="q-gutter-x-xs"> <QBadge
<QIcon :text-color="isLessThan50(row.totalWithVat) ? 'black' : 'white'"
v-if="row.futureAgency !== row.agency && row.agency" :color="totalPriceColor(row.totalWithVat)"
color="primary" class="q-ma-none"
name="vn:agency-term" dense
size="xs" >
> {{ toCurrency(row.totalWithVat || 0) }}
<QTooltip class="column"> </QBadge>
<span>
{{
t('advanceTickets.originAgency', {
agency: row.futureAgency,
})
}}
</span>
<span>
{{
t('advanceTickets.destinationAgency', {
agency: row.agency,
})
}}
</span>
</QTooltip>
</QIcon>
</QTd>
</template> </template>
<template #column-futureId="{ row }">
<template #body-cell-ticketId="{ row }"> <QBtn flat class="link" dense>
<QTd> {{ row.futureId }}
<QBtn flat class="link"> <TicketDescriptorProxy :id="row.futureId" />
{{ row.id }} </QBtn>
<TicketDescriptorProxy :id="row.id" />
</QBtn>
</QTd>
</template> </template>
<template #body-cell-state="{ row }"> <template #column-futureState="{ row }">
<QTd> <QBadge
<QBadge text-color="black"
v-if="row.state" :color="row.futureClassColor"
text-color="black" class="q-ma-none"
:color="row.classColor" dense
class="q-ma-none" >
dense {{ row.futureState }}
> </QBadge>
{{ row.state }}
</QBadge>
<span v-else> {{ dashIfEmpty(row.state) }}</span>
</QTd>
</template> </template>
<template #body-cell-import="{ row }"> <template #column-futureImport="{ row }">
<QTd> <QBadge
<QBadge :text-color="isLessThan50(row.futureTotalWithVat) ? 'black' : 'white'"
:text-color="isLessThan50(row.totalWithVat) ? 'black' : 'white'" :color="totalPriceColor(row.futureTotalWithVat)"
:color="totalPriceColor(row.totalWithVat)" class="q-ma-none"
class="q-ma-none" dense
dense >
> {{ toCurrency(row.futureTotalWithVat || 0) }}
{{ toCurrency(row.totalWithVat || 0) }} </QBadge>
</QBadge>
</QTd>
</template> </template>
<template #body-cell-futureId="{ row }"> </VnTable>
<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 <VnProgress
:progress="progressPercentage" :progress="progressPercentage"
:cancelled="cancelProgress" :cancelled="cancelProgress"
@ -722,11 +557,11 @@ onMounted(async () => {
</template> </template>
<style scoped lang="scss"> <style scoped lang="scss">
.vertical-separator { :deep(.vertical-separator) {
border-left: 4px solid white !important; border-left: 4px solid white !important;
} }
.horizontal-separator { :deep(.horizontal-separator) {
border-bottom: 4px solid white !important; border-top: 4px solid white !important;
} }
</style> </style>

View File

@ -11,7 +11,7 @@ import axios from 'axios';
import { onMounted } from 'vue'; import { onMounted } from 'vue';
import VnInputNumber from 'src/components/common/VnInputNumber.vue'; import VnInputNumber from 'src/components/common/VnInputNumber.vue';
const { t } = useI18n(); const { t, te } = useI18n();
const props = defineProps({ const props = defineProps({
dataKey: { dataKey: {
type: String, type: String,
@ -27,20 +27,21 @@ const warehousesOptions = ref([]);
const itemPackingTypes = ref([]); const itemPackingTypes = ref([]);
const getItemPackingTypes = async () => { const getItemPackingTypes = async () => {
try { const filter = {
const filter = { where: { isActive: true },
where: { isActive: true }, };
}; const { data } = await axios.get('ItemPackingTypes', {
const { data } = await axios.get('ItemPackingTypes', { params: { filter: JSON.stringify(filter) },
params: { filter: JSON.stringify(filter) }, });
}); itemPackingTypes.value = data.map((ipt) => ({
itemPackingTypes.value = data.map((ipt) => ({ description: t(ipt.description),
description: t(ipt.description), code: ipt.code,
code: ipt.code, }));
})); };
} catch (error) {
console.error(error); const getLocale = (val) => {
} const param = `params.${val}`;
return te(param) ? t(param) : t(`globals.${param}`);
}; };
onMounted(async () => await getItemPackingTypes()); onMounted(async () => await getItemPackingTypes());
@ -53,6 +54,7 @@ onMounted(async () => await getItemPackingTypes());
auto-load auto-load
/> />
<VnFilterPanel <VnFilterPanel
search-url="advanceTickets"
:data-key="props.dataKey" :data-key="props.dataKey"
:search-button="true" :search-button="true"
:hidden-tags="['search']" :hidden-tags="['search']"
@ -60,7 +62,7 @@ onMounted(async () => await getItemPackingTypes());
> >
<template #tags="{ tag, formatFn }"> <template #tags="{ tag, formatFn }">
<div class="q-gutter-x-xs"> <div class="q-gutter-x-xs">
<strong>{{ t(`params.${tag.label}`) }}: </strong> <strong>{{ getLocale(tag.label) }}: </strong>
<span>{{ formatFn(tag.value) }}</span> <span>{{ formatFn(tag.value) }}</span>
</div> </div>
</template> </template>
@ -96,6 +98,7 @@ onMounted(async () => await getItemPackingTypes());
dense dense
outlined outlined
rounded rounded
:use-like="false"
> >
</VnSelect> </VnSelect>
</QItemSection> </QItemSection>
@ -113,6 +116,7 @@ onMounted(async () => await getItemPackingTypes());
dense dense
outlined outlined
rounded rounded
:use-like="false"
> >
</VnSelect> </VnSelect>
</QItemSection> </QItemSection>
@ -136,6 +140,19 @@ onMounted(async () => await getItemPackingTypes());
/> />
</QItemSection> </QItemSection>
</QItem> </QItem>
<QItem>
<QItemSection>
<VnSelect
:label="t('globals.params.departmentFk')"
v-model="params.departmentFk"
url="Departments"
:fields="['id', 'name']"
dense
outlined
rounded
/>
</QItemSection>
</QItem>
<QItem> <QItem>
<QItemSection> <QItemSection>
<VnSelect <VnSelect

View File

@ -24,33 +24,25 @@ const itemPackingTypes = ref([]);
const stateOptions = ref([]); const stateOptions = ref([]);
const getItemPackingTypes = async () => { const getItemPackingTypes = async () => {
try { const filter = {
const filter = { where: { isActive: true },
where: { isActive: true }, };
}; const { data } = await axios.get('ItemPackingTypes', {
const { data } = await axios.get('ItemPackingTypes', { params: { filter: JSON.stringify(filter) },
params: { filter: JSON.stringify(filter) }, });
}); itemPackingTypes.value = data.map((ipt) => ({
itemPackingTypes.value = data.map((ipt) => ({ description: t(ipt.description),
description: t(ipt.description), code: ipt.code,
code: ipt.code, }));
}));
} catch (error) {
console.error(error);
}
}; };
const getGroupedStates = async () => { const getGroupedStates = async () => {
try { const { data } = await axios.get('AlertLevels');
const { data } = await axios.get('AlertLevels'); stateOptions.value = data.map((state) => ({
stateOptions.value = data.map((state) => ({ id: state.id,
id: state.id, name: t(`futureTickets.${state.code}`),
name: t(`futureTickets.${state.code}`), code: state.code,
code: state.code, }));
}));
} catch (error) {
console.error(error);
}
}; };
onMounted(async () => { onMounted(async () => {

View File

@ -100,7 +100,7 @@ weeklyTickets:
advanceTickets: advanceTickets:
preparation: Preparación preparation: Preparación
origin: Origen origin: Origen
destination: Destinatario destination: Destino
originAgency: 'Agencia origen: {agency}' originAgency: 'Agencia origen: {agency}'
destinationAgency: 'Agencia destino: {agency}' destinationAgency: 'Agencia destino: {agency}'
ticketId: ID ticketId: ID

View File

@ -17,6 +17,11 @@ const $props = defineProps({
required: false, required: false,
default: null, default: null,
}, },
dataKey: {
type: String,
required: false,
default: 'workerData',
},
}); });
const image = ref(null); const image = ref(null);
@ -65,7 +70,7 @@ const handlePhotoUpdated = (evt = false) => {
<CardDescriptor <CardDescriptor
ref="cardDescriptorRef" ref="cardDescriptorRef"
module="Worker" module="Worker"
data-key="workerData" :data-key="dataKey"
url="Workers/descriptor" url="Workers/descriptor"
:filter="{ where: { id: entityId } }" :filter="{ where: { id: entityId } }"
title="user.nickname" title="user.nickname"

View File

@ -12,6 +12,11 @@ const $props = defineProps({
<template> <template>
<QPopupProxy> <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> </QPopupProxy>
</template> </template>

View File

@ -44,8 +44,9 @@ async function toggleNotification(notification) {
`worker.notificationsManager.${notification.active ? '' : 'un'}subscribed` `worker.notificationsManager.${notification.active ? '' : 'un'}subscribed`
), ),
}); });
} catch { } catch (e) {
notification.active = !notification.active; notification.active = !notification.active;
throw e;
} }
} }

View File

@ -1,182 +0,0 @@
<script setup>
import { ref } from 'vue';
import { computed } from 'vue';
import { useI18n } from 'vue-i18n';
import VnTable from 'src/components/VnTable/VnTable.vue';
import VnSelect from 'src/components/common/VnSelect.vue';
import axios from 'axios';
import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
import FetchData from 'src/components/FetchData.vue';
import VnInput from 'src/components/common/VnInput.vue';
const { t } = useI18n();
const columns = computed(() => [
{
align: 'left',
name: primaryKey,
label: t('primaryKey'),
create: true,
},
{
align: 'left',
name: 'en',
label: t('defaultLang(en)'),
},
{
align: 'left',
name: lang,
label: lang,
},
{
align: 'right',
label: '',
name: 'tableActions',
actions: [
{
title: t('View Summary'),
icon: 'save',
action: (row) => upsertI18n(row),
isPrimary: true,
disable: (row) => !row.hasChanges,
},
],
},
]);
const tableRef = ref({});
const langs = ref([]);
const tables = ref([]);
const lang = ref('es');
const primaryKey = computed(() => table.value.primaryKey);
const field = computed(() => table.value.field);
const table = ref();
const originalData = ref([]);
const url = computed(() => table.value?.tableName + 's');
async function loadTable(data) {
if (data) {
originalData.value = [];
tableRef.value.CrudModelRef.formData = [];
const newData = {};
for (const translation of data) {
if (!newData[translation[primaryKey.value]])
newData[translation[primaryKey.value]] = {};
newData[translation[primaryKey.value]][translation.lang] =
translation[field.value];
}
for (const currentData in newData) {
originalData.value.push({
[primaryKey.value]: currentData,
...newData[currentData],
});
tableRef.value.CrudModelRef.formData.push({
[primaryKey.value]: currentData,
...newData[currentData],
});
}
return;
}
tableRef.value.CrudModelRef.formData = JSON.parse(JSON.stringify(originalData.value));
}
function resetOriginalData() {
originalData.value = null;
}
async function upsertI18n(data) {
await axios.patch(url.value, {
[field.value]: data[lang.value],
[primaryKey.value]: data[primaryKey.value],
lang: lang.value,
});
const index = originalData.value.findIndex(
(t) => t[primaryKey.value] == data[primaryKey.value]
);
originalData.value[index] = data;
data.hasChanges = false;
}
</script>
<template>
<FetchData url="Languages" @on-fetch="(data) => (langs = data)" auto-load />
<FetchData
url="Applications/get-i18n-tables"
@on-fetch="(data) => (tables = data)"
auto-load
/>
<VnSubToolbar>
<template #st-data>
<VnSelect
:label="t('table')"
v-model="table"
:options="tables"
option-label="tableName"
option-value="tableName"
@update:model-value="resetOriginalData()"
:emit-value="false"
/>
<VnSelect
:label="t('lang')"
v-model="lang"
:options="langs"
option-label="code"
option-value="code"
@update:model-value="loadTable()"
/>
</template>
</VnSubToolbar>
<VnTable
ref="tableRef"
data-key="translations"
:url="url"
:columns="columns"
:filter="{ limit: 50 }"
:create="{
urlCreate: url,
title: 'Create translation',
onDataSaved: () => tableRef.reload(),
formInitialData: { lang: 'en' },
}"
:right-search="false"
@on-fetch="(data) => loadTable(data)"
:save-fn="upsertI18n"
:search-url="false"
>
<template #[`column-${lang}`]="{ row }">
<VnInput
v-model="row[lang]"
:clearable="false"
@keyup.enter="upsertI18n(row)"
@update:model-value="
(value) => {
row.hasChanges =
value !=
originalData.find((o) => o[primaryKey] == row[primaryKey])?.[
lang
];
}
"
/>
</template>
<template #more-create-dialog="{ data }">
<VnInput v-model="data[field]" :label="field" />
</template>
</VnTable>
</template>
<i18n>
es:
primaryKey: Clave primaria
defaultLang(en): Idioma por defecto(Eng)
secondLang: Idioma secundario
table: Tabla
lang: Idioma
en:
primaryKey: Primary key
defaultLang(en): Default language(Eng)
secondLang: Second language
table: Table
lang: Language
</i18n>

View File

@ -34,21 +34,13 @@ const columns = computed(() => [
]); ]);
const deleteWarehouse = async (row) => { const deleteWarehouse = async (row) => {
try { await axios.delete(`${urlPath.value}/${row.id}`);
await axios.delete(`${urlPath.value}/${row.id}`); fetchWarehouses();
fetchWarehouses();
} catch (error) {
console.error(error);
}
}; };
const createZoneWarehouse = async (ZoneWarehouseFormData) => { const createZoneWarehouse = async (ZoneWarehouseFormData) => {
try { await axios.post(urlPath.value, ZoneWarehouseFormData);
await axios.post(urlPath.value, ZoneWarehouseFormData); fetchWarehouses();
fetchWarehouses();
} catch (error) {
console.error(error);
}
}; };
watch( watch(

View File

@ -22,7 +22,6 @@ import Account from './account';
import Monitor from './monitor'; import Monitor from './monitor';
import MailAlias from './mailAlias'; import MailAlias from './mailAlias';
import Role from './role'; import Role from './role';
import TranslationsVn from './translationsVn.js';
export default [ export default [
Item, Item,
@ -49,5 +48,4 @@ export default [
MailAlias, MailAlias,
Monitor, Monitor,
Role, Role,
TranslationsVn,
]; ];

View File

@ -1,16 +0,0 @@
import { RouterView } from 'vue-router';
export default {
path: '/translations',
name: 'Translations',
meta: {
title: 'translations',
icon: 'history_edu',
moduleName: 'Translations',
},
component: RouterView,
menus: {
main: [],
card: [],
},
};

View File

@ -12,7 +12,7 @@ export default {
component: RouterView, component: RouterView,
redirect: { name: 'WorkerMain' }, redirect: { name: 'WorkerMain' },
menus: { menus: {
main: ['WorkerList', 'WorkerDepartment', 'TranslationsVn'], main: ['WorkerList', 'WorkerDepartment'],
card: [ card: [
'WorkerBasicData', 'WorkerBasicData',
'WorkerNotes', 'WorkerNotes',
@ -55,15 +55,6 @@ export default {
}, },
component: () => import('src/pages/Worker/WorkerDepartment.vue'), component: () => import('src/pages/Worker/WorkerDepartment.vue'),
}, },
{
path: 'translations',
name: 'TranslationsVn',
meta: {
title: 'translations',
icon: 'history_edu',
},
component: () => import('src/pages/Worker/TranslationsVn.vue'),
},
{ {
path: 'create', path: 'create',
name: 'WorkerCreate', name: 'WorkerCreate',

View File

@ -22,7 +22,6 @@ import zone from 'src/router/modules/zone';
import account from './modules/account'; import account from './modules/account';
import monitor from 'src/router/modules/monitor'; import monitor from 'src/router/modules/monitor';
import mailAlias from './modules/mailAlias'; import mailAlias from './modules/mailAlias';
import translationsVn from './modules/translationsVn';
const routes = [ const routes = [
{ {
@ -98,7 +97,6 @@ const routes = [
account, account,
role, role,
mailAlias, mailAlias,
translationsVn,
{ {
path: '/:catchAll(.*)*', path: '/:catchAll(.*)*',
name: 'NotFound', name: 'NotFound',

View File

@ -13,7 +13,7 @@ describe('Logout', () => {
}); });
describe('not user', () => { describe('not user', () => {
beforeEach(() => { beforeEach(() => {
cy.intercept('GET', '**/VnUsers/acl', { cy.intercept('GET', '**DefaultViewConfigs**', {
statusCode: 401, statusCode: 401,
body: { body: {
error: { error: {
@ -24,10 +24,11 @@ describe('Logout', () => {
}, },
}, },
statusMessage: 'AUTHORIZATION_REQUIRED', statusMessage: 'AUTHORIZATION_REQUIRED',
}).as('someRoute'); });
}); });
it('when token not exists', () => { it('when token not exists', () => {
cy.reload(); cy.get('.q-list > [href="#/item"]').click();
cy.get('.q-notification__message').should( cy.get('.q-notification__message').should(
'have.text', 'have.text',
'Authorization Required' 'Authorization Required'

View File

@ -7,31 +7,20 @@ describe('AgencyWorkCenter', () => {
const createButton = '.q-page-sticky > div > .q-btn > .q-btn__content > .q-icon'; const createButton = '.q-page-sticky > div > .q-btn > .q-btn__content > .q-icon';
const workCenterCombobox = 'input[role="combobox"]'; const workCenterCombobox = 'input[role="combobox"]';
it('assign workCenter', () => { it('check workCenter crud', () => {
// create
cy.get(createButton).click(); cy.get(createButton).click();
cy.get(workCenterCombobox).type('workCenterOne{enter}'); 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-item__section--side > .q-btn > .q-btn__content > .q-icon').click();
cy.get('.q-notification__message').should( cy.hasNotify('WorkCenter removed successfully');
'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');
}); });
}); });

View File

@ -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');
});
});
});

View File

@ -17,10 +17,7 @@ describe('WorkerNotificationsManager', () => {
cy.login('developer'); cy.login('developer');
cy.visit(`/#/worker/${salesPersonId}/notifications`); cy.visit(`/#/worker/${salesPersonId}/notifications`);
cy.get(firstAvailableNotification).click(); cy.get(firstAvailableNotification).click();
cy.notificationHas( cy.hasNotify('The notification subscription of this worker cant be modified');
'.q-notification__message',
'The notification subscription of this worker cant be modified'
);
}); });
it('should active a notification that is yours', () => { it('should active a notification that is yours', () => {

View File

@ -152,6 +152,14 @@ Cypress.Commands.add('notificationHas', (selector, text) => {
cy.get(selector).should('have.text', 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) => { Cypress.Commands.add('fillRow', (rowSelector, data) => {
// Usar el selector proporcionado para obtener la fila deseada // Usar el selector proporcionado para obtener la fila deseada
cy.waitForElement('tbody'); 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' '.column > .q-avatar > .q-avatar__content > .q-img > .q-img__container > .q-img__image'
).click(); ).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}"`);
});
});

View File

@ -36,8 +36,6 @@ describe('Axios boot', () => {
describe('onResponseError()', async () => { describe('onResponseError()', async () => {
it('should call to the Notify plugin with a message error for an status code "500"', async () => { it('should call to the Notify plugin with a message error for an status code "500"', async () => {
Notify.create = vi.fn();
const error = { const error = {
response: { response: {
status: 500, status: 500,
@ -45,19 +43,10 @@ describe('Axios boot', () => {
}; };
const result = onResponseError(error); const result = onResponseError(error);
expect(result).rejects.toEqual(expect.objectContaining(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 () => { it('should call to the Notify plugin with a message from the response property', async () => {
Notify.create = vi.fn();
const error = { const error = {
response: { response: {
status: 401, status: 401,
@ -70,14 +59,7 @@ describe('Axios boot', () => {
}; };
const result = onResponseError(error); const result = onResponseError(error);
expect(result).rejects.toEqual(expect.objectContaining(error)); expect(result).rejects.toEqual(expect.objectContaining(error));
expect(Notify.create).toHaveBeenCalledWith(
expect.objectContaining({
message: 'Invalid user or password',
type: 'negative',
})
);
}); });
}); });
}); });