Corretto incongruenze OrdersCart
This commit is contained in:
@@ -10,7 +10,7 @@ import { CCopyBtn } from '../CCopyBtn'
|
||||
|
||||
import { func_tools, toolsext } from '@store/Modules/toolsext'
|
||||
|
||||
import { IOrder, IOrderCart, IProduct } from '@src/model'
|
||||
import { IBaseOrder, IOrder, IOrderCart, IProduct } from '@src/model'
|
||||
import { tools } from '@store/Modules/tools'
|
||||
import { useProducts } from '@store/Products'
|
||||
|
||||
@@ -43,11 +43,15 @@ export default defineComponent({
|
||||
const globalStore = useGlobalStore()
|
||||
const products = useProducts()
|
||||
|
||||
const listord = ref(<IOrderCart[]>[])
|
||||
const sumval = ref(0)
|
||||
|
||||
const site = ref(globalStore.site)
|
||||
|
||||
const myorder = reactive(<IOrder>{
|
||||
idapp: process.env.APP_ID,
|
||||
quantity: 0,
|
||||
quantitypreordered: 0,
|
||||
idStorehouse: '',
|
||||
idProvider: ''
|
||||
})
|
||||
@@ -87,7 +91,11 @@ export default defineComponent({
|
||||
return false
|
||||
}
|
||||
|
||||
await products.addtoCartBase({ $q, t, code: myproduct.value.code!, order: myorder, addqty: add })
|
||||
const ris = await products.addtoCartBase({ $q, t, code: myproduct.value.code!, order: myorder, addqty: add })
|
||||
updateproduct()
|
||||
if (ris && ris.myord) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function getnumstore() {
|
||||
@@ -214,16 +222,36 @@ export default defineComponent({
|
||||
|
||||
function enableAddQty() {
|
||||
if (site.value.ecomm && site.value.ecomm.enablePreOrders) {
|
||||
return true
|
||||
return getQtyBookableAvailable() > 0 || getQtyAvailable() > 0
|
||||
} else {
|
||||
return getQtyAvailable() > 0
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function visuListDisponibili() {
|
||||
openlistorders.value = true
|
||||
sumval.value = products.getSumQtyOrderProductInOrdersCart(myproduct.value._id)
|
||||
|
||||
listord.value = arrordersCart.value.filter((ordercart: IOrderCart) => ordercart.items!.reduce((accumulator, item) => {
|
||||
return accumulator + item.order.quantity
|
||||
}, 0))
|
||||
}
|
||||
|
||||
function visuListBookable() {
|
||||
openlistorders.value = true
|
||||
sumval.value = products.getSumQtyPreOrderInOrdersCart(myproduct.value._id)
|
||||
|
||||
listord.value = arrordersCart.value.filter((ordercart: IOrderCart) => ordercart.items!.reduce((accumulator, item) => {
|
||||
return accumulator + item.order.quantitypreordered
|
||||
}, 0))
|
||||
}
|
||||
|
||||
onMounted(load)
|
||||
|
||||
return {
|
||||
visuListDisponibili,
|
||||
visuListBookable,
|
||||
addtoCart,
|
||||
iconWhishlist,
|
||||
getmycardcl,
|
||||
@@ -251,6 +279,8 @@ export default defineComponent({
|
||||
site,
|
||||
getQtyWarnPreOrdered,
|
||||
getQtyBookableAvailable,
|
||||
listord,
|
||||
sumval,
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -109,12 +109,12 @@
|
||||
<q-list>
|
||||
<q-item
|
||||
:clickable="tools.isManager()"
|
||||
@click="tools.isManager() ? (openlistorders = true) : null"
|
||||
@click="tools.isManager() ? (visuListDisponibili()) : null"
|
||||
>
|
||||
<q-item-section avatar>
|
||||
<q-icon
|
||||
:color="getQtyAvailable() >= 0 ? 'green' : 'blue'"
|
||||
:name="getQtyAvailable() >= 0 ? 'fas fa-store' : 'fas fa-edit'"
|
||||
color="green"
|
||||
name="fas fa-store"
|
||||
/>
|
||||
</q-item-section>
|
||||
|
||||
@@ -146,9 +146,9 @@
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
<q-item
|
||||
v-if="getQtyBookableAvailable() > 0"
|
||||
v-if="getQtyBookableAvailable() > 0 || (myproduct.bookableQty > 0)"
|
||||
:clickable="tools.isManager()"
|
||||
@click="tools.isManager() ? (openlistorders = true) : null"
|
||||
@click="tools.isManager() ? (visuListBookable()) : null"
|
||||
>
|
||||
<q-item-section avatar>
|
||||
<q-icon color="blue" name="fas fa-edit" />
|
||||
@@ -210,7 +210,6 @@
|
||||
class="self-center no-outline"
|
||||
tabindex="0"
|
||||
>
|
||||
Preord.: {{ myorder.quantitypreordered }}
|
||||
</div>
|
||||
</template>
|
||||
</q-field>
|
||||
@@ -298,7 +297,7 @@
|
||||
|
||||
<tbody>
|
||||
<tr
|
||||
v-for="(ordcart, index) of arrordersCart"
|
||||
v-for="(ordcart, index) of listord"
|
||||
:key="index"
|
||||
class="listaev listaev__table"
|
||||
>
|
||||
@@ -347,7 +346,7 @@
|
||||
<td class="text-center">
|
||||
Totali:
|
||||
<span class="totali">{{
|
||||
products.getSumQtyOrderProductInOrdersCart(myproduct._id)
|
||||
sumval
|
||||
}}</span>
|
||||
</td>
|
||||
<td> </td>
|
||||
|
||||
Reference in New Issue
Block a user