aggiornamento...
This commit is contained in:
@@ -57,15 +57,19 @@ export default defineComponent({
|
||||
|
||||
const openlistorders = ref(false)
|
||||
const endload = ref(false)
|
||||
const myproduct = ref(<IProduct>{})
|
||||
|
||||
const valoriopt = computed(() => (item: any, addall: boolean, addnone: boolean) => {
|
||||
// console.log('valoriopt', item.table)
|
||||
return globalStore.getTableJoinByName(item.table, addall, addnone, item.filter)
|
||||
})
|
||||
|
||||
const myproduct = computed((): IProduct => {
|
||||
return products.getProduct(props.code)
|
||||
})
|
||||
/*const myproduct = computed((): IProduct => {
|
||||
console.log('getproduct computed')
|
||||
const ris = products.getProduct(props.code)
|
||||
console.log(' received', ris)
|
||||
return ris
|
||||
})*/
|
||||
|
||||
|
||||
function iconWhishlist(order: IProduct) {
|
||||
@@ -103,6 +107,8 @@ export default defineComponent({
|
||||
|
||||
}
|
||||
|
||||
updateproduct()
|
||||
|
||||
if (ris === null || myorder.quantity === 0)
|
||||
tools.showNotif($q, msg)
|
||||
else
|
||||
@@ -130,6 +136,10 @@ export default defineComponent({
|
||||
}
|
||||
}
|
||||
|
||||
function updateproduct() {
|
||||
myproduct.value = products.getProduct(props.code)
|
||||
}
|
||||
|
||||
function getStorehouses() {
|
||||
|
||||
const myarr: any = []
|
||||
@@ -154,15 +164,8 @@ export default defineComponent({
|
||||
return false
|
||||
}
|
||||
|
||||
function updateQtyAvailable() {
|
||||
myproduct.value.quantityAvailable = myproduct.value.stockQty
|
||||
if (myproduct.value.QuantitaOrdinateInAttesa! > 0) {
|
||||
myproduct.value.quantityAvailable! -= myproduct.value.QuantitaOrdinateInAttesa!
|
||||
}
|
||||
}
|
||||
|
||||
function getQtyAvailable() {
|
||||
updateQtyAvailable()
|
||||
products.updateQuantityAvailable(myproduct.value._id)
|
||||
let qty = myproduct.value.quantityAvailable!
|
||||
return qty
|
||||
}
|
||||
@@ -184,6 +187,8 @@ export default defineComponent({
|
||||
})
|
||||
|
||||
function load() {
|
||||
updateproduct()
|
||||
console.log('Load', myproduct.value.name)
|
||||
// console.log('created Cproductcard', code)
|
||||
|
||||
arrordersCart.value = products.getOrdersCartByIdProduct(myproduct.value._id)
|
||||
@@ -199,7 +204,7 @@ export default defineComponent({
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
console.log('°°° ENDLOAD °°°')
|
||||
endload.value = true
|
||||
}
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
myproduct.after_price
|
||||
}}</span>
|
||||
</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
|
||||
class="prod_sconti"
|
||||
v-for="(sconti, index) of myproduct.scontisticas"
|
||||
@@ -60,6 +60,7 @@
|
||||
{{ sconti.description }}
|
||||
</div>
|
||||
</q-item-label>
|
||||
-->
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
</q-list>
|
||||
|
||||
@@ -10,13 +10,14 @@ import { CMyFieldDb } from '@/components/CMyFieldDb'
|
||||
import { useGlobalStore } from '@store/globalStore'
|
||||
import { costanti } from '@costanti'
|
||||
import { tools } from '@src/store/Modules/tools'
|
||||
import { ISites } from '@src/model'
|
||||
|
||||
export default defineComponent({
|
||||
name: 'Confsite',
|
||||
components: { CImgText, CCard, CMyPage, CTitleBanner, CMyFieldRec, CMyFieldDb },
|
||||
setup() {
|
||||
|
||||
const mysite = ref(null)
|
||||
const mysite = ref(<ISites>{})
|
||||
const tab = ref('server')
|
||||
|
||||
const globalStore = useGlobalStore()
|
||||
|
||||
@@ -44,7 +44,7 @@ export const useProducts = defineStore('Products', {
|
||||
|
||||
getProduct: (state: IProductsState) => (code: string): IProduct => {
|
||||
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 => {
|
||||
@@ -106,17 +106,20 @@ export const useProducts = defineStore('Products', {
|
||||
|
||||
getSumQtyOrderProductInOrdersCart: (state: IProductsState) => (idproduct: string): number => {
|
||||
let totalQuantity = 0;
|
||||
|
||||
if (state.orders) {
|
||||
const orderscart = state.orders
|
||||
if (orderscart) {
|
||||
for (const myord of orderscart) {
|
||||
myord.items?.forEach((item: IBaseOrder) => {
|
||||
if (item.order) {
|
||||
if (item.order.idProduct === idproduct) {
|
||||
totalQuantity += item.order.quantity || 0;
|
||||
if (myord.items) {
|
||||
for (const item of myord.items) {
|
||||
if (item.order) {
|
||||
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[] | [] => {
|
||||
console.log('getOrdersCartByIdProduct')
|
||||
// console.log('.cart.items', this.cart.items)
|
||||
try {
|
||||
if (state.orders) {
|
||||
@@ -133,6 +137,7 @@ export const useProducts = defineStore('Products', {
|
||||
return item.order.idProduct === idproduct
|
||||
})
|
||||
})
|
||||
console.log('Ordini ', ris)
|
||||
return ris ? ris : []
|
||||
}
|
||||
} catch (e) {
|
||||
@@ -141,6 +146,17 @@ export const useProducts = defineStore('Products', {
|
||||
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 => {
|
||||
|
||||
const tomorrow = tools.getDateNow()
|
||||
|
||||
Reference in New Issue
Block a user