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
| <template>
| <a-card :bordered="false">
| <!-- 查询区域 -->
| <div class="table-page-search-wrapper">
| <a-form layout="inline" @keyup.enter.native="searchQuery">
| <a-row :gutter="24">
| <a-col :md="6" :sm="8">
| <a-form-item label="用户名">
| <a-input placeholder="请输入用户名" v-model.trim="queryParam.username" />
| </a-form-item>
| </a-col>
|
| <a-col :md="6" :sm="8">
| <span style="float: left;overflow: hidden;" class="table-page-search-submit-buttons">
| <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
| </span>
| </a-col>
| </a-row>
| </a-form>
| </div>
|
| <a-table ref="table" bordered size="middle" rowKey="id" :columns="columns" :dataSource="dataSource" />
| </a-card>
| </template>
|
| <script>
| import { getAction } from '@tievd/cube-block/lib/api/manage'
| import * as dayjs from 'dayjs'
|
| export default {
| name: 'UserOnlineList',
| data() {
| return {
| queryParam: {},
| dataSource: [],
| columns: [
| {
| title: '用户名',
| dataIndex: 'username'
| },
| {
| title: '登录IP',
| dataIndex: 'ip'
| },
| {
| title: '操作系统',
| dataIndex: 'os'
| },
| {
| title: '游览器',
| dataIndex: 'browse'
| },
| {
| title: '登录时间',
| dataIndex: 'loginTime'
| },
| {
| title: '在线时长(分钟)',
| dataIndex: 'onlineTime'
| }
| ]
| }
| },
| created: function() {
| this.loadData()
| },
| methods: {
| loadData: function() {
| getAction('/sys/user/online/list', this.queryParam).then(res => {
| this.dataSource = res.result.map(record => {
| let onlineUser = JSON.parse(record)
| let onlineTime = res.timestamp - onlineUser.loginTime
| onlineUser.loginTime = dayjs(onlineUser.loginTime).format('YYYY-MM-DD HH:mm:ss')
| onlineUser.onlineTime = (onlineTime / 1000 / 60).toFixed()
| return onlineUser
| })
| })
| },
| searchQuery: function() {
| this.loadData()
| }
| }
| }
| </script>
| <style scoped></style>
|
|