- edit campi prodotti
- edit ordini
This commit is contained in:
@@ -126,4 +126,8 @@
|
||||
width: 100%;
|
||||
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">
|
||||
{{ labelDataArrivoMerce }}
|
||||
<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">
|
||||
{{ labelDataRitiro }}
|
||||
<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">
|
||||
|
||||
Reference in New Issue
Block a user