Skip to content

Commit 1961c03

Browse files
committed
perf: change password
1 parent 33f2114 commit 1961c03

File tree

10 files changed

+761
-7
lines changed

10 files changed

+761
-7
lines changed

src/router/reports/users.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,15 @@ export default [
1313
}
1414
},
1515
{
16-
path: 'group-activity',
17-
component: () => import('@/views/reports/audits/Dashboard.vue'), // Parent router-view
18-
name: 'GroupActivity',
16+
path: 'change-password',
17+
component: () => import('@/views/reports/users/ChangePassword.vue'), // Parent router-view
18+
// component: () => import('@/views/reports/audits/Dashboard.vue'), // Parent router-view
19+
name: 'ChangePassword',
1920
meta: {
2021
permissions: [],
2122
expanded: true,
2223
icon: 'user-o',
23-
title: i18n.t('ReportsGroups')
24+
title: i18n.t('ChangePassword')
2425
}
2526
}
2627
]
Lines changed: 234 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,234 @@
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>
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<template>
2+
<SummaryCountCard :config="logConfig" :items="LogItems" />
3+
</template>
4+
5+
<script>
6+
import SummaryCountCard from '@/components/Dashboard/SummaryCountCard.vue'
7+
8+
export default {
9+
components: { SummaryCountCard },
10+
props: {
11+
days: {
12+
type: [Number, String],
13+
default: '7'
14+
}
15+
},
16+
data() {
17+
return {
18+
logConfig: {
19+
title: this.$t('LogData'),
20+
tip: this.$t('LogData')
21+
},
22+
data: {
23+
total_count_user_login_logs: 0,
24+
total_count_operate_logs: 0,
25+
total_count_change_password_logs: 0
26+
}
27+
}
28+
},
29+
computed: {
30+
LogItems() {
31+
return [
32+
{
33+
title: this.$t('LoginNum'),
34+
body: {
35+
route: { name: `LoginLogList` },
36+
count: this.data.total_count_user_login_logs,
37+
disabled: !this.$hasPerm('audits.view_userloginlog')
38+
}
39+
},
40+
{
41+
title: this.$t('OperationLogNum'),
42+
body: {
43+
route: { name: `OperateLogList` },
44+
count: this.data.total_count_operate_logs,
45+
disabled: !this.$hasPerm('audits.view_operatelog')
46+
}
47+
},
48+
{
49+
title: this.$t('DeclassificationLogNum'),
50+
body: {
51+
route: { name: `PasswordChangeLog` },
52+
count: this.data.total_count_change_password_logs,
53+
disabled: !this.$hasPerm('audits.view_passwordchangelog')
54+
}
55+
}
56+
]
57+
}
58+
},
59+
watch: {
60+
days() {
61+
this.getData()
62+
}
63+
},
64+
mounted() {
65+
this.getData()
66+
},
67+
methods: {
68+
async getData() {
69+
this.data = await this.$axios.get(`/api/v1/index/?days=${this.days}
70+
&total_count_user_login_logs=1
71+
&total_count_operate_logs=1
72+
&total_count_change_password_logs=1
73+
`)
74+
}
75+
}
76+
}
77+
</script>
78+
79+
<style scoped>
80+
.margin-top-10 {
81+
margin-top: 10px;
82+
}
83+
</style>

0 commit comments

Comments
 (0)