forked from verdnatura/salix-front
Reviewed-on: verdnatura/salix-front#140 Reviewed-by: Alex Moreno <alexm@verdnatura.es>
This commit is contained in:
commit
c6f8bbd616
|
@ -174,7 +174,23 @@ const columns = ref([
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const downloadCSV = async () => {
|
const downloadCSV = async () => {
|
||||||
await invoiceOutGlobalStore.getNegativeBasesCsv(dateRange.from, dateRange.to);
|
const params = filter.value;
|
||||||
|
|
||||||
|
const filterParams = {
|
||||||
|
limit: 20,
|
||||||
|
where: {
|
||||||
|
and: [],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
for (const param in params) {
|
||||||
|
if (params[param]) filterParams.where.and.push({ [param]: params[param] });
|
||||||
|
}
|
||||||
|
|
||||||
|
await invoiceOutGlobalStore.getNegativeBasesCsv(
|
||||||
|
dateRange.from,
|
||||||
|
dateRange.to,
|
||||||
|
JSON.stringify(filterParams)
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const search = async () => {
|
const search = async () => {
|
||||||
|
@ -187,13 +203,13 @@ const search = async () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
const searchFilter = {
|
const searchFilter = {
|
||||||
limit: 20
|
limit: 20,
|
||||||
}
|
};
|
||||||
|
|
||||||
if (and.length) {
|
if (and.length) {
|
||||||
searchFilter.where = {
|
searchFilter.where = {
|
||||||
and
|
and,
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const params = {
|
const params = {
|
||||||
|
@ -230,9 +246,7 @@ const selectWorkerId = (id) => {
|
||||||
selectedWorkerId.value = id;
|
selectedWorkerId.value = id;
|
||||||
};
|
};
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(() => refresh());
|
||||||
refresh();
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
|
@ -219,9 +219,9 @@ export const useInvoiceOutGlobalStore = defineStore({
|
||||||
throw err;
|
throw err;
|
||||||
},
|
},
|
||||||
|
|
||||||
async getNegativeBasesCsv(from, to) {
|
async getNegativeBasesCsv(from, to, filter = {}) {
|
||||||
try {
|
try {
|
||||||
const params = { from: from, to: to };
|
const params = { from: from, to: to, filter };
|
||||||
const CSVResponse = await invoiceOutService.getNegativeBasesCsv(params);
|
const CSVResponse = await invoiceOutService.getNegativeBasesCsv(params);
|
||||||
|
|
||||||
if (CSVResponse.data && CSVResponse.data.error) throw new Error();
|
if (CSVResponse.data && CSVResponse.data.error) throw new Error();
|
||||||
|
|
Loading…
Reference in New Issue