Elements-SY

modify

...@@ -13,11 +13,118 @@ export const inputBlurValidate = { ...@@ -13,11 +13,118 @@ export const inputBlurValidate = {
13 methods: { 13 methods: {
14 // 最小件数失焦事件 14 // 最小件数失焦事件
15 inputBlurMinPieces({ target }) { 15 inputBlurMinPieces({ target }) {
16 - this.validateNumOfPieces(target.value, "minNumOfPieces"); 16 + // 件数最小值和最大值都为空的情况下
17 + if (
18 + this.queryForm.minNumOfPieces == "" &&
19 + this.queryForm.maxNumOfPieces == ""
20 + ) {
21 + this.validateForm = true;
22 + this.$refs.minNumOfPieces.innerHTML = "";
23 + }
24 + // 鼠标聚焦最小件数,最小件数无值的情况下去校验最大件数
25 + if (target.value == "" && this.queryForm.maxNumOfPieces) {
26 + if (/^[1-9]\d*$/.test(Number(this.queryForm.maxNumOfPieces))) {
27 + this.validateForm = true;
28 + this.$refs.minNumOfPieces.innerHTML = "";
29 + } else {
30 + this.validateForm = false;
31 + this.$refs.minNumOfPieces.innerHTML = "请输入有效件数";
32 + }
33 + }
34 + // 最小件数有值的情况下
35 + if (target.value && Number(target.value) > 0) {
36 + if (/^[1-9]\d*$/.test(Number(target.value))) {
37 + if (this.queryForm.maxNumOfPieces) {
38 + if (
39 + Number(this.queryForm.maxNumOfPieces) <
40 + Number(this.queryForm.minNumOfPieces)
41 + ) {
42 + this.validateForm = false;
43 + this.$refs.minNumOfPieces.innerHTML = "最小件数不得大于最大件数";
44 + } else if (
45 + /^[1-9]\d*$/.test(Number(this.queryForm.maxNumOfPieces))
46 + ) {
47 + this.validateForm = true;
48 + this.$refs.minNumOfPieces.innerHTML = "";
49 + } else {
50 + this.validateForm = false;
51 + this.$refs.minNumOfPieces.innerHTML = "请输入有效件数";
52 + }
53 + } else {
54 + this.validateForm = true;
55 + this.$refs.minNumOfPieces.innerHTML = "";
56 + }
57 + } else {
58 + this.validateForm = false;
59 + this.$refs.minNumOfPieces.innerHTML = "请输入有效件数";
60 + }
61 + } else {
62 + if (target.value && isNaN(target.value)) {
63 + this.validateForm = false;
64 + this.$refs.minNumOfPieces.innerHTML = "请输入有效件数";
65 + }
66 + if (target.value && Number(target.value) < 1) {
67 + this.validateForm = false;
68 + this.$refs.minNumOfPieces.innerHTML = "请输入有效件数";
69 + }
70 + }
17 }, 71 },
18 // 最大件数失焦事件 72 // 最大件数失焦事件
19 inputBlurMaxPieces({ target }) { 73 inputBlurMaxPieces({ target }) {
20 - this.validateNumOfPieces(target.value, "maxNumOfPieces"); 74 + // 件数最小值和最大值都为空的情况下
75 + if (
76 + this.queryForm.minNumOfPieces == "" &&
77 + this.queryForm.maxNumOfPieces == ""
78 + ) {
79 + this.validateForm = true;
80 + this.$refs.minNumOfPieces.innerHTML = "";
81 + }
82 + // 鼠标聚焦最大件数,最大件数无值的情况下去校验最小件数
83 + if (target.value == "" && this.queryForm.minNumOfPieces) {
84 + if (/^[1-9]\d*$/.test(Number(this.queryForm.minNumOfPieces))) {
85 + this.validateForm = true;
86 + this.$refs.minNumOfPieces.innerHTML = "";
87 + } else {
88 + this.validateForm = false;
89 + this.$refs.minNumOfPieces.innerHTML = "请输入有效件数";
90 + }
91 + }
92 + if (target.value && Number(target.value) > 0) {
93 + if (/^[1-9]\d*$/.test(Number(target.value))) {
94 + if (this.queryForm.minNumOfPieces) {
95 + if (
96 + Number(this.queryForm.maxNumOfPieces) <
97 + Number(this.queryForm.minNumOfPieces)
98 + ) {
99 + this.validateForm = false;
100 + this.$refs.minNumOfPieces.innerHTML = "最小件数不得大于最大件数";
101 + } else if (
102 + /^[1-9]\d*$/.test(Number(this.queryForm.minNumOfPieces))
103 + ) {
104 + this.validateForm = true;
105 + this.$refs.minNumOfPieces.innerHTML = "";
106 + } else {
107 + this.validateForm = false;
108 + this.$refs.minNumOfPieces.innerHTML = "请输入有效件数";
109 + }
110 + } else {
111 + this.validateForm = true;
112 + this.$refs.minNumOfPieces.innerHTML = "";
113 + }
114 + } else {
115 + this.validateForm = false;
116 + this.$refs.minNumOfPieces.innerHTML = "请输入有效件数";
117 + }
118 + } else {
119 + if (target.value && isNaN(target.value)) {
120 + this.validateForm = false;
121 + this.$refs.minNumOfPieces.innerHTML = "请输入有效件数";
122 + }
123 + if (target.value && Number(target.value) < 1) {
124 + this.validateForm = false;
125 + this.$refs.minNumOfPieces.innerHTML = "请输入有效件数";
126 + }
127 + }
21 }, 128 },
22 // 最小重量失焦事件 129 // 最小重量失焦事件
23 inputBlurMinWeight({ target }) { 130 inputBlurMinWeight({ target }) {
...@@ -70,7 +177,7 @@ export const inputBlurValidate = { ...@@ -70,7 +177,7 @@ export const inputBlurValidate = {
70 this.validateForm = false; 177 this.validateForm = false;
71 this.$refs.minWeight.innerHTML = "请输入有效重量,小数保留5位"; 178 this.$refs.minWeight.innerHTML = "请输入有效重量,小数保留5位";
72 } 179 }
73 - if (Number(target.value) < 0) { 180 + if (target.value && Number(target.value) < 0) {
74 this.validateForm = false; 181 this.validateForm = false;
75 this.$refs.minWeight.innerHTML = "请输入有效重量,小数保留5位"; 182 this.$refs.minWeight.innerHTML = "请输入有效重量,小数保留5位";
76 } 183 }
...@@ -127,7 +234,7 @@ export const inputBlurValidate = { ...@@ -127,7 +234,7 @@ export const inputBlurValidate = {
127 this.validateForm = false; 234 this.validateForm = false;
128 this.$refs.minWeight.innerHTML = "请输入有效重量,小数保留5位"; 235 this.$refs.minWeight.innerHTML = "请输入有效重量,小数保留5位";
129 } 236 }
130 - if (Number(target.value) < 0) { 237 + if (target.value && Number(target.value) < 0) {
131 this.validateForm = false; 238 this.validateForm = false;
132 this.$refs.minWeight.innerHTML = "请输入有效重量,小数保留5位"; 239 this.$refs.minWeight.innerHTML = "请输入有效重量,小数保留5位";
133 } 240 }
...@@ -190,7 +297,7 @@ export const inputBlurValidate = { ...@@ -190,7 +297,7 @@ export const inputBlurValidate = {
190 this.$refs.minCNYCustomVal.innerHTML = 297 this.$refs.minCNYCustomVal.innerHTML =
191 "请输入有效申报价值,小数保留2位"; 298 "请输入有效申报价值,小数保留2位";
192 } 299 }
193 - if (Number(target.value) < 0) { 300 + if (target.value && Number(target.value) < 0) {
194 this.validateForm = false; 301 this.validateForm = false;
195 this.$refs.minCNYCustomVal.innerHTML = 302 this.$refs.minCNYCustomVal.innerHTML =
196 "请输入有效申报价值,小数保留2位"; 303 "请输入有效申报价值,小数保留2位";
...@@ -255,7 +362,7 @@ export const inputBlurValidate = { ...@@ -255,7 +362,7 @@ export const inputBlurValidate = {
255 this.$refs.minCNYCustomVal.innerHTML = 362 this.$refs.minCNYCustomVal.innerHTML =
256 "请输入有效申报价值,小数保留2位"; 363 "请输入有效申报价值,小数保留2位";
257 } 364 }
258 - if (Number(target.value) < 0) { 365 + if (target.value && Number(target.value) < 0) {
259 this.validateForm = false; 366 this.validateForm = false;
260 this.$refs.minCNYCustomVal.innerHTML = 367 this.$refs.minCNYCustomVal.innerHTML =
261 "请输入有效申报价值,小数保留2位"; 368 "请输入有效申报价值,小数保留2位";
...@@ -321,7 +428,7 @@ export const inputBlurValidate = { ...@@ -321,7 +428,7 @@ export const inputBlurValidate = {
321 this.$refs.minSUDCustomVal.innerHTML = 428 this.$refs.minSUDCustomVal.innerHTML =
322 "请输入有效申报价值,小数保留2位"; 429 "请输入有效申报价值,小数保留2位";
323 } 430 }
324 - if (Number(target.value) < 0) { 431 + if (target.value && Number(target.value) < 0) {
325 this.validateForm = false; 432 this.validateForm = false;
326 this.$refs.minSUDCustomVal.innerHTML = 433 this.$refs.minSUDCustomVal.innerHTML =
327 "请输入有效申报价值,小数保留2位"; 434 "请输入有效申报价值,小数保留2位";
...@@ -388,128 +495,12 @@ export const inputBlurValidate = { ...@@ -388,128 +495,12 @@ export const inputBlurValidate = {
388 this.$refs.minSUDCustomVal.innerHTML = 495 this.$refs.minSUDCustomVal.innerHTML =
389 "请输入有效申报价值,小数保留2位"; 496 "请输入有效申报价值,小数保留2位";
390 } 497 }
391 - if (Number(target.value) < 0) { 498 + if (target.value && Number(target.value) < 0) {
392 this.validateForm = false; 499 this.validateForm = false;
393 this.$refs.minSUDCustomVal.innerHTML = 500 this.$refs.minSUDCustomVal.innerHTML =
394 "请输入有效申报价值,小数保留2位"; 501 "请输入有效申报价值,小数保留2位";
395 } 502 }
396 } 503 }
397 }, 504 },
398 - // 校验件数方法 【件数可以为空但件数不得为0】只能输入正整数
399 - validateNumOfPieces(value, pieces) {
400 - if (value.toString().length) {
401 - // 获取当前输入框有值的情况下
402 - this.queryForm[pieces] = Number(value);
403 - let markPieces = false;
404 - if (pieces == "minNumOfPieces" || pieces == "maxNumOfPieces") {
405 - // 最大件数和最小件数都不为空的情况下
406 - if (
407 - this.queryForm.minNumOfPieces.toString() != "" &&
408 - this.queryForm.maxNumOfPieces.toString() != ""
409 - ) {
410 - this.validateForm = true;
411 - this.$refs.minNumOfPieces.innerHTML = "";
412 - markPieces = true;
413 - } else {
414 - markPieces = false;
415 - }
416 - }
417 - if (/^\d+$/.test(this.queryForm[pieces])) {
418 - if (markPieces) {
419 - //当最大件数和最小件数都不为空的情况下,最大件数小于最小件数的时候
420 - if (this.queryForm.maxNumOfPieces < this.queryForm.minNumOfPieces) {
421 - if (Array.isArray(this.$refs.minNumOfPieces)) {
422 - this.msgError("最小件数不得大于最大件数");
423 - this.validateForm = false;
424 - } else {
425 - this.$refs.minNumOfPieces.innerHTML = "";
426 - this.$refs.minNumOfPieces.innerHTML =
427 - "最小件数不得大于最大件数";
428 - this.validateForm = false;
429 - }
430 - }
431 - //当最大件数和最小件数都不为空的情况下,最大件数和最小件数小于1的时候
432 - else if (
433 - this.queryForm.minNumOfPieces < 1 ||
434 - this.queryForm.maxNumOfPieces < 1
435 - ) {
436 - if (Array.isArray(this.$refs.minNumOfPieces)) {
437 - this.msgError("最小件数和最大件数不能小于1");
438 - this.validateForm = false;
439 - } else {
440 - this.$refs.minNumOfPieces.innerHTML = "";
441 - this.$refs.minNumOfPieces.innerHTML =
442 - "最小件数和最大件数不能小于1";
443 - this.validateForm = false;
444 - }
445 - }
446 - //当最大件数和最小件数都不为空的情况下,最大件数和最小件数满足大于1左区间小于等于右区间的时候
447 - else {
448 - this.$refs.minNumOfPieces.innerHTML = "";
449 - this.validateForm = true;
450 - }
451 - } else {
452 - // 当左右区间其中一个有值的情况下
453 - if (value.length) {
454 - if (Number(value) < 1) {
455 - if (Array.isArray(this.$refs.minNumOfPieces)) {
456 - this.msgError("件数不得小于1");
457 - this.$refs.minNumOfPieces.innerHTML = "";
458 - this.$refs.minNumOfPieces.innerHTML = "件数不得小于1";
459 - this.validateForm = false;
460 - } else {
461 - this.msgError("件数不得小于1");
462 - this.$refs.minNumOfPieces.innerHTML = "";
463 - this.$refs.minNumOfPieces.innerHTML = "件数不得小于1";
464 - this.validateForm = false;
465 - }
466 - } else {
467 - if (!Array.isArray(this.$refs.minNumOfPieces)) {
468 - this.$refs.minNumOfPieces.innerHTML = "";
469 - this.validateForm = true;
470 - }
471 - }
472 - }
473 - }
474 - } else {
475 - if (Array.isArray(this.$refs.minNumOfPieces)) {
476 - this.msgError("请输入有效件数");
477 - } else {
478 - this.queryForm[pieces] = value;
479 - this.$refs.minNumOfPieces.innerHTML = "";
480 - this.$refs.minNumOfPieces.innerHTML = "请输入有效件数";
481 - }
482 - this.validateForm = false;
483 - }
484 - } else {
485 - // 【左右区间不是都有值的情况下】
486 - // 最小件数为空最大件数有值的情况下
487 - if (pieces == "minNumOfPieces" && this.queryForm.maxNumOfPieces > 0) {
488 - this.$refs.minNumOfPieces.innerHTML = "";
489 - this.validateForm = true;
490 - } else {
491 - this.$refs.minNumOfPieces.innerHTML = "";
492 - this.$refs.minNumOfPieces.innerHTML = "最大件数不得小于1";
493 - this.validateForm = false;
494 - }
495 - // 最大件数为空最小件数有值的情况下
496 - if (pieces == "maxNumOfPieces" && this.queryForm.minNumOfPieces > 0) {
497 - this.$refs.minNumOfPieces.innerHTML = "";
498 - this.validateForm = true;
499 - } else {
500 - this.$refs.minNumOfPieces.innerHTML = "";
501 - this.validateForm = true;
502 - }
503 - // 左右区间 都为空的情况下
504 - if (
505 - this.queryForm.minNumOfPieces.toString().length == 0 &&
506 - this.queryForm.maxNumOfPieces.toString().length == 0
507 - ) {
508 - this.$refs.minNumOfPieces.innerHTML = "";
509 - this.validateForm = true;
510 - }
511 - }
512 - return this.validateForm;
513 - },
514 }, 505 },
515 }; 506 };
......
...@@ -716,6 +716,7 @@ export default { ...@@ -716,6 +716,7 @@ export default {
716 this.id++; 716 this.id++;
717 this.tableData.unshift({ 717 this.tableData.unshift({
718 id: this.id, 718 id: this.id,
719 + statusMark: true, // 作为是否为新增
719 flightNo: "", // 航班号 720 flightNo: "", // 航班号
720 calculateDay: "", // 航班日期//+1 -1 721 calculateDay: "", // 航班日期//+1 -1
721 flightRoute: "", // 航线 722 flightRoute: "", // 航线
...@@ -735,7 +736,7 @@ export default { ...@@ -735,7 +736,7 @@ export default {
735 }, 736 },
736 // 删除 737 // 删除
737 deleBtn(item, $index) { 738 deleBtn(item, $index) {
738 - console.log("删除:", item, $index); 739 + // console.log("删除:", item, $index);
739 this.tableData.splice($index, 1); 740 this.tableData.splice($index, 1);
740 }, 741 },
741 // 类别 742 // 类别
...@@ -752,22 +753,37 @@ export default { ...@@ -752,22 +753,37 @@ export default {
752 this.queryForm.originOfFlightNo 753 this.queryForm.originOfFlightNo
753 ); 754 );
754 }, 755 },
756 + /*
757 + 如果是编辑,那么添加航班顺位时
758 + */
755 // 表单提交 759 // 表单提交
756 submitForm(formName) { 760 submitForm(formName) {
757 this.$refs[formName].validate((valid) => { 761 this.$refs[formName].validate((valid) => {
758 if (valid && this.validateForm) { 762 if (valid && this.validateForm) {
759 - this.tableData.map((item, i) => {
760 - item.priority = ++i;
761 - });
762 - // 爆仓是否继续配舱
763 const newtTableData = JSON.parse(JSON.stringify(this.tableData)); 763 const newtTableData = JSON.parse(JSON.stringify(this.tableData));
764 const tableData = newtTableData; 764 const tableData = newtTableData;
765 - tableData.filter((item) => { 765 + tableData.map((item, i) => {
766 + // 爆仓是否继续配舱
766 if (item.permitOverweight == false) { 767 if (item.permitOverweight == false) {
767 item.permitOverweight = "N"; 768 item.permitOverweight = "N";
768 } else { 769 } else {
769 item.permitOverweight = "Y"; 770 item.permitOverweight = "Y";
770 } 771 }
772 + // // 作为是否为新增
773 + // if (item.hasOwnProperty("statusMark")) {
774 + // delete item.id;
775 + // }
776 + if (item.hasOwnProperty("routeList")) {
777 + delete item.routeList;
778 + }
779 + item.priority = ++i;
780 + return item;
781 + });
782 + // 新增时没有id说明有statusMark字段,则删除statusMark属性
783 + tableData.map((item) => {
784 + if (!item.hasOwnProperty("id")) {
785 + delete item.statusMark;
786 + }
771 }); 787 });
772 // 校验ET86配舱航班顺位维度 788 // 校验ET86配舱航班顺位维度
773 let fltNo = this.tableData.some((item) => item.flightNo == ""); // 通过遍历判断航班顺位列表有没有填写的航班号 789 let fltNo = this.tableData.some((item) => item.flightNo == ""); // 通过遍历判断航班顺位列表有没有填写的航班号
...@@ -817,11 +833,6 @@ export default { ...@@ -817,11 +833,6 @@ export default {
817 this.postAdd(queryParmas); // 新增 833 this.postAdd(queryParmas); // 新增
818 } else { 834 } else {
819 if (this.validateForm) { 835 if (this.validateForm) {
820 - queryParmas.flightRankDtoList.map((item) => {
821 - if (item.hasOwnProperty("routeList")) {
822 - delete item.routeList;
823 - }
824 - });
825 this.postUpdate(queryParmas); // 修改 836 this.postUpdate(queryParmas); // 修改
826 } 837 }
827 } 838 }
......
...@@ -111,7 +111,7 @@ export default { ...@@ -111,7 +111,7 @@ export default {
111 } 111 }
112 } 112 }
113 }, 113 },
114 - // Ursa校验 使用JavaScript写一个匹配字母的表达式 114 + // Ursa校验
115 validateUrsa(ursaMark, ursa) { 115 validateUrsa(ursaMark, ursa) {
116 // 分隔字符串并且转数组&去除数组空字符串 116 // 分隔字符串并且转数组&去除数组空字符串
117 let ursaList = ursa.split(";").filter((str) => str !== ""); 117 let ursaList = ursa.split(";").filter((str) => str !== "");
......