aggiornamento...

This commit is contained in:
Surya Paolo
2023-12-17 19:19:10 +01:00
parent a941592c21
commit c2af144c05
4 changed files with 45 additions and 22 deletions

View File

@@ -57,15 +57,19 @@ export default defineComponent({
const openlistorders = ref(false) const openlistorders = ref(false)
const endload = ref(false) const endload = ref(false)
const myproduct = ref(<IProduct>{})
const valoriopt = computed(() => (item: any, addall: boolean, addnone: boolean) => { const valoriopt = computed(() => (item: any, addall: boolean, addnone: boolean) => {
// console.log('valoriopt', item.table) // console.log('valoriopt', item.table)
return globalStore.getTableJoinByName(item.table, addall, addnone, item.filter) return globalStore.getTableJoinByName(item.table, addall, addnone, item.filter)
}) })
const myproduct = computed((): IProduct => { /*const myproduct = computed((): IProduct => {
return products.getProduct(props.code) console.log('getproduct computed')
}) const ris = products.getProduct(props.code)
console.log(' received', ris)
return ris
})*/
function iconWhishlist(order: IProduct) { function iconWhishlist(order: IProduct) {
@@ -103,6 +107,8 @@ export default defineComponent({
} }
updateproduct()
if (ris === null || myorder.quantity === 0) if (ris === null || myorder.quantity === 0)
tools.showNotif($q, msg) tools.showNotif($q, msg)
else else
@@ -130,6 +136,10 @@ export default defineComponent({
} }
} }
function updateproduct() {
myproduct.value = products.getProduct(props.code)
}
function getStorehouses() { function getStorehouses() {
const myarr: any = [] const myarr: any = []
@@ -154,15 +164,8 @@ export default defineComponent({
return false return false
} }
function updateQtyAvailable() {
myproduct.value.quantityAvailable = myproduct.value.stockQty
if (myproduct.value.QuantitaOrdinateInAttesa! > 0) {
myproduct.value.quantityAvailable! -= myproduct.value.QuantitaOrdinateInAttesa!
}
}
function getQtyAvailable() { function getQtyAvailable() {
updateQtyAvailable() products.updateQuantityAvailable(myproduct.value._id)
let qty = myproduct.value.quantityAvailable! let qty = myproduct.value.quantityAvailable!
return qty return qty
} }
@@ -184,6 +187,8 @@ export default defineComponent({
}) })
function load() { function load() {
updateproduct()
console.log('Load', myproduct.value.name)
// console.log('created Cproductcard', code) // console.log('created Cproductcard', code)
arrordersCart.value = products.getOrdersCartByIdProduct(myproduct.value._id) arrordersCart.value = products.getOrdersCartByIdProduct(myproduct.value._id)
@@ -199,7 +204,7 @@ export default defineComponent({
} }
} }
console.log('°°° ENDLOAD °°°')
endload.value = true endload.value = true
} }
@@ -218,8 +223,8 @@ export default defineComponent({
function enableAddQty() { function enableAddQty() {
if (site.value.ecomm!.enablePreOrders) { if (site.value.ecomm!.enablePreOrders) {
return true return true
} else { } else {
return getQtyAvailable() > 0 return getQtyAvailable() > 0
} }
} }

View File

@@ -51,7 +51,7 @@
myproduct.after_price myproduct.after_price
}}</span> }}</span>
</q-item-label> </q-item-label>
<q-item-label v-if="myproduct.scontisticas && myproduct.scontisticas.length > 0"> <!--<q-item-label v-if="myproduct.scontisticas && myproduct.scontisticas.length > 0">
<div <div
class="prod_sconti" class="prod_sconti"
v-for="(sconti, index) of myproduct.scontisticas" v-for="(sconti, index) of myproduct.scontisticas"
@@ -60,6 +60,7 @@
{{ sconti.description }} {{ sconti.description }}
</div> </div>
</q-item-label> </q-item-label>
-->
</q-item-section> </q-item-section>
</q-item> </q-item>
</q-list> </q-list>

View File

@@ -10,13 +10,14 @@ import { CMyFieldDb } from '@/components/CMyFieldDb'
import { useGlobalStore } from '@store/globalStore' import { useGlobalStore } from '@store/globalStore'
import { costanti } from '@costanti' import { costanti } from '@costanti'
import { tools } from '@src/store/Modules/tools' import { tools } from '@src/store/Modules/tools'
import { ISites } from '@src/model'
export default defineComponent({ export default defineComponent({
name: 'Confsite', name: 'Confsite',
components: { CImgText, CCard, CMyPage, CTitleBanner, CMyFieldRec, CMyFieldDb }, components: { CImgText, CCard, CMyPage, CTitleBanner, CMyFieldRec, CMyFieldDb },
setup() { setup() {
const mysite = ref(null) const mysite = ref(<ISites>{})
const tab = ref('server') const tab = ref('server')
const globalStore = useGlobalStore() const globalStore = useGlobalStore()

View File

@@ -44,7 +44,7 @@ export const useProducts = defineStore('Products', {
getProduct: (state: IProductsState) => (code: string): IProduct => { getProduct: (state: IProductsState) => (code: string): IProduct => {
const prod = state.products.find((prod: IProduct) => prod.code === code) const prod = state.products.find((prod: IProduct) => prod.code === code)
return prod ? prod : { storehouses: [], scontisticas: [] } return prod ? prod : { active: false, img: '', code: '', name: '', storehouses: [], scontisticas: [] }
}, },
getCart: (state: IProductsState) => (): ICart => { getCart: (state: IProductsState) => (): ICart => {
@@ -106,17 +106,20 @@ export const useProducts = defineStore('Products', {
getSumQtyOrderProductInOrdersCart: (state: IProductsState) => (idproduct: string): number => { getSumQtyOrderProductInOrdersCart: (state: IProductsState) => (idproduct: string): number => {
let totalQuantity = 0; let totalQuantity = 0;
if (state.orders) { if (state.orders) {
const orderscart = state.orders const orderscart = state.orders
if (orderscart) { if (orderscart) {
for (const myord of orderscart) { for (const myord of orderscart) {
myord.items?.forEach((item: IBaseOrder) => { if (myord.items) {
if (item.order) { for (const item of myord.items) {
if (item.order.idProduct === idproduct) { if (item.order) {
totalQuantity += item.order.quantity || 0; if (item.order.idProduct === idproduct) {
totalQuantity += item.order.quantity || 0;
}
} }
} }
}); }
} }
} }
} }
@@ -124,6 +127,7 @@ export const useProducts = defineStore('Products', {
}, },
getOrdersCartByIdProduct: (state: IProductsState) => (idproduct: string): IOrderCart[] | [] => { getOrdersCartByIdProduct: (state: IProductsState) => (idproduct: string): IOrderCart[] | [] => {
console.log('getOrdersCartByIdProduct')
// console.log('.cart.items', this.cart.items) // console.log('.cart.items', this.cart.items)
try { try {
if (state.orders) { if (state.orders) {
@@ -133,6 +137,7 @@ export const useProducts = defineStore('Products', {
return item.order.idProduct === idproduct return item.order.idProduct === idproduct
}) })
}) })
console.log('Ordini ', ris)
return ris ? ris : [] return ris ? ris : []
} }
} catch (e) { } catch (e) {
@@ -141,6 +146,17 @@ export const useProducts = defineStore('Products', {
return [] return []
}, },
updateQuantityAvailable: (state: IProductsState) => (id: string): any => {
const indelem = state.products.findIndex((prod: IProduct) => prod._id === id)
if (indelem >= 0) {
state.products[indelem].quantityAvailable = state.products[indelem].stockQty
if (state.products[indelem].QuantitaOrdinateInAttesa! > 0) {
state.products[indelem].quantityAvailable! -= state.products[indelem].QuantitaOrdinateInAttesa!
}
}
},
getRecordEmpty: (state: IProductsState) => (): IProduct => { getRecordEmpty: (state: IProductsState) => (): IProduct => {
const tomorrow = tools.getDateNow() const tomorrow = tools.getDateNow()