index.vue
8.83 KB
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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
<template>
<div ref="getHeight" class="app-container">
<div class="main">
<h2 class="crumbsTitle">登录日志</h2>
<div class="container tabCon">
<!-- 搜索框 -->
<div class="conSearch">
<div class="serchForm">
<el-form ref="ruleForm" :inline="true" :model="searchData">
<el-row :gutter="18">
<el-col :span="5">
<el-form-item label="账号:" prop="account">
<el-input
v-model="searchData.account"
placeholder="请输入"
/>
</el-form-item>
</el-col>
<el-col :span="5">
<el-form-item label="地区:" prop="location">
<el-input
v-model="searchData.location"
placeholder="请输入"
/>
</el-form-item>
</el-col>
<el-col :span="5">
<el-form-item label="IP:" prop="requestIp">
<el-input
v-model="searchData.requestIp"
placeholder="请输入"
/>
</el-form-item>
</el-col>
<el-col :span="9">
<el-form-item label="登录时间:" class="timeLabel" prop="loginDate">
<el-date-picker
v-model="searchData.loginDate"
value-format="yyyy-MM-dd HH:mm:ss"
type="daterange"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期"
clearable
@change="handleTime"
/>
</el-form-item>
</el-col>
</el-row>
</el-form>
</div>
<div class="textRight">
<el-button type="primary" class="f-right" @click="handleSearch">
搜索
</el-button>
<el-button @click="resetSearch"> 重置 </el-button>
</div>
</div>
<div v-if="dataTable.length>0">
<el-table
ref="table"
:data="dataTable"
border
fit
stripe
highlight-current-row
>
<el-table-column align="center" width="80" type="index" label="">
<template slot="header">
<span> | 序号 </span>
</template>
</el-table-column>
<el-table-column align="center">
<template slot="header">
<span> | 账号 </span>
</template>
<template slot-scope="{ row }">
<span>{{ row.account }}</span>
</template>
</el-table-column>
<el-table-column align="center">
<template slot="header">
<span> | 姓名 </span>
</template>
<template slot-scope="{ row }">
<span>{{ row.userName }}</span>
</template>
</el-table-column>
<el-table-column align="center">
<template slot="header">
<span> | IP </span>
</template>
<template slot-scope="{ row }">
<span>{{ row.requestIp }}</span>
</template>
</el-table-column>
<el-table-column>
<template slot="header">
<span> | 浏览器 </span>
</template>
<template slot-scope="{ row }">
<span>{{ row.browser }}</span>
</template>
</el-table-column>
<el-table-column class-name="status-col">
<template slot="header">
<span> | 浏览器版本 </span>
</template>
<template slot-scope="{ row }">
<span>{{ row.browserVersion }}</span>
</template>
</el-table-column>
<el-table-column>
<template slot="header">
<span>
| 操作系统
</span>
</template>
<template slot-scope="{ row }">
<span>{{ row.operatingSystem }}</span>
</template>
</el-table-column>
<el-table-column>
<template slot="header">
<span>
| 地区
</span>
</template>
<template slot-scope="{ row }">
<span>{{ row.location }}</span>
</template>
</el-table-column>
<el-table-column>
<template slot="header">
<span>
| 登录时间
</span>
</template>
<template slot-scope="{ row }">
<span>{{ row.loginDate }}</span>
</template>
</el-table-column>
<el-table-column align="center">
<template slot="header">
<span> | 描述 </span>
</template>
<template slot-scope="{ row }">
<span v-if="row.description.indexOf('登录成功') !== -1" class="baseFontCorle">{{ ellipsis(row.description, 10) }}</span>
<span v-else class="delect">{{ ellipsis(row.description, 10) }}</span>
</template>
</el-table-column>
</el-table>
<!-- 分页 -->
<pagination
v-show="total > 0"
:total="Number(total)"
:page.sync="pages.current"
:limit.sync="pages.size"
@pagination="getList"
/>
<!-- end -->
</div>
<module-tip :data-table="dataTable" :list-loading="listLoading" />
</div>
</div>
</div>
</template>
<script lang="ts">
import { Component, Vue } from 'vue-property-decorator'
import { ElForm } from 'element-ui/types/form'
import { ellipsis } from '@/utils'
// interface接口
import {
TableData
} from '@/pages/monitoring/interface/types'
// 组件
import Pagination from '@/components/Pagination/index.vue'
import ModuleTip from '@/components/ModuleTip/index.vue'
// api
import { getList } from '@/pages/monitoring/api/index'
@Component({
name: 'loginList',
components: {
Pagination,
ModuleTip
}
})
export default class extends Vue {
private dataTable: TableData[]=[]
private listLoading = true
private total = ''
private timeID?: number = undefined
private searchData = {
account: '',
location: '',
requestIp: '',
startCreateTime: '',
endCreateTime: '',
loginDate: [],
size: 10,
current: 1
} as any
private pages={
size: 10,
current: 1
} as any
/// 生命周期
created() {
this.initData()
}
/// // 功能函数 /////
// 获取地区数据
initData() {
this.getList()
}
// 获取数据
private async getList() {
this.listLoading = true
const parent = {
account: this.searchData.account,
location: this.searchData.location,
requestIp: this.searchData.requestIp,
startCreateTime: this.searchData.startCreateTime,
endCreateTime: this.searchData.endCreateTime,
...this.pages
}
const { data } = await getList(parent)
if (data.isSuccess === true) {
this.dataTable = data.data.records
this.total = data.data.total
}
setTimeout(() => {
this.listLoading = false
}, 0.1)
}
// 搜索
private handleSearch() {
this.pages.current = 1
this.getList()
}
/// // ui /////
// 重置
resetSearch() {
(this.$refs.ruleForm as ElForm).resetFields()
delete this.searchData.startCreateTime
delete this.searchData.endCreateTime
delete this.searchData.loginDate
this.getList()
}
// 动态模糊搜索
querySearchOwner(queryString: any, cb: any) {
let restaurants = this.dataTable
let results = queryString
? restaurants.filter(this.createStateFilter(queryString))
: restaurants
clearTimeout(this.timeID)
this.timeID = window.setTimeout(() => {
cb(
results.map((item:any) => {
return {
value: item.location,
id: item.id
}
})
)
}, 1000 * Math.random())
}
createStateFilter(queryString: any) {
return (state:any) => {
return (
(state.location as any).toLowerCase().indexOf(queryString.toLowerCase()) >
-1
)
}
}
// 获取开始时间和结束时间
handleTime(val:any) {
this.searchData.startCreateTime = val[0]
this.searchData.endCreateTime = val[1]
}
// 内容控制字数,多出的用省略号
ellipsis(value: any, num: any) {
return ellipsis(value, num)
}
}
</script>
<style lang="scss" scoped>
</style>