From a536f53f64172926c0acb404189691267c9cc37f Mon Sep 17 00:00:00 2001 From: wangwenrui Date: Thu, 2 Jan 2020 18:10:24 +0800 Subject: [PATCH] =?UTF-8?q?fix:alert=20account=20promSever=20=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E4=BF=AE=E6=94=B9=E9=A1=B5=E9=9D=A2=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/common/language/en.js | 1 + .../common/rightBox/alertConfigBox.vue | 345 +++++++---------- .../src/components/page/config/account.vue | 227 ++++------- .../src/components/page/config/promServer.vue | 360 ++++++++---------- 4 files changed, 370 insertions(+), 563 deletions(-) diff --git a/nezha-fronted/src/components/common/language/en.js b/nezha-fronted/src/components/common/language/en.js index 758f99f7c..c501bbc6e 100644 --- a/nezha-fronted/src/components/common/language/en.js +++ b/nezha-fronted/src/components/common/language/en.js @@ -41,6 +41,7 @@ const en = { validate: { //校验规则 required: 'Required', number: 'Must be a number', + email:'E-mail is invalide', config: { account: { diff --git a/nezha-fronted/src/components/common/rightBox/alertConfigBox.vue b/nezha-fronted/src/components/common/rightBox/alertConfigBox.vue index 6505d3358..b3b0fcb10 100644 --- a/nezha-fronted/src/components/common/rightBox/alertConfigBox.vue +++ b/nezha-fronted/src/components/common/rightBox/alertConfigBox.vue @@ -3,26 +3,19 @@
-
-
- -
- {{$t('overall.esc')}} -
-
-
- -
- {{$t('overall.save')}} - {{$t('overall.edit')}} -
-
-
- -
- {{$t('overall.delete')}} -
+ + + +
+ @@ -30,176 +23,82 @@ -
- -
-
{{$t('alert.config.name')}}
-
- -
{{alertRule.alertName}}
-
-
- -
-
{{$t('alert.list.type')}}
-
- - - - -
{{item.value}}
-
-
- -
-
{{$t('alert.config.link')}}
-
-
{{alertRule.linkObject ? alertRule.linkObject.name : ''}}
- - + + + + + +
{{alertRule.alertName}}
+
+ + + + + +
{{item.value}}
+
+ + + + + +
{{alertRule.linkObject ? alertRule.linkObject.name : ''}}
+
+ + + +
{{alertRule.expr}}
+
+ + + + + +
{{alertRule.last}}s
+
+ + + + + {{item.value}} + + + -
-
- -
-
{{$t('alert.config.expr')}}
-
- -
{{alertRule.expr}}
-
-
- -
-
{{$t('alert.config.for')}}
-
- - - -
{{alertRule.last}}s
-
-
- -
-
{{$t('alert.severity')}}
-
- - - {{item.value}} - - - - - -
{{alertRule.severity}}
-
-
- -
-
{{$t('alert.summary')}}
-
- -
{{alertRule.summary}}
-
-
- -
-
{{$t('alert.description')}}
-
- -
{{alertRule.description}}
-
-
- - -
+
{{alertRule.severity}}
+ + + + +
{{alertRule.summary}}
+
+ + + +
{{alertRule.description}}
+
+ + + + - - -
-
{{$t('overall.cancel')}}
{{alertRule.id == '' ? $t('overall.create') : $t('overall.save')}}
-
- -
@@ -214,6 +113,36 @@ return { alertRule: {id: ''}, rightBox: {show: false, isEdit: false, title: ''}, + rules:{ + alertName:[ + {required:true,message:this.$t('validate.required'),trigger:'blur'} + ], + type:[ + {required:true,message:this.$t('validate.required'),trigger:'change'} + ], + linkId:[ + {required:true,message:this.$t('validate.required'),trigger:"change"} + ], + expr:[ + {required:true,message:this.$t('validate.required'),trigger:'blur'} + ], + last:[ + {required:true,message:this.$t('validate.required'),trigger:'blur'}, + {type:'number',message:this.$t('validate.number')} + ], + severity:[ + {required:true,message:this.$t('validate.required'),trigger:'change'}, + ], + summary:[ + {required:true,message:this.$t('validate.required'),trigger:'blur'}, + ], + // description:[ + // {required:true,message:this.$t('validate.required'),trigger:'blur'}, + // ], + // receiver:[ + // {required:true,message:this.$t('validate.required'),trigger:'change'}, + // ] + }, severityData: [ { key: 'medium', @@ -276,27 +205,33 @@ this.rightBox.isEdit = isEdit; }, save: function() { - if (this.alertRule.id) { - this.$put('alert/rule', this.alertRule).then(response => { - if (response.code === 200) { - this.$message({duration: 1000, type: 'success', message: this.$t("tip.saveSuccess")}); - this.$emit('reload'); - this.rightBox.show = false; + this.$refs.alertRuleForm.validate((valid) => { + if (valid) { + if (this.alertRule.id) { + this.$put('alert/rule', this.alertRule).then(response => { + if (response.code === 200) { + this.$message({duration: 1000, type: 'success', message: this.$t("tip.saveSuccess")}); + this.$emit('reload'); + this.rightBox.show = false; + } else { + this.$message.error(response.msg); + } + }); } else { - this.$message.error(response.msg); + this.$post('alert/rule', this.alertRule).then(response => { + if (response.code === 200) { + this.$message({duration: 1000, type: 'success', message: this.$t("tip.saveSuccess")}); + this.$emit('reload'); + this.rightBox.show = false; + } else { + this.$message.error(response.msg); + } + }); } - }); - } else { - this.$post('alert/rule', this.alertRule).then(response => { - if (response.code === 200) { - this.$message({duration: 1000, type: 'success', message: this.$t("tip.saveSuccess")}); - this.$emit('reload'); - this.rightBox.show = false; - } else { - this.$message.error(response.msg); - } - }); - } + } else { + return false; + } + }) }, changeType(type) { this.alertRule.linkId = ''; diff --git a/nezha-fronted/src/components/page/config/account.vue b/nezha-fronted/src/components/page/config/account.vue index 34fdf6209..17b8b3f98 100644 --- a/nezha-fronted/src/components/page/config/account.vue +++ b/nezha-fronted/src/components/page/config/account.vue @@ -100,25 +100,17 @@
-
-
- -
- {{$t('overall.esc')}} -
-
-
- -
- {{$t('overall.save')}} - {{$t('overall.edit')}} -
-
-
- -
- {{$t('overall.delete')}} -
+ + + +
@@ -127,116 +119,39 @@ -
-
-
{{$t('config.account.account')}}
-
- -
{{user.username}}
-
-
-
-
{{$t('config.account.password')}}
-
- -
-
-
-
E-mail
-
- -
{{user.email}}
-
-
- - -
-
{{$t('config.account.enable')}}
-
- - -
-
-
-
{{$t('config.account.createTime')}}
-
-
{{user.createTime}}
-
-
-
+ + + + + +
{{user.username}}
+
+ + + + + + + +
{{user.email}}
+
+ + + + + + + + +
{{user.createTime}}
+
+
+
- - -
-
{{$t('overall.cancel')}}
{{user.userId == '' ? $t('overall.create') : $t('overall.save')}}
-
- -
@@ -305,6 +220,18 @@ export default { width: 100 } ], + rules:{ + username:[ + {required:true,message:this.$t('validate.required'),trigger:'blur'} + ], + password:[ + {required:true,message:this.$t('validate.required'),trigger:'blur'} + ], + email:[ + {required:true,message:this.$t('validate.required'),trigger:'blur'}, + {type:'email',message:this.$t('validate.email')} + ] + }, tableData: [], receiverData: [{ id: '1', @@ -395,27 +322,33 @@ export default { this.rightBox.show = true; }, save: function() { - if (this.user.userId) { - this.$put('sys/user/update', this.user).then(response => { - if (response.code === 200) { - this.rightBox.show = false; - this.$message({duration: 1000, type: 'success', message: this.$t("tip.saveSuccess")}); + this.$refs.accountForm.validate((valid) => { + if(valid){ + if (this.user.userId) { + this.$put('sys/user/update', this.user).then(response => { + if (response.code === 200) { + this.rightBox.show = false; + this.$message({duration: 1000, type: 'success', message: this.$t("tip.saveSuccess")}); + } else { + this.$message.error(response.msg); + } + this.getTableData(); + }); } else { - this.$message.error(response.msg); + this.$post('sys/user/save', this.user).then(response => { + if (response.code === 200) { + this.rightBox.show = false; + this.$message({duration: 1000, type: 'success', message: this.$t("tip.saveSuccess")}); + this.getTableData(); + } else { + this.$message.error(response.msg); + } + }); } - this.getTableData(); - }); - } else { - this.$post('sys/user/save', this.user).then(response => { - if (response.code === 200) { - this.rightBox.show = false; - this.$message({duration: 1000, type: 'success', message: this.$t("tip.saveSuccess")}); - this.getTableData(); - } else { - this.$message.error(response.msg); - } - }); - } + }else{ + return false; + } + }) }, saveOrToEdit: function() { if (!this.rightBox.isEdit) { diff --git a/nezha-fronted/src/components/page/config/promServer.vue b/nezha-fronted/src/components/page/config/promServer.vue index 9106ca778..55ec7fa71 100644 --- a/nezha-fronted/src/components/page/config/promServer.vue +++ b/nezha-fronted/src/components/page/config/promServer.vue @@ -114,27 +114,19 @@
-
-
-
- -
- {{$t('overall.esc')}} -
-
-
- -
- {{$t('overall.save')}} - {{$t('overall.edit')}} -
-
-
- -
- {{$t('overall.delete')}} -
-
+
+ + + + +
@@ -142,180 +134,105 @@ -
-
-
DC
-
- - - {{item.name}} - -
-
-
-
- -
- {{$t('overall.esc')}} -
-
-
- 标题 - - - - - - - -
-
-
-
- {{$t('overall.cancel')}} -
-
- {{$t('overall.save')}} -
-
- -
- -
-
-
- -
-
-
-
- -
- {{$t('overall.esc')}} -
-
-
- 标题 -
-
- - -
-
- - -
-
- - -
-
- - -
-
-
-
-
-
- {{$t('overall.cancel')}} -
-
- {{$t('overall.save')}} -
-
- -
+ + + + +
+ + + {{item.name}} + +
+
+
+
+ {{$t('overall.esc')}} +
-
{{promServer.idc.name}}
+
+ {{$t('asset.createAssetTab.editIdcTab.title')}} + + + + + + +
+
+
+
{{$t('overall.cancel')}} +
+
{{$t('overall.save')}}
+
+ +
+ +
+
+ + +
+ +
+
+
+
+ {{$t('overall.esc')}} +
+
+
+ {{$t('asset.createAssetTab.AddIdcTab.title')}} +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+ +
-
-
Host
-
- -
{{promServer.host}}
-
+
{{promServer.idc.name}}
-
-
Port
-
- -
{{promServer.port}}
-
-
-
-
{{$t('config.promServer.type')}}
-
- - - - -
{{item.value}}
-
-
-
+
+ + + + + +
{{promServer.host}}
+
+ + + +
{{promServer.port}}
+
+ + + + + +
{{item.value}}
+
+
+
- - -
-
{{$t('overall.cancel')}}
{{promServer.id == '' ? $t('overall.create') : $t('overall.save')}}
-
- -
@@ -337,6 +254,21 @@ export default { host: '', idc: {id: '', name: '', location: ''} }, + rules:{ + 'idc.name':[ + {required:true,message:this.$t('validate.required'),trigger:'change'} + ], + host:[ + {required:true,message:this.$t('validate.required'),trigger:'blur'} + ], + port:[ + {required:true,message:this.$t('validate.required'),trigger:'blur'}, + {type:'number',message: this.$t('validate.number')} + ], + type:[ + {required:true,message:this.$t('validate.required'),trigger:'change'}, + ] + }, pageObj: { pageNo: 1, pageSize: 20, @@ -473,29 +405,35 @@ export default { this.rightBox.show = true; }, save: function() { - if (this.promServer.id) { - this.$put('promServer', this.promServer).then(response => { - if (response.code === 200) { - this.$message({duration: 1000, type: 'success', message: this.$t("tip.saveSuccess")}); - this.getTableData(); - this.rightBox.isEdit = false; - this.esc(); + this.$refs.promServerForm.validate((valid => { + if(valid){ + if (this.promServer.id) { + this.$put('promServer', this.promServer).then(response => { + if (response.code === 200) { + this.$message({duration: 1000, type: 'success', message: this.$t("tip.saveSuccess")}); + this.getTableData(); + this.rightBox.isEdit = false; + this.esc(); + } else { + this.$message.error(response.msg); + } + }); } else { - this.$message.error(response.msg); + this.$post('promServer', this.promServer).then(response => { + if (response.code === 200) { + this.$message({duration: 1000, type: 'success', message: this.$t("tip.saveSuccess")}); + this.getTableData(); + this.rightBox.isEdit = false; + this.esc(); + } else { + this.$message.error(response.msg); + } + }); } - }); - } else { - this.$post('promServer', this.promServer).then(response => { - if (response.code === 200) { - this.$message({duration: 1000, type: 'success', message: this.$t("tip.saveSuccess")}); - this.getTableData(); - this.rightBox.isEdit = false; - this.esc(); - } else { - this.$message.error(response.msg); - } - }); - } + }else{ + return false; + } + })) }, saveOrToEdit: function() { if (!this.rightBox.isEdit) {