- Categorie
- ProductInfo
This commit is contained in:
@@ -253,6 +253,31 @@
|
||||
></q-btn>
|
||||
<br />
|
||||
</div>
|
||||
<div class="row">
|
||||
<q-btn
|
||||
label="10. Elimina la Tabella PRODUCTS e PRODUCTINFOS !)"
|
||||
color="negative"
|
||||
@click="EseguiFunz('dropProducts')"
|
||||
></q-btn>
|
||||
<br />
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<q-btn
|
||||
label="11. Elimina tutti gli ORDINI ! (Orders, Orderscart, Cart) !)"
|
||||
color="negative"
|
||||
@click="EseguiFunz('dropAllOrders')"
|
||||
></q-btn>
|
||||
<br />
|
||||
</div>
|
||||
<div class="row">
|
||||
<q-btn
|
||||
label="12. Elimina tutti i Carrelli (Cart) !)"
|
||||
color="negative"
|
||||
@click="EseguiFunz('dropAllCarts')"
|
||||
></q-btn>
|
||||
<br />
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<q-btn
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="q-pa-md row items-start q-gutter-md" v-for="(product, index) in getProducts()" :key="index">
|
||||
<CProductCard :code="product.code"/>
|
||||
<CProductCard :id="product._id"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -8,7 +8,7 @@ import { useI18n } from '@/boot/i18n'
|
||||
import { toolsext } from '@store/Modules/toolsext'
|
||||
import { useQuasar } from 'quasar'
|
||||
import { costanti } from '@costanti'
|
||||
import { ICart, IOrder, IOrderCart, IShareWithUs } from '@src/model/Products'
|
||||
import { ICart, IOrder, IOrderCart, IProduct, IShareWithUs } from '@src/model/Products'
|
||||
|
||||
import { shared_consts } from '@src/common/shared_vuejs'
|
||||
|
||||
@@ -178,13 +178,39 @@ export default defineComponent({
|
||||
})
|
||||
}
|
||||
|
||||
function getActualIdStorehouse(myprod: IProduct) {
|
||||
// Ottieni il negozio attualmente selezionato:
|
||||
// Se ce n'è solo 1 allora prendi quello !
|
||||
if (myprod.storehouses.length === 1) {
|
||||
return myprod.storehouses[0]._id
|
||||
} else {
|
||||
// Ottieni il negozio attualmente scelto !
|
||||
return ''
|
||||
}
|
||||
}
|
||||
|
||||
function getActualGasordine(myprod: IProduct) {
|
||||
// Ottieni il negozio attualmente selezionato:
|
||||
// Se ce n'è solo 1 allora prendi quello !
|
||||
if (myprod.gasordines.length === 1) {
|
||||
return myprod.gasordines[0]._id
|
||||
} else {
|
||||
// Ottieni il gasordine attualmente scelto !
|
||||
return ''
|
||||
}
|
||||
}
|
||||
|
||||
async function insertArticolo() {
|
||||
let lowerSearchText = search.value.trim();
|
||||
|
||||
const myprod = productStore.getProductByCode(lowerSearchText);
|
||||
if (myprod && myprod.active) {
|
||||
let myorder: IOrder = { quantity: 1, quantitypreordered: 0, price: 0, TotalPriceProduct: 0 }
|
||||
await productStore.addtoCartBase({ $q, t, code: myprod.code!, order: myorder, addqty: true })
|
||||
let myorder: IOrder = { quantity: 1, quantitypreordered: 0,
|
||||
TotalPriceProduct: 0, price: 0,
|
||||
idStorehouse: getActualIdStorehouse(myprod),
|
||||
idGasordine: getActualGasordine(myprod),
|
||||
}
|
||||
await productStore.addtoCartBase({ $q, t, id: myprod._id, order: myorder, addqty: true })
|
||||
search.value = ''
|
||||
load()
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ export default defineComponent({
|
||||
const productStore = useProducts()
|
||||
const $router = useRouter()
|
||||
const $q = useQuasar()
|
||||
const { t } = useI18n();
|
||||
const { t } = useI18n()
|
||||
|
||||
const myorderscart = ref(<IOrderCart[] | undefined>[])
|
||||
const myarrrec = ref(<any>{})
|
||||
@@ -313,6 +313,7 @@ export default defineComponent({
|
||||
endload,
|
||||
getOrdersCartWithTotals,
|
||||
productStore,
|
||||
t,
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -54,10 +54,10 @@
|
||||
:key="index"
|
||||
>
|
||||
<div
|
||||
v-if="!!item && item.order && item.order.product"
|
||||
v-if="!!item && item.order && item.order.product && item.order.product.productInfo"
|
||||
>
|
||||
{{ item.order.product.name }} ({{
|
||||
productStore.getQuantityByOrder($t, item.order)
|
||||
{{ item.order.product.productInfo.name }} ({{
|
||||
productStore.getQuantityByOrder(t, item.order)
|
||||
}})<br />
|
||||
</div>
|
||||
</div>
|
||||
@@ -139,8 +139,8 @@
|
||||
</q-td>
|
||||
<q-td key="items" :props="props">
|
||||
<div v-for="(item, index) of props.row.items" :key="index">
|
||||
<div v-if="!!item.order && item.order.product">
|
||||
{{ item.order.product.name }} ({{
|
||||
<div v-if="!!item.order && item.order.product && item.order.product.productInfo">
|
||||
{{ item.order.product.productInfo.name }} ({{
|
||||
productStore.getQuantityByOrder($t, item.order)
|
||||
}})<br />
|
||||
</div>
|
||||
|
||||
@@ -15,7 +15,7 @@ import { CProductCard } from '@src/components/CProductCard'
|
||||
|
||||
|
||||
export default defineComponent({
|
||||
name: 'ProductInfo',
|
||||
name: 'productInfo',
|
||||
components: { CProductCard },
|
||||
props: {},
|
||||
setup() {
|
||||
@@ -26,7 +26,8 @@ export default defineComponent({
|
||||
const $route = useRoute()
|
||||
const $q = useQuasar()
|
||||
const { t } = useI18n();
|
||||
const code = ref('')
|
||||
const id = ref('')
|
||||
const cosa = ref(0)
|
||||
|
||||
// const { setValDb, getValDb } = MixinBase()
|
||||
|
||||
@@ -34,11 +35,13 @@ export default defineComponent({
|
||||
// Inizializza
|
||||
console.log('created productInfo')
|
||||
console.log($route)
|
||||
if (!!$route.params.codprod) {
|
||||
code.value = $route.params.codprod.toString()
|
||||
if (!!$route.params.idprod) {
|
||||
id.value = $route.params.idprod.toString()
|
||||
}
|
||||
if (!!$route.params.idprod) {
|
||||
cosa.value = tools.strToVal($route.params.cosa.toString())
|
||||
}
|
||||
|
||||
console.log('code', code)
|
||||
}
|
||||
|
||||
onMounted(mounted)
|
||||
@@ -49,7 +52,8 @@ export default defineComponent({
|
||||
tools,
|
||||
toolsext,
|
||||
shared_consts,
|
||||
code,
|
||||
id,
|
||||
cosa,
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<div class="panel">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<CProductCard :code="code" complete="true"/>
|
||||
<CProductCard :id="id" :cosa="cosa" :complete="true"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -3,3 +3,12 @@ $heightBtn: 100%;
|
||||
.card .product-image {
|
||||
height: 300px;
|
||||
}
|
||||
|
||||
.container{
|
||||
margin-top: 4px;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.prod_trov{
|
||||
font-style: italic;
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import { defineComponent, onMounted, ref, watch } from 'vue'
|
||||
import { defineComponent, onMounted, ref, watch, computed } from 'vue'
|
||||
import { tools } from '@store/Modules/tools'
|
||||
import { useUserStore } from '@store/UserStore'
|
||||
import { useRouter } from 'vue-router'
|
||||
@@ -29,40 +29,71 @@ export default defineComponent({
|
||||
const search = ref('')
|
||||
|
||||
const cosa = ref(0)
|
||||
const cat = ref('')
|
||||
|
||||
watch(() => cosa.value, (newval, oldval) => {
|
||||
tools.setCookie(tools.COOK_COSA_PRODOTTI, cosa.value.toString())
|
||||
})
|
||||
|
||||
function mounted() {
|
||||
cosa.value = tools.getCookie(tools.COOK_COSA_PRODOTTI, shared_consts.PROD.BOTTEGA, true)
|
||||
// Inizializza
|
||||
productStore.loadProducts()
|
||||
}
|
||||
function getProducts() {
|
||||
const getArrProducts = computed(() => {
|
||||
let arrprod = productStore.getProducts(cosa.value)
|
||||
if (!search.value) {
|
||||
let catstr = cat.value;
|
||||
if (!search.value && !catstr) {
|
||||
return arrprod
|
||||
}
|
||||
|
||||
let lowerSearchText = search.value.toLowerCase();
|
||||
|
||||
return arrprod.filter((product: IProduct) => {
|
||||
let lowerName = product.name!.toLowerCase();
|
||||
return product.code!.includes(search.value) || lowerName.includes(lowerSearchText);
|
||||
});
|
||||
let lowerName = product.productInfo.name!.toLowerCase()
|
||||
let hasCategoria = !catstr || (catstr && product.productInfo.idCatProds?.includes(catstr))
|
||||
return (product.productInfo.code!.includes(search.value) || lowerName.includes(lowerSearchText)) && hasCategoria
|
||||
});
|
||||
})
|
||||
|
||||
/*function getProducts() {
|
||||
let arrprod = productStore.getProducts(cosa.value)
|
||||
if (!search.value) {
|
||||
return arrprod
|
||||
}
|
||||
|
||||
let lowerSearchText = search.value.toLowerCase();
|
||||
let catstr = cat.value;
|
||||
|
||||
return arrprod.filter((product: IProduct) => {
|
||||
let lowerName = product.productInfo.name!.toLowerCase();
|
||||
const hasCategoria = !catstr || (catstr && product.productInfo.idCatProds?.includes(catstr));
|
||||
return (product.productInfo.code!.includes(search.value) || lowerName.includes(lowerSearchText)) && hasCategoria
|
||||
});
|
||||
}*/
|
||||
|
||||
function mounted() {
|
||||
cosa.value = tools.getCookie(tools.COOK_COSA_PRODOTTI, shared_consts.PROD.BOTTEGA, true)
|
||||
// Inizializza
|
||||
productStore.loadProducts()
|
||||
}
|
||||
|
||||
function getCatProds() {
|
||||
let arrcat = productStore.getCatProds()
|
||||
let riscat = [{ label: 'Tutti', value: '' }]
|
||||
for (const rec of arrcat) {
|
||||
riscat.push({ label: rec.name, value: rec._id })
|
||||
}
|
||||
|
||||
return riscat
|
||||
}
|
||||
|
||||
|
||||
function getNumQtaGas() {
|
||||
const arrprod = productStore.getProducts(shared_consts.PROD.GAS)
|
||||
return arrprod.length
|
||||
}
|
||||
|
||||
|
||||
function getNumQtaBottega() {
|
||||
const arrprod = productStore.getProducts(shared_consts.PROD.BOTTEGA)
|
||||
return arrprod.length
|
||||
}
|
||||
|
||||
|
||||
onMounted(mounted)
|
||||
|
||||
return {
|
||||
@@ -70,12 +101,16 @@ export default defineComponent({
|
||||
costanti,
|
||||
tools,
|
||||
toolsext,
|
||||
getProducts,
|
||||
getArrProducts,
|
||||
search,
|
||||
cosa,
|
||||
shared_consts,
|
||||
getNumQtaGas,
|
||||
getNumQtaBottega,
|
||||
getCatProds,
|
||||
cat,
|
||||
productStore,
|
||||
t,
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -18,9 +18,9 @@
|
||||
<template v-slot:gas>
|
||||
<div class="row items-center no-wrap">
|
||||
<div class="text-center">
|
||||
{{ $t('gas.ordina_sul_gas') }}
|
||||
{{ t('gas.ordina_sul_gas') }}
|
||||
<br />
|
||||
{{ $t('gas.x_prodotti_gas', { qta: getNumQtaGas() }) }}
|
||||
{{ t('gas.x_prodotti_gas', { qta: getNumQtaGas() }) }}
|
||||
</div>
|
||||
<q-icon right name="fas fa-user-friends" />
|
||||
</div>
|
||||
@@ -29,10 +29,10 @@
|
||||
<template v-slot:bottega>
|
||||
<div class="row items-center no-wrap">
|
||||
<div class="text-center">
|
||||
{{ $t('gas.bottega') }}
|
||||
{{ t('gas.bottega') }}
|
||||
<br />
|
||||
{{
|
||||
$t('gas.x_prodotti_bottega', { qta: getNumQtaBottega() })
|
||||
t('gas.x_prodotti_bottega', { qta: getNumQtaBottega() })
|
||||
}}
|
||||
</div>
|
||||
<q-icon right name="fas fa-store" />
|
||||
@@ -43,13 +43,13 @@
|
||||
</div>
|
||||
<div class="container">
|
||||
<div
|
||||
class="q-gutter-y-md column text-center q-mx-auto"
|
||||
class="q-gutter-y-md column text-center q-mx-auto q-py-sm"
|
||||
style="width: 350px; max-width: 100%"
|
||||
>
|
||||
<q-input
|
||||
filledd
|
||||
stack-label
|
||||
:label="$t('ecomm.code_o_text_search')"
|
||||
:label="t('ecomm.code_o_text_search')"
|
||||
v-model="search"
|
||||
class="q-ml-md"
|
||||
>
|
||||
@@ -58,13 +58,35 @@
|
||||
</template>
|
||||
</q-input>
|
||||
</div>
|
||||
<div class="row q-gutter-sm justify-evenly q-mx-auto">
|
||||
<div v-for="(reccat, index) in getCatProds()" :key="index">
|
||||
<q-btn
|
||||
:push="cat === reccat.value"
|
||||
dense
|
||||
rounded
|
||||
:color="cat === reccat.value ? 'blue' : undefined"
|
||||
glossy
|
||||
:label="reccat.label"
|
||||
@click="cat = reccat.value"
|
||||
>
|
||||
</q-btn>
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-center q-py-sm prod_trov">
|
||||
{{
|
||||
t('ecomm.prodotti_trovati', {
|
||||
qta: getArrProducts.length,
|
||||
qtatot: productStore.getNumProdTot(),
|
||||
})
|
||||
}}{{}}
|
||||
</div>
|
||||
<div class="row">
|
||||
<div
|
||||
class="q-pa-md row items-start q-gutter-md"
|
||||
v-for="(product, index) in getProducts()"
|
||||
v-for="(product, index) in getArrProducts"
|
||||
:key="index"
|
||||
>
|
||||
<CProductCard :code="product.code" :complete="false" :cosa="cosa" />
|
||||
<CProductCard :id="product._id" :complete="false" :cosa="cosa" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user