From 1c829f9177eab675b22be4d20ef2761ed1bbb423 Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期二, 15 九月 2026 16:15:48 +0800
Subject: [PATCH] refactor(layout): 调整布局样式并优化轮播卡片组件
---
src/views/reportAnalysis/PSIDataAnalysis/components/left-top.vue | 182 +++++++++++++++++++++------------------------
1 files changed, 86 insertions(+), 96 deletions(-)
diff --git a/src/views/reportAnalysis/PSIDataAnalysis/components/left-top.vue b/src/views/reportAnalysis/PSIDataAnalysis/components/left-top.vue
index cd8f1e3..5c84946 100644
--- a/src/views/reportAnalysis/PSIDataAnalysis/components/left-top.vue
+++ b/src/views/reportAnalysis/PSIDataAnalysis/components/left-top.vue
@@ -1,10 +1,13 @@
<template>
<div>
- <PanelHeader title="浜у搧閿�鍞噾棰濆垎鏋�" />
+ <PanelHeader title="閿�鍞搧鍒嗗竷" />
<div class="main-panel panel-item-customers">
<CarouselCards :items="cardItems" :visible-count="3" />
<div class="pie-chart-wrapper">
- <div class="pie-background"></div>
+ <div class="pie-center">
+ <span class="pie-center-value">{{ totalAmount }}</span>
+ <span class="pie-center-label">鍚堣(鍏�)</span>
+ </div>
<Echarts
ref="echartsRef"
:chartStyle="chartStyle"
@@ -22,10 +25,11 @@
<script setup>
import { ref, onMounted, computed } from 'vue'
-import { deptStaffDistribution } from '@/api/viewIndex.js'
+import { productSalesAnalysis } from '@/api/viewIndex.js'
import PanelHeader from './PanelHeader.vue'
import CarouselCards from './CarouselCards.vue'
import Echarts from '@/components/Echarts/echarts.vue'
+import { BI, baseChartOptions, withTooltip, formatAmount } from '../theme.js'
/**
* @introduction 鎶婃暟缁勪腑key鍊肩浉鍚岀殑閭d竴椤规彁鍙栧嚭鏉ワ紝缁勬垚涓�涓璞�
@@ -48,16 +52,20 @@
const echartsRef = ref(null)
const pieDatas = ref([])
-const pieColors = ['#D1E4F5', '#5782F7', '#2F67EF', '#82BAFF', '#43e8fc', '#27EBE7']
+const pieColors = BI.series
const pieObjData = computed(() => array2obj(pieDatas.value, 'name'))
+
+const totalAmount = computed(() =>
+ formatAmount(pieDatas.value.reduce((sum, d) => sum + (Number(d.value) || 0), 0))
+)
const pieLegend = computed(() => {
const data = pieDatas.value.map((d, idx) => ({
name: d.name,
icon: 'circle',
textStyle: {
- fontSize: 18,
+ fontSize: 14,
color: pieColors[idx % pieColors.length],
},
}))
@@ -65,35 +73,35 @@
return {
orient: 'vertical',
top: 'center',
- left: '60%',
- itemGap: 30,
+ left: '52%',
+ itemGap: 24,
data: data,
formatter: function (name) {
const item = pieObjData.value[name]
if (!item) return name
- return `{title|${name}}{value|${item.value}}{unit|浜簘{percent|${item.rate}}{unit|%}`
+ return `{title|${name}}{value|${formatAmount(item.value)}}{percent|${item.rate}}{unit|%}`
},
textStyle: {
rich: {
- value: {
- color: '#43e8fc',
+ title: {
fontSize: 14,
- fontWeight: 600,
- padding: [0, 0, 0, 30],
- },
- unit: {
- color: '#82baff',
- fontSize: 12,
- fontWeight: 600,
- padding: [0, 10, 0, 0],
- },
- percent: {
- color: '#43e8fc',
- fontSize: 14,
- fontWeight: 600,
+ color: BI.text,
padding: [0, 0, 0, 0],
},
- title: {
+ value: {
+ color: BI.textStrong,
+ fontSize: 14,
+ fontWeight: 600,
+ padding: [0, 6, 0, 10],
+ },
+ percent: {
+ color: BI.accentBright,
+ fontSize: 14,
+ fontWeight: 600,
+ padding: [0, 0, 0, 6],
+ },
+ unit: {
+ color: BI.text,
fontSize: 12,
padding: [0, 0, 0, 0],
},
@@ -102,20 +110,21 @@
}
})
-const pieTooltip = {
+const pieTooltip = withTooltip({
trigger: 'item',
- formatter: '{a} <br/>{b} : {c} ({d}%)',
-}
+ formatter: '{a} <br/>{b} : {c}鍏� ({d}%)',
+})
const pieSeries = computed(() => [
{
- name: '鍚勪骇鍝侀攢鍞噾棰濆垎鏋�',
+ name: '浜у搧閿�鍞噾棰濆垎鏋�',
type: 'pie',
- radius: '60%',
+ radius: ['48%', '68%'],
center: ['25%', '50%'],
itemStyle: {
- borderColor: '#0a1c3a',
+ borderColor: BI.sliceBorder,
borderWidth: 2,
+ borderRadius: 4,
},
label: {
show: false
@@ -130,68 +139,35 @@
},
])
-const pieOptions = {
- backgroundColor: 'transparent',
- textStyle: { color: '#B8C8E0' },
-}
+const pieOptions = baseChartOptions
const cardItems = ref([])
-// 鍋囨暟鎹�
-const mockData = [
- { name: '鐢熶骇閮�', value: 125, rate: '35.2' },
- { name: '鎶�鏈儴', value: 85, rate: '23.9' },
- { name: '閿�鍞儴', value: 65, rate: '18.3' },
- { name: '璐㈠姟閮�', value: 32, rate: '9.0' },
- { name: '浜轰簨閮�', value: 28, rate: '7.9' },
- { name: '琛屾斂閮�', value: 20, rate: '5.6' },
-]
-
-const getDeptStaffDistribution = () => {
- setMockData()
- // deptStaffDistribution().then(res => {
- // if (res.code === 200) {
- // const items = res.data.items || []
- // // 鍗$墖鏁版嵁
- // cardItems.value = items.map(item => ({
- // label: item.name,
- // value: parseInt(item.value),
- // unit: '浜�'
- // }))
- // // 鍥捐〃鏁版嵁
- // pieDatas.value = items.map(item => ({
- // name: item.name,
- // value: parseInt(item.value),
- // rate: item.rate
- // }))
- // } else {
- // // 浣跨敤鍋囨暟鎹�
- // setMockData()
- // }
- // }).catch(err => {
- // console.error('鑾峰彇閮ㄩ棬浜哄憳鍒嗗竷鏁版嵁澶辫触:', err)
- // // 浣跨敤鍋囨暟鎹�
- // setMockData()
- // })
-}
-
-const setMockData = () => {
- // 鍗$墖鏁版嵁
- cardItems.value = mockData.map(item => ({
- label: item.name,
- value: item.value,
- unit: '浜�'
- }))
- // 鍥捐〃鏁版嵁
- pieDatas.value = mockData.map(item => ({
- name: item.name,
- value: item.value,
- rate: item.rate
- }))
+const fetchData = () => {
+ productSalesAnalysis()
+ .then((res) => {
+ if (res.code === 200 && Array.isArray(res.data)) {
+ const items = res.data
+ cardItems.value = items.map((item) => ({
+ label: item.name,
+ value: item.value,
+ unit: '鍏�',
+ rate: item.rate,
+ }))
+ pieDatas.value = items.map((item) => ({
+ name: item.name,
+ value: parseFloat(item.value) || 0,
+ rate: item.rate,
+ }))
+ }
+ })
+ .catch((err) => {
+ console.error('鑾峰彇浜у搧閿�鍞噾棰濆垎鏋愬け璐�:', err)
+ })
}
onMounted(() => {
- getDeptStaffDistribution()
+ fetchData()
})
</script>
@@ -203,28 +179,42 @@
}
.panel-item-customers {
- border: 1px solid #1a58b0;
+ border: 1px solid var(--bi-panel-border);
+ background: var(--bi-panel-bg);
+ border-radius: 8px;
padding: 18px;
width: 100%;
height: 449px;
}
+
.pie-chart-wrapper {
position: relative;
width: 100%;
height: 320px;
}
-.pie-background {
+
+.pie-center {
position: absolute;
left: 25%;
top: 50%;
- transform: translate(-51.5%, -50%);
- width: 310px;
- height: 310px;
- background-image: url('@/assets/BI/鐜懓鍥捐竟妗�.png');
- background-size: contain;
- background-position: center;
- background-repeat: no-repeat;
- z-index: 1;
+ transform: translate(-50%, -50%);
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ gap: 4px;
pointer-events: none;
+ z-index: 2;
+}
+
+.pie-center-value {
+ font-weight: 600;
+ font-size: 20px;
+ color: var(--bi-text-strong);
+ font-variant-numeric: tabular-nums;
+}
+
+.pie-center-label {
+ font-size: 12px;
+ color: var(--bi-text);
}
</style>
--
Gitblit v1.9.3