hi-ucs/back/src/views/modules/sys/log-operation.vue

289 lines
7.8 KiB
Vue
Raw Normal View History

2022-06-14 09:32:49 +08:00
<template>
<el-card shadow="never" class="aui-card--fill">
<div class="mod-sys__log-operation">
2022-07-11 17:50:01 +08:00
<el-form
:inline="true"
:model="dataForm"
@keyup.enter.native="getDataList()"
>
2022-06-14 09:32:49 +08:00
<el-form-item>
2022-07-11 17:50:01 +08:00
<el-select
v-model="dataForm.status"
:placeholder="$t('logOperation.status')"
clearable
>
<el-option
:label="$t('logOperation.status0')"
:value="0"
></el-option>
<el-option
:label="$t('logOperation.status1')"
:value="1"
></el-option>
2022-06-14 09:32:49 +08:00
</el-select>
</el-form-item>
2022-07-11 17:50:01 +08:00
<el-form-item>
<el-input
v-model="dataForm.creatorName"
placeholder="请输入操作人"
></el-input>
</el-form-item>
<el-form-item>
<el-date-picker
v-model="value1"
2022-07-11 18:33:58 +08:00
type="datetimerange"
2022-07-11 17:50:01 +08:00
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期"
>
</el-date-picker>
</el-form-item>
<el-form-item>
<el-input
v-model="dataForm.operation"
placeholder="请输入操作名称"
></el-input>
</el-form-item>
2022-06-14 09:32:49 +08:00
<el-form-item>
<el-button @click="getDataList()">{{ $t('query') }}</el-button>
</el-form-item>
<el-form-item>
2022-07-11 17:50:01 +08:00
<el-button @click="resetFunction()"> 重置 </el-button>
</el-form-item>
2022-07-11 18:59:21 +08:00
<!-- <el-form-item>
2022-07-11 17:50:01 +08:00
<el-button type="info" @click="exportHandle()">{{
$t('export')
}}</el-button>
2022-07-11 18:59:21 +08:00
</el-form-item> -->
2022-06-14 09:32:49 +08:00
</el-form>
2022-07-11 17:50:01 +08:00
<el-table
v-loading="dataListLoading"
:data="dataList"
border
@sort-change="dataListSortChangeHandle"
style="width: 100%"
:row-class-name="rowClassName"
>
<el-table-column
label="序号"
align="center"
prop="xh"
width="50"
></el-table-column>
<el-table-column
prop="operation"
label="操作名称"
header-align="center"
align="center"
></el-table-column>
<el-table-column
prop="creatorName"
label="操作人"
header-align="center"
align="center"
></el-table-column>
<el-table-column
prop="createDate"
label="操作时间"
sortable="custom"
header-align="center"
align="center"
width="180"
></el-table-column>
<el-table-column
prop="ip"
label="客户端IP"
header-align="center"
align="center"
></el-table-column>
<el-table-column
prop="requestUri"
label="请求地址"
header-align="center"
align="center"
></el-table-column>
<el-table-column
prop="requestMethod"
:label="$t('logOperation.requestMethod')"
header-align="center"
align="center"
></el-table-column>
<el-table-column
prop="requestParams"
:label="$t('logOperation.requestParams')"
header-align="center"
align="center"
width="150"
:show-overflow-tooltip="true"
></el-table-column>
<el-table-column
label="返回结果"
header-align="center"
width="150"
align="center"
:show-overflow-tooltip="true"
2022-07-11 18:53:42 +08:00
>
<template slot-scope="scope">
<div class="blue-font-color" @click="copyFunction(scope.row)">
复制
</div>
</template>
</el-table-column>
2022-07-11 17:50:01 +08:00
<el-table-column
prop="requestTime"
:label="$t('logOperation.requestTime')"
sortable="custom"
header-align="center"
align="center"
>
2022-06-14 09:32:49 +08:00
<template slot-scope="scope">
{{ `${scope.row.requestTime}ms` }}
</template>
</el-table-column>
2022-07-11 17:50:01 +08:00
<el-table-column
prop="status"
:label="$t('logOperation.status')"
sortable="custom"
header-align="center"
align="center"
>
2022-06-14 09:32:49 +08:00
<template slot-scope="scope">
2022-07-11 17:50:01 +08:00
<el-tag v-if="scope.row.status === 0" size="small" type="danger">{{
$t('logOperation.status0')
}}</el-tag>
<el-tag v-else size="small" type="success">{{
$t('logOperation.status1')
}}</el-tag>
2022-06-14 09:32:49 +08:00
</template>
</el-table-column>
2022-07-11 17:50:01 +08:00
<!-- <el-table-column
prop="userAgent"
:label="$t('logOperation.userAgent')"
header-align="center"
align="center"
width="150"
:show-overflow-tooltip="true"
></el-table-column> -->
2022-06-14 09:32:49 +08:00
</el-table>
<el-pagination
:current-page="page"
:page-sizes="[10, 20, 50, 100]"
:page-size="limit"
:total="total"
layout="total, sizes, prev, pager, next, jumper"
@size-change="pageSizeChangeHandle"
2022-07-11 17:50:01 +08:00
@current-change="pageCurrentChangeHandle"
>
2022-06-14 09:32:49 +08:00
</el-pagination>
</div>
</el-card>
</template>
<script>
import mixinViewModule from '@/mixins/view-module'
export default {
mixins: [mixinViewModule],
data () {
return {
mixinViewModuleOptions: {
getDataListURL: '/sys/log/operation/page',
getDataListIsPage: true,
exportURL: '/sys/log/operation/export'
},
dataForm: {
2022-07-11 17:50:01 +08:00
status: '',
creatorName: '',
startDate: '',
endDate: '',
operation: ''
},
value1: ''
}
},
watch: {
value1 (val) {
val[0] = this.handleTime(val[0], 'yyyy-MM-dd HH:mm:ss')
this.dataForm.startDate = val[0]
val[1] = this.handleTime(val[1], 'yyyy-MM-dd HH:mm:ss')
this.dataForm.endDate = val[1]
}
},
methods: {
2022-07-11 18:53:42 +08:00
// 复制方法
copyFunction (row) {
var data = row.resultData
var oInput = document.createElement('input')
oInput.value = data
document.body.appendChild(oInput)
oInput.select()
document.execCommand('Copy')
oInput.className = 'oInput'
oInput.style.display = 'none'
this.$message({
type: 'success',
message: this.$t('复制成功')
})
},
2022-07-11 17:50:01 +08:00
// 重置按钮
resetFunction () {
const params = {
status: '',
creatorName: '',
startDate: '',
endDate: '',
operation: '',
2022-07-14 14:55:49 +08:00
operationType: ''
2022-07-11 17:50:01 +08:00
}
this.value1 = '' // 格式化日期
this.operationType = '' // 操作类型转化
this.page = 1
this.limit = 10
this.dataForm = params
this.getDataList() // 重置完调用查询方法
},
// 序号
rowClassName ({ row, rowIndex }) {
row.xh = rowIndex + 1 + (this.page - 1) * this.limit
},
// 定义格式化函数:
handleTime (time, format) {
if (time == null || time == undefined || time == '') {
return ''
}
var t = new Date(time)
var tf = function (i) {
return (i < 10 ? '0' : '') + i
2022-06-14 09:32:49 +08:00
}
2022-07-11 17:50:01 +08:00
return format.replace(/yyyy|MM|dd|HH|mm|ss/g, function (a) {
switch (a) {
case 'yyyy':
return tf(t.getFullYear())
break
case 'MM':
return tf(t.getMonth() + 1)
break
case 'mm':
return tf(t.getMinutes())
break
case 'dd':
return tf(t.getDate())
break
case 'HH':
return tf(t.getHours())
break
case 'ss':
return tf(t.getSeconds())
break
}
})
2022-06-14 09:32:49 +08:00
}
}
}
</script>
2022-07-11 18:53:42 +08:00
<style scoped lang="scss">
2022-07-14 15:37:55 +08:00
.blue-font-color {
2022-07-11 18:53:42 +08:00
color: #0058e1;
cursor: pointer;
}
</style>