- Aggiornamento dal DB di GM al DB Locale
This commit is contained in:
@@ -115,7 +115,6 @@ 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)
|
||||
@@ -659,6 +658,22 @@ export default defineComponent({
|
||||
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) {
|
||||
if (myproduct.value) {
|
||||
@@ -744,8 +759,8 @@ export default defineComponent({
|
||||
refreshFieldFromGM,
|
||||
updatetogm,
|
||||
refreshDataFromGM,
|
||||
refreshAllDataBookFromGM,
|
||||
loading,
|
||||
updatelocaldb,
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -157,6 +157,25 @@
|
||||
<q-item-label>Carica da GM</q-item-label>
|
||||
</q-item-section>
|
||||
</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
|
||||
v-if="
|
||||
tools.isManager() && !optcatalogo.generazionePDFInCorso && (editOn || options.show_edit_book)
|
||||
@@ -209,7 +228,6 @@
|
||||
@click="
|
||||
showQtaDisponibile = true;
|
||||
visufromgm = true;
|
||||
updatelocaldb = false;
|
||||
"
|
||||
>
|
||||
<q-item-section avatar>
|
||||
@@ -599,7 +617,7 @@
|
||||
:options="{
|
||||
nameTable: 'T_Web_Articoli',
|
||||
campispeciali: true,
|
||||
numrec: 100,
|
||||
numrec: 1,
|
||||
where: 'T.IdArticolo =' + myproduct.productInfo.sku,
|
||||
showQtaDisponibile,
|
||||
outhtml: true,
|
||||
|
||||
@@ -1713,7 +1713,7 @@
|
||||
multiple
|
||||
emit-value
|
||||
map-options
|
||||
option-value="idCollana"
|
||||
option-value="_id"
|
||||
option-label="title"
|
||||
>
|
||||
</q-select>
|
||||
|
||||
@@ -111,7 +111,8 @@ export default defineComponent({
|
||||
collanestr.value = ''
|
||||
if (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 + ' '
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ export default defineComponent({
|
||||
},
|
||||
setup(props, { emit }) {
|
||||
// Copia locale della lista_prodotti per manipolazione interna
|
||||
const internalProducts = ref([...props.lista_prodotti]);
|
||||
const internalProducts = ref([...props.lista_prodotti || []]);
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
@@ -108,6 +108,7 @@ export default defineComponent({
|
||||
{ name: "authors", label: "Autore", field: "authors", align: "left" },
|
||||
{ name: "trafiletto", label: "Trafiletto", field: "trafiletto", 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: "ranking", label: "Class.", field: "ranking", 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: "totVen", label: "Venduti", field: "totVen", 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: "quantity", label: "Magazz.", field: "quantity", align: "right" },
|
||||
{ name: "isbn", label: "ISBN", field: "isbn", align: "left" },
|
||||
|
||||
@@ -83,6 +83,8 @@
|
||||
|
||||
<!-- Argomento -->
|
||||
<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>
|
||||
|
||||
@@ -124,6 +126,12 @@
|
||||
>
|
||||
{{ element.productInfo?.totFat }}
|
||||
</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>
|
||||
|
||||
<!-- Quantità -->
|
||||
@@ -231,8 +239,8 @@
|
||||
:options="{
|
||||
nameTable: 'T_Web_Articoli',
|
||||
campispeciali: true,
|
||||
numrec: 100,
|
||||
where: 'T.IdArticolo =' + selProd.productInfo.sku,
|
||||
numrec: 1,
|
||||
where: 'T.IdArticolo =' + selProd.productInfo.sku + ' AND T.DataPubblicazione IS NOT NULL ORDER BY T.DataOra DESC;',
|
||||
showQtaDisponibile,
|
||||
outhtml: true,
|
||||
}"
|
||||
|
||||
@@ -1603,7 +1603,7 @@ export interface IAttivita {
|
||||
}
|
||||
|
||||
export interface IOptQueryGM {
|
||||
idapp: string
|
||||
idapp?: string
|
||||
nameTable: string
|
||||
campispeciali?: boolean
|
||||
query?: string
|
||||
|
||||
@@ -54,6 +54,7 @@ export interface IProductInfo {
|
||||
totFat?: number,
|
||||
vLast3M?: number,
|
||||
fatLast3M?: number,
|
||||
fatLast6M?: number,
|
||||
vLast6M?: number,
|
||||
vLastY?: number,
|
||||
vLast2Y?: number,
|
||||
@@ -103,7 +104,6 @@ export interface IProdView {
|
||||
|
||||
export interface IProduct {
|
||||
_id?: any
|
||||
indiceRanking?: number
|
||||
active?: boolean
|
||||
isbn?: string
|
||||
idProductInfo?: string,
|
||||
|
||||
@@ -4376,7 +4376,7 @@ export const fieldsTable = {
|
||||
value: 'collanas',
|
||||
label: 'Collane',
|
||||
columns: colTableCollane,
|
||||
colkey: 'idCollana',
|
||||
colkey: '_id',
|
||||
collabel: 'title',
|
||||
},
|
||||
{
|
||||
|
||||
@@ -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 !
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
@@ -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 })
|
||||
|
||||
@@ -22,7 +22,8 @@ import { CSelectUserActive } from '@src/components/CSelectUserActive'
|
||||
import type {
|
||||
IOptCatalogo, IDimensioni, IFilterCatalogo,
|
||||
IMyScheda, IProdView, IProduct, ISchedaSingola, ISearchList, ICatalog, IImg,
|
||||
IText
|
||||
IText,
|
||||
ICollana,
|
||||
} from 'model';
|
||||
import {
|
||||
IMyPage,
|
||||
@@ -444,7 +445,7 @@ export default defineComponent({
|
||||
filtroProductTypes: number[],
|
||||
filtroExcludeProductTypes: number[],
|
||||
editore: string[],
|
||||
idCollane: number[],
|
||||
idCollane: ICollana[],
|
||||
arrargomstr: any[],
|
||||
catstr: string,
|
||||
gasselstr: string,
|
||||
@@ -504,7 +505,7 @@ export default defineComponent({
|
||||
// Filtri per collana
|
||||
const hasCollana = boolfiltroVuotoCollane
|
||||
? true
|
||||
: idCollane.includes(product.productInfo.idCollana);
|
||||
: (idCollane || []).some((item: ICollana) => product.productInfo.idCollana === item.idCollana)
|
||||
|
||||
// Filtri per GAS
|
||||
const productgassel = !gasselstr || (cosaValue === shared_consts.PROD.GAS && product.idGasordine === gasselstr);
|
||||
|
||||
Reference in New Issue
Block a user