93 lines
2.4 KiB
Vue
93 lines
2.4 KiB
Vue
<template>
|
|
<!--
|
|
Ported from legacy henza_admin/src/views/statics/index.vue — the customer
|
|
activity log ("آمار"). Pick a customer, see their recent actions.
|
|
-->
|
|
<a-spin :spinning="loading">
|
|
<a-card title="آمار">
|
|
<a-form layout="vertical">
|
|
<div class="grid-2">
|
|
<a-form-item label="مشتری">
|
|
<a-select
|
|
v-model:value="customer"
|
|
show-search
|
|
allow-clear
|
|
placeholder="انتخاب کنید"
|
|
:filter-option="filterOption"
|
|
@change="load"
|
|
>
|
|
<a-select-option v-for="c in customers" :key="c.id" :value="c.id">
|
|
{{ c.name }} - {{ c.mobile }}
|
|
</a-select-option>
|
|
</a-select>
|
|
</a-form-item>
|
|
</div>
|
|
</a-form>
|
|
|
|
<a-table
|
|
:data-source="logs"
|
|
:columns="columns"
|
|
:pagination="{ pageSize: 20 }"
|
|
size="small"
|
|
row-key="id"
|
|
>
|
|
<template #bodyCell="{ column, record }">
|
|
<template v-if="column.dataIndex === 'caj'">
|
|
{{ jdateTime(record.caj) }}
|
|
</template>
|
|
</template>
|
|
</a-table>
|
|
</a-card>
|
|
</a-spin>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { onMounted, ref } from 'vue';
|
|
import { jdateTime } from '../../utils/filters';
|
|
import api from '../../api/client';
|
|
|
|
const loading = ref(false);
|
|
const customers = ref<{ id: string; name: string; mobile: string }[]>([]);
|
|
const customer = ref<string | undefined>(undefined);
|
|
const logs = ref<Record<string, any>[]>([]);
|
|
|
|
const columns = [
|
|
{ title: 'عملیات', dataIndex: 'action' },
|
|
{ title: 'جزئیات', dataIndex: 'detail' },
|
|
{ title: 'تاریخ', dataIndex: 'caj' },
|
|
];
|
|
|
|
function filterOption(input: string, option: any) {
|
|
return String(option?.children?.[0]?.children ?? '').includes(input);
|
|
}
|
|
|
|
async function load() {
|
|
if (!customer.value) {
|
|
logs.value = [];
|
|
return;
|
|
}
|
|
try {
|
|
loading.value = true;
|
|
const { data } = await api.get(`log/ago/${customer.value}`);
|
|
logs.value = data;
|
|
} catch (e) {
|
|
console.log(e);
|
|
} finally {
|
|
loading.value = false;
|
|
}
|
|
}
|
|
|
|
onMounted(async () => {
|
|
try {
|
|
const { data } = await api.get('log/list/customer');
|
|
customers.value = data;
|
|
} catch (e) {
|
|
console.log(e);
|
|
}
|
|
});
|
|
</script>
|
|
|
|
<style scoped>
|
|
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; }
|
|
</style>
|