Aggiornamento cataloghi...
This commit is contained in:
@@ -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() {
|
||||
|
||||
@@ -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 || '' : '',
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user