From 9d485123b8c947f61c94aee67a0ceec8953a510d Mon Sep 17 00:00:00 2001
From: yaowanxin <3588231647@qq.com>
Date: 星期五, 30 一月 2026 17:36:56 +0800
Subject: [PATCH] 用印管理、规章制度管理页面添加分页功能

---
 src/views/reportAnalysis/productionAnalysis/components/left-top.vue |  227 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 227 insertions(+), 0 deletions(-)

diff --git a/src/views/reportAnalysis/productionAnalysis/components/left-top.vue b/src/views/reportAnalysis/productionAnalysis/components/left-top.vue
new file mode 100644
index 0000000..0cce7d6
--- /dev/null
+++ b/src/views/reportAnalysis/productionAnalysis/components/left-top.vue
@@ -0,0 +1,227 @@
+<template>
+  <div>
+    <PanelHeader title="宸ュ簭浜у嚭鍒嗘瀽" />
+    <div class="main-panel panel-item-customers">
+      <div class="filters-row">
+        <DateTypeSwitch v-model="dateType" @change="handleDateTypeChange" />
+      </div>
+      <div class="pie-chart-wrapper" ref="pieWrapperRef">
+        <div class="pie-background" ref="pieBackgroundRef"></div>
+        <Echarts
+          ref="echartsRef"
+          :chartStyle="chartStyle"
+          :legend="pieLegend"
+          :series="pieSeries"
+          :tooltip="pieTooltip"
+          :color="pieColors"
+          :options="pieOptions"
+          style="height: 320px"
+        />
+      </div>
+    </div>
+  </div>
+</template>
+
+<script setup>
+import { ref, onMounted, onBeforeUnmount, computed } from 'vue'
+import { productSalesAnalysis } from '@/api/viewIndex.js'
+import PanelHeader from './PanelHeader.vue'
+import Echarts from '@/components/Echarts/echarts.vue'
+import DateTypeSwitch from '@/views/reportAnalysis/financialAnalysis/components/DateTypeSwitch.vue'
+import { useChartBackground } from '@/hooks/useChartBackground.js'
+
+const pieWrapperRef = ref(null)
+const pieBackgroundRef = ref(null)
+
+const dateType = ref(1) // 1=鍛� 2=鏈� 3=瀛e害
+
+function array2obj(array, key) {
+  const resObj = {}
+  for (let i = 0; i < array.length; i++) {
+    resObj[array[i][key]] = array[i]
+  }
+  return resObj
+}
+
+const chartStyle = {
+  width: '100%',
+  height: '100%',
+}
+
+const echartsRef = ref(null)
+const pieDatas = ref([])
+const pieColors = ['#D1E4F5', '#5782F7', '#2F67EF', '#82BAFF', '#43e8fc', '#27EBE7']
+
+const pieObjData = computed(() => array2obj(pieDatas.value, 'name'))
+
+const pieLegend = computed(() => {
+  const data = pieDatas.value.map((d, idx) => ({
+    name: d.name,
+    icon: 'circle',
+    textStyle: {
+      fontSize: 18,
+      color: pieColors[idx % pieColors.length],
+    },
+  }))
+
+  return {
+    orient: 'vertical',
+    top: 'center',
+    left: '52%',
+    itemGap: 30,
+    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|%}`
+    },
+    textStyle: {
+      rich: {
+        value: {
+          color: '#43e8fc',
+          fontSize: 14,
+          fontWeight: 600,
+          padding: [0, 0, 0, 10],
+        },
+        unit: {
+          color: '#82baff',
+          fontSize: 12,
+          fontWeight: 600,
+          padding: [0, 10, 0, 0],
+        },
+        percent: {
+          color: '#43e8fc',
+          fontSize: 14,
+          fontWeight: 600,
+          padding: [0, 0, 0, 0],
+        },
+        title: {
+          fontSize: 12,
+          padding: [0, 0, 0, 0],
+        },
+      },
+    },
+  }
+})
+
+const pieTooltip = {
+  trigger: 'item',
+  formatter: '{a} <br/>{b} : {c}鍏� ({d}%)',
+}
+
+const pieSeries = computed(() => [
+  {
+    name: '浜у搧閿�鍞噾棰濆垎鏋�',
+    type: 'pie',
+    radius: '60%',
+    center: ['25%', '50%'],
+    itemStyle: {
+      borderColor: '#0a1c3a',
+      borderWidth: 2,
+    },
+    label: {
+      show: false
+    },
+    minAngle: 15,
+    data: pieDatas.value,
+    animationType: 'scale',
+    animationEasing: 'elasticOut',
+    animationDelay: function () {
+      return Math.random() * 200
+    },
+  },
+])
+
+const pieOptions = {
+  backgroundColor: 'transparent',
+  textStyle: { color: '#B8C8E0' },
+}
+
+// 浣跨敤灏佽鐨勮儗鏅綅缃皟鏁存柟娉�
+// 鍥捐〃涓績鏄� ['25%', '50%']锛岃儗鏅渶瑕佸榻愬埌杩欎釜浣嶇疆
+const { init: initBackground, cleanup: cleanupBackground } = useChartBackground({
+  wrapperRef: pieWrapperRef,
+  backgroundRef: pieBackgroundRef,
+  left: '25%',       // 鍥捐〃涓績 X 鏄� 25%
+  top: '50%',        // 鍥捐〃涓績 Y 鏄� 50%
+  offsetX: '-51.5%', // X 杞村亸绉�
+  offsetY: '-50%',   // Y 杞村亸绉�
+  watchData: pieDatas // 鐩戝惉鏁版嵁鍙樺寲锛岃嚜鍔ㄨ皟鏁翠綅缃�
+})
+
+const fetchData = () => {
+  productSalesAnalysis()
+    .then((res) => {
+      if (res.code === 200 && Array.isArray(res.data)) {
+        const items = res.data
+        pieDatas.value = items.map((item) => ({
+          name: item.name,
+          value: parseFloat(item.value) || 0,
+          rate: item.rate,
+        }))
+      }
+    })
+    .catch((err) => {
+      console.error('鑾峰彇浜у搧閿�鍞噾棰濆垎鏋愬け璐�:', err)
+    })
+}
+
+const handleDateTypeChange = () => {
+  fetchData()
+}
+
+onMounted(() => {
+  fetchData()
+  initBackground()
+})
+
+onBeforeUnmount(() => {
+  cleanupBackground()
+})
+</script>
+
+<style scoped>
+.main-panel {
+  display: flex;
+  flex-direction: column;
+  gap: 20px;
+}
+
+.panel-item-customers {
+  border: 1px solid #1a58b0;
+  padding: 18px;
+  width: 100%;
+  height: 449px;
+}
+
+.filters-row {
+  display: flex;
+  justify-content: flex-end;
+  align-items: center;
+  gap: 12px;
+  margin-bottom: 10px;
+}
+
+.pie-chart-wrapper {
+  position: relative;
+  width: 100%;
+  height: 320px;
+  background: transparent;
+}
+
+.pie-background {
+  position: absolute;
+  width: 310px;
+  height: 310px;
+  background-image: url('@/assets/BI/鐜懓鍥捐竟妗�.png');
+  background-size: contain;
+  background-position: center;
+  background-repeat: no-repeat;
+  z-index: 1;
+  pointer-events: none;
+  /* 浣嶇疆鐢� JS 鍔ㄦ�佽缃紝榛樿灞呬腑 */
+  left: 25%;
+  top: 50%;
+  transform: translate(-51.5%, -50%);
+}
+</style>

--
Gitblit v1.9.3