diff --git a/__inizia.sh b/__inizia.sh index aea4bfdb..1694b4fb 100644 --- a/__inizia.sh +++ b/__inizia.sh @@ -33,9 +33,11 @@ else rm -R ./public/upload/products/* rm -R ./public/upload/pages/* rm -R ./public/upload/catalogo/* + rm -R ./public/upload/scheda/* cp -R _ALL_SITES/$site/upload/products/* ./public/upload/products/ cp -R _ALL_SITES/$site/upload/pages/* ./public/upload/pages/ cp -R _ALL_SITES/$site/upload/catalogo/* ./public/upload/catalogo/ + cp -R _ALL_SITES/$site/upload/scheda/* ./public/upload/scheda/ rm -R ./public/images/* cp -R _ALL_SITES/$site/images/* ./public/images/ diff --git a/public/images/bestseller.png b/public/images/bestseller.png new file mode 100644 index 00000000..c48abeac Binary files /dev/null and b/public/images/bestseller.png differ diff --git a/public/images/novita.png b/public/images/novita.png new file mode 100644 index 00000000..0b54ec7d Binary files /dev/null and b/public/images/novita.png differ diff --git a/src/common/shared_vuejs.ts b/src/common/shared_vuejs.ts index e08669af..e0178c44 100755 --- a/src/common/shared_vuejs.ts +++ b/src/common/shared_vuejs.ts @@ -379,6 +379,8 @@ export const shared_consts = { PRODUCTS_V2: 22, INVENTARIO: 30, MACRO_CATALOGO_JSON: 40, + MACRO_RANKING: 50, + MACRO_DESCRELINKSITOWEB: 60, }, BotType: [ @@ -2229,6 +2231,25 @@ export const shared_consts = { PRODUCT: 1000, }, + ORDINAMENTO_CATALOGHI: [ + { + label: '[Default]', + value: 0, + }, + { + label: 'Data di Uscita', + value: 1, + }, + { + label: 'Bestseller', + value: 2, + }, + { + label: 'Alfabetico', + value: 0, + }, + ], + VERSIONI_PRODOTTO: [ { label: '[Nessuno]', diff --git a/src/components/CCatalogoCard/CCatalogoCard.ts b/src/components/CCatalogoCard/CCatalogoCard.ts index 4fc5a6e5..695311eb 100755 --- a/src/components/CCatalogoCard/CCatalogoCard.ts +++ b/src/components/CCatalogoCard/CCatalogoCard.ts @@ -74,7 +74,7 @@ export default defineComponent({ type: Object as PropType, required: false, default: () => ({ - + }), }, }, @@ -160,7 +160,7 @@ export default defineComponent({ if (myproduct.value) { const ris = await products.addtoCartBase({ $q, t, id: myproduct.value._id, order: myorder, addqty: add }) - updateproduct() + updateproduct(false) if (ris && ris.myord) { } @@ -217,10 +217,22 @@ export default defineComponent({ } - async function updateproduct() { + async function updateproduct(atload: boolean) { - myproduct.value = null; - myproduct.value = await products.getProductById(props.id) + let carica = true + + if (atload) { + if (props.product) { + myproduct.value = props.product + carica = false + } + } else { + } + + if (carica) { + myproduct.value = null; + myproduct.value = await products.getProductById(props.id) + } // products.updateQuantityAvailable(myproduct.value._id) } @@ -325,7 +337,7 @@ export default defineComponent({ updateTimerLabel() } - async function mounted() { + async function mounted() { await load() // Start the timer when the component is mounted @@ -360,7 +372,7 @@ export default defineComponent({ async function load() { indvariazSel.value = -1 initproduct() - await updateproduct() + await updateproduct(true) labelDataArrivoMerce.value = '' labelDataRitiro.value = '' @@ -512,6 +524,31 @@ export default defineComponent({ return !escludiArticolo(variazione) } + function isProductNovita() { + const monthsAgo = props.scheda.etichette?.novita?.months ?? 6; // Numero di mesi da considerare "recenti" + + const publishingDate = new Date(myproduct.value!.productInfo.date_publishing!); + + // Calcola i millisecondi corrispondenti a X mesi fa + const monthsInMilliseconds = monthsAgo * 30 * 24 * 60 * 60 * 1000; // Approssimazione, non tutti i mesi hanno 30 giorni + + // Crea una data che rappresenta X mesi fa + const monthsAgoDate = new Date(tools.getTimeNow() - monthsInMilliseconds); + + // Confronta la data di pubblicazione con la data X mesi fa + return publishingDate > monthsAgoDate; + } + function isProductBestseller() { + + try { + //return myproduct.value!.productInfo.rank1Y! > 0 && (myproduct.value!.productInfo.rank1Y! < props.scheda.etichette?.bestseller?.primiNInClassifica!) + return myproduct.value!.indiceRanking! > 0 && (myproduct.value!.indiceRanking! < props.scheda.etichette?.bestseller?.primiNInClassifica!) + } catch (e) { + return false + } + + } + onMounted(mounted) onBeforeUnmount(beforeDestroy) @@ -568,6 +605,8 @@ export default defineComponent({ click_author, click_opendetail, checkIfVariazioneDaVisu, + isProductNovita, + isProductBestseller, } } }) diff --git a/src/components/CCatalogoCard/CCatalogoCard.vue b/src/components/CCatalogoCard/CCatalogoCard.vue index b898842a..4e7e892b 100755 --- a/src/components/CCatalogoCard/CCatalogoCard.vue +++ b/src/components/CCatalogoCard/CCatalogoCard.vue @@ -76,13 +76,15 @@ 'flex', // Classi comuni 'image-container', { 'shadow-2': options.in_3d }, // Classe condizionale - scheda.posiz_text === costanti.POSIZ_TESTO.IN_BASSO + scheda.testo_right.font?.posiz_text === + costanti.POSIZ_TESTO.IN_BASSO ? 'flex-col' : 'flex-row', // Layout flessibile ]" :style="{ justifyContent: - scheda.posiz_text === costanti.POSIZ_TESTO.IN_BASSO + scheda.testo_right.font?.posiz_text === + costanti.POSIZ_TESTO.IN_BASSO ? 'center' : 'flex-start', alignItems: 'stretch', // Cambiato in 'stretch' per occupare l'altezza @@ -113,6 +115,7 @@ : myproduct.productInfo.image_link " :alt="myproduct.productInfo.name" + :fit="scheda.dimensioni?.immagine_prodotto?.size?.fit ?? 'cover'" :class="{ 'book-image-fixed': complete, 'cursor-pointer': !complete, @@ -120,10 +123,11 @@ 'image-wrapper': optcatalogo.pdf, }" :style="{ - zIndex: 9000, + zIndex: 2, width: - scheda.posiz_text === costanti.POSIZ_TESTO.IN_BASSO - ? '50%' + scheda.testo_right.font?.posiz_text === + costanti.POSIZ_TESTO.IN_BASSO + ? scheda.testo_right.font?.perc_text ?? '50%' : '45%', ...(tools.adjustSize( optcatalogo, @@ -135,6 +139,12 @@ scheda.dimensioni?.immagine_prodotto.size?.width ) + ' !important', }), + height: scheda.dimensioni?.immagine_prodotto?.size?.height + ? tools.adjustSize( + optcatalogo, + scheda.dimensioni?.immagine_prodotto?.size?.height + ) + : undefined, display: 'block', }" @click="click_opendetail()" @@ -143,12 +153,14 @@
-
- - +
+
+ + +
+
+ +
+
+ +
@@ -200,28 +240,7 @@
- -
-
diff --git a/src/components/CMyEditElem/CMyEditElem.ts b/src/components/CMyEditElem/CMyEditElem.ts index 3d2fa4ba..7826e61a 100755 --- a/src/components/CMyEditElem/CMyEditElem.ts +++ b/src/components/CMyEditElem/CMyEditElem.ts @@ -26,6 +26,7 @@ import { CSelectFontSize } from '@src/components/CSelectFontSize' import { CMySize } from '@src/components/CMySize' import { CBorders } from '@src/components/CBorders' import { CMyDimensioni } from '@src/components/CMyDimensioni' +import { CMyText } from '@src/components/CMyText' import MixinMetaTags from '@/mixins/mixin-metatags' import MixinBase from '@/mixins/mixin-base' @@ -42,7 +43,7 @@ export default defineComponent({ CImgTitle, CTitle, LandingFooter, CEventsCalendar, CCardCarousel, COpenStreetMap, CMyPage, CMyPageIntro, CMyEditor, CMyFieldRec, CSelectColor, CSelectFontSize, CSelectImage, CImgPoster, CSelectAnimation, CMySlider, - CMySize, CBorders, CMyDimensioni, + CMySize, CBorders, CMyDimensioni, CMyText, }, emits: ['saveElem', 'selElemClick', 'toggleSize', 'deleteElem', 'dupPage'], props: { @@ -81,28 +82,6 @@ export default defineComponent({ const $q = useQuasar() const { t } = useI18n() - const posizTextOptions = ref([ - { label: 'In basso', value: costanti.POSIZ_TESTO.IN_BASSO }, - { label: 'A Destra', value: costanti.POSIZ_TESTO.A_DESTRA }, - ]) - const formatOptions = ref([ - { label: 'auto', value: 'CODE128' }, - { label: 'EAN-13', value: 'EAN-13' }, - { label: 'UPC', value: 'upc' }, - ]) - const fontSizeOptions = ref([ - { label: '9', value: '9' }, - { label: '10', value: '10' }, - { label: '11', value: '11' }, - { label: '12', value: '12' }, - { label: '13', value: '13' }, - { label: '14', value: '14' }, - { label: '15', value: '15' }, - { label: '16', value: '16' }, - { label: '18', value: '18' }, - { label: '20', value: '20' }, - { label: '22', value: '22' }, - ]) const animare = ref(0) const slide = ref(0) @@ -243,6 +222,7 @@ export default defineComponent({ function modifElem() { disableSave.value = false elemChanged.value = true + } function modifElemAndSchede() { modifElem() @@ -276,33 +256,57 @@ export default defineComponent({ if (myel.value.catalogo && myel.value.catalogo?.arrSchede) { for (const recscheda of myel.value.catalogo?.arrSchede) { - if (recscheda.scheda && (!recscheda.scheda?.testo_bottom)) { - recscheda.scheda.testo_bottom = { contenuto: '', maxlength: 100 } - } - if (recscheda.scheda && !recscheda.scheda.testo_bottom!.font) { - recscheda.scheda.testo_bottom!.font = { name: '', size: ''} - } - if (recscheda.scheda && (!recscheda.scheda?.testo_right || !recscheda.scheda?.testo_right.font) ) { - recscheda.scheda.testo_right = { contenuto: '', font: { name: '', size: ''} } - } - if (recscheda.scheda && (!recscheda.scheda?.dimensioni.pagina.imgsfondo)) { - recscheda.scheda.dimensioni.pagina = tools.resetRecIDimensioni(recscheda.scheda?.dimensioni.pagina) - } - if (recscheda.scheda && (!recscheda.scheda?.barcode || !recscheda.scheda?.barcode.font)) { - recscheda.scheda.barcode = { - show: false, - format: '', - size: { - width: '2', - height: '33', - }, - font: { - name: '', - size: '11', + if (recscheda.scheda) { + if ((!recscheda.scheda?.testo_bottom)) { + recscheda.scheda.testo_bottom = { contenuto: '', maxlength: 100 } + } + if (!recscheda.scheda.testo_bottom!.font) { + recscheda.scheda.testo_bottom!.font = { name: '', size: '' } + } + if ((!recscheda.scheda?.testo_right || !recscheda.scheda?.testo_right.font)) { + recscheda.scheda.testo_right = { contenuto: '', font: { name: '', size: '' } } + } + if ((!recscheda.scheda?.dimensioni.pagina)) { + recscheda.scheda.dimensioni.pagina = tools.resetRecIPagina(recscheda.scheda?.dimensioni.pagina) + } + if ((!recscheda.scheda?.dimensioni.pagina.dimensioni)) { + recscheda.scheda.dimensioni.pagina = tools.resetRecIPagina(recscheda.scheda?.dimensioni.pagina) + } + if (!recscheda.scheda?.dimensioni?.pagina?.testo_up) { + recscheda.scheda!.dimensioni.pagina.testo_up = tools.resetIText(null) + } + if (!recscheda.scheda?.dimensioni?.pagina?.testo_down) { + recscheda.scheda!.dimensioni.pagina.testo_down = tools.resetIText(null) + } + + if (!recscheda.scheda?.etichette?.novita?.show) { + recscheda.scheda.etichette!.novita = { + show: false, + months: 6, + } + recscheda.scheda.etichette!.bestseller = { + show: false, + primiNInClassifica: 0, + + } + } + + if ((!recscheda.scheda?.barcode || !recscheda.scheda?.barcode.font)) { + recscheda.scheda.barcode = { + show: false, + format: '', + size: { + width: '2', + height: '33', + }, + font: { + name: '', + size: '11', + } } } - } + } } } @@ -322,7 +326,7 @@ export default defineComponent({ if (myel.value.catalogo) { if (!myel.value.catalogo.areadistampa) { myel.value.catalogo.areadistampa = tools.resetRecIAreaDiStampa(null) - myel.value.catalogo.areadistampa.margini = { left: '0.59', top: '0.59', right: '0.59', bottom: '0.28'} + myel.value.catalogo.areadistampa.margini = { left: '0.59', top: '0.59', right: '0.59', bottom: '0.28' } } myel.value.catalogo.areadistampa = tools.resetRecIAreaDiStampa(myel.value.catalogo.areadistampa) @@ -449,15 +453,19 @@ export default defineComponent({ show_separatore: true, name: 'Scheda Nuova', dimensioni, - line_height: 100, numschede_perRiga: 2, numschede_perCol: 2, - posiz_text: costanti.POSIZ_TESTO.A_DESTRA, testo_right: { contenuto: '', + font: { + posiz_text: costanti.POSIZ_TESTO.A_DESTRA, + }, }, testo_bottom: { contenuto: '', + font: { + posiz_text: costanti.POSIZ_TESTO.IN_BASSO, + } }, barcode: { show: false, @@ -487,7 +495,7 @@ export default defineComponent({ _id: objectId(), scheda: newscheda, order: maxorder + 10, - numSchede: 1, + numPagineMax: 0, } ) // console.log('arrschede', myel.value.catalogo!.arrSchede) @@ -533,13 +541,14 @@ export default defineComponent({ myschedadest.scheda = tools.jsonCopy(myschedatocopy.scheda!) myschedadest.scheda!._id = objectId() myschedadest.order = 20 - + myschedadest.scheda!.name = myschedadest.scheda!.name + '_copia' - myschedadest.scheda!.isTemplate = false + myschedadest.scheda!.isTemplate = false }) - + } } + function dupNewScheda(id: string) { if (!myel.value.catalogo!.arrSchede) return @@ -550,9 +559,9 @@ export default defineComponent({ let myscheda = tools.jsonCopy(myfindscheda) delete myscheda._id delete myscheda.scheda!._id - myscheda.numSchede = 1 + myscheda.numPagineMax = 0 myscheda.order = myscheda.order + 10, - myscheda._id = objectId() + myscheda._id = objectId() myscheda.scheda!._id = objectId() myscheda.scheda!.name = myscheda.scheda!.name + '_copia' myscheda.scheda!.isTemplate = false @@ -759,6 +768,8 @@ export default defineComponent({ let arr: any = [] + arr.push({ label: '[Nessuna]', value: '' }) + if (arrschede) { arrschede.forEach((recscheda: ISchedaSingola) => { arr.push({ label: recscheda.scheda!.name, value: recscheda.scheda!._id }) @@ -933,15 +944,12 @@ export default defineComponent({ saveFieldElem, updateCatalogoSizeWidth, dupPage, - posizTextOptions, tabScheda, addNewScheda, dupNewScheda, delRecScheda, SchedeOpt, addProdSpeciale, - formatOptions, - fontSizeOptions, idSchedaDaCopiare, copyfromTemplate, modifElemAndSchede, diff --git a/src/components/CMyEditElem/CMyEditElem.vue b/src/components/CMyEditElem/CMyEditElem.vue index f3babc8d..a92e65df 100755 --- a/src/components/CMyEditElem/CMyEditElem.vue +++ b/src/components/CMyEditElem/CMyEditElem.vue @@ -979,7 +979,7 @@ v-on:keyup.enter="saveElem" > - +
-->
@@ -1343,7 +1343,7 @@ label="Selezione Collane/Editori" icon="fas fa-play-circle" > -
+
+ + + @@ -1398,9 +1411,8 @@ :options="shared_consts.VERSIONI_PRODOTTO" @update:model-value="modifElem" multiple - dense label="Escludi" - style="width: 150px" + style="width: 300px" emit-value map-options > @@ -1414,9 +1426,8 @@ :options="Products.publishers" @update:model-value="modifElem" multiple - dense label="Editori" - style="width: 150px" + style="width: 300px" emit-value map-options option-value="_id" @@ -1439,6 +1450,7 @@ @@ -1536,7 +1548,6 @@ > - - +
+
+ + + + +
-
+
+ + @@ -1628,9 +1672,8 @@ :options="shared_consts.VERSIONI_PRODOTTO" @update:model-value="modifElem" multiple - dense label="Escludi" - style="width: 150px" + style="width: 300px" emit-value map-options > @@ -1646,9 +1689,8 @@ :options="Products.publishers" @update:model-value="modifElem" multiple - dense label="Editori" - style="width: 150px" + style="width: 300px" emit-value map-options option-value="_id" @@ -1670,7 +1712,6 @@ filled use-input new-value-mode="add-unique" - dense style="width: 350px" />
@@ -1681,14 +1722,36 @@ dense-toggle expand-separator label="Pagina" + :disabled="recscheda.scheda.linkIdTemplate" icon="fas fa-play-circle" > + + + + @@ -1711,6 +1776,7 @@ dense-toggle expand-separator label="Schede" + :disabled="recscheda.scheda.linkIdTemplate" icon="fas fa-play-circle" > - - - + -
- Parole Chiave: {autore} {titolo} {descrizione} - {descrizione_estesa} {prezzo} -
- - - - - - - - - - - - +
+ + + + + + + + +
@@ -1928,14 +1972,22 @@ label="Prima Pagina" icon="fas fa-play-circle" > - Prima Pagina:
+ +

@@ -1948,12 +2000,23 @@ label="Ultima Pagina" icon="fas fa-play-circle" > - +
+ + + +
({ width: '', height: '', + gap: '', + fit: '', }), }, label: { @@ -37,6 +39,11 @@ export default defineComponent({ required: false, default: false, }, + fit: { + type: Boolean, + required: false, + default: false, + }, addstr: { type: Boolean, required: false, @@ -75,6 +82,9 @@ export default defineComponent({ function modifValueGap(value: any) { emit('update:modelValue', { ...internalModel, gap: value }); } + function modifValueFit(value: any) { + emit('update:modelValue', { ...internalModel, fit: value }); + } function modifValueRatio(value: any) { // modifValueWidth(0) @@ -104,8 +114,10 @@ export default defineComponent({ modifValueHeight, modifValueRatio, modifValueGap, + modifValueFit, internalModel, ratio, + tools, keepRatio, } } diff --git a/src/components/CMySize/CMySize.vue b/src/components/CMySize/CMySize.vue index 301e665b..7ab9a22a 100755 --- a/src/components/CMySize/CMySize.vue +++ b/src/components/CMySize/CMySize.vue @@ -28,7 +28,7 @@ :disable="!keepRatio" @update:model-value="modifValueRatio" > - + + +
diff --git a/src/components/CMyText/CMyText.scss b/src/components/CMyText/CMyText.scss new file mode 100755 index 00000000..e69de29b diff --git a/src/components/CMyText/CMyText.ts b/src/components/CMyText/CMyText.ts new file mode 100755 index 00000000..f969bea1 --- /dev/null +++ b/src/components/CMyText/CMyText.ts @@ -0,0 +1,79 @@ +import { defineComponent, ref, computed, PropType, toRef, reactive, watch } from 'vue' +import { IOperators, ISize, IText } from 'model' + +import { useI18n } from '@/boot/i18n' +import { useQuasar } from 'quasar' + +import { tools } from '@store/Modules/tools' + +import { costanti } from '@costanti' + +import { CMySlider } from '@src/components/CMySlider' +import { CMyFieldRec } from '@src/components/CMyFieldRec' + +import { shared_consts } from '@/common/shared_vuejs' + +export default defineComponent({ + name: 'CMyText', + emits: ['update:modelValue', 'modifElem', 'saveFieldElem',], + components: { CMySlider, CMyFieldRec }, + props: { + modelValue: { + type: Object as PropType, + required: true, + }, + label: { + type: String, + required: true, + }, + disable: { + type: Boolean, + required: false, + default: false, + }, + show_maxlength: { + type: Boolean, + required: false, + default: true, + }, + }, + setup(props, { emit }) { + const $q = useQuasar() + const { t } = useI18n() + + const internalModel = reactive({ ...props.modelValue }) + + function modifElem() { + // console.log('modifElem') + emit('update:modelValue', { ...internalModel }); + emit('modifElem', null); + } + function update_col() { + // console.log('update_col') + emit('update:modelValue', { ...internalModel }); + emit('modifElem', null); + } + + function saveFieldElem() { + emit('update:modelValue', { ...internalModel }); + emit('saveFieldElem', null); + } + + // Sincronizzare i cambiamenti esterni con internalModel quando props cambiano + watch(() => props.modelValue, (newModel: any) => { + Object.assign(internalModel, newModel); + + }, { immediate: true }); + + return { + t, + shared_consts, + internalModel, + modifElem, + tools, + costanti, + saveFieldElem, + update_col, + } + } +}) diff --git a/src/components/CMyText/CMyText.vue b/src/components/CMyText/CMyText.vue new file mode 100755 index 00000000..60d24d21 --- /dev/null +++ b/src/components/CMyText/CMyText.vue @@ -0,0 +1,83 @@ + + + + + diff --git a/src/components/CMyText/index.ts b/src/components/CMyText/index.ts new file mode 100755 index 00000000..5e78ef48 --- /dev/null +++ b/src/components/CMyText/index.ts @@ -0,0 +1 @@ +export {default as CMyText} from './CMyText.vue' diff --git a/src/model/GlobalStore.ts b/src/model/GlobalStore.ts index dde81bcf..f552fcc9 100755 --- a/src/model/GlobalStore.ts +++ b/src/model/GlobalStore.ts @@ -688,10 +688,14 @@ export interface ISize { width?: string height?: string gap?: string + fit?: string } export interface IFont { name?: string size?: string + line_height?: number + posiz_text?: number + perc_text?: string } export interface IBorder { @@ -706,6 +710,21 @@ export interface IImg { fit?: string } +export interface INovita { + show?: boolean + months?: number +} + +export interface IBestseller { + show?: boolean + primiNInClassifica?: number +} + +export interface IEtichette { + novita?: INovita + bestseller?: IBestseller +} + export interface IBarCode { show?: boolean format?: string @@ -714,6 +733,12 @@ export interface IBarCode { widthlines?: number } +export interface IPagina { + dimensioni?: IDimensioni + testo_up?: IText + testo_down?: IText +} + export interface IDimensioni { size?: ISize margini?: IBorder @@ -743,7 +768,7 @@ export interface IText { } export interface IElementiScheda { - pagina: IDimensioni + pagina: IPagina riga: IDimensioni scheda_prodotto: IDimensioni immagine_prodotto: IDimensioni @@ -753,15 +778,15 @@ export interface IMyScheda { _id?: string, idapp?: string, isTemplate?: boolean, + linkIdTemplate?: string, name?: string, - line_height?: number numschede_perRiga?: number numschede_perCol?: number show_separatore: boolean testo_right?: IText testo_bottom?: IText - posiz_text?: number barcode?: IBarCode, + etichette?: IEtichette, dimensioni: IElementiScheda productTypes?: number[] @@ -777,7 +802,7 @@ export interface ISchedaSingola { _id?: string scheda?: IMyScheda, order?: number, - numSchede?: number, + numPagineMax?: number, // In Memoria arrProdToShow?: IProduct[][][] @@ -785,12 +810,13 @@ export interface ISchedaSingola { export interface ICatalogo { //++AddCATALOGO_FIELDS - productTypes: number[] - excludeproductTypes: number[] - formato: string[] - Categoria: string[] - Editore: string[] - pdf: boolean + productTypes?: number[] + excludeproductTypes?: number[] + formato?: string[] + Categoria?: string[] + Editore?: string[] + sort?: number + pdf?: boolean pdf_filename?: string printable?: boolean diff --git a/src/model/Products.ts b/src/model/Products.ts index 185d2e33..a0e83758 100755 --- a/src/model/Products.ts +++ b/src/model/Products.ts @@ -42,6 +42,21 @@ export interface IProductInfo { productTypes?: number[] versioneGM?: string short_descr: string + + totaleVenduti?: number, + venditeLastM?: number, + venditeLast6M?: number, + venditeLastY?: number, + venditeLast2Y?: number, + dataUltimoOrdine?: Date, + rank3M?: number, + rank6M?: number, + rank1Y?: number, + + descrizione_breve_macro?: string, + descrizione_completa_macro?: string, + sottotitolo?: string, + link_macro?: string, } export interface IVariazione { @@ -76,6 +91,7 @@ export interface IProdView { export interface IProduct { _id?: any + indiceRanking?: number active?: boolean isbn?: string idProductInfo?: string, diff --git a/src/rootgen/admin/importdata/importdata.ts b/src/rootgen/admin/importdata/importdata.ts index b14183c8..2fc869d2 100755 --- a/src/rootgen/admin/importdata/importdata.ts +++ b/src/rootgen/admin/importdata/importdata.ts @@ -79,9 +79,17 @@ export default defineComponent({ value: shared_consts.Cmd.CAT_NO_SPAZI }, { - label: 'Importa da JSON (ImportaMacro)', + label: 'Importa Cataloghi da JSON (ImportaMacro)', value: shared_consts.Cmd.MACRO_CATALOGO_JSON }, + { + label: 'Importa Ranking da JSON (ImportaMacro)', + value: shared_consts.Cmd.MACRO_RANKING + }, + { + label: 'Importa Descrizioni e Link da Sito GruppoMacro (XML)', + value: shared_consts.Cmd.MACRO_DESCRELINKSITOWEB + }, ] ) @@ -356,8 +364,17 @@ export default defineComponent({ return importCmdTxt(cmd, testo); } else if (cmd === shared_consts.Cmd.CAT_NO_SPAZI) { return importNoSpazi(cmd, testo); - } else if (cmd === shared_consts.Cmd.MACRO_CATALOGO_JSON) { + } else if ((cmd === shared_consts.Cmd.MACRO_CATALOGO_JSON || cmd === shared_consts.Cmd.MACRO_RANKING)) { return importMacroCatalogoJson(cmd, testo); + } else if (cmd === shared_consts.Cmd.MACRO_DESCRELINKSITOWEB) { + + console.log('TESTO PRIMA:', testo) + const testoJSON = tools.convertXMLStringToJSON(testo) + + const testoJSONtoPrint = JSON.stringify(testoJSON, null, 2) + console.log(testoJSONtoPrint) + + return importMacroCatalogoJson(cmd, testoJSONtoPrint) } function addfield(col: number, field: string, rec: any, opt: any) { @@ -401,7 +418,7 @@ export default defineComponent({ if (cmd === shared_consts.Cmd.PRODUCTS_V2) { skipfirstrow.value = false - } else if (cmd === shared_consts.Cmd.MACRO_CATALOGO_JSON) { + } else if ((cmd === shared_consts.Cmd.MACRO_CATALOGO_JSON) || (cmd === shared_consts.Cmd.MACRO_RANKING) || (cmd === shared_consts.Cmd.MACRO_DESCRELINKSITOWEB)) { skipfirstrow.value = false } @@ -433,8 +450,6 @@ export default defineComponent({ strris += ' istat:\'' + tools.addslashes(rec[0]) + '\',' strris += ' comune:\'' + tools.addslashes(rec[1]) + '\',' strris += ' prov:\'' + tools.addslashes(rec[2]) + '\'' - - } else if (cmd === shared_consts.Cmd.PRODUCTS) { if (!primo) { strris += ', ' @@ -450,8 +465,8 @@ export default defineComponent({ col++; strris += addfield(col, 'weight', rec, { isnumero: true }); col++; strris += addfield(col, 'unit', rec, {}); col++; - strris += addfield(col, 'link', rec, {}); col++; - + strris += addfield(col, 'link', rec, {}); col++; + strris += addfield(col, 'perc_iva', rec, {}); col++; strris += addfield(col, 'price_acquistato', rec, { isnumero: true, iseuro: true }); col++; @@ -542,7 +557,7 @@ export default defineComponent({ try { console.log('ev', ev) reset() - + if (ev.target && ev.target.files) { const file = ev.target.files[0] const reader = new FileReader() @@ -580,8 +595,8 @@ export default defineComponent({ } function eseguiCmdCatalogoJson() { - let options = { aggiornaStockQty: checkAggiornaQta.value } - + let options = { aggiornaStockQty: checkAggiornaQta.value } + userStore.importToServerCmd($q, t, cosafare.value, { arrdata: risultato.value, options }, true) risultato.value = '' } diff --git a/src/rootgen/admin/importdata/importdata.vue b/src/rootgen/admin/importdata/importdata.vue index a3dc6855..48fef9ad 100755 --- a/src/rootgen/admin/importdata/importdata.vue +++ b/src/rootgen/admin/importdata/importdata.vue @@ -19,6 +19,8 @@ + +
@@ -28,7 +30,7 @@
{{ risraw }}
-
+


diff --git a/src/store/Modules/costanti.ts b/src/store/Modules/costanti.ts index 6a282f40..8ca3a86d 100755 --- a/src/store/Modules/costanti.ts +++ b/src/store/Modules/costanti.ts @@ -500,19 +500,8 @@ export const costanti = { TESTO_BORDATO: 5, }, - SORT_ALPHA: 0, + SORT_DEFAULT: 0, SORT_PUBDATE: 1, - - - ORDINAMENTO_CATALOGHI: [ - { - label: 'Data di Uscita', - value: 1, - }, - { - label: 'Alfabetico', - value: 0, - }, - ], + SORT_BESTSELLER: 2, } diff --git a/src/store/Modules/fieldsTable.ts b/src/store/Modules/fieldsTable.ts index 6b0e20a4..6ce9bd6f 100755 --- a/src/store/Modules/fieldsTable.ts +++ b/src/store/Modules/fieldsTable.ts @@ -161,6 +161,9 @@ export const colISize = [ export const colIText = [ AddCol({ name: 'contenuto', label_trans: 'catalogo.contenuto', fieldtype: costanti.FieldType.html }), AddCol({ name: 'maxlength', label_trans: 'catalogo.maxlength', fieldtype: costanti.FieldType.number }), + AddCol({ name: 'posiz_text', label_trans: 'catalogo.posiz_text', fieldtype: costanti.FieldType.number }), + AddCol({ name: 'perc_text', label_trans: 'catalogo.perc_text', fieldtype: costanti.FieldType.string }), + AddCol({ name: 'line_height', label_trans: 'catalogo.line_height', fieldtype: costanti.FieldType.number }), ] export const colmyIImg = [ AddCol({ name: 'imagefile', label_trans: 'iimg.imagefile', fieldtype: costanti.FieldType.image }), @@ -170,6 +173,7 @@ export const colmyIImg = [ export const colmyScheda = [ AddCol({ name: 'name', label_trans: 'scheda.name', fieldtype: costanti.FieldType.string }), AddCol({ name: 'isTemplate', label_trans: 'scheda.isTemplate', fieldtype: costanti.FieldType.boolean }), + AddCol({ name: 'linkIdTemplate', label_trans: 'scheda.linkIdTemplate', fieldtype: costanti.FieldType.string }), AddCol({ name: 'widthscheda', label_trans: 'scheda.widthscheda', fieldtype: costanti.FieldType.number }), AddCol({ name: 'widthpag', label_trans: 'scheda.widthpag', fieldtype: costanti.FieldType.number }), AddCol({ name: 'widthimg', label_trans: 'scheda.widthimg', fieldtype: costanti.FieldType.number }), @@ -180,8 +184,6 @@ export const colmyScheda = [ AddCol({ name: 'margine_top', label_trans: 'scheda.margine_top', fieldtype: costanti.FieldType.number }), AddCol({ name: 'margine_pagina', label_trans: 'scheda.margine_pagina', fieldtype: costanti.FieldType.string }), AddCol({ name: 'margine_riga', label_trans: 'scheda.margine_riga', fieldtype: costanti.FieldType.string }), - AddCol({ name: 'posiz_text', label_trans: 'catalogo.posiz_text', fieldtype: costanti.FieldType.number }), - AddCol({ name: 'line_height', label_trans: 'catalogo.line_height', fieldtype: costanti.FieldType.number }), AddCol({ name: 'productTypes', label_trans: 'productTypes', fieldtype: costanti.FieldType.number }), AddCol({ name: 'excludeproductTypes', label_trans: 'excludeproductTypes', fieldtype: costanti.FieldType.number }), diff --git a/src/store/Modules/tools.ts b/src/store/Modules/tools.ts index cdbc1abb..a169cd88 100644 --- a/src/store/Modules/tools.ts +++ b/src/store/Modules/tools.ts @@ -22,6 +22,7 @@ import { IText, IAreaDiStampa, ICatalogo, + IPagina, } from '@model' import MixinBase from '@/mixins/mixin-base' @@ -351,6 +352,31 @@ export const tools = { }, ], + posizTextOptions: [ + { label: 'In basso', value: costanti.POSIZ_TESTO.IN_BASSO }, + { label: 'A Destra', value: costanti.POSIZ_TESTO.A_DESTRA }, + ], + + fontSizeOptions: [ + { label: '9', value: '9' }, + { label: '10', value: '10' }, + { label: '11', value: '11' }, + { label: '12', value: '12' }, + { label: '13', value: '13' }, + { label: '14', value: '14' }, + { label: '15', value: '15' }, + { label: '16', value: '16' }, + { label: '18', value: '18' }, + { label: '20', value: '20' }, + { label: '22', value: '22' }, + ], + + formatOptions: [ + { label: 'auto', value: 'CODE128' }, + { label: 'EAN-13', value: 'EAN-13' }, + { label: 'UPC', value: 'upc' }, + ], + SelectListFormatPDF: [ { label: 'a4 (mm)', value: [210, 297] }, { label: '22,60 x 31,26 (in mm)', value: [226.0, 312.6] }, @@ -9223,6 +9249,23 @@ export const tools = { rec.contenuto = '' rec.maxlength = 0 + rec.font = { + line_height: 1, + posiz_text: 0, + perc_text: '50%', + name: '', + size: '14px', + } + } + + if (!rec.font) { + rec.font = { + line_height: 1, + posiz_text: 0, + perc_text: '50%', + name: '', + size: '14px', + } } return rec @@ -9253,6 +9296,35 @@ export const tools = { return myrec }, + resetRecIPagina(rec: IPagina | null) { + + let myrec: IPagina = {} + + if (!rec) { + let dimensioni: IDimensioni = this.resetRecIDimensioni(null) + + myrec = { + dimensioni, + testo_up: this.resetIText(null), + testo_down: this.resetIText(null), + } + } + + if (!myrec.dimensioni) { + myrec.dimensioni = this.resetRecIDimensioni(null) + } + if (!myrec.testo_up) { + myrec.testo_up = this.resetIText(null) + } + if (!myrec.testo_down) { + myrec.testo_down = this.resetIText(null) + } + + + + return myrec + }, + resetRecIAreaDiStampa(rec: IAreaDiStampa | null) { let myrec: IAreaDiStampa = {} @@ -9304,19 +9376,68 @@ export const tools = { } }, - getValueAndSuffix(myvalue: any): {value: number, suffix: string} { + getValueAndSuffix(myvalue: any): { value: number, suffix: string } { if (!myvalue) { - return {value: 0, suffix: ''}; + return { value: 0, suffix: '' }; } // Estrae l'unità di misura const unit = myvalue.replace(/[\d.]/g, ''); // Ottiene il suffisso (es. 'px') const numericalValue = parseFloat(myvalue) || 0; // Converti la parte numerica in float - return { value: numericalValue, suffix: unit}; // Restituisce il valore con il suffisso + return { value: numericalValue, suffix: unit }; // Restituisce il valore con il suffisso }, + xmlToJson(xml: any) { + // Converte un XML in un oggetto JavaScript + var obj: any = {}; + if (xml.nodeType === 1) { // Elemento + // Se ha attributi, aggiungili all'oggetto + if (xml.attributes.length > 0) { + obj["@attributes"] = {} + for (var j = 0; j < xml.attributes.length; j++) { + var attribute = xml.attributes.item(j); + obj["@attributes"][attribute.nodeName] = attribute.nodeValue; + } + } + } else if (xml.nodeType === 3) { // Testo + obj = xml.nodeValue; + } + + // Se ha figli, applica la funzione ricorsivamente + if (xml.hasChildNodes()) { + for (var i = 0; i < xml.childNodes.length; i++) { + var item = xml.childNodes.item(i); + var nodeName = item.nodeName; + if (typeof (obj[nodeName]) === "undefined") { + obj[nodeName] = this.xmlToJson(item); + } else { + if (typeof (obj[nodeName]) === "object") { + // Se l'elemento esiste già, trasformalo in un array + if (typeof (obj[nodeName].push) === "undefined") { + var old = obj[nodeName]; + obj[nodeName] = []; + obj[nodeName].push(old); + } + obj[nodeName].push(this.xmlToJson(item)); + } else { + obj[nodeName] = [obj[nodeName]]; + obj[nodeName].push(this.xmlToJson(item)); + } + } + } + } + return obj + }, + + // Esempio di utilizzo + convertXMLStringToJSON(xmlString: string): any { + var parser = new DOMParser(); + var xmlDoc = parser.parseFromString(xmlString, "application/xml"); + var jsonResult = this.xmlToJson(xmlDoc); + return jsonResult; + }, // FINE ! // getLocale() { diff --git a/src/store/Products.ts b/src/store/Products.ts index 135f2b6d..8a809557 100755 --- a/src/store/Products.ts +++ b/src/store/Products.ts @@ -1277,6 +1277,10 @@ export const useProducts = defineStore('Products', { const maxDescriptionLength = testo.maxlength ?? 100; const description = myproduct.productInfo.short_descr || ''; const long_descr = myproduct.productInfo.description || ''; + const date_pub = tools.getstrDateShort(myproduct.productInfo.date_publishing) || ''; + const ranking_globale = myproduct.productInfo.rank1Y || 0; + const ranking = myproduct.indiceRanking! || 0; + const venduti = myproduct.productInfo.totaleVenduti || 0; const truncatedDescription = description.length > maxDescriptionLength ? description.substring(0, description.lastIndexOf(' ', maxDescriptionLength)) + '...' @@ -1286,6 +1290,20 @@ export const useProducts = defineStore('Products', { ? long_descr.substring(0, long_descr.lastIndexOf(' ', maxDescriptionLength)) + '...' : long_descr; + + const long_descr_macro = myproduct.productInfo.descrizione_completa_macro || ''; + const descrizione_completa_macro = long_descr_macro.length > maxDescriptionLength + ? long_descr_macro.substring(0, long_descr_macro.lastIndexOf(' ', maxDescriptionLength)) + '...' + : long_descr_macro; + + const short_descr = myproduct.productInfo.descrizione_breve_macro || ''; + const descrizione_breve_macro = short_descr.length > maxDescriptionLength + ? short_descr.substring(0, short_descr.lastIndexOf(' ', maxDescriptionLength)) + '...' + : short_descr; + + const sottotitolo = myproduct.productInfo.sottotitolo || ''; + const link_macro = myproduct.productInfo.link_macro || ''; + const prezzo = myproduct.arrvariazioni ? myproduct.arrvariazioni[0].price?.toFixed(2) : '' const prezzo_scontato = myproduct.arrvariazioni ? myproduct.arrvariazioni[0].sale_price?.toFixed(2) : '' const misure = myproduct.arrvariazioni ? myproduct.arrvariazioni[0].misure : '' @@ -1301,10 +1319,18 @@ export const useProducts = defineStore('Products', { '{descrizione_estesa}': truncatedlongDescription || '', '{pagine}': pagine || '', '{misure}': misure || '', + '{date_pub}': date_pub || '', + '{ranking_globale}': ranking_globale || '', + '{ranking}': ranking || '', + '{venduti}': venduti || '', '{formato}': formato || '', '{prezzo}': prezzo || '', '{scale}': scale || '', '{prezzo_scontato}': prezzo_scontato || '', + '{descrizione_completa_macro}': descrizione_completa_macro || '', + '{descrizione_breve_macro}': descrizione_breve_macro || '', + '{link_macro}': link_macro || '', + '{sottotitolo}': sottotitolo || '', }; // Esegue le sostituzioni diff --git a/src/views/ecommerce/catalogo/catalogo.scss b/src/views/ecommerce/catalogo/catalogo.scss index 2823611e..964ac536 100755 --- a/src/views/ecommerce/catalogo/catalogo.scss +++ b/src/views/ecommerce/catalogo/catalogo.scss @@ -85,8 +85,28 @@ body { font-family: 'DINPro-BoldItalic', sans-serif; } - .book-details { font-family: 'DINPro', sans-serif; margin-bottom: calc(5 * var(--scalecatalog) * 1px); } + + +.book-descr-estesa { + font-family: 'DINPro', sans-serif; + font-size: calc(14 * var(--scalecatalog) * 1px); +} + +.book-novita { + font-size: calc(20 * var(--scalecatalog) * 1px); +} + + +.book-text-up { + font-family: 'DINPro', sans-serif; + margin-bottom: calc(5 * var(--scalecatalog) * 1px); + font-size: calc(20 * var(--scalecatalog) * 1px); +} +.book-text-down { + font-family: 'DINPro', sans-serif; + margin-bottom: calc(5 * var(--scalecatalog) * 1px); +} diff --git a/src/views/ecommerce/catalogo/catalogo.ts b/src/views/ecommerce/catalogo/catalogo.ts index 9f000ead..25796b00 100755 --- a/src/views/ecommerce/catalogo/catalogo.ts +++ b/src/views/ecommerce/catalogo/catalogo.ts @@ -14,7 +14,7 @@ import { CProductCard } from '@src/components/CProductCard' import { CMySelect } from '@src/components/CMySelect' import { CContainerCatalogoCard } from '@src/components/CContainerCatalogoCard' import { CSelectUserActive } from '@src/components/CSelectUserActive' -import { ICatalogo, IFilterCatalogo, IMyScheda, IProdView, IProduct, ISchedaSingola, ISearchList } from 'model' +import { ICatalogo, IDimensioni, IFilterCatalogo, IMyScheda, IProdView, IProduct, ISchedaSingola, ISearchList } from 'model' // import { VueHtmlToPaper } from 'vue-html-to-paper' import html2pdf from 'html2pdf.js' @@ -192,7 +192,7 @@ export default defineComponent({ } function calcArrProducts() { - // console.log('calcArrProducts') + console.log('calcArrProducts') // eventuali titoli specifici estratti dall'array di Prodotti Selezionati //const searchtext = getSearchText() @@ -270,20 +270,12 @@ export default defineComponent({ }); } - // console.log('filter.value.sort', filter.value.sort) - // sort using filter.value.sort : - if (filter.value.sort === costanti.SORT_PUBDATE) { - - arrprod = arrprod.sort((a: IProduct, b: IProduct) => { - return b.productInfo.date_publishing_ts - a.productInfo.date_publishing_ts - }) - - } else if (filter.value.sort === costanti.SORT_ALPHA) { - - } + arrprod = getProductsSorted(arrprod, filter.value.sort); arrProducts.value = arrprod + populateDataWithlinkIdTemplate() + generatearrProdToViewSorted() loaddata() @@ -291,7 +283,55 @@ export default defineComponent({ refreshpage.value = false } - function getProductsFilteredByScheda(scheda: IMyScheda) { + + function sovrascriviSchedaFromTemplate(idTemplate: string, origScheda: ISchedaSingola) { + if (!props.optcatalogo) + return + + const arrschede: ISchedaSingola[] = globalStore.getMySchede() + const myfindscheda = arrschede.find((recscheda: ISchedaSingola) => recscheda.scheda?._id === idTemplate) + + let mynewscheda = tools.jsonCopy(origScheda) + + const linkIdTemplate = origScheda.scheda?.linkIdTemplate + const precname = origScheda.scheda?.name + + if (myfindscheda) { + let myschedatocopy = tools.jsonCopy(myfindscheda) + + if (myschedatocopy) { + myschedatocopy.scheda._id = origScheda.scheda?._id + myschedatocopy.scheda.isTemplate = false + myschedatocopy.scheda.name = precname + myschedatocopy.scheda.linkIdTemplate = linkIdTemplate + + return myschedatocopy.scheda + } + } + + return null + } + + function populateDataWithlinkIdTemplate() { + + if (props.optcatalogo) { + + for (const recscheda of props.optcatalogo.arrSchede!) { + if (recscheda.scheda?.linkIdTemplate) { + // ricopia da Template: + const myscheda = sovrascriviSchedaFromTemplate(recscheda.scheda?.linkIdTemplate, recscheda) + if (myscheda) { + recscheda.scheda = myscheda + } + + } + } + } + + } + + + function getProductsFilteredByScheda(scheda: IMyScheda): IProduct[] { const searchtext = scheda.arrProdottiSpeciali @@ -346,7 +386,7 @@ export default defineComponent({ if (!boolfiltroVuotoProductTypes) { // check if productInfo.productTypes array includes some item in scheda.ProductTypes array - hasProductTypes = !scheda.productTypes || (scheda.productTypes && (product.productInfo.productTypes || []).some((item: any) => scheda.productTypes.includes(item))) + hasProductTypes = !scheda.productTypes || (scheda.productTypes && (product.productInfo.productTypes || []).some((item: any) => scheda.productTypes!.includes(item))) } if (!boolfiltroVuotoEditore) { hasPublished = !scheda.editore || (scheda.editore && scheda.editore.includes(product.productInfo.idPublisher!)) @@ -354,7 +394,7 @@ export default defineComponent({ if (!boolfiltroVuotoExcludeProductTypes) { // check if productInfo.productTypes array exclude some item in scheda.ProductTypes array - hasExcludeProductTypes = !scheda.excludeproductTypes || (scheda.excludeproductTypes && (product.productInfo.productTypes || []).every((item: any) => scheda.excludeproductTypes.includes(item))) + hasExcludeProductTypes = !scheda.excludeproductTypes || (scheda.excludeproductTypes && (product.productInfo.productTypes || []).every((item: any) => scheda.excludeproductTypes!.includes(item))) } return searchMatch && hasCategoria && hasAuthor && hasProductTypes && hasPublished && !hasExcludeProductTypes; @@ -364,15 +404,35 @@ export default defineComponent({ } }) - // console.log('filter.value.sort', filter.value.sort) - // sort using filter.value.sort : - if (scheda.sort === costanti.SORT_PUBDATE) { + arrprod = getProductsSorted(arrprod, scheda?.sort!); + + return arrprod + + } + + function getProductsSorted(arrprod: IProduct[], sort: number) { + console.log('getProductsSorted', sort) + if (sort === costanti.SORT_PUBDATE) { arrprod = arrprod.sort((a: IProduct, b: IProduct) => { return b.productInfo.date_publishing_ts - a.productInfo.date_publishing_ts }) + } else if (sort === costanti.SORT_BESTSELLER) { - } else if (scheda.sort === costanti.SORT_ALPHA) { + arrprod = arrprod.sort((a: IProduct, b: IProduct) => { + return b.productInfo.rank1Y! - a.productInfo.rank1Y! + }) + + arrprod = arrprod.map((product, index) => { + return { + ...product, + indiceRanking: index + 1 + }; + }) + + console.log('arr', arrprod) + + } else if (sort === costanti.SORT_DEFAULT) { } @@ -423,20 +483,43 @@ export default defineComponent({ } function generatearrProdToViewSorted() { - // console.log('generatearrProdToViewSorted') + console.log('generatearrProdToViewSorted', arrProducts.value) // Svuota arrProdToView.value = [] + // gia filtrati + const arrGeneraleProdotti = arrProducts.value; + + let indprod = 0 + let indprodGenerale = 0 + for (const recscheda of props.optcatalogo.arrSchede!) { if (recscheda && recscheda.scheda) { let schedePerRiga = recscheda.scheda.numschede_perRiga || 1 let schedePerCol = recscheda.scheda.numschede_perCol || 1 let schedePerPagina = schedePerRiga * schedePerCol - // Filtra i prodotti in base ai filtri impostati ! - const arrProdFiltrati = getProductsFilteredByScheda(recscheda.scheda) - let indprod = 0 + let arrProdFiltrati: IProduct[] = [] + + if (recscheda.scheda.productTypes!.length > 0) { + // Filtra i prodotti in base ai filtri impostati ! + arrProdFiltrati = getProductsFilteredByScheda(recscheda.scheda) + indprod = 0 + } else { + if (recscheda.scheda?.sort! > 0) { + arrProdFiltrati = getProductsSorted(arrGeneraleProdotti, recscheda.scheda.sort!); + indprod = 0 + } else { + indprod = indprodGenerale + arrProdFiltrati = arrGeneraleProdotti + } + + + } + + // console.log('arrProdFiltrati indiceRanking = ', arrProdFiltrati[0].indiceRanking) + let indadded = 0 recscheda.arrProdToShow = [] @@ -463,17 +546,27 @@ export default defineComponent({ recscheda.arrProdToShow[pagina][riga] = []; } + console.log('RANKING: ', result.myrec.indiceRanking!) + recscheda.arrProdToShow[pagina][riga][col] = result.myrec indadded++ } } } + + if (recscheda.numPagineMax! > 0) { + if (pagina + 1 >= recscheda.numPagineMax!) + break; // fine pagine + } + } // console.log('*** arrProdToShow', recscheda.arrProdToShow) } } + + console.log('Fine...') } function getNextProd() { @@ -720,51 +813,8 @@ export default defineComponent({ } function groupedPages(recscheda: ISchedaSingola) { - - let numschedeattuali = 0 - if (recscheda.scheda) { - const schedePerRiga = recscheda.scheda.numschede_perRiga || 1 - const schedePerCol = recscheda.scheda.numschede_perCol || 1 - const schedePerPagina = schedePerRiga * schedePerCol - - let indiceprodotto = 0 - - const pages = [] - - // Iterate attraverso l'array prodotti con step = schedePerPagina - for (let pageStart = 0; pageStart < arrProducts.value.length; pageStart += schedePerPagina) { - const page = [] - - // Crea le righe per questa pagina - for (let rowStart = 0; rowStart < schedePerRiga; rowStart++) { - const row = [] - - // Riempi ogni riga con il numero corretto di prodotti - for (let col = 0; col < schedePerCol; col++) { - const productIndex = pageStart + (rowStart * schedePerRiga) + col - row.push(indiceprodotto) - indiceprodotto++ - } - - page.push(row) - } - - numschedeattuali++ - pages.push(page) - - if (recscheda.numSchede! > 0) { - if (numschedeattuali >= recscheda.numSchede!) - return pages - } - } - - return pages - } - - return null - + return recscheda.arrProdToShow } - function generateStyleCatalogo(optcatalogo: ICatalogo) { return { @@ -773,19 +823,19 @@ export default defineComponent({ } function generateStylePageScheda(optcatalogo: ICatalogo, scheda: IMyScheda) { - const marginTop = scheda.dimensioni?.pagina?.margini?.top ? tools.adjustSize(props.optcatalogo, scheda.dimensioni?.pagina?.margini?.top) : (tools.adjustSize(props.optcatalogo, optcatalogo.dimensioni_def?.pagina?.margini?.top) ?? '') - const marginBottom = scheda.dimensioni?.pagina?.margini?.bottom ? tools.adjustSize(props.optcatalogo, scheda.dimensioni?.pagina?.margini?.bottom) : (tools.adjustSize(props.optcatalogo, optcatalogo.dimensioni_def?.pagina?.margini?.bottom) ?? '') - const marginLeft = scheda.dimensioni?.pagina?.margini?.left ? tools.adjustSize(props.optcatalogo, scheda.dimensioni?.pagina?.margini?.left) : (tools.adjustSize(props.optcatalogo, optcatalogo.dimensioni_def?.pagina?.margini?.left) ?? '') - const marginRight = scheda.dimensioni?.pagina?.margini?.right ? tools.adjustSize(props.optcatalogo, scheda.dimensioni?.pagina?.margini?.right): (tools.adjustSize(props.optcatalogo, optcatalogo.dimensioni_def?.pagina?.margini?.right) ?? '') + const marginTop = scheda.dimensioni?.pagina?.dimensioni?.margini?.top ? tools.adjustSize(props.optcatalogo, scheda.dimensioni?.pagina?.dimensioni?.margini?.top) : (tools.adjustSize(props.optcatalogo, optcatalogo.dimensioni_def?.pagina?.margini?.top) ?? '') + const marginBottom = scheda.dimensioni?.pagina?.dimensioni?.margini?.bottom ? tools.adjustSize(props.optcatalogo, scheda.dimensioni?.pagina?.dimensioni?.margini?.bottom) : (tools.adjustSize(props.optcatalogo, optcatalogo.dimensioni_def?.pagina?.margini?.bottom) ?? '') + const marginLeft = scheda.dimensioni?.pagina?.dimensioni?.margini?.left ? tools.adjustSize(props.optcatalogo, scheda.dimensioni?.pagina?.dimensioni?.margini?.left) : (tools.adjustSize(props.optcatalogo, optcatalogo.dimensioni_def?.pagina?.margini?.left) ?? '') + const marginRight = scheda.dimensioni?.pagina?.dimensioni?.margini?.right ? tools.adjustSize(props.optcatalogo, scheda.dimensioni?.pagina?.dimensioni?.margini?.right) : (tools.adjustSize(props.optcatalogo, optcatalogo.dimensioni_def?.pagina?.margini?.right) ?? '') - const paddingTop = scheda.dimensioni?.pagina?.padding?.top ? tools.adjustSize(props.optcatalogo, scheda.dimensioni?.pagina?.padding?.top) : (tools.adjustSize(props.optcatalogo, optcatalogo.dimensioni_def?.pagina?.padding?.top) ?? '') - const paddingBottom = scheda.dimensioni?.pagina?.padding?.bottom ? tools.adjustSize(props.optcatalogo, scheda.dimensioni?.pagina?.padding?.bottom) : (tools.adjustSize(props.optcatalogo, optcatalogo.dimensioni_def?.pagina?.padding?.bottom) ?? '') - const paddingLeft = scheda.dimensioni?.pagina?.padding?.left ? tools.adjustSize(props.optcatalogo, scheda.dimensioni?.pagina?.padding?.left) : (tools.adjustSize(props.optcatalogo, optcatalogo.dimensioni_def?.pagina?.padding?.left) ?? '') - const paddingRight = scheda.dimensioni?.pagina?.padding?.right ? tools.adjustSize(props.optcatalogo, scheda.dimensioni?.pagina?.padding?.right) : (tools.adjustSize(props.optcatalogo, optcatalogo.dimensioni_def?.pagina?.padding?.right) ?? '') + const paddingTop = scheda.dimensioni?.pagina?.dimensioni?.padding?.top ? tools.adjustSize(props.optcatalogo, scheda.dimensioni?.pagina?.dimensioni?.padding?.top) : (tools.adjustSize(props.optcatalogo, optcatalogo.dimensioni_def?.pagina?.padding?.top) ?? '') + const paddingBottom = scheda.dimensioni?.pagina?.dimensioni?.padding?.bottom ? tools.adjustSize(props.optcatalogo, scheda.dimensioni?.pagina?.dimensioni?.padding?.bottom) : (tools.adjustSize(props.optcatalogo, optcatalogo.dimensioni_def?.pagina?.padding?.bottom) ?? '') + const paddingLeft = scheda.dimensioni?.pagina?.dimensioni?.padding?.left ? tools.adjustSize(props.optcatalogo, scheda.dimensioni?.pagina?.dimensioni?.padding?.left) : (tools.adjustSize(props.optcatalogo, optcatalogo.dimensioni_def?.pagina?.padding?.left) ?? '') + const paddingRight = scheda.dimensioni?.pagina?.dimensioni?.padding?.right ? tools.adjustSize(props.optcatalogo, scheda.dimensioni?.pagina?.dimensioni?.padding?.right) : (tools.adjustSize(props.optcatalogo, optcatalogo.dimensioni_def?.pagina?.padding?.right) ?? '') // Esiste un immagine di sfondo specifica della singola pagina ? - let fileimg = scheda.dimensioni?.pagina?.imgsfondo?.imagefile - let backgroundSize = scheda.dimensioni?.pagina?.imgsfondo?.fit + let fileimg = scheda.dimensioni?.pagina?.dimensioni?.imgsfondo?.imagefile + let backgroundSize = scheda.dimensioni?.pagina?.dimensioni?.imgsfondo?.fit if (fileimg) { fileimg = fileimg ? `url(${costanti.DIR_UPLOAD + costanti.DIR_SCHEDA + fileimg})` : '' } @@ -799,8 +849,56 @@ export default defineComponent({ let backgroundImage = fileimg ?? '' - let width = scheda.dimensioni?.pagina?.size?.width ? tools.adjustSize(optcatalogo, scheda.dimensioni?.pagina?.size?.width) : (tools.adjustSize(optcatalogo, optcatalogo.dimensioni_def?.pagina?.size?.width) ?? '') - let height = scheda.dimensioni?.pagina?.size?.height ? tools.adjustSize(optcatalogo, scheda.dimensioni?.pagina?.size?.height) : (tools.adjustSize(optcatalogo, optcatalogo.dimensioni_def?.pagina?.size?.height) ?? '') + let width = scheda.dimensioni?.pagina?.dimensioni?.size?.width ? tools.adjustSize(optcatalogo, scheda.dimensioni?.pagina?.dimensioni?.size?.width) : (tools.adjustSize(optcatalogo, optcatalogo.dimensioni_def?.pagina?.size?.width) ?? '') + let height = scheda.dimensioni?.pagina?.dimensioni?.size?.height ? tools.adjustSize(optcatalogo, scheda.dimensioni?.pagina?.dimensioni?.size?.height) : (tools.adjustSize(optcatalogo, optcatalogo.dimensioni_def?.pagina?.size?.height) ?? '') + + return { + marginBottom, + marginTop, + marginLeft, + marginRight, + paddingBottom, + paddingTop, + paddingLeft, + paddingRight, + backgroundImage, + backgroundSize, + '--width': width, + '--height': height, + ...(width ? { width: `${width} !important;` } : {}), + ...(height ? { height: `${height} !important;` } : {}) // Aggiungi l'altezza solo se è valorizzata + }; + } + + function generateStyleByPageDim(optcatalogo: ICatalogo, mypage: IDimensioni) { + const marginTop = mypage!.margini?.top ? tools.adjustSize(props.optcatalogo, mypage!.margini?.top) : (tools.adjustSize(props.optcatalogo, optcatalogo.dimensioni_def?.pagina?.margini?.top) ?? '') + const marginBottom = mypage!.margini?.bottom ? tools.adjustSize(props.optcatalogo, mypage!.margini?.bottom) : (tools.adjustSize(props.optcatalogo, optcatalogo.dimensioni_def?.pagina?.margini?.bottom) ?? '') + const marginLeft = mypage!.margini?.left ? tools.adjustSize(props.optcatalogo, mypage!.margini?.left) : (tools.adjustSize(props.optcatalogo, optcatalogo.dimensioni_def?.pagina?.margini?.left) ?? '') + const marginRight = mypage!.margini?.right ? tools.adjustSize(props.optcatalogo, mypage!.margini?.right) : (tools.adjustSize(props.optcatalogo, optcatalogo.dimensioni_def?.pagina?.margini?.right) ?? '') + + const paddingTop = mypage!.padding?.top ? tools.adjustSize(props.optcatalogo, mypage!.padding?.top) : (tools.adjustSize(props.optcatalogo, optcatalogo.dimensioni_def?.pagina?.padding?.top) ?? '') + const paddingBottom = mypage!.padding?.bottom ? tools.adjustSize(props.optcatalogo, mypage!.padding?.bottom) : (tools.adjustSize(props.optcatalogo, optcatalogo.dimensioni_def?.pagina?.padding?.bottom) ?? '') + const paddingLeft = mypage!.padding?.left ? tools.adjustSize(props.optcatalogo, mypage!.padding?.left) : (tools.adjustSize(props.optcatalogo, optcatalogo.dimensioni_def?.pagina?.padding?.left) ?? '') + const paddingRight = mypage!.padding?.right ? tools.adjustSize(props.optcatalogo, mypage!.padding?.right) : (tools.adjustSize(props.optcatalogo, optcatalogo.dimensioni_def?.pagina?.padding?.right) ?? '') + + // Esiste un immagine di sfondo specifica della singola pagina ? + let fileimg = mypage!.imgsfondo?.imagefile + let backgroundSize = mypage!.imgsfondo?.fit + if (fileimg) { + fileimg = fileimg ? `url(${costanti.DIR_UPLOAD + costanti.DIR_CATALOGO + fileimg})` : '' + } + + if (!fileimg) { + // Esiste un immagine di sfondo uguali per tutte le pagine ? + fileimg = optcatalogo.dimensioni_def?.pagina.imgsfondo?.imagefile + backgroundSize = optcatalogo.dimensioni_def?.pagina.imgsfondo?.fit + fileimg = fileimg ? `url(${costanti.DIR_UPLOAD + costanti.DIR_CATALOGO + fileimg})` : '' + } + + let backgroundImage = fileimg ?? '' + + let width = mypage!.size?.width ? tools.adjustSize(optcatalogo, mypage!.size?.width) : (tools.adjustSize(optcatalogo, optcatalogo.dimensioni_def?.pagina?.size?.width) ?? '') + let height = mypage!.size?.height ? tools.adjustSize(optcatalogo, mypage!.size?.height) : (tools.adjustSize(optcatalogo, optcatalogo.dimensioni_def?.pagina?.size?.height) ?? '') return { marginBottom, @@ -821,10 +919,10 @@ export default defineComponent({ } function getWidthPagina(optcatalogo: ICatalogo, scheda: IMyScheda) { - return scheda.dimensioni?.pagina?.size?.width ? tools.adjustSize(optcatalogo, scheda.dimensioni?.pagina?.size?.width) : (tools.adjustSize(optcatalogo, optcatalogo.dimensioni_def?.pagina?.size?.width) ?? '') + return scheda.dimensioni?.pagina?.dimensioni?.size?.width ? tools.adjustSize(optcatalogo, scheda.dimensioni?.pagina?.dimensioni?.size?.width) : (tools.adjustSize(optcatalogo, optcatalogo.dimensioni_def?.pagina?.size?.width) ?? '') } function getHeightPagina(optcatalogo: ICatalogo, scheda: IMyScheda) { - return scheda.dimensioni?.pagina?.size?.height ? tools.adjustSize(optcatalogo, scheda.dimensioni?.pagina?.size?.height) : (tools.adjustSize(optcatalogo, optcatalogo.dimensioni_def?.pagina?.size?.height) ?? '') + return scheda.dimensioni?.pagina?.dimensioni?.size?.height ? tools.adjustSize(optcatalogo, scheda.dimensioni?.pagina?.dimensioni?.size?.height) : (tools.adjustSize(optcatalogo, optcatalogo.dimensioni_def?.pagina?.size?.height) ?? '') } function getStyleRowSeparator(recscheda: ISchedaSingola) { @@ -938,6 +1036,7 @@ export default defineComponent({ getWidthPagina, getHeightPagina, getStyleRowSeparator, + generateStyleByPageDim, } } }) diff --git a/src/views/ecommerce/catalogo/catalogo.vue b/src/views/ecommerce/catalogo/catalogo.vue index 2e908e19..ca68b88d 100755 --- a/src/views/ecommerce/catalogo/catalogo.vue +++ b/src/views/ecommerce/catalogo/catalogo.vue @@ -48,9 +48,7 @@ -
+
- \
@@ -250,10 +232,7 @@ class="row items-start" style="place-content: center" > -
+
@@ -319,6 +300,30 @@ ) " > +
+
+
+
@@ -407,12 +374,17 @@
- - +
@@ -428,27 +400,12 @@