2018-08-01 22:55:40 +08:00
|
|
|
<template>
|
|
|
|
|
<div>
|
2018-08-02 20:28:50 +08:00
|
|
|
<el-tooltip
|
|
|
|
|
effect="dark"
|
|
|
|
|
:content="tooltipContent"
|
|
|
|
|
placement="bottom">
|
|
|
|
|
<el-button
|
|
|
|
|
class="d2-ml-0 d2-mr btn-text can-hover"
|
|
|
|
|
type="text"
|
|
|
|
|
@click="handleClick">
|
2018-08-02 20:16:41 +08:00
|
|
|
<el-badge
|
2018-08-08 09:19:11 +08:00
|
|
|
v-if="logLength > 0"
|
2018-08-02 20:28:50 +08:00
|
|
|
:max="99"
|
2018-08-09 01:03:20 +08:00
|
|
|
:value="logLengthError"
|
|
|
|
|
:is-dot="logLengthError === 0">
|
2018-08-02 20:28:50 +08:00
|
|
|
<d2-icon
|
2018-08-09 01:03:20 +08:00
|
|
|
:name="logLengthError === 0 ? 'dot-circle-o' : 'bug'"
|
2018-08-02 20:28:50 +08:00
|
|
|
style="font-size: 20px"/>
|
2018-08-02 20:16:41 +08:00
|
|
|
</el-badge>
|
2018-08-02 20:28:50 +08:00
|
|
|
<d2-icon
|
|
|
|
|
v-else
|
|
|
|
|
name="dot-circle-o"
|
|
|
|
|
style="font-size: 20px"/>
|
2018-08-01 22:55:40 +08:00
|
|
|
</el-button>
|
|
|
|
|
</el-tooltip>
|
|
|
|
|
<el-dialog
|
2018-08-02 21:30:04 +08:00
|
|
|
:title="tooltipContent"
|
2018-08-01 22:55:40 +08:00
|
|
|
:fullscreen="true"
|
|
|
|
|
:visible.sync="dialogVisible"
|
|
|
|
|
:append-to-body="true">
|
2018-08-07 16:24:13 +08:00
|
|
|
<div class="d2-mb-10">
|
|
|
|
|
<el-button type="danger" size="mini" @click="handleLogClean">
|
|
|
|
|
<d2-icon name="trash-o"/>
|
|
|
|
|
清空
|
|
|
|
|
</el-button>
|
|
|
|
|
</div>
|
2018-08-01 22:55:40 +08:00
|
|
|
<d2-error-log-list/>
|
|
|
|
|
</el-dialog>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
2018-08-07 16:24:13 +08:00
|
|
|
import { mapGetters, mapMutations } from 'vuex'
|
2018-08-01 22:55:40 +08:00
|
|
|
export default {
|
|
|
|
|
data () {
|
|
|
|
|
return {
|
|
|
|
|
dialogVisible: false
|
|
|
|
|
}
|
2018-08-02 20:16:41 +08:00
|
|
|
},
|
|
|
|
|
computed: {
|
2018-08-09 01:03:20 +08:00
|
|
|
...mapGetters('d2admin', {
|
|
|
|
|
logLength: 'log/length',
|
|
|
|
|
logLengthError: 'log/lengthError'
|
|
|
|
|
}),
|
2018-08-02 20:16:41 +08:00
|
|
|
tooltipContent () {
|
2018-08-08 09:19:11 +08:00
|
|
|
return this.logLength === 0
|
2018-08-07 16:07:05 +08:00
|
|
|
? '没有日志或异常'
|
2018-08-09 01:03:20 +08:00
|
|
|
: `${this.logLength} 条日志${this.logLengthError > 0
|
|
|
|
|
? ` | 包含 ${this.logLengthError} 个异常`
|
2018-08-07 16:07:05 +08:00
|
|
|
: ''}`
|
2018-08-02 20:16:41 +08:00
|
|
|
}
|
2018-08-02 20:21:40 +08:00
|
|
|
},
|
|
|
|
|
methods: {
|
2018-08-09 01:03:20 +08:00
|
|
|
...mapMutations('d2admin/log', [
|
|
|
|
|
'clean'
|
2018-08-07 16:24:13 +08:00
|
|
|
]),
|
2018-08-02 20:21:40 +08:00
|
|
|
handleClick () {
|
2018-08-08 09:19:11 +08:00
|
|
|
if (this.logLength > 0) {
|
2018-08-02 20:21:40 +08:00
|
|
|
this.dialogVisible = true
|
|
|
|
|
}
|
2018-08-07 16:24:13 +08:00
|
|
|
},
|
|
|
|
|
handleLogClean () {
|
|
|
|
|
this.dialogVisible = false
|
2018-08-09 01:03:20 +08:00
|
|
|
this.clean()
|
2018-08-02 20:21:40 +08:00
|
|
|
}
|
2018-08-01 22:55:40 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|