aggiornamento Ordini GAS filtri

This commit is contained in:
Surya Paolo
2024-02-13 18:13:36 +01:00
parent 6a01379b67
commit c6e0caa3f4
71 changed files with 1105 additions and 281 deletions

View File

@@ -642,6 +642,14 @@
></q-btn>
<br />
</div>
<div class="row">
<q-btn
label="Genera CSV Ordine Prodotti"
color="primary"
@click="EseguiFunz('GeneraCSVOrdineProdotti')"
></q-btn>
<br />
</div>
</template>
<script lang="ts" src="./dbop.ts">
</script>

View File

@@ -0,0 +1,41 @@
$heightBtn: 100%;
.card .product-image {
height: 300px;
}
.mycol{
color:gray;
}
.q-item__label--caption{
color: blue;
}
.ordstat{
text-align: center;
border: 1px solid #8778cb;
border-radius: 10px;
padding: 5px;
}
.confermato {
font-weight: bold;
color: green;
}
.note {
font-style: italic;
color:blue;
}
.totali {
font-weight: bold;
color: blue;
font-size: 1rem;
}
.totaliacq {
font-weight: bold;
color: red;
font-size: 1rem;
}

View File

@@ -0,0 +1,236 @@
import { defineComponent, onMounted, ref, watch } from 'vue'
import { tools } from '@store/Modules/tools'
import { useUserStore } from '@store/UserStore'
import { useRouter } from 'vue-router'
import { useGlobalStore } from '@store/globalStore'
import { useProducts } from '@store/Products'
import { useI18n } from '@/boot/i18n'
import { toolsext } from '@store/Modules/toolsext'
import { useQuasar } from 'quasar'
import { costanti } from '@costanti'
import { shared_consts } from '@src/common/shared_vuejs'
// import MixinBase from '@src/mixins/mixin-base'
import { serv_constants } from '@store/Modules/serv_constants'
import { fieldsTable } from '@store/Modules/fieldsTable'
import { CSingleCart } from '../../../components/CSingleCart'
import { CTitleBanner, CMyFieldDb } from '@components'
import { ICart, IOrder, IOrderCart } from '@src/model'
export default defineComponent({
name: 'gestoreordini',
components: { CSingleCart, CTitleBanner, CMyFieldDb },
props: {},
setup() {
const userStore = useUserStore()
const globalStore = useGlobalStore()
const productStore = useProducts()
const $router = useRouter()
const $q = useQuasar()
const { t } = useI18n()
const mygestord = ref(<any[] | undefined>[])
const myarrrec = ref(<any>{})
const myoldrec = ref(<any>{})
const templemail = ref('')
const storeGasordine = ref(<any>'')
const cosa = ref(0)
const arrout = ref(<any[]>[])
const initialPagination = ref({
sortBy: 'desc',
descending: false,
rowsPerPage: 10,
// rowsNumber: xx if getting data from a server
})
const conferma_carrello = ref(false)
const conferma_ordine = ref(false)
const endload = ref(false)
const taborders = ref(shared_consts.OrderStat.IN_CORSO.value)
const columns = ref(<any>[
{
name: 'name',
required: true,
align: 'left',
label: 'Nome Prodotto',
field: 'nameSurname',
sortable: true
},
{
name: 'weight',
required: true,
label: 'Peso',
field: 'weight',
sortable: true
},
{
name: 'price_acquistato',
required: true,
label: 'Prezzo (P)',
field: 'price_acquistato',
sortable: true
},
{
name: 'totalQuantity',
required: true,
label: 'Qty',
field: 'totalQuantity',
sortable: true
},
{
name: 'totalPrice_acquistato',
required: true,
label: 'Totale (P)',
field: 'totalPrice_acquistato',
sortable: true
},
{
name: 'totalPrice',
required: true,
label: 'Totale (C)',
field: 'totalPrice',
sortable: true
},
])
watch(() => cosa.value, (newval, oldval) => {
})
watch(() => storeGasordine.value, (newval, oldval) => {
tools.setCookie(tools.COOK_SELGAS, storeGasordine.value)
updateorders()
})
function getCols(props: any) {
return props.cols.filter((col: any) => col.name !== 'desc')
}
async function getGestoreOrd() {
const hasGasordine: any = (cosa.value === shared_consts.PROD.TUTTI) ? undefined : (cosa.value === shared_consts.PROD.GAS)
const ris = await productStore.getGestoreOrdini({ idGasordine: storeGasordine.value })
return ris
}
async function getGestoreOrdWithTotals() {
const orderscart = await getGestoreOrd();
if (orderscart) {
// Calculate totals
const totals = {
name: 'TOTALI',
weight: '',
totalQuantity: orderscart.reduce((total: number, rec: any) => total + rec.totalQuantity, 0),
totalPrice_acquistato: orderscart.reduce((total: number, rec: any) => total + rec.totalPrice_acquistato, 0),
totalPrice: orderscart.reduce((total: number, rec: any) => total + rec.totalPrice, 0),
};
let rowsWithTotals: any = [...orderscart];
if (tools.isManager()) {
// Combine orders and totals
rowsWithTotals.push(totals);
}
return rowsWithTotals;
} else {
return []
}
}
async function updateorders() {
mygestord.value = await getGestoreOrd()
if (mygestord.value) {
for (const gestord of mygestord.value) {
myarrrec.value[gestord._id] = Object.keys(gestord)
}
}
arrout.value = await getGestoreOrdWithTotals()
}
async function mounted() {
storeGasordine.value = tools.getCookie(tools.COOK_SELGAS, '')
await userStore.newsletterload(false)
await productStore.loadProducts()
taborders.value = -1
await updateorders()
if (taborders.value === -1)
taborders.value = shared_consts.OrderStat.IN_CORSO.value
endload.value = true
}
function CanBeShipped() {
return productStore.cart.items!.filter((rec) => rec.order.product!.canBeShipped).length
}
function CanBeBuyOnline() {
return productStore.cart.items!.filter((rec) => rec.order.product!.canBeBuyOnline).length
}
function getnumsteps() {
let numsteps = 1
if (CanBeShipped())
numsteps++
if (CanBeBuyOnline())
numsteps++
return numsteps
}
function docheckout() {
// Può essere spedito?
if (CanBeShipped()) {
// mostra form di spedizione
}
if (CanBeBuyOnline()) {
// mostra form di acquisto Online
}
}
onMounted(mounted)
return {
userStore,
costanti,
tools,
toolsext,
shared_consts,
globalStore,
columns,
taborders,
getGestoreOrd,
updateorders,
getCols,
endload,
getGestoreOrdWithTotals,
productStore,
t,
initialPagination,
cosa,
templemail,
fieldsTable,
arrout,
storeGasordine,
}
}
})

View File

@@ -0,0 +1,117 @@
<template>
<q-page>
<CTitleBanner title="Ordini"></CTitleBanner>
<q-spinner v-if="!endload" color="primary" size="3em" :thickness="2" />
<div class="q-gutter-md text-center">
<q-btn-toggle
v-model="cosa"
push
rounded
glossy
toggle-color="purple"
:options="[
{ value: shared_consts.PROD.TUTTI, slot: 'tutti' },
{ value: shared_consts.PROD.BOTTEGA, slot: 'bottega' },
{ value: shared_consts.PROD.GAS, slot: 'gas' },
]"
>
<template v-slot:tutti>
<div class="row items-center no-wrap">
<div class="text-center">
{{ t('gas.tutti') }}
</div>
<q-icon right name="fas fa-user-friends" />
</div>
</template>
<template v-slot:gas>
<div class="row items-center no-wrap">
<div class="text-center">
{{ t('gas.ordina_sul_gas') }}
</div>
<q-icon right name="fas fa-user-friends" />
</div>
</template>
<template v-slot:bottega>
<div class="row items-center no-wrap">
<div class="text-center">
{{ t('gas.bottega') }}
</div>
<q-icon right name="fas fa-store" />
</div>
</template>
</q-btn-toggle>
</div>
<div v-if="endload" class="panel">
<q-select
:behavior="$q.platform.is.ios === true ? 'dialog' : 'menu'"
outlined
v-model="storeGasordine"
:options="productStore.getGasordines()"
:label="t('products.gasordine') + `:`"
emit-value
map-options
>
</q-select>
<div class="q-pa-sm" v-if="arrout">
<q-table
:columns="columns"
row-key="numorder"
:pagination="initialPagination"
:rows="arrout"
>
<template v-slot:body="props">
<q-tr :props="props">
<q-td key="name" :props="props">
<span v-if="props.row.name"> &nbsp; {{ props.row.name }}</span>
</q-td>
<q-td key="weight" :props="props">
<span v-if="props.row.weight">
&nbsp; {{ props.row.weight }}
{{ tools.getUnitsMeasure(props.row.unit, true) }}</span
>
</q-td>
<q-td key="price_acquistato" :props="props">
<span v-if="props.row.price_acquistato">
&nbsp; {{ props.row.price_acquistato.toFixed(2) }}
</span>
</q-td>
<q-td key="totalQuantity" :props="props">
<span v-if="props.row.totalQuantity">
&nbsp;
{{ props.row.totalQuantity }}</span
>
</q-td>
<q-td key="totalPrice_acquistato" :props="props">
<span v-if="props.row.totalPrice_acquistato">
<span :class="props.row.name !== 'TOTALI' ? '' : 'totaliacq'">
&nbsp; {{ props.row.totalPrice_acquistato.toFixed(2) }}
&nbsp;</span
>
</span>
</q-td>
<q-td key="totalPrice" :props="props">
<span v-if="props.row.totalPrice">
<span :class="props.row.name !== 'TOTALI' ? '' : 'totali'">
&nbsp; {{ props.row.totalPrice.toFixed(2) }}
&nbsp;</span
>
</span>
</q-td>
</q-tr>
</template>
</q-table>
</div>
</div>
</q-page>
</template>
<script lang="ts" src="./gestoreordini.ts">
</script>
<style lang="scss" scoped>
@import './gestoreordini';
</style>

View File

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

View File

@@ -36,6 +36,8 @@ export default defineComponent({
const cosa = ref(0)
const arrout = ref(<any[]>[])
const initialPagination = ref({
sortBy: 'desc',
descending: false,
@@ -47,6 +49,8 @@ export default defineComponent({
const conferma_ordine = ref(false)
const endload = ref(false)
const storeGasordine = ref(<any>'')
const taborders = ref(shared_consts.OrderStat.IN_CORSO.value)
const statusnow = ref(0)
const arrnumstatus = ref(<any[]>[])
@@ -165,7 +169,16 @@ export default defineComponent({
])
watch(() => cosa.value, (newval, oldval) => {
updateorders(true)
})
watch(() => taborders.value, (newval, oldval) => {
updateorders(false)
})
watch(() => storeGasordine.value, (newval, oldval) => {
tools.setCookie(tools.COOK_SELGAS, storeGasordine.value)
updateorders(true)
})
// const { setValDb, getValDb } = MixinBase()
@@ -176,7 +189,7 @@ export default defineComponent({
function getOrdersCart(): IOrderCart[] | undefined {
const hasGasordine: any = (cosa.value === shared_consts.PROD.TUTTI) ? undefined : (cosa.value === shared_consts.PROD.GAS)
const ris = productStore.getOrdersCart(taborders.value, hasGasordine)
const ris = productStore.getOrdersCart(taborders.value, hasGasordine, storeGasordine.value)
return ris
}
@@ -184,7 +197,7 @@ export default defineComponent({
function getOrdersCartWithTotals(): any[] {
const orderscart = getOrdersCart();
if (orderscart) {
if (orderscart && taborders.value > 0) {
// Calculate totals
const totals = {
created_at: new Date(),
@@ -216,10 +229,12 @@ export default defineComponent({
}
function getAllOrdersCart() {
return productStore.getOrdersAllCart()
return productStore.getOrdersAllCart(storeGasordine.value)
}
function updateorders() {
function updateorders(updatetab: boolean) {
arrout.value = []
myorderscart.value = getOrdersCart()
if (myorderscart.value) {
for (const orderscart of myorderscart.value) {
@@ -227,19 +242,22 @@ export default defineComponent({
}
}
const allorders = getAllOrdersCart()
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)
if (updatetab) {
const allorders = getAllOrdersCart()
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()
}
selectfirstavailable()
arrout.value = getOrdersCartWithTotals()
}
function selectfirstavailable() {
taborders.value = -1
Object.keys(arrnumstatus.value).forEach((stat: any) => {
if (arrnumstatus.value[stat] > 0) {
if (taborders.value === -1)
@@ -250,12 +268,14 @@ export default defineComponent({
async function mounted() {
taborders.value = -1
storeGasordine.value = tools.getCookie(tools.COOK_SELGAS, '')
await userStore.newsletterload(false)
await productStore.loadProducts()
taborders.value = -1
updateorders()
updateorders(true)
if (taborders.value === -1)
taborders.value = shared_consts.OrderStat.IN_CORSO.value
@@ -328,7 +348,7 @@ export default defineComponent({
if (statusnow.value === status) {
order.status = statusnow.value
updateorders()
updateorders(true)
tools.showPositiveNotif($q, 'Ordine ' + statusStr)
}
// change_field('status')
@@ -398,6 +418,8 @@ export default defineComponent({
sendMailTest,
templemail,
fieldsTable,
storeGasordine,
arrout,
}
}
})

View File

@@ -43,18 +43,41 @@
</template>
</q-btn-toggle>
</div>
<div v-if="endload" class="panel">
<q-tabs v-model="taborders" inline-label class="text-blue">
<span v-for="(stat, index) of shared_consts.OrderStat" :key="index">
<q-tab v-if="arrnumstatus[stat.value] > 0" :class="stat.color" :name="stat.value" :icon="stat.icon"
:label="`(` + arrnumstatus[stat.value] + `) ` + stat.label" />
<q-tab
v-if="arrnumstatus[stat.value] > 0"
:class="stat.color"
:name="stat.value"
:icon="stat.icon"
:label="`(` + arrnumstatus[stat.value] + `) ` + stat.label"
/>
</span>
</q-tabs>
<q-select
:behavior="$q.platform.is.ios === true ? 'dialog' : 'menu'"
outlined
v-model="storeGasordine"
:options="productStore.getGasordines()"
:label="t('products.gasordine') + `:`"
emit-value
map-options
>
</q-select>
<div class="q-pa-sm">
<q-table :grid="$q.screen.lt.sm" :hide-header="$q.screen.lt.sm" :columns="columns" row-key="numorder"
:pagination="initialPagination" :rows="getOrdersCartWithTotals()">
<q-table
v-if="taborders > 0"
:grid="$q.screen.lt.sm"
:hide-header="$q.screen.lt.sm"
:columns="columns"
row-key="numorder"
:pagination="initialPagination"
:rows="arrout"
>
<template v-if="$q.screen.lt.sm" v-slot:item="props">
<div class="q-pa-xs col-xs-12 col-sm-6 col-md-4">
<q-card class="my-card-shadow yes_shadow">
@@ -64,13 +87,21 @@
<q-item-label>{{ col.label }}</q-item-label>
</q-item-section>
<q-item-section side>
<q-item-label v-if="col.name === 'created_at'" caption>{{ tools.getstrDateTime(col.value) }}
<q-item-label v-if="col.name === 'created_at'" caption
>{{ tools.getstrDateTime(col.value) }}
</q-item-label>
<q-item-label v-else-if="col.name === 'nameSurname'" caption>
<q-item-label
v-else-if="col.name === 'nameSurname'"
caption
>
<span v-if="props.row.user">
<span :class="props.row.user.name !== 'TOTALI' ? '' : 'totali'
">{{ tools.getNomeUtenteByRecUser(props.row.user) }}
</span></span>
<span
:class="
props.row.user.name !== 'TOTALI' ? '' : 'totali'
"
>{{ tools.getNomeUtenteByRecUser(props.row.user) }}
</span></span
>
</q-item-label>
<q-item-label v-else-if="col.name === 'items'" caption>
<div
@@ -85,33 +116,53 @@
item.order.product.productInfo
"
>
{{ productStore.getStrInfoOrder(t, item.order) }}
{{ item.order.product.productInfo.name }} ({{
productStore.getQuantityByOrder(t, item.order)
}})<br />
</div>
</div>
</q-item-label>
<q-item-label v-else-if="col.name === 'totalPrice'" caption>
<q-item-label
v-else-if="col.name === 'totalPrice'"
caption
>
{{ props.row.totalPrice }} €
</q-item-label>
<q-item-label v-else-if="col.name === 'totalPriceCalc'" caption>
<q-item-label
v-else-if="col.name === 'totalPriceCalc'"
caption
>
{{ props.row.totalPriceCalc }} €
</q-item-label>
<q-item-label v-else-if="col.name === 'status'" caption>
{{ shared_consts.getStatusStr(props.row.status) }}
</q-item-label>
<q-item-label v-else-if="col.name === 'comandi'" caption>
<div v-if="tools.isManager() &&
props.row.user.name !== 'TOTALI'
" class="q-pa-sm">
<div
v-if="
tools.isManager() &&
props.row.user.name !== 'TOTALI'
"
class="q-pa-sm"
>
<q-btn-dropdown rounded dense label="Azioni">
<q-list class="text-primary">
<q-item v-for="(
<q-item
v-for="(
cmd, index
) of shared_consts.OrderCmdStr" :key="index" clickable v-close-popup
@click="clickFunz(props.row, cmd.value)">
) of shared_consts.OrderCmdStr"
:key="index"
clickable
v-close-popup
@click="clickFunz(props.row, cmd.value)"
>
<q-item-section avatar>
<q-avatar :icon="cmd.icon" :color="cmd.color" text-color="white" />
<q-avatar
:icon="cmd.icon"
:color="cmd.color"
text-color="white"
/>
</q-item-section>
<q-item-section>
<q-item-label>{{ cmd.label }}</q-item-label>
@@ -121,8 +172,11 @@
</q-btn-dropdown>
</div>
</q-item-label>
<q-item-label v-else-if="col.name === 'apri' && props.row._id" caption>
<q-item-label
v-else-if="col.name === 'apri' && props.row._id"
caption
>
<div class="q-pa-sm">
<q-btn
size="sm"
@@ -158,13 +212,25 @@
</div>
</q-td>
<q-td key="comandi" :props="props">
<div v-if="tools.isManager() && props.row.user.name !== 'TOTALI'" class="q-pa-sm">
<div
v-if="tools.isManager() && props.row.user.name !== 'TOTALI'"
class="q-pa-sm"
>
<q-btn-dropdown rounded dense label="Azioni">
<q-list class="text-primary">
<q-item v-for="(cmd, index) of shared_consts.OrderCmdStr" :key="index" clickable v-close-popup
@click="clickFunz(props.row, cmd.value)">
<q-item
v-for="(cmd, index) of shared_consts.OrderCmdStr"
:key="index"
clickable
v-close-popup
@click="clickFunz(props.row, cmd.value)"
>
<q-item-section avatar>
<q-avatar :icon="cmd.icon" :color="cmd.color" text-color="white" />
<q-avatar
:icon="cmd.icon"
:color="cmd.color"
text-color="white"
/>
</q-item-section>
<q-item-section>
<q-item-label>{{ cmd.label }}</q-item-label>
@@ -176,19 +242,22 @@
</q-td>
<q-td key="numorder" :props="props">
<span v-if="props.row.numorder">
&nbsp; n. {{ props.row.numorder }}</span>
&nbsp; n. {{ props.row.numorder }}</span
>
</q-td>
<q-td key="nameSurname" :props="props">
<span v-if="props.row.user">
<span :class="props.row.user.name !== 'TOTALI' ? '' : 'totali'">{{
tools.getNomeUtenteByRecUser(props.row.user) }}
</span></span>
<span
:class="props.row.user.name !== 'TOTALI' ? '' : 'totali'"
>{{ tools.getNomeUtenteByRecUser(props.row.user) }}
</span></span
>
</q-td>
<q-td key="created_at" :props="props">
{{ tools.getstrDateTime(props.row.created_at) }}
<span v-if="taborders === shared_consts.OrderStat.COMPLETATI">
<br />Consegnato il:<br />{{
tools.getstrDateTime(props.row.date_consegnato)
tools.getstrDateTime(props.row.date_consegnato)
}}
</span>
</q-td>
@@ -202,7 +271,7 @@
"
>
{{ item.order.product.productInfo.name }} ({{
productStore.getQuantityByOrder($t, item.order)
productStore.getQuantityByOrder($t, item.order)
}})<br />
</div>
</div>
@@ -217,12 +286,14 @@
</div>
</q-td>
<q-td key="totalPrice" :props="props">
<span :class="props.row.user.name !== 'TOTALI' ? '' : 'totali'">{{ props.row.totalPrice }} €</span>
<span :class="props.row.user.name !== 'TOTALI' ? '' : 'totali'"
>{{ props.row.totalPrice }} €</span
>
</q-td>
<q-td key="status" :props="props">
<span :class="props.row.status">{{
shared_consts.getStatusStr(props.row.status)
}}</span>
}}</span>
<br />
<div v-if="props.row.confermato" class="ordstat">
{{ tools.getstrDateTime(props.row.date_confermato) }}: