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',
},
{
label: 'Imposta come Cancellato', //CANCELED
label: '📩 Imposta come Cancellato', //CANCELED
value: 10,
icon: 'delete',
color: 'red',

View File

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

View File

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

View File

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

View File

@@ -604,12 +604,12 @@
</q-item-section>
</q-item-section>
</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-icon color="blue" name="fas fa-hourglass-half" />
</q-item-section>
<q-item-section v-if="!!myproduct.gasordine.dataora_chiusura_ordini">
<q-item-section>
<q-item-label class="countdown_scadenza">
<span v-if="timerLabelScadenza">{{ timerLabelScadenza }}</span>
<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 { CMyAvatar } from '@/components/CMyAvatar'
import { CMyFieldDb } from '@/components/CMyFieldDb'
import { CSelectUserActive } from '@/components/CSelectUserActive'
import { toolsext } from '@store/Modules/toolsext'
import { useGlobalStore } from '@store/globalStore'
import { useTestStore } from '@store/testStore'
import { useUserStore } from '@store/UserStore'
import { useProducts } from '@store/Products'
import MixinUsers from '../../mixins/mixin-users'
import { CMyCart, CSigninNoreg } from '@/components'
@@ -33,7 +35,8 @@ export default defineComponent({
name: 'MyHeader',
components: {
drawer, messagePopover,
CMyFieldDb, CMyAvatar, CSigninNoreg, CMyCart, notifPopover, coinsPopover
CMyFieldDb, CMyAvatar, CSigninNoreg, CMyCart, notifPopover, coinsPopover,
CSelectUserActive,
},
props: {
extraContent: {
@@ -66,6 +69,7 @@ export default defineComponent({
const userStore = useUserStore()
const globalStore = useGlobalStore()
const products = useProducts()
const testStore = useTestStore()
const notifStore = useNotifStore()
@@ -594,6 +598,8 @@ export default defineComponent({
iconConn,
clIconConn,
toHome,
products,
userStore,
}
},

View File

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

View File

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

View File

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

View File

@@ -1698,6 +1698,7 @@ const msg_it = {
totale: 'Totale',
calcolato: 'Calcolato',
carrello: 'Carrello',
carrello_di: 'Carrello di {user}',
settings: 'Impostazioni',
qta_in_attesa: '(Ordinati In attesa {qty})',
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: 'totalQtyPreordered', label_trans: 'orderscart.totalQtyPreordered', 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 }),
]

View File

@@ -66,6 +66,7 @@ export const tools = {
FILTER_MYFOLLOW: 2,
COOK_SEARCH: 'SEARCH_',
COOK_SELCART: 'SELCART_',
COOK_TAB_CIRCUIT: 'TAB_CIRC',
COOK_COSA_PRODOTTI: 'PROD',
@@ -3005,6 +3006,11 @@ export const tools = {
return userStore.isManager || userStore.isAdmin
},
isSeller() {
const userStore = useUserStore()
return userStore.isManager || userStore.isAdmin
},
isSocioResidente() {
const userStore = useUserStore()
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 { serv_constants } from '@src/store/Modules/serv_constants'
@@ -107,6 +107,7 @@ export const useProducts = defineStore('Products', {
catprods: [],
subcatprods: [],
productInfos: [],
userActive: {username: '', name: '', surname: '', _id: ''},
}),
getters: {
@@ -356,7 +357,7 @@ export const useProducts = defineStore('Products', {
createOrderByProduct(product: IProduct, order: IOrder): IOrder {
const userStore = useUserStore()
const myorder: IOrder = {
userId: userStore.my._id,
userId: this.userActive._id,
idapp: process.env.APP_ID,
status: shared_consts.OrderStatus.IN_CART,
TotalPriceProduct: 0,
@@ -379,7 +380,7 @@ export const useProducts = defineStore('Products', {
initcat() {
// rec.userId = userStore.my._id
// rec.userId = this.userActive._id
return this.getRecordEmpty()
@@ -401,15 +402,26 @@ export const useProducts = defineStore('Products', {
if (!globalStore.site.confpages.enableEcommerce)
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, '')
// }
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) => {
if (res.data.products) {
// console.log('aggiorna prodotti')
@@ -452,7 +464,7 @@ export const useProducts = defineStore('Products', {
if (!globalStore.site.confpages.enableEcommerce)
return null
console.log('updateOrderByOrder', 'userid=', userStore.my._id)
console.log('updateOrderByOrder', 'userid=', this.userActive._id)
let ris = null
@@ -492,7 +504,7 @@ export const useProducts = defineStore('Products', {
if (!globalStore.site.confpages.enableEcommerce)
return null
console.log('updateOrdersCartById', 'userid=', userStore.my._id)
console.log('updateOrdersCartById', 'userid=', this.userActive._id)
let ris = null
@@ -529,7 +541,7 @@ export const useProducts = defineStore('Products', {
if (!globalStore.site.confpages.enableEcommerce)
return null
// if (userStore.my._id === '') {
// if (this.userActive._id === '') {
// return new Types.AxiosError(0, null, 0, '')
// }
@@ -563,13 +575,13 @@ export const useProducts = defineStore('Products', {
if (!globalStore.site.confpages.enableEcommerce)
return null
// if (userStore.my._id === '') {
// if (this.userActive._id === '') {
// return new Types.AxiosError(0, null, 0, '')
// }
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) => {
if (res.data && res.data.cart) { // console.log('RISULTANTE CATEGORIES DAL SERVER = ', res.data.categories)
this.cart = res.data.cart
@@ -596,7 +608,7 @@ export const useProducts = defineStore('Products', {
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) => {
this.updateDataProduct(res)
@@ -680,11 +692,11 @@ export const useProducts = defineStore('Products', {
// if (neworder && !neworder.idStorehouse)
// 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
ris = await Api.SendReq('/cart/' + userStore.my._id, 'POST', { order: neworder })
ris = await Api.SendReq('/cart/' + this.userActive._id, 'POST', { order: neworder })
.then((res) => {
if (res.data.cart) { // console.log('RISULTANTE CATEGORIES DAL SERVER = ', res.data.categories)
this.cart = res.data.cart
@@ -714,11 +726,11 @@ export const useProducts = defineStore('Products', {
if (!globalStore.site.confpages.enableEcommerce)
return null
// console.log('addSubQtyToItem', 'userid=', userStore.my._id, order)
// console.log('addSubQtyToItem', 'userid=', this.userActive._id, order)
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) => {
this.updateDataProduct(res)
@@ -749,7 +761,7 @@ export const useProducts = defineStore('Products', {
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) => {
if (res.data.status === shared_consts.OrderStatus.CHECKOUT_SENT) {
@@ -811,7 +823,7 @@ export const useProducts = defineStore('Products', {
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) => {
this.updateDataProduct(res)
@@ -1013,6 +1025,19 @@ export const useProducts = defineStore('Products', {
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) {
return await Api.SendReq('/orders/sendmail', 'POST', { templemail_id, idOrdersCart, previewonly: tools.isDebug(), test })
.then((res) => {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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