Files
tehran_tala/apps/admin-panel/src/views/DashboardAnalytics.vue
T

65 lines
1.9 KiB
Vue

<template>
<!--
Ported from legacy henza_admin/src/views/DashboardAnalytics.vue — the retail
dashboard ("آمار تک فروشی").
Legacy's file is 342 lines but reads only ONE field from the server:
`model.lastOrder`. Everything else on the page is Vuexy demo data defined in
the component itself (analyticsData.js series, radial bars, order-type
colours) and renders nothing real — so only the live table is ported.
-->
<a-spin :spinning="loading">
<a-card title="سفارشات هفته جاری">
<a-table
size="small"
:data-source="model.lastOrder"
:columns="columns"
:pagination="{ pageSize: 15 }"
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-spin>
</template>
<script setup lang="ts">
import { onMounted, reactive, ref } from 'vue';
import { jdate } from '../utils/filters';
import api from '../api/client';
const loading = ref(false);
const model = reactive<Record<string, any>>({ lastOrder: [] });
const columns = [
{ title: 'شماره سفارش', dataIndex: 'name' },
{ title: 'مشتری', dataIndex: 'customer' },
{ title: 'وزن', dataIndex: 'w' },
{ title: 'وضعیت', dataIndex: 'sts_str' },
{ title: 'تاریخ', dataIndex: 'caj' },
];
function tagColor(c: string) {
return { success: 'green', warning: 'orange', danger: 'red', primary: 'blue' }[c] ?? '';
}
onMounted(async () => {
try {
loading.value = true;
const { data } = await api.get('get-analytics-tak');
Object.assign(model, data);
} catch (e) {
console.error(e);
} finally {
loading.value = false;
}
});
</script>