diff --git a/nezha-fronted/src/components/common/rightBox/alertConfigBox.vue b/nezha-fronted/src/components/common/rightBox/alertConfigBox.vue index d868b3641..00bcf652b 100644 --- a/nezha-fronted/src/components/common/rightBox/alertConfigBox.vue +++ b/nezha-fronted/src/components/common/rightBox/alertConfigBox.vue @@ -21,79 +21,66 @@ - - - - -
{{alertRule.alertName}}
-
- - - - - - - -
{{alertRule.expr}}
-
- - - - - -
{{alertRule.last}}s
-
- - - - - - - - - - -
{{alertRule.severity}}
-
- - - -
{{alertRule.summary}}
-
- - - -
{{alertRule.description}}
-
- - -
+ + + + +
{{alertRule.alertName}}
+
+ + + +
{{alertRule.expr}}
+
+ + + + + +
{{alertRule.last}}s
+
+ + + + + + + + + + +
{{alertRule.severity}}
+
+ + + + + + + + + + +
{{alertRule.summary}}
+
+ + + +
{{alertRule.description}}
+
+
@@ -118,7 +105,7 @@ }, data() { return { - alertRule: {id: ''}, + alertRule: {id: '', receiverShow: [], receiver: ''}, rightBox: {show: false, isEdit: false, title: ''}, rules:{ alertName:[ @@ -172,31 +159,7 @@ value: this.$t('alert.config.typeOption.asset') } ], - receiverData: [{ - id: '1', - name: 'group1', - description: '小组1desc' - }, { - id: '2', - name: 'group2', - description: '小组2desc' - }, { - id: '3', - name: '小组3', - description: '小组3desc' - }, { - id: '4', - name: '小组4', - description: '小组4desc' - }, { - id: '5', - name: '小组啊小组5', - description: '小组5desc' - }, { - id: '6', - name: '小组6', - description: '小组6desc' - }], + userData: [], linkObjList: [] } }, @@ -211,6 +174,7 @@ save: function() { this.$refs.alertRuleForm.validate((valid) => { if (valid) { + this.alertRule.receiver = this.alertRule.receiverShow.join(","); if (this.alertRule.id) { this.$put('alert/rule', this.alertRule).then(response => { if (response.code === 200) { @@ -237,16 +201,6 @@ } }) }, - /*changeType(type) { - this.alertRule.linkId = ''; - if (type == 1) { - this.getProjectList(); - } else if (type == 2) { - this.getModuleList(); - } else if (type == 3) { - this.getAssetList(); - } - },*/ del: function() { this.$confirm(this.$t("tip.confirmDelete"), { confirmButtonText: this.$t("tip.yes"), @@ -272,43 +226,6 @@ this.save(); } }, - toEditReceiver: function(item) { - if (!item.isEdit) { - //如果不在编辑状态,那么其他项如果有改动,则还原改动,最后开始编辑 - this.blurEditReceiver(); - item.isEdit = true; - } else { - //如果已在编辑状态,判断name是否有变更,有变更则发请求 - if (item.name != item.oldName) { - if (this.updateReceiverName(item) == 200) { - item.isEdit = false; - } - } else { - item.errorMessage = ''; - item.isEdit = false; - } - } - }, - blurEditReceiver: function() { - for (let i = 0; i < this.receiverData.length; i++) { - if (this.receiverData[i].isEdit) { - this.receiverData[i].name = this.receiverData[i].oldName; - this.receiverData[i].isEdit = false; - this.receiverData[i].errorMessage = ''; - break; - } - } - }, - toDelReceiver: function(item) { - this.blurEditReceiver(); - //TODO 请求后台,删除组 - }, - initReceiverData: function() { - for (let i = 0; i < this.receiverData.length; i++) { - this.$set(this.receiverData[i], 'oldName', this.receiverData[i].name); - this.$set(this.receiverData[i], 'isEdit', false); - } - }, esc: function() { this.rightBox.show = false; }, @@ -320,7 +237,13 @@ } }) }, - + getUserList() { + this.$get('sys/user/list', {pageNo: 1, pageSize: -1}).then(response => { + if (response.code == 200) { + this.userData = response.data.list; + } + }) + }, getModuleList() { this.$get('module', {pageNo: 1, pageSize: -1}).then(response => { if (response.code == 200) { @@ -338,7 +261,7 @@ }, }, created() { - this.initReceiverData(); + this.getUserList(); this.rightBox.title = this.$t("alert.config.createAlertConfig"); }, watch: { diff --git a/nezha-fronted/src/components/page/alert/config.vue b/nezha-fronted/src/components/page/alert/config.vue index de5f7fec9..7467aab10 100644 --- a/nezha-fronted/src/components/page/alert/config.vue +++ b/nezha-fronted/src/components/page/alert/config.vue @@ -367,6 +367,15 @@ this.$get('alert/rule', this.searchLabel).then(response => { this.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; } @@ -382,7 +391,6 @@ severity: '', summary: '', description: '', - receivers: '', } }, jumpTo(data, id) {