corretto problema che si aggiornava a fatica... si bloccava... era una label che veniva continuamente azzerata e riscritta...

This commit is contained in:
Surya Paolo
2024-02-09 00:25:51 +01:00
parent 288318fdb6
commit aa108d9213
8 changed files with 141 additions and 29 deletions

View File

@@ -672,7 +672,7 @@ export default defineComponent({
sortBy = sortBy + ''
// descending = descending + ''
let arrsort = (sortBy && sortBy.indexOf(',') > 0) ? sortBy.split(',') : [];
let arrdescending = (descending && descending.lenght > 1 && descending.indexOf(',') > 0) ? descending.split(',') : [];
let arrdescending = (descending && descending.length > 1 && descending.indexOf(',') > 0) ? descending.split(',') : [];
if (arrsort.length > 0) {
for (let i = 0; i < arrsort.length; i++) {
let field = arrsort[i].trim()

View File

@@ -652,7 +652,7 @@ export default defineComponent({
sortBy = sortBy + ''
// descending = descending + ''
let arrsort = (sortBy && sortBy.indexOf(',') > 0) ? sortBy.split(',') : [];
let arrdescending = (descending && descending.lenght > 1 && descending.indexOf(',') > 0) ? descending.split(',') : [];
let arrdescending = (descending && descending.length > 1 && descending.indexOf(',') > 0) ? descending.split(',') : [];
if (arrsort.length > 0) {
for (let i = 0; i < arrsort.length; i++) {
let field = arrsort[i].trim()

View File

@@ -98,12 +98,6 @@ export default defineComponent({
const scale = ref(1)
const valoriopt = computed(() => (item: any, addall: boolean, addnone: boolean) => {
// console.log('valoriopt', item.table)
return globalStore.getTableJoinByName(item.table, addall, addnone, item.filter)
})
watch(() => editOn.value, (to: any, from: any) => {
if (!editOn.value)
ricarica()
@@ -266,15 +260,26 @@ export default defineComponent({
})
function updateLabel() {
if (myproduct.value.gasordine) {
let dataArrivoMerce = ''
let dataRitiro = ''
try {
if (myproduct.value && myproduct.value.gasordine) {
if (myproduct.value.gasordine.data_arrivo_merce)
labelDataArrivoMerce.value = tools.getstrDateShort(myproduct.value.gasordine.data_arrivo_merce)
dataArrivoMerce = tools.getstrDateShort(myproduct.value.gasordine.data_arrivo_merce)
if (myproduct.value.gasordine.dataora_ritiro)
labelDataRitiro.value = tools.getstrDateTime(myproduct.value.gasordine.dataora_ritiro)
dataRitiro = tools.getstrDateTime(myproduct.value.gasordine.dataora_ritiro)
} else {
labelDataArrivoMerce.value = ''
labelDataRitiro.value = ''
dataArrivoMerce = ''
dataRitiro = ''
}
} catch (e) {
}
if (labelDataArrivoMerce.value !== dataArrivoMerce)
labelDataArrivoMerce.value = dataArrivoMerce
if (labelDataRitiro.value !== dataRitiro)
labelDataRitiro.value = dataRitiro
updateTimerLabel()
}
@@ -291,7 +296,7 @@ export default defineComponent({
}
function updateTimerLabel() {
if (myproduct.value.gasordine && myproduct.value.gasordine._id && myproduct.value.gasordine.dataora_chiusura_ordini)
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 = ''
@@ -304,12 +309,14 @@ export default defineComponent({
function startTimer() {
// Update the timer label every second
timerInterval.value = setInterval(() => updateTimerLabel(), 1000);
timerInterval.value = setInterval(() => updateTimerLabel(), 60000);
}
function load() {
initproduct()
updateproduct()
labelDataArrivoMerce.value = ''
labelDataRitiro.value = ''
// console.log('Load', myproduct.value.name)
// console.log('created Cproductcard', code)

View File

@@ -637,6 +637,7 @@
</q-item-label>
</q-item-section>
</q-item>
<q-item
v-if="
myproduct.gasordine &&

View File

@@ -2097,12 +2097,6 @@ export const colTableProducts = [
fieldtype: costanti.FieldType.select,
jointable: 'gasordines',
}),
AddCol({
name: 'idGasordine',
label_trans: 'gas.name',
fieldtype: costanti.FieldType.select,
jointable: 'gasordines',
}),
AddCol({
name: 'idProvider',
label_trans: 'provider.name',

View File

@@ -8354,6 +8354,31 @@ export const tools = {
// Calculate the difference in milliseconds
const countdown = targetTime - currentDate.getTime();
if (countdown > 0) {
// Convert milliseconds to seconds
const countdownInSeconds = Math.floor(countdown / 1000);
const days = Math.floor(countdownInSeconds / (60 * 60 * 24));
const hours = Math.floor((countdownInSeconds % (60 * 60 * 24)) / (60 * 60));
const minutes = Math.floor((countdownInSeconds % (60 * 60)) / 60);
const gg = days > 0 ? 'giorni' : ''
const strgg = gg ? `${days} giorni` : ''
return (`${strgg} ${this.pad(hours)}h ${this.pad(minutes)}m`);
} else {
return '';
}
},
getCountDownWithSeconds(mydate: Date) {
const currentDate = new Date();
const targetTime = new Date(mydate).getTime();
// Calculate the difference in milliseconds
const countdown = targetTime - currentDate.getTime();
if (countdown > 0) {
// Convert milliseconds to seconds
const countdownInSeconds = Math.floor(countdown / 1000);

View File

@@ -32,14 +32,26 @@ export default defineComponent({
const cat = ref('')
const loadpage = ref(false)
const refreshpage = ref(false)
const show_hide = ref(false)
const arrProducts = ref<any>([])
const numRecLoaded = ref(0)
// Create a ref for the component to fix
const componentToFixRef = ref(<any>null);
const isFixed = ref(false);
const arrLoaded = computed(() => {
if (arrProducts.value && numRecLoaded.value)
return arrProducts.value.slice(0, numRecLoaded.value)
else {
return []
}
})
// Register the scroll event on component mount
const handleScroll = () => {
const scrollTop = window.scrollY || document.documentElement.scrollTop;
@@ -69,6 +81,8 @@ export default defineComponent({
})
function calcArrProducts() {
console.log('calcArrProducts')
refreshpage.value = true
let arrprod = productStore.getProducts(cosa.value)
let catstr = cat.value;
@@ -93,6 +107,7 @@ export default defineComponent({
}
arrProducts.value = arrprod
loaddata()
refreshpage.value = false
}
@@ -121,6 +136,12 @@ export default defineComponent({
window.addEventListener('scroll', handleScroll);
calcArrProducts()
loaddata()
}
function loaddata() {
numRecLoaded.value = 20
}
// Remove the event listener on component destroy
@@ -138,6 +159,26 @@ export default defineComponent({
return riscat
}
function onLoadScroll(index: number, done: any) {
if (index >= 1) {
if (numRecLoaded.value < arrProducts.value.length) {
const step = 10
let mynrec = numRecLoaded.value + step
if (mynrec > arrProducts.value.length)
mynrec = arrProducts.value.length
numRecLoaded.value = mynrec
done()
}
} else {
done(true)
}
}
onMounted(mounted)
return {
@@ -157,6 +198,10 @@ export default defineComponent({
componentToFixRef,
isFixed,
arrProducts,
show_hide,
onLoadScroll,
numRecLoaded,
arrLoaded,
}
}
})

View File

@@ -116,14 +116,54 @@
})
}}</span>
</div>
<div class="row justify-around" v-if="tools.isManager()">
<q-toggle
v-model="show_hide"
push
label="Mostra Nascosti"
rounded
glossy
toggle-color="primary"
></q-toggle>
</div>
<div class="row justify-around">
<div
<q-infinite-scroll
v-if="arrLoaded && arrLoaded.length > 0"
ref="myinfscroll"
:initial-index="0"
@load="onLoadScroll"
:offset="2000"
debounce="200"
class="q-pa-xs row items-start"
v-for="(product, index) in arrProducts"
>
<div
class="q-pa-xs"
v-for="(product, index) in arrLoaded"
:key="index"
>
<CProductCard :id="product._id" :complete="false" :cosa="cosa" />
<CProductCard
v-if="product.active || show_hide"
:id="product._id"
:complete="false"
:cosa="cosa"
/>
</div>
<template v-slot:loading>
<div class="text-center">
<q-spinner-dots color="primary" size="40px" />
</div>
</template>
</q-infinite-scroll>
<br />
<q-btn
dense
size="md"
color="primary"
rounded
label="Vedi altri Prodotti..."
@click="numRecLoaded += 10"
>
</q-btn>
</div>
</div>
</div>