Files
report_viewer/src/ui/JRZQ6F2A/components/NBankOrgSection.vue

175 lines
3.8 KiB
Vue
Raw Normal View History

2025-12-16 12:27:12 +08:00
<template>
2025-12-16 17:34:28 +08:00
<div class="mb-6">
<LTitle title="非银机构申请机构数分布" />
<div class="mt-4">
<!-- 饼图宽度占满 -->
<div class="h-64 mb-4">
2025-12-16 12:27:12 +08:00
<v-chart class="chart-container" :option="pieChartOption" autoresize />
</div>
2025-12-16 17:34:28 +08:00
<!-- 详细列表在图表下方展示所有项并带颜色标识 -->
2025-12-16 12:27:12 +08:00
<div class="space-y-2">
2025-12-16 17:34:28 +08:00
<div v-for="(item, index) in detailList" :key="index" class="flex justify-between items-center text-sm">
<div class="flex items-center">
<span class="w-2 h-2 rounded-full mr-2" :style="{ backgroundColor: item.color }" />
<span class="text-gray-600">{{ item.label }}</span>
</div>
2025-12-16 12:27:12 +08:00
<span class="text-[#333333] font-bold">{{ item.value }}</span>
</div>
</div>
</div>
</div>
</template>
<script setup>
import { computed } from 'vue'
import VChart from 'vue-echarts'
import { use } from 'echarts/core'
import { CanvasRenderer } from 'echarts/renderers'
import { PieChart } from 'echarts/charts'
import {
TitleComponent,
TooltipComponent,
LegendComponent
} from 'echarts/components'
2025-12-16 17:34:28 +08:00
import LTitle from '@/components/LTitle.vue'
2025-12-16 12:27:12 +08:00
import { getNBankOrgDetails, FIELD_LABELS } from '../utils/dataParser'
// 注册ECharts组件
use([
CanvasRenderer,
PieChart,
TitleComponent,
TooltipComponent,
LegendComponent
])
const props = defineProps({
data: {
type: Object,
required: true,
default: () => ({})
},
period: {
type: String,
required: true
}
})
2025-12-16 17:34:28 +08:00
// 颜色映射表(与图表保持一致)
const COLORS = [
'#2B79EE',
'#61D2F4',
'#34D399',
'#FBBF24',
'#F97316',
'#EF4444',
'#A855F7',
'#6B7280',
]
2025-12-16 12:27:12 +08:00
// 获取非银机构数详情
const nbankOrgs = computed(() => getNBankOrgDetails(props.data, props.period))
// 计算非银机构总数
const nbankTotal = computed(() => {
const orgs = nbankOrgs.value
return Object.values(orgs).reduce((sum, val) => sum + (val || 0), 0)
})
2025-12-16 17:34:28 +08:00
// 详细列表(包含所有项,包含 0 家)
2025-12-16 12:27:12 +08:00
const detailList = computed(() => {
const orgs = nbankOrgs.value
const labels = FIELD_LABELS.nbank
2025-12-16 17:34:28 +08:00
2025-12-16 12:27:12 +08:00
return Object.entries(orgs)
2025-12-16 17:34:28 +08:00
.map(([key, value], index) => ({
2025-12-16 12:27:12 +08:00
key,
label: labels[key] || key,
2025-12-16 17:34:28 +08:00
value: value || 0,
color: COLORS[index % COLORS.length],
2025-12-16 12:27:12 +08:00
}))
})
// 饼图配置
const pieChartOption = computed(() => {
const list = detailList.value
2025-12-16 17:34:28 +08:00
if (!list || list.length === 0) {
2025-12-16 12:27:12 +08:00
return {
title: {
text: '暂无数据',
left: 'center',
top: 'center',
textStyle: {
color: '#999',
fontSize: 14
}
}
}
}
return {
tooltip: {
trigger: 'item',
formatter: '{b}: {c}家 ({d}%)'
},
2025-12-16 17:34:28 +08:00
graphic: {
type: 'text',
left: 'center',
top: 'center',
style: {
text: '非银机构',
fill: '#111827',
fontSize: 14,
fontWeight: 'bold',
},
2025-12-16 12:27:12 +08:00
},
series: [
{
name: '机构数',
type: 'pie',
radius: ['40%', '70%'],
2025-12-16 17:34:28 +08:00
center: ['50%', '50%'],
2025-12-16 12:27:12 +08:00
avoidLabelOverlap: false,
itemStyle: {
borderRadius: 4,
borderColor: '#fff',
borderWidth: 2
},
label: {
2025-12-16 17:34:28 +08:00
show: false
2025-12-16 12:27:12 +08:00
},
emphasis: {
2025-12-16 17:34:28 +08:00
itemStyle: {
shadowBlur: 10,
shadowOffsetX: 0,
shadowColor: 'rgba(0, 0, 0, 0.5)'
},
2025-12-16 12:27:12 +08:00
label: {
show: true,
fontSize: 14,
2025-12-16 17:34:28 +08:00
fontWeight: 'bold',
color: '#333'
2025-12-16 12:27:12 +08:00
}
},
data: list.map(item => ({
value: item.value,
2025-12-16 17:34:28 +08:00
name: item.label,
itemStyle: {
color: item.color
}
2025-12-16 12:27:12 +08:00
}))
}
]
}
})
</script>
2025-12-16 17:34:28 +08:00
<style lang="scss" scoped>
.chart-container {
width: 100%;
height: 100%;
2025-12-16 12:27:12 +08:00
}
</style>