Commit 7f0be280c3b5e028be8ca0c333e67decd607370b

Authored by 648540858
1 parent bfae9780

修复未验证通过的表单被应该提交

web_src/src/components/dialog/catalogEdit.vue
@@ -12,15 +12,6 @@ @@ -12,15 +12,6 @@
12 > 12 >
13 <div id="shared" style="margin-top: 1rem;margin-right: 100px;"> 13 <div id="shared" style="margin-top: 1rem;margin-right: 100px;">
14 <el-form ref="form" :rules="rules" :model="form" label-width="140px" > 14 <el-form ref="form" :rules="rules" :model="form" label-width="140px" >
15 -<!-- <el-form-item >-->  
16 -<!-- 建议的类型:-->  
17 -<!-- <br/>-->  
18 -<!-- &emsp;&emsp;行政区划(可选2位/4位/6位/8位/10位数字,例如:130432,表示河北省邯郸市广平县)-->  
19 -<!-- <br/>-->  
20 -<!-- &emsp;&emsp;业务分组(第11、12、13位215,例如:34020000002150000001)-->  
21 -<!-- <br/>-->  
22 -<!-- &emsp;&emsp;虚拟组织(第11、12、13位216,例如:34020000002160000001)-->  
23 -<!-- </el-form-item>-->  
24 <el-form-item label="节点编号" prop="id" > 15 <el-form-item label="节点编号" prop="id" >
25 <el-input v-model="form.id" :disabled="isEdit" clearable></el-input> 16 <el-input v-model="form.id" :disabled="isEdit" clearable></el-input>
26 </el-form-item> 17 </el-form-item>
@@ -63,7 +54,11 @@ export default { @@ -63,7 +54,11 @@ export default {
63 return callback(new Error('行政区划编号必须为2/4/6/8位')); 54 return callback(new Error('行政区划编号必须为2/4/6/8位'));
64 } 55 }
65 if (this.form.parentId !== this.platformDeviceId && this.form.parentId.length >= value.trim().length) { 56 if (this.form.parentId !== this.platformDeviceId && this.form.parentId.length >= value.trim().length) {
66 - return callback(new Error('行政区划编号长度应该每次两位递增')); 57 + if (this.form.parentId.length === 20) {
  58 + return callback(new Error('业务分组/虚拟组织下不可创建行政区划'));
  59 + }else {
  60 + return callback(new Error('行政区划编号长度应该每次两位递增'));
  61 + }
67 } 62 }
68 }else { 63 }else {
69 if (value.trim().length !== 20) { 64 if (value.trim().length !== 20) {
@@ -122,27 +117,31 @@ export default { @@ -122,27 +117,31 @@ export default {
122 this.level = level; 117 this.level = level;
123 }, 118 },
124 onSubmit: function () { 119 onSubmit: function () {
125 - console.log("onSubmit");  
126 - console.log(this.form);  
127 - this.$axios({  
128 - method:"post",  
129 - url:`/api/platform/catalog/${!this.isEdit? "add":"edit"}`,  
130 - data: this.form  
131 - }).then((res)=> {  
132 - if (res.data.code === 0) {  
133 - if (this.submitCallback)this.submitCallback(this.form)  
134 - }else {  
135 - this.$message({  
136 - showClose: true,  
137 - message: res.data.msg,  
138 - type: "error", 120 + this.$refs["form"].validate((valid) => {
  121 + if (valid) {
  122 + this.$axios({
  123 + method:"post",
  124 + url:`/api/platform/catalog/${!this.isEdit? "add":"edit"}`,
  125 + data: this.form
  126 + }).then((res)=> {
  127 + if (res.data.code === 0) {
  128 + if (this.submitCallback)this.submitCallback(this.form)
  129 + }else {
  130 + this.$message({
  131 + showClose: true,
  132 + message: res.data.msg,
  133 + type: "error",
  134 + });
  135 + }
  136 + this.close();
  137 + })
  138 + .catch((error)=> {
  139 + console.log(error);
139 }); 140 });
140 - }  
141 - this.close();  
142 - })  
143 - .catch((error)=> {  
144 - console.log(error);  
145 - }); 141 + } else {
  142 + return false;
  143 + }
  144 + });
146 }, 145 },
147 close: function () { 146 close: function () {
148 this.isEdit = false; 147 this.isEdit = false;