index.vue
9.98 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
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
<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="userName">
<el-input
v-model="searchData.userName"
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 type="selection" width="45" align="center" /> -->
<el-table-column align="center" width="80" type="index" label="">
<template slot="header">
<span> | 序号 </span>
</template>
</el-table-column>
<el-table-column align="center" width="120">
<template slot="header">
<span> | 姓名 </span>
</template>
<template slot-scope="{ row }" width="120">
<span>{{ row.userName }}</span>
</template>
</el-table-column>
<el-table-column align="center" width="120">
<template slot="header">
<span> | 请求地址 </span>
</template>
<template slot-scope="{ row }" width="120">
<span>{{ row.requestUri }}</span>
</template>
</el-table-column>
<el-table-column
label=""
align="center"
width="120"
column-key="httpMethod"
prop="httpMethod"
:filter-multiple="false"
:filters="optTypeOptions"
:filter-method="filterHandler"
>
<template slot="header">
<span>
| 请求类型
<i class="iconfont"></i>
</span>
</template>
<template slot-scope="{ row }">
<span>{{ row.httpMethod.code }}</span>
</template>
</el-table-column>
<el-table-column align="center" width="120">
<template slot="header">
<span> | IP </span>
</template>
<template slot-scope="{ row }">
<span>{{ row.requestIp }}</span>
</template>
</el-table-column>
<el-table-column align="center" width="150">
<template slot="header">
<span> | 操作描述 </span>
</template>
<template slot-scope="{ row }">
<span>{{ ellipsis(row.description, 10) }}</span>
</template>
</el-table-column>
<el-table-column
label="类型"
align="center"
:filter-multiple="false"
column-key="type"
prop="type"
:filters="TypeOptions"
:filter-method="filterHandlerType"
>
<template slot="header">
<span>
| 类型
<i class="iconfont"></i>
</span>
</template>
<template slot-scope="{ row }">
<span v-if="row.type.code==='OPT'">正常</span>
<span v-else>异常</span>
</template>
</el-table-column>
<el-table-column width="150">
<template slot="header">
<span> | 请求方法 </span>
</template>
<template slot-scope="{ row }">
<span>{{ ellipsis(row.actionMethod, 30) }}</span>
</template>
</el-table-column>
<el-table-column width="150">
<template slot="header">
<span>
| 开始时间
</span>
</template>
<template slot-scope="{ row }">
<span>{{ row.createTime }}</span>
</template>
</el-table-column>
<el-table-column width="150">
<template slot="header">
<span>
| 消耗时间(ms)
</span>
</template>
<template slot-scope="{ row }">
<span>{{ row.consumingTime }}</span>
</template>
</el-table-column>
<el-table-column>
<template slot="header">
<span>
| 终端|浏览器
</span>
</template>
<template slot-scope="{ row }">
<span>{{ ellipsis(row.ua, 20) }}</span>
</template>
</el-table-column>
</el-table>
<!-- 分页 -->
<pagination
v-show="total > 0"
:total="Number(total)"
:page.sync="searchData.current"
:limit.sync="searchData.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'
import { optTypeOptions, TypeOptions } from '@/utils/common-selete'
// interface接口
import {
TableData
} from '@/pages/monitoring/interface/types'
// 组件
import Pagination from '@/components/Pagination/index.vue'
import ModuleTip from '@/components/ModuleTip/index.vue'
// api
import { getOperationList } 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 optTypeOptions = [] as any
private TypeOptions = [] as any
private filterStatus=true
private searchData = {
userName: '',
requestIp: '',
loginDate: '',
size: 10,
current: 1
} as any
/// 生命周期
created() {
this.initData()
}
/// // 功能函数 /////
// 获取地区数据
initData() {
this.getList()
this.optTypeOptions = optTypeOptions
this.TypeOptions = TypeOptions
}
// 获取数据
private async getList() {
this.listLoading = true
const { data } = await getOperationList({ ...this.searchData })
if (data.isSuccess === true) {
this.dataTable = data.data.records
this.total = data.data.total
}
setTimeout(() => {
this.listLoading = false
}, 0.1)
}
// 搜索
private handleSearch() {
this.searchData.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]
}
// 筛选请求类型
filterHandler(value:any, row:any) {
return row.httpMethod.code === value
}
// 筛选类型
filterHandlerType(value:any, row:any) {
this.filterStatus = value
return row.type.code === value
}
// 筛选数据状态
filterData(filter:any) {
const status = filter['type']
if (status.length > 0) {
this.searchData.type = this.filterStatus
} else {
this.searchData.type = null
}
this.getList()
}
// 内容控制字数,多出的用省略号
ellipsis(value: any, num: any) {
return ellipsis(value, num)
}
}
</script>
<style lang="scss" scoped>
</style>