46 lines
1.8 KiB
Vue
46 lines
1.8 KiB
Vue
<script setup>
|
|
import { ProductService } from '@/service/ProductService';
|
|
import { onMounted, ref } from 'vue';
|
|
import { BelongingService } from '@/service/BelongingService';
|
|
import { useRouter } from 'vue-router';
|
|
|
|
const products = ref(null);
|
|
|
|
function formatCurrency(value) {
|
|
return value.toLocaleString('en-US', { style: 'currency', currency: 'USD' });
|
|
}
|
|
|
|
onMounted(() => {
|
|
BelongingService.getAllBelongings().then((data) => (products.value = data));
|
|
});
|
|
|
|
const router = useRouter();
|
|
function editBelonging(belongingId) {
|
|
router.push('/belonging/edit-belonging/' + belongingId);
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<div class="card">
|
|
<div class="font-semibold text-xl mb-4">آخرین دارایی های افزوده شده</div>
|
|
<DataTable :value="products" :rows="5" :paginator="true" responsiveLayout="scroll">
|
|
<Column style="min-width: 15%" header="Image">
|
|
<template #body="slotProps">
|
|
<img :src="`${slotProps.data.mainImageUrl}`" :alt="slotProps.data.name" width="50" class="shadow" />
|
|
</template>
|
|
</Column>
|
|
<Column field="name" header="نام" :sortable="true" style="min-width: 35%"></Column>
|
|
<Column field="price" header="دسته بندی" :sortable="true" style="min-width: 30%">
|
|
<template #body="slotProps">
|
|
{{ slotProps.data.category?.nativeName }}
|
|
</template>
|
|
</Column>
|
|
<Column style="min-width: 15%" header="نمایش">
|
|
<template #body="slotProps">
|
|
<Button icon="pi pi-search" type="button" class="p-button-text" @click="editBelonging(slotProps.data._id)"></Button>
|
|
</template>
|
|
</Column>
|
|
</DataTable>
|
|
</div>
|
|
</template>
|