3 Commits ea94ae63d6 ... b27389609a

Author SHA1 Message Date
  littleblue55 b27389609a 企业预测数据导出接口修改 1 month ago
  littleblue55 4cfe61acf4 得分水平分析-正态分布 1 month ago
  littleblue55 6aa2cbe083 首页补充接口 1 month ago
4 changed files with 389 additions and 147 deletions
  1. 24 0
      src/api/home.js
  2. 211 73
      src/views/dashboard/sandianscore.vue
  3. 153 73
      src/views/index.vue
  4. 1 1
      src/views/predict/predict/index.vue

+ 24 - 0
src/api/home.js

@@ -0,0 +1,24 @@
+import request from '@/utils/request'
+
+// 获取柱状图数据
+export function getBarData() {
+    return request({
+        url: '/industry_oveview/industry_oveview/i_all_list',
+        method: 'get'
+    })
+}
+// 获取饼图数据
+export function getPieData() {
+    return request({
+        url: '/industry_oveview/industry_oveview/i_list',
+        method: 'get'
+    })
+}
+// 获取首页数据
+export function getIndexData(query) {
+    return request({
+        url: '/industry_oveview/industry_oveview/list',
+        method: 'get',
+        params: query
+    })
+}

+ 211 - 73
src/views/dashboard/sandianscore.vue

@@ -1,5 +1,5 @@
 <template>
-<!-- 得分水平分布-企业水平分析 - littlegreen - 补充form和label -->
+  <!-- 得分水平分布-企业水平分析 - littlegreen - 补充form和label -->
   <div
     :class="className"
     :style="{ height: '100%', width: width, padding: '20px' }"
@@ -58,11 +58,9 @@
           当前行业: {{ industryMap.get(selectedCode) }}
         </div>
         <el-form-item>
-          <el-button
-            type="primary"
-            icon="el-icon-search"
-            @click="updateChart"
-            >搜索</el-button>
+          <el-button type="primary" icon="el-icon-search" @click="updateChart"
+            >搜索</el-button
+          >
         </el-form-item>
       </el-form>
     </div>
@@ -151,6 +149,14 @@ export default {
         energyConsumeScore: "能源消费量得分",
         powerConsumeScore: "电力消费量得分",
       },
+      keyToLevel: {
+        totalIndustrialValueScore: "totalIndustrialValueLevel",
+        taxableIncomeScore: "taxableIncomeLevel",
+        paidTaxScore: "paidTaxLevel",
+        fundingScore: "fundingLevel",
+        energyConsumeScore: "energyConsumeLevel",
+        powerConsumeScore: "powerConsumeLevel",
+      },
       selectedYear: null,
       queryParams: {
         pageNum: 1,
@@ -263,9 +269,18 @@ export default {
         );
       }
       const values = filteredData.map((item) => item[this.selectedDataKey]);
+      console.log(filteredData, values, "filteredData")
       const minVal = Math.min(...values).toFixed(2);
       const maxVal = Math.max(...values).toFixed(2);
-      console.log(filteredData, "filteredData");
+      // console.log(minVal, maxVal)
+      // console.log(
+      //   filteredData,
+      //   "filteredData",
+      //   this.selectedDataKey,
+      //   values,
+      //   "values"
+      // );
+      // console.log(filteredData, "filteredData");
       if (
         this.selectedRange === null ||
         this.selectedRange === "" ||
@@ -280,35 +295,69 @@ export default {
       let maxNum = -1;
       // littlegreen - 传入最大值、最小值、间隔,获得区间列表
       function generateRangeArray(x1, x2, interval) {
+        // 确保输入为浮点数
         x1 = parseFloat(x1);
         x2 = parseFloat(x2);
         interval = parseFloat(interval);
+
         const result = [];
+
+        // 从最接近 x1 的更小的值开始
         let current = x1;
+        // console.log(current)
         while (current < x2) {
-          let next;
-          if (current == x1) {
-            current = Math.floor(current * 10) / 10;
-          }
-          next = parseFloat((current + interval).toFixed(2));
-          // 保留两位小数
+          let next = parseFloat((current + interval).toFixed(2));
+
+          // 保留两位小数,并添加区间到结果
           result.push({
-            name: `${current}-${next}`,
+            name: `${current.toFixed(2)}-${next.toFixed(2)}`,
             min: current,
             max: next,
           });
           current = next;
         }
-        // 最后一个区间
-        if (current <= x2) {
+
+        // 如果最后一个区间包含最大值,则加入
+        if (current < x2) {
           result.push({
-            name: `${current}-${x2}`,
+            name: `${current.toFixed(2)}-${x2.toFixed(2)}`,
             min: current,
             max: x2,
           });
         }
+
         return result;
       }
+      // function generateRangeArray(x1, x2, interval) {
+      //   x1 = parseFloat(x1);
+      //   x2 = parseFloat(x2);
+      //   interval = parseFloat(interval);
+      //   const result = [];
+      //   let current = x1 - (x2 - x1);
+      //   while (current < x2) {
+      //     let next;
+      //     if (current == x1) {
+      //       current = Math.floor(current * 10) / 10;
+      //     }
+      //     next = parseFloat((current + interval).toFixed(2));
+      //     // 保留两位小数
+      //     result.push({
+      //       name: `${current}-${next}`,
+      //       min: current,
+      //       max: next,
+      //     });
+      //     current = next;
+      //   }
+      //   // 最后一个区间
+      //   if (current <= x2) {
+      //     result.push({
+      //       name: `${current}-${x2}`,
+      //       min: current,
+      //       max: x2,
+      //     });
+      //   }
+      //   return result;
+      // }
       // 生成区间标签和频次
       const histogramData = [];
       let result = generateRangeArray(minVal, maxVal, 0.1);
@@ -318,29 +367,12 @@ export default {
         count += values.filter(
           (value) => value >= item.min && value < item.max
         ).length;
-        if (item.max === maxVal) {
+        // console.log(item.max, maxVal)
+        if (item.max == maxVal) {
           count += values.filter((value) => value === item.max).length;
         }
         histogramData.push({ name: item.name, value: count });
       });
-      // for (let i = 0; i < binCount; i++) {
-      //   const x0 = minVal + i * Number(this.selectedRange);
-      //   const x1 = Math.min(x0 + Number(this.selectedRange), maxVal).toFixed(2);
-
-      //   // const label = `${x0}-${x1}`;
-      //   // let count = 0;
-      //   // count += values.filter((value) => value >= x0 && value < x1).length;
-      //   // if (x1 === maxVal) {
-      //   //   count += values.filter((value) => value === maxVal).length;
-      //   // }
-
-      //   // if (count > 0) {
-      //   //   if (count > maxNum) {
-      //   //     maxNum = count;
-      //   //   }
-      //   //   histogramData.push({ name: label, value: count });
-      //   // }
-      // }
 
       const maxHistogramValue = Math.max(
         ...histogramData.map((item) => item.value)
@@ -350,6 +382,80 @@ export default {
         0
       );
 
+      //--------------------------正态分布----------------------------------
+      // 计算均值
+      const mean = values.reduce((acc, val) => acc + val, 0) / values.length;
+      // console.log(mean.toFixed(2),"mean")
+      // 计算标准差
+      const stdDev = Math.sqrt(
+        values.reduce((acc, val) => acc + Math.pow(val - mean, 2), 0) /
+          values.length
+      );
+
+      // 创建间隔为0.1的区间
+      const center = mean.toFixed(2)
+      const interval = 0.1;
+      let minLimit = Math.floor(Math.min(...values) * 10) / 10; // 向下取整到最近的0.1
+      let maxLimit = Math.ceil(Math.max(...values) * 10) / 10; // 向上取整到最近的0.1
+      console.log("中心", center,minLimit,maxLimit) 
+      if(center-minLimit != maxLimit-center){
+        minLimit = Math.floor(minLimit - (maxLimit-center - (center-minLimit)))
+      }
+      const intervals = [];
+      console.log(minLimit,maxLimit, interval)
+      // 乘以1000 是将小数变成整数去计算,小数计算会有误差
+      for (let i = minLimit * 1000 ; i <= maxLimit*1000 ; i += (interval*1000)) {
+        intervals.push(parseFloat((i/1000).toFixed(2)))
+      }
+      // 计算每个间隔的频次
+      const frequency = new Array(intervals.length - 1).fill(0); // 初始化频次数组
+
+      let intervalArr = intervals.slice(0,-1)
+      const intervalStrings = [];
+      for (let i = 0; i < intervalArr.length; i++) {
+          const start = intervalArr[i].toFixed(1); // 保留一位小数
+          const end = ((intervalArr[i]*1000 + interval*1000)/1000).toFixed(1); // 保留一位小数
+          intervalStrings.push({
+            name: `${start}-${end}`,
+            max: end,
+            min: start
+          }); // 构建区间字符串
+      }
+      console.log(intervals,intervalArr)
+      values.forEach((value) => {
+        for (let j = 0; j < intervalStrings.length - 1; j++) {
+          // console.log(value)
+          // 保证包含右边界
+          // console.log(intervals[j].min, intervals[j].max)
+          if (value >= intervalStrings[j].min && value < intervalStrings[j].max) {
+            // console.log(intervals[j],intervals[j + 1])
+            frequency[j]++;
+            break; // 找到对应区间后可以跳出循环
+          }
+        }
+      });
+
+      // 确保处理最大值等于maxLimit的情况
+      if (values.some((value) => value == maxLimit)) {
+        frequency[frequency.length - 1]++;
+      }
+
+      // 计算正态分布值
+      const normalDistributionValues = intervals
+        .slice(0, -1)
+        .map((intervalStart, index) => {
+          const intervalEnd = intervals[index + 1];
+          const midpoint = (intervalStart + intervalEnd) / 2; // 每个区间的中点
+          return (
+            (1 / (stdDev * Math.sqrt(2 * Math.PI))) *
+            Math.exp(-0.5 * Math.pow((midpoint - mean) / stdDev, 2))
+          );
+        });
+      // 输出结果
+      // console.log("Intervals:", intervals.slice(0, -1)); // 显示间隔
+      // console.log("Frequencies:", frequency);
+      // console.log("Normal Distribution Values:", normalDistributionValues);
+      //---------------------------------正态分布end---------------------------
       // const quadraticData = this.generateQuadraticData(binCount, maxHistogramValue, totalHistogramValue);
       // littlegreen - 去掉line和scatter,增加x轴拖动,根据检测区间修改柱状的颜色
       const option = {
@@ -375,7 +481,7 @@ export default {
             const xAxisLabel = params[0].axisValueLabel; // x轴的标签
             const yAxisLabel = params[0].seriesName;
             // 构建自定义的 tooltip 内容,包含年份
-            return `${xAxisLabel}<br> ${yAxisLabel}: ${value}`;
+            return `${xAxisLabel}</br> ${yAxisLabel}: ${value} `;
           },
         },
         legend: {
@@ -383,6 +489,7 @@ export default {
             `${this.selectedYear}年 ${
               this.keyToChinese[this.selectedDataKey]
             }企业数统计`,
+            "正态分布"
           ],
         },
         grid: {
@@ -394,18 +501,24 @@ export default {
         xAxis: {
           type: "category",
           name: "分布区间",
-          data: histogramData.map((item) => item.name),
+          // data: histogramData.map((item) => item.name),
+          data: intervalStrings.map(item=>item.name),
           axisLabel: {
             fontSize: 12,
             interval: 0,
             rotate: 20,
+            // padding: [0, 0, 0, -200]
           },
         },
-        yAxis: {
+        yAxis: [{
           name: "企业数",
           type: "value",
           minInterval: 1,
-        },
+        },{
+          name: '正态分布',
+          type: 'value'
+
+        }],
         series: [
           {
             name: `${this.selectedYear}年 ${
@@ -419,11 +532,17 @@ export default {
                 color: function (params) {
                   const value = params.dataIndex; // 获取当前柱子在数据中的索引
                   if (flag == 1) {
+                    let min = parseFloat(intervalStrings[value].min)*1000
+                    let max = parseFloat(intervalStrings[value].max)*1000
+                    const detectMin = parseFloat(that.detectMin)*1000
+                    const detectMax = parseFloat(that.detectMax)*1000
                     if (
-                      result[value].min >= that.detectMin &&
-                      result[value].max <= that.detectMax
+                      min >= detectMin &&
+                      max <= detectMax
                     ) {
                       return "#ffcc00"; // 变更颜色为黄色
+                    }else if(min == detectMax){
+                      return "#ffcc00";
                     }
                     return "rgba(245,0,0,0.6)";
                   }
@@ -432,59 +551,78 @@ export default {
                 },
               },
             },
-            data: histogramData.map((item) => item.value),
+            // data: histogramData.map((item) => item.value),
+            data: frequency,
             label: {
               show: false, // 将show属性设置为false,去掉柱子上的数字
             },
           },
-          // {
-          //   type: "scatter",
-          //   symbol: "circle",
-          //   symbolSize: 10,
-          //   data: histogramData.map((item, index) => [index, item.value]),
-          //   itemStyle: {
-          //     color: "red",
-          //   },
-          // },
-          // {
-          //   type: "line",
-          //   data: histogramData.map((item, index) => [index, item.value]),
-          //   lineStyle: {
-          //     color: "#1a7cc8",
-          //   },
-          //   symbol: "none",
-          // },
+          {
+            name:"正态分布",
+            yAxisIndex: 1,
+            type: "line",
+            data: normalDistributionValues,
+            lineStyle: {
+              color: "#1a7cc8",
+            },
+            symbol: "none",
+          },
         ],
       };
       this.isChartShow = true;
       this.chart.setOption(option);
       this.chart.on("click", function (param) {
-        if (
-          typeof param.dataIndex === "number" &&
+        // console.log(param.dataIndex, intervalStrings)
+        if(typeof param.dataIndex === "number" &&
           param.dataIndex >= 0 &&
-          param.dataIndex < result.length
-        ) {
-          let dataIndexValue = result[param.dataIndex];
-          const filteredArray = filteredData.filter((item) => {
-            const isMaxValEqual = result[1] === maxVal;
-            const lowerBoundCheck =
-              item[that.selectedDataKey] >= dataIndexValue.min;
-            const upperBoundCheck = isMaxValEqual
+          param.dataIndex < intervalStrings.length
+        ){
+          let dataIndexValue = intervalStrings[param.dataIndex];
+          const filteredArray = filteredData.filter((item)=>{
+            const isMaxValEqual = parseFloat(dataIndexValue.max) == parseFloat(maxVal);
+            const lowerBoundCheck = item[that.selectedDataKey] >= dataIndexValue.min;
+            const upperBoundCheck  = isMaxValEqual
               ? item[that.selectedDataKey] <= dataIndexValue.max
               : item[that.selectedDataKey] < dataIndexValue.max;
-
             return lowerBoundCheck && upperBoundCheck;
-          });
+          })
+          // console.log(filteredData,filteredArray,that.selectedDataKey)
           that.tableData = filteredArray.map((item) => {
             return {
               industryName: item.code,
               enterpriseId: item.enterpriseName,
               year: item.year,
               value: item[that.selectedDataKey],
-              level:"高"
+              level: item[that.keyToLevel[that.selectedDataKey]],
             };
           });
         }
+        // if (
+        //   typeof param.dataIndex === "number" &&
+        //   param.dataIndex >= 0 &&
+        //   param.dataIndex < intervalStrings.length
+        // ) {
+        //   let dataIndexValue = intervalStrings[param.dataIndex];
+        //   const filteredArray = filteredData.filter((item) => {
+        //     const isMaxValEqual = intervalStrings[1] === maxVal;
+        //     const lowerBoundCheck =
+        //       item[that.selectedDataKey] >= dataIndexValue.min;
+        //     const upperBoundCheck = isMaxValEqual
+        //       ? item[that.selectedDataKey] <= dataIndexValue.max
+        //       : item[that.selectedDataKey] < dataIndexValue.max;
+
+        //     return lowerBoundCheck && upperBoundCheck;
+        //   });
+        //   that.tableData = filteredArray.map((item) => {
+        //     return {
+        //       industryName: item.code,
+        //       enterpriseId: item.enterpriseName,
+        //       year: item.year,
+        //       value: item[that.selectedDataKey],
+        //       level: "高",
+        //     };
+        //   });
+        // }
         // const filteredArray = filteredData.filter((item) => {
         //     const isMaxValEqual = result[1] === maxVal;
         //     const lowerBoundCheck = item[that.selectedDataKey] >= dataIndexValue.min;

+ 153 - 73
src/views/index.vue

@@ -1,5 +1,5 @@
 <template>
-<!-- 首页 - littlegreen -->
+  <!-- 首页 - littlegreen -->
   <div :class="className" :style="{ height: '100%', width: width }">
     <el-row
       :gutter="20"
@@ -10,15 +10,25 @@
         <el-card>
           <div class="i-gq">
             <h3 class="i-title">政府与企业总投入</h3>
-            <el-dropdown >
-              <span class="el-dropdown-link" style="color: black;font-size: 16px;font-weight: bold;">
-                {{ selectYear }}
-                <i class="el-icon-arrow-down el-icon--right" style="font-size: 16px;font-weight: bold;"></i>
+            <el-dropdown>
+              <span
+                class="el-dropdown-link"
+                style="color: black; font-size: 16px; font-weight: bold"
+              >
+                {{ selectYearName }}
+                <i
+                  class="el-icon-arrow-down el-icon--right"
+                  style="font-size: 16px; font-weight: bold"
+                ></i>
                 <!-- <i class="el-icon-sort el-icon--right" style="font-size: 16px;font-weight: bold;transform:rotate(90deg)"></i> -->
               </span>
               <el-dropdown-menu slot="dropdown">
-                <el-dropdown-item v-for="(data, i) in yearDataList" :key="i" @click.native="handleDrop(data)">
-                  {{data.name}}
+                <el-dropdown-item
+                  v-for="(data, i) in yearDataList"
+                  :key="i"
+                  @click.native="handleDrop(data)"
+                >
+                  {{ data.name }}
                 </el-dropdown-item>
               </el-dropdown-menu>
             </el-dropdown>
@@ -27,27 +37,41 @@
             <el-col :span="6">
               <div>
                 <p class="i-name">土地/亩</p>
-                <p class="i-number">500</p>
+                <p class="i-number">
+                  {{ indexData.landArea ? indexData.landArea : "-" }}
+                </p>
               </div>
             </el-col>
             <el-col :span="6"
               ><div>
                 <p class="i-name">电力/万千瓦时</p>
-                <p class="i-number">4185</p>
+                <p class="i-number">
+                  {{
+                    indexData.powerConsumeSum ? indexData.powerConsumeSum : "-"
+                  }}
+                </p>
               </div></el-col
             >
             <el-col :span="6"
               ><div>
                 <p class="i-name">天然气/立方米</p>
-                <p class="i-number">33284</p>
+                <p class="i-number">
+                  {{
+                    indexData.energyConsumeSum
+                      ? indexData.energyConsumeSum
+                      : "-"
+                  }}
+                </p>
               </div></el-col
             >
             <el-col :span="6">
               <div>
                 <p class="i-name">研发经费/万元</p>
-                <p class="i-number">14299</p>
+                <p class="i-number">
+                  {{ indexData.fundingSum ? indexData.fundingSum : "-" }}
+                </p>
               </div>
-              </el-col>
+            </el-col>
           </el-row>
         </el-card>
       </el-col>
@@ -84,19 +108,33 @@
             <el-col :span="24"
               ><div class="i-out-box">
                 <p class="i-name">工业总产值/万元</p>
-                <p class="i-number">54252622</p>
+                <p class="i-number">
+                  {{
+                    indexData.totalIndustrialValueSum
+                      ? indexData.totalIndustrialValueSum
+                      : "-"
+                  }}
+                </p>
               </div></el-col
             >
             <el-col :span="24"
               ><div class="i-out-box">
                 <p class="i-name">应税收入/万元</p>
-                <p class="i-number">41857</p>
+                <p class="i-number">
+                  {{
+                    indexData.taxableIncomeSum
+                      ? indexData.taxableIncomeSum
+                      : "-"
+                  }}
+                </p>
               </div></el-col
             >
             <el-col :span="24"
               ><div class="i-out-box">
                 <p class="i-name">实缴税金/万元</p>
-                <p class="i-number">33651</p>
+                <p class="i-number">
+                  {{ indexData.paidTaxSum ? indexData.paidTaxSum : "-" }}
+                </p>
               </div></el-col
             >
           </el-row>
@@ -121,6 +159,7 @@
 <script>
 import * as echarts from "echarts";
 import resize from "./dashboard/mixins/resize";
+import { getBarData, getPieData, getIndexData } from "@/api/home";
 export default {
   mixins: [resize],
   props: {
@@ -140,24 +179,42 @@ export default {
   data() {
     return {
       chart: null,
+      chartData: [],
       piechart: null,
-      yearDataList:[
-        {
-          name: "总和"
-        },
+      pieChartData: [],
+      yearDataList: [
         {
-          name: "2023"
+          name: "总和",
+          key: 0,
         },
-        {
-          name: "2024"
-        }
       ],
-      selectYear: "总和"
+      selectYearName: "总和",
+      selectYear: 0,
+      indexData: {
+        createBy: null,
+        createTime: null,
+        updateBy: null,
+        updateTime: null,
+        remark: null,
+        id: null,
+        year: null,
+        landArea: null,
+        powerConsumeSum: null,
+        energyConsumeSum: null,
+        fundingSum: null,
+        employeeNumberSum: null,
+        profitSum: null,
+        enterpriseNumbers: null,
+        totalIndustrialValueSum: null,
+        taxableIncomeSum: null,
+        paidTaxSum: null,
+      },
     };
   },
   mounted() {
-    this.initChart();
-    this.initPieChart();
+    this.fetchData();
+    // this.initChart();
+    // this.initPieChart();
   },
   beforeDestroy() {
     if (this.chart) {
@@ -174,8 +231,8 @@ export default {
         this.chart.dispose();
       }
       this.chart = echarts.init(this.$refs.chart);
+      console.log(this.chartData);
       // 饼图
-      //
       this.chart.setOption(
         {
           tooltip: {
@@ -186,16 +243,16 @@ export default {
           },
           dataZoom: [
             {
-              type: 'slider',
+              type: "slider",
               yAxisIndex: 0,
               left: 0,
-              start: 80,
-              end: 100
+              start: 95,
+              end: 100,
             },
             {
-              type: 'inside',
-              yAxisIndex: 0
-            }
+              type: "inside",
+              yAxisIndex: 0,
+            },
           ],
           legend: {},
           grid: {
@@ -212,29 +269,13 @@ export default {
           yAxis: {
             type: "category",
             // inverse: true,
-            data: [
-              "文教、工美、体育和娱乐用品制造业",
-              "文教、工美、体育和娱乐用品制造12",
-              "文教、工美、体育和娱乐用品制造业67",
-              "文教、工美、体育和娱乐用品制造业89",
-              "文教、工美、体育和娱乐用品制造业90",
-              "文教、工美、体育和娱乐用品制造业23",
-              "文教、工美、体育和娱乐用品制造业21",
-              "文教、工美、体育和娱乐用品制造业22",
-              "文教、工美、体育和娱乐用品制造业334",
-              "文教、工美、体育和娱乐用品制造业77",
-              "文教、工美、体育和娱乐用品制造业78",
-              "文教、工美、体育和娱乐用品制造业79",
-              "文教、工美、体育和娱乐用品制造业71",
-              "文教、工美、体育和娱乐用品制造业72",
-              "文教、工美、体育和娱乐用品制造业73",
-            ],
+            data: this.chartData.map((item) => item.industryName),
           },
           series: [
             {
               // realtimeSort: true,
               type: "bar",
-              data: [60, 50, 40, 30, 20, 10, 32, 45, 78, 99,33,44,55,66,77],
+              data: this.chartData.map((item) => item.number),
               label: {
                 show: true,
                 formatter: "{c}",
@@ -333,6 +374,13 @@ export default {
       if (this.piechart) {
         this.piechart.dispose();
       }
+      // console.log(this.pieChartData);
+      let chartArray = this.pieChartData.map((item) => {
+        return {
+          value: item.number,
+          name: item.industryName,
+        };
+      });
       this.piechart = echarts.init(this.$refs.piechart);
       this.piechart.setOption({
         tooltip: {
@@ -352,36 +400,68 @@ export default {
             label: {
               show: true,
             },
-            // emphasis: {
-            //   label: {
-            //     show: false,
-            //     fontSize: 40,
-            //     fontWeight: "bold",
-            //   },
-            // },
             labelLine: {
               show: true,
             },
-            data: [
-              { value: 1048, name: "文教、工美、体育和娱乐用品制造业" },
-              { value: 735, name: "皮革、毛皮、羽毛及其制品和制鞋业" },
-              { value: 580, name: "电气机械和器材制造业" },
-              { value: 484, name: "印刷和记录媒介复制业" },
-              { value: 300, name: "电气机械和器材制造业" },
-              { value: 300, name: "皮革、毛皮、羽毛及其制品和制鞋业" },
-              { value: 300, name: "金属制品业" },
-              { value: 300, name: "农副食品加工业" },
-              { value: 300, name: "酒、饮料和精制茶制造业" },
-              { value: 300, name: "其他" },
-            ],
+            data: chartArray,
           },
         ],
       });
     },
     // 切换年份
-    handleDrop(e){
-      this.selectYear = e?.name
-    }
+    handleDrop(e) {
+      this.selectYear = e?.key;
+      this.selectYearName = e?.name;
+      this.updateData(this.selectYear);
+    },
+    fetchData() {
+      getBarData()
+        .then((res) => {
+          if (res && res?.rows) {
+            this.chartData = res.rows;
+            this.initChart();
+          }
+        })
+        .catch((error) => {
+          console.error("Error fetching data:", error);
+        });
+      getPieData()
+        .then((res) => {
+          if (res && res?.rows) {
+            this.pieChartData = res.rows;
+            this.initPieChart();
+          }
+        })
+        .catch((error) => {
+          console.error("Error fetching data:", error);
+        });
+      this.updateData(this.selectYear);
+    },
+    updateData(year) {
+      const that = this;
+      getIndexData({
+        year: year,
+      })
+        .then((res) => {
+          that.indexData = res?.rows[0];
+          let arr = res?.rows[0].years.map((item) => {
+            return {
+              name: item,
+              key: item,
+            };
+          });
+          that.yearDataList = [
+            {
+              name: "总和",
+              key: 0,
+            },
+            ...arr,
+          ];
+        })
+        .catch((error) => {
+          console.error("Error fetching data:", error);
+        });
+    },
   },
 };
 </script>

+ 1 - 1
src/views/predict/predict/index.vue

@@ -389,7 +389,7 @@ export default {
     },
     /** 导出按钮操作 */
     handleExport() {
-      this.download('predict/predict/export', {
+      this.download('/predicttotal/predicttotal/export', {
         ...this.queryParams
       }, `predict_${new Date().getTime()}.xlsx`)
     }  ,