perf: 优化操作日志详情界面

This commit is contained in:
jiangweidong
2023-01-17 11:34:37 +08:00
committed by Jiangjie.Bai
parent 449d4ae18e
commit 45ff13c7ce
5 changed files with 70 additions and 10 deletions

View File

@@ -302,6 +302,7 @@
"PasswordOrToken": "Password / Token" "PasswordOrToken": "Password / Token"
}, },
"audits": { "audits": {
"ChangeField": "Change field",
"OperateRecord": "Operating record", "OperateRecord": "Operating record",
"Hosts": "Host", "Hosts": "Host",
"RunUser": "Run user", "RunUser": "Run user",

View File

@@ -303,6 +303,7 @@
"PasswordOrToken": "パスワード/トークン" "PasswordOrToken": "パスワード/トークン"
}, },
"audits": { "audits": {
"ChangeField": "フィールドを変更します",
"OperateRecord": "操作記録です", "OperateRecord": "操作記録です",
"Hosts": "本体", "Hosts": "本体",
"RunUser": "実行ユーザー", "RunUser": "実行ユーザー",

View File

@@ -402,6 +402,7 @@
"PasswordOrToken": "密码 / 令牌" "PasswordOrToken": "密码 / 令牌"
}, },
"audits": { "audits": {
"ChangeField": "变更字段",
"OperateRecord": "操作记录", "OperateRecord": "操作记录",
"Hosts": "主机", "Hosts": "主机",
"RunUser": "运行用户", "RunUser": "运行用户",

View File

@@ -8,9 +8,9 @@
<el-dialog <el-dialog
:title="this.$tc('route.OperateLog')" :title="this.$tc('route.OperateLog')"
:visible.sync="logDetailVisible" :visible.sync="logDetailVisible"
width="70%" width="80%"
> >
<TwoTabFormatter :row="rowObj" /> <OperateLogDetail :row="rowObj" />
</el-dialog> </el-dialog>
</div> </div>
</template> </template>
@@ -18,13 +18,13 @@
<script> <script>
import GenericListPage from '@/layout/components/GenericListPage' import GenericListPage from '@/layout/components/GenericListPage'
import { getDaysAgo, getDaysFuture } from '@/utils/common' import { getDaysAgo, getDaysFuture } from '@/utils/common'
import TwoTabFormatter from '@/components/TableFormatters/TwoTabFormatter' import OperateLogDetail from './components/OperateLogDetail'
import { ActionsFormatter } from '@/components/TableFormatters' import { ActionsFormatter } from '@/components/TableFormatters'
export default { export default {
components: { components: {
GenericListPage, GenericListPage,
TwoTabFormatter OperateLogDetail
}, },
data() { data() {
const vm = this const vm = this
@@ -33,10 +33,8 @@ export default {
const dateTo = getDaysFuture(1, now).toISOString() const dateTo = getDaysFuture(1, now).toISOString()
return { return {
rowObj: { rowObj: {
left: '', diff: '',
right: '', title: vm.$t('audits.AfterChange')
leftTitle: vm.$t('audits.BeforeChange'),
rightTitle: vm.$t('audits.AfterChange')
}, },
logDetailVisible: false, logDetailVisible: false,
loading: false, loading: false,
@@ -82,8 +80,7 @@ export default {
vm.$axios.get( vm.$axios.get(
`/api/v1/audits/operate-logs/${row.id}/?type=action_detail`, `/api/v1/audits/operate-logs/${row.id}/?type=action_detail`,
).then(res => { ).then(res => {
vm.rowObj.left = res.before vm.rowObj.diff = res.diff
vm.rowObj.right = res.after
vm.logDetailVisible = true vm.logDetailVisible = true
}).finally(() => { }).finally(() => {
vm.loading = false vm.loading = false

View File

@@ -0,0 +1,60 @@
<template>
<div>
<div v-if="isEmpty()" style="text-align: center">
{{ this.$tc('common.NoContent') }}
</div>
<div v-else>
<el-table
:data="row.diff"
style="width: 100%"
height="500"
>
<el-table-column
prop="field"
:label="this.$tc('audits.ChangeField')"
width="100"
show-overflow-tooltip
/>
<el-table-column
prop="before"
:label="this.$tc('audits.BeforeChange')"
show-overflow-tooltip
/>
<el-table-column
prop="after"
:label="this.$tc('audits.AfterChange')"
show-overflow-tooltip
/>
</el-table>
</div>
</div>
</template>
<script>
export default {
name: 'OperateLogDetail',
props: {
row: {
type: Object,
default: () => ({})
}
},
data() {},
methods: {
isEmpty() {
const content = this.row.diff
return !content || JSON.stringify(content) === '{}'
}
}
}
</script>
<style scoped>
.el-tag{
width: 100%;
white-space: normal;
height:auto;
}
</style>