index.vue
9.9 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
<template>
<a-form :model="queryForm" layout="inline" :label-col="{ style: { width: '80px' } }">
<!-- <a-form-item label="apptype:" style="padding: 5px 0">
<a-select v-model:value="queryForm.apptype"
style="width: 280px"
:options="apptypeList"
optionFilterProp="label"
>
</a-select>
</a-form-item> -->
<a-form-item label="服务名称:" style="padding: 5px 0">
<a-select v-model:value="queryForm.appname"
style="width: 280px"
:options="appnameList"
optionFilterProp="label"
>
</a-select>
</a-form-item>
<a-form-item label="日志等级:" style="padding: 5px 0">
<a-select v-model:value="queryForm.levels"
style="width: 280px"
mode="multiple"
:maxTagCount="1"
:options="levelList"
optionFilterProp="label"
>
</a-select>
</a-form-item>
<a-form-item label="选择日期:" style="padding: 5px 0">
<a-date-picker v-model:value="queryForm.date" :format="'YYYY-MM-DD'" style="width: 280px"/>
</a-form-item>
<a-form-item label="选择时间:" style="padding: 5px 0">
<a-time-picker v-model:value="queryForm.startTime" style="width: 140px"/>
<a-time-picker v-model:value="queryForm.endTime" style="width: 140px"/>
</a-form-item>
<a-form-item label="内容:" style="padding: 5px 0">
<a-input v-model:value="queryForm.content_like" placeholder="请输入内容" style="width: 280px"/>
</a-form-item>
<a-form-item style="padding: 5px 0">
<a-button type="primary" @click="confirmSearch(1)" :loading="isLoading">查询</a-button>
<!-- <a-button type="primary" @click="confirmSearch1">弹框</a-button> -->
</a-form-item>
</a-form>
<!-- <a-table :dataSource="dataList" v-loading="isLoading" :rowKey="dataList => dataList.id" :columns="columns" :pagination="false" :scroll="{ y: contentHeight }">
</a-table> -->
<el-table
:data="dataList"
v-loading="isLoading"
:rowKey="id"
:height="contentHeight"
style="width: 100%">
<el-table-column
prop="time"
label="时间"
width="180">
</el-table-column>
<el-table-column
prop="thread"
label="线程号"
width="180">
</el-table-column>
<el-table-column
prop="location"
label="日志位置"
width="300">
</el-table-column>
<el-table-column
prop="content"
label="日志内容">
<template #default="{ row }">
<p v-html="stringFormatter(row.content)"></p>
</template>
</el-table-column>
</el-table>
<a-pagination
v-model:current="pageNum"
v-model:pageSize="pageSize"
:total="total"
:show-total="total => `共 ${total} 条`"
:pageSizeOptions="['20', '50', '100']"
@change="onPageNumChange"
@showSizeChange="onPageSizeChange"
show-size-changer
show-quick-jumper
style="text-align:center"
/>
<!-- <moreDialog ref='moreDialogRef'></moreDialog> -->
</template>
<script>
import {reactive, ref, toRaw} from 'vue'
import moment from 'moment'
import SystemLogApi from '@/views/SystemLog/SystemLog.js'
import {isArray} from '@/PublicUtil/Judgment'
import {filterEmptyValueInObject, formatDate, formatTime} from '@/PublicUtil/PublicUtil'
import {PlusOutlined} from '@ant-design/icons-vue'
import moreDialog from './moreDialog.vue'
export default {
components: {
PlusOutlined,
VNodes: (_, {attrs}) => {
return attrs.vnodes
},
moreDialog
},
setup() {
const columns = ref([
{
title: '时间',
dataIndex: 'time',
align: 'center',
width: 220
},
{
title: '线程号',
dataIndex: 'thread',
align: 'center',
width: 120
},
{
title: '日志位置',
dataIndex: 'location',
align: 'center',
width: 300
},
{
title: '日志内容',
dataIndex: 'content',
align: 'center',
customRender:({text,record})=>{
const rawData = toRaw(queryForm)
if (rawData.content_like && rawData.content_like !== '') {
text = text.split(rawData.content_like).join("<span style='color:red;'>" + rawData.content_like + "</span>")
// console.log(str)
// let pHtml = document.createElement("p");
return (<p v-html='str'>{text}</p>)
}else{
return text
}
}
},
// {
// title: '日志标识',
// dataIndex: 'id',
// align: 'center',
// }
])
//ref
const moreDialogRef = ref()
// scalar
const isLoading = ref(false)
const isSuspended = ref(false)
const pageNum = ref(1)
const pageSize = ref(20)
const total = ref()
// sequence
const dataList = ref([])
const apptypeList = ref([{
value: 'store',
label: 'store',
},{
value: 'mall',
label: 'mall',
}])
const appnameList = ref([{
value: 'process',
label: 'process',
},{
value: 'receive',
label: 'receive',
},{
value: 'report',
label: 'report',
},{
value: 'openapi',
label: 'openapi',
}])
const levelList = ref([{
value: 'info',
label: 'info',
},{
value: 'error',
label: 'error',
},{
value: 'debug',
label: 'debug',
},{
value: 'warn',
label: 'warn',
}])
const queryForm = reactive(
{
// apptype:'store',
appname: 'process',
levels: ['info','error','debug','warn'],
content_like: '',
date: moment(moment().format('YYYY-MM-DD'), 'YYYY-MM-DD'),
startTime: moment('00:00:00', 'HH:mm:ss'),
endTime: moment('23:59:59', 'HH:mm:ss'),
}
)
const onPageNumChange = function(num) {
pageNum.value = num
confirmSearch()
}
const onPageSizeChange = function(current, size) {
pageNum.value = 1
pageSize.value = size
confirmSearch()
}
const confirmSearch = function(val){
isLoading.value = true
const rawData = toRaw(queryForm)
pageNum.value = val?1:pageNum.value
const data = filterEmptyValueInObject(
{
// apptype: rawData.apptype,
appname: rawData.appname,
levels: rawData.levels?rawData.levels.toString():null,
content_like: rawData.content_like,
startTime: formatDate(rawData.date) + ' ' + formatTime(rawData.startTime),
endTime: formatDate(rawData.date) + ' ' + formatTime(rawData.endTime),
page: pageNum.value,
pageSize: pageSize.value,
}
)
SystemLogApi.getLogSelect(data).then(
(r) => {
isLoading.value = false
dataList.value = []
if(r.code==200){
// r.forEach((item,index)=>{
// item.index = index+1
// })
if(r.data){
dataList.value = r.data.list
total.value = r.data.total
}
}
}
)
}
const stringFormatter = function(text){
const rawData = toRaw(queryForm)
if (rawData.content_like && rawData.content_like !== '') {
let str = text.split(rawData.content_like).join("<span style='color:red;'>" + rawData.content_like + "</span>")
return str
}else{
return text
}
}
const contentHeight = ref(0)
const __main = function() {
contentHeight.value = window.innerHeight - 230
// confirmSearch()
}
const confirmSearch1 = function(){
moreDialogRef.value.initDialog();
}
__main()
return {
// scalar
isLoading,
pageNum,
pageSize,
total,
contentHeight,
// sequence
apptypeList,
appnameList,
levelList,
dataList,
queryForm,
columns,
// function
confirmSearch,
confirmSearch1,
stringFormatter,
onPageNumChange,
onPageSizeChange,
//ref
moreDialogRef
}
}
}
</script>
<style lang="less" scoped>
.success {
color: #26ff29;
}
// /deep/.el-table{
// th,tr{
// background-color: #fafafa;
// }
// }
.failed {
color: red;
}
</style>