From 859ba022fa21d143bd13f96b91415d621ae5ccc0 Mon Sep 17 00:00:00 2001 From: Surya Paolo Date: Fri, 16 May 2025 18:52:12 +0200 Subject: [PATCH] =?UTF-8?q?-=20estrazione=20dei=20dati=20del=20libro=20sul?= =?UTF-8?q?=20sito=20di=20Amazon.=20-=20possibilit=C3=A0=20di=20visualizza?= =?UTF-8?q?re=20i=20dati=20estratti=20e=20di=20aggiornare=20i=20dati,=20si?= =?UTF-8?q?a=20solo=20se=20vuoti,=20che=20sovrascrivere=20tutti=20i=20dati?= =?UTF-8?q?.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .prettierrc | 2 +- src/components/CCatalogoCard/CCatalogoCard.ts | 663 ++++++++++-------- .../CCatalogoCard/CCatalogoCard.vue | 271 +++++-- src/components/CProductTable/CProductTable.ts | 6 + .../CSchedaProdotto/CSchedaProdotto.ts | 468 +++++++------ .../CSchedaProdotto/CSchedaProdotto.vue | 23 +- .../CSearchProduct/CSearchProduct.ts | 6 +- .../CTableCupleLabelValue.scss | 17 +- .../CTableCupleLabelValue.vue | 3 +- src/model/Products.ts | 1 + src/statics/lang/it.js | 7 +- src/store/Modules/fieldsTable.ts | 1 + src/store/Modules/tools.ts | 18 + src/store/Products.ts | 2 +- src/store/globalStore.ts | 597 ++++++++++++---- src/views/ecommerce/cash/cash.vue | 77 +- src/views/ecommerce/catalogo/catalogo.vue | 273 ++++++-- .../ecommerce/productsList/productsList.vue | 203 ++++-- 18 files changed, 1840 insertions(+), 798 deletions(-) diff --git a/.prettierrc b/.prettierrc index 73fd2486..3fb4af0b 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,6 +1,6 @@ { "singleAttributePerLine": true, - "printWidth": 60, + "printWidth": 80, "tabWidth": 2, "useTabs": false, "semi": true, diff --git a/src/components/CCatalogoCard/CCatalogoCard.ts b/src/components/CCatalogoCard/CCatalogoCard.ts index 9d790207..ad99b452 100755 --- a/src/components/CCatalogoCard/CCatalogoCard.ts +++ b/src/components/CCatalogoCard/CCatalogoCard.ts @@ -1,42 +1,53 @@ import type { PropType } from 'vue'; -import { defineComponent, ref, toRef, computed, watch, onMounted, reactive, onBeforeUnmount } from 'vue' -import { useI18n } from 'vue-i18n' -import { useUserStore } from '@store/UserStore' -import { useGlobalStore } from '@store/globalStore' -import { useQuasar } from 'quasar' +import { + defineComponent, + ref, + toRef, + computed, + watch, + onMounted, + reactive, + onBeforeUnmount, +} from 'vue'; +import { useI18n } from 'vue-i18n'; +import { useUserStore } from '@store/UserStore'; +import { useGlobalStore } from '@store/globalStore'; +import { useQuasar } from 'quasar'; -import { CTitleBanner } from '../CTitleBanner' -import { CCardState } from '../CCardState' -import { CCopyBtn } from '../CCopyBtn' -import { CViewTable } from '../CViewTable' -import { CMyValueDb } from '../CMyValueDb' -import { CPrice } from '../CPrice' -import { CText } from '../CText' -import { CLabel } from '@src/components/CLabel' -import { CSchedaProdotto } from '@src/components/CSchedaProdotto' -import { CModifTrafiletto } from '@src/components/CModifTrafiletto' +import { CTitleBanner } from '../CTitleBanner'; +import { CCardState } from '../CCardState'; +import { CCopyBtn } from '../CCopyBtn'; +import { CViewTable } from '../CViewTable'; +import { CMyValueDb } from '../CMyValueDb'; +import { CPrice } from '../CPrice'; +import { CText } from '../CText'; +import { CLabel } from '@src/components/CLabel'; +import { CSchedaProdotto } from '@src/components/CSchedaProdotto'; +import { CModifTrafiletto } from '@src/components/CModifTrafiletto'; -import { CBarCode } from '../CBarCode' -import { CTableCupleLabelValue } from '../CTableCupleLabelValue' +import { CBarCode } from '../CBarCode'; +import { CTableCupleLabelValue } from '../CTableCupleLabelValue'; -import { func_tools, toolsext } from '@store/Modules/toolsext' +import { func_tools, toolsext } from '@store/Modules/toolsext'; import type { - IOptCatalogo, IGasordine, IMyScheda, IOrder, IOrderCart, - IProduct, IVariazione, - IRecFields + IOptCatalogo, + IGasordine, + IMyScheda, + IOrder, + IOrderCart, + IProduct, + IVariazione, + IRecFields, } from '@src/model'; -import { - IBaseOrder -} from '@src/model' -import { tools } from '@tools' -import { useProducts } from '@store/Products' +import { IBaseOrder } from '@src/model'; +import { tools } from '@tools'; +import { useProducts } from '@store/Products'; -import { shared_consts } from '@src/common/shared_vuejs' -import { useRouter } from 'vue-router' - -import { costanti } from '@costanti' +import { shared_consts } from '@src/common/shared_vuejs'; +import { useRouter } from 'vue-router'; +import { costanti } from '@costanti'; export default defineComponent({ name: 'CCatalogoCard', @@ -65,7 +76,7 @@ export default defineComponent({ options: { type: Object, required: false, - default: () => { } + default: () => {}, }, modelValue: { type: Object as PropType, @@ -79,63 +90,75 @@ export default defineComponent({ scheda: { type: Object as PropType, required: false, - default: () => ({ - - }), + default: () => ({}), }, }, components: { - CTitleBanner, CCardState, CCopyBtn, CMyValueDb, CPrice, CBarCode, CLabel, - CText, CViewTable, CTableCupleLabelValue, CSchedaProdotto, CModifTrafiletto + CTitleBanner, + CCardState, + CCopyBtn, + CMyValueDb, + CPrice, + CBarCode, + CLabel, + CText, + CViewTable, + CTableCupleLabelValue, + CSchedaProdotto, + CModifTrafiletto, }, setup(props, { emit }) { - const $q = useQuasar() - const { t } = useI18n() - const userStore = useUserStore() - const globalStore = useGlobalStore() - const products = useProducts() + const $q = useQuasar(); + const { t } = useI18n(); + const userStore = useUserStore(); + const globalStore = useGlobalStore(); + const products = useProducts(); - const listord = ref([]) - const sumval = ref(0) - const loading = ref(false) + const listord = ref([]); + const sumval = ref(0); + const loading = ref(false); - const indvariazSel = ref(-1) + const indvariazSel = ref(-1); - const site = ref(globalStore.site) + const site = ref(globalStore.site); - const arrlistScheda = ref([]) + const arrlistScheda = ref([]); + const $router = useRouter(); - const $router = useRouter() + const fullscreenImage = ref(null); - const fullscreenImage = ref(null) - - const apriSchedaPDF = ref(false) - const visufromgm = ref(false) - const updatefromgm = ref(false) - const updatetogm = ref(false) - const showQtaDisponibile = ref(false) - const field_updated_fromGM = ref('') + const apriSchedaPDF = ref(false); + const visufromgm = ref(false); + const visudataextracted = ref(false); + const updatefromgm = ref(false); + const updatetogm = ref(false); + const showQtaDisponibile = ref(false); + const field_updated_fromGM = ref(''); + const dataextractedWeb = ref(''); // Crea una copia locale reattiva di modelValue const optcatalogo = ref({ ...props.modelValue }); const editOn = computed({ get(): boolean { - return globalStore.editOn ? globalStore.editOn : false + return globalStore.editOn ? globalStore.editOn : false; }, set(value: boolean) { - return tools.updateEditOn(value) - } - }) + return tools.updateEditOn(value); + }, + }); // Watcher per sincronizzare le modifiche di modelValue - watch(() => props.modelValue, (newVal) => { - optcatalogo.value = { ...newVal }; - // updateCatalogoPadre() - }, { deep: false }); - + watch( + () => props.modelValue, + (newVal) => { + optcatalogo.value = { ...newVal }; + // updateCatalogoPadre() + }, + { deep: false } + ); function updateCatalogoPadre() { emit('update:modelValue', optcatalogo.value); @@ -144,7 +167,7 @@ export default defineComponent({ // Metodo per aggiornare il valore del catalogo const updateCatalogo = (updatedCatalogo: IOptCatalogo) => { optcatalogo.value = updatedCatalogo; // Aggiorna la copia locale - updateCatalogoPadre() + updateCatalogoPadre(); }; const myorder = reactive({ @@ -155,69 +178,69 @@ export default defineComponent({ idGasordine: '', storehouse: {}, gasordine: { active: false }, - }) + }); - const storeSelected = ref('') - const arrordersCart = ref([]) - const modifOn = ref(false) - const modifTrafiletto = ref(false) - const modifProd = ref(false) + const storeSelected = ref(''); + const arrordersCart = ref([]); + const modifOn = ref(false); + const modifTrafiletto = ref(false); + const modifProd = ref(false); - const timerInterval = ref(null) - const timerLabelScadenza = ref('') - const labelDataRitiro = ref('') - const labelDataArrivoMerce = ref('') + const timerInterval = ref(null); + const timerLabelScadenza = ref(''); + const labelDataRitiro = ref(''); + const labelDataArrivoMerce = ref(''); - const openlistorders = ref(false) - const endload = ref(false) - const myproduct = ref({}) + const openlistorders = ref(false); + const endload = ref(false); + const myproduct = ref({}); - const isFullScreen = ref(false) - const imageSrc = ref('URL_DEL_TUO_FILE_IMMAGINE') - const startX = ref(0) - const startY = ref(0) - const scale = ref(1) + const isFullScreen = ref(false); + const imageSrc = ref('URL_DEL_TUO_FILE_IMMAGINE'); + const startX = ref(0); + const startY = ref(0); + const scale = ref(1); const getTesto_Right = computed(() => { return products.replaceKeyWordsByProduct( optcatalogo.value, myproduct.value!, props.scheda.testo_right!, - props.idPage, - ) - }) + props.idPage + ); + }); const getTesto_Right_attaccato = computed(() => { return products.replaceKeyWordsByProduct( optcatalogo.value, myproduct.value!, props.scheda.testo_right_attaccato!, - props.idPage, - ) - }) + props.idPage + ); + }); const getTesto_Debug = computed(() => { return products.replaceKeyWordsByProduct( optcatalogo.value, myproduct.value!, { contenuto: '{debug}', maxlength: 10000 }, - props.idPage, - ) - }) + props.idPage + ); + }); const getTesto_Bottom = computed(() => { return products.replaceKeyWordsByProduct( optcatalogo.value, myproduct.value!, props.scheda.testo_bottom!, - props.idPage, - ) - }) - - - watch(() => editOn.value, (to: any, from: any) => { - if (!editOn.value) - ricarica() - }) + props.idPage + ); + }); + watch( + () => editOn.value, + (to: any, from: any) => { + if (!editOn.value) ricarica(); + } + ); /*const myproduct = computed((): IProduct => { console.log('getproduct computed') @@ -226,23 +249,26 @@ export default defineComponent({ return ris })*/ - function iconWhishlist(order: IProduct) { - return 'fas fa-heart' + return 'fas fa-heart'; } async function addtoCart(add: boolean) { - if (!userStore.isLogged) { - tools.showNeutralNotif($q, t('ecomm.area_personale')) - globalStore.rightDrawerOpen = true - return false + tools.showNeutralNotif($q, t('ecomm.area_personale')); + globalStore.rightDrawerOpen = true; + return false; } if (myproduct.value) { - const ris = await products.addtoCartBase({ $q, t, id: myproduct.value._id, order: myorder, addqty: add }) - updateproduct(false) + const ris = await products.addtoCartBase({ + $q, + t, + id: myproduct.value._id, + order: myorder, + addqty: add, + }); + updateproduct(false); if (ris && ris.myord) { - } } } @@ -250,179 +276,178 @@ export default defineComponent({ function getnumstore() { if (myproduct.value) { if (myproduct.value.storehouses) - return myproduct.value.storehouses.length - else - return 0 + return myproduct.value.storehouses.length; + else return 0; } - return 0 + return 0; } function getSingleStorehouse() { try { - if (!myproduct.value) - return '' + if (!myproduct.value) return ''; - const mystore = myproduct.value.storehouses[0] - if (mystore) - return mystore.name + ' (' + mystore.city + ')' - else - return '' + const mystore = myproduct.value.storehouses[0]; + if (mystore) return mystore.name + ' (' + mystore.city + ')'; + else return ''; } catch (e) { - return '' + return ''; } } function getSingleGasordine(gasordine: IGasordine) { try { - const mygas = gasordine + const mygas = gasordine; if (mygas) /*return mygas.name + ' (' + mygas.city + ') ' + t('gas.dataora_chiusura_ordini') + ': ' + tools.getstrDateShort(mygas.dataora_chiusura_ordini) + ' ' + t('gas.data_arrivo_merce') + ': ' + tools.getstrDateShort(mygas.data_arrivo_merce) + ' ' + t('gas.dataora_ritiro') + ': ' + tools.getstrDateShort(mygas.dataora_ritiro)*/ - return mygas.name - else - return '' + return mygas.name; + else return ''; } catch (e) { - return '' + return ''; } } function initproduct() { - - myorder.quantity = 0 - myorder.quantitypreordered = 0 - myorder.idStorehouse = '' - myorder.idGasordine = '' - + myorder.quantity = 0; + myorder.quantitypreordered = 0; + myorder.idStorehouse = ''; + myorder.idGasordine = ''; } async function updateproduct(atload: boolean, forza?: boolean) { - - let carica = true + let carica = true; if (atload) { if (props.product) { - myproduct.value = props.product - carica = false + myproduct.value = props.product; + carica = false; } } else { } if (carica) { myproduct.value = null; - updateproductmodif(null, forza) + updateproductmodif(null, forza); } // products.updateQuantityAvailable(myproduct.value._id) } async function ricarica() { - endload.value = false + endload.value = false; if (myproduct.value) { - const prod = await products.loadProductById(myproduct.value._id) + const prod = await products.loadProductById(myproduct.value._id); if (prod) { - myproduct.value = prod + myproduct.value = prod; } } - await load() - + await load(); } async function updateproductmodif(element: any, forza?: boolean) { - console.log('CCATALOGOCARD: updateproductmodif') + console.log('CCATALOGOCARD: updateproductmodif'); try { if (element?._id) { - myproduct.value = await products.getProductById(element?._id, forza) + myproduct.value = await products.getProductById(element?._id, forza); } else { - myproduct.value = await products.getProductById(props.id, forza) + myproduct.value = await products.getProductById(props.id, forza); } - updateLabel() + updateLabel(); } catch (e) { - console.error('err', e) + console.error('err', e); } } function getStorehouses() { - if (!myproduct.value) - return [] + if (!myproduct.value) return []; - const myarr: any = [] - let ind = 1 + const myarr: any = []; + let ind = 1; myproduct.value.storehouses.forEach((store) => { - myarr.push( - { - id: ind, - label: store.name + ' (' + store.city + ')', - value: store._id - }) + myarr.push({ + id: ind, + label: store.name + ' (' + store.city + ')', + value: store._id, + }); - ind++ - }) + ind++; + }); // console.log('arraystore', myarr) - return myarr + return myarr; } function checkifCartDisable() { // return !myorder.idStorehouse - return isOrdineChiuso() + return isOrdineChiuso(); } function checkifCartEnable() { - return false + return false; } function getQtyWarn() { if (myorder.quantity > 0) { - return t('ecomm.di_cui_x_in_carrello', { qty: myorder.quantity }) + return t('ecomm.di_cui_x_in_carrello', { qty: myorder.quantity }); } - return '' + return ''; } function getQtyWarnPreOrdered() { if (myorder.quantitypreordered > 0) { - return t('ecomm.di_cui_x_in_carrello', { qty: myorder.quantitypreordered }) + return t('ecomm.di_cui_x_in_carrello', { + qty: myorder.quantitypreordered, + }); } - return '' + return ''; } - watch(() => props.id, async (newval, oldval) => { - // console.log('change code') - await load() - }) + watch( + () => props.id, + async (newval, oldval) => { + // console.log('change code') + await load(); + } + ); - watch(() => storeSelected.value, (newval, oldval) => { - myorder.idStorehouse = newval - }) + watch( + () => storeSelected.value, + (newval, oldval) => { + myorder.idStorehouse = newval; + } + ); function updateLabel() { - let dataArrivoMerce = '' - let dataRitiro = '' + let dataArrivoMerce = ''; + let dataRitiro = ''; try { if (myproduct.value && myproduct.value.gasordine) { if (myproduct.value.gasordine.data_arrivo_merce) - dataArrivoMerce = tools.getstrDateShort(myproduct.value.gasordine.data_arrivo_merce) + dataArrivoMerce = tools.getstrDateShort( + myproduct.value.gasordine.data_arrivo_merce + ); if (myproduct.value.gasordine.dataora_ritiro) - dataRitiro = tools.getstrDateTime(myproduct.value.gasordine.dataora_ritiro) + dataRitiro = tools.getstrDateTime( + myproduct.value.gasordine.dataora_ritiro + ); } else { - dataArrivoMerce = '' - dataRitiro = '' + dataArrivoMerce = ''; + dataRitiro = ''; } - } catch (e) { - - } + } catch (e) {} if (labelDataArrivoMerce.value !== dataArrivoMerce) - labelDataArrivoMerce.value = dataArrivoMerce + labelDataArrivoMerce.value = dataArrivoMerce; if (labelDataRitiro.value !== dataRitiro) - labelDataRitiro.value = dataRitiro + labelDataRitiro.value = dataRitiro; - updateTimerLabel() + updateTimerLabel(); } async function mounted() { - await load() + await load(); // Start the timer when the component is mounted startTimer(); @@ -434,18 +459,28 @@ export default defineComponent({ } function updateTimerLabel() { - if (myproduct.value && (myproduct.value.gasordine && myproduct.value.gasordine._id && myproduct.value.gasordine.dataora_chiusura_ordini)) - timerLabelScadenza.value = tools.getCountDown(myproduct.value.gasordine.dataora_chiusura_ordini) - else - timerLabelScadenza.value = '' + if ( + myproduct.value && + myproduct.value.gasordine && + myproduct.value.gasordine._id && + myproduct.value.gasordine.dataora_chiusura_ordini + ) + timerLabelScadenza.value = tools.getCountDown( + myproduct.value.gasordine.dataora_chiusura_ordini + ); + else timerLabelScadenza.value = ''; } function isOrdineChiuso() { if (myproduct.value) { - return myproduct.value.gasordine && myproduct.value.gasordine.dataora_chiusura_ordini && - tools.getCountDown(myproduct.value.gasordine.dataora_chiusura_ordini) === '' - } else - return false + return ( + myproduct.value.gasordine && + myproduct.value.gasordine.dataora_chiusura_ordini && + tools.getCountDown( + myproduct.value.gasordine.dataora_chiusura_ordini + ) === '' + ); + } else return false; } function startTimer() { @@ -454,93 +489,112 @@ export default defineComponent({ } async function load() { - indvariazSel.value = -1 - initproduct() - await updateproduct(true, true) - labelDataArrivoMerce.value = '' - labelDataRitiro.value = '' + indvariazSel.value = -1; + initproduct(); + await updateproduct(true, true); + labelDataArrivoMerce.value = ''; + labelDataRitiro.value = ''; // console.log('Load', myproduct.value.name) if (myproduct.value) { - arrordersCart.value = products.getOrdersCartInAttesaByIdProduct(myproduct.value._id) + arrordersCart.value = products.getOrdersCartInAttesaByIdProduct( + myproduct.value._id + ); - if (myproduct.value.storehouses && myproduct.value.storehouses.length === 1) { + if ( + myproduct.value.storehouses && + myproduct.value.storehouses.length === 1 + ) { // Se solo 1 presente, metto fisso l'unico negozio ! - myorder.idStorehouse = myproduct.value.storehouses[0]._id + myorder.idStorehouse = myproduct.value.storehouses[0]._id; } if (myproduct.value.gasordine) { - myorder.idGasordine = myproduct.value.gasordine._id + myorder.idGasordine = myproduct.value.gasordine._id; } - const ord = products.getOrderProductInCart(myproduct.value._id) + const ord = products.getOrderProductInCart(myproduct.value._id); if (ord) { - myorder.quantity = ord.quantity - myorder.quantitypreordered = ord.quantitypreordered + myorder.quantity = ord.quantity; + myorder.quantitypreordered = ord.quantitypreordered; // Seleziona il Negozio che avevo già scelto nell'ordine ! - if (ord.idStorehouse) - storeSelected.value = ord.idStorehouse - + if (ord.idStorehouse) storeSelected.value = ord.idStorehouse; } } - updateLabel() + updateLabel(); // console.log('myproduct', myproduct.value, 'arrvariaz', myproduct.value.arrvariazioni, 'compl', props.complete) if (props.complete && myproduct.value && myproduct.value.arrvariazioni) { // console.log('ENTRATO') - indvariazSel.value = 0 + indvariazSel.value = 0; } - // console.log('°°° ENDLOAD °°°') - endload.value = true + endload.value = true; } function getclimgproduct() { - return 'myimgproduct centermydiv' + return 'myimgproduct centermydiv'; } - function visuListDisponibili() { if (myproduct.value) { - openlistorders.value = true - sumval.value = products.getSumQtyOrderProductInOrdersCart(myproduct.value._id) + openlistorders.value = true; + sumval.value = products.getSumQtyOrderProductInOrdersCart( + myproduct.value._id + ); - listord.value = arrordersCart.value.filter((orderscart: IOrderCart) => orderscart.items!.reduce((accumulator, item) => { - return accumulator + item.order.quantity - }, 0)) - } else - return false + listord.value = arrordersCart.value.filter((orderscart: IOrderCart) => + orderscart.items!.reduce((accumulator, item) => { + return accumulator + item.order.quantity; + }, 0) + ); + } else return false; } function visuListBookable() { if (myproduct.value) { - openlistorders.value = true - sumval.value = products.getSumQtyPreOrderInOrdersCart(myproduct.value._id) + openlistorders.value = true; + sumval.value = products.getSumQtyPreOrderInOrdersCart( + myproduct.value._id + ); - listord.value = arrordersCart.value.filter((orderscart: IOrderCart) => orderscart.items!.reduce((accumulator, item) => { - return accumulator + item.order.quantitypreordered - }, 0)) + listord.value = arrordersCart.value.filter((orderscart: IOrderCart) => + orderscart.items!.reduce((accumulator, item) => { + return accumulator + item.order.quantitypreordered; + }, 0) + ); } else { - return '' + return ''; } } function isOrdGas(): boolean { if (myproduct.value) - return (myproduct.value && !!myproduct.value.idGasordine && myproduct.value.gasordine! && myproduct.value.gasordine.active) - else - return false + return ( + myproduct.value && + !!myproduct.value.idGasordine && + myproduct.value.gasordine! && + myproduct.value.gasordine.active + ); + else return false; } function getpercqtaraggiunta(): number { if (myproduct.value) - return tools.calcperc((myproduct.value.bookableGASBloccatiQty + myproduct.value.QuantitaPrenotateInAttesa!) * myproduct.value.productInfo.weight!, myproduct.value.qtyToReachForGas * myproduct.value.productInfo.weight!) / 100 - else - return 0 + return ( + tools.calcperc( + (myproduct.value.bookableGASBloccatiQty + + myproduct.value.QuantitaPrenotateInAttesa!) * + myproduct.value.productInfo.weight!, + myproduct.value.qtyToReachForGas * + myproduct.value.productInfo.weight! + ) / 100 + ); + else return 0; } function toggleFullScreen() { @@ -579,34 +633,35 @@ export default defineComponent({ } function naviga(path: string) { - $router.push(path) + $router.push(path); } function setvariazioneSelected(indvariaz: number) { - if (indvariazSel.value === indvariaz) - indvariazSel.value = -1 + if (indvariazSel.value === indvariaz) indvariazSel.value = -1; else { - indvariazSel.value = -1 - indvariazSel.value = indvariaz + indvariazSel.value = -1; + indvariazSel.value = indvariaz; } } function click_author(id: any, autore: any) { - emit('selauthor', id, autore) + emit('selauthor', id, autore); } function click_opendetail() { - if (!optcatalogo.value.pdf) - emit('opendetail') + if (!optcatalogo.value.pdf) emit('opendetail'); } function escludiArticolo(variazione: IVariazione) { - const hasExcludeProductTypes = !optcatalogo.value.excludeproductTypes || (optcatalogo.value.excludeproductTypes && (optcatalogo.value.excludeproductTypes.includes(variazione.versione!))) + const hasExcludeProductTypes = + !optcatalogo.value.excludeproductTypes || + (optcatalogo.value.excludeproductTypes && + optcatalogo.value.excludeproductTypes.includes(variazione.versione!)); - return hasExcludeProductTypes + return hasExcludeProductTypes; } function checkIfVariazioneDaVisu(variazione: IVariazione) { - return !escludiArticolo(variazione) + return !escludiArticolo(variazione); } function isProductNovita() { @@ -624,27 +679,25 @@ export default defineComponent({ return publishingDate > monthsAgoDate; } function isProductBestseller() { - try { if (props.scheda.etichette?.bestseller?.show) { // diventa un bestseller quando il numero di fatturati Annuali è superiore a - const numfatturati = props.scheda.etichette?.bestseller?.quantiFattRaggiunti ?? 50; + const numfatturati = + props.scheda.etichette?.bestseller?.quantiFattRaggiunti ?? 50; - return myproduct.value!.productInfo.fatLast6M > numfatturati + return myproduct.value!.productInfo.fatLast6M > numfatturati; } } catch (e) { - return false + return false; } - return false - + return false; } function getScale() { if (optcatalogo.value.printable) - return optcatalogo.value.areadistampa!.scale_printable - else - return optcatalogo.value.areadistampa!.scale + return optcatalogo.value.areadistampa!.scale_printable; + else return optcatalogo.value.areadistampa!.scale; } /*async function refreshDataFromGM() { @@ -685,38 +738,91 @@ export default defineComponent({ async function refreshSingleBookFromGM(options: any) { if (myproduct.value) { - loading.value = true - updatefromgm.value = true - field_updated_fromGM.value = '' - const ris = await globalStore.updateAllBookFromGM_T_Web_Articoli({ sku: myproduct.value.productInfo.sku!, isbn: myproduct.value.productInfo.code, ...options }) + loading.value = true; + updatefromgm.value = true; + field_updated_fromGM.value = ''; + const ris = await globalStore.updateAllBookFromGM_T_Web_Articoli({ + sku: myproduct.value.productInfo.sku!, + isbn: myproduct.value.productInfo.code, + ...options, + }); if (ris) { // field_updated_fromGM.value = t('dbgm.updateLocalDb_OK') if (ris.error) { - tools.showNegativeNotif($q, ris.error) + tools.showNegativeNotif($q, ris.error); } else { - - await updateproduct(false, false) - tools.showPositiveNotif($q, t('dbgm.updateLocalDb_OK')) + await updateproduct(false, false); + tools.showPositiveNotif($q, t('dbgm.updateLocalDb_OK')); } - updatefromgm.value = false + updatefromgm.value = false; } - loading.value = false + loading.value = false; } - } async function refreshFieldFromGM(field: string) { if (myproduct.value) { - loading.value = true - updatefromgm.value = true - field_updated_fromGM.value = '' - field_updated_fromGM.value = await globalStore.getGM_FieldOf_T_Web_Articoli(myproduct.value.productInfo.sku!, field, shared_consts.CmdQueryMs.GET) - loading.value = false + loading.value = true; + updatefromgm.value = true; + field_updated_fromGM.value = ''; + field_updated_fromGM.value = + await globalStore.getGM_FieldOf_T_Web_Articoli( + myproduct.value.productInfo.sku!, + field, + shared_consts.CmdQueryMs.GET + ); + loading.value = false; } } - onMounted(mounted) - onBeforeUnmount(beforeDestroy) + async function scrapingBook(update: boolean, aggiornasoloSeVuoti: boolean) { + const options = { + update, + aggiornasoloSeVuoti, + }; + const myparam = { product_id: myproduct.value._id, options }; + + loading.value = true; + + const dataupdated = await globalStore + .scrapingBook(myparam) + .then((dataupdated) => { + if (dataupdated) { + tools.showPositiveNotif($q, t('dbgm.scrapingOkUpdated')); + } + return dataupdated; + }) + .catch((e) => { + console.error('Errore aggiornamento singolo libro:', e); + tools.showNegativeNotif($q, t('dbgm.updateLocalDb_ERROR')); + loading.value = false; + }); + loading.value = false; + + return dataupdated; + } + + async function getDataExtracted() { + + visudataextracted.value = true; + loading.value = true; + + dataextractedWeb.value = '... caricamento in corso...'; + + try { + const data = await scrapingBook(false); + const html = tools.generateHtmlTableFromObject(data); + dataextractedWeb.value = html; + } catch (error) { + console.error('Errore durante l\'estrazione dei dati:', error); + dataextractedWeb.value = 'Errore nel caricamento dei dati.'; + } finally { + loading.value = false; + } + } + + onMounted(mounted); + onBeforeUnmount(beforeDestroy); return { visuListDisponibili, @@ -783,16 +889,19 @@ export default defineComponent({ updateCatalogo, optcatalogo, visufromgm, + visudataextracted, updatefromgm, showQtaDisponibile, field_updated_fromGM, refreshFieldFromGM, updatetogm, + dataextractedWeb, // refreshDataFromGM, // refreshAllDataBookFromGM, refreshSingleBookFromGM, loading, modifTrafiletto, - } - } -}) + getDataExtracted, + }; + }, +}); diff --git a/src/components/CCatalogoCard/CCatalogoCard.vue b/src/components/CCatalogoCard/CCatalogoCard.vue index f1e4947c..48f7d67e 100755 --- a/src/components/CCatalogoCard/CCatalogoCard.vue +++ b/src/components/CCatalogoCard/CCatalogoCard.vue @@ -7,7 +7,10 @@ :style=" scheda.dimensioni?.pagina?.dimensioni?.size?.height ? ' height: ' + - tools.adjustSize(optcatalogo, scheda.dimensioni?.pagina?.dimensioni?.size?.height) + + tools.adjustSize( + optcatalogo, + scheda.dimensioni?.pagina?.dimensioni?.size?.height + ) + 'px !important; ' : '' " @@ -51,12 +54,26 @@ 'flex', // Classi comuni 'image-container', { 'shadow-2': options.in_3d && !optcatalogo.pdf }, // Classe condizionale - scheda.testo_right_attaccato.font?.posiz_text === costanti.POSIZ_TESTO.IN_BASSO ? '' : 'flex flex-row', // Layout flessibile + scheda.testo_right_attaccato.font?.posiz_text === + costanti.POSIZ_TESTO.IN_BASSO + ? '' + : 'flex flex-row', // Layout flessibile ]" :style="{ - gap: tools.adjustSize(optcatalogo, scheda.dimensioni?.scheda_prodotto?.size?.gap) ?? '0.1rem', - width: tools.adjustSize(optcatalogo, scheda.dimensioni?.scheda_prodotto?.size?.width) ?? '100%', - height: tools.adjustSize(optcatalogo, scheda.dimensioni?.scheda_prodotto?.size?.height), + gap: + tools.adjustSize( + optcatalogo, + scheda.dimensioni?.scheda_prodotto?.size?.gap + ) ?? '0.1rem', + width: + tools.adjustSize( + optcatalogo, + scheda.dimensioni?.scheda_prodotto?.size?.width + ) ?? '100%', + height: tools.adjustSize( + optcatalogo, + scheda.dimensioni?.scheda_prodotto?.size?.height + ), }" >
@@ -68,11 +85,16 @@ v-if="myproduct.productInfo" :src=" myproduct.productInfo.imagefile - ? tools.getFullFileNameByImageFile('productInfos', myproduct.productInfo.imagefile) + ? tools.getFullFileNameByImageFile( + 'productInfos', + myproduct.productInfo.imagefile + ) : myproduct.productInfo.image_link " :alt="myproduct.productInfo.name" - :fit="scheda.dimensioni?.immagine_prodotto?.size?.fit ?? 'cover'" + :fit=" + scheda.dimensioni?.immagine_prodotto?.size?.fit ?? 'cover' + " :class="{ 'book-image-fixed': complete, 'cursor-pointer': !complete, @@ -82,15 +104,25 @@ :style="{ zIndex: 2, width: - scheda.testo_right.font?.posiz_text === costanti.POSIZ_TESTO.IN_BASSO + scheda.testo_right.font?.posiz_text === + costanti.POSIZ_TESTO.IN_BASSO ? (scheda.testo_right.font?.perc_text ?? '50%') : '45%', - ...(tools.adjustSize(optcatalogo, scheda.dimensioni?.immagine_prodotto?.size?.width) && { + ...(tools.adjustSize( + optcatalogo, + scheda.dimensioni?.immagine_prodotto?.size?.width + ) && { width: - tools.adjustSize(optcatalogo, scheda.dimensioni?.immagine_prodotto.size?.width) + ' !important', + tools.adjustSize( + optcatalogo, + scheda.dimensioni?.immagine_prodotto.size?.width + ) + ' !important', }), height: scheda.dimensioni?.immagine_prodotto?.size?.height - ? tools.adjustSize(optcatalogo, scheda.dimensioni?.immagine_prodotto?.size?.height) + ? tools.adjustSize( + optcatalogo, + scheda.dimensioni?.immagine_prodotto?.size?.height + ) : undefined, display: 'block', }" @@ -179,7 +211,10 @@ --> Visualizza su GM + + + + + + Visualizza dati Estrapolati (dal WEB + Esterno) + +
@@ -840,9 +953,13 @@ optcatalogo.last_page.text_html && optcatalogo.last_page.text_html.contenuto " - :style="generateStyleByPageDim(optcatalogo, optcatalogo.last_page)" + :style=" + generateStyleByPageDim(optcatalogo, optcatalogo.last_page) + " > -
+
@@ -854,14 +971,18 @@
Sfondo: {{ - tools.getDirUpload() + costanti.DIR_CATALOGO + optcatalogo.dimensioni_def?.pagina.imgsfondo?.imagefile + tools.getDirUpload() + + costanti.DIR_CATALOGO + + optcatalogo.dimensioni_def?.pagina.imgsfondo?.imagefile }}
@@ -871,17 +992,37 @@
Prima Pagina: - {{ tools.getDirUpload() + costanti.DIR_CATALOGO + optcatalogo.first_page.imgsfondo.imagefile }} + {{ + tools.getDirUpload() + + costanti.DIR_CATALOGO + + optcatalogo.first_page.imgsfondo.imagefile + }}
- +
Ultima Pagina: - {{ tools.getDirUpload() + costanti.DIR_CATALOGO + optcatalogo.last_page.imgsfondo.imagefile }} + {{ + tools.getDirUpload() + + costanti.DIR_CATALOGO + + optcatalogo.last_page.imgsfondo.imagefile + }}
- +
diff --git a/src/views/ecommerce/productsList/productsList.vue b/src/views/ecommerce/productsList/productsList.vue index 015bcd1f..4756cd11 100755 --- a/src/views/ecommerce/productsList/productsList.vue +++ b/src/views/ecommerce/productsList/productsList.vue @@ -1,12 +1,22 @@ - +