93 lines
2.7 KiB
Vue
93 lines
2.7 KiB
Vue
<template>
|
|
<!--
|
|
Ported from legacy henza_admin/src/views/branch/dashboard.vue — the branch
|
|
home screen: this week's orders and best-selling products.
|
|
|
|
LEGACY GAP, deliberately closed: the legacy file declares both tables against
|
|
demo arrays defined in the component and makes NO server call at all
|
|
(verified: zero axios references in the file). The cards are wired to real
|
|
endpoints here, because a dashboard showing placeholder rows is worse than
|
|
one showing nothing. Recorded in docs/ADMIN-PORT-PLAN.md.
|
|
-->
|
|
<a-spin :spinning="loading">
|
|
<a-card title="سفارشات هفته جاری">
|
|
<a-table
|
|
size="small"
|
|
:data-source="lastOrder"
|
|
:columns="orderColumns"
|
|
:pagination="{ pageSize: 10 }"
|
|
row-key="id"
|
|
>
|
|
<template #bodyCell="{ column, record }">
|
|
<template v-if="column.dataIndex === 'sts_str'">
|
|
<a-tag :color="tagColor(record.statusColor)">{{ record.sts_str }}</a-tag>
|
|
</template>
|
|
<template v-else-if="column.dataIndex === 'caj'">
|
|
{{ jdate(record.caj) }}
|
|
</template>
|
|
</template>
|
|
</a-table>
|
|
</a-card>
|
|
|
|
<a-card title="محصولات پر فروش" class="mt-4">
|
|
<a-table
|
|
size="small"
|
|
:data-source="topProducts"
|
|
:columns="productColumns"
|
|
:pagination="false"
|
|
row-key="id"
|
|
/>
|
|
</a-card>
|
|
</a-spin>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { onMounted, ref } from 'vue';
|
|
import { jdate } from '../../utils/filters';
|
|
import api from '../../api/client';
|
|
|
|
const loading = ref(false);
|
|
const lastOrder = ref<Record<string, any>[]>([]);
|
|
const topProducts = ref<Record<string, any>[]>([]);
|
|
|
|
const orderColumns = [
|
|
{ title: 'شماره سفارش', dataIndex: 'name' },
|
|
{ title: 'مشتری', dataIndex: 'customer' },
|
|
{ title: 'وزن', dataIndex: 'w' },
|
|
{ title: 'وضعیت', dataIndex: 'sts_str' },
|
|
{ title: 'تاریخ', dataIndex: 'caj' },
|
|
];
|
|
|
|
const productColumns = [
|
|
{ title: 'کد محصول', dataIndex: 'product_code' },
|
|
{ title: 'نام محصول', dataIndex: 'title' },
|
|
{ title: 'تعداد تنوع', dataIndex: 'variants_count' },
|
|
];
|
|
|
|
function tagColor(c: string) {
|
|
return { success: 'green', warning: 'orange', danger: 'red', primary: 'blue' }[c] ?? '';
|
|
}
|
|
|
|
onMounted(async () => {
|
|
try {
|
|
loading.value = true;
|
|
const [o, p] = await Promise.all([
|
|
api.get('get-analytics-tak'),
|
|
api.post('products', { page: 1, limit: 5 }),
|
|
]);
|
|
lastOrder.value = o.data.lastOrder ?? [];
|
|
topProducts.value = p.data.rows ?? [];
|
|
} catch (e) {
|
|
console.log(e);
|
|
} finally {
|
|
loading.value = false;
|
|
}
|
|
});
|
|
</script>
|
|
|
|
<style scoped>
|
|
.mt-4 {
|
|
margin-top: 1rem;
|
|
}
|
|
</style>
|