- Aggiornamento dal DB di GM al DB Locale

This commit is contained in:
Surya Paolo
2025-04-16 23:28:21 +02:00
parent 383e0bb484
commit 14375d6b15
13 changed files with 118 additions and 21 deletions

View File

@@ -4376,7 +4376,7 @@ export const fieldsTable = {
value: 'collanas',
label: 'Collane',
columns: colTableCollane,
colkey: 'idCollana',
colkey: '_id',
collabel: 'title',
},
{

View File

@@ -26,7 +26,8 @@ import type {
IAreaDiStampa,
IOptCatalogo,
IPagina,
IMyScheda
IMyScheda,
ICollana
} from '@model';
import {
Privacy,
@@ -63,6 +64,7 @@ import type { AxiosResponse } from 'axios';
import { default as Axios } from 'axios'
import { PayloadMessageTypes } from '@src/common'
import { useNotifStore } from '@store/NotifStore'
import { useProducts } from '../Products';
const { t } = i18n.global;
@@ -3556,6 +3558,11 @@ export const tools = {
}
},
getDateFromISOString(mydate): Date {
const mydate2 = new Date(mydate)
return mydate2
},
getDateNow() {
const mydate = new Date()
return mydate
@@ -9870,6 +9877,28 @@ export const tools = {
.join(", ");
},
formatCollane(collane: number[] | number | undefined | null): string {
if (!collane) {
return "";
}
const products = useProducts()
if (Array.isArray(collane)) {
// Estrai le collane e uniscile con ', '
return collane
.map((idcollana) => {
const reccoll: ICollana | undefined = products.collane!.find((coll: ICollana) => coll.idCollana === idcollana)
return reccoll ? `${reccoll.title ?? ""}`.trim() : ""
})
.filter((name) => name.length > 0) // Filtra eventuali nomi vuoti
.join(", ");
} else {
const reccoll: ICollana | undefined = products.collane!.find((coll: ICollana) => coll.idCollana === collane)
return reccoll ? `${reccoll.title}` : ''
}
},
// FINE !

View File

@@ -1388,7 +1388,7 @@ export const useProducts = defineStore('Products', {
}
const autori = this.getAutoriByArrayAuthors(myproduct.productInfo.authors)
const collana = myproduct.productInfo.collana
const collana = tools.formatCollane(myproduct.productInfo.idCollana)
const maxDescriptionLength = testo.maxlength ?? 100;
const description = myproduct.productInfo.short_descr || '';
@@ -1480,7 +1480,7 @@ export const useProducts = defineStore('Products', {
'{ranking_globale}': ranking_globale || '',
'{venduti}': venduti || '',
'{formato}': formato || '',
'{collana_title}': collana ? collana.title || '' : '',
'{collana}': collana ? collana || '' : '',
'{prezzo}': prezzo || '',
'{scale}': scale || '',
'{prezzo_scontato}': prezzo_scontato || '',
@@ -1493,6 +1493,7 @@ export const useProducts = defineStore('Products', {
'{imagefile}': imagefile || '',
};
// Esegue le sostituzioni
let result = testo.contenuto;
for (const [key, value] of Object.entries(replacements)) {

View File

@@ -2590,9 +2590,9 @@ export const useGlobalStore = defineStore('GlobalStore', {
const options: IOptQueryGM = {
nameTable: 'T_Web_Articoli',
campispeciali: !field,
numrec: 100,
numrec: 1,
query: '',
where: 'T.IdArticolo =' + sku,
where: 'T.IdArticolo =' + sku + ' AND T.DataPubblicazione IS NOT NULL ORDER BY T.DataOra DESC;',
fieldGM: field,
showQtaDisponibile: false,
outhtml: false,
@@ -2623,6 +2623,12 @@ export const useGlobalStore = defineStore('GlobalStore', {
return !!valueris
},
async updateAllBookFromGM_T_Web_Articoli(sku: string) {
const valueris = await this.updateAllBookTableContent({ sku });
return valueris
},
async setGM_FieldOf_T_Web_Articoli(sku: string, data: Record<string, any>, cmd: number) {
try {
@@ -2668,6 +2674,22 @@ export const useGlobalStore = defineStore('GlobalStore', {
}
},
async updateAllBookTableContent(options: any) {
try {
// aggiungi idapp ad options
options.idapp = tools.getEnv('VITE_APP_ID')
return Api.SendReq('/apisqlsrv/updateAllBook', 'POST', { options })
.then((res) => {
return res.data.data
}).catch((error: any) => {
console.error('Error fetchTableContent: ', error)
})
} catch (error) {
console.error("Errore nel recupero della tabella:", error);
throw error;
}
},
async saveTableContent(options: IOptQueryGM) {
try {
return Api.SendReq('/apisqlsrv/save-table', 'POST', { options })