ZhangXianQiang
2024-04-11 6817c96db53ac16f5d5eca72b73230d898f32126
src/views/screen/components/screen-data/index.vue
New file
@@ -0,0 +1,177 @@
<template>
  <div class="data-container">
    <wrapper-title :title="'工单数据'" :path="'/work-order-center/maintenance/work-order/work-order'"></wrapper-title>
    <div class="data-content">
      <div class="data-panel">
        <div class="panel-title">
          <div class="icon">
            <img src="@/assets/icons/arrow.png" alt="">
          </div>
          <div class="title">
            整体工单数
          </div>
        </div>
        <div class="panel-container">
          <div class="panel-item">
            <data-hola :holaTitle="`工单总数`" :centerValue="3000" :holaColor="`#4ea8ff`"></data-hola>
          </div>
          <div class="panel-item">
            <data-hola :holaTitle="`已处理工单数`" :centerValue="1600" :holaColor="`#5dec24`"></data-hola>
          </div>
          <div class="panel-item">
            <data-hola :holaTitle="`未处理工单数`" :centerValue="200" :holaColor="`#dfc639`"></data-hola>
          </div>
        </div>
      </div>
      <div class="data-panel">
        <div class="panel-title">
          <div class="icon">
            <img src="@/assets/icons/arrow.png" alt="">
          </div>
          <div class="title">
            分区工单数
          </div>
        </div>
        <div class="echart-container">
          <div id="barChart" ref="barChart"></div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import * as echarts from 'echarts';
import WrapperTitle from '../wrapper-title/index';
import DataHola from './components/data-hola';
let chart = null;
export default {
  name: 'ScreenData',
  components: {
    WrapperTitle,
    DataHola
  },
  data() {
    return {
      dataList: {
        name: ['富顺县', '荣县', '高新区', '自流井区', '贡井区', '大安区', '沿滩区'],
        data1: [210, 310, 40, 102, 111, 201, 123],
        data2: [20, 30, 10, 10, 11, 21, 5],
      },
    }
  },
  methods: {
    initEchart() {
      const option = {
        grid: {
          top: '10%',
          right: 0,
          bottom: '15%',
        },
        legend: {
          right: 0,
          textStyle: {
            color: '#447ED6'
          }
        },
        tooltip: {},
        xAxis: {
          type: 'category',
          axisLabel: {
            color: '#447ED6',
            rotate: 45
          },
          data: this.dataList.name
        },
        yAxis: {
          axisLabel: {
            color: '#4D76B0',
          },
        },
        series: [
          {
            type: 'bar',
            name: '已处理工单数',
            stack: 'total',
            itemStyle: {
              color: '#4ea8ff'
            },
            data: this.dataList.data1
          },
          {
            type: 'bar',
            name: '未处理工单数',
            stack: 'total',
            itemStyle: {
              color: '#dfc639'
            },
            data: this.dataList.data2
          },
        ]
      }
      chart.setOption(option, true);
    }
  },
  mounted() {
    chart = echarts.init(this.$refs.barChart);
    this.initEchart();
  }
}
</script>
<style lang="scss" scoped>
.data-container {
  width: 100%;
  height: 500px;
  display: flex;
  flex-direction: column;
  .data-content {
    flex: 1;
    background: rgba(67, 102, 155, 0.3);
    border: 1px solid rgba(47, 91, 157, 0.8);
    padding: 10px;
    box-sizing: border-box;
  }
}
.echart-container {
  width: 100%;
  height: 260px;
  #barChart {
    width: 100%;
    height: 100%;
  }
}
.panel-title {
  color: #b9b9b9;
  display: flex;
  align-items: center;
  .icon {
    width: 20px;
    margin-right: 5px;
    img {
      width: 100%;
      display: block;
    }
  }
}
.panel-container {
  width: 100%;
  display: flex;
  justify-content: space-around;
  margin: 10px 0;
  .panel-item {
    width: 120px;
    height: 120px;
  }
}
</style>