possibilità di modificare un ordine, e anche i totali
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { defineComponent, onMounted, ref, computed } from 'vue'
|
||||
import { defineComponent, onMounted, ref, computed, watch } from 'vue'
|
||||
import { tools } from '@store/Modules/tools'
|
||||
import { useUserStore } from '@store/UserStore'
|
||||
import { useRouter } from 'vue-router'
|
||||
@@ -15,6 +15,7 @@ import { shared_consts } from '@src/common/shared_vuejs'
|
||||
import { CSingleCart } from '../CSingleCart'
|
||||
import { CTitleBanner } from '@components'
|
||||
|
||||
|
||||
export default defineComponent({
|
||||
name: 'COrdersCart',
|
||||
props: {
|
||||
@@ -46,6 +47,17 @@ export default defineComponent({
|
||||
const recOrderCart = ref(<IOrderCart>{})
|
||||
|
||||
const search = ref('')
|
||||
const editOn = ref(false)
|
||||
|
||||
const allTotalPrice = ref(<number | undefined>undefined);
|
||||
|
||||
watch(allTotalPrice, (newValue: any) => {
|
||||
if (!newValue)
|
||||
recOrderCart.value.totalPrice = 0
|
||||
else
|
||||
recOrderCart.value.totalPrice = parseFloat(newValue);
|
||||
});
|
||||
|
||||
|
||||
const statusnow = computed(() => (): number => {
|
||||
if (recOrderCart.value) {
|
||||
@@ -57,6 +69,8 @@ export default defineComponent({
|
||||
function mounted() {
|
||||
// Inizializza
|
||||
load()
|
||||
|
||||
allTotalPrice.value = recOrderCart.value.totalPrice
|
||||
}
|
||||
|
||||
function getItems(): IBaseOrder[] | [] {
|
||||
@@ -93,6 +107,14 @@ export default defineComponent({
|
||||
}
|
||||
}
|
||||
|
||||
function myTotalPriceCalc(): string {
|
||||
if (recOrderCart.value) {
|
||||
return recOrderCart.value.totalPriceCalc ? recOrderCart.value.totalPriceCalc.toFixed(2) : ''
|
||||
} else {
|
||||
return '0'
|
||||
}
|
||||
}
|
||||
|
||||
function myTotalQty(): number {
|
||||
if (recOrderCart.value) {
|
||||
return recOrderCart.value.totalQty
|
||||
@@ -108,6 +130,7 @@ export default defineComponent({
|
||||
oldrec.value = myrec.value
|
||||
note.value = recOrderCart.value.note!
|
||||
}
|
||||
allTotalPrice.value = recOrderCart.value.totalPrice
|
||||
endload.value = true
|
||||
}
|
||||
|
||||
@@ -172,7 +195,7 @@ export default defineComponent({
|
||||
if (myprod && myprod.active) {
|
||||
let myorder: IOrder = {
|
||||
quantity: 1, quantitypreordered: 0,
|
||||
TotalPriceProduct: 0, price: 0,
|
||||
TotalPriceProduct: 0, TotalPriceProductCalc: 0, price: 0,
|
||||
idStorehouse: getActualIdStorehouse(myprod),
|
||||
idGasordine: getActualGasordine(myprod),
|
||||
}
|
||||
@@ -182,8 +205,9 @@ export default defineComponent({
|
||||
}
|
||||
}
|
||||
|
||||
function updateOrdersCart(paramstoupdate: any) {
|
||||
productStore.updateOrdersCartById(props.idOrdersCart, paramstoupdate)
|
||||
async function updateOrdersCart(paramstoupdate: any) {
|
||||
await productStore.updateOrdersCartById(props.idOrdersCart, paramstoupdate)
|
||||
|
||||
}
|
||||
|
||||
function ordersUpdated() {
|
||||
@@ -191,6 +215,17 @@ export default defineComponent({
|
||||
load()
|
||||
}
|
||||
|
||||
function changeTotalPrice() {
|
||||
|
||||
|
||||
change_field('totalPrice')
|
||||
}
|
||||
|
||||
function updateTotalPrice() {
|
||||
updateOrdersCart({totalPrice: allTotalPrice.value})
|
||||
}
|
||||
|
||||
|
||||
|
||||
onMounted(mounted)
|
||||
|
||||
@@ -214,6 +249,11 @@ export default defineComponent({
|
||||
updateOrdersCart,
|
||||
ordersUpdated,
|
||||
t,
|
||||
editOn,
|
||||
allTotalPrice,
|
||||
changeTotalPrice,
|
||||
updateTotalPrice,
|
||||
myTotalPriceCalc,
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user