Elements-SY

modify

...@@ -223,7 +223,7 @@ export function getTime(type) { ...@@ -223,7 +223,7 @@ export function getTime(type) {
223 * @return {*} 223 * @return {*}
224 */ 224 */
225 export function debounce(func, wait, immediate) { 225 export function debounce(func, wait, immediate) {
226 - let timeout, args, context, timestamp, result; 226 + let timeout, args, context, timestamp, result, data;
227 227
228 const later = function () { 228 const later = function () {
229 // 据上一次触发时间间隔 229 // 据上一次触发时间间隔
...@@ -236,7 +236,7 @@ export function debounce(func, wait, immediate) { ...@@ -236,7 +236,7 @@ export function debounce(func, wait, immediate) {
236 timeout = null; 236 timeout = null;
237 // 如果设定为immediate===true,因为开始边界已经调用过了此处无需调用 237 // 如果设定为immediate===true,因为开始边界已经调用过了此处无需调用
238 if (!immediate) { 238 if (!immediate) {
239 - result = func.apply(context, args); 239 + result = func.apply(context, data);
240 if (!timeout) context = args = null; 240 if (!timeout) context = args = null;
241 } 241 }
242 } 242 }
...@@ -245,6 +245,7 @@ export function debounce(func, wait, immediate) { ...@@ -245,6 +245,7 @@ export function debounce(func, wait, immediate) {
245 return function (...args) { 245 return function (...args) {
246 context = this; 246 context = this;
247 timestamp = +new Date(); 247 timestamp = +new Date();
248 + data = args;
248 const callNow = immediate && !timeout; 249 const callNow = immediate && !timeout;
249 // 如果延时不存在,重新设定延时 250 // 如果延时不存在,重新设定延时
250 if (!timeout) timeout = setTimeout(later, wait); 251 if (!timeout) timeout = setTimeout(later, wait);
......
...@@ -56,32 +56,22 @@ ...@@ -56,32 +56,22 @@
56 <el-table-column 56 <el-table-column
57 label="加减天数" 57 label="加减天数"
58 prop="calculateDay" 58 prop="calculateDay"
59 - width="100" 59 + width="140"
60 align="center" 60 align="center"
61 > 61 >
62 <template slot-scope="scope"> 62 <template slot-scope="scope">
63 - <el-input 63 + <el-input-number
64 - type="text"
65 v-model="scope.row.calculateDay" 64 v-model="scope.row.calculateDay"
66 :disabled="scope.row.edit" 65 :disabled="scope.row.edit"
67 - min="-7" 66 + :min="-7"
68 - max="7" 67 + :max="7"
68 + :precision="0"
69 v-input-filter 69 v-input-filter
70 clearable 70 clearable
71 placeholder="" 71 placeholder=""
72 size="small" 72 size="small"
73 + style="width: 100%"
73 /> 74 />
74 - <!-- <el-input
75 - type="number"
76 - v-model="scope.row.calculateDay"
77 - :disabled="scope.row.edit"
78 - min="-7"
79 - max="7"
80 - v-input-filter
81 - clearable
82 - placeholder=""
83 - size="small"
84 - /> -->
85 </template> 75 </template>
86 </el-table-column> 76 </el-table-column>
87 <el-table-column 77 <el-table-column
...@@ -497,40 +487,6 @@ export default { ...@@ -497,40 +487,6 @@ export default {
497 ]; 487 ];
498 } 488 }
499 }, 489 },
500 - mounted() {},
501 - directives: {
502 - // 处理加减天数
503 - "input-filter": {
504 - bind: function (el, binding, { context }) {
505 - el.handler = function (event) {
506 - if (event.data == "E" || event.data == "e") {
507 - // 无理数时
508 - event.target.value = "";
509 - }
510 - if (event.target.value) {
511 - if (Number(event.target.value) < -7) {
512 - event.target.value = "";
513 - context.msgError("加减天数最小不能低于7天");
514 - } else if (Number(event.target.value) > 7) {
515 - event.target.value = "";
516 - context.msgError("加减天数最小不能大于7天");
517 - } else if (/[\.]/.test(Number(event.target.value))) {
518 - // 浮点数时
519 - event.target.value = "";
520 - } else {
521 -
522 - }
523 - event.target.dispatchEvent(new Event("input"));
524 - }
525 - };
526 - el.addEventListener("input", el.handler);
527 - },
528 - unbind: function (el) {
529 - el.removeEventListener("input", el.handler);
530 - },
531 - },
532 - },
533 - filters: {},
534 methods: { 490 methods: {
535 // ET86新增 491 // ET86新增
536 postAdd(params) { 492 postAdd(params) {
...@@ -553,7 +509,7 @@ export default { ...@@ -553,7 +509,7 @@ export default {
553 const { code, data, msg } = res; 509 const { code, data, msg } = res;
554 if (code == 200) { 510 if (code == 200) {
555 data.list.flightRankDtoList.map((item) => { 511 data.list.flightRankDtoList.map((item) => {
556 - if (name == "view") { 512 + if (name == "view") { // 跳转页面传过来的字段值等于view展示查看
557 item.edit = true; 513 item.edit = true;
558 } else { 514 } else {
559 item.edit = false; 515 item.edit = false;
...@@ -565,13 +521,10 @@ export default { ...@@ -565,13 +521,10 @@ export default {
565 item.permitOverweight = true; 521 item.permitOverweight = true;
566 } 522 }
567 }); 523 });
568 - data.list.flightRankDtoList.map((item) => { 524 + // ET86配舱航班顺位列表
569 - item.calculateDay = item.calculateDay;
570 - });
571 - // ET86配舱航班顺位
572 this.tableData = data.list.flightRankDtoList; 525 this.tableData = data.list.flightRankDtoList;
573 Object.keys(data.list.fltRuleDto).map((key) => { 526 Object.keys(data.list.fltRuleDto).map((key) => {
574 - if (key == "multiHs") { 527 + if (key == "multiHs") { // N为单品名,Y为多品名
575 if (data.list.fltRuleDto[key] == "N") { 528 if (data.list.fltRuleDto[key] == "N") {
576 data.list.fltRuleDto[key] = true; 529 data.list.fltRuleDto[key] = true;
577 } else { 530 } else {
...@@ -583,6 +536,7 @@ export default { ...@@ -583,6 +536,7 @@ export default {
583 data.list.fltRuleDto[key] = ""; 536 data.list.fltRuleDto[key] = "";
584 } 537 }
585 }); 538 });
539 + // 申报类别详情转化成数组赋值给申报类别勾选框作为回显展示数据
586 if (data.list.fltRuleDto.declarationCategory) { 540 if (data.list.fltRuleDto.declarationCategory) {
587 this.checkboxClassType = 541 this.checkboxClassType =
588 data.list.fltRuleDto.declarationCategory.split(";"); 542 data.list.fltRuleDto.declarationCategory.split(";");
...@@ -660,24 +614,28 @@ export default { ...@@ -660,24 +614,28 @@ export default {
660 }, 614 },
661 // 失焦查询 615 // 失焦查询
662 blurSearch() { 616 blurSearch() {
617 + // 转大写字母
663 this.tableData[this.currentIndex].flightNo = this.upCase( 618 this.tableData[this.currentIndex].flightNo = this.upCase(
664 this.tableData[this.currentIndex].flightNo 619 this.tableData[this.currentIndex].flightNo
665 - ); // 转大写字母 620 + );
666 - let params = { 621 + // 筛选重复的航班:【重复规则】航班号 + 加减天数 + 航线有同样的就认为是重复
667 - fltNo: this.tableData[this.currentIndex].flightNo,
668 - };
669 let repeat = this.tableData.filter( 622 let repeat = this.tableData.filter(
670 (item) => 623 (item) =>
671 item.flightNo == this.tableData[this.currentIndex].flightNo && 624 item.flightNo == this.tableData[this.currentIndex].flightNo &&
672 item.calculateDay == this.tableData[this.currentIndex].calculateDay && 625 item.calculateDay == this.tableData[this.currentIndex].calculateDay &&
673 item.flightRoute == this.tableData[this.currentIndex].flightRoute 626 item.flightRoute == this.tableData[this.currentIndex].flightRoute
674 - ); // 筛选重复的航班 627 + );
628 + // 出现重复的返回
675 if (repeat.length > 1) { 629 if (repeat.length > 1) {
676 this.msgError("航班顺位已重复"); 630 this.msgError("航班顺位已重复");
677 return; 631 return;
678 } 632 }
633 + let params = {
634 + fltNo: this.tableData[this.currentIndex].flightNo,
635 + };
636 + // 航班号输入框失焦时判断有没有航班号,有航班号调用航线查询
679 if (params.fltNo) { 637 if (params.fltNo) {
680 - this.getQueryRouteByFltNo(params); 638 + this.getQueryRouteByFltNo(params); // 航线查询
681 } else { 639 } else {
682 this.tableData[this.currentIndex].flightRoute = ""; 640 this.tableData[this.currentIndex].flightRoute = "";
683 this.tableData[this.currentIndex].routeList = []; 641 this.tableData[this.currentIndex].routeList = [];
...@@ -715,7 +673,7 @@ export default { ...@@ -715,7 +673,7 @@ export default {
715 let include = this.cargoType.filter((item) => 673 let include = this.cargoType.filter((item) =>
716 arr.some((val) => val == item.chineseName) 674 arr.some((val) => val == item.chineseName)
717 ); // 查询已被勾选的类别 675 ); // 查询已被勾选的类别
718 - this.checkboxCargoType = include; //已勾选申报类别的数据 676 + this.checkboxCargoType = include; // 已勾选申报类别的数据
719 this.queryForm.declarationCategory = arr.join(";"); 677 this.queryForm.declarationCategory = arr.join(";");
720 }, 678 },
721 // 失焦事件 679 // 失焦事件
......
1 +import { debounce } from "@/utils";
1 export default { 2 export default {
3 + directives: {
4 + // 处理加减天数
5 + "input-filter": {
6 + bind: function (el, binding, { context }) {
7 + el.handler = function (event) {
8 + context.calculateDay(event);
9 + };
10 + el.addEventListener("input", el.handler);
11 + },
12 + unbind: function (el) {
13 + el.removeEventListener("input", el.handler);
14 + },
15 + },
16 + },
2 methods: { 17 methods: {
18 + // 防抖函数处理加减天数校验
19 + calculateDay: debounce(function (...args) {
20 + // 判断有没有值
21 + if (args.length) {
22 + // 判断传过来的是不是一个对象
23 + const { target } = args[0];
24 + // 是不是一个数字
25 + if (isNaN(Number(target.value))) {
26 + this.msgError("请输入有效数字");
27 + target.value = "";
28 + } else {
29 + // 非数字时
30 + if (Number(target.value) < -7) {
31 + this.msgError("加减天数最小不能大于7天");
32 + target.value = "";
33 + } else if (Number(target.value) > 7) {
34 + this.msgError("加减天数最大不能大于7天");
35 + target.value = "";
36 + } else if (/[\.]/.test(Number(target.value))) {
37 + // 浮点数时
38 + this.msgError("加减天数只能为整数");
39 + target.value = "";
40 + }
41 + }
42 + target.dispatchEvent(new Event("input"));
43 + }
44 + }, 800),
3 // 获取字典 45 // 获取字典
4 getObj({ serviceCode }) { 46 getObj({ serviceCode }) {
5 let service_Code = []; 47 let service_Code = [];
......