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-bottom.vue |  188 ++++++++++++++++++++++-------------------------
 1 files changed, 88 insertions(+), 100 deletions(-)

diff --git a/src/views/reportAnalysis/PSIDataAnalysis/components/left-bottom.vue b/src/views/reportAnalysis/PSIDataAnalysis/components/left-bottom.vue
index 9ddab7f..eb2b081 100644
--- a/src/views/reportAnalysis/PSIDataAnalysis/components/left-bottom.vue
+++ b/src/views/reportAnalysis/PSIDataAnalysis/components/left-bottom.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="chart"
           :chartStyle="chartStyle"
@@ -26,7 +29,8 @@
 import Echarts from '@/components/Echarts/echarts.vue'
 import PanelHeader from './PanelHeader.vue'
 import CarouselCards from './CarouselCards.vue'
-import { productCategoryDistribution } from '@/api/viewIndex.js'
+import { rawMaterialPurchaseAmountRatio } from '@/api/viewIndex.js'
+import { BI, baseChartOptions, withTooltip, formatAmount } from '../theme.js'
 
 /**
  * @introduction 鎶婃暟缁勪腑key鍊肩浉鍚岀殑閭d竴椤规彁鍙栧嚭鏉ワ紝缁勬垚涓�涓璞�
@@ -48,20 +52,14 @@
 // 鍗$墖鏁版嵁
 const cardItems = ref([])
 
-// 鍋囨暟鎹�
-const mockCardData = [
-  { name: '鐢靛瓙浜у搧', value: 156, rate: '28.5' },
-  { name: '鏈烘璁惧', value: 132, rate: '24.1' },
-  { name: '鍘熸潗鏂�', value: 98, rate: '17.9' },
-  { name: '鍖栧伐浜у搧', value: 87, rate: '15.9' },
-  { name: '绾虹粐鍝�', value: 45, rate: '8.2' },
-  { name: '鍏朵粬', value: 31, rate: '5.7' },
-]
-
 // 棰滆壊鍒楄〃
-const landColors = ['#26FFCB', '#24CBFF', '#35FBF4', '#2651FF', '#D1E4F5', '#5782F7', '#2F67EF', '#82BAFF']
+const landColors = BI.series
 
 const landObjData = computed(() => array2obj(dataList.value, 'name'))
+
+const totalAmount = computed(() =>
+  formatAmount(dataList.value.reduce((sum, d) => sum + (Number(d.value) || 0), 0))
+)
 
 // 鍥句緥閰嶇疆锛堝彸渚х珫鎺掞級
 const landLegend = computed(() => {
@@ -69,7 +67,7 @@
     name: d.name,
     icon: 'circle',
     textStyle: {
-      fontSize: 18,
+      fontSize: 14,
       color: landColors[idx % landColors.length],
     },
   }))
@@ -77,35 +75,35 @@
   return {
     orient: 'vertical',
     top: 'center',
-    left: '60%',
-    itemGap: 30,
+    left: '52%',
+    itemGap: 24,
     data: data,
     formatter: function (name) {
       const item = landObjData.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],
         },
@@ -115,21 +113,22 @@
 })
 
 // 鎻愮ず妗�
-const landTooltip = {
+const landTooltip = withTooltip({
   trigger: 'item',
-  formatter: '{a} <br/>{b} : {c} ({d}%)',
-}
+  formatter: '{a} <br/>{b} : {c}鍏� ({d}%)',
+})
 
 // 鍙屽眰鐜舰楗煎浘
 const landSeries = ref([
   {
     name: '浜у搧閲囪喘閲戦鍒嗘瀽',
     type: 'pie',
-    radius: ['40%', '60%'],
+    radius: ['48%', '68%'],
     center: ['25%', '50%'],
     itemStyle: {
-      borderColor: '#0a1c3a',
+      borderColor: BI.sliceBorder,
       borderWidth: 2,
+      borderRadius: 4,
       color: function (params) {
         return landColors[params.dataIndex % landColors.length]
       },
@@ -146,9 +145,9 @@
     },
   },
   {
-    // 鍐呭湀
+    // 鍐呭湀杞ㄩ亾鐜�
     type: 'pie',
-    radius: ['40%', '45%'],
+    radius: ['40%', '43%'],
     center: ['25%', '50%'],
     silent: true,
     label: {
@@ -158,7 +157,7 @@
       show: false,
     },
     itemStyle: {
-      color: 'rgba(0, 127, 255, 0.25)',
+      color: 'rgba(74, 108, 240, 0.22)',
     },
     data: [1],
   },
@@ -169,57 +168,35 @@
   height: '100%',
 }
 
-const pieOptions = {
-  backgroundColor: 'transparent',
-  textStyle: { color: '#B8C8E0' },
-}
+const pieOptions = baseChartOptions
 
-const setMockData = () => {
-  // 鍗$墖鏁版嵁
-  cardItems.value = mockCardData.map(item => ({
-    label: item.name,
-    value: item.value,
-    unit: '浠�',
-    rate: item.rate
-  }))
-  // 鍥捐〃鏁版嵁
-  dataList.value = mockCardData.map((it) => ({
-    name: it.name,
-    value: Number(it.value || 0),
-    rate: it.rate,
-    children: [],
-  }))
-  landSeries.value[0].data = dataList.value
-}
-
-const loadData = async () => {
-  setMockData()
-  // try {
-  //   const res = await productCategoryDistribution()
-  //   const items = res?.data?.items || []
-  //   dataList.value = items.map((it) => ({
-  //     name: it.name,
-  //     value: Number(it.value || 0),
-  //     rate: it.rate,
-  //     children: Array.isArray(it.children) ? it.children : [],
-  //   }))
-  //   // 鍗$墖鏁版嵁
-  //   cardItems.value = items.map(item => ({
-  //     label: item.name,
-  //     value: parseInt(item.value),
-  //     unit: '浠�',
-  //     rate: item.rate
-  //   }))
-  //   landLegend.data = dataList.value.map((d) => d.name)
-  //   landSeries.value[0].data = dataList.value
-  // } catch (e) {
-  //   console.error('鑾峰彇浜у搧澶х被鍒嗗竷澶辫触:', e)
-  //   setMockData()
-  // }
+const fetchData = () => {
+  rawMaterialPurchaseAmountRatio()
+    .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,
+        }))
+        dataList.value = items.map((it) => ({
+          name: it.name,
+          value: parseFloat(it.value) || 0,
+          rate: it.rate,
+          children: [],
+        }))
+        landSeries.value[0].data = dataList.value
+      }
+    })
+    .catch((err) => {
+      console.error('鑾峰彇鍘熸潗鏂欓噰璐噾棰濆崰姣斿け璐�:', err)
+    })
 }
 
 onMounted(() => {
-  loadData()
+  fetchData()
 })
 </script>
 
@@ -231,7 +208,9 @@
 }
 
 .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;
@@ -244,19 +223,28 @@
   background: transparent;
 }
 
-
-.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