|
| 1 | +<template> |
| 2 | + <div> |
| 3 | + <BaseReport |
| 4 | + title="用户活跃度分析报告" |
| 5 | + :nav="nav" |
| 6 | + :name="name" |
| 7 | + :description="description" |
| 8 | + v-bind="$attrs" |
| 9 | + > |
| 10 | + <div class="charts-grid"> |
| 11 | + <SwitchDate class="switch-date" @change="onChange" /> |
| 12 | + <br> |
| 13 | + <div class="chart-container"> |
| 14 | + <div class="chart-container-title"> |
| 15 | + <div class="chart-container-title-text">{{ $t('RealTimeData') }}</div> |
| 16 | + <SummaryCountCard |
| 17 | + :items="totalData" |
| 18 | + /> |
| 19 | + </div> |
| 20 | + </div> |
| 21 | + |
| 22 | + <div class="chart-container"> |
| 23 | + <div class="chart-container-title"> |
| 24 | + <div class="chart-container-title-text">修改者城市分布</div> |
| 25 | + <div class="chart"> |
| 26 | + <echarts |
| 27 | + ref="userActivity" |
| 28 | + :options="userActivityOptions" |
| 29 | + :autoresize="true" |
| 30 | + /> |
| 31 | + </div> |
| 32 | + </div> |
| 33 | + </div> |
| 34 | + |
| 35 | + <div class="chart-container full-width"> |
| 36 | + <div class="chart-container-title"> |
| 37 | + <div class="chart-container-title-text">修改趋势</div> |
| 38 | + <div class="chart"> |
| 39 | + <echarts |
| 40 | + ref="loginTrend" |
| 41 | + :options="loginTrendOptions" |
| 42 | + :autoresize="true" |
| 43 | + /> |
| 44 | + </div> |
| 45 | + </div> |
| 46 | + </div> |
| 47 | + |
| 48 | + <div class="chart-container"> |
| 49 | + <div class="chart-container-title"> |
| 50 | + <div class="chart-container-title-text">被修改用户排名</div> |
| 51 | + <RankTable :config="config.change_password_top10_users" /> |
| 52 | + </div> |
| 53 | + </div> |
| 54 | + |
| 55 | + <div class="chart-container"> |
| 56 | + <div class="chart-container-title"> |
| 57 | + <div class="chart-container-title-text">修改者排名</div> |
| 58 | + <RankTable :config="config.change_password_top10_change_bys" /> |
| 59 | + </div> |
| 60 | + </div> |
| 61 | + </div> |
| 62 | + </BaseReport> |
| 63 | + </div> |
| 64 | +</template> |
| 65 | + |
| 66 | +<script> |
| 67 | +import SwitchDate from '@/components/Dashboard/SwitchDate' |
| 68 | +import RankTable from './components/RankTable.vue' |
| 69 | +import BaseReport from '../base/BaseReport.vue' |
| 70 | +import SummaryCountCard from '@/components/Dashboard/SummaryCountCard.vue' |
| 71 | +
|
| 72 | +export default { |
| 73 | + components: { |
| 74 | + SummaryCountCard, |
| 75 | + RankTable, |
| 76 | + BaseReport, |
| 77 | + SwitchDate |
| 78 | + }, |
| 79 | + props: { |
| 80 | + nav: { |
| 81 | + type: Boolean, |
| 82 | + default: true |
| 83 | + } |
| 84 | + }, |
| 85 | + data() { |
| 86 | + return { |
| 87 | + name: 'ChangePassword', |
| 88 | + description: 'xxxxxxxxxx.', |
| 89 | + days: localStorage.getItem('reportDays') || '7', |
| 90 | + total_count_change_password: { |
| 91 | + 'total': 0, |
| 92 | + 'user_total': 0, |
| 93 | + 'change_by_total': 0 |
| 94 | + }, |
| 95 | + config: { |
| 96 | + change_password_top10_users: { |
| 97 | + data: [], |
| 98 | + columns: [ |
| 99 | + { |
| 100 | + prop: 'user', |
| 101 | + label: this.$t('Username') |
| 102 | + }, |
| 103 | + { |
| 104 | + prop: 'count', |
| 105 | + label: this.$t('Count') |
| 106 | + } |
| 107 | + ] |
| 108 | + }, |
| 109 | + change_password_top10_change_bys: { |
| 110 | + data: [], |
| 111 | + columns: [ |
| 112 | + { |
| 113 | + prop: 'change_by', |
| 114 | + label: this.$t('Username') |
| 115 | + }, |
| 116 | + { |
| 117 | + prop: 'count', |
| 118 | + label: this.$t('Count') |
| 119 | + } |
| 120 | + ] |
| 121 | + }, |
| 122 | + user_change_password_metrics: { |
| 123 | + dates_metrics_date: [], |
| 124 | + dates_metrics_total: [0] |
| 125 | + }, |
| 126 | + change_password_region_distribution: [] |
| 127 | + } |
| 128 | + } |
| 129 | + }, |
| 130 | + computed: { |
| 131 | + totalData() { |
| 132 | + return [ |
| 133 | + { |
| 134 | + title: this.$t('ChangePasswordNum'), |
| 135 | + body: { |
| 136 | + route: { name: `PasswordChangeLog` }, |
| 137 | + count: this.total_count_change_password.total |
| 138 | + } |
| 139 | + }, |
| 140 | + { |
| 141 | + title: this.$t('UserNum'), |
| 142 | + body: { |
| 143 | + count: this.total_count_change_password.user_total |
| 144 | + } |
| 145 | + }, |
| 146 | + { |
| 147 | + title: this.$t('ChangeByNum'), |
| 148 | + body: { |
| 149 | + count: this.total_count_change_password.change_by_total |
| 150 | + } |
| 151 | + } |
| 152 | + ] |
| 153 | + }, |
| 154 | + loginTrendOptions() { |
| 155 | + return { |
| 156 | + tooltip: { |
| 157 | + trigger: 'axis' |
| 158 | + }, |
| 159 | + xAxis: { |
| 160 | + type: 'category', |
| 161 | + data: this.config.user_change_password_metrics.dates_metrics_date, |
| 162 | + axisLabel: { |
| 163 | + rotate: 45 |
| 164 | + } |
| 165 | + }, |
| 166 | + yAxis: { |
| 167 | + type: 'value', |
| 168 | + name: '修改次数' |
| 169 | + }, |
| 170 | + series: [ |
| 171 | + { |
| 172 | + name: '修改次数', |
| 173 | + data: this.config.user_change_password_metrics.dates_metrics_total, |
| 174 | + type: 'bar', |
| 175 | + barWidth: '40%', |
| 176 | + itemStyle: { |
| 177 | + color: '#91cc75', |
| 178 | + borderRadius: [4, 4, 0, 0] |
| 179 | + } |
| 180 | + } |
| 181 | + ] |
| 182 | + } |
| 183 | + }, |
| 184 | +
|
| 185 | + userActivityOptions() { |
| 186 | + return { |
| 187 | + tooltip: { |
| 188 | + trigger: 'item' |
| 189 | + }, |
| 190 | + legend: { |
| 191 | + show: false |
| 192 | + }, |
| 193 | + series: [ |
| 194 | + { |
| 195 | + name: '修改者城市分布', |
| 196 | + type: 'pie', |
| 197 | + radius: ['40%', '70%'], |
| 198 | + data: this.config.change_password_region_distribution |
| 199 | + } |
| 200 | + ] |
| 201 | + } |
| 202 | + } |
| 203 | + }, |
| 204 | + watch: { |
| 205 | + days() { |
| 206 | + this.getData() |
| 207 | + } |
| 208 | + }, |
| 209 | + async mounted() { |
| 210 | + await this.getData() |
| 211 | + }, |
| 212 | + methods: { |
| 213 | + onChange(val) { |
| 214 | + this.days = val |
| 215 | + localStorage.setItem('reportDays', val) |
| 216 | + }, |
| 217 | + async getData() { |
| 218 | + const data = await this.$axios.get(`/api/v1/reports/reports/user-change-password/?days=${this.days}`) |
| 219 | + this.$set(this.total_count_change_password, 'total', data.total_count_change_password.total) |
| 220 | + this.$set(this.total_count_change_password, 'user_total', data.total_count_change_password.user_total) |
| 221 | + this.$set(this.total_count_change_password, 'change_by_total', data.total_count_change_password.change_by_total) |
| 222 | + this.$set(this.config.change_password_top10_users, 'data', data.change_password_top10_users) |
| 223 | + this.$set(this.config.change_password_top10_change_bys, 'data', data.change_password_top10_change_bys) |
| 224 | + this.$set(this.config, 'change_password_region_distribution', data.change_password_region_distribution) |
| 225 | + this.$set(this.config.user_change_password_metrics, 'dates_metrics_date', data.user_change_password_metrics.dates_metrics_date) |
| 226 | + this.$set(this.config.user_change_password_metrics, 'dates_metrics_total', data.user_change_password_metrics.dates_metrics_total) |
| 227 | + } |
| 228 | + } |
| 229 | +} |
| 230 | +</script> |
| 231 | + |
| 232 | +<style lang="scss" scoped> |
| 233 | +
|
| 234 | +</style> |
0 commit comments