Mr.Zhang
2023-09-14 e4b524d3150ee0f67cd60a07badf71e7bdc66e72
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
<template>
  <div class="content">
    <div class="top-num">
      <div class="title">数据统计</div>
      <div class="num-content">
        <div class="num-item" v-for="(item, index) in statistics" :key="index">
          <div class="num-title">{{ item.title }}</div>
          <div class="num-value">{{ item.num }}</div>
        </div>
      </div>
    </div>
    <div class="table">
      <div class="tool">
        <div class="title">用户登录次数趋势图</div>
        <div class="right-option">
          <el-date-picker
            v-model="value"
            type="daterange"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            value-format="yyyy-MM-dd"
            @change="dataChange"
            >
          </el-date-picker>
          <div style="width: 5px;"></div>
          <el-select v-model="searchForm.orgin" placeholder="请选择登录来源" clearable @change="getList">
            <el-option value="0" label="PC登陆"/>
            <el-option value="1" label="钉钉平台"/>
            <el-option value="2" label="羚羊平台"/>
            <el-option value="3" label="EDGP平台"/>
            <el-option value="4" label="微信小程序"/>
          </el-select>
        </div>
      </div>
      <div id="chart"></div>
    </div>
  </div>
</template>
 
<script>
import { getStagingLoginVO, getActivityLoginVOList } from "@/api/business/workbench.js"
import * as eCharts from 'echarts'
export default {
  data() {
    return {
      statistics: [
        {
          title: '今日活跃用户',
          num: ''
        },
        {
          title: '今日活跃企业',
          num: ''
        },
        {
          title: '本月登录企业数',
          num: ''
        },
        {
          title: '本月登录2次及以上企业数',
          num: ''
        },
        {
          title: '本月登录2次及以上企业数(羚羊)',
          num: ''
        }
      ],
      value: [],
      searchForm: {
        orgin: '',
        startDate: '',
        endDate: ''
      },
      list: []
    }
  },
  created() {
    let temp = new Date()
    let startTemp = new Date()
    this.searchForm.endDate = `${temp.getFullYear()}-${temp.getMonth() + 1}-${temp.getDate()}`
    startTemp.setTime(startTemp.getTime() - 3600 * 1000 * 24 * 15)
    this.searchForm.startDate = `${startTemp.getFullYear()}-${startTemp.getMonth() + 1}-${startTemp.getDate()}`
    this.value = [this.searchForm.startDate, this.searchForm.endDate]
    this.getList()
    getStagingLoginVO()
      .then(res => {
        this.statistics[0].num = res.dayActiveUserNum
        this.statistics[1].num = res.dayActiveCompanyNum
        this.statistics[2].num = res.monthActiveCompanyNum
        this.statistics[3].num = res.monthTwoCompanyNum
        this.statistics[4].num = res.monthTwoCompanyLYNum
      })
  },
  methods: {
    dataChange(v) {
      console.log(v);
      this.searchForm.startDate = v[0]
      this.searchForm.endDate = v[1]
      this.getList()
    },
    getList() {
      getActivityLoginVOList(this.searchForm)
        .then(res => {
          this.list = res
          this.renderChart()
        })
    },
    renderChart() {
      let chart = eCharts.init(document.getElementById('chart'))
      let name = []
      let num = []
      this.list.forEach(item => {
        name.push(item.dataDate)
        num.push(item.dayActiveUserNum)
      })
      chart.setOption({
       
        tooltip: {},
        grid: {
          top: 40,
          bottom: 30,
          left: 60,
          rigth: 30
        },
        xAxis: {
          type: 'category',
          boundaryGap: false,
          data: name
        },
        yAxis: {},
        series: [
          {
            name: '登录次数',
            type: 'line',
            data: num
          }
        ]
      })
    },
  },
}
</script>
 
<style lang="scss" scoped>
.content {
  background-color: #f7f7f7;
  padding: 0 10px;
  height: 100%;
  min-height: 700px;
  display: flex;
  flex-direction: column;
  .title {
    font-weight: 500;
    font-size: 18px;
  }
  .top-num {
    padding: 20px;
    background-color: #fff;
    .num-content {
      margin-top: 20px;
      display: flex;
      
      .num-item {
        margin-right: 20px;
        flex: 1;
        box-shadow: 0px 0px 10px rgba(170, 170, 170, 0.349019607843137);
        padding: 20px;
        &:last-child {
          flex: 2;
          margin-right: 0;
        }
        .num-title {
          font-size: 16px;
        }
        .num-value {
          margin-top: 5px;
          font-size: 20px;
          font-weight: 600;
          color: #02a7f0;
        }
      }
    }
  }
  .table {
    flex: 1;
    margin-top: 10px;
    background-color: #fff;
    padding: 20px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    .tool {
      display: flex;
      justify-content: space-between;
      .right-option {
        display: flex;
      }
    }
    #chart {
      flex: 1;
    }
  }
}
</style>