fix(web): restore ReportsView Ant tab bindings for typecheck
Wire missing theme, chart layout, and page-header helpers removed during the Ant migration so vue-tsc can typecheck the reports dashboard again. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, onMounted, ref, watch } from 'vue';
|
import { computed, onMounted, ref, watch, type Component } from 'vue';
|
||||||
import { useRoute, useRouter } from 'vue-router';
|
import { useRoute, useRouter } from 'vue-router';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { api } from '@/lib/api';
|
import { api } from '@/lib/api';
|
||||||
@@ -13,18 +13,7 @@ import {
|
|||||||
toFaDigits,
|
toFaDigits,
|
||||||
} from '@/lib/jalali';
|
} from '@/lib/jalali';
|
||||||
import JalaliDateInput from '@/components/JalaliDateInput.vue';
|
import JalaliDateInput from '@/components/JalaliDateInput.vue';
|
||||||
import UiIcon from '@/components/UiIcon.vue';
|
import { CHART_PALETTE, type UiChartOption } from '@/components/ui';
|
||||||
import {
|
|
||||||
UiButton,
|
|
||||||
UiCard,
|
|
||||||
UiField,
|
|
||||||
UiInput,
|
|
||||||
UiModal,
|
|
||||||
UiPageHeader,
|
|
||||||
UiChart,
|
|
||||||
CHART_PALETTE,
|
|
||||||
type UiChartOption,
|
|
||||||
} from '@/components/ui';
|
|
||||||
import type {
|
import type {
|
||||||
OrganizationDto,
|
OrganizationDto,
|
||||||
OrgUserDto,
|
OrgUserDto,
|
||||||
@@ -50,6 +39,70 @@ import {
|
|||||||
REPORTS_BUILDER_METRIC_LABELS,
|
REPORTS_BUILDER_METRIC_LABELS,
|
||||||
REPORTS_BUILDER_METRICS,
|
REPORTS_BUILDER_METRICS,
|
||||||
} from '@mento/shared';
|
} from '@mento/shared';
|
||||||
|
import { Empty as AEmpty, theme } from 'ant-design-vue';
|
||||||
|
import type { TableColumnsType } from 'ant-design-vue';
|
||||||
|
import { PageHeader } from '@/components/page';
|
||||||
|
import { CrmSkeleton, CrmSkeletonCard, CrmSkeletonKpi } from '@/components/skeleton';
|
||||||
|
import {
|
||||||
|
BarChartOutlined,
|
||||||
|
CalendarOutlined,
|
||||||
|
DeleteOutlined,
|
||||||
|
DollarOutlined,
|
||||||
|
FileExcelOutlined,
|
||||||
|
FileTextOutlined,
|
||||||
|
LinkOutlined,
|
||||||
|
RiseOutlined,
|
||||||
|
SaveOutlined,
|
||||||
|
TeamOutlined,
|
||||||
|
} from '@/icons/ant-bridge';
|
||||||
|
import { use } from 'echarts/core';
|
||||||
|
import { CanvasRenderer } from 'echarts/renderers';
|
||||||
|
import { BarChart, LineChart, PieChart } from 'echarts/charts';
|
||||||
|
import {
|
||||||
|
GridComponent,
|
||||||
|
LegendComponent,
|
||||||
|
TitleComponent,
|
||||||
|
TooltipComponent,
|
||||||
|
} from 'echarts/components';
|
||||||
|
import VChart from 'vue-echarts';
|
||||||
|
|
||||||
|
use([
|
||||||
|
CanvasRenderer,
|
||||||
|
LineChart,
|
||||||
|
PieChart,
|
||||||
|
BarChart,
|
||||||
|
GridComponent,
|
||||||
|
TooltipComponent,
|
||||||
|
LegendComponent,
|
||||||
|
TitleComponent,
|
||||||
|
]);
|
||||||
|
|
||||||
|
const { token } = theme.useToken();
|
||||||
|
const emptySimple = AEmpty.PRESENTED_IMAGE_SIMPLE;
|
||||||
|
|
||||||
|
const stretchColStyle = { display: 'flex' };
|
||||||
|
const stretchCardStyle = {
|
||||||
|
width: '100%',
|
||||||
|
height: '100%',
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'column' as const,
|
||||||
|
};
|
||||||
|
const stretchCardStyles = {
|
||||||
|
body: {
|
||||||
|
flex: 1,
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'column' as const,
|
||||||
|
minHeight: 0,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
const chartBoxStyle = {
|
||||||
|
height: '260px',
|
||||||
|
width: '100%',
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'center',
|
||||||
|
justifyContent: 'center',
|
||||||
|
};
|
||||||
|
const chartFillStyle = { height: '100%', width: '100%' };
|
||||||
|
|
||||||
type PeriodKey = 'today' | 'week' | 'month' | 'quarter' | 'year' | 'custom';
|
type PeriodKey = 'today' | 'week' | 'month' | 'quarter' | 'year' | 'custom';
|
||||||
type PageMode = 'dashboard' | 'builder' | 'leads';
|
type PageMode = 'dashboard' | 'builder' | 'leads';
|
||||||
@@ -71,6 +124,21 @@ const PERIOD_KEYS = new Set<PeriodKey>([
|
|||||||
'custom',
|
'custom',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
const modeOptions = [
|
||||||
|
{ value: 'dashboard' as PageMode, label: 'داشبورد' },
|
||||||
|
{ value: 'builder' as PageMode, label: 'گزارشساز' },
|
||||||
|
{ value: 'leads' as PageMode, label: 'لیدها' },
|
||||||
|
];
|
||||||
|
|
||||||
|
const periodOptions = PERIODS.map((p) => ({ value: p.key, label: p.label }));
|
||||||
|
|
||||||
|
function kpiIcon(key: string): Component {
|
||||||
|
if (key === 'new_customers') return TeamOutlined;
|
||||||
|
if (key === 'invoice_count') return FileTextOutlined;
|
||||||
|
if (key === 'sales_amount') return RiseOutlined;
|
||||||
|
return DollarOutlined;
|
||||||
|
}
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const auth = useAuthStore();
|
const auth = useAuthStore();
|
||||||
@@ -116,7 +184,6 @@ const teamsAvailable = ref(true);
|
|||||||
/** ماژول تهحساب فعال + حداقل یک اتصال تنظیمشده */
|
/** ماژول تهحساب فعال + حداقل یک اتصال تنظیمشده */
|
||||||
const hasTahesabSetup = ref(false);
|
const hasTahesabSetup = ref(false);
|
||||||
|
|
||||||
const builderMetricOptions = computed(() => REPORTS_BUILDER_METRICS);
|
|
||||||
const builderDimensionOptions = computed((): ReportsBuilderDimension[] => {
|
const builderDimensionOptions = computed((): ReportsBuilderDimension[] => {
|
||||||
if (isReportsLeadBuilderMetric(builderMetric.value)) {
|
if (isReportsLeadBuilderMetric(builderMetric.value)) {
|
||||||
const allow = new Set<ReportsBuilderDimension>([
|
const allow = new Set<ReportsBuilderDimension>([
|
||||||
@@ -132,12 +199,6 @@ const builderDimensionOptions = computed((): ReportsBuilderDimension[] => {
|
|||||||
return [...REPORTS_BUILDER_DIMENSIONS.filter((d) => d !== 'lead_stage')];
|
return [...REPORTS_BUILDER_DIMENSIONS.filter((d) => d !== 'lead_stage')];
|
||||||
});
|
});
|
||||||
|
|
||||||
const showTahesabSalesReport = computed(
|
|
||||||
() =>
|
|
||||||
Boolean(auth.user?.enabledModules?.includes('tahesab')) &&
|
|
||||||
hasTahesabSetup.value,
|
|
||||||
);
|
|
||||||
|
|
||||||
const currency = computed(
|
const currency = computed(
|
||||||
() =>
|
() =>
|
||||||
builderResult.value?.currency ||
|
builderResult.value?.currency ||
|
||||||
@@ -158,6 +219,21 @@ const canManageActiveView = computed(() => {
|
|||||||
return v.owner?.id === auth.user?.id;
|
return v.owner?.id === auth.user?.id;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const savedViewOptions = computed(() => [
|
||||||
|
{ value: '', label: 'پیشفرض' },
|
||||||
|
...savedViews.value.map((v) => ({
|
||||||
|
value: v.id,
|
||||||
|
label: `${v.name}${v.isShared ? ' (سازمانی)' : ''}`,
|
||||||
|
})),
|
||||||
|
]);
|
||||||
|
|
||||||
|
const activeViewSelect = computed({
|
||||||
|
get: () => activeViewId.value ?? '',
|
||||||
|
set: (id: string) => {
|
||||||
|
void selectSavedView(id);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
const funnelByPipeline = computed(() => {
|
const funnelByPipeline = computed(() => {
|
||||||
const rows = data.value?.funnel ?? [];
|
const rows = data.value?.funnel ?? [];
|
||||||
const map = new Map<string, { name: string; stages: ReportsFunnelStageDto[] }>();
|
const map = new Map<string, { name: string; stages: ReportsFunnelStageDto[] }>();
|
||||||
@@ -199,6 +275,57 @@ function formatCompareValue(
|
|||||||
return num(value);
|
return num(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const periodCompareColumns: TableColumnsType = [
|
||||||
|
{ title: 'شاخص', dataIndex: 'label', key: 'label' },
|
||||||
|
{
|
||||||
|
title: 'فعلی',
|
||||||
|
key: 'current',
|
||||||
|
customRender: ({ record }: { record: ReportsPeriodCompareRowDto }) =>
|
||||||
|
formatCompareValue(record.current, record.format),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'قبل',
|
||||||
|
key: 'previous',
|
||||||
|
customRender: ({ record }: { record: ReportsPeriodCompareRowDto }) =>
|
||||||
|
formatCompareValue(record.previous, record.format),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'تغییر',
|
||||||
|
key: 'delta',
|
||||||
|
customRender: ({ record }: { record: ReportsPeriodCompareRowDto }) =>
|
||||||
|
formatChange(record.changePercent),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
function periodCompareRowProps(record: ReportsPeriodCompareRowDto) {
|
||||||
|
return {
|
||||||
|
style: record.drillKind ? { cursor: 'pointer' } : undefined,
|
||||||
|
onClick: () => {
|
||||||
|
if (record.drillKind) void openDrill(record.drillKind);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const metricOptions = REPORTS_BUILDER_METRICS.map((m) => ({
|
||||||
|
value: m,
|
||||||
|
label: REPORTS_BUILDER_METRIC_LABELS[m],
|
||||||
|
}));
|
||||||
|
|
||||||
|
const dimensionOptions = REPORTS_BUILDER_DIMENSIONS.map((d) => ({
|
||||||
|
value: d,
|
||||||
|
label: REPORTS_BUILDER_DIMENSION_LABELS[d],
|
||||||
|
}));
|
||||||
|
|
||||||
|
const userOptions = computed(() => [
|
||||||
|
{ value: '', label: 'همه کاربران مجاز' },
|
||||||
|
...orgUsers.value.map((u) => ({ value: u.id, label: u.fullName })),
|
||||||
|
]);
|
||||||
|
|
||||||
|
const teamOptions = computed(() => [
|
||||||
|
{ value: '', label: 'همه تیمها' },
|
||||||
|
...orgTeams.value.map((t) => ({ value: t.id, label: t.name })),
|
||||||
|
]);
|
||||||
|
|
||||||
function rangeLabel() {
|
function rangeLabel() {
|
||||||
if (!from.value || !to.value) return '—';
|
if (!from.value || !to.value) return '—';
|
||||||
try {
|
try {
|
||||||
@@ -295,6 +422,15 @@ function openCustom() {
|
|||||||
syncViewQuery(null);
|
syncViewQuery(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function applyCustomRange() {
|
||||||
|
activeViewId.value = null;
|
||||||
|
syncViewQuery(null);
|
||||||
|
void load().then(() => {
|
||||||
|
if (pageMode.value === 'builder') void runBuilder();
|
||||||
|
if (pageMode.value === 'leads') void loadLeads();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function currentFilters(): ReportsViewFilters {
|
function currentFilters(): ReportsViewFilters {
|
||||||
return {
|
return {
|
||||||
period: period.value,
|
period: period.value,
|
||||||
@@ -508,6 +644,22 @@ watch(builderMetric, (metric) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const builderTableColumns = computed<TableColumnsType>(() => [
|
||||||
|
{
|
||||||
|
title: builderResult.value?.dimensionLabel ?? 'بُعد',
|
||||||
|
dataIndex: 'label',
|
||||||
|
key: 'label',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: builderResult.value?.metricLabel ?? 'متریک',
|
||||||
|
key: 'value',
|
||||||
|
customRender: ({ record }: { record: { value: number } }) =>
|
||||||
|
builderResult.value?.format === 'money'
|
||||||
|
? money(record.value)
|
||||||
|
: num(record.value),
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
const builderChartOption = computed<UiChartOption>(() => {
|
const builderChartOption = computed<UiChartOption>(() => {
|
||||||
const rows = (builderResult.value?.rows ?? []).slice(0, 12);
|
const rows = (builderResult.value?.rows ?? []).slice(0, 12);
|
||||||
const isMoney = builderResult.value?.format === 'money';
|
const isMoney = builderResult.value?.format === 'money';
|
||||||
|
|||||||
Reference in New Issue
Block a user