- filtro se GAS o Prodotti

This commit is contained in:
Surya Paolo
2023-12-28 21:00:10 +01:00
parent 196b19ac66
commit ed76b9c1dd
12 changed files with 207 additions and 36 deletions

View File

@@ -1,4 +1,4 @@
import { defineComponent, ref, toRef, computed, PropType, watch, onMounted, reactive } from 'vue'
import { defineComponent, ref, toRef, computed, PropType, watch, onMounted, reactive, onBeforeUnmount } from 'vue'
import { useI18n } from '@src/boot/i18n'
import { useUserStore } from '@store/UserStore'
import { useGlobalStore } from '@store/globalStore'
@@ -65,8 +65,12 @@ export default defineComponent({
const storeSelected = ref('')
const gasordineSelected = ref('')
const recgasordineSelected = ref(<any>null)
const arrordersCart = ref(<IOrderCart[]>[])
const timerInterval = ref(<any>null)
const timerLabelScadenza = ref('')
const openlistorders = ref(false)
const endload = ref(false)
const myproduct = ref(<IProduct>{})
@@ -217,8 +221,33 @@ export default defineComponent({
watch(() => gasordineSelected.value, (newval, oldval) => {
myorder.idGasordine = newval
recgasordineSelected.value = myproduct.value.gasordines.find((rec: any) => rec._id === gasordineSelected.value)
})
function mounted() {
load()
// Start the timer when the component is mounted
startTimer();
}
function beforeDestroy() {
// Clear the interval when the component is destroyed to prevent memory leaks
clearInterval(timerInterval.value);
}
function updateTimerLabel() {
if (recgasordineSelected.value)
timerLabelScadenza.value = tools.getCountDown(recgasordineSelected.value.dataora_chiusura_ordini)
else
timerLabelScadenza.value = ''
}
function startTimer() {
// Update the timer label every second
timerInterval.value = setInterval(() => updateTimerLabel(), 1000);
}
function load() {
updateproduct()
// console.log('Load', myproduct.value.name)
@@ -234,22 +263,29 @@ export default defineComponent({
if (myproduct.value.gasordines && myproduct.value.gasordines.length === 1) {
myorder.idGasordine = myproduct.value.gasordines[0]._id
gasordineSelected.value = myorder.idGasordine!
}
const ord = products.getOrderProductInCart(myproduct.value._id)
if (ord) {
myorder.quantity = ord.quantity
myorder.quantitypreordered = ord.quantitypreordered
if (ord.idGasordine)
if (ord.idGasordine) {
gasordineSelected.value = ord.idGasordine!
recgasordineSelected.value = myproduct.value.gasordines.find((rec: IGasordine) => rec._id === ord.idGasordine!)
}
// Seleziona il Negozio che avevo già scelto nell'ordine !
if (ord.idStorehouse)
storeSelected.value = ord.idStorehouse
}
if (gasordineSelected.value) {
recgasordineSelected.value = myproduct.value.gasordines.find((rec: IGasordine) => rec._id === gasordineSelected.value)
}
}
// console.log('°°° ENDLOAD °°°')
@@ -283,7 +319,8 @@ export default defineComponent({
}, 0))
}
onMounted(load)
onMounted(mounted)
onBeforeUnmount(beforeDestroy)
return {
visuListDisponibili,
@@ -316,6 +353,8 @@ export default defineComponent({
listord,
sumval,
getGasordines,
recgasordineSelected,
timerLabelScadenza,
}
}
})