- corretto cancellazione ordine

This commit is contained in:
Surya Paolo
2024-02-15 18:59:13 +01:00
parent c6e0caa3f4
commit a82e07b4ce
5 changed files with 58 additions and 8 deletions

View File

@@ -3,7 +3,6 @@
v-if="order && order.product && order.product.productInfo" v-if="order && order.product && order.product.productInfo"
class="q-pa-xs q-gutter-xs" class="q-pa-xs q-gutter-xs"
> >
order: {{order}}
<div v-if="order.product"> <div v-if="order.product">
<q-item> <q-item>
<q-item-section top thumbnail class="q-ml-none"> <q-item-section top thumbnail class="q-ml-none">
@@ -26,7 +25,7 @@
</div> </div>
{{ order.product.productInfo.name }} {{ order.product.productInfo.name }}
</q-item-label> </q-item-label>
<q-item-label caption> <q-item-label caption>
<div <div
class="text-black text-h8" class="text-black text-h8"
@@ -65,7 +64,16 @@
</div> </div>
<div class="row q-mb-xs no-wrap items-center centeritems"> <div class="row q-mb-xs no-wrap items-center centeritems">
<q-btn <q-btn
v-if="showall && !nomodif" v-if="showall && !nomodif && products.CanDeleteIfSub(order)"
icon="fas fa-trash"
color="negative"
round
size="xs"
@click="removeFromCard"
>
</q-btn>
<q-btn
v-else-if="showall && !nomodif"
:disable="!products.enableSubQty(order)" :disable="!products.enableSubQty(order)"
size="sm" size="sm"
icon="fas fa-cart-arrow-down" icon="fas fa-cart-arrow-down"
@@ -123,7 +131,7 @@
updateOrder({ updateOrder({
quantitypreordered: order.quantitypreordered, quantitypreordered: order.quantitypreordered,
quantity: order.quantity, quantity: order.quantity,
price: order.price, price: order.price,
}) })
" "
> >
@@ -167,7 +175,8 @@
<span <span
v-if=" v-if="
tools.isManager() && tools.isManager() &&
order.TotalPriceProduct.toFixed(2) !== order.TotalPriceProductCalc.toFixed(2) order.TotalPriceProduct.toFixed(2) !==
order.TotalPriceProductCalc.toFixed(2)
" "
:class="isApplicatoSconto() ? 'ordine_scontato_nuovo' : ''" :class="isApplicatoSconto() ? 'ordine_scontato_nuovo' : ''"
> >

View File

@@ -197,7 +197,7 @@ export const useProducts = defineStore('Products', {
getOrdersAllCart: (state: IProductsState) => (idGasordine: string): IOrderCart[] => { getOrdersAllCart: (state: IProductsState) => (idGasordine: string): IOrderCart[] => {
return state.orders.filter((rec: IOrderCart) => { return state.orders.filter((rec: IOrderCart) => {
if ((idGasordine && !rec.items?.some(item => item.order.idGasordine === idGasordine))) { if ((idGasordine && !rec.items?.some(item => item.order && item.order.idGasordine === idGasordine))) {
return false; // Skip records not matching gasordine condition return false; // Skip records not matching gasordine condition
} }
return true return true
@@ -210,11 +210,11 @@ export const useProducts = defineStore('Products', {
getOrdersCart: (state: IProductsState) => (tipoord: number, hasGasordine: any, idGasordine: string): IOrderCart[] | undefined => { getOrdersCart: (state: IProductsState) => (tipoord: number, hasGasordine: any, idGasordine: string): IOrderCart[] | undefined => {
return state.orders.filter((rec: IOrderCart) => { return state.orders.filter((rec: IOrderCart) => {
if (idGasordine && !rec.items?.some(item => item.order.idGasordine === idGasordine)) { if (idGasordine && !rec.items?.some(item => item.order && item.order.idGasordine === idGasordine)) {
return false; // Skip records not matching gasordine condition return false; // Skip records not matching gasordine condition
} }
if (hasGasordine && !rec.items?.some(item => item.order.idGasordine)) { if (hasGasordine && !rec.items?.some(item => item.order && item.order.idGasordine)) {
return false; // Skip records not matching gasordine condition return false; // Skip records not matching gasordine condition
} }
@@ -1013,6 +1013,13 @@ export const useProducts = defineStore('Products', {
return qty ? qty > 0 : false return qty ? qty > 0 : false
}, },
CanDeleteIfSub(myorder: IOrder): boolean {
let qty = myorder.quantity + myorder.quantitypreordered
qty = qty - this.qtaNextSub(myorder, myorder.product!)
return qty === 0
},
enableAddQty(myorder: IOrder, myproduct: IProduct): boolean { enableAddQty(myorder: IOrder, myproduct: IProduct): boolean {
const globalStore = useGlobalStore() const globalStore = useGlobalStore()
if (globalStore.site.ecomm && globalStore.site.ecomm.enablePreOrders) { if (globalStore.site.ecomm && globalStore.site.ecomm.enablePreOrders) {

View File

@@ -650,6 +650,14 @@
></q-btn> ></q-btn>
<br /> <br />
</div> </div>
<div class="row">
<q-btn
label="Remove DeletedOrders InOrderscart"
color="primary"
@click="EseguiFunz('RemoveDeletedOrdersInOrderscart')"
></q-btn>
<br />
</div>
</template> </template>
<script lang="ts" src="./dbop.ts"> <script lang="ts" src="./dbop.ts">
</script> </script>

View File

@@ -55,6 +55,14 @@ export default defineComponent({
const statusnow = ref(0) const statusnow = ref(0)
const arrnumstatus = ref(<any[]>[]) const arrnumstatus = ref(<any[]>[])
const columns = ref(<any>[ const columns = ref(<any>[
{
name: 'ind',
required: true,
align: 'left',
label: 'Ind',
field: 'ind',
sortable: true
},
{ {
name: 'apri', name: 'apri',
align: 'center', align: 'center',
@@ -104,6 +112,14 @@ export default defineComponent({
]) ])
const columns_Admin = ref(<any>[ const columns_Admin = ref(<any>[
{
name: 'ind',
required: true,
align: 'left',
label: 'Ind',
field: 'ind',
sortable: true
},
{ {
name: 'apri', name: 'apri',
align: 'center', align: 'center',
@@ -220,6 +236,11 @@ export default defineComponent({
rowsWithTotals.push(totals); rowsWithTotals.push(totals);
} }
// Supponendo che rowsWithTotals sia il tuo array di record
rowsWithTotals.forEach((record: any, index: number) => {
record.ind = index;
});
return rowsWithTotals; return rowsWithTotals;
} else { } else {
return [] return []

View File

@@ -198,6 +198,11 @@
</template> </template>
<template v-else v-slot:body="props"> <template v-else v-slot:body="props">
<q-tr :props="props"> <q-tr :props="props">
<q-td key="ind" :props="props">
<div class="q-pa-sm">
{{index}}
</div>
</q-td>
<q-td key="apri" :props="props"> <q-td key="apri" :props="props">
<div class="q-pa-sm"> <div class="q-pa-sm">
<q-btn <q-btn