index.vue
10.7 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
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
<template>
<div class="box">
<div class="innerBox operationLog">
<search-top
:searchForm="searchForm"
:searchData="searchData"
@search="handleSearch">
</search-top>
<div class="user-btn">
<permission-button
btnType="all"
:btnData="btnData"
@btnClick="btnClick">
</permission-button>
</div>
<el-table
v-loading="loading"
ref="multipleTable"
:data="logTableData"
style="width: 100%; "
:cell-style="cellStyle"
:header-cell-style="{background:'#f5f7fa'}"
@row-click="handleRowClick"
@selection-change="handleSelectionChange">
<el-table-column
type="selection"
width="55">
</el-table-column>
<el-table-column
v-for="(item, index) in tableColumn"
:key="index"
:prop="item.prop"
:label="item.label"
>
<template slot-scope="scope">
<template>
{{logTableData[scope.$index][item.prop]?logTableData[scope.$index][item.prop]:'--'}}
</template>
</template>
</el-table-column>
</el-table>
<el-pagination
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
background
:current-page="pageIndex"
:page-sizes="[10, 20, 30, 40, 50]"
:page-size="pageSize"
layout="total, slot, ->, prev, pager, next, sizes, jumper"
:total="total">
<span class="el-pagination__total">第{{pageIndex}}/{{Math.ceil(total/pageSize)}}页</span>
</el-pagination>
</div>
</div>
</template>
<script>
import store from "@/store"
import SearchTop from '@/components/SearchTop'
import permissionButton from "@/components/PermissionButton"
import { getOperationLogList, deleteOperationLog, exportOperationLog ,getDictDataListByKey} from '@/api/system'
export default {
name: "operationLog",
components: {
SearchTop,
permissionButton
},
data() {
return {
// 分页参数
pageIndex: 1,
pageSize: 10,
total: 20,
multipleSelection: [],
selectAll: [],
selectSum: 0,
// form表单绑定的值
searchParams: {
'beginDate':this.$Common.filterTime(new Date()).slice(0,10),
'endDate':this.$Common.filterTime(new Date()).slice(0,10),
},
searchForm: {
name: '',
number: '',
time:[this.$Common.filterTime(new Date()).slice(0,10),this.$Common.filterTime(new Date()).slice(0,10)],
option: ''
},
// select组件的option选项
optionValue: [],
// 表单信息;modelValue的值需与searchForm的属性一一对应。
searchData: [
{ modelValue: 'name', label: '系统菜单:', type: 'input' },
{ modelValue: 'number', label: '操作账号:', type: 'input' },
{ modelValue: 'time', label: '操作时间:', type: 'time' ,},
{ modelValue: 'option', label: '操作类型:', type: 'select', optionValue: '' }
],
// 表格参数
tableColumn: [
{ prop: 'id', label: '日志编号' },
{ prop: 'menuName', label: '系统菜单',width:200 },
{ prop: 'operateTypeName', label: '操作类型' },
{ prop: 'createBy', label: '操作账号' },
{ prop: 'orgName', label: '所属组织' },
{ prop: 'ip', label: '主机IP' },
{ prop: 'address', label: '操作地点' },
{ prop: 'remark', label: '操作状态',width:100 },
{ prop: 'createTime', label: '创建时间',width:200 }
],
logTableData: [],
loading: true,
// 按钮
btnData: [
// {
// type: "primary",
// name: "删除",
// pType: "delete"
// }, {
// type: "primary",
// name: "导出",
// pType: "export"
// }
]
}
},
mounted() {
this.getList();
this.getDictDataListByKey();
//权限按钮
var allBtn = this.$Common.filterAsycRouter(this.$store.getters.asycRouters,'/system/operationLog');
if(allBtn&&allBtn.length>0){
//清空默认的的
this.listBtnData = []
this.btnData = []
allBtn.map( item => {
// if(item.pType == 'x'){
// item.type = 'text';
// this.listBtnData.push(item)
// }
if(item.pType == 'delete' || item.pType == 'export'){
this.btnData.push({
'type': "primary",
'name':item.name,
'pType': item.pType,
})
}
})
}
},
methods: {
//获取 服务类型 数据
getDictDataListByKey() {
// {'1':"GPS"},{'2':"导航"},{'3':"后视镜"},{'4':"记录仪"},{'5':"座椅"},{'6':"贴膜"}];
// this.searchData[3].optionValue = [
// { value: 'new', label: '新增' },
// { value: 'delete', label: '删除' },
// { value: 'down', label: '导出' }
// ];
// return
getDictDataListByKey({'dictType':'sys_log_operate_type'}).then( response => {
var arr = []
response.data.items.map( item => {
arr.push({
// 'value':item.id,
'value':item.dataKey,
'label':item.dataValue,
})
})
this.searchData[3].optionValue = arr;
}).catch( error => {})
},
//重置 数据
clearAllData(type){
console.log('=-------------清楚查询数据')
this.pageIndex = 1;
var arr = ['name','character','time','status']
var arrAsyc = ['userName','phoneNumber','operateType','userStatus','sTime','eTime']
switch(type){
case 'search':
//增加 修改 删除 tree 得重置查询条件
let obj = {};
let obj2 = {};
arrAsyc.map( item => {
obj[item] = ''
})
arr.map( item => {
obj2[item] = ''
})
this.$set(this,'searchParams',obj)
this.$set(this,'searchForm',obj2)
break;
case 'select':
this.selectAll = [];
this.selectSum = 0;
break;
}
},
getParams() {
this.searchParams.pageSize = this.pageSize
this.searchParams.pageIndex = this.pageIndex
return this.searchParams
},
mergeAllSelection() {
console.log('删除接口---------mergeAllSelection-----------------------',this.selectAll)
let arr = []
for(var i in this.selectAll) {
this.selectAll[i].length && arr.push(...this.selectAll[i])
}
return arr
},
// 接口-start
getList() {
this.logTableData = [];
this.loading = true
const params = this.getParams()
// console.log('查询List--')
// console.log(params)
getOperationLogList(params).then(res => {
this.logTableData = res.data.items
this.total = res.data.page.totalCount
this.loading = false
this.$nextTick(() => {
if(this.selectAll[this.pageIndex]) {
for(var tableIndex in this.logTableData) {
for(var selectIndex in this.selectAll[this.pageIndex]) {
if(this.logTableData[tableIndex].id == this.selectAll[this.pageIndex][selectIndex].id) {
this.$refs.multipleTable.toggleRowSelection(this.logTableData[tableIndex])
}
}
}
}
})
}).catch(err => {})
},
deleteOperationLog() {
// console.log('删除接口--')
const ids = []
this.selectAll.forEach(element => {
element.forEach(item => {
ids.push(item.id)
})
})
deleteOperationLog({'ids':ids}).then(res => {
console.log(res.data,'-------------------------log delete back ')
if(res.code == 200){
this.$message({
message: '删除成功',
type: 'success'
})
}else{
that.$message({
type: "error",
message: response.message
});
}
this.getList();
//清除 查询 order 条件
this.clearAllData('select');
})
},
exportOperationLog() {
let arr = this.mergeAllSelection()
// console.log(arr)
exportOperationLog().then(res => {
console.log('导出List--')
console.log(res.data)
this.$message({
message: '导出成功',
type: 'success'
})
})
},
// 接口-end
// 查询;获取到用户输入
handleSearch(params) {
//清除 查询 order 条件
this.clearAllData('select');
let obj = {};
obj.menuName = params.name;
obj.createBy = params.number;
obj.operateType = params.option;
obj.beginDate = params.time ? params.time[0] : undefined;
obj.endDate = params.time ? params.time[1] : undefined;
this.searchParams = obj
this.getList()
},
handleSizeChange(val) {
this.pageSize = val
this.getList()
},
selectValChange() {
!this.selectAll[this.pageIndex]
?
this.selectSum = this.selectSum + this.multipleSelection.length
:
this.selectSum = this.selectSum - this.selectAll[this.pageIndex].length + this.multipleSelection.length;
this.selectAll[this.pageIndex] = this.multipleSelection;
},
handleCurrentChange(val) {
this.selectValChange()
this.pageIndex = val
this.getList()
},
handleRowClick(row, e, col) {
this.$Common.rowClick(this, row, col)
},
handleSelectionChange(val, row) {
this.multipleSelection = val
},
handleDelete() {
!this.selectSum
?
this.$message({
message: '请选择要删除的数据!',
type: 'warning'
})
:
this.$confirm("是否删除当前"+this.selectSum+"条记录?", '提示', {
type: 'error',
confirmButtonText: "继续",
showCancelButton: false
}).then(() => {
this.deleteOperationLog()
// console.log('删除接口--')
}).catch(() => {})
},
cellStyle({row, column, rowIndex, columnIndex}) {
const rowGray = [0, 1]
const colGreen = [6]
const colBlue = [7, 8]
if(rowGray.includes(rowIndex) && colGreen.includes(columnIndex)) {
return 'color:#BFBFBF'
}
if(colGreen.includes(columnIndex)) {
return 'color:#00A854'
}
if(colBlue.includes(columnIndex)) {
return 'color:#1890FF'
}
},
// 按钮事件
btnClick(pType) {
this.selectValChange()
switch(pType) {
case 'delete':
this.handleDelete()
break
case 'export':
this.exportOperationLog()
break
}
}
}
}
</script>
<style>
.operationLog .el-pagination {
padding: 20px;
}
.operationLog .el-table tr {
cursor: pointer;
height: 57px;
}
</style>