Add priceUnit and salesPrice columns
This commit is contained in:
@@ -10,7 +10,8 @@ import GuestLayout from '../Layouts/GuestLayout.vue';
|
||||
|
||||
import { useForm } from '@inertiajs/inertia-vue3'
|
||||
import axios from 'axios';
|
||||
import IkeaLogo from './Ikea/IkeaLogo.vue';
|
||||
import filterimg from '@/assets/eglass-filter.png';
|
||||
|
||||
|
||||
const props = defineProps({
|
||||
products: {
|
||||
@@ -36,6 +37,7 @@ const sdropdown = ref([
|
||||
|
||||
const products = ref([]);
|
||||
const countryHash = ref([]);
|
||||
const showItemFilter = ref(false);
|
||||
|
||||
let tproducts = computed(() => {
|
||||
return products.value.map((prod) => {
|
||||
@@ -45,6 +47,20 @@ let tproducts = computed(() => {
|
||||
})
|
||||
})
|
||||
|
||||
let uniqProducts = computed(() => {
|
||||
var output = [];
|
||||
var keys = [];
|
||||
options_items.value.forEach((element) => {
|
||||
var key = element.item;
|
||||
if (keys.indexOf(key) === -1) {
|
||||
keys.push(key);
|
||||
output.push(element.item);
|
||||
}
|
||||
});
|
||||
console.log('OUT',output);
|
||||
return output;
|
||||
});
|
||||
|
||||
const type = 'GeoChart';
|
||||
const form = useForm({
|
||||
countries: '',
|
||||
@@ -76,6 +92,8 @@ const hresults = ref([
|
||||
{ text: "Code", value: "code", sortable: true },
|
||||
{ text: "Name of product", value: "item", sortable: true },
|
||||
{ text: "Description", value: "desc", sortable: true },
|
||||
{ text: "Units", value: "units", sortable: true },
|
||||
{ text: "Price", value: "price", sortable: true },
|
||||
{ text: "Image", value: "img", sortable: false }
|
||||
])
|
||||
const rates = ref([]);
|
||||
@@ -183,7 +201,7 @@ const async_search = async () => {
|
||||
console.log('SEARCH', route('products.search', [form.field.value, form.text, country]));
|
||||
const response = await axios.get(route('products.search', [form.field.value, form.text, country]));
|
||||
|
||||
options_items.value = response.data.map((i) => { return { "item": i.name, "desc": i.typeName, "img": i.mainImageUrl, "code": i.code, "url": i.url } });
|
||||
options_items.value = response.data.map((i) => { return { "item": i.name, "desc": i.typeName, "img": i.mainImageUrl, "code": i.code, "url": i.url, "price": i.salesPrice, "units": i.priceUnit } });
|
||||
console.log("VALUES=", options_items.value);
|
||||
} catch (e) {
|
||||
const response = await Swal.fire({
|
||||
@@ -257,7 +275,7 @@ const onSelectCurrency = () => {
|
||||
else currencyCoef.value = 1.0;
|
||||
|
||||
products.value = products.value.map((product) => { product.salesPrice = (product.salesPrice * currencyCoef.value).toFixed(2); return product });
|
||||
|
||||
|
||||
console.log('PROD-NEW', products.value);
|
||||
}
|
||||
}
|
||||
@@ -316,12 +334,21 @@ const submit = () => {
|
||||
<input class="rounded-md " v-model="form.text" @input="async_search" />
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</form>
|
||||
<div class="mt-5">
|
||||
<EasyTable :rows-per-page=20 :headers="hresults" :items="options_items" @click-row="showRow" alternating>
|
||||
<EasyTable class="none" :rows-per-page=20 :headers="hresults" :items="options_items" @click-row="showRow" alternating>
|
||||
<template #item-img="{ code, img }">
|
||||
<img class="h-12" :src="img" alt="" />
|
||||
<img class="h-12" :src="img" :alt="code" />
|
||||
</template>
|
||||
<template #header-item="header">
|
||||
<div class="filter-column overflow-visible">
|
||||
<img :src="filterimg" class="filter-icon" @click="showItemFilter = !showItemFilter" />
|
||||
{{ header.text }}
|
||||
<div class="filter-menu filter-sport-menu" v-if="showItemFilter">
|
||||
<multiselect :options="uniqProducts"></multiselect>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</EasyTable>
|
||||
</div>
|
||||
@@ -359,5 +386,31 @@ const submit = () => {
|
||||
</template>
|
||||
<style>
|
||||
@import 'vue3-easy-data-table/dist/style.css';
|
||||
</style>
|
||||
|
||||
|
||||
.filter-column {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-items: center;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.filter-icon {
|
||||
cursor: pointer;
|
||||
display: inline-block;
|
||||
width: 15px !important;
|
||||
height: 15px !important;
|
||||
margin-right: 4px;
|
||||
}
|
||||
|
||||
.filter-menu {
|
||||
padding: 5px 5px;
|
||||
z-index: 1;
|
||||
position: absolute;
|
||||
top: 40px;
|
||||
width: 250px;
|
||||
background-color: #fff;
|
||||
|
||||
}</style>
|
||||
<style src="vue-multiselect/dist/vue-multiselect.css"></style>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user