<template>
  <div style="background-color:#f0f2f5;padding:12px;">
    <a-spin :spinning="loading">
      <a-row :gutter="24">
        <!-- 左侧数据统计 -->
        <a-col :xl="10" :lg="10" :md="10" :sm="24" :xs="24">
          <a-card :title="$t('functional-analysis.top-btn.statistics')" style="margin-right: -12px;">
            <template slot="extra">
              <a-form layout="inline" style="margin-right: -24px;">
                <a-form-item :label="$t('functional-analysis.top-btn.node-type')">
                  <a-select @change="nodeTypeChange" :value="nodeType" style="width: 120px;">
                    <a-select-option v-for="(item, index) in nodeTypeDict" :key="index" :value="item.value">
                      {{ item.name }}
                    </a-select-option>
                  </a-select>
                </a-form-item>
              </a-form>
            </template>
            <div id="nodes-pie-chart" :style="{ height: nodesChartHeight }" />
            <div id="nodes-number-chart" :style="{ height: nodesChartHeight }" />
          </a-card>
        </a-col>
        <!-- 右侧四个饼图 -->
        <a-col :xl="14" :lg="14" :md="14" :sm="24" :xs="24">
          <a-row :gutter="24">
            <!-- 风险项数量 -->
            <a-col :xl="12" :lg="12" :md="12" :sm="24" :xs="24">
              <a-card :title="$t('summary-Archive.statistical-analysis.number-of-risk-items')">
                <template slot="extra">
                  <a-form layout="inline" style="margin-right: -24px;">
                    <a-form-item :label="$t('functional-analysis.top-btn.risk.type')">
                      <a-select @change="riskTypeChange" :value="riskType" style="width: 120px;">
                        <a-select-option v-for="(item, index) in riskTypeDict" :key="index" :value="item.value">
                          {{ item.name }}
                        </a-select-option>
                      </a-select>
                    </a-form-item>
                  </a-form>
                </template>
                <div id="risk-items-chart" :style="{ height: pieChartHeight }"></div>
              </a-card>
            </a-col>
            <!-- 优化措施状态报表 -->
            <a-col :xl="12" :lg="12" :md="12" :sm="24" :xs="24">
              <a-card :title="$t('summary-Archive.statistical-analysis.project-optimization-measures')"
                      style="margin:0px 0px 12px -12px;">
                <div id="opt-measure-chart" :style="{ height: pieChartHeight }"></div>
              </a-card>
            </a-col>
            <!-- 探测清单 -->
            <a-col :xl="12" :lg="12" :md="12" :sm="24" :xs="24">
              <a-card :title="$t('summary-Archive.statistical-analysis.probe-list')">
                <div id="probe-list-chart" :style="{ height: pieChartHeight }"></div>
              </a-card>
            </a-col>
            <!-- 失效风险状况 -->
            <a-col :xl="12" :lg="12" :md="12" :sm="24" :xs="24">
              <a-card :title="$t('functional-analysis.top-btn.fault-risk-status')" style="margin:0px 0px 12px -12px;">
                <div id="fault-risk-status-chart" :style="{ height: pieChartHeight }"></div>
              </a-card>
            </a-col>
            <!-- 历史问题分析 -->
            <!-- <a-col :xl="12" :lg="12" :md="12" :sm="24" :xs="24">
              <a-card
                :title="$t('summary-Archive.statistical-analysis.historical-problem-analysis')"
                style="margin:0px 0px 12px -12px;"
                >
                <div id="history-problem-chart" :style="{ height: pieChartHeight }"></div>
              </a-card>
            </a-col> -->
          </a-row>
        </a-col>
      </a-row>
    </a-spin>
  </div>
</template>
<script>

import * as echarts from 'echarts';

export default {
  components: {},
  data() {
    return {
      loading: true,
      fmeaId: this.$com.fmeaId || this.$route.query.fmeaId,
      // 节点类型
      nodeType: "01",
      // 节点类型字典
      nodeTypeDict: [
        { value: "01", name: this.$t('global-dict.structure') },
        { value: "02", name: this.$t('global-dict.function') },
        { value: "04", name: this.$t('global-dict.product-features') },
        { value: "06", name: this.$t('global-dict.failure') },
        { value: "14", name: this.$t('global-dict.current-measures') },
        { value: "07", name: this.$t('global-dict.optimization-measures') },
      ],
      // 风险类型
      riskType: "01",
      // 风险类型字典
      riskTypeDict: [
        { value: "01", name: this.$t('global-dict.all') },
        { value: "14", name: this.$t('global-dict.current-measures') },
        { value: "07", name: this.$t('global-dict.optimization-measures') },
      ],
      // 历史版本部分
      historyData: "",
      // 节点数量统计数据
      nodesNumberData: [],
      // 风险项数量
      riskData: [],
      // 项目优化措施状态
      optMeasureData: [],
      // 探测清单
      probeListData: [],
      // 历史问题分析
      historyProblemData: [],
      // 失效风险状况
      faultRiskStatusData: {
        before: [],
        after: []
      },
      nodesPieChart: undefined,
      nodesNumberChart: undefined,
      riskItemsChart: undefined,
      optMeasureChart: undefined,
      probeListChart: undefined,
      // historyProblemChart: undefined,
      projectRiskChart: undefined,
      nodesChartHeight: (window.innerHeight - 230) / 2 + 'px',
      pieChartHeight: (window.innerHeight - 348) / 2 + 'px'
    };
  },
  mounted() {
    this.$nextTick(() => {
      this.initPageDatas();
    });
    window.onresize = () => {
      this.nodesChartHeight = (window.innerHeight - 230) / 2 + 'px'
      this.pieChartHeight = (window.innerHeight - 348) / 2 + 'px'
      this.nodesNumberChart.resize();
      this.nodesPieChart.resize();
      this.riskItemsChart.resize();
      this.optMeasureChart.resize();
      this.probeListChart.resize();
      // this.historyProblemChart.resize();
      this.projectRiskChart.resize();
    };
  },
  methods: {
    delCookie(name) {
      //删除isLook，必须加;path=/，不然没权限删除其他页面储存的isLook
      document.cookie = name + "=" + escape("") + ";expires=-1" + ";path=/";
    },
    setCookie(name, value) {
      //必须加;path=/，不然其他页面读取不到
      if (value) {
        var days = 1; //定义一天
        var exp = new Date();
        exp.setTime(exp.getTime() + days * 24 * 60 * 60 * 1000);
        // 写入Cookie, toGMTString将时间转换成字符串
        document.cookie =
            name +
            "=" +
            escape(value) +
            ";expires=" +
            exp.toGMTString +
            ";path=/";
      }
    },
    // 加载页面数据
    async initPageDatas() {
      var _that = this
			// 风险数量更新到风险分析统计表中
			await this.$api.riskReportAnalysis({
				fmeaId: _that.$store.getters.fmeaId,
				rfmeaId: _that.$store.getters.rfmeaId,
			}).then(res => {
				if (res.flag) {
					// 更新成功
				} else {
					_that.$message.error(res.message, 1);
				}
			})
      // 数据统计-节点数量统计
      await this.$api.getStatistics({
        fmeaId: _that.$store.getters.rfmeaId,
        // struId: '' 可以不传
      }).then(res => {
        if (res.flag) {
          _that.nodesNumberData = res.data;
        } else {
          _that.$message.error(res.message, 1);
        }
      });
      // 风险项统计
      await this.$api.getRiskStatus({
        fmeaId: _that.$store.getters.rfmeaId,
      }).then(res => {
        if (res.flag) {
          _that.riskData = res.data;
        } else {
          _that.$message.error(res.message, 1);
        }
      })
      // 项目优化措施状态
      await this.$api.getOptMeasureReport({
        fmeaId: _that.fmeaId
      }).then((response) => {
        if (response && response.data && response.flag) {
          let complateData= response.data.finish ? response.data.finish : 0;
          let abandonData= response.data.giveUp ? response.data.giveUp : 0;
          let processedData= response.data.notDo ? response.data.notDo : 0;
          let decidedData= response.data.waitDecide ? response.data.waitDecide : 0;
          let waitExcuteData= response.data.waitExcute ? response.data.waitExcute : undefined ;
          _that.optMeasureData = [
            {
              name: _that.$t('global-dict.complete'),
              value: (complateData || abandonData || processedData || decidedData || waitExcuteData) ? (complateData ? complateData : ''):complateData,
              itemStyle: { color: '#91cc75' }
            },
            {
              name: _that.$t('global-dict.abandon'),
              value: (complateData || abandonData || processedData || decidedData || waitExcuteData) ? (abandonData ? abandonData : ''):abandonData,
              itemStyle: { color: '#bbb' }
            },
            {
              name: _that.$t('global-dict.un-processed'),
              value: (complateData || abandonData || processedData || decidedData || waitExcuteData) ? (processedData ? processedData : ''):processedData,
              itemStyle: { color: '#ee6666' }
            },
            {
              name: _that.$t('global-dict.to-be-decided'),
              value: (complateData || abandonData || processedData || decidedData || waitExcuteData) ? (decidedData ? decidedData : ''):decidedData,
              itemStyle: { color: '#ffdc60' }
            },
            {
              name: _that.$t('global-dict.to-be-implemented'),
              value: (complateData || abandonData || processedData || decidedData || waitExcuteData) ? (waitExcuteData ? waitExcuteData : ''):waitExcuteData,
              itemStyle: { color: '#73c0de' }
            },
          ]
        }
      });
      // 探测清单
      await this.$api.getProbeReport({
        fmeaId: _that.fmeaId
      }).then((response) => {
        if (response && response.data && response.flag) {
          let complateData= response.data.finish ? response.data.finish : 0;
          let abandonData= response.data.giveUp ? response.data.giveUp : 0;
          let processedData= response.data.notDo ? response.data.notDo : 0;
          let decidedData= response.data.waitDecide ? response.data.waitDecide : 0;
          let waitExcuteData= response.data.waitExcute ? response.data.waitExcute : 0;
          _that.probeListData = [
            {
              name: _that.$t('global-dict.complete'),
              value: (complateData || abandonData || processedData || decidedData || waitExcuteData) ? (complateData ? complateData : ''):complateData,
              itemStyle: { color: '#91cc75' }
            },
            {
              name: _that.$t('global-dict.abandon'),
              value: (complateData || abandonData || processedData || decidedData || waitExcuteData) ? (abandonData ? abandonData : ''):abandonData,
              itemStyle: { color: '#bbb' }
            },
            {
              name: _that.$t('global-dict.un-processed'),
              value: (complateData || abandonData || processedData || decidedData || waitExcuteData) ? (processedData ? processedData : ''):processedData,
              itemStyle: { color: '#ee6666' }
            },
            {
              name: _that.$t('global-dict.to-be-decided'),
              value: (complateData || abandonData || processedData || decidedData || waitExcuteData) ? (decidedData ? decidedData : ''):decidedData,
              itemStyle: { color: '#ffdc60' }
            },
            {
              name: _that.$t('global-dict.to-be-implemented'),
              value: (complateData || abandonData || processedData || decidedData || waitExcuteData) ? (waitExcuteData ? waitExcuteData : ''):waitExcuteData,
              itemStyle: { color: '#73c0de' }
            },
          ]
        }
      });
      this.loading = false;
      // 历史问题分析
      // await this.$api.getHistoryReport({
      //   fmeaId: _that.fmeaId
      // }).then((response) => {
      //   if (response && response.data && response.flag) {
      //     _that.historyProblemData = [
      //       {
      //         name: _that.$t('global-dict.associated'),
      //         value: response.data.resolved ? response.data.resolved : 0,
      //         itemStyle: { color: '#91cc75' }
      //       },
      //       {
      //         name: _that.$t('global-dict.not-associated'),
      //         value: response.data.unResolved,
      //         itemStyle: { color: '#bbb' }
      //       }
      //     ]
      //   }
      // });
      // 失效风险状况
      await this.$api.riskReportSearch({
        fmeaId: _that.fmeaId
      }).then(response => {
        if (response && response.data && response.flag) {
          if (response.data.riskAnalysisData) {
            _that.faultRiskStatusData = {
              before: [
                {
                  value: response.data.riskAnalysisData.beforeOptH,
                  name: 'AP=H',
                  itemStyle: { color: '#ee6666' }
                },
                {
                  value: response.data.riskAnalysisData.beforeOptM,
                  name: 'AP=M',
                  itemStyle: { color: '#ffdc60' }
                },
                {
                  value: response.data.riskAnalysisData.beforeOptL,
                  name: 'AP=L',
                  itemStyle: { color: '#91cc75' }
                }
              ],
              after: [
                {
                  value: response.data.riskAnalysisData.afterOptH,
                  name: 'AP=H',
                  itemStyle: { color: '#ee6666' }
                },
                {
                  value: response.data.riskAnalysisData.afterOptM,
                  name: 'AP=M',
                  itemStyle: { color: '#ffdc60' }
                },
                {
                  value: response.data.riskAnalysisData.afterOptL,
                  name: 'AP=L',
                  itemStyle: { color: '#91cc75' }
                }
              ]
            }
          }
        }
      });
      this.nodeTypeChange(this.nodeType);
      this.riskTypeChange(this.riskType);
      this.initThreeCharts();
      this.initFaultRiskStatusChart();
    },
    // 数据统计-节点类型切换
    nodeTypeChange(val) {
      this.nodeType = val;
      this.initNodesPieChart(val);
      this.initNodesNumberChart();
    },
    // 风险项数量-措施风险类型切换
    riskTypeChange(val) {
      this.riskType = val;
      this.initRiskNmberChart(val);
    },
    // 数据统计-数量分布饼图
    initNodesPieChart(val) {
      let obj = {};
      switch (val) {
        case '01': // 结构
          obj = {
            "rightSubtext": this.$t('functional-analysis.top-btn.structure-number-distribution'),
            "rightName1": this.$t('functional-analysis.top-btn.number-of-non-bottom-level-items'),
            "rightValue1": this.nodesNumberData.structureVo.nonBottomQuantity !== null ? this.nodesNumberData.structureVo.nonBottomQuantity : 0,
            "rightName2": this.$t('functional-analysis.top-btn.number-of-bottom-level-items'),
            "rightValue2": this.nodesNumberData.structureVo.bottomQuantity !== null ? this.nodesNumberData.structureVo.bottomQuantity :0
          };
          break;
        case '02': // 功能
          obj = {
            "rightSubtext": this.$t('functional-analysis.top-btn.function-number-distribution'),
            "rightName1": this.$t('functional-analysis.top-btn.number-of-non-bottom-level-functions'),
            "rightValue1": this.nodesNumberData.functionVo.nonBottomQuantity !== null ? this.nodesNumberData.functionVo.nonBottomQuantity : 0,
            "rightName2": this.$t('functional-analysis.top-btn.number-of-bottom-level-functions'),
            "rightValue2": this.nodesNumberData.functionVo.bottomQuantity !== null ? this.nodesNumberData.functionVo.bottomQuantity :0
          };
          break;
        case '04': // 产品特性
          obj = {
            "rightSubtext": this.$t('functional-analysis.top-btn.product-feature-quantity-distribution'),
            "rightName1": this.$t('functional-analysis.top-btn.total-non-bottom-level-product-characteristics'),
            "rightValue1": this.nodesNumberData.productFeatureVo.nonBottomQuantity !== null ? this.nodesNumberData.productFeatureVo.nonBottomQuantity : 0,
            "rightName2": this.$t('functional-analysis.top-btn.number-of-bottom-level-product-characteristics'),
            "rightValue2": this.nodesNumberData.productFeatureVo.bottomQuantity !== null ? this.nodesNumberData.productFeatureVo.bottomQuantity : 0
          };
          break;
        case '06': // 失效
          obj = {
            "rightSubtext": this.$t('functional-analysis.top-btn.number-of-failures-distribution'),
            "rightName1": this.$t('functional-analysis.top-btn.number-of-non-bottom-level-failures'),
            "rightValue1": this.nodesNumberData.failureVo.nonBottomQuantity !== null ? this.nodesNumberData.failureVo.nonBottomQuantity : 0,
            "rightName2": this.$t('functional-analysis.top-btn.number-of-bottom-level-failures'),
            "rightValue2": this.nodesNumberData.failureVo.bottomQuantity !== null  ? this.nodesNumberData.failureVo.bottomQuantity : 0
          };
          break;
        case '14': // 当前措施
          obj = {
            "rightSubtext": this.$t('functional-analysis.top-btn.current-measure-distribution'),
            "rightName1": this.$t('functional-analysis.top-btn.number-of-preventive-measures'),
            "rightValue1": this.nodesNumberData.currentMeasuresVo.nonBottomQuantity !== null ? this.nodesNumberData.currentMeasuresVo.nonBottomQuantity : 0,
            "rightName2": this.$t('functional-analysis.top-btn.number-of-detection-measures'),
            "rightValue2": this.nodesNumberData.currentMeasuresVo.bottomQuantity !== null ? this.nodesNumberData.currentMeasuresVo.bottomQuantity :0
          };
          break;
        case '07': // 优化措施
          obj = {
            "rightSubtext": this.$t('functional-analysis.top-btn.distribution-of-optimization-measures'),
            "rightName1": this.$t('functional-analysis.top-btn.number-of-preventive-measures'),
            "rightValue1": this.nodesNumberData.optimizationMeasuresVo.nonBottomQuantity !== null ? this.nodesNumberData.optimizationMeasuresVo.nonBottomQuantity : 0,
            "rightName2": this.$t('functional-analysis.top-btn.number-of-detection-measures'),
            "rightValue2": this.nodesNumberData.optimizationMeasuresVo.bottomQuantity !== null ? this.nodesNumberData.optimizationMeasuresVo.bottomQuantity : 0
          };
          break;
        default:
          obj = {
            "rightSubtext": this.$t('functional-analysis.top-btn.structure-number-distribution'),
            "rightName1": this.$t('functional-analysis.top-btn.number-of-non-bottom-level-items'),
            "rightValue1": this.nodesNumberData.structureVo.nonBottomQuantity !== null ? this.nodesNumberData.structureVo.nonBottomQuantity : 0,
            "rightName2": this.$t('functional-analysis.top-btn.number-of-bottom-level-items'),
            "rightValue2": this.nodesNumberData.structureVo.bottomQuantity !== null ? this.nodesNumberData.structureVo.bottomQuantity : 0
          };
      }
      let option = {
        tooltip: {
          trigger: 'item'
        },
        title: [
          {
            subtext: obj.rightSubtext,
            left: '50%',
            textAlign: 'center',
            subtextStyle: {
              fontSize: 15,
              fontWeight: 'normal'
            }
          },
        ],
        series: [
          {
            type: 'pie',
            radius: ['30%', '60%'],
            label: {
              normal: {
                show: true,
                position: 'inner',
                textStyle: {
                  fontWeight: 400,
                  fontSize: 16,
                  color: '#fff'
                },
                formatter: '{c}'
              }
            },
            data: [
              { value: (obj.rightValue1 || obj.rightValue2) ? (obj.rightValue1 ? obj.rightValue1 : ''):obj.rightValue1, name: obj.rightName1 },
              { value: (obj.rightValue1 || obj.rightValue2) ? (obj.rightValue2 ? obj.rightValue2 : ''):obj.rightValue2, name: obj.rightName2 }
            ]
          }
        ]
      };
      this.nodesPieChart = echarts.init(document.getElementById('nodes-pie-chart'));
      // 使用刚指定的配置项和数据显示图表。
      this.nodesPieChart.setOption(option);
    },
    // 数据统计-数量分布柱状图
    initNodesNumberChart() {
      let option = {
        grid: {
          left: '8%',
          right: '5%',
          top: '5%',
          bottom: '10%',
        },
        xAxis: {
          type: 'category',
          data: [
            {
              value: this.$t('global-dict.structure'),
              textStyle: {
                overflow: 'truncate',
                ellipsis: '...'
              }
            },
            {
              value: this.$t('global-dict.function'),
              textStyle: {
                overflow: 'truncate',
                ellipsis: '...'
              }
            },
            {
              value: this.$t('global-dict.product-features'),
              textStyle: {
                overflow: 'truncate',
                ellipsis: '...'
              }
            },
            {
              value: this.$t('global-dict.failure'),
              textStyle: {
                overflow: 'truncate',
                ellipsis: '...'
              }
            },
            {
              value: this.$t('global-dict.current-measures'),
              textStyle: {
                overflow: 'truncate',
                ellipsis: '...'
              }
            },
            {
              value: this.$t('global-dict.optimization-measures'),
              textStyle: {
                overflow: 'truncate',
                ellipsis: '...'
              }
            }
          ],
        },
        yAxis: {
          type: 'value'
        },
        series: [
          {
            label: {
              show: true,
              position: 'top',
              valueAnimation: true
            },
            data: [
              {
                value: this.nodesNumberData.structureVo.total,
                itemStyle: {
                  color: 'black'
                }
              },
              {
                value: this.nodesNumberData.functionVo.total,
                itemStyle: {
                  color: 'green'
                }
              },
              {
                value: this.nodesNumberData.productFeatureVo.total,
                itemStyle: {
                  color: 'blue'
                }
              },
              {
                value: this.nodesNumberData.failureVo.total,
                itemStyle: {
                  color: 'red'
                }
              },
              {
                value: this.nodesNumberData.currentMeasuresVo.total,
                itemStyle: {
                  color: '#aaa'
                }
              },
              {
                value: this.nodesNumberData.optimizationMeasuresVo.total,
                itemStyle: {
                  color: '#ccc'
                }
              }
            ],
            type: 'bar',
            showBackground: true,
            backgroundStyle: {
              color: 'rgba(180, 180, 180, 0.2)'
            }
          }
        ],
        tooltip: {
          formatter: function (params) {
            return params.name + ':' + params.data.value;
          }
        }
      }
      this.nodesNumberChart = echarts.init(document.getElementById('nodes-number-chart'));
      this.nodesNumberChart.setOption(option);
    },
    // 风险数量-饼图
    initRiskNmberChart(val) {
      let _that = this;
      let highValue = 0;
      let mediumValue = 0;
      let lowValue = 0;
      if (val === '01') {
        highValue = this.riskData.allVo.highQuantity !== null ? this.riskData.allVo.highQuantity : 0;
        mediumValue = this.riskData.allVo.mediumQuantity !== null ? this.riskData.allVo.mediumQuantity : 0;
        lowValue = this.riskData.allVo.lowQuantity !== null ? this.riskData.allVo.lowQuantity : 0;
      } else if (val === '14') {
        highValue = this.riskData.currentVo.highQuantity !== null ? this.riskData.currentVo.highQuantity : 0;
        mediumValue = this.riskData.currentVo.mediumQuantity !== null ? this.riskData.currentVo.mediumQuantity : 0;
        lowValue = this.riskData.currentVo.lowQuantity !== null ? this.riskData.currentVo.lowQuantity : 0;
      } else {
        highValue = this.riskData.optimizeVo.highQuantity !== null ? this.riskData.optimizeVo.highQuantity : 0;
        mediumValue = this.riskData.optimizeVo.mediumQuantity !== null ? this.riskData.optimizeVo.mediumQuantity : 0;
        lowValue = this.riskData.optimizeVo.lowQuantity !== null ? this.riskData.optimizeVo.lowQuantity : 0;
      }
      let option = {
        toolbox: {
          feature: {
            saveAsImage: {
              pixelRatio: 2,
              title:this.$t('global-dict.Save-as-Image')
            }
          }
        },
        legend: {
          bottom: '5%',
          left: 'center'
        },
        tooltip: {
          trigger: 'item'
        },
        title: [
          {
            left: 'center',
            top: '10%',
            textAlign: 'center',
            subtextStyle: {
              fontSize: 15,
              fontWeight: 'normal'
            }
          },
        ],
        series: {
          type: 'pie',
          radius: ['20%', '50%'],
          label: {
            normal: {
              show: true,
              position: 'inner',
              textStyle: {
                fontWeight: 400,
                fontSize: 16,
                color: '#fff'
              },
              formatter: '{c}'
            }
          },
          data: [
            {
              name: _that.$t('global-dict.high-risk'),
              value: (highValue || mediumValue || lowValue) ? (highValue ? highValue :''):highValue,
              itemStyle: { color: '#ee6666' }
            },
            {
              name: _that.$t('global-dict.medium-risk'),
              value: (highValue || mediumValue || lowValue) ? (mediumValue ? mediumValue : ''):mediumValue,
              itemStyle: { color: '#ffdc60' }
            },
            {
              name: _that.$t('global-dict.low-risk'),
              value: (highValue || mediumValue || lowValue) ? (lowValue ? lowValue : ''):lowValue,
              itemStyle: { color: '#91cc75' }
            },
          ]
        }
      }
      this.riskItemsChart = echarts.init(document.getElementById('risk-items-chart'));
      this.riskItemsChart.setOption(option);
    },
    // 项目优化、探测清单、历史问题-饼图
    initThreeCharts() {
      this.optMeasureChart = echarts.init(document.getElementById('opt-measure-chart'));
      this.probeListChart = echarts.init(document.getElementById('probe-list-chart'));
      // this.historyProblemChart = echarts.init(document.getElementById('history-problem-chart'));
      let nodesNumberData = [this.optMeasureData, this.probeListData];
      let option = [];
      for (let i = 0; i < nodesNumberData.length; i++) {
        option.push(
            {
              toolbox: {
                feature: {
                  saveAsImage: {
                    pixelRatio: 2,
                    title:this.$t('global-dict.Save-as-Image')
                  }
                }
              },
              legend: {
                bottom: '5%',
                left: 'center'
              },
              tooltip: {
                trigger: 'item'
              },
              title: [
                {
                  left: 'center',
                  top: '10%',
                  textAlign: 'center',
                  subtextStyle: {
                    fontSize: 15,
                    fontWeight: 'normal'
                  }
                },
              ],
              series: {
                type: 'pie',
                radius: ['20%', '50%'],
                label: {
                  normal: {
                    show: true,
                    position: 'inner',
                    textStyle: {
                      fontWeight: 400,
                      fontSize: 16,
                      color: '#fff'
                    },
                    formatter: '{c}'
                  }
                },
                data: nodesNumberData[i]
              }
            });
      }
      this.optMeasureChart.setOption(option[0]);
      this.probeListChart.setOption(option[1]);
      // this.historyProblemChart.setOption(option[2]);
    },
    // 失效风险状况分析
    initFaultRiskStatusChart() {
      let option = {
        toolbox: {
          feature: {
            saveAsImage: {
              pixelRatio: 2,
              title:this.$t('global-dict.Save-as-Image')
            }
          }
        },
        legend: {
          bottom: '5%',
          left: 'center'
        },
        graphic: [
          {
            type: 'text',
            top: 'center',
            left: '22%',
            style: {
              text: this.$t('functional-analysis.top-btn.before-optimize'),
            }
          },
          {
            type: 'text',
            top: 'center',
            left: '65%',
            style: {
              text: this.$t('functional-analysis.top-btn.after-optimize'),
            }
          }
        ],
        series: [
          {
            name: this.$t('functional-analysis.top-btn.before-optimize'),
            type: 'pie',
            center: ['25%', '50%'],
            label: { // 文本标签
              show: true,
              position: 'outside',
              formatter: '{b}:{c}'
            },
            avoidLabelOverlap: true, // 防止标签重叠
            radius: ['20%', '50%'],
            emphasis: {
              label: {
                show: true,
                fontSize: 16,
                fontWeight: 'bold'
              }
            },
            data: this.faultRiskStatusData.before
          },
          {
            name: this.$t('functional-analysis.top-btn.after-optimize'),
            type: 'pie',
            center: ['68%', '50%'],
            label: { // 文本标签
              show: true,
              position: 'outside',
              formatter: '{b}:{c}'
            },
            radius: ['20%', '50%'],
            avoidLabelOverlap: true, // 防止标签重叠
            emphasis: {
              label: {
                show: true,
                fontSize: 16,
                fontWeight: 'bold'
              }
            },
            data: this.faultRiskStatusData.after
          }
        ]
      };
      this.projectRiskChart = echarts.init(document.getElementById('fault-risk-status-chart'));
      this.projectRiskChart.setOption(option);
    }
  }
};
</script>
<style lang="less" scoped>
/deep/ .ant-card-extra {
  padding: 0px 0;
}
</style>
