Blame view

src/views/report/operationalAnalysisList.vue 5.07 KB
b25b036d   wuxw   v1.9 优化日期
1
  <template>
10d3499d   wuxw   开发完成 admin 台账功能
2
3
4
    <div class="operational-analysis-container">
      <el-row class="animated fadeInRight ecommerce">
        <el-col :span="4">
07e12785   wuxw   v1.9 admin账户中部分页面...
5
          <select-admin-one-community @changeCommunity="handleCommunityChange" />
10d3499d   wuxw   开发完成 admin 台账功能
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
        </el-col>
        <el-col :span="20">
          <el-row>
            <el-col v-for="(chart, index) in charts" :key="index" :span="8" class="margin-bottom">
              <el-card class="box-card">
                <div :id="chart.id" style="width: 100%; height: 300px;"></div>
              </el-card>
            </el-col>
          </el-row>
        </el-col>
      </el-row>
    </div>
  </template>
  
  <script>
07e12785   wuxw   v1.9 admin账户中部分页面...
21
  import SelectAdminOneCommunity from '@/components/community/selectAdminOneCommunity'
10d3499d   wuxw   开发完成 admin 台账功能
22
23
24
25
26
27
  import { getCommunityOperationalAnalysis } from '@/api/report/operationalAnalysisApi'
  import * as echarts from 'echarts'
  
  export default {
    name: 'OperationalAnalysisList',
    components: {
07e12785   wuxw   v1.9 admin账户中部分页面...
28
      SelectAdminOneCommunity
10d3499d   wuxw   开发完成 admin 台账功能
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
    },
    data() {
      return {
        charts: [
          { id: 'communityPayFeeDetail', title: this.$t('operationalAnalysis.chart.payFee') },
          { id: 'communityRepair', title: this.$t('operationalAnalysis.chart.repair') },
          { id: 'communityInspection', title: this.$t('operationalAnalysis.chart.inspection') },
          { id: 'communityMaintainance', title: this.$t('operationalAnalysis.chart.maintainance') },
          { id: 'communityItemIn', title: this.$t('operationalAnalysis.chart.itemIn') },
          { id: 'communityItemOut', title: this.$t('operationalAnalysis.chart.itemOut') },
          { id: 'communityCarIn', title: this.$t('operationalAnalysis.chart.carIn') },
          { id: 'communityPersonIn', title: this.$t('operationalAnalysis.chart.personIn') },
          { id: 'communityContract', title: this.$t('operationalAnalysis.chart.contract') }
        ],
        communityId: ''
      }
    },
    methods: {
      handleCommunityChange(community) {
        this.communityId = community.communityId
        this.loadOperationalAnalysisData()
      },
      async loadOperationalAnalysisData() {
        try {
          const params = {
            communityId: this.communityId
          }
          const res = await getCommunityOperationalAnalysis(params)
          this.initCharts(res.data)
        } catch (error) {
          this.$message.error(this.$t('operationalAnalysis.fetchError'))
        }
      },
      initCharts(data) {
        this.initAnalysisChart(data.feeDetailData, 'communityPayFeeDetail', this.$t('operationalAnalysis.chart.payFee'), this.$t('operationalAnalysis.chart.payFee'))
        this.initAnalysisChart(data.repairData, 'communityRepair', this.$t('operationalAnalysis.chart.repair'), this.$t('operationalAnalysis.chart.repair'))
        this.initAnalysisChart(data.inspectionData, 'communityInspection', this.$t('operationalAnalysis.chart.inspection'), this.$t('operationalAnalysis.chart.inspection'))
        this.initAnalysisChart(data.maintainanceData, 'communityMaintainance', this.$t('operationalAnalysis.chart.maintainance'), this.$t('operationalAnalysis.chart.maintainance'))
        this.initAnalysisChart(data.itemInData, 'communityItemIn', this.$t('operationalAnalysis.chart.itemIn'), this.$t('operationalAnalysis.chart.itemIn'))
        this.initAnalysisChart(data.itemOutData, 'communityItemOut', this.$t('operationalAnalysis.chart.itemOut'), this.$t('operationalAnalysis.chart.itemOut'))
        this.initAnalysisChart(data.carInData, 'communityCarIn', this.$t('operationalAnalysis.chart.carIn'), this.$t('operationalAnalysis.chart.carIn'))
        this.initAnalysisChart(data.personInData, 'communityPersonIn', this.$t('operationalAnalysis.chart.personIn'), this.$t('operationalAnalysis.chart.personIn'))
        this.initAnalysisChart(data.contractData, 'communityContract', this.$t('operationalAnalysis.chart.contract'), this.$t('operationalAnalysis.chart.contract'))
      },
      initAnalysisChart(data, elementId, title, lineName) {
        const dom = document.getElementById(elementId)
        if (!dom) return
        
        const myChart = echarts.init(dom)
        const createTime = []
        const countValues = []
        
        data.forEach(item => {
          createTime.push(item.createTime)
          countValues.push(item.countValue)
        })
  
        const option = {
          title: {
            text: title
          },
          tooltip: {
            trigger: 'axis'
          },
          legend: {
            data: createTime
          },
          grid: {
            left: '3%',
            right: '4%',
            bottom: '3%',
            containLabel: true
          },
          toolbox: {
            feature: {
              saveAsImage: {}
            }
          },
          xAxis: {
            type: 'category',
            boundaryGap: false,
            data: createTime
          },
          yAxis: {
            type: 'value'
          },
          series: [{
            name: lineName,
            type: 'line',
            stack: 'Total',
            data: countValues
          }]
        }
  
        myChart.setOption(option)
        window.addEventListener('resize', () => {
          myChart.resize()
        })
      }
    }
  }
  </script>
  
  <style lang="scss" scoped>
  .operational-analysis-container {
    padding: 20px;
    
    .margin-bottom {
      margin-bottom: 20px;
    }
    
    .box-card {
      margin: 0 10px;
    }
  }
  </style>