Search in products with country
Some checks are pending
deploy / deploy (push) Waiting to run

This commit is contained in:
2024-01-03 21:28:11 +01:00
parent fbcc3226fe
commit cf8844471b

View File

@@ -87,7 +87,9 @@ const gchartEvents = ref({
} }
},); },);
const sleep = (ms) => {
return new Promise(resolve => setTimeout(resolve, ms))
}
const fetch = async () => { const fetch = async () => {
try { try {
@@ -137,7 +139,7 @@ const fetch_ccodes = async () => {
try { try {
const response = await axios.get(route('ccountry.codes')) const response = await axios.get(route('ccountry.codes'))
ccodes.value = response.data; ccodes.value = response.data;
ccodes.value = Object.entries(ccodes.value).map(([k,v]) => { if (v !== null) return { "country": k, "code": v } } ).filter( n => n); ccodes.value = Object.entries(ccodes.value).map(([k, v]) => { if (v !== null) return { "country": k, "code": v } }).filter(n => n);
console.log("ccodes=", ccodes.value); console.log("ccodes=", ccodes.value);
} catch (e) { } catch (e) {
const response = await Swal.fire({ const response = await Swal.fire({
@@ -155,8 +157,10 @@ const fetch_ccodes = async () => {
const async_search = async (item) => { const async_search = async (item) => {
try { try {
if (item.length >= 2) { if (item.length >= 2) {
console.log('SEARCH',item,form.country.code,route('products.search', [item, form.country.code]));
console.log('SEARCH', item, form.country.code, route('products.search', [item, form.country.code]));
const response = await axios.get(route('products.search', [item, form.country.code])); const response = await axios.get(route('products.search', [item, form.country.code]));
options_items.value = response.data.map((i) => { return { "item": i.name, "desc": i.typeName, "img": i.mainImageUrl, "code": i.code } }); options_items.value = response.data.map((i) => { return { "item": i.name, "desc": i.typeName, "img": i.mainImageUrl, "code": i.code } });
console.log("VALUES=", options_items.value); console.log("VALUES=", options_items.value);
} }
@@ -233,7 +237,8 @@ const submit = () => {
<span class="font-extrabold font-mono">Krajina produktu na vyhladanie</span> <span class="font-extrabold font-mono">Krajina produktu na vyhladanie</span>
</div> </div>
<div> <div>
<multiselect :close-on-select="false" :multiple="false" v-model="form.country" :options="ccodes" label="country" track-by="code"> <multiselect :close-on-select="false" :multiple="false" v-model="form.country" :options="ccodes"
label="country" track-by="code">
</multiselect> </multiselect>
</div> </div>
<div> <div>
@@ -241,7 +246,8 @@ const submit = () => {
</div> </div>
<div> <div>
<multiselect v-model="form.codes" label="item" track-by="item" :custom-label="customLabel" <multiselect v-model="form.codes" label="item" track-by="item" :custom-label="customLabel"
placeholder="Find item" :searchable="true" :options="options_items" @search-change="async_search" /> :internal-search="false" placeholder="Find item" :searchable="true" :options="options_items"
@search-change="async_search" />
</div> </div>
<div> <div>
<span class="font-extrabold font-mono">Prepocet do meny</span> <span class="font-extrabold font-mono">Prepocet do meny</span>