- caaloghi, categorie
This commit is contained in:
@@ -8,6 +8,7 @@ import { CTitleBanner } from '../CTitleBanner'
|
||||
import { CCardState } from '../CCardState'
|
||||
import { CCopyBtn } from '../CCopyBtn'
|
||||
import { CMyValueDb } from '../CMyValueDb'
|
||||
import { CPrice } from '../CPrice'
|
||||
|
||||
import { func_tools, toolsext } from '@store/Modules/toolsext'
|
||||
|
||||
@@ -48,8 +49,13 @@ export default defineComponent({
|
||||
required: false,
|
||||
default: false,
|
||||
},
|
||||
options: {
|
||||
type: Object,
|
||||
required: false,
|
||||
default: () => { }
|
||||
}
|
||||
},
|
||||
components: { CTitleBanner, CCardState, CCopyBtn, CMyValueDb, VuePdfApp },
|
||||
components: { CTitleBanner, CCardState, CCopyBtn, CMyValueDb, VuePdfApp, CPrice },
|
||||
setup(props, { emit }) {
|
||||
const $q = useQuasar()
|
||||
const { t } = useI18n()
|
||||
@@ -91,7 +97,7 @@ export default defineComponent({
|
||||
|
||||
const openlistorders = ref(false)
|
||||
const endload = ref(false)
|
||||
const myproduct = ref(<IProduct>{})
|
||||
const myproduct = ref(<IProduct | null>{})
|
||||
|
||||
const isFullScreen = ref(false)
|
||||
const imageSrc = ref('URL_DEL_TUO_FILE_IMMAGINE')
|
||||
@@ -129,10 +135,12 @@ export default defineComponent({
|
||||
return false
|
||||
}
|
||||
|
||||
const ris = await products.addtoCartBase({ $q, t, id: myproduct.value._id, order: myorder, addqty: add })
|
||||
updateproduct()
|
||||
if (ris && ris.myord) {
|
||||
if (myproduct.value) {
|
||||
const ris = await products.addtoCartBase({ $q, t, id: myproduct.value._id, order: myorder, addqty: add })
|
||||
updateproduct()
|
||||
if (ris && ris.myord) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,6 +156,9 @@ export default defineComponent({
|
||||
|
||||
function getSingleStorehouse() {
|
||||
try {
|
||||
if (!myproduct.value)
|
||||
return ''
|
||||
|
||||
const mystore = myproduct.value.storehouses[0]
|
||||
if (mystore)
|
||||
return mystore.name + ' (' + mystore.city + ')'
|
||||
@@ -183,28 +194,30 @@ export default defineComponent({
|
||||
|
||||
}
|
||||
|
||||
function updateproduct() {
|
||||
async function updateproduct() {
|
||||
|
||||
myproduct.value = products.getProductById(props.id)
|
||||
myproduct.value = null;
|
||||
myproduct.value = await products.getProductById(props.id)
|
||||
|
||||
// products.updateQuantityAvailable(myproduct.value._id)
|
||||
}
|
||||
|
||||
async function ricarica() {
|
||||
endload.value = false
|
||||
const prod = await products.loadProductById(myproduct.value._id)
|
||||
if (prod) {
|
||||
myproduct.value = prod
|
||||
if (myproduct.value) {
|
||||
const prod = await products.loadProductById(myproduct.value._id)
|
||||
if (prod) {
|
||||
myproduct.value = prod
|
||||
}
|
||||
}
|
||||
load()
|
||||
endload.value = true
|
||||
await load()
|
||||
|
||||
}
|
||||
|
||||
function updateproductmodif() {
|
||||
async function updateproductmodif() {
|
||||
|
||||
try {
|
||||
myproduct.value = products.getProductById(props.id)
|
||||
myproduct.value = await products.getProductById(props.id)
|
||||
|
||||
updateLabel()
|
||||
} catch (e) {
|
||||
@@ -256,9 +269,9 @@ export default defineComponent({
|
||||
return ''
|
||||
}
|
||||
|
||||
watch(() => props.id, (newval, oldval) => {
|
||||
watch(() => props.id, async (newval, oldval) => {
|
||||
// console.log('change code')
|
||||
load()
|
||||
await load()
|
||||
})
|
||||
|
||||
watch(() => storeSelected.value, (newval, oldval) => {
|
||||
@@ -289,12 +302,8 @@ export default defineComponent({
|
||||
updateTimerLabel()
|
||||
}
|
||||
|
||||
function mounted() {
|
||||
load()
|
||||
|
||||
if (props.complete && myproduct.value && myproduct.value.arrvariazioni) {
|
||||
indvariazSel.value = 0
|
||||
}
|
||||
async function mounted() {
|
||||
await load()
|
||||
|
||||
// Start the timer when the component is mounted
|
||||
startTimer();
|
||||
@@ -306,15 +315,18 @@ export default defineComponent({
|
||||
}
|
||||
|
||||
function updateTimerLabel() {
|
||||
if (myproduct.value && 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 = ''
|
||||
}
|
||||
|
||||
function isOrdineChiuso() {
|
||||
return myproduct.value.gasordine && myproduct.value.gasordine.dataora_chiusura_ordini &&
|
||||
tools.getCountDown(myproduct.value.gasordine.dataora_chiusura_ordini) === ''
|
||||
if (myproduct.value) {
|
||||
return myproduct.value.gasordine && myproduct.value.gasordine.dataora_chiusura_ordini &&
|
||||
tools.getCountDown(myproduct.value.gasordine.dataora_chiusura_ordini) === ''
|
||||
} else
|
||||
return false
|
||||
}
|
||||
|
||||
function startTimer() {
|
||||
@@ -322,17 +334,18 @@ export default defineComponent({
|
||||
timerInterval.value = setInterval(() => updateTimerLabel(), 60000);
|
||||
}
|
||||
|
||||
function load() {
|
||||
async function load() {
|
||||
indvariazSel.value = -1
|
||||
initproduct()
|
||||
updateproduct()
|
||||
await updateproduct()
|
||||
labelDataArrivoMerce.value = ''
|
||||
labelDataRitiro.value = ''
|
||||
|
||||
// console.log('Load', myproduct.value.name)
|
||||
|
||||
arrordersCart.value = products.getOrdersCartInAttesaByIdProduct(myproduct.value._id)
|
||||
|
||||
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
|
||||
@@ -356,6 +369,13 @@ export default defineComponent({
|
||||
|
||||
updateLabel()
|
||||
|
||||
// console.log('myproduct', myproduct.value, 'arrvariaz', myproduct.value.arrvariazioni, 'compl', props.complete)
|
||||
if (props.complete && myproduct.value && myproduct.value.arrvariazioni) {
|
||||
// console.log('ENTRATO')
|
||||
indvariazSel.value = 0
|
||||
}
|
||||
|
||||
|
||||
// console.log('°°° ENDLOAD °°°')
|
||||
endload.value = true
|
||||
}
|
||||
@@ -366,25 +386,35 @@ export default defineComponent({
|
||||
|
||||
|
||||
function visuListDisponibili() {
|
||||
openlistorders.value = true
|
||||
sumval.value = products.getSumQtyOrderProductInOrdersCart(myproduct.value._id)
|
||||
if (myproduct.value) {
|
||||
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))
|
||||
} else
|
||||
return false
|
||||
}
|
||||
|
||||
function visuListBookable() {
|
||||
openlistorders.value = true
|
||||
sumval.value = products.getSumQtyPreOrderInOrdersCart(myproduct.value._id)
|
||||
if (myproduct.value) {
|
||||
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))
|
||||
} else {
|
||||
return ''
|
||||
}
|
||||
}
|
||||
|
||||
function isOrdGas(): boolean {
|
||||
return (myproduct.value && !!myproduct.value.idGasordine && myproduct.value.gasordine! && myproduct.value.gasordine.active)
|
||||
if (myproduct.value)
|
||||
return (myproduct.value && !!myproduct.value.idGasordine && myproduct.value.gasordine! && myproduct.value.gasordine.active)
|
||||
else
|
||||
return false
|
||||
}
|
||||
|
||||
function getpercqtaraggiunta(): number {
|
||||
@@ -436,8 +466,10 @@ export default defineComponent({
|
||||
function setvariazioneSelected(indvariaz: number) {
|
||||
if (indvariazSel.value === indvariaz)
|
||||
indvariazSel.value = -1
|
||||
else
|
||||
else {
|
||||
indvariazSel.value = -1
|
||||
indvariazSel.value = indvariaz
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(mounted)
|
||||
|
||||
Reference in New Issue
Block a user