2021-04-13 20:33:12 +08:00
|
|
|
|
<template>
|
|
|
|
|
|
<div>
|
|
|
|
|
|
<nz-data-list
|
|
|
|
|
|
ref="dataList"
|
|
|
|
|
|
:api="url"
|
|
|
|
|
|
:custom-table-title.sync="tools.customTableTitle"
|
|
|
|
|
|
:from="fromRoute.alertRule"
|
|
|
|
|
|
:layout="['searchInput', 'elementSet']"
|
2021-04-29 22:24:38 +08:00
|
|
|
|
:search-msg="searchMsg"
|
|
|
|
|
|
@search="search"
|
|
|
|
|
|
>
|
2021-04-13 20:33:12 +08:00
|
|
|
|
<template v-slot:top-tool-right>
|
2021-05-17 16:41:01 +08:00
|
|
|
|
<button id="alert-add" v-has="'alertRule_add'" :title="$t('overall.createAlertRule')" class="top-tool-btn"
|
|
|
|
|
|
@click="add">
|
|
|
|
|
|
<i class="nz-icon-create-square nz-icon"></i>
|
|
|
|
|
|
</button>
|
|
|
|
|
|
<top-tool-more-options
|
|
|
|
|
|
ref="export"
|
2021-04-13 20:33:12 +08:00
|
|
|
|
id="alert-rule"
|
|
|
|
|
|
:params="searchLabel"
|
2021-05-17 16:41:01 +08:00
|
|
|
|
:permissions="{import: 'alertRule_add', export: 'alertRule_view'}"
|
|
|
|
|
|
class="top-tool-export margin-l-10 margin-r-10"
|
2021-04-13 20:33:12 +08:00
|
|
|
|
export-file-name="AlertRule"
|
|
|
|
|
|
export-url="/alert/rule/export"
|
|
|
|
|
|
import-url="/alert/rule/import"
|
|
|
|
|
|
@afterImport="getTableData"
|
|
|
|
|
|
>
|
2021-05-17 16:41:01 +08:00
|
|
|
|
<template v-slot:before>
|
|
|
|
|
|
<div>
|
|
|
|
|
|
<el-dropdown-item>
|
|
|
|
|
|
<delete-button :type="'link'" :title="$t('overall.batchDel')" id="alert-rule-batch-delete" v-has="'alertRule_delete'" :api="url" :delete-objs="batchDeleteObjs" @after="getTableData" @before="delFlag=true"></delete-button>
|
|
|
|
|
|
</el-dropdown-item>
|
|
|
|
|
|
</div>
|
2021-04-13 20:33:12 +08:00
|
|
|
|
</template>
|
2021-05-17 16:41:01 +08:00
|
|
|
|
</top-tool-more-options>
|
2021-04-13 20:33:12 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
<template v-slot:default="slotProps">
|
|
|
|
|
|
<alert-rule-table
|
|
|
|
|
|
ref="dataTable"
|
2021-05-18 19:18:14 +08:00
|
|
|
|
v-loading="tools.loading"
|
2021-04-13 20:33:12 +08:00
|
|
|
|
:api="url"
|
|
|
|
|
|
:custom-table-title="tools.customTableTitle"
|
|
|
|
|
|
:height="mainTableHeight"
|
|
|
|
|
|
:table-data="tableData"
|
|
|
|
|
|
@del="del"
|
|
|
|
|
|
@edit="edit"
|
|
|
|
|
|
@orderBy="tableDataSort"
|
|
|
|
|
|
@queryMessage="queryMessage"
|
|
|
|
|
|
@reload="getTableData"
|
2021-06-01 14:26:09 +08:00
|
|
|
|
@addSilence="addSilence"
|
2021-04-13 20:33:12 +08:00
|
|
|
|
@selectionChange="selectionChange"
|
|
|
|
|
|
@showBottomBox="(targetTab, object) => { $refs.dataList.showBottomBox(targetTab, object) }"></alert-rule-table>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<!-- 分页组件 -->
|
|
|
|
|
|
<template v-slot:pagination>
|
|
|
|
|
|
<Pagination ref="Pagination" :pageObj="pageObj" :tableId="tableId" @pageNo='pageNo' @pageSize='pageSize'></Pagination>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</nz-data-list>
|
|
|
|
|
|
<transition name="right-box">
|
|
|
|
|
|
<alert-rule-box v-if="rightBox.show" ref="alertConfigBox" :alert-rule="object" @close="closeRightBox"></alert-rule-box>
|
|
|
|
|
|
</transition>
|
2021-06-01 15:19:47 +08:00
|
|
|
|
<transition name="right-box"><alert-silence-box v-if='silenceBoxShow' :alert-silence="objectSilence" @close="closeSilenceBox"></alert-silence-box>
|
|
|
|
|
|
</transition>
|
2021-04-13 20:33:12 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
|
|
|
import bus from '@/libs/bus'
|
|
|
|
|
|
import exportXLSX from '@/components/common/exportXLSX'
|
|
|
|
|
|
import alertRuleBox from '@/components/common/rightBox/alertRuleBox'
|
|
|
|
|
|
import deleteButton from '@/components/common/deleteButton'
|
|
|
|
|
|
import nzDataList from '@/components/common/table/nzDataList'
|
|
|
|
|
|
import dataListMixin from '@/components/common/mixin/dataList'
|
|
|
|
|
|
import alertRuleTable from '@/components/common/table/alert/alertRuleTable'
|
2021-05-17 16:41:01 +08:00
|
|
|
|
import topToolMoreOptions from '@/components/common/popBox/topToolMoreOptions'
|
2021-06-01 15:19:47 +08:00
|
|
|
|
import alertSilenceBox from '@/components/common/rightBox/alertSilenceBox'
|
2021-05-17 16:41:01 +08:00
|
|
|
|
|
2021-04-13 20:33:12 +08:00
|
|
|
|
export default {
|
|
|
|
|
|
name: 'alert-config',
|
|
|
|
|
|
components: {
|
|
|
|
|
|
deleteButton,
|
|
|
|
|
|
alertRuleBox,
|
|
|
|
|
|
alertRuleTable,
|
|
|
|
|
|
nzDataList,
|
2021-05-17 16:41:01 +08:00
|
|
|
|
'export-excel': exportXLSX,
|
2021-06-01 14:26:09 +08:00
|
|
|
|
topToolMoreOptions,
|
|
|
|
|
|
alertSilenceBox
|
2021-04-13 20:33:12 +08:00
|
|
|
|
},
|
|
|
|
|
|
mixins: [dataListMixin],
|
|
|
|
|
|
data () {
|
|
|
|
|
|
return {
|
|
|
|
|
|
url: 'alert/rule',
|
|
|
|
|
|
tableId: 'alertRuleTable', // 需要分页的table的id,用于记录每页数量
|
|
|
|
|
|
blankObject: {
|
|
|
|
|
|
id: '',
|
|
|
|
|
|
alertName: '',
|
|
|
|
|
|
linkObject: { id: '', name: '' },
|
|
|
|
|
|
expr: '',
|
|
|
|
|
|
unit: 2,
|
|
|
|
|
|
operator: '>',
|
|
|
|
|
|
last: 60,
|
2021-05-08 09:40:53 +08:00
|
|
|
|
severityId: '',
|
2021-04-13 20:33:12 +08:00
|
|
|
|
summary: '',
|
2021-05-08 09:40:53 +08:00
|
|
|
|
description: '',
|
|
|
|
|
|
method: []
|
2021-04-13 20:33:12 +08:00
|
|
|
|
},
|
2021-06-01 14:26:09 +08:00
|
|
|
|
blankSilenceObject: {
|
|
|
|
|
|
id: '',
|
|
|
|
|
|
startAt: '',
|
|
|
|
|
|
endAt: '',
|
|
|
|
|
|
ruleId: '',
|
|
|
|
|
|
type: 'asset',
|
|
|
|
|
|
linkId: '',
|
|
|
|
|
|
remark: '',
|
|
|
|
|
|
time: [],
|
|
|
|
|
|
matchers: [
|
|
|
|
|
|
{ name: '', value: '', regex: 0 }
|
|
|
|
|
|
],
|
|
|
|
|
|
name: ''
|
|
|
|
|
|
},
|
|
|
|
|
|
objectSilence: {},
|
|
|
|
|
|
silenceBoxShow: false,
|
2021-04-13 20:33:12 +08:00
|
|
|
|
searchMsg: { // 给搜索框子组件传递的信息
|
|
|
|
|
|
zheze_none: true,
|
|
|
|
|
|
searchLabelList: [{
|
|
|
|
|
|
id: 1,
|
|
|
|
|
|
name: 'ID',
|
|
|
|
|
|
type: 'input',
|
2021-05-10 15:59:39 +08:00
|
|
|
|
label: 'ids',
|
2021-04-13 20:33:12 +08:00
|
|
|
|
disabled: false
|
|
|
|
|
|
}, {
|
|
|
|
|
|
id: 2,
|
|
|
|
|
|
name: this.$t('alert.alertName'),
|
|
|
|
|
|
type: 'input',
|
2021-05-10 15:59:39 +08:00
|
|
|
|
label: 'name',
|
2021-04-13 20:33:12 +08:00
|
|
|
|
disabled: false
|
|
|
|
|
|
}, {
|
|
|
|
|
|
id: 4,
|
|
|
|
|
|
name: this.$t('alert.severity'),
|
2021-05-10 15:59:39 +08:00
|
|
|
|
type: 'severity',
|
2021-06-10 18:36:24 +08:00
|
|
|
|
label: 'severityIds',
|
2021-04-13 20:33:12 +08:00
|
|
|
|
disabled: false
|
|
|
|
|
|
}]
|
|
|
|
|
|
},
|
|
|
|
|
|
searchTime: bus.getTimezontDateRange()
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
methods: {
|
|
|
|
|
|
queryMessage (alertRule) {
|
|
|
|
|
|
if (!this.hasButton('alertMessage_view')) {
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
2021-05-08 18:08:32 +08:00
|
|
|
|
this.$refs.dataList.showBottomBox('alertRuleAlertMessage', alertRule)
|
2021-04-13 20:33:12 +08:00
|
|
|
|
},
|
|
|
|
|
|
getTableData () {
|
|
|
|
|
|
this.$set(this.searchLabel, 'pageNo', this.pageObj.pageNo)
|
|
|
|
|
|
this.$set(this.searchLabel, 'pageSize', this.pageObj.pageSize)
|
|
|
|
|
|
this.tools.loading = true
|
|
|
|
|
|
this.$get(this.url, this.searchLabel).then(response => {
|
|
|
|
|
|
this.tools.loading = false
|
|
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
|
response.data.list.forEach(item => {
|
|
|
|
|
|
let temp = []
|
|
|
|
|
|
if (item.receiver) {
|
|
|
|
|
|
temp = item.receiver.split(',').map(t => {
|
|
|
|
|
|
return parseInt(t)
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
item.receiverShow = temp
|
|
|
|
|
|
})
|
|
|
|
|
|
this.tableData = response.data.list
|
|
|
|
|
|
this.pageObj.total = response.data.total
|
|
|
|
|
|
if (!this.scrollbarWrap) {
|
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
|
this.scrollbarWrap = this.$refs.dataTable.$refs.dataTable.bodyWrapper
|
|
|
|
|
|
this.toTopBtnHandler(this.scrollbarWrap)
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
2021-05-08 09:40:53 +08:00
|
|
|
|
edit (u) {
|
|
|
|
|
|
this.$get(`${this.url}/${u.id}`).then(response => {
|
|
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
|
this.object = {
|
|
|
|
|
|
...response.data,
|
2021-05-12 19:07:07 +08:00
|
|
|
|
method: response.data.method ? response.data.method.split(',').map(item => Number(item)) : [],
|
|
|
|
|
|
receiverShow: response.data.receiver ? response.data.receiver.split(',').map(item => Number(item)) : []
|
2021-05-08 09:40:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
this.rightBox.show = true
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
2021-04-13 20:33:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
mounted () {
|
2021-05-12 16:19:43 +08:00
|
|
|
|
},
|
|
|
|
|
|
watch: {
|
|
|
|
|
|
$route: {
|
|
|
|
|
|
immediate: true,
|
|
|
|
|
|
handler () {
|
|
|
|
|
|
const add = this.$route.query.add
|
|
|
|
|
|
if (add) {
|
|
|
|
|
|
if (add === 'alertRule') {
|
|
|
|
|
|
this.add()
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2021-05-11 22:29:14 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2021-04-13 20:33:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
</script>
|