fix: se aggiungi XLS non si aggiornava la lista correttamente, non ricaricava...
This commit is contained in:
@@ -263,7 +263,6 @@ export default defineComponent({
|
||||
() => props.modelValue.selectedVersionStampabile,
|
||||
async () => {
|
||||
if (loadpage.value) {
|
||||
|
||||
//nascondi.value = true;
|
||||
arrProducts.value = [];
|
||||
console.log('aggiorna... ');
|
||||
@@ -1297,7 +1296,6 @@ export default defineComponent({
|
||||
sort_dir: number
|
||||
): IProduct[] {
|
||||
if (sort_field) {
|
||||
|
||||
// Crea una copia dell'array per non modificare l'originale
|
||||
const sortedArr = [...arrprod].sort((a: IProduct, b: IProduct) => {
|
||||
const valA =
|
||||
@@ -1596,12 +1594,22 @@ export default defineComponent({
|
||||
|
||||
async function mounted() {
|
||||
// console.log('mounted Catalogo')
|
||||
caricatutto();
|
||||
|
||||
const instampa = globalStore.inStampa;
|
||||
|
||||
window.addEventListener('scroll', handleScroll);
|
||||
|
||||
if (onlyCatalogoPDF.value) {
|
||||
setTimeout(async () => {
|
||||
preparePDF(instampa, true);
|
||||
}, 2000);
|
||||
}
|
||||
}
|
||||
|
||||
async function caricatutto(forzaagg?: boolean) {
|
||||
let mycat = null;
|
||||
|
||||
let instampa = false;
|
||||
|
||||
instampa = globalStore.inStampa;
|
||||
|
||||
if (optcatalogo.value.idCatalogSel) {
|
||||
// controlla se è stato passato l'id dalla pagina:
|
||||
let idcatsel = '';
|
||||
@@ -1619,7 +1627,7 @@ export default defineComponent({
|
||||
|
||||
// console.log('instampa... ', instampa)
|
||||
|
||||
if (mycat && !mycat.lista_prodotti) {
|
||||
if ((mycat && !mycat.lista_prodotti) || forzaagg) {
|
||||
mycat = await catalogStore.fetchCatalogById(mycat._id);
|
||||
}
|
||||
myCatalog.value = mycat;
|
||||
@@ -1704,17 +1712,10 @@ export default defineComponent({
|
||||
|
||||
// Inizializza
|
||||
loadpage.value = true;
|
||||
window.addEventListener('scroll', handleScroll);
|
||||
|
||||
calcArrProducts();
|
||||
|
||||
ismounting.value = false;
|
||||
|
||||
if (onlyCatalogoPDF.value) {
|
||||
setTimeout(async () => {
|
||||
preparePDF(instampa, true);
|
||||
}, 2000);
|
||||
}
|
||||
}
|
||||
|
||||
function loaddata() {
|
||||
@@ -2370,7 +2371,7 @@ export default defineComponent({
|
||||
}
|
||||
|
||||
async function updateProducts(arr: any, aggiorna?: boolean) {
|
||||
console.log('UpdateProducts', arr.length)
|
||||
console.log('UpdateProducts', arr.length);
|
||||
if (myCatalog.value && myCatalog.value?.lista_prodotti) {
|
||||
if (
|
||||
myCatalog.value.lista_prodotti?.length !== arr.length ||
|
||||
@@ -2390,8 +2391,33 @@ export default defineComponent({
|
||||
}
|
||||
}
|
||||
|
||||
async function addArrayProductsToList(arrayprod: IProduct[]) {
|
||||
if (arrayprod && arrayprod.length > 0) {
|
||||
const arr = myCatalog.value?.lista_prodotti || [];
|
||||
|
||||
// add this record to lista_prodotti
|
||||
for (const element of arrayprod) {
|
||||
if (
|
||||
myCatalog.value &&
|
||||
!myCatalog.value?.lista_prodotti?.some((p) => p._id === element._id)
|
||||
) {
|
||||
// inserire il record
|
||||
arr.push(element);
|
||||
}
|
||||
}
|
||||
|
||||
// Ricarica tutto
|
||||
await updateProducts(arr, true);
|
||||
|
||||
// Ricarica tutto
|
||||
await caricatutto(true)
|
||||
|
||||
addnewProd.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function addProductToList(element: IProduct, where: string) {
|
||||
console.log('addProductToList', element)
|
||||
console.log('addProductToList', element);
|
||||
|
||||
if (element) {
|
||||
// add this record to lista_prodotti
|
||||
@@ -2415,6 +2441,28 @@ export default defineComponent({
|
||||
addnewProd.value = true;
|
||||
}
|
||||
|
||||
async function clickdeleteAllBooks() {
|
||||
const confirm = await $q
|
||||
.dialog({
|
||||
title: 'Elimina Lista',
|
||||
message: 'Sicuro di ELIMINARE tutta la lista ?',
|
||||
ok: {
|
||||
label: 'Elimina Tutto',
|
||||
push: true,
|
||||
},
|
||||
cancel: {
|
||||
label: 'Annulla',
|
||||
},
|
||||
})
|
||||
.onOk(async () => {
|
||||
if (!confirm) return;
|
||||
|
||||
myCatalog.value.lista_prodotti = [];
|
||||
|
||||
salvaListaProdotti(true);
|
||||
});
|
||||
}
|
||||
|
||||
function toggleDebug() {
|
||||
optcatalogo.value.indebug = !optcatalogo.value.indebug;
|
||||
}
|
||||
@@ -2742,6 +2790,11 @@ export default defineComponent({
|
||||
}
|
||||
}
|
||||
|
||||
async function refreshProducts() {
|
||||
// calcArrProducts(true);
|
||||
await generatearrProdToViewSorted(true, false);
|
||||
}
|
||||
|
||||
onMounted(mounted);
|
||||
|
||||
return {
|
||||
@@ -2801,6 +2854,7 @@ export default defineComponent({
|
||||
updateProducts,
|
||||
clickaddNewBook,
|
||||
addProductToList,
|
||||
addArrayProductsToList,
|
||||
addnewProd,
|
||||
showListaFiltrata,
|
||||
rigeneraLibri,
|
||||
@@ -2841,6 +2895,8 @@ export default defineComponent({
|
||||
showColorPicker,
|
||||
mostraTuttiITab,
|
||||
esistePagIntroduttiva,
|
||||
clickdeleteAllBooks,
|
||||
refreshProducts,
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
@@ -202,6 +202,14 @@
|
||||
@click="reSortList"
|
||||
></q-btn>-->
|
||||
|
||||
<q-btn
|
||||
v-if="!showListaFiltrata && tools.isCollaboratore()"
|
||||
rounded
|
||||
label="Elimina Tutti"
|
||||
icon="fas fa-trash"
|
||||
color="negative"
|
||||
@click="clickdeleteAllBooks()"
|
||||
></q-btn>
|
||||
<q-btn
|
||||
v-if="!showListaFiltrata && tools.isCollaboratore()"
|
||||
rounded
|
||||
@@ -255,6 +263,7 @@
|
||||
:title="getTitoloCatalogo()"
|
||||
:canadd="!showListaFiltrata"
|
||||
@addtolist="(elem: any) => addProductToList(elem, shared_consts.WHERE_INSERT.ONBOTTOM)"
|
||||
@addarraytolist="(arrayprod: any) => addArrayProductsToList(arrayprod)"
|
||||
/>
|
||||
</q-tab-panel>
|
||||
<q-tab-panel
|
||||
@@ -1868,6 +1877,7 @@
|
||||
:title="getTitoloCatalogo()"
|
||||
:canadd="!showListaFiltrata"
|
||||
@addtolist="(elem: any) => addProductToList(elem, shared_consts.WHERE_INSERT.ONTOP)"
|
||||
@addarraytolist="(arrayprod: any) => addArrayProductsToList(arrayprod)"
|
||||
/>
|
||||
</q-tab-panel>
|
||||
</q-tab-panels>
|
||||
|
||||
Reference in New Issue
Block a user