From 234409bb4a612c5b69b78b1e844492f0a7122521 Mon Sep 17 00:00:00 2001
From: TreeWish <1131093754@qq.com>
Date: 星期二, 28 二月 2023 19:15:32 +0800
Subject: [PATCH] 工程&管线接口对接

---
 src/components/chart/BaseBarChart.vue |   55 +++++++++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 49 insertions(+), 6 deletions(-)

diff --git a/src/components/chart/BaseBarChart.vue b/src/components/chart/BaseBarChart.vue
index ea195ce..ed0e9c4 100644
--- a/src/components/chart/BaseBarChart.vue
+++ b/src/components/chart/BaseBarChart.vue
@@ -4,7 +4,11 @@
 
 <script>
 import * as echarts from "echarts"
-import { countCountryDimension, countProvinceDimension } from "@/api/screen.js"
+import {
+  countCountryDimension,
+  countProvinceDimension,
+  countZhPipeStations,
+} from "@/api/screen.js"
 export default {
   props: {
     width: {
@@ -30,6 +34,10 @@
     project: {
       type: String,
       default: "鍏ㄥ浗椤圭洰",
+    },
+    title: {
+      type: String,
+      default: "",
     },
   },
   data() {
@@ -92,11 +100,36 @@
       if (this.dataList) {
         data = this.dataList
       }
+      let count = 0
+      let countVal = 0
+
+      const title = this.title
       data.forEach(item => {
-        let name = item.province || item.country
+        let name = item.province || item.country || item.杈撻�佷粙璐�
+        let value = item.count || item.绔欏満鏁伴噺
+        if (title == "绔欏満搴ф暟" && item.绠¢亾鏁伴噺) {
+          count += item.绠¢亾鏁伴噺
+        } else {
+          count += item.count || 0
+        }
+
+        // switch (title) {
+        //   case "绔欏満搴ф暟":
+        //     countVal = item.绠¢亾鏁伴噺
+        //     break
+        //   case "椤圭洰涓暟":
+        //     countVal = item.count
+        //     break
+        // }
+
         xAxisData.push(name)
-        yAxisData.push(item.count)
+        yAxisData.push(value)
       })
+      console.log("绠¢亾鏁伴噺", countVal)
+
+      if (typeof count === "number") {
+        this.$bus.$emit("changeCount", count)
+      }
       let option = {
         backgroundColor: "transparent",
         tooltip: {
@@ -134,6 +167,9 @@
                 var maxLength = 2 //姣忛」鏄剧ず鏂囧瓧涓暟
                 var valLength = value.length //X杞寸被鐩」鐨勬枃瀛椾釜鏁�
                 var rowN = Math.ceil(valLength / maxLength) //绫荤洰椤归渶瑕佹崲琛岀殑琛屾暟
+                if (xAxisData.length < 7) {
+                  return value
+                }
                 if (rowN > 1) {
                   //濡傛灉绫荤洰椤圭殑鏂囧瓧澶т簬3,
                   for (var i = 0; i < rowN; i++) {
@@ -170,6 +206,7 @@
         ],
         series: [
           {
+            name: this.title,
             type: "bar",
             data: yAxisData,
             barWidth: "12px",
@@ -252,6 +289,7 @@
     },
     project: {
       deep: true,
+      immediate: true,
       handler(newVal) {
         let requsetFn = null
         switch (newVal) {
@@ -261,7 +299,12 @@
           case "鍏ㄥ浗椤圭洰":
             requsetFn = countProvinceDimension
             break
-
+          case "鍏ㄧ悆绠$綉鍥�":
+            requsetFn = countZhPipeStations
+            break
+          case "鍏ㄥ浗绠$綉鍥�":
+            requsetFn = countZhPipeStations
+            break
           default:
             break
         }
@@ -271,7 +314,7 @@
     },
   },
   mounted() {
-    this.initData()
+    // this.initData()
     this.initChart()
     if (this.autoResize) {
       window.addEventListener("resize", this.resizeHandler)
@@ -289,7 +332,7 @@
   },
   methods: {
     resizeHandler() {
-      this.chart.resize()
+      this.chart && this.chart.resize()
     },
     initChart() {
       this.chart = echarts.init(this.$refs.chart, "", {

--
Gitblit v1.9.3