From 1ce6d765ee451f455d58a55fd9e5688b5e2ec8e7 Mon Sep 17 00:00:00 2001 From: Surya Paolo Date: Sun, 10 Dec 2023 15:15:27 +0100 Subject: [PATCH] aggiornamento product --- src/components/CMyCart/CMyCart.ts | 4 +- src/components/CMyCart/CMyCart.vue | 2 +- src/components/CProductCard/CProductCard.ts | 186 ++++++++++-------- src/components/CProductCard/CProductCard.vue | 13 +- .../CUserNonVerif/CUserNonVerif.vue | 2 +- src/statics/lang/it.js | 1 + src/store/Modules/tools.ts | 2 +- src/views/ecommerce/checkOut/checkOut.vue | 4 +- src/views/ecommerce/orderInfo/orderInfo.ts | 62 +++++- src/views/ecommerce/orderInfo/orderInfo.vue | 1 - 10 files changed, 169 insertions(+), 108 deletions(-) diff --git a/src/components/CMyCart/CMyCart.ts b/src/components/CMyCart/CMyCart.ts index 5accf7c1..19e9dd37 100755 --- a/src/components/CMyCart/CMyCart.ts +++ b/src/components/CMyCart/CMyCart.ts @@ -39,8 +39,8 @@ export default defineComponent({ }) const numOrders = computed(() => { - if (!!products.cart) { - return products.cart.items!.length + if (!!products.cart && products.cart.items) { + return products.cart.items.length } else { return 0 } diff --git a/src/components/CMyCart/CMyCart.vue b/src/components/CMyCart/CMyCart.vue index b2c41836..13b77aae 100755 --- a/src/components/CMyCart/CMyCart.vue +++ b/src/components/CMyCart/CMyCart.vue @@ -30,7 +30,7 @@
diff --git a/src/components/CProductCard/CProductCard.ts b/src/components/CProductCard/CProductCard.ts index 4f80e0d2..80b9b6a3 100755 --- a/src/components/CProductCard/CProductCard.ts +++ b/src/components/CProductCard/CProductCard.ts @@ -1,4 +1,4 @@ -import { defineComponent, ref, toRef, computed, PropType, watch } from 'vue' +import { defineComponent, ref, toRef, computed, PropType, watch, onMounted } from 'vue' import { useI18n } from '@src/boot/i18n' import { useUserStore } from '@store/UserStore' import { useGlobalStore } from '@store/globalStore' @@ -42,7 +42,7 @@ export default defineComponent({ const myorder = ref({ idapp: process.env.APP_ID, - quantity: 1, + quantity: 0, idStorehouse: '' }) @@ -50,6 +50,12 @@ export default defineComponent({ const storeSelected = ref('') + const valoriopt = computed(() => (item: any, addall: boolean, addnone: boolean) => { + // console.log('valoriopt', item.table) + return globalStore.getTableJoinByName(item.table, addall, addnone, item.filter) + }) + + function iconWhishlist(order: IProduct) { if (true) { return 'far fa-heart' @@ -98,105 +104,111 @@ export default defineComponent({ else tools.showPositiveNotif($q, msg) - }) + }) } -function getnumstore() { - if (myproduct.value.storehouses) - return myproduct.value.storehouses.length - else - return 0 -} + function getnumstore() { + if (myproduct.value.storehouses) + return myproduct.value.storehouses.length + else + return 0 + } -function getSingleStorehouse() { - const mystore = myproduct.value.storehouses[0] - if (mystore) - return mystore.name + ' (' + mystore.city + ')' - else - return '' -} + function getSingleStorehouse() { + const mystore = myproduct.value.storehouses[0] + if (mystore) + return mystore.name + ' (' + mystore.city + ')' + else + return '' + } -function getStorehouses() { + function getStorehouses() { - const myarr: any = [] - let ind = 1 - myproduct.value.storehouses.forEach((store) => { - myarr.push( - { - id: ind, - label: store.name + ' (' + store.city + ')', - value: store._id + const myarr: any = [] + let ind = 1 + myproduct.value.storehouses.forEach((store) => { + myarr.push( + { + id: ind, + label: store.name + ' (' + store.city + ')', + value: store._id + }) + + ind++ }) - ind++ - }) + // console.log('arraystore', myarr) + return myarr + } - // console.log('arraystore', myarr) - return myarr -} + function checkifCartDisable() { + return !myorder.value.idStorehouse + } -function checkifCartDisable() { - return !myorder.value.idStorehouse -} + watch(() => props.code, (newval, oldval) => { + console.log('change code') + load() + }) -watch(() => props.code, (newval, oldval) => { - console.log('change code') - load() -}) + watch(() => storeSelected.value, (newval, oldval) => { + myorder.value.idStorehouse = newval + }) -watch(() => storeSelected.value, (newval, oldval) => { - myorder.value.idStorehouse = newval -}) + async function load() { + // console.log('created Cproductcard', code) + if (props.code) { + myproduct.value = await products.loadProduct({ code: props.code }) + } else { + // @ts-ignore + myproduct.value = props.product + } -async function load() { - // console.log('created Cproductcard', code) - if (props.code) { - myproduct.value = await products.loadProduct({ code: props.code }) - } else { - // @ts-ignore - myproduct.value = props.product - } + console.log('myproduct', myproduct, 'product', props.product) - console.log('myproduct', myproduct, 'product', props.product) + if (!!myproduct.value) { + if (myproduct.value.storehouses.length === 1) { + myorder.value.idStorehouse = myproduct.value.storehouses[0]._id + } + } - if (!!myproduct.value) { - if (myproduct.value.storehouses.length === 1) { - myorder.value.idStorehouse = myproduct.value.storehouses[0]._id + const ord = products.getOrderProductInCart(myproduct.value._id) + if (ord) { + myorder.value.quantity = ord.quantity + } + + } + + function getmycardcl() { + return (props.complete) ? 'my-card-big' : 'my-card' + } + + function getclimg() { + return (props.complete) ? 'myimgtitle centermydiv' : 'centermydiv' + } + + function enableSubQty() { + return myorder.value ? myorder.value.quantity > 0 : true + } + + onMounted(load) + + return { + decqty, + addqty, + addtoCart, + iconWhishlist, + getmycardcl, + getclimg, + getnumstore, + getSingleStorehouse, + getStorehouses, + checkifCartDisable, + myproduct, + myorder, + tools, + t, + storeSelected, + enableSubQty, } } -} - -function getmycardcl() { - return (props.complete) ? 'my-card-big' : 'my-card' -} - -function getclimg() { - return (props.complete) ? 'myimgtitle centermydiv' : 'centermydiv' -} - -function enableSubQty() { - return myorder.value ? myorder.value.quantity > 0 : true -} - -load() - -return { - decqty, - addqty, - addtoCart, - iconWhishlist, - getmycardcl, - getclimg, - getnumstore, - getSingleStorehouse, - getStorehouses, - checkifCartDisable, - myproduct, - myorder, - tools, - t, - storeSelected, - enableSubQty, -} - } }) diff --git a/src/components/CProductCard/CProductCard.vue b/src/components/CProductCard/CProductCard.vue index bf76c7c4..82378323 100755 --- a/src/components/CProductCard/CProductCard.vue +++ b/src/components/CProductCard/CProductCard.vue @@ -1,7 +1,5 @@ diff --git a/src/views/ecommerce/orderInfo/orderInfo.ts b/src/views/ecommerce/orderInfo/orderInfo.ts index 0accd4a0..71609f14 100755 --- a/src/views/ecommerce/orderInfo/orderInfo.ts +++ b/src/views/ecommerce/orderInfo/orderInfo.ts @@ -38,6 +38,47 @@ export default defineComponent({ const statusnow = ref(0) const arrnumstatus = ref([]) const columns = ref([ + { + name: 'numorder', + required: true, + align: 'left', + label: 'Numero Ordine', + field: 'numorder', + sortable: true + }, + { + name: 'created_at', + required: true, + align: 'center', + label: 'Effettuato il', + field: 'created_at', + sortable: true + }, + { + name: 'items', + required: true, + label: 'Articoli', + field: 'items', + sortable: true + }, + { + name: 'totalPrice', + required: true, + label: 'Totale', + field: 'totalPrice', + sortable: true + }, + { + name: 'status', + align: 'center', + required: true, + label: 'Stato', + field: 'status', + sortable: true + } + ]) + + const columns_Admin = ref([ { name: 'numorder', required: true, @@ -83,6 +124,14 @@ export default defineComponent({ label: 'Stato', field: 'status', sortable: true + }, + { + name: 'comandi', + align: 'center', + required: false, + label: 'Comandi', + field: 'comandi', + sortable: false } ]) @@ -124,16 +173,9 @@ export default defineComponent({ console.log('arrnumstatus;') console.log(arrnumstatus.value) - columns.value = [...columns.value, - { - name: 'comandi', - align: 'center', - required: false, - label: 'Comandi', - field: 'comandi', - sortable: false - }] - + if (tools.isManager()) { + columns.value = [...columns_Admin.value] + } } function CanBeShipped() { diff --git a/src/views/ecommerce/orderInfo/orderInfo.vue b/src/views/ecommerce/orderInfo/orderInfo.vue index 5118b9d4..dcde9edf 100755 --- a/src/views/ecommerce/orderInfo/orderInfo.vue +++ b/src/views/ecommerce/orderInfo/orderInfo.vue @@ -125,7 +125,6 @@ }} - Bottone: