- edit campi prodotti
- edit ordini
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
<div>
|
||||
<div class="container">
|
||||
<div class="q-pa-sm col items-start q-gutter-xs" v-for="(itemorder, index) in getItemsCart()" :key="index">
|
||||
<CSingleCart :order="itemorder.order" :showall="true" />
|
||||
<CSingleCart :order="itemorder.order" :idOrdersCart="recOrderCart._id" :showall="true" />
|
||||
</div>
|
||||
</div>
|
||||
<q-separator></q-separator>
|
||||
|
||||
@@ -172,6 +172,12 @@ export default defineComponent({
|
||||
}
|
||||
}
|
||||
|
||||
function azzera() {
|
||||
saveit.value = true
|
||||
showDateTimeScroller.value = false
|
||||
emit('savetoclose', null, valueprec.value)
|
||||
}
|
||||
|
||||
created()
|
||||
|
||||
return {
|
||||
@@ -190,6 +196,7 @@ export default defineComponent({
|
||||
mydate,
|
||||
mytime,
|
||||
tools,
|
||||
azzera,
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
@@ -79,6 +79,10 @@
|
||||
}
|
||||
"
|
||||
/>
|
||||
</div>
|
||||
<q-card-actions align="center">
|
||||
<q-btn icon="fas fa-trash"
|
||||
@click="azzera"></q-btn>
|
||||
<div class="row justify-center">
|
||||
<q-btn
|
||||
:label="$t('dialog.cancel')"
|
||||
@@ -90,7 +94,7 @@
|
||||
v-close-popup
|
||||
></q-btn>
|
||||
</div>
|
||||
</div>
|
||||
</q-card-actions>
|
||||
</q-card>
|
||||
</q-popup-proxy>
|
||||
<q-popup-proxy
|
||||
|
||||
@@ -8,8 +8,11 @@ import { CCopyBtn } from '@/components/CCopyBtn'
|
||||
import { CSingleCart } from '@/components/CSingleCart'
|
||||
import { CTitleBanner } from '@/components/CTitleBanner'
|
||||
|
||||
import { useI18n } from '@src/boot/i18n'
|
||||
|
||||
import MixinUsers from '../../mixins/mixin-users'
|
||||
|
||||
|
||||
export default defineComponent({
|
||||
name: 'CMyCart',
|
||||
props: {},
|
||||
@@ -18,6 +21,7 @@ export default defineComponent({
|
||||
setup() {
|
||||
const globalStore = useGlobalStore()
|
||||
const products = useProducts()
|
||||
const { t } = useI18n()
|
||||
|
||||
const { getnumItemsCart } = MixinUsers()
|
||||
|
||||
@@ -70,6 +74,7 @@ export default defineComponent({
|
||||
getnumItemsCart,
|
||||
existsOrders,
|
||||
globalStore,
|
||||
t,
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
<q-separator></q-separator>
|
||||
<div id="mybody">
|
||||
<div v-for="(rec, index) in ordersCart" :key="index" class="col">
|
||||
<CSingleCart :order="rec.order" :showall="false"> </CSingleCart>
|
||||
<CSingleCart :order="rec.order" :showall="false" :idOrdersCart="ordersCart ? ordersCart._id: ''"> </CSingleCart>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="numOrders === 0" style="text-align: center" class="text-grey">
|
||||
@@ -36,7 +36,7 @@
|
||||
rounded
|
||||
icon="fas fa-shopping-cart"
|
||||
color="primary"
|
||||
:label="$t('ecomm.btn_cassa')"
|
||||
:label="t('ecomm.btn_cassa')"
|
||||
@click="globalStore.rightCartOpen = false"
|
||||
class="q-mb-sm"
|
||||
to="/checkout"
|
||||
@@ -50,7 +50,7 @@
|
||||
rounded
|
||||
icon="fas fa-clipboard-list"
|
||||
color="positive"
|
||||
:label="$t('ecomm.btn_ordini')"
|
||||
:label="t('ecomm.btn_ordini')"
|
||||
class="q-mb-sm"
|
||||
@click="globalStore.rightCartOpen = false"
|
||||
to="/orderinfo"
|
||||
|
||||
24
src/components/CMyValueDb/CMyValueDb.scss
Executable file
24
src/components/CMyValueDb/CMyValueDb.scss
Executable file
@@ -0,0 +1,24 @@
|
||||
.colmodif {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
|
||||
.colmodif:hover {
|
||||
background-color: #a8f0ff;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.colsel {
|
||||
background-color: #81b8ff;
|
||||
}
|
||||
|
||||
.cldisable{
|
||||
color: gray !important;
|
||||
}
|
||||
|
||||
.clinput{
|
||||
@media (max-width: 500px) {
|
||||
display: flex;
|
||||
flex-grow: 1;
|
||||
}
|
||||
}
|
||||
194
src/components/CMyValueDb/CMyValueDb.ts
Executable file
194
src/components/CMyValueDb/CMyValueDb.ts
Executable file
@@ -0,0 +1,194 @@
|
||||
import { defineComponent, onMounted, PropType, ref, watch } from 'vue'
|
||||
import { useQuasar } from 'quasar'
|
||||
import { useI18n } from '@/boot/i18n'
|
||||
import { useGlobalStore } from '@store/globalStore'
|
||||
import { fieldsTable } from '@store/Modules/fieldsTable'
|
||||
import { tools } from '@store/Modules/tools'
|
||||
import { costanti } from '@costanti'
|
||||
import { CMyPopupEdit } from '@/components/CMyPopupEdit'
|
||||
import { IColGridTable, IOperators, ISpecialField } from 'model'
|
||||
import MixinBase from '@/mixins/mixin-base'
|
||||
|
||||
|
||||
export default defineComponent({
|
||||
name: 'CMyValueDb',
|
||||
emits: ['save'],
|
||||
props: {
|
||||
title: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
hint: {
|
||||
type: String,
|
||||
required: false,
|
||||
default: '',
|
||||
},
|
||||
mykey: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
mysubkey: {
|
||||
type: String,
|
||||
required: false,
|
||||
default: '',
|
||||
},
|
||||
specialField: {
|
||||
type: Object as PropType<ISpecialField>,
|
||||
required: false,
|
||||
default: null,
|
||||
},
|
||||
filter: {
|
||||
type: [String, Function],
|
||||
required: false,
|
||||
default: null,
|
||||
},
|
||||
indrec: {
|
||||
type: Number,
|
||||
required: false,
|
||||
default: -1,
|
||||
},
|
||||
maxlength: {
|
||||
type: Number,
|
||||
required: false,
|
||||
default: 0,
|
||||
},
|
||||
minlength: {
|
||||
type: Number,
|
||||
required: false,
|
||||
default: 0,
|
||||
},
|
||||
mysubsubkey: {
|
||||
type: String,
|
||||
required: false,
|
||||
default: '',
|
||||
},
|
||||
type: {
|
||||
type: Number,
|
||||
required: true,
|
||||
},
|
||||
serv: {
|
||||
type: Boolean,
|
||||
required: false,
|
||||
default: false,
|
||||
},
|
||||
canModify: {
|
||||
type: Boolean,
|
||||
required: false,
|
||||
default: true,
|
||||
},
|
||||
disable: {
|
||||
type: Boolean,
|
||||
required: false,
|
||||
default: false,
|
||||
},
|
||||
jointable: {
|
||||
type: String,
|
||||
required: false,
|
||||
default: '',
|
||||
},
|
||||
table: {
|
||||
type: String,
|
||||
required: false,
|
||||
default: 'settings',
|
||||
},
|
||||
myimg: {
|
||||
type: String,
|
||||
required: false,
|
||||
default: '',
|
||||
},
|
||||
rec: {
|
||||
type: Object,
|
||||
required: false,
|
||||
default: null,
|
||||
},
|
||||
mycol: {
|
||||
type: Object as PropType<IColGridTable> | undefined,
|
||||
required: false,
|
||||
default: () => {
|
||||
return { }
|
||||
},
|
||||
},
|
||||
id: {
|
||||
type: String,
|
||||
required: false,
|
||||
default: '',
|
||||
},
|
||||
idmain: {
|
||||
type: String,
|
||||
required: false,
|
||||
default: '',
|
||||
},
|
||||
tablesel: {
|
||||
type: String,
|
||||
required: false,
|
||||
default: '',
|
||||
},
|
||||
pickup: {
|
||||
type: Boolean,
|
||||
required: false,
|
||||
default: false,
|
||||
},
|
||||
},
|
||||
components: { CMyPopupEdit },
|
||||
setup(props, { emit }) {
|
||||
const $q = useQuasar()
|
||||
const { t } = useI18n()
|
||||
const globalStore = useGlobalStore()
|
||||
|
||||
const col = ref(<IColGridTable>{
|
||||
name: 'test', fieldtype: 0, showWhen: costanti.showWhen.NewRec + costanti.showWhen.InEdit + costanti.showWhen.InView, visible: true, maxlength: props.maxlength, minlength: props.minlength
|
||||
})
|
||||
const row = ref({})
|
||||
|
||||
const { setValDb, getValDb } = MixinBase()
|
||||
|
||||
function showandsel(row: any, col: any, newval: any, valinitial: any) {
|
||||
console.log('showandsel CMyFieldDb', row, col, newval)
|
||||
|
||||
if (newval !== valinitial) {
|
||||
setValDb($q, props.mykey, newval, props.type, props.serv, props.table, props.mysubkey, props.id, props.indrec, props.mysubsubkey, props.specialField)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function save(newval: any) {
|
||||
emit('save', newval)
|
||||
}
|
||||
|
||||
function withBorder() {
|
||||
if (col.value)
|
||||
return col.value.fieldtype !== costanti.FieldType.onlydate && col.value.fieldtype !== costanti.FieldType.date
|
||||
else
|
||||
return false
|
||||
}
|
||||
|
||||
function mounted() {
|
||||
if (props.rec) {
|
||||
row.value = props.rec
|
||||
}
|
||||
if (props.mycol && props.mycol.name !== '') {
|
||||
col.value = props.mycol
|
||||
} else {
|
||||
// console.log('Tab = ', props.table, 'key=', props.mykey, 'mycolProp', props.mycol)
|
||||
col.value = fieldsTable.getColByTable(props.table, props.mykey)
|
||||
}
|
||||
|
||||
// console.log('COL = ', col.value, 'MyCol passed', props.mycol)
|
||||
}
|
||||
|
||||
onMounted(mounted)
|
||||
|
||||
return {
|
||||
tools,
|
||||
costanti,
|
||||
fieldsTable,
|
||||
globalStore,
|
||||
col,
|
||||
row,
|
||||
showandsel,
|
||||
withBorder,
|
||||
save,
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
78
src/components/CMyValueDb/CMyValueDb.vue
Executable file
78
src/components/CMyValueDb/CMyValueDb.vue
Executable file
@@ -0,0 +1,78 @@
|
||||
<template>
|
||||
<div class="text-center">
|
||||
<div class="row items-center justify-center q-gutter-xs q-ma-xs">
|
||||
<div :class="` `" :style="withBorder() ? `` : ``">
|
||||
<div v-if="title && type === costanti.FieldType.string" class="q-ma-xs">
|
||||
<q-field
|
||||
rounded
|
||||
outlined
|
||||
:bg-color="$q.dark.isActive ? '' : 'blue-4'"
|
||||
dense
|
||||
style="min-width: 110px"
|
||||
>
|
||||
<template v-slot:control>
|
||||
<div class="centermydiv">
|
||||
<div v-if="myimg" class="text-center">
|
||||
<q-img
|
||||
:src="myimg"
|
||||
class="text-center"
|
||||
style="height: 50px; width: 50px"
|
||||
:alt="title"
|
||||
>
|
||||
</q-img>
|
||||
</div>
|
||||
<div
|
||||
class="self-center full-width no-outline text-center"
|
||||
tabindex="0"
|
||||
>
|
||||
{{ title }}
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</q-field>
|
||||
</div>
|
||||
|
||||
<CMyPopupEdit
|
||||
debounce="1000"
|
||||
:fielddb="true"
|
||||
v-bind="$attrs"
|
||||
:rec="rec"
|
||||
:isrec="!!rec"
|
||||
:table="table"
|
||||
:hint="title"
|
||||
:title="title"
|
||||
:field="mykey"
|
||||
:filter="filter"
|
||||
:subfield="mysubkey"
|
||||
:specialField="specialField"
|
||||
:mysubsubkey="mysubsubkey"
|
||||
:indrec="indrec"
|
||||
:type="type"
|
||||
:serv="serv"
|
||||
:disable="disable"
|
||||
:jointable="jointable"
|
||||
:myimg="myimg"
|
||||
:canModify="canModify"
|
||||
:canEdit="true"
|
||||
:id="id"
|
||||
:idmain="idmain"
|
||||
:mycol="col ? col : {}"
|
||||
:tablesel="tablesel"
|
||||
:pickup="pickup"
|
||||
v-model:row="row"
|
||||
minuteinterval="1"
|
||||
@showandsave="showandsel"
|
||||
@save="save"
|
||||
>
|
||||
</CMyPopupEdit>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" src="./CMyValueDb.ts">
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@import './CMyValueDb.scss';
|
||||
</style>
|
||||
1
src/components/CMyValueDb/index.ts
Executable file
1
src/components/CMyValueDb/index.ts
Executable file
@@ -0,0 +1 @@
|
||||
export {default as CMyValueDb} from './CMyValueDb.vue'
|
||||
@@ -102,6 +102,7 @@ export default defineComponent({
|
||||
}
|
||||
|
||||
function load() {
|
||||
endload.value = false
|
||||
recOrderCart.value = productStore.getOrdersCartById(props.idOrdersCart)
|
||||
if (recOrderCart.value) {
|
||||
oldrec.value = myrec.value
|
||||
@@ -181,6 +182,16 @@ export default defineComponent({
|
||||
}
|
||||
}
|
||||
|
||||
function updateOrdersCart(paramstoupdate: any) {
|
||||
productStore.updateOrdersCartById(props.idOrdersCart, paramstoupdate)
|
||||
}
|
||||
|
||||
function ordersUpdated() {
|
||||
console.log('ordersUpdated')
|
||||
load()
|
||||
}
|
||||
|
||||
|
||||
onMounted(mounted)
|
||||
|
||||
return {
|
||||
@@ -200,6 +211,8 @@ export default defineComponent({
|
||||
endload,
|
||||
search,
|
||||
insertArticolo,
|
||||
updateOrdersCart,
|
||||
ordersUpdated,
|
||||
t,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
:idOrdersCart="recOrderCart._id"
|
||||
:editmode="tools.isManager()"
|
||||
:nomodif="true"
|
||||
@update="ordersUpdated()"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -127,3 +127,7 @@
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
.q-card__section--vert{
|
||||
padding: 4px;
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import { useQuasar } from 'quasar'
|
||||
import { CTitleBanner } from '../CTitleBanner'
|
||||
import { CCardState } from '../CCardState'
|
||||
import { CCopyBtn } from '../CCopyBtn'
|
||||
import { CMyValueDb } from '../CMyValueDb'
|
||||
|
||||
import { func_tools, toolsext } from '@store/Modules/toolsext'
|
||||
|
||||
@@ -17,6 +18,7 @@ import { useProducts } from '@store/Products'
|
||||
import { shared_consts } from '@src/common/shared_vuejs'
|
||||
import { useRouter } from 'vue-router'
|
||||
|
||||
import { costanti } from '@costanti'
|
||||
export default defineComponent({
|
||||
name: 'CProductCard',
|
||||
props: {
|
||||
@@ -41,7 +43,7 @@ export default defineComponent({
|
||||
default: false,
|
||||
},
|
||||
},
|
||||
components: { CTitleBanner, CCardState, CCopyBtn },
|
||||
components: { CTitleBanner, CCardState, CCopyBtn, CMyValueDb },
|
||||
setup(props, { emit }) {
|
||||
const $q = useQuasar()
|
||||
const { t } = useI18n()
|
||||
@@ -51,6 +53,7 @@ export default defineComponent({
|
||||
|
||||
const listord = ref(<IOrderCart[]>[])
|
||||
const sumval = ref(0)
|
||||
const editOn = ref(false)
|
||||
|
||||
const site = ref(globalStore.site)
|
||||
|
||||
@@ -93,6 +96,13 @@ export default defineComponent({
|
||||
return globalStore.getTableJoinByName(item.table, addall, addnone, item.filter)
|
||||
})
|
||||
|
||||
|
||||
watch(() => editOn.value, (to: any, from: any) => {
|
||||
if (!editOn.value)
|
||||
ricarica()
|
||||
})
|
||||
|
||||
|
||||
/*const myproduct = computed((): IProduct => {
|
||||
console.log('getproduct computed')
|
||||
const ris = products.getProduct(props.code)
|
||||
@@ -180,6 +190,30 @@ export default defineComponent({
|
||||
// products.updateQuantityAvailable(myproduct.value._id)
|
||||
}
|
||||
|
||||
async function ricarica() {
|
||||
endload.value = false
|
||||
const prod = await products.loadProductById(myproduct.value._id)
|
||||
if (prod) {
|
||||
myproduct.value = prod
|
||||
}
|
||||
load()
|
||||
endload.value = true
|
||||
|
||||
}
|
||||
|
||||
function updateproductmodif() {
|
||||
|
||||
try {
|
||||
myproduct.value = products.getProductById(props.id)
|
||||
|
||||
recgasordineSelected.value = myproduct.value.gasordines.find((rec: any) => rec._id === gasordineSelected.value)
|
||||
|
||||
updateLabel()
|
||||
} catch (e) {
|
||||
console.error('err', e)
|
||||
}
|
||||
}
|
||||
|
||||
function getStorehouses() {
|
||||
if (!myproduct.value)
|
||||
return []
|
||||
@@ -223,7 +257,7 @@ export default defineComponent({
|
||||
|
||||
function checkifCartDisable() {
|
||||
// return !myorder.idStorehouse
|
||||
return false
|
||||
return isOrdineChiuso()
|
||||
}
|
||||
|
||||
function getQtyWarn() {
|
||||
@@ -288,6 +322,11 @@ export default defineComponent({
|
||||
timerLabelScadenza.value = ''
|
||||
}
|
||||
|
||||
function isOrdineChiuso() {
|
||||
return recgasordineSelected.value && recgasordineSelected.value.dataora_chiusura_ordini &&
|
||||
tools.getCountDown(recgasordineSelected.value.dataora_chiusura_ordini) === ''
|
||||
}
|
||||
|
||||
function startTimer() {
|
||||
// Update the timer label every second
|
||||
timerInterval.value = setInterval(() => updateTimerLabel(), 1000);
|
||||
@@ -350,7 +389,7 @@ export default defineComponent({
|
||||
openlistorders.value = true
|
||||
sumval.value = products.getSumQtyOrderProductInOrdersCart(myproduct.value._id)
|
||||
|
||||
listord.value = arrordersCart.value.filter((ordercart: IOrderCart) => ordercart.items!.reduce((accumulator, item) => {
|
||||
listord.value = arrordersCart.value.filter((orderscart: IOrderCart) => orderscart.items!.reduce((accumulator, item) => {
|
||||
return accumulator + item.order.quantity
|
||||
}, 0))
|
||||
}
|
||||
@@ -359,7 +398,7 @@ export default defineComponent({
|
||||
openlistorders.value = true
|
||||
sumval.value = products.getSumQtyPreOrderInOrdersCart(myproduct.value._id)
|
||||
|
||||
listord.value = arrordersCart.value.filter((ordercart: IOrderCart) => ordercart.items!.reduce((accumulator, item) => {
|
||||
listord.value = arrordersCart.value.filter((orderscart: IOrderCart) => orderscart.items!.reduce((accumulator, item) => {
|
||||
return accumulator + item.order.quantitypreordered
|
||||
}, 0))
|
||||
}
|
||||
@@ -460,6 +499,13 @@ export default defineComponent({
|
||||
onTouchEnd,
|
||||
$router,
|
||||
naviga,
|
||||
globalStore,
|
||||
editOn,
|
||||
costanti,
|
||||
updateproduct,
|
||||
updateproductmodif,
|
||||
isOrdineChiuso,
|
||||
ricarica,
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -87,9 +87,19 @@
|
||||
class="text-black q-ml-xs text-h8"
|
||||
v-if="myproduct.productInfo.unit"
|
||||
>
|
||||
{{ tools.getWeightByUnit(myproduct.productInfo.unit, true, myproduct.productInfo.weight) }}
|
||||
{{
|
||||
tools.getUnitsMeasure(myproduct.productInfo.unit, true, myproduct.productInfo.weight)
|
||||
tools.getWeightByUnit(
|
||||
myproduct.productInfo.unit,
|
||||
true,
|
||||
myproduct.productInfo.weight
|
||||
)
|
||||
}}
|
||||
{{
|
||||
tools.getUnitsMeasure(
|
||||
myproduct.productInfo.unit,
|
||||
true,
|
||||
myproduct.productInfo.weight
|
||||
)
|
||||
}}</span
|
||||
>
|
||||
</q-item-label>
|
||||
@@ -270,7 +280,7 @@
|
||||
</div>
|
||||
</q-card-section>
|
||||
|
||||
<q-card-section v-if="myproduct.note">
|
||||
<q-card-section v-if="myproduct.note" class="q-pa-none">
|
||||
<q-item>
|
||||
<q-item-section avatar>
|
||||
<q-icon color="black" name="fas fa-book" />
|
||||
@@ -429,13 +439,21 @@
|
||||
<span v-if="getpercqtaraggiunta() >= 1">{{
|
||||
t('ecomm.offerta_gas_raggiunta', {
|
||||
qta: myproduct.qtyToReachForGas,
|
||||
unit: tools.getUnitsMeasure(myproduct.productInfo.unit, true, myproduct.productInfo.weight),
|
||||
unit: tools.getUnitsMeasure(
|
||||
myproduct.productInfo.unit,
|
||||
true,
|
||||
myproduct.productInfo.weight
|
||||
),
|
||||
})
|
||||
}}</span>
|
||||
<span v-else>{{
|
||||
t('ecomm.offerta_gas', {
|
||||
qta: myproduct.qtyToReachForGas,
|
||||
unit: tools.getUnitsMeasure(myproduct.productInfo.unit, true, myproduct.productInfo.weight),
|
||||
unit: tools.getUnitsMeasure(
|
||||
myproduct.productInfo.unit,
|
||||
true,
|
||||
myproduct.productInfo.weight
|
||||
),
|
||||
})
|
||||
}}</span>
|
||||
</q-item-label>
|
||||
@@ -496,16 +514,35 @@
|
||||
<q-icon color="blue" name="fas fa-hourglass-half" />
|
||||
</q-item-section>
|
||||
|
||||
<q-item-section>
|
||||
<q-item-section v-if="!!recgasordineSelected.dataora_chiusura_ordini">
|
||||
<q-item-label class="subtit_prod">
|
||||
{{ t('gas.dataora_chiusura_ordini') }}
|
||||
</q-item-label>
|
||||
<q-item-label class="countdown_scadenza">
|
||||
{{ timerLabelScadenza }}
|
||||
<span v-if="timerLabelScadenza">{{ timerLabelScadenza }}</span>
|
||||
<span v-else-if="isOrdineChiuso()">{{
|
||||
t('ecomm.ordine_scaduto', {
|
||||
date: tools.getstrshortDateTime(
|
||||
recgasordineSelected.dataora_chiusura_ordini
|
||||
),
|
||||
})
|
||||
}}</span>
|
||||
<CMyValueDb
|
||||
v-if="editOn"
|
||||
:title="t('gas.dataora_chiusura_ordini')"
|
||||
table="gasordines"
|
||||
:id="recgasordineSelected._id"
|
||||
:rec="recgasordineSelected"
|
||||
mykey="dataora_chiusura_ordini"
|
||||
debounce="1000"
|
||||
:save="updateproductmodif()"
|
||||
:type="costanti.FieldType.date"
|
||||
>
|
||||
</CMyValueDb>
|
||||
</q-item-label>
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
<q-item v-if="labelDataArrivoMerce">
|
||||
<q-item v-if="labelDataArrivoMerce || editOn">
|
||||
<q-item-section avatar>
|
||||
<q-icon color="red" name="fas fa-shipping-fast" />
|
||||
</q-item-section>
|
||||
@@ -515,11 +552,25 @@
|
||||
{{ t('gas.data_arrivo_merce') }}
|
||||
</q-item-label>
|
||||
<q-item-label class="countdown_scadenza">
|
||||
<CMyValueDb
|
||||
v-if="editOn"
|
||||
:title="t('gas.data_arrivo_merce')"
|
||||
table="gasordines"
|
||||
:id="recgasordineSelected._id"
|
||||
:rec="recgasordineSelected"
|
||||
mykey="data_arrivo_merce"
|
||||
debounce="1000"
|
||||
:save="updateproductmodif()"
|
||||
:type="costanti.FieldType.date"
|
||||
>
|
||||
</CMyValueDb>
|
||||
<div v-else>
|
||||
{{ labelDataArrivoMerce }}
|
||||
</div>
|
||||
</q-item-label>
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
<q-item v-if="labelDataRitiro">
|
||||
<q-item v-if="labelDataRitiro || editOn">
|
||||
<q-item-section avatar>
|
||||
<q-icon color="green" name="fas fa-people-carry" />
|
||||
</q-item-section>
|
||||
@@ -529,7 +580,21 @@
|
||||
{{ t('gas.dataora_ritiro') }}
|
||||
</q-item-label>
|
||||
<q-item-label class="countdown_scadenza">
|
||||
<CMyValueDb
|
||||
v-if="editOn"
|
||||
:title="t('gas.dataora_ritiro')"
|
||||
table="gasordines"
|
||||
:id="recgasordineSelected._id"
|
||||
:rec="recgasordineSelected"
|
||||
mykey="dataora_ritiro"
|
||||
debounce="1000"
|
||||
:save="updateproductmodif()"
|
||||
:type="costanti.FieldType.date"
|
||||
>
|
||||
</CMyValueDb>
|
||||
<div v-else>
|
||||
{{ labelDataRitiro }}
|
||||
</div>
|
||||
</q-item-label>
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
@@ -563,6 +628,122 @@
|
||||
<div class="no-outline label-qta text-center" tabindex="0">
|
||||
{{ myorder.quantity + myorder.quantitypreordered }}
|
||||
</div>
|
||||
<div v-if="editOn">
|
||||
<CMyValueDb
|
||||
:title="t('products.note')"
|
||||
table="products"
|
||||
:id="myproduct._id"
|
||||
:rec="myproduct"
|
||||
mykey="note"
|
||||
debounce="1000"
|
||||
:save="updateproductmodif()"
|
||||
:type="costanti.FieldType.string"
|
||||
>
|
||||
</CMyValueDb>
|
||||
|
||||
<div v-if="!isOrdGas()">
|
||||
<CMyValueDb
|
||||
:title="t('products.stockQty')"
|
||||
table="products"
|
||||
:id="myproduct._id"
|
||||
:rec="myproduct"
|
||||
mykey="stockQty"
|
||||
debounce="1000"
|
||||
:save="updateproductmodif()"
|
||||
:type="costanti.FieldType.number"
|
||||
>
|
||||
</CMyValueDb>
|
||||
<CMyValueDb
|
||||
:title="t('products.stockBloccatiQty')"
|
||||
table="products"
|
||||
:id="myproduct._id"
|
||||
:rec="myproduct"
|
||||
mykey="stockBloccatiQty"
|
||||
debounce="1000"
|
||||
:save="updateproductmodif()"
|
||||
:type="costanti.FieldType.number"
|
||||
>
|
||||
</CMyValueDb>
|
||||
<CMyValueDb
|
||||
:title="t('products.bookedQtyOrdered')"
|
||||
table="products"
|
||||
:id="myproduct._id"
|
||||
:rec="myproduct"
|
||||
mykey="bookedQtyOrdered"
|
||||
debounce="1000"
|
||||
:save="updateproductmodif()"
|
||||
:type="costanti.FieldType.number"
|
||||
>
|
||||
</CMyValueDb>
|
||||
<CMyValueDb
|
||||
:title="t('products.bookedQtyConfirmed')"
|
||||
table="products"
|
||||
:id="myproduct._id"
|
||||
:rec="myproduct"
|
||||
mykey="bookedQtyConfirmed"
|
||||
debounce="1000"
|
||||
:save="updateproductmodif()"
|
||||
:type="costanti.FieldType.number"
|
||||
>
|
||||
</CMyValueDb>
|
||||
</div>
|
||||
<q-separator> </q-separator>
|
||||
<div v-if="isOrdGas()">
|
||||
<CMyValueDb
|
||||
:title="t('products.maxbookableGASQty')"
|
||||
table="products"
|
||||
:id="myproduct._id"
|
||||
:rec="myproduct"
|
||||
mykey="maxbookableGASQty"
|
||||
debounce="1000"
|
||||
:save="updateproductmodif()"
|
||||
:type="costanti.FieldType.number"
|
||||
>
|
||||
</CMyValueDb>
|
||||
<CMyValueDb
|
||||
:title="t('products.bookableGASBloccatiQty')"
|
||||
table="products"
|
||||
:id="myproduct._id"
|
||||
:rec="myproduct"
|
||||
mykey="bookableGASBloccatiQty"
|
||||
debounce="1000"
|
||||
:save="updateproductmodif()"
|
||||
:type="costanti.FieldType.number"
|
||||
>
|
||||
</CMyValueDb>
|
||||
<CMyValueDb
|
||||
:title="t('ecomm.bookedGASQtyOrdered')"
|
||||
table="products"
|
||||
:id="myproduct._id"
|
||||
:rec="myproduct"
|
||||
mykey="bookedGASQtyOrdered"
|
||||
debounce="1000"
|
||||
:save="updateproductmodif()"
|
||||
:type="costanti.FieldType.number"
|
||||
>
|
||||
</CMyValueDb>
|
||||
<CMyValueDb
|
||||
:title="t('products.bookedGASQtyConfirmed')"
|
||||
table="products"
|
||||
:id="myproduct._id"
|
||||
:rec="myproduct"
|
||||
mykey="bookedGASQtyConfirmed"
|
||||
debounce="1000"
|
||||
:save="updateproductmodif()"
|
||||
:type="costanti.FieldType.number"
|
||||
>
|
||||
</CMyValueDb>
|
||||
</div>
|
||||
<div class="text-center">
|
||||
<q-btn
|
||||
rounded
|
||||
icon="fas fa-sync-alt"
|
||||
color="primary"
|
||||
:label="t('ecomm.ricarica')"
|
||||
@click="ricarica()"
|
||||
></q-btn>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</q-field>
|
||||
|
||||
@@ -597,6 +778,26 @@
|
||||
></q-btn>
|
||||
</div>
|
||||
</q-card-section>
|
||||
<q-toggle
|
||||
v-if="tools.isManager()"
|
||||
v-model="editOn"
|
||||
color="green"
|
||||
icon="fas fa-pencil-alt"
|
||||
dense
|
||||
>
|
||||
</q-toggle>
|
||||
<CMyValueDb
|
||||
v-if="editOn"
|
||||
:title="t('ecomm.active')"
|
||||
table="products"
|
||||
:id="myproduct._id"
|
||||
:rec="myproduct"
|
||||
mykey="active"
|
||||
debounce="1000"
|
||||
:save="updateproductmodif()"
|
||||
:type="costanti.FieldType.boolean"
|
||||
>
|
||||
</CMyValueDb>
|
||||
</q-card>
|
||||
|
||||
<q-dialog v-model="openlistorders">
|
||||
|
||||
@@ -38,7 +38,7 @@ export default defineComponent({
|
||||
},
|
||||
},
|
||||
components: { CTitleBanner, CCardState, CCopyBtn },
|
||||
setup(props) {
|
||||
setup(props, { emit }) {
|
||||
const products = useProducts()
|
||||
const order = toRef(props, 'order')
|
||||
const { t } = useI18n()
|
||||
@@ -110,8 +110,9 @@ export default defineComponent({
|
||||
|
||||
}
|
||||
|
||||
function updateOrder(val: any) {
|
||||
|
||||
async function updateOrder(paramstoupdate: any) {
|
||||
await products.updateOrderByOrder(props.idOrdersCart, order.value._id, paramstoupdate)
|
||||
emit('update')
|
||||
}
|
||||
|
||||
function getRisparmio(): string {
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
v-if="order.product.productInfo.unit"
|
||||
>
|
||||
{{ tools.getWeightTotalByOrder(order) }}
|
||||
{{ tools.getUnitsMeasure(order.product.productInfo.unit, true) }}
|
||||
{{ tools.getUnitsMeasure(order.product.productInfo.unit, true, order.product.productInfo.weight) }}
|
||||
</div>
|
||||
<div class="row q-mb-xs no-wrap items-center centeritems">
|
||||
<q-btn
|
||||
@@ -49,7 +49,7 @@
|
||||
borderless
|
||||
rounded
|
||||
dense
|
||||
:label="$t('products.quantity')"
|
||||
:label="t('products.quantity')"
|
||||
></q-input>
|
||||
<q-input
|
||||
v-model="order.quantitypreordered"
|
||||
@@ -58,10 +58,21 @@
|
||||
borderless
|
||||
rounded
|
||||
dense
|
||||
@update:model-value="updateOrder"
|
||||
:label="$t('ecomm.preord')"
|
||||
:label="t('ecomm.preord')"
|
||||
></q-input>
|
||||
</div>
|
||||
<div v-if="tools.isManager">
|
||||
<q-btn
|
||||
outline
|
||||
rounded
|
||||
dense
|
||||
color="green"
|
||||
icon="fas fa-redo"
|
||||
:label="t('orderscart.update_order')"
|
||||
@click="updateOrder({quantitypreordered: order.quantitypreordered, quantity: order.quantity})"
|
||||
>
|
||||
</q-btn>
|
||||
</div>
|
||||
<div v-else-if="showall" :class="`q-mx-sm text-blue-14 qta`">
|
||||
{{ order.quantity + order.quantitypreordered }}
|
||||
</div>
|
||||
@@ -86,7 +97,7 @@
|
||||
<q-item-label>
|
||||
<div class="col-2 no-wrap text-subtitle3_short q-mr-sm">
|
||||
<span class="prezzo_singolo">
|
||||
{{ (order.quantity + order.quantitypreordered) }} x €
|
||||
{{ order.quantity + order.quantitypreordered }} x €
|
||||
{{ order.price ? order.price : 0 }}
|
||||
</span>
|
||||
<span :class="isApplicatoSconto() ? 'ordine_scontato_nuovo' : ''">
|
||||
@@ -103,8 +114,8 @@
|
||||
>€
|
||||
{{
|
||||
(
|
||||
(order.price * order.quantity) +
|
||||
(order.price * order.quantitypreordered)
|
||||
order.price * order.quantity +
|
||||
order.price * order.quantitypreordered
|
||||
).toFixed(2)
|
||||
}}</span
|
||||
>)</span
|
||||
|
||||
@@ -8,11 +8,13 @@ import MixinMetaTags from '@src/mixins/mixin-metatags'
|
||||
import { useUserStore } from '@store/UserStore'
|
||||
import { useGlobalStore } from '@store/globalStore'
|
||||
import { useQuasar } from 'quasar'
|
||||
import { IDataPass, ISpecialField } from '@model'
|
||||
import { IDataPass, IProducer, IProduct, ISpecialField } from '@model'
|
||||
import { tools } from '../store/Modules/tools'
|
||||
import { costanti } from '@costanti'
|
||||
import { fieldsTable } from '@store/Modules/fieldsTable'
|
||||
|
||||
import { useProducts } from '@store/Products'
|
||||
|
||||
// You can declare a mixin as the same style as components.
|
||||
export default function () {
|
||||
function showNotif(msg: string) {
|
||||
@@ -183,6 +185,14 @@ export default function () {
|
||||
}
|
||||
}
|
||||
|
||||
if (table === 'products') {
|
||||
const productStore = useProducts()
|
||||
const idprod = productStore.products.findIndex((rec: IProduct) => rec._id === id)
|
||||
if (idprod >= 0 && key) {
|
||||
productStore.products[idprod][key as keyof IProduct] = value
|
||||
}
|
||||
}
|
||||
|
||||
console.log('mydatatosave', mydatatosave)
|
||||
|
||||
// @ts-ignore
|
||||
|
||||
@@ -224,7 +224,7 @@ export interface IUserFields {
|
||||
numinvitati?: number
|
||||
numinvitatiattivi?: number
|
||||
cart?: ICart
|
||||
ordercart?: IOrderCart
|
||||
orderscart?: IOrderCart
|
||||
calcstat?: ICalcStat|null
|
||||
|
||||
account?: IAccount
|
||||
|
||||
@@ -240,6 +240,7 @@ const msg_it = {
|
||||
ricevo_dono_long: 'Evviva!!!<br><strong>QUESTO MOVIMENTO È REALE E POSSIBILE SE LO FACCIAMO FUNZIONARE TUTTI INSIEME !</strong>',
|
||||
},
|
||||
dialog: {
|
||||
azzera: 'Azzera',
|
||||
continue: 'Continuare',
|
||||
close: 'Chiudi',
|
||||
copyclipboard: 'Copiato negli appunti',
|
||||
@@ -1713,6 +1714,8 @@ const msg_it = {
|
||||
offerta_gas_raggiunta: 'Complimenti! Gli ordini hanno superato il minimo quantitativo di {qta} {unit}',
|
||||
note: 'Note',
|
||||
apriordine: 'Vedi Ordine',
|
||||
ordine_scaduto: 'l\'Ordine è stato chiuso il {date}!',
|
||||
ricarica: 'Ricarica',
|
||||
},
|
||||
gas: {
|
||||
name: 'Ordine Gas',
|
||||
@@ -1735,6 +1738,7 @@ const msg_it = {
|
||||
sendmail_test: 'Invia Email TEST',
|
||||
email_sent: '{inviate} email inviate !',
|
||||
email_not_send: 'Email non inviata',
|
||||
update_order: 'Aggiorna Ordine',
|
||||
},
|
||||
cash: {
|
||||
creatorUserId: 'Creatore',
|
||||
|
||||
@@ -8323,6 +8323,7 @@ export const tools = {
|
||||
// Calculate the difference in milliseconds
|
||||
const countdown = targetTime - currentDate.getTime();
|
||||
|
||||
if (countdown > 0) {
|
||||
// Convert milliseconds to seconds
|
||||
const countdownInSeconds = Math.floor(countdown / 1000);
|
||||
|
||||
@@ -8335,6 +8336,9 @@ export const tools = {
|
||||
const strgg = gg ? `${days} giorni` : ''
|
||||
|
||||
return (`${strgg} ${this.pad(hours)}:${this.pad(minutes)}:${this.pad(seconds)}`);
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
|
||||
@@ -303,8 +303,8 @@ export const useProducts = defineStore('Products', {
|
||||
getOrdersCartByIdProduct: (state: IProductsState) => (idproduct: string): IOrderCart[] | [] => {
|
||||
try {
|
||||
if (state.orders) {
|
||||
const ris = state.orders.filter((ordercart: IOrderCart) => {
|
||||
return ordercart.items!.some(item => {
|
||||
const ris = state.orders.filter((orderscart: IOrderCart) => {
|
||||
return orderscart.items!.some(item => {
|
||||
if (item.order)
|
||||
return (item.order.idProduct === idproduct)
|
||||
&& (item.order.status! < shared_consts.OrderStatus.CHECKOUT_SENT)
|
||||
@@ -322,8 +322,8 @@ export const useProducts = defineStore('Products', {
|
||||
getOrdersCartInAttesaByIdProduct: (state: IProductsState) => (idproduct: string): IOrderCart[] | [] => {
|
||||
try {
|
||||
if (state.orders) {
|
||||
const ris = state.orders.filter((ordercart: IOrderCart) => {
|
||||
return ordercart.items!.some(item => {
|
||||
const ris = state.orders.filter((orderscart: IOrderCart) => {
|
||||
return orderscart.items!.some(item => {
|
||||
if (item.order)
|
||||
return (item.order.idProduct === idproduct)
|
||||
&& (item.order.status! <= shared_consts.OrderStatus.CHECKOUT_SENT)
|
||||
@@ -435,24 +435,100 @@ export const useProducts = defineStore('Products', {
|
||||
return ris
|
||||
},
|
||||
|
||||
async loadProduct({ code }: { code: any }) {
|
||||
async updateOrderByOrder(idOrdersCart: string, idOrder: string, paramstoupdate: any) {
|
||||
|
||||
const userStore = useUserStore()
|
||||
const globalStore = useGlobalStore()
|
||||
|
||||
// console.log('loadProducts')
|
||||
|
||||
if (!globalStore.site.confpages.enableEcommerce)
|
||||
return null
|
||||
|
||||
console.log('updateOrderByOrder', 'userid=', userStore.my._id)
|
||||
|
||||
let ris = null
|
||||
|
||||
ris = await Api.SendReq('/orders/updateord', 'POST', { idOrdersCart, idOrder, paramstoupdate })
|
||||
.then((res) => {
|
||||
let myorderscart = res.data.orderscart
|
||||
if (res) {
|
||||
myorderscart = res.data && res.data.orderscart ? res.data.orderscart : null
|
||||
if (myorderscart) {
|
||||
const idord = this.orders.findIndex((ord: IOrderCart) => ord._id === myorderscart._id)
|
||||
if (idord >= 0) {
|
||||
console.log('aggiorna ordine')
|
||||
this.orders[idord] = {...myorderscart}
|
||||
}
|
||||
}
|
||||
}
|
||||
return myorderscart
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log('error updateOrderByOrder', error)
|
||||
userStore.setErrorCatch(error)
|
||||
return new Types.AxiosError(serv_constants.RIS_CODE_ERR, null, toolsext.ERR_GENERICO, error)
|
||||
})
|
||||
|
||||
// ApiTables.aftercalling(ris, checkPending, 'categories')
|
||||
|
||||
return ris
|
||||
},
|
||||
|
||||
async updateOrdersCartById(idOrdersCart: string, paramstoupdate: any) {
|
||||
|
||||
const userStore = useUserStore()
|
||||
const globalStore = useGlobalStore()
|
||||
|
||||
// console.log('loadProducts')
|
||||
|
||||
if (!globalStore.site.confpages.enableEcommerce)
|
||||
return null
|
||||
|
||||
console.log('updateOrdersCartById', 'userid=', userStore.my._id)
|
||||
|
||||
let ris = null
|
||||
|
||||
ris = await Api.SendReq('/orders/update', 'POST', { idOrdersCart, paramstoupdate })
|
||||
.then((res) => {
|
||||
let myorderscart = res.data.orderscart
|
||||
if (res) {
|
||||
if (myorderscart) {
|
||||
const idord = this.orders.findIndex((ord: IOrderCart) => ord._id === myorderscart._id)
|
||||
if (idord >= 0) {
|
||||
console.log('aggiorna orderscart')
|
||||
this.orders[idord] = myorderscart
|
||||
}
|
||||
}
|
||||
}
|
||||
return myorderscart
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log('error updateOrderByOrder', error)
|
||||
userStore.setErrorCatch(error)
|
||||
return new Types.AxiosError(serv_constants.RIS_CODE_ERR, null, toolsext.ERR_GENERICO, error)
|
||||
})
|
||||
|
||||
// ApiTables.aftercalling(ris, checkPending, 'categories')
|
||||
|
||||
return ris
|
||||
},
|
||||
|
||||
async loadProductById(id: string) {
|
||||
|
||||
console.log('loadProduct', code)
|
||||
const userStore = useUserStore()
|
||||
const globalStore = useGlobalStore()
|
||||
|
||||
if (!globalStore.site.confpages.enableEcommerce)
|
||||
return null
|
||||
|
||||
console.log('getProduct', 'code', code)
|
||||
|
||||
// if (userStore.my._id === '') {
|
||||
// return new Types.AxiosError(0, null, 0, '')
|
||||
// }
|
||||
|
||||
let ris = null
|
||||
|
||||
ris = await Api.SendReq('/products/' + code, 'POST', { code })
|
||||
ris = await Api.SendReq('/products/id/' + id, 'GET', null)
|
||||
.then((res) => {
|
||||
console.log('product', res.data.product)
|
||||
if (res.data.product) { // console.log('RISULTANTE CATEGORIES DAL SERVER = ', res.data.categories)
|
||||
|
||||
@@ -221,8 +221,8 @@ export default defineComponent({
|
||||
function updateorders() {
|
||||
myorderscart.value = getOrdersCart()
|
||||
if (myorderscart.value) {
|
||||
for (const ordercart of myorderscart.value) {
|
||||
myarrrec.value[ordercart._id] = Object.keys(ordercart)
|
||||
for (const orderscart of myorderscart.value) {
|
||||
myarrrec.value[orderscart._id] = Object.keys(orderscart)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -300,14 +300,14 @@
|
||||
</div>
|
||||
|
||||
<!--
|
||||
<div v-for="(ordercart, index) in getOrdersCart" :key="index">
|
||||
<div v-for="(orderscart, index) in getOrdersCart" :key="index">
|
||||
|
||||
<div>
|
||||
{{ ordercart.numorder }}<br>
|
||||
{{ orderscart.numorder }}<br>
|
||||
</div>
|
||||
|
||||
<div class="container">
|
||||
<div class="q-pa-sm col items-start q-gutter-xs" v-for="(itemorder, index) in ordercart.items" :key="index">
|
||||
<div class="q-pa-sm col items-start q-gutter-xs" v-for="(itemorder, index) in orderscart.items" :key="index">
|
||||
|
||||
<CSingleCart :order="itemorder.order" :showall="true" :nomodif="true"/>
|
||||
</div>
|
||||
@@ -315,14 +315,14 @@
|
||||
<q-separator></q-separator>
|
||||
<div class="col-6 q-mr-sm" style="text-align: right">
|
||||
<span class="text-grey q-mr-xs">Totale:</span> <span
|
||||
class="text-subtitle1 q-mr-sm ">€ {{ ordercart.totalPrice.toFixed(2) }}</span>
|
||||
class="text-subtitle1 q-mr-sm ">€ {{ orderscart.totalPrice.toFixed(2) }}</span>
|
||||
</div>
|
||||
|
||||
<q-input v-model="ordercart.note" style="max-width: 400px;" label="Note aggiuntive:"
|
||||
<q-input v-model="orderscart.note" style="max-width: 400px;" label="Note aggiuntive:"
|
||||
filled dense
|
||||
debounce="1000"
|
||||
autogrow
|
||||
@input="change_field(ordercart.id, 'note')">
|
||||
@input="change_field(orderscart.id, 'note')">
|
||||
</q-input>
|
||||
|
||||
<br>
|
||||
|
||||
Reference in New Issue
Block a user