Showing
1 changed file
with
165 additions
and
11 deletions
| ... | @@ -13,15 +13,54 @@ export const inputBlurValidate = { | ... | @@ -13,15 +13,54 @@ export const inputBlurValidate = { |
| 13 | methods: { | 13 | methods: { |
| 14 | // 最小件数失焦事件 | 14 | // 最小件数失焦事件 |
| 15 | inputBlurMinPieces({ index, queryForm }) { | 15 | inputBlurMinPieces({ index, queryForm }) { |
| 16 | - console.log(index, queryForm); | 16 | + const validateData = { |
| 17 | - // this.validateNumOfPieces(target.value, "minNumOfPieces"); | 17 | + reg: /^\d+$/, |
| 18 | + index: index, | ||
| 19 | + minNumOfPieces: queryForm.minNumOfPieces, | ||
| 20 | + maxNumOfPieces: queryForm.maxNumOfPieces, | ||
| 21 | + errorMsgAttr: "piecesMsg", | ||
| 22 | + validateForm: false, // form表单节流阀 | ||
| 23 | + errorMsg: { | ||
| 24 | + empty: "不能为空", | ||
| 25 | + valid: "请输入有效件数", | ||
| 26 | + range: "件数不得小于1", | ||
| 27 | + interval: "最小件数和最大件数不能小于1", | ||
| 28 | + }, | ||
| 29 | + }; | ||
| 30 | + this.validateNumOfPieces(validateData); | ||
| 18 | }, | 31 | }, |
| 19 | // 最大件数失焦事件 | 32 | // 最大件数失焦事件 |
| 20 | - inputBlurMaxPieces({ index, item = queryForm }) { | 33 | + inputBlurMaxPieces({ index, queryForm }) { |
| 21 | - // this.validateNumOfPieces(target.value, "maxNumOfPieces"); | 34 | + const validateData = { |
| 35 | + reg: /^\d+$/, | ||
| 36 | + index: index, | ||
| 37 | + minNumOfPieces: queryForm.minNumOfPieces, | ||
| 38 | + maxNumOfPieces: queryForm.maxNumOfPieces, | ||
| 39 | + errorMsgAttr: "piecesMsg", | ||
| 40 | + validateForm: false, // form表单节流阀 | ||
| 41 | + errorMsg: { | ||
| 42 | + empty: "不能为空", | ||
| 43 | + valid: "请输入有效件数", | ||
| 44 | + range: "件数不得小于1", | ||
| 45 | + interval: "最小件数和最大件数不能小于1", | ||
| 46 | + }, | ||
| 47 | + }; | ||
| 22 | }, | 48 | }, |
| 23 | // 最小重量失焦事件 | 49 | // 最小重量失焦事件 |
| 24 | - inputBlurMinWeight({ index, item = queryForm }) { | 50 | + inputBlurMinWeight({ index, queryForm }) { |
| 51 | + const validateData = { | ||
| 52 | + reg: /^(0|[1-9]\d*)(.\d{1,2})?$/, | ||
| 53 | + index: index, | ||
| 54 | + minWeight: queryForm.minWeight, | ||
| 55 | + maxWeight: queryForm.maxWeight, | ||
| 56 | + errorMsgAttr: "weightMsg", | ||
| 57 | + validateForm: false, // form表单节流阀 | ||
| 58 | + errorMsg: { | ||
| 59 | + empty: "不能为空", | ||
| 60 | + valid: "请输入有效重量,小数保留5位", | ||
| 61 | + interval: "最小重量不得大于最大重量", | ||
| 62 | + }, | ||
| 63 | + }; | ||
| 25 | return; | 64 | return; |
| 26 | // 重量最小值和最大值都为空的情况下 | 65 | // 重量最小值和最大值都为空的情况下 |
| 27 | if (this.queryForm.minWeight == "" && this.queryForm.maxWeight == "") { | 66 | if (this.queryForm.minWeight == "" && this.queryForm.maxWeight == "") { |
| ... | @@ -79,7 +118,20 @@ export const inputBlurValidate = { | ... | @@ -79,7 +118,20 @@ export const inputBlurValidate = { |
| 79 | } | 118 | } |
| 80 | }, | 119 | }, |
| 81 | // 最大重量失焦事件 | 120 | // 最大重量失焦事件 |
| 82 | - inputBlurMaxWeight({ index, item = queryForm }) { | 121 | + inputBlurMaxWeight({ index, queryForm }) { |
| 122 | + const validateData = { | ||
| 123 | + reg: /^(0|[1-9]\d*)(.\d{1,2})?$/, | ||
| 124 | + index: index, | ||
| 125 | + minWeight: queryForm.minWeight, | ||
| 126 | + maxWeight: queryForm.maxWeight, | ||
| 127 | + errorMsgAttr: "weightMsg", | ||
| 128 | + validateForm: false, // form表单节流阀 | ||
| 129 | + errorMsg: { | ||
| 130 | + empty: "不能为空", | ||
| 131 | + valid: "请输入有效重量,小数保留5位", | ||
| 132 | + interval: "最小重量不得大于最大重量", | ||
| 133 | + }, | ||
| 134 | + }; | ||
| 83 | return; | 135 | return; |
| 84 | // 重量最小值和最大值都为空的情况下 | 136 | // 重量最小值和最大值都为空的情况下 |
| 85 | if (this.queryForm.minWeight == "" && this.queryForm.maxWeight == "") { | 137 | if (this.queryForm.minWeight == "" && this.queryForm.maxWeight == "") { |
| ... | @@ -151,7 +203,20 @@ export const inputBlurValidate = { | ... | @@ -151,7 +203,20 @@ export const inputBlurValidate = { |
| 151 | return "数字合法"; | 203 | return "数字合法"; |
| 152 | }, | 204 | }, |
| 153 | // 人民币最小申报价值 | 205 | // 人民币最小申报价值 |
| 154 | - inputCNYBlurMin({ index, item = queryForm }, customVal) { | 206 | + inputCNYBlurMin({ index, queryForm }) { |
| 207 | + const validateData = { | ||
| 208 | + reg: /^(0|[1-9]\d*)(.\d{1,2})?$/, | ||
| 209 | + index: index, | ||
| 210 | + minCustomVal: queryForm.minCustomVal, | ||
| 211 | + maxCustomVal: queryForm.maxCustomVal, | ||
| 212 | + errorMsgAttr: "currencyCdMsg", // 币种 | ||
| 213 | + validateForm: false, // form表单节流阀 | ||
| 214 | + errorMsg: { | ||
| 215 | + empty: "不能为空", | ||
| 216 | + valid: "请输入有效申报价值,小数保留2位", | ||
| 217 | + interval: "最小申报价值不得大于最大申报价值", | ||
| 218 | + }, | ||
| 219 | + }; | ||
| 155 | return; | 220 | return; |
| 156 | // 申报价值最小值和最大值都为空的情况下 | 221 | // 申报价值最小值和最大值都为空的情况下 |
| 157 | if ( | 222 | if ( |
| ... | @@ -216,7 +281,20 @@ export const inputBlurValidate = { | ... | @@ -216,7 +281,20 @@ export const inputBlurValidate = { |
| 216 | } | 281 | } |
| 217 | }, | 282 | }, |
| 218 | // 人民币最大申报价值 | 283 | // 人民币最大申报价值 |
| 219 | - inputCNYBlurMax({ index, item = queryForm }, customVal) { | 284 | + inputCNYBlurMax({ index, queryForm }) { |
| 285 | + const validateData = { | ||
| 286 | + reg: /^(0|[1-9]\d*)(.\d{1,2})?$/, | ||
| 287 | + index: index, | ||
| 288 | + minCustomVal: queryForm.minCustomVal, | ||
| 289 | + maxCustomVal: queryForm.maxCustomVal, | ||
| 290 | + errorMsgAttr: "currencyCdMsg", // 币种 | ||
| 291 | + validateForm: false, // form表单节流阀 | ||
| 292 | + errorMsg: { | ||
| 293 | + empty: "不能为空", | ||
| 294 | + valid: "请输入有效申报价值,小数保留2位", | ||
| 295 | + interval: "最小申报价值不得大于最大申报价值", | ||
| 296 | + }, | ||
| 297 | + }; | ||
| 220 | return; | 298 | return; |
| 221 | // 申报价值最小值和最大值都为空的情况下 | 299 | // 申报价值最小值和最大值都为空的情况下 |
| 222 | if ( | 300 | if ( |
| ... | @@ -282,7 +360,20 @@ export const inputBlurValidate = { | ... | @@ -282,7 +360,20 @@ export const inputBlurValidate = { |
| 282 | } | 360 | } |
| 283 | }, | 361 | }, |
| 284 | // 美元最小申报价值 | 362 | // 美元最小申报价值 |
| 285 | - inputSUDBlurMin({ index, item = queryForm }, customVal) { | 363 | + inputSUDBlurMin({ index, queryForm }) { |
| 364 | + const validateData = { | ||
| 365 | + reg: /^(0|[1-9]\d*)(.\d{1,2})?$/, | ||
| 366 | + index: index, | ||
| 367 | + minUsdCustomVal: queryForm.minUsdCustomVal, | ||
| 368 | + maxUsdCustomVal: queryForm.maxUsdCustomVal, | ||
| 369 | + errorMsgAttr: "currencyCdUsd", // 币种 | ||
| 370 | + validateForm: false, // form表单节流阀 | ||
| 371 | + errorMsg: { | ||
| 372 | + empty: "不能为空", | ||
| 373 | + valid: "请输入有效申报价值,小数保留2位", | ||
| 374 | + interval: "最小申报价值不得大于最大申报价值", | ||
| 375 | + }, | ||
| 376 | + }; | ||
| 286 | return; | 377 | return; |
| 287 | // 申报价值最小值和最大值都为空的情况下 | 378 | // 申报价值最小值和最大值都为空的情况下 |
| 288 | if ( | 379 | if ( |
| ... | @@ -349,7 +440,20 @@ export const inputBlurValidate = { | ... | @@ -349,7 +440,20 @@ export const inputBlurValidate = { |
| 349 | } | 440 | } |
| 350 | }, | 441 | }, |
| 351 | // 美元最大申报价值 | 442 | // 美元最大申报价值 |
| 352 | - inputSUDBlurMax({ index, item = queryForm }, customVal) { | 443 | + inputSUDBlurMax({ index, queryForm }) { |
| 444 | + const validateData = { | ||
| 445 | + reg: /^(0|[1-9]\d*)(.\d{1,2})?$/, | ||
| 446 | + index: index, | ||
| 447 | + minUsdCustomVal: queryForm.minUsdCustomVal, | ||
| 448 | + maxUsdCustomVal: queryForm.maxUsdCustomVal, | ||
| 449 | + errorMsgAttr: "currencyCdUsd", // 币种 | ||
| 450 | + validateForm: false, // form表单节流阀 | ||
| 451 | + errorMsg: { | ||
| 452 | + empty: "不能为空", | ||
| 453 | + valid: "请输入有效申报价值,小数保留2位", | ||
| 454 | + interval: "最小申报价值不得大于最大申报价值", | ||
| 455 | + }, | ||
| 456 | + }; | ||
| 353 | return; | 457 | return; |
| 354 | // 申报价值最小值和最大值都为空的情况下 | 458 | // 申报价值最小值和最大值都为空的情况下 |
| 355 | if ( | 459 | if ( |
| ... | @@ -417,8 +521,58 @@ export const inputBlurValidate = { | ... | @@ -417,8 +521,58 @@ export const inputBlurValidate = { |
| 417 | } | 521 | } |
| 418 | }, | 522 | }, |
| 419 | // 校验件数方法 【件数可以为空但件数不得为0】只能输入正整数 | 523 | // 校验件数方法 【件数可以为空但件数不得为0】只能输入正整数 |
| 420 | - validateNumOfPieces({ index, item }) { | 524 | + validateNumOfPieces(item) { |
| 525 | + if (item.minNumOfPieces == "" && item.maxNumOfPieces == "") { | ||
| 526 | + this.queryForm[item.errorMsgAttr] = ""; | ||
| 527 | + this.queryForm.validateForm = true; | ||
| 528 | + } | ||
| 529 | + if (item.minNumOfPieces == "" && item.maxNumOfPieces) { | ||
| 530 | + if ( | ||
| 531 | + item.reg.test(Number(item.maxNumOfPieces)) && | ||
| 532 | + Number(item.maxNumOfPieces) > 0 | ||
| 533 | + ) { | ||
| 534 | + this.queryForm[item.errorMsgAttr] = ""; | ||
| 535 | + this.queryForm.validateForm = true; | ||
| 536 | + } else { | ||
| 537 | + this.queryForm[item.errorMsgAttr] = item.errorMsg.valid; | ||
| 538 | + this.queryForm.validateForm = false; | ||
| 539 | + } | ||
| 540 | + } | ||
| 541 | + | ||
| 542 | + if (item.minNumOfPieces && Number(item.minNumOfPieces) > 0) { | ||
| 543 | + if (item.reg.test(Number(item.minNumOfPieces))) { | ||
| 544 | + if (this.queryForm.maxWeight) { | ||
| 545 | + if (Number(item.maxNumOfPieces) < Number(item.minNumOfPieces)) { | ||
| 546 | + this.queryForm[item.errorMsgAttr] = item.errorMsg.interval; | ||
| 547 | + this.queryForm.validateForm = false; | ||
| 548 | + } else if (item.reg.test(Number(item.maxNumOfPieces))) { | ||
| 549 | + this.queryForm[item.errorMsgAttr] = ""; | ||
| 550 | + this.queryForm.validateForm = true; | ||
| 551 | + } else { | ||
| 552 | + this.queryForm[item.errorMsgAttr] = item.errorMsg.valid; | ||
| 553 | + this.queryForm.validateForm = false; | ||
| 554 | + } | ||
| 555 | + } else { | ||
| 556 | + this.queryForm[item.errorMsgAttr] = ""; | ||
| 557 | + this.queryForm.validateForm = true; | ||
| 558 | + } | ||
| 559 | + } else { | ||
| 560 | + this.queryForm[item.errorMsgAttr] = item.errorMsg.valid; | ||
| 561 | + this.queryForm.validateForm = false; | ||
| 562 | + } | ||
| 563 | + } else { | ||
| 564 | + if (item.minNumOfPieces && isNaN(item.minNumOfPieces)) { | ||
| 565 | + this.queryForm[item.errorMsgAttr] = item.errorMsg.valid; | ||
| 566 | + this.queryForm.validateForm = false; | ||
| 567 | + } | ||
| 568 | + if (Number(item.minNumOfPieces) < 0) { | ||
| 569 | + this.queryForm[item.errorMsgAttr] = item.errorMsg.valid; | ||
| 570 | + this.queryForm.validateForm = false; | ||
| 571 | + } | ||
| 572 | + } | ||
| 573 | + console.log(this.queryForm.validateForm); | ||
| 421 | return; | 574 | return; |
| 575 | + | ||
| 422 | if (value.toString().length) { | 576 | if (value.toString().length) { |
| 423 | // 获取当前输入框有值的情况下 | 577 | // 获取当前输入框有值的情况下 |
| 424 | this.queryForm[pieces] = Number(value); | 578 | this.queryForm[pieces] = Number(value); | ... | ... |
-
Please register or login to post a comment