2026-10-18 21:04:26 +03:30
|
|
|
|
<script setup lang="ts">
|
2026-11-05 14:46:35 +03:30
|
|
|
|
import { computed, onMounted, ref } from 'vue';
|
|
|
|
|
|
import { RouterLink, useRouter } from 'vue-router';
|
2026-10-18 21:04:26 +03:30
|
|
|
|
import type { DiscDistributionRow } from '@mento/shared';
|
2026-11-05 14:46:35 +03:30
|
|
|
|
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,
|
|
|
|
|
|
Space as ASpace,
|
|
|
|
|
|
Typography,
|
|
|
|
|
|
} from 'ant-design-vue';
|
|
|
|
|
|
import { ArrowRightOutlined, DownloadOutlined } from '@/icons/ant-bridge';
|
2026-10-18 21:04:26 +03:30
|
|
|
|
import { api } from '@/lib/api';
|
|
|
|
|
|
import { toFaDigits } from '@/lib/jalali';
|
2026-11-05 14:46:35 +03:30
|
|
|
|
import { CrmSkeleton, CrmSkeletonCard } from '@/components/skeleton';
|
2026-10-18 21:04:26 +03:30
|
|
|
|
|
2026-11-05 14:46:35 +03:30
|
|
|
|
const { Title: ATypographyTitle, Text: ATypographyText } = Typography;
|
|
|
|
|
|
|
|
|
|
|
|
const router = useRouter();
|
2026-10-18 21:04:26 +03:30
|
|
|
|
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;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-11-05 14:46:35 +03:30
|
|
|
|
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;
|
|
|
|
|
|
}
|
2026-10-18 21:04:26 +03:30
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<template>
|
2026-11-05 14:46:35 +03:30
|
|
|
|
<a-row :gutter="[16, 16]">
|
|
|
|
|
|
<a-col :span="24">
|
|
|
|
|
|
<a-flex justify="space-between" align="center" wrap="wrap" :gap="12">
|
|
|
|
|
|
<div>
|
|
|
|
|
|
<a-typography-title :level="3" :style="{ margin: 0 }">
|
|
|
|
|
|
توزیع تیپهای DISC
|
|
|
|
|
|
</a-typography-title>
|
|
|
|
|
|
<a-typography-text type="secondary">
|
|
|
|
|
|
فقط ارزیابیهای تأییدشده و قابل اتکا، در محدودهٔ دسترسی شما
|
|
|
|
|
|
</a-typography-text>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<a-space wrap>
|
|
|
|
|
|
<a-button @click="router.push({ name: 'contacts' })">
|
|
|
|
|
|
<template #icon><ArrowRightOutlined /></template>
|
|
|
|
|
|
بازگشت
|
|
|
|
|
|
</a-button>
|
|
|
|
|
|
<a-button :disabled="exporting" :loading="exporting" @click="exportExcel">
|
|
|
|
|
|
<template #icon><DownloadOutlined /></template>
|
|
|
|
|
|
خروجی اکسل
|
|
|
|
|
|
</a-button>
|
|
|
|
|
|
</a-space>
|
|
|
|
|
|
</a-flex>
|
|
|
|
|
|
</a-col>
|
2026-10-18 21:04:26 +03:30
|
|
|
|
|
2026-11-05 14:46:35 +03:30
|
|
|
|
<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>
|