Compare commits
91 Commits
095c1f477f
...
5dd508c559
Author | SHA1 | Date |
---|---|---|
Carlos Satorres | 5dd508c559 | |
Javier Segarra | ec96f6bea7 | |
Alex Moreno | ee2450c82f | |
Alex Moreno | 655a76ff62 | |
Alex Moreno | fbd57dc96b | |
Jon Elias | 843c54fcc1 | |
Alex Moreno | 8e7cb9c46e | |
Javier Segarra | a99f64f66a | |
Jon Elias | f3429297cf | |
Javier Segarra | 3e06ba3c18 | |
Jon Elias | d191d88e81 | |
Javier Segarra | caca9aea71 | |
Jorge Penadés | 6c30ea9e7a | |
Jorge Penadés | e994ae72b6 | |
Jorge Penadés | a1284cefc2 | |
Jon Elias | c558636799 | |
Jorge Penadés | a3f56aaf24 | |
Jon Elias | 1dedf00fef | |
Jon Elias | a1aa9337c8 | |
Javier Segarra | b8ac82bc75 | |
Alex Moreno | e10e0d01e6 | |
Javier Segarra | feb752f75c | |
Javier Segarra | fb4de9cda9 | |
Jorge Penadés | 8b52629b0b | |
Jorge Penadés | 3a4c0e729a | |
Jorge Penadés | 9d8698fa2f | |
Jorge Penadés | 661cc0b5ee | |
Alex Moreno | 01ffb663f1 | |
Jorge Penadés | 0eeb22d40a | |
Jorge Penadés | 7048f96565 | |
Jorge Penadés | 50fbf64cf9 | |
Jorge Penadés | c72fa52851 | |
Alex Moreno | 6276843613 | |
Alex Moreno | 14d2ddfa83 | |
Alex Moreno | ef426dc579 | |
Alex Moreno | 4913cf2c29 | |
Javier Segarra | 651b67e98f | |
Alex Moreno | 94361f18fa | |
Alex Moreno | 142302193e | |
Alex Moreno | 9d7f2b95e8 | |
Alex Moreno | 2db0369b74 | |
Alex Moreno | 1709795cf9 | |
Alex Moreno | 26c1394321 | |
Alex Moreno | 367f660508 | |
Alex Moreno | 9019d4ff90 | |
Alex Moreno | 522f32aa9a | |
Jorge Penadés | 55f9023201 | |
Jorge Penadés | d1055ad572 | |
Alex Moreno | bf29be1c5f | |
Alex Moreno | 8cbf40f465 | |
Alex Moreno | 3b03f0dfee | |
Carlos Andrés | 6c866e48a0 | |
Carlos Andrés | e04d77f55e | |
Carlos Andrés | 5268140d8b | |
Carlos Andrés | 977512cae0 | |
Carlos Andrés | 242bf6f318 | |
Carlos Satorres | 69498cccf9 | |
Carlos Satorres | 518ed40c91 | |
Carlos Satorres | 8a972507a4 | |
Carlos Satorres | 837f42d21f | |
Carlos Andrés | 087ec5f39f | |
Jorge Penadés | 9632fb7c75 | |
Jorge Penadés | 43f94ede64 | |
Carlos Andrés | c21785b1f6 | |
Carlos Andrés | 16133faca7 | |
Jorge Penadés | ad93e16896 | |
Jorge Penadés | 0274dfcef2 | |
Carlos Andrés | 317e9ad034 | |
Jorge Penadés | 9665a3407f | |
Jorge Penadés | 85aeda337f | |
Carlos Andrés | 5da6e9b2ca | |
Carlos Andrés | 8c20b8736b | |
Javier Segarra | 4116f681b0 | |
Javier Segarra | 95758e2564 | |
Javier Segarra | 8e37d22164 | |
Javier Segarra | 69e6f0f467 | |
Javier Segarra | e8ad185873 | |
Javier Segarra | 69a2eae542 | |
Javier Segarra | 1a0a2d9442 | |
Javier Segarra | c7c9c13944 | |
Javier Segarra | 703aaa1f38 | |
Alex Moreno | 9ac3316567 | |
Jorge Penadés | 4572817699 | |
Carlos Andrés | b460a0be2f | |
Carlos Andrés | 18593cc3f9 | |
Carlos Andrés | 4a0c15ed90 | |
Carlos Andrés | e9fad1a44e | |
Carlos Andrés | fc73149dcf | |
Jorge Penadés | 53399c8f74 | |
Jorge Penadés | 4e5a4ae7a3 | |
Jorge Penadés | fb7087d38a |
|
@ -1,4 +1,7 @@
|
|||
const { defineConfig } = require('cypress');
|
||||
// https://docs.cypress.io/app/tooling/reporters
|
||||
// https://docs.cypress.io/app/references/configuration
|
||||
// https://www.npmjs.com/package/cypress-mochawesome-reporter
|
||||
|
||||
module.exports = defineConfig({
|
||||
e2e: {
|
||||
|
@ -16,6 +19,7 @@ module.exports = defineConfig({
|
|||
reporterOptions: {
|
||||
charts: true,
|
||||
reportPageTitle: 'Cypress Inline Reporter',
|
||||
reportFilename: '[status]_[datetime]-report',
|
||||
embeddedScreenshots: true,
|
||||
reportDir: 'test/cypress/reports',
|
||||
inlineAssets: true,
|
||||
|
|
|
@ -17,10 +17,6 @@ const $props = defineProps({
|
|||
type: Number,
|
||||
default: null,
|
||||
},
|
||||
provinces: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
});
|
||||
const { t } = useI18n();
|
||||
|
||||
|
@ -56,7 +52,6 @@ const onDataSaved = (...args) => {
|
|||
:province-selected="$props.provinceSelected"
|
||||
:country-fk="$props.countryFk"
|
||||
v-model="data.provinceFk"
|
||||
:provinces="$props.provinces"
|
||||
/>
|
||||
</VnRow>
|
||||
</template>
|
||||
|
|
|
@ -56,10 +56,10 @@ async function onCityCreated(newTown, formData) {
|
|||
}
|
||||
|
||||
function setTown(newTown, data) {
|
||||
if (!newTown) return;
|
||||
town.value = newTown;
|
||||
data.provinceFk = newTown.provinceFk;
|
||||
data.countryFk = newTown.province.countryFk;
|
||||
if (!newTown) return;
|
||||
town.value = newTown;
|
||||
}
|
||||
|
||||
async function setProvince(id, data) {
|
||||
|
@ -73,7 +73,7 @@ async function onProvinceCreated(data) {
|
|||
await provincesFetchDataRef.value.fetch({
|
||||
where: { countryFk: postcodeFormData.countryFk },
|
||||
});
|
||||
postcodeFormData.provinceFk.value = data.id;
|
||||
postcodeFormData.provinceFk = data.id;
|
||||
}
|
||||
|
||||
watch(
|
||||
|
@ -90,22 +90,33 @@ watch(
|
|||
postcodeFormData.townFk = null;
|
||||
}
|
||||
if (oldValueFk !== newCountryFk) {
|
||||
await provincesFetchDataRef.value.fetch({
|
||||
where: {
|
||||
countryFk: newCountryFk,
|
||||
},
|
||||
});
|
||||
await townsFetchDataRef.value.fetch({
|
||||
where: {
|
||||
provinceFk: {
|
||||
inq: provincesOptions.value.map(({ id }) => id),
|
||||
},
|
||||
},
|
||||
});
|
||||
await fetchProvinces(newCountryFk);
|
||||
await fetchTowns(newCountryFk);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
async function fetchTowns(countryFk) {
|
||||
const townsFilter = countryFk
|
||||
? {
|
||||
where: {
|
||||
provinceFk: {
|
||||
inq: provincesOptions.value.map(({ id }) => id),
|
||||
},
|
||||
},
|
||||
}
|
||||
: {};
|
||||
await townsFetchDataRef.value.fetch(townsFilter);
|
||||
}
|
||||
async function fetchProvinces(countryFk) {
|
||||
const provincesFilter = countryFk
|
||||
? {
|
||||
where: {
|
||||
countryFk: countryFk,
|
||||
},
|
||||
}
|
||||
: {};
|
||||
await provincesFetchDataRef.value.fetch(provincesFilter);
|
||||
}
|
||||
watch(
|
||||
() => postcodeFormData.provinceFk,
|
||||
async (newProvinceFk, oldValueFk) => {
|
||||
|
@ -147,6 +158,13 @@ async function handleCountries(data) {
|
|||
auto-load
|
||||
url="Towns/location"
|
||||
/>
|
||||
<FetchData
|
||||
ref="CountriesFetchDataRef"
|
||||
:sort-by="['name ASC']"
|
||||
@on-fetch="handleCountries"
|
||||
auto-load
|
||||
url="Countries"
|
||||
/>
|
||||
|
||||
<FormModelPopup
|
||||
url-create="postcodes"
|
||||
|
@ -193,7 +211,6 @@ async function handleCountries(data) {
|
|||
<CreateNewCityForm
|
||||
:country-fk="data.countryFk"
|
||||
:province-selected="data.provinceFk"
|
||||
:provinces="provincesOptions"
|
||||
@on-data-saved="
|
||||
(_, requestResponse) =>
|
||||
onCityCreated(requestResponse, data)
|
||||
|
@ -209,14 +226,12 @@ async function handleCountries(data) {
|
|||
@update:model-value="(value) => setProvince(value, data)"
|
||||
v-model="data.provinceFk"
|
||||
:clearable="true"
|
||||
:provinces="provincesOptions"
|
||||
@on-province-created="onProvinceCreated"
|
||||
/>
|
||||
<VnSelect
|
||||
url="Countries"
|
||||
:sort-by="['name ASC']"
|
||||
:label="t('Country')"
|
||||
@update:options="handleCountries"
|
||||
:options="countriesOptions"
|
||||
hide-selected
|
||||
option-label="name"
|
||||
option-value="id"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<script setup>
|
||||
import { reactive, ref } from 'vue';
|
||||
import { computed, reactive, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
import FetchData from 'components/FetchData.vue';
|
||||
|
@ -34,6 +34,12 @@ const onDataSaved = (dataSaved, requestResponse) => {
|
|||
);
|
||||
emit('onDataSaved', dataSaved, requestResponse);
|
||||
};
|
||||
const where = computed(() => {
|
||||
if (!$props.countryFk) {
|
||||
return {};
|
||||
}
|
||||
return { countryFk: $props.countryFk };
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
@ -41,9 +47,7 @@ const onDataSaved = (dataSaved, requestResponse) => {
|
|||
@on-fetch="(data) => (autonomiesOptions = data)"
|
||||
auto-load
|
||||
:filter="{
|
||||
where: {
|
||||
countryFk: $props.countryFk,
|
||||
},
|
||||
where,
|
||||
}"
|
||||
url="Autonomies/location"
|
||||
:sort-by="['name ASC']"
|
||||
|
|
|
@ -156,26 +156,22 @@ const rotateRight = () => {
|
|||
};
|
||||
|
||||
const onSubmit = () => {
|
||||
try {
|
||||
if (!newPhoto.files && !newPhoto.url) {
|
||||
notify(t('Select an image'), 'negative');
|
||||
return;
|
||||
}
|
||||
|
||||
const options = {
|
||||
type: 'blob',
|
||||
};
|
||||
|
||||
editor.value
|
||||
.result(options)
|
||||
.then((result) => {
|
||||
const file = new File([result], newPhoto.files?.name || '');
|
||||
newPhoto.blob = file;
|
||||
})
|
||||
.then(() => makeRequest());
|
||||
} catch (err) {
|
||||
console.error('Error uploading image');
|
||||
if (!newPhoto.files && !newPhoto.url) {
|
||||
notify(t('Select an image'), 'negative');
|
||||
return;
|
||||
}
|
||||
|
||||
const options = {
|
||||
type: 'blob',
|
||||
};
|
||||
|
||||
editor.value
|
||||
.result(options)
|
||||
.then((result) => {
|
||||
const file = new File([result], newPhoto.files?.name || '');
|
||||
newPhoto.blob = file;
|
||||
})
|
||||
.then(() => makeRequest());
|
||||
};
|
||||
|
||||
const makeRequest = async () => {
|
||||
|
|
|
@ -51,21 +51,17 @@ const onDataSaved = () => {
|
|||
};
|
||||
|
||||
const onSubmit = async () => {
|
||||
try {
|
||||
isLoading.value = true;
|
||||
const rowsToEdit = $props.rows.map((row) => ({ id: row.id, itemFk: row.itemFk }));
|
||||
const payload = {
|
||||
field: selectedField.value.field,
|
||||
newValue: newValue.value,
|
||||
lines: rowsToEdit,
|
||||
};
|
||||
isLoading.value = true;
|
||||
const rowsToEdit = $props.rows.map((row) => ({ id: row.id, itemFk: row.itemFk }));
|
||||
const payload = {
|
||||
field: selectedField.value.field,
|
||||
newValue: newValue.value,
|
||||
lines: rowsToEdit,
|
||||
};
|
||||
|
||||
await axios.post($props.editUrl, payload);
|
||||
onDataSaved();
|
||||
isLoading.value = false;
|
||||
} catch (err) {
|
||||
console.error('Error submitting table cell edit');
|
||||
}
|
||||
await axios.post($props.editUrl, payload);
|
||||
onDataSaved();
|
||||
isLoading.value = false;
|
||||
};
|
||||
|
||||
const closeForm = () => {
|
||||
|
|
|
@ -84,34 +84,30 @@ const tableColumns = computed(() => [
|
|||
]);
|
||||
|
||||
const onSubmit = async () => {
|
||||
try {
|
||||
let filter = itemFilter;
|
||||
const params = itemFilterParams;
|
||||
const where = {};
|
||||
for (let key in params) {
|
||||
const value = params[key];
|
||||
if (!value) continue;
|
||||
let filter = itemFilter;
|
||||
const params = itemFilterParams;
|
||||
const where = {};
|
||||
for (let key in params) {
|
||||
const value = params[key];
|
||||
if (!value) continue;
|
||||
|
||||
switch (key) {
|
||||
case 'name':
|
||||
where[key] = { like: `%${value}%` };
|
||||
break;
|
||||
case 'producerFk':
|
||||
case 'typeFk':
|
||||
case 'size':
|
||||
case 'inkFk':
|
||||
where[key] = value;
|
||||
}
|
||||
switch (key) {
|
||||
case 'name':
|
||||
where[key] = { like: `%${value}%` };
|
||||
break;
|
||||
case 'producerFk':
|
||||
case 'typeFk':
|
||||
case 'size':
|
||||
case 'inkFk':
|
||||
where[key] = value;
|
||||
}
|
||||
filter.where = where;
|
||||
|
||||
const { data } = await axios.get(props.url, {
|
||||
params: { filter: JSON.stringify(filter) },
|
||||
});
|
||||
tableRows.value = data;
|
||||
} catch (err) {
|
||||
console.error('Error fetching entries items');
|
||||
}
|
||||
filter.where = where;
|
||||
|
||||
const { data } = await axios.get(props.url, {
|
||||
params: { filter: JSON.stringify(filter) },
|
||||
});
|
||||
tableRows.value = data;
|
||||
};
|
||||
|
||||
const closeForm = () => {
|
||||
|
|
|
@ -86,32 +86,28 @@ const tableColumns = computed(() => [
|
|||
]);
|
||||
|
||||
const onSubmit = async () => {
|
||||
try {
|
||||
let filter = travelFilter;
|
||||
const params = travelFilterParams;
|
||||
const where = {};
|
||||
for (let key in params) {
|
||||
const value = params[key];
|
||||
if (!value) continue;
|
||||
let filter = travelFilter;
|
||||
const params = travelFilterParams;
|
||||
const where = {};
|
||||
for (let key in params) {
|
||||
const value = params[key];
|
||||
if (!value) continue;
|
||||
|
||||
switch (key) {
|
||||
case 'agencyModeFk':
|
||||
case 'warehouseInFk':
|
||||
case 'warehouseOutFk':
|
||||
case 'shipped':
|
||||
case 'landed':
|
||||
where[key] = value;
|
||||
}
|
||||
switch (key) {
|
||||
case 'agencyModeFk':
|
||||
case 'warehouseInFk':
|
||||
case 'warehouseOutFk':
|
||||
case 'shipped':
|
||||
case 'landed':
|
||||
where[key] = value;
|
||||
}
|
||||
|
||||
filter.where = where;
|
||||
const { data } = await axios.get('Travels', {
|
||||
params: { filter: JSON.stringify(filter) },
|
||||
});
|
||||
tableRows.value = data;
|
||||
} catch (err) {
|
||||
console.error('Error fetching travels');
|
||||
}
|
||||
|
||||
filter.where = where;
|
||||
const { data } = await axios.get('Travels', {
|
||||
params: { filter: JSON.stringify(filter) },
|
||||
});
|
||||
tableRows.value = data;
|
||||
};
|
||||
|
||||
const closeForm = () => {
|
||||
|
|
|
@ -4,7 +4,7 @@ import { useI18n } from 'vue-i18n';
|
|||
|
||||
const emit = defineEmits(['onSubmit']);
|
||||
|
||||
defineProps({
|
||||
const $props = defineProps({
|
||||
title: {
|
||||
type: String,
|
||||
default: '',
|
||||
|
@ -25,16 +25,21 @@ defineProps({
|
|||
type: String,
|
||||
default: '',
|
||||
},
|
||||
submitOnEnter: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
});
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
const closeButton = ref(null);
|
||||
const isLoading = ref(false);
|
||||
|
||||
const onSubmit = () => {
|
||||
emit('onSubmit');
|
||||
closeForm();
|
||||
if ($props.submitOnEnter) {
|
||||
emit('onSubmit');
|
||||
closeForm();
|
||||
}
|
||||
};
|
||||
|
||||
const closeForm = () => {
|
||||
|
|
|
@ -88,20 +88,16 @@ const applyTags = (params, search) => {
|
|||
};
|
||||
|
||||
const fetchItemTypes = async (id) => {
|
||||
try {
|
||||
const filter = {
|
||||
fields: ['id', 'name', 'categoryFk'],
|
||||
where: { categoryFk: id },
|
||||
include: 'category',
|
||||
order: 'name ASC',
|
||||
};
|
||||
const { data } = await axios.get('ItemTypes', {
|
||||
params: { filter: JSON.stringify(filter) },
|
||||
});
|
||||
itemTypesOptions.value = data;
|
||||
} catch (err) {
|
||||
console.error('Error fetching item types', err);
|
||||
}
|
||||
const filter = {
|
||||
fields: ['id', 'name', 'categoryFk'],
|
||||
where: { categoryFk: id },
|
||||
include: 'category',
|
||||
order: 'name ASC',
|
||||
};
|
||||
const { data } = await axios.get('ItemTypes', {
|
||||
params: { filter: JSON.stringify(filter) },
|
||||
});
|
||||
itemTypesOptions.value = data;
|
||||
};
|
||||
|
||||
const getCategoryClass = (category, params) => {
|
||||
|
@ -111,23 +107,19 @@ const getCategoryClass = (category, params) => {
|
|||
};
|
||||
|
||||
const getSelectedTagValues = async (tag) => {
|
||||
try {
|
||||
if (!tag?.selectedTag?.id) return;
|
||||
tag.value = null;
|
||||
const filter = {
|
||||
fields: ['value'],
|
||||
order: 'value ASC',
|
||||
limit: 30,
|
||||
};
|
||||
if (!tag?.selectedTag?.id) return;
|
||||
tag.value = null;
|
||||
const filter = {
|
||||
fields: ['value'],
|
||||
order: 'value ASC',
|
||||
limit: 30,
|
||||
};
|
||||
|
||||
const params = { filter: JSON.stringify(filter) };
|
||||
const { data } = await axios.get(`Tags/${tag.selectedTag.id}/filterValue`, {
|
||||
params,
|
||||
});
|
||||
tag.valueOptions = data;
|
||||
} catch (err) {
|
||||
console.error('Error getting selected tag values');
|
||||
}
|
||||
const params = { filter: JSON.stringify(filter) };
|
||||
const { data } = await axios.get(`Tags/${tag.selectedTag.id}/filterValue`, {
|
||||
params,
|
||||
});
|
||||
tag.valueOptions = data;
|
||||
};
|
||||
|
||||
const removeTag = (index, params, search) => {
|
||||
|
|
|
@ -39,14 +39,10 @@ const refund = async () => {
|
|||
invoiceCorrectionTypeFk: invoiceParams.invoiceCorrectionTypeFk,
|
||||
};
|
||||
|
||||
try {
|
||||
const { data } = await axios.post('InvoiceOuts/refundAndInvoice', params);
|
||||
notify(t('Refunded invoice'), 'positive');
|
||||
const [id] = data?.refundId || [];
|
||||
if (id) router.push({ name: 'InvoiceOutSummary', params: { id } });
|
||||
} catch (err) {
|
||||
console.error('Error refunding invoice', err);
|
||||
}
|
||||
const { data } = await axios.post('InvoiceOuts/refundAndInvoice', params);
|
||||
notify(t('Refunded invoice'), 'positive');
|
||||
const [id] = data?.refundId || [];
|
||||
if (id) router.push({ name: 'InvoiceOutSummary', params: { id } });
|
||||
};
|
||||
</script>
|
||||
|
||||
|
|
|
@ -49,36 +49,32 @@ const makeInvoice = async () => {
|
|||
makeInvoice: checked.value,
|
||||
};
|
||||
|
||||
try {
|
||||
if (checked.value && hasToInvoiceByAddress) {
|
||||
const response = await new Promise((resolve) => {
|
||||
quasar
|
||||
.dialog({
|
||||
component: VnConfirm,
|
||||
componentProps: {
|
||||
title: t('Bill destination client'),
|
||||
message: t('transferInvoiceInfo'),
|
||||
},
|
||||
})
|
||||
.onOk(() => {
|
||||
resolve(true);
|
||||
})
|
||||
.onCancel(() => {
|
||||
resolve(false);
|
||||
});
|
||||
});
|
||||
if (!response) {
|
||||
return;
|
||||
}
|
||||
if (checked.value && hasToInvoiceByAddress) {
|
||||
const response = await new Promise((resolve) => {
|
||||
quasar
|
||||
.dialog({
|
||||
component: VnConfirm,
|
||||
componentProps: {
|
||||
title: t('Bill destination client'),
|
||||
message: t('transferInvoiceInfo'),
|
||||
},
|
||||
})
|
||||
.onOk(() => {
|
||||
resolve(true);
|
||||
})
|
||||
.onCancel(() => {
|
||||
resolve(false);
|
||||
});
|
||||
});
|
||||
if (!response) {
|
||||
return;
|
||||
}
|
||||
|
||||
const { data } = await axios.post('InvoiceOuts/transfer', params);
|
||||
notify(t('Transferred invoice'), 'positive');
|
||||
const id = data?.[0];
|
||||
if (id) router.push({ name: 'InvoiceOutSummary', params: { id } });
|
||||
} catch (err) {
|
||||
console.error('Error transfering invoice', err);
|
||||
}
|
||||
|
||||
const { data } = await axios.post('InvoiceOuts/transfer', params);
|
||||
notify(t('Transferred invoice'), 'positive');
|
||||
const id = data?.[0];
|
||||
if (id) router.push({ name: 'InvoiceOutSummary', params: { id } });
|
||||
};
|
||||
</script>
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<script setup>
|
||||
import { ref } from 'vue';
|
||||
import { ref, watch } from 'vue';
|
||||
import { useValidator } from 'src/composables/useValidator';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
|
@ -17,20 +17,23 @@ const $props = defineProps({
|
|||
type: Number,
|
||||
default: null,
|
||||
},
|
||||
provinces: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
});
|
||||
const provinceFk = defineModel({ type: Number, default: null });
|
||||
|
||||
const { validate } = useValidator();
|
||||
const { t } = useI18n();
|
||||
|
||||
const filter = ref({
|
||||
include: { relation: 'country' },
|
||||
where: {
|
||||
countryFk: $props.countryFk,
|
||||
},
|
||||
});
|
||||
const provincesOptions = ref($props.provinces);
|
||||
provinceFk.value = $props.provinceSelected;
|
||||
const provincesFetchDataRef = ref();
|
||||
|
||||
provinceFk.value = $props.provinceSelected;
|
||||
if (!$props.countryFk) {
|
||||
filter.value.where = {};
|
||||
}
|
||||
async function onProvinceCreated(_, data) {
|
||||
await provincesFetchDataRef.value.fetch({ where: { countryFk: $props.countryFk } });
|
||||
provinceFk.value = data.id;
|
||||
|
@ -39,23 +42,29 @@ async function onProvinceCreated(_, data) {
|
|||
async function handleProvinces(data) {
|
||||
provincesOptions.value = data;
|
||||
}
|
||||
|
||||
watch(
|
||||
() => $props.countryFk,
|
||||
async () => {
|
||||
if ($props.countryFk) {
|
||||
filter.value.where.countryFk = $props.countryFk;
|
||||
} else filter.value.where = {};
|
||||
await provincesFetchDataRef.value.fetch({});
|
||||
}
|
||||
);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<FetchData
|
||||
ref="provincesFetchDataRef"
|
||||
:filter="{
|
||||
include: { relation: 'country' },
|
||||
where: {
|
||||
countryFk: $props.countryFk,
|
||||
},
|
||||
}"
|
||||
:filter="filter"
|
||||
@on-fetch="handleProvinces"
|
||||
url="Provinces"
|
||||
auto-load
|
||||
/>
|
||||
<VnSelectDialog
|
||||
:label="t('Province')"
|
||||
:options="$props.provinces"
|
||||
:options="provincesOptions"
|
||||
:tooltip="t('Create province')"
|
||||
hide-selected
|
||||
v-model="provinceFk"
|
||||
|
|
|
@ -58,79 +58,71 @@ const getConfig = async (url, filter) => {
|
|||
};
|
||||
|
||||
const fetchViewConfigData = async () => {
|
||||
try {
|
||||
const userConfigFilter = {
|
||||
where: { tableCode: $props.tableCode, userFk: user.value.id },
|
||||
};
|
||||
const userConfig = await getConfig('UserConfigViews', userConfigFilter);
|
||||
const userConfigFilter = {
|
||||
where: { tableCode: $props.tableCode, userFk: user.value.id },
|
||||
};
|
||||
const userConfig = await getConfig('UserConfigViews', userConfigFilter);
|
||||
|
||||
if (userConfig) {
|
||||
initialUserConfigViewData.value = userConfig;
|
||||
setUserConfigViewData(userConfig.configuration);
|
||||
return;
|
||||
}
|
||||
if (userConfig) {
|
||||
initialUserConfigViewData.value = userConfig;
|
||||
setUserConfigViewData(userConfig.configuration);
|
||||
return;
|
||||
}
|
||||
|
||||
const defaultConfigFilter = { where: { tableCode: $props.tableCode } };
|
||||
const defaultConfig = await getConfig('DefaultViewConfigs', defaultConfigFilter);
|
||||
const defaultConfigFilter = { where: { tableCode: $props.tableCode } };
|
||||
const defaultConfig = await getConfig('DefaultViewConfigs', defaultConfigFilter);
|
||||
|
||||
if (defaultConfig) {
|
||||
// Si el backend devuelve una configuración por defecto la usamos
|
||||
setUserConfigViewData(defaultConfig.columns);
|
||||
return;
|
||||
} else {
|
||||
// Si no hay configuración por defecto mostramos todas las columnas
|
||||
const defaultColumns = {};
|
||||
$props.allColumns.forEach((col) => (defaultColumns[col] = true));
|
||||
setUserConfigViewData(defaultColumns);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Error fetching config view data', err);
|
||||
if (defaultConfig) {
|
||||
// Si el backend devuelve una configuración por defecto la usamos
|
||||
setUserConfigViewData(defaultConfig.columns);
|
||||
return;
|
||||
} else {
|
||||
// Si no hay configuración por defecto mostramos todas las columnas
|
||||
const defaultColumns = {};
|
||||
$props.allColumns.forEach((col) => (defaultColumns[col] = true));
|
||||
setUserConfigViewData(defaultColumns);
|
||||
}
|
||||
};
|
||||
|
||||
const saveConfig = async () => {
|
||||
try {
|
||||
const params = {};
|
||||
const configuration = {};
|
||||
const params = {};
|
||||
const configuration = {};
|
||||
|
||||
formattedCols.value.forEach((col) => {
|
||||
const { name, active } = col;
|
||||
configuration[name] = active;
|
||||
});
|
||||
formattedCols.value.forEach((col) => {
|
||||
const { name, active } = col;
|
||||
configuration[name] = active;
|
||||
});
|
||||
|
||||
// Si existe una view config del usuario hacemos un update si no la creamos
|
||||
if (initialUserConfigViewData.value) {
|
||||
params.updates = [
|
||||
{
|
||||
data: {
|
||||
configuration: configuration,
|
||||
},
|
||||
where: {
|
||||
id: initialUserConfigViewData.value.id,
|
||||
},
|
||||
},
|
||||
];
|
||||
} else {
|
||||
params.creates = [
|
||||
{
|
||||
userFk: user.value.id,
|
||||
tableCode: $props.tableCode,
|
||||
tableConfig: $props.tableCode,
|
||||
// Si existe una view config del usuario hacemos un update si no la creamos
|
||||
if (initialUserConfigViewData.value) {
|
||||
params.updates = [
|
||||
{
|
||||
data: {
|
||||
configuration: configuration,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
const response = await axios.post('UserConfigViews/crud', params);
|
||||
if (response.data && response.data[0]) {
|
||||
initialUserConfigViewData.value = response.data[0];
|
||||
}
|
||||
emitSavedConfig();
|
||||
notify('globals.dataSaved', 'positive');
|
||||
popupProxyRef.value.hide();
|
||||
} catch (err) {
|
||||
console.error('Error saving user view config', err);
|
||||
where: {
|
||||
id: initialUserConfigViewData.value.id,
|
||||
},
|
||||
},
|
||||
];
|
||||
} else {
|
||||
params.creates = [
|
||||
{
|
||||
userFk: user.value.id,
|
||||
tableCode: $props.tableCode,
|
||||
tableConfig: $props.tableCode,
|
||||
configuration: configuration,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
const response = await axios.post('UserConfigViews/crud', params);
|
||||
if (response.data && response.data[0]) {
|
||||
initialUserConfigViewData.value = response.data[0];
|
||||
}
|
||||
emitSavedConfig();
|
||||
notify('globals.dataSaved', 'positive');
|
||||
popupProxyRef.value.hide();
|
||||
};
|
||||
|
||||
const emitSavedConfig = () => {
|
||||
|
|
|
@ -74,6 +74,9 @@ const arrayData = useArrayData($props.dataKey, {
|
|||
const route = useRoute();
|
||||
const store = arrayData.store;
|
||||
const userParams = ref({});
|
||||
|
||||
defineExpose({ search, sanitizer, params: userParams });
|
||||
|
||||
onMounted(() => {
|
||||
userParams.value = $props.modelValue ?? {};
|
||||
emit('init', { params: userParams.value });
|
||||
|
@ -197,7 +200,7 @@ const customTags = computed(() =>
|
|||
|
||||
async function remove(key) {
|
||||
userParams.value[key] = undefined;
|
||||
search();
|
||||
await search();
|
||||
emit('remove', key);
|
||||
emit('update:modelValue', userParams.value);
|
||||
}
|
||||
|
@ -223,8 +226,6 @@ function sanitizer(params) {
|
|||
}
|
||||
return params;
|
||||
}
|
||||
|
||||
defineExpose({ search, sanitizer, userParams });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
|
|
@ -132,10 +132,24 @@ const addFilter = async (filter, params) => {
|
|||
|
||||
async function fetch(params) {
|
||||
useArrayData(props.dataKey, params);
|
||||
arrayData.reset(['filter.skip', 'skip']);
|
||||
arrayData.reset(['filter.skip', 'skip', 'page']);
|
||||
await arrayData.fetch({ append: false });
|
||||
if (!store.hasMoreData) isLoading.value = false;
|
||||
return emitStoreData();
|
||||
}
|
||||
|
||||
async function update(params) {
|
||||
useArrayData(props.dataKey, params);
|
||||
const { limit, skip } = store;
|
||||
store.limit = limit + skip;
|
||||
store.skip = 0;
|
||||
await arrayData.fetch({ append: false });
|
||||
store.limit = limit;
|
||||
store.skip = skip;
|
||||
return emitStoreData();
|
||||
}
|
||||
|
||||
function emitStoreData() {
|
||||
if (!store.hasMoreData) isLoading.value = false;
|
||||
emit('onFetch', store.data);
|
||||
return store.data;
|
||||
}
|
||||
|
@ -181,7 +195,7 @@ async function onLoad(index, done) {
|
|||
done(isDone);
|
||||
}
|
||||
|
||||
defineExpose({ fetch, addFilter, paginate });
|
||||
defineExpose({ fetch, update, addFilter, paginate });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
|
|
@ -1,11 +1,24 @@
|
|||
import { useSession } from 'src/composables/useSession';
|
||||
import { getUrl } from './getUrl';
|
||||
import axios from 'axios';
|
||||
import { exportFile } from 'quasar';
|
||||
|
||||
const { getTokenMultimedia } = useSession();
|
||||
const token = getTokenMultimedia();
|
||||
|
||||
export async function downloadFile(id, model = 'dms', urlPath = '/downloadFile', url) {
|
||||
let appUrl = await getUrl('', 'lilium');
|
||||
appUrl = appUrl.replace('/#/', '');
|
||||
window.open(url ?? `${appUrl}/api/${model}/${id}${urlPath}?access_token=${token}`);
|
||||
const appUrl = (await getUrl('', 'lilium')).replace('/#/', '');
|
||||
const response = await axios.get(
|
||||
url ?? `${appUrl}/${model}/${id}${urlPath}?access_token=${token}`,
|
||||
{ responseType: 'blob' }
|
||||
);
|
||||
|
||||
const contentDisposition = response.headers['content-disposition'];
|
||||
const matches = /filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/.exec(contentDisposition);
|
||||
const filename =
|
||||
matches != null && matches[1]
|
||||
? matches[1].replace(/['"]/g, '')
|
||||
: 'downloaded-file';
|
||||
|
||||
exportFile(filename, response.data);
|
||||
}
|
||||
|
|
|
@ -87,7 +87,7 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) {
|
|||
const params = { filter };
|
||||
|
||||
Object.assign(params, userParams);
|
||||
params.filter.skip = store.skip;
|
||||
if (params.filter) params.filter.skip = store.skip;
|
||||
if (store?.order && typeof store?.order == 'string') store.order = [store.order];
|
||||
if (store.order?.length) params.filter.order = [...store.order];
|
||||
else delete params.filter.order;
|
||||
|
|
|
@ -769,6 +769,7 @@ travel:
|
|||
hb: HB
|
||||
basicData:
|
||||
daysInForward: Days in forward
|
||||
isRaid: Raid
|
||||
thermographs:
|
||||
temperature: Temperature
|
||||
destination: Destination
|
||||
|
|
|
@ -763,6 +763,7 @@ travel:
|
|||
hb: HB
|
||||
basicData:
|
||||
daysInForward: Días redada
|
||||
isRaid: Redada
|
||||
thermographs:
|
||||
temperature: Temperatura
|
||||
destination: Destino
|
||||
|
|
|
@ -11,21 +11,13 @@ const { t } = useI18n();
|
|||
const { notify } = useNotify();
|
||||
|
||||
const onSynchronizeAll = async () => {
|
||||
try {
|
||||
notify(t('Synchronizing in the background'), 'positive');
|
||||
await axios.patch(`Accounts/syncAll`);
|
||||
} catch (error) {
|
||||
console.error('Error synchronizing all accounts', error);
|
||||
}
|
||||
notify(t('Synchronizing in the background'), 'positive');
|
||||
await axios.patch(`Accounts/syncAll`);
|
||||
};
|
||||
|
||||
const onSynchronizeRoles = async () => {
|
||||
try {
|
||||
await axios.patch(`RoleInherits/sync`);
|
||||
notify(t('Roles synchronized!'), 'positive');
|
||||
} catch (error) {
|
||||
console.error('Error synchronizing roles', error);
|
||||
}
|
||||
await axios.patch(`RoleInherits/sync`);
|
||||
notify(t('Roles synchronized!'), 'positive');
|
||||
};
|
||||
</script>
|
||||
|
||||
|
|
|
@ -111,29 +111,25 @@ const columns = computed(() => [
|
|||
},
|
||||
]);
|
||||
const deleteAcl = async ({ id }) => {
|
||||
try {
|
||||
await new Promise((resolve) => {
|
||||
quasar
|
||||
.dialog({
|
||||
component: VnConfirm,
|
||||
componentProps: {
|
||||
title: t('Remove ACL'),
|
||||
message: t('Do you want to remove this ACL?'),
|
||||
},
|
||||
})
|
||||
.onOk(() => {
|
||||
resolve(true);
|
||||
})
|
||||
.onCancel(() => {
|
||||
resolve(false);
|
||||
});
|
||||
});
|
||||
await axios.delete(`ACLs/${id}`);
|
||||
tableRef.value.reload();
|
||||
notify('ACL removed', 'positive');
|
||||
} catch (error) {
|
||||
console.error('Error deleting Acl: ', error);
|
||||
}
|
||||
await new Promise((resolve) => {
|
||||
quasar
|
||||
.dialog({
|
||||
component: VnConfirm,
|
||||
componentProps: {
|
||||
title: t('Remove ACL'),
|
||||
message: t('Do you want to remove this ACL?'),
|
||||
},
|
||||
})
|
||||
.onOk(() => {
|
||||
resolve(true);
|
||||
})
|
||||
.onCancel(() => {
|
||||
resolve(false);
|
||||
});
|
||||
});
|
||||
await axios.delete(`ACLs/${id}`);
|
||||
tableRef.value.reload();
|
||||
notify('ACL removed', 'positive');
|
||||
};
|
||||
</script>
|
||||
|
||||
|
|
|
@ -34,13 +34,9 @@ const refresh = () => paginateRef.value.fetch();
|
|||
const navigate = (id) => router.push({ name: 'AccountSummary', params: { id } });
|
||||
|
||||
const killSession = async ({ userId, created }) => {
|
||||
try {
|
||||
await axios.post(`${urlPath}/killSession`, { userId, created });
|
||||
paginateRef.value.fetch();
|
||||
notify(t('Session killed'), 'positive');
|
||||
} catch (error) {
|
||||
console.error('Error killing session', error);
|
||||
}
|
||||
await axios.post(`${urlPath}/killSession`, { userId, created });
|
||||
paginateRef.value.fetch();
|
||||
notify(t('Session killed'), 'positive');
|
||||
};
|
||||
</script>
|
||||
|
||||
|
|
|
@ -40,12 +40,8 @@ const formUrlCreate = ref(null);
|
|||
const formUrlUpdate = ref(null);
|
||||
const formCustomFn = ref(null);
|
||||
const onTestConection = async () => {
|
||||
try {
|
||||
await axios.get(`LdapConfigs/test`);
|
||||
notify(t('LDAP connection established!'), 'positive');
|
||||
} catch (error) {
|
||||
console.error('Error testing connection', error);
|
||||
}
|
||||
await axios.get(`LdapConfigs/test`);
|
||||
notify(t('LDAP connection established!'), 'positive');
|
||||
};
|
||||
const getInitialLdapConfig = async () => {
|
||||
try {
|
||||
|
@ -72,14 +68,10 @@ const getInitialLdapConfig = async () => {
|
|||
}
|
||||
};
|
||||
const deleteMailForward = async () => {
|
||||
try {
|
||||
await axios.delete(URL_UPDATE);
|
||||
initialData.value = { ...DEFAULT_DATA };
|
||||
hasData.value = false;
|
||||
notify(t('globals.dataSaved'), 'positive');
|
||||
} catch (err) {
|
||||
console.error('Error deleting mail forward', err);
|
||||
}
|
||||
await axios.delete(URL_UPDATE);
|
||||
initialData.value = { ...DEFAULT_DATA };
|
||||
hasData.value = false;
|
||||
notify(t('globals.dataSaved'), 'positive');
|
||||
};
|
||||
|
||||
onMounted(async () => await getInitialLdapConfig());
|
||||
|
|
|
@ -46,12 +46,8 @@ const formUrlUpdate = ref(null);
|
|||
const formCustomFn = ref(null);
|
||||
|
||||
const onTestConection = async () => {
|
||||
try {
|
||||
await axios.get(`SambaConfigs/test`);
|
||||
notify(t('Samba connection established!'), 'positive');
|
||||
} catch (error) {
|
||||
console.error('Error testing connection', error);
|
||||
}
|
||||
await axios.get(`SambaConfigs/test`);
|
||||
notify(t('Samba connection established!'), 'positive');
|
||||
};
|
||||
|
||||
const getInitialSambaConfig = async () => {
|
||||
|
@ -79,14 +75,10 @@ const getInitialSambaConfig = async () => {
|
|||
};
|
||||
|
||||
const deleteMailForward = async () => {
|
||||
try {
|
||||
await axios.delete(URL_UPDATE);
|
||||
initialData.value = { ...DEFAULT_DATA };
|
||||
hasData.value = false;
|
||||
notify(t('globals.dataSaved'), 'positive');
|
||||
} catch (err) {
|
||||
console.error('Error deleting mail forward', err);
|
||||
}
|
||||
await axios.delete(URL_UPDATE);
|
||||
initialData.value = { ...DEFAULT_DATA };
|
||||
hasData.value = false;
|
||||
notify(t('globals.dataSaved'), 'positive');
|
||||
};
|
||||
|
||||
onMounted(async () => await getInitialSambaConfig());
|
||||
|
|
|
@ -44,13 +44,9 @@ const removeAlias = () => {
|
|||
cancel: true,
|
||||
})
|
||||
.onOk(async () => {
|
||||
try {
|
||||
await axios.delete(`MailAliases/${entityId.value}`);
|
||||
notify(t('Alias removed'), 'positive');
|
||||
router.push({ name: 'AccountAlias' });
|
||||
} catch (err) {
|
||||
console.error('Error removing alias');
|
||||
}
|
||||
await axios.delete(`MailAliases/${entityId.value}`);
|
||||
notify(t('Alias removed'), 'positive');
|
||||
router.push({ name: 'AccountAlias' });
|
||||
});
|
||||
};
|
||||
</script>
|
||||
|
|
|
@ -41,35 +41,22 @@ const fetchAccountExistence = async () => {
|
|||
};
|
||||
|
||||
const fetchMailForwards = async () => {
|
||||
try {
|
||||
const response = await axios.get(`MailForwards/${route.params.id}`);
|
||||
return response.data;
|
||||
} catch (err) {
|
||||
console.error('Error fetching mail forwards', err);
|
||||
return null;
|
||||
}
|
||||
const response = await axios.get(`MailForwards/${route.params.id}`);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
const deleteMailForward = async () => {
|
||||
try {
|
||||
await axios.delete(`MailForwards/${route.params.id}`);
|
||||
formData.value.forwardTo = null;
|
||||
initialData.value.forwardTo = null;
|
||||
initialData.value.hasData = hasData.value;
|
||||
notify(t('globals.dataSaved'), 'positive');
|
||||
} catch (err) {
|
||||
console.error('Error deleting mail forward', err);
|
||||
}
|
||||
await axios.delete(`MailForwards/${route.params.id}`);
|
||||
formData.value.forwardTo = null;
|
||||
initialData.value.forwardTo = null;
|
||||
initialData.value.hasData = hasData.value;
|
||||
notify(t('globals.dataSaved'), 'positive');
|
||||
};
|
||||
|
||||
const updateMailForward = async () => {
|
||||
try {
|
||||
await axios.patch('MailForwards', formData.value);
|
||||
initialData.value = { ...formData.value };
|
||||
initialData.value.hasData = hasData.value;
|
||||
} catch (err) {
|
||||
console.error('Error creating mail forward', err);
|
||||
}
|
||||
await axios.patch('MailForwards', formData.value);
|
||||
initialData.value = { ...formData.value };
|
||||
initialData.value.hasData = hasData.value;
|
||||
};
|
||||
|
||||
const onSubmit = async () => {
|
||||
|
|
|
@ -32,12 +32,8 @@ const filter = {
|
|||
where: { id: entityId },
|
||||
};
|
||||
const removeRole = async () => {
|
||||
try {
|
||||
await axios.delete(`VnRoles/${entityId.value}`);
|
||||
notify(t('Role removed'), 'positive');
|
||||
} catch (error) {
|
||||
console.error('Error deleting role', error);
|
||||
}
|
||||
await axios.delete(`VnRoles/${entityId.value}`);
|
||||
notify(t('Role removed'), 'positive');
|
||||
};
|
||||
</script>
|
||||
|
||||
|
|
|
@ -95,6 +95,7 @@ const columns = computed(() => [
|
|||
optionLabel: 'description',
|
||||
},
|
||||
},
|
||||
orderBy: 'priority',
|
||||
},
|
||||
{
|
||||
align: 'right',
|
||||
|
|
|
@ -167,7 +167,7 @@ const toCustomerAddressEdit = (addressId) => {
|
|||
<div>{{ item.street }}</div>
|
||||
<div>
|
||||
{{ item.postalCode }} - {{ item.city }},
|
||||
{{ item.province.name }}
|
||||
{{ item.province?.name }}
|
||||
</div>
|
||||
<div>
|
||||
{{ item.phone }}
|
||||
|
|
|
@ -106,28 +106,24 @@ const setParams = (params) => {
|
|||
};
|
||||
|
||||
const getPreview = async () => {
|
||||
try {
|
||||
const params = {
|
||||
recipientId: entityId,
|
||||
};
|
||||
const validationMessage = validateMessage();
|
||||
if (validationMessage) return notify(t(validationMessage), 'negative');
|
||||
const params = {
|
||||
recipientId: entityId,
|
||||
};
|
||||
const validationMessage = validateMessage();
|
||||
if (validationMessage) return notify(t(validationMessage), 'negative');
|
||||
|
||||
setParams(params);
|
||||
setParams(params);
|
||||
|
||||
const path = `${sampleType.value.model}/${entityId.value}/${sampleType.value.code}-html`;
|
||||
const { data } = await axios.get(path, { params });
|
||||
const path = `${sampleType.value.model}/${entityId.value}/${sampleType.value.code}-html`;
|
||||
const { data } = await axios.get(path, { params });
|
||||
|
||||
if (!data) return;
|
||||
quasar.dialog({
|
||||
component: CustomerSamplesPreview,
|
||||
componentProps: {
|
||||
htmlContent: data,
|
||||
},
|
||||
});
|
||||
} catch (err) {
|
||||
notify('Errors getting preview', 'negative');
|
||||
}
|
||||
if (!data) return;
|
||||
quasar.dialog({
|
||||
component: CustomerSamplesPreview,
|
||||
componentProps: {
|
||||
htmlContent: data,
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
const onSubmit = async () => {
|
||||
|
|
|
@ -42,13 +42,9 @@ const setData = (entity) => {
|
|||
};
|
||||
|
||||
const removeDepartment = async () => {
|
||||
try {
|
||||
await axios.post(`/Departments/${entityId.value}/removeChild`, entityId.value);
|
||||
router.push({ name: 'WorkerDepartment' });
|
||||
notify('department.departmentRemoved', 'positive');
|
||||
} catch (err) {
|
||||
console.error('Error removing department');
|
||||
}
|
||||
await axios.post(`/Departments/${entityId.value}/removeChild`, entityId.value);
|
||||
router.push({ name: 'WorkerDepartment' });
|
||||
notify('department.departmentRemoved', 'positive');
|
||||
};
|
||||
|
||||
const { openConfirmationModal } = useVnConfirm();
|
||||
|
|
|
@ -236,13 +236,9 @@ const copyOriginalRowsData = (rows) => {
|
|||
};
|
||||
|
||||
const saveChange = async (field, { rowIndex, row }) => {
|
||||
try {
|
||||
if (originalRowDataCopy.value[rowIndex][field] == row[field]) return;
|
||||
await axios.patch(`Buys/${row.id}`, row);
|
||||
originalRowDataCopy.value[rowIndex][field] = row[field];
|
||||
} catch (err) {
|
||||
console.error('Error saving changes', err);
|
||||
}
|
||||
if (originalRowDataCopy.value[rowIndex][field] == row[field]) return;
|
||||
await axios.patch(`Buys/${row.id}`, row);
|
||||
originalRowDataCopy.value[rowIndex][field] = row[field];
|
||||
};
|
||||
|
||||
const openRemoveDialog = async () => {
|
||||
|
@ -260,15 +256,11 @@ const openRemoveDialog = async () => {
|
|||
},
|
||||
})
|
||||
.onOk(async () => {
|
||||
try {
|
||||
await deleteBuys();
|
||||
const notifyMessage = t(
|
||||
`Buy${rowsSelected.value.length > 1 ? 's' : ''} deleted`
|
||||
);
|
||||
notify(notifyMessage, 'positive');
|
||||
} catch (err) {
|
||||
console.error('Error deleting buys');
|
||||
}
|
||||
await deleteBuys();
|
||||
const notifyMessage = t(
|
||||
`Buy${rowsSelected.value.length > 1 ? 's' : ''} deleted`
|
||||
);
|
||||
notify(notifyMessage, 'positive');
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -282,17 +274,13 @@ const importBuys = () => {
|
|||
};
|
||||
|
||||
const toggleGroupingMode = async (buy, mode) => {
|
||||
try {
|
||||
const groupingMode = mode === 'grouping' ? mode : 'packing';
|
||||
const newGroupingMode = buy.groupingMode === groupingMode ? null : groupingMode;
|
||||
const params = {
|
||||
groupingMode: newGroupingMode,
|
||||
};
|
||||
await axios.patch(`Buys/${buy.id}`, params);
|
||||
buy.groupingMode = newGroupingMode;
|
||||
} catch (err) {
|
||||
console.error('Error toggling grouping mode');
|
||||
}
|
||||
const groupingMode = mode === 'grouping' ? mode : 'packing';
|
||||
const newGroupingMode = buy.groupingMode === groupingMode ? null : groupingMode;
|
||||
const params = {
|
||||
groupingMode: newGroupingMode,
|
||||
};
|
||||
await axios.patch(`Buys/${buy.id}`, params);
|
||||
buy.groupingMode = newGroupingMode;
|
||||
};
|
||||
|
||||
const lockIconType = (groupingMode, mode) => {
|
||||
|
|
|
@ -123,36 +123,28 @@ const fillData = async (rawData) => {
|
|||
};
|
||||
|
||||
const fetchBuys = async (buys) => {
|
||||
try {
|
||||
const params = { buys };
|
||||
const { data } = await axios.post(
|
||||
`Entries/${route.params.id}/importBuysPreview`,
|
||||
params
|
||||
);
|
||||
importData.value.buys = data;
|
||||
} catch (err) {
|
||||
console.error('Error fetching buys');
|
||||
}
|
||||
const params = { buys };
|
||||
const { data } = await axios.post(
|
||||
`Entries/${route.params.id}/importBuysPreview`,
|
||||
params
|
||||
);
|
||||
importData.value.buys = data;
|
||||
};
|
||||
|
||||
const onSubmit = async () => {
|
||||
try {
|
||||
const params = importData.value;
|
||||
const hasAnyEmptyRow = params.buys.some((buy) => {
|
||||
return buy.itemFk === null;
|
||||
});
|
||||
const params = importData.value;
|
||||
const hasAnyEmptyRow = params.buys.some((buy) => {
|
||||
return buy.itemFk === null;
|
||||
});
|
||||
|
||||
if (hasAnyEmptyRow) {
|
||||
notify(t('Some of the imported buys does not have an item'), 'negative');
|
||||
return;
|
||||
}
|
||||
|
||||
await axios.post(`Entries/${route.params.id}/importBuys`, params);
|
||||
notify('globals.dataSaved', 'positive');
|
||||
redirectToBuysView();
|
||||
} catch (err) {
|
||||
console.error('Error importing buys', err);
|
||||
if (hasAnyEmptyRow) {
|
||||
notify(t('Some of the imported buys does not have an item'), 'negative');
|
||||
return;
|
||||
}
|
||||
|
||||
await axios.post(`Entries/${route.params.id}/importBuys`, params);
|
||||
notify('globals.dataSaved', 'positive');
|
||||
redirectToBuysView();
|
||||
};
|
||||
|
||||
const redirectToBuysView = () => {
|
||||
|
|
|
@ -147,12 +147,9 @@ async function setEntryData(data) {
|
|||
}
|
||||
|
||||
const fetchEntryBuys = async () => {
|
||||
try {
|
||||
const { data } = await axios.get(`Entries/${entry.value.id}/getBuys`);
|
||||
if (data) entryBuys.value = data;
|
||||
} catch (err) {
|
||||
console.error('Error fetching entry buys');
|
||||
}
|
||||
|
||||
};
|
||||
</script>
|
||||
|
||||
|
|
|
@ -221,7 +221,7 @@ onMounted(async () => {
|
|||
t('entry.list.tableVisibleColumns.isExcludedFromAvailable')
|
||||
}}</QTooltip>
|
||||
</QIcon>
|
||||
<QIcon v-if="!!row.daysInForward" name="vn:net" color="primary">
|
||||
<QIcon v-if="!!row.isRaid" name="vn:net" color="primary">
|
||||
<QTooltip>
|
||||
{{
|
||||
t('globals.raid', { daysInForward: row.daysInForward })
|
||||
|
|
|
@ -30,8 +30,6 @@ const recalc = async () => {
|
|||
isLoading.value = true;
|
||||
await axios.post('Applications/waste_addSales/execute-proc', params);
|
||||
notify('wasteRecalc.recalcOk', 'positive');
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
} finally {
|
||||
isLoading.value = false;
|
||||
}
|
||||
|
|
|
@ -61,25 +61,18 @@ const showSendInvoiceDialog = (type) => {
|
|||
};
|
||||
|
||||
const sendEmailInvoice = async ({ address }) => {
|
||||
try {
|
||||
if (!address) notify(`The email can't be empty`, 'negative');
|
||||
if (!address) notify(`The email can't be empty`, 'negative');
|
||||
|
||||
if (invoiceFormType.value === 'pdf') {
|
||||
return sendEmail(`InvoiceOuts/${$props.invoiceOutData.ref}/invoice-email`, {
|
||||
recipientId: $props.invoiceOutData.client.id,
|
||||
recipient: address,
|
||||
});
|
||||
} else {
|
||||
return sendEmail(
|
||||
`InvoiceOuts/${$props.invoiceOutData.ref}/invoice-csv-email`,
|
||||
{
|
||||
recipientId: $props.invoiceOutData.client.id,
|
||||
recipient: address,
|
||||
}
|
||||
);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Error sending email', err);
|
||||
if (invoiceFormType.value === 'pdf') {
|
||||
return sendEmail(`InvoiceOuts/${$props.invoiceOutData.ref}/invoice-email`, {
|
||||
recipientId: $props.invoiceOutData.client.id,
|
||||
recipient: address,
|
||||
});
|
||||
} else {
|
||||
return sendEmail(`InvoiceOuts/${$props.invoiceOutData.ref}/invoice-csv-email`, {
|
||||
recipientId: $props.invoiceOutData.client.id,
|
||||
recipient: address,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -88,46 +81,30 @@ const redirectToInvoiceOutList = () => {
|
|||
};
|
||||
|
||||
const deleteInvoice = async () => {
|
||||
try {
|
||||
await axios.post(`InvoiceOuts/${$props.invoiceOutData.id}/delete`);
|
||||
notify(t('InvoiceOut deleted'), 'positive');
|
||||
} catch (err) {
|
||||
console.error('Error deleting invoice out', err);
|
||||
}
|
||||
await axios.post(`InvoiceOuts/${$props.invoiceOutData.id}/delete`);
|
||||
notify(t('InvoiceOut deleted'), 'positive');
|
||||
};
|
||||
|
||||
const bookInvoice = async () => {
|
||||
try {
|
||||
await axios.post(`InvoiceOuts/${$props.invoiceOutData.ref}/book`);
|
||||
notify(t('InvoiceOut booked'), 'positive');
|
||||
} catch (err) {
|
||||
console.error('Error booking invoice out', err);
|
||||
}
|
||||
await axios.post(`InvoiceOuts/${$props.invoiceOutData.ref}/book`);
|
||||
notify(t('InvoiceOut booked'), 'positive');
|
||||
};
|
||||
|
||||
const generateInvoicePdf = async () => {
|
||||
try {
|
||||
await axios.post(`InvoiceOuts/${$props.invoiceOutData.id}/createPdf`);
|
||||
notify(t('The invoice PDF document has been regenerated'), 'positive');
|
||||
} catch (err) {
|
||||
console.error('Error generating invoice out pdf', err);
|
||||
}
|
||||
await axios.post(`InvoiceOuts/${$props.invoiceOutData.id}/createPdf`);
|
||||
notify(t('The invoice PDF document has been regenerated'), 'positive');
|
||||
};
|
||||
|
||||
const refundInvoice = async (withWarehouse) => {
|
||||
try {
|
||||
const params = { ref: $props.invoiceOutData.ref, withWarehouse: withWarehouse };
|
||||
const { data } = await axios.post('InvoiceOuts/refund', params);
|
||||
location.href = window.origin + `/#/ticket/${data[0].id}/sale`;
|
||||
notify(
|
||||
t('refundInvoiceSuccessMessage', {
|
||||
refundTicket: data[0].id,
|
||||
}),
|
||||
'positive'
|
||||
);
|
||||
} catch (err) {
|
||||
console.error('Error generating invoice out pdf', err);
|
||||
}
|
||||
const params = { ref: $props.invoiceOutData.ref, withWarehouse: withWarehouse };
|
||||
const { data } = await axios.post('InvoiceOuts/refund', params);
|
||||
location.href = window.origin + `/#/ticket/${data[0].id}/sale`;
|
||||
notify(
|
||||
t('refundInvoiceSuccessMessage', {
|
||||
refundTicket: data[0].id,
|
||||
}),
|
||||
'positive'
|
||||
);
|
||||
};
|
||||
|
||||
const showTransferInvoiceForm = async () => {
|
||||
|
|
|
@ -135,15 +135,10 @@ onMounted(() => (stateStore.rightDrawer = true));
|
|||
onUnmounted(() => (stateStore.rightDrawer = false));
|
||||
|
||||
function openPdf(id) {
|
||||
try {
|
||||
openReport(`${MODEL}/${id}/download`);
|
||||
} catch (err) {
|
||||
console.error('Error opening PDF', err);
|
||||
}
|
||||
openReport(`${MODEL}/${id}/download`);
|
||||
}
|
||||
|
||||
function downloadPdf() {
|
||||
try {
|
||||
if (selectedRows.value.size === 0) return;
|
||||
const selectedCardsArray = Array.from(selectedRows.value.values());
|
||||
|
||||
|
@ -162,9 +157,7 @@ function downloadPdf() {
|
|||
|
||||
openReport(`${MODEL}/downloadZip`, params);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Error opening PDF');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
watchEffect(selectedRows);
|
||||
|
|
|
@ -45,13 +45,9 @@ const arrayData = useArrayData('ItemShelvings', {
|
|||
const rows = computed(() => arrayData.store.data || []);
|
||||
|
||||
const applyColumnFilter = async (col) => {
|
||||
try {
|
||||
const paramKey = col.columnFilter?.filterParamKey || col.field;
|
||||
params[paramKey] = col.columnFilter.filterValue;
|
||||
await arrayData.addFilter({ filter: null, params });
|
||||
} catch (err) {
|
||||
console.error('Error applying column filter', err);
|
||||
}
|
||||
const paramKey = col.columnFilter?.filterParamKey || col.field;
|
||||
params[paramKey] = col.columnFilter.filterValue;
|
||||
await arrayData.addFilter({ filter: null, params });
|
||||
};
|
||||
|
||||
const getInputEvents = (col) => {
|
||||
|
@ -173,15 +169,11 @@ const totalLabels = computed(() =>
|
|||
);
|
||||
|
||||
const removeLines = async () => {
|
||||
try {
|
||||
const itemShelvingIds = rowsSelected.value.map((row) => row.itemShelvingFk);
|
||||
await axios.post('ItemShelvings/deleteItemShelvings', { itemShelvingIds });
|
||||
rowsSelected.value = [];
|
||||
notify('shelvings.shelvingsRemoved', 'positive');
|
||||
await arrayData.fetch({ append: false });
|
||||
} catch (err) {
|
||||
console.error('Error removing lines', err);
|
||||
}
|
||||
const itemShelvingIds = rowsSelected.value.map((row) => row.itemShelvingFk);
|
||||
await axios.post('ItemShelvings/deleteItemShelvings', { itemShelvingIds });
|
||||
rowsSelected.value = [];
|
||||
notify('shelvings.shelvingsRemoved', 'positive');
|
||||
await arrayData.fetch({ append: false });
|
||||
};
|
||||
onMounted(async () => {
|
||||
await arrayData.fetch({ append: false });
|
||||
|
|
|
@ -19,22 +19,18 @@ const tagOptions = ref([]);
|
|||
const valueOptionsMap = ref(new Map());
|
||||
|
||||
const getSelectedTagValues = async (tag) => {
|
||||
try {
|
||||
if (!tag.tagFk && tag.tag.isFree) return;
|
||||
const filter = {
|
||||
fields: ['value'],
|
||||
order: 'value ASC',
|
||||
limit: 30,
|
||||
};
|
||||
if (!tag.tagFk && tag.tag.isFree) return;
|
||||
const filter = {
|
||||
fields: ['value'],
|
||||
order: 'value ASC',
|
||||
limit: 30,
|
||||
};
|
||||
|
||||
const params = { filter: JSON.stringify(filter) };
|
||||
const { data } = await axios.get(`Tags/${tag.tagFk}/filterValue`, {
|
||||
params,
|
||||
});
|
||||
valueOptionsMap.value.set(tag.tagFk, data);
|
||||
} catch (err) {
|
||||
console.error('Error getting selected tag values');
|
||||
}
|
||||
const params = { filter: JSON.stringify(filter) };
|
||||
const { data } = await axios.get(`Tags/${tag.tagFk}/filterValue`, {
|
||||
params,
|
||||
});
|
||||
valueOptionsMap.value.set(tag.tagFk, data);
|
||||
};
|
||||
|
||||
const onItemTagsFetched = async (itemTags) => {
|
||||
|
|
|
@ -32,17 +32,13 @@ const ItemTaxRef = ref(null);
|
|||
const taxesOptions = ref([]);
|
||||
|
||||
const submitTaxes = async (data) => {
|
||||
try {
|
||||
let payload = data.map((tax) => ({
|
||||
id: tax.id,
|
||||
taxClassFk: tax.taxClassFk,
|
||||
}));
|
||||
let payload = data.map((tax) => ({
|
||||
id: tax.id,
|
||||
taxClassFk: tax.taxClassFk,
|
||||
}));
|
||||
|
||||
await axios.post(`Items/updateTaxes`, payload);
|
||||
notify(t('globals.dataSaved'), 'positive');
|
||||
} catch (err) {
|
||||
console.error('Error saving taxes', err);
|
||||
}
|
||||
await axios.post(`Items/updateTaxes`, payload);
|
||||
notify(t('globals.dataSaved'), 'positive');
|
||||
};
|
||||
</script>
|
||||
<template>
|
||||
|
|
|
@ -221,24 +221,16 @@ const updateMinPrice = async (value, props) => {
|
|||
};
|
||||
|
||||
const upsertPrice = async (props, resetMinPrice = false) => {
|
||||
try {
|
||||
const { row } = props;
|
||||
if (tableRef.value.CrudModelRef.getChanges().updates.length > 0) {
|
||||
if (resetMinPrice) row.hasMinPrice = 0;
|
||||
await upsertFixedPrice(row);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Error editing price', err);
|
||||
const { row } = props;
|
||||
if (tableRef.value.CrudModelRef.getChanges().updates.length > 0) {
|
||||
if (resetMinPrice) row.hasMinPrice = 0;
|
||||
await upsertFixedPrice(row);
|
||||
}
|
||||
};
|
||||
|
||||
async function upsertFixedPrice(row) {
|
||||
try {
|
||||
const { data } = await axios.patch('FixedPrices/upsertFixedPrice', row);
|
||||
return data;
|
||||
} catch (err) {
|
||||
console.error('Error editing price', err);
|
||||
}
|
||||
const { data } = await axios.patch('FixedPrices/upsertFixedPrice', row);
|
||||
return data;
|
||||
}
|
||||
|
||||
async function saveOnRowChange(row) {
|
||||
|
@ -321,14 +313,10 @@ const onEditCellDataSaved = async () => {
|
|||
};
|
||||
|
||||
const removeFuturePrice = async () => {
|
||||
try {
|
||||
rowsSelected.value.forEach(({ id }) => {
|
||||
const rowIndex = fixedPrices.value.findIndex(({ id }) => id === id);
|
||||
removePrice(id, rowIndex);
|
||||
});
|
||||
} catch (err) {
|
||||
console.error('Error removing price', err);
|
||||
}
|
||||
rowsSelected.value.forEach(({ id }) => {
|
||||
const rowIndex = fixedPrices.value.findIndex(({ id }) => id === id);
|
||||
removePrice(id, rowIndex);
|
||||
});
|
||||
};
|
||||
|
||||
function confirmRemove(item, isFuture) {
|
||||
|
@ -345,13 +333,9 @@ function confirmRemove(item, isFuture) {
|
|||
}
|
||||
|
||||
const removePrice = async (id) => {
|
||||
try {
|
||||
await axios.delete(`FixedPrices/${id}`);
|
||||
notify(t('globals.dataSaved'), 'positive');
|
||||
tableRef.value.reload({});
|
||||
} catch (err) {
|
||||
console.error('Error removing price', err);
|
||||
}
|
||||
await axios.delete(`FixedPrices/${id}`);
|
||||
notify(t('globals.dataSaved'), 'positive');
|
||||
tableRef.value.reload({});
|
||||
};
|
||||
const dateStyle = (date) =>
|
||||
date
|
||||
|
|
|
@ -55,22 +55,18 @@ const onCategoryChange = async (categoryFk, search) => {
|
|||
};
|
||||
|
||||
const getSelectedTagValues = async (tag) => {
|
||||
try {
|
||||
if (!tag?.selectedTag?.id) return;
|
||||
tag.value = null;
|
||||
const filter = {
|
||||
fields: ['value'],
|
||||
order: 'value ASC',
|
||||
};
|
||||
if (!tag?.selectedTag?.id) return;
|
||||
tag.value = null;
|
||||
const filter = {
|
||||
fields: ['value'],
|
||||
order: 'value ASC',
|
||||
};
|
||||
|
||||
const params = { filter: JSON.stringify(filter) };
|
||||
const { data } = await axios.get(`Tags/${tag.selectedTag.id}/filterValue`, {
|
||||
params,
|
||||
});
|
||||
tag.valueOptions = data;
|
||||
} catch (err) {
|
||||
console.error('Error getting selected tag values');
|
||||
}
|
||||
const params = { filter: JSON.stringify(filter) };
|
||||
const { data } = await axios.get(`Tags/${tag.selectedTag.id}/filterValue`, {
|
||||
params,
|
||||
});
|
||||
tag.valueOptions = data;
|
||||
};
|
||||
|
||||
const applyTags = (params, search) => {
|
||||
|
|
|
@ -173,40 +173,29 @@ const getBadgeColor = (date) => {
|
|||
};
|
||||
|
||||
const changeQuantity = async (request) => {
|
||||
try {
|
||||
if (request.saleFk) {
|
||||
const params = {
|
||||
quantity: request.saleQuantity,
|
||||
};
|
||||
if (request.saleFk) {
|
||||
const params = {
|
||||
quantity: request.saleQuantity,
|
||||
};
|
||||
|
||||
await axios.patch(`Sales/${request.saleFk}`, params);
|
||||
notify(t('globals.dataSaved'), 'positive');
|
||||
confirmRequest(request);
|
||||
} else confirmRequest(request);
|
||||
} catch (error) {
|
||||
console.error('Error changing quantity:: ', error);
|
||||
}
|
||||
await axios.patch(`Sales/${request.saleFk}`, params);
|
||||
notify(t('globals.dataSaved'), 'positive');
|
||||
confirmRequest(request);
|
||||
} else confirmRequest(request);
|
||||
};
|
||||
|
||||
const confirmRequest = async (request) => {
|
||||
try {
|
||||
if (request.itemFk && request.saleQuantity) {
|
||||
const params = {
|
||||
itemFk: request.itemFk,
|
||||
quantity: request.saleQuantity,
|
||||
attenderFk: request.attenderFk,
|
||||
};
|
||||
if (request.itemFk && request.saleQuantity) {
|
||||
const params = {
|
||||
itemFk: request.itemFk,
|
||||
quantity: request.saleQuantity,
|
||||
attenderFk: request.attenderFk,
|
||||
};
|
||||
|
||||
const { data } = await axios.post(
|
||||
`TicketRequests/${request.id}/confirm`,
|
||||
params
|
||||
);
|
||||
request.itemDescription = data.concept;
|
||||
request.isOk = true;
|
||||
notify(t('globals.dataSaved'), 'positive');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error confirming request:: ', error);
|
||||
const { data } = await axios.post(`TicketRequests/${request.id}/confirm`, params);
|
||||
request.itemDescription = data.concept;
|
||||
request.isOk = true;
|
||||
notify(t('globals.dataSaved'), 'positive');
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -103,15 +103,11 @@ const getBadgeColor = (date) => {
|
|||
};
|
||||
|
||||
const removeOrders = async () => {
|
||||
try {
|
||||
const selectedIds = selectedRows.value.map((row) => row.id);
|
||||
const params = { deletes: selectedIds };
|
||||
await axios.post('SalesMonitors/deleteOrders', params);
|
||||
selectedRows.value = [];
|
||||
await table.value.reload();
|
||||
} catch (err) {
|
||||
console.error('Error deleting orders', err);
|
||||
}
|
||||
const selectedIds = selectedRows.value.map((row) => row.id);
|
||||
const params = { deletes: selectedIds };
|
||||
await axios.post('SalesMonitors/deleteOrders', params);
|
||||
selectedRows.value = [];
|
||||
await table.value.reload();
|
||||
};
|
||||
|
||||
const openTab = (id) =>
|
||||
|
|
|
@ -350,7 +350,7 @@ const openTab = (id) =>
|
|||
class="q-mr-sm"
|
||||
dense
|
||||
flat
|
||||
@click="$refs.tableRef.reload()"
|
||||
@click="tableRef.CrudModelRef.vnPaginateRef.update()"
|
||||
>
|
||||
<QTooltip>{{ $t('globals.refresh') }}</QTooltip>
|
||||
</QBtn>
|
||||
|
|
|
@ -22,22 +22,17 @@ const agencyList = ref([]);
|
|||
const addressList = ref([]);
|
||||
|
||||
const fetchAddressList = async (addressId) => {
|
||||
try {
|
||||
const { data } = await axios.get('addresses', {
|
||||
params: {
|
||||
filter: JSON.stringify({
|
||||
fields: ['id', 'nickname', 'street', 'city'],
|
||||
where: { id: addressId },
|
||||
}),
|
||||
},
|
||||
});
|
||||
addressList.value = data;
|
||||
if (addressList.value?.length === 1) {
|
||||
state.get(ORDER_MODEL).addressFk = addressList.value[0].id;
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(`Error fetching addresses`, err);
|
||||
return err.response;
|
||||
const { data } = await axios.get('addresses', {
|
||||
params: {
|
||||
filter: JSON.stringify({
|
||||
fields: ['id', 'nickname', 'street', 'city'],
|
||||
where: { id: addressId },
|
||||
}),
|
||||
},
|
||||
});
|
||||
addressList.value = data;
|
||||
if (addressList.value?.length === 1) {
|
||||
state.get(ORDER_MODEL).addressFk = addressList.value[0].id;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -45,18 +40,13 @@ const fetchAgencyList = async (landed, addressFk) => {
|
|||
if (!landed || !addressFk) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const { data } = await axios.get('Agencies/landsThatDay', {
|
||||
params: {
|
||||
addressFk,
|
||||
landed: new Date(landed).toISOString(),
|
||||
},
|
||||
});
|
||||
agencyList.value = data;
|
||||
} catch (err) {
|
||||
console.error(`Error fetching agencies`, err);
|
||||
return err.response;
|
||||
}
|
||||
const { data } = await axios.get('Agencies/landsThatDay', {
|
||||
params: {
|
||||
addressFk,
|
||||
landed: new Date(landed).toISOString(),
|
||||
},
|
||||
});
|
||||
agencyList.value = data;
|
||||
};
|
||||
|
||||
const fetchOrderDetails = (order) => {
|
||||
|
@ -92,12 +82,8 @@ const orderFilter = {
|
|||
};
|
||||
|
||||
const onClientChange = async (clientId) => {
|
||||
try {
|
||||
const { data } = await axios.get(`Clients/${clientId}`);
|
||||
await fetchAddressList(data.defaultAddressFk);
|
||||
} catch (error) {
|
||||
console.error('Error al cambiar el cliente:', error);
|
||||
}
|
||||
const { data } = await axios.get(`Clients/${clientId}`);
|
||||
await fetchAddressList(data.defaultAddressFk);
|
||||
};
|
||||
</script>
|
||||
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
<script setup>
|
||||
import { useStateStore } from 'stores/useStateStore';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import { onBeforeMount, onMounted, onUnmounted, ref, computed, watch } from 'vue';
|
||||
import { onMounted, onUnmounted, ref, computed, watch } from 'vue';
|
||||
import axios from 'axios';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import VnPaginate from 'src/components/ui/VnPaginate.vue';
|
||||
import CatalogItem from 'src/components/ui/CatalogItem.vue';
|
||||
import OrderCatalogFilter from 'src/pages/Order/Card/OrderCatalogFilter.vue';
|
||||
import VnSearchbar from 'src/components/ui/VnSearchbar.vue';
|
||||
import getParamWhere from 'src/filters/getParamWhere';
|
||||
import { useArrayData } from 'src/composables/useArrayData';
|
||||
|
||||
const route = useRoute();
|
||||
|
@ -18,7 +17,6 @@ const { t } = useI18n();
|
|||
const dataKey = 'OrderCatalogList';
|
||||
const arrayData = useArrayData(dataKey);
|
||||
const store = arrayData.store;
|
||||
const showFilter = ref(null);
|
||||
const tags = ref([]);
|
||||
|
||||
let catalogParams = {
|
||||
|
@ -26,27 +24,6 @@ let catalogParams = {
|
|||
orderBy: JSON.stringify({ field: 'relevancy DESC, name', way: 'ASC', isTag: false }),
|
||||
};
|
||||
|
||||
onBeforeMount(() => {
|
||||
const whereParams = getParamWhere(route);
|
||||
if (whereParams) {
|
||||
const formattedWhereParams = {};
|
||||
if (whereParams.and) {
|
||||
whereParams.and.forEach((item) => {
|
||||
Object.assign(formattedWhereParams, item);
|
||||
});
|
||||
} else {
|
||||
Object.assign(formattedWhereParams, whereParams);
|
||||
}
|
||||
|
||||
catalogParams = {
|
||||
...catalogParams,
|
||||
...formattedWhereParams,
|
||||
};
|
||||
} else {
|
||||
showFilter.value = true;
|
||||
}
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
stateStore.rightDrawer = true;
|
||||
checkOrderConfirmation();
|
||||
|
@ -90,7 +67,7 @@ function extractValueTags(items) {
|
|||
);
|
||||
tagValue.value = resultValueTags;
|
||||
}
|
||||
const autoLoad = computed(() => !!catalogParams.categoryFk);
|
||||
const autoLoad = computed(() => !!JSON.parse(route?.query.table ?? '{}')?.categoryFk);
|
||||
|
||||
watch(
|
||||
() => store.data,
|
||||
|
@ -112,7 +89,7 @@ watch(
|
|||
:info="t('You can search items by name or id')"
|
||||
/>
|
||||
<QDrawer v-model="stateStore.rightDrawer" side="right" :width="256" show-if-above>
|
||||
<QScrollArea v-if="showFilter" class="fit text-grey-8">
|
||||
<QScrollArea class="fit text-grey-8">
|
||||
<OrderCatalogFilter
|
||||
:data-key="dataKey"
|
||||
:tag-value="tagValue"
|
||||
|
@ -128,8 +105,6 @@ watch(
|
|||
url="Orders/CatalogFilter"
|
||||
:limit="50"
|
||||
:user-params="catalogParams"
|
||||
@on-fetch="showFilter = true"
|
||||
:update-router="false"
|
||||
:auto-load="autoLoad"
|
||||
>
|
||||
<template #body="{ rows }">
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<script setup>
|
||||
import { computed, ref, onMounted } from 'vue';
|
||||
import { ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRoute } from 'vue-router';
|
||||
import axios from 'axios';
|
||||
|
@ -8,7 +8,6 @@ import VnFilterPanel from 'src/components/ui/VnFilterPanel.vue';
|
|||
import VnSelect from 'components/common/VnSelect.vue';
|
||||
import VnFilterPanelChip from 'components/ui/VnFilterPanelChip.vue';
|
||||
import VnInput from 'src/components/common/VnInput.vue';
|
||||
import getParamWhere from 'src/filters/getParamWhere';
|
||||
import CatalogFilterValueDialog from 'src/pages/Order/Card/CatalogFilterValueDialog.vue';
|
||||
import { useArrayData } from 'composables/useArrayData';
|
||||
|
||||
|
@ -32,11 +31,8 @@ const route = useRoute();
|
|||
|
||||
const arrayData = useArrayData(props.dataKey);
|
||||
|
||||
const currentParams = ref({});
|
||||
const categoryList = ref(null);
|
||||
const selectedCategoryFk = ref(null);
|
||||
const typeList = ref([]);
|
||||
const selectedTypeFk = ref(null);
|
||||
const searchByTag = ref(null);
|
||||
|
||||
const vnFilterPanelRef = ref();
|
||||
|
@ -53,50 +49,32 @@ const orderWayList = ref([
|
|||
const orderBySelected = ref('relevancy DESC, name');
|
||||
const orderWaySelected = ref('ASC');
|
||||
|
||||
onMounted(() => {
|
||||
selectedCategoryFk.value = getParamWhere(route, 'categoryFk');
|
||||
selectedTypeFk.value = getParamWhere(route, 'typeFk');
|
||||
});
|
||||
|
||||
const resetCategory = (params, search) => {
|
||||
selectedCategoryFk.value = null;
|
||||
typeList.value = null;
|
||||
params.categoryFk = null;
|
||||
params.typeFk = null;
|
||||
arrayData.store.userFilter = null;
|
||||
removeTagGroupParam(search);
|
||||
};
|
||||
|
||||
const selectCategory = (params, category, search) => {
|
||||
if (params.categoryFk === category?.id) {
|
||||
resetCategory(params, search);
|
||||
return;
|
||||
}
|
||||
selectedCategoryFk.value = category?.id;
|
||||
params.categoryFk = category?.id;
|
||||
params.typeFk = null;
|
||||
selectedTypeFk.value = null;
|
||||
loadTypes(category?.id);
|
||||
search();
|
||||
};
|
||||
|
||||
const loadTypes = async (categoryFk = selectedCategoryFk.value) => {
|
||||
const selectCategory = async (params, category, search) => {
|
||||
if (vnFilterPanelRef.value.params.categoryFk === category?.id) {
|
||||
resetCategory(params, search);
|
||||
return;
|
||||
}
|
||||
params.typeFk = null;
|
||||
params.categoryFk = category.id;
|
||||
await loadTypes(category?.id);
|
||||
await search();
|
||||
};
|
||||
|
||||
const loadTypes = async (id) => {
|
||||
const { data } = await axios.get(`Orders/${route.params.id}/getItemTypeAvailable`, {
|
||||
params: { itemCategoryId: categoryFk },
|
||||
params: { itemCategoryId: id },
|
||||
});
|
||||
typeList.value = data;
|
||||
};
|
||||
|
||||
const selectedCategory = computed(() => {
|
||||
return (categoryList.value || []).find(
|
||||
(category) => category?.id === selectedCategoryFk.value
|
||||
);
|
||||
});
|
||||
|
||||
const selectedType = computed(() => {
|
||||
return (typeList.value || []).find((type) => type?.id === selectedTypeFk.value);
|
||||
});
|
||||
|
||||
function exprBuilder(param, value) {
|
||||
switch (param) {
|
||||
case 'categoryFk':
|
||||
|
@ -122,21 +100,21 @@ const applyTags = (tagInfo, params, search) => {
|
|||
|
||||
async function onSearchByTag(value) {
|
||||
if (!value.target.value) return;
|
||||
if (!currentParams.value?.tagGroups) {
|
||||
currentParams.value.tagGroups = [];
|
||||
if (!vnFilterPanelRef.value.params?.tagGroups) {
|
||||
vnFilterPanelRef.value.params.tagGroups = [];
|
||||
}
|
||||
|
||||
currentParams.value.tagGroups.push({
|
||||
vnFilterPanelRef.value.params.tagGroups.push({
|
||||
values: [{ value: value.target.value }],
|
||||
});
|
||||
searchByTag.value = null;
|
||||
}
|
||||
|
||||
const removeTagGroupParam = (search, valIndex) => {
|
||||
const removeTagGroupParam = (params, search, valIndex) => {
|
||||
if (!valIndex && valIndex !== 0) {
|
||||
currentParams.value.tagGroups = null;
|
||||
params.tagGroups = null;
|
||||
} else {
|
||||
currentParams.value.tagGroups.splice(valIndex, 1);
|
||||
params.tagGroups.splice(valIndex, 1);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -148,7 +126,8 @@ const setCategoryList = (data) => {
|
|||
icon: `vn:${(category.icon || '').split('-')[1]}`,
|
||||
}));
|
||||
|
||||
selectedCategoryFk.value && loadTypes();
|
||||
vnFilterPanelRef.value.params.categoryFk &&
|
||||
loadTypes(vnFilterPanelRef.value.params.categoryFk);
|
||||
};
|
||||
|
||||
const getCategoryClass = (category, params) => {
|
||||
|
@ -157,12 +136,6 @@ const getCategoryClass = (category, params) => {
|
|||
}
|
||||
};
|
||||
|
||||
const clearFilter = (key) => {
|
||||
if (key === 'categoryFk') {
|
||||
resetCategory();
|
||||
}
|
||||
};
|
||||
|
||||
function addOrder(value, field, params) {
|
||||
let { orderBy } = params;
|
||||
orderBy = JSON.parse(orderBy);
|
||||
|
@ -170,11 +143,6 @@ function addOrder(value, field, params) {
|
|||
params.orderBy = JSON.stringify(orderBy);
|
||||
vnFilterPanelRef.value.search();
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
selectedCategoryFk.value = getParamWhere(route, 'categoryFk');
|
||||
selectedTypeFk.value = getParamWhere(route, 'typeFk');
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
@ -182,24 +150,22 @@ onMounted(() => {
|
|||
<VnFilterPanel
|
||||
ref="vnFilterPanelRef"
|
||||
:data-key="props.dataKey"
|
||||
:hidden-tags="['orderFk', 'orderBy']"
|
||||
:un-removable-params="['orderFk', 'orderBy']"
|
||||
:hidden-tags="['filter', 'orderFk', 'orderBy']"
|
||||
:unremovable-params="['orderFk', 'orderBy']"
|
||||
:expr-builder="exprBuilder"
|
||||
:custom-tags="['tagGroups', 'categoryFk']"
|
||||
:redirect="false"
|
||||
@remove="clearFilter"
|
||||
v-model="currentParams"
|
||||
>
|
||||
<template #tags="{ tag, formatFn }">
|
||||
<strong v-if="tag.label === 'typeFk'">
|
||||
{{ t(selectedType?.name || '') }}
|
||||
<strong v-if="tag.label === 'typeFk' && typeList">
|
||||
{{ t(typeList.find((t) => t.id == tag.value)?.name || '') }}
|
||||
</strong>
|
||||
<div v-else class="q-gutter-x-xs">
|
||||
<strong>{{ t(`params.${tag.label}`) }}: </strong>
|
||||
<span>{{ formatFn(tag.value) }}</span>
|
||||
</div>
|
||||
</template>
|
||||
<template #customTags="{ tags: customTags, params, searchFn }">
|
||||
<template #customTags="{ params, tags: customTags, searchFn }">
|
||||
<template v-for="customTag in customTags" :key="customTag.label">
|
||||
<VnFilterPanelChip
|
||||
v-for="(tag, valIndex) in Array.isArray(customTag.value)
|
||||
|
@ -210,11 +176,16 @@ onMounted(() => {
|
|||
@remove="
|
||||
customTag.label === 'categoryFk'
|
||||
? resetCategory(params, searchFn)
|
||||
: removeTagGroupParam(searchFn, valIndex)
|
||||
: removeTagGroupParam(params, searchFn, valIndex)
|
||||
"
|
||||
>
|
||||
<strong v-if="customTag.label === 'categoryFk'">
|
||||
{{ t(selectedCategory?.name || '') }}
|
||||
<strong v-if="customTag.label === 'categoryFk' && categoryList">
|
||||
{{
|
||||
t(
|
||||
categoryList.find((c) => c.id == customTag.value)?.name ||
|
||||
''
|
||||
)
|
||||
}}
|
||||
</strong>
|
||||
<strong v-if="tag?.tagSelection?.name" class="q-mr-xs">
|
||||
{{ tag.tagSelection.name }}:
|
||||
|
@ -261,13 +232,8 @@ onMounted(() => {
|
|||
emit-value
|
||||
use-input
|
||||
sort-by="name ASC"
|
||||
:disable="!selectedCategoryFk"
|
||||
@update:model-value="
|
||||
(value) => {
|
||||
selectedTypeFk = value;
|
||||
searchFn();
|
||||
}
|
||||
"
|
||||
:disable="!params.categoryFk"
|
||||
@update:model-value="searchFn()"
|
||||
>
|
||||
<template #option="{ itemProps, opt }">
|
||||
<QItem v-bind="itemProps">
|
||||
|
@ -337,7 +303,7 @@ onMounted(() => {
|
|||
style="display: inline-block"
|
||||
:tags="tags"
|
||||
@apply-tags="
|
||||
($event) => applyTags($event, currentParams, searchFn)
|
||||
($event) => applyTags($event, params, searchFn)
|
||||
"
|
||||
/>
|
||||
</QPopupProxy>
|
||||
|
|
|
@ -20,22 +20,17 @@ const addressList = ref([]);
|
|||
defineEmits(['confirm', ...useDialogPluginComponent.emits]);
|
||||
|
||||
const fetchAddressList = async (addressId) => {
|
||||
try {
|
||||
const { data } = await axios.get('addresses', {
|
||||
params: {
|
||||
filter: JSON.stringify({
|
||||
fields: ['id', 'nickname', 'street', 'city'],
|
||||
where: { id: addressId },
|
||||
}),
|
||||
},
|
||||
});
|
||||
addressList.value = data;
|
||||
if (addressList.value?.length === 1) {
|
||||
state.get(ORDER_MODEL).addressId = addressList.value[0].id;
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(`Error fetching addresses`, err);
|
||||
return err.response;
|
||||
const { data } = await axios.get('addresses', {
|
||||
params: {
|
||||
filter: JSON.stringify({
|
||||
fields: ['id', 'nickname', 'street', 'city'],
|
||||
where: { id: addressId },
|
||||
}),
|
||||
},
|
||||
});
|
||||
addressList.value = data;
|
||||
if (addressList.value?.length === 1) {
|
||||
state.get(ORDER_MODEL).addressId = addressList.value[0].id;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -43,18 +38,13 @@ const fetchAgencyList = async (landed, addressFk) => {
|
|||
if (!landed || !addressFk) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const { data } = await axios.get('Agencies/landsThatDay', {
|
||||
params: {
|
||||
addressFk,
|
||||
landed: new Date(landed).toISOString(),
|
||||
},
|
||||
});
|
||||
agencyList.value = data;
|
||||
} catch (err) {
|
||||
console.error(`Error fetching agencies`, err);
|
||||
return err.response;
|
||||
}
|
||||
const { data } = await axios.get('Agencies/landsThatDay', {
|
||||
params: {
|
||||
addressFk,
|
||||
landed: new Date(landed).toISOString(),
|
||||
},
|
||||
});
|
||||
agencyList.value = data;
|
||||
};
|
||||
|
||||
const $props = defineProps({
|
||||
|
@ -70,12 +60,8 @@ const initialFormState = reactive({
|
|||
});
|
||||
|
||||
const onClientChange = async (clientId = $props.clientFk) => {
|
||||
try {
|
||||
const { data } = await axios.get(`Clients/${clientId}`);
|
||||
await fetchAddressList(data.defaultAddressFk);
|
||||
} catch (error) {
|
||||
console.error('Error al cambiar el cliente:', error);
|
||||
}
|
||||
const { data } = await axios.get(`Clients/${clientId}`);
|
||||
await fetchAddressList(data.defaultAddressFk);
|
||||
};
|
||||
|
||||
async function onDataSaved(_, id) {
|
||||
|
|
|
@ -47,17 +47,13 @@ const onChangesSaved = () => {
|
|||
};
|
||||
|
||||
const setWireTransfer = async () => {
|
||||
try {
|
||||
const params = {
|
||||
id: route.params.id,
|
||||
payMethodFk: wireTransferFk.value,
|
||||
};
|
||||
const params = {
|
||||
id: route.params.id,
|
||||
payMethodFk: wireTransferFk.value,
|
||||
};
|
||||
|
||||
await axios.patch(`Suppliers/${route.params.id}`, params);
|
||||
notify('globals.dataSaved', 'positive');
|
||||
} catch (err) {
|
||||
console.error('Error setting wire transfer', err);
|
||||
}
|
||||
await axios.patch(`Suppliers/${route.params.id}`, params);
|
||||
notify('globals.dataSaved', 'positive');
|
||||
};
|
||||
</script>
|
||||
<template>
|
||||
|
|
|
@ -33,6 +33,7 @@ const canEditZone = useAcl().hasAny([
|
|||
const agencyFetchRef = ref();
|
||||
const warehousesOptions = ref([]);
|
||||
const companiesOptions = ref([]);
|
||||
const currenciesOptions = ref([]);
|
||||
const agenciesOptions = ref([]);
|
||||
const zonesOptions = ref([]);
|
||||
const addresses = ref([]);
|
||||
|
|
|
@ -49,13 +49,7 @@ async function handleSave() {
|
|||
|
||||
<template>
|
||||
<FetchData
|
||||
@on-fetch="
|
||||
(data) =>
|
||||
(observationTypes = data.map((type) => {
|
||||
type.label = t(`ticketNotes.observationTypes.${type.description}`);
|
||||
return type;
|
||||
}))
|
||||
"
|
||||
@on-fetch="(data) => (observationTypes = data)"
|
||||
auto-load
|
||||
url="ObservationTypes"
|
||||
/>
|
||||
|
@ -82,7 +76,7 @@ async function handleSave() {
|
|||
:label="t('ticketNotes.observationType')"
|
||||
:options="observationTypes"
|
||||
hide-selected
|
||||
option-label="label"
|
||||
option-label="description"
|
||||
option-value="id"
|
||||
v-model="row.observationTypeFk"
|
||||
:disable="!!row.id"
|
||||
|
|
|
@ -172,13 +172,9 @@ const getRequestState = (state) => {
|
|||
const isEditable = (isOk) => isOk !== null;
|
||||
|
||||
async function removeLine(id) {
|
||||
try {
|
||||
await axios.delete(`TicketRequests/${id}`);
|
||||
notify(t('globals.dataSaved'), 'positive');
|
||||
location.reload();
|
||||
} catch (err) {
|
||||
console.error('Error ', err);
|
||||
}
|
||||
await axios.delete(`TicketRequests/${id}`);
|
||||
notify(t('globals.dataSaved'), 'positive');
|
||||
location.reload();
|
||||
}
|
||||
|
||||
onMounted(() => (stateStore.rightDrawer = false));
|
||||
|
|
|
@ -156,15 +156,11 @@ const columns = computed(() => [
|
|||
]);
|
||||
|
||||
const getConfig = async () => {
|
||||
try {
|
||||
let filter = {
|
||||
fields: ['daysForWarningClaim'],
|
||||
};
|
||||
const { data } = await axios.get(`TicketConfigs`, { filter });
|
||||
ticketConfig.value = data;
|
||||
} catch (err) {
|
||||
console.error('Error getting ticket config', err);
|
||||
}
|
||||
let filter = {
|
||||
fields: ['daysForWarningClaim'],
|
||||
};
|
||||
const { data } = await axios.get(`TicketConfigs`, { filter });
|
||||
ticketConfig.value = data;
|
||||
};
|
||||
|
||||
const onSalesFetched = (salesData) => {
|
||||
|
@ -187,41 +183,33 @@ const resetChanges = async () => {
|
|||
};
|
||||
|
||||
const updateQuantity = async (sale) => {
|
||||
try {
|
||||
const payload = { quantity: sale.quantity };
|
||||
await axios.post(`Sales/${sale.id}/updateQuantity`, payload);
|
||||
notify('globals.dataSaved', 'positive');
|
||||
} catch (err) {
|
||||
console.error('Error updating quantity', err);
|
||||
}
|
||||
const payload = { quantity: sale.quantity };
|
||||
await axios.post(`Sales/${sale.id}/updateQuantity`, payload);
|
||||
notify('globals.dataSaved', 'positive');
|
||||
};
|
||||
|
||||
const addSale = async (sale) => {
|
||||
try {
|
||||
const payload = {
|
||||
barcode: sale.itemFk,
|
||||
quantity: sale.quantity,
|
||||
};
|
||||
const payload = {
|
||||
barcode: sale.itemFk,
|
||||
quantity: sale.quantity,
|
||||
};
|
||||
|
||||
const { data } = await axios.post(`tickets/${route.params.id}/addSale`, payload);
|
||||
const { data } = await axios.post(`tickets/${route.params.id}/addSale`, payload);
|
||||
|
||||
if (!data) return;
|
||||
if (!data) return;
|
||||
|
||||
const newSale = data;
|
||||
sale.id = newSale.id;
|
||||
sale.image = newSale.item.image;
|
||||
sale.subName = newSale.item.subName;
|
||||
sale.concept = newSale.concept;
|
||||
sale.quantity = newSale.quantity;
|
||||
sale.discount = newSale.discount;
|
||||
sale.price = newSale.price;
|
||||
sale.item = newSale.item;
|
||||
const newSale = data;
|
||||
sale.id = newSale.id;
|
||||
sale.image = newSale.item.image;
|
||||
sale.subName = newSale.item.subName;
|
||||
sale.concept = newSale.concept;
|
||||
sale.quantity = newSale.quantity;
|
||||
sale.discount = newSale.discount;
|
||||
sale.price = newSale.price;
|
||||
sale.item = newSale.item;
|
||||
|
||||
notify('globals.dataSaved', 'positive');
|
||||
window.location.reload();
|
||||
} catch (err) {
|
||||
console.error('Error adding sale', err);
|
||||
}
|
||||
notify('globals.dataSaved', 'positive');
|
||||
window.location.reload();
|
||||
};
|
||||
|
||||
const changeQuantity = async (sale) => {
|
||||
|
@ -240,13 +228,9 @@ const changeQuantity = async (sale) => {
|
|||
const updateConcept = async (sale) => {
|
||||
canProceed.value = await isSalePrepared(sale);
|
||||
if (!canProceed.value) return;
|
||||
try {
|
||||
const data = { newConcept: sale.concept };
|
||||
await axios.post(`Sales/${sale.id}/updateConcept`, data);
|
||||
notify('globals.dataSaved', 'positive');
|
||||
} catch (err) {
|
||||
console.error('Error updating concept', err);
|
||||
}
|
||||
const data = { newConcept: sale.concept };
|
||||
await axios.post(`Sales/${sale.id}/updateConcept`, data);
|
||||
notify('globals.dataSaved', 'positive');
|
||||
};
|
||||
|
||||
const DEFAULT_EDIT = {
|
||||
|
@ -302,18 +286,15 @@ const onOpenEditDiscountPopover = async (sale) => {
|
|||
const updatePrice = async (sale) => {
|
||||
canProceed.value = await isSalePrepared(sale);
|
||||
if (!canProceed.value) return;
|
||||
try {
|
||||
const newPrice = edit.value.price;
|
||||
if (newPrice != null && newPrice != sale.price) {
|
||||
await axios.post(`Sales/${sale.id}/updatePrice`, { newPrice });
|
||||
sale.price = newPrice;
|
||||
edit.value = { ...DEFAULT_EDIT };
|
||||
notify('globals.dataSaved', 'positive');
|
||||
}
|
||||
await getMana();
|
||||
} catch (err) {
|
||||
console.error('Error updating price', err);
|
||||
const newPrice = edit.value.price;
|
||||
if (newPrice != null && newPrice != sale.price) {
|
||||
await axios.post(`Sales/${sale.id}/updatePrice`, { newPrice });
|
||||
sale.price = newPrice;
|
||||
edit.value = { ...DEFAULT_EDIT };
|
||||
notify('globals.dataSaved', 'positive');
|
||||
}
|
||||
|
||||
await getMana();
|
||||
};
|
||||
|
||||
const changeDiscount = async (sale) => {
|
||||
|
@ -360,15 +341,11 @@ const getNewPrice = computed(() => {
|
|||
});
|
||||
|
||||
const newOrderFromTicket = async () => {
|
||||
try {
|
||||
const { data } = await axios.post(`Orders/newFromTicket`, {
|
||||
ticketFk: Number(route.params.id),
|
||||
});
|
||||
const routeData = router.resolve({ name: 'OrderCatalog', params: { id: data } });
|
||||
window.open(routeData.href, '_blank');
|
||||
} catch (err) {
|
||||
console.error('Error creating new order', err);
|
||||
}
|
||||
const { data } = await axios.post(`Orders/newFromTicket`, {
|
||||
ticketFk: Number(route.params.id),
|
||||
});
|
||||
const routeData = router.resolve({ name: 'OrderCatalog', params: { id: data } });
|
||||
window.open(routeData.href, '_blank');
|
||||
};
|
||||
|
||||
const goToLog = (saleId) => {
|
||||
|
@ -383,15 +360,11 @@ const goToLog = (saleId) => {
|
|||
};
|
||||
|
||||
const changeTicketState = async (val) => {
|
||||
try {
|
||||
stateBtnDropdownRef.value.hide();
|
||||
const params = { ticketFk: route.params.id, code: val };
|
||||
await axios.post('Tickets/state', params);
|
||||
notify('globals.dataSaved', 'positive');
|
||||
await resetChanges();
|
||||
} catch (err) {
|
||||
console.error('Error changing ticket state', err);
|
||||
}
|
||||
stateBtnDropdownRef.value.hide();
|
||||
const params = { ticketFk: route.params.id, code: val };
|
||||
await axios.post('Tickets/state', params);
|
||||
notify('globals.dataSaved', 'positive');
|
||||
await resetChanges();
|
||||
};
|
||||
|
||||
const removeSelectedSales = () => {
|
||||
|
@ -402,47 +375,34 @@ const removeSelectedSales = () => {
|
|||
};
|
||||
|
||||
const removeSales = async () => {
|
||||
try {
|
||||
const params = {
|
||||
sales: selectedRows.value.filter((sale) => sale.id),
|
||||
ticketId: store.data.id,
|
||||
};
|
||||
selectedRows.value
|
||||
.filter((sale) => !sale.id)
|
||||
.forEach((sale) =>
|
||||
tableRef.value.CrudModelRef.formData.splice(sale.$index, 1)
|
||||
);
|
||||
const params = {
|
||||
sales: selectedRows.value.filter((sale) => sale.id),
|
||||
ticketId: store.data.id,
|
||||
};
|
||||
selectedRows.value
|
||||
.filter((sale) => !sale.id)
|
||||
.forEach((sale) => tableRef.value.CrudModelRef.formData.splice(sale.$index, 1));
|
||||
|
||||
if (params.sales.length == 0) return;
|
||||
await axios.post('Sales/deleteSales', params);
|
||||
removeSelectedSales();
|
||||
notify('globals.dataSaved', 'positive');
|
||||
window.location.reload();
|
||||
} catch (err) {
|
||||
console.error('Error deleting sales', err);
|
||||
}
|
||||
if (params.sales.length == 0) return;
|
||||
await axios.post('Sales/deleteSales', params);
|
||||
removeSelectedSales();
|
||||
notify('globals.dataSaved', 'positive');
|
||||
window.location.reload();
|
||||
};
|
||||
|
||||
const setTransferParams = async () => {
|
||||
try {
|
||||
selectedSales.value = selectedValidSales.value;
|
||||
const checkedSales = JSON.parse(JSON.stringify(selectedSales.value));
|
||||
transfer.value = {
|
||||
lastActiveTickets: [],
|
||||
sales: checkedSales,
|
||||
};
|
||||
selectedSales.value = selectedValidSales.value;
|
||||
const checkedSales = JSON.parse(JSON.stringify(selectedSales.value));
|
||||
transfer.value = {
|
||||
lastActiveTickets: [],
|
||||
sales: checkedSales,
|
||||
};
|
||||
|
||||
const params = { ticketId: store.data.id };
|
||||
const { data } = await axios.get(
|
||||
`clients/${store.data.clientFk}/lastActiveTickets`,
|
||||
{
|
||||
params,
|
||||
}
|
||||
);
|
||||
transfer.value.lastActiveTickets = data;
|
||||
} catch (err) {
|
||||
console.error('Error setting transfer params', err);
|
||||
}
|
||||
const params = { ticketId: store.data.id };
|
||||
const { data } = await axios.get(`clients/${store.data.clientFk}/lastActiveTickets`, {
|
||||
params,
|
||||
});
|
||||
transfer.value.lastActiveTickets = data;
|
||||
};
|
||||
|
||||
onMounted(async () => {
|
||||
|
|
|
@ -140,13 +140,9 @@ const createClaim = () => {
|
|||
};
|
||||
|
||||
const onCreateClaimAccepted = async () => {
|
||||
try {
|
||||
const params = { ticketId: ticket.value.id, sales: props.sales };
|
||||
const { data } = await axios.post(`Claims/createFromSales`, params);
|
||||
push({ name: 'ClaimBasicData', params: { id: data.id } });
|
||||
} catch (error) {
|
||||
console.error('Error creating claim: ', error);
|
||||
}
|
||||
const params = { ticketId: ticket.value.id, sales: props.sales };
|
||||
const { data } = await axios.post(`Claims/createFromSales`, params);
|
||||
push({ name: 'ClaimBasicData', params: { id: data.id } });
|
||||
};
|
||||
|
||||
const setReserved = async (reserved) => {
|
||||
|
|
|
@ -69,19 +69,15 @@ function isEditable() {
|
|||
}
|
||||
|
||||
async function changeState(value) {
|
||||
try {
|
||||
stateBtnDropdownRef.value?.hide();
|
||||
const formData = {
|
||||
ticketFk: entityId.value,
|
||||
code: value,
|
||||
};
|
||||
await axios.post(`Tickets/state`, formData);
|
||||
notify('globals.dataSaved', 'positive');
|
||||
summaryRef.value?.fetch();
|
||||
descriptorData.fetch({});
|
||||
} catch (err) {
|
||||
console.error('Error changing ticket state', err);
|
||||
}
|
||||
stateBtnDropdownRef.value?.hide();
|
||||
const formData = {
|
||||
ticketFk: entityId.value,
|
||||
code: value,
|
||||
};
|
||||
await axios.post(`Tickets/state`, formData);
|
||||
notify('globals.dataSaved', 'positive');
|
||||
summaryRef.value?.fetch();
|
||||
descriptorData.fetch({});
|
||||
}
|
||||
|
||||
function toTicketUrl(section) {
|
||||
|
@ -280,13 +276,8 @@ function toTicketUrl(section) {
|
|||
"
|
||||
>
|
||||
<span class="label" style="margin-right: 4px">
|
||||
({{
|
||||
t(
|
||||
`ticketNotes.observationTypes.${item.observationType.description}`
|
||||
)
|
||||
}}):
|
||||
({{ item.observationType.description }}):
|
||||
</span>
|
||||
|
||||
<span>{{ item.description }}</span>
|
||||
</QItem>
|
||||
</QVirtualScroll>
|
||||
|
|
|
@ -37,46 +37,37 @@ onBeforeMount(async () => {
|
|||
});
|
||||
|
||||
const fetchClient = async (formData) => {
|
||||
try {
|
||||
const filter = {
|
||||
include: {
|
||||
relation: 'defaultAddress',
|
||||
scope: {
|
||||
fields: ['id', 'agencyModeFk'],
|
||||
},
|
||||
const filter = {
|
||||
include: {
|
||||
relation: 'defaultAddress',
|
||||
scope: {
|
||||
fields: ['id', 'agencyModeFk'],
|
||||
},
|
||||
where: { id: formData.clientId },
|
||||
};
|
||||
const params = { filter: JSON.stringify(filter) };
|
||||
const { data } = await axios.get('Clients', { params });
|
||||
const [client] = data;
|
||||
selectedClient.value = client;
|
||||
} catch (err) {
|
||||
console.error('Error fetching client');
|
||||
}
|
||||
},
|
||||
where: { id: formData.clientId },
|
||||
};
|
||||
const params = { filter: JSON.stringify(filter) };
|
||||
const { data } = await axios.get('Clients', { params });
|
||||
const [client] = data;
|
||||
selectedClient.value = client;
|
||||
};
|
||||
|
||||
const fetchAddresses = async (formData) => {
|
||||
try {
|
||||
if (!formData.clientId) return;
|
||||
if (!formData.clientId) return;
|
||||
|
||||
const filter = {
|
||||
fields: ['nickname', 'street', 'city', 'id'],
|
||||
where: { isActive: true },
|
||||
order: 'nickname ASC',
|
||||
};
|
||||
const params = { filter: JSON.stringify(filter) };
|
||||
const { data } = await axios.get(`Clients/${formData.clientId}/addresses`, {
|
||||
params,
|
||||
});
|
||||
addressesOptions.value = data;
|
||||
const filter = {
|
||||
fields: ['nickname', 'street', 'city', 'id'],
|
||||
where: { isActive: true },
|
||||
order: 'nickname ASC',
|
||||
};
|
||||
const params = { filter: JSON.stringify(filter) };
|
||||
const { data } = await axios.get(`Clients/${formData.clientId}/addresses`, {
|
||||
params,
|
||||
});
|
||||
addressesOptions.value = data;
|
||||
|
||||
const { defaultAddress } = selectedClient.value;
|
||||
formData.addressId = defaultAddress.id;
|
||||
} catch (err) {
|
||||
console.error(`Error fetching addresses`, err);
|
||||
return err.response;
|
||||
}
|
||||
const { defaultAddress } = selectedClient.value;
|
||||
formData.addressId = defaultAddress.id;
|
||||
};
|
||||
|
||||
const onClientSelected = async (formData) => {
|
||||
|
|
|
@ -37,46 +37,37 @@ onBeforeMount(async () => {
|
|||
});
|
||||
|
||||
const fetchClient = async (formData) => {
|
||||
try {
|
||||
const filter = {
|
||||
include: {
|
||||
relation: 'defaultAddress',
|
||||
scope: {
|
||||
fields: ['id', 'agencyModeFk'],
|
||||
},
|
||||
const filter = {
|
||||
include: {
|
||||
relation: 'defaultAddress',
|
||||
scope: {
|
||||
fields: ['id', 'agencyModeFk'],
|
||||
},
|
||||
where: { id: formData.clientId },
|
||||
};
|
||||
const params = { filter: JSON.stringify(filter) };
|
||||
const { data } = await axios.get('Clients', { params });
|
||||
const [client] = data;
|
||||
selectedClient.value = client;
|
||||
} catch (err) {
|
||||
console.error('Error fetching client');
|
||||
}
|
||||
},
|
||||
where: { id: formData.clientId },
|
||||
};
|
||||
const params = { filter: JSON.stringify(filter) };
|
||||
const { data } = await axios.get('Clients', { params });
|
||||
const [client] = data;
|
||||
selectedClient.value = client;
|
||||
};
|
||||
|
||||
const fetchAddresses = async (formData) => {
|
||||
try {
|
||||
if (!formData.clientId) return;
|
||||
if (!formData.clientId) return;
|
||||
|
||||
const filter = {
|
||||
fields: ['nickname', 'street', 'city', 'id'],
|
||||
where: { isActive: true },
|
||||
order: 'nickname ASC',
|
||||
};
|
||||
const params = { filter: JSON.stringify(filter) };
|
||||
const { data } = await axios.get(`Clients/${formData.clientId}/addresses`, {
|
||||
params,
|
||||
});
|
||||
addressesOptions.value = data;
|
||||
const filter = {
|
||||
fields: ['nickname', 'street', 'city', 'id'],
|
||||
where: { isActive: true },
|
||||
order: 'nickname ASC',
|
||||
};
|
||||
const params = { filter: JSON.stringify(filter) };
|
||||
const { data } = await axios.get(`Clients/${formData.clientId}/addresses`, {
|
||||
params,
|
||||
});
|
||||
addressesOptions.value = data;
|
||||
|
||||
const { defaultAddress } = selectedClient.value;
|
||||
formData.addressId = defaultAddress.id;
|
||||
} catch (err) {
|
||||
console.error(`Error fetching addresses`, err);
|
||||
return err.response;
|
||||
}
|
||||
const { defaultAddress } = selectedClient.value;
|
||||
formData.addressId = defaultAddress.id;
|
||||
};
|
||||
|
||||
const onClientSelected = async (formData) => {
|
||||
|
|
|
@ -68,13 +68,9 @@ const params = reactive({
|
|||
});
|
||||
|
||||
const applyColumnFilter = async (col) => {
|
||||
try {
|
||||
const paramKey = col.columnFilter?.filterParamKey || col.field;
|
||||
params[paramKey] = col.columnFilter.filterValue;
|
||||
await arrayData.addFilter({ params });
|
||||
} catch (err) {
|
||||
console.error('Error applying column filter', err);
|
||||
}
|
||||
const paramKey = col.columnFilter?.filterParamKey || col.field;
|
||||
params[paramKey] = col.columnFilter.filterValue;
|
||||
await arrayData.addFilter({ params });
|
||||
};
|
||||
|
||||
const getInputEvents = (col) => {
|
||||
|
@ -248,23 +244,19 @@ const totalPriceColor = (totalWithVat) =>
|
|||
isLessThan50(totalWithVat) ? 'warning' : 'transparent';
|
||||
|
||||
const moveTicketsFuture = async () => {
|
||||
try {
|
||||
const ticketsToMove = selectedTickets.value.map((ticket) => ({
|
||||
originId: ticket.id,
|
||||
destinationId: ticket.futureId,
|
||||
originShipped: ticket.shipped,
|
||||
destinationShipped: ticket.futureShipped,
|
||||
workerFk: ticket.workerFk,
|
||||
}));
|
||||
const ticketsToMove = selectedTickets.value.map((ticket) => ({
|
||||
originId: ticket.id,
|
||||
destinationId: ticket.futureId,
|
||||
originShipped: ticket.shipped,
|
||||
destinationShipped: ticket.futureShipped,
|
||||
workerFk: ticket.workerFk,
|
||||
}));
|
||||
|
||||
let params = { tickets: ticketsToMove };
|
||||
await axios.post('Tickets/merge', params);
|
||||
notify(t('advanceTickets.moveTicketSuccess'), 'positive');
|
||||
selectedTickets.value = [];
|
||||
arrayData.fetch({ append: false });
|
||||
} catch (error) {
|
||||
console.error('Error moving tickets to future', error);
|
||||
}
|
||||
let params = { tickets: ticketsToMove };
|
||||
await axios.post('Tickets/merge', params);
|
||||
notify(t('advanceTickets.moveTicketSuccess'), 'positive');
|
||||
selectedTickets.value = [];
|
||||
arrayData.fetch({ append: false });
|
||||
};
|
||||
onMounted(async () => {
|
||||
await arrayData.fetch({ append: false });
|
||||
|
|
|
@ -254,46 +254,40 @@ const fetchAvailableAgencies = async (formData) => {
|
|||
};
|
||||
|
||||
const fetchClient = async (formData) => {
|
||||
try {
|
||||
const filter = {
|
||||
include: {
|
||||
relation: 'defaultAddress',
|
||||
scope: {
|
||||
fields: ['id', 'agencyModeFk'],
|
||||
},
|
||||
const filter = {
|
||||
include: {
|
||||
relation: 'defaultAddress',
|
||||
scope: {
|
||||
fields: ['id', 'agencyModeFk'],
|
||||
},
|
||||
where: { id: formData.clientId },
|
||||
};
|
||||
const params = { filter: JSON.stringify(filter) };
|
||||
const { data } = await axios.get('Clients', { params });
|
||||
const [client] = data;
|
||||
selectedClient.value = client;
|
||||
} catch (err) {
|
||||
console.error('Error fetching client');
|
||||
}
|
||||
},
|
||||
where: { id: formData.clientId },
|
||||
};
|
||||
const params = { filter: JSON.stringify(filter) };
|
||||
const { data } = await axios.get('Clients', { params });
|
||||
const [client] = data;
|
||||
selectedClient.value = client;
|
||||
};
|
||||
|
||||
const fetchAddresses = async (formData) => {
|
||||
try {
|
||||
if (!formData.clientId) return;
|
||||
if (!formData.clientId) return;
|
||||
|
||||
const filter = {
|
||||
fields: ['nickname', 'street', 'city', 'id', 'isActive'],
|
||||
order: 'nickname ASC',
|
||||
};
|
||||
const params = { filter: JSON.stringify(filter) };
|
||||
const { data } = await axios.get(`Clients/${formData.clientId}/addresses`, {
|
||||
params,
|
||||
});
|
||||
addressesOptions.value = data;
|
||||
const filter = {
|
||||
fields: ['nickname', 'street', 'city', 'id', 'isActive'],
|
||||
order: 'nickname ASC',
|
||||
};
|
||||
const params = { filter: JSON.stringify(filter) };
|
||||
const { data } = await axios.get(`Clients/${formData.clientId}/addresses`, {
|
||||
params,
|
||||
});
|
||||
addressesOptions.value = data;
|
||||
|
||||
const { defaultAddress } = selectedClient.value;
|
||||
formData.addressId = defaultAddress.id;
|
||||
} catch (err) {
|
||||
console.error(`Error fetching addresses`, err);
|
||||
return err.response;
|
||||
}
|
||||
addressesOptions.value = data;
|
||||
|
||||
const { defaultAddress } = selectedClient.value;
|
||||
formData.addressId = defaultAddress.id;
|
||||
};
|
||||
|
||||
const getColor = (row) => {
|
||||
if (row.alertLevelCode === 'OK') return 'bg-success';
|
||||
else if (row.alertLevelCode === 'FREE') return 'bg-notice';
|
||||
|
|
|
@ -153,24 +153,16 @@ const columns = computed(() => [
|
|||
]);
|
||||
|
||||
const deleteWeekly = async (ticketFk) => {
|
||||
try {
|
||||
await axios.delete(`TicketWeeklies/${ticketFk}`);
|
||||
notify(t('globals.dataSaved'), 'positive');
|
||||
const ticketIndex = store.data.findIndex((e) => e.ticketFk == ticketFk);
|
||||
store.data.splice(ticketIndex, 1);
|
||||
location.reload();
|
||||
} catch (err) {
|
||||
console.error('Error deleting weekly', err);
|
||||
}
|
||||
await axios.delete(`TicketWeeklies/${ticketFk}`);
|
||||
notify(t('globals.dataSaved'), 'positive');
|
||||
const ticketIndex = store.data.findIndex((e) => e.ticketFk == ticketFk);
|
||||
store.data.splice(ticketIndex, 1);
|
||||
location.reload();
|
||||
};
|
||||
|
||||
const onUpdate = async (ticketFk, field, value) => {
|
||||
try {
|
||||
const params = { ticketFk, [field]: value };
|
||||
await axios.patch('TicketWeeklies', params);
|
||||
} catch (err) {
|
||||
console.error('Error updating weekly', err);
|
||||
}
|
||||
const params = { ticketFk, [field]: value };
|
||||
await axios.patch('TicketWeeklies', params);
|
||||
};
|
||||
|
||||
onMounted(async () => {
|
||||
|
|
|
@ -10,16 +10,6 @@ ticketNotes:
|
|||
observationType: Observation type
|
||||
removeNote: Remove note
|
||||
addNote: Add note
|
||||
observationTypes:
|
||||
ItemPicker: Item picker
|
||||
Packager: Packager
|
||||
Delivery: Delivery
|
||||
SalesPerson: Sales person
|
||||
Administrative: Administrative
|
||||
Weight: Weight
|
||||
InvoiceOut: Invoice Out
|
||||
DropOff: Drop Off
|
||||
Sustitución: Sustitution
|
||||
ticketSale:
|
||||
visible: Visible
|
||||
available: Available
|
||||
|
|
|
@ -19,18 +19,6 @@ ticketNotes:
|
|||
observationType: Tipo de observación
|
||||
removeNote: Quitar nota
|
||||
addNote: Añadir nota
|
||||
observationTypes:
|
||||
ItemPicker: Sacador
|
||||
Packager: Encajador
|
||||
Delivery: Envío
|
||||
SalesPerson: Comercial
|
||||
Administrative: Administrativa
|
||||
Weight: Peso
|
||||
InvoiceOut: Facturas
|
||||
DropOff: Despacho
|
||||
Sustitución: Sustitución
|
||||
Accepted: Aceptado
|
||||
Denied: Denegado
|
||||
purchaseRequest:
|
||||
requester: Solicitante
|
||||
atender: Comprador
|
||||
|
|
|
@ -21,12 +21,7 @@ const agenciesOptions = ref([]);
|
|||
@on-fetch="(data) => (agenciesOptions = data)"
|
||||
auto-load
|
||||
/>
|
||||
<FormModel
|
||||
:url="`Travels/${route.params.id}`"
|
||||
:url-update="`Travels/${route.params.id}`"
|
||||
model="Travel"
|
||||
auto-load
|
||||
>
|
||||
<FormModel :url-update="`Travels/${route.params.id}`" model="Travel" auto-load>
|
||||
<template #form="{ data }">
|
||||
<VnRow>
|
||||
<VnInput v-model="data.ref" :label="t('globals.reference')" />
|
||||
|
@ -78,6 +73,7 @@ const agenciesOptions = ref([]);
|
|||
</VnInput>
|
||||
</VnRow>
|
||||
<VnRow>
|
||||
<QCheckbox v-model="data.isRaid" :label="t('travel.basicData.isRaid')" />
|
||||
<QCheckbox
|
||||
:label="t('travel.summary.delivered')"
|
||||
v-model="data.isDelivered"
|
||||
|
@ -93,7 +89,7 @@ const agenciesOptions = ref([]);
|
|||
|
||||
<i18n>
|
||||
es:
|
||||
raidDays: Al rellenarlo, generamos una redada. Indica los días que un travel se moverá automáticamente en el tiempo
|
||||
raidDays: Si se marca "Redada", la fecha de entrega se moverá automáticamente los días indicados (incluido 0). Si se deja vacio, la fecha no cambiará
|
||||
en:
|
||||
raidDays: When filling, a raid is generated. Enter the number of days the travel will automatically forward in time
|
||||
raidDays: If "Raid" is checked, the landing date will automatically shift by the specified number of days (including 0). If left empty, the date will stay the same.
|
||||
</i18n>
|
||||
|
|
|
@ -1,34 +1,7 @@
|
|||
<script setup>
|
||||
import VnCard from 'components/common/VnCard.vue';
|
||||
import TravelDescriptor from './TravelDescriptor.vue';
|
||||
|
||||
const filter = {
|
||||
fields: [
|
||||
'id',
|
||||
'ref',
|
||||
'shipped',
|
||||
'landed',
|
||||
'totalEntries',
|
||||
'warehouseInFk',
|
||||
'warehouseOutFk',
|
||||
'cargoSupplierFk',
|
||||
'agencyModeFk',
|
||||
],
|
||||
include: [
|
||||
{
|
||||
relation: 'warehouseIn',
|
||||
scope: {
|
||||
fields: ['name'],
|
||||
},
|
||||
},
|
||||
{
|
||||
relation: 'warehouseOut',
|
||||
scope: {
|
||||
fields: ['name'],
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
import filter from './TravelFilter.js';
|
||||
</script>
|
||||
<template>
|
||||
<VnCard
|
||||
|
|
|
@ -7,6 +7,7 @@ import CardDescriptor from 'components/ui/CardDescriptor.vue';
|
|||
import VnLv from 'src/components/ui/VnLv.vue';
|
||||
import useCardDescription from 'src/composables/useCardDescription';
|
||||
import TravelDescriptorMenuItems from './TravelDescriptorMenuItems.vue';
|
||||
import filter from './TravelFilter.js';
|
||||
|
||||
import { toDate } from 'src/filters';
|
||||
|
||||
|
@ -21,35 +22,6 @@ const $props = defineProps({
|
|||
const route = useRoute();
|
||||
const { t } = useI18n();
|
||||
|
||||
const filter = {
|
||||
fields: [
|
||||
'id',
|
||||
'ref',
|
||||
'shipped',
|
||||
'landed',
|
||||
'totalEntries',
|
||||
'warehouseInFk',
|
||||
'warehouseOutFk',
|
||||
'cargoSupplierFk',
|
||||
'agencyModeFk',
|
||||
'daysInForward',
|
||||
],
|
||||
include: [
|
||||
{
|
||||
relation: 'warehouseIn',
|
||||
scope: {
|
||||
fields: ['name'],
|
||||
},
|
||||
},
|
||||
{
|
||||
relation: 'warehouseOut',
|
||||
scope: {
|
||||
fields: ['name'],
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const entityId = computed(() => {
|
||||
return $props.id || route.params.id;
|
||||
});
|
||||
|
@ -65,7 +37,7 @@ const setData = (entity) => (data.value = useCardDescription(entity.ref, entity.
|
|||
:title="data.title"
|
||||
:subtitle="data.subtitle"
|
||||
:filter="filter"
|
||||
data-key="travelData"
|
||||
data-key="Travel"
|
||||
@on-fetch="setData"
|
||||
>
|
||||
<template #menu="{ entity }">
|
||||
|
@ -80,12 +52,7 @@ const setData = (entity) => (data.value = useCardDescription(entity.ref, entity.
|
|||
</template>
|
||||
<template #icons="{ entity }">
|
||||
<QCardActions class="q-gutter-x-md">
|
||||
<QIcon
|
||||
v-if="entity.daysInForward"
|
||||
name="vn:net"
|
||||
color="primary"
|
||||
size="xs"
|
||||
>
|
||||
<QIcon v-if="entity.isRaid" name="vn:net" color="primary" size="xs">
|
||||
<QTooltip>
|
||||
{{
|
||||
t('globals.raid', { daysInForward: entity.daysInForward })
|
||||
|
|
|
@ -32,16 +32,12 @@ const cloneTravel = () => {
|
|||
};
|
||||
|
||||
const cloneTravelWithEntries = async () => {
|
||||
try {
|
||||
const { data } = await axios.post(`Travels/${$props.travel.id}/cloneWithEntries`);
|
||||
notify('globals.dataSaved', 'positive');
|
||||
router.push({ name: 'TravelBasicData', params: { id: data.id } });
|
||||
} catch (err) {
|
||||
console.error('Error cloning travel with entries');
|
||||
}
|
||||
const { data } = await axios.post(`Travels/${$props.travel.id}/cloneWithEntries`);
|
||||
notify('globals.dataSaved', 'positive');
|
||||
router.push({ name: 'TravelBasicData', params: { id: data.id } });
|
||||
};
|
||||
|
||||
const canDelete = computed(() => useAcl().hasAny('Travel','*','WRITE'));
|
||||
const canDelete = computed(() => useAcl().hasAny('Travel', '*', 'WRITE'));
|
||||
|
||||
const openDeleteEntryDialog = (id) => {
|
||||
quasar
|
||||
|
@ -58,13 +54,9 @@ const openDeleteEntryDialog = (id) => {
|
|||
};
|
||||
|
||||
const deleteTravel = async (id) => {
|
||||
try {
|
||||
await axios.delete(`Travels/${id}`);
|
||||
router.push({ name: 'TravelList' });
|
||||
notify('globals.dataDeleted', 'positive');
|
||||
} catch (err) {
|
||||
console.error('Error deleting travel');
|
||||
}
|
||||
await axios.delete(`Travels/${id}`);
|
||||
router.push({ name: 'TravelList' });
|
||||
notify('globals.dataDeleted', 'positive');
|
||||
};
|
||||
</script>
|
||||
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
export default {
|
||||
fields: [
|
||||
'id',
|
||||
'ref',
|
||||
'shipped',
|
||||
'landed',
|
||||
'totalEntries',
|
||||
'warehouseInFk',
|
||||
'warehouseOutFk',
|
||||
'cargoSupplierFk',
|
||||
'agencyModeFk',
|
||||
'isRaid',
|
||||
'daysInForward',
|
||||
],
|
||||
include: [
|
||||
{
|
||||
relation: 'warehouseIn',
|
||||
scope: {
|
||||
fields: ['name'],
|
||||
},
|
||||
},
|
||||
{
|
||||
relation: 'warehouseOut',
|
||||
scope: {
|
||||
fields: ['name'],
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
|
@ -193,44 +193,32 @@ const entriesTotalM3 = computed(() =>
|
|||
);
|
||||
|
||||
const getTravelEntries = async (id) => {
|
||||
try {
|
||||
const { data } = await axios.get(`Travels/${id}/getEntries`);
|
||||
entries.value = data;
|
||||
} catch (err) {
|
||||
console.error('Error fetching travel entries');
|
||||
}
|
||||
const { data } = await axios.get(`Travels/${id}/getEntries`);
|
||||
entries.value = data;
|
||||
};
|
||||
|
||||
const getTravelThermographs = async (id) => {
|
||||
try {
|
||||
const filter = {
|
||||
include: {
|
||||
relation: 'warehouse',
|
||||
scope: {
|
||||
fields: ['id', 'name'],
|
||||
},
|
||||
const filter = {
|
||||
include: {
|
||||
relation: 'warehouse',
|
||||
scope: {
|
||||
fields: ['id', 'name'],
|
||||
},
|
||||
where: { travelFk: id },
|
||||
};
|
||||
},
|
||||
where: { travelFk: id },
|
||||
};
|
||||
|
||||
const { data } = await axios.get('TravelThermographs', {
|
||||
params: { filter: JSON.parse(JSON.stringify(filter)) },
|
||||
});
|
||||
thermographs.value = data;
|
||||
} catch (err) {
|
||||
console.error('Error fetching travel thermographs');
|
||||
}
|
||||
const { data } = await axios.get('TravelThermographs', {
|
||||
params: { filter: JSON.parse(JSON.stringify(filter)) },
|
||||
});
|
||||
thermographs.value = data;
|
||||
};
|
||||
|
||||
async function setTravelData(travelData) {
|
||||
try {
|
||||
if (travelData) {
|
||||
travel.value = travelData;
|
||||
await getTravelEntries(travel.value.id);
|
||||
await getTravelThermographs(travel.value.id);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(`Error setting travel data`, err);
|
||||
if (travelData) {
|
||||
travel.value = travelData;
|
||||
await getTravelEntries(travel.value.id);
|
||||
await getTravelThermographs(travel.value.id);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -268,6 +256,11 @@ const getLink = (param) => `#/travel/${entityId.value}/${param}`;
|
|||
:label="t('globals.warehouseOut')"
|
||||
:value="travel.warehouseOut?.name"
|
||||
/>
|
||||
<QCheckbox
|
||||
:label="t('travel.basicData.isRaid')"
|
||||
v-model="travel.isRaid"
|
||||
:disable="true"
|
||||
/>
|
||||
<QCheckbox
|
||||
:label="t('travel.summary.delivered')"
|
||||
v-model="travel.isDelivered"
|
||||
|
@ -286,6 +279,10 @@ const getLink = (param) => `#/travel/${entityId.value}/${param}`;
|
|||
:label="t('globals.warehouseIn')"
|
||||
:value="travel.warehouseIn?.name"
|
||||
/>
|
||||
<VnLv
|
||||
:label="t('travel.basicData.daysInForward')"
|
||||
:value="travel?.daysInForward"
|
||||
/>
|
||||
<QCheckbox
|
||||
:label="t('travel.summary.received')"
|
||||
v-model="travel.isReceived"
|
||||
|
@ -303,10 +300,6 @@ const getLink = (param) => `#/travel/${entityId.value}/${param}`;
|
|||
<VnLv :label="t('globals.reference')" :value="travel.ref" />
|
||||
<VnLv label="m³" :value="travel.m3" />
|
||||
<VnLv :label="t('globals.totalEntries')" :value="travel.totalEntries" />
|
||||
<VnLv
|
||||
:label="t('travel.basicData.daysInForward')"
|
||||
:value="travel?.daysInForward"
|
||||
/>
|
||||
</QCard>
|
||||
<QCard class="full-width">
|
||||
<VnTitle :text="t('travel.summary.entries')" />
|
||||
|
|
|
@ -122,13 +122,9 @@ const redirectToThermographForm = (action, id) => {
|
|||
};
|
||||
|
||||
const removeThermograph = async (id) => {
|
||||
try {
|
||||
await axios.delete(`Travels/deleteThermograph?id=${id}`);
|
||||
await thermographPaginateRef.value.fetch();
|
||||
notify(t('Thermograph removed'), 'positive');
|
||||
} catch (err) {
|
||||
console.error('Error removing termograph');
|
||||
}
|
||||
await axios.delete(`Travels/deleteThermograph?id=${id}`);
|
||||
await thermographPaginateRef.value.fetch();
|
||||
notify(t('Thermograph removed'), 'positive');
|
||||
};
|
||||
</script>
|
||||
|
||||
|
|
|
@ -56,17 +56,13 @@ onBeforeMount(async () => {
|
|||
});
|
||||
|
||||
const fetchDmsTypes = async () => {
|
||||
try {
|
||||
const params = {
|
||||
filter: {
|
||||
where: { code: 'thermograph' },
|
||||
},
|
||||
};
|
||||
const { data } = await axios.get('DmsTypes/findOne', { params });
|
||||
return data;
|
||||
} catch (err) {
|
||||
console.error('Error fetching Dms Types');
|
||||
}
|
||||
const params = {
|
||||
filter: {
|
||||
where: { code: 'thermograph' },
|
||||
},
|
||||
};
|
||||
const { data } = await axios.get('DmsTypes/findOne', { params });
|
||||
return data;
|
||||
};
|
||||
|
||||
const setCreateDefaultParams = async () => {
|
||||
|
|
|
@ -293,20 +293,16 @@ const openReportPdf = () => {
|
|||
};
|
||||
|
||||
const saveFieldValue = async (val, field, index) => {
|
||||
try {
|
||||
// Evitar la solicitud de guardado si el valor no ha cambiado
|
||||
if (originalRowDataCopy.value[index][field] == val) return;
|
||||
// Evitar la solicitud de guardado si el valor no ha cambiado
|
||||
if (originalRowDataCopy.value[index][field] == val) return;
|
||||
|
||||
const id = rows.value[index].id;
|
||||
const params = { [field]: val };
|
||||
await axios.patch(`Travels/${id}`, params);
|
||||
// Actualizar la copia de los datos originales con el nuevo valor
|
||||
originalRowDataCopy.value[index][field] = val;
|
||||
const id = rows.value[index].id;
|
||||
const params = { [field]: val };
|
||||
await axios.patch(`Travels/${id}`, params);
|
||||
// Actualizar la copia de los datos originales con el nuevo valor
|
||||
originalRowDataCopy.value[index][field] = val;
|
||||
|
||||
await arrayData.fetch({ append: false });
|
||||
} catch (err) {
|
||||
console.error('Error updating travel');
|
||||
}
|
||||
await arrayData.fetch({ append: false });
|
||||
};
|
||||
|
||||
const stopEventPropagation = (event, col) => {
|
||||
|
|
|
@ -227,10 +227,12 @@ const columns = computed(() => [
|
|||
>
|
||||
<template #column-status="{ row }">
|
||||
<div class="row">
|
||||
<QIcon v-if="!!row.daysInForward" name="vn:net" color="primary">
|
||||
<QIcon v-if="!!row.isRaid" name="vn:net" color="primary">
|
||||
<QTooltip>
|
||||
{{
|
||||
t('globals.raid', { daysInForward: row.daysInForward })
|
||||
t('globals.raid', {
|
||||
daysInForward: row.daysInForward,
|
||||
})
|
||||
}}</QTooltip
|
||||
>
|
||||
</QIcon>
|
||||
|
|
|
@ -19,16 +19,10 @@ const createTrayFormDialogRef = ref();
|
|||
const selectedEntityId = ref();
|
||||
|
||||
async function loadTrays() {
|
||||
try {
|
||||
const res = await axios.get('WagonTypeTrays');
|
||||
const filteredTrays = res.data.filter(
|
||||
(tray) => tray.wagonTypeFk === entityId.value
|
||||
);
|
||||
wagonTrays.value = filteredTrays;
|
||||
return;
|
||||
} catch (err) {
|
||||
console.error('Error loading trays:', err);
|
||||
}
|
||||
const res = await axios.get('WagonTypeTrays');
|
||||
const filteredTrays = res.data.filter((tray) => tray.wagonTypeFk === entityId.value);
|
||||
wagonTrays.value = filteredTrays;
|
||||
return;
|
||||
}
|
||||
|
||||
async function addTray(newTray) {
|
||||
|
|
|
@ -60,40 +60,29 @@ const updateSelectedDate = (year) => {
|
|||
};
|
||||
|
||||
const createEvent = async (date) => {
|
||||
try {
|
||||
const params = {
|
||||
dated: date,
|
||||
absenceTypeId: props.absenceType.id,
|
||||
businessFk: props.businessFk,
|
||||
};
|
||||
const params = {
|
||||
dated: date,
|
||||
absenceTypeId: props.absenceType.id,
|
||||
businessFk: props.businessFk,
|
||||
};
|
||||
|
||||
const { data } = await axios.post(
|
||||
`Workers/${route.params.id}/createAbsence`,
|
||||
params
|
||||
);
|
||||
const { data } = await axios.post(`Workers/${route.params.id}/createAbsence`, params);
|
||||
|
||||
if (data) emit('refresh');
|
||||
} catch (error) {
|
||||
console.error('error creating event:: ', error);
|
||||
}
|
||||
if (data) emit('refresh');
|
||||
};
|
||||
|
||||
const editEvent = async (event) => {
|
||||
try {
|
||||
const absenceType = props.absenceType;
|
||||
const params = {
|
||||
absenceId: event.absenceId,
|
||||
absenceTypeId: absenceType.id,
|
||||
};
|
||||
const { data } = await axios.patch(
|
||||
`Workers/${route.params.id}/updateAbsence`,
|
||||
params
|
||||
);
|
||||
const absenceType = props.absenceType;
|
||||
const params = {
|
||||
absenceId: event.absenceId,
|
||||
absenceTypeId: absenceType.id,
|
||||
};
|
||||
const { data } = await axios.patch(
|
||||
`Workers/${route.params.id}/updateAbsence`,
|
||||
params
|
||||
);
|
||||
|
||||
if (data) emit('refresh');
|
||||
} catch (error) {
|
||||
console.error('error editing event:: ', error);
|
||||
}
|
||||
if (data) emit('refresh');
|
||||
};
|
||||
|
||||
const deleteEvent = async (event, date) => {
|
||||
|
|
|
@ -39,15 +39,9 @@ const entityId = computed(() => {
|
|||
const workerExcluded = ref(false);
|
||||
|
||||
const getIsExcluded = async () => {
|
||||
try {
|
||||
const { data } = await axios.get(
|
||||
`WorkerDisableExcludeds/${entityId.value}/exists`
|
||||
);
|
||||
if (!data) return;
|
||||
workerExcluded.value = data.exists;
|
||||
} catch (err) {
|
||||
console.error('Error getting worker excluded: ', err);
|
||||
}
|
||||
const { data } = await axios.get(`WorkerDisableExcludeds/${entityId.value}/exists`);
|
||||
if (!data) return;
|
||||
workerExcluded.value = data.exists;
|
||||
};
|
||||
|
||||
const handleExcluded = async () => {
|
||||
|
|
|
@ -32,14 +32,11 @@ const initialData = computed(() => {
|
|||
});
|
||||
|
||||
const deallocatePDA = async (deviceProductionFk) => {
|
||||
try {
|
||||
await axios.post(`Workers/${route.params.id}/deallocatePDA`, {
|
||||
pda: deviceProductionFk,
|
||||
});
|
||||
notify(t('PDA deallocated'), 'positive');
|
||||
} catch (err) {
|
||||
console.error('Error deallocating PDA');
|
||||
}
|
||||
await axios.post(`Workers/${route.params.id}/deallocatePDA`, {
|
||||
pda: deviceProductionFk,
|
||||
});
|
||||
notify(t('PDA deallocated'), 'positive');
|
||||
|
||||
paginate.value.fetch();
|
||||
};
|
||||
|
||||
|
|
|
@ -251,13 +251,9 @@ const addEvents = (data) => {
|
|||
};
|
||||
|
||||
const fetchHours = async () => {
|
||||
try {
|
||||
await workerHoursRef.value.fetch();
|
||||
await getWorkedHours(startOfWeek.value, endOfWeek.value);
|
||||
await getAbsences();
|
||||
} catch (err) {
|
||||
console.error('Error fetching worker hours');
|
||||
}
|
||||
await workerHoursRef.value.fetch();
|
||||
await getWorkedHours(startOfWeek.value, endOfWeek.value);
|
||||
await getAbsences();
|
||||
};
|
||||
|
||||
const fetchWeekData = async () => {
|
||||
|
@ -265,25 +261,21 @@ const fetchWeekData = async () => {
|
|||
year: selectedDate.value.getFullYear(),
|
||||
week: selectedWeekNumber.value,
|
||||
};
|
||||
try {
|
||||
const mail = (
|
||||
await axiosNoError.get(`Workers/${route.params.id}/mail`, {
|
||||
params: { filter: { where } },
|
||||
})
|
||||
).data[0];
|
||||
const mail = (
|
||||
await axiosNoError.get(`Workers/${route.params.id}/mail`, {
|
||||
params: { filter: { where } },
|
||||
})
|
||||
).data[0];
|
||||
|
||||
if (!mail) state.value = null;
|
||||
else {
|
||||
state.value = mail.state;
|
||||
reason.value = mail.reason;
|
||||
}
|
||||
|
||||
canResend.value = !!(
|
||||
await axiosNoError.get('WorkerTimeControlMails/count', { params: { where } })
|
||||
).data.count;
|
||||
} catch (err) {
|
||||
console.error('Error fetching week data');
|
||||
if (!mail) state.value = null;
|
||||
else {
|
||||
state.value = mail.state;
|
||||
reason.value = mail.reason;
|
||||
}
|
||||
|
||||
canResend.value = !!(
|
||||
await axiosNoError.get('WorkerTimeControlMails/count', { params: { where } })
|
||||
).data.count;
|
||||
};
|
||||
|
||||
const setHours = (data) => {
|
||||
|
@ -357,23 +349,19 @@ const showReasonForm = () => {
|
|||
};
|
||||
|
||||
const updateWorkerTimeControlMail = async (state, reason) => {
|
||||
try {
|
||||
const params = {
|
||||
year: selectedDate.value.getFullYear(),
|
||||
week: selectedWeekNumber.value,
|
||||
state,
|
||||
};
|
||||
const workerId = Number(route.params.id);
|
||||
const params = {
|
||||
year: selectedDate.value.getFullYear(),
|
||||
week: selectedWeekNumber.value,
|
||||
state,
|
||||
};
|
||||
const workerId = Number(route.params.id);
|
||||
|
||||
if (reason) params.reason = reason;
|
||||
if (reason) params.reason = reason;
|
||||
|
||||
await axios.post(`WorkerTimeControls/${workerId}/updateMailState`, params);
|
||||
await getMailStates(selectedDate.value);
|
||||
await fetchWeekData();
|
||||
notify(t('globals.dataSaved'), 'positive');
|
||||
} catch (err) {
|
||||
console.error('Error updating worker time control mail');
|
||||
}
|
||||
await axios.post(`WorkerTimeControls/${workerId}/updateMailState`, params);
|
||||
await getMailStates(selectedDate.value);
|
||||
await fetchWeekData();
|
||||
notify(t('globals.dataSaved'), 'positive');
|
||||
};
|
||||
|
||||
const isSatisfied = async () => {
|
||||
|
@ -389,20 +377,16 @@ const isUnsatisfied = async (reason) => {
|
|||
};
|
||||
|
||||
const resendEmail = async () => {
|
||||
try {
|
||||
const params = {
|
||||
recipient: worker.value?.user?.email,
|
||||
week: selectedWeekNumber.value,
|
||||
year: selectedDate.value.getFullYear(),
|
||||
workerId: Number(route.params.id),
|
||||
state: 'SENDED',
|
||||
};
|
||||
await axios.post('WorkerTimeControls/weekly-hour-record-email', params);
|
||||
await getMailStates(selectedDate.value);
|
||||
notify(t('Email sended'), 'positive');
|
||||
} catch (err) {
|
||||
console.error('Error sending email');
|
||||
}
|
||||
const params = {
|
||||
recipient: worker.value?.user?.email,
|
||||
week: selectedWeekNumber.value,
|
||||
year: selectedDate.value.getFullYear(),
|
||||
workerId: Number(route.params.id),
|
||||
state: 'SENDED',
|
||||
};
|
||||
await axios.post('WorkerTimeControls/weekly-hour-record-email', params);
|
||||
await getMailStates(selectedDate.value);
|
||||
notify(t('Email sended'), 'positive');
|
||||
};
|
||||
|
||||
onBeforeMount(() => {
|
||||
|
|
|
@ -50,17 +50,11 @@ const directionIconName = computed(() => {
|
|||
});
|
||||
|
||||
const deleteHourEntry = async () => {
|
||||
try {
|
||||
const { data } = await axios.post(
|
||||
`WorkerTimeControls/${$props.id}/deleteTimeEntry`
|
||||
);
|
||||
const { data } = await axios.post(`WorkerTimeControls/${$props.id}/deleteTimeEntry`);
|
||||
|
||||
if (!data) return;
|
||||
emit('onHourEntryDeleted');
|
||||
notify('Entry removed', 'positive');
|
||||
} catch (err) {
|
||||
console.error('Error deleting hour entry');
|
||||
}
|
||||
if (!data) return;
|
||||
emit('onHourEntryDeleted');
|
||||
notify('Entry removed', 'positive');
|
||||
};
|
||||
|
||||
const showWorkerTimeForm = () => emit('showWorkerTimeForm');
|
||||
|
|
|
@ -33,28 +33,23 @@ const onNodeExpanded = (nodeKeysArray) => {
|
|||
};
|
||||
|
||||
const fetchNodeLeaves = async (nodeKey) => {
|
||||
try {
|
||||
const node = treeRef.value?.getNodeByKey(nodeKey);
|
||||
const node = treeRef.value?.getNodeByKey(nodeKey);
|
||||
|
||||
if (!node || node.sons === 0) return;
|
||||
if (!node || node.sons === 0) return;
|
||||
|
||||
const params = { parentId: node.id };
|
||||
const response = await axios.get('/departments/getLeaves', { params });
|
||||
if (response.data) {
|
||||
node.children = response.data.map((n) => {
|
||||
const hasChildrens = n.sons > 0;
|
||||
const params = { parentId: node.id };
|
||||
const response = await axios.get('/departments/getLeaves', { params });
|
||||
if (response.data) {
|
||||
node.children = response.data.map((n) => {
|
||||
const hasChildrens = n.sons > 0;
|
||||
|
||||
n.children = hasChildrens ? [{}] : null;
|
||||
n.clickable = true;
|
||||
return n;
|
||||
});
|
||||
}
|
||||
|
||||
state.set('Tree', node);
|
||||
} catch (err) {
|
||||
console.error('Error fetching department leaves', err);
|
||||
throw new Error();
|
||||
n.children = hasChildrens ? [{}] : null;
|
||||
n.clickable = true;
|
||||
return n;
|
||||
});
|
||||
}
|
||||
|
||||
state.set('Tree', node);
|
||||
};
|
||||
|
||||
const removeNode = (node) => {
|
||||
|
@ -72,15 +67,11 @@ const removeNode = (node) => {
|
|||
};
|
||||
|
||||
async function remove(id) {
|
||||
try {
|
||||
await axios.post(`/Departments/${id}/removeChild`, { id });
|
||||
quasar.notify({
|
||||
message: t('department.departmentRemoved'),
|
||||
type: 'positive',
|
||||
});
|
||||
} catch (err) {
|
||||
console.error('Error removing department');
|
||||
}
|
||||
await axios.post(`/Departments/${id}/removeChild`, { id });
|
||||
quasar.notify({
|
||||
message: t('department.departmentRemoved'),
|
||||
type: 'positive',
|
||||
});
|
||||
}
|
||||
|
||||
const showCreateNodeForm = (nodeId) => {
|
||||
|
|
|
@ -43,7 +43,7 @@ const { t } = useI18n();
|
|||
const { openConfirmationModal } = useVnConfirm();
|
||||
|
||||
const isNew = computed(() => props.isNewMode);
|
||||
const dated = ref(null);
|
||||
const dated = ref(props.date);
|
||||
const tickedNodes = ref();
|
||||
|
||||
const _excludeType = ref('all');
|
||||
|
@ -57,34 +57,23 @@ const excludeType = computed({
|
|||
const arrayData = useArrayData('ZoneEvents');
|
||||
|
||||
const exclusionGeoCreate = async () => {
|
||||
try {
|
||||
const params = {
|
||||
zoneFk: parseInt(route.params.id),
|
||||
date: dated.value,
|
||||
geoIds: tickedNodes.value,
|
||||
};
|
||||
await axios.post('Zones/exclusionGeo', params);
|
||||
await refetchEvents();
|
||||
} catch (err) {
|
||||
console.error('Error creating exclusion geo: ', err);
|
||||
}
|
||||
const params = {
|
||||
zoneFk: parseInt(route.params.id),
|
||||
date: dated.value,
|
||||
geoIds: tickedNodes.value,
|
||||
};
|
||||
await axios.post('Zones/exclusionGeo', params);
|
||||
await refetchEvents();
|
||||
};
|
||||
|
||||
const exclusionCreate = async () => {
|
||||
try {
|
||||
if (isNew.value)
|
||||
await axios.post(`Zones/${route.params.id}/exclusions`, [
|
||||
{ dated: dated.value },
|
||||
]);
|
||||
else
|
||||
await axios.post(`Zones/${route.params.id}/exclusions`, {
|
||||
dated: dated.value,
|
||||
});
|
||||
|
||||
await refetchEvents();
|
||||
} catch (err) {
|
||||
console.error('Error creating exclusion: ', err);
|
||||
}
|
||||
if (isNew.value)
|
||||
await axios.post(`Zones/${route.params.id}/exclusions`, [{ dated: dated.value }]);
|
||||
else
|
||||
await axios.post(`Zones/${route.params.id}/exclusions`, {
|
||||
dated: dated.value,
|
||||
});
|
||||
await refetchEvents();
|
||||
};
|
||||
|
||||
const onSubmit = async () => {
|
||||
|
@ -93,13 +82,9 @@ const onSubmit = async () => {
|
|||
};
|
||||
|
||||
const deleteEvent = async () => {
|
||||
try {
|
||||
if (!props.event) return;
|
||||
await axios.delete(`Zones/${route.params.id}/exclusions`);
|
||||
await refetchEvents();
|
||||
} catch (err) {
|
||||
console.error('Error deleting event: ', err);
|
||||
}
|
||||
if (!props.event) return;
|
||||
await axios.delete(`Zones/${route.params.id}/exclusions`);
|
||||
await refetchEvents();
|
||||
};
|
||||
|
||||
const closeForm = () => emit('closeForm');
|
||||
|
@ -129,13 +114,14 @@ onMounted(() => {
|
|||
@on-submit="onSubmit()"
|
||||
:default-cancel-button="false"
|
||||
:default-submit-button="false"
|
||||
:submit-on-enter="false"
|
||||
>
|
||||
<template #form-inputs>
|
||||
<VnRow class="row q-gutter-md q-mb-lg">
|
||||
<VnInputDate
|
||||
:label="t('eventsInclusionForm.day')"
|
||||
v-model="dated"
|
||||
:model-value="props.date"
|
||||
:required="true"
|
||||
/>
|
||||
</VnRow>
|
||||
<div class="column q-gutter-y-sm q-mb-md">
|
||||
|
@ -196,6 +182,7 @@ onMounted(() => {
|
|||
:label="isNew ? t('globals.add') : t('globals.save')"
|
||||
type="submit"
|
||||
color="primary"
|
||||
@click="onSubmit()"
|
||||
/>
|
||||
</template>
|
||||
</FormPopup>
|
||||
|
|
|
@ -57,45 +57,34 @@ const inclusionType = computed({
|
|||
const arrayData = useArrayData('ZoneEvents');
|
||||
|
||||
const createEvent = async () => {
|
||||
try {
|
||||
eventInclusionFormData.value.weekDays = weekdayStore.toSet(
|
||||
eventInclusionFormData.value.wdays
|
||||
eventInclusionFormData.value.weekDays = weekdayStore.toSet(
|
||||
eventInclusionFormData.value.wdays
|
||||
);
|
||||
|
||||
if (inclusionType.value == 'day') eventInclusionFormData.value.weekDays = '';
|
||||
else eventInclusionFormData.value.dated = null;
|
||||
|
||||
if (inclusionType.value != 'range') {
|
||||
eventInclusionFormData.value.started = null;
|
||||
eventInclusionFormData.value.ended = null;
|
||||
}
|
||||
|
||||
if (isNew.value)
|
||||
await axios.post(`Zones/${route.params.id}/events`, eventInclusionFormData.value);
|
||||
else
|
||||
await axios.put(
|
||||
`Zones/${route.params.id}/events/${props.event?.id}`,
|
||||
eventInclusionFormData.value
|
||||
);
|
||||
|
||||
if (inclusionType.value == 'day') eventInclusionFormData.value.weekDays = '';
|
||||
else eventInclusionFormData.value.dated = null;
|
||||
|
||||
if (inclusionType.value != 'range') {
|
||||
eventInclusionFormData.value.started = null;
|
||||
eventInclusionFormData.value.ended = null;
|
||||
}
|
||||
|
||||
if (isNew.value)
|
||||
await axios.post(
|
||||
`Zones/${route.params.id}/events`,
|
||||
eventInclusionFormData.value
|
||||
);
|
||||
else
|
||||
await axios.put(
|
||||
`Zones/${route.params.id}/events/${props.event?.id}`,
|
||||
eventInclusionFormData.value
|
||||
);
|
||||
|
||||
await refetchEvents();
|
||||
emit('onSubmit');
|
||||
} catch (err) {
|
||||
console.error('Error creating event', err);
|
||||
}
|
||||
await refetchEvents();
|
||||
emit('onSubmit');
|
||||
};
|
||||
|
||||
const deleteEvent = async () => {
|
||||
try {
|
||||
if (!props.event) return;
|
||||
await axios.delete(`Zones/${route.params.id}/events/${props.event?.id}`);
|
||||
await refetchEvents();
|
||||
} catch (err) {
|
||||
console.error('Error deleting event: ', err);
|
||||
}
|
||||
if (!props.event) return;
|
||||
await axios.delete(`Zones/${route.params.id}/events/${props.event?.id}`);
|
||||
await refetchEvents();
|
||||
};
|
||||
|
||||
const closeForm = () => {
|
||||
|
|
|
@ -57,15 +57,11 @@ const arrayData = useArrayData('ZoneEvents', {
|
|||
});
|
||||
|
||||
const fetchData = async () => {
|
||||
try {
|
||||
if (!params.value.zoneFk || !params.value.started || !params.value.ended) return;
|
||||
if (!params.value.zoneFk || !params.value.started || !params.value.ended) return;
|
||||
|
||||
await arrayData.applyFilter({
|
||||
params: params.value,
|
||||
});
|
||||
} catch (err) {
|
||||
console.error('Error fetching events: ', err);
|
||||
}
|
||||
await arrayData.applyFilter({
|
||||
params: params.value,
|
||||
});
|
||||
};
|
||||
|
||||
watch(
|
||||
|
@ -87,13 +83,9 @@ const formatWdays = (event) => {
|
|||
};
|
||||
|
||||
const deleteEvent = async (id) => {
|
||||
try {
|
||||
if (!id) return;
|
||||
await axios.delete(`Zones/${route.params.id}/events/${id}`);
|
||||
await fetchData();
|
||||
} catch (err) {
|
||||
console.error('Error deleting event: ', err);
|
||||
}
|
||||
if (!id) return;
|
||||
await axios.delete(`Zones/${route.params.id}/events/${id}`);
|
||||
await fetchData();
|
||||
};
|
||||
|
||||
const openInclusionForm = (event) => {
|
||||
|
|
|
@ -10,13 +10,9 @@ const { t } = useI18n();
|
|||
const route = useRoute();
|
||||
|
||||
const onSelected = async (val, node) => {
|
||||
try {
|
||||
if (val === null) val = undefined;
|
||||
const params = { geoId: node.id, isIncluded: val };
|
||||
await axios.post(`Zones/${route.params.id}/toggleIsIncluded`, params);
|
||||
} catch (err) {
|
||||
console.error('Error updating included', err);
|
||||
}
|
||||
if (val === null) val = undefined;
|
||||
const params = { geoId: node.id, isIncluded: val };
|
||||
await axios.post(`Zones/${route.params.id}/toggleIsIncluded`, params);
|
||||
};
|
||||
</script>
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@ const datakey = 'ZoneLocations';
|
|||
const url = computed(() => `Zones/${route.params.id}/getLeaves`);
|
||||
const arrayData = useArrayData(datakey, {
|
||||
url: url.value,
|
||||
limit: null,
|
||||
});
|
||||
const store = arrayData.store;
|
||||
|
||||
|
@ -74,6 +75,7 @@ const onNodeExpanded = async (nodeKeysArray) => {
|
|||
if (response.data) {
|
||||
node.childs = response.data.map((n) => {
|
||||
if (n.sons > 0) n.childs = [{}];
|
||||
n.selected = isSelected(n.selected);
|
||||
return n;
|
||||
});
|
||||
}
|
||||
|
@ -90,21 +92,16 @@ const onNodeExpanded = async (nodeKeysArray) => {
|
|||
previousExpandedNodes.value = nodeKeysSet;
|
||||
};
|
||||
|
||||
const formatNodeSelected = (node) => {
|
||||
if (node.selected === 1) node.selected = true;
|
||||
else if (node.selected === 0) node.selected = false;
|
||||
|
||||
if (node.sons > 0 && !node.childs) node.childs = [{}];
|
||||
};
|
||||
|
||||
const fetchNodeLeaves = async (nodeKey) => {
|
||||
if (!treeRef.value) return;
|
||||
const node = treeRef.value?.getNodeByKey(nodeKey);
|
||||
if (node.selected === 1) node.selected = true;
|
||||
else if (node.selected === 0) node.selected = false;
|
||||
if (typeof node.selected === 'number') node.selected = !!node.selected;
|
||||
if (node.sons > 0 && !node.childs) {
|
||||
node.childs = [{}];
|
||||
const index = expanded.value.indexOf(node.id);
|
||||
expanded.value.splice(index, 1);
|
||||
}
|
||||
if (!node || node.sons === 0) return;
|
||||
|
||||
state.set('Tree', node);
|
||||
};
|
||||
|
||||
function getNodeIds(node) {
|
||||
|
@ -119,6 +116,10 @@ function getNodeIds(node) {
|
|||
return ids;
|
||||
}
|
||||
|
||||
function isSelected(selected) {
|
||||
if (typeof selected === 'number') return !!selected;
|
||||
}
|
||||
|
||||
watch(
|
||||
() => store.data,
|
||||
async (val) => {
|
||||
|
@ -128,18 +129,9 @@ watch(
|
|||
nodes.value[0].childs = [...val];
|
||||
const fetchedNodeKeys = val.flatMap(getNodeIds);
|
||||
state.set('Tree', [...fetchedNodeKeys]);
|
||||
|
||||
if (!store.userParams?.search) {
|
||||
val.forEach((n) => {
|
||||
formatNodeSelected(n);
|
||||
});
|
||||
store.data = null;
|
||||
expanded.value = [null];
|
||||
} else {
|
||||
for (let n of state.get('Tree')) {
|
||||
await fetchNodeLeaves(n);
|
||||
}
|
||||
expanded.value = [null, ...fetchedNodeKeys];
|
||||
expanded.value = [null, ...fetchedNodeKeys];
|
||||
for (let n of state.get('Tree')) {
|
||||
await fetchNodeLeaves(n);
|
||||
}
|
||||
previousExpandedNodes.value = new Set(expanded.value);
|
||||
},
|
||||
|
@ -147,13 +139,11 @@ watch(
|
|||
);
|
||||
|
||||
const reFetch = async () => {
|
||||
const { data } = await arrayData.fetch({ append: false });
|
||||
nodes.value = data;
|
||||
expanded.value = [null];
|
||||
await arrayData.fetch({});
|
||||
};
|
||||
|
||||
onMounted(async () => {
|
||||
if (store.userParams?.search) await arrayData.fetch({});
|
||||
await reFetch();
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
|
@ -167,13 +157,13 @@ onUnmounted(() => {
|
|||
v-if="showSearchBar"
|
||||
v-model="store.userParams.search"
|
||||
:placeholder="$t('globals.search')"
|
||||
@update:model-value="reFetch()"
|
||||
@keydown.enter.stop.prevent="reFetch"
|
||||
>
|
||||
<template #prepend>
|
||||
<QBtn color="primary" icon="search" dense flat @click="reFetch()" />
|
||||
</template>
|
||||
</VnInput>
|
||||
<VnSearchbar :data-key="datakey" :url="url" :redirect="false" />
|
||||
<VnSearchbar v-if="!showSearchBar" :data-key="datakey" :url="url" :redirect="false" />
|
||||
<QTree
|
||||
ref="treeRef"
|
||||
:nodes="nodes"
|
||||
|
|
|
@ -21,17 +21,13 @@ const arrayData = useArrayData('ZoneDeliveryDays', {
|
|||
|
||||
const deliveryMethodsConfig = { pickUp: ['PICKUP'], delivery: ['AGENCY', 'DELIVERY'] };
|
||||
const fetchData = async (params) => {
|
||||
try {
|
||||
const { data } = params
|
||||
? await arrayData.applyFilter({
|
||||
params,
|
||||
})
|
||||
: await arrayData.fetch({ append: false });
|
||||
if (!data.events || !data.events.length)
|
||||
notify(t('deliveryPanel.noEventsWarning'), 'warning');
|
||||
} catch (err) {
|
||||
console.error('Error fetching events: ', err);
|
||||
}
|
||||
const { data } = params
|
||||
? await arrayData.applyFilter({
|
||||
params,
|
||||
})
|
||||
: await arrayData.fetch({ append: false });
|
||||
if (!data.events || !data.events.length)
|
||||
notify(t('deliveryPanel.noEventsWarning'), 'warning');
|
||||
};
|
||||
|
||||
const onSubmit = async () => {
|
||||
|
|
|
@ -99,7 +99,7 @@ describe('VnLocation', () => {
|
|||
});
|
||||
|
||||
it('Create postCode', () => {
|
||||
const postCode = '1234475';
|
||||
const postCode = Math.floor(100000 + Math.random() * 900000);
|
||||
const province = 'Valencia';
|
||||
cy.get(createLocationButton).click();
|
||||
cy.get('.q-card > h1').should('have.text', 'New postcode');
|
||||
|
@ -115,20 +115,68 @@ describe('VnLocation', () => {
|
|||
|
||||
checkVnLocation(postCode, province);
|
||||
});
|
||||
it('Create city', () => {
|
||||
const postCode = '9011';
|
||||
const province = 'Saskatchew';
|
||||
|
||||
it('Create city without country', () => {
|
||||
const cityName = 'Saskatchew'.concat(Math.random(1 * 100));
|
||||
cy.get(createLocationButton).click();
|
||||
cy.get(dialogInputs).eq(0).type(postCode);
|
||||
cy.get(
|
||||
`${createForm.prefix} > :nth-child(4) > .q-select > ${createForm.sufix} > :nth-child(2) > .q-icon`
|
||||
).click();
|
||||
cy.selectOption('#q-portal--dialog--3 .q-select', 'one');
|
||||
cy.get('#q-portal--dialog--3 .q-input').type(province);
|
||||
cy.get('#q-portal--dialog--3 .q-input').type(cityName);
|
||||
cy.get('#q-portal--dialog--3 .q-btn--standard').click();
|
||||
cy.get('#q-portal--dialog--1 .q-btn--standard').click();
|
||||
cy.waitForElement('.q-form');
|
||||
checkVnLocation(postCode, province);
|
||||
});
|
||||
|
||||
it('Create province without country', () => {
|
||||
const provinceName = 'Saskatchew'.concat(Math.random(1 * 100));
|
||||
cy.get(createLocationButton).click();
|
||||
cy.get(
|
||||
`${createForm.prefix} > :nth-child(5) > .q-select > ${createForm.sufix} > :nth-child(2) `
|
||||
)
|
||||
.eq(0)
|
||||
.click();
|
||||
cy.selectOption('#q-portal--dialog--3 .q-select', 'one');
|
||||
cy.countSelectOptions('#q-portal--dialog--3 .q-select', 4);
|
||||
cy.get('#q-portal--dialog--3 .q-input').type(provinceName);
|
||||
|
||||
cy.get('#q-portal--dialog--3 .q-btn--standard').click();
|
||||
});
|
||||
|
||||
it('Create city with country', () => {
|
||||
const cityName = 'Saskatchew'.concat(Math.random(1 * 100));
|
||||
cy.get(createLocationButton).click();
|
||||
cy.selectOption(
|
||||
`${createForm.prefix} > :nth-child(5) > :nth-child(3) `,
|
||||
'Italia'
|
||||
);
|
||||
cy.get(
|
||||
`${createForm.prefix} > :nth-child(4) > .q-select > ${createForm.sufix} > :nth-child(2) > .q-icon`
|
||||
).click();
|
||||
cy.selectOption('#q-portal--dialog--4 .q-select', 'Province four');
|
||||
cy.countSelectOptions('#q-portal--dialog--4 .q-select', 1);
|
||||
|
||||
cy.get('#q-portal--dialog--4 .q-input').type(cityName);
|
||||
cy.get('#q-portal--dialog--4 .q-btn--standard').click();
|
||||
});
|
||||
|
||||
it('Create province with country', () => {
|
||||
const provinceName = 'Saskatchew'.concat(Math.random(1 * 100));
|
||||
cy.get(createLocationButton).click();
|
||||
cy.selectOption(
|
||||
`${createForm.prefix} > :nth-child(5) > :nth-child(3) `,
|
||||
'España'
|
||||
);
|
||||
cy.get(
|
||||
`${createForm.prefix} > :nth-child(5) > .q-select > ${createForm.sufix} > :nth-child(2) `
|
||||
)
|
||||
.eq(0)
|
||||
.click();
|
||||
|
||||
cy.selectOption('#q-portal--dialog--4 .q-select', 'one');
|
||||
cy.countSelectOptions('#q-portal--dialog--4 .q-select', 2);
|
||||
|
||||
cy.get('#q-portal--dialog--4 .q-input').type(provinceName);
|
||||
cy.get('#q-portal--dialog--4 .q-btn--standard').click();
|
||||
});
|
||||
|
||||
function checkVnLocation(postCode, province) {
|
||||
|
|
|
@ -91,6 +91,11 @@ Cypress.Commands.add('selectOption', (selector, option) => {
|
|||
cy.get(selector).click();
|
||||
cy.get('.q-menu .q-item').contains(option).click();
|
||||
});
|
||||
Cypress.Commands.add('countSelectOptions', (selector, option) => {
|
||||
cy.waitForElement(selector);
|
||||
cy.get(selector).click();
|
||||
cy.get('.q-menu .q-item').should('have.length', option);
|
||||
});
|
||||
|
||||
Cypress.Commands.add('fillInForm', (obj, form = '.q-form > .q-card') => {
|
||||
cy.waitForElement('.q-form > .q-card');
|
||||
|
|
|
@ -1,25 +1,36 @@
|
|||
import { vi, describe, expect, it } from 'vitest';
|
||||
import { vi, describe, expect, it, beforeAll, afterAll } from 'vitest';
|
||||
import { axios } from 'app/test/vitest/helper';
|
||||
import { downloadFile } from 'src/composables/downloadFile';
|
||||
import { useSession } from 'src/composables/useSession';
|
||||
|
||||
const session = useSession();
|
||||
const token = session.getToken();
|
||||
|
||||
describe('downloadFile', () => {
|
||||
const baseUrl = 'http://localhost:9000';
|
||||
let defaulCreateObjectURL;
|
||||
|
||||
beforeAll(() => {
|
||||
defaulCreateObjectURL = window.URL.createObjectURL;
|
||||
window.URL.createObjectURL = vi.fn(() => 'blob:http://localhost:9000/blob-id');
|
||||
});
|
||||
|
||||
afterAll(() => (window.URL.createObjectURL = defaulCreateObjectURL));
|
||||
|
||||
it('should open a new window to download the file', async () => {
|
||||
const url = 'http://localhost:9000';
|
||||
|
||||
vi.spyOn(axios, 'get').mockResolvedValueOnce({ data: url });
|
||||
|
||||
const mockWindowOpen = vi.spyOn(window, 'open');
|
||||
const res = {
|
||||
data: new Blob(['file content'], { type: 'application/octet-stream' }),
|
||||
headers: { 'content-disposition': 'attachment; filename="test-file.txt"' },
|
||||
};
|
||||
vi.spyOn(axios, 'get').mockImplementation((url) => {
|
||||
if (url == 'Urls/getUrl') return Promise.resolve({ data: baseUrl });
|
||||
else if (url.includes('downloadFile')) return Promise.resolve(res);
|
||||
});
|
||||
|
||||
await downloadFile(1);
|
||||
|
||||
expect(mockWindowOpen).toHaveBeenCalledWith(
|
||||
`${url}/api/dms/1/downloadFile?access_token=${token}`
|
||||
expect(axios.get).toHaveBeenCalledWith(
|
||||
`${baseUrl}/dms/1/downloadFile?access_token=${token}`,
|
||||
{ responseType: 'blob' }
|
||||
);
|
||||
|
||||
mockWindowOpen.mockRestore();
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue