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"
SERVERDIR_WEBSITE="/var/www/gruppomacro.app"
SERVERPW_WEBSITE="pwdadmin@1AOK"
PORT_SPA="8089"
PORT_PWA="8099"

1
.gitignore vendored
View File

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

View File

@@ -10,7 +10,7 @@
<meta name="description" content="<%= productDescription %>">
<meta name="format-detection" content="telephone=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"
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",
"version": "1.2.32",
"version": "1.2.33",
"description": "Gruppo Macro",
"productName": "Gruppo Macro",
"author": "Surya",
@@ -9,20 +9,20 @@
"license": "MIT",
"type": "module",
"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",
"build": "quasar build",
"buildpwa": "NODE_ENV=production APP_VERSION='1.2.32' quasar build -m pwa",
"buildpwatest": "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.33' quasar build -m pwa",
"type-check": "vue-tsc --noEmit",
"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}\"",
"lintfile": "eslint --ext .js,.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",
"pwa": "NODE_ENV=development PORT=8099 APP_VERSION='1.2.32' quasar dev -m pwa",
"spa": "NODE_ENV=development PORT=8089 APP_VERSION='1.2.32' quasar dev",
"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.33' quasar dev",
"debug": "quasar dev --mode debug",
"test": "echo \"No test specified\" && exit 0",
"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 cfgenv */
const VITE_APP_VERSION = "1.2.32";
const VITE_APP_VERSION = "1.2.33";
// Costanti di configurazione
const DYNAMIC_CACHE = 'dynamic-cache-v2';

View File

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

View File

@@ -115,7 +115,9 @@ export default defineComponent({
const apriSchedaPDF = ref(false)
const visufromgm = ref(false)
const updatelocaldb = ref(false)
const updatefromgm = ref(false)
const updatetogm = ref(false)
const showQtaDisponibile = ref(false)
const field_updated_fromGM = ref('')
@@ -312,7 +314,7 @@ export default defineComponent({
if (carica) {
myproduct.value = null;
updateproductmodif()
updateproductmodif(null)
}
// products.updateQuantityAvailable(myproduct.value._id)
@@ -334,9 +336,9 @@ export default defineComponent({
console.log('CCATALOGOCARD: updateproductmodif')
try {
if (element?._id) {
myproduct.value = await products.getProductById(element?._id)
myproduct.value = await products.getProductById(element?._id, true)
} else {
myproduct.value = await products.getProductById(props.id)
myproduct.value = await products.getProductById(props.id, true)
}
updateLabel()
@@ -627,8 +629,8 @@ export default defineComponent({
function isProductBestseller() {
try {
//return myproduct.value!.productInfo.rank1Y! > 0 && (myproduct.value!.productInfo.rank1Y! < props.scheda.etichette?.bestseller?.primiNInClassifica!)
return myproduct.value!.indiceRanking! > 0 && (myproduct.value!.indiceRanking! < props.scheda.etichette?.bestseller?.primiNInClassifica)
// diventa un bestseller quando il rank6M è tra i primi 10 ordinandoli per rank6M
return myproduct.value!.productInfo.rank6M! > 0 && (myproduct.value!.productInfo.rank6M!)
} catch (e) {
return false
}
@@ -643,6 +645,19 @@ export default defineComponent({
}
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) {
@@ -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)
loading.value = false
}
}
onMounted(mounted)
@@ -728,8 +742,10 @@ export default defineComponent({
showQtaDisponibile,
field_updated_fromGM,
refreshFieldFromGM,
updatetogm,
refreshDataFromGM,
loading,
updatelocaldb,
}
}
})

View File

@@ -154,7 +154,7 @@
/>
</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>
<q-item
@@ -209,6 +209,7 @@
@click="
showQtaDisponibile = true;
visufromgm = true;
updatelocaldb = false;
"
>
<q-item-section avatar>
@@ -575,6 +576,8 @@
@updateproductmodif="updateproductmodif"
>
</CSchedaProdotto>
updateFieldToGM
</q-dialog>
<q-dialog
v-if="visufromgm && myproduct"
@@ -638,6 +641,38 @@
</q-card-section>
</q-card>
</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>
</template>

View File

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

View File

@@ -1,5 +1,8 @@
<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
:label="label ? label : undefined"
:stack-label="!!label"
@@ -7,23 +10,36 @@
:dense="dense"
color="blue-6"
>
<template v-if="copy" v-slot:prepend>
<q-btn round dense flat icon="far fa-copy" @click="copytoclip"/>
<template
v-if="copy"
v-slot:prepend
>
<q-btn
round
dense
flat
icon="far fa-copy"
@click="copytoclip"
/>
</template>
<template v-slot:control>
<div class="self-center full-width no-outline" tabindex="0">
<span :class="class_text" :style="`color: ` + color " v-html="value"></span>
<div
class="self-center full-width no-outline"
tabindex="0"
>
<span
:class="class_text"
:style="`color: ` + color"
v-html="value"
></span>
<slot></slot>
</div>
</template>
</q-field>
</div>
</template>
<script lang="ts" src="./CLabel.ts">
</script>
<script lang="ts" src="./CLabel.ts"></script>
<style lang="scss" scoped>
@import './CLabel.scss';

View File

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

View File

@@ -240,6 +240,8 @@ export default defineComponent({
const loaded = ref(false)
const popupEditRef = ref(null)
const addstrrequired = ref('')
const col = ref(<IColGridTable>{
@@ -287,7 +289,6 @@ export default defineComponent({
if (props.filter)
col.value.filter = props.filter
col.value.fieldtype = props.type
col.value.label = props.title
if (props.type === costanti.FieldType.image) {
myImgGall.value = [{
@@ -412,6 +413,7 @@ export default defineComponent({
}
function changevalRecOrig(newval: any, subcol: string = '') {
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)
@@ -459,6 +461,7 @@ export default defineComponent({
if (props.isInModif)
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)
@@ -951,6 +968,10 @@ export default defineComponent({
mypath,
changeValRecCoordAddr,
addstrrequired,
t,
handleKeydown,
handleCancel,
popupEditRef,
}
}
})

View File

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

View File

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

View File

@@ -146,6 +146,11 @@ export default defineComponent({
required: false,
default: false,
},
showall: {
type: Boolean,
required: false,
default: false,
},
},
components: { CMyPopupEdit },
setup(props, { emit }) {
@@ -164,7 +169,10 @@ export default defineComponent({
console.log('showandsave CMyFieldDb', row, col, newval)
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"
:title="title"
:field="mykey"
:showall="showall"
:filter="filter"
:subfield="mysubkey"
:specialField="specialField"

View File

@@ -6,6 +6,7 @@ import { tools } from '@tools'
import { useGlobalStore } from '@src/store/globalStore'
import { CMyValueDb } from '@src/components/CMyValueDb'
import { CSchedaProdotto } from '@src/components/CSchedaProdotto'
import { CSearchProduct } from '@src/components/CSearchProduct'
import { CMyDialog } from '@src/components/CMyDialog'
@@ -29,6 +30,7 @@ export default defineComponent({
emits: ["update:lista_prodotti", "update:optcatalogo"],
components: {
draggable, CSearchProduct, CMyDialog, CMyValueDb, CViewTable, CLabel,
CSchedaProdotto,
},
props: {
lista_prodotti: {
@@ -69,7 +71,6 @@ export default defineComponent({
const field_updated_fromGM = ref('')
const modifOn = ref(false)
const endload = ref(false)
const optionscatalogo = ref(<any>{maxlength: 0})
@@ -173,18 +174,6 @@ export default defineComponent({
.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
onMounted(() => {
const savedColumns = tools.getCookie("selColCat");
@@ -269,7 +258,6 @@ export default defineComponent({
isColumnVisible,
internalProducts,
formatAuthors,
formatCatProds,
removeProduct,
modifyProduct,
tools,
@@ -290,7 +278,6 @@ export default defineComponent({
loading,
showQtaDisponibile,
modifOn,
endload,
updateproductmodif,
optionscatalogo,
t,

View File

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

View File

@@ -17,11 +17,12 @@ import type {
import { shared_consts } from "app/src/common/shared_vuejs";
import { useProducts } from "app/src/store/Products";
import { useI18n } from "vue-i18n";
import { useQuasar } from "quasar";
export default defineComponent({
name: "CSchedaProdotto",
emits: [],
emits: ['updateproductmodif'],
components: {
CTableCupleLabelValue
},
@@ -37,14 +38,10 @@ export default defineComponent({
}),
},
updateproductmodif: {
type: Function as PropType<(element: any) => void>,
required: false,
default: () => () => { },
},
},
setup(props, { emit }) {
// Copia locale della lista_prodotti per manipolazione interna
const $q = useQuasar()
const { t } = useI18n()
const globalStore = useGlobalStore()
@@ -52,6 +49,11 @@ export default defineComponent({
const mytab = ref('scheda')
const loading = ref(false)
const updatetogm = ref(false)
const field_updated_toGM = ref('')
const myproduct = ref<IProduct>({ ...props.modelValue })
watch(() => props.modelValue, (newVal) => {
@@ -95,6 +97,16 @@ export default defineComponent({
debounce: "1000",
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,
label: "Venduti",
@@ -172,17 +184,6 @@ export default defineComponent({
function getArrListDescrizioni(): 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,
label: "Descrizione Trafiletto per Catalogo",
@@ -193,6 +194,19 @@ export default defineComponent({
debounce: "1000",
type: costanti.FieldType.string,
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,
@@ -205,6 +219,7 @@ export default defineComponent({
debounce: "1000",
type: costanti.FieldType.string,
dense: true,
showall: true,
},
{
editOn: true,
@@ -216,6 +231,7 @@ export default defineComponent({
debounce: "1000",
type: costanti.FieldType.string,
dense: true,
showall: true,
},
]
@@ -258,6 +274,18 @@ export default defineComponent({
type: costanti.FieldType.onlydate,
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,
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)
return {
@@ -348,6 +446,12 @@ export default defineComponent({
getArrListStat,
mytab,
myproduct,
updateproductmodif,
updatetogm,
field_updated_toGM,
loading,
updateRecordToGM,
refreshDataFromGM,
}
}
})

View File

@@ -11,6 +11,18 @@
></q-btn>
</q-toolbar>
<q-card-section class="q-pa-xs inset-shadow">
<div>
<q-inner-loading
id="spinner"
:showing="loading"
>
<q-spinner-tail
color="primary"
size="4em"
>
</q-spinner-tail>
</q-inner-loading>
<q-tabs
v-model="mytab"
inline-label
@@ -58,6 +70,25 @@
</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>
</template>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -2049,6 +2049,10 @@ const msg_it = {
isPagIntro: 'Pagina Introduttiva',
},
dbgm: {
updateLocalDb_OK: 'DB Aggiornato',
},
queryai: {
descr: 'Descrizione',
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 !
// 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[] => {
let arrcat = state.catprods_gas
@@ -163,7 +174,7 @@ export const useProducts = defineStore('Products', {
}
if (myarrcat) {
if (mystr)
mystr = ' - '
mystr += ' - '
mystr += myarrcat.name
}
}
@@ -547,13 +558,13 @@ export const useProducts = defineStore('Products', {
this.products = [...arrprod]
},*/
async getProductById(id: string): Promise<IProduct> {
async getProductById(id: string, forza?: boolean): Promise<IProduct> {
let prod = null
try {
if (!id) {
return null
}
if (!this.products) {
if (!this.products || forza) {
// Se non lo carico all'avvio, allora fai la chiamata al server
prod = await this.loadProductById(id)
} else {
@@ -574,8 +585,8 @@ export const useProducts = defineStore('Products', {
//console.log('loadProducts')
if (!globalStore.site.confpages.enableEcommerce)
return null
// if (!globalStore.site.confpages.enableEcommerce)
// return null
// console.log('getProducts', 'userid=', this.userActive._id)
@@ -711,8 +722,8 @@ export const useProducts = defineStore('Products', {
const userStore = useUserStore()
const globalStore = useGlobalStore()
if (!globalStore.site.confpages.enableEcommerce)
return null
//if (!globalStore.site.confpages.enableEcommerce)
// return null
// if (this.userActive._id === '') {
// return new Types.AxiosError(0, null, 0, '')
@@ -1384,23 +1395,23 @@ export const useProducts = defineStore('Products', {
const long_descr = myproduct.productInfo.description || '';
const date_pub = tools.getstrDateShort(myproduct.productInfo.date_pub) || '';
const fatLast3M = myproduct.productInfo.fatLast3M! || 0;
const fatLast6M = myproduct.productInfo.fatLast6M! || 0;
const vLast3M = myproduct.productInfo.vLast3M! || 0;
const vLast6M = myproduct.productInfo.vLast6M! || 0;
const ranking_globale = myproduct.productInfo.rank3M! || 0;
const ranking = myproduct.indiceRanking! || 0;
const venduti = myproduct.productInfo.totVen! || 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 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) +
this.getkeyValStr('Rank', ranking) +
this.getkeyValStr('Rank3M', myproduct.productInfo.rank3M) +
this.getkeyValStr('Venduti', linkvenduti) +
this.getkeyValStr('vLast3M', vLast3M) +
this.getkeyValStr('vLast6M', vLast6M) +
this.getkeyValStr('Fatturati', linkfatturati) +
this.getkeyValStr('fatLast3M', fatLast3M)
this.getkeyValStr('fatLast3M', fatLast3M) +
this.getkeyValStr('fatLast6M', fatLast6M)
const truncatedDescription = description.length > maxDescriptionLength
? description.substring(0, description.lastIndexOf(' ', maxDescriptionLength)) + '...'
@@ -1467,7 +1478,6 @@ export const useProducts = defineStore('Products', {
'{argomento}': categoria || '',
'{date_pub}': date_pub || '',
'{ranking_globale}': ranking_globale || '',
'{ranking}': ranking || '',
'{venduti}': venduti || '',
'{formato}': formato || '',
'{collana_title}': collana ? collana.title || '' : '',

View File

@@ -2607,10 +2607,55 @@ export const useGlobalStore = defineStore('GlobalStore', {
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) {
try {
// aggiungi idapp ad options
options.idapp = tools.getEnv('VITE_APP_ID')
return Api.SendReq('/apisqlsrv/view-table', 'POST', { options })
.then((res) => {
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) {
const mydata = {
@@ -2651,10 +2710,6 @@ export const useGlobalStore = defineStore('GlobalStore', {
},
SchedeOpt() {
return this.getSchedeOpt
},
aggiornaRecordInLocaleDopoUpdateSulServer(datain: any, resdata: any) {
try {

View File

@@ -535,6 +535,8 @@ export default defineComponent({
})
.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(' idCollane=' + idCollane)
console.log('PRODOTTI FILTRATI:', arrris.length)
@@ -656,33 +658,68 @@ export default defineComponent({
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[] {
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
const sortedArr = [...arrprod].sort((a: IProduct, b: IProduct) => {
const valA = a.productInfo?.[sort_field];
const valB = b.productInfo?.[sort_field];
// Gestisce il caso in cui il campo non esiste
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') {
return sort_dir === 1 ? valA - valB : valB - valA;
} else {
// Per stringhe o altri tipi
}
// 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) => ({
...product,
indiceRanking: index + 1
}));
}))
}
return arrprod;
@@ -807,8 +844,6 @@ export default defineComponent({
recscheda.arrProdToShow[pagina][riga] = [];
}
// console.log('RANKING: ', result.myrec.indiceRanking!)
arrprod.push(result.myrec)
recscheda.arrProdToShow[pagina][riga][col] = result.myrec