From fc015404a623c628c7c83b67a86cb9caee0feba4 Mon Sep 17 00:00:00 2001 From: Surya Paolo Date: Wed, 23 Apr 2025 01:59:39 +0200 Subject: [PATCH] - ordinamento tabella titoli - migliorata la lista degli argomenti --- .../CCatalogoCard/CCatalogoCard.vue | 3 +- src/components/CMyEditElem/CMyEditElem.vue | 9 ++ src/components/CProductTable/CProductTable.ts | 38 +++++ .../CProductTable/CProductTable.vue | 13 ++ .../CSearchProduct/CSearchProduct.ts | 131 +++++++++--------- src/model/GlobalStore.ts | 1 + src/model/Products.ts | 2 +- src/store/Products.ts | 8 +- src/views/ecommerce/catalogo/catalogo.scss | 68 ++++++--- src/views/ecommerce/catalogo/catalogo.ts | 26 +++- src/views/ecommerce/catalogo/catalogo.vue | 60 +++++--- 11 files changed, 245 insertions(+), 114 deletions(-) diff --git a/src/components/CCatalogoCard/CCatalogoCard.vue b/src/components/CCatalogoCard/CCatalogoCard.vue index 29a3d02f..1a784fa7 100755 --- a/src/components/CCatalogoCard/CCatalogoCard.vue +++ b/src/components/CCatalogoCard/CCatalogoCard.vue @@ -257,7 +257,7 @@ - Vedi Numero di Pagine (Da GM) + -->
+ + + {maxlength: 0}) const editOn = computed({ @@ -255,6 +259,37 @@ export default defineComponent({ } + const sortTable = (sortAttributeToSort: string) => { + + if (!props.optcatalogo.showListaArgomenti) + return false + + if (sortAttributeToSort) { + if (sortAttribute.value === sortAttributeToSort) { + sortDirection.value = -sortDirection.value + } else { + sortAttribute.value = sortAttributeToSort + sortDirection.value = 1 + } + internalProducts.value = internalProducts.value.sort((a: any, b: any) => { + const aVal = a.productInfo?.[sortAttributeToSort] ?? '' + const bVal = b.productInfo?.[sortAttributeToSort] ?? '' + if (aVal instanceof Date && bVal instanceof Date) { + 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 + } + if (typeof aVal === 'string' && typeof bVal === 'string') { + return sortDirection.value === 1 ? aVal.localeCompare(bVal) : bVal.localeCompare(aVal) + } + return sortDirection.value === 1 ? String(aVal).localeCompare(String(bVal)) : String(bVal).localeCompare(String(aVal)) + }) + } + } + + + onMounted(mounted) return { @@ -287,6 +322,9 @@ export default defineComponent({ optionscatalogo, t, products, + sortTable, + sortAttribute, + sortDirection, } } }) diff --git a/src/components/CProductTable/CProductTable.vue b/src/components/CProductTable/CProductTable.vue index 4841b7c4..6d337c7a 100755 --- a/src/components/CProductTable/CProductTable.vue +++ b/src/components/CProductTable/CProductTable.vue @@ -25,8 +25,21 @@ {{ col.label }} + + diff --git a/src/components/CSearchProduct/CSearchProduct.ts b/src/components/CSearchProduct/CSearchProduct.ts index 8a501df6..c6f6d68d 100755 --- a/src/components/CSearchProduct/CSearchProduct.ts +++ b/src/components/CSearchProduct/CSearchProduct.ts @@ -1,5 +1,5 @@ import type { PropType } from 'vue'; -import { defineComponent, onMounted, ref, watch, computed} from 'vue' +import { defineComponent, onMounted, ref, watch, computed } from 'vue' import { tools } from '@tools' import { useUserStore } from '@store/UserStore' import { useRouter } from 'vue-router' @@ -23,6 +23,7 @@ import type { import { fieldsTable } from '@store/Modules/fieldsTable' +import Products from 'app/src/rootgen/admin/products/products.vue'; export default defineComponent({ name: 'CSearchProduct', @@ -37,7 +38,7 @@ export default defineComponent({ idprodtoshow: { type: String, required: false, - default : '', + default: '', }, empty: { type: Boolean, @@ -47,7 +48,7 @@ export default defineComponent({ nameLinkTemplate: { type: String, required: false, - default : '', + default: '', }, visu: { type: Number, @@ -245,7 +246,7 @@ export default defineComponent({ router.push(path) } - function collabel (rec: any) { + function collabel(rec: any) { // console.log('Record:', rec) let label = '' if (rec && rec.productInfo) { @@ -254,79 +255,81 @@ export default defineComponent({ if (!productStore.isPubblicatoById(rec.productInfo.idStatoProdotto)) label += ' (' + productStore.getDescrStatiProdottoByIdStatoProdotto(rec.productInfo.idStatoProdotto || '') + ')' } - - // console.log('Computed label:', label) - } - return label + if (productStore.isEsaurito(rec)) { + label += ' (Attualmente non disponibile)' + } + // console.log('Computed label:', label) } + return label + } function insertProd() { - // console.log('insertProd') - emit('insert', myproduct.value) + // console.log('insertProd') + emit('insert', myproduct.value) } - function clickClose() { - searchList.value[0].value = '' - myproduct.value = null - emit('close') - } +function clickClose() { + searchList.value[0].value = '' + myproduct.value = null + emit('close') +} - function updateproductmodif(element: IProduct) { - console.log('CSEARCHPRODUCT: updateproductmodif') - emit('updateproductmodif', element) - } +function updateproductmodif(element: IProduct) { + console.log('CSEARCHPRODUCT: updateproductmodif') + emit('updateproductmodif', element) +} - async function searchOnGM(mystr: string) { - // refreshSingleBookFromGM({usaDBGMLocale: false}) - const options = { +async function searchOnGM(mystr: string) { + // refreshSingleBookFromGM({usaDBGMLocale: false}) + const options = { - } - const ris = await globalStore.updateAllBookFromGM_T_Web_Articoli({ sku: '', isbn: mystr, ...options }) - if (ris) { + } + const ris = await globalStore.updateAllBookFromGM_T_Web_Articoli({ sku: '', isbn: mystr, ...options }) + if (ris) { - const id = getSearchId() - loadProduct(id) - updateproductmodif(myproduct.value) + const id = getSearchId() + loadProduct(id) + updateproductmodif(myproduct.value) - // await updateproduct(false) - tools.showPositiveNotif($q, t('dbgm.updateLocalDb_OK')) - // updatefromgm.value = false - } + // await updateproduct(false) + tools.showPositiveNotif($q, t('dbgm.updateLocalDb_OK')) + // updatefromgm.value = false + } - } +} - onMounted(mounted) +onMounted(mounted) - return { - userStore, - costanti, - tools, - toolsext, - search, - shared_consts, - productStore, - t, - loadpage, - refreshpage, - show_hide, - searchList, - fieldsTable, - mycolumns, - naviga, - myproduct, - optcatalogo, - idPage, - selauthor, - valoriopt, - labelcombo, - searchText, - insertProd, - focus, - clickClose, - saveSearch, - updateproductmodif, - searchOnGM, - } +return { + userStore, + costanti, + tools, + toolsext, + search, + shared_consts, + productStore, + t, + loadpage, + refreshpage, + show_hide, + searchList, + fieldsTable, + mycolumns, + naviga, + myproduct, + optcatalogo, + idPage, + selauthor, + valoriopt, + labelcombo, + searchText, + insertProd, + focus, + clickClose, + saveSearch, + updateproductmodif, + searchOnGM, +} } }) diff --git a/src/model/GlobalStore.ts b/src/model/GlobalStore.ts index 22a23203..39e1f132 100755 --- a/src/model/GlobalStore.ts +++ b/src/model/GlobalStore.ts @@ -861,6 +861,7 @@ export interface IOptCatalogo { printable?: boolean indebug?: boolean maxnumlibri?: number + showListaArgomenti?: boolean generazionePDFInCorso?: boolean first_page?: IDimensioni diff --git a/src/model/Products.ts b/src/model/Products.ts index 7bb83f1a..68ef66b0 100755 --- a/src/model/Products.ts +++ b/src/model/Products.ts @@ -190,7 +190,7 @@ export interface IProductsState { productInfos: IProductInfo[] userActive: IUserShort - isPubblicatoById: (idStatoProdotto: number) => boolean; + isPubblicatoById?: (idStatoProdotto: number) => boolean; } export interface IProducer { diff --git a/src/store/Products.ts b/src/store/Products.ts index 52d4a357..aac707e6 100755 --- a/src/store/Products.ts +++ b/src/store/Products.ts @@ -130,18 +130,18 @@ export const useProducts = defineStore('Products', { }, isDisponibile: (state: IProductsState) => (product: IProduct): boolean => { - return product.arrvariazioni[0].quantita > 100 + return product?.arrvariazioni?.[0]?.quantita > 100 }, isQtaLimitata: (state: IProductsState) => (product: IProduct): boolean => { - return product.arrvariazioni[0].quantita > 50 && product.arrvariazioni[0].quantita < 100 + return product?.arrvariazioni?.[0]?.quantita > 50 && product?.arrvariazioni?.[0]?.quantita < 100 }, isInEsaurendo: (state: IProductsState) => (product: IProduct): boolean => { - return product.arrvariazioni[0].quantita > 0 && product.arrvariazioni[0].quantita < 50 + return product?.arrvariazioni?.[0]?.quantita > 0 && product.arrvariazioni?.[0]?.quantita < 50 }, isEsaurito: (state: IProductsState) => (product: IProduct): boolean => { - return product.arrvariazioni[0].quantita <= 0 + return product?.arrvariazioni?.[0]?.quantita <= 0 }, isPubblicatoById: (state: IProductsState) => (idStatoProdotto: number): boolean => { diff --git a/src/views/ecommerce/catalogo/catalogo.scss b/src/views/ecommerce/catalogo/catalogo.scss index f0199b22..a5b33b51 100755 --- a/src/views/ecommerce/catalogo/catalogo.scss +++ b/src/views/ecommerce/catalogo/catalogo.scss @@ -32,23 +32,7 @@ body { } -// Underline like a href -.category { - color: darkblue; - font-family: Arial, Helvetica, sans-serif; - font-size: 14px; - line-height: 19px; - - cursor: pointer; -} - -.category_sel { - color: white !important; - background: #5c8ef4 !important; - padding: 2px; -} - -.category-title{ +.category-title { font-weight: bold; font-size: 1.1rem; margin-bottom: 0.5rem; @@ -59,10 +43,13 @@ body { } .fixed-width { - width: var(--width) !important; /* Usa una variabile CSS */ + width: var(--width) !important; + /* Usa una variabile CSS */ } + .fixed-height { - height: var(--height) !important; /* Usa una variabile CSS */ + height: var(--height) !important; + /* Usa una variabile CSS */ } .break { @@ -96,6 +83,7 @@ body { margin-bottom: calc(5 * var(--scalecatalog) * 1px); font-size: calc(16 * var(--scalecatalog) * 1px); text-align: left !important; + &.big { font-size: calc(22 * var(--scalecatalog) * 1px); } @@ -109,7 +97,7 @@ body { word-wrap: break-word; } -.book-link{ +.book-link { font-style: italic; font-size: calc(14 * var(--scalecatalog) * 1px); } @@ -125,6 +113,7 @@ body { font-size: calc(20 * var(--scalecatalog) * 1px); height: calc(380 * var(--scalecatalog) * 1px); } + .book-text-down { font-family: 'DINPro', sans-serif; margin-bottom: calc(5 * var(--scalecatalog) * 1px); @@ -137,4 +126,41 @@ body { margin-bottom: calc(5 * var(--scalecatalog) * 1px); font-size: calc(35 * var(--scalecatalog) * 1px); height: calc(100 * var(--scalecatalog) * 1px); -} \ No newline at end of file +} + +.categories { + display: flex; + flex-wrap: wrap; + justify-content: center; + gap: 8px; + padding: 12px; + border-radius: 24px; + background-color: #e6f0ff; +} + +.category { + font-family: 'Segoe UI', Arial, sans-serif; + font-size: 0.95rem; + padding: 8px 16px; + background-color: white; + color: #2c3e50; + border: 1px solid #b0c4de; + border-radius: 20px; + cursor: pointer; + transition: all 0.2s ease-in-out; + user-select: none; +} + +.category:hover { + background-color: #dbe9ff; + color: #1a3f8a; + border-color: #89aef0; +} + +.category_sel { + background-color: #5c8ef4 !important; + color: white !important; + font-weight: 600; + border-color: #5c8ef4 !important; + box-shadow: 0 0 0 2px rgba(92, 142, 244, 0.3); +} diff --git a/src/views/ecommerce/catalogo/catalogo.ts b/src/views/ecommerce/catalogo/catalogo.ts index 1b6815c7..eecc13b9 100755 --- a/src/views/ecommerce/catalogo/catalogo.ts +++ b/src/views/ecommerce/catalogo/catalogo.ts @@ -200,6 +200,10 @@ export default defineComponent({ return !!getCatalogoByMyPage.value }) + const showListaArgomenti = computed(() => { + return optcatalogo.value.showListaArgomenti + }) + // Register the scroll event on component mount const handleScroll = () => { const scrollTop = window.scrollY || document.documentElement.scrollTop; @@ -572,10 +576,14 @@ export default defineComponent({ // Se nel catalogo è stato già generato, allora gli passo quello. const trovatocatalogo = getCatalogoByMyPage.value - if (trovatocatalogo?.lista_prodotti.length === 0) { + if (optcatalogo.value.showListaArgomenti) { generalista = true } + /*if (trovatocatalogo?.lista_prodotti.length === 0) { + generalista = true + }*/ + if (!generalista && (trovatocatalogo?.lista_prodotti.length > 0)) { arrprod = trovatocatalogo?.lista_prodotti } else { @@ -604,7 +612,7 @@ export default defineComponent({ // console.log('arrprod', arrprod) populateDataWithlinkIdTemplate(); - generatearrProdToViewSorted(!generalista, salva); + generatearrProdToViewSorted(!generalista, salva, !optcatalogo.value.showListaArgomenti); loaddata(); refreshpage.value = false; @@ -754,7 +762,7 @@ export default defineComponent({ } } - function generatearrProdToViewSorted(usaprodottiSalvati?: boolean, salva?: boolean) { + function generatearrProdToViewSorted(usaprodottiSalvati?: boolean, salva?: boolean, salvasudb?: boolean) { console.log('generatearrProdToViewSorted... usaprodottiSalvati=', usaprodottiSalvati, ' salva=', salva) try { @@ -880,7 +888,9 @@ export default defineComponent({ if (trovatocatalogo) { trovatocatalogo.lista_prodotti = arrprod - salvaListaProdotti(false) + if (salvasudb) { + salvaListaProdotti(false) + } } } @@ -901,7 +911,7 @@ export default defineComponent({ } // Salva gli ID dei prodotti nel catalogo - tools.saveFieldToServer($q, 'catalogs', getCatalogoByMyPage.value._id, mydata, true, false) + tools.saveFieldToServer($q, 'catalogs', getCatalogoByMyPage.value._id, mydata, !optcatalogo.value.showListaArgomenti, false) if (ricarica) { @@ -1244,7 +1254,10 @@ export default defineComponent({ if (getCatalogoByMyPage.value) { getCatalogoByMyPage.value.lista_prodotti = [...arr] - salvaListaProdotti(true) + if (optcatalogo.value.showListaArgomenti) + salvaListaProdotti(true) + else + generatearrProdToViewSorted(true, false); } } @@ -1332,6 +1345,7 @@ export default defineComponent({ clickaddNewBook, addProductToList, addnewProd, + showListaArgomenti, } } }) diff --git a/src/views/ecommerce/catalogo/catalogo.vue b/src/views/ecommerce/catalogo/catalogo.vue index 3f5efd44..d0b860e8 100755 --- a/src/views/ecommerce/catalogo/catalogo.vue +++ b/src/views/ecommerce/catalogo/catalogo.vue @@ -62,7 +62,35 @@ name="lista" v-if="optcatalogo" > + +
+
+
+ {{ reccat.label }} +
+
+
+
+ {{ + t('ecomm.prodotti_trovati', { + qta: arrProducts.length, + qtatot: productStore.getNumProdTot(), + }) + }} +
+
+
-
- +
{{ reccat.label }} - - | + > + {{ reccat.label }} +
@@ -261,7 +287,7 @@