This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
nezha-nezha-fronted/nezha-fronted/src/components/common/table/alert/alertRuleEvalLogTable.vue

188 lines
4.7 KiB
Vue
Raw Normal View History

2021-11-02 18:34:00 +08:00
<template>
<el-table
id="alertRuleTable"
ref="dataTable"
:data="tableData"
:height="height"
tooltip-effect="light"
border
@header-dragend="dragend"
@sort-change="tableDataSort"
@selection-change="selectionChange"
@row-dblclick="(row)=>{queryMessage(row)}"
>
<el-table-column
:resizable="false"
align="center"
type="selection"
width="55">
</el-table-column>
<el-table-column
v-for="(item, index) in customTableTitle"
v-if="item.show"
:key="`col-${index}`"
:fixed="item.fixed"
:label="item.label"
:min-width="`${item.minWidth}`"
:prop="item.prop"
:resizable="true"
:sort-orders="['ascending', 'descending']"
:sortable="item.sortable"
:width="`${item.width}`"
:show-overflow-tooltip="item.prop === 'description'"
class="data-column"
>
<template slot="header">
<span class="data-column__span">{{item.label}}</span>
<div class="col-resize-area"></div>
</template>
<template slot-scope="scope" :column="item">
<template v-if="item.prop === 'state'">
<div>
<div :class="{'active-icon green-bg':scope.row.state == 200,'active-icon red-bg':scope.row.state != 200}" style="position: relative">
</div>
<span>{{scope.row.state == 200?'Ok':'Error'}}</span>
2021-11-02 18:34:00 +08:00
</div>
</template>
<template v-else-if="item.prop === 'duration'">
<el-tooltip :disabled="!scope.row.etts" effect="light" placement="right">
<div slot="content">
{{$t('config.terminallog.endTime')}}<br/>
2022-04-20 16:57:14 +08:00
{{utcTimeToTimezoneStr(scope.row.etts)}}
2021-11-02 18:34:00 +08:00
</div>
<span>{{getDuration(scope.row)}}</span>
</el-tooltip>
</template>
<template v-else-if="item.prop === 'stts'">
2022-04-20 16:57:14 +08:00
{{utcTimeToTimezoneStr(scope.row[item.prop])}}
2021-11-02 18:34:00 +08:00
</template>
<span v-else-if="scope.row[item.prop]">{{scope.row[item.prop]}}</span>
<template v-else>-</template>
</template>
</el-table-column>
<template slot="empty">
<div v-if="!loading" class="table-no-data">
<svg class="icon" aria-hidden="true">
<use xlink:href="#nz-icon-no-data-list"></use>
</svg>
<div class="table-no-data__title">No results found</div>
</div>
<div v-else>&nbsp;</div>
</template>
</el-table>
</template>
<script>
import table from '@/components/common/mixin/table'
import { calcDurationByStringTimeMs } from '@/components/common/js/tools'
2021-11-02 18:34:00 +08:00
export default {
name: 'alertRuleTable',
mixins: [table],
props: {
loading: Boolean,
nowTime: {}
},
data () {
return {
tableTitle: [
{
label: this.$t('overall.state'),
2021-11-02 18:34:00 +08:00
prop: 'state',
show: true,
minWidth: 100
2021-11-02 18:34:00 +08:00
}, {
label: this.$t('alert.alertRuleMessage'),
prop: 'msg',
show: true,
minWidth: 100
2021-11-02 18:34:00 +08:00
}, {
label: this.$t('overall.startTime'),
2021-11-02 18:34:00 +08:00
prop: 'stts',
show: true,
minWidth: 300
2021-11-02 18:34:00 +08:00
}, {
label: this.$t('config.terminallog.duration'),
prop: 'duration',
show: true,
minWidth: 120
}
]
}
},
computed: {
},
methods: {
getDuration (record) {
if (record.etts) {
return calcDurationByStringTimeMs(record.stts, record.etts)
2021-11-02 18:34:00 +08:00
}
return calcDurationByStringTimeMs(record.stts, this.utcTimeToTimezoneStr(this.nowTime))
2021-11-02 18:34:00 +08:00
}
}
}
</script>
<style scoped>
.colorEF7458{
color: #EF7458;
}
.color23BF9A{
color: #23BF9A;
}
/deep/ .active-icon {
margin-left: 5px;
}
</style>
<style>
.severity .P1{
background: #F5846A;
border-radius: 2px;
font-size: 12px;
color: #FFFFFF;
padding: 2px 6px;
}
.severity .P2{
background: #F7A54A;
border-radius: 2px;
font-size: 12px;
color: #FFFFFF;
padding: 2px 6px;
}
.severity .P3{
background: #F1C13D;
border-radius: 2px;
font-size: 12px;
color: #FFFFFF;
padding: 2px 6px;
}
.schedEnableTitle{
padding: 20px 15px;
margin-right: 0;
left: 1995px !important;
background: #FFFFFF;
border: 1px solid rgba(119,131,145,0.60);
box-shadow: 0 6px 16px 0 rgba(0,0,0,0.08);
border-radius: 3px;
}
.schedEnableTitle .nz-icon-a-rilizhou, .schedEnableTitle .nz-icon-dingshishijian{
font-size: 14px;
color: #666666;
margin-right: 12px;
}
.schedEnableTitle .week-item{
width: 32px;
height: 22px;
line-height: 22px;
opacity: 0.9;
background: #F6F6FA;
border-radius: 2px;
display: inline-block;
font-size: 12px;
color: #666666;
letter-spacing: 0;
font-weight: 400;
padding-left: 3px;
margin-right: 12px;
margin-bottom: 6px;
}
</style>