Poter inserire un Ordine anche per un altra persona... (Modalità Cassa)

This commit is contained in:
Surya Paolo
2024-01-16 23:00:15 +01:00
parent 62267ef618
commit 40076e3e1d
23 changed files with 144 additions and 30 deletions

View File

@@ -1177,7 +1177,7 @@ export const shared_consts = {
color: 'blue', color: 'blue',
}, },
{ {
label: 'Imposta come Cancellato', //CANCELED label: '📩 Imposta come Cancellato', //CANCELED
value: 10, value: 10,
icon: 'delete', icon: 'delete',
color: 'red', color: 'red',

View File

@@ -14,6 +14,7 @@ import { shared_consts } from '@src/common/shared_vuejs'
import { CSingleCart } from '../CSingleCart' import { CSingleCart } from '../CSingleCart'
import { CTitleBanner } from '@components' import { CTitleBanner } from '@components'
import { CSelectUserActive } from '@src/components/CSelectUserActive'
export default defineComponent({ export default defineComponent({
name: 'CCart', name: 'CCart',
@@ -30,7 +31,7 @@ export default defineComponent({
}, },
}, },
components: { CSingleCart, CTitleBanner }, components: { CSingleCart, CTitleBanner, CSelectUserActive },
setup(props) { setup(props) {
const userStore = useUserStore() const userStore = useUserStore()
const globalStore = useGlobalStore() const globalStore = useGlobalStore()

View File

@@ -1,6 +1,7 @@
<template> <template>
<q-spinner v-if="!endload" color="primary" size="3em" :thickness="2" /> <q-spinner v-if="!endload" color="primary" size="3em" :thickness="2" />
<div v-if="endload"> <div v-if="endload">
<CSelectUserActive></CSelectUserActive>
<div v-if="recOrderCart" class="panel"> <div v-if="recOrderCart" class="panel">
<div> <div>
<div class="container"> <div class="container">

View File

@@ -258,7 +258,6 @@ export default defineComponent({
function updateLabel() { function updateLabel() {
if (myproduct.value.gasordine) { if (myproduct.value.gasordine) {
//labelDataRitiro.value = tools.getstrDateTime(recgasordineSelected.value.dataora_ritiro)
if (myproduct.value.gasordine.data_arrivo_merce) if (myproduct.value.gasordine.data_arrivo_merce)
labelDataArrivoMerce.value = tools.getstrDateShort(myproduct.value.gasordine.data_arrivo_merce) labelDataArrivoMerce.value = tools.getstrDateShort(myproduct.value.gasordine.data_arrivo_merce)
if (myproduct.value.gasordine.dataora_ritiro) if (myproduct.value.gasordine.dataora_ritiro)
@@ -267,6 +266,7 @@ export default defineComponent({
labelDataArrivoMerce.value = '' labelDataArrivoMerce.value = ''
labelDataRitiro.value = '' labelDataRitiro.value = ''
} }
updateTimerLabel()
} }
function mounted() { function mounted() {

View File

@@ -604,12 +604,12 @@
</q-item-section> </q-item-section>
</q-item-section> </q-item-section>
</q-item> </q-item>
<q-item v-if="myproduct.gasordine && myproduct.gasordine.active"> <q-item v-if="myproduct.gasordine && myproduct.gasordine.active && (myproduct.gasordine.dataora_chiusura_ordini || editOn)">
<q-item-section avatar> <q-item-section avatar>
<q-icon color="blue" name="fas fa-hourglass-half" /> <q-icon color="blue" name="fas fa-hourglass-half" />
</q-item-section> </q-item-section>
<q-item-section v-if="!!myproduct.gasordine.dataora_chiusura_ordini"> <q-item-section>
<q-item-label class="countdown_scadenza"> <q-item-label class="countdown_scadenza">
<span v-if="timerLabelScadenza">{{ timerLabelScadenza }}</span> <span v-if="timerLabelScadenza">{{ timerLabelScadenza }}</span>
<span v-else-if="isOrdineChiuso()">{{ <span v-else-if="isOrdineChiuso()">{{

View File

@@ -0,0 +1,26 @@
import { defineComponent, ref } from 'vue'
import { useUserStore } from '@store/UserStore'
import { useProducts } from '@store/Products'
import { useI18n } from '@/boot/i18n'
import { tools } from '@store/Modules/tools'
export default defineComponent({
name: 'CSelectUserActive',
props: {
},
components: {},
setup(props, { emit }) {
const { t } = useI18n()
const userStore = useUserStore()
const productStore = useProducts()
return {
userStore,
productStore,
t,
tools,
}
},
})

View File

@@ -0,0 +1,22 @@
<template>
<q-select
v-if="tools.isSeller() && productStore.userActive"
v-model="productStore.userActive"
:options="userStore.usersList"
label="Spesa dell'Utente:"
filled
:bg-color="userStore.my._id !== productStore.userActive._id ? 'green' : undefined"
:option-label="(opt) => tools.getNomeUtenteEUsernameByRecUser(opt)"
option-value="null"
emit-value
map-options
@update:model-value="productStore.changeuserActive(productStore.userActive)"
>
</q-select>
</template>
<script lang="ts" src="./CSelectUserActive.ts">
</script>
<style lang="scss" scoped>
@import './CSelectUserActive.scss';
</style>

View File

@@ -0,0 +1 @@
export {default as CSelectUserActive} from './CSelectUserActive.vue'

View File

@@ -16,10 +16,12 @@ import coinsPopover from '../../layouts/toolbar/coinsPopover/coinsPopover.vue'
import drawer from '../../layouts/drawer/drawer.vue' import drawer from '../../layouts/drawer/drawer.vue'
import { CMyAvatar } from '@/components/CMyAvatar' import { CMyAvatar } from '@/components/CMyAvatar'
import { CMyFieldDb } from '@/components/CMyFieldDb' import { CMyFieldDb } from '@/components/CMyFieldDb'
import { CSelectUserActive } from '@/components/CSelectUserActive'
import { toolsext } from '@store/Modules/toolsext' import { toolsext } from '@store/Modules/toolsext'
import { useGlobalStore } from '@store/globalStore' import { useGlobalStore } from '@store/globalStore'
import { useTestStore } from '@store/testStore' import { useTestStore } from '@store/testStore'
import { useUserStore } from '@store/UserStore' import { useUserStore } from '@store/UserStore'
import { useProducts } from '@store/Products'
import MixinUsers from '../../mixins/mixin-users' import MixinUsers from '../../mixins/mixin-users'
import { CMyCart, CSigninNoreg } from '@/components' import { CMyCart, CSigninNoreg } from '@/components'
@@ -33,7 +35,8 @@ export default defineComponent({
name: 'MyHeader', name: 'MyHeader',
components: { components: {
drawer, messagePopover, drawer, messagePopover,
CMyFieldDb, CMyAvatar, CSigninNoreg, CMyCart, notifPopover, coinsPopover CMyFieldDb, CMyAvatar, CSigninNoreg, CMyCart, notifPopover, coinsPopover,
CSelectUserActive,
}, },
props: { props: {
extraContent: { extraContent: {
@@ -66,6 +69,7 @@ export default defineComponent({
const userStore = useUserStore() const userStore = useUserStore()
const globalStore = useGlobalStore() const globalStore = useGlobalStore()
const products = useProducts()
const testStore = useTestStore() const testStore = useTestStore()
const notifStore = useNotifStore() const notifStore = useNotifStore()
@@ -594,6 +598,8 @@ export default defineComponent({
iconConn, iconConn,
clIconConn, clIconConn,
toHome, toHome,
products,
userStore,
} }
}, },

View File

@@ -115,7 +115,12 @@
<div v-if="site.confpages && site.confpages.showMsgs"> <div v-if="site.confpages && site.confpages.showMsgs">
<message-popover></message-popover> <message-popover></message-popover>
</div> </div>
<div v-if="site.confpages && site.confpages.showCoins || site.confpages.showRIS"> <div
v-if="
(site.confpages && site.confpages.showCoins) ||
site.confpages.showRIS
"
>
<coinsPopover v-model="rightCoinsOpen"></coinsPopover> <coinsPopover v-model="rightCoinsOpen"></coinsPopover>
</div> </div>
<div v-if="site.confpages && site.confpages.showNotif"> <div v-if="site.confpages && site.confpages.showNotif">
@@ -250,8 +255,11 @@
@click="rightCartOpen = !rightCartOpen" @click="rightCartOpen = !rightCartOpen"
> >
</q-btn> </q-btn>
<CSelectUserActive></CSelectUserActive>
<div v-if="tools.isLogged()" class="text-weight-bold text-cart"> <div v-if="tools.isLogged()" class="text-weight-bold text-cart">
{{ $t('ecomm.carrello') }} {{ $t('ecomm.carrello_di', { user: products.userActive.username }) }}
</div> </div>
<CMyCart v-if="isfinishLoading"></CMyCart> <CMyCart v-if="isfinishLoading"></CMyCart>
</q-drawer> </q-drawer>

View File

@@ -1,4 +1,4 @@
import { IUserFields } from './UserStore' import { IUserFields, IUserShort } from './UserStore'
export interface IProductInfo { export interface IProductInfo {
@@ -101,6 +101,7 @@ export interface IProductsState {
catprods: ICatProd[] catprods: ICatProd[]
subcatprods: ISubCatProd[] subcatprods: ISubCatProd[]
productInfos: IProductInfo[] productInfos: IProductInfo[]
userActive: IUserShort
} }
export interface IProducer { export interface IProducer {
@@ -213,6 +214,7 @@ export interface ICart {
userId?: string userId?: string
totalQty?: number totalQty?: number
totalPrice?: number totalPrice?: number
totalPriceCalc?: number
department?: string department?: string
items?: IBaseOrder[] items?: IBaseOrder[]
note?: string note?: string

View File

@@ -193,6 +193,14 @@ export interface IUserAport {
profile?: IUserProfile profile?: IUserProfile
} }
export interface IUserShort {
_id: string
username: string
name: string
surname: string
profile?: IUserProfile
}
export interface IUserFields { export interface IUserFields {
_id: string _id: string
idapp?: string idapp?: string

View File

@@ -1698,6 +1698,7 @@ const msg_it = {
totale: 'Totale', totale: 'Totale',
calcolato: 'Calcolato', calcolato: 'Calcolato',
carrello: 'Carrello', carrello: 'Carrello',
carrello_di: 'Carrello di {user}',
settings: 'Impostazioni', settings: 'Impostazioni',
qta_in_attesa: '(Ordinati In attesa {qty})', qta_in_attesa: '(Ordinati In attesa {qty})',
sconto_applicato: 'Risparmi {risparmio} € !', sconto_applicato: 'Risparmi {risparmio} € !',

View File

@@ -2036,6 +2036,7 @@ export const colTableOrdersCart = [
AddCol({ name: 'totalQty', label_trans: 'orderscart.totalQty', fieldtype: costanti.FieldType.number }), AddCol({ name: 'totalQty', label_trans: 'orderscart.totalQty', fieldtype: costanti.FieldType.number }),
AddCol({ name: 'totalQtyPreordered', label_trans: 'orderscart.totalQtyPreordered', fieldtype: costanti.FieldType.number }), AddCol({ name: 'totalQtyPreordered', label_trans: 'orderscart.totalQtyPreordered', fieldtype: costanti.FieldType.number }),
AddCol({ name: 'totalPrice', label_trans: 'orderscart.totalPrice', fieldtype: costanti.FieldType.number }), AddCol({ name: 'totalPrice', label_trans: 'orderscart.totalPrice', fieldtype: costanti.FieldType.number }),
AddCol({ name: 'totalPriceCalc', label_trans: 'orderscart.totalPriceCalc', fieldtype: costanti.FieldType.number }),
AddCol({ name: 'status', label_trans: 'orderscart.status', fieldtype: costanti.FieldType.number }), AddCol({ name: 'status', label_trans: 'orderscart.status', fieldtype: costanti.FieldType.number }),
] ]

View File

@@ -66,6 +66,7 @@ export const tools = {
FILTER_MYFOLLOW: 2, FILTER_MYFOLLOW: 2,
COOK_SEARCH: 'SEARCH_', COOK_SEARCH: 'SEARCH_',
COOK_SELCART: 'SELCART_',
COOK_TAB_CIRCUIT: 'TAB_CIRC', COOK_TAB_CIRCUIT: 'TAB_CIRC',
COOK_COSA_PRODOTTI: 'PROD', COOK_COSA_PRODOTTI: 'PROD',
@@ -3005,6 +3006,11 @@ export const tools = {
return userStore.isManager || userStore.isAdmin return userStore.isManager || userStore.isAdmin
}, },
isSeller() {
const userStore = useUserStore()
return userStore.isManager || userStore.isAdmin
},
isSocioResidente() { isSocioResidente() {
const userStore = useUserStore() const userStore = useUserStore()
return !!userStore.my.profile ? userStore.my.profile.socioresidente : false return !!userStore.my.profile ? userStore.my.profile.socioresidente : false

View File

@@ -1,4 +1,4 @@
import { IBaseOrder, ICart, IOrder, IOrderCart, IProduct, IProductsState, IProductInfo, ICatProd } from 'model' import { IBaseOrder, ICart, IOrder, IOrderCart, IProduct, IProductsState, IProductInfo, ICatProd, IUserShort } from 'model'
import { Api } from '@api' import { Api } from '@api'
import { serv_constants } from '@src/store/Modules/serv_constants' import { serv_constants } from '@src/store/Modules/serv_constants'
@@ -107,6 +107,7 @@ export const useProducts = defineStore('Products', {
catprods: [], catprods: [],
subcatprods: [], subcatprods: [],
productInfos: [], productInfos: [],
userActive: {username: '', name: '', surname: '', _id: ''},
}), }),
getters: { getters: {
@@ -356,7 +357,7 @@ export const useProducts = defineStore('Products', {
createOrderByProduct(product: IProduct, order: IOrder): IOrder { createOrderByProduct(product: IProduct, order: IOrder): IOrder {
const userStore = useUserStore() const userStore = useUserStore()
const myorder: IOrder = { const myorder: IOrder = {
userId: userStore.my._id, userId: this.userActive._id,
idapp: process.env.APP_ID, idapp: process.env.APP_ID,
status: shared_consts.OrderStatus.IN_CART, status: shared_consts.OrderStatus.IN_CART,
TotalPriceProduct: 0, TotalPriceProduct: 0,
@@ -379,7 +380,7 @@ export const useProducts = defineStore('Products', {
initcat() { initcat() {
// rec.userId = userStore.my._id // rec.userId = this.userActive._id
return this.getRecordEmpty() return this.getRecordEmpty()
@@ -401,15 +402,26 @@ export const useProducts = defineStore('Products', {
if (!globalStore.site.confpages.enableEcommerce) if (!globalStore.site.confpages.enableEcommerce)
return null return null
// console.log('getProducts', 'userid=', userStore.my._id) // console.log('getProducts', 'userid=', this.userActive._id)
// if (userStore.my._id === '') { // if (this.userActive._id === '') {
// return new Types.AxiosError(0, null, 0, '') // return new Types.AxiosError(0, null, 0, '')
// } // }
let ris = null let ris = null
ris = await Api.SendReq('/products', 'POST', { userId: userStore.my._id }) let myIdActiveSelected = userStore.my._id
if (tools.isSeller())
myIdActiveSelected = tools.getCookie(tools.COOK_SELCART, userStore.my._id, false)
const trovato = userStore.usersList.find((user: IUserShort) => user._id === myIdActiveSelected)
if (trovato)
this.userActive = trovato
else
this.userActive = userStore.my
ris = await Api.SendReq('/products', 'POST', { userId: this.userActive._id })
.then((res) => { .then((res) => {
if (res.data.products) { if (res.data.products) {
// console.log('aggiorna prodotti') // console.log('aggiorna prodotti')
@@ -452,7 +464,7 @@ export const useProducts = defineStore('Products', {
if (!globalStore.site.confpages.enableEcommerce) if (!globalStore.site.confpages.enableEcommerce)
return null return null
console.log('updateOrderByOrder', 'userid=', userStore.my._id) console.log('updateOrderByOrder', 'userid=', this.userActive._id)
let ris = null let ris = null
@@ -492,7 +504,7 @@ export const useProducts = defineStore('Products', {
if (!globalStore.site.confpages.enableEcommerce) if (!globalStore.site.confpages.enableEcommerce)
return null return null
console.log('updateOrdersCartById', 'userid=', userStore.my._id) console.log('updateOrdersCartById', 'userid=', this.userActive._id)
let ris = null let ris = null
@@ -529,7 +541,7 @@ export const useProducts = defineStore('Products', {
if (!globalStore.site.confpages.enableEcommerce) if (!globalStore.site.confpages.enableEcommerce)
return null return null
// if (userStore.my._id === '') { // if (this.userActive._id === '') {
// return new Types.AxiosError(0, null, 0, '') // return new Types.AxiosError(0, null, 0, '')
// } // }
@@ -563,13 +575,13 @@ export const useProducts = defineStore('Products', {
if (!globalStore.site.confpages.enableEcommerce) if (!globalStore.site.confpages.enableEcommerce)
return null return null
// if (userStore.my._id === '') { // if (this.userActive._id === '') {
// return new Types.AxiosError(0, null, 0, '') // return new Types.AxiosError(0, null, 0, '')
// } // }
let ris = null let ris = null
ris = await Api.SendReq('/cart/' + userStore.my._id, 'GET', null) ris = await Api.SendReq('/cart/' + this.userActive._id, 'GET', null)
.then((res) => { .then((res) => {
if (res.data && res.data.cart) { // console.log('RISULTANTE CATEGORIES DAL SERVER = ', res.data.categories) if (res.data && res.data.cart) { // console.log('RISULTANTE CATEGORIES DAL SERVER = ', res.data.categories)
this.cart = res.data.cart this.cart = res.data.cart
@@ -596,7 +608,7 @@ export const useProducts = defineStore('Products', {
const userStore = useUserStore() const userStore = useUserStore()
return Api.SendReq('/cart/' + userStore.my._id, 'DELETE', { orderId: order._id }) return Api.SendReq('/cart/' + this.userActive._id, 'DELETE', { orderId: order._id })
.then((res) => { .then((res) => {
this.updateDataProduct(res) this.updateDataProduct(res)
@@ -680,11 +692,11 @@ export const useProducts = defineStore('Products', {
// if (neworder && !neworder.idStorehouse) // if (neworder && !neworder.idStorehouse)
// return new Types.AxiosError(serv_constants.RIS_CODE_ERR, null, toolsext.ERR_GENERICO, 'Nessuno Store') // return new Types.AxiosError(serv_constants.RIS_CODE_ERR, null, toolsext.ERR_GENERICO, 'Nessuno Store')
console.log('addToCart', 'userid=', userStore.my._id, neworder) console.log('addToCart', 'userid=', this.userActive._id, neworder)
let ris = null let ris = null
ris = await Api.SendReq('/cart/' + userStore.my._id, 'POST', { order: neworder }) ris = await Api.SendReq('/cart/' + this.userActive._id, 'POST', { order: neworder })
.then((res) => { .then((res) => {
if (res.data.cart) { // console.log('RISULTANTE CATEGORIES DAL SERVER = ', res.data.categories) if (res.data.cart) { // console.log('RISULTANTE CATEGORIES DAL SERVER = ', res.data.categories)
this.cart = res.data.cart this.cart = res.data.cart
@@ -714,11 +726,11 @@ export const useProducts = defineStore('Products', {
if (!globalStore.site.confpages.enableEcommerce) if (!globalStore.site.confpages.enableEcommerce)
return null return null
// console.log('addSubQtyToItem', 'userid=', userStore.my._id, order) // console.log('addSubQtyToItem', 'userid=', this.userActive._id, order)
let ris = null let ris = null
ris = await Api.SendReq('/cart/' + userStore.my._id, 'POST', { addqty, subqty, order }) ris = await Api.SendReq('/cart/' + this.userActive._id, 'POST', { addqty, subqty, order })
.then((res: any) => { .then((res: any) => {
this.updateDataProduct(res) this.updateDataProduct(res)
@@ -749,7 +761,7 @@ export const useProducts = defineStore('Products', {
let ris = null let ris = null
ris = await Api.SendReq('/cart/' + userStore.my._id + '/createorderscart', 'POST', { cart_id, status, note, options: this.getOptions() }) ris = await Api.SendReq('/cart/' + this.userActive._id + '/createorderscart', 'POST', { cart_id, status, note, options: this.getOptions() })
.then((res) => { .then((res) => {
if (res.data.status === shared_consts.OrderStatus.CHECKOUT_SENT) { if (res.data.status === shared_consts.OrderStatus.CHECKOUT_SENT) {
@@ -811,7 +823,7 @@ export const useProducts = defineStore('Products', {
let ris = null let ris = null
ris = await Api.SendReq('/cart/' + userStore.my._id + '/ordercartstatus', 'POST', { order_id, status, options: this.getOptions() }) ris = await Api.SendReq('/cart/' + this.userActive._id + '/ordercartstatus', 'POST', { order_id, status, options: this.getOptions() })
.then((res) => { .then((res) => {
this.updateDataProduct(res) this.updateDataProduct(res)
@@ -1013,6 +1025,19 @@ export const useProducts = defineStore('Products', {
return arrprod.length return arrprod.length
}, },
changeuserActive(valuerec: any) {
if (valuerec) {
console.log('valuerec', valuerec)
tools.setCookie(tools.COOK_SELCART, valuerec._id)
this.products = []
this.orders = []
this.cart = { items: [], totalPrice: 0, totalQty: 0, userId: '' }
this.loadOrders()
this.loadProducts()
}
},
async sendMailToTheBuyer(idOrdersCart: string, templemail_id: string, test: boolean) { async sendMailToTheBuyer(idOrdersCart: string, templemail_id: string, test: boolean) {
return await Api.SendReq('/orders/sendmail', 'POST', { templemail_id, idOrdersCart, previewonly: tools.isDebug(), test }) return await Api.SendReq('/orders/sendmail', 'POST', { templemail_id, idOrdersCart, previewonly: tools.isDebug(), test })
.then((res) => { .then((res) => {

View File

@@ -11,12 +11,13 @@ import { costanti } from '@costanti'
import { shared_consts } from '@/common/shared_vuejs' import { shared_consts } from '@/common/shared_vuejs'
import { CProductCard } from '@src/components/CProductCard' import { CProductCard } from '@src/components/CProductCard'
import { CSelectUserActive } from '@src/components/CSelectUserActive'
import { IProduct } from '@src/model' import { IProduct } from '@src/model'
export default defineComponent({ export default defineComponent({
name: 'cash', name: 'cash',
components: { CProductCard }, components: { CProductCard, CSelectUserActive },
props: {}, props: {},
setup() { setup() {
const userStore = useUserStore() const userStore = useUserStore()

View File

@@ -6,6 +6,7 @@
<div v-if="loadpage" class="panel"> <div v-if="loadpage" class="panel">
<div> <div>
<div class="text-center"> <div class="text-center">
<CSelectUserActive></CSelectUserActive>
<q-btn-toggle <q-btn-toggle
v-model="cosa" v-model="cosa"
push push

View File

@@ -22,6 +22,7 @@ export default defineComponent({
props: {}, props: {},
setup() { setup() {
const userStore = useUserStore() const userStore = useUserStore()
const products = useProducts()
const { t } = useI18n(); const { t } = useI18n();
function mounted() { function mounted() {
@@ -37,6 +38,7 @@ export default defineComponent({
toolsext, toolsext,
shared_consts, shared_consts,
t, t,
products,
} }
} }
}) })

View File

@@ -1,6 +1,6 @@
<template> <template>
<q-page> <q-page>
<CTitleBanner :title="t('ecomm.carrello')"></CTitleBanner> <CTitleBanner :title="t('ecomm.carrello_di', {user: products.userActive.username})"></CTitleBanner>
<CCart> <CCart>
</CCart> </CCart>
</q-page> </q-page>

View File

@@ -11,12 +11,13 @@ import { costanti } from '@costanti'
import { shared_consts } from '@/common/shared_vuejs' import { shared_consts } from '@/common/shared_vuejs'
import { CProductCard } from '@src/components/CProductCard' import { CProductCard } from '@src/components/CProductCard'
import { CSelectUserActive } from '@src/components/CSelectUserActive'
import { IProduct } from '@src/model' import { IProduct } from '@src/model'
export default defineComponent({ export default defineComponent({
name: 'ProductsList', name: 'ProductsList',
components: { CProductCard }, components: { CProductCard, CSelectUserActive },
props: {}, props: {},
setup() { setup() {
const userStore = useUserStore() const userStore = useUserStore()

View File

@@ -5,6 +5,7 @@
</div> </div>
<div v-if="loadpage" class="panel"> <div v-if="loadpage" class="panel">
<div> <div>
<CSelectUserActive></CSelectUserActive>
<div class="text-center"> <div class="text-center">
<q-btn-toggle <q-btn-toggle
v-model="cosa" v-model="cosa"