+
+
+
+ Label
+
+
+
+
+
+
+
+
+
+
+
-
+
@@ -119,6 +182,17 @@
show: false,
title: ''
},
+ rules: {
+ name: [
+ {required: true, message: this.$t('validate.required'), trigger: 'blur'}
+ ],
+ project: [
+ {required: true, message: this.$t('validate.required'), trigger: 'blur'}
+ ],
+ port: [
+ {type: 'number', message: this.$t('validate.number'), trigger: 'blur'}
+ ],
+ },
projectList: [],
}
},
@@ -135,28 +209,35 @@
/*保存*/
save() {
this.module.param = this.paramToJson(this.module.paramObj);
- if (this.module.id) {
- this.$put('module', this.module).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.moduleForm.validate((valid) => {
+ if (valid) {
+ if (this.module.id) {
+ this.$put('module', this.module).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.module.projectId = this.module.project.id;
+ this.$post('module', this.module).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.module.projectId = this.module.project.id;
- this.$post('module', this.module).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 {
+ console.log('error submit!!');
+ return false;
+ }
+ });
},
/*删除*/
@@ -216,7 +297,7 @@
paramToJson: function(param) {
let tempParam = {};
for (let i = 0; i < param.length; i++) {
- eval('tempParam.' + param[i].key + '="' + param[i].value + '"');
+ eval('tempParam["' + param[i].key + '"]="' + param[i].value + '"');
}
let jsonString = JSON.stringify(tempParam);
if (jsonString == '{}') {
@@ -245,78 +326,4 @@
diff --git a/nezha-fronted/src/components/common/rightBox/projectBox.vue b/nezha-fronted/src/components/common/rightBox/projectBox.vue
index 13f31bb9d..af56a97a7 100644
--- a/nezha-fronted/src/components/common/rightBox/projectBox.vue
+++ b/nezha-fronted/src/components/common/rightBox/projectBox.vue
@@ -3,39 +3,31 @@
-
-
-
-
-
{{$t('overall.esc')}}
-
-
-
-
-
-
{{$t('overall.save')}}
-
-
-
-
-
-
{{$t('overall.delete')}}
-
+
+
+
{{rightBox.title}}
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
-