fuliqi
2024-12-25 301532b5c1cad2c1d45080bfef86579b20486bf5
src/views/home/work-order/index.vue
@@ -49,6 +49,9 @@
  },
  methods: {
    initChart() {
      // 对 complete 对象的键进行排序
      const sortedKeys  = Object.keys(this.acitveData.complete)
          .sort(); // 按照字符串的字典序对键进行排序
      const option = {
        legend: {
          right: 'right',
@@ -86,13 +89,17 @@
        tooltip: {},
        xAxis: {
          type: 'category',
          data: Object.keys(this.acitveData.complete),
          data: sortedKeys,
          axisLabel: {
            interval: 0  // 强制显示所有标签
          },
          sortSeriesData: false
        },
        yAxis: {},
        series: [
          {
            name: '完成工单数',
            data: Object.entries(this.acitveData.complete).map(([key, value]) => value),
            data: sortedKeys.map(key => this.acitveData.complete[key]),
            type: 'line',
            itemStyle: {
              color: 'rgba(62, 144, 247, 1)'
@@ -100,7 +107,7 @@
          },
          {
            name: '待完成工单数',
            data: Object.entries(this.acitveData.waiting).map(([key, value]) => value),
            data: sortedKeys.map(key => this.acitveData.waiting[key]),
            type: 'line',
            itemStyle: {
              color: 'rgba(85, 192, 191, 1)'
@@ -108,7 +115,7 @@
          },
          {
            name: '待审批工单数',
            data: Object.entries(this.acitveData.pending).map(([key, value]) => value),
            data: sortedKeys.map(key => this.acitveData.pending[key]),
            type: 'line',
            itemStyle: {
              color: 'rgba(255, 165, 0, 1)'
@@ -131,6 +138,7 @@
            pending: {}
          }
        }
        lineChart = echarts.init(this.$refs.chartContent);
        this.initChart();
        this.observe();