PASSAGGIO A VITE !
AGG. 1.1.23
This commit is contained in:
@@ -1,17 +1,17 @@
|
||||
import { defineComponent, onMounted, ref, watch, computed, onBeforeUnmount } from 'vue'
|
||||
import { tools } from '@store/Modules/tools'
|
||||
import { tools } from '@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 { useI18n } from 'vue-i18n'
|
||||
import { toolsext } from '@store/Modules/toolsext'
|
||||
import { useQuasar } from 'quasar'
|
||||
import { costanti } from '@costanti'
|
||||
|
||||
import { shared_consts } from '@/common/shared_vuejs'
|
||||
import { shared_consts } from '@src/common/shared_vuejs'
|
||||
import { CAITools } from '@src/components/CAITools'
|
||||
import { IProduct } from '@src/model'
|
||||
import type { IProduct } from '@src/model'
|
||||
|
||||
export default defineComponent({
|
||||
name: 'ToolsAIMain',
|
||||
@@ -70,24 +70,24 @@ export default defineComponent({
|
||||
function calcArrProducts() {
|
||||
refreshpage.value = true
|
||||
let arrprod = productStore.getProducts(cosa.value)
|
||||
let catstr = cat.value;
|
||||
let lowerSearchText = search.value.toLowerCase().trim();
|
||||
const catstr = cat.value;
|
||||
const lowerSearchText = search.value.toLowerCase().trim();
|
||||
if ((!lowerSearchText || (lowerSearchText && lowerSearchText.length < 2)) && !catstr) {
|
||||
|
||||
} else {
|
||||
|
||||
arrprod = arrprod.filter((product: IProduct) => {
|
||||
let lowerName = product.productInfo.name!.toLowerCase();
|
||||
let hasCategoria = !catstr || (catstr && product.productInfo.idCatProds?.includes(catstr));
|
||||
const lowerName = product.productInfo.name!.toLowerCase();
|
||||
const hasCategoria = !catstr || (catstr && product.productInfo.idCatProds?.includes(catstr));
|
||||
|
||||
// Use a regular expression to match whole words
|
||||
let codeMatch = new RegExp(`\\b${lowerSearchText}\\b`, 'i');
|
||||
let nameMatch = new RegExp(`\\b${lowerSearchText}`, 'i');
|
||||
const codeMatch = new RegExp(`\\b${lowerSearchText}\\b`, 'i');
|
||||
const nameMatch = new RegExp(`\\b${lowerSearchText}`, 'i');
|
||||
|
||||
// Check if any word in lowerName starts with lowerSearchText
|
||||
let anyWordStartsWithSearch = lowerName.split(/\s+/).some(word => nameMatch.test(word));
|
||||
const anyWordStartsWithSearch = lowerName.split(/\s+/).some(word => nameMatch.test(word));
|
||||
|
||||
return (codeMatch.test(product.productInfo.code!) || anyWordStartsWithSearch) && hasCategoria;
|
||||
return (codeMatch.test(product.productInfo.code) || anyWordStartsWithSearch) && hasCategoria;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -100,10 +100,10 @@ export default defineComponent({
|
||||
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));
|
||||
@@ -128,8 +128,8 @@ export default defineComponent({
|
||||
});
|
||||
|
||||
function getCatProds() {
|
||||
let arrcat = productStore.getCatProds(cosa.value)
|
||||
let riscat: any = [{ label: 'Tutti', value: '', icon: undefined, color: undefined }]
|
||||
const arrcat = productStore.getCatProds(cosa.value)
|
||||
const riscat: any = [{ label: 'Tutti', value: '', icon: undefined, color: undefined }]
|
||||
for (const rec of arrcat) {
|
||||
riscat.push({ label: rec.name, value: rec._id, icon: rec.icon, color: rec.color })
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user