fix: remove all try catch(err) (error) console.error
gitea/salix-front/pipeline/pr-master This commit looks good
Details
gitea/salix-front/pipeline/pr-master This commit looks good
Details
This commit is contained in:
parent
8cbf40f465
commit
bf29be1c5f
|
@ -156,26 +156,22 @@ const rotateRight = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const onSubmit = () => {
|
const onSubmit = () => {
|
||||||
try {
|
if (!newPhoto.files && !newPhoto.url) {
|
||||||
if (!newPhoto.files && !newPhoto.url) {
|
notify(t('Select an image'), 'negative');
|
||||||
notify(t('Select an image'), 'negative');
|
return;
|
||||||
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');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 () => {
|
const makeRequest = async () => {
|
||||||
|
|
|
@ -51,21 +51,17 @@ const onDataSaved = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const onSubmit = async () => {
|
const onSubmit = async () => {
|
||||||
try {
|
isLoading.value = true;
|
||||||
isLoading.value = true;
|
const rowsToEdit = $props.rows.map((row) => ({ id: row.id, itemFk: row.itemFk }));
|
||||||
const rowsToEdit = $props.rows.map((row) => ({ id: row.id, itemFk: row.itemFk }));
|
const payload = {
|
||||||
const payload = {
|
field: selectedField.value.field,
|
||||||
field: selectedField.value.field,
|
newValue: newValue.value,
|
||||||
newValue: newValue.value,
|
lines: rowsToEdit,
|
||||||
lines: rowsToEdit,
|
};
|
||||||
};
|
|
||||||
|
|
||||||
await axios.post($props.editUrl, payload);
|
await axios.post($props.editUrl, payload);
|
||||||
onDataSaved();
|
onDataSaved();
|
||||||
isLoading.value = false;
|
isLoading.value = false;
|
||||||
} catch (err) {
|
|
||||||
console.error('Error submitting table cell edit');
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const closeForm = () => {
|
const closeForm = () => {
|
||||||
|
|
|
@ -84,34 +84,30 @@ const tableColumns = computed(() => [
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const onSubmit = async () => {
|
const onSubmit = async () => {
|
||||||
try {
|
let filter = itemFilter;
|
||||||
let filter = itemFilter;
|
const params = itemFilterParams;
|
||||||
const params = itemFilterParams;
|
const where = {};
|
||||||
const where = {};
|
for (let key in params) {
|
||||||
for (let key in params) {
|
const value = params[key];
|
||||||
const value = params[key];
|
if (!value) continue;
|
||||||
if (!value) continue;
|
|
||||||
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case 'name':
|
case 'name':
|
||||||
where[key] = { like: `%${value}%` };
|
where[key] = { like: `%${value}%` };
|
||||||
break;
|
break;
|
||||||
case 'producerFk':
|
case 'producerFk':
|
||||||
case 'typeFk':
|
case 'typeFk':
|
||||||
case 'size':
|
case 'size':
|
||||||
case 'inkFk':
|
case 'inkFk':
|
||||||
where[key] = value;
|
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 = () => {
|
const closeForm = () => {
|
||||||
|
|
|
@ -86,32 +86,28 @@ const tableColumns = computed(() => [
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const onSubmit = async () => {
|
const onSubmit = async () => {
|
||||||
try {
|
let filter = travelFilter;
|
||||||
let filter = travelFilter;
|
const params = travelFilterParams;
|
||||||
const params = travelFilterParams;
|
const where = {};
|
||||||
const where = {};
|
for (let key in params) {
|
||||||
for (let key in params) {
|
const value = params[key];
|
||||||
const value = params[key];
|
if (!value) continue;
|
||||||
if (!value) continue;
|
|
||||||
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case 'agencyModeFk':
|
case 'agencyModeFk':
|
||||||
case 'warehouseInFk':
|
case 'warehouseInFk':
|
||||||
case 'warehouseOutFk':
|
case 'warehouseOutFk':
|
||||||
case 'shipped':
|
case 'shipped':
|
||||||
case 'landed':
|
case 'landed':
|
||||||
where[key] = value;
|
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 = () => {
|
const closeForm = () => {
|
||||||
|
|
|
@ -217,9 +217,6 @@ async function save() {
|
||||||
updateAndEmit('onDataSaved', formData.value, response?.data);
|
updateAndEmit('onDataSaved', formData.value, response?.data);
|
||||||
if ($props.reload) await arrayData.fetch({});
|
if ($props.reload) await arrayData.fetch({});
|
||||||
hasChanges.value = false;
|
hasChanges.value = false;
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
notify('errors.writeRequest', 'negative');
|
|
||||||
} finally {
|
} finally {
|
||||||
isLoading.value = false;
|
isLoading.value = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,20 +88,16 @@ const applyTags = (params, search) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const fetchItemTypes = async (id) => {
|
const fetchItemTypes = async (id) => {
|
||||||
try {
|
const filter = {
|
||||||
const filter = {
|
fields: ['id', 'name', 'categoryFk'],
|
||||||
fields: ['id', 'name', 'categoryFk'],
|
where: { categoryFk: id },
|
||||||
where: { categoryFk: id },
|
include: 'category',
|
||||||
include: 'category',
|
order: 'name ASC',
|
||||||
order: 'name ASC',
|
};
|
||||||
};
|
const { data } = await axios.get('ItemTypes', {
|
||||||
const { data } = await axios.get('ItemTypes', {
|
params: { filter: JSON.stringify(filter) },
|
||||||
params: { filter: JSON.stringify(filter) },
|
});
|
||||||
});
|
itemTypesOptions.value = data;
|
||||||
itemTypesOptions.value = data;
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Error fetching item types', err);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const getCategoryClass = (category, params) => {
|
const getCategoryClass = (category, params) => {
|
||||||
|
@ -111,23 +107,19 @@ const getCategoryClass = (category, params) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const getSelectedTagValues = async (tag) => {
|
const getSelectedTagValues = async (tag) => {
|
||||||
try {
|
if (!tag?.selectedTag?.id) return;
|
||||||
if (!tag?.selectedTag?.id) return;
|
tag.value = null;
|
||||||
tag.value = null;
|
const filter = {
|
||||||
const filter = {
|
fields: ['value'],
|
||||||
fields: ['value'],
|
order: 'value ASC',
|
||||||
order: 'value ASC',
|
limit: 30,
|
||||||
limit: 30,
|
};
|
||||||
};
|
|
||||||
|
|
||||||
const params = { filter: JSON.stringify(filter) };
|
const params = { filter: JSON.stringify(filter) };
|
||||||
const { data } = await axios.get(`Tags/${tag.selectedTag.id}/filterValue`, {
|
const { data } = await axios.get(`Tags/${tag.selectedTag.id}/filterValue`, {
|
||||||
params,
|
params,
|
||||||
});
|
});
|
||||||
tag.valueOptions = data;
|
tag.valueOptions = data;
|
||||||
} catch (err) {
|
|
||||||
console.error('Error getting selected tag values');
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const removeTag = (index, params, search) => {
|
const removeTag = (index, params, search) => {
|
||||||
|
|
|
@ -39,14 +39,10 @@ const refund = async () => {
|
||||||
invoiceCorrectionTypeFk: invoiceParams.invoiceCorrectionTypeFk,
|
invoiceCorrectionTypeFk: invoiceParams.invoiceCorrectionTypeFk,
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
const { data } = await axios.post('InvoiceOuts/refundAndInvoice', params);
|
||||||
const { data } = await axios.post('InvoiceOuts/refundAndInvoice', params);
|
notify(t('Refunded invoice'), 'positive');
|
||||||
notify(t('Refunded invoice'), 'positive');
|
const [id] = data?.refundId || [];
|
||||||
const [id] = data?.refundId || [];
|
if (id) router.push({ name: 'InvoiceOutSummary', params: { id } });
|
||||||
if (id) router.push({ name: 'InvoiceOutSummary', params: { id } });
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Error refunding invoice', err);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -49,36 +49,32 @@ const makeInvoice = async () => {
|
||||||
makeInvoice: checked.value,
|
makeInvoice: checked.value,
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
if (checked.value && hasToInvoiceByAddress) {
|
||||||
if (checked.value && hasToInvoiceByAddress) {
|
const response = await new Promise((resolve) => {
|
||||||
const response = await new Promise((resolve) => {
|
quasar
|
||||||
quasar
|
.dialog({
|
||||||
.dialog({
|
component: VnConfirm,
|
||||||
component: VnConfirm,
|
componentProps: {
|
||||||
componentProps: {
|
title: t('Bill destination client'),
|
||||||
title: t('Bill destination client'),
|
message: t('transferInvoiceInfo'),
|
||||||
message: t('transferInvoiceInfo'),
|
},
|
||||||
},
|
})
|
||||||
})
|
.onOk(() => {
|
||||||
.onOk(() => {
|
resolve(true);
|
||||||
resolve(true);
|
})
|
||||||
})
|
.onCancel(() => {
|
||||||
.onCancel(() => {
|
resolve(false);
|
||||||
resolve(false);
|
});
|
||||||
});
|
});
|
||||||
});
|
if (!response) {
|
||||||
if (!response) {
|
return;
|
||||||
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>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -57,31 +57,27 @@ async function getConfig(url, filter) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchViewConfigData() {
|
async function fetchViewConfigData() {
|
||||||
try {
|
const defaultFilter = {
|
||||||
const defaultFilter = {
|
where: { tableCode: $props.tableCode },
|
||||||
where: { tableCode: $props.tableCode },
|
};
|
||||||
};
|
|
||||||
|
|
||||||
const userConfig = await getConfig('UserConfigViews', {
|
const userConfig = await getConfig('UserConfigViews', {
|
||||||
where: {
|
where: {
|
||||||
...defaultFilter.where,
|
...defaultFilter.where,
|
||||||
...{ userFk: user.value.id },
|
...{ userFk: user.value.id },
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (userConfig) {
|
if (userConfig) {
|
||||||
initialUserConfigViewData.value = userConfig;
|
initialUserConfigViewData.value = userConfig;
|
||||||
setUserConfigViewData(userConfig.configuration);
|
setUserConfigViewData(userConfig.configuration);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const defaultConfig = await getConfig('DefaultViewConfigs', defaultFilter);
|
const defaultConfig = await getConfig('DefaultViewConfigs', defaultFilter);
|
||||||
if (defaultConfig) {
|
if (defaultConfig) {
|
||||||
setUserConfigViewData(defaultConfig.columns);
|
setUserConfigViewData(defaultConfig.columns);
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Error fetching config view data', err);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,7 +88,6 @@ async function saveConfig() {
|
||||||
setUserConfigViewData(configuration, true);
|
setUserConfigViewData(configuration, true);
|
||||||
if (!$props.tableCode) return popupProxyRef.value.hide();
|
if (!$props.tableCode) return popupProxyRef.value.hide();
|
||||||
|
|
||||||
try {
|
|
||||||
const params = {};
|
const params = {};
|
||||||
// Si existe una view config del usuario hacemos un update si no la creamos
|
// Si existe una view config del usuario hacemos un update si no la creamos
|
||||||
if (initialUserConfigViewData.value) {
|
if (initialUserConfigViewData.value) {
|
||||||
|
@ -123,10 +118,7 @@ async function saveConfig() {
|
||||||
}
|
}
|
||||||
notify('globals.dataSaved', 'positive');
|
notify('globals.dataSaved', 'positive');
|
||||||
popupProxyRef.value.hide();
|
popupProxyRef.value.hide();
|
||||||
} catch (err) {
|
|
||||||
console.error('Error saving user view config', err);
|
|
||||||
notify('errors.writeRequest', 'negative');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
|
|
|
@ -58,79 +58,71 @@ const getConfig = async (url, filter) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const fetchViewConfigData = async () => {
|
const fetchViewConfigData = async () => {
|
||||||
try {
|
const userConfigFilter = {
|
||||||
const userConfigFilter = {
|
where: { tableCode: $props.tableCode, userFk: user.value.id },
|
||||||
where: { tableCode: $props.tableCode, userFk: user.value.id },
|
};
|
||||||
};
|
const userConfig = await getConfig('UserConfigViews', userConfigFilter);
|
||||||
const userConfig = await getConfig('UserConfigViews', userConfigFilter);
|
|
||||||
|
|
||||||
if (userConfig) {
|
if (userConfig) {
|
||||||
initialUserConfigViewData.value = userConfig;
|
initialUserConfigViewData.value = userConfig;
|
||||||
setUserConfigViewData(userConfig.configuration);
|
setUserConfigViewData(userConfig.configuration);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const defaultConfigFilter = { where: { tableCode: $props.tableCode } };
|
const defaultConfigFilter = { where: { tableCode: $props.tableCode } };
|
||||||
const defaultConfig = await getConfig('DefaultViewConfigs', defaultConfigFilter);
|
const defaultConfig = await getConfig('DefaultViewConfigs', defaultConfigFilter);
|
||||||
|
|
||||||
if (defaultConfig) {
|
if (defaultConfig) {
|
||||||
// Si el backend devuelve una configuración por defecto la usamos
|
// Si el backend devuelve una configuración por defecto la usamos
|
||||||
setUserConfigViewData(defaultConfig.columns);
|
setUserConfigViewData(defaultConfig.columns);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
// Si no hay configuración por defecto mostramos todas las columnas
|
// Si no hay configuración por defecto mostramos todas las columnas
|
||||||
const defaultColumns = {};
|
const defaultColumns = {};
|
||||||
$props.allColumns.forEach((col) => (defaultColumns[col] = true));
|
$props.allColumns.forEach((col) => (defaultColumns[col] = true));
|
||||||
setUserConfigViewData(defaultColumns);
|
setUserConfigViewData(defaultColumns);
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Error fetching config view data', err);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const saveConfig = async () => {
|
const saveConfig = async () => {
|
||||||
try {
|
const params = {};
|
||||||
const params = {};
|
const configuration = {};
|
||||||
const configuration = {};
|
|
||||||
|
|
||||||
formattedCols.value.forEach((col) => {
|
formattedCols.value.forEach((col) => {
|
||||||
const { name, active } = col;
|
const { name, active } = col;
|
||||||
configuration[name] = active;
|
configuration[name] = active;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Si existe una view config del usuario hacemos un update si no la creamos
|
// Si existe una view config del usuario hacemos un update si no la creamos
|
||||||
if (initialUserConfigViewData.value) {
|
if (initialUserConfigViewData.value) {
|
||||||
params.updates = [
|
params.updates = [
|
||||||
{
|
{
|
||||||
data: {
|
data: {
|
||||||
configuration: configuration,
|
|
||||||
},
|
|
||||||
where: {
|
|
||||||
id: initialUserConfigViewData.value.id,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
];
|
|
||||||
} else {
|
|
||||||
params.creates = [
|
|
||||||
{
|
|
||||||
userFk: user.value.id,
|
|
||||||
tableCode: $props.tableCode,
|
|
||||||
tableConfig: $props.tableCode,
|
|
||||||
configuration: configuration,
|
configuration: configuration,
|
||||||
},
|
},
|
||||||
];
|
where: {
|
||||||
}
|
id: initialUserConfigViewData.value.id,
|
||||||
|
},
|
||||||
const response = await axios.post('UserConfigViews/crud', params);
|
},
|
||||||
if (response.data && response.data[0]) {
|
];
|
||||||
initialUserConfigViewData.value = response.data[0];
|
} else {
|
||||||
}
|
params.creates = [
|
||||||
emitSavedConfig();
|
{
|
||||||
notify('globals.dataSaved', 'positive');
|
userFk: user.value.id,
|
||||||
popupProxyRef.value.hide();
|
tableCode: $props.tableCode,
|
||||||
} catch (err) {
|
tableConfig: $props.tableCode,
|
||||||
console.error('Error saving user view config', err);
|
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 = () => {
|
const emitSavedConfig = () => {
|
||||||
|
|
|
@ -11,21 +11,13 @@ const { t } = useI18n();
|
||||||
const { notify } = useNotify();
|
const { notify } = useNotify();
|
||||||
|
|
||||||
const onSynchronizeAll = async () => {
|
const onSynchronizeAll = async () => {
|
||||||
try {
|
notify(t('Synchronizing in the background'), 'positive');
|
||||||
notify(t('Synchronizing in the background'), 'positive');
|
await axios.patch(`Accounts/syncAll`);
|
||||||
await axios.patch(`Accounts/syncAll`);
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error synchronizing all accounts', error);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const onSynchronizeRoles = async () => {
|
const onSynchronizeRoles = async () => {
|
||||||
try {
|
await axios.patch(`RoleInherits/sync`);
|
||||||
await axios.patch(`RoleInherits/sync`);
|
notify(t('Roles synchronized!'), 'positive');
|
||||||
notify(t('Roles synchronized!'), 'positive');
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error synchronizing roles', error);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -94,29 +94,25 @@ const columns = computed(() => [
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
const deleteAcl = async ({ id }) => {
|
const deleteAcl = async ({ id }) => {
|
||||||
try {
|
await new Promise((resolve) => {
|
||||||
await new Promise((resolve) => {
|
quasar
|
||||||
quasar
|
.dialog({
|
||||||
.dialog({
|
component: VnConfirm,
|
||||||
component: VnConfirm,
|
componentProps: {
|
||||||
componentProps: {
|
title: t('Remove ACL'),
|
||||||
title: t('Remove ACL'),
|
message: t('Do you want to remove this ACL?'),
|
||||||
message: t('Do you want to remove this ACL?'),
|
},
|
||||||
},
|
})
|
||||||
})
|
.onOk(() => {
|
||||||
.onOk(() => {
|
resolve(true);
|
||||||
resolve(true);
|
})
|
||||||
})
|
.onCancel(() => {
|
||||||
.onCancel(() => {
|
resolve(false);
|
||||||
resolve(false);
|
});
|
||||||
});
|
});
|
||||||
});
|
await axios.delete(`ACLs/${id}`);
|
||||||
await axios.delete(`ACLs/${id}`);
|
tableRef.value.reload();
|
||||||
tableRef.value.reload();
|
notify('ACL removed', 'positive');
|
||||||
notify('ACL removed', 'positive');
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error deleting Acl: ', error);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -34,13 +34,9 @@ const refresh = () => paginateRef.value.fetch();
|
||||||
const navigate = (id) => router.push({ name: 'AccountSummary', params: { id } });
|
const navigate = (id) => router.push({ name: 'AccountSummary', params: { id } });
|
||||||
|
|
||||||
const killSession = async ({ userId, created }) => {
|
const killSession = async ({ userId, created }) => {
|
||||||
try {
|
await axios.post(`${urlPath}/killSession`, { userId, created });
|
||||||
await axios.post(`${urlPath}/killSession`, { userId, created });
|
paginateRef.value.fetch();
|
||||||
paginateRef.value.fetch();
|
notify(t('Session killed'), 'positive');
|
||||||
notify(t('Session killed'), 'positive');
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error killing session', error);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -40,12 +40,8 @@ const formUrlCreate = ref(null);
|
||||||
const formUrlUpdate = ref(null);
|
const formUrlUpdate = ref(null);
|
||||||
const formCustomFn = ref(null);
|
const formCustomFn = ref(null);
|
||||||
const onTestConection = async () => {
|
const onTestConection = async () => {
|
||||||
try {
|
await axios.get(`LdapConfigs/test`);
|
||||||
await axios.get(`LdapConfigs/test`);
|
notify(t('LDAP connection established!'), 'positive');
|
||||||
notify(t('LDAP connection established!'), 'positive');
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error testing connection', error);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
const getInitialLdapConfig = async () => {
|
const getInitialLdapConfig = async () => {
|
||||||
try {
|
try {
|
||||||
|
@ -72,14 +68,10 @@ const getInitialLdapConfig = async () => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const deleteMailForward = async () => {
|
const deleteMailForward = async () => {
|
||||||
try {
|
await axios.delete(URL_UPDATE);
|
||||||
await axios.delete(URL_UPDATE);
|
initialData.value = { ...DEFAULT_DATA };
|
||||||
initialData.value = { ...DEFAULT_DATA };
|
hasData.value = false;
|
||||||
hasData.value = false;
|
notify(t('globals.dataSaved'), 'positive');
|
||||||
notify(t('globals.dataSaved'), 'positive');
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Error deleting mail forward', err);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
onMounted(async () => await getInitialLdapConfig());
|
onMounted(async () => await getInitialLdapConfig());
|
||||||
|
|
|
@ -46,12 +46,8 @@ const formUrlUpdate = ref(null);
|
||||||
const formCustomFn = ref(null);
|
const formCustomFn = ref(null);
|
||||||
|
|
||||||
const onTestConection = async () => {
|
const onTestConection = async () => {
|
||||||
try {
|
await axios.get(`SambaConfigs/test`);
|
||||||
await axios.get(`SambaConfigs/test`);
|
notify(t('Samba connection established!'), 'positive');
|
||||||
notify(t('Samba connection established!'), 'positive');
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error testing connection', error);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const getInitialSambaConfig = async () => {
|
const getInitialSambaConfig = async () => {
|
||||||
|
@ -79,14 +75,10 @@ const getInitialSambaConfig = async () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const deleteMailForward = async () => {
|
const deleteMailForward = async () => {
|
||||||
try {
|
await axios.delete(URL_UPDATE);
|
||||||
await axios.delete(URL_UPDATE);
|
initialData.value = { ...DEFAULT_DATA };
|
||||||
initialData.value = { ...DEFAULT_DATA };
|
hasData.value = false;
|
||||||
hasData.value = false;
|
notify(t('globals.dataSaved'), 'positive');
|
||||||
notify(t('globals.dataSaved'), 'positive');
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Error deleting mail forward', err);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
onMounted(async () => await getInitialSambaConfig());
|
onMounted(async () => await getInitialSambaConfig());
|
||||||
|
|
|
@ -44,13 +44,9 @@ const removeAlias = () => {
|
||||||
cancel: true,
|
cancel: true,
|
||||||
})
|
})
|
||||||
.onOk(async () => {
|
.onOk(async () => {
|
||||||
try {
|
await axios.delete(`MailAliases/${entityId.value}`);
|
||||||
await axios.delete(`MailAliases/${entityId.value}`);
|
notify(t('Alias removed'), 'positive');
|
||||||
notify(t('Alias removed'), 'positive');
|
router.push({ name: 'AccountAlias' });
|
||||||
router.push({ name: 'AccountAlias' });
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Error removing alias');
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -46,13 +46,9 @@ const columns = computed(() => [
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const deleteAlias = async (row) => {
|
const deleteAlias = async (row) => {
|
||||||
try {
|
await axios.delete(`${urlPath.value}/${row.id}`);
|
||||||
await axios.delete(`${urlPath.value}/${row.id}`);
|
notify(t('User removed'), 'positive');
|
||||||
notify(t('User removed'), 'positive');
|
fetchAliases();
|
||||||
fetchAliases();
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
|
|
|
@ -61,23 +61,15 @@ const fetchAccountExistence = async () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const deleteMailAlias = async (row) => {
|
const deleteMailAlias = async (row) => {
|
||||||
try {
|
await axios.delete(`${urlPath}/${row.id}`);
|
||||||
await axios.delete(`${urlPath}/${row.id}`);
|
fetchMailAliases();
|
||||||
fetchMailAliases();
|
notify(t('Unsubscribed from alias!'), 'positive');
|
||||||
notify(t('Unsubscribed from alias!'), 'positive');
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const createMailAlias = async (mailAliasFormData) => {
|
const createMailAlias = async (mailAliasFormData) => {
|
||||||
try {
|
await axios.post(urlPath, mailAliasFormData);
|
||||||
await axios.post(urlPath, mailAliasFormData);
|
notify(t('Subscribed to alias!'), 'positive');
|
||||||
notify(t('Subscribed to alias!'), 'positive');
|
fetchMailAliases();
|
||||||
fetchMailAliases();
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const fetchMailAliases = async () => {
|
const fetchMailAliases = async () => {
|
||||||
|
|
|
@ -41,35 +41,22 @@ const fetchAccountExistence = async () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const fetchMailForwards = async () => {
|
const fetchMailForwards = async () => {
|
||||||
try {
|
const response = await axios.get(`MailForwards/${route.params.id}`);
|
||||||
const response = await axios.get(`MailForwards/${route.params.id}`);
|
return response.data;
|
||||||
return response.data;
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Error fetching mail forwards', err);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const deleteMailForward = async () => {
|
const deleteMailForward = async () => {
|
||||||
try {
|
await axios.delete(`MailForwards/${route.params.id}`);
|
||||||
await axios.delete(`MailForwards/${route.params.id}`);
|
formData.value.forwardTo = null;
|
||||||
formData.value.forwardTo = null;
|
initialData.value.forwardTo = null;
|
||||||
initialData.value.forwardTo = null;
|
initialData.value.hasData = hasData.value;
|
||||||
initialData.value.hasData = hasData.value;
|
notify(t('globals.dataSaved'), 'positive');
|
||||||
notify(t('globals.dataSaved'), 'positive');
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Error deleting mail forward', err);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const updateMailForward = async () => {
|
const updateMailForward = async () => {
|
||||||
try {
|
await axios.patch('MailForwards', formData.value);
|
||||||
await axios.patch('MailForwards', formData.value);
|
initialData.value = { ...formData.value };
|
||||||
initialData.value = { ...formData.value };
|
initialData.value.hasData = hasData.value;
|
||||||
initialData.value.hasData = hasData.value;
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Error creating mail forward', err);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const onSubmit = async () => {
|
const onSubmit = async () => {
|
||||||
|
|
|
@ -32,12 +32,8 @@ const filter = {
|
||||||
where: { id: entityId },
|
where: { id: entityId },
|
||||||
};
|
};
|
||||||
const removeRole = async () => {
|
const removeRole = async () => {
|
||||||
try {
|
await axios.delete(`VnRoles/${entityId.value}`);
|
||||||
await axios.delete(`VnRoles/${entityId.value}`);
|
notify(t('Role removed'), 'positive');
|
||||||
notify(t('Role removed'), 'positive');
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error deleting role', error);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -46,29 +46,19 @@ const columns = computed(() => [
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const deleteSubRole = async (row) => {
|
const deleteSubRole = async (row) => {
|
||||||
try {
|
await axios.delete(`${urlPath.value}/${row.id}`);
|
||||||
await axios.delete(`${urlPath.value}/${row.id}`);
|
fetchSubRoles();
|
||||||
fetchSubRoles();
|
notify(t('Role removed. Changes will take a while to fully propagate.'), 'positive');
|
||||||
notify(
|
|
||||||
t('Role removed. Changes will take a while to fully propagate.'),
|
|
||||||
'positive'
|
|
||||||
);
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const createSubRole = async (subRoleFormData) => {
|
const createSubRole = async (subRoleFormData) => {
|
||||||
try {
|
|
||||||
await axios.post(urlPath.value, subRoleFormData);
|
await axios.post(urlPath.value, subRoleFormData);
|
||||||
notify(
|
notify(
|
||||||
t('Role added! Changes will take a while to fully propagate.'),
|
t('Role added! Changes will take a while to fully propagate.'),
|
||||||
'positive'
|
'positive'
|
||||||
);
|
);
|
||||||
fetchSubRoles();
|
fetchSubRoles();
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
|
|
|
@ -106,28 +106,24 @@ const setParams = (params) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const getPreview = async () => {
|
const getPreview = async () => {
|
||||||
try {
|
const params = {
|
||||||
const params = {
|
recipientId: entityId,
|
||||||
recipientId: entityId,
|
};
|
||||||
};
|
const validationMessage = validateMessage();
|
||||||
const validationMessage = validateMessage();
|
if (validationMessage) return notify(t(validationMessage), 'negative');
|
||||||
if (validationMessage) return notify(t(validationMessage), 'negative');
|
|
||||||
|
|
||||||
setParams(params);
|
setParams(params);
|
||||||
|
|
||||||
const path = `${sampleType.value.model}/${entityId.value}/${sampleType.value.code}-html`;
|
const path = `${sampleType.value.model}/${entityId.value}/${sampleType.value.code}-html`;
|
||||||
const { data } = await axios.get(path, { params });
|
const { data } = await axios.get(path, { params });
|
||||||
|
|
||||||
if (!data) return;
|
if (!data) return;
|
||||||
quasar.dialog({
|
quasar.dialog({
|
||||||
component: CustomerSamplesPreview,
|
component: CustomerSamplesPreview,
|
||||||
componentProps: {
|
componentProps: {
|
||||||
htmlContent: data,
|
htmlContent: data,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
} catch (err) {
|
|
||||||
notify('Errors getting preview', 'negative');
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const onSubmit = async () => {
|
const onSubmit = async () => {
|
||||||
|
|
|
@ -42,13 +42,9 @@ const setData = (entity) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const removeDepartment = async () => {
|
const removeDepartment = async () => {
|
||||||
try {
|
await axios.post(`/Departments/${entityId.value}/removeChild`, entityId.value);
|
||||||
await axios.post(`/Departments/${entityId.value}/removeChild`, entityId.value);
|
router.push({ name: 'WorkerDepartment' });
|
||||||
router.push({ name: 'WorkerDepartment' });
|
notify('department.departmentRemoved', 'positive');
|
||||||
notify('department.departmentRemoved', 'positive');
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Error removing department');
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const { openConfirmationModal } = useVnConfirm();
|
const { openConfirmationModal } = useVnConfirm();
|
||||||
|
|
|
@ -237,13 +237,9 @@ const copyOriginalRowsData = (rows) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const saveChange = async (field, { rowIndex, row }) => {
|
const saveChange = async (field, { rowIndex, row }) => {
|
||||||
try {
|
if (originalRowDataCopy.value[rowIndex][field] == row[field]) return;
|
||||||
if (originalRowDataCopy.value[rowIndex][field] == row[field]) return;
|
await axios.patch(`Buys/${row.id}`, row);
|
||||||
await axios.patch(`Buys/${row.id}`, row);
|
originalRowDataCopy.value[rowIndex][field] = row[field];
|
||||||
originalRowDataCopy.value[rowIndex][field] = row[field];
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Error saving changes', err);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const openRemoveDialog = async () => {
|
const openRemoveDialog = async () => {
|
||||||
|
@ -261,15 +257,11 @@ const openRemoveDialog = async () => {
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
.onOk(async () => {
|
.onOk(async () => {
|
||||||
try {
|
await deleteBuys();
|
||||||
await deleteBuys();
|
const notifyMessage = t(
|
||||||
const notifyMessage = t(
|
`Buy${rowsSelected.value.length > 1 ? 's' : ''} deleted`
|
||||||
`Buy${rowsSelected.value.length > 1 ? 's' : ''} deleted`
|
);
|
||||||
);
|
notify(notifyMessage, 'positive');
|
||||||
notify(notifyMessage, 'positive');
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Error deleting buys');
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -283,17 +275,13 @@ const importBuys = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const toggleGroupingMode = async (buy, mode) => {
|
const toggleGroupingMode = async (buy, mode) => {
|
||||||
try {
|
const groupingMode = mode === 'grouping' ? mode : 'packing';
|
||||||
const groupingMode = mode === 'grouping' ? mode : 'packing';
|
const newGroupingMode = buy.groupingMode === groupingMode ? null : groupingMode;
|
||||||
const newGroupingMode = buy.groupingMode === groupingMode ? null : groupingMode;
|
const params = {
|
||||||
const params = {
|
groupingMode: newGroupingMode,
|
||||||
groupingMode: newGroupingMode,
|
};
|
||||||
};
|
await axios.patch(`Buys/${buy.id}`, params);
|
||||||
await axios.patch(`Buys/${buy.id}`, params);
|
buy.groupingMode = newGroupingMode;
|
||||||
buy.groupingMode = newGroupingMode;
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Error toggling grouping mode');
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const lockIconType = (groupingMode, mode) => {
|
const lockIconType = (groupingMode, mode) => {
|
||||||
|
|
|
@ -123,36 +123,28 @@ const fillData = async (rawData) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const fetchBuys = async (buys) => {
|
const fetchBuys = async (buys) => {
|
||||||
try {
|
const params = { buys };
|
||||||
const params = { buys };
|
const { data } = await axios.post(
|
||||||
const { data } = await axios.post(
|
`Entries/${route.params.id}/importBuysPreview`,
|
||||||
`Entries/${route.params.id}/importBuysPreview`,
|
params
|
||||||
params
|
);
|
||||||
);
|
importData.value.buys = data;
|
||||||
importData.value.buys = data;
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Error fetching buys');
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const onSubmit = async () => {
|
const onSubmit = async () => {
|
||||||
try {
|
const params = importData.value;
|
||||||
const params = importData.value;
|
const hasAnyEmptyRow = params.buys.some((buy) => {
|
||||||
const hasAnyEmptyRow = params.buys.some((buy) => {
|
return buy.itemFk === null;
|
||||||
return buy.itemFk === null;
|
});
|
||||||
});
|
|
||||||
|
|
||||||
if (hasAnyEmptyRow) {
|
if (hasAnyEmptyRow) {
|
||||||
notify(t('Some of the imported buys does not have an item'), 'negative');
|
notify(t('Some of the imported buys does not have an item'), 'negative');
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
await axios.post(`Entries/${route.params.id}/importBuys`, params);
|
|
||||||
notify('globals.dataSaved', 'positive');
|
|
||||||
redirectToBuysView();
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Error importing buys', err);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await axios.post(`Entries/${route.params.id}/importBuys`, params);
|
||||||
|
notify('globals.dataSaved', 'positive');
|
||||||
|
redirectToBuysView();
|
||||||
};
|
};
|
||||||
|
|
||||||
const redirectToBuysView = () => {
|
const redirectToBuysView = () => {
|
||||||
|
|
|
@ -147,12 +147,9 @@ async function setEntryData(data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const fetchEntryBuys = async () => {
|
const fetchEntryBuys = async () => {
|
||||||
try {
|
|
||||||
const { data } = await axios.get(`Entries/${entry.value.id}/getBuys`);
|
const { data } = await axios.get(`Entries/${entry.value.id}/getBuys`);
|
||||||
if (data) entryBuys.value = data;
|
if (data) entryBuys.value = data;
|
||||||
} catch (err) {
|
|
||||||
console.error('Error fetching entry buys');
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -30,8 +30,6 @@ const recalc = async () => {
|
||||||
isLoading.value = true;
|
isLoading.value = true;
|
||||||
await axios.post('Applications/waste_addSales/execute-proc', params);
|
await axios.post('Applications/waste_addSales/execute-proc', params);
|
||||||
notify('wasteRecalc.recalcOk', 'positive');
|
notify('wasteRecalc.recalcOk', 'positive');
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
} finally {
|
} finally {
|
||||||
isLoading.value = false;
|
isLoading.value = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,25 +61,18 @@ const showSendInvoiceDialog = (type) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const sendEmailInvoice = async ({ address }) => {
|
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') {
|
if (invoiceFormType.value === 'pdf') {
|
||||||
return sendEmail(`InvoiceOuts/${$props.invoiceOutData.ref}/invoice-email`, {
|
return sendEmail(`InvoiceOuts/${$props.invoiceOutData.ref}/invoice-email`, {
|
||||||
recipientId: $props.invoiceOutData.client.id,
|
recipientId: $props.invoiceOutData.client.id,
|
||||||
recipient: address,
|
recipient: address,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
return sendEmail(
|
return sendEmail(`InvoiceOuts/${$props.invoiceOutData.ref}/invoice-csv-email`, {
|
||||||
`InvoiceOuts/${$props.invoiceOutData.ref}/invoice-csv-email`,
|
recipientId: $props.invoiceOutData.client.id,
|
||||||
{
|
recipient: address,
|
||||||
recipientId: $props.invoiceOutData.client.id,
|
});
|
||||||
recipient: address,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Error sending email', err);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -88,46 +81,30 @@ const redirectToInvoiceOutList = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const deleteInvoice = async () => {
|
const deleteInvoice = async () => {
|
||||||
try {
|
await axios.post(`InvoiceOuts/${$props.invoiceOutData.id}/delete`);
|
||||||
await axios.post(`InvoiceOuts/${$props.invoiceOutData.id}/delete`);
|
notify(t('InvoiceOut deleted'), 'positive');
|
||||||
notify(t('InvoiceOut deleted'), 'positive');
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Error deleting invoice out', err);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const bookInvoice = async () => {
|
const bookInvoice = async () => {
|
||||||
try {
|
await axios.post(`InvoiceOuts/${$props.invoiceOutData.ref}/book`);
|
||||||
await axios.post(`InvoiceOuts/${$props.invoiceOutData.ref}/book`);
|
notify(t('InvoiceOut booked'), 'positive');
|
||||||
notify(t('InvoiceOut booked'), 'positive');
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Error booking invoice out', err);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const generateInvoicePdf = async () => {
|
const generateInvoicePdf = async () => {
|
||||||
try {
|
await axios.post(`InvoiceOuts/${$props.invoiceOutData.id}/createPdf`);
|
||||||
await axios.post(`InvoiceOuts/${$props.invoiceOutData.id}/createPdf`);
|
notify(t('The invoice PDF document has been regenerated'), 'positive');
|
||||||
notify(t('The invoice PDF document has been regenerated'), 'positive');
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Error generating invoice out pdf', err);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const refundInvoice = async (withWarehouse) => {
|
const refundInvoice = async (withWarehouse) => {
|
||||||
try {
|
const params = { ref: $props.invoiceOutData.ref, withWarehouse: withWarehouse };
|
||||||
const params = { ref: $props.invoiceOutData.ref, withWarehouse: withWarehouse };
|
const { data } = await axios.post('InvoiceOuts/refund', params);
|
||||||
const { data } = await axios.post('InvoiceOuts/refund', params);
|
location.href = window.origin + `/#/ticket/${data[0].id}/sale`;
|
||||||
location.href = window.origin + `/#/ticket/${data[0].id}/sale`;
|
notify(
|
||||||
notify(
|
t('refundInvoiceSuccessMessage', {
|
||||||
t('refundInvoiceSuccessMessage', {
|
refundTicket: data[0].id,
|
||||||
refundTicket: data[0].id,
|
}),
|
||||||
}),
|
'positive'
|
||||||
'positive'
|
);
|
||||||
);
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Error generating invoice out pdf', err);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const showTransferInvoiceForm = async () => {
|
const showTransferInvoiceForm = async () => {
|
||||||
|
|
|
@ -143,15 +143,10 @@ onMounted(() => (stateStore.rightDrawer = true));
|
||||||
onUnmounted(() => (stateStore.rightDrawer = false));
|
onUnmounted(() => (stateStore.rightDrawer = false));
|
||||||
|
|
||||||
function openPdf(id) {
|
function openPdf(id) {
|
||||||
try {
|
openReport(`${MODEL}/${id}/download`);
|
||||||
openReport(`${MODEL}/${id}/download`);
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Error opening PDF', err);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function downloadPdf() {
|
function downloadPdf() {
|
||||||
try {
|
|
||||||
if (selectedRows.value.size === 0) return;
|
if (selectedRows.value.size === 0) return;
|
||||||
const selectedCardsArray = Array.from(selectedRows.value.values());
|
const selectedCardsArray = Array.from(selectedRows.value.values());
|
||||||
|
|
||||||
|
@ -170,9 +165,7 @@ function downloadPdf() {
|
||||||
|
|
||||||
openReport(`${MODEL}/downloadZip`, params);
|
openReport(`${MODEL}/downloadZip`, params);
|
||||||
}
|
}
|
||||||
} catch (err) {
|
|
||||||
console.error('Error opening PDF');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
watchEffect(selectedRows);
|
watchEffect(selectedRows);
|
||||||
|
|
|
@ -58,46 +58,34 @@ onMounted(async () => {
|
||||||
|
|
||||||
const data = ref(useCardDescription());
|
const data = ref(useCardDescription());
|
||||||
const setData = async (entity) => {
|
const setData = async (entity) => {
|
||||||
try {
|
if (!entity) return;
|
||||||
if (!entity) return;
|
data.value = useCardDescription(entity.name, entity.id);
|
||||||
data.value = useCardDescription(entity.name, entity.id);
|
await updateStock();
|
||||||
await updateStock();
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Error item');
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const getItemConfigs = async () => {
|
const getItemConfigs = async () => {
|
||||||
try {
|
const { data } = await axios.get('ItemConfigs/findOne');
|
||||||
const { data } = await axios.get('ItemConfigs/findOne');
|
if (!data) return;
|
||||||
if (!data) return;
|
return (warehouseConfig.value = data.warehouseFk);
|
||||||
return (warehouseConfig.value = data.warehouseFk);
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Error item');
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
const updateStock = async () => {
|
const updateStock = async () => {
|
||||||
try {
|
available.value = null;
|
||||||
available.value = null;
|
visible.value = null;
|
||||||
visible.value = null;
|
|
||||||
|
|
||||||
const params = {
|
const params = {
|
||||||
warehouseFk: $props.warehouseFk,
|
warehouseFk: $props.warehouseFk,
|
||||||
dated: $props.dated,
|
dated: $props.dated,
|
||||||
};
|
};
|
||||||
|
|
||||||
await getItemConfigs();
|
await getItemConfigs();
|
||||||
if (!params.warehouseFk) {
|
if (!params.warehouseFk) {
|
||||||
params.warehouseFk = warehouseConfig.value;
|
params.warehouseFk = warehouseConfig.value;
|
||||||
}
|
|
||||||
const { data } = await axios.get(`Items/${entityId.value}/getVisibleAvailable`, {
|
|
||||||
params,
|
|
||||||
});
|
|
||||||
available.value = data.available;
|
|
||||||
visible.value = data.visible;
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Error updating stock');
|
|
||||||
}
|
}
|
||||||
|
const { data } = await axios.get(`Items/${entityId.value}/getVisibleAvailable`, {
|
||||||
|
params,
|
||||||
|
});
|
||||||
|
available.value = data.available;
|
||||||
|
visible.value = data.visible;
|
||||||
};
|
};
|
||||||
|
|
||||||
const openRegularizeStockForm = () => {
|
const openRegularizeStockForm = () => {
|
||||||
|
@ -105,12 +93,8 @@ const openRegularizeStockForm = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const cloneItem = async () => {
|
const cloneItem = async () => {
|
||||||
try {
|
const { data } = await axios.post(`Items/${entityId.value}/clone`);
|
||||||
const { data } = await axios.post(`Items/${entityId.value}/clone`);
|
router.push({ name: 'ItemTags', params: { id: data.id } });
|
||||||
router.push({ name: 'ItemTags', params: { id: data.id } });
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Error cloning item');
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const openCloneDialog = async () => {
|
const openCloneDialog = async () => {
|
||||||
|
|
|
@ -45,13 +45,9 @@ const arrayData = useArrayData('ItemShelvings', {
|
||||||
const rows = computed(() => arrayData.store.data || []);
|
const rows = computed(() => arrayData.store.data || []);
|
||||||
|
|
||||||
const applyColumnFilter = async (col) => {
|
const applyColumnFilter = async (col) => {
|
||||||
try {
|
const paramKey = col.columnFilter?.filterParamKey || col.field;
|
||||||
const paramKey = col.columnFilter?.filterParamKey || col.field;
|
params[paramKey] = col.columnFilter.filterValue;
|
||||||
params[paramKey] = col.columnFilter.filterValue;
|
await arrayData.addFilter({ filter: null, params });
|
||||||
await arrayData.addFilter({ filter: null, params });
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Error applying column filter', err);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const getInputEvents = (col) => {
|
const getInputEvents = (col) => {
|
||||||
|
@ -173,15 +169,11 @@ const totalLabels = computed(() =>
|
||||||
);
|
);
|
||||||
|
|
||||||
const removeLines = async () => {
|
const removeLines = async () => {
|
||||||
try {
|
const itemShelvingIds = rowsSelected.value.map((row) => row.itemShelvingFk);
|
||||||
const itemShelvingIds = rowsSelected.value.map((row) => row.itemShelvingFk);
|
await axios.post('ItemShelvings/deleteItemShelvings', { itemShelvingIds });
|
||||||
await axios.post('ItemShelvings/deleteItemShelvings', { itemShelvingIds });
|
rowsSelected.value = [];
|
||||||
rowsSelected.value = [];
|
notify('shelvings.shelvingsRemoved', 'positive');
|
||||||
notify('shelvings.shelvingsRemoved', 'positive');
|
await arrayData.fetch({ append: false });
|
||||||
await arrayData.fetch({ append: false });
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Error removing lines', err);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
await arrayData.fetch({ append: false });
|
await arrayData.fetch({ append: false });
|
||||||
|
|
|
@ -19,22 +19,18 @@ const tagOptions = ref([]);
|
||||||
const valueOptionsMap = ref(new Map());
|
const valueOptionsMap = ref(new Map());
|
||||||
|
|
||||||
const getSelectedTagValues = async (tag) => {
|
const getSelectedTagValues = async (tag) => {
|
||||||
try {
|
if (!tag.tagFk && tag.tag.isFree) return;
|
||||||
if (!tag.tagFk && tag.tag.isFree) return;
|
const filter = {
|
||||||
const filter = {
|
fields: ['value'],
|
||||||
fields: ['value'],
|
order: 'value ASC',
|
||||||
order: 'value ASC',
|
limit: 30,
|
||||||
limit: 30,
|
};
|
||||||
};
|
|
||||||
|
|
||||||
const params = { filter: JSON.stringify(filter) };
|
const params = { filter: JSON.stringify(filter) };
|
||||||
const { data } = await axios.get(`Tags/${tag.tagFk}/filterValue`, {
|
const { data } = await axios.get(`Tags/${tag.tagFk}/filterValue`, {
|
||||||
params,
|
params,
|
||||||
});
|
});
|
||||||
valueOptionsMap.value.set(tag.tagFk, data);
|
valueOptionsMap.value.set(tag.tagFk, data);
|
||||||
} catch (err) {
|
|
||||||
console.error('Error getting selected tag values');
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const onItemTagsFetched = async (itemTags) => {
|
const onItemTagsFetched = async (itemTags) => {
|
||||||
|
|
|
@ -32,17 +32,13 @@ const ItemTaxRef = ref(null);
|
||||||
const taxesOptions = ref([]);
|
const taxesOptions = ref([]);
|
||||||
|
|
||||||
const submitTaxes = async (data) => {
|
const submitTaxes = async (data) => {
|
||||||
try {
|
let payload = data.map((tax) => ({
|
||||||
let payload = data.map((tax) => ({
|
id: tax.id,
|
||||||
id: tax.id,
|
taxClassFk: tax.taxClassFk,
|
||||||
taxClassFk: tax.taxClassFk,
|
}));
|
||||||
}));
|
|
||||||
|
|
||||||
await axios.post(`Items/updateTaxes`, payload);
|
await axios.post(`Items/updateTaxes`, payload);
|
||||||
notify(t('globals.dataSaved'), 'positive');
|
notify(t('globals.dataSaved'), 'positive');
|
||||||
} catch (err) {
|
|
||||||
console.error('Error saving taxes', err);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
|
|
|
@ -221,24 +221,16 @@ const updateMinPrice = async (value, props) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const upsertPrice = async (props, resetMinPrice = false) => {
|
const upsertPrice = async (props, resetMinPrice = false) => {
|
||||||
try {
|
const { row } = props;
|
||||||
const { row } = props;
|
if (tableRef.value.CrudModelRef.getChanges().updates.length > 0) {
|
||||||
if (tableRef.value.CrudModelRef.getChanges().updates.length > 0) {
|
if (resetMinPrice) row.hasMinPrice = 0;
|
||||||
if (resetMinPrice) row.hasMinPrice = 0;
|
await upsertFixedPrice(row);
|
||||||
await upsertFixedPrice(row);
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Error editing price', err);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
async function upsertFixedPrice(row) {
|
async function upsertFixedPrice(row) {
|
||||||
try {
|
const { data } = await axios.patch('FixedPrices/upsertFixedPrice', row);
|
||||||
const { data } = await axios.patch('FixedPrices/upsertFixedPrice', row);
|
return data;
|
||||||
return data;
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Error editing price', err);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function saveOnRowChange(row) {
|
async function saveOnRowChange(row) {
|
||||||
|
@ -321,14 +313,10 @@ const onEditCellDataSaved = async () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const removeFuturePrice = async () => {
|
const removeFuturePrice = async () => {
|
||||||
try {
|
rowsSelected.value.forEach(({ id }) => {
|
||||||
rowsSelected.value.forEach(({ id }) => {
|
const rowIndex = fixedPrices.value.findIndex(({ id }) => id === id);
|
||||||
const rowIndex = fixedPrices.value.findIndex(({ id }) => id === id);
|
removePrice(id, rowIndex);
|
||||||
removePrice(id, rowIndex);
|
});
|
||||||
});
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Error removing price', err);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
function confirmRemove(item, isFuture) {
|
function confirmRemove(item, isFuture) {
|
||||||
|
@ -345,13 +333,9 @@ function confirmRemove(item, isFuture) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const removePrice = async (id) => {
|
const removePrice = async (id) => {
|
||||||
try {
|
await axios.delete(`FixedPrices/${id}`);
|
||||||
await axios.delete(`FixedPrices/${id}`);
|
notify(t('globals.dataSaved'), 'positive');
|
||||||
notify(t('globals.dataSaved'), 'positive');
|
tableRef.value.reload({});
|
||||||
tableRef.value.reload({});
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Error removing price', err);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
const dateStyle = (date) =>
|
const dateStyle = (date) =>
|
||||||
date
|
date
|
||||||
|
|
|
@ -73,13 +73,9 @@ const exprBuilder = (param, value) => {
|
||||||
const params = reactive({ isFloramondo: false, isActive: true });
|
const params = reactive({ isFloramondo: false, isActive: true });
|
||||||
|
|
||||||
const applyColumnFilter = async (col) => {
|
const applyColumnFilter = async (col) => {
|
||||||
try {
|
const paramKey = col.columnFilter?.filterParamKey || col.field;
|
||||||
const paramKey = col.columnFilter?.filterParamKey || col.field;
|
params[paramKey] = col.columnFilter.filterValue;
|
||||||
params[paramKey] = col.columnFilter.filterValue;
|
await paginateRef.value.addFilter(null, params);
|
||||||
await paginateRef.value.addFilter(null, params);
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Error applying column filter', err);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const getInputEvents = (col) => {
|
const getInputEvents = (col) => {
|
||||||
|
@ -379,13 +375,9 @@ const redirectToItemSummary = (id) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const cloneItem = async (itemFk) => {
|
const cloneItem = async (itemFk) => {
|
||||||
try {
|
const { data } = await axios.post(`Items/${itemFk}/clone`);
|
||||||
const { data } = await axios.post(`Items/${itemFk}/clone`);
|
if (!data) return;
|
||||||
if (!data) return;
|
router.push({ name: 'ItemTags', params: { id: data.id } });
|
||||||
router.push({ name: 'ItemTags', params: { id: data.id } });
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Error cloning item', err);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
|
|
|
@ -55,22 +55,18 @@ const onCategoryChange = async (categoryFk, search) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const getSelectedTagValues = async (tag) => {
|
const getSelectedTagValues = async (tag) => {
|
||||||
try {
|
if (!tag?.selectedTag?.id) return;
|
||||||
if (!tag?.selectedTag?.id) return;
|
tag.value = null;
|
||||||
tag.value = null;
|
const filter = {
|
||||||
const filter = {
|
fields: ['value'],
|
||||||
fields: ['value'],
|
order: 'value ASC',
|
||||||
order: 'value ASC',
|
};
|
||||||
};
|
|
||||||
|
|
||||||
const params = { filter: JSON.stringify(filter) };
|
const params = { filter: JSON.stringify(filter) };
|
||||||
const { data } = await axios.get(`Tags/${tag.selectedTag.id}/filterValue`, {
|
const { data } = await axios.get(`Tags/${tag.selectedTag.id}/filterValue`, {
|
||||||
params,
|
params,
|
||||||
});
|
});
|
||||||
tag.valueOptions = data;
|
tag.valueOptions = data;
|
||||||
} catch (err) {
|
|
||||||
console.error('Error getting selected tag values');
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const applyTags = (params, search) => {
|
const applyTags = (params, search) => {
|
||||||
|
|
|
@ -125,41 +125,30 @@ const columns = computed(() => [
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const changeQuantity = async (request) => {
|
const changeQuantity = async (request) => {
|
||||||
try {
|
if (request.saleFk) {
|
||||||
if (request.saleFk) {
|
const params = {
|
||||||
const params = {
|
quantity: request.saleQuantity,
|
||||||
quantity: request.saleQuantity,
|
};
|
||||||
};
|
|
||||||
|
|
||||||
await axios.patch(`Sales/${request.saleFk}`, params);
|
await axios.patch(`Sales/${request.saleFk}`, params);
|
||||||
notify(t('globals.dataSaved'), 'positive');
|
notify(t('globals.dataSaved'), 'positive');
|
||||||
confirmRequest(request);
|
confirmRequest(request);
|
||||||
} else confirmRequest(request);
|
} else confirmRequest(request);
|
||||||
} catch (error) {
|
|
||||||
console.error('Error changing quantity:: ', error);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const confirmRequest = async (request) => {
|
const confirmRequest = async (request) => {
|
||||||
try {
|
if (request.itemFk && request.saleQuantity) {
|
||||||
if (request.itemFk && request.saleQuantity) {
|
const params = {
|
||||||
const params = {
|
itemFk: request.itemFk,
|
||||||
itemFk: request.itemFk,
|
quantity: request.saleQuantity,
|
||||||
quantity: request.saleQuantity,
|
attenderFk: request.attenderFk,
|
||||||
attenderFk: request.attenderFk,
|
};
|
||||||
};
|
|
||||||
|
|
||||||
const { data } = await axios.post(
|
const { data } = await axios.post(`TicketRequests/${request.id}/confirm`, params);
|
||||||
`TicketRequests/${request.id}/confirm`,
|
|
||||||
params
|
|
||||||
);
|
|
||||||
|
|
||||||
request.itemDescription = data.concept;
|
request.itemDescription = data.concept;
|
||||||
request.isOk = true;
|
request.isOk = true;
|
||||||
notify(t('globals.dataSaved'), 'positive');
|
notify(t('globals.dataSaved'), 'positive');
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error confirming request:: ', error);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -103,15 +103,11 @@ const getBadgeColor = (date) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const removeOrders = async () => {
|
const removeOrders = async () => {
|
||||||
try {
|
const selectedIds = selectedRows.value.map((row) => row.id);
|
||||||
const selectedIds = selectedRows.value.map((row) => row.id);
|
const params = { deletes: selectedIds };
|
||||||
const params = { deletes: selectedIds };
|
await axios.post('SalesMonitors/deleteOrders', params);
|
||||||
await axios.post('SalesMonitors/deleteOrders', params);
|
selectedRows.value = [];
|
||||||
selectedRows.value = [];
|
await table.value.reload();
|
||||||
await table.value.reload();
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Error deleting orders', err);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const openTab = (id) =>
|
const openTab = (id) =>
|
||||||
|
|
|
@ -22,22 +22,17 @@ const agencyList = ref([]);
|
||||||
const addressList = ref([]);
|
const addressList = ref([]);
|
||||||
|
|
||||||
const fetchAddressList = async (addressId) => {
|
const fetchAddressList = async (addressId) => {
|
||||||
try {
|
const { data } = await axios.get('addresses', {
|
||||||
const { data } = await axios.get('addresses', {
|
params: {
|
||||||
params: {
|
filter: JSON.stringify({
|
||||||
filter: JSON.stringify({
|
fields: ['id', 'nickname', 'street', 'city'],
|
||||||
fields: ['id', 'nickname', 'street', 'city'],
|
where: { id: addressId },
|
||||||
where: { id: addressId },
|
}),
|
||||||
}),
|
},
|
||||||
},
|
});
|
||||||
});
|
addressList.value = data;
|
||||||
addressList.value = data;
|
if (addressList.value?.length === 1) {
|
||||||
if (addressList.value?.length === 1) {
|
state.get(ORDER_MODEL).addressFk = addressList.value[0].id;
|
||||||
state.get(ORDER_MODEL).addressFk = addressList.value[0].id;
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
console.error(`Error fetching addresses`, err);
|
|
||||||
return err.response;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -45,18 +40,13 @@ const fetchAgencyList = async (landed, addressFk) => {
|
||||||
if (!landed || !addressFk) {
|
if (!landed || !addressFk) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
const { data } = await axios.get('Agencies/landsThatDay', {
|
||||||
const { data } = await axios.get('Agencies/landsThatDay', {
|
params: {
|
||||||
params: {
|
addressFk,
|
||||||
addressFk,
|
landed: new Date(landed).toISOString(),
|
||||||
landed: new Date(landed).toISOString(),
|
},
|
||||||
},
|
});
|
||||||
});
|
agencyList.value = data;
|
||||||
agencyList.value = data;
|
|
||||||
} catch (err) {
|
|
||||||
console.error(`Error fetching agencies`, err);
|
|
||||||
return err.response;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const fetchOrderDetails = (order) => {
|
const fetchOrderDetails = (order) => {
|
||||||
|
@ -92,12 +82,8 @@ const orderFilter = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const onClientChange = async (clientId) => {
|
const onClientChange = async (clientId) => {
|
||||||
try {
|
const { data } = await axios.get(`Clients/${clientId}`);
|
||||||
const { data } = await axios.get(`Clients/${clientId}`);
|
await fetchAddressList(data.defaultAddressFk);
|
||||||
await fetchAddressList(data.defaultAddressFk);
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error al cambiar el cliente:', error);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -22,22 +22,17 @@ const addressList = ref([]);
|
||||||
defineEmits(['confirm', ...useDialogPluginComponent.emits]);
|
defineEmits(['confirm', ...useDialogPluginComponent.emits]);
|
||||||
|
|
||||||
const fetchAddressList = async (addressId) => {
|
const fetchAddressList = async (addressId) => {
|
||||||
try {
|
const { data } = await axios.get('addresses', {
|
||||||
const { data } = await axios.get('addresses', {
|
params: {
|
||||||
params: {
|
filter: JSON.stringify({
|
||||||
filter: JSON.stringify({
|
fields: ['id', 'nickname', 'street', 'city'],
|
||||||
fields: ['id', 'nickname', 'street', 'city'],
|
where: { id: addressId },
|
||||||
where: { id: addressId },
|
}),
|
||||||
}),
|
},
|
||||||
},
|
});
|
||||||
});
|
addressList.value = data;
|
||||||
addressList.value = data;
|
if (addressList.value?.length === 1) {
|
||||||
if (addressList.value?.length === 1) {
|
state.get(ORDER_MODEL).addressId = addressList.value[0].id;
|
||||||
state.get(ORDER_MODEL).addressId = addressList.value[0].id;
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
console.error(`Error fetching addresses`, err);
|
|
||||||
return err.response;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -45,18 +40,13 @@ const fetchAgencyList = async (landed, addressFk) => {
|
||||||
if (!landed || !addressFk) {
|
if (!landed || !addressFk) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
const { data } = await axios.get('Agencies/landsThatDay', {
|
||||||
const { data } = await axios.get('Agencies/landsThatDay', {
|
params: {
|
||||||
params: {
|
addressFk,
|
||||||
addressFk,
|
landed: new Date(landed).toISOString(),
|
||||||
landed: new Date(landed).toISOString(),
|
},
|
||||||
},
|
});
|
||||||
});
|
agencyList.value = data;
|
||||||
agencyList.value = data;
|
|
||||||
} catch (err) {
|
|
||||||
console.error(`Error fetching agencies`, err);
|
|
||||||
return err.response;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// const fetchOrderDetails = (order) => {
|
// const fetchOrderDetails = (order) => {
|
||||||
|
@ -109,12 +99,8 @@ const initialFormState = reactive({
|
||||||
// };
|
// };
|
||||||
|
|
||||||
const onClientChange = async (clientId = $props.clientFk) => {
|
const onClientChange = async (clientId = $props.clientFk) => {
|
||||||
try {
|
const { data } = await axios.get(`Clients/${clientId}`);
|
||||||
const { data } = await axios.get(`Clients/${clientId}`);
|
await fetchAddressList(data.defaultAddressFk);
|
||||||
await fetchAddressList(data.defaultAddressFk);
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error al cambiar el cliente:', error);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
async function onDataSaved(_, id) {
|
async function onDataSaved(_, id) {
|
||||||
|
|
|
@ -47,17 +47,13 @@ const onChangesSaved = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const setWireTransfer = async () => {
|
const setWireTransfer = async () => {
|
||||||
try {
|
const params = {
|
||||||
const params = {
|
id: route.params.id,
|
||||||
id: route.params.id,
|
payMethodFk: wireTransferFk.value,
|
||||||
payMethodFk: wireTransferFk.value,
|
};
|
||||||
};
|
|
||||||
|
|
||||||
await axios.patch(`Suppliers/${route.params.id}`, params);
|
await axios.patch(`Suppliers/${route.params.id}`, params);
|
||||||
notify('globals.dataSaved', 'positive');
|
notify('globals.dataSaved', 'positive');
|
||||||
} catch (err) {
|
|
||||||
console.error('Error setting wire transfer', err);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
|
|
|
@ -34,26 +34,20 @@ const newTicketFormData = reactive({});
|
||||||
const date = new Date();
|
const date = new Date();
|
||||||
|
|
||||||
const createTicket = async () => {
|
const createTicket = async () => {
|
||||||
try {
|
const expeditionIds = $props.selectedExpeditions.map((expedition) => expedition.id);
|
||||||
const expeditionIds = $props.selectedExpeditions.map(
|
const params = {
|
||||||
(expedition) => expedition.id
|
clientId: $props.ticket.clientFk,
|
||||||
);
|
landed: newTicketFormData.landed,
|
||||||
const params = {
|
warehouseId: $props.ticket.warehouseFk,
|
||||||
clientId: $props.ticket.clientFk,
|
addressId: $props.ticket.addressFk,
|
||||||
landed: newTicketFormData.landed,
|
agencyModeId: $props.ticket.agencyModeFk,
|
||||||
warehouseId: $props.ticket.warehouseFk,
|
routeId: newTicketFormData.routeFk,
|
||||||
addressId: $props.ticket.addressFk,
|
expeditionIds: expeditionIds,
|
||||||
agencyModeId: $props.ticket.agencyModeFk,
|
};
|
||||||
routeId: newTicketFormData.routeFk,
|
|
||||||
expeditionIds: expeditionIds,
|
|
||||||
};
|
|
||||||
|
|
||||||
const { data } = await axios.post('Expeditions/moveExpeditions', params);
|
const { data } = await axios.post('Expeditions/moveExpeditions', params);
|
||||||
notify(t('globals.dataSaved'), 'positive');
|
notify(t('globals.dataSaved'), 'positive');
|
||||||
router.push({ name: 'TicketSummary', params: { id: data.id } });
|
router.push({ name: 'TicketSummary', params: { id: data.id } });
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -150,31 +150,19 @@ const getTotal = computed(() => {
|
||||||
});
|
});
|
||||||
|
|
||||||
const getComponentsSum = async () => {
|
const getComponentsSum = async () => {
|
||||||
try {
|
const { data } = await axios.get(`Tickets/${route.params.id}/getComponentsSum`);
|
||||||
const { data } = await axios.get(`Tickets/${route.params.id}/getComponentsSum`);
|
componentsList.value = data;
|
||||||
componentsList.value = data;
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const getTheoricalCost = async () => {
|
const getTheoricalCost = async () => {
|
||||||
try {
|
const { data } = await axios.get(`Tickets/${route.params.id}/freightCost`);
|
||||||
const { data } = await axios.get(`Tickets/${route.params.id}/freightCost`);
|
theoricalCost.value = data;
|
||||||
theoricalCost.value = data;
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const getTicketVolume = async () => {
|
const getTicketVolume = async () => {
|
||||||
try {
|
if (!ticketData.value) return;
|
||||||
if (!ticketData.value) return;
|
const { data } = await axios.get(`Tickets/${ticketData.value.id}/getVolume`);
|
||||||
const { data } = await axios.get(`Tickets/${ticketData.value.id}/getVolume`);
|
ticketVolume.value = data[0].volume;
|
||||||
ticketVolume.value = data[0].volume;
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
|
|
@ -163,16 +163,13 @@ const showNewTicketDialog = (withRoute = false) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const deleteExpedition = async () => {
|
const deleteExpedition = async () => {
|
||||||
try {
|
|
||||||
const expeditionIds = selectedRows.value.map((expedition) => expedition.id);
|
const expeditionIds = selectedRows.value.map((expedition) => expedition.id);
|
||||||
const params = { expeditionIds };
|
const params = { expeditionIds };
|
||||||
await axios.post('Expeditions/deleteExpeditions', params);
|
await axios.post('Expeditions/deleteExpeditions', params);
|
||||||
vnTableRef.value.reload();
|
vnTableRef.value.reload();
|
||||||
selectedExpeditions.value = [];
|
selectedExpeditions.value = [];
|
||||||
notify(t('expedition.expeditionRemoved'), 'positive');
|
notify(t('expedition.expeditionRemoved'), 'positive');
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const showLog = async (expedition) => {
|
const showLog = async (expedition) => {
|
||||||
|
@ -181,7 +178,6 @@ const showLog = async (expedition) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const getExpeditionState = async (expedition) => {
|
const getExpeditionState = async (expedition) => {
|
||||||
try {
|
|
||||||
const filter = {
|
const filter = {
|
||||||
where: { expeditionFk: expedition.id },
|
where: { expeditionFk: expedition.id },
|
||||||
order: ['created DESC'],
|
order: ['created DESC'],
|
||||||
|
@ -195,9 +191,7 @@ const getExpeditionState = async (expedition) => {
|
||||||
...state,
|
...state,
|
||||||
isScanned: !!state.isScanned,
|
isScanned: !!state.isScanned,
|
||||||
}));
|
}));
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
|
|
|
@ -172,13 +172,9 @@ const getRequestState = (state) => {
|
||||||
const isEditable = (isOk) => isOk !== null;
|
const isEditable = (isOk) => isOk !== null;
|
||||||
|
|
||||||
async function removeLine(id) {
|
async function removeLine(id) {
|
||||||
try {
|
await axios.delete(`TicketRequests/${id}`);
|
||||||
await axios.delete(`TicketRequests/${id}`);
|
notify(t('globals.dataSaved'), 'positive');
|
||||||
notify(t('globals.dataSaved'), 'positive');
|
location.reload();
|
||||||
location.reload();
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Error ', err);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => (stateStore.rightDrawer = false));
|
onMounted(() => (stateStore.rightDrawer = false));
|
||||||
|
|
|
@ -152,15 +152,11 @@ const columns = computed(() => [
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const getConfig = async () => {
|
const getConfig = async () => {
|
||||||
try {
|
let filter = {
|
||||||
let filter = {
|
fields: ['daysForWarningClaim'],
|
||||||
fields: ['daysForWarningClaim'],
|
};
|
||||||
};
|
const { data } = await axios.get(`TicketConfigs`, { filter });
|
||||||
const { data } = await axios.get(`TicketConfigs`, { filter });
|
ticketConfig.value = data;
|
||||||
ticketConfig.value = data;
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Error getting ticket config', err);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const onSalesFetched = (salesData) => {
|
const onSalesFetched = (salesData) => {
|
||||||
|
@ -183,41 +179,33 @@ const resetChanges = async () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const updateQuantity = async (sale) => {
|
const updateQuantity = async (sale) => {
|
||||||
try {
|
const payload = { quantity: sale.quantity };
|
||||||
const payload = { quantity: sale.quantity };
|
await axios.post(`Sales/${sale.id}/updateQuantity`, payload);
|
||||||
await axios.post(`Sales/${sale.id}/updateQuantity`, payload);
|
notify('globals.dataSaved', 'positive');
|
||||||
notify('globals.dataSaved', 'positive');
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Error updating quantity', err);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const addSale = async (sale) => {
|
const addSale = async (sale) => {
|
||||||
try {
|
const payload = {
|
||||||
const payload = {
|
barcode: sale.itemFk,
|
||||||
barcode: sale.itemFk,
|
quantity: sale.quantity,
|
||||||
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;
|
const newSale = data;
|
||||||
sale.id = newSale.id;
|
sale.id = newSale.id;
|
||||||
sale.image = newSale.item.image;
|
sale.image = newSale.item.image;
|
||||||
sale.subName = newSale.item.subName;
|
sale.subName = newSale.item.subName;
|
||||||
sale.concept = newSale.concept;
|
sale.concept = newSale.concept;
|
||||||
sale.quantity = newSale.quantity;
|
sale.quantity = newSale.quantity;
|
||||||
sale.discount = newSale.discount;
|
sale.discount = newSale.discount;
|
||||||
sale.price = newSale.price;
|
sale.price = newSale.price;
|
||||||
sale.item = newSale.item;
|
sale.item = newSale.item;
|
||||||
|
|
||||||
notify('globals.dataSaved', 'positive');
|
notify('globals.dataSaved', 'positive');
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
} catch (err) {
|
|
||||||
console.error('Error adding sale', err);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const changeQuantity = (sale) => {
|
const changeQuantity = (sale) => {
|
||||||
|
@ -232,13 +220,9 @@ const changeQuantity = (sale) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const updateConcept = async (sale) => {
|
const updateConcept = async (sale) => {
|
||||||
try {
|
const data = { newConcept: sale.concept };
|
||||||
const data = { newConcept: sale.concept };
|
await axios.post(`Sales/${sale.id}/updateConcept`, data);
|
||||||
await axios.post(`Sales/${sale.id}/updateConcept`, data);
|
notify('globals.dataSaved', 'positive');
|
||||||
notify('globals.dataSaved', 'positive');
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Error updating concept', err);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const DEFAULT_EDIT = {
|
const DEFAULT_EDIT = {
|
||||||
|
@ -292,18 +276,14 @@ const onOpenEditDiscountPopover = async (sale) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const updatePrice = async (sale) => {
|
const updatePrice = async (sale) => {
|
||||||
try {
|
const newPrice = edit.value.price;
|
||||||
const newPrice = edit.value.price;
|
if (newPrice != null && newPrice != sale.price) {
|
||||||
if (newPrice != null && newPrice != sale.price) {
|
await axios.post(`Sales/${sale.id}/updatePrice`, { newPrice });
|
||||||
await axios.post(`Sales/${sale.id}/updatePrice`, { newPrice });
|
sale.price = newPrice;
|
||||||
sale.price = newPrice;
|
edit.value = { ...DEFAULT_EDIT };
|
||||||
edit.value = { ...DEFAULT_EDIT };
|
notify('globals.dataSaved', 'positive');
|
||||||
notify('globals.dataSaved', 'positive');
|
|
||||||
}
|
|
||||||
await getMana();
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Error updating price', err);
|
|
||||||
}
|
}
|
||||||
|
await getMana();
|
||||||
};
|
};
|
||||||
|
|
||||||
const changeDiscount = (sale) => {
|
const changeDiscount = (sale) => {
|
||||||
|
@ -344,15 +324,11 @@ const getNewPrice = computed(() => {
|
||||||
});
|
});
|
||||||
|
|
||||||
const newOrderFromTicket = async () => {
|
const newOrderFromTicket = async () => {
|
||||||
try {
|
const { data } = await axios.post(`Orders/newFromTicket`, {
|
||||||
const { data } = await axios.post(`Orders/newFromTicket`, {
|
ticketFk: Number(route.params.id),
|
||||||
ticketFk: Number(route.params.id),
|
});
|
||||||
});
|
const routeData = router.resolve({ name: 'OrderCatalog', params: { id: data } });
|
||||||
const routeData = router.resolve({ name: 'OrderCatalog', params: { id: data } });
|
window.open(routeData.href, '_blank');
|
||||||
window.open(routeData.href, '_blank');
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Error creating new order', err);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const goToLog = (saleId) => {
|
const goToLog = (saleId) => {
|
||||||
|
@ -367,15 +343,11 @@ const goToLog = (saleId) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const changeTicketState = async (val) => {
|
const changeTicketState = async (val) => {
|
||||||
try {
|
stateBtnDropdownRef.value.hide();
|
||||||
stateBtnDropdownRef.value.hide();
|
const params = { ticketFk: route.params.id, code: val };
|
||||||
const params = { ticketFk: route.params.id, code: val };
|
await axios.post('Tickets/state', params);
|
||||||
await axios.post('Tickets/state', params);
|
notify('globals.dataSaved', 'positive');
|
||||||
notify('globals.dataSaved', 'positive');
|
await resetChanges();
|
||||||
await resetChanges();
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Error changing ticket state', err);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const removeSelectedSales = () => {
|
const removeSelectedSales = () => {
|
||||||
|
@ -386,47 +358,34 @@ const removeSelectedSales = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const removeSales = async () => {
|
const removeSales = async () => {
|
||||||
try {
|
const params = {
|
||||||
const params = {
|
sales: selectedRows.value.filter((sale) => sale.id),
|
||||||
sales: selectedRows.value.filter((sale) => sale.id),
|
ticketId: store.data.id,
|
||||||
ticketId: store.data.id,
|
};
|
||||||
};
|
selectedRows.value
|
||||||
selectedRows.value
|
.filter((sale) => !sale.id)
|
||||||
.filter((sale) => !sale.id)
|
.forEach((sale) => tableRef.value.CrudModelRef.formData.splice(sale.$index, 1));
|
||||||
.forEach((sale) =>
|
|
||||||
tableRef.value.CrudModelRef.formData.splice(sale.$index, 1)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (params.sales.length == 0) return;
|
if (params.sales.length == 0) return;
|
||||||
await axios.post('Sales/deleteSales', params);
|
await axios.post('Sales/deleteSales', params);
|
||||||
removeSelectedSales();
|
removeSelectedSales();
|
||||||
notify('globals.dataSaved', 'positive');
|
notify('globals.dataSaved', 'positive');
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
} catch (err) {
|
|
||||||
console.error('Error deleting sales', err);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const setTransferParams = async () => {
|
const setTransferParams = async () => {
|
||||||
try {
|
selectedSales.value = selectedValidSales.value;
|
||||||
selectedSales.value = selectedValidSales.value;
|
const checkedSales = JSON.parse(JSON.stringify(selectedSales.value));
|
||||||
const checkedSales = JSON.parse(JSON.stringify(selectedSales.value));
|
transfer.value = {
|
||||||
transfer.value = {
|
lastActiveTickets: [],
|
||||||
lastActiveTickets: [],
|
sales: checkedSales,
|
||||||
sales: checkedSales,
|
};
|
||||||
};
|
|
||||||
|
|
||||||
const params = { ticketId: store.data.id };
|
const params = { ticketId: store.data.id };
|
||||||
const { data } = await axios.get(
|
const { data } = await axios.get(`clients/${store.data.clientFk}/lastActiveTickets`, {
|
||||||
`clients/${store.data.clientFk}/lastActiveTickets`,
|
params,
|
||||||
{
|
});
|
||||||
params,
|
transfer.value.lastActiveTickets = data;
|
||||||
}
|
|
||||||
);
|
|
||||||
transfer.value.lastActiveTickets = data;
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Error setting transfer params', err);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
|
|
|
@ -140,13 +140,9 @@ const createClaim = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const onCreateClaimAccepted = async () => {
|
const onCreateClaimAccepted = async () => {
|
||||||
try {
|
const params = { ticketId: ticket.value.id, sales: props.sales };
|
||||||
const params = { ticketId: ticket.value.id, sales: props.sales };
|
const { data } = await axios.post(`Claims/createFromSales`, params);
|
||||||
const { data } = await axios.post(`Claims/createFromSales`, params);
|
push({ name: 'ClaimBasicData', params: { id: data.id } });
|
||||||
push({ name: 'ClaimBasicData', params: { id: data.id } });
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error creating claim: ', error);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const setReserved = async (reserved) => {
|
const setReserved = async (reserved) => {
|
||||||
|
@ -166,14 +162,10 @@ const createRefund = async (withWarehouse) => {
|
||||||
negative: true,
|
negative: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
const { data } = await axios.post('Tickets/cloneAll', params);
|
||||||
const { data } = await axios.post('Tickets/cloneAll', params);
|
const [refundTicket] = data;
|
||||||
const [refundTicket] = data;
|
notify(t('refundTicketCreated', { ticketId: refundTicket.id }), 'positive');
|
||||||
notify(t('refundTicketCreated', { ticketId: refundTicket.id }), 'positive');
|
push({ name: 'TicketSale', params: { id: refundTicket.id } });
|
||||||
push({ name: 'TicketSale', params: { id: refundTicket.id } });
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -150,18 +150,14 @@ const shelvingsTableColumns = computed(() => [
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const getSaleTrackings = async (sale) => {
|
const getSaleTrackings = async (sale) => {
|
||||||
try {
|
const filter = {
|
||||||
const filter = {
|
where: { saleFk: sale.saleFk },
|
||||||
where: { saleFk: sale.saleFk },
|
order: ['itemFk DESC'],
|
||||||
order: ['itemFk DESC'],
|
};
|
||||||
};
|
const { data } = await axios.get(`SaleTrackings/listSaleTracking`, {
|
||||||
const { data } = await axios.get(`SaleTrackings/listSaleTracking`, {
|
params: { filter: JSON.stringify(filter) },
|
||||||
params: { filter: JSON.stringify(filter) },
|
});
|
||||||
});
|
saleTrackings.value = data;
|
||||||
saleTrackings.value = data;
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const showLog = async (sale) => {
|
const showLog = async (sale) => {
|
||||||
|
@ -170,17 +166,13 @@ const showLog = async (sale) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const getItemShelvingSales = async (sale) => {
|
const getItemShelvingSales = async (sale) => {
|
||||||
try {
|
const filter = {
|
||||||
const filter = {
|
where: { saleFk: sale.saleFk },
|
||||||
where: { saleFk: sale.saleFk },
|
};
|
||||||
};
|
const { data } = await axios.get(`ItemShelvingSales/filter`, {
|
||||||
const { data } = await axios.get(`ItemShelvingSales/filter`, {
|
params: { filter: JSON.stringify(filter) },
|
||||||
params: { filter: JSON.stringify(filter) },
|
});
|
||||||
});
|
itemShelvingsSales.value = data;
|
||||||
itemShelvingsSales.value = data;
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const showShelving = async (sale) => {
|
const showShelving = async (sale) => {
|
||||||
|
@ -189,36 +181,28 @@ const showShelving = async (sale) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const updateQuantity = async (sale) => {
|
const updateQuantity = async (sale) => {
|
||||||
try {
|
if (oldQuantity.value === sale.quantity) return;
|
||||||
if (oldQuantity.value === sale.quantity) return;
|
const params = {
|
||||||
const params = {
|
quantity: sale.quantity,
|
||||||
quantity: sale.quantity,
|
};
|
||||||
};
|
await axios.patch(`ItemShelvingSales/${sale.id}`, params);
|
||||||
await axios.patch(`ItemShelvingSales/${sale.id}`, params);
|
oldQuantity.value = null;
|
||||||
oldQuantity.value = null;
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const updateParking = async (sale) => {
|
const updateParking = async (sale) => {
|
||||||
try {
|
const filter = {
|
||||||
const filter = {
|
fields: ['id'],
|
||||||
fields: ['id'],
|
where: {
|
||||||
where: {
|
code: sale.shelvingFk,
|
||||||
code: sale.shelvingFk,
|
},
|
||||||
},
|
};
|
||||||
};
|
const { data } = await axios.get(`Shelvings/findOne`, {
|
||||||
const { data } = await axios.get(`Shelvings/findOne`, {
|
params: { filter: JSON.stringify(filter) },
|
||||||
params: { filter: JSON.stringify(filter) },
|
});
|
||||||
});
|
const params = {
|
||||||
const params = {
|
parkingFk: sale.parkingFk,
|
||||||
parkingFk: sale.parkingFk,
|
};
|
||||||
};
|
await axios.patch(`Shelvings/${data.id}`, params);
|
||||||
await axios.patch(`Shelvings/${data.id}`, params);
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const updateShelving = async (sale) => {
|
const updateShelving = async (sale) => {
|
||||||
|
@ -241,61 +225,41 @@ const updateShelving = async (sale) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const saleTrackingNew = async (sale, stateCode, isChecked) => {
|
const saleTrackingNew = async (sale, stateCode, isChecked) => {
|
||||||
try {
|
const params = {
|
||||||
const params = {
|
saleFk: sale.saleFk,
|
||||||
saleFk: sale.saleFk,
|
isChecked,
|
||||||
isChecked,
|
quantity: sale.quantity,
|
||||||
quantity: sale.quantity,
|
stateCode,
|
||||||
stateCode,
|
};
|
||||||
};
|
await axios.post(`SaleTrackings/new`, params);
|
||||||
await axios.post(`SaleTrackings/new`, params);
|
notify(t('globals.dataSaved'), 'positive');
|
||||||
notify(t('globals.dataSaved'), 'positive');
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const saleTrackingDel = async ({ saleFk }, stateCode) => {
|
const saleTrackingDel = async ({ saleFk }, stateCode) => {
|
||||||
try {
|
const params = {
|
||||||
const params = {
|
saleFk,
|
||||||
saleFk,
|
stateCodes: [stateCode],
|
||||||
stateCodes: [stateCode],
|
};
|
||||||
};
|
await axios.post(`SaleTrackings/delete`, params);
|
||||||
await axios.post(`SaleTrackings/delete`, params);
|
notify(t('globals.dataSaved'), 'positive');
|
||||||
notify(t('globals.dataSaved'), 'positive');
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const clickSaleGroupDetail = async (sale) => {
|
const clickSaleGroupDetail = async (sale) => {
|
||||||
try {
|
if (!sale.saleGroupDetailFk) return;
|
||||||
if (!sale.saleGroupDetailFk) return;
|
|
||||||
|
|
||||||
await axios.delete(`SaleGroupDetails/${sale.saleGroupDetailFk}`);
|
await axios.delete(`SaleGroupDetails/${sale.saleGroupDetailFk}`);
|
||||||
sale.hasSaleGroupDetail = false;
|
sale.hasSaleGroupDetail = false;
|
||||||
notify(t('globals.dataSaved'), 'positive');
|
notify(t('globals.dataSaved'), 'positive');
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const clickPreviousSelected = (sale) => {
|
const clickPreviousSelected = (sale) => {
|
||||||
try {
|
qCheckBoxController(sale, 'isPreviousSelected');
|
||||||
qCheckBoxController(sale, 'isPreviousSelected');
|
if (!sale.isPreviousSelected) sale.isPrevious = false;
|
||||||
if (!sale.isPreviousSelected) sale.isPrevious = false;
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const clickPrevious = (sale) => {
|
const clickPrevious = (sale) => {
|
||||||
try {
|
qCheckBoxController(sale, 'isPrevious');
|
||||||
qCheckBoxController(sale, 'isPrevious');
|
if (sale.isPrevious) sale.isPreviousSelected = true;
|
||||||
if (sale.isPrevious) sale.isPreviousSelected = true;
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const qCheckBoxController = (sale, action) => {
|
const qCheckBoxController = (sale, action) => {
|
||||||
|
@ -306,16 +270,12 @@ const qCheckBoxController = (sale, action) => {
|
||||||
isPreviousSelected: 'PREVIOUS_PREPARATION',
|
isPreviousSelected: 'PREVIOUS_PREPARATION',
|
||||||
};
|
};
|
||||||
const stateCode = STATE_CODES[action];
|
const stateCode = STATE_CODES[action];
|
||||||
try {
|
if (!sale[action]) {
|
||||||
if (!sale[action]) {
|
saleTrackingNew(sale, stateCode, true);
|
||||||
saleTrackingNew(sale, stateCode, true);
|
sale[action] = true;
|
||||||
sale[action] = true;
|
} else {
|
||||||
} else {
|
saleTrackingDel(sale, stateCode);
|
||||||
saleTrackingDel(sale, stateCode);
|
sale[action] = false;
|
||||||
sale[action] = false;
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -46,40 +46,32 @@ watch(
|
||||||
onMounted(async () => await getDefaultTaxClass());
|
onMounted(async () => await getDefaultTaxClass());
|
||||||
|
|
||||||
const createRefund = async () => {
|
const createRefund = async () => {
|
||||||
try {
|
if (!selected.value.length) return;
|
||||||
if (!selected.value.length) return;
|
|
||||||
|
|
||||||
const params = {
|
const params = {
|
||||||
servicesIds: selected.value.map((s) => +s.id),
|
servicesIds: selected.value.map((s) => +s.id),
|
||||||
withWarehouse: false,
|
withWarehouse: false,
|
||||||
negative: true,
|
negative: true,
|
||||||
};
|
};
|
||||||
const { data } = await axios.post('Sales/clone', params);
|
const { data } = await axios.post('Sales/clone', params);
|
||||||
const [refundTicket] = data;
|
const [refundTicket] = data;
|
||||||
notify(
|
notify(
|
||||||
t('service.createRefundSuccess', {
|
t('service.createRefundSuccess', {
|
||||||
ticketId: refundTicket.id,
|
ticketId: refundTicket.id,
|
||||||
}),
|
}),
|
||||||
'positive'
|
'positive'
|
||||||
);
|
);
|
||||||
router.push({ name: 'TicketSale', params: { id: refundTicket.id } });
|
router.push({ name: 'TicketSale', params: { id: refundTicket.id } });
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const getDefaultTaxClass = async () => {
|
const getDefaultTaxClass = async () => {
|
||||||
try {
|
let filter = {
|
||||||
let filter = {
|
where: { code: 'G' },
|
||||||
where: { code: 'G' },
|
};
|
||||||
};
|
const { data } = await axios.get('TaxClasses/findOne', {
|
||||||
const { data } = await axios.get('TaxClasses/findOne', {
|
params: { filter: JSON.stringify(filter) },
|
||||||
params: { filter: JSON.stringify(filter) },
|
});
|
||||||
});
|
defaultTaxClass.value = data;
|
||||||
defaultTaxClass.value = data;
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const columns = computed(() => [
|
const columns = computed(() => [
|
||||||
|
|
|
@ -69,19 +69,15 @@ function isEditable() {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function changeState(value) {
|
async function changeState(value) {
|
||||||
try {
|
stateBtnDropdownRef.value?.hide();
|
||||||
stateBtnDropdownRef.value?.hide();
|
const formData = {
|
||||||
const formData = {
|
ticketFk: entityId.value,
|
||||||
ticketFk: entityId.value,
|
code: value,
|
||||||
code: value,
|
};
|
||||||
};
|
await axios.post(`Tickets/state`, formData);
|
||||||
await axios.post(`Tickets/state`, formData);
|
notify('globals.dataSaved', 'positive');
|
||||||
notify('globals.dataSaved', 'positive');
|
summaryRef.value?.fetch();
|
||||||
summaryRef.value?.fetch();
|
descriptorData.fetch({});
|
||||||
descriptorData.fetch({});
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Error changing ticket state', err);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function toTicketUrl(section) {
|
function toTicketUrl(section) {
|
||||||
|
|
|
@ -75,22 +75,18 @@ const columns = computed(() => [
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const applyVolumes = async (salesData) => {
|
const applyVolumes = async (salesData) => {
|
||||||
try {
|
if (!salesData.length) return;
|
||||||
if (!salesData.length) return;
|
|
||||||
|
|
||||||
sales.value = salesData;
|
sales.value = salesData;
|
||||||
const ticket = sales.value[0].ticketFk;
|
const ticket = sales.value[0].ticketFk;
|
||||||
const { data } = await axios.get(`Tickets/${ticket}/getVolume`);
|
const { data } = await axios.get(`Tickets/${ticket}/getVolume`);
|
||||||
const volumes = new Map(data.saleVolume.map((volume) => [volume.saleFk, volume]));
|
const volumes = new Map(data.saleVolume.map((volume) => [volume.saleFk, volume]));
|
||||||
|
|
||||||
sales.value.forEach((sale) => {
|
sales.value.forEach((sale) => {
|
||||||
sale.saleVolume = volumes.get(sale.id);
|
sale.saleVolume = volumes.get(sale.id);
|
||||||
});
|
});
|
||||||
|
|
||||||
packingTypeVolume.value = data.packingTypeVolume;
|
packingTypeVolume.value = data.packingTypeVolume;
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
onMounted(() => (stateStore.rightDrawer = true));
|
onMounted(() => (stateStore.rightDrawer = true));
|
||||||
|
|
|
@ -27,20 +27,16 @@ const warehousesOptions = ref([]);
|
||||||
const itemPackingTypes = ref([]);
|
const itemPackingTypes = ref([]);
|
||||||
|
|
||||||
const getItemPackingTypes = async () => {
|
const getItemPackingTypes = async () => {
|
||||||
try {
|
const filter = {
|
||||||
const filter = {
|
where: { isActive: true },
|
||||||
where: { isActive: true },
|
};
|
||||||
};
|
const { data } = await axios.get('ItemPackingTypes', {
|
||||||
const { data } = await axios.get('ItemPackingTypes', {
|
params: { filter: JSON.stringify(filter) },
|
||||||
params: { filter: JSON.stringify(filter) },
|
});
|
||||||
});
|
itemPackingTypes.value = data.map((ipt) => ({
|
||||||
itemPackingTypes.value = data.map((ipt) => ({
|
description: t(ipt.description),
|
||||||
description: t(ipt.description),
|
code: ipt.code,
|
||||||
code: ipt.code,
|
}));
|
||||||
}));
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const getLocale = (val) => {
|
const getLocale = (val) => {
|
||||||
|
|
|
@ -37,46 +37,37 @@ onBeforeMount(async () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
const fetchClient = async (formData) => {
|
const fetchClient = async (formData) => {
|
||||||
try {
|
const filter = {
|
||||||
const filter = {
|
include: {
|
||||||
include: {
|
relation: 'defaultAddress',
|
||||||
relation: 'defaultAddress',
|
scope: {
|
||||||
scope: {
|
fields: ['id', 'agencyModeFk'],
|
||||||
fields: ['id', 'agencyModeFk'],
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
where: { id: formData.clientId },
|
},
|
||||||
};
|
where: { id: formData.clientId },
|
||||||
const params = { filter: JSON.stringify(filter) };
|
};
|
||||||
const { data } = await axios.get('Clients', { params });
|
const params = { filter: JSON.stringify(filter) };
|
||||||
const [client] = data;
|
const { data } = await axios.get('Clients', { params });
|
||||||
selectedClient.value = client;
|
const [client] = data;
|
||||||
} catch (err) {
|
selectedClient.value = client;
|
||||||
console.error('Error fetching client');
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const fetchAddresses = async (formData) => {
|
const fetchAddresses = async (formData) => {
|
||||||
try {
|
if (!formData.clientId) return;
|
||||||
if (!formData.clientId) return;
|
|
||||||
|
|
||||||
const filter = {
|
const filter = {
|
||||||
fields: ['nickname', 'street', 'city', 'id'],
|
fields: ['nickname', 'street', 'city', 'id'],
|
||||||
where: { isActive: true },
|
where: { isActive: true },
|
||||||
order: 'nickname ASC',
|
order: 'nickname ASC',
|
||||||
};
|
};
|
||||||
const params = { filter: JSON.stringify(filter) };
|
const params = { filter: JSON.stringify(filter) };
|
||||||
const { data } = await axios.get(`Clients/${formData.clientId}/addresses`, {
|
const { data } = await axios.get(`Clients/${formData.clientId}/addresses`, {
|
||||||
params,
|
params,
|
||||||
});
|
});
|
||||||
addressesOptions.value = data;
|
addressesOptions.value = data;
|
||||||
|
|
||||||
const { defaultAddress } = selectedClient.value;
|
const { defaultAddress } = selectedClient.value;
|
||||||
formData.addressId = defaultAddress.id;
|
formData.addressId = defaultAddress.id;
|
||||||
} catch (err) {
|
|
||||||
console.error(`Error fetching addresses`, err);
|
|
||||||
return err.response;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const onClientSelected = async (formData) => {
|
const onClientSelected = async (formData) => {
|
||||||
|
|
|
@ -37,46 +37,37 @@ onBeforeMount(async () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
const fetchClient = async (formData) => {
|
const fetchClient = async (formData) => {
|
||||||
try {
|
const filter = {
|
||||||
const filter = {
|
include: {
|
||||||
include: {
|
relation: 'defaultAddress',
|
||||||
relation: 'defaultAddress',
|
scope: {
|
||||||
scope: {
|
fields: ['id', 'agencyModeFk'],
|
||||||
fields: ['id', 'agencyModeFk'],
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
where: { id: formData.clientId },
|
},
|
||||||
};
|
where: { id: formData.clientId },
|
||||||
const params = { filter: JSON.stringify(filter) };
|
};
|
||||||
const { data } = await axios.get('Clients', { params });
|
const params = { filter: JSON.stringify(filter) };
|
||||||
const [client] = data;
|
const { data } = await axios.get('Clients', { params });
|
||||||
selectedClient.value = client;
|
const [client] = data;
|
||||||
} catch (err) {
|
selectedClient.value = client;
|
||||||
console.error('Error fetching client');
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const fetchAddresses = async (formData) => {
|
const fetchAddresses = async (formData) => {
|
||||||
try {
|
if (!formData.clientId) return;
|
||||||
if (!formData.clientId) return;
|
|
||||||
|
|
||||||
const filter = {
|
const filter = {
|
||||||
fields: ['nickname', 'street', 'city', 'id'],
|
fields: ['nickname', 'street', 'city', 'id'],
|
||||||
where: { isActive: true },
|
where: { isActive: true },
|
||||||
order: 'nickname ASC',
|
order: 'nickname ASC',
|
||||||
};
|
};
|
||||||
const params = { filter: JSON.stringify(filter) };
|
const params = { filter: JSON.stringify(filter) };
|
||||||
const { data } = await axios.get(`Clients/${formData.clientId}/addresses`, {
|
const { data } = await axios.get(`Clients/${formData.clientId}/addresses`, {
|
||||||
params,
|
params,
|
||||||
});
|
});
|
||||||
addressesOptions.value = data;
|
addressesOptions.value = data;
|
||||||
|
|
||||||
const { defaultAddress } = selectedClient.value;
|
const { defaultAddress } = selectedClient.value;
|
||||||
formData.addressId = defaultAddress.id;
|
formData.addressId = defaultAddress.id;
|
||||||
} catch (err) {
|
|
||||||
console.error(`Error fetching addresses`, err);
|
|
||||||
return err.response;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const onClientSelected = async (formData) => {
|
const onClientSelected = async (formData) => {
|
||||||
|
|
|
@ -68,13 +68,9 @@ const params = reactive({
|
||||||
});
|
});
|
||||||
|
|
||||||
const applyColumnFilter = async (col) => {
|
const applyColumnFilter = async (col) => {
|
||||||
try {
|
const paramKey = col.columnFilter?.filterParamKey || col.field;
|
||||||
const paramKey = col.columnFilter?.filterParamKey || col.field;
|
params[paramKey] = col.columnFilter.filterValue;
|
||||||
params[paramKey] = col.columnFilter.filterValue;
|
await arrayData.addFilter({ params });
|
||||||
await arrayData.addFilter({ params });
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Error applying column filter', err);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const getInputEvents = (col) => {
|
const getInputEvents = (col) => {
|
||||||
|
@ -248,23 +244,19 @@ const totalPriceColor = (totalWithVat) =>
|
||||||
isLessThan50(totalWithVat) ? 'warning' : 'transparent';
|
isLessThan50(totalWithVat) ? 'warning' : 'transparent';
|
||||||
|
|
||||||
const moveTicketsFuture = async () => {
|
const moveTicketsFuture = async () => {
|
||||||
try {
|
const ticketsToMove = selectedTickets.value.map((ticket) => ({
|
||||||
const ticketsToMove = selectedTickets.value.map((ticket) => ({
|
originId: ticket.id,
|
||||||
originId: ticket.id,
|
destinationId: ticket.futureId,
|
||||||
destinationId: ticket.futureId,
|
originShipped: ticket.shipped,
|
||||||
originShipped: ticket.shipped,
|
destinationShipped: ticket.futureShipped,
|
||||||
destinationShipped: ticket.futureShipped,
|
workerFk: ticket.workerFk,
|
||||||
workerFk: ticket.workerFk,
|
}));
|
||||||
}));
|
|
||||||
|
|
||||||
let params = { tickets: ticketsToMove };
|
let params = { tickets: ticketsToMove };
|
||||||
await axios.post('Tickets/merge', params);
|
await axios.post('Tickets/merge', params);
|
||||||
notify(t('futureTickets.moveTicketSuccess'), 'positive');
|
notify(t('futureTickets.moveTicketSuccess'), 'positive');
|
||||||
selectedTickets.value = [];
|
selectedTickets.value = [];
|
||||||
arrayData.fetch({ append: false });
|
arrayData.fetch({ append: false });
|
||||||
} catch (error) {
|
|
||||||
console.error('Error moving tickets to future', error);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
await arrayData.fetch({ append: false });
|
await arrayData.fetch({ append: false });
|
||||||
|
|
|
@ -24,33 +24,25 @@ const itemPackingTypes = ref([]);
|
||||||
const stateOptions = ref([]);
|
const stateOptions = ref([]);
|
||||||
|
|
||||||
const getItemPackingTypes = async () => {
|
const getItemPackingTypes = async () => {
|
||||||
try {
|
const filter = {
|
||||||
const filter = {
|
where: { isActive: true },
|
||||||
where: { isActive: true },
|
};
|
||||||
};
|
const { data } = await axios.get('ItemPackingTypes', {
|
||||||
const { data } = await axios.get('ItemPackingTypes', {
|
params: { filter: JSON.stringify(filter) },
|
||||||
params: { filter: JSON.stringify(filter) },
|
});
|
||||||
});
|
itemPackingTypes.value = data.map((ipt) => ({
|
||||||
itemPackingTypes.value = data.map((ipt) => ({
|
description: t(ipt.description),
|
||||||
description: t(ipt.description),
|
code: ipt.code,
|
||||||
code: ipt.code,
|
}));
|
||||||
}));
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const getGroupedStates = async () => {
|
const getGroupedStates = async () => {
|
||||||
try {
|
const { data } = await axios.get('AlertLevels');
|
||||||
const { data } = await axios.get('AlertLevels');
|
stateOptions.value = data.map((state) => ({
|
||||||
stateOptions.value = data.map((state) => ({
|
id: state.id,
|
||||||
id: state.id,
|
name: t(`futureTickets.${state.code}`),
|
||||||
name: t(`futureTickets.${state.code}`),
|
code: state.code,
|
||||||
code: state.code,
|
}));
|
||||||
}));
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
|
|
|
@ -254,46 +254,37 @@ const fetchAvailableAgencies = async (formData) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const fetchClient = async (formData) => {
|
const fetchClient = async (formData) => {
|
||||||
try {
|
const filter = {
|
||||||
const filter = {
|
include: {
|
||||||
include: {
|
relation: 'defaultAddress',
|
||||||
relation: 'defaultAddress',
|
scope: {
|
||||||
scope: {
|
fields: ['id', 'agencyModeFk'],
|
||||||
fields: ['id', 'agencyModeFk'],
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
where: { id: formData.clientId },
|
},
|
||||||
};
|
where: { id: formData.clientId },
|
||||||
const params = { filter: JSON.stringify(filter) };
|
};
|
||||||
const { data } = await axios.get('Clients', { params });
|
const params = { filter: JSON.stringify(filter) };
|
||||||
const [client] = data;
|
const { data } = await axios.get('Clients', { params });
|
||||||
selectedClient.value = client;
|
const [client] = data;
|
||||||
} catch (err) {
|
selectedClient.value = client;
|
||||||
console.error('Error fetching client');
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const fetchAddresses = async (formData) => {
|
const fetchAddresses = async (formData) => {
|
||||||
try {
|
if (!formData.clientId) return;
|
||||||
if (!formData.clientId) return;
|
|
||||||
|
|
||||||
const filter = {
|
const filter = {
|
||||||
fields: ['nickname', 'street', 'city', 'id'],
|
fields: ['nickname', 'street', 'city', 'id'],
|
||||||
where: { isActive: true },
|
where: { isActive: true },
|
||||||
order: 'nickname ASC',
|
order: 'nickname ASC',
|
||||||
};
|
};
|
||||||
const params = { filter: JSON.stringify(filter) };
|
const params = { filter: JSON.stringify(filter) };
|
||||||
const { data } = await axios.get(`Clients/${formData.clientId}/addresses`, {
|
const { data } = await axios.get(`Clients/${formData.clientId}/addresses`, {
|
||||||
params,
|
params,
|
||||||
});
|
});
|
||||||
addressesOptions.value = data;
|
addressesOptions.value = data;
|
||||||
|
|
||||||
const { defaultAddress } = selectedClient.value;
|
const { defaultAddress } = selectedClient.value;
|
||||||
formData.addressId = defaultAddress.id;
|
formData.addressId = defaultAddress.id;
|
||||||
} catch (err) {
|
|
||||||
console.error(`Error fetching addresses`, err);
|
|
||||||
return err.response;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
const getColor = (row) => {
|
const getColor = (row) => {
|
||||||
if (row.alertLevelCode === 'OK') return 'bg-success';
|
if (row.alertLevelCode === 'OK') return 'bg-success';
|
||||||
|
|
|
@ -153,24 +153,16 @@ const columns = computed(() => [
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const deleteWeekly = async (ticketFk) => {
|
const deleteWeekly = async (ticketFk) => {
|
||||||
try {
|
await axios.delete(`TicketWeeklies/${ticketFk}`);
|
||||||
await axios.delete(`TicketWeeklies/${ticketFk}`);
|
notify(t('globals.dataSaved'), 'positive');
|
||||||
notify(t('globals.dataSaved'), 'positive');
|
const ticketIndex = store.data.findIndex((e) => e.ticketFk == ticketFk);
|
||||||
const ticketIndex = store.data.findIndex((e) => e.ticketFk == ticketFk);
|
store.data.splice(ticketIndex, 1);
|
||||||
store.data.splice(ticketIndex, 1);
|
location.reload();
|
||||||
location.reload();
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Error deleting weekly', err);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const onUpdate = async (ticketFk, field, value) => {
|
const onUpdate = async (ticketFk, field, value) => {
|
||||||
try {
|
const params = { ticketFk, [field]: value };
|
||||||
const params = { ticketFk, [field]: value };
|
await axios.patch('TicketWeeklies', params);
|
||||||
await axios.patch('TicketWeeklies', params);
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Error updating weekly', err);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
|
|
|
@ -32,16 +32,12 @@ const cloneTravel = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const cloneTravelWithEntries = async () => {
|
const cloneTravelWithEntries = async () => {
|
||||||
try {
|
const { data } = await axios.post(`Travels/${$props.travel.id}/cloneWithEntries`);
|
||||||
const { data } = await axios.post(`Travels/${$props.travel.id}/cloneWithEntries`);
|
notify('globals.dataSaved', 'positive');
|
||||||
notify('globals.dataSaved', 'positive');
|
router.push({ name: 'TravelBasicData', params: { id: data.id } });
|
||||||
router.push({ name: 'TravelBasicData', params: { id: data.id } });
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Error cloning travel with entries');
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const canDelete = computed(() => useAcl().hasAny('Travel','*','WRITE'));
|
const canDelete = computed(() => useAcl().hasAny('Travel', '*', 'WRITE'));
|
||||||
|
|
||||||
const openDeleteEntryDialog = (id) => {
|
const openDeleteEntryDialog = (id) => {
|
||||||
quasar
|
quasar
|
||||||
|
@ -58,13 +54,9 @@ const openDeleteEntryDialog = (id) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const deleteTravel = async (id) => {
|
const deleteTravel = async (id) => {
|
||||||
try {
|
await axios.delete(`Travels/${id}`);
|
||||||
await axios.delete(`Travels/${id}`);
|
router.push({ name: 'TravelList' });
|
||||||
router.push({ name: 'TravelList' });
|
notify('globals.dataDeleted', 'positive');
|
||||||
notify('globals.dataDeleted', 'positive');
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Error deleting travel');
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -193,44 +193,32 @@ const entriesTotalM3 = computed(() =>
|
||||||
);
|
);
|
||||||
|
|
||||||
const getTravelEntries = async (id) => {
|
const getTravelEntries = async (id) => {
|
||||||
try {
|
const { data } = await axios.get(`Travels/${id}/getEntries`);
|
||||||
const { data } = await axios.get(`Travels/${id}/getEntries`);
|
entries.value = data;
|
||||||
entries.value = data;
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Error fetching travel entries');
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const getTravelThermographs = async (id) => {
|
const getTravelThermographs = async (id) => {
|
||||||
try {
|
const filter = {
|
||||||
const filter = {
|
include: {
|
||||||
include: {
|
relation: 'warehouse',
|
||||||
relation: 'warehouse',
|
scope: {
|
||||||
scope: {
|
fields: ['id', 'name'],
|
||||||
fields: ['id', 'name'],
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
where: { travelFk: id },
|
},
|
||||||
};
|
where: { travelFk: id },
|
||||||
|
};
|
||||||
|
|
||||||
const { data } = await axios.get('TravelThermographs', {
|
const { data } = await axios.get('TravelThermographs', {
|
||||||
params: { filter: JSON.parse(JSON.stringify(filter)) },
|
params: { filter: JSON.parse(JSON.stringify(filter)) },
|
||||||
});
|
});
|
||||||
thermographs.value = data;
|
thermographs.value = data;
|
||||||
} catch (err) {
|
|
||||||
console.error('Error fetching travel thermographs');
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
async function setTravelData(travelData) {
|
async function setTravelData(travelData) {
|
||||||
try {
|
if (travelData) {
|
||||||
if (travelData) {
|
travel.value = travelData;
|
||||||
travel.value = travelData;
|
await getTravelEntries(travel.value.id);
|
||||||
await getTravelEntries(travel.value.id);
|
await getTravelThermographs(travel.value.id);
|
||||||
await getTravelThermographs(travel.value.id);
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
console.error(`Error setting travel data`, err);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -122,13 +122,9 @@ const redirectToThermographForm = (action, id) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const removeThermograph = async (id) => {
|
const removeThermograph = async (id) => {
|
||||||
try {
|
await axios.delete(`Travels/deleteThermograph?id=${id}`);
|
||||||
await axios.delete(`Travels/deleteThermograph?id=${id}`);
|
await thermographPaginateRef.value.fetch();
|
||||||
await thermographPaginateRef.value.fetch();
|
notify(t('Thermograph removed'), 'positive');
|
||||||
notify(t('Thermograph removed'), 'positive');
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Error removing termograph');
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -56,17 +56,13 @@ onBeforeMount(async () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
const fetchDmsTypes = async () => {
|
const fetchDmsTypes = async () => {
|
||||||
try {
|
const params = {
|
||||||
const params = {
|
filter: {
|
||||||
filter: {
|
where: { code: 'thermograph' },
|
||||||
where: { code: 'thermograph' },
|
},
|
||||||
},
|
};
|
||||||
};
|
const { data } = await axios.get('DmsTypes/findOne', { params });
|
||||||
const { data } = await axios.get('DmsTypes/findOne', { params });
|
return data;
|
||||||
return data;
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Error fetching Dms Types');
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const setCreateDefaultParams = async () => {
|
const setCreateDefaultParams = async () => {
|
||||||
|
|
|
@ -293,20 +293,16 @@ const openReportPdf = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const saveFieldValue = async (val, field, index) => {
|
const saveFieldValue = async (val, field, index) => {
|
||||||
try {
|
// Evitar la solicitud de guardado si el valor no ha cambiado
|
||||||
// Evitar la solicitud de guardado si el valor no ha cambiado
|
if (originalRowDataCopy.value[index][field] == val) return;
|
||||||
if (originalRowDataCopy.value[index][field] == val) return;
|
|
||||||
|
|
||||||
const id = rows.value[index].id;
|
const id = rows.value[index].id;
|
||||||
const params = { [field]: val };
|
const params = { [field]: val };
|
||||||
await axios.patch(`Travels/${id}`, params);
|
await axios.patch(`Travels/${id}`, params);
|
||||||
// Actualizar la copia de los datos originales con el nuevo valor
|
// Actualizar la copia de los datos originales con el nuevo valor
|
||||||
originalRowDataCopy.value[index][field] = val;
|
originalRowDataCopy.value[index][field] = val;
|
||||||
|
|
||||||
await arrayData.fetch({ append: false });
|
await arrayData.fetch({ append: false });
|
||||||
} catch (err) {
|
|
||||||
console.error('Error updating travel');
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const stopEventPropagation = (event, col) => {
|
const stopEventPropagation = (event, col) => {
|
||||||
|
|
|
@ -19,16 +19,10 @@ const createTrayFormDialogRef = ref();
|
||||||
const selectedEntityId = ref();
|
const selectedEntityId = ref();
|
||||||
|
|
||||||
async function loadTrays() {
|
async function loadTrays() {
|
||||||
try {
|
const res = await axios.get('WagonTypeTrays');
|
||||||
const res = await axios.get('WagonTypeTrays');
|
const filteredTrays = res.data.filter((tray) => tray.wagonTypeFk === entityId.value);
|
||||||
const filteredTrays = res.data.filter(
|
wagonTrays.value = filteredTrays;
|
||||||
(tray) => tray.wagonTypeFk === entityId.value
|
return;
|
||||||
);
|
|
||||||
wagonTrays.value = filteredTrays;
|
|
||||||
return;
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Error loading trays:', err);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function addTray(newTray) {
|
async function addTray(newTray) {
|
||||||
|
|
|
@ -60,40 +60,29 @@ const updateSelectedDate = (year) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const createEvent = async (date) => {
|
const createEvent = async (date) => {
|
||||||
try {
|
const params = {
|
||||||
const params = {
|
dated: date,
|
||||||
dated: date,
|
absenceTypeId: props.absenceType.id,
|
||||||
absenceTypeId: props.absenceType.id,
|
businessFk: props.businessFk,
|
||||||
businessFk: props.businessFk,
|
};
|
||||||
};
|
|
||||||
|
|
||||||
const { data } = await axios.post(
|
const { data } = await axios.post(`Workers/${route.params.id}/createAbsence`, params);
|
||||||
`Workers/${route.params.id}/createAbsence`,
|
|
||||||
params
|
|
||||||
);
|
|
||||||
|
|
||||||
if (data) emit('refresh');
|
if (data) emit('refresh');
|
||||||
} catch (error) {
|
|
||||||
console.error('error creating event:: ', error);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const editEvent = async (event) => {
|
const editEvent = async (event) => {
|
||||||
try {
|
const absenceType = props.absenceType;
|
||||||
const absenceType = props.absenceType;
|
const params = {
|
||||||
const params = {
|
absenceId: event.absenceId,
|
||||||
absenceId: event.absenceId,
|
absenceTypeId: absenceType.id,
|
||||||
absenceTypeId: absenceType.id,
|
};
|
||||||
};
|
const { data } = await axios.patch(
|
||||||
const { data } = await axios.patch(
|
`Workers/${route.params.id}/updateAbsence`,
|
||||||
`Workers/${route.params.id}/updateAbsence`,
|
params
|
||||||
params
|
);
|
||||||
);
|
|
||||||
|
|
||||||
if (data) emit('refresh');
|
if (data) emit('refresh');
|
||||||
} catch (error) {
|
|
||||||
console.error('error editing event:: ', error);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const deleteEvent = async (event, date) => {
|
const deleteEvent = async (event, date) => {
|
||||||
|
|
|
@ -39,15 +39,9 @@ const entityId = computed(() => {
|
||||||
const workerExcluded = ref(false);
|
const workerExcluded = ref(false);
|
||||||
|
|
||||||
const getIsExcluded = async () => {
|
const getIsExcluded = async () => {
|
||||||
try {
|
const { data } = await axios.get(`WorkerDisableExcludeds/${entityId.value}/exists`);
|
||||||
const { data } = await axios.get(
|
if (!data) return;
|
||||||
`WorkerDisableExcludeds/${entityId.value}/exists`
|
workerExcluded.value = data.exists;
|
||||||
);
|
|
||||||
if (!data) return;
|
|
||||||
workerExcluded.value = data.exists;
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Error getting worker excluded: ', err);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleExcluded = async () => {
|
const handleExcluded = async () => {
|
||||||
|
|
|
@ -32,14 +32,11 @@ const initialData = computed(() => {
|
||||||
});
|
});
|
||||||
|
|
||||||
const deallocatePDA = async (deviceProductionFk) => {
|
const deallocatePDA = async (deviceProductionFk) => {
|
||||||
try {
|
await axios.post(`Workers/${route.params.id}/deallocatePDA`, {
|
||||||
await axios.post(`Workers/${route.params.id}/deallocatePDA`, {
|
pda: deviceProductionFk,
|
||||||
pda: deviceProductionFk,
|
});
|
||||||
});
|
notify(t('PDA deallocated'), 'positive');
|
||||||
notify(t('PDA deallocated'), 'positive');
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Error deallocating PDA');
|
|
||||||
}
|
|
||||||
paginate.value.fetch();
|
paginate.value.fetch();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -251,13 +251,9 @@ const addEvents = (data) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const fetchHours = async () => {
|
const fetchHours = async () => {
|
||||||
try {
|
await workerHoursRef.value.fetch();
|
||||||
await workerHoursRef.value.fetch();
|
await getWorkedHours(startOfWeek.value, endOfWeek.value);
|
||||||
await getWorkedHours(startOfWeek.value, endOfWeek.value);
|
await getAbsences();
|
||||||
await getAbsences();
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Error fetching worker hours');
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const fetchWeekData = async () => {
|
const fetchWeekData = async () => {
|
||||||
|
@ -265,25 +261,21 @@ const fetchWeekData = async () => {
|
||||||
year: selectedDate.value.getFullYear(),
|
year: selectedDate.value.getFullYear(),
|
||||||
week: selectedWeekNumber.value,
|
week: selectedWeekNumber.value,
|
||||||
};
|
};
|
||||||
try {
|
const mail = (
|
||||||
const mail = (
|
await axiosNoError.get(`Workers/${route.params.id}/mail`, {
|
||||||
await axiosNoError.get(`Workers/${route.params.id}/mail`, {
|
params: { filter: { where } },
|
||||||
params: { filter: { where } },
|
})
|
||||||
})
|
).data[0];
|
||||||
).data[0];
|
|
||||||
|
|
||||||
if (!mail) state.value = null;
|
if (!mail) state.value = null;
|
||||||
else {
|
else {
|
||||||
state.value = mail.state;
|
state.value = mail.state;
|
||||||
reason.value = mail.reason;
|
reason.value = mail.reason;
|
||||||
}
|
|
||||||
|
|
||||||
canResend.value = !!(
|
|
||||||
await axiosNoError.get('WorkerTimeControlMails/count', { params: { where } })
|
|
||||||
).data.count;
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Error fetching week data');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
canResend.value = !!(
|
||||||
|
await axiosNoError.get('WorkerTimeControlMails/count', { params: { where } })
|
||||||
|
).data.count;
|
||||||
};
|
};
|
||||||
|
|
||||||
const setHours = (data) => {
|
const setHours = (data) => {
|
||||||
|
@ -357,23 +349,19 @@ const showReasonForm = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const updateWorkerTimeControlMail = async (state, reason) => {
|
const updateWorkerTimeControlMail = async (state, reason) => {
|
||||||
try {
|
const params = {
|
||||||
const params = {
|
year: selectedDate.value.getFullYear(),
|
||||||
year: selectedDate.value.getFullYear(),
|
week: selectedWeekNumber.value,
|
||||||
week: selectedWeekNumber.value,
|
state,
|
||||||
state,
|
};
|
||||||
};
|
const workerId = Number(route.params.id);
|
||||||
const workerId = Number(route.params.id);
|
|
||||||
|
|
||||||
if (reason) params.reason = reason;
|
if (reason) params.reason = reason;
|
||||||
|
|
||||||
await axios.post(`WorkerTimeControls/${workerId}/updateMailState`, params);
|
await axios.post(`WorkerTimeControls/${workerId}/updateMailState`, params);
|
||||||
await getMailStates(selectedDate.value);
|
await getMailStates(selectedDate.value);
|
||||||
await fetchWeekData();
|
await fetchWeekData();
|
||||||
notify(t('globals.dataSaved'), 'positive');
|
notify(t('globals.dataSaved'), 'positive');
|
||||||
} catch (err) {
|
|
||||||
console.error('Error updating worker time control mail');
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const isSatisfied = async () => {
|
const isSatisfied = async () => {
|
||||||
|
@ -389,20 +377,16 @@ const isUnsatisfied = async (reason) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const resendEmail = async () => {
|
const resendEmail = async () => {
|
||||||
try {
|
const params = {
|
||||||
const params = {
|
recipient: worker.value?.user?.email,
|
||||||
recipient: worker.value?.user?.email,
|
week: selectedWeekNumber.value,
|
||||||
week: selectedWeekNumber.value,
|
year: selectedDate.value.getFullYear(),
|
||||||
year: selectedDate.value.getFullYear(),
|
workerId: Number(route.params.id),
|
||||||
workerId: Number(route.params.id),
|
state: 'SENDED',
|
||||||
state: 'SENDED',
|
};
|
||||||
};
|
await axios.post('WorkerTimeControls/weekly-hour-record-email', params);
|
||||||
await axios.post('WorkerTimeControls/weekly-hour-record-email', params);
|
await getMailStates(selectedDate.value);
|
||||||
await getMailStates(selectedDate.value);
|
notify(t('Email sended'), 'positive');
|
||||||
notify(t('Email sended'), 'positive');
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Error sending email');
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
onBeforeMount(() => {
|
onBeforeMount(() => {
|
||||||
|
|
|
@ -50,17 +50,11 @@ const directionIconName = computed(() => {
|
||||||
});
|
});
|
||||||
|
|
||||||
const deleteHourEntry = async () => {
|
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;
|
if (!data) return;
|
||||||
emit('onHourEntryDeleted');
|
emit('onHourEntryDeleted');
|
||||||
notify('Entry removed', 'positive');
|
notify('Entry removed', 'positive');
|
||||||
} catch (err) {
|
|
||||||
console.error('Error deleting hour entry');
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const showWorkerTimeForm = () => emit('showWorkerTimeForm');
|
const showWorkerTimeForm = () => emit('showWorkerTimeForm');
|
||||||
|
|
|
@ -33,28 +33,23 @@ const onNodeExpanded = (nodeKeysArray) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const fetchNodeLeaves = async (nodeKey) => {
|
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 params = { parentId: node.id };
|
||||||
const response = await axios.get('/departments/getLeaves', { params });
|
const response = await axios.get('/departments/getLeaves', { params });
|
||||||
if (response.data) {
|
if (response.data) {
|
||||||
node.children = response.data.map((n) => {
|
node.children = response.data.map((n) => {
|
||||||
const hasChildrens = n.sons > 0;
|
const hasChildrens = n.sons > 0;
|
||||||
|
|
||||||
n.children = hasChildrens ? [{}] : null;
|
n.children = hasChildrens ? [{}] : null;
|
||||||
n.clickable = true;
|
n.clickable = true;
|
||||||
return n;
|
return n;
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
state.set('Tree', node);
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Error fetching department leaves', err);
|
|
||||||
throw new Error();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
state.set('Tree', node);
|
||||||
};
|
};
|
||||||
|
|
||||||
const removeNode = (node) => {
|
const removeNode = (node) => {
|
||||||
|
@ -72,15 +67,11 @@ const removeNode = (node) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
async function remove(id) {
|
async function remove(id) {
|
||||||
try {
|
await axios.post(`/Departments/${id}/removeChild`, { id });
|
||||||
await axios.post(`/Departments/${id}/removeChild`, { id });
|
quasar.notify({
|
||||||
quasar.notify({
|
message: t('department.departmentRemoved'),
|
||||||
message: t('department.departmentRemoved'),
|
type: 'positive',
|
||||||
type: 'positive',
|
});
|
||||||
});
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Error removing department');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const showCreateNodeForm = (nodeId) => {
|
const showCreateNodeForm = (nodeId) => {
|
||||||
|
|
|
@ -57,34 +57,24 @@ const excludeType = computed({
|
||||||
const arrayData = useArrayData('ZoneEvents');
|
const arrayData = useArrayData('ZoneEvents');
|
||||||
|
|
||||||
const exclusionGeoCreate = async () => {
|
const exclusionGeoCreate = async () => {
|
||||||
try {
|
const params = {
|
||||||
const params = {
|
zoneFk: parseInt(route.params.id),
|
||||||
zoneFk: parseInt(route.params.id),
|
date: dated.value,
|
||||||
date: dated.value,
|
geoIds: tickedNodes.value,
|
||||||
geoIds: tickedNodes.value,
|
};
|
||||||
};
|
await axios.post('Zones/exclusionGeo', params);
|
||||||
await axios.post('Zones/exclusionGeo', params);
|
await refetchEvents();
|
||||||
await refetchEvents();
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Error creating exclusion geo: ', err);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const exclusionCreate = async () => {
|
const exclusionCreate = async () => {
|
||||||
try {
|
if (isNew.value)
|
||||||
if (isNew.value)
|
await axios.post(`Zones/${route.params.id}/exclusions`, [{ dated: dated.value }]);
|
||||||
await axios.post(`Zones/${route.params.id}/exclusions`, [
|
else
|
||||||
{ dated: dated.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();
|
await refetchEvents();
|
||||||
} catch (err) {
|
|
||||||
console.error('Error creating exclusion: ', err);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const onSubmit = async () => {
|
const onSubmit = async () => {
|
||||||
|
@ -93,13 +83,9 @@ const onSubmit = async () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const deleteEvent = async () => {
|
const deleteEvent = async () => {
|
||||||
try {
|
if (!props.event) return;
|
||||||
if (!props.event) return;
|
await axios.delete(`Zones/${route.params.id}/exclusions`);
|
||||||
await axios.delete(`Zones/${route.params.id}/exclusions`);
|
await refetchEvents();
|
||||||
await refetchEvents();
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Error deleting event: ', err);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const closeForm = () => emit('closeForm');
|
const closeForm = () => emit('closeForm');
|
||||||
|
|
|
@ -57,45 +57,34 @@ const inclusionType = computed({
|
||||||
const arrayData = useArrayData('ZoneEvents');
|
const arrayData = useArrayData('ZoneEvents');
|
||||||
|
|
||||||
const createEvent = async () => {
|
const createEvent = async () => {
|
||||||
try {
|
eventInclusionFormData.value.weekDays = weekdayStore.toSet(
|
||||||
eventInclusionFormData.value.weekDays = weekdayStore.toSet(
|
eventInclusionFormData.value.wdays
|
||||||
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 = '';
|
await refetchEvents();
|
||||||
else eventInclusionFormData.value.dated = null;
|
emit('onSubmit');
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const deleteEvent = async () => {
|
const deleteEvent = async () => {
|
||||||
try {
|
if (!props.event) return;
|
||||||
if (!props.event) return;
|
await axios.delete(`Zones/${route.params.id}/events/${props.event?.id}`);
|
||||||
await axios.delete(`Zones/${route.params.id}/events/${props.event?.id}`);
|
await refetchEvents();
|
||||||
await refetchEvents();
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Error deleting event: ', err);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const closeForm = () => {
|
const closeForm = () => {
|
||||||
|
|
|
@ -57,15 +57,11 @@ const arrayData = useArrayData('ZoneEvents', {
|
||||||
});
|
});
|
||||||
|
|
||||||
const fetchData = async () => {
|
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({
|
await arrayData.applyFilter({
|
||||||
params: params.value,
|
params: params.value,
|
||||||
});
|
});
|
||||||
} catch (err) {
|
|
||||||
console.error('Error fetching events: ', err);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
|
@ -87,13 +83,9 @@ const formatWdays = (event) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const deleteEvent = async (id) => {
|
const deleteEvent = async (id) => {
|
||||||
try {
|
if (!id) return;
|
||||||
if (!id) return;
|
await axios.delete(`Zones/${route.params.id}/events/${id}`);
|
||||||
await axios.delete(`Zones/${route.params.id}/events/${id}`);
|
await fetchData();
|
||||||
await fetchData();
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Error deleting event: ', err);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const openInclusionForm = (event) => {
|
const openInclusionForm = (event) => {
|
||||||
|
|
|
@ -10,13 +10,9 @@ const { t } = useI18n();
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
|
|
||||||
const onSelected = async (val, node) => {
|
const onSelected = async (val, node) => {
|
||||||
try {
|
if (val === null) val = undefined;
|
||||||
if (val === null) val = undefined;
|
const params = { geoId: node.id, isIncluded: val };
|
||||||
const params = { geoId: node.id, isIncluded: val };
|
await axios.post(`Zones/${route.params.id}/toggleIsIncluded`, params);
|
||||||
await axios.post(`Zones/${route.params.id}/toggleIsIncluded`, params);
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Error updating included', err);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -34,21 +34,13 @@ const columns = computed(() => [
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const deleteWarehouse = async (row) => {
|
const deleteWarehouse = async (row) => {
|
||||||
try {
|
await axios.delete(`${urlPath.value}/${row.id}`);
|
||||||
await axios.delete(`${urlPath.value}/${row.id}`);
|
fetchWarehouses();
|
||||||
fetchWarehouses();
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const createZoneWarehouse = async (ZoneWarehouseFormData) => {
|
const createZoneWarehouse = async (ZoneWarehouseFormData) => {
|
||||||
try {
|
await axios.post(urlPath.value, ZoneWarehouseFormData);
|
||||||
await axios.post(urlPath.value, ZoneWarehouseFormData);
|
fetchWarehouses();
|
||||||
fetchWarehouses();
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
|
|
|
@ -21,17 +21,13 @@ const arrayData = useArrayData('ZoneDeliveryDays', {
|
||||||
|
|
||||||
const deliveryMethodsConfig = { pickUp: ['PICKUP'], delivery: ['AGENCY', 'DELIVERY'] };
|
const deliveryMethodsConfig = { pickUp: ['PICKUP'], delivery: ['AGENCY', 'DELIVERY'] };
|
||||||
const fetchData = async (params) => {
|
const fetchData = async (params) => {
|
||||||
try {
|
const { data } = params
|
||||||
const { data } = params
|
? await arrayData.applyFilter({
|
||||||
? await arrayData.applyFilter({
|
params,
|
||||||
params,
|
})
|
||||||
})
|
: await arrayData.fetch({ append: false });
|
||||||
: await arrayData.fetch({ append: false });
|
if (!data.events || !data.events.length)
|
||||||
if (!data.events || !data.events.length)
|
notify(t('deliveryPanel.noEventsWarning'), 'warning');
|
||||||
notify(t('deliveryPanel.noEventsWarning'), 'warning');
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Error fetching events: ', err);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const onSubmit = async () => {
|
const onSubmit = async () => {
|
||||||
|
|
Loading…
Reference in New Issue