- aggiornamento Cataloghi

- Gestione delle versioni del prodotto ("Nuovi","Usati","Epub", ecc..)
This commit is contained in:
Surya Paolo
2024-06-20 17:22:46 +02:00
parent 49d51712bd
commit 2ffcf56625
55 changed files with 659 additions and 400 deletions

View File

@@ -551,6 +551,11 @@
color="primary"
@click="EseguiFunz('correggiCircuitiANull', '', '')"
></q-btn>
<br /><q-btn
label="Correggi i ProductType in ProductTypes"
color="primary"
@click="EseguiFunz('correggiProductTypes', '', '')"
></q-btn>
<br />
</div>
<div class="row">

View File

@@ -1,4 +1,4 @@
import { defineComponent, onMounted, ref, watch, computed, onBeforeUnmount } from 'vue'
import { defineComponent, onMounted, ref, watch, computed, onBeforeUnmount, PropType } from 'vue'
import { tools } from '@store/Modules/tools'
import { useUserStore } from '@store/UserStore'
import { useRouter } from 'vue-router'
@@ -12,17 +12,30 @@ import { costanti } from '@costanti'
import { shared_consts } from '@/common/shared_vuejs'
import { CProductCard } from '@src/components/CProductCard'
import { CMySelect } from '@src/components/CMySelect'
import { CCatalogoCard } from '@src/components/CCatalogoCard'
import { CContainerCatalogoCard } from '@src/components/CContainerCatalogoCard'
import { CSelectUserActive } from '@src/components/CSelectUserActive'
import { IProduct, ISearchList } from 'model'
import { ICatalogo, IProduct, ISearchList } from 'model'
import { fieldsTable } from '@store/Modules/fieldsTable'
export default defineComponent({
name: 'Catalogo',
components: { CCatalogoCard, CProductCard, CSelectUserActive, CMySelect },
props: {},
setup() {
components: { CContainerCatalogoCard, CProductCard, CSelectUserActive, CMySelect },
props: {
optcatalogo: {
type: Object as PropType<ICatalogo>,
required: false,
default: () => ({
//++AddCATALOGO_FIELDS
productTypes: [0],
excludeproductTypes: [],
formato: [],
Categoria: [],
Editore: [],
}),
},
},
setup(props) {
const userStore = useUserStore()
const globalStore = useGlobalStore()
const productStore = useProducts()
@@ -49,6 +62,8 @@ export default defineComponent({
const mycolumns = ref([])
const tabvisu = ref('categorie')
const searchList = ref([] as ISearchList[])
const arrProducts = ref<any>([])
@@ -67,13 +82,6 @@ export default defineComponent({
return lab
})
const getlist = computed(() => {
const mylist = searchList.value.find((rec: any) => rec.table === 'products')
return mylist
})
const arrLoaded = computed(() => {
if (arrProducts.value && numRecLoaded.value)
return arrProducts.value.slice(0, numRecLoaded.value)
@@ -96,8 +104,8 @@ export default defineComponent({
watch(() => cat.value, (newval, oldval) => {
if (cat.value) {
filter.value.author = '' // disattivo il filtro autore
search.value = '' // disattivo anche la ricerca per testo
filter.value.author = '' // disattivo il filtro autore
resetSearch()
}
calcArrProducts()
@@ -107,7 +115,7 @@ export default defineComponent({
calcArrProducts()
})
watch(() => search.value, (newval, oldval) => {
watch(() => getSearchText(), (newval, oldval) => {
calcArrProducts()
if (tools.scrollTop() > 300) {
tools.scrollToTopValue(300)
@@ -118,7 +126,7 @@ export default defineComponent({
// Se filtroAuthor attivato, allora evito il filtro per Categoria
if (filter.value.author) {
cat.value = '' // disattivo il filtro categoria
search.value = '' // disattivo anche la ricerca per testo
resetSearch()
}
calcArrProducts()
@@ -134,22 +142,52 @@ export default defineComponent({
calcArrProducts()
})
function resetSearch() {
const mialista = getSearchList()
if (mialista && mialista.value && mialista.value.hasOwnProperty('name')) {
mialista.value = null
}
search.value = ''
}
function getSearchList() {
const mylist = searchList.value.find((rec: any) => rec.table === 'products' && rec.key === 'titolo')
return mylist
}
function getSearchText(): string {
const lista = getSearchList()
return lista && lista.value && lista.value.hasOwnProperty('name') ? lista.value.name : ''
}
function calcArrProducts() {
// console.log('calcArrProducts')
const searchtext = getSearchText()
refreshpage.value = true
let arrprod = productStore.getProducts(cosa.value) || [];
let filtroAuthor = filter.value.author || '';
let catstr = cat.value || '';
//++AddCATALOGO_FIELDS
let filtroProductTypes = props.optcatalogo.productTypes || [0]
let filtroExcludeProductTypes = props.optcatalogo.excludeproductTypes || [0]
let boolfiltroVuotoProductTypes = (filtroProductTypes.length === 0 || (filtroProductTypes.length === 1 && (filtroProductTypes[0] === 0)))
let boolfiltroVuotoExcludeProductTypes = filtroExcludeProductTypes.length === 0
//console.log('filtroVersione', filtroProductTypes)
let catstr = cat.value || ''
let gasselstr = ''
if (cosa.value === shared_consts.PROD.GAS) {
gasselstr = idGasSel.value || '';
}
let lowerSearchText = (search.value || '').toLowerCase().trim();
let lowerSearchText = (searchtext || '').toLowerCase().trim();
lowerSearchText = lowerSearchText.replace(/[-@:=]/g, '');
if ((!lowerSearchText || (lowerSearchText && lowerSearchText.length < 2)) && !catstr && !filtroAuthor && (!gasselstr && (cosa.value !== shared_consts.PROD.GAS))) {
if ((!lowerSearchText || (lowerSearchText && lowerSearchText.length < 2)) && !catstr && boolfiltroVuotoProductTypes && boolfiltroVuotoExcludeProductTypes && !filtroAuthor && (!gasselstr && (cosa.value !== shared_consts.PROD.GAS))) {
} else {
@@ -159,6 +197,21 @@ export default defineComponent({
let hasCategoria = !catstr || (catstr && (product.productInfo.idCatProds || []).includes(catstr));
let hasAuthor = !filtroAuthor || (filtroAuthor && (product.productInfo.idAuthors || []).includes(filtroAuthor));
let hasProductTypes = true
let hasExcludeProductTypes = false
//++AddCATALOGO_FIELDS
if (props.optcatalogo && !boolfiltroVuotoProductTypes) {
// check if productInfo.productTypes array includes some item in props.optcatalogo.ProductTypes array
hasProductTypes = !props.optcatalogo.productTypes || (props.optcatalogo.productTypes && (product.productInfo.productTypes || []).some((item: any) => props.optcatalogo.productTypes.includes(item)))
}
if (props.optcatalogo && !boolfiltroVuotoExcludeProductTypes) {
// check if productInfo.productTypes array exclude some item in props.optcatalogo.ProductTypes array
hasExcludeProductTypes = !props.optcatalogo.excludeproductTypes || (props.optcatalogo.excludeproductTypes && (product.productInfo.productTypes || []).every((item: any) => props.optcatalogo.excludeproductTypes.includes(item)))
}
let productgassel = true
if (gasselstr || (cosa.value === shared_consts.PROD.GAS)) {
productgassel = (product.idGasordine === gasselstr)
@@ -171,7 +224,7 @@ export default defineComponent({
// Check if all words in lowerSearchText are present in lowerName
let allWordsPresent = lowerSearchText.split(/\s+/).every(word => new RegExp(`\\b${word}\\b`, 'i').test(lowerName));
return (codeMatch.test(product.productInfo.code || '') || allWordsPresent) && hasCategoria && hasAuthor && productgassel;
return (codeMatch.test(product.productInfo.code || '') || allWordsPresent) && hasCategoria && hasAuthor && productgassel && hasProductTypes && !hasExcludeProductTypes;
} else {
console.error('product or product.productInfo is null');
return false;
@@ -214,7 +267,7 @@ export default defineComponent({
key: 'titolo',
type: costanti.FieldType.select_by_server,
value: '',
addall: true,
// addall: true,
arrvalue: [],
useinput: true,
filter: null,
@@ -224,9 +277,12 @@ export default defineComponent({
optauthors.value = productStore.getAuthors()
cosa.value = tools.getCookie(tools.COOK_COSA_PRODOTTI, shared_consts.PROD.GAS, true)
if (cosa.value === shared_consts.PROD.TUTTI)
cosa.value = shared_consts.PROD.GAS
//++Todo: Per ora visualizzo solo il "Negozio" e non i GAS...
cosa.value = shared_consts.PROD.BOTTEGA
//cosa.value = tools.getCookie(tools.COOK_COSA_PRODOTTI, shared_consts.PROD.GAS, true)
//if (cosa.value === shared_consts.PROD.TUTTI)
// Inizializza
loadpage.value = true
@@ -297,14 +353,16 @@ export default defineComponent({
filter.value.author = id
}
function searchval(newval: any, table: any, tablesel: any) {
/*function searchval(newval: any, table: any, tablesel: any) {
console.log('REFRR searchval', newval, table, 'tablesel', tablesel)
if (newval === '') {
search.value = ''
if (newval) {
if (newval.hasOwnProperty('name')) {
search.value = newval.name
}
} else {
search.value = newval.name
resetSearch()
}
}
}*/
const valoriopt = computed(() => (item: any, addall: boolean, addnone: boolean) => {
// console.log('valoriopt', item.table)
@@ -342,10 +400,10 @@ export default defineComponent({
selauthor,
searchList,
fieldsTable,
searchval,
valoriopt,
labelcombo,
mycolumns,
tabvisu,
}
}
})

View File

@@ -7,131 +7,25 @@
<div v-if="true"></div>
<div class="container">
<q-slide-transition>
<div
v-show="isFixed || tools.scrollTop() < 300"
:class="
'column text-center q-mx-auto q-py-sm q-mb-sm ' +
(isFixed ? 'fixed-group ' : '')
"
style="width: 350px; max-width: 100%"
>
<div>
<q-input
ref="componentToFixRef"
filled
stack-label
rounded
:dense="tools.isMobile() ? true : false"
:label="t('ecomm.code_o_text_search')"
v-model="search"
debounce="300"
class="q-ml-md"
>
<template v-slot:append>
<q-icon name="search" />
</template>
</q-input>
</div>
</div>
</q-slide-transition>
<div v-if="cosa === shared_consts.PROD.GAS">
<div v-if="!idGasSel">
<div class="text-center text-h6 text-red">Ordini Attivi:</div>
</div>
<div class="row q-gutter-xs justify-center q-mx-auto">
<div
v-for="(recgas, index) in productStore.getGasordinesActives()"
:key="index"
>
<q-btn
push
dense
:size="tools.isMobile() ? '0.9rem' : '1.05rem'"
:color="idGasSel === recgas._id ? 'primary' : undefined"
:text-color="idGasSel === recgas._id ? 'white' : 'black'"
:label="recgas.name"
@click="idGasSel = recgas._id"
>
</q-btn>
</div>
</div>
<div class="text-center q-py-sm prod_trov">
<span
v-show="productStore.getNumProdTot() !== arrProducts.length"
>{{
t('ecomm.prodotti_trovati', {
qta: arrProducts.length,
qtatot: productStore.getNumProdTot(),
})
}}</span
>
</div>
<div class="row justify-around" v-if="tools.isManager()">
<q-toggle
v-model="show_hide"
push
label="Mostra Nascosti"
rounded
glossy
toggle-color="primary"
></q-toggle>
</div>
<div class="row justify-around">
<q-infinite-scroll
v-if="arrLoaded && arrLoaded.length > 0"
ref="myinfscroll"
:initial-index="0"
@load="onLoadScroll"
:offset="2000"
debounce="200"
class="q-pa-xs row items-start"
>
<div
class="q-pa-xs"
v-for="(product, index) in arrLoaded"
:key="index"
>
<CCatalogoCard
v-if="
product.active ||
(show_hide &&
productInfo.productType ===
shared_consts.PRODUCTTYPE.PRODUCT)
"
:id="product._id"
:complete="false"
:cosa="cosa"
/>
<CProductCard
v-else-if="product.active || show_hide"
:id="product._id"
:complete="false"
:cosa="cosa"
/>
</div>
<template v-slot:loading>
<div class="text-center">
<q-spinner-dots color="primary" size="40px" />
</div>
</template>
</q-infinite-scroll>
</div>
</div>
<div v-else>
<div class="category-title">Categorie</div>
<div class="row q-gutter-xs justify-center q-mx-auto bg-blue-1">
<div v-for="(reccat, index) in getCatProds()" :key="index">
<span
:class="{
category: true,
category_sel: cat === reccat.value,
}"
@click="cat = reccat.value"
>{{ reccat.label }}
</span>
|
<!--<q-btn
<q-tabs v-model="tabvisu" dense class="bg-indigo text-white">
<q-tab name="categorie" icon="fas fa-folder-open" label="Categorie" />
<q-tab name="autori" icon="fas fa-user" label="Autori" />
<q-tab name="ricerca" icon="fas fa-search" label="Cerca" />
</q-tabs>
<q-tab-panels v-model="tabvisu" animated class="">
<q-tab-panel name="categorie">
<div class="row q-gutter-xs justify-center q-mx-auto bg-blue-1">
<div v-for="(reccat, index) in getCatProds()" :key="index">
<span
:class="{
category: true,
category_sel: cat === reccat.value,
}"
@click="cat = reccat.value"
>{{ reccat.label }}
</span>
|
<!--<q-btn
:push="cat === reccat.value"
dense
:size="tools.isMobile() ? '0.70rem' : '1rem'"
@@ -143,97 +37,37 @@
@click="cat = reccat.value"
>
</q-btn>-->
</div>
</div>
</div>
<div class="text-center q-py-sm prod_trov">
<span
v-show="productStore.getNumProdTot() !== arrProducts.length"
>{{
t('ecomm.prodotti_trovati', {
qta: arrProducts.length,
qtatot: productStore.getNumProdTot(),
})
}}</span
>
</div>
<div class="row justify-around" v-if="tools.isManager()">
<q-toggle
v-model="show_hide"
push
label="Mostra Nascosti"
rounded
glossy
toggle-color="primary"
></q-toggle>
</div>
<div class="col" v-for="(item, index) in searchList" :key="index">
<CMySelect
:col="fieldsTable.getColByColumns(mycolumns, item.key)"
v-if="
item.type === costanti.FieldType.select ||
item.type === costanti.FieldType.select_by_server
"
:label="
item.value && item.value._id > 0 ? undefined : labelcombo(item)
"
v-model:value="item.value"
@update:value="searchval(item.value, item.table, tablesel)"
:addall="item.addall"
:addnone="item.addnone"
:addlast="true"
:tablesel="
item.type === costanti.FieldType.select_by_server
? item.tablesel
: ''
"
:pickup="item.type === costanti.FieldType.select_by_server"
:label-color="$q.dark.isActive ? 'white' : 'black'"
myclass="comboselector"
color="primary"
:dense="true"
:icon_alternative="item.icon"
:optval="fieldsTable.getKeyByTable(item.table)"
:optlab="fieldsTable.getLabelByTable(item.table)"
:options="valoriopt(item, false)"
:filter="item.filter"
:filter_extra="item.filter_extra"
style="font-size: 0.8rem !important"
:useinput="
item.useinput &&
item.type !== costanti.FieldType.select_by_server
"
>
</CMySelect>
</div>
<q-toolbar>
<q-select
class="full-width"
v-model="filter.author"
:options="optauthors"
label="Autore"
placeholder="Tutti"
emit-value
map-options
use-input
hide-selected
fill-input
stack-label
filled
@filter="filterFn"
>
<template v-slot:append>
<q-icon
v-if="filter.author !== ''"
class="cursor-pointer"
name="clear"
@click.stop.prevent="filter.author = ''"
/> </template
></q-select>
<!--<q-select
</q-tab-panel>
<q-tab-panel name="autori">
<q-toolbar>
<q-select
class="full-width"
v-model="filter.author"
:options="optauthors"
label="Autore"
placeholder="Tutti"
emit-value
map-options
use-input
hide-selected
fill-input
stack-label
use-chips
filled
rounded
@filter="filterFn"
>
<template v-slot:append>
<q-icon
v-if="filter.author !== ''"
class="cursor-pointer"
name="clear"
@click.stop.prevent="filter.author = ''"
/> </template
></q-select>
<!--<q-select
v-model="filter.publisher"
:options="publishers"
label="Editore"
@@ -254,57 +88,121 @@
placeholder="Tutte"
dense
/>-->
</q-toolbar>
<div class="row justify-around">
<q-infinite-scroll
v-if="arrLoaded && arrLoaded.length > 0"
ref="myinfscroll"
:initial-index="0"
@load="onLoadScroll"
:offset="2000"
debounce="200"
class="q-pa-xs row items-start"
style="place-content: center"
>
<div
class="q-pa-xs"
v-for="(product, index) in arrLoaded"
:key="index"
</q-toolbar>
</q-tab-panel>
<q-tab-panel name="ricerca">
<div class="col" v-for="(item, index) in searchList" :key="index">
<CMySelect
:col="fieldsTable.getColByColumns(mycolumns, item.key)"
v-if="
item.type === costanti.FieldType.select ||
item.type === costanti.FieldType.select_by_server
"
:label="
item.value && item.value._id > 0
? undefined
: labelcombo(item)
"
v-model:value="item.value"
:addall="item.addall"
:addnone="item.addnone"
:addlast="true"
:tablesel="
item.type === costanti.FieldType.select_by_server
? item.tablesel
: ''
"
:pickup="item.type === costanti.FieldType.select_by_server"
:label-color="$q.dark.isActive ? 'white' : 'black'"
myclass="comboselector"
color="primary"
:dense="true"
:icon_alternative="item.icon"
:optval="fieldsTable.getKeyByTable(item.table)"
:optlab="fieldsTable.getLabelByTable(item.table)"
:options="valoriopt(item, false)"
:filter="item.filter"
:filter_extra="item.filter_extra"
style="font-size: 0.8rem !important"
:useinput="
item.useinput &&
item.type !== costanti.FieldType.select_by_server
"
>
<CCatalogoCard
v-if="
product.active ||
(show_hide &&
productInfo.productType ===
shared_consts.PRODUCTTYPE.PRODUCT)
"
:id="product._id"
:complete="false"
:cosa="cosa"
:options="{
show_short_descr: false,
show_price: false,
show_cat: false,
quante_col: 'c2',
in_3d: false,
}"
@selauthor="selauthor"
/>
<CProductCard
v-else-if="product.active || show_hide"
:id="product._id"
:complete="false"
:cosa="cosa"
/>
</CMySelect>
</div>
</q-tab-panel>
</q-tab-panels>
<div class="text-center q-py-sm prod_trov">
<span v-show="productStore.getNumProdTot() !== arrProducts.length">{{
t('ecomm.prodotti_trovati', {
qta: arrProducts.length,
qtatot: productStore.getNumProdTot(),
})
}}</span>
</div>
<div class="row justify-around" v-if="tools.isManager() && false">
<q-toggle
v-model="show_hide"
push
label="Mostra Nascosti"
rounded
glossy
toggle-color="primary"
></q-toggle>
</div>
<div class="row justify-around">
<q-infinite-scroll
v-if="arrLoaded && arrLoaded.length > 0"
ref="myinfscroll"
:initial-index="0"
@load="onLoadScroll"
:offset="2000"
debounce="200"
class="q-pa-xs row items-start"
style="place-content: center"
>
<div
class="q-pa-xs"
v-for="(product, index) in arrLoaded"
:key="index"
>
<CContainerCatalogoCard
v-if="
product.active ||
(show_hide &&
productInfo.productTypes.includes(
shared_consts.PRODUCTTYPE.PRODUCT
))
"
:id="product._id"
:complete="false"
:cosa="cosa"
:optcatalogo="optcatalogo"
:options="{
show_short_descr: false,
show_price: false,
show_cat: false,
quante_col: 'c2',
in_3d: false,
}"
@selauthor="selauthor"
/>
<CProductCard
v-else-if="product.active || show_hide"
:id="product._id"
:complete="false"
:cosa="cosa"
/>
</div>
<template v-slot:loading>
<div class="text-center">
<q-spinner-dots color="primary" size="40px" />
</div>
<template v-slot:loading>
<div class="text-center">
<q-spinner-dots color="primary" size="40px" />
</div>
</template>
</q-infinite-scroll>
</div>
</template>
</q-infinite-scroll>
</div>
</div>
</div>

View File

@@ -8,6 +8,8 @@ import { CMyPage } from '@/components/CMyPage'
import { CCheckIfIsLogged } from '@/components/CCheckIfIsLogged'
import { toolsext } from '@store/Modules/toolsext'
import { tools } from '@store/Modules/tools'
import { shared_consts } from '@src/common/shared_vuejs'
export default defineComponent({
name: 'mypagegood',
@@ -19,6 +21,7 @@ export default defineComponent({
const $q = useQuasar()
const { t } = useI18n()
const idGood = computed(() => $route.params.idGood ? $route.params.idGood.toString() : 0)
return {
@@ -26,6 +29,7 @@ export default defineComponent({
idGood,
toolsext,
tools,
shared_consts,
}
}
})