Aggiornamento cataloghi...

This commit is contained in:
Surya Paolo
2025-04-11 18:49:42 +02:00
parent cea3bcfa0e
commit 3616e2ca0f
44 changed files with 593 additions and 206 deletions

View File

@@ -9,3 +9,5 @@ DIRECTORY_LOCAL="myprojplanet_vite"
DIRECTORY_SERVER="/var/www/nodejs_piuchebuono_server" DIRECTORY_SERVER="/var/www/nodejs_piuchebuono_server"
SERVERDIR_WEBSITE="/var/www/gruppomacro.app" SERVERDIR_WEBSITE="/var/www/gruppomacro.app"
SERVERPW_WEBSITE="pwdadmin@1AOK" SERVERPW_WEBSITE="pwdadmin@1AOK"
PORT_SPA="8089"
PORT_PWA="8099"

1
.gitignore vendored
View File

@@ -36,3 +36,4 @@ upload/
._upload ._upload
scripts/localhost.pem scripts/localhost.pem
scripts/localhost-key.pem scripts/localhost-key.pem
scripts/_ALL_SITES/

View File

@@ -10,7 +10,7 @@
<meta name="description" content="<%= productDescription %>"> <meta name="description" content="<%= productDescription %>">
<meta name="format-detection" content="telephone=no"> <meta name="format-detection" content="telephone=no">
<meta name="msapplication-tap-highlight" content="no"> <meta name="msapplication-tap-highlight" content="no">
<meta name="version" content="1.2.32"> <meta name="version" content="1.2.33">
<meta name="viewport" <meta name="viewport"
content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width<% if (ctx.mode.cordova || ctx.mode.capacitor) { %>, viewport-fit=cover<% } %>"> content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width<% if (ctx.mode.cordova || ctx.mode.capacitor) { %>, viewport-fit=cover<% } %>">

View File

@@ -1,6 +1,6 @@
{ {
"name": "gruppomacro", "name": "gruppomacro",
"version": "1.2.32", "version": "1.2.33",
"description": "Gruppo Macro", "description": "Gruppo Macro",
"productName": "Gruppo Macro", "productName": "Gruppo Macro",
"author": "Surya", "author": "Surya",
@@ -9,20 +9,20 @@
"license": "MIT", "license": "MIT",
"type": "module", "type": "module",
"scripts": { "scripts": {
"dev": "PORT=8089 APP_VERSION='1.2.32' quasar dev", "dev": "PORT=8089 APP_VERSION='1.2.33' quasar dev",
"dev_noCheck": "SKIP_TSC=true quasar dev", "dev_noCheck": "SKIP_TSC=true quasar dev",
"build": "quasar build", "build": "quasar build",
"buildpwa": "NODE_ENV=production APP_VERSION='1.2.32' quasar build -m pwa", "buildpwa": "NODE_ENV=production APP_VERSION='1.2.33' quasar build -m pwa",
"buildpwatest": "NODE_ENV=production APP_VERSION='1.2.32' quasar build -m pwa", "buildpwatest": "NODE_ENV=production APP_VERSION='1.2.33' quasar build -m pwa",
"type-check": "vue-tsc --noEmit", "type-check": "vue-tsc --noEmit",
"type-check:watch": "vue-tsc --noEmit --watch", "type-check:watch": "vue-tsc --noEmit --watch",
"buildspa": "APP_VERSION='1.2.32' quasar build -m spa", "buildspa": "APP_VERSION='1.2.33' quasar build -m spa",
"lint": "eslint -c ./eslint.config.js \"./src*/**/*.{ts,js,cjs,mjs,vue}\"", "lint": "eslint -c ./eslint.config.js \"./src*/**/*.{ts,js,cjs,mjs,vue}\"",
"lintfile": "eslint --ext .js,.ts,.vue --ignore-path .gitignore ./ > file.out.txt", "lintfile": "eslint --ext .js,.ts,.vue --ignore-path .gitignore ./ > file.out.txt",
"lintfileNoJS": "eslint --ext .ts,.vue --ignore-path .gitignore ./ > file.out.txt", "lintfileNoJS": "eslint --ext .ts,.vue --ignore-path .gitignore ./ > file.out.txt",
"fix": "eslint -c ./eslint.config.js \"./src*/**/*.{ts,js,cjs,mjs,vue}\" --ignore-pattern .gitignore ./ --fix > file.out.txt", "fix": "eslint -c ./eslint.config.js \"./src*/**/*.{ts,js,cjs,mjs,vue}\" --ignore-pattern .gitignore ./ --fix > file.out.txt",
"pwa": "NODE_ENV=development PORT=8099 APP_VERSION='1.2.32' quasar dev -m pwa", "pwa": "NODE_ENV=development PORT=8099 APP_VERSION='1.2.33' quasar dev -m pwa",
"spa": "NODE_ENV=development PORT=8089 APP_VERSION='1.2.32' quasar dev", "spa": "NODE_ENV=development PORT=8089 APP_VERSION='1.2.33' quasar dev",
"debug": "quasar dev --mode debug", "debug": "quasar dev --mode debug",
"test": "echo \"No test specified\" && exit 0", "test": "echo \"No test specified\" && exit 0",
"generate-sw": "workbox generateSW workbox-config.js", "generate-sw": "workbox generateSW workbox-config.js",

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
public/fonts/DINPro-CondBlack.otf Executable file

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
public/fonts/DINPro.otf Normal file

Binary file not shown.

BIN
public/fonts/font_maps.ttf Normal file

Binary file not shown.

BIN
public/fonts/font_maps.woff Normal file

Binary file not shown.

BIN
public/fonts/gogocarto.woff Normal file

Binary file not shown.

View File

@@ -1 +1 @@
TERMINA DI LAVORARE SU riso.app: (Sovrascrivo!) TERMINA DI LAVORARE SU piuchebuono.app: (Sovrascrivo!)

View File

@@ -3,7 +3,7 @@
/* global workbox */ /* global workbox */
/* global cfgenv */ /* global cfgenv */
const VITE_APP_VERSION = "1.2.32"; const VITE_APP_VERSION = "1.2.33";
// Costanti di configurazione // Costanti di configurazione
const DYNAMIC_CACHE = 'dynamic-cache-v2'; const DYNAMIC_CACHE = 'dynamic-cache-v2';

View File

@@ -2392,13 +2392,13 @@ export const shared_consts = {
ORDINAMENTO_CATALOGHI_PUBBLICO: [ ORDINAMENTO_CATALOGHI_PUBBLICO: [
{ label: '[Nessuno]', value: '' }, { label: '[Nessuno]', value: '' },
{ label: 'Alfabetico', value: 'name' }, { label: 'Alfabetico', value: 'name' },
{ label: 'Data di Pubblicazione', value: 'date_pub_ts' }, { label: 'Data di Pubblicazione', value: 'date_pub' },
], ],
ORDINAMENTO_CATALOGHI: [ ORDINAMENTO_CATALOGHI: [
{ label: '[Nessuno]', value: '' }, { label: '[Nessuno]', value: '' },
{ label: 'Alfabetico', value: 'name' }, { label: 'Alfabetico', value: 'name' },
{ label: 'Data di Pubblicazione', value: 'date_pub_ts' }, { label: 'Data di Pubblicazione', value: 'date_pub' },
{ label: 'Totale Venduti', value: 'totVen' }, { label: 'Totale Venduti', value: 'totVen' },
{ label: 'Totale Fatturati', value: 'totFat' }, { label: 'Totale Fatturati', value: 'totFat' },
{ label: 'Venduti Ultimi 3 Mesi', value: 'vLast3M' }, { label: 'Venduti Ultimi 3 Mesi', value: 'vLast3M' },
@@ -2406,6 +2406,7 @@ export const shared_consts = {
{ label: 'Venduti Ultimo Anno', value: 'vLastY' }, { label: 'Venduti Ultimo Anno', value: 'vLastY' },
{ label: 'Venduti Ultimi 2 Anni', value: 'vLast2Y' }, { label: 'Venduti Ultimi 2 Anni', value: 'vLast2Y' },
{ label: 'Fatturati Ultimi 3 Mesi', value: 'fatLast3M' }, { label: 'Fatturati Ultimi 3 Mesi', value: 'fatLast3M' },
{ label: 'Fatturati Ultimi 6 Mesi', value: 'fatLast6M' },
{ label: 'Data Ultimo Ordine', value: 'dataUltimoOrdine' }, { label: 'Data Ultimo Ordine', value: 'dataUltimoOrdine' },
], ],
@@ -2473,6 +2474,7 @@ export const shared_consts = {
CmdQueryMs: { CmdQueryMs: {
GET: 0, GET: 0,
SET: 1, SET: 1,
UPDATE: 2,
}, },
SCHEDA_PRODOTTO: { SCHEDA_PRODOTTO: {

View File

@@ -115,7 +115,9 @@ export default defineComponent({
const apriSchedaPDF = ref(false) const apriSchedaPDF = ref(false)
const visufromgm = ref(false) const visufromgm = ref(false)
const updatelocaldb = ref(false)
const updatefromgm = ref(false) const updatefromgm = ref(false)
const updatetogm = ref(false)
const showQtaDisponibile = ref(false) const showQtaDisponibile = ref(false)
const field_updated_fromGM = ref('') const field_updated_fromGM = ref('')
@@ -312,7 +314,7 @@ export default defineComponent({
if (carica) { if (carica) {
myproduct.value = null; myproduct.value = null;
updateproductmodif() updateproductmodif(null)
} }
// products.updateQuantityAvailable(myproduct.value._id) // products.updateQuantityAvailable(myproduct.value._id)
@@ -334,9 +336,9 @@ export default defineComponent({
console.log('CCATALOGOCARD: updateproductmodif') console.log('CCATALOGOCARD: updateproductmodif')
try { try {
if (element?._id) { if (element?._id) {
myproduct.value = await products.getProductById(element?._id) myproduct.value = await products.getProductById(element?._id, true)
} else { } else {
myproduct.value = await products.getProductById(props.id) myproduct.value = await products.getProductById(props.id, true)
} }
updateLabel() updateLabel()
@@ -627,8 +629,8 @@ export default defineComponent({
function isProductBestseller() { function isProductBestseller() {
try { try {
//return myproduct.value!.productInfo.rank1Y! > 0 && (myproduct.value!.productInfo.rank1Y! < props.scheda.etichette?.bestseller?.primiNInClassifica!) // diventa un bestseller quando il rank6M è tra i primi 10 ordinandoli per rank6M
return myproduct.value!.indiceRanking! > 0 && (myproduct.value!.indiceRanking! < props.scheda.etichette?.bestseller?.primiNInClassifica) return myproduct.value!.productInfo.rank6M! > 0 && (myproduct.value!.productInfo.rank6M!)
} catch (e) { } catch (e) {
return false return false
} }
@@ -643,6 +645,19 @@ export default defineComponent({
} }
async function refreshDataFromGM() { async function refreshDataFromGM() {
if (myproduct.value) {
loading.value = true
updatefromgm.value = true
field_updated_fromGM.value = ''
const ris = await globalStore.updateLocalDbFromGM_T_Web_Articoli(myproduct.value.productInfo.sku!)
if (ris) {
field_updated_fromGM.value = t('dbgm.updateLocalDb_OK')
await updateproduct(false)
tools.showPositiveNotif($q, t('dbgm.updateLocalDb_OK'))
}
loading.value = false
}
} }
async function refreshFieldFromGM(field: string) { async function refreshFieldFromGM(field: string) {
@@ -653,7 +668,6 @@ export default defineComponent({
field_updated_fromGM.value = await globalStore.getGM_FieldOf_T_Web_Articoli(myproduct.value.productInfo.sku!, field, shared_consts.CmdQueryMs.GET) field_updated_fromGM.value = await globalStore.getGM_FieldOf_T_Web_Articoli(myproduct.value.productInfo.sku!, field, shared_consts.CmdQueryMs.GET)
loading.value = false loading.value = false
} }
} }
onMounted(mounted) onMounted(mounted)
@@ -728,8 +742,10 @@ export default defineComponent({
showQtaDisponibile, showQtaDisponibile,
field_updated_fromGM, field_updated_fromGM,
refreshFieldFromGM, refreshFieldFromGM,
updatetogm,
refreshDataFromGM, refreshDataFromGM,
loading, loading,
updatelocaldb,
} }
} }
}) })

View File

@@ -154,7 +154,7 @@
/> />
</q-item-section> </q-item-section>
<q-item-section> <q-item-section>
<q-item-label>Aggiorna da GM</q-item-label> <q-item-label>Carica da GM</q-item-label>
</q-item-section> </q-item-section>
</q-item> </q-item>
<q-item <q-item
@@ -209,6 +209,7 @@
@click=" @click="
showQtaDisponibile = true; showQtaDisponibile = true;
visufromgm = true; visufromgm = true;
updatelocaldb = false;
" "
> >
<q-item-section avatar> <q-item-section avatar>
@@ -575,6 +576,8 @@
@updateproductmodif="updateproductmodif" @updateproductmodif="updateproductmodif"
> >
</CSchedaProdotto> </CSchedaProdotto>
updateFieldToGM
</q-dialog> </q-dialog>
<q-dialog <q-dialog
v-if="visufromgm && myproduct" v-if="visufromgm && myproduct"
@@ -638,6 +641,38 @@
</q-card-section> </q-card-section>
</q-card> </q-card>
</q-dialog> </q-dialog>
<q-dialog
v-if="updatetogm && myproduct"
v-model="updatetogm"
>
<q-card class="dialog_card">
<q-toolbar class="bg-primary text-white">
<q-toolbar-title> Aggiorna su GM: </q-toolbar-title>
<q-btn
flat
round
color="white"
icon="close"
v-close-popup
></q-btn>
</q-toolbar>
<q-card-section class="q-pa-xs inset-shadow">
<q-inner-loading
id="spinner"
:showing="loading"
>
<q-spinner-tail
color="primary"
size="4em"
>
</q-spinner-tail>
</q-inner-loading>
<br />
<br />
</q-card-section>
</q-card>
</q-dialog>
</div> </div>
</template> </template>

View File

@@ -106,6 +106,7 @@ export default defineComponent({
} }
function updateproductmodif(element: IProduct) { function updateproductmodif(element: IProduct) {
console.log('CCONTAIER: updateproductmodif')
emit('updateproductmodif', element) emit('updateproductmodif', element)
} }

View File

@@ -1,29 +1,45 @@
<template> <template>
<div class="q-gutter-y-xs column" style="min-width: 100px"> <div
class="q-gutter-y-xs column"
style="min-width: 100px"
>
<q-field <q-field
:label="label ? label : undefined" :label="label ? label : undefined"
:stack-label="!!label" :stack-label="!!label"
outlined outlined
:dense="dense" :dense="dense"
color="blue-6" color="blue-6"
>
<template
v-if="copy"
v-slot:prepend
> >
<q-btn
<template v-if="copy" v-slot:prepend> round
<q-btn round dense flat icon="far fa-copy" @click="copytoclip"/> dense
flat
icon="far fa-copy"
@click="copytoclip"
/>
</template> </template>
<template v-slot:control> <template v-slot:control>
<div class="self-center full-width no-outline" tabindex="0"> <div
<span :class="class_text" :style="`color: ` + color " v-html="value"></span> class="self-center full-width no-outline"
tabindex="0"
>
<span
:class="class_text"
:style="`color: ` + color"
v-html="value"
></span>
<slot></slot> <slot></slot>
</div> </div>
</template> </template>
</q-field> </q-field>
</div> </div>
</template> </template>
<script lang="ts" src="./CLabel.ts"> <script lang="ts" src="./CLabel.ts"></script>
</script>
<style lang="scss" scoped> <style lang="scss" scoped>
@import './CLabel.scss'; @import './CLabel.scss';

View File

@@ -1863,7 +1863,7 @@
rounded rounded
outlined outlined
v-model="recscheda.scheda.linkIdTemplate" v-model="recscheda.scheda.linkIdTemplate"
:options="globalStore.SchedeOpt()" :options="globalStore.getSchedeOpt()"
@update:model-value="modifElem" @update:model-value="modifElem"
label="Scheda collegata:" label="Scheda collegata:"
style="width: 250px" style="width: 250px"
@@ -1879,7 +1879,7 @@
rounded rounded
outlined outlined
v-model="idSchedaDaCopiare" v-model="idSchedaDaCopiare"
:options="globalStore.SchedeOpt()" :options="globalStore.getSchedeOpt()"
@update:model-value="modifElem" @update:model-value="modifElem"
label="Scegli Scheda" label="Scegli Scheda"
style="width: 250px" style="width: 250px"

View File

@@ -240,6 +240,8 @@ export default defineComponent({
const loaded = ref(false) const loaded = ref(false)
const popupEditRef = ref(null)
const addstrrequired = ref('') const addstrrequired = ref('')
const col = ref(<IColGridTable>{ const col = ref(<IColGridTable>{
@@ -287,7 +289,6 @@ export default defineComponent({
if (props.filter) if (props.filter)
col.value.filter = props.filter col.value.filter = props.filter
col.value.fieldtype = props.type col.value.fieldtype = props.type
col.value.label = props.title
if (props.type === costanti.FieldType.image) { if (props.type === costanti.FieldType.image) {
myImgGall.value = [{ myImgGall.value = [{
@@ -412,6 +413,7 @@ export default defineComponent({
} }
function changevalRecOrig(newval: any, subcol: string = '') { function changevalRecOrig(newval: any, subcol: string = '') {
console.log('changevalRec', newval)
// if (!props.insertMode || (props.insertMode && col.value.fieldtype !== costanti.FieldType.multioption)) { // if (!props.insertMode || (props.insertMode && col.value.fieldtype !== costanti.FieldType.multioption)) {
if (col.value && col.value.allowchar === costanti.ALLOWCHAR_CODE) { if (col.value && col.value.allowchar === costanti.ALLOWCHAR_CODE) {
newval = tools.removespaces_slash(newval) newval = tools.removespaces_slash(newval)
@@ -459,6 +461,7 @@ export default defineComponent({
if (props.isInModif) if (props.isInModif)
OpenEdit() OpenEdit()
emit('save', newval)
// } // }
} }
@@ -908,6 +911,20 @@ export default defineComponent({
} }
} }
function handleCancel() {
// Gestisci la chiusura del q-popup-edit
console.log("Chiusura di q-popup-edit");
}
function handleKeydown(event) {
// Interrompi la propagazione del tasto ESC
if (event.key === "Escape") {
event.stopPropagation();
console.log("Tasto ESC intercettato e bloccato");
popupEditRef.value.hide();
}
}
onBeforeMount(mounted) onBeforeMount(mounted)
@@ -951,6 +968,10 @@ export default defineComponent({
mypath, mypath,
changeValRecCoordAddr, changeValRecCoordAddr,
addstrrequired, addstrrequired,
t,
handleKeydown,
handleCancel,
popupEditRef,
} }
} }
}) })

View File

@@ -82,7 +82,7 @@
(col.tipovisu !== costanti.TipoVisu.LINK || (col.tipovisu === costanti.TipoVisu.LINK && myvalue)) (col.tipovisu !== costanti.TipoVisu.LINK || (col.tipovisu === costanti.TipoVisu.LINK && myvalue))
" "
> >
<span class="extrafield">{{ $t(col.extrafield) }}</span> <span class="extrafield">{{ t(col.extrafield) }}</span>
</span> </span>
</div> </div>
<div v-if="canModify"> <div v-if="canModify">
@@ -92,7 +92,7 @@
:minlength="col.minlength ? col.minlength : undefined" :minlength="col.minlength ? col.minlength : undefined"
v-model="myvalue" v-model="myvalue"
@update:model-value="changevalRec" @update:model-value="changevalRec"
:label="col.visulabel ? addstrrequired + $t(col.label_trans) : undefined" :label="col.visulabel ? addstrrequired + t(col.label_trans) : undefined"
:autogrow="col.fieldtype !== costanti.FieldType.crypted" :autogrow="col.fieldtype !== costanti.FieldType.crypted"
@keyup.enter.stop @keyup.enter.stop
autofocus autofocus
@@ -205,7 +205,7 @@
@update:model-value="changevalRec" @update:model-value="changevalRec"
autofocus autofocus
:rules="[(val) => !!val || !col.required || 'Campo richiesto']" :rules="[(val) => !!val || !col.required || 'Campo richiesto']"
:label="col.visulabel ? addstrrequired + $t(col.label_trans) : col.label" :label="col.visulabel ? addstrrequired + t(col.label_trans) : col.label"
> >
</q-input> </q-input>
<q-field v-if="col.showLinkResult && myvalue"> <q-field v-if="col.showLinkResult && myvalue">
@@ -219,7 +219,7 @@
<CLabel <CLabel
v-bind="$attrs" v-bind="$attrs"
:value="myvalue" :value="myvalue"
:label="$t(col.label_trans)" :label="t(col.label_trans)"
/> />
</div> </div>
<div v-else> <div v-else>
@@ -290,10 +290,11 @@
<div v-else-if="col.fieldtype === costanti.FieldType.number || col.fieldtype === costanti.FieldType.currency"> <div v-else-if="col.fieldtype === costanti.FieldType.number || col.fieldtype === costanti.FieldType.currency">
<div v-if="canEdit || isInModif"> <div v-if="canEdit || isInModif">
<div> <div>
<CInput <CInput
v-model="myvalue" v-model="myvalue"
:label="col.visulabel ? $t(col.label_trans) : visulabel ? addstrrequired + $t(col.label_trans) : undefined" :label="
col.visulabel ? t(col.label_trans) : visulabel ? addstrrequired + t(col.label_trans) : undefined
"
:dense="dense" :dense="dense"
@savedb="Savedb" @savedb="Savedb"
/> />
@@ -304,7 +305,7 @@
:symbol="tools.getSymbolByCircuit(row)" :symbol="tools.getSymbolByCircuit(row)"
:color="tools.getColorByCircuit(row)" :color="tools.getColorByCircuit(row)"
v-model="myvalue" v-model="myvalue"
:label="$t(col.label_trans)" :label="t(col.label_trans)"
> >
</CCurrencyValue> </CCurrencyValue>
</div> </div>
@@ -331,13 +332,15 @@
</div> </div>
<div v-else> <div v-else>
<CInput <CInput
v-model="myvalue" v-model="myvalue"
:label="col.visulabel ? $t(col.label_trans) : visulabel ? addstrrequired + $t(col.label_trans) : undefined" :label="
:dense="dense" col.visulabel ? t(col.label_trans) : visulabel ? addstrrequired + t(col.label_trans) : undefined
@savedb="changevalRec" "
:maxlength="col.maxlength ? col.maxlength : undefined" :dense="dense"
autofocus @savedb="changevalRec"
/> :maxlength="col.maxlength ? col.maxlength : undefined"
autofocus
/>
</div> </div>
</div> </div>
<div <div
@@ -345,7 +348,7 @@
style="text-align: center" style="text-align: center"
> >
<span class="text-h7 text-weight-bold row justify-center"> <span class="text-h7 text-weight-bold row justify-center">
{{ $t(col.label_trans) }} {{ t(col.label_trans) }}
</span> </span>
<CGallery <CGallery
:imagebak=" :imagebak="
@@ -384,7 +387,7 @@
> >
<div v-if="canEdit"> <div v-if="canEdit">
<span class="text-h7 text-weight-bold row justify-center"> <span class="text-h7 text-weight-bold row justify-center">
{{ $t(col.label_trans ? col.label_trans : '') }} {{ t(col.label_trans ? col.label_trans : '') }}
</span> </span>
<CGallery <CGallery
:imagebak="col.showpicprofile_ifnotset ? userStore.getImgByProfile(row['profile'], true) : ''" :imagebak="col.showpicprofile_ifnotset ? userStore.getImgByProfile(row['profile'], true) : ''"
@@ -441,7 +444,7 @@
</div> </div>
<div v-else-if="col.fieldtype === costanti.FieldType.image_and_filename"> <div v-else-if="col.fieldtype === costanti.FieldType.image_and_filename">
<div v-if="canEdit"> <div v-if="canEdit">
{{ $t('reg.photo') }} {{ t('reg.photo') }}
<q-input <q-input
v-model="myvalue" v-model="myvalue"
@update:value="changevalRec" @update:value="changevalRec"
@@ -505,7 +508,7 @@
</div> </div>
<div v-else-if="col.fieldtype === costanti.FieldType.imgcard"> <div v-else-if="col.fieldtype === costanti.FieldType.imgcard">
<div v-if="canEdit"> <div v-if="canEdit">
{{ $t('reg.photo') }} {{ t('reg.photo') }}
<CSelectImage <CSelectImage
v-bind="$attrs" v-bind="$attrs"
:imagebak="col.showpicprofile_ifnotset ? userStore.getImgByProfile(row['profile'], true) : ''" :imagebak="col.showpicprofile_ifnotset ? userStore.getImgByProfile(row['profile'], true) : ''"
@@ -568,7 +571,7 @@
:type_out="col.field_outtype" :type_out="col.field_outtype"
:col="col" :col="col"
:row="row" :row="row"
:label="col.label ? col.label : $t(col.label_trans)" :label="col.label ? col.label : t(col.label_trans)"
v-model:value="myvalue" v-model:value="myvalue"
@update:value="changevalRec" @update:value="changevalRec"
:tablesel="tablesel" :tablesel="tablesel"
@@ -594,7 +597,7 @@
:type_out="col.field_outtype" :type_out="col.field_outtype"
:col="col" :col="col"
:row="row" :row="row"
:label="col.label ? col.label : $t(col.label_trans)" :label="col.label ? col.label : t(col.label_trans)"
v-model:value="myvalue" v-model:value="myvalue"
@update:value="changevalRec" @update:value="changevalRec"
:tablesel="tablesel" :tablesel="tablesel"
@@ -615,7 +618,11 @@
<div v-if="myvalue"> <div v-if="myvalue">
<CDateTime <CDateTime
:label=" :label="
col.label ? addstrrequired + col.label : col.label_trans ? addstrrequired + $t(col.label_trans) : undefined col.label
? addstrrequired + col.label
: col.label_trans
? addstrrequired + t(col.label_trans)
: undefined
" "
:class="{ 'cursor-pointer': canEdit }" :class="{ 'cursor-pointer': canEdit }"
v-model:value="myvalue" v-model:value="myvalue"
@@ -640,7 +647,11 @@
<div v-if="myvalue"> <div v-if="myvalue">
<CDateTime <CDateTime
:label=" :label="
col.label ? addstrrequired + col.label : col.label_trans ? addstrrequired + $t(col.label_trans) : undefined col.label
? addstrrequired + col.label
: col.label_trans
? addstrrequired + t(col.label_trans)
: undefined
" "
:class="{ 'cursor-pointer': canEdit }" :class="{ 'cursor-pointer': canEdit }"
v-model:value="myvalue" v-model:value="myvalue"
@@ -656,7 +667,7 @@
</div> </div>
<div v-else-if="col.fieldtype === costanti.FieldType.binary"> <div v-else-if="col.fieldtype === costanti.FieldType.binary">
<div v-if="isInModif"> <div v-if="isInModif">
<span v-if="insertMode"> {{ col.label ? col.label : $t(col.label_trans) }}: </span> <span v-if="insertMode"> {{ col.label ? col.label : t(col.label_trans) }}: </span>
<CMyToggleList <CMyToggleList
:label="col.titlepopupedit ? col.titlepopupedit : undefined" :label="col.titlepopupedit ? col.titlepopupedit : undefined"
:options="globalStore.getTableJoinByName(col.jointable, col.addall, col.addnone, col.filter)" :options="globalStore.getTableJoinByName(col.jointable, col.addall, col.addnone, col.filter)"
@@ -689,7 +700,7 @@
:row="row" :row="row"
:multiple="true" :multiple="true"
:withToggle="true" :withToggle="true"
:label="col.label ? col.label : $t(col.label_trans)" :label="col.label ? col.label : t(col.label_trans)"
:filter_table="col.filter_table" :filter_table="col.filter_table"
:filter_field="col.filter_field" :filter_field="col.filter_field"
:value_extra="value_extra" :value_extra="value_extra"
@@ -769,7 +780,7 @@
v-model="myvalue" v-model="myvalue"
:inline="col.inline" :inline="col.inline"
:type="col.typeobj" :type="col.typeobj"
:label="col.label ? col.label : $t(col.label_trans)" :label="col.label ? col.label : t(col.label_trans)"
@update:model-value="changevalRec" @update:model-value="changevalRec"
:options="globalStore.getTableJoinLabelValueByName(col)" :options="globalStore.getTableJoinLabelValueByName(col)"
></q-option-group> ></q-option-group>
@@ -792,7 +803,7 @@
:type_out="col.field_outtype" :type_out="col.field_outtype"
:col="col" :col="col"
:row="row" :row="row"
:label="col.label ? col.label : $t(col.label_trans)" :label="col.label ? col.label : t(col.label_trans)"
v-model:value="myvalue" v-model:value="myvalue"
:pickup="col.fieldtype === costanti.FieldType.select_by_server" :pickup="col.fieldtype === costanti.FieldType.select_by_server"
:tablesel="col.fieldtype === costanti.FieldType.select_by_server ? tablesel : ''" :tablesel="col.fieldtype === costanti.FieldType.select_by_server ? tablesel : ''"
@@ -814,13 +825,13 @@
</div> </div>
<div v-else> <div v-else>
<!-- <!--
rec: {{rec}} rec: {{rec}}<br><br>
row: {{row}} row: {{row}}<br><br>
col.jointable {{col.jointable}} col.jointable {{col.jointable}}<br><br>
myvalue {{myvalue}} myvalue {{myvalue}}<br><br>
opt: {{globalStore.getTableJoinByName(col.jointable, col.addall, col.addnone, col.filter)}} opt: {{globalStore.getTableJoinByName(col.jointable, col.addall, col.addnone, col.filter)}}<br><br>
val: {{fieldsTable.getKeyByTable(col.jointable)}} val: {{fieldsTable.getKeyByTable(col.jointable)}}<br><br>
lab: {{fieldsTable.getLabelByTable(col.jointable)}}--> lab: {{fieldsTable.getLabelByTable(col.jointable)}}<br><br>-->
<CMyChipList <CMyChipList
:rec="row" :rec="row"
myclass="text-center" myclass="text-center"
@@ -844,7 +855,7 @@
:col="col" :col="col"
:row="row" :row="row"
:multiselect_by_server="true" :multiselect_by_server="true"
:label="col.label ? col.label : $t(col.label_trans)" :label="col.label ? col.label : t(col.label_trans)"
v-model:arrvalue="myvalue" v-model:arrvalue="myvalue"
@update:arrvalue="changevalRec" @update:arrvalue="changevalRec"
:addall="false" :addall="false"
@@ -873,7 +884,7 @@
:type_out="col.field_outtype" :type_out="col.field_outtype"
:col="col" :col="col"
:row="row" :row="row"
:label="col.label ? col.label : $t(col.label_trans)" :label="col.label ? col.label : t(col.label_trans)"
v-model:value="myvalue" v-model:value="myvalue"
@update:value="changevalRec" @update:value="changevalRec"
:filter_table="col.filter_table" :filter_table="col.filter_table"
@@ -908,8 +919,8 @@
:dense="dense" :dense="dense"
class="bg-primary text-white" class="bg-primary text-white"
> >
<span v-if="col.label_trans">{{ $t(col.label_trans) }}</span <span v-if="col.label_trans">{{ t(col.label_trans) }}</span
><span v-else> {{ $t('event.testo_di_spiegazione') }}: </span> ><span v-else> {{ t('event.testo_di_spiegazione') }}: </span>
<q-space /> <q-space />
</q-bar> </q-bar>
<div v-if="!isFieldDb()"> <div v-if="!isFieldDb()">
@@ -1034,18 +1045,20 @@
</div> </div>
<q-popup-edit <q-popup-edit
ref="popupEditRef"
v-if="!isInModif && canEdit && noPopupeditByCol(col)" v-if="!isInModif && canEdit && noPopupeditByCol(col)"
v-model="myvalue" v-model="myvalue"
:disable="col.disable || disable || col.fieldtype === costanti.FieldType.image_and_filename" :disable="col.disable || disable || col.fieldtype === costanti.FieldType.image_and_filename"
:readonly="col.disable || disable" :readonly="col.disable || disable"
:title="col.title ? col.title : col.titlepopupedit" :title="col.title ? col.title : col.titlepopupedit"
buttons buttons
:label-set="$t('dialog.save')" :label-set="t('dialog.save')"
:label-cancel="$t('dialog.cancel')" :label-cancel="t('dialog.cancel')"
persistent persistent
@save="SaveValueInt" @save="SaveValueInt"
@show="OpenEdit" @show="OpenEdit"
v-slot="scope" v-slot="scope"
@cancel="handleCancel"
> >
<div v-if="col.fieldtype === costanti.FieldType.boolean"> <div v-if="col.fieldtype === costanti.FieldType.boolean">
<q-checkbox <q-checkbox
@@ -1065,9 +1078,10 @@
:maxlength="col.maxlength ? col.maxlength : undefined" :maxlength="col.maxlength ? col.maxlength : undefined"
:minlength="col.minlength ? col.minlength : undefined" :minlength="col.minlength ? col.minlength : undefined"
v-model="scope.value" v-model="scope.value"
:label="col.visulabel ? addstrrequired + $t(col.label_trans) : undefined" :label="col.visulabel ? addstrrequired + t(col.label_trans) : undefined"
:autogrow="col.fieldtype !== costanti.FieldType.crypted" :autogrow="col.fieldtype !== costanti.FieldType.crypted"
@keyup.enter.stop @keyup.enter.stop
@keydown="handleKeydown"
autofocus autofocus
:rules="[(val) => !!val || !col.required || 'Campo richiesto']" :rules="[(val) => !!val || !col.required || 'Campo richiesto']"
> >
@@ -1087,7 +1101,7 @@
debounce="1000" debounce="1000"
:maxlength="col.maxlength ? col.maxlength : undefined" :maxlength="col.maxlength ? col.maxlength : undefined"
autofocus autofocus
:label="col.visulabel ? $t(col.label_trans) : visulabel ? addstrrequired + col.label : undefined" :label="col.visulabel ? t(col.label_trans) : visulabel ? addstrrequired + col.label : undefined"
> >
</q-input> </q-input>
</div> </div>
@@ -1100,7 +1114,7 @@
:symbol="tools.getSymbolByCircuit(row)" :symbol="tools.getSymbolByCircuit(row)"
:color="tools.getColorByCircuit(row)" :color="tools.getColorByCircuit(row)"
v-model="scope.value" v-model="scope.value"
:label="$t(col.label_trans)" :label="t(col.label_trans)"
> >
</CCurrencyValue> </CCurrencyValue>
</div> </div>
@@ -1121,7 +1135,7 @@
autofocus autofocus
@update:model-value="changevalRec" @update:model-value="changevalRec"
style="max-width: 100px" style="max-width: 100px"
:label="col.label ? col.label : $t(col.label_trans)" :label="col.label ? col.label : t(col.label_trans)"
> >
</q-input> </q-input>
</div> </div>
@@ -1162,7 +1176,7 @@
:type_out="col.field_outtype" :type_out="col.field_outtype"
:col="col" :col="col"
:row="row" :row="row"
:label="col.label ? col.label : $t(col.label_trans)" :label="col.label ? col.label : t(col.label_trans)"
v-model:value="scope.value" v-model:value="scope.value"
:pickup="col.fieldtype === costanti.FieldType.select_by_server" :pickup="col.fieldtype === costanti.FieldType.select_by_server"
:addnone="col.addnone" :addnone="col.addnone"
@@ -1186,7 +1200,7 @@
:col="col" :col="col"
:row="row" :row="row"
:multiselect_by_server="true" :multiselect_by_server="true"
:label="col.label ? col.label : $t(col.label_trans)" :label="col.label ? col.label : t(col.label_trans)"
v-model:arrvalue="scope.value" v-model:arrvalue="scope.value"
@update:arrvalue="changevalRec" @update:arrvalue="changevalRec"
:addall="false" :addall="false"
@@ -1210,18 +1224,17 @@
</div> </div>
<div v-else-if="col.fieldtype === costanti.FieldType.multiselect"> <div v-else-if="col.fieldtype === costanti.FieldType.multiselect">
<CMySelect <CMySelect
v-if="scope.value"
:type_out="col.field_outtype" :type_out="col.field_outtype"
:col="col" :col="col"
:row="row" :row="row"
:multiple="true" :multiple="true"
:withToggle="true" :withToggle="true"
:label="col.label ? col.label : $t(col.label_trans)" :label="col.label ? col.label : col.label_trans ? t(col.label_trans) : ''"
:filter_table="col.filter_table" :filter_table="col.filter_table"
:filter_field="col.filter_field" :filter_field="col.filter_field"
:value_extra="value_extra"
v-model:arrvalue="scope.value" v-model:arrvalue="scope.value"
@update:arrvalue="changevalRec" @update:arrvalue="changevalRec"
:addall="false"
:addnone="false" :addnone="false"
label-color="primary" label-color="primary"
class="combowidth" class="combowidth"
@@ -1288,7 +1301,7 @@
:type_out="col.field_outtype" :type_out="col.field_outtype"
:col="col" :col="col"
:row="row" :row="row"
:label="col.label ? col.label : $t(col.label_trans)" :label="col.label ? col.label : t(col.label_trans)"
v-model:value="scope.value" v-model:value="scope.value"
@update:value="changevalRec" @update:value="changevalRec"
:tablesel="tablesel" :tablesel="tablesel"
@@ -1312,7 +1325,7 @@
:type_out="col.field_outtype" :type_out="col.field_outtype"
:col="col" :col="col"
:row="row" :row="row"
:label="col.label ? col.label : $t(col.label_trans)" :label="col.label ? col.label : t(col.label_trans)"
v-model:value="scope.value" v-model:value="scope.value"
@update:value="changevalRec" @update:value="changevalRec"
:tablesel="tablesel" :tablesel="tablesel"
@@ -1329,7 +1342,11 @@
<div v-else-if="col.fieldtype === costanti.FieldType.date"> <div v-else-if="col.fieldtype === costanti.FieldType.date">
<CDateTime <CDateTime
:label=" :label="
col.label ? addstrrequired + col.label : col.label_trans ? addstrrequired + $t(col.label_trans) : undefined col.label
? addstrrequired + col.label
: col.label_trans
? addstrrequired + t(col.label_trans)
: undefined
" "
:class="{ 'cursor-pointer': canEdit }" :class="{ 'cursor-pointer': canEdit }"
v-model:value="myvalue" v-model:value="myvalue"
@@ -1343,7 +1360,7 @@
</div> </div>
<div v-else-if="col.fieldtype === costanti.FieldType.onlydate"> <div v-else-if="col.fieldtype === costanti.FieldType.onlydate">
<CDateTime <CDateTime
:label="col.label ? addstrrequired + col.label : addstrrequired + $t(col.label_trans)" :label="col.label ? addstrrequired + col.label : addstrrequired + t(col.label_trans)"
:class="{ 'cursor-pointer': canEdit }" :class="{ 'cursor-pointer': canEdit }"
:valueDate="myvalue" :valueDate="myvalue"
v-model:value="myvalue" v-model:value="myvalue"
@@ -1372,7 +1389,7 @@
:maxlength="col.maxlength ? col.maxlength : undefined" :maxlength="col.maxlength ? col.maxlength : undefined"
:minlength="col.minlength ? col.minlength : undefined" :minlength="col.minlength ? col.minlength : undefined"
v-model="scope.value" v-model="scope.value"
:label="col.visulabel ? addstrrequired + $t(col.label_trans) : undefined" :label="col.visulabel ? addstrrequired + t(col.label_trans) : undefined"
:autogrow="col.fieldtype !== costanti.FieldType.crypted" :autogrow="col.fieldtype !== costanti.FieldType.crypted"
@keyup.enter.stop @keyup.enter.stop
autofocus autofocus
@@ -1384,7 +1401,7 @@
:type_out="col.field_outtype" :type_out="col.field_outtype"
:col="col" :col="col"
:row="row" :row="row"
:label="col.label ? col.label : $t(col.label_trans)" :label="col.label ? col.label : t(col.label_trans)"
v-model:value="scope.value" v-model:value="scope.value"
:optval="fieldsTable.getKeyByTable(col.jointable)" :optval="fieldsTable.getKeyByTable(col.jointable)"
:optlab="fieldsTable.getLabelByTable(col.jointable)" :optlab="fieldsTable.getLabelByTable(col.jointable)"
@@ -1422,7 +1439,7 @@
</div> </div>
<div v-else-if="col.fieldtype === costanti.FieldType.image_and_filename"> <div v-else-if="col.fieldtype === costanti.FieldType.image_and_filename">
<div v-if="canEdit"> <div v-if="canEdit">
{{ $t('reg.photo') }} {{ t('reg.photo') }}
<q-input <q-input
v-model="myvalue" v-model="myvalue"
@update:value="changevalRec" @update:value="changevalRec"

View File

@@ -21,10 +21,7 @@ export default defineComponent({
}, },
arrvalue: { arrvalue: {
type: Array, type: Array,
required: false, required: true,
default: () => {
return []
}
}, },
value: [String, Number, Object], value: [String, Number, Object],
label: { label: {
@@ -268,7 +265,7 @@ export default defineComponent({
saveOptInCookie(newval) saveOptInCookie(newval)
// console.log(' ----- Myselect changeval Arrvalue', myarrvalue.value) console.log(' ----- Myselect changeval Arrvalue', myarrvalue.value)
emit('update:arrvalue', myarrvalue.value) emit('update:arrvalue', myarrvalue.value)
emit('changeval', myarrvalue.value) emit('changeval', myarrvalue.value)
@@ -325,6 +322,7 @@ export default defineComponent({
} }
function mounted() { function mounted() {
console.log('CMYSELECT: mounted')
optionsreal.value = props.options optionsreal.value = props.options
if (props.focus) { if (props.focus) {
focusVisibleSelect() focusVisibleSelect()
@@ -352,7 +350,7 @@ export default defineComponent({
} }
function update() { function update() {
// console.log('update', props.value, props) console.log('update', props.value, props)
// console.log(' #### mounted myselect', props.options, 'arrvalue', myarrvalue.value) // console.log(' #### mounted myselect', props.options, 'arrvalue', myarrvalue.value)
let rec: any let rec: any
if (optionsreal.value) { if (optionsreal.value) {

View File

@@ -146,6 +146,11 @@ export default defineComponent({
required: false, required: false,
default: false, default: false,
}, },
showall: {
type: Boolean,
required: false,
default: false,
},
}, },
components: { CMyPopupEdit }, components: { CMyPopupEdit },
setup(props, { emit }) { setup(props, { emit }) {
@@ -164,7 +169,10 @@ export default defineComponent({
console.log('showandsave CMyFieldDb', row, col, newval) console.log('showandsave CMyFieldDb', row, col, newval)
if (newval !== valinitial) { if (newval !== valinitial) {
return tools.saveInDBForTypes($q, props.mykey, newval, props.type, props.serv, props.table, props.mysubkey, props.id, props.indrec, props.mysubsubkey, props.specialField) const ris = tools.saveInDBForTypes($q, props.mykey, newval, props.type, props.serv, props.table, props.mysubkey, props.id, props.indrec, props.mysubsubkey, props.specialField)
save(newval)
return ris
} }
} }

View File

@@ -50,6 +50,7 @@
:hint="title" :hint="title"
:title="title" :title="title"
:field="mykey" :field="mykey"
:showall="showall"
:filter="filter" :filter="filter"
:subfield="mysubkey" :subfield="mysubkey"
:specialField="specialField" :specialField="specialField"

View File

@@ -6,6 +6,7 @@ import { tools } from '@tools'
import { useGlobalStore } from '@src/store/globalStore' import { useGlobalStore } from '@src/store/globalStore'
import { CMyValueDb } from '@src/components/CMyValueDb' import { CMyValueDb } from '@src/components/CMyValueDb'
import { CSchedaProdotto } from '@src/components/CSchedaProdotto'
import { CSearchProduct } from '@src/components/CSearchProduct' import { CSearchProduct } from '@src/components/CSearchProduct'
import { CMyDialog } from '@src/components/CMyDialog' import { CMyDialog } from '@src/components/CMyDialog'
@@ -29,6 +30,7 @@ export default defineComponent({
emits: ["update:lista_prodotti", "update:optcatalogo"], emits: ["update:lista_prodotti", "update:optcatalogo"],
components: { components: {
draggable, CSearchProduct, CMyDialog, CMyValueDb, CViewTable, CLabel, draggable, CSearchProduct, CMyDialog, CMyValueDb, CViewTable, CLabel,
CSchedaProdotto,
}, },
props: { props: {
lista_prodotti: { lista_prodotti: {
@@ -69,7 +71,6 @@ export default defineComponent({
const field_updated_fromGM = ref('') const field_updated_fromGM = ref('')
const modifOn = ref(false) const modifOn = ref(false)
const endload = ref(false)
const optionscatalogo = ref(<any>{maxlength: 0}) const optionscatalogo = ref(<any>{maxlength: 0})
@@ -173,18 +174,6 @@ export default defineComponent({
.join(", "); .join(", ");
} }
function formatCatProds(catprods: ICatProd[] | undefined | null): string {
if (!catprods || !Array.isArray(catprods)) {
return "";
}
// Estrai il nome e il cognome di ogni autore e uniscili con ', '
return catprods
.map((catprod) => `${catprod.name ?? ""}`.trim())
.filter((name) => name.length > 0) // Filtra eventuali nomi vuoti
.join(", ");
}
// Caricamento delle preferenze al mount del componente // Caricamento delle preferenze al mount del componente
onMounted(() => { onMounted(() => {
const savedColumns = tools.getCookie("selColCat"); const savedColumns = tools.getCookie("selColCat");
@@ -269,7 +258,6 @@ export default defineComponent({
isColumnVisible, isColumnVisible,
internalProducts, internalProducts,
formatAuthors, formatAuthors,
formatCatProds,
removeProduct, removeProduct,
modifyProduct, modifyProduct,
tools, tools,
@@ -290,7 +278,6 @@ export default defineComponent({
loading, loading,
showQtaDisponibile, showQtaDisponibile,
modifOn, modifOn,
endload,
updateproductmodif, updateproductmodif,
optionscatalogo, optionscatalogo,
t, t,

View File

@@ -82,11 +82,10 @@
</td> </td>
<!-- Argomento --> <!-- Argomento -->
<td v-if="isColumnVisible('catprods')">{{ formatCatProds(element.productInfo?.catprods) }}</td> <td v-if="isColumnVisible('catprods')">{{ tools.formatCatProds(element.productInfo?.catprods) }}</td>
<td v-if="isColumnVisible('date_pub')">{{ tools.getstrDate(element.productInfo?.date_pub) }}</td> <td v-if="isColumnVisible('date_pub')">{{ tools.getstrDate(element.productInfo?.date_pub) }}</td>
<td v-if="isColumnVisible('ranking')">{{ element.indiceRanking }}</td>
<td <td
v-if="isColumnVisible('rank3M')" v-if="isColumnVisible('rank3M')"
style="text-align: right" style="text-align: right"
@@ -189,13 +188,18 @@
maximized maximized
> >
<q-spinner <q-spinner
v-if="!endload" v-if="loading"
color="primary" color="primary"
size="3em" size="3em"
:thickness="2" :thickness="2"
/> />
<div v-if="!!selProd && !!selProd.productInfo"> <div v-if="!!selProd && !!selProd.productInfo">
<CSchedaProdotto
v-model="selProd"
@updateproductmodif="updateproductmodif"
>
</CSchedaProdotto>
</div> </div>
</q-dialog> </q-dialog>
<q-dialog <q-dialog
@@ -216,7 +220,7 @@
</q-toolbar> </q-toolbar>
<q-card-section class="q-pa-xs inset-shadow"> <q-card-section class="q-pa-xs inset-shadow">
<q-spinner <q-spinner
v-if="!endload" v-if="loading"
color="primary" color="primary"
size="3em" size="3em"
:thickness="2" :thickness="2"

View File

@@ -17,11 +17,12 @@ import type {
import { shared_consts } from "app/src/common/shared_vuejs"; import { shared_consts } from "app/src/common/shared_vuejs";
import { useProducts } from "app/src/store/Products"; import { useProducts } from "app/src/store/Products";
import { useI18n } from "vue-i18n"; import { useI18n } from "vue-i18n";
import { useQuasar } from "quasar";
export default defineComponent({ export default defineComponent({
name: "CSchedaProdotto", name: "CSchedaProdotto",
emits: [], emits: ['updateproductmodif'],
components: { components: {
CTableCupleLabelValue CTableCupleLabelValue
}, },
@@ -37,14 +38,10 @@ export default defineComponent({
}), }),
}, },
updateproductmodif: {
type: Function as PropType<(element: any) => void>,
required: false,
default: () => () => { },
},
}, },
setup(props, { emit }) { setup(props, { emit }) {
// Copia locale della lista_prodotti per manipolazione interna // Copia locale della lista_prodotti per manipolazione interna
const $q = useQuasar()
const { t } = useI18n() const { t } = useI18n()
const globalStore = useGlobalStore() const globalStore = useGlobalStore()
@@ -52,6 +49,11 @@ export default defineComponent({
const mytab = ref('scheda') const mytab = ref('scheda')
const loading = ref(false)
const updatetogm = ref(false)
const field_updated_toGM = ref('')
const myproduct = ref<IProduct>({ ...props.modelValue }) const myproduct = ref<IProduct>({ ...props.modelValue })
watch(() => props.modelValue, (newVal) => { watch(() => props.modelValue, (newVal) => {
@@ -95,6 +97,16 @@ export default defineComponent({
debounce: "1000", debounce: "1000",
type: costanti.FieldType.number, type: costanti.FieldType.number,
}, },
{
editOn: false,
label: "Fatturati ultimi 6 Mesi",
table: "productinfos",
id: myproduct.value.productInfo._id,
rec: myproduct.value.productInfo,
mykey: "fatLast6M",
debounce: "1000",
type: costanti.FieldType.number,
},
{ {
editOn: false, editOn: false,
label: "Venduti", label: "Venduti",
@@ -172,17 +184,6 @@ export default defineComponent({
function getArrListDescrizioni(): IRecFields[] { function getArrListDescrizioni(): IRecFields[] {
const arrlist: IRecFields[] = [ const arrlist: IRecFields[] = [
{
editOn: true,
label: "Descrizione breve macro",
table: "productinfos",
id: myproduct.value.productInfo._id, // ID dinamico, da sostituire con il valore reale
rec: myproduct.value.productInfo, // Oggetto dinamico, da sostituire con il valore reale
mykey: "descrizione_breve_macro",
debounce: "1000",
type: costanti.FieldType.string,
dense: true,
},
{ {
editOn: true, editOn: true,
label: "Descrizione Trafiletto per Catalogo", label: "Descrizione Trafiletto per Catalogo",
@@ -193,6 +194,19 @@ export default defineComponent({
debounce: "1000", debounce: "1000",
type: costanti.FieldType.string, type: costanti.FieldType.string,
dense: true, dense: true,
showall: true,
},
{
editOn: true,
label: "Descrizione breve macro",
table: "productinfos",
id: myproduct.value.productInfo._id, // ID dinamico, da sostituire con il valore reale
rec: myproduct.value.productInfo, // Oggetto dinamico, da sostituire con il valore reale
mykey: "descrizione_breve_macro",
debounce: "1000",
type: costanti.FieldType.string,
dense: true,
showall: true,
}, },
{ {
editOn: true, editOn: true,
@@ -205,6 +219,7 @@ export default defineComponent({
debounce: "1000", debounce: "1000",
type: costanti.FieldType.string, type: costanti.FieldType.string,
dense: true, dense: true,
showall: true,
}, },
{ {
editOn: true, editOn: true,
@@ -216,6 +231,7 @@ export default defineComponent({
debounce: "1000", debounce: "1000",
type: costanti.FieldType.string, type: costanti.FieldType.string,
dense: true, dense: true,
showall: true,
}, },
] ]
@@ -258,6 +274,18 @@ export default defineComponent({
type: costanti.FieldType.onlydate, type: costanti.FieldType.onlydate,
dense: true, dense: true,
}, },
{
editOn: true,
label: "Argomento",
table: "productinfos",
id: myproduct.value.productInfo?._id,
rec: myproduct.value.productInfo,
mykey: "idCatProds",
debounce: "1000",
type: costanti.FieldType.multiselect,
jointable: 'catprods',
dense: true,
},
{ {
editOn: true, editOn: true,
label: "Pagine", label: "Pagine",
@@ -334,6 +362,76 @@ export default defineComponent({
} }
function updateproductmodif(element: any) {
console.log('CSCHEDAPRODOTTO updateproductmodif ', element)
emit('updateproductmodif', element)
}
async function updateFieldsDataToGM(data: any) {
if (myproduct.value) {
try {
loading.value = true; // Attiva lo stato di caricamento
updatetogm.value = true; // Indica che l'aggiornamento è in corso
// Ottieni lo SKU del prodotto corrente
const sku = myproduct.value.productInfo.sku;
if (!sku) {
throw new Error("SKU non disponibile per il prodotto.");
}
// Aggiorna il campo nel database utilizzando setGM_FieldOf_T_Web_Articoli
const result = await globalStore.setGM_FieldOf_T_Web_Articoli(
sku, // SKU del prodotto
data, // Nuovo valore per il campo
shared_consts.CmdQueryMs.SET // Comando per l'aggiornamento
);
console.log(`Record aggiornato con successo. Risultato:`, result);
} catch (error) {
console.error(`Errore durante l'aggiornamento del record:`, error.message);
throw new Error(`Errore durante l'aggiornamento del record: ${error.message}`);
} finally {
loading.value = false; // Disattiva lo stato di caricamento
updatetogm.value = false; // Indica che l'aggiornamento è terminato
}
} else {
console.warn("Nessun prodotto selezionato per l'aggiornamento.");
}
}
function updateRecordToGM() {
console.log('myproduct.value.productInfo.catprods', myproduct.value.productInfo.catprods)
let mydata = {
ListaArgomenti: products.getArrayidArgomentoByArridCatProds(myproduct.value.productInfo.idCatProds)
}
console.log('devo salvare mydata', mydata)
updateFieldsDataToGM(mydata)
}
async function updateproduct(load?: boolean) {
myproduct.value = await products.getProductById(myproduct.value._id, true)
}
async function refreshDataFromGM() {
if (myproduct.value) {
loading.value = true
const ris = await globalStore.updateLocalDbFromGM_T_Web_Articoli(myproduct.value.productInfo.sku!)
if (ris) {
await updateproduct(false)
tools.showPositiveNotif($q, t('dbgm.updateLocalDb_OK'))
}
loading.value = false
}
}
onMounted(mounted) onMounted(mounted)
return { return {
@@ -348,6 +446,12 @@ export default defineComponent({
getArrListStat, getArrListStat,
mytab, mytab,
myproduct, myproduct,
updateproductmodif,
updatetogm,
field_updated_toGM,
loading,
updateRecordToGM,
refreshDataFromGM,
} }
} }
}) })

View File

@@ -11,53 +11,84 @@
></q-btn> ></q-btn>
</q-toolbar> </q-toolbar>
<q-card-section class="q-pa-xs inset-shadow"> <q-card-section class="q-pa-xs inset-shadow">
<q-tabs <div>
v-model="mytab" <q-inner-loading
inline-label id="spinner"
class="text-blue shadow-2" :showing="loading"
> >
<q-tab <q-spinner-tail
label="Scheda" color="primary"
name="scheda" size="4em"
icon="fas fa-file-alt"
></q-tab>
<q-tab
label="Descrizioni"
name="descr"
icon="fas fa-align-left"
></q-tab>
<q-tab
label="Statistiche"
name="stat"
icon="fas fa-stats"
></q-tab>
</q-tabs>
<q-tab-panels
v-model="mytab"
animated
>
<q-tab-panel name="scheda">
<CTableCupleLabelValue
:list="getArrListScheda()"
@updateproductmodif="updateproductmodif"
> >
</CTableCupleLabelValue> </q-spinner-tail>
</q-tab-panel> </q-inner-loading>
<q-tab-panel name="descr">
<CTableCupleLabelValue <q-tabs
:list="getArrListDescrizioni()" v-model="mytab"
@updateproductmodif="updateproductmodif" inline-label
> class="text-blue shadow-2"
</CTableCupleLabelValue> >
</q-tab-panel> <q-tab
<q-tab-panel name="stat"> label="Scheda"
<CTableCupleLabelValue name="scheda"
:list="getArrListStat()" icon="fas fa-file-alt"
@updateproductmodif="updateproductmodif" ></q-tab>
> <q-tab
</CTableCupleLabelValue> label="Descrizioni"
</q-tab-panel> name="descr"
</q-tab-panels> icon="fas fa-align-left"
></q-tab>
<q-tab
label="Statistiche"
name="stat"
icon="fas fa-stats"
></q-tab>
</q-tabs>
<q-tab-panels
v-model="mytab"
animated
>
<q-tab-panel name="scheda">
<CTableCupleLabelValue
:list="getArrListScheda()"
@updateproductmodif="updateproductmodif"
>
</CTableCupleLabelValue>
</q-tab-panel>
<q-tab-panel name="descr">
<CTableCupleLabelValue
:list="getArrListDescrizioni()"
@updateproductmodif="updateproductmodif"
>
</CTableCupleLabelValue>
</q-tab-panel>
<q-tab-panel name="stat">
<CTableCupleLabelValue
:list="getArrListStat()"
@updateproductmodif="updateproductmodif"
>
</CTableCupleLabelValue>
</q-tab-panel>
</q-tab-panels>
</div>
<div class="">
<q-btn
rounded
class="q-ma-sm"
color="accent"
icon="fas fa-save"
label="Carica da GM"
@click="refreshDataFromGM"
></q-btn>
<q-btn
rounded
class="q-ma-sm"
color="accent"
icon="fas fa-save"
label="Aggiorna su GM"
@click="updateRecordToGM"
></q-btn>
</div>
</q-card-section> </q-card-section>
</q-card> </q-card>
</template> </template>

View File

@@ -119,6 +119,7 @@ export default defineComponent({
async function loadProduct(id: string) { async function loadProduct(id: string) {
// Carica il prodotto // Carica il prodotto
console.log('loadProduct', id)
if (id) { if (id) {
myproduct.value = await productStore.loadProductById(id) myproduct.value = await productStore.loadProductById(id)
@@ -192,7 +193,8 @@ export default defineComponent({
if (props.nameLinkTemplate) { if (props.nameLinkTemplate) {
const linkIdTemplate = globalStore.getLinkIdTemplateByName(props.nameLinkTemplate) const linkIdTemplate = globalStore.getLinkIdTemplateByName(props.nameLinkTemplate)
optcatalogo.value.arrSchede[0].scheda.linkIdTemplate = linkIdTemplate if (linkIdTemplate)
optcatalogo.value.arrSchede[0].scheda.linkIdTemplate = linkIdTemplate
} else { } else {
optcatalogo.value.arrSchede[0].scheda.name = 'SEARCH_NEW' optcatalogo.value.arrSchede[0].scheda.name = 'SEARCH_NEW'
} }
@@ -265,6 +267,7 @@ export default defineComponent({
} }
function updateproductmodif(element: IProduct) { function updateproductmodif(element: IProduct) {
console.log('CSEARCHPRODUCT: updateproductmodif')
emit('updateproductmodif', element) emit('updateproductmodif', element)
} }

View File

@@ -23,6 +23,8 @@
:col="fieldsTable.getColByColumns(mycolumns, item.key)" :col="fieldsTable.getColByColumns(mycolumns, item.key)"
:label="item.value && item.value._id > 0 ? undefined : labelcombo(item)" :label="item.value && item.value._id > 0 ? undefined : labelcombo(item)"
v-model:value="item.value" v-model:value="item.value"
v-model:arrvalue="item.arrvalue"
@update:arrvalue="updateproductmodif"
:addall="item.addall" :addall="item.addall"
:addnone="item.addnone" :addnone="item.addnone"
:focus="focus" :focus="focus"
@@ -38,13 +40,17 @@
:filter="item.filter" :filter="item.filter"
:filter_extra="item.filter_extra" :filter_extra="item.filter_extra"
:useinput="item.useinput && item.type !== costanti.FieldType.select_by_server" :useinput="item.useinput && item.type !== costanti.FieldType.select_by_server"
@clear="item.value = ''; myproduct = null; saveSearch()" @clear="
item.value = '';
myproduct = null;
saveSearch();
"
> >
</CMySelect> </CMySelect>
</div> </div>
<div <div
v-if="myproduct?._id" v-if="myproduct?._id && optcatalogo.arrSchede?.length > 0"
class="row justify-center" class="row justify-center"
style="text-align: center" style="text-align: center"
> >

View File

@@ -35,6 +35,7 @@ export default defineComponent({
} }
function updateproductmodif(element: any) { function updateproductmodif(element: any) {
// console.log('CTABLECUPLE updateproductmodif ', element)
emit('updateproductmodif', element) emit('updateproductmodif', element)
} }

View File

@@ -18,8 +18,11 @@
:id="myrec.id" :id="myrec.id"
:rec="myrec.rec" :rec="myrec.rec"
:mykey="myrec.mykey" :mykey="myrec.mykey"
:mysubkey="myrec.mysubkey"
:debounce="myrec.debounce" :debounce="myrec.debounce"
:jointable="myrec.jointable"
:maxlength="myrec.maxlength" :maxlength="myrec.maxlength"
:showall="myrec.showall"
:type="myrec.type" :type="myrec.type"
:dense="myrec.dense ? myrec.dense : true" :dense="myrec.dense ? myrec.dense : true"
@save="updateproductmodif" @save="updateproductmodif"

View File

@@ -1994,6 +1994,9 @@ h3 {
position: relative; position: relative;
width: 100%; width: 100%;
padding-top: 56.25%; padding-top: 56.25%;
max-width: 800px; /* Limita la larghezza massima */
margin: 0 auto; /* Centra il video orizzontalmente */
/* 16:9 Aspect Ratio */ /* 16:9 Aspect Ratio */
} }
@@ -2003,6 +2006,7 @@ h3 {
left: 0; left: 0;
width: 100%; width: 100%;
height: 100%; height: 100%;
border: none; /* Rimuovi eventuali bordi */
} }
.fake-link { .fake-link {

View File

@@ -825,10 +825,13 @@ export interface IRecFields {
id?: string id?: string
rec?: any rec?: any
mykey?: string mykey?: string
mysubkey?: string
jointable?: string
debounce?: string debounce?: string
type?: number type?: number
dense?: boolean dense?: boolean
maxlength?: number maxlength?: number
showall?: boolean
} }
export interface ISchedaSingola { export interface ISchedaSingola {
@@ -1600,13 +1603,18 @@ export interface IAttivita {
} }
export interface IOptQueryGM { export interface IOptQueryGM {
idapp: string
nameTable: string nameTable: string
campispeciali?: boolean campispeciali?: boolean
query?: string query?: string
numrec?: number numrec?: number
where?: string where?: string
fieldGM?: string fieldGM?: string
outhtml: boolean outhtml?: boolean
showQtaDisponibile?: boolean showQtaDisponibile?: boolean
cmd?: number cmd?: number
insertMode?: boolean
data?: any
updatelocaldb?: boolean
} }

View File

@@ -2049,6 +2049,10 @@ const msg_it = {
isPagIntro: 'Pagina Introduttiva', isPagIntro: 'Pagina Introduttiva',
}, },
dbgm: {
updateLocalDb_OK: 'DB Aggiornato',
},
queryai: { queryai: {
descr: 'Descrizione', descr: 'Descrizione',
catAI: 'Categoria', catAI: 'Categoria',

View File

@@ -9858,6 +9858,20 @@ export const tools = {
); );
}, },
formatCatProds(catprods: ICatProd[] | undefined | null): string {
if (!catprods || !Array.isArray(catprods)) {
return "";
}
// Estrai il nome e il cognome di ogni autore e uniscili con ', '
return catprods
.map((catprod) => `${catprod.name ?? ""}`.trim())
.filter((name) => name.length > 0) // Filtra eventuali nomi vuoti
.join(", ");
},
// FINE ! // FINE !
// getLocale() { // getLocale() {

View File

@@ -129,6 +129,17 @@ export const useProducts = defineStore('Products', {
}, },
getArrayidArgomentoByArridCatProds: (state: IProductsState) => (arridCatProds: string[]): string[] => {
const myarr: string[] = []
for (const idCatProd of arridCatProds) {
const catprod = state.catprods.find((rec: ICatProd) => rec._id === idCatProd)
if (catprod && catprod.idArgomento && !myarr.includes(catprod.idArgomento.toString())) {
myarr.push(catprod.idArgomento.toString())
}
}
return myarr
},
getCatProdsByGas: (state: IProductsState) => (idGasOrdine: string): ICatProd[] => { getCatProdsByGas: (state: IProductsState) => (idGasOrdine: string): ICatProd[] => {
let arrcat = state.catprods_gas let arrcat = state.catprods_gas
@@ -163,7 +174,7 @@ export const useProducts = defineStore('Products', {
} }
if (myarrcat) { if (myarrcat) {
if (mystr) if (mystr)
mystr = ' - ' mystr += ' - '
mystr += myarrcat.name mystr += myarrcat.name
} }
} }
@@ -547,13 +558,13 @@ export const useProducts = defineStore('Products', {
this.products = [...arrprod] this.products = [...arrprod]
},*/ },*/
async getProductById(id: string): Promise<IProduct> { async getProductById(id: string, forza?: boolean): Promise<IProduct> {
let prod = null let prod = null
try { try {
if (!id) { if (!id) {
return null return null
} }
if (!this.products) { if (!this.products || forza) {
// Se non lo carico all'avvio, allora fai la chiamata al server // Se non lo carico all'avvio, allora fai la chiamata al server
prod = await this.loadProductById(id) prod = await this.loadProductById(id)
} else { } else {
@@ -574,8 +585,8 @@ export const useProducts = defineStore('Products', {
//console.log('loadProducts') //console.log('loadProducts')
if (!globalStore.site.confpages.enableEcommerce) // if (!globalStore.site.confpages.enableEcommerce)
return null // return null
// console.log('getProducts', 'userid=', this.userActive._id) // console.log('getProducts', 'userid=', this.userActive._id)
@@ -711,8 +722,8 @@ export const useProducts = defineStore('Products', {
const userStore = useUserStore() const userStore = useUserStore()
const globalStore = useGlobalStore() const globalStore = useGlobalStore()
if (!globalStore.site.confpages.enableEcommerce) //if (!globalStore.site.confpages.enableEcommerce)
return null // return null
// if (this.userActive._id === '') { // if (this.userActive._id === '') {
// return new Types.AxiosError(0, null, 0, '') // return new Types.AxiosError(0, null, 0, '')
@@ -1384,23 +1395,23 @@ export const useProducts = defineStore('Products', {
const long_descr = myproduct.productInfo.description || ''; const long_descr = myproduct.productInfo.description || '';
const date_pub = tools.getstrDateShort(myproduct.productInfo.date_pub) || ''; const date_pub = tools.getstrDateShort(myproduct.productInfo.date_pub) || '';
const fatLast3M = myproduct.productInfo.fatLast3M! || 0; const fatLast3M = myproduct.productInfo.fatLast3M! || 0;
const fatLast6M = myproduct.productInfo.fatLast6M! || 0;
const vLast3M = myproduct.productInfo.vLast3M! || 0; const vLast3M = myproduct.productInfo.vLast3M! || 0;
const vLast6M = myproduct.productInfo.vLast6M! || 0; const vLast6M = myproduct.productInfo.vLast6M! || 0;
const ranking_globale = myproduct.productInfo.rank3M! || 0; const ranking_globale = myproduct.productInfo.rank3M! || 0;
const ranking = myproduct.indiceRanking! || 0;
const venduti = myproduct.productInfo.totVen! || 0; const venduti = myproduct.productInfo.totVen! || 0;
const fatturati = myproduct.productInfo.totFat! || 0; const fatturati = myproduct.productInfo.totFat! || 0;
const linkvenduti = '<a href="http://vps-88271abb.vps.ovh.net/apimacro/public/view-ordini-by-idarticolo/' + myproduct.productInfo.sku + '" target="_blank">' + venduti + '</a>' const linkvenduti = '<a href="http://vps-88271abb.vps.ovh.net/apimacro/public/view-ordini-by-idarticolo/' + myproduct.productInfo.sku + '" target="_blank">' + venduti + '</a>'
const linkfatturati = '<a href="http://vps-88271abb.vps.ovh.net/apimacro/public/view-fatturati-by-idarticolo/' + myproduct.productInfo.sku + '" target="_blank">' + fatturati + '</a>' const linkfatturati = '<a href="http://vps-88271abb.vps.ovh.net/apimacro/public/view-fatturati-by-idarticolo/' + myproduct.productInfo.sku + '" target="_blank">' + fatturati + '</a>'
const debugstr = this.getkeyValStr('Pubblicato il', date_pub) + const debugstr = this.getkeyValStr('Pubblicato il', date_pub) +
this.getkeyValStr('Rank', ranking) +
this.getkeyValStr('Rank3M', myproduct.productInfo.rank3M) + this.getkeyValStr('Rank3M', myproduct.productInfo.rank3M) +
this.getkeyValStr('Venduti', linkvenduti) + this.getkeyValStr('Venduti', linkvenduti) +
this.getkeyValStr('vLast3M', vLast3M) + this.getkeyValStr('vLast3M', vLast3M) +
this.getkeyValStr('vLast6M', vLast6M) + this.getkeyValStr('vLast6M', vLast6M) +
this.getkeyValStr('Fatturati', linkfatturati) + this.getkeyValStr('Fatturati', linkfatturati) +
this.getkeyValStr('fatLast3M', fatLast3M) this.getkeyValStr('fatLast3M', fatLast3M) +
this.getkeyValStr('fatLast6M', fatLast6M)
const truncatedDescription = description.length > maxDescriptionLength const truncatedDescription = description.length > maxDescriptionLength
? description.substring(0, description.lastIndexOf(' ', maxDescriptionLength)) + '...' ? description.substring(0, description.lastIndexOf(' ', maxDescriptionLength)) + '...'
@@ -1467,7 +1478,6 @@ export const useProducts = defineStore('Products', {
'{argomento}': categoria || '', '{argomento}': categoria || '',
'{date_pub}': date_pub || '', '{date_pub}': date_pub || '',
'{ranking_globale}': ranking_globale || '', '{ranking_globale}': ranking_globale || '',
'{ranking}': ranking || '',
'{venduti}': venduti || '', '{venduti}': venduti || '',
'{formato}': formato || '', '{formato}': formato || '',
'{collana_title}': collana ? collana.title || '' : '', '{collana_title}': collana ? collana.title || '' : '',

View File

@@ -2607,10 +2607,55 @@ export const useGlobalStore = defineStore('GlobalStore', {
return null return null
}, },
async updateLocalDbFromGM_T_Web_Articoli(sku: string) {
const options: IOptQueryGM = {
nameTable: 'T_Web_Articoli',
query: '',
where: 'T.IdArticolo =' + sku,
showQtaDisponibile: false,
outhtml: false,
cmd: shared_consts.CmdQueryMs.UPDATE,
updatelocaldb: true,
}
const valueris = await this.fetchTableContent(options);
return !!valueris
},
async setGM_FieldOf_T_Web_Articoli(sku: string, data: Record<string, any>, cmd: number) {
try {
// Verifica se i campi specificati sono validi
if (!data || Object.keys(data).length === 0) {
throw new Error("I campi specificati non sono validi.");
}
// Costruisce le opzioni per l'aggiornamento
const options: IOptQueryGM = {
nameTable: 'T_Web_Articoli',
insertMode: false, // Impostiamo su false per eseguire un UPDATE (modifica)
data, // Dati da aggiornare
where: `IdArticolo = ${sku}`, // Condizione WHERE basata sullo SKU
cmd,
};
// Eseguiamo l'operazione di salvataggio
const result = await this.saveTableContent(options);
// Restituiamo il risultato dell'operazione
return result;
} catch (error) {
console.error("Errore durante l'aggiornamento dei campi:", error.message);
throw new Error(`Errore durante l'aggiornamento dei campi per lo SKU ${sku}: ${error.message}`);
}
},
async fetchTableContent(options: IOptQueryGM) { async fetchTableContent(options: IOptQueryGM) {
try { try {
// aggiungi idapp ad options
options.idapp = tools.getEnv('VITE_APP_ID')
return Api.SendReq('/apisqlsrv/view-table', 'POST', { options }) return Api.SendReq('/apisqlsrv/view-table', 'POST', { options })
.then((res) => { .then((res) => {
return res.data.data return res.data.data
@@ -2623,6 +2668,20 @@ export const useGlobalStore = defineStore('GlobalStore', {
} }
}, },
async saveTableContent(options: IOptQueryGM) {
try {
return Api.SendReq('/apisqlsrv/save-table', 'POST', { options })
.then((res) => {
return res.data.data
}).catch((error: any) => {
console.error('Error saveTableContent: ', error)
})
} catch (error) {
console.error("Errore nel salvataggio della tabella:", error);
throw error;
}
},
async getMailInABox(cmd: string, record: any = undefined) { async getMailInABox(cmd: string, record: any = undefined) {
const mydata = { const mydata = {
@@ -2651,10 +2710,6 @@ export const useGlobalStore = defineStore('GlobalStore', {
}, },
SchedeOpt() {
return this.getSchedeOpt
},
aggiornaRecordInLocaleDopoUpdateSulServer(datain: any, resdata: any) { aggiornaRecordInLocaleDopoUpdateSulServer(datain: any, resdata: any) {
try { try {

View File

@@ -535,6 +535,8 @@ export default defineComponent({
}) })
.sort((a, b) => getProductsSorted([a, b], sortField, sortDir)[0] === a ? -1 : 1); .sort((a, b) => getProductsSorted([a, b], sortField, sortDir)[0] === a ? -1 : 1);
console.log(' sortField=' + sortField)
console.log(' sortDir=' + sortDir)
console.log(' Filtro=' + arrargomstr) console.log(' Filtro=' + arrargomstr)
console.log(' idCollane=' + idCollane) console.log(' idCollane=' + idCollane)
console.log('PRODOTTI FILTRATI:', arrris.length) console.log('PRODOTTI FILTRATI:', arrris.length)
@@ -656,33 +658,68 @@ export default defineComponent({
return arrprod; return arrprod;
} }
/**
* Funzione che ordina un array di prodotti in base a un campo specifico
* @param arrprod array di prodotti da ordinare
* @param sort_field campo su cui effettuare l'ordinamento
* @param sort_dir direzione dell'ordinamento (1 asc, -1 desc)
* @returns array di prodotti ordinati
*/
function getProductsSorted(arrprod: IProduct[], sort_field: string, sort_dir: number): IProduct[] { function getProductsSorted(arrprod: IProduct[], sort_field: string, sort_dir: number): IProduct[] {
if (sort_field) { if (sort_field) {
console.log('--- Primi 10 elementi INIZIALI:');
arrprod.slice(0, 15).forEach((product, index) => {
console.log(
`${index + 1}. ${product.productInfo?.name} (${product.productInfo?.date_pub})`
);
});
// Crea una copia dell'array per non modificare l'originale // Crea una copia dell'array per non modificare l'originale
const sortedArr = [...arrprod].sort((a: IProduct, b: IProduct) => { const sortedArr = [...arrprod].sort((a: IProduct, b: IProduct) => {
const valA = a.productInfo?.[sort_field]; const valA = a.productInfo?.[sort_field];
const valB = b.productInfo?.[sort_field]; const valB = b.productInfo?.[sort_field];
// Gestisce il caso in cui il campo non esiste
if (valA === undefined || valB === undefined) { if (valA === undefined || valB === undefined) {
return 0; // Gestisce il caso in cui il campo non esiste return 0;
} }
// Ordinamento per data
if (valA instanceof Date && valB instanceof Date) {
return sort_dir === 1 ? valA.getTime() - valB.getTime() : valB.getTime() - valA.getTime();
}
// Ordinamento per numeri
if (typeof valA === 'number' && typeof valB === 'number') { if (typeof valA === 'number' && typeof valB === 'number') {
return sort_dir === 1 ? valA - valB : valB - valA; return sort_dir === 1 ? valA - valB : valB - valA;
} else {
// Per stringhe o altri tipi
const compA = valA.toString().toLowerCase();
const compB = valB.toString().toLowerCase();
return sort_dir === 1
? compA.localeCompare(compB)
: compB.localeCompare(compA);
} }
// Ordinamento per stringhe o altri tipi
const compA = valA.toString().toLowerCase();
const compB = valB.toString().toLowerCase();
return sort_dir === 1
? compA.localeCompare(compB)
: compB.localeCompare(compA);
}); });
// logga i primi 3 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: ***** ');
sortedArr.slice(0, 15).forEach((product, index) => {
console.log(
`${index + 1}. ${product.productInfo?.name} (${product.productInfo?.date_pub})`
);
});
} else {
console.log('Nessun prodotto trovato.');
}
// Aggiunge l'indice di ranking ai prodotti
return sortedArr.map((product, index) => ({ return sortedArr.map((product, index) => ({
...product, ...product,
indiceRanking: index + 1 }))
}));
} }
return arrprod; return arrprod;
@@ -807,8 +844,6 @@ export default defineComponent({
recscheda.arrProdToShow[pagina][riga] = []; recscheda.arrProdToShow[pagina][riga] = [];
} }
// console.log('RANKING: ', result.myrec.indiceRanking!)
arrprod.push(result.myrec) arrprod.push(result.myrec)
recscheda.arrProdToShow[pagina][riga][col] = result.myrec recscheda.arrProdToShow[pagina][riga][col] = result.myrec