2021-04-13 20:33:12 +08:00
|
|
|
<template>
|
|
|
|
|
<el-table
|
|
|
|
|
id="alertSilenceTable"
|
|
|
|
|
ref="dataTable"
|
|
|
|
|
:data="tableData"
|
|
|
|
|
:height="height"
|
|
|
|
|
border
|
2022-03-04 13:59:25 +08:00
|
|
|
:default-sort="orderBy"
|
2021-04-13 20:33:12 +08:00
|
|
|
@header-dragend="dragend"
|
|
|
|
|
@sort-change="tableDataSort"
|
|
|
|
|
@selection-change="selectionChange"
|
|
|
|
|
>
|
|
|
|
|
<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']"
|
2021-05-07 19:10:28 +08:00
|
|
|
:sortable="item.sortable"
|
2021-04-13 20:33:12 +08:00
|
|
|
:width="`${item.width}`"
|
|
|
|
|
class="data-column"
|
|
|
|
|
>
|
|
|
|
|
<template slot="header">
|
2021-05-25 17:58:38 +08:00
|
|
|
<span class="data-column__span">{{item.label}}</span>
|
2021-04-13 20:33:12 +08:00
|
|
|
<div class="col-resize-area"></div>
|
|
|
|
|
</template>
|
|
|
|
|
<template slot-scope="scope" :column="item">
|
|
|
|
|
<template v-if="item.prop === 'duration'">
|
|
|
|
|
<el-tooltip :disabled="!scope.row.endAt" effect="light" placement="right">
|
|
|
|
|
<div slot="content">
|
|
|
|
|
{{$t('config.terminallog.endTime')}}<br/>
|
2021-05-10 19:04:39 +08:00
|
|
|
{{utcTimeToTimezoneStr(scope.row.endAt)}}
|
2021-04-13 20:33:12 +08:00
|
|
|
</div>
|
|
|
|
|
<span>{{getDuration(scope.row)}}</span>
|
|
|
|
|
</el-tooltip>
|
|
|
|
|
</template>
|
|
|
|
|
<template v-else-if="item.prop === 'matchers'">
|
2021-05-07 21:27:47 +08:00
|
|
|
<span v-for="(item1, i) in labelsSort(scope.row.matchers)" :key="i">
|
|
|
|
|
<span >
|
|
|
|
|
<nz-alert-tag
|
2021-05-20 16:38:39 +08:00
|
|
|
:key="i" :cursor-point="tagType(item1.name) !== 'info'"
|
2021-05-07 21:27:47 +08:00
|
|
|
:label="item1.name"
|
|
|
|
|
:type="tagType(item1.name)"
|
|
|
|
|
:regex="item1.regex"
|
|
|
|
|
style="margin: 5px 0 5px 5px;"
|
|
|
|
|
>
|
|
|
|
|
{{item1.value}}
|
|
|
|
|
</nz-alert-tag>
|
|
|
|
|
</span>
|
|
|
|
|
</span>
|
2021-04-13 20:33:12 +08:00
|
|
|
</template>
|
|
|
|
|
<template v-else-if="item.prop === 'state'">
|
2021-05-10 17:41:54 +08:00
|
|
|
<span v-if="scope.row.state===1" class="silence-active">active</span>
|
|
|
|
|
<span v-if="scope.row.state===2" class="silence-pending">pending</span>
|
2021-04-13 20:33:12 +08:00
|
|
|
<span v-if="scope.row.state===3" class="silence-expired">expired</span>
|
|
|
|
|
</template>
|
|
|
|
|
<template v-else-if="item.prop === 'utime'">
|
|
|
|
|
{{utcTimeToTimezoneStr(scope.row[item.prop])}}
|
|
|
|
|
</template>
|
2021-05-10 19:04:39 +08:00
|
|
|
<template v-else-if="item.prop === 'startAt'">
|
|
|
|
|
{{utcTimeToTimezoneStr(scope.row[item.prop])}}
|
|
|
|
|
</template>
|
2021-04-13 20:33:12 +08:00
|
|
|
<span v-else-if="scope.row[item.prop]">{{scope.row[item.prop] || '-'}}</span>
|
|
|
|
|
<template v-else>-</template>
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column
|
|
|
|
|
:resizable="false"
|
|
|
|
|
:width="operationWidth"
|
|
|
|
|
fixed="right">
|
|
|
|
|
<div slot="header" class="table-operation-title">{{$t('overall.option')}}</div>
|
|
|
|
|
<div slot-scope="scope" class="table-operation-items">
|
2022-03-18 09:20:44 +08:00
|
|
|
<!-- <button :class="{'table-operation-item--disable': scope.row.state === 3}" class="table-operation-item" v-has="'alertSilence_edit'" @click="$emit('edit', scope.row)" :disabled="scope.row.state === 3"><i class="nz-icon nz-icon-edit"></i></button>-->
|
|
|
|
|
<button class="table-operation-item" @click="$emit('showBottomBox', 'alertMessageTab', scope.row)"><i class="nz-icon nz-icon-view1"></i></button>
|
2021-11-10 18:09:05 +08:00
|
|
|
<el-dropdown size="medium" v-has="['alertSilence_expire', 'alertSilence_edit']" trigger="click" @command="tableOperation">
|
2021-04-13 20:33:12 +08:00
|
|
|
<div class="table-operation-item table-operation-item--more">
|
2021-05-27 13:53:42 +08:00
|
|
|
<i class="nz-icon nz-icon-more3"></i>
|
2021-04-13 20:33:12 +08:00
|
|
|
</div>
|
2021-10-29 12:02:34 +08:00
|
|
|
<el-dropdown-menu slot="dropdown" class="right-box-select-top right-public-box-dropdown-top">
|
2022-03-18 09:20:44 +08:00
|
|
|
<el-dropdown-item :command="['edit', scope.row]" :class="{'table-operation-item--disable': scope.row.state === 3}" class="table-operation-item" v-has="'alertSilence_edit'" :disabled="scope.row.state === 3"><i class="nz-icon nz-icon-edit"></i><span class="operation-dropdown-text">{{$t('overall.edit')}}</span></el-dropdown-item>
|
2021-08-26 14:51:38 +08:00
|
|
|
<el-dropdown-item v-has="'alertSilence_edit'" :command="['copy', scope.row]"><i class="nz-icon nz-icon-override"></i><span class="operation-dropdown-text">{{$t('overall.duplicate')}}</span></el-dropdown-item>
|
2021-06-21 09:56:02 +08:00
|
|
|
<el-dropdown-item v-has="'alertSilence_expire'" :command="['delete', scope.row]"><i class="nz-icon nz-icon-delete"></i><span class="operation-dropdown-text">{{$t('buttons.delete')}}</span></el-dropdown-item>
|
2021-04-13 20:33:12 +08:00
|
|
|
</el-dropdown-menu>
|
|
|
|
|
</el-dropdown>
|
|
|
|
|
</div>
|
|
|
|
|
</el-table-column>
|
2021-10-22 19:39:49 +08:00
|
|
|
<template slot="empty">
|
2021-10-25 14:45:28 +08:00
|
|
|
<div v-if="!loading" class="table-no-data">
|
2021-10-22 17:47:42 +08:00
|
|
|
<svg class="icon" aria-hidden="true">
|
|
|
|
|
<use xlink:href="#nz-icon-no-data-list"></use>
|
|
|
|
|
</svg>
|
2021-10-28 17:53:27 +08:00
|
|
|
<div class="table-no-data__title">No results found</div>
|
2021-10-22 17:47:42 +08:00
|
|
|
</div>
|
2021-10-22 19:39:49 +08:00
|
|
|
<div v-else> </div>
|
2021-10-22 17:47:42 +08:00
|
|
|
</template>
|
2021-04-13 20:33:12 +08:00
|
|
|
</el-table>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
import table from '@/components/common/mixin/table'
|
|
|
|
|
import { calcDurationByStringTimeB } from '@/components/common/js/tools'
|
2021-05-07 21:27:47 +08:00
|
|
|
import nzAlertTag from '../../../page/alert/nzAlertTag'
|
2021-05-11 19:43:59 +08:00
|
|
|
import { sameLabels } from '@/components/common/js/constants'
|
2021-04-13 20:33:12 +08:00
|
|
|
export default {
|
|
|
|
|
name: 'alertSilenceTable',
|
2021-05-07 21:27:47 +08:00
|
|
|
components: {
|
|
|
|
|
nzAlertTag
|
|
|
|
|
},
|
2021-04-13 20:33:12 +08:00
|
|
|
mixins: [table],
|
2021-10-22 17:47:42 +08:00
|
|
|
props: {
|
2021-11-02 18:34:00 +08:00
|
|
|
loading: Boolean,
|
|
|
|
|
nowTime: {}
|
2021-10-22 17:47:42 +08:00
|
|
|
},
|
2021-04-13 20:33:12 +08:00
|
|
|
data () {
|
|
|
|
|
return {
|
|
|
|
|
/* 表格相关 */
|
|
|
|
|
tableTitle: [
|
|
|
|
|
{
|
|
|
|
|
label: 'ID',
|
|
|
|
|
prop: 'id',
|
|
|
|
|
show: true,
|
2021-05-07 19:10:28 +08:00
|
|
|
width: 80,
|
2021-05-07 21:27:47 +08:00
|
|
|
sortable: 'custom'
|
2021-05-08 18:08:32 +08:00
|
|
|
},
|
|
|
|
|
{
|
2021-05-12 10:59:21 +08:00
|
|
|
label: this.$t('alert.silence.name'),
|
2021-05-08 18:08:32 +08:00
|
|
|
prop: 'name',
|
|
|
|
|
show: true,
|
2021-10-28 14:13:14 +08:00
|
|
|
minWidth: 150
|
2021-04-13 20:33:12 +08:00
|
|
|
}, {
|
2021-05-12 09:47:28 +08:00
|
|
|
label: this.$t('alert.silence.matchers'),
|
2021-04-13 20:33:12 +08:00
|
|
|
prop: 'matchers',
|
2021-05-07 19:10:28 +08:00
|
|
|
show: true,
|
2021-07-22 10:00:29 +08:00
|
|
|
minWidth: 200,
|
2021-05-07 21:27:47 +08:00
|
|
|
sortable: 'custom'
|
2021-04-13 20:33:12 +08:00
|
|
|
}, {
|
2021-05-08 11:25:05 +08:00
|
|
|
label: this.$t('alert.silence.startTime'),
|
2021-04-13 20:33:12 +08:00
|
|
|
prop: 'startAt',
|
|
|
|
|
show: true,
|
2021-05-07 19:10:28 +08:00
|
|
|
width: 300,
|
2021-05-07 21:27:47 +08:00
|
|
|
sortable: 'custom'
|
2021-04-13 20:33:12 +08:00
|
|
|
}, {
|
|
|
|
|
label: this.$t('config.terminallog.duration'),
|
|
|
|
|
prop: 'duration',
|
|
|
|
|
show: true,
|
|
|
|
|
width: 120
|
|
|
|
|
}, {
|
2021-05-11 17:20:22 +08:00
|
|
|
label: this.$t('alert.silence.remark'),
|
|
|
|
|
prop: 'remark',
|
2021-04-13 20:33:12 +08:00
|
|
|
show: true,
|
|
|
|
|
width: 120
|
|
|
|
|
}, {
|
2021-05-08 11:25:05 +08:00
|
|
|
label: this.$t('alert.silence.upTime'),
|
2021-04-13 20:33:12 +08:00
|
|
|
prop: 'utime',
|
2021-05-11 19:43:59 +08:00
|
|
|
show: false,
|
2021-08-02 15:41:43 +08:00
|
|
|
width: 300
|
2021-04-13 20:33:12 +08:00
|
|
|
}, {
|
2021-05-08 11:25:05 +08:00
|
|
|
label: this.$t('alert.silence.state'),
|
2021-04-13 20:33:12 +08:00
|
|
|
prop: 'state',
|
|
|
|
|
show: true,
|
|
|
|
|
width: 120
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
computed: {
|
|
|
|
|
getDuration () {
|
|
|
|
|
return function (record) {
|
|
|
|
|
if (record.endAt) {
|
|
|
|
|
return calcDurationByStringTimeB(record.startAt, record.endAt)
|
|
|
|
|
}
|
2021-05-10 13:49:27 +08:00
|
|
|
return calcDurationByStringTimeB(record.startAt, this.utcTimeToTimezoneStr(this.nowTime))
|
2021-04-13 20:33:12 +08:00
|
|
|
}
|
2021-05-07 21:27:47 +08:00
|
|
|
},
|
|
|
|
|
tagType () {
|
|
|
|
|
return (key) => {
|
2021-05-11 19:43:59 +08:00
|
|
|
if (sameLabels.find(item => item === key)) {
|
2021-05-07 21:27:47 +08:00
|
|
|
return 'normal'
|
|
|
|
|
} else {
|
|
|
|
|
return 'info'
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
labelsSort (obj) {
|
|
|
|
|
obj = obj || []
|
2021-05-11 19:43:59 +08:00
|
|
|
const buildIn = sameLabels
|
2021-05-07 21:27:47 +08:00
|
|
|
if (typeof obj === 'string') obj = JSON.parse(obj)
|
|
|
|
|
const labels = JSON.parse(JSON.stringify(obj))
|
|
|
|
|
const result = []
|
|
|
|
|
const result2 = []
|
|
|
|
|
for (const key of buildIn) {
|
|
|
|
|
labels.forEach(item => {
|
|
|
|
|
if (item.name === key) {
|
|
|
|
|
result.push(item)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
labels.forEach(item => {
|
|
|
|
|
if (buildIn.indexOf(item.name) === -1) {
|
|
|
|
|
result2.push(item)
|
|
|
|
|
}
|
|
|
|
|
})
|
2021-05-20 18:45:27 +08:00
|
|
|
// console.log([...result, ...result2])
|
2021-05-07 21:27:47 +08:00
|
|
|
return [...result, ...result2]
|
2021-04-13 20:33:12 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|