f205d763 by weimo934

f(zddcb):表单验证1

1 parent fc9f7f43
...@@ -21,6 +21,8 @@ ...@@ -21,6 +21,8 @@
21 <tr> 21 <tr>
22 <td colspan="2">行政区</td> 22 <td colspan="2">行政区</td>
23 <td colspan="2"> 23 <td colspan="2">
24 <el-form :rules="rules" ref="ruleForm" :inline="true" >
25 <el-form-item prop="xzq">
24 <el-select 26 <el-select
25 class="formSelect" 27 class="formSelect"
26 v-model="formData.xzqbsm" 28 v-model="formData.xzqbsm"
...@@ -34,6 +36,8 @@ ...@@ -34,6 +36,8 @@
34 > 36 >
35 </el-option> 37 </el-option>
36 </el-select> 38 </el-select>
39 </el-form-item>
40 </el-form>
37 </td> 41 </td>
38 <td colspan="2">地籍区</td> 42 <td colspan="2">地籍区</td>
39 <td colspan="2"> 43 <td colspan="2">
...@@ -337,7 +341,7 @@ ...@@ -337,7 +341,7 @@
337 </table> 341 </table>
338 342
339 <div style="min-height: 40px;text-align: center;margin-top: 10px"> 343 <div style="min-height: 40px;text-align: center;margin-top: 10px">
340 <el-button type="success" @click="updateZDxx">保存</el-button> 344 <el-button type="success" @click="updateZDxx()">保存</el-button>
341 <el-button type="primary" @click="submitZDxx">提交</el-button> 345 <el-button type="primary" @click="submitZDxx">提交</el-button>
342 </div> 346 </div>
343 </div> 347 </div>
...@@ -369,6 +373,30 @@ export default { ...@@ -369,6 +373,30 @@ export default {
369 props: {}, 373 props: {},
370 data() { 374 data() {
371 return { 375 return {
376 rules: {
377 hdmc: [
378 { required: true, message: '请输入活动名称', trigger: 'blur' },
379 { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }
380 ],
381 xzq: [
382 { required: true, message: '请选择活行政区', trigger: 'change' }
383 ],
384 date1: [
385 { type: 'date', required: true, message: '请选择日期', trigger: 'change' }
386 ],
387 date2: [
388 { type: 'date', required: true, message: '请选择时间', trigger: 'change' }
389 ],
390 type: [
391 { type: 'array', required: true, message: '请至少选择一个活动性质', trigger: 'change' }
392 ],
393 resource: [
394 { required: true, message: '请选择活动资源', trigger: 'change' }
395 ],
396 desc: [
397 { required: true, message: '请填写活动形式', trigger: 'blur' }
398 ]
399 },
372 rjl:'', 400 rjl:'',
373 jzmd:'', 401 jzmd:'',
374 jzxg:'', 402 jzxg:'',
...@@ -442,13 +470,19 @@ export default { ...@@ -442,13 +470,19 @@ export default {
442 .catch((error) => {}); 470 .catch((error) => {});
443 }, 471 },
444 //修改宗地基本信息 472 //修改宗地基本信息
445 updateZDxx() { 473 updateZDxx(formData) {
446 //获取权利性质数据 474 //获取权利性质数据
447 this.formData.list = this.$refs.qlxzModule.getQlxzDataList(); 475 this.formData.list = this.$refs.qlxzModule.getQlxzDataList();
448 //判断容密高是否为区间值,如果是区间值,则将输入框的值赋予 476 //判断容密高是否为区间值,如果是区间值,则将输入框的值赋予
449 this.formData.jyrjl = this.isInterval(this.formData.jyrjl) ? this.rjl : this.formData.jyrjl; 477 this.formData.jyrjl = this.isInterval(this.formData.jyrjl) ? this.rjl : this.formData.jyrjl;
450 this.formData.jyjzmd = this.isInterval(this.formData.jyjzmd) ? this.jzmd : this.formData.jyjzmd; 478 this.formData.jyjzmd = this.isInterval(this.formData.jyjzmd) ? this.jzmd : this.formData.jyjzmd;
451 this.formData.jyjzxg = this.isInterval(this.formData.jyjzxg) ? this.jzxg : this.formData.jyjzxg; 479 this.formData.jyjzxg = this.isInterval(this.formData.jyjzxg) ? this.jzxg : this.formData.jyjzxg;
480
481
482 this.$refs['ruleForm'].validate((valid) => {
483 debugger
484 if (valid) {
485 alert('submit!');
452 updateQjZdjbxx(this.formData) 486 updateQjZdjbxx(this.formData)
453 .then((res) => { 487 .then((res) => {
454 if (res.code == 200) { 488 if (res.code == 200) {
...@@ -467,6 +501,12 @@ export default { ...@@ -467,6 +501,12 @@ export default {
467 } 501 }
468 }) 502 })
469 .catch((error) => {}); 503 .catch((error) => {});
504 } else {
505 alert("error submit")
506 return false;
507 }
508 });
509
470 }, 510 },
471 //提交宗地基本信息 511 //提交宗地基本信息
472 submitZDxx(){ 512 submitZDxx(){
...@@ -475,6 +515,7 @@ export default { ...@@ -475,6 +515,7 @@ export default {
475 status:1, 515 status:1,
476 type:"zd" 516 type:"zd"
477 } 517 }
518
478 submit(data).then((res)=>{ 519 submit(data).then((res)=>{
479 if(res.code===200){ 520 if(res.code===200){
480 this.$message.success("提交完成!") 521 this.$message.success("提交完成!")
......