From 358f0d6816adfd305d92dc5efb0f3fde200f6d1d Mon Sep 17 00:00:00 2001 From: Surya Paolo Date: Wed, 30 Apr 2025 13:27:47 +0200 Subject: [PATCH] - miglioramenti ricerca titoli e modifica del trafiletto - miglior visualizzazione delle liste --- src/common/shared_vuejs.ts | 3 +- src/components/CCatalogoCard/CCatalogoCard.ts | 5 +- .../CCatalogoCard/CCatalogoCard.vue | 41 +++ .../CModifTrafiletto/CModifTrafiletto.scss | 23 ++ .../CModifTrafiletto/CModifTrafiletto.ts | 168 +++++++++++ .../CModifTrafiletto/CModifTrafiletto.vue | 77 +++++ src/components/CModifTrafiletto/index.ts | 1 + src/components/CMyChipList/CMyChipList.scss | 2 +- src/components/CMyChipList/CMyChipList.vue | 23 +- src/components/CMyEditor/CMyEditor.ts | 8 +- src/components/CMyEditor/CMyEditor.vue | 7 +- src/components/CMyEditorAI/CMyEditorAI.scss | 4 + src/components/CMyEditorAI/CMyEditorAI.ts | 275 ++++++++++++++++++ src/components/CMyEditorAI/CMyEditorAI.vue | 86 ++++++ src/components/CMyEditorAI/index.ts | 1 + src/components/CMyPopupEdit/CMyPopupEdit.ts | 31 +- src/components/CMyPopupEdit/CMyPopupEdit.vue | 65 +++++ src/components/CMyRecCatalog/CMyRecCatalog.ts | 2 +- src/components/CProductTable/CProductTable.ts | 33 ++- .../CProductTable/CProductTable.vue | 4 +- .../CSchedaProdotto/CSchedaProdotto.ts | 45 ++- .../CSearchProduct/CSearchProduct.ts | 3 +- .../CSearchProduct/CSearchProduct.vue | 3 +- .../CTableCupleLabelValue.vue | 1 + src/model/CatalogStore.ts | 1 + src/model/GlobalStore.ts | 2 + src/model/Products.ts | 12 +- src/statics/lang/it.js | 7 + src/store/Modules/costanti.ts | 7 + src/store/Modules/fieldsTable.ts | 35 ++- src/store/Products.ts | 26 +- src/store/globalStore.ts | 3 + .../admin/gestoreordini/gestoreordini.ts | 2 +- src/views/ecommerce/cash/cash.ts | 2 +- src/views/ecommerce/catalogo/catalogo.ts | 110 ++++--- src/views/ecommerce/catalogo/catalogo.vue | 115 ++++---- src/views/ecommerce/checkOut/checkOut.ts | 2 +- src/views/ecommerce/orderInfo/orderInfo.ts | 2 +- .../ecommerce/productsList/productsList.ts | 2 +- src/views/toolsAI/main/main.ts | 2 +- 40 files changed, 1093 insertions(+), 148 deletions(-) create mode 100755 src/components/CModifTrafiletto/CModifTrafiletto.scss create mode 100755 src/components/CModifTrafiletto/CModifTrafiletto.ts create mode 100755 src/components/CModifTrafiletto/CModifTrafiletto.vue create mode 100755 src/components/CModifTrafiletto/index.ts create mode 100755 src/components/CMyEditorAI/CMyEditorAI.scss create mode 100755 src/components/CMyEditorAI/CMyEditorAI.ts create mode 100755 src/components/CMyEditorAI/CMyEditorAI.vue create mode 100755 src/components/CMyEditorAI/index.ts diff --git a/src/common/shared_vuejs.ts b/src/common/shared_vuejs.ts index f1424e73..2be1cdef 100755 --- a/src/common/shared_vuejs.ts +++ b/src/common/shared_vuejs.ts @@ -2403,11 +2403,12 @@ export const shared_consts = { { label: 'Totale Fatturati', value: 'totFat' }, { label: 'Venduti Ultimi 3 Mesi', value: 'vLast3M' }, { label: 'Venduti Ultimi 6 Mesi', value: 'vLast6M' }, - { label: 'Venduti Ultimo Anno', value: 'vLastY' }, + { label: 'Venduti Ultimo Anno', value: 'vLast1Y' }, { label: 'Venduti Ultimi 2 Anni', value: 'vLast2Y' }, { label: 'Fatturati Ultimi 3 Mesi', value: 'fatLast3M' }, { label: 'Fatturati Ultimi 6 Mesi', value: 'fatLast6M' }, { label: 'Fatturati Ultimo Anno', value: 'fatLast1Y' }, + { label: 'Fatturati Ultimi 2 Anno', value: 'fatLast2Y' }, { label: 'Data Ultimo Ordine', value: 'dataUltimoOrdine' }, ], diff --git a/src/components/CCatalogoCard/CCatalogoCard.ts b/src/components/CCatalogoCard/CCatalogoCard.ts index 9be563a4..b83e8356 100755 --- a/src/components/CCatalogoCard/CCatalogoCard.ts +++ b/src/components/CCatalogoCard/CCatalogoCard.ts @@ -14,6 +14,7 @@ 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' @@ -89,7 +90,7 @@ export default defineComponent({ }, components: { CTitleBanner, CCardState, CCopyBtn, CMyValueDb, VuePdfApp, CPrice, CBarCode, CLabel, - CText, CViewTable, CTableCupleLabelValue, CSchedaProdotto + CText, CViewTable, CTableCupleLabelValue, CSchedaProdotto, CModifTrafiletto }, setup(props, { emit }) { const $q = useQuasar() @@ -163,6 +164,7 @@ export default defineComponent({ const storeSelected = ref('') const arrordersCart = ref([]) const modifOn = ref(false) + const modifTrafiletto = ref(false) const modifProd = ref(false) const timerInterval = ref(null) @@ -788,6 +790,7 @@ export default defineComponent({ // refreshAllDataBookFromGM, refreshSingleBookFromGM, loading, + modifTrafiletto, } } }) diff --git a/src/components/CCatalogoCard/CCatalogoCard.vue b/src/components/CCatalogoCard/CCatalogoCard.vue index 00207fb4..cfe37a6c 100755 --- a/src/components/CCatalogoCard/CCatalogoCard.vue +++ b/src/components/CCatalogoCard/CCatalogoCard.vue @@ -137,6 +137,27 @@ Modifica + + + + + + Modifica Trafiletto + + +
+ {{ label }} +
+ + +
+ :icon="rec.icon || undefined" + style="border-radius: 10px;" + > {{ rec.label }}
diff --git a/src/components/CMyEditor/CMyEditor.ts b/src/components/CMyEditor/CMyEditor.ts index 796b0c09..7957a5bb 100755 --- a/src/components/CMyEditor/CMyEditor.ts +++ b/src/components/CMyEditor/CMyEditor.ts @@ -34,6 +34,11 @@ export default defineComponent({ required: false, default: false, }, + hideTools: { + type: Boolean, + required: false, + default: false, + }, maxlength: { type: Number, required: false, @@ -51,8 +56,6 @@ export default defineComponent({ const myvalue = ref('') const mycolor = ref('') - const showeditor = ref(true) - const myfonts = ref({ arial: 'Arial', arial_black: 'Arial Black', @@ -157,7 +160,6 @@ export default defineComponent({ console.log('saveval', myvalue.value) emit('showandsave', myvalue.value) // emit('update:value', myvalue) - showeditor.value = false } function setcolor() { diff --git a/src/components/CMyEditor/CMyEditor.vue b/src/components/CMyEditor/CMyEditor.vue index 1333cf59..27f36a36 100755 --- a/src/components/CMyEditor/CMyEditor.vue +++ b/src/components/CMyEditor/CMyEditor.vue @@ -13,19 +13,19 @@ color="white" icon="close" v-close-popup - @click="showeditor = false" >

- + @@ -40,10 +40,11 @@ toolbar-toggle-color="yellow-8" toolbar-bg="primary" :readonly="!canModify" - :toolbar="showtools ? toolbarcomp : []" + :toolbar="showtools && !hideTools ? toolbarcomp : []" :fonts="myfonts" @update:model-value="changeval" @paste="onPaste" + @keyup.esc.stop="visueditor = false" @keyup.enter.stop v-model="myvalue" > diff --git a/src/components/CMyEditorAI/CMyEditorAI.scss b/src/components/CMyEditorAI/CMyEditorAI.scss new file mode 100755 index 00000000..b892863a --- /dev/null +++ b/src/components/CMyEditorAI/CMyEditorAI.scss @@ -0,0 +1,4 @@ +.myflex{ + display: flex; + flex: 1; +} diff --git a/src/components/CMyEditorAI/CMyEditorAI.ts b/src/components/CMyEditorAI/CMyEditorAI.ts new file mode 100755 index 00000000..b501f084 --- /dev/null +++ b/src/components/CMyEditorAI/CMyEditorAI.ts @@ -0,0 +1,275 @@ + +import { tools } from '@tools' +import { CTitleBanner } from '../CTitleBanner' + +import { defineComponent, onMounted, ref, toRef, watch } from 'vue' +import { useQuasar } from 'quasar' + +export default defineComponent({ + name: 'CMyEditorAI', + components: { CTitleBanner }, + props: { + title: { + type: String, + required: false, + default: '', + }, + value: { + type: String, + required: false, + default: '', + }, + myclass: { + type: String, + required: false, + default: '', + }, + showButtons: { + type: Boolean, + required: false, + default: true, + }, + canModify: { + type: Boolean, + required: false, + default: false, + }, + hideTools: { + type: Boolean, + required: false, + default: false, + }, + maxlength: { + type: Number, + required: false, + default: 0, + } + }, + setup(props, { emit }) { + const $q = useQuasar() + + const editorRef = ref(null) + const editor = ref('') + const characterCount = ref(0) + + //const myvalue = toRef(props, 'value') + const myvalue = ref('') + const mycolor = ref('') + + const myfonts = ref({ + arial: 'Arial', + arial_black: 'Arial Black', + AGaramondProRegular: 'AGaramondPro-Regular', + comic_sans: 'Comic Sans MS', + courier_new: 'Courier New', + impact: 'Impact', + lucida_grande: 'Lucida Grande', + times_new_roman: 'Times New Roman', + verdana: 'Verdana', + }) + + const showtools = ref(false) + + const toolbarcomp = ref([ + ['left', 'center', 'right', 'justify'], + ['bold', 'italic', 'underline', 'strike'], + ['token', 'hr', 'link', 'custom_btn', 'print', 'fullscreen'], + [ + { + label: $q.lang.editor.formatting, + icon: $q.iconSet.editor.formatting, + list: 'no-icons', + options: [ + 'p', + 'h4', + 'h5', + 'h6', + 'code' + ] + }, + { + label: $q.lang.editor.fontSize, + icon: $q.iconSet.editor.fontSize, + fixedLabel: true, + fixedIcon: true, + list: 'no-icons', + options: [ + 'size-1', + 'size-2', + 'size-3', + 'size-4', + 'size-5', + 'size-6', + 'size-7' + ] + }, + { + label: $q.lang.editor.defaultFont, + icon: $q.iconSet.editor.font, + fixedIcon: true, + list: 'no-icons', + options: [ + 'default_font', + 'arial', + 'arial_black', + 'comic_sans', + 'courier_new', + 'impact', + 'lucida_grande', + 'times_new_roman', + 'verdana' + ] + }, + 'removeFormat' + ], + ['quote', 'unordered', 'ordered', 'outdent', 'indent'], + + ['undo', 'redo', 'viewsource'], + ]) + + watch(() => props.value, (newval, oldval) => { + if (props.value === undefined) + myvalue.value = '' + else + myvalue.value = props.value + + }) + + function getTextLength(html: string) { + // Crea un elemento temporaneo per convertire HTML in testo + const div = document.createElement('div'); + div.innerHTML = html; // Imposta l'HTML + return div.innerText.length; // Restituisce la lunghezza del testo + } + + function changeval(newval: any) { + // console.log('myEditor: changeval', newval) + characterCount.value = getTextLength(newval) + emit('update:value', newval) + } + + function annulla() { + emit('annulla', true) + } + + function saveval() { + // Converti i in + + myvalue.value = tools.convertiTagHTMLPerBOT(myvalue.value) + + console.log('saveval', myvalue.value) + emit('showandsave', myvalue.value) + // emit('update:value', myvalue) + } + + function setcolor() { + document.execCommand('foreColor', false, mycolor.value) + } + + /** + * Capture the paste event, only allow plain-text, no images. + * + * see: https://stackoverflow.com/a/28213320 + * + * @param {object} evt - array of files + * @author Daniel Thompson-Yvetot + * @license MIT + */ + function pasteCapture(evt: any) { + // let text, onPasteStripFormattingIEPaste + // evt.preventDefault() + // if (evt.originalEvent && evt.originalEvent.clipboardData.getData) { + // text = evt.originalEvent.clipboardData.getData('text/plain') + // $refs.editor_ref.runCmd('insertText', text) + // } + // else if (evt.clipboardData && evt.clipboardData.getData) { + // text = evt.clipboardData.getData('text/plain') + // $refs.editor_ref.runCmd('insertText', text) + // } + // else if (window.clipboardData && window.clipboardData.getData) { + // if (!onPasteStripFormattingIEPaste) { + // onPasteStripFormattingIEPaste = true + // $refs.editor_ref.runCmd('ms-pasteTextOnly', text) + // } + // onPasteStripFormattingIEPaste = false + // } + } + + function mounted() { + if (props.value === undefined) + myvalue.value = '' + else + myvalue.value = props.value + + showtools.value = tools.getCookie('showtools', '0') === '1' + + characterCount.value = getTextLength(myvalue.value) + } + + function onPaste(evt: any) { + // Let inputs do their thing, so we don't break pasting of links. + if (evt.target.nodeName === 'INPUT') return + let text, onPasteStripFormattingIEPaste + evt.preventDefault() + evt.stopPropagation() + if (evt.originalEvent && evt.originalEvent.clipboardData.getData) { + text = evt.originalEvent.clipboardData.getData('text/plain') + editorRef.value.runCmd('insertText', text) + } + else if (evt.clipboardData && evt.clipboardData.getData) { + text = evt.clipboardData.getData('text/plain') + editorRef.value.runCmd('insertText', text) + } + /*else if (ClipboardEvent.clipboardData && ClipboardEvent.clipboardData.getData) { + if (!onPasteStripFormattingIEPaste) { + onPasteStripFormattingIEPaste = true + editorRef.value.runCmd('ms-pasteTextOnly', text) + } + onPasteStripFormattingIEPaste = false + }*/ + } + + const copyToClipboard = (text) => { + navigator.clipboard.writeText(text) + .then(() => { + $q.notify({ + message: 'Testo copiato negli appunti!', + color: 'positive', + icon: 'check', + position: 'top' + }); + }) + .catch(err => { + console.error('Errore durante la copia:', err); + $q.notify({ + message: 'Errore nella copia', + color: 'negative', + icon: 'error', + position: 'top' + }); + }); + }; + + + onMounted(mounted) + + return { + myfonts, + toolbarcomp, + editor, + myvalue, + mycolor, + changeval, + annulla, + saveval, + setcolor, + pasteCapture, + tools, + onPaste, + editorRef, + showtools, + characterCount, + copyToClipboard, + } + } +}) diff --git a/src/components/CMyEditorAI/CMyEditorAI.vue b/src/components/CMyEditorAI/CMyEditorAI.vue new file mode 100755 index 00000000..82c10e66 --- /dev/null +++ b/src/components/CMyEditorAI/CMyEditorAI.vue @@ -0,0 +1,86 @@ + + + + + diff --git a/src/components/CMyEditorAI/index.ts b/src/components/CMyEditorAI/index.ts new file mode 100755 index 00000000..3a58d224 --- /dev/null +++ b/src/components/CMyEditorAI/index.ts @@ -0,0 +1 @@ +export {default as CMyEditorAI} from './CMyEditorAI.vue' diff --git a/src/components/CMyPopupEdit/CMyPopupEdit.ts b/src/components/CMyPopupEdit/CMyPopupEdit.ts index 8dd123ea..57d944ad 100755 --- a/src/components/CMyPopupEdit/CMyPopupEdit.ts +++ b/src/components/CMyPopupEdit/CMyPopupEdit.ts @@ -15,6 +15,7 @@ import { CCurrencyValue } from '../CCurrencyValue' import { CMapEditAddressByCoord } from '../CMapEditAddressByCoord' import { CInput } from '../CInput' import { CMyEditor } from '../CMyEditor' +import { CMyEditorAI } from '../CMyEditorAI' import { CGallery } from '../CGallery' import { CSelectImage } from '../CSelectImage' import { CAccomodation } from '../CAccomodation' @@ -219,7 +220,7 @@ export default defineComponent({ }, }, components: { - CMyChipList, CDateTime, CDate, CMyToggleList, CMySelect, CMyEditor, CGallery, + CMyChipList, CDateTime, CDate, CMyToggleList, CMySelect, CMyEditor, CGallery, CMyEditorAI, CCurrencyValue, CLabel, CAccomodation, CSelectImage, CMapEditAddressByCoord, CInput, }, setup(props, { emit }) { @@ -254,6 +255,27 @@ export default defineComponent({ minlength: props.mycol ? props.mycol.minlength : undefined }) + const copyToClipboard = (text) => { + navigator.clipboard.writeText(text) + .then(() => { + $q.notify({ + message: 'Testo copiato negli appunti!', + color: 'positive', + icon: 'check', + position: 'top' + }); + }) + .catch(err => { + console.error('Errore durante la copia:', err); + $q.notify({ + message: 'Errore nella copia', + color: 'negative', + icon: 'error', + position: 'top' + }); + }); + }; + const { setValDb, getValDb } = MixinBase() const { getMyUsername } = MixinUsers() @@ -414,7 +436,7 @@ export default defineComponent({ } function changevalRecOrig(newval: any, subcol: string = '') { - console.log('changevalRec', newval) + // console.log('changevalRec', newval) // if (!props.insertMode || (props.insertMode && col.value.fieldtype !== costanti.FieldType.multioption)) { if (col.value && col.value.allowchar === costanti.ALLOWCHAR_CODE) { newval = tools.removespaces_slash(newval) @@ -481,8 +503,7 @@ export default defineComponent({ } function mounted() { - console.log('mounted CMyPopupEdit') - + //console.log('mounted CMyPopupEdit') myrow.value = props.rec && props.isrec ? { ...props.rec } : { ...props.row } @@ -928,6 +949,7 @@ export default defineComponent({ } } + onBeforeMount(mounted) @@ -975,6 +997,7 @@ export default defineComponent({ handleKeydown, handleCancel, popupEditRef, + copyToClipboard, } } }) diff --git a/src/components/CMyPopupEdit/CMyPopupEdit.vue b/src/components/CMyPopupEdit/CMyPopupEdit.vue index 854a161f..8f379e99 100755 --- a/src/components/CMyPopupEdit/CMyPopupEdit.vue +++ b/src/components/CMyPopupEdit/CMyPopupEdit.vue @@ -183,6 +183,36 @@ +
+
+ + + +
+ {{ $t('dialog.condition') }} +
+ + +
+
+
+
+ + +
@@ -1097,6 +1143,25 @@
+
+
+ + +
+
editore._id === receditore) - editorestr.value += rectrovato.name + ' ' + editorestr.value += rectrovato?.name + ' ' } } diff --git a/src/components/CProductTable/CProductTable.ts b/src/components/CProductTable/CProductTable.ts index f58fc328..81223487 100755 --- a/src/components/CProductTable/CProductTable.ts +++ b/src/components/CProductTable/CProductTable.ts @@ -106,8 +106,8 @@ export default defineComponent({ // Colonne della tabella const allColumns = [ - { name: "pos", label: "Pos", field: "pos", align: "left", style: "width: 50px" }, - { name: "drag", label: "Ordinam.", field: "", align: "left", style: "width: 50px", edit: true }, + { name: "pos", label: "Ind", field: "pos", align: "left", style: "width: 50px" }, + { name: "drag", label: "Ord", field: "", align: "left", style: "width: 50px", edit: true }, { name: "image", label: "Foto", field: "image", align: "center" }, { name: "name", label: "Titolo del Libro", field: "name", align: "left" }, { name: "authors", label: "Autore", field: "authors", align: "left" }, @@ -125,11 +125,11 @@ export default defineComponent({ //{ name: "rank6M", label: "Class. 6M", field: "rank6M", align: "right", visu: costanti.VISUCAMPI.PER_EDITORE }, //{ name: "rank1Y", label: "Class. 1Y", field: "rank1Y", align: "right", visu: costanti.VISUCAMPI.PER_EDITORE }, { name: "pagine", label: "Pag.", field: "pagine", align: "right" }, - { name: "totVen", label: "Venduti", field: "totVen", align: "right", visu: costanti.VISUCAMPI.PER_EDITORE }, - { name: "totFat", label: "Fattur.", field: "totFat", align: "right", visu: costanti.VISUCAMPI.PER_EDITORE }, + { name: "totVen", label: "Vend", field: "totVen", align: "right", visu: costanti.VISUCAMPI.PER_EDITORE }, { name: "fatLast6M", label: "Fat 6M", field: "fatLast6M", align: "right", visu: costanti.VISUCAMPI.PER_EDITORE }, - { name: "fatLast1Y", label: "Fat Anno", field: "fatLast1Y", align: "right", visu: costanti.VISUCAMPI.PER_EDITORE }, + { name: "fatLast1Y", label: "Fat 1A", field: "fatLast1Y", align: "right", visu: costanti.VISUCAMPI.PER_EDITORE }, { name: "fatLast2Y", label: "Fat 2A", field: "fatLast2Y", align: "right", visu: costanti.VISUCAMPI.PER_EDITORE }, + { name: "totFat", label: "Fat 5A", field: "totFat", align: "right", visu: costanti.VISUCAMPI.PER_EDITORE }, { name: "ult_ord", label: "Ult. Ordine", field: "ult_ord", align: "left", visu: costanti.VISUCAMPI.PER_EDITORE }, { name: "quantity", label: "Magazz.", field: "quantity", align: "right", visu: costanti.VISUCAMPI.PER_EDITORE }, { name: "actions", label: "Azioni", field: "", align: "center", visu: costanti.VISUCAMPI.PER_EDITORE }, @@ -202,6 +202,9 @@ export default defineComponent({ case 'fatLast1Y': return element.productInfo?.fatLast1Y; + case 'fatLast2Y': + return element.productInfo?.fatLast2Y; + case 'ult_ord': return tools.getstrDate(element.productInfo?.dataUltimoOrdine); @@ -254,6 +257,7 @@ export default defineComponent({ case 'totFat': case 'fatLast6M': case 'fatLast1Y': + case 'fatLast2Y': default: return ''; @@ -268,14 +272,12 @@ export default defineComponent({ height: '50px' }; - case 'rank3M': - case 'rank6M': - case 'rank1Y': case 'pagine': case 'totVen': case 'totFat': case 'fatLast6M': case 'fatLast1Y': + case 'fatLast2Y': case 'quantity': return { textAlign: 'right' @@ -308,7 +310,15 @@ export default defineComponent({ // 3. Funzione per verificare se una colonna è visibile (isColumnVisible) - const isColumnVisible = (column) => { + const isColumnVisible = (column, real?: boolean) => { + if (column === 'actions' && !real) { + return false + } + if (internalProducts.value?.length > 1000) { + if (column === 'image') { + return false + } + } const ok = allColumns.some((col) => col.name === column) && (!props.optcatalogo.showListaArgomenti || (props.optcatalogo.showListaArgomenti && !column.edit)) return selectedColumns.value.includes(column) && ok; } @@ -458,11 +468,6 @@ export default defineComponent({ case 'image': return () => showProduct(element); - case 'name': - case 'authors': - case 'isbn': - return () => showProduct(element); - case 'stato': return () => { // esempio: mostra dettagli dello stato diff --git a/src/components/CProductTable/CProductTable.vue b/src/components/CProductTable/CProductTable.vue index c0ba4a2b..b959eab6 100755 --- a/src/components/CProductTable/CProductTable.vue +++ b/src/components/CProductTable/CProductTable.vue @@ -12,7 +12,7 @@ option-value="name" option-label="label" filled - style="max-width: 400px" + style="max-width: 300px" />
@@ -108,7 +108,7 @@ {{ getFieldValue(element, field) }} - + -
Cerca un Titolo:
+
QUESTO MOVIMENTO È REALE E POSSIBILE SE LO FACCIAMO FUNZIONARE TUTTI INSIEME !', }, dialog: { + conditionAND: 'Filtra se Tutti i criteri sono veri (AND)', + conditionOR: 'Filtra se almeno uno dei criteri è vero (OR)', + condition: 'Condizione', azzera: 'Azzera', continue: 'Continuare', close: 'Chiudi', @@ -2024,6 +2030,7 @@ const msg_it = { }, cataloglist: { + op_andor: 'Condizione', casaeditrice: 'Casa Editrice', numprodotti: 'Libri presenti', foto_collana: 'Foto Catalogo', diff --git a/src/store/Modules/costanti.ts b/src/store/Modules/costanti.ts index 784239bc..28acaedc 100755 --- a/src/store/Modules/costanti.ts +++ b/src/store/Modules/costanti.ts @@ -482,6 +482,8 @@ export const costanti = { cards: 16000, color: 17000, arrmenu: 18000, + op_andor: 19000, + editor_nohtml: 20000, }, @@ -543,4 +545,9 @@ export const costanti = { PER_ADMIN: 16, }, + OP_ANDOR: { + OP_OR: 0, + OP_AND: 1, + } + } diff --git a/src/store/Modules/fieldsTable.ts b/src/store/Modules/fieldsTable.ts index 7f8b49cc..bdaffec7 100755 --- a/src/store/Modules/fieldsTable.ts +++ b/src/store/Modules/fieldsTable.ts @@ -150,19 +150,24 @@ export const colTableCatalogList = [ name: 'argomenti', label_trans: 'cataloglist.argomenti', fieldtype: costanti.FieldType.multiselect, - jointable: 'catprods', + jointable: 'catprtotali', + }), + AddCol({ + name: 'condition_andor', + label_trans: 'cataloglist.op_andor', + fieldtype: costanti.FieldType.op_andor, }), AddCol({ name: 'idCollane', label_trans: 'cataloglist.collane', fieldtype: costanti.FieldType.multiselect, - jointable: 'collanas', + jointable: 'collanastotali', }), AddCol({ name: 'editore', label_trans: 'cataloglist.editore', fieldtype: costanti.FieldType.multiselect, - jointable: 'publishers', + jointable: 'publishers_totali', }), AddCol({ name: 'descr_introduttiva', label_trans: 'cataloglist.descr_introduttiva', fieldtype: costanti.FieldType.html, maxlength: 1300 }), @@ -2587,6 +2592,9 @@ export const colTableProductInfos = [ AddCol({ name: 'date', label_trans: 'products.date', fieldtype: costanti.FieldType.date }), AddCol({ name: 'link_scheda', label_trans: 'products.link_scheda' }), AddCol({ name: 'ingredienti', label_trans: 'products.ingredienti', fieldtype: costanti.FieldType.html }), + AddCol({ name: 'descrizione_breve_macro', label_trans: 'products.descrizione_breve_macro', fieldtype: costanti.FieldType.editor_nohtml }), + AddCol({ name: 'descrizione_completa_macro', label_trans: 'products.descrizione_completa_macro', fieldtype: costanti.FieldType.editor_nohtml }), + AddCol({ name: 'descr_trafiletto_catalogo', label_trans: 'products.descr_trafiletto_catalogo', fieldtype: costanti.FieldType.editor_nohtml }), AddCol({ name: 'valori_nutrizionali', label_trans: 'products.valori_nutrizionali', fieldtype: costanti.FieldType.html }), AddCol({ name: 'author', label_trans: 'products.author', fieldtype: costanti.FieldType.string }), AddCol({ name: 'collezione', label_trans: 'products.collezione', fieldtype: costanti.FieldType.string }), @@ -4395,6 +4403,13 @@ export const fieldsTable = { colkey: '_id', collabel: 'name', }, + { + value: 'catprtotali', + label: 'Categorie', + columns: colTableCatProd, + colkey: '_id', + collabel: (row: any) => row.name + ' (' + row.quanti + ')', + }, { value: 't_web_statiprodottos', label: 'Stati Prodotto', @@ -4423,6 +4438,13 @@ export const fieldsTable = { colkey: '_id', collabel: 'title', }, + { + value: 'collanastotali', + label: 'Collane Totali', + columns: colTableCollane, + colkey: '_id', + collabel: (row: any) => row.title + ' (' + row.quanti + ')', + }, { value: 'publishers', label: 'Nome', @@ -4430,6 +4452,13 @@ export const fieldsTable = { colkey: '_id', collabel: 'name', }, + { + value: 'publishers_totali', + label: 'Nome', + columns: colTablePublisher, + colkey: '_id', + collabel: (row: any) => row.name + ' (' + row.quanti + ')', + }, { value: 'catais', label: 'Categorie AI', diff --git a/src/store/Products.ts b/src/store/Products.ts index ac5c336c..e7b387b8 100755 --- a/src/store/Products.ts +++ b/src/store/Products.ts @@ -1,4 +1,4 @@ -import type { IBaseOrder, ICart, IOrder, IOrderCart, IProduct, IProductsState, IProductInfo, ICatProd, IUserShort, IGasordine, IAuthor, ISubCatProd, IText, IOptCatalogo, ICatalog, ICatPrTotali, ISingleProductOrdered, ISchedaSingola, IMyScheda, IElementiScheda, T_Web_StatiProdotto, T_Web_Tipologie, T_WEB_TipiFormato, IPublisher } from 'model' +import type { IBaseOrder, ICart, IOrder, IOrderCart, IProduct, IProductsState, IProductInfo, ICatProd, IUserShort, IGasordine, IAuthor, ISubCatProd, IText, IOptCatalogo, ICatalog, ICatPrTotali, ISingleProductOrdered, ISchedaSingola, IMyScheda, IElementiScheda, T_Web_StatiProdotto, T_Web_Tipologie, T_WEB_TipiFormato, IPublisher, ICollaneTotali } from 'model' import { Api } from '@api' import { serv_constants } from '@src/store/Modules/serv_constants' @@ -352,6 +352,15 @@ export const useProducts = defineStore('Products', { return 0 }, + getTotaliProdottiByIdCollana: (state: IProductsState) => (idCollana: string): number => { + const myfirstcat = state.collanetotali!.find((rec: ICollaneTotali) => rec._id === idCollana) + + if (myfirstcat) { + return myfirstcat.quanti! + } + return 0 + }, + getSubCatProdsByGas: (state: IProductsState) => (idGasOrdine: string, idCatProd: string): ISubCatProd[] => { let arrcat = state.subcatprods @@ -696,7 +705,7 @@ export const useProducts = defineStore('Products', { }, - async loadProducts() { + async loadProducts(loadonlyifempty?: boolean) { const userStore = useUserStore() const globalStore = useGlobalStore() @@ -712,6 +721,11 @@ export const useProducts = defineStore('Products', { // return new Types.AxiosError(0, null, 0, '') // } + if (loadonlyifempty) { + if (this.products?.length > 0) + return true + } + let ris = null let myIdActiveSelected = userStore.my._id @@ -1515,7 +1529,7 @@ export const useProducts = defineStore('Products', { replacements['{collana}'] = tools.formatCollane(myproduct.productInfo.idCollana) || ''; } - const maxDescriptionLength = testo.maxlength ?? 100; + const maxDescriptionLength = testo.maxlength || 600; if (testo.contenuto.includes('{descrizione_da_fdv}')) { const description = myproduct.productInfo.short_descr || ''; @@ -1534,7 +1548,7 @@ export const useProducts = defineStore('Products', { if (testo.contenuto.includes('{descrizione_estesa}')) { let addtesto = false; const long_descr_macro = myproduct.productInfo.descrizione_completa_macro || ''; - if (long_descr_macro.length > maxDescriptionLength) { + if (long_descr_macro.length > maxDescriptionLength && maxDescriptionLength > 0) { addtesto = true; } const addstrcontinua = '👉🏻 continua a leggere'; @@ -1550,14 +1564,14 @@ export const useProducts = defineStore('Products', { if (testo.contenuto.includes('{descrizione_breve_macro}')) { const short_descr = myproduct.productInfo.descrizione_breve_macro || ''; - replacements['{descrizione_breve_macro}'] = short_descr.length > maxDescriptionLength + replacements['{descrizione_breve_macro}'] = short_descr.length > maxDescriptionLength && maxDescriptionLength > 0 ? short_descr.substring(0, short_descr.lastIndexOf(' ', maxDescriptionLength)) + '...' : short_descr; } if (testo.contenuto.includes('{descr_trafiletto_catalogo}')) { const short_descr = myproduct.productInfo.descr_trafiletto_catalogo || ''; - replacements['{descr_trafiletto_catalogo}'] = short_descr.length > maxDescriptionLength + replacements['{descr_trafiletto_catalogo}'] = short_descr.length > maxDescriptionLength && maxDescriptionLength > 0 ? short_descr.substring(0, short_descr.lastIndexOf(' ', maxDescriptionLength)) + '...' : short_descr; } diff --git a/src/store/globalStore.ts b/src/store/globalStore.ts index b42f0689..1e0c2a26 100644 --- a/src/store/globalStore.ts +++ b/src/store/globalStore.ts @@ -440,11 +440,14 @@ export const useGlobalStore = defineStore('GlobalStore', { else if (table === 'departments') ris = state.departments else if (table === 'categorys') ris = state.categories else if (table === 'catprods') ris = Products.catprods + else if (table === 'catprtotali') ris = Products.catprtotali else if (table === 'collanas') ris = Products.collane + else if (table === 'collanastotali') ris = Products.collane else if (table === 'subcatprods') ris = Products.subcatprods else if (table === 'catprods_gas') ris = Products.catprods_gas else if (table === 'authors') ris = Products.authors else if (table === 'publishers') ris = Products.publishers + else if (table === 'publishers_totali') ris = Products.publishers else if (table === 't_web_statiprodottos') ris = Products.stati_prodotto else if (table === 't_web_tipologies') ris = Products.tipologie else if (table === 't_web_tipiformatos') ris = Products.tipoformato diff --git a/src/views/admin/gestoreordini/gestoreordini.ts b/src/views/admin/gestoreordini/gestoreordini.ts index 0289719a..a017c0ce 100755 --- a/src/views/admin/gestoreordini/gestoreordini.ts +++ b/src/views/admin/gestoreordini/gestoreordini.ts @@ -162,7 +162,7 @@ export default defineComponent({ storeGasordine.value = tools.getCookie(tools.COOK_SELGAS, '') await userStore.newsletterload(false) - await productStore.loadProducts() + await productStore.loadProducts(true) taborders.value = -1 diff --git a/src/views/ecommerce/cash/cash.ts b/src/views/ecommerce/cash/cash.ts index 031b1ead..103c5cc3 100755 --- a/src/views/ecommerce/cash/cash.ts +++ b/src/views/ecommerce/cash/cash.ts @@ -78,7 +78,7 @@ export default defineComponent({ async function mounted() { loadpage.value = false - await productStore.loadProducts() + await productStore.loadProducts(true) cosa.value = tools.getCookie(tools.COOK_COSA_PRODOTTI, shared_consts.PROD.TUTTI, true) // Inizializza loadpage.value = true diff --git a/src/views/ecommerce/catalogo/catalogo.ts b/src/views/ecommerce/catalogo/catalogo.ts index 614cb685..c708ac8c 100755 --- a/src/views/ecommerce/catalogo/catalogo.ts +++ b/src/views/ecommerce/catalogo/catalogo.ts @@ -26,6 +26,7 @@ import type { IText, ICollana, IOptRigenera, + IOpAndOr, } from 'model'; import { IMyPage, @@ -107,8 +108,8 @@ export default defineComponent({ }, { deep: false }); watch(optrigenera.value, (newVal) => { - tools.setCookie((showListaArgomenti.value ? 'INC_ES_' : '') +'VIS_DISP', newVal.visibilitaDisp); - tools.setCookie((showListaArgomenti.value ? 'INC_ES_' : '') +'VIS_STATO', newVal.stato); + tools.setCookie((showListaArgomenti.value ? 'INC_ES_' : '') + 'VIS_DISP', newVal.visibilitaDisp); + tools.setCookie((showListaArgomenti.value ? 'INC_ES_' : '') + 'VIS_STATO', newVal.stato); if (showListaArgomenti.value) calcArrProducts() }, { deep: true }); @@ -243,12 +244,14 @@ export default defineComponent({ watch(() => cat.value, (newval, oldval) => { - if (loadpage.value) { - tools.setCookie(getKeyCatAtLoad(), cat.value.toString()) - filter.value.author = '' // disattivo il filtro autore - resetSearch() + if (showListaArgomenti.value) { + if (loadpage.value) { + tools.setCookie(getKeyCatAtLoad(), cat.value.toString()) + filter.value.author = '' // disattivo il filtro autore + resetSearch() - calcArrProducts() + calcArrProducts() + } } }) @@ -489,6 +492,7 @@ export default defineComponent({ editore: string[], idCollane: string[], arrargomstr: any[], + op_andor: IOpAndOr, catstr: string, gasselstr: string, cosaValue: any, @@ -505,7 +509,11 @@ export default defineComponent({ const boolfiltroVuotoidTipologie = filtroidTipologie.length === 0; const boolfiltroVuotoEditore = editore.length === 0; const boolfiltroVuotoCollane = idCollane.length === 0; - // const boolfiltroVuotoArgomenti = arrargomstr.length === 0; + const boolfiltroVuotoArgomenti = arrargomstr.length === 0; + + const se_tutti_veri = op_andor.condition_andor === costanti.OP_ANDOR.OP_AND; + + const trovatocatalogo = getCatalogoByMyPage.value const arrris = products .filter((product: IProduct) => { @@ -536,20 +544,32 @@ export default defineComponent({ const lowerName = (product.productInfo.name || '').toLowerCase(); const lowerCode = (product.productInfo.code || '').toLowerCase(); + const boolfiltroVuotoCat = product.productInfo.idCatProds?.length === 0 + // Filtri per argomenti e categorie - let hasCategoria = false; - let hasArgomentiCat = true; + let hasCategoria = se_tutti_veri; + let hasArgomentiCat = se_tutti_veri; if (arrargomstr && arrargomstr.length > 0) { hasArgomentiCat = (product.productInfo.idCatProds || []).some((idCat: any) => arrargomstr.includes(idCat)); - hasCategoria = true; + hasCategoria = se_tutti_veri; } else { - if (catstr === costanti.NO_CATEGORY) { - hasCategoria = product.productInfo.idCatProds?.length === 0 + if (!optcatalogo.value.showListaArgomenti) { + } else { - hasCategoria = !catstr || (catstr && (product.productInfo.idCatProds || []).includes(catstr)); + hasCategoria = (catstr === costanti.NO_CATEGORY) + ? (boolfiltroVuotoCat ? se_tutti_veri : product.productInfo.idCatProds.length === 0) + : !catstr || (product.productInfo.idCatProds || []).includes(catstr); + + hasArgomentiCat = boolfiltroVuotoArgomenti + ? se_tutti_veri + : hasArgomentiCat } } + /*hasArgomentiCat = boolfiltroVuotoArgomenti + ? se_tutti_veri + : hasArgomentiCat*/ + // Filtri per autore const hasAuthor = !filtroAuthor || (product.productInfo.idAuthors || []).includes(filtroAuthor); @@ -569,13 +589,13 @@ export default defineComponent({ // Filtri per editore const hasPublished = boolfiltroVuotoEditore - ? true + ? se_tutti_veri : editore.includes(product.productInfo.idPublisher); // Filtri per collana const hasCollana = boolfiltroVuotoCollane - ? true - : (idCollane || []).includes(product.productInfo.idCollana?.toString()) + ? se_tutti_veri + : (idCollane || []).includes(product.productInfo.idCollana) // Filtri per GAS const productgassel = !gasselstr || (cosaValue === shared_consts.PROD.GAS && product.idGasordine === gasselstr); @@ -589,20 +609,24 @@ export default defineComponent({ return codeMatch || allWordsPresent; }); - return ( - searchMatch && - hasAuthor && - productgassel && - hasidTipologie && - // hasProductTypes && - ( - hasPublished && - hasCollana && - hasCategoria && - hasArgomentiCat - ) - // && !hasExcludeProductTypes - ); + // Funzione che valuta un gruppo in base a OP_AND o OP_OR + + // Raccolgo tutti i gruppi attivi + const filtri = [hasArgomentiCat, hasCategoria, hasCollana, hasPublished]; + + // Decido se combinare in AND o OR sulla base della scelta globale + let risult = searchMatch && hasAuthor && productgassel && hasidTipologie + + if (op_andor.condition_andor === costanti.OP_ANDOR.OP_AND) { + risult = risult && filtri.every(Boolean); // Tutti i gruppi devono essere veri + } else { + risult = risult && filtri.some(Boolean) + } + + return risult + + // && !hasExcludeProductTypes + }) .sort((a, b) => getProductsSorted([a, b], sortField, sortDir)[0] === a ? -1 : 1); @@ -654,6 +678,10 @@ export default defineComponent({ generalista = true }*/ + let op_andor: IOpAndOr = { + condition_andor: trovatocatalogo?.condition_andor !== undefined ? trovatocatalogo.condition_andor : costanti.OP_ANDOR.OP_AND, + } + if (!generalista && (trovatocatalogo?.lista_prodotti.length > 0)) { arrprod = trovatocatalogo?.lista_prodotti } else { @@ -668,6 +696,7 @@ export default defineComponent({ filtroPublishers, filtroCollane, arrargomstr, + op_andor, catstr, gasselstr, cosa.value, @@ -749,6 +778,11 @@ export default defineComponent({ const gasselstr = cosa.value === shared_consts.PROD.GAS ? idGasSel.value || '' : ''; const trovatocatalogo = getCatalogoByMyPage.value + + let op_andor: IOpAndOr = { + condition_andor: trovatocatalogo?.condition_andor ?? costanti.OP_ANDOR.OP_AND, + } + if (trovatocatalogo?.lista_prodotti.length > 0) { arrprod = trovatocatalogo?.lista_prodotti } else { @@ -764,6 +798,7 @@ export default defineComponent({ filtroPublishers, filtroCollane, arrargomstr, + op_andor, catstr, gasselstr, cosa.value, @@ -785,7 +820,7 @@ export default defineComponent({ function getProductsSorted(arrprod: IProduct[], sort_field: string, sort_dir: number): IProduct[] { if (sort_field) { - console.log('--- Primi 10 elementi INIZIALI:'); + // console.log('--- Primi 10 elementi INIZIALI:'); arrprod.slice(0, 15).forEach((product, index) => { console.log( `${index + 1}. ${product.productInfo?.name} (${product.productInfo?.date_pub})` @@ -817,7 +852,7 @@ export default defineComponent({ // logga i primi N elementi, mostrando il nome del prodotto (productInfo.name e la data di pibblicazione : productinfo.date_pub if (sortedArr.length > 0) { - console.log('Primi 15 elementi ordinati: ***** '); + // console.log('Primi 15 elementi ordinati: ***** '); sortedArr.slice(0, 15).forEach((product, index) => { console.log( `${index + 1}. ${product.productInfo?.name} (${product.productInfo?.date_pub})` @@ -1053,15 +1088,16 @@ export default defineComponent({ generatinglist.value = true - cat.value = tools.getCookie(getKeyCatAtLoad(), '') + if (showListaArgomenti.value) + cat.value = tools.getCookie(getKeyCatAtLoad(), '') tabcatalogo.value = tools.getCookie('TAB_CAT', 'visu') optrigenera.value.visibilitaDisp = tools.getCookie((showListaArgomenti.value ? 'INC_ES_' : '') + 'VIS_DISP', costanti.DISP.DISPONIBILI) - optrigenera.value.stato = tools.getCookie((showListaArgomenti.value ? 'INC_ES_' : '') +'VIS_STATO', costanti.STATO.IN_COMMERCIO) + optrigenera.value.stato = tools.getCookie((showListaArgomenti.value ? 'INC_ES_' : '') + 'VIS_STATO', costanti.STATO.IN_COMMERCIO) loadpage.value = false - await productStore.loadProducts() + await productStore.loadProducts(true) mycolumns.value = fieldsTable.getArrColsByTable('products') @@ -1120,7 +1156,7 @@ export default defineComponent({ ); } - + // productStore.getTotaliProdottiByIdCollana(rec._id) function onLoadScroll(index: number, done: any) { if (index >= 1) { diff --git a/src/views/ecommerce/catalogo/catalogo.vue b/src/views/ecommerce/catalogo/catalogo.vue index 0c04c1ce..c8b0dbcc 100755 --- a/src/views/ecommerce/catalogo/catalogo.vue +++ b/src/views/ecommerce/catalogo/catalogo.vue @@ -8,10 +8,10 @@ {{ getTitoloCatalogo() }}
- {{$t('cataloglist.referenti')}}: {{ getReferentiCatalogo() }} + {{ $t('cataloglist.referenti') }}: {{ getReferentiCatalogo() }}
-
- - - - - - - +
+
+ + +
+
+ + + + + + +