- Aggiunto bottone Aggiungi al Carrello sulla lista dei libri dei cataloghi

This commit is contained in:
Surya Paolo
2025-06-06 00:07:47 +02:00
parent 06fe6eb861
commit 664975b1fd
36 changed files with 1110 additions and 751 deletions

View File

@@ -112,7 +112,7 @@ export default defineComponent({
const { t } = useI18n();
const userStore = useUserStore();
const globalStore = useGlobalStore();
const products = useProducts();
const Products = useProducts();
const listord = ref(<IOrderCart[]>[]);
const sumval = ref(0);
@@ -137,19 +137,19 @@ export default defineComponent({
const field_updated_fromGM = ref('');
const dataextractedWeb = ref('');
const widthoggetto = ref(40)
const heightoggetto = ref(40)
const widthoggetto = ref(40);
const heightoggetto = ref(40);
// Crea una copia locale reattiva di modelValue
const optcatalogo = ref<IOptCatalogo>({ ...props.modelValue });
const mywidthogg = computed(() => {
return widthoggetto.value * tools.getScaleX(optcatalogo.value, props.scheda)
})
return widthoggetto.value * tools.getScaleX(optcatalogo.value, props.scheda);
});
const myheightogg = computed(() => {
return heightoggetto.value * tools.getScaleY(optcatalogo.value, props.scheda)
})
return heightoggetto.value * tools.getScaleY(optcatalogo.value, props.scheda);
});
const editOn = computed({
get(): boolean {
@@ -213,7 +213,7 @@ export default defineComponent({
const scale = ref(1);
const getTesto_Right = computed(() => {
return products.replaceKeyWordsByProduct(
return Products.replaceKeyWordsByProduct(
optcatalogo.value,
myproduct.value!,
props.scheda.testo_right!,
@@ -221,7 +221,7 @@ export default defineComponent({
);
});
const getTesto_Right_attaccato = computed(() => {
return products.replaceKeyWordsByProduct(
return Products.replaceKeyWordsByProduct(
optcatalogo.value,
myproduct.value!,
props.scheda.testo_right_attaccato!,
@@ -229,7 +229,7 @@ export default defineComponent({
);
});
const getTesto_Debug = computed(() => {
return products.replaceKeyWordsByProduct(
return Products.replaceKeyWordsByProduct(
optcatalogo.value,
myproduct.value!,
{ contenuto: '{debug}', maxlength: 10000 },
@@ -238,7 +238,7 @@ export default defineComponent({
});
const getTesto_Bottom = computed(() => {
return products.replaceKeyWordsByProduct(
return Products.replaceKeyWordsByProduct(
optcatalogo.value,
myproduct.value!,
props.scheda.testo_bottom!,
@@ -255,7 +255,7 @@ export default defineComponent({
/*const myproduct = computed((): IProduct => {
console.log('getproduct computed')
const ris = products.getProduct(props.code)
const ris = Products.getProduct(props.code)
console.log(' received', ris)
return ris
})*/
@@ -271,7 +271,7 @@ export default defineComponent({
}
if (myproduct.value) {
const ris = await products.addtoCartBase({
const ris = await Products.addtoCartBase({
$q,
t,
id: myproduct.value._id,
@@ -286,8 +286,7 @@ export default defineComponent({
function getnumstore() {
if (myproduct.value) {
if (myproduct.value.storehouses)
return myproduct.value.storehouses.length;
if (myproduct.value.storehouses) return myproduct.value.storehouses.length;
else return 0;
}
return 0;
@@ -320,13 +319,6 @@ export default defineComponent({
}
}
function initproduct() {
myorder.quantity = 0;
myorder.quantitypreordered = 0;
myorder.idStorehouse = '';
myorder.idGasordine = '';
}
async function updateproduct(atload: boolean, forza?: boolean) {
let carica = true;
@@ -343,13 +335,13 @@ export default defineComponent({
updateproductmodif(null, forza);
}
// products.updateQuantityAvailable(myproduct.value._id)
// Products.updateQuantityAvailable(myproduct.value._id)
}
async function ricarica() {
endload.value = false;
if (myproduct.value) {
const prod = await products.loadProductById(myproduct.value._id);
const prod = await Products.loadProductById(myproduct.value._id);
if (prod) {
myproduct.value = prod;
}
@@ -361,9 +353,9 @@ export default defineComponent({
console.log('CCATALOGOCARD: updateproductmodif');
try {
if (element?._id) {
myproduct.value = await products.getProductById(element?._id, forza);
myproduct.value = await Products.getProductById(element?._id, forza);
} else {
myproduct.value = await products.getProductById(props.id, forza);
myproduct.value = await Products.getProductById(props.id, forza);
}
updateLabel();
@@ -441,9 +433,7 @@ export default defineComponent({
myproduct.value.gasordine.data_arrivo_merce
);
if (myproduct.value.gasordine.dataora_ritiro)
dataRitiro = tools.getstrDateTime(
myproduct.value.gasordine.dataora_ritiro
);
dataRitiro = tools.getstrDateTime(myproduct.value.gasordine.dataora_ritiro);
} else {
dataArrivoMerce = '';
dataRitiro = '';
@@ -451,8 +441,7 @@ export default defineComponent({
} catch (e) {}
if (labelDataArrivoMerce.value !== dataArrivoMerce)
labelDataArrivoMerce.value = dataArrivoMerce;
if (labelDataRitiro.value !== dataRitiro)
labelDataRitiro.value = dataRitiro;
if (labelDataRitiro.value !== dataRitiro) labelDataRitiro.value = dataRitiro;
updateTimerLabel();
}
@@ -487,9 +476,7 @@ export default defineComponent({
return (
myproduct.value.gasordine &&
myproduct.value.gasordine.dataora_chiusura_ordini &&
tools.getCountDown(
myproduct.value.gasordine.dataora_chiusura_ordini
) === ''
tools.getCountDown(myproduct.value.gasordine.dataora_chiusura_ordini) === ''
);
} else return false;
}
@@ -501,7 +488,7 @@ export default defineComponent({
async function load() {
indvariazSel.value = -1;
initproduct();
Products.initproduct(myorder);
await updateproduct(true, true);
labelDataArrivoMerce.value = '';
labelDataRitiro.value = '';
@@ -509,30 +496,9 @@ export default defineComponent({
// console.log('Load', myproduct.value.name)
if (myproduct.value) {
arrordersCart.value = products.getOrdersCartInAttesaByIdProduct(
myproduct.value._id
);
if (
myproduct.value.storehouses &&
myproduct.value.storehouses.length === 1
) {
// Se solo 1 presente, metto fisso l'unico negozio !
myorder.idStorehouse = myproduct.value.storehouses[0]._id;
}
if (myproduct.value.gasordine) {
myorder.idGasordine = myproduct.value.gasordine._id;
}
const ord = products.getOrderProductInCart(myproduct.value._id);
if (ord) {
myorder.quantity = ord.quantity;
myorder.quantitypreordered = ord.quantitypreordered;
// Seleziona il Negozio che avevo già scelto nell'ordine !
if (ord.idStorehouse) storeSelected.value = ord.idStorehouse;
}
Products.setMyOrder(myorder, myproduct.value, storeSelected.value, {
setstore: true,
});
}
updateLabel();
@@ -554,9 +520,7 @@ export default defineComponent({
function visuListDisponibili() {
if (myproduct.value) {
openlistorders.value = true;
sumval.value = products.getSumQtyOrderProductInOrdersCart(
myproduct.value._id
);
sumval.value = Products.getSumQtyOrderProductInOrdersCart(myproduct.value._id);
listord.value = arrordersCart.value.filter((orderscart: IOrderCart) =>
orderscart.items!.reduce((accumulator, item) => {
@@ -569,9 +533,7 @@ export default defineComponent({
function visuListBookable() {
if (myproduct.value) {
openlistorders.value = true;
sumval.value = products.getSumQtyPreOrderInOrdersCart(
myproduct.value._id
);
sumval.value = Products.getSumQtyPreOrderInOrdersCart(myproduct.value._id);
listord.value = arrordersCart.value.filter((orderscart: IOrderCart) =>
orderscart.items!.reduce((accumulator, item) => {
@@ -601,8 +563,7 @@ export default defineComponent({
(myproduct.value.bookableGASBloccatiQty +
myproduct.value.QuantitaPrenotateInAttesa!) *
myproduct.value.productInfo.weight!,
myproduct.value.qtyToReachForGas *
myproduct.value.productInfo.weight!
myproduct.value.qtyToReachForGas * myproduct.value.productInfo.weight!
) / 100
);
else return 0;
@@ -770,12 +731,11 @@ export default defineComponent({
loading.value = true;
updatefromgm.value = true;
field_updated_fromGM.value = '';
field_updated_fromGM.value =
await globalStore.getGM_FieldOf_T_Web_Articoli(
myproduct.value.productInfo.sku!,
field,
shared_consts.CmdQueryMs.GET
);
field_updated_fromGM.value = await globalStore.getGM_FieldOf_T_Web_Articoli(
myproduct.value.productInfo.sku!,
field,
shared_consts.CmdQueryMs.GET
);
loading.value = false;
}
}
@@ -798,7 +758,7 @@ export default defineComponent({
}
if (!dataupdated) {
tools.showNegativeNotif($q, t('dbgm.dati_non_estratti'));
visudataextracted.value = false
visudataextracted.value = false;
}
return dataupdated;
})
@@ -858,7 +818,7 @@ export default defineComponent({
openlistorders,
func_tools,
toolsext,
products,
Products,
arrordersCart,
endload,
shared_consts,
@@ -918,7 +878,7 @@ export default defineComponent({
widthoggetto,
heightoggetto,
mywidthogg,
myheightogg
myheightogg,
};
},
});

View File

@@ -82,16 +82,17 @@ export default defineComponent({
// console.log('options', props.options)
if (props.options.length > 0) {
props.options.forEach((rec: any, index) => {
// console.log('rec', rec)
if (props.type === costanti.FieldType.multiselect) {
if (!!myval.value) {
/*
console.log('rec', rec)
console.log('optval', props.optval)
console.log('optlab', props.optlab)
console.log('myval.value', myval.value)
console.log('rec[props.optval]', rec[props.optval])
*/
*/
let trovato = false

View File

@@ -28,7 +28,7 @@ export default defineComponent({
// console.log('$route.path', $route.path)
rec.value = globalStore.getPage(props.path)
console.log('rec', rec)
// console.log('rec', rec)
}
onMounted(mounted)

View File

@@ -74,7 +74,7 @@ export default defineComponent({
const argomentistr = ref('')
const numprodtot = ref(0)
const editorestr = ref('')
const editore_escludi_str = ref('')
const editorestr_escludi = ref('')
const products = useProducts()
@@ -142,11 +142,11 @@ export default defineComponent({
editorestr.value += rectrovato?.name + ' '
}
}
editore_escludi_str.value = ''
editorestr_escludi.value = ''
if (myrec.value.editore_escludi) {
for (const receditore of myrec.value.editore_escludi) {
const rectrovato: IPublisher = products.publishers.find((editore: IPublisher) => editore._id === receditore)
editores_escludi_tr.value += rectrovato?.name + ' '
editorestr_escludi.value += rectrovato?.name + ' '
}
}

View File

@@ -93,7 +93,7 @@
<span class="text-blue">{{ editorestr }}</span>
</div>
<div
v-if="!tools.isUtente() && editore_escludi_str && dettagli"
v-if="!tools.isUtente() && editorestr_escludi && dettagli"
class="text-caption text-h7 text-grey q-pb-xs"
>
<q-icon name="fas fa-book-open" /> {{ $t('cataloglist.editore_escludi') }}:

View File

@@ -1,30 +1,38 @@
import type { PropType} from 'vue';
import { defineComponent, ref, toRef, computed, watch, onMounted, reactive, onBeforeUnmount } from 'vue'
import { useI18n } from 'vue-i18n'
import { useUserStore } from '@store/UserStore'
import { useGlobalStore } from '@store/globalStore'
import { useQuasar } from 'quasar'
import type { PropType } from 'vue';
import {
defineComponent,
ref,
toRef,
computed,
watch,
onMounted,
reactive,
onBeforeUnmount,
} from 'vue';
import { useI18n } from 'vue-i18n';
import { useUserStore } from '@store/UserStore';
import { useGlobalStore } from '@store/globalStore';
import { useQuasar } from 'quasar';
import { CTitleBanner } from '../CTitleBanner'
import { CCardState } from '../CCardState'
import { CCopyBtn } from '../CCopyBtn'
import { CMyFieldRec } from '../CMyFieldRec'
import { CBarCode } from '../CBarCode'
import { CText } from '../CText'
import { CMyValueDb } from '../CMyValueDb'
import { CTitleBanner } from '../CTitleBanner';
import { CCardState } from '../CCardState';
import { CCopyBtn } from '../CCopyBtn';
import { CMyFieldRec } from '../CMyFieldRec';
import { CBarCode } from '../CBarCode';
import { CText } from '../CText';
import { CMyValueDb } from '../CMyValueDb';
import { func_tools, toolsext } from '@store/Modules/toolsext'
import { func_tools, toolsext } from '@store/Modules/toolsext';
import type { IGasordine, IOrder, IOrderCart, IProduct } from '@src/model';
import { IBaseOrder } from '@src/model'
import { tools } from '@tools'
import { useProducts } from '@store/Products'
import { IBaseOrder } from '@src/model';
import { tools } from '@tools';
import { useProducts } from '@store/Products';
import { shared_consts } from '@src/common/shared_vuejs'
import { useRouter } from 'vue-router'
import { costanti } from '@costanti'
import { shared_consts } from '@src/common/shared_vuejs';
import { useRouter } from 'vue-router';
import { costanti } from '@costanti';
export default defineComponent({
name: 'CProductCard',
@@ -51,27 +59,32 @@ export default defineComponent({
},
},
components: {
CTitleBanner, CCardState, CCopyBtn,
CMyFieldRec, CMyValueDb, CBarCode, CText,
CTitleBanner,
CCardState,
CCopyBtn,
CMyFieldRec,
CMyValueDb,
CBarCode,
CText,
},
setup(props, { emit }) {
const $q = useQuasar()
const { t } = useI18n()
const userStore = useUserStore()
const globalStore = useGlobalStore()
const products = useProducts()
const $q = useQuasar();
const { t } = useI18n();
const userStore = useUserStore();
const globalStore = useGlobalStore();
const Products = useProducts();
const listord = ref(<IOrderCart[]>[])
const sumval = ref(0)
const editOn = ref(false)
const listord = ref(<IOrderCart[]>[]);
const sumval = ref(0);
const editOn = ref(false);
const site = ref(globalStore.site)
const site = ref(globalStore.site);
const $router = useRouter()
const $router = useRouter();
const fullscreenImage = ref(<any>null)
const fullscreenImage = ref(<any>null);
const apriSchedaPDF = ref(false)
const apriSchedaPDF = ref(false);
let myorder = reactive(<IOrder>{
idapp: tools.getEnv('VITE_APP_ID'),
@@ -81,219 +94,209 @@ export default defineComponent({
idGasordine: '',
storehouse: {},
gasordine: { active: false },
})
});
const storeSelected = ref('')
const arrordersCart = ref(<IOrderCart[]>[])
const storeSelected = ref('');
const arrordersCart = ref(<IOrderCart[]>[]);
const timerInterval = ref(<any>null)
const timerLabelScadenza = ref('')
const labelDataRitiro = ref('')
const labelDataArrivoMerce = ref('')
const timerInterval = ref(<any>null);
const timerLabelScadenza = ref('');
const labelDataRitiro = ref('');
const labelDataArrivoMerce = ref('');
const openlistorders = ref(false)
const endload = ref(false)
const myproduct = ref(<IProduct>{})
const openlistorders = ref(false);
const endload = ref(false);
const myproduct = ref(<IProduct>{});
const isFullScreen = ref(false)
const imageSrc = ref('URL_DEL_TUO_FILE_IMMAGINE')
const startX = ref(0)
const startY = ref(0)
const scale = ref(1)
watch(() => editOn.value, (to: any, from: any) => {
if (!editOn.value)
ricarica()
})
const isFullScreen = ref(false);
const imageSrc = ref('URL_DEL_TUO_FILE_IMMAGINE');
const startX = ref(0);
const startY = ref(0);
const scale = ref(1);
watch(
() => editOn.value,
(to: any, from: any) => {
if (!editOn.value) ricarica();
}
);
/*const myproduct = computed((): IProduct => {
console.log('getproduct computed')
const ris = products.getProduct(props.code)
const ris = Products.getProduct(props.code)
console.log(' received', ris)
return ris
})*/
function iconWhishlist(order: IProduct) {
if (true) {
return 'far fa-heart'
return 'far fa-heart';
} else {
return 'fas fa-heart'
return 'fas fa-heart';
}
}
async function addtoCart(add: boolean) {
if (!userStore.isLogged) {
tools.showNeutralNotif($q, t('ecomm.area_personale'))
globalStore.rightDrawerOpen = true
return false
tools.showNeutralNotif($q, t('ecomm.area_personale'));
globalStore.rightDrawerOpen = true;
return false;
}
const ris = await products.addtoCartBase({ $q, t, id: myproduct.value._id, order: myorder, addqty: add })
updateproduct()
const ris = await Products.addtoCartBase({
$q,
t,
id: myproduct.value._id,
order: myorder,
addqty: add,
});
updateproduct();
if (ris && ris.myord) {
}
}
function getnumstore() {
if (myproduct.value) {
if (myproduct.value.storehouses)
return myproduct.value.storehouses.length
else
return 0
if (myproduct.value.storehouses) return myproduct.value.storehouses.length;
else return 0;
}
return 0
return 0;
}
function getSingleStorehouse() {
try {
const mystore = myproduct.value.storehouses[0]
if (mystore)
return mystore.name + ' (' + mystore.city + ')'
else
return ''
const mystore = myproduct.value.storehouses[0];
if (mystore) return mystore.name + ' (' + mystore.city + ')';
else return '';
} catch (e) {
return ''
return '';
}
}
function getSingleGasordine(gasordine: IGasordine) {
try {
const mygas = gasordine
const mygas = gasordine;
if (mygas)
/*return mygas.name + ' (' + mygas.city + ') ' + t('gas.dataora_chiusura_ordini') + ': ' + tools.getstrDateShort(mygas.dataora_chiusura_ordini)
+ ' ' + t('gas.data_arrivo_merce') + ': ' + tools.getstrDateShort(mygas.data_arrivo_merce)
+ ' ' + t('gas.dataora_ritiro') + ': ' + tools.getstrDateShort(mygas.dataora_ritiro)*/
return mygas.name
else
return ''
return mygas.name;
else return '';
} catch (e) {
return ''
return '';
}
}
function initproduct() {
myorder.quantity = 0
myorder.quantitypreordered = 0
myorder.idStorehouse = ''
myorder.idGasordine = ''
}
async function updateproduct() {
// console.log('props.id', props.id)
myproduct.value = await products.getProductById(props.id)
myproduct.value = await Products.getProductById(props.id);
// products.updateQuantityAvailable(myproduct.value._id)
// Products.updateQuantityAvailable(myproduct.value._id)
}
async function ricarica() {
endload.value = false
const prod = await products.loadProductById(myproduct.value._id)
endload.value = false;
const prod = await Products.loadProductById(myproduct.value._id);
if (prod) {
myproduct.value = prod
myproduct.value = prod;
}
await load()
endload.value = true
await load();
endload.value = true;
}
async function updateproductmodif(element: any) {
// console.log('updateproductmodif')
try {
if (element?._id) {
myproduct.value = await products.getProductById(element?._id)
myproduct.value = await Products.getProductById(element?._id);
} else {
myproduct.value = await products.getProductById(props.id)
myproduct.value = await Products.getProductById(props.id);
}
updateLabel()
updateLabel();
} catch (e) {
console.error('err', e)
console.error('err', e);
}
}
function getStorehouses() {
if (!myproduct.value)
return []
if (!myproduct.value) return [];
const myarr: any = []
let ind = 1
const myarr: any = [];
let ind = 1;
myproduct.value.storehouses.forEach((store) => {
myarr.push(
{
id: ind,
label: store.name + ' (' + store.city + ')',
value: store._id
})
myarr.push({
id: ind,
label: store.name + ' (' + store.city + ')',
value: store._id,
});
ind++
})
ind++;
});
// console.log('arraystore', myarr)
return myarr
return myarr;
}
function checkifCartDisable() {
// return !myorder.idStorehouse
return isOrdineChiuso()
return isOrdineChiuso();
}
function getQtyWarn() {
if (myorder.quantity > 0) {
return t('ecomm.di_cui_x_in_carrello', { qty: myorder.quantity })
return t('ecomm.di_cui_x_in_carrello', { qty: myorder.quantity });
}
return ''
return '';
}
function getQtyWarnPreOrdered() {
if (myorder.quantitypreordered > 0) {
return t('ecomm.di_cui_x_in_carrello', { qty: myorder.quantitypreordered })
return t('ecomm.di_cui_x_in_carrello', { qty: myorder.quantitypreordered });
}
return ''
return '';
}
watch(() => props.id, async (newval, oldval) => {
// console.log('change code')
await load()
})
watch(
() => props.id,
async (newval, oldval) => {
// console.log('change code')
await load();
}
);
watch(() => storeSelected.value, (newval, oldval) => {
myorder.idStorehouse = newval
})
watch(
() => storeSelected.value,
(newval, oldval) => {
myorder.idStorehouse = newval;
}
);
function updateLabel() {
let dataArrivoMerce = ''
let dataRitiro = ''
let dataArrivoMerce = '';
let dataRitiro = '';
try {
if (myproduct.value && myproduct.value.gasordine) {
if (myproduct.value.gasordine.data_arrivo_merce)
dataArrivoMerce = tools.getstrDateShort(myproduct.value.gasordine.data_arrivo_merce)
dataArrivoMerce = tools.getstrDateShort(
myproduct.value.gasordine.data_arrivo_merce
);
if (myproduct.value.gasordine.dataora_ritiro)
dataRitiro = tools.getstrDateTime(myproduct.value.gasordine.dataora_ritiro)
dataRitiro = tools.getstrDateTime(myproduct.value.gasordine.dataora_ritiro);
} else {
dataArrivoMerce = ''
dataRitiro = ''
dataArrivoMerce = '';
dataRitiro = '';
}
} catch (e) {
}
} catch (e) {}
if (labelDataArrivoMerce.value !== dataArrivoMerce)
labelDataArrivoMerce.value = dataArrivoMerce
if (labelDataRitiro.value !== dataRitiro)
labelDataRitiro.value = dataRitiro
labelDataArrivoMerce.value = dataArrivoMerce;
if (labelDataRitiro.value !== dataRitiro) labelDataRitiro.value = dataRitiro;
updateTimerLabel()
updateTimerLabel();
}
async function mounted() {
await load()
await load();
// Start the timer when the component is mounted
startTimer();
@@ -305,15 +308,24 @@ export default defineComponent({
}
function updateTimerLabel() {
if (myproduct.value && myproduct.value.gasordine && myproduct.value.gasordine._id && myproduct.value.gasordine.dataora_chiusura_ordini)
timerLabelScadenza.value = tools.getCountDown(myproduct.value.gasordine.dataora_chiusura_ordini)
else
timerLabelScadenza.value = ''
if (
myproduct.value &&
myproduct.value.gasordine &&
myproduct.value.gasordine._id &&
myproduct.value.gasordine.dataora_chiusura_ordini
)
timerLabelScadenza.value = tools.getCountDown(
myproduct.value.gasordine.dataora_chiusura_ordini
);
else timerLabelScadenza.value = '';
}
function isOrdineChiuso() {
return myproduct.value.gasordine && myproduct.value.gasordine.dataora_chiusura_ordini &&
return (
myproduct.value.gasordine &&
myproduct.value.gasordine.dataora_chiusura_ordini &&
tools.getCountDown(myproduct.value.gasordine.dataora_chiusura_ordini) === ''
);
}
function startTimer() {
@@ -322,76 +334,74 @@ export default defineComponent({
}
async function load() {
initproduct()
await updateproduct()
labelDataArrivoMerce.value = ''
labelDataRitiro.value = ''
Products.initproduct(myorder);
await updateproduct();
// console.log('Load', myproduct.value.name)
// console.log('created Cproductcard', code)
labelDataArrivoMerce.value = '';
labelDataRitiro.value = '';
arrordersCart.value = products.getOrdersCartInAttesaByIdProduct(myproduct.value._id)
arrordersCart.value = Products.getOrdersCartInAttesaByIdProduct(
myproduct.value._id
);
if (!!myproduct.value) {
if (myproduct.value.storehouses && myproduct.value.storehouses.length === 1) {
// Se solo 1 presente, metto fisso l'unico negozio !
myorder.idStorehouse = myproduct.value.storehouses[0]._id
}
if (myproduct.value.gasordine) {
myorder.idGasordine = myproduct.value.gasordine._id
}
const ord = products.getOrderProductInCart(myproduct.value._id)
if (ord) {
myorder.quantity = ord.quantity
myorder.quantitypreordered = ord.quantitypreordered
// Seleziona il Negozio che avevo già scelto nell'ordine !
if (ord.idStorehouse)
storeSelected.value = ord.idStorehouse
}
Products.setMyOrder(myorder, myproduct.value, storeSelected.value, {
setstore: true,
});
}
updateLabel()
updateLabel();
// console.log('°°° ENDLOAD °°°')
endload.value = true
endload.value = true;
}
function getclimgproduct() {
return 'myimgproduct centermydiv'
return 'myimgproduct centermydiv';
}
function visuListDisponibili() {
openlistorders.value = true
sumval.value = products.getSumQtyOrderProductInOrdersCart(myproduct.value._id)
openlistorders.value = true;
sumval.value = Products.getSumQtyOrderProductInOrdersCart(myproduct.value._id);
listord.value = arrordersCart.value.filter((orderscart: IOrderCart) => orderscart.items!.reduce((accumulator, item) => {
return accumulator + item.order.quantity
}, 0))
listord.value = arrordersCart.value.filter((orderscart: IOrderCart) =>
orderscart.items!.reduce((accumulator, item) => {
return accumulator + item.order.quantity;
}, 0)
);
}
function visuListBookable() {
openlistorders.value = true
sumval.value = products.getSumQtyPreOrderInOrdersCart(myproduct.value._id)
openlistorders.value = true;
sumval.value = Products.getSumQtyPreOrderInOrdersCart(myproduct.value._id);
listord.value = arrordersCart.value.filter((orderscart: IOrderCart) => orderscart.items!.reduce((accumulator, item) => {
return accumulator + item.order.quantitypreordered
}, 0))
listord.value = arrordersCart.value.filter((orderscart: IOrderCart) =>
orderscart.items!.reduce((accumulator, item) => {
return accumulator + item.order.quantitypreordered;
}, 0)
);
}
function isOrdGas(): boolean {
return (myproduct.value && !!myproduct.value.idGasordine && myproduct.value.gasordine! && myproduct.value.gasordine.active)
return (
myproduct.value &&
!!myproduct.value.idGasordine &&
myproduct.value.gasordine! &&
myproduct.value.gasordine.active
);
}
function getpercqtaraggiunta(): number {
if (myproduct.value)
return tools.calcperc((myproduct.value.bookableGASBloccatiQty + myproduct.value.QuantitaPrenotateInAttesa!) * myproduct.value.productInfo.weight!, myproduct.value.qtyToReachForGas * myproduct.value.productInfo.weight!) / 100
else
return 0
return (
tools.calcperc(
(myproduct.value.bookableGASBloccatiQty +
myproduct.value.QuantitaPrenotateInAttesa!) *
myproduct.value.productInfo.weight!,
myproduct.value.qtyToReachForGas * myproduct.value.productInfo.weight!
) / 100
);
else return 0;
}
function toggleFullScreen() {
@@ -430,7 +440,7 @@ export default defineComponent({
}
function naviga(path: string) {
$router.push(path)
$router.push(path);
}
function hasImage(): boolean {
@@ -439,11 +449,11 @@ export default defineComponent({
}
const { imagefile, image_link } = myproduct.value.productInfo;
return ((!!imagefile && imagefile !== '') || (!!image_link && image_link !== ''))
return (!!imagefile && imagefile !== '') || (!!image_link && image_link !== '');
}
onMounted(mounted)
onBeforeUnmount(beforeDestroy)
onMounted(mounted);
onBeforeUnmount(beforeDestroy);
return {
visuListDisponibili,
@@ -465,7 +475,7 @@ export default defineComponent({
openlistorders,
func_tools,
toolsext,
products,
Products,
arrordersCart,
endload,
shared_consts,
@@ -493,6 +503,6 @@ export default defineComponent({
ricarica,
apriSchedaPDF,
hasImage,
}
}
})
};
},
});

View File

@@ -136,7 +136,7 @@
v-if="
(cosa === shared_consts.PROD.TUTTI && !isOrdGas()) ||
cosa === shared_consts.PROD.BOTTEGA ||
(cosa === shared_consts.PROD.GAS && products.getQtyAvailable(myproduct) > 0)
(cosa === shared_consts.PROD.GAS && Products.getQtyAvailable(myproduct) > 0)
"
:clickable="tools.isManager()"
style="padding: 16px !important;"
@@ -166,7 +166,7 @@
v-if="!editOn"
class="prod_disp"
>
{{ products.getQtyAvailable(myproduct) }}
{{ Products.getQtyAvailable(myproduct) }}
</span>
<CMyValueDb
v-if="editOn"
@@ -193,7 +193,7 @@
</q-item-label>
</q-item-section>
<q-item-section
v-if="tools.isManager() && products.getQtyBloccataAvailable(myproduct) > 0"
v-if="tools.isManager() && Products.getQtyBloccataAvailable(myproduct) > 0"
>
<q-item-section avatar>
<q-icon
@@ -203,7 +203,7 @@
</q-item-section>
<q-item-section
v-if="
tools.isManager() && products.getQtyBloccataAvailable(myproduct) > 0
tools.isManager() && Products.getQtyBloccataAvailable(myproduct) > 0
"
>
<q-item-label> {{ t('ecomm.bloccati') }}: </q-item-label>
@@ -240,7 +240,7 @@
{{ myproduct.productInfo.name }}
</div>
<div v-if="myproduct?.productInfo?.authors" class="text-h8 text-italic titolo_prod q-mb-sm">
{{ products.getAutoriByArrayAuthors(myproduct.productInfo.authors) }}
{{ Products.getAutoriByArrayAuthors(myproduct.productInfo.authors) }}
</div>
<div class="product_code">
&nbsp; {{ t('ecomm.codice') }}: {{ myproduct.productInfo.code }}
@@ -552,7 +552,7 @@
</q-item-section>
<q-item-section
v-if="
tools.isManager() && products.getQtyBloccataBookableAvailable(myproduct) > 0
tools.isManager() && Products.getQtyBloccataBookableAvailable(myproduct) > 0
"
>
<q-item-section avatar>
@@ -715,7 +715,7 @@
</q-item-label>
</q-item-section>
<q-item-section
v-if="tools.isManager() && products.getQtyBloccataAvailable(myproduct) > 0"
v-if="tools.isManager() && Products.getQtyBloccataAvailable(myproduct) > 0"
>
<q-item-section avatar>
<q-icon
@@ -724,12 +724,12 @@
/>
</q-item-section>
<q-item-section
v-if="tools.isManager() && products.getQtyBloccataAvailable(myproduct) > 0"
v-if="tools.isManager() && Products.getQtyBloccataAvailable(myproduct) > 0"
>
<q-item-label> {{ t('ecomm.bloccati') }}: </q-item-label>
<q-item-label>
<span class="text-black q-ml-xs text-h8">
{{ products.getQtyBloccataAvailable(myproduct) }}</span
{{ Products.getQtyBloccataAvailable(myproduct) }}</span
>
</q-item-label>
</q-item-section>
@@ -843,16 +843,16 @@
<q-btn
icon="fas fa-cart-arrow-down"
:color="
checkifCartDisable() || !products.enableSubQty(myorder)
checkifCartDisable() || !Products.enableSubQty(myorder)
? 'grey'
: 'negative'
"
:disable="checkifCartDisable() || !products.enableSubQty(myorder)"
:disable="checkifCartDisable() || !Products.enableSubQty(myorder)"
rounded
size="md"
:label="
t('products.subcart', {
qta: products.qtaNextSub(myorder, myproduct),
qta: Products.qtaNextSub(myorder, myproduct),
})
"
@click="addtoCart(false)"
@@ -877,16 +877,16 @@
<q-btn
icon-right="fas fa-cart-plus"
:color="
checkifCartDisable() || !products.enableAddQty(myorder, myproduct)
checkifCartDisable() || !Products.enableAddQty(myorder, myproduct)
? 'grey'
: 'positive'
"
:disable="checkifCartDisable() || !products.enableAddQty(myorder, myproduct)"
:disable="checkifCartDisable() || !Products.enableAddQty(myorder, myproduct)"
rounded
size="md"
:label="
t('products.addcart', {
qta: products.qtaNextAdd(myorder, myproduct),
qta: Products.qtaNextAdd(myorder, myproduct),
})
"
@click="addtoCart(true)"

View File

@@ -1,4 +1,12 @@
import { PropType, computed, defineComponent, onMounted, ref, watch } from 'vue';
import {
PropType,
computed,
defineComponent,
onMounted,
ref,
watch,
reactive,
} from 'vue';
import draggable from 'vuedraggable';
import { tools } from '@tools';
@@ -7,7 +15,8 @@ import { useQuasar } from 'quasar';
import { useRouter } from 'vue-router';
import { useGlobalStore } from '@src/store/globalStore';
import { useProducts } from '@src/store/productStore';
import { useProducts } from '@src/store/Products';
import { useUserStore } from '@src/store/UserStore';
import { CMyValueDb } from '@src/components/CMyValueDb';
import { CSchedaProdotto } from '@src/components/CSchedaProdotto';
@@ -20,7 +29,6 @@ import { IAuthor, ICatProd } from 'app/src/model';
import type { IMyScheda, IOptCatalogo, IProduct } from '@src/model';
import { shared_consts } from 'app/src/common/shared_vuejs';
import { useProducts } from 'app/src/store/Products';
import { CViewTable } from '../CViewTable';
import { CLabel } from '../CLabel';
import { useI18n } from 'vue-i18n';
@@ -67,16 +75,17 @@ export default defineComponent({
// Copia locale della lista_prodotti per manipolazione interna
const internalProducts = ref([...(props.lista_prodotti || [])]);
const productStore = useProducts();
const $router = useRouter();
const { t } = useI18n();
const $q = useQuasar();
const arrordersCart = ref(<IOrderCart[]>[]);
const globalStore = useGlobalStore();
const products = useProducts();
const ProductStore = useProducts();
const userStore = useUserStore();
const showProd = ref(false);
const selProd = ref(<IProduct | null>null);
@@ -97,6 +106,7 @@ export default defineComponent({
const addstr = ref('');
const optionscatalogo = ref(<any>{ maxlength: 0 });
function handleUpdate(newList) {
@@ -302,6 +312,14 @@ export default defineComponent({
noexp: true,
notsortable: true,
},
{
name: 'addtocart',
label: 'Carrello',
field: 'addtocart',
align: 'center',
noexp: true,
notsortable: true,
},
{ name: 'name', label: 'Titolo', field: 'name', align: 'left' },
{
name: 'sottotitolo',
@@ -436,18 +454,28 @@ export default defineComponent({
const allColumnsComputed = computed(() => {
return allColumns.value.filter(
(col) => !col.visu || col.visu === costanti.VISUCAMPI.PER_TUTTI || (col.visu === costanti.VISUCAMPI.PER_EDITORE && tools.isCollaboratore())
(col) =>
!col.visu ||
col.visu === costanti.VISUCAMPI.PER_TUTTI ||
(col.visu === costanti.VISUCAMPI.PER_EDITORE && tools.isCollaboratore())
);
});
async function mounted() {
console.log('mounted CProductTable');
//myorder = ProductStore.createMyOrder()
// ProductStore.initproduct(myorder);
internalProducts.value.forEach((p: IProduct) => {
p.myorder = ProductStore.createMyOrder();
});
// console.log('mounted CProductTable');
loading.value = true;
if (props.table === shared_consts.TABLES_CATALOG) {
selectedColumns.value = selectedColumns_Catalogs.value;
} else {
// "products"
// "ProductStore"
selectedColumns.value = tools.isUtente()
? selectedColumns_Utenti.value
: selectedColumns_Editori.value;
@@ -455,10 +483,10 @@ export default defineComponent({
addstr.value = tools.addstrCookie(props.table);
if (props.table === 'products') {
if (props.table === shared_consts.TABLES_PRODUCTS) {
allColumns.value = allColumns_Catalog.value;
isVisibleEditBtn.value = true;
} else if (props.table === 'catalogs') {
} else if (props.table === shared_consts.TABLES_CATALOG) {
allColumns.value = allColumns_Raccolta.value;
isVisibleEditBtn.value = false;
}
@@ -522,6 +550,8 @@ export default defineComponent({
return tools.getstrDate(catalog.data_online);
case 'data_online_stampa':
return tools.getstrDate(catalog.data_online_stampa);
case 'addtocart':
return true;
case 'image':
return catalog.foto_collana?.imagefile
? tools.getFullFileNameByImageFile(
@@ -535,7 +565,10 @@ export default defineComponent({
switch (field.field) {
case 'image':
return element.productInfo?.imagefile
? tools.getFullFileNameByImageFile('productInfos', element.productInfo?.imagefile)
? tools.getFullFileNameByImageFile(
'productInfos',
element.productInfo?.imagefile
)
: element.productInfo?.image_link;
case 'name':
@@ -576,21 +609,25 @@ export default defineComponent({
return element.arrvariazioni?.[0]?.edizione;
case 'casaeditrice':
return products.getCasaEditriceByIdPublisher(element.productInfo?.idPublisher);
return ProductStore.getCasaEditriceByIdPublisher(
element.productInfo?.idPublisher
);
case 'idCollana':
return tools.formatCollane(element.productInfo?.idCollana);
case 'stato':
return products.getDescrStatiProdottoByIdStatoProdotto(
return ProductStore.getDescrStatiProdottoByIdStatoProdotto(
element.productInfo?.idStatoProdotto || ''
);
case 'tipologia':
return products.getDescrByIdTipologia(element.arrvariazioni?.[0]?.idTipologia || '');
return ProductStore.getDescrByIdTipologia(
element.arrvariazioni?.[0]?.idTipologia || ''
);
case 'tipoformato':
return products.getDescrByIdTipoFormato(
return ProductStore.getDescrByIdTipoFormato(
element.arrvariazioni?.[0]?.idTipoFormato || ''
);
@@ -599,11 +636,11 @@ export default defineComponent({
case 'prezzo':
// return element.price ? '€ ' + element.price.toFixed(2) : '';
return '€ ' + element.arrvariazioni?.[0]?.price.toFixed(2);
return '€ ' + element.arrvariazioni?.[0]?.price?.toFixed(2);
case 'prezzo_sconto':
// return element.sale_price ? '€ ' + element.sale_price.toFixed(2) : '';
return '€ ' + element.arrvariazioni?.[0]?.sale_price.toFixed(2);
return '€ ' + element.arrvariazioni?.[0]?.sale_price?.toFixed(2);
case 'rank3M':
return element.productInfo?.rank3M;
@@ -637,7 +674,9 @@ export default defineComponent({
case 'quantity':
if (tools.isUtente())
return tools.getDescrQuantitàByQuantity(element.arrvariazioni?.[0]?.quantita);
return tools.getDescrQuantitàByQuantity(
element.arrvariazioni?.[0]?.quantita
);
else return element.arrvariazioni?.[0]?.quantita;
default:
@@ -659,13 +698,13 @@ export default defineComponent({
: 'text-red';
case 'stato':
if (products.isProssimaUscita(element.productInfo)) {
if (ProductStore.isProssimaUscita(element.productInfo)) {
return 'bg-purple-3';
}
if (products.isPrevendita(element.productInfo)) {
if (ProductStore.isPrevendita(element.productInfo)) {
return 'bg-blue-3';
}
if (products.isNonVendibile(element.productInfo)) {
if (ProductStore.isNonVendibile(element.productInfo)) {
return 'bg-grey';
}
return '';
@@ -680,14 +719,14 @@ export default defineComponent({
}
case 'quantity':
if (products.isPubblicato(element.productInfo)) {
if (products.isQtaLimitata(element)) {
if (ProductStore.isPubblicato(element.productInfo)) {
if (ProductStore.isQtaLimitata(element)) {
return 'bg-yellow';
}
if (products.isInEsaurendo(element)) {
if (ProductStore.isInEsaurendo(element)) {
return 'bg-orange';
}
if (products.isEsaurito(element)) {
if (ProductStore.isEsaurito(element)) {
return 'text-white bg-red-10';
}
}
@@ -846,14 +885,19 @@ export default defineComponent({
persistent: false,
})
.onOk(() => {
internalProducts.value = internalProducts.value.filter((p: any) => p._id !== product._id);
internalProducts.value = internalProducts.value.filter(
(p: any) => p._id !== product._id
);
emit('update:lista_prodotti', internalProducts.value); // Notifica il parent del cambiamento
});
};
// 8. Salvataggio delle colonne selezionate in un cookie
const saveSelectedColumns = () => {
tools.setCookie(addstr.value + 'selColCat_2', JSON.stringify(selectedColumns.value));
tools.setCookie(
addstr.value + 'selColCat_2',
JSON.stringify(selectedColumns.value)
);
};
// 9. Watcher per salvare automaticamente le preferenze quando cambiano
@@ -901,7 +945,7 @@ export default defineComponent({
let link_macro = element.productInfo?.link_macro;
if (tools.isUtente() && link_macro) {
tools.openUrl(link_macro + '?utm_source=catalog&id=' + props.idcatalog)
tools.openUrl(link_macro + '?utm_source=catalog&id=' + props.idcatalog);
} else {
selProd.value = element;
@@ -910,7 +954,7 @@ export default defineComponent({
} else if (isCatalog()) {
// Apri la pagina del catalogo
if (element.idPageAssigned) {
const mypagepath = productStore.getPathByPage(element.idPageAssigned);
const mypagepath = ProductStore.getPathByPage(element.idPageAssigned);
// fai il route sulla pagina myfilename
$router.push(`/${mypagepath}`);
@@ -953,9 +997,9 @@ export default defineComponent({
console.log('PRODUCT TABLE: updateproductmodif');
try {
if (element?._id) {
selProd.value = await products.getProductById(element?._id);
selProd.value = await ProductStore.getProductById(element?._id);
} else {
selProd.value = await products.getProductById(selProd.value?._id);
selProd.value = await ProductStore.getProductById(selProd.value?._id);
}
// update record inside internalProducts
@@ -1019,7 +1063,9 @@ export default defineComponent({
return sortDirection.value === 1 ? aVal - bVal : bVal - aVal;
}
if (typeof aVal === 'string' && typeof bVal === 'string') {
return sortDirection.value === 1 ? aVal.localeCompare(bVal) : bVal.localeCompare(aVal);
return sortDirection.value === 1
? aVal.localeCompare(bVal)
: bVal.localeCompare(aVal);
}
return sortDirection.value === 1
? String(aVal).localeCompare(String(bVal))
@@ -1092,7 +1138,9 @@ export default defineComponent({
}
function isSortable(field: string): boolean {
return allColumns && !allColumns.value.find((col) => col.name === field)?.notsortable;
return (
allColumns && !allColumns.value.find((col) => col.name === field)?.notsortable
);
}
function getImageByElement(element) {
@@ -1107,10 +1155,48 @@ export default defineComponent({
}
function isProduct() {
return props.table === 'products';
return props.table === shared_consts.TABLES_PRODUCTS;
}
function isCatalog() {
return props.table === 'catalogs';
return props.table === shared_consts.TABLES_CATALOG;
}
/*
async function addToCart(element: any) {
if (props.table === shared_consts.TABLES_PRODUCTS) {
await updateProduct(element);
if (!!element) {
arrordersCart.value = ProductStore.getOrdersCartInAttesaByIdProduct(
element._id
);
ProductStore.setMyOrder(myorder, element, null, {
setstore: false,
});
}
}
}*/
async function addtoCart(element: any, add: boolean) {
if (!userStore.isLogged) {
tools.showNeutralNotif($q, t('ecomm.area_personale'));
globalStore.rightDrawerOpen = true;
return false;
}
ProductStore.setMyOrder(element.myorder, element, null, {
setstore: false,
});
const ris = await ProductStore.addtoCartBase({
$q,
t,
id: element._id,
order: element.myorder,
addqty: add,
});
updateProduct(element);
}
onMounted(mounted);
@@ -1144,7 +1230,7 @@ export default defineComponent({
updateproductmodif,
optionscatalogo,
t,
products,
ProductStore,
sortTable,
sortAttribute,
sortDirection,
@@ -1160,6 +1246,8 @@ export default defineComponent({
isProduct,
isCatalog,
allColumnsComputed,
addtoCart,
arrordersCart,
};
},
});

View File

@@ -54,9 +54,7 @@
<span>{{ col.label }}</span>
<span v-if="isSortable(col.name)">
<q-icon
v-if="
sortAttribute === col.name && optcatalogo.showListaArgomenti
"
v-if="sortAttribute === col.name && optcatalogo.showListaArgomenti"
:name="sortDirection === 1 ? 'expand_less' : 'expand_more'"
size="36px"
class="q-ml-xs"
@@ -131,11 +129,40 @@
/>
</span>
</td>
<td v-else-if="field.name === 'addtocart' && isColumnVisible('addtocart')">
<q-btn
icon-right="fas fa-cart-plus"
color="positive"
rounded
dense
size="sm"
:label="
t('products.addcart', {
qta: ProductStore.qtaNextAdd(element.myorder, element),
})
"
@click="addtoCart(element, true)"
>
</q-btn>
<q-btn
v-if="ProductStore.enableSubQty(element.myorder)"
icon-right="fas fa-cart-arrow-down"
color="negative"
rounded
dense
size="sm"
:label="
t('products.subcart', {
qta: ProductStore.qtaNextSub(element.myorder, element),
})
"
@click="addtoCart(element, false)"
>
</q-btn>
</td>
<!-- Immagine Piccola -->
<td
v-else-if="field.name === 'image' && isColumnVisible('image')"
>
<td v-else-if="field.name === 'image' && isColumnVisible('image')">
<q-img
:src="
getImageByElement(element)
@@ -162,9 +189,7 @@
</td>
<!-- Azioni -->
<td
v-else-if="
field.name === 'actions' && isColumnVisible('actions', true)
"
v-else-if="field.name === 'actions' && isColumnVisible('actions', true)"
>
<q-btn-dropdown
label="Azioni"

View File

@@ -365,7 +365,7 @@ export default defineComponent({
mykey: 'idCatProds',
debounce: '1000',
type: costanti.FieldType.multiselect,
jointable: 'catprtotali',
jointable: 'catprods',
dense: true,
},
{

View File

@@ -72,7 +72,7 @@
v-model="causal"
rounded
filled
maxlength="80"
maxlength="120"
counter
:label="$t('circuit.note_richiedente')"
class="q-ma-sm full-width q-px-xs"