From c8a4be65c1107b4e8f3ac71e14c1b62b70bfe03d Mon Sep 17 00:00:00 2001 From: Surya Paolo Date: Mon, 15 Jan 2024 22:19:33 +0100 Subject: [PATCH] =?UTF-8?q?possibilit=C3=A0=20di=20modificare=20un=20ordin?= =?UTF-8?q?e,=20e=20anche=20i=20totali?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.example.production | 2 +- .env.prod.pcb | 2 +- .env.test.pcb | 2 +- .env.test.risosrv | 2 +- .env.test_riso.pcb | 2 +- src/common/shared_vuejs.ts | 34 ++++---- src/components/CCart/CCart.ts | 2 +- src/components/CMyCircuits/CMyCircuits.ts | 4 +- src/components/COrdersCart/COrdersCart.ts | 48 ++++++++++- src/components/COrdersCart/COrdersCart.vue | 45 ++++++++++- src/components/CSingleCart/CSingleCart.ts | 88 +++++++++++++++++++-- src/components/CSingleCart/CSingleCart.vue | 60 +++++++++++--- src/components/MyHeader/MyHeader.ts | 2 +- src/model/Products.ts | 2 + src/statics/lang/it.js | 5 +- src/store/Api/Inst-Pao.ts | 2 +- src/store/Modules/fieldsTable.ts | 2 + src/store/Modules/tools.ts | 6 +- src/store/Modules/toolsext.ts | 6 +- src/store/Products.ts | 15 ++-- src/store/UserStore.ts | 2 +- src/store/globalStore.ts | 4 +- src/views/admin/dbop/dbop.vue | 5 ++ src/views/ecommerce/orderInfo/orderInfo.ts | 21 ++--- src/views/ecommerce/orderInfo/orderInfo.vue | 46 ++++++----- 25 files changed, 315 insertions(+), 94 deletions(-) diff --git a/.env.example.production b/.env.example.production index d58eb56e..332732e9 100755 --- a/.env.example.production +++ b/.env.example.production @@ -1,4 +1,4 @@ -APP_VERSION="1.0.22" +APP_VERSION="1.0.23" SERVICE_WORKER_FILE="service-worker.js" APP_ID="13" DIRECTORY_LOCAL=newfreeplanet diff --git a/.env.prod.pcb b/.env.prod.pcb index 587891a6..b9ba0995 100644 --- a/.env.prod.pcb +++ b/.env.prod.pcb @@ -1,4 +1,4 @@ -APP_VERSION="1.0.22" +APP_VERSION="1.0.23" SERVICE_WORKER_FILE="service-worker.js" APP_ID="17" DIRECTORY_LOCAL=newfreeplanet diff --git a/.env.test.pcb b/.env.test.pcb index 7f1794e5..78789df3 100755 --- a/.env.test.pcb +++ b/.env.test.pcb @@ -1,4 +1,4 @@ -APP_VERSION="1.0.22" +APP_VERSION="1.0.23" SERVICE_WORKER_FILE="service-worker.js" APP_ID="17" DIRECTORY_LOCAL=newfreeplanet diff --git a/.env.test.risosrv b/.env.test.risosrv index 5e30204f..c06411ad 100755 --- a/.env.test.risosrv +++ b/.env.test.risosrv @@ -1,4 +1,4 @@ -APP_VERSION="1.0.22" +APP_VERSION="1.0.23" SERVICE_WORKER_FILE="service-worker.js" APP_ID="13" DIRECTORY_LOCAL=newfreeplanet diff --git a/.env.test_riso.pcb b/.env.test_riso.pcb index 49f1cbb1..66dd553c 100755 --- a/.env.test_riso.pcb +++ b/.env.test_riso.pcb @@ -1,4 +1,4 @@ -APP_VERSION="1.0.22" +APP_VERSION="1.0.23" SERVICE_WORKER_FILE="service-worker.js" APP_ID="13" DIRECTORY_LOCAL=newfreeplanet diff --git a/src/common/shared_vuejs.ts b/src/common/shared_vuejs.ts index 082a5d71..e2fcab16 100755 --- a/src/common/shared_vuejs.ts +++ b/src/common/shared_vuejs.ts @@ -1066,12 +1066,14 @@ export const shared_consts = { RECEIVED: 7, COMPLETED: 6, CANCELED: 10, + PREPARED: 15, DELETE_REALLY: 20, }, OrderStat: { // IN_CART: { label: 'In Carrello', value: 1 }, //IN_CART IN_CORSO: { label: 'In Corso', value: 2, icon: 'fas fa-tasks', color: 'text-black' }, //CHECKOUT_SENT + PREPARED: { label: 'Preparati', value: 15, icon: 'fas fa-archive', color: 'text-orange' }, CONFERMATI: { label: 'Confermati', value: 3, icon: 'fas fa-calendar', color: 'text-blue' }, //ORDER_CONFIRMED PAGATI: { label: 'Pagati', value: 4, icon: 'money', color: 'text-green' }, //PAYED DELIVERED: { label: 'Consegnato', value: 5, icon: 'fas fa-calendar', color: 'text-blue' }, //DELIVERED @@ -1081,14 +1083,6 @@ export const shared_consts = { CANCELLATI: { label: 'Cancellati', value: 10, icon: 'delete', color: 'text-red' }, //CANCELED }, - OrderStatusView: [ - 2, - 3, - 4, - 6, - 10, - ], - REACTIONS_FIELD: { numseen: 1, @@ -1110,6 +1104,10 @@ export const shared_consts = { label: 'Ordine in Lavorazione', value: 2, }, + { + label: 'Preparato', + value: 15, + }, { label: 'Ordine Confermato', value: 3, @@ -1149,23 +1147,29 @@ export const shared_consts = { color: 'secondary', }, { - label: 'Conferma Ordine Evaso (e aggiorna Qta in Stock)', //ORDER_CONFIRMED + label: '📩 Conferma Ordine Evaso (e aggiorna Qta in Stock)', //ORDER_CONFIRMED value: 3, icon: 'fas fa-calendar-check', color: 'primary', }, + { + label: '📩 Imposta come Consegnato', //DELIVERED + value: 5, + icon: 'fas fa-shipping-fast', + color: 'blue', + }, + { + label: 'Imposta come Preparato', //PREPARED + value: 15, + icon: 'fas fa-archive', + color: 'blue', + }, { label: 'Imposta come Pagato', //PAYED value: 4, icon: 'money', color: 'positive', }, - { - label: 'Imposta come Consegnato', //DELIVERED - value: 5, - icon: 'fas fa-shipping-fast', - color: 'blue', - }, { label: 'Imposta come Spedito', //DELIVERED value: 5, diff --git a/src/components/CCart/CCart.ts b/src/components/CCart/CCart.ts index dae13526..0b8331cf 100755 --- a/src/components/CCart/CCart.ts +++ b/src/components/CCart/CCart.ts @@ -230,7 +230,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), } diff --git a/src/components/CMyCircuits/CMyCircuits.ts b/src/components/CMyCircuits/CMyCircuits.ts index ac8e7338..44bfbc58 100755 --- a/src/components/CMyCircuits/CMyCircuits.ts +++ b/src/components/CMyCircuits/CMyCircuits.ts @@ -130,10 +130,10 @@ export default defineComponent({ async function mounted() { - console.log(' ## INIZIO MOUNT ') + // console.log(' ## INIZIO MOUNT ') username.value = userStore.my.username await loadCircuits() - console.log(' -- FINE MOUNT ') + // console.log(' -- FINE MOUNT ') } function updateValue(val: number) { diff --git a/src/components/COrdersCart/COrdersCart.ts b/src/components/COrdersCart/COrdersCart.ts index 95701261..abf85baf 100755 --- a/src/components/COrdersCart/COrdersCart.ts +++ b/src/components/COrdersCart/COrdersCart.ts @@ -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({}) const search = ref('') + const editOn = ref(false) + + const allTotalPrice = ref(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, } } }) diff --git a/src/components/COrdersCart/COrdersCart.vue b/src/components/COrdersCart/COrdersCart.vue index 39c7ccc3..e7f25471 100755 --- a/src/components/COrdersCart/COrdersCart.vue +++ b/src/components/COrdersCart/COrdersCart.vue @@ -2,6 +2,15 @@
+ +
{{ t('orderscart.numero_ordine') }}: {{ recOrderCart.numorder }}
@@ -26,17 +35,51 @@ :order="itemorder.order" :showall="false" :idOrdersCart="recOrderCart._id" - :editmode="tools.isManager()" + :editmode="editOn" :nomodif="true" @update="ordersUpdated()" />
+ +
+ {{ t('ecomm.calcolato') }}: + € {{ myTotalPriceCalc() }} +
{{ t('ecomm.totale') }}: € {{ myTotalPrice() }}
+
+ + + + +
undefined); + const orderQuantityPreordered = ref(undefined); + const orderTotalPriceProduct = ref(undefined); + + const enableQty = ref(false) + const endload = ref(false) + const enableQtyPreordered = ref(false) + const enableChangeTotalPrice = ref(false) + + watch(orderQuantity, (newValue: any) => { + if (!newValue) + order.value.quantity = 0 + else + order.value.quantity = parseFloat(newValue); + + enableChangeTotalPrice.value = false + }); + + watch(orderQuantityPreordered, (newValue: any) => { + if (!newValue) + order.value.quantitypreordered = 0 + else + order.value.quantitypreordered = parseFloat(newValue); + + enableChangeTotalPrice.value = false + }); + + watch(orderTotalPriceProduct, (newValue: any) => { + if (!newValue) + order.value.TotalPriceProduct = 0 + else + order.value.TotalPriceProduct = parseFloat(newValue); + }); + + watch(() => props.order.TotalPriceProduct, (newValue: any) => { + if (!newValue) + orderTotalPriceProduct.value = 0 + else + orderTotalPriceProduct.value = parseFloat(newValue); + }); + function myimgclass() { if (props.showall) { return 'imgNormal' @@ -102,23 +144,46 @@ export default defineComponent({ } function removeFromCard() { - if (props.idOrdersCart) { - // - } else { - products.removeFromCart({ order: order.value }) - } - + products.removeFromCart({ order: order.value }) + } async function updateOrder(paramstoupdate: any) { - await products.updateOrderByOrder(props.idOrdersCart, order.value._id, paramstoupdate) + endload.value = false + if (enableChangeTotalPrice.value) { + paramstoupdate = { ...paramstoupdate, TotalPriceProduct: order.value.TotalPriceProduct } + } + const myOrdersCart = await products.updateOrderByOrder(props.idOrdersCart, order.value._id, paramstoupdate) emit('update') + mounted() } function getRisparmio(): string { return ((order.value.product!.price * order.value.quantity) - order.value.TotalPriceProduct).toFixed(2) } + function mounted() { + endload.value = false + if (props.order.quantity !== 0) { + orderQuantity.value = props.order.quantity + enableQty.value = true + } + if (props.order.quantitypreordered !== 0) { + orderQuantityPreordered.value = props.order.quantitypreordered + enableQtyPreordered.value = true + } + + orderTotalPriceProduct.value = props.order.TotalPriceProduct + endload.value = true + } + + function changeTotalPrice() { + console.log('changeTotalPrice') + enableChangeTotalPrice.value = true + } + + onMounted(mounted) + return { myimgclass, addsubqty, @@ -129,6 +194,13 @@ export default defineComponent({ products, t, updateOrder, + orderQuantity, + orderQuantityPreordered, + enableQty, + enableQtyPreordered, + changeTotalPrice, + orderTotalPriceProduct, + endload, } }, }) diff --git a/src/components/CSingleCart/CSingleCart.vue b/src/components/CSingleCart/CSingleCart.vue index e0840e49..306f15fa 100755 --- a/src/components/CSingleCart/CSingleCart.vue +++ b/src/components/CSingleCart/CSingleCart.vue @@ -24,7 +24,13 @@ v-if="order.product.productInfo.unit" > {{ tools.getWeightTotalByOrder(order) }} - {{ tools.getUnitsMeasure(order.product.productInfo.unit, true, order.product.productInfo.weight) }} + {{ + tools.getUnitsMeasure( + order.product.productInfo.unit, + true, + order.product.productInfo.weight + ) + }}
+
+
+ -
-
+
@@ -108,30 +132,40 @@ : 0 }} + + (Calc: € + {{ + order.TotalPriceProductCalc + ? order.TotalPriceProductCalc.toFixed(2) + : 0 + }}) + +  (€ {{ ( - order.price * order.quantity + - order.price * order.quantitypreordered + (order.price * order.quantity) + + (order.price * order.quantitypreordered) ).toFixed(2) }})  - {{ + {{ $t('ecomm.sconto_applicato', { risparmio: getRisparmio() }) }}
- + -
+
{ - console.log(' Import dinamically lang =', lang) + // console.log(' Import dinamically lang =', lang) if ($q.lang) $q.lang.set(this.getlangforQuasar(lang.default.isoName)) import('../../statics/i18n').then(() => { - console.log(' *** MY LANG DOPO=', $q.lang.isoName) + // console.log(' *** MY LANG DOPO=', $q.lang.isoName) }) }) diff --git a/src/store/Modules/toolsext.ts b/src/store/Modules/toolsext.ts index 332ca508..91b955cf 100755 --- a/src/store/Modules/toolsext.ts +++ b/src/store/Modules/toolsext.ts @@ -143,16 +143,16 @@ export const toolsext = { setLangAtt($q: any, $router: Router, mylang: string) { const globalStore = useGlobalStore() - console.log('setLangAtt =', mylang) + // console.log('setLangAtt =', mylang) // console.log('PRIMA this.$q.lang.isoName', this.$q.lang.isoName) // dynamic import, so loading on demand only import(`quasar/lang/${this.getlangforQuasar(mylang)}`).then((lang) => { - console.log(' Import dinamically lang =', lang) + // console.log(' Import dinamically lang =', lang) $q.lang.set(this.getlangforQuasar(lang.default.isoName)) import('../../statics/i18n').then(() => { - console.log(' *** MY LANG DOPO=', $q.lang.isoName) + // console.log(' *** MY LANG DOPO=', $q.lang.isoName) }) }) diff --git a/src/store/Products.ts b/src/store/Products.ts index 84f57aa8..98384c41 100755 --- a/src/store/Products.ts +++ b/src/store/Products.ts @@ -22,6 +22,7 @@ function getRecordOrdersCartEmpty(): IOrderCart { user: null, totalQty: 0, totalPrice: 0, + totalPriceCalc: 0, status: 0, confermato: false, consegnato: false, @@ -198,6 +199,9 @@ export const useProducts = defineStore('Products', { if (tipoord === shared_consts.OrderStat.IN_CORSO.value) return state.orders.filter((rec: IOrderCart) => ((rec.status ? rec.status : 0) <= shared_consts.OrderStatus.CHECKOUT_SENT) && (hasGasordine ? rec.items?.some(item => item.order.idGasordine) : true)) + else if (tipoord === shared_consts.OrderStat.PREPARED.value) + return state.orders.filter((rec: IOrderCart) => (rec.status === shared_consts.OrderStatus.PREPARED) + && (hasGasordine ? rec.items?.some(item => item.order.idGasordine) : true)) else if (tipoord === shared_consts.OrderStat.CONFERMATI.value) return state.orders.filter((rec: IOrderCart) => (rec.status === shared_consts.OrderStatus.ORDER_CONFIRMED) && (hasGasordine ? rec.items?.some(item => item.order.idGasordine) : true)) @@ -356,6 +360,7 @@ export const useProducts = defineStore('Products', { idapp: process.env.APP_ID, status: shared_consts.OrderStatus.IN_CART, TotalPriceProduct: 0, + TotalPriceProductCalc: 0, idProduct: product._id, product, // Copia tutto l'oggetto Product ! @@ -391,12 +396,12 @@ export const useProducts = defineStore('Products', { const userStore = useUserStore() const globalStore = useGlobalStore() - // console.log('loadProducts') + //console.log('loadProducts') if (!globalStore.site.confpages.enableEcommerce) return null - console.log('getProducts', 'userid=', userStore.my._id) + // console.log('getProducts', 'userid=', userStore.my._id) // if (userStore.my._id === '') { // return new Types.AxiosError(0, null, 0, '') @@ -407,7 +412,7 @@ export const useProducts = defineStore('Products', { ris = await Api.SendReq('/products', 'POST', { userId: userStore.my._id }) .then((res) => { if (res.data.products) { - console.log('aggiorna prodotti') + // console.log('aggiorna prodotti') this.products = [] this.products = res.data.products } else { @@ -460,7 +465,7 @@ export const useProducts = defineStore('Products', { const idord = this.orders.findIndex((ord: IOrderCart) => ord._id === myorderscart._id) if (idord >= 0) { console.log('aggiorna ordine') - this.orders[idord] = {...myorderscart} + this.orders[idord] = { ...myorderscart } } } } @@ -551,7 +556,7 @@ export const useProducts = defineStore('Products', { async loadOrders() { - console.log('loadOrders') + // console.log('loadOrders') const userStore = useUserStore() const globalStore = useGlobalStore() diff --git a/src/store/UserStore.ts b/src/store/UserStore.ts index cef27d92..9e8e7fc6 100755 --- a/src/store/UserStore.ts +++ b/src/store/UserStore.ts @@ -1134,7 +1134,7 @@ export const useUserStore = defineStore('UserStore', { }, setlang($q: any, router: Router, newstr: string) { - console.log('SETLANG', newstr) + // console.log('SETLANG', newstr) this.lang = newstr toolsext.setLangAtt($q, router, newstr) toolsext.setLangAtt($q, router, newstr) diff --git a/src/store/globalStore.ts b/src/store/globalStore.ts index 771decff..c503532d 100644 --- a/src/store/globalStore.ts +++ b/src/store/globalStore.ts @@ -488,7 +488,7 @@ export const useGlobalStore = defineStore('GlobalStore', { addDynamicPages($router: Router | null) { // console.log('this.mypage', this.mypage) - console.log('addDynamicPages.........') + /// console.log('addDynamicPages.........') const arrpagesroute: IListRoutes[] = [] for (const page of this.mypage) { @@ -907,7 +907,7 @@ export const useGlobalStore = defineStore('GlobalStore', { }, async loadAfterLogin() { - console.log('loadAfterLogin') + // console.log('loadAfterLogin') this.clearDataAfterLoginOnlyIfActiveConnection() let isok = false diff --git a/src/views/admin/dbop/dbop.vue b/src/views/admin/dbop/dbop.vue index 31d3f838..7d8811d0 100755 --- a/src/views/admin/dbop/dbop.vue +++ b/src/views/admin/dbop/dbop.vue @@ -289,6 +289,11 @@ color="negative" @click="EseguiFunz('dropAllCarts')" > +
diff --git a/src/views/ecommerce/orderInfo/orderInfo.ts b/src/views/ecommerce/orderInfo/orderInfo.ts index 668c3142..dc6681f1 100755 --- a/src/views/ecommerce/orderInfo/orderInfo.ts +++ b/src/views/ecommerce/orderInfo/orderInfo.ts @@ -108,6 +108,14 @@ export default defineComponent({ field: 'apri', sortable: false }, + { + name: 'comandi', + align: 'center', + required: false, + label: 'Comandi', + field: 'comandi', + sortable: false + }, { name: 'numorder', required: true, @@ -154,14 +162,6 @@ export default defineComponent({ field: 'status', sortable: true }, - { - name: 'comandi', - align: 'center', - required: false, - label: 'Comandi', - field: 'comandi', - sortable: false - } ]) watch(() => cosa.value, (newval, oldval) => { @@ -197,6 +197,7 @@ export default defineComponent({ status: 0, // Add other properties as needed totalPrice: orderscart.reduce((total: number, rec: any) => total + rec.totalPrice, 0), + totalPriceCalc: orderscart.reduce((total: number, rec: any) => total + rec.totalPriceCalc, 0), }; let rowsWithTotals: any = [...orderscart]; @@ -227,12 +228,14 @@ export default defineComponent({ } const allorders = getAllOrdersCart() - for (const status of [2, 3, 4, 5, 6, 7, 8, 10]) { + 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() + + } function selectfirstavailable() { diff --git a/src/views/ecommerce/orderInfo/orderInfo.vue b/src/views/ecommerce/orderInfo/orderInfo.vue index d7780ac5..90c01931 100755 --- a/src/views/ecommerce/orderInfo/orderInfo.vue +++ b/src/views/ecommerce/orderInfo/orderInfo.vue @@ -112,6 +112,9 @@ {{ props.row.totalPrice }} € + + {{ props.row.totalPriceCalc }} € + {{ shared_consts.getStatusStr(props.row.status) }} @@ -137,14 +140,14 @@
- +
@@ -162,6 +165,7 @@
+ +
+ + + + + + + + {{ cmd.label }} + + + + +
+
  n. {{ props.row.numorder }} @@ -235,6 +256,10 @@ {{ tools.getstrDateTime(props.row.date_consegnato) }}: {{ $t('ecomm.consegnato') }} +
+ {{ tools.getstrDateTime(props.row.date_preparato) }}: + {{ $t('ecomm.preparato') }} +
{{ tools.getstrDateTime(props.row.date_spedito) }}: {{ $t('ecomm.spedito') }} @@ -244,23 +269,6 @@ {{ $t('ecomm.ricevuto') }}
- -
- - - - - - - - {{ cmd.label }} - - - - -
-