Persist workspace tabs in the app shell with Ant Design styling aligned to the desktop top bar, and fix tab bar layout flicker on select. Add shared PageHeader components, query helpers, and missing header state across CRM views; improve mobile shell layout and Vite HMR stability on Windows. Co-authored-by: Cursor <cursoragent@cursor.com>
125 lines
3.8 KiB
Vue
125 lines
3.8 KiB
Vue
<script setup lang="ts">
|
||
import { computed, onMounted, ref } from 'vue';
|
||
import { RouterLink } from 'vue-router';
|
||
import type { DiscDistributionRow } from '@mento/shared';
|
||
import {
|
||
Alert as AAlert,
|
||
Button as AButton,
|
||
Card as ACard,
|
||
Col as ACol,
|
||
Empty as AEmpty,
|
||
Flex as AFlex,
|
||
Progress as AProgress,
|
||
Row as ARow,
|
||
Typography,
|
||
} from 'ant-design-vue';
|
||
import { DownloadOutlined } from '@/icons/ant-bridge';
|
||
import { api } from '@/lib/api';
|
||
import { toFaDigits } from '@/lib/jalali';
|
||
import { CrmSkeleton, CrmSkeletonCard } from '@/components/skeleton';
|
||
|
||
import { PageHeader } from '@/components/page';
|
||
import { BarChartOutlined } from '@/icons/ant-bridge';
|
||
const { Text: ATypographyText } = Typography;
|
||
|
||
const rows = ref<DiscDistributionRow[]>([]);
|
||
const error = ref('');
|
||
const loading = ref(true);
|
||
const exporting = ref(false);
|
||
|
||
onMounted(async () => {
|
||
try {
|
||
const { data } = await api.get<DiscDistributionRow[]>('/behavior/disc/distribution');
|
||
rows.value = data;
|
||
} catch {
|
||
error.value = 'گزارش توزیع تیپها بارگذاری نشد.';
|
||
} finally {
|
||
loading.value = false;
|
||
}
|
||
});
|
||
|
||
async function exportExcel() {
|
||
exporting.value = true;
|
||
error.value = '';
|
||
try {
|
||
const { data } = await api.get<Blob>('/behavior/disc/export', { responseType: 'blob' });
|
||
const url = URL.createObjectURL(data);
|
||
const link = document.createElement('a');
|
||
link.href = url;
|
||
link.download = 'disc.xlsx';
|
||
link.click();
|
||
URL.revokeObjectURL(url);
|
||
} catch {
|
||
error.value = 'خروجی اکسل ناموفق بود.';
|
||
} finally {
|
||
exporting.value = false;
|
||
}
|
||
}
|
||
|
||
const totalCount = computed(() => rows.value.reduce((sum, row) => sum + row.count, 0));
|
||
|
||
function percentOf(count: number) {
|
||
return totalCount.value ? Math.round((count / totalCount.value) * 100) : 0;
|
||
}
|
||
</script>
|
||
|
||
<template>
|
||
<a-row :gutter="[16, 16]">
|
||
<a-col :span="24">
|
||
<PageHeader
|
||
title="توزیع تیپهای DISC"
|
||
subtitle="فقط ارزیابیهای تأییدشده و قابل اتکا، در محدودهٔ دسترسی شما"
|
||
:icon="BarChartOutlined"
|
||
:back-to="{ name: 'contacts' }"
|
||
>
|
||
<template #actions>
|
||
<a-button :disabled="exporting" :loading="exporting" @click="exportExcel">
|
||
<template #icon><DownloadOutlined /></template>
|
||
خروجی اکسل
|
||
</a-button>
|
||
</template>
|
||
</PageHeader>
|
||
</a-col>
|
||
|
||
<a-col :span="24">
|
||
<CrmSkeleton :loading="loading">
|
||
<CrmSkeletonCard :rows="6">
|
||
<a-alert v-if="error" type="error" show-icon :message="error" />
|
||
<a-empty
|
||
v-else-if="!rows.length"
|
||
description="هنوز تیپ قابل اتکایی ثبت نشده است."
|
||
/>
|
||
<a-card v-else :bordered="false">
|
||
<a-flex vertical :gap="16">
|
||
<a-row
|
||
v-for="row in rows"
|
||
:key="row.label"
|
||
:gutter="[12, 8]"
|
||
align="middle"
|
||
>
|
||
<a-col :xs="24" :sm="4">
|
||
<RouterLink :to="{ name: 'contacts', query: { disc: row.label } }">
|
||
{{ row.label }}
|
||
</RouterLink>
|
||
</a-col>
|
||
<a-col :xs="8" :sm="4">
|
||
<a-typography-text>{{ toFaDigits(row.count) }}</a-typography-text>
|
||
</a-col>
|
||
<a-col :xs="16" :sm="16">
|
||
<a-progress :percent="percentOf(row.count)" :show-info="false" />
|
||
</a-col>
|
||
</a-row>
|
||
</a-flex>
|
||
</a-card>
|
||
</CrmSkeletonCard>
|
||
</CrmSkeleton>
|
||
</a-col>
|
||
|
||
<a-col :span="24">
|
||
<a-typography-text type="secondary">
|
||
درصدها سهم مشتریان دارای ارزیابی معتبر هستند، نه دقت یک آزمون روانشناسی.
|
||
</a-typography-text>
|
||
</a-col>
|
||
</a-row>
|
||
</template>
|