- scheda prodotto migliorata
- aggiornamento filtri
This commit is contained in:
@@ -299,7 +299,7 @@ export default defineComponent({
|
||||
|
||||
}
|
||||
|
||||
async function updateproduct(atload: boolean) {
|
||||
async function updateproduct(atload: boolean, forza?: boolean) {
|
||||
|
||||
let carica = true
|
||||
|
||||
@@ -313,7 +313,7 @@ export default defineComponent({
|
||||
|
||||
if (carica) {
|
||||
myproduct.value = null;
|
||||
updateproductmodif(null)
|
||||
updateproductmodif(null, forza)
|
||||
}
|
||||
|
||||
// products.updateQuantityAvailable(myproduct.value._id)
|
||||
@@ -331,13 +331,13 @@ export default defineComponent({
|
||||
|
||||
}
|
||||
|
||||
async function updateproductmodif(element: any) {
|
||||
async function updateproductmodif(element: any, forza?: boolean) {
|
||||
console.log('CCATALOGOCARD: updateproductmodif')
|
||||
try {
|
||||
if (element?._id) {
|
||||
myproduct.value = await products.getProductById(element?._id, true)
|
||||
myproduct.value = await products.getProductById(element?._id, forza)
|
||||
} else {
|
||||
myproduct.value = await products.getProductById(props.id, true)
|
||||
myproduct.value = await products.getProductById(props.id, forza)
|
||||
}
|
||||
|
||||
updateLabel()
|
||||
@@ -458,7 +458,7 @@ export default defineComponent({
|
||||
async function load() {
|
||||
indvariazSel.value = -1
|
||||
initproduct()
|
||||
await updateproduct(true)
|
||||
await updateproduct(true, true)
|
||||
labelDataArrivoMerce.value = ''
|
||||
labelDataRitiro.value = ''
|
||||
|
||||
@@ -643,7 +643,7 @@ export default defineComponent({
|
||||
return optcatalogo.value.areadistampa!.scale
|
||||
}
|
||||
|
||||
async function refreshDataFromGM() {
|
||||
/*async function refreshDataFromGM() {
|
||||
if (myproduct.value) {
|
||||
loading.value = true
|
||||
updatefromgm.value = true
|
||||
@@ -659,8 +659,9 @@ export default defineComponent({
|
||||
loading.value = false
|
||||
}
|
||||
|
||||
}
|
||||
async function refreshAllDataBookFromGM(options: any) {
|
||||
}*/
|
||||
|
||||
/*async function refreshAllDataBookFromGM(options: any) {
|
||||
if (myproduct.value) {
|
||||
loading.value = true
|
||||
updatefromgm.value = true
|
||||
@@ -669,14 +670,15 @@ export default defineComponent({
|
||||
if (ris) {
|
||||
// field_updated_fromGM.value = t('dbgm.updateLocalDb_OK')
|
||||
|
||||
await updateproduct(false)
|
||||
await updateproduct(false, false)
|
||||
tools.showPositiveNotif($q, t('dbgm.updateLocalDb_OK'))
|
||||
updatefromgm.value = false
|
||||
}
|
||||
loading.value = false
|
||||
}
|
||||
|
||||
}
|
||||
}*/
|
||||
|
||||
async function refreshSingleBookFromGM(options: any) {
|
||||
if (myproduct.value) {
|
||||
loading.value = true
|
||||
@@ -686,8 +688,13 @@ export default defineComponent({
|
||||
if (ris) {
|
||||
// field_updated_fromGM.value = t('dbgm.updateLocalDb_OK')
|
||||
|
||||
await updateproduct(false)
|
||||
if (ris.error) {
|
||||
tools.showNegativeNotif($q, ris.error)
|
||||
} else {
|
||||
|
||||
await updateproduct(false, false)
|
||||
tools.showPositiveNotif($q, t('dbgm.updateLocalDb_OK'))
|
||||
}
|
||||
updatefromgm.value = false
|
||||
}
|
||||
loading.value = false
|
||||
@@ -777,8 +784,8 @@ export default defineComponent({
|
||||
field_updated_fromGM,
|
||||
refreshFieldFromGM,
|
||||
updatetogm,
|
||||
refreshDataFromGM,
|
||||
refreshAllDataBookFromGM,
|
||||
// refreshDataFromGM,
|
||||
// refreshAllDataBookFromGM,
|
||||
refreshSingleBookFromGM,
|
||||
loading,
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
|
||||
<q-item
|
||||
<!--<q-item
|
||||
v-if="
|
||||
tools.isManager() && !optcatalogo.generazionePDFInCorso && (editOn || options.show_edit_book)
|
||||
"
|
||||
@@ -156,7 +156,7 @@
|
||||
<q-item-section>
|
||||
<q-item-label>Carica da GM</q-item-label>
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
</q-item>-->
|
||||
<q-item
|
||||
v-if="
|
||||
tools.isManager() && !optcatalogo.generazionePDFInCorso && (editOn || options.show_edit_book)
|
||||
|
||||
@@ -37,6 +37,10 @@ export default defineComponent({
|
||||
const draftValue = ref(props.modelValue)
|
||||
const editing = ref(false)
|
||||
|
||||
watch(toRef(props, 'modelValue'), (newVal) => {
|
||||
draftValue.value = newVal;
|
||||
})
|
||||
|
||||
function copytoclip() {
|
||||
tools.copyStringToClipboard($q, draftValue.value.toString(), true)
|
||||
}
|
||||
|
||||
@@ -264,7 +264,7 @@ export default defineComponent({
|
||||
|
||||
watch(() => props.rec, (newval, oldval) => {
|
||||
refresh()
|
||||
})
|
||||
}, { deep: true })
|
||||
|
||||
const myrow = ref(<any>null)
|
||||
const mypath = ref('')
|
||||
@@ -480,11 +480,13 @@ export default defineComponent({
|
||||
}
|
||||
|
||||
function mounted() {
|
||||
// console.log('mounted CMyPopupEdit')
|
||||
console.log('mounted CMyPopupEdit')
|
||||
|
||||
|
||||
myrow.value = props.rec && props.isrec ? { ...props.rec } : { ...props.row }
|
||||
|
||||
console.log('myrow', myrow.value?.arrvariazioni?.[0])
|
||||
|
||||
try {
|
||||
|
||||
// console.log('mounted', 'isFieldDb()', myrow.value, 'sub', props.subfield, 'field', props.field)
|
||||
|
||||
@@ -10,6 +10,7 @@ import { shared_consts } from '@src/common/shared_vuejs'
|
||||
import type { IColGridTable } from 'model';
|
||||
import { IOperators } from 'model'
|
||||
import { tools } from '@tools'
|
||||
import { useProducts } from 'app/src/store/Products';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'CMySelect',
|
||||
@@ -177,6 +178,8 @@ export default defineComponent({
|
||||
const selectMultiple = ref(null)
|
||||
const selectGeneric = ref(null)
|
||||
|
||||
const productStore = useProducts()
|
||||
|
||||
const mystr = ref('')
|
||||
|
||||
const valoriload = computed(() => {
|
||||
@@ -829,6 +832,20 @@ export default defineComponent({
|
||||
emit('searchOnGM', mystr)
|
||||
}
|
||||
|
||||
function applyLabelColorBasedOnProductStatus(myrec: any) {
|
||||
let classi = ''
|
||||
if (props.tablesel === 'products') {
|
||||
if (productStore.isNonVendibile(myrec)) {
|
||||
classi = 'bg-grey'
|
||||
}
|
||||
if (!productStore.isDisponibile(myrec)) {
|
||||
classi = 'bg-red-1'
|
||||
}
|
||||
}
|
||||
return classi
|
||||
}
|
||||
|
||||
|
||||
onMounted(mounted)
|
||||
|
||||
|
||||
@@ -850,6 +867,7 @@ export default defineComponent({
|
||||
clear,
|
||||
mystr,
|
||||
searchOnGM,
|
||||
applyLabelColorBasedOnProductStatus,
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -147,8 +147,9 @@
|
||||
</template>
|
||||
<template v-slot:option="scope">
|
||||
<q-item v-bind="scope.itemProps">
|
||||
<q-item-section>
|
||||
<q-item-label>
|
||||
<q-item-section :class="applyLabelColorBasedOnProductStatus(scope.opt)">
|
||||
<q-item-label >
|
||||
|
||||
{{ tools.getValueByFunzOrVal(scope.opt, optlab) }}
|
||||
</q-item-label>
|
||||
</q-item-section>
|
||||
|
||||
@@ -115,6 +115,7 @@ export default defineComponent({
|
||||
{ name: "catprods", label: "Argomento", field: "catprods", align: "left" },
|
||||
{ name: "idCollana", label: "Collana", field: "idCollana", align: "left" },
|
||||
{ name: "stato", label: "Stato", field: "stato", align: "left" },
|
||||
{ name: "tipologia", label: "Tipologia", field: "tipologia", 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" },
|
||||
@@ -245,9 +246,6 @@ export default defineComponent({
|
||||
}
|
||||
}
|
||||
|
||||
async function refreshDataFromGM() {
|
||||
|
||||
}
|
||||
async function refreshFieldFromGM(field: string) {
|
||||
if (selProd.value) {
|
||||
loading.value = true
|
||||
@@ -312,7 +310,6 @@ export default defineComponent({
|
||||
updateProduct,
|
||||
field_updated_fromGM,
|
||||
refreshFieldFromGM,
|
||||
refreshDataFromGM,
|
||||
updatefromgm,
|
||||
visufromgm,
|
||||
loading,
|
||||
|
||||
@@ -56,10 +56,11 @@
|
||||
<tr
|
||||
:key="element._id"
|
||||
:class="{
|
||||
'text-white bg-purple': products.isProssimaUscita(element.productInfo),
|
||||
'bg-yellow': products.isPubblicato(element.productInfo) && products.isQtaLimitata(element),
|
||||
'bg-orange': products.isPubblicato(element.productInfo) && products.isInEsaurendo(element),
|
||||
'text-white bg-red-10': products.isPubblicato(element.productInfo) && products.isEsaurito(element),
|
||||
'bg-grey': !products.isPubblicato(element.productInfo),
|
||||
'bg-grey': products.isNonVendibile(element.productInfo),
|
||||
}"
|
||||
>
|
||||
<!-- Icona Drag Handle -->
|
||||
@@ -115,6 +116,12 @@
|
||||
<td v-if="isColumnVisible('stato')">
|
||||
{{ products.getDescrStatiProdottoByIdStatoProdotto(element.productInfo.idStatoProdotto || '') }}
|
||||
</td>
|
||||
<td v-if="isColumnVisible('tipologia')">
|
||||
{{ products.getDescrByIdTipologia(element.arrvariazioni[0].idTipologia || '') }}
|
||||
</td>
|
||||
<td v-if="isColumnVisible('tipoformato')">
|
||||
{{ products.getDescrByIdTipoFormato(element.arrvariazioni[0].idTipoFormato || '') }}
|
||||
</td>
|
||||
|
||||
<td v-if="isColumnVisible('date_pub')">{{ tools.getstrDate(element.productInfo?.date_pub) }}</td>
|
||||
|
||||
|
||||
@@ -274,6 +274,18 @@ export default defineComponent({
|
||||
type: costanti.FieldType.onlydate,
|
||||
dense: true,
|
||||
},
|
||||
{
|
||||
editOn: false,
|
||||
label: "Stato",
|
||||
table: "productinfos",
|
||||
id: myproduct.value.productInfo._id,
|
||||
rec: myproduct.value.productInfo,
|
||||
mykey: "idStatoProdotto",
|
||||
debounce: "1000",
|
||||
type: costanti.FieldType.select,
|
||||
jointable: 't_web_statiprodottos',
|
||||
dense: true,
|
||||
},
|
||||
{
|
||||
editOn: true,
|
||||
label: "Argomento",
|
||||
@@ -309,6 +321,30 @@ export default defineComponent({
|
||||
type: costanti.FieldType.string,
|
||||
dense: true,
|
||||
},
|
||||
{
|
||||
editOn: false,
|
||||
label: "Tipologia",
|
||||
table: "arrvariazioni",
|
||||
id: myproduct.value._id,
|
||||
rec: myproduct.value,
|
||||
mykey: "idTipologia",
|
||||
debounce: "1000",
|
||||
type: costanti.FieldType.select,
|
||||
jointable: 't_web_tipologies',
|
||||
dense: true,
|
||||
},
|
||||
{
|
||||
editOn: false,
|
||||
label: "Formato",
|
||||
table: "arrvariazioni",
|
||||
id: myproduct.value._id,
|
||||
rec: myproduct.value,
|
||||
mykey: "idTipoFormato",
|
||||
debounce: "1000",
|
||||
type: costanti.FieldType.select,
|
||||
jointable: 't_web_tipiformatos',
|
||||
dense: true,
|
||||
},
|
||||
{
|
||||
editOn: true,
|
||||
label: "Formato",
|
||||
@@ -412,11 +448,11 @@ export default defineComponent({
|
||||
}
|
||||
|
||||
async function updateproduct(load?: boolean) {
|
||||
myproduct.value = await products.getProductById(myproduct.value._id, true)
|
||||
myproduct.value = await products.getProductById(myproduct.value._id, load)
|
||||
|
||||
}
|
||||
|
||||
async function refreshDataFromGM() {
|
||||
/*async function refreshDataFromGM() {
|
||||
if (myproduct.value) {
|
||||
loading.value = true
|
||||
const ris = await globalStore.updateLocalDbFromGM_T_Web_Articoli(myproduct.value.productInfo.sku!, myproduct.value.isbn)
|
||||
@@ -429,7 +465,29 @@ export default defineComponent({
|
||||
loading.value = false
|
||||
}
|
||||
|
||||
}*/
|
||||
|
||||
async function refreshSingleBookFromGM(options: any) {
|
||||
if (myproduct.value) {
|
||||
loading.value = true
|
||||
await globalStore.updateAllBookFromGM_T_Web_Articoli({ sku: myproduct.value.productInfo.sku!, isbn: myproduct.value.productInfo.code, ...options })
|
||||
.then((ris) => {
|
||||
if (ris) {
|
||||
if (ris.error) {
|
||||
tools.showNegativeNotif($q, ris.error)
|
||||
} else {
|
||||
|
||||
updateproduct(false)
|
||||
// console.log('product AGGIORNATO:', myproduct.value)
|
||||
tools.showPositiveNotif($q, t('dbgm.updateLocalDb_OK'))
|
||||
}
|
||||
loading.value = false
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
onMounted(mounted)
|
||||
@@ -451,7 +509,8 @@ export default defineComponent({
|
||||
field_updated_toGM,
|
||||
loading,
|
||||
updateRecordToGM,
|
||||
refreshDataFromGM,
|
||||
refreshSingleBookFromGM,
|
||||
// refreshDataFromGM,
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -77,8 +77,8 @@
|
||||
class="q-ma-sm"
|
||||
color="accent"
|
||||
icon="fas fa-save"
|
||||
label="Carica da GM"
|
||||
@click="refreshDataFromGM"
|
||||
label="Riaggiorna da GM"
|
||||
@click="refreshSingleBookFromGM({usaDBGMLocale: false})"
|
||||
></q-btn>
|
||||
<q-btn
|
||||
rounded
|
||||
@@ -86,6 +86,7 @@
|
||||
color="accent"
|
||||
icon="fas fa-save"
|
||||
label="Aggiorna su GM"
|
||||
:disabled="true"
|
||||
@click="updateRecordToGM"
|
||||
></q-btn>
|
||||
</div>
|
||||
|
||||
@@ -292,7 +292,12 @@ async function searchOnGM(mystr: string) {
|
||||
updateproductmodif(myproduct.value)
|
||||
|
||||
// await updateproduct(false)
|
||||
if (ris.error) {
|
||||
tools.showNegativeNotif($q, ris.error)
|
||||
} else {
|
||||
tools.showPositiveNotif($q, t('dbgm.updateLocalDb_OK'))
|
||||
}
|
||||
|
||||
// updatefromgm.value = false
|
||||
}
|
||||
|
||||
|
||||
@@ -84,6 +84,8 @@ export interface IVariazione {
|
||||
misure?: string
|
||||
pagine?: number
|
||||
tipologia?: string
|
||||
idTipologia?: number
|
||||
idTipoFormato?: number
|
||||
edizione?: string
|
||||
preOrderDate?: Date
|
||||
addtocart_link?: string
|
||||
@@ -180,6 +182,8 @@ export interface IProductsState {
|
||||
authors: IAuthor[]
|
||||
publishers: IPublisher[]
|
||||
stati_prodotto?: T_Web_StatiProdotto[]
|
||||
tipologie?: T_Web_Tipologie[]
|
||||
tipoformato?: T_WEB_TipiFormato[]
|
||||
cart: ICart
|
||||
orders: IOrderCart[]
|
||||
catprods: ICatProd[]
|
||||
@@ -191,6 +195,7 @@ export interface IProductsState {
|
||||
userActive: IUserShort
|
||||
|
||||
isPubblicatoById?: (idStatoProdotto: number) => boolean;
|
||||
isProssimaUscitaById?: (idStatoProdotto: number) => boolean;
|
||||
}
|
||||
|
||||
export interface IProducer {
|
||||
@@ -280,6 +285,20 @@ export interface T_Web_StatiProdotto {
|
||||
enabled?: boolean
|
||||
}
|
||||
|
||||
export interface T_Web_Tipologie {
|
||||
IdTipologia: number
|
||||
Descrizione: string
|
||||
dataora?: Date,
|
||||
enabled?: boolean
|
||||
}
|
||||
|
||||
export interface T_WEB_TipiFormato {
|
||||
IdTipoFormato: number
|
||||
Descrizione: string
|
||||
dataora?: Date,
|
||||
enabled?: boolean
|
||||
}
|
||||
|
||||
export interface IStorehouse {
|
||||
_id?: any
|
||||
idapp?: string
|
||||
|
||||
@@ -646,6 +646,24 @@ export const colTableCatProd = [
|
||||
AddCol(DeleteRec),
|
||||
AddCol(DuplicateRec),
|
||||
]
|
||||
export const colTableStatiProdotto = [
|
||||
AddCol({ name: 'IdTipologia', label_trans: 'statoprod.IdTipologia' }),
|
||||
AddCol({ name: 'Descrizione', label_trans: 'statoprod.Descrizione' }),
|
||||
AddCol(DeleteRec),
|
||||
AddCol(DuplicateRec),
|
||||
]
|
||||
export const colTableTipoFormato = [
|
||||
AddCol({ name: 'IdTipoFormato', label_trans: 'statoprod.IdTipologia' }),
|
||||
AddCol({ name: 'Descrizione', label_trans: 'statoprod.Descrizione' }),
|
||||
AddCol(DeleteRec),
|
||||
AddCol(DuplicateRec),
|
||||
]
|
||||
export const colTableTipologie = [
|
||||
AddCol({ name: 'IdStatoProdotto', label_trans: 'statoprod.IdStatoProdotto' }),
|
||||
AddCol({ name: 'Descrizione', label_trans: 'statoprod.Descrizione' }),
|
||||
AddCol(DeleteRec),
|
||||
AddCol(DuplicateRec),
|
||||
]
|
||||
export const colTableCollane = [
|
||||
AddCol({ name: 'idCollana', label_trans: 'collane.idCollana', fieldtype: costanti.FieldType.number }),
|
||||
AddCol({ name: 'title', label_trans: 'collane.title' }),
|
||||
@@ -4372,6 +4390,27 @@ export const fieldsTable = {
|
||||
colkey: '_id',
|
||||
collabel: 'name',
|
||||
},
|
||||
{
|
||||
value: 't_web_statiprodottos',
|
||||
label: 'Stati Prodotto',
|
||||
columns: colTableStatiProdotto,
|
||||
colkey: 'IdStatoProdotto',
|
||||
collabel: 'Descrizione',
|
||||
},
|
||||
{
|
||||
value: 't_web_tipiformatos',
|
||||
label: 'Tipo Formato',
|
||||
columns: colTableTipoFormato,
|
||||
colkey: 'IdTipoFormato',
|
||||
collabel: 'Descrizione',
|
||||
},
|
||||
{
|
||||
value: 't_web_tipologies',
|
||||
label: 'Tipologie',
|
||||
columns: colTableTipologie,
|
||||
colkey: 'IdStatoProdotto',
|
||||
collabel: 'Descrizione',
|
||||
},
|
||||
{
|
||||
value: 'collanas',
|
||||
label: 'Collane',
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { IBaseOrder, ICart, IOrder, IOrderCart, IProduct, IProductsState, IProductInfo, ICatProd, IUserShort, IGasordine, IAuthor, ISubCatProd, IText, IOptCatalogo, ICatalog, ICatPrTotali, ISingleProductOrdered, ISchedaSingola, IMyScheda, IElementiScheda, T_Web_StatiProdotto } from 'model'
|
||||
import type { IBaseOrder, ICart, IOrder, IOrderCart, IProduct, IProductsState, IProductInfo, ICatProd, IUserShort, IGasordine, IAuthor, ISubCatProd, IText, IOptCatalogo, ICatalog, ICatPrTotali, ISingleProductOrdered, ISchedaSingola, IMyScheda, IElementiScheda, T_Web_StatiProdotto, T_Web_Tipologie, T_WEB_TipiFormato } from 'model'
|
||||
|
||||
import { Api } from '@api'
|
||||
import { serv_constants } from '@src/store/Modules/serv_constants'
|
||||
@@ -130,6 +130,10 @@ export const useProducts = defineStore('Products', {
|
||||
},
|
||||
|
||||
isDisponibile: (state: IProductsState) => (product: IProduct): boolean => {
|
||||
return product?.arrvariazioni?.[0]?.quantita > 1
|
||||
},
|
||||
|
||||
isDisponibilitaOk: (state: IProductsState) => (product: IProduct): boolean => {
|
||||
return product?.arrvariazioni?.[0]?.quantita > 100
|
||||
},
|
||||
|
||||
@@ -146,11 +150,9 @@ export const useProducts = defineStore('Products', {
|
||||
|
||||
isPubblicatoById: (state: IProductsState) => (idStatoProdotto: number): boolean => {
|
||||
switch (idStatoProdotto) {
|
||||
case 1:
|
||||
case 4:
|
||||
case 34:
|
||||
case 45:
|
||||
case 46:
|
||||
case 1: // In Commercio
|
||||
case 45: // In Commercio
|
||||
case 46: // 2023 in commercio
|
||||
case undefined:
|
||||
return true;
|
||||
default:
|
||||
@@ -158,16 +160,41 @@ export const useProducts = defineStore('Products', {
|
||||
}
|
||||
},
|
||||
|
||||
isProssimaUscitaById: (state: IProductsState) => (idStatoProdotto: number): boolean => {
|
||||
// 4 - Prossima uscita
|
||||
// 34 - In Prevendita
|
||||
return (idStatoProdotto === 4) || (idStatoProdotto === 34)
|
||||
},
|
||||
|
||||
isPubblicato: (state: IProductsState) => (productInfo: IProductInfo): boolean => {
|
||||
return state.isPubblicatoById(productInfo.idStatoProdotto)
|
||||
},
|
||||
|
||||
isNonVendibile: (state: IProductsState) => (productInfo: IProductInfo): boolean => {
|
||||
return !state.isPubblicatoById(productInfo.idStatoProdotto) && !state.isProssimaUscitaById(productInfo.idStatoProdotto)
|
||||
},
|
||||
|
||||
isProssimaUscita: (state: IProductsState) => (productInfo: IProductInfo): boolean => {
|
||||
return state.isProssimaUscitaById(productInfo.idStatoProdotto)
|
||||
},
|
||||
|
||||
getDescrStatiProdottoByIdStatoProdotto: (state: IProductsState) => (idStatoProdotto: number): string => {
|
||||
const ctrec = state.stati_prodotto.find((mystatus: T_Web_StatiProdotto) => mystatus.IdStatoProdotto === idStatoProdotto)
|
||||
return (ctrec) ? ctrec.Descrizione : ''
|
||||
},
|
||||
|
||||
|
||||
getDescrByIdTipologia: (state: IProductsState) => (idTipologia: number): string => {
|
||||
const ctrec = state.tipologie.find((mystatus: T_Web_Tipologie) => mystatus.IdTipologia === idTipologia)
|
||||
return (ctrec) ? ctrec.Descrizione : ''
|
||||
},
|
||||
|
||||
getDescrByIdTipoFormato: (state: IProductsState) => (idTipoFormato: number): string => {
|
||||
const ctrec = state.tipoformato.find((mystatus: T_WEB_TipiFormato) => mystatus.IdTipoFormato === idTipoFormato)
|
||||
return (ctrec) ? ctrec.Descrizione : ''
|
||||
},
|
||||
|
||||
|
||||
getArrayidArgomentoByArridCatProds: (state: IProductsState) => (arridCatProds: string[]): string[] => {
|
||||
const myarr: string[] = []
|
||||
for (const idCatProd of arridCatProds) {
|
||||
@@ -1426,114 +1453,158 @@ export const useProducts = defineStore('Products', {
|
||||
return testo.contenuto;
|
||||
}
|
||||
|
||||
const autori = this.getAutoriByArrayAuthors(myproduct.productInfo.authors)
|
||||
const collana = tools.formatCollane(myproduct.productInfo.idCollana)
|
||||
const replacements: { [key: string]: any } = {};
|
||||
|
||||
if (testo.contenuto.includes('{autore}')) {
|
||||
replacements['{autore}'] = this.getAutoriByArrayAuthors(myproduct.productInfo.authors) || '';
|
||||
}
|
||||
|
||||
if (testo.contenuto.includes('{collana}')) {
|
||||
replacements['{collana}'] = tools.formatCollane(myproduct.productInfo.idCollana) || '';
|
||||
}
|
||||
|
||||
const maxDescriptionLength = testo.maxlength ?? 100;
|
||||
|
||||
if (testo.contenuto.includes('{descrizione_da_fdv}')) {
|
||||
const description = myproduct.productInfo.short_descr || '';
|
||||
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 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('Pub:', date_pub) +
|
||||
this.getkeyValStr('fat6M', fatLast6M) +
|
||||
// this.getkeyValStr('Rank3M', myproduct.productInfo.rank3M) +
|
||||
this.getkeyValStr('Ven:', linkvenduti) +
|
||||
this.getkeyValStr('v3M', vLast3M) +
|
||||
this.getkeyValStr('v6M', vLast6M) +
|
||||
this.getkeyValStr('Fatt:', linkfatturati) +
|
||||
this.getkeyValStr('fat3M', fatLast3M)
|
||||
|
||||
const truncatedDescription = description.length > maxDescriptionLength
|
||||
replacements['{descrizione_da_fdv}'] = description.length > maxDescriptionLength
|
||||
? description.substring(0, description.lastIndexOf(' ', maxDescriptionLength)) + '...'
|
||||
: description;
|
||||
}
|
||||
|
||||
const truncatedlongDescription = long_descr.length > maxDescriptionLength
|
||||
if (testo.contenuto.includes('{descrizione_estesa_fdv}')) {
|
||||
const long_descr = myproduct.productInfo.description || '';
|
||||
replacements['{descrizione_estesa_fdv}'] = long_descr.length > maxDescriptionLength
|
||||
? long_descr.substring(0, long_descr.lastIndexOf(' ', maxDescriptionLength)) + '...'
|
||||
: long_descr;
|
||||
}
|
||||
|
||||
let addtesto = false
|
||||
|
||||
if (testo.contenuto.includes('{descrizione_estesa}')) {
|
||||
let addtesto = false;
|
||||
const long_descr_macro = myproduct.productInfo.descrizione_completa_macro || '';
|
||||
if (long_descr_macro.length > maxDescriptionLength) {
|
||||
addtesto = true
|
||||
addtesto = true;
|
||||
}
|
||||
const addstrcontinua = '<span class="book-link">👉🏻 <a href="{link_macro}" target="_blank">continua a leggere</a></span>'
|
||||
|
||||
const addstrcontinua = '<span class="book-link">👉🏻 <a href="{link_macro}" target="_blank">continua a leggere</a></span>';
|
||||
let descrizione_completa_macro = addtesto
|
||||
? long_descr_macro.substring(0, long_descr_macro.lastIndexOf(' ', maxDescriptionLength)) + '...'
|
||||
: long_descr_macro;
|
||||
|
||||
if (addtesto) {
|
||||
descrizione_completa_macro += addstrcontinua
|
||||
descrizione_completa_macro += addstrcontinua;
|
||||
}
|
||||
replacements['{descrizione_estesa}'] = descrizione_completa_macro || '';
|
||||
}
|
||||
|
||||
const descr_trafiletto_catalogo = myproduct.productInfo.descr_trafiletto_catalogo || '';
|
||||
if (testo.contenuto.includes('{descrizione_breve_macro}')) {
|
||||
const short_descr = myproduct.productInfo.descrizione_breve_macro || '';
|
||||
const descrizione_breve_macro = short_descr.length > maxDescriptionLength
|
||||
replacements['{descrizione_breve_macro}'] = short_descr.length > maxDescriptionLength
|
||||
? short_descr.substring(0, short_descr.lastIndexOf(' ', maxDescriptionLength)) + '...'
|
||||
: short_descr;
|
||||
}
|
||||
|
||||
const sottotitolo = myproduct.productInfo.sottotitolo || '';
|
||||
const link_macro = myproduct.productInfo.link_macro || '';
|
||||
if (testo.contenuto.includes('{descr_trafiletto_catalogo}')) {
|
||||
const short_descr = myproduct.productInfo.descr_trafiletto_catalogo || '';
|
||||
replacements['{descr_trafiletto_catalogo}'] = short_descr.length > maxDescriptionLength
|
||||
? short_descr.substring(0, short_descr.lastIndexOf(' ', maxDescriptionLength)) + '...'
|
||||
: short_descr;
|
||||
}
|
||||
|
||||
const prezzo = tools.arrotonda2Dec(myproduct.arrvariazioni![0].price) || ''
|
||||
const prezzo_scontato = tools.arrotonda2Dec(myproduct.arrvariazioni![0].sale_price) || ''
|
||||
const categoria = this.getCatProdsStrByCatProds(myproduct.productInfo.catprods!)
|
||||
const sottocategoria = myproduct.productInfo.subcatprods && myproduct.productInfo.subcatprods.length > 0 ? myproduct.productInfo.subcatprods[0].name! : ''
|
||||
const descr_categoria = myproduct.productInfo.catprods && myproduct.productInfo.catprods.length > 0 ? this.getCatProdDescrStrByIdCatProd(myproduct.productInfo.catprods![0].name) : ''
|
||||
const misure = myproduct.arrvariazioni![0].misure || ''
|
||||
const formato = myproduct.arrvariazioni![0].formato || ''
|
||||
const pagine = myproduct.arrvariazioni![0].pagine || ''
|
||||
const qta = myproduct.arrvariazioni![0].quantita || ''
|
||||
const isbn = myproduct.productInfo.code || ''
|
||||
const image_link = myproduct.productInfo.image_link || ''
|
||||
const imagefile = myproduct.productInfo.imagefile || ''
|
||||
const stato = this.getDescrStatiProdottoByIdStatoProdotto(myproduct.productInfo.idStatoProdotto || '')
|
||||
if (testo.contenuto.includes('{prezzo}') || testo.contenuto.includes('{prezzo_scontato}')) {
|
||||
const prezzo = tools.arrotonda2Dec(myproduct.arrvariazioni![0].price) || '';
|
||||
const prezzo_scontato = tools.arrotonda2Dec(myproduct.arrvariazioni![0].sale_price) || '';
|
||||
replacements['{prezzo}'] = prezzo;
|
||||
replacements['{prezzo_scontato}'] = prezzo_scontato;
|
||||
}
|
||||
|
||||
const scale = optcatalogo.printable ? optcatalogo.areadistampa?.scale : 1
|
||||
// Crea una mappa di sostituzioni
|
||||
const replacements = {
|
||||
'{autore}': autori || '',
|
||||
'{titolo}': myproduct.productInfo.name || '',
|
||||
'{sottotitolo}': (sottotitolo) || '',
|
||||
'{descrizione_da_fdv}': truncatedDescription || '',
|
||||
'{descrizione_estesa_fdv}': truncatedlongDescription || '',
|
||||
'{descrizione_estesa}': descrizione_completa_macro || '',
|
||||
'{debug}': (debugstr) || '',
|
||||
'{categoria}': (categoria) || '',
|
||||
'{sottocategoria}': (sottocategoria) || '',
|
||||
'{descr_categoria}': (descr_categoria) || '',
|
||||
'{pagine}': (pagine) || '',
|
||||
'{isbn}': (isbn) || '',
|
||||
'{misure}': misure || '',
|
||||
'{argomento}': categoria || '',
|
||||
'{date_pub}': date_pub || '',
|
||||
'{ranking_globale}': ranking_globale || '',
|
||||
'{venduti}': venduti || '',
|
||||
'{formato}': formato || '',
|
||||
'{stato}': stato || '',
|
||||
'{collana}': collana ? collana || '' : '',
|
||||
'{prezzo}': prezzo || '',
|
||||
'{scale}': scale || '',
|
||||
'{prezzo_scontato}': prezzo_scontato || '',
|
||||
'{descrizione_completa_macro}': descrizione_completa_macro || '',
|
||||
'{descrizione_breve_macro}': descrizione_breve_macro || '',
|
||||
'{descr_trafiletto_catalogo}': descr_trafiletto_catalogo || '',
|
||||
'{link_macro}': link_macro || '',
|
||||
'{qta}': qta || '',
|
||||
'{image_link}': image_link || '',
|
||||
'{imagefile}': imagefile || '',
|
||||
};
|
||||
// Additional replacements based on the content
|
||||
const keysToCheck = [
|
||||
'{titolo}', '{sottotitolo}', '{categoria}', '{sottocategoria}', '{descr_categoria}',
|
||||
'{pagine}', '{isbn}', '{misure}', '{argomento}', '{date_pub}', '{ranking_globale}',
|
||||
'{venduti}', '{formato}', '{tipologia}', '{stato}', '{scale}', '{descr_trafiletto_catalogo}',
|
||||
'{link_macro}', '{qta}', '{image_link}', '{imagefile}', '{debug}'
|
||||
];
|
||||
|
||||
for (const key of keysToCheck) {
|
||||
if (testo.contenuto.includes(key)) {
|
||||
switch (key) {
|
||||
case '{titolo}':
|
||||
replacements[key] = myproduct.productInfo.name || '';
|
||||
break;
|
||||
case '{sottotitolo}':
|
||||
replacements[key] = myproduct.productInfo.sottotitolo || '';
|
||||
break;
|
||||
case '{sottocategoria}':
|
||||
replacements[key] = myproduct.productInfo.subcatprods && myproduct.productInfo.subcatprods.length > 0 ? myproduct.productInfo.subcatprods[0].name! : '';
|
||||
break;
|
||||
case '{descr_categoria}':
|
||||
replacements[key] = myproduct.productInfo.catprods && myproduct.productInfo.catprods.length > 0 ? this.getCatProdDescrStrByIdCatProd(myproduct.productInfo.catprods![0].name) : '';
|
||||
break;
|
||||
case '{pagine}':
|
||||
replacements[key] = myproduct.arrvariazioni![0].pagine || '';
|
||||
break;
|
||||
case '{isbn}':
|
||||
replacements[key] = myproduct.productInfo.code || '';
|
||||
break;
|
||||
case '{misure}':
|
||||
replacements[key] = myproduct.arrvariazioni![0].misure || '';
|
||||
break;
|
||||
case '{argomento}':
|
||||
replacements[key] = this.getCatProdsStrByCatProds(myproduct.productInfo.catprods!) || '';
|
||||
break;
|
||||
case '{date_pub}':
|
||||
replacements[key] = tools.getstrDateShort(myproduct.productInfo.date_pub) || '';
|
||||
break;
|
||||
case '{ranking_globale}':
|
||||
replacements[key] = myproduct.productInfo.rank3M! || '0';
|
||||
break;
|
||||
case '{venduti}':
|
||||
replacements[key] = myproduct.productInfo.totVen! || '0';
|
||||
break;
|
||||
case '{formato}':
|
||||
replacements[key] = this.getDescrByIdTipoFormato(myproduct.arrvariazioni[0].idTipoFormato || 0)
|
||||
break;
|
||||
case '{tipologia}':
|
||||
replacements[key] = this.getDescrByIdTipologia(myproduct.arrvariazioni[0].idTipologia || 0);
|
||||
break;
|
||||
case '{stato}':
|
||||
replacements[key] = this.getDescrStatiProdottoByIdStatoProdotto(myproduct.productInfo.idStatoProdotto || '');
|
||||
break;
|
||||
case '{scale}':
|
||||
replacements[key] = optcatalogo.printable ? optcatalogo.areadistampa?.scale : '1';
|
||||
break;
|
||||
case '{link_macro}':
|
||||
replacements[key] = myproduct.productInfo.link_macro || '';
|
||||
break;
|
||||
case '{qta}':
|
||||
replacements[key] = myproduct.arrvariazioni![0].quantita || '';
|
||||
break;
|
||||
case '{image_link}':
|
||||
replacements[key] = myproduct.productInfo.image_link || '';
|
||||
break;
|
||||
case '{imagefile}':
|
||||
replacements[key] = myproduct.productInfo.imagefile || '';
|
||||
break;
|
||||
case '{debug}':
|
||||
const date_pub = replacements['{date_pub}'] || '';
|
||||
const fatLast6M = myproduct.productInfo.fatLast6M! || 0;
|
||||
const linkvenduti = `<a href="http://vps-88271abb.vps.ovh.net/apimacro/public/view-ordini-by-idarticolo/${myproduct.productInfo.sku}" target="_blank">${replacements['{venduti}']}</a>`;
|
||||
const vLast3M = myproduct.productInfo.vLast3M! || 0;
|
||||
const vLast6M = myproduct.productInfo.vLast6M! || 0;
|
||||
const linkfatturati = `<a href="http://vps-88271abb.vps.ovh.net/apimacro/public/view-fatturati-by-idarticolo/${myproduct.productInfo.sku}" target="_blank">${myproduct.productInfo.totFat! || 0}</a>`;
|
||||
const fatLast3M = myproduct.productInfo.fatLast3M! || 0;
|
||||
|
||||
replacements[key] = this.getkeyValStr('Pub:', date_pub) +
|
||||
this.getkeyValStr('fat6M', fatLast6M) +
|
||||
this.getkeyValStr('Ven:', linkvenduti) +
|
||||
this.getkeyValStr('v3M', vLast3M) +
|
||||
this.getkeyValStr('v6M', vLast6M) +
|
||||
this.getkeyValStr('Fatt:', linkfatturati) +
|
||||
this.getkeyValStr('fat3M', fatLast3M);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Esegue le sostituzioni
|
||||
let result = testo.contenuto;
|
||||
@@ -1541,7 +1612,7 @@ export const useProducts = defineStore('Products', {
|
||||
result = result.replace(new RegExp(key, 'g'), value);
|
||||
}
|
||||
|
||||
return result.trim()
|
||||
return result.trim();
|
||||
},
|
||||
|
||||
getSubCatStrByProduct(myproductInfo: IProductInfo): string {
|
||||
|
||||
@@ -13,7 +13,10 @@ import type {
|
||||
StateConnection,
|
||||
ISchedaSingola,
|
||||
IOptQueryGM,
|
||||
IOptCatalogo
|
||||
IOptCatalogo,
|
||||
IProduct,
|
||||
IProductInfo,
|
||||
IVariazione
|
||||
} from '@model';
|
||||
import {
|
||||
ICity, IMySkill,
|
||||
@@ -442,6 +445,8 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
else if (table === 'authors') ris = Products.authors
|
||||
else if (table === 'publishers') ris = Products.publishers
|
||||
else if (table === 't_web_statiprodottos') ris = Products.stati_prodotto
|
||||
else if (table === 't_web_tipologies') ris = Products.tipologie
|
||||
else if (table === 't_web_tipiformatos') ris = Products.tipoformato
|
||||
else if (table === 'catais') ris = state.catAI
|
||||
else if (table === 'queryais') ris = state.queryAIList
|
||||
else if (table === 'sharewithus') ris = state.sharewithus
|
||||
@@ -1829,6 +1834,8 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
Products.collane = (res.data.collane) ? [...res.data.collane] : []
|
||||
Products.subcatprods = (res.data.subcatprods) ? [...res.data.subcatprods] : []
|
||||
Products.stati_prodotto = (res.data.stati_prodotto) ? [...res.data.stati_prodotto] : []
|
||||
Products.tipologie = (res.data.tipologie) ? [...res.data.tipologie] : []
|
||||
Products.tipoformato = (res.data.tipoformato) ? [...res.data.tipoformato] : []
|
||||
Products.catprods_gas = (res.data.catprods_gas) ? [...res.data.catprods_gas] : []
|
||||
Products.authors = (res.data.authors) ? [...res.data.authors] : []
|
||||
Products.publishers = (res.data.publishers) ? [...res.data.publishers] : []
|
||||
@@ -2676,15 +2683,41 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
}
|
||||
},
|
||||
|
||||
async updateTablesInMemory(data: any) {
|
||||
|
||||
const table = data.table
|
||||
const id = data.idRecUpdated
|
||||
|
||||
if (!id)
|
||||
return
|
||||
|
||||
const productStore = useProducts()
|
||||
|
||||
try {
|
||||
if (table === 'products') {
|
||||
await productStore.loadProductById(id)
|
||||
} else if (table === 'productinfos') {
|
||||
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Errore durante l'aggiornamento della tabella in memoria:", error);
|
||||
}
|
||||
},
|
||||
|
||||
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 await Api.SendReq('/apisqlsrv/updateAllBook', 'POST', { options })
|
||||
.then(async (res) => {
|
||||
if (res?.data?.data?.logerror) {
|
||||
return { error: 'Errore ' + res?.data?.data?.logerror }
|
||||
}
|
||||
await this.updateTablesInMemory(res.data.data)
|
||||
return res.data.data
|
||||
}).catch((error: any) => {
|
||||
console.error('Error fetchTableContent: ', error)
|
||||
return { error: 'Errore ' + error }
|
||||
})
|
||||
} catch (error) {
|
||||
console.error("Errore nel recupero della tabella:", error);
|
||||
|
||||
@@ -21,6 +21,11 @@
|
||||
color="positive"
|
||||
@click="EseguiFunz('UpdateStatFatturato')"
|
||||
></q-btn>
|
||||
<q-btn
|
||||
label="Aggiorna Categorie (Elimina quelli vuoti)"
|
||||
color="positive"
|
||||
@click="EseguiFunz('UpdateCatDeleteEmpty')"
|
||||
></q-btn>
|
||||
<br><br>
|
||||
<q-btn
|
||||
label="Riaggiorna TUTTI gli ARTICOLI da GM SERVER"
|
||||
|
||||
@@ -33,8 +33,6 @@ import {
|
||||
|
||||
import { fieldsTable } from '@store/Modules/fieldsTable'
|
||||
import { useCatalogStore } from '@src/store/CatalogStore'
|
||||
import { Catalogo } from '.';
|
||||
import Products from 'app/src/rootgen/admin/products/products.vue';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'Catalogo',
|
||||
@@ -109,7 +107,7 @@ export default defineComponent({
|
||||
const catalogStore = useCatalogStore()
|
||||
|
||||
const tabvisu = ref('categorie')
|
||||
const tabcatalogo = ref()
|
||||
const tabcatalogo = ref('lista')
|
||||
|
||||
const searchList = ref([] as ISearchList[])
|
||||
|
||||
@@ -995,7 +993,8 @@ export default defineComponent({
|
||||
const arrcat = productStore.getCatProds(cosa.value)
|
||||
const riscat: any = [{ label: 'Tutti', value: '', icon: undefined, color: undefined }]
|
||||
for (const rec of arrcat) {
|
||||
riscat.push({ label: rec.name, value: rec._id, icon: rec.icon, color: rec.color })
|
||||
const label = rec.name + ' (' + productStore.getTotaliProdottiByIdCatProd(rec._id) + ')'
|
||||
riscat.push({ label, value: rec._id, icon: rec.icon, color: rec.color })
|
||||
}
|
||||
|
||||
return riscat
|
||||
|
||||
@@ -12,12 +12,6 @@
|
||||
dense
|
||||
class="bg-green text-white"
|
||||
>
|
||||
<q-tab
|
||||
name="visu"
|
||||
icon="fas fa-eye"
|
||||
label="Visualizza"
|
||||
>
|
||||
</q-tab>
|
||||
<q-tab
|
||||
v-if="lista_prodotti"
|
||||
name="lista"
|
||||
@@ -25,6 +19,12 @@
|
||||
label="Lista"
|
||||
>
|
||||
</q-tab>
|
||||
<q-tab
|
||||
name="visu"
|
||||
icon="fas fa-eye"
|
||||
label="Catalogo"
|
||||
>
|
||||
</q-tab>
|
||||
<q-tab
|
||||
v-if="tools.isGrafico()"
|
||||
name="sfondo"
|
||||
@@ -46,6 +46,7 @@
|
||||
>
|
||||
</q-tab>
|
||||
<q-tab
|
||||
v-if="tools.isAdmin()"
|
||||
name="opzioni"
|
||||
icon="fas fa-save"
|
||||
label="Avanzati"
|
||||
|
||||
Reference in New Issue
Block a user