forked from verdnatura/salix-front
Compare commits
3 Commits
dev
...
warmfix_cr
Author | SHA1 | Date |
---|---|---|
Javier Segarra | 9a518ed990 | |
Javier Segarra | 26de0cf72f | |
Javier Segarra | 70dcadc57d |
|
@ -39,7 +39,37 @@ const onResponse = (response) => {
|
||||||
const onResponseError = (error) => {
|
const onResponseError = (error) => {
|
||||||
stateQuery.remove(error.config);
|
stateQuery.remove(error.config);
|
||||||
|
|
||||||
if (session.isLoggedIn() && error.response?.status === 401) {
|
let message = '';
|
||||||
|
|
||||||
|
const response = error.response;
|
||||||
|
const responseData = response && response.data;
|
||||||
|
const responseError = responseData && response.data.error;
|
||||||
|
if (responseError) {
|
||||||
|
message = responseError.message;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (response?.status) {
|
||||||
|
case 422:
|
||||||
|
if (error.name == 'ValidationError')
|
||||||
|
message +=
|
||||||
|
' "' +
|
||||||
|
responseError.details.context +
|
||||||
|
'.' +
|
||||||
|
Object.keys(responseError.details.codes).join(',') +
|
||||||
|
'"';
|
||||||
|
break;
|
||||||
|
case 500:
|
||||||
|
message = 'errors.statusInternalServerError';
|
||||||
|
break;
|
||||||
|
case 502:
|
||||||
|
message = 'errors.statusBadGateway';
|
||||||
|
break;
|
||||||
|
case 504:
|
||||||
|
message = 'errors.statusGatewayTimeout';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (session.isLoggedIn() && response?.status === 401) {
|
||||||
session.destroy(false);
|
session.destroy(false);
|
||||||
const hash = window.location.hash;
|
const hash = window.location.hash;
|
||||||
const url = hash.slice(1);
|
const url = hash.slice(1);
|
||||||
|
@ -48,6 +78,8 @@ const onResponseError = (error) => {
|
||||||
return Promise.reject(error);
|
return Promise.reject(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
notify(message, 'negative');
|
||||||
|
|
||||||
return Promise.reject(error);
|
return Promise.reject(error);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -3,51 +3,14 @@ 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 = (error) => {
|
app.config.errorHandler = function (err) {
|
||||||
let message;
|
console.error(err);
|
||||||
const response = error.response;
|
notify('globals.error', 'negative', 'error');
|
||||||
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');
|
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
|
@ -108,11 +108,11 @@ watch(
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => postcodeFormData.provinceFk,
|
() => postcodeFormData.provinceFk,
|
||||||
async (newProvinceFk) => {
|
async (newProvinceFk, oldValueFk) => {
|
||||||
if (Array.isArray(newProvinceFk)) {
|
if (Array.isArray(newProvinceFk)) {
|
||||||
newProvinceFk = newProvinceFk[0];
|
newProvinceFk = newProvinceFk[0];
|
||||||
}
|
}
|
||||||
if (newProvinceFk !== postcodeFormData.provinceFk) {
|
if (newProvinceFk !== oldValueFk) {
|
||||||
await townsFetchDataRef.value.fetch({
|
await townsFetchDataRef.value.fetch({
|
||||||
where: { provinceFk: newProvinceFk },
|
where: { provinceFk: newProvinceFk },
|
||||||
});
|
});
|
||||||
|
@ -147,13 +147,7 @@ async function handleCountries(data) {
|
||||||
auto-load
|
auto-load
|
||||||
url="Towns/location"
|
url="Towns/location"
|
||||||
/>
|
/>
|
||||||
<FetchData
|
|
||||||
@on-fetch="handleCountries"
|
|
||||||
:sort-by="['name ASC']"
|
|
||||||
:limit="30"
|
|
||||||
auto-load
|
|
||||||
url="Countries"
|
|
||||||
/>
|
|
||||||
<FormModelPopup
|
<FormModelPopup
|
||||||
url-create="postcodes"
|
url-create="postcodes"
|
||||||
model="postcode"
|
model="postcode"
|
||||||
|
@ -219,8 +213,10 @@ async function handleCountries(data) {
|
||||||
@on-province-created="onProvinceCreated"
|
@on-province-created="onProvinceCreated"
|
||||||
/>
|
/>
|
||||||
<VnSelect
|
<VnSelect
|
||||||
|
url="Countries"
|
||||||
|
:sort-by="['name ASC']"
|
||||||
:label="t('Country')"
|
:label="t('Country')"
|
||||||
:options="countriesOptions"
|
@update:options="handleCountries"
|
||||||
hide-selected
|
hide-selected
|
||||||
option-label="name"
|
option-label="name"
|
||||||
option-value="id"
|
option-value="id"
|
||||||
|
|
|
@ -217,6 +217,9 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,7 +61,6 @@ 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')"
|
||||||
|
@ -71,7 +70,6 @@ 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>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref } from 'vue';
|
import { ref, watch } from 'vue';
|
||||||
import { useValidator } from 'src/composables/useValidator';
|
import { useValidator } from 'src/composables/useValidator';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
|
|
||||||
|
|
|
@ -46,9 +46,13 @@ const columns = computed(() => [
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const deleteAlias = async (row) => {
|
const deleteAlias = async (row) => {
|
||||||
await axios.delete(`${urlPath.value}/${row.id}`);
|
try {
|
||||||
notify(t('User removed'), 'positive');
|
await axios.delete(`${urlPath.value}/${row.id}`);
|
||||||
fetchAliases();
|
notify(t('User removed'), 'positive');
|
||||||
|
fetchAliases();
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
|
|
|
@ -61,15 +61,23 @@ const fetchAccountExistence = async () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const deleteMailAlias = async (row) => {
|
const deleteMailAlias = async (row) => {
|
||||||
await axios.delete(`${urlPath}/${row.id}`);
|
try {
|
||||||
fetchMailAliases();
|
await axios.delete(`${urlPath}/${row.id}`);
|
||||||
notify(t('Unsubscribed from alias!'), 'positive');
|
fetchMailAliases();
|
||||||
|
notify(t('Unsubscribed from alias!'), 'positive');
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const createMailAlias = async (mailAliasFormData) => {
|
const createMailAlias = async (mailAliasFormData) => {
|
||||||
await axios.post(urlPath, mailAliasFormData);
|
try {
|
||||||
notify(t('Subscribed to alias!'), 'positive');
|
await axios.post(urlPath, mailAliasFormData);
|
||||||
fetchMailAliases();
|
notify(t('Subscribed to alias!'), 'positive');
|
||||||
|
fetchMailAliases();
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const fetchMailAliases = async () => {
|
const fetchMailAliases = async () => {
|
||||||
|
|
|
@ -46,15 +46,29 @@ const columns = computed(() => [
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const deleteSubRole = async (row) => {
|
const deleteSubRole = async (row) => {
|
||||||
await axios.delete(`${urlPath.value}/${row.id}`);
|
try {
|
||||||
fetchSubRoles();
|
await axios.delete(`${urlPath.value}/${row.id}`);
|
||||||
notify(t('Role removed. Changes will take a while to fully propagate.'), 'positive');
|
fetchSubRoles();
|
||||||
|
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) => {
|
||||||
await axios.post(urlPath.value, subRoleFormData);
|
try {
|
||||||
notify(t('Role added! Changes will take a while to fully propagate.'), 'positive');
|
await axios.post(urlPath.value, subRoleFormData);
|
||||||
fetchSubRoles();
|
notify(
|
||||||
|
t('Role added! Changes will take a while to fully propagate.'),
|
||||||
|
'positive'
|
||||||
|
);
|
||||||
|
fetchSubRoles();
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
|
|
|
@ -258,28 +258,15 @@ 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"
|
||||||
:params="{ departmentCodes: ['shopping'] }"
|
:where="{ role: 'buyer' }"
|
||||||
:fields="['id', 'nickname']"
|
sort-by="id"
|
||||||
sort-by="nickname ASC"
|
url="Workers"
|
||||||
hide-selected
|
hide-selected
|
||||||
option-label="nickname"
|
option-label="firstName"
|
||||||
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 }">
|
||||||
|
|
|
@ -52,27 +52,15 @@ const redirectToItemTypeBasicData = (_, { id }) => {
|
||||||
</VnRow>
|
</VnRow>
|
||||||
<VnRow>
|
<VnRow>
|
||||||
<VnSelect
|
<VnSelect
|
||||||
url="Workers/search"
|
|
||||||
v-model="data.workerFk"
|
v-model="data.workerFk"
|
||||||
:label="t('shared.worker')"
|
:label="t('itemType.shared.worker')"
|
||||||
sort-by="nickname ASC"
|
url="Workers"
|
||||||
:fields="['id', 'nickname']"
|
sort-by="firstName ASC"
|
||||||
:params="{ departmentCodes: ['shopping'] }"
|
:fields="['id', 'firstName']"
|
||||||
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')"
|
||||||
|
|
|
@ -41,27 +41,15 @@ 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')"
|
||||||
sort-by="nickname ASC"
|
url="Workers"
|
||||||
:fields="['id', 'nickname']"
|
sort-by="firstName ASC"
|
||||||
:params="{ departmentCodes: ['shopping'] }"
|
:fields="['id', 'firstName']"
|
||||||
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')"
|
||||||
|
|
|
@ -112,20 +112,32 @@ const getShipped = async (params) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const onChangeZone = async (zoneId) => {
|
const onChangeZone = async (zoneId) => {
|
||||||
formData.value.agencyModeFk = null;
|
try {
|
||||||
const { data } = await axios.get(`Zones/${zoneId}`);
|
formData.value.agencyModeFk = null;
|
||||||
formData.value.agencyModeFk = data.agencyModeFk;
|
const { data } = await axios.get(`Zones/${zoneId}`);
|
||||||
|
formData.value.agencyModeFk = data.agencyModeFk;
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const onChangeAddress = async (addressId) => {
|
const onChangeAddress = async (addressId) => {
|
||||||
formData.value.nickname = null;
|
try {
|
||||||
const { data } = await axios.get(`Addresses/${addressId}`);
|
formData.value.nickname = null;
|
||||||
formData.value.nickname = data.nickname;
|
const { data } = await axios.get(`Addresses/${addressId}`);
|
||||||
|
formData.value.nickname = data.nickname;
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const getClientDefaultAddress = async (clientId) => {
|
const getClientDefaultAddress = async (clientId) => {
|
||||||
const { data } = await axios.get(`Clients/${clientId}`);
|
try {
|
||||||
if (data) addressId.value = data.defaultAddressFk;
|
const { data } = await axios.get(`Clients/${clientId}`);
|
||||||
|
if (data) addressId.value = data.defaultAddressFk;
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const clientAddressesList = async (value) => {
|
const clientAddressesList = async (value) => {
|
||||||
|
|
|
@ -70,51 +70,60 @@ const isFormInvalid = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const getPriceDifference = async () => {
|
const getPriceDifference = async () => {
|
||||||
const params = {
|
try {
|
||||||
landed: formData.value.landed,
|
const params = {
|
||||||
addressId: formData.value.addressFk,
|
landed: formData.value.landed,
|
||||||
agencyModeId: formData.value.agencyModeFk,
|
addressId: formData.value.addressFk,
|
||||||
zoneId: formData.value.zoneFk,
|
agencyModeId: formData.value.agencyModeFk,
|
||||||
warehouseId: formData.value.warehouseFk,
|
zoneId: formData.value.zoneFk,
|
||||||
shipped: formData.value.shipped,
|
warehouseId: formData.value.warehouseFk,
|
||||||
};
|
shipped: formData.value.shipped,
|
||||||
const { data } = await axios.post(
|
};
|
||||||
`tickets/${formData.value.id}/priceDifference`,
|
const { data } = await axios.post(
|
||||||
params
|
`tickets/${formData.value.id}/priceDifference`,
|
||||||
);
|
params
|
||||||
formData.value.sale = data;
|
);
|
||||||
|
formData.value.sale = data;
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const submit = async () => {
|
const submit = async () => {
|
||||||
if (!formData.value.option) return notify(t('basicData.chooseAnOption'), 'negative');
|
try {
|
||||||
|
if (!formData.value.option)
|
||||||
|
return notify(t('basicData.chooseAnOption'), 'negative');
|
||||||
|
|
||||||
const params = {
|
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 () => {
|
||||||
|
|
|
@ -34,20 +34,26 @@ const newTicketFormData = reactive({});
|
||||||
const date = new Date();
|
const date = new Date();
|
||||||
|
|
||||||
const createTicket = async () => {
|
const createTicket = async () => {
|
||||||
const expeditionIds = $props.selectedExpeditions.map((expedition) => expedition.id);
|
try {
|
||||||
const params = {
|
const expeditionIds = $props.selectedExpeditions.map(
|
||||||
clientId: $props.ticket.clientFk,
|
(expedition) => expedition.id
|
||||||
landed: newTicketFormData.landed,
|
);
|
||||||
warehouseId: $props.ticket.warehouseFk,
|
const params = {
|
||||||
addressId: $props.ticket.addressFk,
|
clientId: $props.ticket.clientFk,
|
||||||
agencyModeId: $props.ticket.agencyModeFk,
|
landed: newTicketFormData.landed,
|
||||||
routeId: newTicketFormData.routeFk,
|
warehouseId: $props.ticket.warehouseFk,
|
||||||
expeditionIds: expeditionIds,
|
addressId: $props.ticket.addressFk,
|
||||||
};
|
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>
|
||||||
|
|
||||||
|
|
|
@ -150,19 +150,31 @@ const getTotal = computed(() => {
|
||||||
});
|
});
|
||||||
|
|
||||||
const getComponentsSum = async () => {
|
const getComponentsSum = async () => {
|
||||||
const { data } = await axios.get(`Tickets/${route.params.id}/getComponentsSum`);
|
try {
|
||||||
componentsList.value = data;
|
const { data } = await axios.get(`Tickets/${route.params.id}/getComponentsSum`);
|
||||||
|
componentsList.value = data;
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const getTheoricalCost = async () => {
|
const getTheoricalCost = async () => {
|
||||||
const { data } = await axios.get(`Tickets/${route.params.id}/freightCost`);
|
try {
|
||||||
theoricalCost.value = data;
|
const { data } = await axios.get(`Tickets/${route.params.id}/freightCost`);
|
||||||
|
theoricalCost.value = data;
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const getTicketVolume = async () => {
|
const getTicketVolume = async () => {
|
||||||
if (!ticketData.value) return;
|
try {
|
||||||
const { data } = await axios.get(`Tickets/${ticketData.value.id}/getVolume`);
|
if (!ticketData.value) return;
|
||||||
ticketVolume.value = data[0].volume;
|
const { data } = await axios.get(`Tickets/${ticketData.value.id}/getVolume`);
|
||||||
|
ticketVolume.value = data[0].volume;
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
|
|
@ -163,12 +163,16 @@ const showNewTicketDialog = (withRoute = false) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const deleteExpedition = async () => {
|
const deleteExpedition = async () => {
|
||||||
const expeditionIds = selectedRows.value.map((expedition) => expedition.id);
|
try {
|
||||||
const params = { expeditionIds };
|
const expeditionIds = selectedRows.value.map((expedition) => expedition.id);
|
||||||
await axios.post('Expeditions/deleteExpeditions', params);
|
const params = { expeditionIds };
|
||||||
vnTableRef.value.reload();
|
await axios.post('Expeditions/deleteExpeditions', params);
|
||||||
selectedExpeditions.value = [];
|
vnTableRef.value.reload();
|
||||||
notify(t('expedition.expeditionRemoved'), 'positive');
|
selectedExpeditions.value = [];
|
||||||
|
notify(t('expedition.expeditionRemoved'), 'positive');
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const showLog = async (expedition) => {
|
const showLog = async (expedition) => {
|
||||||
|
@ -177,19 +181,23 @@ const showLog = async (expedition) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const getExpeditionState = async (expedition) => {
|
const getExpeditionState = async (expedition) => {
|
||||||
const filter = {
|
try {
|
||||||
where: { expeditionFk: expedition.id },
|
const filter = {
|
||||||
order: ['created DESC'],
|
where: { expeditionFk: expedition.id },
|
||||||
};
|
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) },
|
||||||
});
|
});
|
||||||
|
|
||||||
expeditionsLogsData.value = expeditionStates.map((state) => ({
|
expeditionsLogsData.value = expeditionStates.map((state) => ({
|
||||||
...state,
|
...state,
|
||||||
isScanned: !!state.isScanned,
|
isScanned: !!state.isScanned,
|
||||||
}));
|
}));
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
|
|
|
@ -165,10 +165,14 @@ const createRefund = async (withWarehouse) => {
|
||||||
negative: true,
|
negative: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
const { data } = await axios.post('Tickets/cloneAll', params);
|
try {
|
||||||
const [refundTicket] = data;
|
const { data } = await axios.post('Tickets/cloneAll', params);
|
||||||
notify(t('refundTicketCreated', { ticketId: refundTicket.id }), 'positive');
|
const [refundTicket] = data;
|
||||||
push({ name: 'TicketSale', params: { id: refundTicket.id } });
|
notify(t('refundTicketCreated', { ticketId: refundTicket.id }), 'positive');
|
||||||
|
push({ name: 'TicketSale', params: { id: refundTicket.id } });
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -150,14 +150,18 @@ const shelvingsTableColumns = computed(() => [
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const getSaleTrackings = async (sale) => {
|
const getSaleTrackings = async (sale) => {
|
||||||
const filter = {
|
try {
|
||||||
where: { saleFk: sale.saleFk },
|
const filter = {
|
||||||
order: ['itemFk DESC'],
|
where: { saleFk: sale.saleFk },
|
||||||
};
|
order: ['itemFk DESC'],
|
||||||
const { data } = await axios.get(`SaleTrackings/listSaleTracking`, {
|
};
|
||||||
params: { filter: JSON.stringify(filter) },
|
const { data } = await axios.get(`SaleTrackings/listSaleTracking`, {
|
||||||
});
|
params: { filter: JSON.stringify(filter) },
|
||||||
saleTrackings.value = data;
|
});
|
||||||
|
saleTrackings.value = data;
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const showLog = async (sale) => {
|
const showLog = async (sale) => {
|
||||||
|
@ -166,13 +170,17 @@ const showLog = async (sale) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const getItemShelvingSales = async (sale) => {
|
const getItemShelvingSales = async (sale) => {
|
||||||
const filter = {
|
try {
|
||||||
where: { saleFk: sale.saleFk },
|
const filter = {
|
||||||
};
|
where: { saleFk: sale.saleFk },
|
||||||
const { data } = await axios.get(`ItemShelvingSales/filter`, {
|
};
|
||||||
params: { filter: JSON.stringify(filter) },
|
const { data } = await axios.get(`ItemShelvingSales/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) => {
|
||||||
|
@ -181,28 +189,36 @@ const showShelving = async (sale) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const updateQuantity = async (sale) => {
|
const updateQuantity = async (sale) => {
|
||||||
if (oldQuantity.value === sale.quantity) return;
|
try {
|
||||||
const params = {
|
if (oldQuantity.value === sale.quantity) return;
|
||||||
quantity: sale.quantity,
|
const params = {
|
||||||
};
|
quantity: sale.quantity,
|
||||||
await axios.patch(`ItemShelvingSales/${sale.id}`, params);
|
};
|
||||||
oldQuantity.value = null;
|
await axios.patch(`ItemShelvingSales/${sale.id}`, params);
|
||||||
|
oldQuantity.value = null;
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const updateParking = async (sale) => {
|
const updateParking = async (sale) => {
|
||||||
const filter = {
|
try {
|
||||||
fields: ['id'],
|
const filter = {
|
||||||
where: {
|
fields: ['id'],
|
||||||
code: sale.shelvingFk,
|
where: {
|
||||||
},
|
code: sale.shelvingFk,
|
||||||
};
|
},
|
||||||
const { data } = await axios.get(`Shelvings/findOne`, {
|
};
|
||||||
params: { filter: JSON.stringify(filter) },
|
const { data } = await axios.get(`Shelvings/findOne`, {
|
||||||
});
|
params: { filter: JSON.stringify(filter) },
|
||||||
const params = {
|
});
|
||||||
parkingFk: sale.parkingFk,
|
const params = {
|
||||||
};
|
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) => {
|
||||||
|
@ -225,41 +241,61 @@ const updateShelving = async (sale) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const saleTrackingNew = async (sale, stateCode, isChecked) => {
|
const saleTrackingNew = async (sale, stateCode, isChecked) => {
|
||||||
const params = {
|
try {
|
||||||
saleFk: sale.saleFk,
|
const params = {
|
||||||
isChecked,
|
saleFk: sale.saleFk,
|
||||||
quantity: sale.quantity,
|
isChecked,
|
||||||
stateCode,
|
quantity: sale.quantity,
|
||||||
};
|
stateCode,
|
||||||
await axios.post(`SaleTrackings/new`, params);
|
};
|
||||||
notify(t('globals.dataSaved'), 'positive');
|
await axios.post(`SaleTrackings/new`, params);
|
||||||
|
notify(t('globals.dataSaved'), 'positive');
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const saleTrackingDel = async ({ saleFk }, stateCode) => {
|
const saleTrackingDel = async ({ saleFk }, stateCode) => {
|
||||||
const params = {
|
try {
|
||||||
saleFk,
|
const params = {
|
||||||
stateCodes: [stateCode],
|
saleFk,
|
||||||
};
|
stateCodes: [stateCode],
|
||||||
await axios.post(`SaleTrackings/delete`, params);
|
};
|
||||||
notify(t('globals.dataSaved'), 'positive');
|
await axios.post(`SaleTrackings/delete`, params);
|
||||||
|
notify(t('globals.dataSaved'), 'positive');
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const clickSaleGroupDetail = async (sale) => {
|
const clickSaleGroupDetail = async (sale) => {
|
||||||
if (!sale.saleGroupDetailFk) return;
|
try {
|
||||||
|
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) => {
|
||||||
qCheckBoxController(sale, 'isPreviousSelected');
|
try {
|
||||||
if (!sale.isPreviousSelected) sale.isPrevious = false;
|
qCheckBoxController(sale, 'isPreviousSelected');
|
||||||
|
if (!sale.isPreviousSelected) sale.isPrevious = false;
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const clickPrevious = (sale) => {
|
const clickPrevious = (sale) => {
|
||||||
qCheckBoxController(sale, 'isPrevious');
|
try {
|
||||||
if (sale.isPrevious) sale.isPreviousSelected = true;
|
qCheckBoxController(sale, 'isPrevious');
|
||||||
|
if (sale.isPrevious) sale.isPreviousSelected = true;
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const qCheckBoxController = (sale, action) => {
|
const qCheckBoxController = (sale, action) => {
|
||||||
|
@ -270,12 +306,16 @@ const qCheckBoxController = (sale, action) => {
|
||||||
isPreviousSelected: 'PREVIOUS_PREPARATION',
|
isPreviousSelected: 'PREVIOUS_PREPARATION',
|
||||||
};
|
};
|
||||||
const stateCode = STATE_CODES[action];
|
const stateCode = STATE_CODES[action];
|
||||||
if (!sale[action]) {
|
try {
|
||||||
saleTrackingNew(sale, stateCode, true);
|
if (!sale[action]) {
|
||||||
sale[action] = true;
|
saleTrackingNew(sale, stateCode, true);
|
||||||
} else {
|
sale[action] = true;
|
||||||
saleTrackingDel(sale, stateCode);
|
} else {
|
||||||
sale[action] = false;
|
saleTrackingDel(sale, stateCode);
|
||||||
|
sale[action] = false;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -46,32 +46,40 @@ watch(
|
||||||
onMounted(async () => await getDefaultTaxClass());
|
onMounted(async () => await getDefaultTaxClass());
|
||||||
|
|
||||||
const createRefund = async () => {
|
const createRefund = async () => {
|
||||||
if (!selected.value.length) return;
|
try {
|
||||||
|
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 () => {
|
||||||
let filter = {
|
try {
|
||||||
where: { code: 'G' },
|
let filter = {
|
||||||
};
|
where: { code: 'G' },
|
||||||
const { data } = await axios.get('TaxClasses/findOne', {
|
};
|
||||||
params: { filter: JSON.stringify(filter) },
|
const { data } = await axios.get('TaxClasses/findOne', {
|
||||||
});
|
params: { filter: JSON.stringify(filter) },
|
||||||
defaultTaxClass.value = data;
|
});
|
||||||
|
defaultTaxClass.value = data;
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const columns = computed(() => [
|
const columns = computed(() => [
|
||||||
|
|
|
@ -75,18 +75,22 @@ const columns = computed(() => [
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const applyVolumes = async (salesData) => {
|
const applyVolumes = async (salesData) => {
|
||||||
if (!salesData.length) return;
|
try {
|
||||||
|
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));
|
||||||
|
|
|
@ -27,16 +27,20 @@ const warehousesOptions = ref([]);
|
||||||
const itemPackingTypes = ref([]);
|
const itemPackingTypes = ref([]);
|
||||||
|
|
||||||
const getItemPackingTypes = async () => {
|
const getItemPackingTypes = async () => {
|
||||||
const filter = {
|
try {
|
||||||
where: { isActive: true },
|
const filter = {
|
||||||
};
|
where: { isActive: true },
|
||||||
const { data } = await axios.get('ItemPackingTypes', {
|
};
|
||||||
params: { filter: JSON.stringify(filter) },
|
const { data } = await axios.get('ItemPackingTypes', {
|
||||||
});
|
params: { filter: JSON.stringify(filter) },
|
||||||
itemPackingTypes.value = data.map((ipt) => ({
|
});
|
||||||
description: t(ipt.description),
|
itemPackingTypes.value = data.map((ipt) => ({
|
||||||
code: ipt.code,
|
description: t(ipt.description),
|
||||||
}));
|
code: ipt.code,
|
||||||
|
}));
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const getLocale = (val) => {
|
const getLocale = (val) => {
|
||||||
|
|
|
@ -24,25 +24,33 @@ const itemPackingTypes = ref([]);
|
||||||
const stateOptions = ref([]);
|
const stateOptions = ref([]);
|
||||||
|
|
||||||
const getItemPackingTypes = async () => {
|
const getItemPackingTypes = async () => {
|
||||||
const filter = {
|
try {
|
||||||
where: { isActive: true },
|
const filter = {
|
||||||
};
|
where: { isActive: true },
|
||||||
const { data } = await axios.get('ItemPackingTypes', {
|
};
|
||||||
params: { filter: JSON.stringify(filter) },
|
const { data } = await axios.get('ItemPackingTypes', {
|
||||||
});
|
params: { filter: JSON.stringify(filter) },
|
||||||
itemPackingTypes.value = data.map((ipt) => ({
|
});
|
||||||
description: t(ipt.description),
|
itemPackingTypes.value = data.map((ipt) => ({
|
||||||
code: ipt.code,
|
description: t(ipt.description),
|
||||||
}));
|
code: ipt.code,
|
||||||
|
}));
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const getGroupedStates = async () => {
|
const getGroupedStates = async () => {
|
||||||
const { data } = await axios.get('AlertLevels');
|
try {
|
||||||
stateOptions.value = data.map((state) => ({
|
const { data } = await axios.get('AlertLevels');
|
||||||
id: state.id,
|
stateOptions.value = data.map((state) => ({
|
||||||
name: t(`futureTickets.${state.code}`),
|
id: state.id,
|
||||||
code: state.code,
|
name: t(`futureTickets.${state.code}`),
|
||||||
}));
|
code: state.code,
|
||||||
|
}));
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
|
|
|
@ -44,9 +44,8 @@ async function toggleNotification(notification) {
|
||||||
`worker.notificationsManager.${notification.active ? '' : 'un'}subscribed`
|
`worker.notificationsManager.${notification.active ? '' : 'un'}subscribed`
|
||||||
),
|
),
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch {
|
||||||
notification.active = !notification.active;
|
notification.active = !notification.active;
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,13 +34,21 @@ const columns = computed(() => [
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const deleteWarehouse = async (row) => {
|
const deleteWarehouse = async (row) => {
|
||||||
await axios.delete(`${urlPath.value}/${row.id}`);
|
try {
|
||||||
fetchWarehouses();
|
await axios.delete(`${urlPath.value}/${row.id}`);
|
||||||
|
fetchWarehouses();
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const createZoneWarehouse = async (ZoneWarehouseFormData) => {
|
const createZoneWarehouse = async (ZoneWarehouseFormData) => {
|
||||||
await axios.post(urlPath.value, ZoneWarehouseFormData);
|
try {
|
||||||
fetchWarehouses();
|
await axios.post(urlPath.value, ZoneWarehouseFormData);
|
||||||
|
fetchWarehouses();
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
|
|
|
@ -13,7 +13,7 @@ describe('Logout', () => {
|
||||||
});
|
});
|
||||||
describe('not user', () => {
|
describe('not user', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
cy.intercept('GET', '**DefaultViewConfigs**', {
|
cy.intercept('GET', '**/VnUsers/acl', {
|
||||||
statusCode: 401,
|
statusCode: 401,
|
||||||
body: {
|
body: {
|
||||||
error: {
|
error: {
|
||||||
|
@ -24,11 +24,10 @@ describe('Logout', () => {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
statusMessage: 'AUTHORIZATION_REQUIRED',
|
statusMessage: 'AUTHORIZATION_REQUIRED',
|
||||||
});
|
}).as('someRoute');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('when token not exists', () => {
|
it('when token not exists', () => {
|
||||||
cy.get('.q-list > [href="#/item"]').click();
|
cy.reload();
|
||||||
cy.get('.q-notification__message').should(
|
cy.get('.q-notification__message').should(
|
||||||
'have.text',
|
'have.text',
|
||||||
'Authorization Required'
|
'Authorization Required'
|
||||||
|
|
|
@ -7,20 +7,31 @@ 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('check workCenter crud', () => {
|
it('assign workCenter', () => {
|
||||||
// create
|
|
||||||
cy.get(createButton).click();
|
cy.get(createButton).click();
|
||||||
cy.get(workCenterCombobox).type('workCenterOne{enter}');
|
cy.get(workCenterCombobox).type('workCenterOne{enter}');
|
||||||
cy.hasNotify('Data created');
|
cy.get('.q-notification__message').should('have.text', 'Data created');
|
||||||
|
});
|
||||||
|
|
||||||
// expect error when duplicate
|
it('delete workCenter', () => {
|
||||||
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.hasNotify('WorkCenter removed successfully');
|
cy.get('.q-notification__message').should(
|
||||||
|
'have.text',
|
||||||
|
'WorkCenter removed successfully'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('error on duplicate workCenter', () => {
|
||||||
|
cy.get(createButton).click();
|
||||||
|
cy.get(workCenterCombobox).type('workCenterOne{enter}');
|
||||||
|
cy.get('.q-notification__message').should('have.text', 'Data created');
|
||||||
|
cy.get(createButton).click();
|
||||||
|
cy.get(
|
||||||
|
'.vn-row > .q-field > .q-field__inner > .q-field__control > .q-field__control-container'
|
||||||
|
).type('workCenterOne{enter}');
|
||||||
|
|
||||||
|
cy.get(
|
||||||
|
':nth-child(2) > .q-notification__wrapper > .q-notification__content > .q-notification__message'
|
||||||
|
).should('have.text', 'This workCenter is already assigned to this agency');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -17,7 +17,10 @@ describe('WorkerNotificationsManager', () => {
|
||||||
cy.login('developer');
|
cy.login('developer');
|
||||||
cy.visit(`/#/worker/${salesPersonId}/notifications`);
|
cy.visit(`/#/worker/${salesPersonId}/notifications`);
|
||||||
cy.get(firstAvailableNotification).click();
|
cy.get(firstAvailableNotification).click();
|
||||||
cy.hasNotify('The notification subscription of this worker cant be modified');
|
cy.notificationHas(
|
||||||
|
'.q-notification__message',
|
||||||
|
'The notification subscription of this worker cant be modified'
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should active a notification that is yours', () => {
|
it('should active a notification that is yours', () => {
|
||||||
|
|
|
@ -262,14 +262,3 @@ Cypress.Commands.add('openUserPanel', () => {
|
||||||
'.column > .q-avatar > .q-avatar__content > .q-img > .q-img__container > .q-img__image'
|
'.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}"`);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
|
@ -36,6 +36,8 @@ 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,
|
||||||
|
@ -43,10 +45,19 @@ 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,
|
||||||
|
@ -59,7 +70,14 @@ 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',
|
||||||
|
})
|
||||||
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue