宗地表单和权利性质表单验证
Showing
2 changed files
with
114 additions
and
6 deletions
... | @@ -105,9 +105,11 @@ | ... | @@ -105,9 +105,11 @@ |
105 | :disabled="formData.qszt!='0'" | 105 | :disabled="formData.qszt!='0'" |
106 | v-model="childItem.tdsyqssj" | 106 | v-model="childItem.tdsyqssj" |
107 | type="date" | 107 | type="date" |
108 | ref="tdsyqssj" | ||
108 | :picker-options="childItem.pickerStart" | 109 | :picker-options="childItem.pickerStart" |
109 | value-format="yyyy-MM-dd" | 110 | value-format="yyyy-MM-dd" |
110 | placeholder="选择日期" | 111 | placeholder="选择日期" |
112 | @blur="inputBlur($event,true)" | ||
111 | @input="startTime(index,childIndex)" | 113 | @input="startTime(index,childIndex)" |
112 | > | 114 | > |
113 | </el-date-picker> | 115 | </el-date-picker> |
... | @@ -151,7 +153,11 @@ | ... | @@ -151,7 +153,11 @@ |
151 | <li> | 153 | <li> |
152 | <input | 154 | <input |
153 | type="text" | 155 | type="text" |
154 | 156 | ref="syqx" | |
157 | @blur="inputBlur($event,false)" | ||
158 | maxlength="3" | ||
159 | onkeyup="value=value.replace(/[^\d]/g,'')" | ||
160 | @input="sumTime(index,childIndex,childItem.syqx,childItem.syqx)" | ||
155 | :disabled="formData.qszt!='0'" | 161 | :disabled="formData.qszt!='0'" |
156 | v-model="childItem.syqx" | 162 | v-model="childItem.syqx" |
157 | class="formInput" | 163 | class="formInput" |
... | @@ -212,8 +218,10 @@ | ... | @@ -212,8 +218,10 @@ |
212 | :disabled="formData.qszt!='0'" | 218 | :disabled="formData.qszt!='0'" |
213 | v-model="childItem.tdsyjssj" | 219 | v-model="childItem.tdsyjssj" |
214 | type="date" | 220 | type="date" |
221 | ref="tdsyjssj" | ||
222 | @blur="inputBlur($event,true)" | ||
215 | :picker-options="childItem.pickerEnd" | 223 | :picker-options="childItem.pickerEnd" |
216 | @input="endTime(index,childIndex)" | 224 | @input="endTime(index,childIndex,$event)" |
217 | value-format="yyyy-MM-dd" | 225 | value-format="yyyy-MM-dd" |
218 | placeholder="选择日期" | 226 | placeholder="选择日期" |
219 | > | 227 | > |
... | @@ -234,6 +242,7 @@ | ... | @@ -234,6 +242,7 @@ |
234 | :props="treeProps" | 242 | :props="treeProps" |
235 | :check-strictly="checkStrictly" | 243 | :check-strictly="checkStrictly" |
236 | :clearable="clearable" | 244 | :clearable="clearable" |
245 | ref="qlxzdm" | ||
237 | v-model="items.qlxzdm" | 246 | v-model="items.qlxzdm" |
238 | ></el-select-tree> | 247 | ></el-select-tree> |
239 | </div> | 248 | </div> |
... | @@ -301,6 +310,7 @@ export default { | ... | @@ -301,6 +310,7 @@ export default { |
301 | }, | 310 | }, |
302 | ], | 311 | ], |
303 | outNum: 0, | 312 | outNum: 0, |
313 | rulesResult:true,//权利性质表单校验结果 | ||
304 | }; | 314 | }; |
305 | }, | 315 | }, |
306 | created() {}, | 316 | created() {}, |
... | @@ -322,11 +332,23 @@ export default { | ... | @@ -322,11 +332,23 @@ export default { |
322 | } | 332 | } |
323 | if (Object.keys(startTime).length > 0 && Object.keys(endTime).length > 0) { | 333 | if (Object.keys(startTime).length > 0 && Object.keys(endTime).length > 0) { |
324 | let startYear= new Date(startTime).getFullYear(); | 334 | let startYear= new Date(startTime).getFullYear(); |
325 | let endYear=new Date(endTime).getFullYear(); | 335 | let endYear=new Date(endTime).getFullYear(); |
326 | this.countList[index].list[childIndex].syqx=endYear-startYear; | 336 | //年限暂时不算 |
337 | // this.countList[index].list[childIndex].syqx=endYear-startYear; | ||
327 | } | 338 | } |
328 | }, | 339 | }, |
329 | endTime(index,childIndex){ | 340 | sumTime(index,childIndex,syqx,e){ |
341 | console.log(e,'eeee'); | ||
342 | this.$refs.syqx.forEach((item,index)=>{ | ||
343 | if(item.value == syqx){ | ||
344 | this.$refs.tdsyjssj[index].$el.style.border="" | ||
345 | } | ||
346 | }) | ||
347 | let startTime = this.countList[index].list[childIndex].tdsyqssj; | ||
348 | this.countList[index].list[childIndex].tdsyjssj = Number(startTime.substring(0,4))+Number(syqx)+startTime.slice(4,10); | ||
349 | }, | ||
350 | endTime(index,childIndex,e){ | ||
351 | console.log(e,'eeeeee'); | ||
330 | let startTime = this.countList[index].list[childIndex].tdsyqssj; | 352 | let startTime = this.countList[index].list[childIndex].tdsyqssj; |
331 | let endTime = this.countList[index].list[childIndex].tdsyjssj; | 353 | let endTime = this.countList[index].list[childIndex].tdsyjssj; |
332 | this.countList[index].list[childIndex].pickerStart={ | 354 | this.countList[index].list[childIndex].pickerStart={ |
... | @@ -341,7 +363,7 @@ export default { | ... | @@ -341,7 +363,7 @@ export default { |
341 | if (Object.keys(startTime).length > 0 && Object.keys(endTime).length > 0) { | 363 | if (Object.keys(startTime).length > 0 && Object.keys(endTime).length > 0) { |
342 | let startYear= new Date(startTime).getFullYear(); | 364 | let startYear= new Date(startTime).getFullYear(); |
343 | let endYear=new Date(endTime).getFullYear(); | 365 | let endYear=new Date(endTime).getFullYear(); |
344 | this.countList[index].list[childIndex].syqx=endYear-startYear; | 366 | // this.countList[index].list[childIndex].syqx=endYear-startYear; |
345 | } | 367 | } |
346 | }, | 368 | }, |
347 | //外层操作 | 369 | //外层操作 |
... | @@ -432,8 +454,94 @@ export default { | ... | @@ -432,8 +454,94 @@ export default { |
432 | }); | 454 | }); |
433 | }, | 455 | }, |
434 | getQlxzDataList() { | 456 | getQlxzDataList() { |
457 | console.log(this.countList,'this.countList'); | ||
435 | return this.countList; | 458 | return this.countList; |
436 | }, | 459 | }, |
460 | getRules(){ | ||
461 | let rules = []; | ||
462 | console.log(this.$refs.tdsyqssj,'this.$refs.qlxzdm'); | ||
463 | console.log(this.countList,'this.countList'); | ||
464 | let temp = 0; | ||
465 | this.countList.forEach((item,index)=>{ | ||
466 | rules.push({ | ||
467 | data:this.countList[index].qlxzdm, | ||
468 | name:'权利性质', | ||
469 | dom:this.$refs.qlxzdm[index], | ||
470 | rule: /^\s*$/g, //非空 | ||
471 | }) | ||
472 | item.list.forEach((j,ind)=>{ | ||
473 | rules.push( | ||
474 | { | ||
475 | data:item.list[ind].tdsyqssj, | ||
476 | name:'土地使用起始时间', | ||
477 | dom:this.$refs.tdsyqssj[temp+ind], | ||
478 | // val:this.$refs.tdsyqssj[temp+ind].value, | ||
479 | rule: /^\s*$/g, //非空 | ||
480 | }, | ||
481 | { | ||
482 | data:item.list[ind].syqx, | ||
483 | name:'使用期限', | ||
484 | dom:this.$refs.syqx[temp+ind], | ||
485 | // val:this.$refs.syqx[temp+ind].value, | ||
486 | rule: /^\s*$/g, //非空 | ||
487 | }, | ||
488 | { | ||
489 | data:item.list[ind].tdsyjssj, | ||
490 | name:'土地使用结束时间', | ||
491 | dom:this.$refs.tdsyjssj[temp+ind], | ||
492 | // val:this.$refs.tdsyjssj[temp+ind].value, | ||
493 | rule: /^\s*$/g, //非空 | ||
494 | }, | ||
495 | ) | ||
496 | if (ind == item.list.length-1) { | ||
497 | temp += item.list.length; | ||
498 | } | ||
499 | }) | ||
500 | }) | ||
501 | this.rulesResult = true; | ||
502 | rules.forEach(item=>{ | ||
503 | if(item.rule.test(item.data) || item.data == null){ | ||
504 | if(item.dom.$el){ | ||
505 | item.dom.$el.style.border = '1px solid red'; | ||
506 | }else{ | ||
507 | item.dom.style.border = '1px solid red'; | ||
508 | } | ||
509 | // this.$message({ | ||
510 | // // message: item.name+'不能为空', | ||
511 | // message: '不能为空', | ||
512 | // type: "warning", | ||
513 | // }); | ||
514 | this.rulesResult = false; | ||
515 | return false | ||
516 | } | ||
517 | }) | ||
518 | // console.log(rules,'rules'); | ||
519 | }, | ||
520 | getRulesResult(){ | ||
521 | return this.rulesResult | ||
522 | }, | ||
523 | inputBlur(e,flag){ | ||
524 | if (flag) { | ||
525 | if(e.value!=''){ | ||
526 | e.$el.style.border="" | ||
527 | }else{ | ||
528 | e.$el.style.border="1px solid red" | ||
529 | } | ||
530 | }else{ | ||
531 | if(e.target.value!=''){ | ||
532 | e.target.style.border="" | ||
533 | }else{ | ||
534 | e.target.style.border="1px solid red" | ||
535 | } | ||
536 | } | ||
537 | }, | ||
538 | //后续考虑在点击加减号时操作校验规则 | ||
539 | // addRules(){ | ||
540 | // this.tempQssj.push() | ||
541 | // }, | ||
542 | // minusRules(){ | ||
543 | |||
544 | // }, | ||
437 | }, | 545 | }, |
438 | }; | 546 | }; |
439 | </script> | 547 | </script> | ... | ... |
This diff is collapsed.
Click to expand it.
-
Please register or sign in to post a comment