- 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

@@ -115,7 +115,6 @@ 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 updatetogm = ref(false)
const showQtaDisponibile = ref(false) const showQtaDisponibile = ref(false)
@@ -659,6 +658,22 @@ export default defineComponent({
loading.value = false loading.value = false
} }
}
async function refreshAllDataBookFromGM() {
if (myproduct.value) {
loading.value = true
updatefromgm.value = true
field_updated_fromGM.value = ''
const ris = await globalStore.updateAllBookFromGM_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) {
if (myproduct.value) { if (myproduct.value) {
@@ -744,8 +759,8 @@ export default defineComponent({
refreshFieldFromGM, refreshFieldFromGM,
updatetogm, updatetogm,
refreshDataFromGM, refreshDataFromGM,
refreshAllDataBookFromGM,
loading, loading,
updatelocaldb,
} }
} }
}) })

View File

@@ -157,6 +157,25 @@
<q-item-label>Carica 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
v-if="
tools.isManager() && !optcatalogo.generazionePDFInCorso && (editOn || options.show_edit_book)
"
clickable
v-close-popup
@click="refreshAllDataBookFromGM()"
>
<q-item-section avatar>
<q-avatar
icon="fas fa-pencil-alt"
color="accent"
text-color="white"
/>
</q-item-section>
<q-item-section>
<q-item-label>Riaggiorna Tutto il Libro da GM</q-item-label>
</q-item-section>
</q-item>
<q-item <q-item
v-if=" v-if="
tools.isManager() && !optcatalogo.generazionePDFInCorso && (editOn || options.show_edit_book) tools.isManager() && !optcatalogo.generazionePDFInCorso && (editOn || options.show_edit_book)
@@ -209,7 +228,6 @@
@click=" @click="
showQtaDisponibile = true; showQtaDisponibile = true;
visufromgm = true; visufromgm = true;
updatelocaldb = false;
" "
> >
<q-item-section avatar> <q-item-section avatar>
@@ -599,7 +617,7 @@
:options="{ :options="{
nameTable: 'T_Web_Articoli', nameTable: 'T_Web_Articoli',
campispeciali: true, campispeciali: true,
numrec: 100, numrec: 1,
where: 'T.IdArticolo =' + myproduct.productInfo.sku, where: 'T.IdArticolo =' + myproduct.productInfo.sku,
showQtaDisponibile, showQtaDisponibile,
outhtml: true, outhtml: true,

View File

@@ -1713,7 +1713,7 @@
multiple multiple
emit-value emit-value
map-options map-options
option-value="idCollana" option-value="_id"
option-label="title" option-label="title"
> >
</q-select> </q-select>

View File

@@ -111,7 +111,8 @@ export default defineComponent({
collanestr.value = '' collanestr.value = ''
if (myrec.value.idCollane) { if (myrec.value.idCollane) {
for (const idcollana of myrec.value.idCollane) { for (const idcollana of myrec.value.idCollane) {
const reccoll: ICollana = products.collane!.find((coll: ICollana) => coll.idCollana === idcollana) const reccoll: ICollana = products.collane!.find((coll: ICollana) => coll._id === idcollana)
if (reccoll)
collanestr.value += reccoll.title + ' ' collanestr.value += reccoll.title + ' '
} }
} }

View File

@@ -52,7 +52,7 @@ export default defineComponent({
}, },
setup(props, { emit }) { setup(props, { emit }) {
// Copia locale della lista_prodotti per manipolazione interna // Copia locale della lista_prodotti per manipolazione interna
const internalProducts = ref([...props.lista_prodotti]); const internalProducts = ref([...props.lista_prodotti || []]);
const { t } = useI18n() const { t } = useI18n()
@@ -108,6 +108,7 @@ export default defineComponent({
{ name: "authors", label: "Autore", field: "authors", align: "left" }, { name: "authors", label: "Autore", field: "authors", align: "left" },
{ name: "trafiletto", label: "Trafiletto", field: "trafiletto", align: "left" }, { name: "trafiletto", label: "Trafiletto", field: "trafiletto", align: "left" },
{ name: "catprods", label: "Argomento", field: "catprods", align: "left" }, { name: "catprods", label: "Argomento", field: "catprods", align: "left" },
{ name: "idCollana", label: "Collana", field: "idCollana", align: "left" },
{ name: "date_pub", label: "Pubblicato", field: "date_pub", align: "left" }, { name: "date_pub", label: "Pubblicato", field: "date_pub", align: "left" },
{ name: "ranking", label: "Class.", field: "ranking", align: "right" }, { name: "ranking", label: "Class.", field: "ranking", align: "right" },
{ name: "rank3M", label: "Class. 3M", field: "rank3M", align: "right" }, { name: "rank3M", label: "Class. 3M", field: "rank3M", align: "right" },
@@ -116,6 +117,7 @@ export default defineComponent({
{ name: "pagine", label: "Pag.", field: "pagine", align: "right" }, { name: "pagine", label: "Pag.", field: "pagine", align: "right" },
{ name: "totVen", label: "Venduti", field: "totVen", align: "right" }, { name: "totVen", label: "Venduti", field: "totVen", align: "right" },
{ name: "totFat", label: "Fattur.", field: "totFat", align: "right" }, { name: "totFat", label: "Fattur.", field: "totFat", align: "right" },
{ name: "fatLast6M", label: "Fat 6M", field: "fatLast6M", align: "right" },
{ name: "ult_ord", label: "Ult. Ordine", field: "ult_ord", align: "left" }, { name: "ult_ord", label: "Ult. Ordine", field: "ult_ord", align: "left" },
{ name: "quantity", label: "Magazz.", field: "quantity", align: "right" }, { name: "quantity", label: "Magazz.", field: "quantity", align: "right" },
{ name: "isbn", label: "ISBN", field: "isbn", align: "left" }, { name: "isbn", label: "ISBN", field: "isbn", align: "left" },

View File

@@ -83,6 +83,8 @@
<!-- Argomento --> <!-- Argomento -->
<td v-if="isColumnVisible('catprods')">{{ tools.formatCatProds(element.productInfo?.catprods) }}</td> <td v-if="isColumnVisible('catprods')">{{ tools.formatCatProds(element.productInfo?.catprods) }}</td>
<!-- Collana -->
<td v-if="isColumnVisible('idCollana')">{{ tools.formatCollane(element.productInfo?.idCollana) }}</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>
@@ -124,6 +126,12 @@
> >
{{ element.productInfo?.totFat }} {{ element.productInfo?.totFat }}
</td> </td>
<td
v-if="isColumnVisible('fatLast6M')"
style="text-align: right"
>
{{ element.productInfo?.fatLast6M }}
</td>
<td v-if="isColumnVisible('ult_ord')">{{ tools.getstrDate(element.productInfo?.dataUltimoOrdine) }}</td> <td v-if="isColumnVisible('ult_ord')">{{ tools.getstrDate(element.productInfo?.dataUltimoOrdine) }}</td>
<!-- Quantità --> <!-- Quantità -->
@@ -231,8 +239,8 @@
:options="{ :options="{
nameTable: 'T_Web_Articoli', nameTable: 'T_Web_Articoli',
campispeciali: true, campispeciali: true,
numrec: 100, numrec: 1,
where: 'T.IdArticolo =' + selProd.productInfo.sku, where: 'T.IdArticolo =' + selProd.productInfo.sku + ' AND T.DataPubblicazione IS NOT NULL ORDER BY T.DataOra DESC;',
showQtaDisponibile, showQtaDisponibile,
outhtml: true, outhtml: true,
}" }"

View File

@@ -1603,7 +1603,7 @@ export interface IAttivita {
} }
export interface IOptQueryGM { export interface IOptQueryGM {
idapp: string idapp?: string
nameTable: string nameTable: string
campispeciali?: boolean campispeciali?: boolean
query?: string query?: string

View File

@@ -54,6 +54,7 @@ export interface IProductInfo {
totFat?: number, totFat?: number,
vLast3M?: number, vLast3M?: number,
fatLast3M?: number, fatLast3M?: number,
fatLast6M?: number,
vLast6M?: number, vLast6M?: number,
vLastY?: number, vLastY?: number,
vLast2Y?: number, vLast2Y?: number,
@@ -103,7 +104,6 @@ export interface IProdView {
export interface IProduct { export interface IProduct {
_id?: any _id?: any
indiceRanking?: number
active?: boolean active?: boolean
isbn?: string isbn?: string
idProductInfo?: string, idProductInfo?: string,

View File

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

View File

@@ -26,7 +26,8 @@ import type {
IAreaDiStampa, IAreaDiStampa,
IOptCatalogo, IOptCatalogo,
IPagina, IPagina,
IMyScheda IMyScheda,
ICollana
} from '@model'; } from '@model';
import { import {
Privacy, Privacy,
@@ -63,6 +64,7 @@ import type { AxiosResponse } from 'axios';
import { default as Axios } from 'axios' import { default as Axios } from 'axios'
import { PayloadMessageTypes } from '@src/common' import { PayloadMessageTypes } from '@src/common'
import { useNotifStore } from '@store/NotifStore' import { useNotifStore } from '@store/NotifStore'
import { useProducts } from '../Products';
const { t } = i18n.global; const { t } = i18n.global;
@@ -3556,6 +3558,11 @@ export const tools = {
} }
}, },
getDateFromISOString(mydate): Date {
const mydate2 = new Date(mydate)
return mydate2
},
getDateNow() { getDateNow() {
const mydate = new Date() const mydate = new Date()
return mydate return mydate
@@ -9870,6 +9877,28 @@ export const tools = {
.join(", "); .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 ! // FINE !

View File

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

View File

@@ -2590,9 +2590,9 @@ export const useGlobalStore = defineStore('GlobalStore', {
const options: IOptQueryGM = { const options: IOptQueryGM = {
nameTable: 'T_Web_Articoli', nameTable: 'T_Web_Articoli',
campispeciali: !field, campispeciali: !field,
numrec: 100, numrec: 1,
query: '', query: '',
where: 'T.IdArticolo =' + sku, where: 'T.IdArticolo =' + sku + ' AND T.DataPubblicazione IS NOT NULL ORDER BY T.DataOra DESC;',
fieldGM: field, fieldGM: field,
showQtaDisponibile: false, showQtaDisponibile: false,
outhtml: false, outhtml: false,
@@ -2623,6 +2623,12 @@ export const useGlobalStore = defineStore('GlobalStore', {
return !!valueris 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) { async setGM_FieldOf_T_Web_Articoli(sku: string, data: Record<string, any>, cmd: number) {
try { 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) { async saveTableContent(options: IOptQueryGM) {
try { try {
return Api.SendReq('/apisqlsrv/save-table', 'POST', { options }) return Api.SendReq('/apisqlsrv/save-table', 'POST', { options })

View File

@@ -22,7 +22,8 @@ import { CSelectUserActive } from '@src/components/CSelectUserActive'
import type { import type {
IOptCatalogo, IDimensioni, IFilterCatalogo, IOptCatalogo, IDimensioni, IFilterCatalogo,
IMyScheda, IProdView, IProduct, ISchedaSingola, ISearchList, ICatalog, IImg, IMyScheda, IProdView, IProduct, ISchedaSingola, ISearchList, ICatalog, IImg,
IText IText,
ICollana,
} from 'model'; } from 'model';
import { import {
IMyPage, IMyPage,
@@ -444,7 +445,7 @@ export default defineComponent({
filtroProductTypes: number[], filtroProductTypes: number[],
filtroExcludeProductTypes: number[], filtroExcludeProductTypes: number[],
editore: string[], editore: string[],
idCollane: number[], idCollane: ICollana[],
arrargomstr: any[], arrargomstr: any[],
catstr: string, catstr: string,
gasselstr: string, gasselstr: string,
@@ -504,7 +505,7 @@ export default defineComponent({
// Filtri per collana // Filtri per collana
const hasCollana = boolfiltroVuotoCollane const hasCollana = boolfiltroVuotoCollane
? true ? true
: idCollane.includes(product.productInfo.idCollana); : (idCollane || []).some((item: ICollana) => product.productInfo.idCollana === item.idCollana)
// Filtri per GAS // Filtri per GAS
const productgassel = !gasselstr || (cosaValue === shared_consts.PROD.GAS && product.idGasordine === gasselstr); const productgassel = !gasselstr || (cosaValue === shared_consts.PROD.GAS && product.idGasordine === gasselstr);