2026-05-06 11:00:38 +08:00
|
|
|
|
import { computed, ref } from 'vue'
|
|
|
|
|
|
import {
|
|
|
|
|
|
metricBlueprints,
|
|
|
|
|
|
trendRanges,
|
|
|
|
|
|
trendSeries,
|
|
|
|
|
|
spendByCategory,
|
|
|
|
|
|
exceptionMix,
|
|
|
|
|
|
departmentRangeOptions,
|
|
|
|
|
|
bottlenecks,
|
|
|
|
|
|
budgetSummary
|
|
|
|
|
|
} from '../../data/metrics.js'
|
|
|
|
|
|
import TrendChart from '../../components/charts/TrendChart.vue'
|
|
|
|
|
|
import DonutChart from '../../components/charts/DonutChart.vue'
|
|
|
|
|
|
import BarChart from '../../components/charts/BarChart.vue'
|
|
|
|
|
|
import GaugeChart from '../../components/charts/GaugeChart.vue'
|
|
|
|
|
|
import PersonalWorkbench from '../../components/business/PersonalWorkbench.vue'
|
|
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
|
name: 'OverviewView',
|
|
|
|
|
|
components: { TrendChart, DonutChart, BarChart, GaugeChart, PersonalWorkbench },
|
|
|
|
|
|
props: {
|
|
|
|
|
|
filteredRequests: { type: Array, required: true }
|
|
|
|
|
|
},
|
|
|
|
|
|
emits: ['ask'] ,
|
|
|
|
|
|
setup(props, { emit }) {
|
|
|
|
|
|
const activeTrendRange = ref(trendRanges[0])
|
|
|
|
|
|
const activeDepartmentRange = ref(departmentRangeOptions[0])
|
|
|
|
|
|
|
|
|
|
|
|
const demoTotals = {
|
|
|
|
|
|
pendingCount: 128,
|
|
|
|
|
|
pendingAmount: 361600,
|
|
|
|
|
|
avgSla: 6.8,
|
|
|
|
|
|
autoPassRate: 78,
|
|
|
|
|
|
riskCount: 14,
|
|
|
|
|
|
slaRate: 96
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const demoDepartments = [
|
|
|
|
|
|
{ name: '销售部', amount: 182000, color: '#10b981' },
|
|
|
|
|
|
{ name: '研发中心', amount: 146000, color: '#3b82f6' },
|
|
|
|
|
|
{ name: '市场部', amount: 96000, color: '#f59e0b' },
|
|
|
|
|
|
{ name: '运营部', amount: 68600, color: '#8b5cf6' },
|
|
|
|
|
|
{ name: '行政部', amount: 48300, color: '#3b82f6' }
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
const formatCompact = (value) => {
|
|
|
|
|
|
if (value >= 1_000_000) return `¥${(value / 1_000_000).toFixed(1)}M`
|
|
|
|
|
|
if (value >= 1_000) return `¥${(value / 1_000).toFixed(1)}K`
|
|
|
|
|
|
return `¥${value}`
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const formatCurrency = (value) => formatCompact(value)
|
|
|
|
|
|
|
|
|
|
|
|
const formatMetricValue = (metric, value) => {
|
|
|
|
|
|
if (metric.key === 'pendingAmount') return formatCurrency(Math.round(value))
|
|
|
|
|
|
if (metric.key === 'avgSla') return `${value.toFixed(1)} ${metric.unit}`
|
|
|
|
|
|
if (metric.unit === '%') return `${Math.round(value)} ${metric.unit}`
|
|
|
|
|
|
if (metric.unit) return `${Math.round(value)} ${metric.unit}`
|
|
|
|
|
|
return `${Math.round(value)}`
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const kpiMetrics = computed(() => metricBlueprints.map((metric, index) => {
|
|
|
|
|
|
const rawValue = demoTotals[metric.key]
|
|
|
|
|
|
const displayValue = formatMetricValue(metric, rawValue)
|
|
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
|
...metric,
|
|
|
|
|
|
displayValue,
|
|
|
|
|
|
changeText: metric.change,
|
|
|
|
|
|
delay: index * 55
|
|
|
|
|
|
}
|
|
|
|
|
|
}))
|
|
|
|
|
|
|
|
|
|
|
|
const activeTrend = computed(() => trendSeries[activeTrendRange.value])
|
|
|
|
|
|
|
|
|
|
|
|
const spendTotal = computed(() => spendByCategory.reduce((sum, item) => sum + item.value, 0))
|
|
|
|
|
|
const riskTotal = computed(() => exceptionMix.reduce((sum, item) => sum + item.value, 0))
|
|
|
|
|
|
|
|
|
|
|
|
const spendLegend = computed(() => spendByCategory.map((item) => ({
|
|
|
|
|
|
...item,
|
|
|
|
|
|
display: `${Math.round((item.value / spendTotal.value) * 100)}%`
|
|
|
|
|
|
})))
|
|
|
|
|
|
|
|
|
|
|
|
const riskLegend = computed(() => exceptionMix.map((item) => ({
|
|
|
|
|
|
...item,
|
|
|
|
|
|
display: `${item.value} 单`
|
|
|
|
|
|
})))
|
|
|
|
|
|
|
|
|
|
|
|
const rankedDepartments = computed(() => {
|
|
|
|
|
|
const rows = demoDepartments
|
|
|
|
|
|
const max = Math.max(...rows.map((item) => item.amount), 1)
|
|
|
|
|
|
|
|
|
|
|
|
return rows.slice(0, 5).map((item, index) => ({
|
|
|
|
|
|
...item,
|
|
|
|
|
|
rank: index + 1,
|
|
|
|
|
|
shortName: item.name,
|
|
|
|
|
|
amountLabel: formatCurrency(item.amount),
|
|
|
|
|
|
width: `${Math.max((item.amount / max) * 100, 18)}%`,
|
|
|
|
|
|
color: item.color
|
|
|
|
|
|
}))
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
|
emit,
|
|
|
|
|
|
activeTrendRange,
|
|
|
|
|
|
activeDepartmentRange,
|
|
|
|
|
|
demoTotals,
|
|
|
|
|
|
demoDepartments,
|
|
|
|
|
|
formatCompact,
|
|
|
|
|
|
formatCurrency,
|
|
|
|
|
|
formatMetricValue,
|
|
|
|
|
|
kpiMetrics,
|
|
|
|
|
|
activeTrend,
|
|
|
|
|
|
spendTotal,
|
|
|
|
|
|
riskTotal,
|
|
|
|
|
|
spendLegend,
|
|
|
|
|
|
riskLegend,
|
|
|
|
|
|
rankedDepartments,
|
|
|
|
|
|
metricBlueprints,
|
|
|
|
|
|
trendRanges,
|
|
|
|
|
|
trendSeries,
|
|
|
|
|
|
spendByCategory,
|
|
|
|
|
|
exceptionMix,
|
|
|
|
|
|
departmentRangeOptions,
|
|
|
|
|
|
bottlenecks,
|
|
|
|
|
|
budgetSummary
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2026-05-09 03:04:09 +00:00
|
|
|
|
|