aggiornamento Ordini GAS filtri
This commit is contained in:
@@ -36,6 +36,8 @@ export default defineComponent({
|
||||
|
||||
const cosa = ref(0)
|
||||
|
||||
const arrout = ref(<any[]>[])
|
||||
|
||||
const initialPagination = ref({
|
||||
sortBy: 'desc',
|
||||
descending: false,
|
||||
@@ -47,6 +49,8 @@ export default defineComponent({
|
||||
const conferma_ordine = ref(false)
|
||||
const endload = ref(false)
|
||||
|
||||
const storeGasordine = ref(<any>'')
|
||||
|
||||
const taborders = ref(shared_consts.OrderStat.IN_CORSO.value)
|
||||
const statusnow = ref(0)
|
||||
const arrnumstatus = ref(<any[]>[])
|
||||
@@ -165,7 +169,16 @@ export default defineComponent({
|
||||
])
|
||||
|
||||
watch(() => cosa.value, (newval, oldval) => {
|
||||
updateorders(true)
|
||||
})
|
||||
|
||||
watch(() => taborders.value, (newval, oldval) => {
|
||||
updateorders(false)
|
||||
})
|
||||
|
||||
watch(() => storeGasordine.value, (newval, oldval) => {
|
||||
tools.setCookie(tools.COOK_SELGAS, storeGasordine.value)
|
||||
updateorders(true)
|
||||
})
|
||||
|
||||
// const { setValDb, getValDb } = MixinBase()
|
||||
@@ -176,7 +189,7 @@ export default defineComponent({
|
||||
|
||||
function getOrdersCart(): IOrderCart[] | undefined {
|
||||
const hasGasordine: any = (cosa.value === shared_consts.PROD.TUTTI) ? undefined : (cosa.value === shared_consts.PROD.GAS)
|
||||
const ris = productStore.getOrdersCart(taborders.value, hasGasordine)
|
||||
const ris = productStore.getOrdersCart(taborders.value, hasGasordine, storeGasordine.value)
|
||||
|
||||
return ris
|
||||
}
|
||||
@@ -184,7 +197,7 @@ export default defineComponent({
|
||||
function getOrdersCartWithTotals(): any[] {
|
||||
const orderscart = getOrdersCart();
|
||||
|
||||
if (orderscart) {
|
||||
if (orderscart && taborders.value > 0) {
|
||||
// Calculate totals
|
||||
const totals = {
|
||||
created_at: new Date(),
|
||||
@@ -216,10 +229,12 @@ export default defineComponent({
|
||||
}
|
||||
|
||||
function getAllOrdersCart() {
|
||||
return productStore.getOrdersAllCart()
|
||||
return productStore.getOrdersAllCart(storeGasordine.value)
|
||||
}
|
||||
|
||||
function updateorders() {
|
||||
function updateorders(updatetab: boolean) {
|
||||
arrout.value = []
|
||||
|
||||
myorderscart.value = getOrdersCart()
|
||||
if (myorderscart.value) {
|
||||
for (const orderscart of myorderscart.value) {
|
||||
@@ -227,19 +242,22 @@ export default defineComponent({
|
||||
}
|
||||
}
|
||||
|
||||
const allorders = getAllOrdersCart()
|
||||
for (const status of [15, 2, 3, 4, 5, 6, 7, 8, 10]) {
|
||||
arrnumstatus.value[status] = allorders.filter((rec) => (rec.status === status)).reduce((sum, item) => sum + 1, 0)
|
||||
if (updatetab) {
|
||||
const allorders = getAllOrdersCart()
|
||||
for (const status of [15, 2, 3, 4, 5, 6, 7, 8, 10]) {
|
||||
arrnumstatus.value[status] = allorders.filter((rec) => (rec.status === status)).reduce((sum, item) => sum + 1, 0)
|
||||
}
|
||||
|
||||
selectfirstavailable()
|
||||
}
|
||||
|
||||
selectfirstavailable()
|
||||
|
||||
|
||||
arrout.value = getOrdersCartWithTotals()
|
||||
|
||||
}
|
||||
|
||||
function selectfirstavailable() {
|
||||
|
||||
taborders.value = -1
|
||||
Object.keys(arrnumstatus.value).forEach((stat: any) => {
|
||||
if (arrnumstatus.value[stat] > 0) {
|
||||
if (taborders.value === -1)
|
||||
@@ -250,12 +268,14 @@ export default defineComponent({
|
||||
|
||||
async function mounted() {
|
||||
|
||||
taborders.value = -1
|
||||
storeGasordine.value = tools.getCookie(tools.COOK_SELGAS, '')
|
||||
|
||||
await userStore.newsletterload(false)
|
||||
await productStore.loadProducts()
|
||||
|
||||
taborders.value = -1
|
||||
|
||||
updateorders()
|
||||
updateorders(true)
|
||||
|
||||
if (taborders.value === -1)
|
||||
taborders.value = shared_consts.OrderStat.IN_CORSO.value
|
||||
@@ -328,7 +348,7 @@ export default defineComponent({
|
||||
|
||||
if (statusnow.value === status) {
|
||||
order.status = statusnow.value
|
||||
updateorders()
|
||||
updateorders(true)
|
||||
tools.showPositiveNotif($q, 'Ordine ' + statusStr)
|
||||
}
|
||||
// change_field('status')
|
||||
@@ -398,6 +418,8 @@ export default defineComponent({
|
||||
sendMailTest,
|
||||
templemail,
|
||||
fieldsTable,
|
||||
storeGasordine,
|
||||
arrout,
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user