Merge branch 'develop' of ssh://risosrv:5522/~/repository/newfreeplanet into develop
This commit is contained in:
@@ -18,6 +18,15 @@
|
||||
font-size: 1.2rem;
|
||||
}
|
||||
|
||||
|
||||
.prod_preorder{
|
||||
font-size: 1.2rem;
|
||||
}
|
||||
|
||||
.prod_preorder{
|
||||
font-size: 1.2rem;
|
||||
}
|
||||
|
||||
.prod_qtywarn {
|
||||
padding-left: 10px;
|
||||
font-size: 1rem;
|
||||
|
||||
@@ -10,7 +10,7 @@ import { CCopyBtn } from '../CCopyBtn'
|
||||
|
||||
import { func_tools, toolsext } from '@store/Modules/toolsext'
|
||||
|
||||
import { IOrder, IOrderCart, IProduct } from '@src/model'
|
||||
import { IBaseOrder, IOrder, IOrderCart, IProduct } from '@src/model'
|
||||
import { tools } from '@store/Modules/tools'
|
||||
import { useProducts } from '@store/Products'
|
||||
|
||||
@@ -43,11 +43,15 @@ export default defineComponent({
|
||||
const globalStore = useGlobalStore()
|
||||
const products = useProducts()
|
||||
|
||||
const listord = ref(<IOrderCart[]>[])
|
||||
const sumval = ref(0)
|
||||
|
||||
const site = ref(globalStore.site)
|
||||
|
||||
const myorder = reactive(<IOrder>{
|
||||
idapp: process.env.APP_ID,
|
||||
quantity: 0,
|
||||
quantitypreordered: 0,
|
||||
idStorehouse: '',
|
||||
idProvider: ''
|
||||
})
|
||||
@@ -86,8 +90,12 @@ export default defineComponent({
|
||||
globalStore.rightDrawerOpen = true
|
||||
return false
|
||||
}
|
||||
await products.addtoCartBase({ $q, t, code: myproduct.value.code!, order: myorder, addqty: add })
|
||||
|
||||
const ris = await products.addtoCartBase({ $q, t, code: myproduct.value.code!, order: myorder, addqty: add })
|
||||
updateproduct()
|
||||
if (ris && ris.myord) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function getnumstore() {
|
||||
@@ -114,7 +122,7 @@ export default defineComponent({
|
||||
|
||||
function updateproduct() {
|
||||
myproduct.value = products.getProductByCode(props.code)
|
||||
products.updateQuantityAvailable(myproduct.value._id)
|
||||
// products.updateQuantityAvailable(myproduct.value._id)
|
||||
}
|
||||
|
||||
function getStorehouses() {
|
||||
@@ -148,6 +156,11 @@ export default defineComponent({
|
||||
return qty
|
||||
}
|
||||
|
||||
function getQtyBookableAvailable() {
|
||||
let qty = myproduct.value.bookableAvailableQty!
|
||||
return qty
|
||||
}
|
||||
|
||||
function getQtyWarn() {
|
||||
if (myorder.quantity > 0) {
|
||||
return t('ecomm.di_cui_x_in_carrello', { qty: myorder.quantity })
|
||||
@@ -155,6 +168,13 @@ export default defineComponent({
|
||||
return ''
|
||||
}
|
||||
|
||||
function getQtyWarnPreOrdered() {
|
||||
if (myorder.quantitypreordered > 0) {
|
||||
return t('ecomm.di_cui_x_in_carrello', { qty: myorder.quantitypreordered })
|
||||
}
|
||||
return ''
|
||||
}
|
||||
|
||||
watch(() => props.code, (newval, oldval) => {
|
||||
console.log('change code')
|
||||
load()
|
||||
@@ -179,6 +199,7 @@ export default defineComponent({
|
||||
const ord = products.getOrderProductInCart(myproduct.value._id)
|
||||
if (ord) {
|
||||
myorder.quantity = ord.quantity
|
||||
myorder.quantitypreordered = ord.quantitypreordered
|
||||
}
|
||||
}
|
||||
|
||||
@@ -195,21 +216,42 @@ export default defineComponent({
|
||||
}
|
||||
|
||||
function enableSubQty() {
|
||||
return myorder.quantity ? myorder.quantity > 0 : false
|
||||
let qty = myorder.quantity + myorder.quantitypreordered
|
||||
return qty ? qty > 0 : false
|
||||
}
|
||||
|
||||
function enableAddQty() {
|
||||
if (site.value.ecomm && site.value.ecomm.enablePreOrders) {
|
||||
return true
|
||||
return getQtyBookableAvailable() > 0 || getQtyAvailable() > 0
|
||||
} else {
|
||||
return getQtyAvailable() > 0
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function visuListDisponibili() {
|
||||
openlistorders.value = true
|
||||
sumval.value = products.getSumQtyOrderProductInOrdersCart(myproduct.value._id)
|
||||
|
||||
listord.value = arrordersCart.value.filter((ordercart: IOrderCart) => ordercart.items!.reduce((accumulator, item) => {
|
||||
return accumulator + item.order.quantity
|
||||
}, 0))
|
||||
}
|
||||
|
||||
function visuListBookable() {
|
||||
openlistorders.value = true
|
||||
sumval.value = products.getSumQtyPreOrderInOrdersCart(myproduct.value._id)
|
||||
|
||||
listord.value = arrordersCart.value.filter((ordercart: IOrderCart) => ordercart.items!.reduce((accumulator, item) => {
|
||||
return accumulator + item.order.quantitypreordered
|
||||
}, 0))
|
||||
}
|
||||
|
||||
onMounted(load)
|
||||
|
||||
return {
|
||||
visuListDisponibili,
|
||||
visuListBookable,
|
||||
addtoCart,
|
||||
iconWhishlist,
|
||||
getmycardcl,
|
||||
@@ -235,6 +277,10 @@ export default defineComponent({
|
||||
endload,
|
||||
shared_consts,
|
||||
site,
|
||||
getQtyWarnPreOrdered,
|
||||
getQtyBookableAvailable,
|
||||
listord,
|
||||
sumval,
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -54,7 +54,9 @@
|
||||
myproduct.after_price
|
||||
}}</span>
|
||||
</q-item-label>
|
||||
<q-item-label v-if="myproduct.scontisticas && myproduct.scontisticas.length > 0">
|
||||
<q-item-label
|
||||
v-if="myproduct.scontisticas && myproduct.scontisticas.length > 0"
|
||||
>
|
||||
<div
|
||||
class="prod_sconti"
|
||||
v-for="(sconti, index) of myproduct.scontisticas"
|
||||
@@ -63,7 +65,6 @@
|
||||
{{ sconti.description }}
|
||||
</div>
|
||||
</q-item-label>
|
||||
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
</q-list>
|
||||
@@ -108,40 +109,29 @@
|
||||
<q-list>
|
||||
<q-item
|
||||
:clickable="tools.isManager()"
|
||||
@click="tools.isManager() ? (openlistorders = true) : null"
|
||||
@click="tools.isManager() ? (visuListDisponibili()) : null"
|
||||
>
|
||||
<q-item-section avatar>
|
||||
<q-icon
|
||||
:color="getQtyAvailable() >= 0 ? 'green' : 'blue'"
|
||||
:name="getQtyAvailable() >= 0 ? 'fas fa-store' : 'fas fa-edit'"
|
||||
color="green"
|
||||
name="fas fa-store"
|
||||
/>
|
||||
</q-item-section>
|
||||
|
||||
<q-item-section>
|
||||
<q-item-label>
|
||||
<span v-if="getQtyAvailable() < 0">
|
||||
{{ t('ecomm.preorders') }}
|
||||
</span>
|
||||
<span v-else>
|
||||
{{ t('ecomm.available') }}
|
||||
</span>
|
||||
</q-item-label>
|
||||
<q-item-label>
|
||||
<span class="prod_disp">
|
||||
<span v-if="getQtyAvailable() < 0">
|
||||
{{ -getQtyAvailable() }}
|
||||
</span>
|
||||
<span v-else>
|
||||
{{ getQtyAvailable() }}
|
||||
</span>
|
||||
</span>
|
||||
<div class="prod_qtywarn">
|
||||
{{ getQtyWarn() }}
|
||||
|
||||
<div
|
||||
v-if="
|
||||
tools.isManager() &&
|
||||
!!myproduct.QuantitaOrdinateInAttesa
|
||||
tools.isManager() && !!myproduct.QuantitaOrdinateInAttesa
|
||||
"
|
||||
>
|
||||
{{
|
||||
@@ -155,6 +145,43 @@
|
||||
<q-item-label> </q-item-label>
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
<q-item
|
||||
v-if="getQtyBookableAvailable() > 0 || (myproduct.bookableQty > 0)"
|
||||
:clickable="tools.isManager()"
|
||||
@click="tools.isManager() ? (visuListBookable()) : null"
|
||||
>
|
||||
<q-item-section avatar>
|
||||
<q-icon color="blue" name="fas fa-edit" />
|
||||
</q-item-section>
|
||||
|
||||
<q-item-section>
|
||||
<q-item-label>
|
||||
{{ t('ecomm.preorders') }}
|
||||
</q-item-label>
|
||||
<q-item-label>
|
||||
<span class="prod_preorder">
|
||||
{{ getQtyBookableAvailable() }}
|
||||
</span>
|
||||
<div class="prod_qtywarn">
|
||||
<span v-if="getQtyWarnPreOrdered()">{{
|
||||
getQtyWarnPreOrdered()
|
||||
}}</span>
|
||||
|
||||
<div
|
||||
v-if="
|
||||
tools.isManager() && !!myproduct.QuantitaPrenotateInAttesa
|
||||
"
|
||||
>
|
||||
{{
|
||||
$t('ecomm.qta_prenotate_in_attesa', {
|
||||
qty: myproduct.QuantitaPrenotateInAttesa,
|
||||
})
|
||||
}}
|
||||
</div>
|
||||
</div>
|
||||
</q-item-label>
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
</q-list>
|
||||
<div class="row q-mb-sm no-wrap items-center centeritems">
|
||||
<q-btn
|
||||
@@ -178,6 +205,12 @@
|
||||
<div class="self-center no-outline" tabindex="0">
|
||||
{{ myorder.quantity }}
|
||||
</div>
|
||||
<div
|
||||
v-if="myorder.quantitypreordered"
|
||||
class="self-center no-outline"
|
||||
tabindex="0"
|
||||
>
|
||||
</div>
|
||||
</template>
|
||||
</q-field>
|
||||
|
||||
@@ -224,7 +257,7 @@
|
||||
|
||||
<q-card-actions vertical align="center">
|
||||
<q-btn
|
||||
v-if="myorder.quantity > 0"
|
||||
v-if="myorder.quantity + myorder.quantitypreordered > 0"
|
||||
rounded
|
||||
icon="fas fa-shopping-cart"
|
||||
color="primary"
|
||||
@@ -264,7 +297,7 @@
|
||||
|
||||
<tbody>
|
||||
<tr
|
||||
v-for="(ordcart, index) of arrordersCart"
|
||||
v-for="(ordcart, index) of listord"
|
||||
:key="index"
|
||||
class="listaev listaev__table"
|
||||
>
|
||||
@@ -285,9 +318,22 @@
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<div v-for="(singleord, index) in ordcart.items" :key="index">
|
||||
<span v-if="singleord.order.idProduct === myproduct._id">{{
|
||||
singleord.order.quantity
|
||||
}}</span>
|
||||
<span
|
||||
v-if="
|
||||
singleord.order.idProduct === myproduct._id &&
|
||||
singleord.order.quantity > 0
|
||||
"
|
||||
>
|
||||
{{ singleord.order.quantity }}</span
|
||||
>
|
||||
<span
|
||||
v-if="
|
||||
singleord.order.idProduct === myproduct._id &&
|
||||
singleord.order.quantitypreordered > 0
|
||||
"
|
||||
>
|
||||
{{ singleord.order.quantitypreordered }}</span
|
||||
>
|
||||
</div>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
@@ -300,7 +346,7 @@
|
||||
<td class="text-center">
|
||||
Totali:
|
||||
<span class="totali">{{
|
||||
products.getSumQtyOrderProductInOrdersCart(myproduct._id)
|
||||
sumval
|
||||
}}</span>
|
||||
</td>
|
||||
<td> </td>
|
||||
|
||||
@@ -40,8 +40,9 @@ export default defineComponent({
|
||||
}
|
||||
|
||||
function addsubqty(addqty: boolean, subqty: boolean) {
|
||||
if (products.isQtyAvailableByOrder(props.order)) {
|
||||
if (addqty) {
|
||||
if (props.order.quantity >= 10)
|
||||
if (props.order.quantity >= 20)
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -49,6 +50,20 @@ export default defineComponent({
|
||||
if (props.order.quantity === 0)
|
||||
return false
|
||||
}
|
||||
} else {
|
||||
|
||||
if (products.isInPreorderByOrder(props.order)) {
|
||||
if (addqty) {
|
||||
if (props.order.quantitypreordered >= 20)
|
||||
return false
|
||||
}
|
||||
|
||||
if (subqty) {
|
||||
if (props.order.quantitypreordered === 0)
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
products.addSubQtyToItem({
|
||||
addqty,
|
||||
@@ -56,13 +71,14 @@ export default defineComponent({
|
||||
order: props.order,
|
||||
}).then((res: any) => {
|
||||
if (res.risult) {
|
||||
order.value.quantity = res.qty
|
||||
order.value.quantity = res.myord.quantity
|
||||
order.value.quantitypreordered = res.myord.quantitypreordered
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function isApplicatoSconto() {
|
||||
const totalipotetico = order.value.price * order.value.quantity
|
||||
const totalipotetico = order.value.price * (order.value.quantity + order.value.quantitypreordered)
|
||||
if (totalipotetico > order.value.TotalPriceProduct) {
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -1,45 +1,89 @@
|
||||
<template>
|
||||
<div v-if="order && order.product" class="q-pa-xs q-gutter-xs">
|
||||
|
||||
<div v-if="order.product" class="row items-center justify-evenly no-wrap">
|
||||
<div class="col-2 text-h6 ellipsis">
|
||||
<q-img v-if="order.product && order.product.img" :src="`` + order.product.img" :alt="order.product.name"
|
||||
:class="myimgclass">
|
||||
<q-img
|
||||
v-if="order.product && order.product.img"
|
||||
:src="`` + order.product.img"
|
||||
:alt="order.product.name"
|
||||
:class="myimgclass"
|
||||
>
|
||||
</q-img>
|
||||
</div>
|
||||
<div class="col-4 q-ml-xs">
|
||||
{{ order.product.name }}
|
||||
<div v-if="showall">
|
||||
<br><span class="text-grey">{{ order.product.description }}</span>
|
||||
<br /><span class="text-grey">{{ order.product.description }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-3">
|
||||
<div class="row q-mb-xs no-wrap items-center centeritems">
|
||||
<q-btn v-if="showall && !nomodif" round size="xs" text-color="grey" icon="fas fa-minus"
|
||||
@click="addsubqty(false, true)"></q-btn>
|
||||
<!--<q-field outlined dense style="width: 25px; height: 20px; " class="q-mx-xs text-subtitle4">
|
||||
<template v-slot:control>
|
||||
<div class="self-center no-outline" tabindex="0" >{{ order.quantity }}</div>
|
||||
</template>
|
||||
</q-field>-->
|
||||
<div :class="`q-mx-sm text-blue-14`">{{ order.quantity }}</div>
|
||||
<q-btn v-if="showall && !nomodif" round size="xs" text-color="grey" icon="fas fa-plus"
|
||||
@click="addsubqty(true, false)"></q-btn>
|
||||
<q-btn
|
||||
v-if="showall && !nomodif"
|
||||
round
|
||||
size="xs"
|
||||
text-color="grey"
|
||||
icon="fas fa-minus"
|
||||
@click="addsubqty(false, true)"
|
||||
></q-btn>
|
||||
<div v-if="order.quantity > 0" :class="`q-mx-sm text-blue-14`">
|
||||
{{ order.quantity }}
|
||||
</div>
|
||||
<div v-if="order.quantity > 0 && order.quantitypreordered > 0">
|
||||
+ {{ $t('ecomm.preord') }}:
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="order.quantitypreordered > 0"
|
||||
:class="`q-mx-sm text-blue-14`"
|
||||
>
|
||||
{{ order.quantitypreordered }}
|
||||
</div>
|
||||
<q-btn
|
||||
v-if="showall && !nomodif"
|
||||
round
|
||||
size="xs"
|
||||
text-color="grey"
|
||||
icon="fas fa-plus"
|
||||
@click="addsubqty(true, false)"
|
||||
></q-btn>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-2 no-wrap text-subtitle3_short q-mr-sm">
|
||||
<span :class="isApplicatoSconto() ? 'ordine_scontato_nuovo' : ''">€ {{ order.TotalPriceProduct ? order.TotalPriceProduct.toFixed(2) : 0 }}</span>
|
||||
<span :class="isApplicatoSconto() ? 'ordine_scontato_nuovo' : ''"
|
||||
>€ {{
|
||||
order.TotalPriceProduct ? order.TotalPriceProduct.toFixed(2) : 0
|
||||
}}</span
|
||||
>
|
||||
<span v-if="isApplicatoSconto()">
|
||||
<span class="ordine_scontato">(<span class="barrato">€ {{(order.price * order.quantity).toFixed(2) }}</span>)</span>
|
||||
<span class="ordine_scontato"
|
||||
>(<span class="barrato"
|
||||
>€
|
||||
{{
|
||||
(
|
||||
order.price * order.quantity +
|
||||
order.price * order.quantitypreordered
|
||||
).toFixed(2)
|
||||
}}</span
|
||||
>)</span
|
||||
>
|
||||
</span>
|
||||
<span v-if="isApplicatoSconto()" class="ordine_scritta_sconto">{{ $t('ecomm.sconto_applicato', {risparmio: getRisparmio()}) }}</span>
|
||||
<span v-if="isApplicatoSconto()" class="ordine_scritta_sconto">{{
|
||||
$t('ecomm.sconto_applicato', { risparmio: getRisparmio() })
|
||||
}}</span>
|
||||
</div>
|
||||
<div class="col-1">
|
||||
<q-btn v-if="!nomodif" icon="fas fa-times" color="negative" round size="xs" @click="removeFromCard">
|
||||
<q-btn
|
||||
v-if="!nomodif"
|
||||
icon="fas fa-times"
|
||||
color="negative"
|
||||
round
|
||||
size="xs"
|
||||
@click="removeFromCard"
|
||||
>
|
||||
</q-btn>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ const msg_website_it = {
|
||||
categories: 'Categorie',
|
||||
storehouses: 'Magazzino',
|
||||
providers: 'Fornitori',
|
||||
gasordine: 'Gas Ordine',
|
||||
scontisticas: 'Scontistica',
|
||||
departments: 'Uffici',
|
||||
orders: 'Ordini Ricevuti',
|
||||
@@ -125,6 +126,7 @@ const msg_website_it = {
|
||||
only_residenti: 'Solo Residenti',
|
||||
only_consiglio: 'Solo Consiglieri',
|
||||
color: 'Colore',
|
||||
gasordini: 'Gas Ordini',
|
||||
},
|
||||
msg: {
|
||||
myAppName: 'Più che Buono',
|
||||
|
||||
@@ -50,7 +50,7 @@ export default function () {
|
||||
const arrcart = products.cart
|
||||
if (!!arrcart) {
|
||||
if (!!arrcart.items) {
|
||||
const total = arrcart.items.reduce((sum, item) => sum + item.order.quantity, 0)
|
||||
const total = arrcart.items.reduce((sum, item) => sum + item.order.quantity + item.order.quantitypreordered , 0)
|
||||
return total
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { IAction } from '@src/model/Projects'
|
||||
import { IFriends, IGroupShort, IMyGroup, IPaymentType } from '@src/model/UserStore'
|
||||
import {
|
||||
IDepartment, IProducer, IShareWithUs, IStorehouse, IProvider, IScontistica, ICategory
|
||||
IDepartment, IProducer, IShareWithUs, IStorehouse, IProvider, IScontistica, ICategory, IGasordine
|
||||
} from '@src/model/Products'
|
||||
|
||||
import { IUserFields, IUserProfile } from '@src/model/UserStore'
|
||||
@@ -442,6 +442,7 @@ export interface IGlobalState {
|
||||
calzoom: ICalZoom[],
|
||||
producers: IProducer[],
|
||||
providers: IProvider[],
|
||||
gasordines: IGasordine[],
|
||||
scontisticas: IScontistica[],
|
||||
storehouses: IStorehouse[],
|
||||
departments: IDepartment[],
|
||||
|
||||
@@ -22,8 +22,11 @@ export interface IProduct {
|
||||
color?: string,
|
||||
size?: string,
|
||||
quantityAvailable?: number,
|
||||
bookableAvailableQty?: number,
|
||||
QuantitaOrdinateInAttesa?: number,
|
||||
stockQty?: number,
|
||||
QuantitaPrenotateInAttesa?: number,
|
||||
stockQty: number,
|
||||
bookableQty: number,
|
||||
canBeShipped?: boolean,
|
||||
canBeBuyOnline?: boolean,
|
||||
weight?: number,
|
||||
@@ -46,6 +49,7 @@ export interface IOrder {
|
||||
idProduct?: string
|
||||
idProducer?: string
|
||||
idProvider?: string
|
||||
idGasordine?: string
|
||||
idStorehouse?: string
|
||||
idScontisticas?: string[]
|
||||
price: number
|
||||
@@ -54,6 +58,7 @@ export interface IOrder {
|
||||
color?: string
|
||||
size?: string
|
||||
quantity: number
|
||||
quantitypreordered: number
|
||||
weight?: number
|
||||
stars?: number
|
||||
product?: IProduct
|
||||
@@ -61,6 +66,7 @@ export interface IOrder {
|
||||
storehouse?: IStorehouse
|
||||
scontisticas?: IScontistica[]
|
||||
provider?: IProvider
|
||||
gasordine?: IGasordine
|
||||
date_created?: Date
|
||||
date_checkout?: Date
|
||||
date_payment?: Date
|
||||
@@ -126,6 +132,19 @@ export interface IProvider {
|
||||
website?: string,
|
||||
}
|
||||
|
||||
export interface IGasordine {
|
||||
_id?: any
|
||||
idapp?: string
|
||||
active: boolean
|
||||
name?: string,
|
||||
description?: string,
|
||||
referent?: string,
|
||||
city?: string,
|
||||
img?: string,
|
||||
dataora_chiusura?: Date,
|
||||
dataora_ritiro?: Date,
|
||||
}
|
||||
|
||||
export interface IScontistica {
|
||||
_id?: any
|
||||
idapp?: string
|
||||
|
||||
0
src/rootgen/admin/gasordini/gasordini.scss
Executable file
0
src/rootgen/admin/gasordini/gasordini.scss
Executable file
34
src/rootgen/admin/gasordini/gasordini.ts
Executable file
34
src/rootgen/admin/gasordini/gasordini.ts
Executable file
@@ -0,0 +1,34 @@
|
||||
|
||||
import { colTableGasordine } from '@src/store/Modules/fieldsTable'
|
||||
|
||||
import { CImgText } from '../../../components/CImgText/index'
|
||||
|
||||
import { defineComponent } from 'vue'
|
||||
import { CCard } from '../../../components/CCard'
|
||||
import { CMyPage } from '../../../components/CMyPage'
|
||||
import { CTitleBanner } from '../../../components/CTitleBanner'
|
||||
import { CGridTableRec } from '../../../components/CGridTableRec'
|
||||
|
||||
import MixinMetaTags from '../../../mixins/mixin-metatags'
|
||||
|
||||
export default defineComponent({
|
||||
name: 'GasOrdini',
|
||||
components: { CImgText, CCard, CMyPage, CTitleBanner, CGridTableRec },
|
||||
setup() {
|
||||
const pagination = {
|
||||
sortBy: 'name',
|
||||
descending: false,
|
||||
page: 2,
|
||||
rowsPerPage: 5
|
||||
// rowsNumber: xx if getting data from a server
|
||||
}
|
||||
|
||||
const { setmeta } = MixinMetaTags()
|
||||
|
||||
return {
|
||||
colTableGasordine,
|
||||
setmeta,
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
31
src/rootgen/admin/gasordini/gasordini.vue
Executable file
31
src/rootgen/admin/gasordini/gasordini.vue
Executable file
@@ -0,0 +1,31 @@
|
||||
<template>
|
||||
<CMyPage title="Gas Ordini" imgbackground="images/fornitori.jpg" sizes="max-height: 120px">
|
||||
<span>{{
|
||||
setmeta({
|
||||
title: 'Gas Ordini',
|
||||
description: '',
|
||||
keywords: '',
|
||||
})
|
||||
}}
|
||||
</span>
|
||||
|
||||
<div class="q-ma-sm q-gutter-sm q-pa-xs">
|
||||
<CTitleBanner title="Gas Ordini"></CTitleBanner>
|
||||
<CGridTableRec
|
||||
prop_mytable="gasordines"
|
||||
prop_mytitle="Lista Gas Ordini"
|
||||
:prop_mycolumns="colTableGasordine"
|
||||
prop_colkey="name"
|
||||
nodataLabel="Nessun Gas Ordine"
|
||||
noresultLabel="Il filtro selezionato non ha trovato nessun risultato">
|
||||
|
||||
</CGridTableRec>
|
||||
</div>
|
||||
</CMyPage>
|
||||
</template>
|
||||
<script lang="ts" src="./gasordini.ts">
|
||||
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
@import 'gasordini.scss';
|
||||
</style>
|
||||
@@ -125,6 +125,20 @@ function getRoutesEcomm(site: ISites) {
|
||||
onlyManager: true,
|
||||
onlyEditor: true
|
||||
},
|
||||
{
|
||||
active: true,
|
||||
order: 30,
|
||||
path: '/admin/ecommerce/gasordini',
|
||||
materialIcon: 'fas fa-file-alt',
|
||||
name: 'pages.gasordini',
|
||||
component: () => import('@/rootgen/admin/gasordini/gasordini.vue'),
|
||||
inmenu: true,
|
||||
submenu: true,
|
||||
level_parent: 0,
|
||||
level_child: 0.5,
|
||||
onlyManager: true,
|
||||
onlyEditor: true
|
||||
},
|
||||
{
|
||||
active: true,
|
||||
order: 30,
|
||||
|
||||
@@ -62,6 +62,8 @@ const msg_it = {
|
||||
quantity: 'Quantità',
|
||||
quantityAvailable: 'Disponibili',
|
||||
stockQty: 'In Magazzino',
|
||||
bookableQty: 'Prenotabili',
|
||||
bookableAvailableQty: 'Disponib. Prenotabili',
|
||||
weight: 'Peso',
|
||||
unit: 'Unità di Misura',
|
||||
stars: 'Voto',
|
||||
@@ -1649,7 +1651,8 @@ const msg_it = {
|
||||
ord_not_confirmed: 'E\' avvenuto un errore. Ordine non Confermato. Ricaricare la pagina e riprovare.',
|
||||
btn_cassa: 'Vai alla Cassa',
|
||||
available: 'Disponibili',
|
||||
preorders: 'In Prenotazione',
|
||||
preorders: 'Pre-Ordinabili',
|
||||
preord: 'Pre-Ordinate',
|
||||
di_cui_x_in_carrello: '(nel tuo carrello: {qty})',
|
||||
evaso: 'Ordine Evaso',
|
||||
consegnato: 'Ordine Consegnato',
|
||||
@@ -1668,6 +1671,7 @@ const msg_it = {
|
||||
codice: 'Codice',
|
||||
code_o_text_search: 'Inserisci il codice o il testo',
|
||||
code_add_to_cart: 'Aggiungi un codice al carrello',
|
||||
qta_prenotate_in_attesa: '(Preordinate In attesa {qty})',
|
||||
},
|
||||
},
|
||||
|
||||
|
||||
@@ -442,6 +442,18 @@ export const colTableProviders = [
|
||||
AddCol(DeleteRec),
|
||||
AddCol(DuplicateRec),
|
||||
]
|
||||
export const colTableGasordine = [
|
||||
AddCol({ name: 'active', label_trans: 'sites.active', fieldtype: costanti.FieldType.boolean }),
|
||||
AddCol({ name: 'name', label_trans: 'store.name' }),
|
||||
AddCol({ name: 'description', label_trans: 'store.description' }),
|
||||
AddCol({ name: 'referente', label_trans: 'store.referent' }),
|
||||
AddCol({ name: 'city', label_trans: 'store.city' }),
|
||||
AddCol({ name: 'img', label_trans: 'store.img' }),
|
||||
AddCol({ name: 'dataora_chiusura', label_trans: 'gas.dataora_chiusura', fieldtype: costanti.FieldType.date }),
|
||||
AddCol({ name: 'dataora_ritiro', label_trans: 'gas.dataora_ritiro', fieldtype: costanti.FieldType.date }),
|
||||
AddCol(DeleteRec),
|
||||
AddCol(DuplicateRec),
|
||||
]
|
||||
export const colTableScontistica = [
|
||||
AddCol({ name: 'code', label_trans: 'scontistica.code' }),
|
||||
AddCol({ name: 'description', label_trans: 'scontistica.description' }),
|
||||
@@ -1999,11 +2011,21 @@ export const colTableProducts = [
|
||||
label_trans: 'products.quantityAvailable',
|
||||
fieldtype: costanti.FieldType.number
|
||||
}),
|
||||
AddCol({
|
||||
name: 'bookableAvailableQty',
|
||||
label_trans: 'products.bookableAvailableQty',
|
||||
fieldtype: costanti.FieldType.number
|
||||
}),
|
||||
AddCol({
|
||||
name: 'stockQty',
|
||||
label_trans: 'products.stockQty',
|
||||
fieldtype: costanti.FieldType.number
|
||||
}),
|
||||
AddCol({
|
||||
name: 'bookableQty',
|
||||
label_trans: 'products.bookableQty',
|
||||
fieldtype: costanti.FieldType.number
|
||||
}),
|
||||
AddCol({ name: 'canBeShipped', label_trans: 'products.canBeShipped', fieldtype: costanti.FieldType.boolean }),
|
||||
AddCol({ name: 'canBeBuyOnline', label_trans: 'products.canBeBuyOnline', fieldtype: costanti.FieldType.boolean }),
|
||||
AddCol({ name: 'weight', label_trans: 'products.weight', fieldtype: costanti.FieldType.number }),
|
||||
@@ -3563,6 +3585,13 @@ export const fieldsTable = {
|
||||
colkey: '_id',
|
||||
collabel: 'name',
|
||||
},
|
||||
{
|
||||
value: 'gasordines',
|
||||
label: 'Gas Ordini',
|
||||
columns: colTableGasordine,
|
||||
colkey: '_id',
|
||||
collabel: 'name',
|
||||
},
|
||||
{
|
||||
value: 'scontisticas',
|
||||
label: 'Scontistica',
|
||||
|
||||
@@ -8270,6 +8270,7 @@ export const tools = {
|
||||
},
|
||||
|
||||
|
||||
|
||||
// FINE !
|
||||
|
||||
// getLocale() {
|
||||
|
||||
@@ -30,6 +30,17 @@ export const useProducts = defineStore('Products', {
|
||||
const indelem = state.products.findIndex((prod: IProduct) => prod._id === res.data.product._id)
|
||||
if (indelem >= 0) {
|
||||
state.products[indelem] = { ...res.data.product }
|
||||
|
||||
/*if (!res.data.orders) {
|
||||
// aggiorna anche tutti i product negli ordini !
|
||||
let ordcart: IOrderCart
|
||||
for (ordcart of state.orders) {
|
||||
for (const item of ordcart.items!) {
|
||||
if (item.order.idProduct === res.data.product.idProduct)
|
||||
item.order.product = res.data.product
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
if (res && res.data.orders) {
|
||||
@@ -44,12 +55,15 @@ export const useProducts = defineStore('Products', {
|
||||
|
||||
getProductById: (state: IProductsState) => (id: string): IProduct => {
|
||||
const prod = state.products.find((prod: IProduct) => prod._id === id)
|
||||
return prod ? prod : { active: false, img: '', code: '', name: '', storehouses: [], scontisticas: [], price: 0 }
|
||||
return prod ? prod : { active: false, img: '', code: '', name: '', storehouses: [], scontisticas: [], price: 0, stockQty: 0, bookableQty: 0 }
|
||||
},
|
||||
|
||||
getProductByCode: (state: IProductsState) => (code: string): IProduct => {
|
||||
const prod = state.products.find((prod: IProduct) => prod.code === code)
|
||||
return prod ? prod : { active: false, img: '', code: '', name: '', storehouses: [], scontisticas: [], price: 0 }
|
||||
return prod ? prod : {
|
||||
active: false, img: '', code: '', name: '', storehouses: [], scontisticas: [], price: 0,
|
||||
stockQty: 0, bookableQty: 0
|
||||
}
|
||||
},
|
||||
|
||||
getCart: (state: IProductsState) => (): ICart => {
|
||||
@@ -109,6 +123,28 @@ export const useProducts = defineStore('Products', {
|
||||
return null
|
||||
},
|
||||
|
||||
getSumQtyPreOrderInOrdersCart: (state: IProductsState) => (idproduct: string): number => {
|
||||
let totalQuantity = 0;
|
||||
|
||||
if (state.orders) {
|
||||
const orderscart = state.orders
|
||||
if (orderscart) {
|
||||
for (const myord of orderscart) {
|
||||
if (myord.items) {
|
||||
for (const item of myord.items) {
|
||||
if (item.order) {
|
||||
if ((item.order.idProduct === idproduct) && (item.order.status! < shared_consts.OrderStatus.CHECKOUT_SENT)) {
|
||||
totalQuantity += (item.order.quantitypreordered) || 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return totalQuantity
|
||||
},
|
||||
|
||||
getSumQtyOrderProductInOrdersCart: (state: IProductsState) => (idproduct: string): number => {
|
||||
let totalQuantity = 0;
|
||||
|
||||
@@ -120,7 +156,7 @@ export const useProducts = defineStore('Products', {
|
||||
for (const item of myord.items) {
|
||||
if (item.order) {
|
||||
if ((item.order.idProduct === idproduct) && (item.order.status! < shared_consts.OrderStatus.CHECKOUT_SENT)) {
|
||||
totalQuantity += item.order.quantity || 0;
|
||||
totalQuantity += (item.order.quantity) || 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -169,17 +205,6 @@ export const useProducts = defineStore('Products', {
|
||||
return []
|
||||
},
|
||||
|
||||
updateQuantityAvailable: (state: IProductsState) => (id: string): any => {
|
||||
|
||||
const indelem = state.products.findIndex((prod: IProduct) => prod._id === id)
|
||||
if (indelem >= 0) {
|
||||
state.products[indelem].quantityAvailable = state.products[indelem].stockQty
|
||||
if (state.products[indelem].QuantitaOrdinateInAttesa! > 0) {
|
||||
state.products[indelem].quantityAvailable! -= state.products[indelem].QuantitaOrdinateInAttesa!
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
getRecordEmpty: (state: IProductsState) => (): IProduct => {
|
||||
|
||||
const tomorrow = tools.getDateNow()
|
||||
@@ -205,9 +230,12 @@ export const useProducts = defineStore('Products', {
|
||||
color: '',
|
||||
size: '',
|
||||
quantityAvailable: 0,
|
||||
bookableAvailableQty: 0,
|
||||
stockQty: 0,
|
||||
bookableQty: 0,
|
||||
canBeShipped: false,
|
||||
QuantitaOrdinateInAttesa: 0,
|
||||
QuantitaPrenotateInAttesa: 0,
|
||||
canBeBuyOnline: false,
|
||||
weight: 0,
|
||||
unit: 0,
|
||||
@@ -241,6 +269,7 @@ export const useProducts = defineStore('Products', {
|
||||
weight: product.weight,
|
||||
|
||||
quantity: order.quantity,
|
||||
quantitypreordered: order.quantitypreordered,
|
||||
idStorehouse: order.idStorehouse,
|
||||
idScontisticas: product.idScontisticas,
|
||||
}
|
||||
@@ -411,12 +440,13 @@ export const useProducts = defineStore('Products', {
|
||||
const ordcart = this.getOrderProductInCart(product._id)
|
||||
if (ordcart) {
|
||||
|
||||
if (!addqty && ordcart.quantity === 1) {
|
||||
if (!addqty && ((ordcart.quantity + ordcart.quantitypreordered) === 1)) {
|
||||
// sto per rimuovere l'ultimo pezzo, quindi cancello direttamente
|
||||
const risrem = await this.removeFromCart({ order: ordcart })
|
||||
|
||||
if (risrem) {
|
||||
order.quantity = 0
|
||||
order.quantitypreordered = 0
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
@@ -429,14 +459,22 @@ export const useProducts = defineStore('Products', {
|
||||
order: ordcart,
|
||||
}).then((res: any) => {
|
||||
if (res && res.risult) {
|
||||
order.quantity = res.qty
|
||||
order.quantity = res.myord.quantity
|
||||
order.quantitypreordered = res.myord.quantitypreordered
|
||||
}
|
||||
return res;
|
||||
})
|
||||
}
|
||||
} else {
|
||||
if (order.quantity === 0)
|
||||
if (this.isQtyAvailableByProduct(product)) {
|
||||
order.quantity = 1
|
||||
order.quantitypreordered = 0
|
||||
} else {
|
||||
if (this.isInPreorderByProduct(product)) {
|
||||
order.quantitypreordered = 1
|
||||
order.quantity = 0
|
||||
}
|
||||
}
|
||||
|
||||
if (!order.idStorehouse) {
|
||||
if (product.storehouses.length === 1) {
|
||||
@@ -467,7 +505,7 @@ export const useProducts = defineStore('Products', {
|
||||
}
|
||||
this.updateDataProduct(res)
|
||||
|
||||
return { risult: !!res, qty: order.quantity }
|
||||
return { risult: !!res, myord: res.data.myord }
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log('error addToCart', error)
|
||||
@@ -496,7 +534,7 @@ export const useProducts = defineStore('Products', {
|
||||
.then((res) => {
|
||||
this.updateDataProduct(res)
|
||||
|
||||
return { risult: !!res, qty: res.data.qty }
|
||||
return { risult: !!res, myord: res.data.myord }
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log('error addSubQtyToItem', error)
|
||||
@@ -598,34 +636,86 @@ export const useProducts = defineStore('Products', {
|
||||
async addtoCartBase({ $q, t, code, order, addqty }: { $q: any, t: any, code: string, order: IOrder, addqty: boolean }) {
|
||||
let product = this.getProductByCode(code)
|
||||
|
||||
return this.addToCart({ product, order, addqty }).then((ris) => {
|
||||
return await this.addToCart({ product, order, addqty })
|
||||
.then((ris) => {
|
||||
let strprod = t('ecomm.prodotto')
|
||||
|
||||
if (order.quantity > 1 || order.quantity === 0)
|
||||
let msg = ''
|
||||
console.log('ris', ris)
|
||||
if (ris && ris.myord == null) {
|
||||
msg = t('ecomm.prodotto_tolto')
|
||||
tools.showNotif($q, msg)
|
||||
return
|
||||
}
|
||||
if (ris === null || ris.myord == null) {
|
||||
msg = t('ecomm.error_cart')
|
||||
tools.showNegativeNotif($q, msg)
|
||||
return
|
||||
} else {
|
||||
|
||||
let qta = ris.myord.quantity + ris.myord.quantitypreordered
|
||||
if (qta > 1 || qta === 0)
|
||||
strprod = t('ecomm.prodotti')
|
||||
|
||||
let msg = ''
|
||||
if (ris === null)
|
||||
msg = t('ecomm.error_cart')
|
||||
else {
|
||||
|
||||
if (order.quantity === 0) {
|
||||
msg = t('ecomm.prodotto_tolto')
|
||||
} else {
|
||||
msg = t('ecomm.prod_sul_carrello', { strprod, qty: order.quantity })
|
||||
if (qta > 0) {
|
||||
msg = t('ecomm.prod_sul_carrello', { strprod, qty: qta })
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
this.updateQuantityAvailable(product._id)
|
||||
//updateproduct()
|
||||
|
||||
if (ris === null || order.quantity === 0)
|
||||
if (ris === null || ris.myord.quantity === 0)
|
||||
tools.showNotif($q, msg)
|
||||
else
|
||||
tools.showPositiveNotif($q, msg)
|
||||
|
||||
return ris
|
||||
})
|
||||
},
|
||||
|
||||
getQuantityByOrder($t: any, order: IOrder): string {
|
||||
let mystr = '';
|
||||
if (order.quantity > 0) {
|
||||
mystr += order.quantity
|
||||
}
|
||||
if ((order.quantitypreordered > 0) && (order.quantity > 0)) {
|
||||
mystr += ' ' + $t('ecomm.available')
|
||||
mystr += ' + '
|
||||
}
|
||||
if (order.quantitypreordered > 0) {
|
||||
mystr += ' ' + order.quantitypreordered + ' ' + $t('ecomm.preord');
|
||||
}
|
||||
return mystr
|
||||
},
|
||||
|
||||
isQtyAvailableByProduct(product: IProduct): boolean {
|
||||
if (product) {
|
||||
return (product.quantityAvailable! > 0)
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
isInPreorderByProduct(product: IProduct): boolean {
|
||||
if (product) {
|
||||
return (product.bookableAvailableQty! > 0)
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
isQtyAvailableByOrder(order: IOrder): boolean {
|
||||
if (order && order.product) {
|
||||
return this.isQtyAvailableByProduct(order.product)
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
isInPreorderByOrder(order: IOrder): boolean {
|
||||
if (order && order.product) {
|
||||
return this.isInPreorderByProduct(order.product)
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
},
|
||||
|
||||
|
||||
@@ -122,6 +122,7 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
storehouses: [],
|
||||
scontisticas: [],
|
||||
providers: [],
|
||||
gasordines: [],
|
||||
departments: [],
|
||||
categories: [],
|
||||
sharewithus: [],
|
||||
@@ -309,6 +310,7 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
else if (table === 'producers') ris = state.producers
|
||||
else if (table === 'storehouses') ris = state.storehouses
|
||||
else if (table === 'providers') ris = state.providers
|
||||
else if (table === 'gasordines') ris = state.gasordines
|
||||
else if (table === 'scontisticas') ris = state.scontisticas
|
||||
else if (table === 'groups') ris = state.groups
|
||||
else if (table === 'resps') ris = state.resps
|
||||
@@ -1537,6 +1539,7 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
this.producers = (res.data.producers) ? [...res.data.producers] : []
|
||||
this.storehouses = (res.data.storehouses) ? [...res.data.storehouses] : []
|
||||
this.providers = (res.data.providers) ? [...res.data.providers] : []
|
||||
this.gasordines = (res.data.gasordines) ? [...res.data.gasordines] : []
|
||||
this.scontisticas = (res.data.scontisticas) ? [...res.data.scontisticas] : []
|
||||
this.groups = (res.data.groups) ? [...res.data.groups] : []
|
||||
this.resps = (res.data.resps) ? [...res.data.resps] : []
|
||||
|
||||
@@ -183,7 +183,7 @@ export default defineComponent({
|
||||
|
||||
const myprod = productStore.getProductByCode(lowerSearchText);
|
||||
if (myprod && myprod.active) {
|
||||
let myorder: IOrder = { quantity: 1, price: 0, TotalPriceProduct: 0 }
|
||||
let myorder: IOrder = { quantity: 1, quantitypreordered: 0, price: 0, TotalPriceProduct: 0 }
|
||||
await productStore.addtoCartBase({ $q, t, code: myprod.code!, order: myorder, addqty: true })
|
||||
search.value = ''
|
||||
load()
|
||||
|
||||
@@ -312,6 +312,7 @@ export default defineComponent({
|
||||
getCols,
|
||||
endload,
|
||||
getOrdersCartWithTotals,
|
||||
productStore,
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
v-if="!!item && item.order && item.order.product"
|
||||
>
|
||||
{{ item.order.product.name }} ({{
|
||||
item.order.quantity
|
||||
productStore.getQuantityByOrder($t, item.order)
|
||||
}})<br />
|
||||
</div>
|
||||
</div>
|
||||
@@ -141,7 +141,7 @@
|
||||
<div v-for="(item, index) of props.row.items" :key="index">
|
||||
<div v-if="!!item.order && item.order.product">
|
||||
{{ item.order.product.name }} ({{
|
||||
item.order.quantity
|
||||
productStore.getQuantityByOrder($t, item.order)
|
||||
}})<br />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user