- lista cataloghi: stato "active" (Pubblicati OnLine)

This commit is contained in:
Surya Paolo
2025-05-07 00:13:51 +02:00
parent 57cfa5858b
commit 2cc8fcda03
21 changed files with 400 additions and 347 deletions

View File

@@ -120,9 +120,9 @@ export default defineComponent({
// Colonne della tabella
const allColumns = [
{ name: "pos", label: "Ind", field: "pos", align: "left", style: "width: 50px" },
{ name: "drag", label: "Ord", field: "", align: "left", style: "width: 50px", edit: true },
{ name: "drag", label: "Ord", field: "", align: "left", style: "width: 50px", edit: true, noexp: true },
{ name: "validato", label: "Val", field: "validato", align: "left", style: "" },
{ name: "image", label: "Foto", field: "image", align: "center" },
{ name: "image", label: "Foto", field: "image", align: "center", noexp: true },
{ name: "name", label: "Titolo del Libro", field: "name", align: "left" },
{ name: "authors", label: "Autore", field: "authors", align: "left" },
{ name: "isbn", label: "ISBN", field: "isbn", align: "left" },
@@ -150,7 +150,7 @@ export default defineComponent({
{ name: "totFat", label: "Fat 5A", field: "totFat", align: "right", visu: costanti.VISUCAMPI.PER_EDITORE },
{ name: "ult_ord", label: "Ult. Ordine", field: "ult_ord", align: "left", visu: costanti.VISUCAMPI.PER_EDITORE },
{ name: "quantity", label: "Magazz.", field: "quantity", align: "right", visu: costanti.VISUCAMPI.PER_EDITORE },
{ name: "actions", label: "Azioni", field: "", align: "center", visu: costanti.VISUCAMPI.PER_EDITORE },
{ name: "actions", label: "Azioni", field: "", align: "center", visu: costanti.VISUCAMPI.PER_EDITORE, noexp: true },
];
function getFieldValue(element: any, field: any): any {
@@ -204,10 +204,10 @@ export default defineComponent({
return tools.getstrDate(element.productInfo?.date_pub);
case 'prezzo':
return tools.getstrDate(element.price);
return element.price ? '€ ' + element.price.toFixed(2) : '';
case 'prezzo_sconto':
return tools.getstrDate(element.sale_price);
return element.sale_price ? '€ ' + element.sale_price.toFixed(2) : '';
case 'rank3M':
return element.productInfo?.rank3M;
@@ -315,6 +315,9 @@ export default defineComponent({
return {}
switch (field.field) {
case 'prezzo':
case 'prezzo_sconto':
return { width: '55px', textAlign: 'right' };
case 'validato':
return {
cursor: 'pointer',
@@ -378,6 +381,11 @@ export default defineComponent({
return selectedColumns.value.includes(column) && ok;
}
const getColumnLabelByName = (name: string): string => {
const column = allColumns.find((col) => col.name === name);
return column ? column.label : '';
}
// Funzione per eliminare un prodotto
const removeProduct = (product) => {
internalProducts.value = internalProducts.value.filter((p: any) => p._id !== product._id);
@@ -535,6 +543,37 @@ export default defineComponent({
}
}
function exportToCSV() {
const csvContent = [
selectedColumns.value
.filter((col) => !allColumns.find((c) => c.name === col)?.noexp)
.map((col) => getColumnLabelByName(col))
.join('|'),
...internalProducts.value.map((product: any) => {
return selectedColumns.value
.filter((col) => !allColumns.find((c) => c.name === col)?.noexp)
.map((col: string) => {
const field = { field: col };
return field.field === 'pos' ? internalProducts.value.indexOf(product) + 1 : getFieldValue(product, field);
}).join('|');
}),
].join('\r\n');
const filename = 'prodotti_' + new Date().toISOString().slice(0, 10) + '.csv';
const blob = new Blob([csvContent], { type: 'text/csv;charset=utf-8;' });
const link = document.createElement('a');
const url = URL.createObjectURL(blob);
link.setAttribute('href', url);
link.setAttribute('download', filename);
link.style.visibility = 'hidden';
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}
onMounted(mounted)
@@ -575,6 +614,7 @@ export default defineComponent({
getFieldStyle,
getFieldClick,
handleUpdate,
exportToCSV,
}
}
})