From 47519ea9fd53705418a6c83ea40ae1cfecb26ae3 Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期二, 13 一月 2026 17:54:15 +0800
Subject: [PATCH] 合格率统计重构:物料属性分类查询各自的合格率饼图及对应的柱状图以和详情表格

---
 src/components/echarts/echarts.vue |   28 ++++++++++++++++++++++++----
 1 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/src/components/echarts/echarts.vue b/src/components/echarts/echarts.vue
index 68de3a2..8e72a2e 100644
--- a/src/components/echarts/echarts.vue
+++ b/src/components/echarts/echarts.vue
@@ -18,13 +18,13 @@
     chartStyle: {
       type: Object,
       default: () => ({
-        height: '80%',
+        height: '95%',
         width: '100%'
       })
     },
     dataset: {
       type: Object,
-      default: () => {}
+      default: () => { }
     },
     xAxis: {
       type: Array,
@@ -81,8 +81,8 @@
   watch: {
     options: {
       deep: true,
-        // immediate: true,
-        handler(val) {
+      // immediate: true,
+      handler(val) {
         this.$nextTick(() => {
           this.renderChart()
         })
@@ -198,6 +198,7 @@
     },
     renderChart() {
       const option = {
+        ...this.options,
         backgroundColor: this.options.backgroundColor || '#fff',
         xAxis: this.xAxis,
         yAxis: this.yAxis,
@@ -240,7 +241,26 @@
         this.chartInstance.dispose()
         this.chartInstance = null
       }
+    },
+
+    //  涓嬭浇鍥剧墖鍔熻兘
+    downloadImage(fileName = 'chart') {
+      if (!this.chartInstance) return;
+
+      const url = this.chartInstance.getDataURL({
+        type: 'png',
+        pixelRatio: 2,
+        backgroundColor: '#fff'
+      });
+
+      const a = document.createElement('a');
+      a.href = url;
+      a.download = `${fileName}.png`;
+      document.body.appendChild(a);
+      a.click();
+      document.body.removeChild(a);
     }
+
   },
 }
 </script>

--
Gitblit v1.9.3