- aggiornato scheda e rigenera lista
- corretto filtro sulla Collana
This commit is contained in:
@@ -107,31 +107,193 @@ export default defineComponent({
|
||||
// Colonne della tabella
|
||||
const allColumns = [
|
||||
{ name: "pos", label: "Pos", field: "pos", align: "left", style: "width: 50px" },
|
||||
{ name: "drag", label: "Ordinam.", field: "", align: "left", style: "width: 50px" },
|
||||
{ name: "drag", label: "Ordinam.", field: "", align: "left", style: "width: 50px", edit: true },
|
||||
{ name: "image", label: "Foto", field: "image", align: "center" },
|
||||
{ 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" },
|
||||
{ name: "trafiletto", label: "Trafiletto", field: "trafiletto", align: "left" },
|
||||
{ name: "catprods", label: "Argomento", field: "catprods", align: "left" },
|
||||
{ name: "edizione", label: "Edizione", field: "edizione", align: "left" },
|
||||
{ name: "casaeditrice", label: "Casa Editrice", field: "casaeditrice", align: "left" },
|
||||
{ name: "idCollana", label: "Collana", field: "idCollana", align: "left" },
|
||||
{ name: "stato", label: "Stato", field: "stato", align: "left" },
|
||||
{ name: "tipologia", label: "Tipologia", field: "tipologia", align: "left" },
|
||||
{ name: "date_pub", label: "Pubblicato", field: "date_pub", align: "left" },
|
||||
{ name: "ranking", label: "Class.", field: "ranking", align: "right" },
|
||||
{ name: "rank3M", label: "Class. 3M", field: "rank3M", align: "right" },
|
||||
{ name: "rank6M", label: "Class. 6M", field: "rank6M", align: "right" },
|
||||
{ name: "rank1Y", label: "Class. 1Y", field: "rank1Y", align: "right" },
|
||||
//{ name: "ranking", label: "Class.", field: "ranking", align: "right" },
|
||||
//{ name: "rank3M", label: "Class. 3M", field: "rank3M", align: "right", visu: costanti.VISUCAMPI.PER_EDITORE },
|
||||
//{ name: "rank6M", label: "Class. 6M", field: "rank6M", align: "right", visu: costanti.VISUCAMPI.PER_EDITORE },
|
||||
//{ name: "rank1Y", label: "Class. 1Y", field: "rank1Y", align: "right", visu: costanti.VISUCAMPI.PER_EDITORE },
|
||||
{ name: "pagine", label: "Pag.", field: "pagine", align: "right" },
|
||||
{ name: "totVen", label: "Venduti", field: "totVen", align: "right" },
|
||||
{ name: "totFat", label: "Fattur.", field: "totFat", align: "right" },
|
||||
{ name: "fatLast6M", label: "Fat 6M", field: "fatLast6M", align: "right" },
|
||||
{ name: "fatLast1Y", label: "Fat Anno", field: "fatLast1Y", align: "right" },
|
||||
{ name: "ult_ord", label: "Ult. Ordine", field: "ult_ord", align: "left" },
|
||||
{ name: "quantity", label: "Magazz.", field: "quantity", align: "right" },
|
||||
{ name: "actions", label: "Azioni", field: "", align: "center" },
|
||||
{ name: "totVen", label: "Venduti", field: "totVen", align: "right", visu: costanti.VISUCAMPI.PER_EDITORE },
|
||||
{ name: "totFat", label: "Fattur.", field: "totFat", align: "right", visu: costanti.VISUCAMPI.PER_EDITORE },
|
||||
{ name: "fatLast6M", label: "Fat 6M", field: "fatLast6M", align: "right", visu: costanti.VISUCAMPI.PER_EDITORE },
|
||||
{ name: "fatLast1Y", label: "Fat Anno", field: "fatLast1Y", align: "right", visu: costanti.VISUCAMPI.PER_EDITORE },
|
||||
{ name: "fatLast2Y", label: "Fat 2A", field: "fatLast2Y", 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 },
|
||||
];
|
||||
|
||||
function getFieldValue(element: any, field: any): any {
|
||||
switch (field.field) {
|
||||
case 'image':
|
||||
return element.productInfo?.imagefile
|
||||
? tools.getFullFileNameByImageFile('productInfos', element.productInfo?.imagefile)
|
||||
: element.productInfo?.image_link;
|
||||
|
||||
case 'name':
|
||||
return element.productInfo?.name;
|
||||
|
||||
case 'authors':
|
||||
return formatAuthors(element.productInfo?.authors);
|
||||
|
||||
case 'isbn':
|
||||
return element.isbn;
|
||||
|
||||
case 'trafiletto':
|
||||
return element.productInfo?.descr_trafiletto_catalogo?.length > 100 ? 'SI' : 'NO';
|
||||
|
||||
case 'catprods':
|
||||
return tools.formatCatProds(element.productInfo?.catprods);
|
||||
|
||||
case 'edizione':
|
||||
return element.arrvariazioni?.[0]?.edizione;
|
||||
|
||||
case 'casaeditrice':
|
||||
return products.getCasaEditriceByIdPublisher(element.productInfo?.idPublisher);
|
||||
|
||||
case 'idCollana':
|
||||
return tools.formatCollane(element.productInfo?.idCollana);
|
||||
|
||||
case 'stato':
|
||||
return products.getDescrStatiProdottoByIdStatoProdotto(element.productInfo?.idStatoProdotto || '');
|
||||
|
||||
case 'tipologia':
|
||||
return products.getDescrByIdTipologia(element.arrvariazioni?.[0]?.idTipologia || '');
|
||||
|
||||
case 'tipoformato':
|
||||
return products.getDescrByIdTipoFormato(element.arrvariazioni?.[0]?.idTipoFormato || '');
|
||||
|
||||
case 'date_pub':
|
||||
return tools.getstrDate(element.productInfo?.date_pub);
|
||||
|
||||
case 'rank3M':
|
||||
return element.productInfo?.rank3M;
|
||||
|
||||
case 'rank6M':
|
||||
return element.productInfo?.rank6M;
|
||||
|
||||
case 'rank1Y':
|
||||
return element.productInfo?.rank1Y;
|
||||
|
||||
case 'pagine':
|
||||
return element.arrvariazioni?.[0]?.pagine;
|
||||
|
||||
case 'totVen':
|
||||
return element.productInfo?.totVen;
|
||||
|
||||
case 'totFat':
|
||||
return element.productInfo?.totFat;
|
||||
|
||||
case 'fatLast6M':
|
||||
return element.productInfo?.fatLast6M;
|
||||
|
||||
case 'fatLast1Y':
|
||||
return element.productInfo?.fatLast1Y;
|
||||
|
||||
case 'ult_ord':
|
||||
return tools.getstrDate(element.productInfo?.dataUltimoOrdine);
|
||||
|
||||
case 'quantity':
|
||||
return element.arrvariazioni?.[0]?.quantita;
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function getFieldClass(element: any, field: any): string {
|
||||
switch (field.field) {
|
||||
case 'trafiletto':
|
||||
return element.productInfo?.descr_trafiletto_catalogo?.length > 100
|
||||
? 'text-green'
|
||||
: 'text-red';
|
||||
|
||||
case 'stato':
|
||||
if (products.isProssimaUscita(element.productInfo)) {
|
||||
return 'bg-purple-3';
|
||||
}
|
||||
if (products.isPrevendita(element.productInfo)) {
|
||||
return 'bg-blue-3';
|
||||
}
|
||||
if (products.isNonVendibile(element.productInfo)) {
|
||||
return 'bg-grey';
|
||||
}
|
||||
return '';
|
||||
|
||||
case 'quantity':
|
||||
if (products.isPubblicato(element.productInfo)) {
|
||||
if (products.isQtaLimitata(element)) {
|
||||
return 'bg-yellow';
|
||||
}
|
||||
if (products.isInEsaurendo(element)) {
|
||||
return 'bg-orange';
|
||||
}
|
||||
if (products.isEsaurito(element)) {
|
||||
return 'text-white bg-red-10';
|
||||
}
|
||||
}
|
||||
return '';
|
||||
|
||||
case 'rank3M':
|
||||
case 'rank6M':
|
||||
case 'rank1Y':
|
||||
case 'pagine':
|
||||
case 'totVen':
|
||||
case 'totFat':
|
||||
case 'fatLast6M':
|
||||
case 'fatLast1Y':
|
||||
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
function getFieldStyle(element: any, field: any): Record<string, string> {
|
||||
switch (field.field) {
|
||||
case 'image':
|
||||
return {
|
||||
width: '50px',
|
||||
height: '50px'
|
||||
};
|
||||
|
||||
case 'rank3M':
|
||||
case 'rank6M':
|
||||
case 'rank1Y':
|
||||
case 'pagine':
|
||||
case 'totVen':
|
||||
case 'totFat':
|
||||
case 'fatLast6M':
|
||||
case 'fatLast1Y':
|
||||
case 'quantity':
|
||||
return {
|
||||
textAlign: 'right'
|
||||
};
|
||||
|
||||
case 'trafiletto':
|
||||
return {
|
||||
textAlign: 'center'
|
||||
};
|
||||
|
||||
default:
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
let cookieValue: [] | null = null;
|
||||
try {
|
||||
cookieValue = tools.getCookie("selColCat");
|
||||
@@ -147,7 +309,8 @@ export default defineComponent({
|
||||
|
||||
// 3. Funzione per verificare se una colonna è visibile (isColumnVisible)
|
||||
const isColumnVisible = (column) => {
|
||||
return selectedColumns.value.includes(column);
|
||||
const ok = allColumns.some((col) => col.name === column) && (!props.optcatalogo.showListaArgomenti || (props.optcatalogo.showListaArgomenti && !column.edit))
|
||||
return selectedColumns.value.includes(column) && ok;
|
||||
}
|
||||
|
||||
// Funzione per eliminare un prodotto
|
||||
@@ -270,18 +433,18 @@ export default defineComponent({
|
||||
sortDirection.value = 1
|
||||
}
|
||||
internalProducts.value = internalProducts.value.sort((a: any, b: any) => {
|
||||
const aVal = a.productInfo?.[sortAttributeToSort] ?? ''
|
||||
const bVal = b.productInfo?.[sortAttributeToSort] ?? ''
|
||||
const aVal = getFieldValue(a, { field: sortAttributeToSort });
|
||||
const bVal = getFieldValue(b, { field: sortAttributeToSort });
|
||||
if (aVal instanceof Date && bVal instanceof Date) {
|
||||
return sortDirection.value === 1 ? aVal.getTime() - bVal.getTime() : bVal.getTime() - aVal.getTime()
|
||||
return sortDirection.value === 1 ? aVal.getTime() - bVal.getTime() : bVal.getTime() - aVal.getTime();
|
||||
}
|
||||
if (typeof aVal === 'number' && typeof bVal === 'number') {
|
||||
return sortDirection.value === 1 ? aVal - bVal : bVal - aVal
|
||||
return sortDirection.value === 1 ? aVal - bVal : bVal - aVal;
|
||||
}
|
||||
if (typeof aVal === 'string' && typeof bVal === 'string') {
|
||||
return sortDirection.value === 1 ? aVal.localeCompare(bVal) : bVal.localeCompare(aVal)
|
||||
return sortDirection.value === 1 ? aVal.localeCompare(bVal) : bVal.localeCompare(aVal);
|
||||
}
|
||||
return sortDirection.value === 1 ? String(aVal).localeCompare(String(bVal)) : String(bVal).localeCompare(String(aVal))
|
||||
return sortDirection.value === 1 ? String(aVal).localeCompare(String(bVal)) : String(bVal).localeCompare(String(aVal));
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -290,6 +453,34 @@ export default defineComponent({
|
||||
emit('rigenera')
|
||||
}
|
||||
|
||||
function getFieldClick(element: any, field: any): (() => void) | null {
|
||||
switch (field.field) {
|
||||
case 'image':
|
||||
return () => showProduct(element);
|
||||
|
||||
case 'name':
|
||||
case 'authors':
|
||||
case 'isbn':
|
||||
return () => showProduct(element);
|
||||
|
||||
case 'stato':
|
||||
return () => {
|
||||
// esempio: mostra dettagli dello stato
|
||||
console.log('Stato prodotto:', element.productInfo?.idStatoProdotto);
|
||||
};
|
||||
|
||||
case 'quantity':
|
||||
return () => {
|
||||
// esempio: mostra log disponibilità
|
||||
console.log('Quantità disponibile:', element.arrvariazioni?.[0]?.quantita);
|
||||
};
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
onMounted(mounted)
|
||||
|
||||
return {
|
||||
@@ -324,6 +515,10 @@ export default defineComponent({
|
||||
sortTable,
|
||||
sortAttribute,
|
||||
sortDirection,
|
||||
getFieldValue,
|
||||
getFieldClass,
|
||||
getFieldStyle,
|
||||
getFieldClick,
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -60,176 +60,86 @@
|
||||
<tr
|
||||
:key="element._id"
|
||||
:class="{
|
||||
'bg-grey-2': internalProducts.indexOf(element) % 2 === 1,
|
||||
'bg-grey-3': internalProducts.indexOf(element) % 2 === 1,
|
||||
}"
|
||||
>
|
||||
<!-- Icona Drag Handle -->
|
||||
<td v-if="isColumnVisible('pos')">
|
||||
{{
|
||||
// put index in the first column
|
||||
internalProducts.indexOf(element) + 1
|
||||
}}
|
||||
</td>
|
||||
<td
|
||||
v-if="isColumnVisible('drag')"
|
||||
class="drag-handle"
|
||||
<template
|
||||
v-for="field in allColumns"
|
||||
:key="field.name"
|
||||
>
|
||||
<q-icon
|
||||
name="drag_handle"
|
||||
size="32px"
|
||||
color="primary"
|
||||
/>
|
||||
</td>
|
||||
|
||||
<!-- Immagine Piccola -->
|
||||
<td v-if="isColumnVisible('image')">
|
||||
<q-img
|
||||
:src="
|
||||
element.productInfo?.imagefile
|
||||
? tools.getFullFileNameByImageFile('productInfos', element.productInfo?.imagefile)
|
||||
: element.productInfo?.image_link
|
||||
"
|
||||
style="width: 50px; height: 50px"
|
||||
class="rounded-borders cursor-pointer"
|
||||
@click="showProduct(element)"
|
||||
/>
|
||||
</td>
|
||||
|
||||
<!-- Titolo -->
|
||||
<td v-if="isColumnVisible('name')">{{ element.productInfo?.name }}</td>
|
||||
|
||||
<!-- Autore -->
|
||||
<td v-if="isColumnVisible('authors')">{{ formatAuthors(element.productInfo?.authors) }}</td>
|
||||
|
||||
<!-- ISBN -->
|
||||
<td v-if="isColumnVisible('isbn')">{{ element.isbn }}</td>
|
||||
|
||||
<td
|
||||
v-if="isColumnVisible('trafiletto')"
|
||||
style="text-align: center"
|
||||
:class="element.productInfo?.descr_trafiletto_catalogo?.length > 100 ? 'text-green' : 'text-red'"
|
||||
>
|
||||
{{ element.productInfo?.descr_trafiletto_catalogo?.length > 100 ? 'SI' : 'NO' }}
|
||||
</td>
|
||||
|
||||
<!-- Argomento -->
|
||||
<td v-if="isColumnVisible('catprods')">{{ tools.formatCatProds(element.productInfo?.catprods) }}</td>
|
||||
<!-- Collana -->
|
||||
<td v-if="isColumnVisible('idCollana')">{{ tools.formatCollane(element.productInfo?.idCollana) }}</td>
|
||||
<td
|
||||
v-if="isColumnVisible('stato')"
|
||||
:class="{
|
||||
'bg-purple-3': products.isProssimaUscita(element.productInfo),
|
||||
'bg-grey': products.isNonVendibile(element.productInfo),
|
||||
}"
|
||||
>
|
||||
{{ products.getDescrStatiProdottoByIdStatoProdotto(element.productInfo.idStatoProdotto || '') }}
|
||||
</td>
|
||||
<td v-if="isColumnVisible('tipologia')">
|
||||
{{ products.getDescrByIdTipologia(element.arrvariazioni[0].idTipologia || '') }}
|
||||
</td>
|
||||
<td v-if="isColumnVisible('tipoformato')">
|
||||
{{ products.getDescrByIdTipoFormato(element.arrvariazioni[0].idTipoFormato || '') }}
|
||||
</td>
|
||||
|
||||
<td v-if="isColumnVisible('date_pub')">{{ tools.getstrDate(element.productInfo?.date_pub) }}</td>
|
||||
|
||||
<td
|
||||
v-if="isColumnVisible('rank3M')"
|
||||
style="text-align: right"
|
||||
>
|
||||
{{ element.productInfo?.rank3M }}
|
||||
</td>
|
||||
<td
|
||||
v-if="isColumnVisible('rank6M')"
|
||||
style="text-align: right"
|
||||
>
|
||||
{{ element.productInfo?.rank6M }}
|
||||
</td>
|
||||
<td
|
||||
v-if="isColumnVisible('rank1Y')"
|
||||
style="text-align: right"
|
||||
>
|
||||
{{ element.productInfo?.rank1Y }}
|
||||
</td>
|
||||
|
||||
<td
|
||||
v-if="isColumnVisible('pagine')"
|
||||
style="text-align: right"
|
||||
>
|
||||
{{ element.arrvariazioni[0].pagine }}
|
||||
</td>
|
||||
|
||||
<td
|
||||
v-if="isColumnVisible('totVen')"
|
||||
style="text-align: right"
|
||||
>
|
||||
{{ element.productInfo?.totVen }}
|
||||
</td>
|
||||
<td
|
||||
v-if="isColumnVisible('totFat')"
|
||||
style="text-align: right"
|
||||
>
|
||||
{{ element.productInfo?.totFat }}
|
||||
</td>
|
||||
<td
|
||||
v-if="isColumnVisible('fatLast6M')"
|
||||
style="text-align: right"
|
||||
>
|
||||
{{ element.productInfo?.fatLast6M }}
|
||||
</td>
|
||||
<td
|
||||
v-if="isColumnVisible('fatLast1Y')"
|
||||
style="text-align: right"
|
||||
>
|
||||
{{ element.productInfo?.fatLast1Y }}
|
||||
</td>
|
||||
<td v-if="isColumnVisible('ult_ord')">{{ tools.getstrDate(element.productInfo?.dataUltimoOrdine) }}</td>
|
||||
|
||||
<!-- Quantità -->
|
||||
<td
|
||||
v-if="isColumnVisible('quantity')"
|
||||
style="text-align: right"
|
||||
:class="{
|
||||
'bg-yellow': products.isPubblicato(element.productInfo) && products.isQtaLimitata(element),
|
||||
'bg-orange': products.isPubblicato(element.productInfo) && products.isInEsaurendo(element),
|
||||
'text-white bg-red-10': products.isPubblicato(element.productInfo) && products.isEsaurito(element),
|
||||
}"
|
||||
>
|
||||
{{ element.arrvariazioni[0].quantita }}
|
||||
</td>
|
||||
|
||||
<!-- Azioni -->
|
||||
<td v-if="isColumnVisible('actions')">
|
||||
<q-btn-dropdown
|
||||
label="Azioni"
|
||||
color="primary"
|
||||
flat
|
||||
<!-- Icona Drag Handle -->
|
||||
<td v-if="field.name === 'pos' && isColumnVisible('pos')">
|
||||
{{
|
||||
// put index in the first column
|
||||
internalProducts.indexOf(element) + 1
|
||||
}}
|
||||
</td>
|
||||
<td
|
||||
v-else-if="field.name === 'drag' && isColumnVisible('drag')"
|
||||
class="drag-handle"
|
||||
>
|
||||
<q-list>
|
||||
<q-item
|
||||
clickable
|
||||
v-close-popup
|
||||
@click="modifyProduct(element)"
|
||||
>
|
||||
<q-item-section>
|
||||
<q-item-label>Modifica</q-item-label>
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
<q-item
|
||||
clickable
|
||||
v-close-popup
|
||||
@click="removeProduct(element)"
|
||||
>
|
||||
<q-item-section>
|
||||
<q-item-label>Elimina</q-item-label>
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
</q-list>
|
||||
</q-btn-dropdown>
|
||||
</td>
|
||||
</tr>
|
||||
</template>
|
||||
<q-icon
|
||||
name="drag_handle"
|
||||
size="32px"
|
||||
color="primary"
|
||||
/>
|
||||
</td>
|
||||
|
||||
<!-- Immagine Piccola -->
|
||||
<td v-else-if="field.name === 'image' && isColumnVisible('image')">
|
||||
<q-img
|
||||
:src="
|
||||
element.productInfo?.imagefile
|
||||
? tools.getFullFileNameByImageFile('productInfos', element.productInfo?.imagefile)
|
||||
: element.productInfo?.image_link
|
||||
"
|
||||
style="width: 50px; height: 50px"
|
||||
class="rounded-borders cursor-pointer"
|
||||
@click="showProduct(element)"
|
||||
/>
|
||||
</td>
|
||||
|
||||
<td
|
||||
v-else-if="isColumnVisible(field.name)"
|
||||
:class="getFieldClass(element, field)"
|
||||
:style="getFieldStyle(element, field)"
|
||||
@click="getFieldClick(element, field)?.()"
|
||||
>
|
||||
{{ getFieldValue(element, field) }}
|
||||
</td>
|
||||
<!-- Azioni -->
|
||||
<td v-else-if="field.name === 'actions' && isColumnVisible('actions')">
|
||||
<q-btn-dropdown
|
||||
label="Azioni"
|
||||
color="primary"
|
||||
flat
|
||||
>
|
||||
<q-list>
|
||||
<q-item
|
||||
clickable
|
||||
v-close-popup
|
||||
@click="modifyProduct(element)"
|
||||
>
|
||||
<q-item-section>
|
||||
<q-item-label>Modifica</q-item-label>
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
<q-item
|
||||
clickable
|
||||
v-close-popup
|
||||
@click="removeProduct(element)"
|
||||
>
|
||||
<q-item-section>
|
||||
<q-item-label>Elimina</q-item-label>
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
</q-list>
|
||||
</q-btn-dropdown>
|
||||
</td>
|
||||
</template>
|
||||
</tr></template
|
||||
>
|
||||
>
|
||||
</draggable>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user