- edit campi prodotti
- edit ordini
This commit is contained in:
@@ -7,6 +7,7 @@ import { useQuasar } from 'quasar'
|
||||
import { CTitleBanner } from '../CTitleBanner'
|
||||
import { CCardState } from '../CCardState'
|
||||
import { CCopyBtn } from '../CCopyBtn'
|
||||
import { CMyValueDb } from '../CMyValueDb'
|
||||
|
||||
import { func_tools, toolsext } from '@store/Modules/toolsext'
|
||||
|
||||
@@ -17,6 +18,7 @@ import { useProducts } from '@store/Products'
|
||||
import { shared_consts } from '@src/common/shared_vuejs'
|
||||
import { useRouter } from 'vue-router'
|
||||
|
||||
import { costanti } from '@costanti'
|
||||
export default defineComponent({
|
||||
name: 'CProductCard',
|
||||
props: {
|
||||
@@ -41,7 +43,7 @@ export default defineComponent({
|
||||
default: false,
|
||||
},
|
||||
},
|
||||
components: { CTitleBanner, CCardState, CCopyBtn },
|
||||
components: { CTitleBanner, CCardState, CCopyBtn, CMyValueDb },
|
||||
setup(props, { emit }) {
|
||||
const $q = useQuasar()
|
||||
const { t } = useI18n()
|
||||
@@ -51,6 +53,7 @@ export default defineComponent({
|
||||
|
||||
const listord = ref(<IOrderCart[]>[])
|
||||
const sumval = ref(0)
|
||||
const editOn = ref(false)
|
||||
|
||||
const site = ref(globalStore.site)
|
||||
|
||||
@@ -93,6 +96,13 @@ export default defineComponent({
|
||||
return globalStore.getTableJoinByName(item.table, addall, addnone, item.filter)
|
||||
})
|
||||
|
||||
|
||||
watch(() => editOn.value, (to: any, from: any) => {
|
||||
if (!editOn.value)
|
||||
ricarica()
|
||||
})
|
||||
|
||||
|
||||
/*const myproduct = computed((): IProduct => {
|
||||
console.log('getproduct computed')
|
||||
const ris = products.getProduct(props.code)
|
||||
@@ -180,6 +190,30 @@ export default defineComponent({
|
||||
// products.updateQuantityAvailable(myproduct.value._id)
|
||||
}
|
||||
|
||||
async function ricarica() {
|
||||
endload.value = false
|
||||
const prod = await products.loadProductById(myproduct.value._id)
|
||||
if (prod) {
|
||||
myproduct.value = prod
|
||||
}
|
||||
load()
|
||||
endload.value = true
|
||||
|
||||
}
|
||||
|
||||
function updateproductmodif() {
|
||||
|
||||
try {
|
||||
myproduct.value = products.getProductById(props.id)
|
||||
|
||||
recgasordineSelected.value = myproduct.value.gasordines.find((rec: any) => rec._id === gasordineSelected.value)
|
||||
|
||||
updateLabel()
|
||||
} catch (e) {
|
||||
console.error('err', e)
|
||||
}
|
||||
}
|
||||
|
||||
function getStorehouses() {
|
||||
if (!myproduct.value)
|
||||
return []
|
||||
@@ -223,7 +257,7 @@ export default defineComponent({
|
||||
|
||||
function checkifCartDisable() {
|
||||
// return !myorder.idStorehouse
|
||||
return false
|
||||
return isOrdineChiuso()
|
||||
}
|
||||
|
||||
function getQtyWarn() {
|
||||
@@ -288,6 +322,11 @@ export default defineComponent({
|
||||
timerLabelScadenza.value = ''
|
||||
}
|
||||
|
||||
function isOrdineChiuso() {
|
||||
return recgasordineSelected.value && recgasordineSelected.value.dataora_chiusura_ordini &&
|
||||
tools.getCountDown(recgasordineSelected.value.dataora_chiusura_ordini) === ''
|
||||
}
|
||||
|
||||
function startTimer() {
|
||||
// Update the timer label every second
|
||||
timerInterval.value = setInterval(() => updateTimerLabel(), 1000);
|
||||
@@ -350,7 +389,7 @@ export default defineComponent({
|
||||
openlistorders.value = true
|
||||
sumval.value = products.getSumQtyOrderProductInOrdersCart(myproduct.value._id)
|
||||
|
||||
listord.value = arrordersCart.value.filter((ordercart: IOrderCart) => ordercart.items!.reduce((accumulator, item) => {
|
||||
listord.value = arrordersCart.value.filter((orderscart: IOrderCart) => orderscart.items!.reduce((accumulator, item) => {
|
||||
return accumulator + item.order.quantity
|
||||
}, 0))
|
||||
}
|
||||
@@ -359,7 +398,7 @@ export default defineComponent({
|
||||
openlistorders.value = true
|
||||
sumval.value = products.getSumQtyPreOrderInOrdersCart(myproduct.value._id)
|
||||
|
||||
listord.value = arrordersCart.value.filter((ordercart: IOrderCart) => ordercart.items!.reduce((accumulator, item) => {
|
||||
listord.value = arrordersCart.value.filter((orderscart: IOrderCart) => orderscart.items!.reduce((accumulator, item) => {
|
||||
return accumulator + item.order.quantitypreordered
|
||||
}, 0))
|
||||
}
|
||||
@@ -460,6 +499,13 @@ export default defineComponent({
|
||||
onTouchEnd,
|
||||
$router,
|
||||
naviga,
|
||||
globalStore,
|
||||
editOn,
|
||||
costanti,
|
||||
updateproduct,
|
||||
updateproductmodif,
|
||||
isOrdineChiuso,
|
||||
ricarica,
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user