Elements-SY

modify

......@@ -223,7 +223,7 @@ export function getTime(type) {
* @return {*}
*/
export function debounce(func, wait, immediate) {
let timeout, args, context, timestamp, result;
let timeout, args, context, timestamp, result, data;
const later = function () {
// 据上一次触发时间间隔
......@@ -236,7 +236,7 @@ export function debounce(func, wait, immediate) {
timeout = null;
// 如果设定为immediate===true,因为开始边界已经调用过了此处无需调用
if (!immediate) {
result = func.apply(context, args);
result = func.apply(context, data);
if (!timeout) context = args = null;
}
}
......@@ -245,6 +245,7 @@ export function debounce(func, wait, immediate) {
return function (...args) {
context = this;
timestamp = +new Date();
data = args;
const callNow = immediate && !timeout;
// 如果延时不存在,重新设定延时
if (!timeout) timeout = setTimeout(later, wait);
......
......@@ -56,32 +56,22 @@
<el-table-column
label="加减天数"
prop="calculateDay"
width="100"
width="140"
align="center"
>
<template slot-scope="scope">
<el-input
type="text"
<el-input-number
v-model="scope.row.calculateDay"
:disabled="scope.row.edit"
min="-7"
max="7"
:min="-7"
:max="7"
:precision="0"
v-input-filter
clearable
placeholder=""
size="small"
style="width: 100%"
/>
<!-- <el-input
type="number"
v-model="scope.row.calculateDay"
:disabled="scope.row.edit"
min="-7"
max="7"
v-input-filter
clearable
placeholder=""
size="small"
/> -->
</template>
</el-table-column>
<el-table-column
......@@ -497,40 +487,6 @@ export default {
];
}
},
mounted() {},
directives: {
// 处理加减天数
"input-filter": {
bind: function (el, binding, { context }) {
el.handler = function (event) {
if (event.data == "E" || event.data == "e") {
// 无理数时
event.target.value = "";
}
if (event.target.value) {
if (Number(event.target.value) < -7) {
event.target.value = "";
context.msgError("加减天数最小不能低于7天");
} else if (Number(event.target.value) > 7) {
event.target.value = "";
context.msgError("加减天数最小不能大于7天");
} else if (/[\.]/.test(Number(event.target.value))) {
// 浮点数时
event.target.value = "";
} else {
}
event.target.dispatchEvent(new Event("input"));
}
};
el.addEventListener("input", el.handler);
},
unbind: function (el) {
el.removeEventListener("input", el.handler);
},
},
},
filters: {},
methods: {
// ET86新增
postAdd(params) {
......@@ -553,7 +509,7 @@ export default {
const { code, data, msg } = res;
if (code == 200) {
data.list.flightRankDtoList.map((item) => {
if (name == "view") {
if (name == "view") { // 跳转页面传过来的字段值等于view展示查看
item.edit = true;
} else {
item.edit = false;
......@@ -565,13 +521,10 @@ export default {
item.permitOverweight = true;
}
});
data.list.flightRankDtoList.map((item) => {
item.calculateDay = item.calculateDay;
});
// ET86配舱航班顺位
// ET86配舱航班顺位列表
this.tableData = data.list.flightRankDtoList;
Object.keys(data.list.fltRuleDto).map((key) => {
if (key == "multiHs") {
if (key == "multiHs") { // N为单品名,Y为多品名
if (data.list.fltRuleDto[key] == "N") {
data.list.fltRuleDto[key] = true;
} else {
......@@ -583,6 +536,7 @@ export default {
data.list.fltRuleDto[key] = "";
}
});
// 申报类别详情转化成数组赋值给申报类别勾选框作为回显展示数据
if (data.list.fltRuleDto.declarationCategory) {
this.checkboxClassType =
data.list.fltRuleDto.declarationCategory.split(";");
......@@ -660,24 +614,28 @@ export default {
},
// 失焦查询
blurSearch() {
// 转大写字母
this.tableData[this.currentIndex].flightNo = this.upCase(
this.tableData[this.currentIndex].flightNo
); // 转大写字母
let params = {
fltNo: this.tableData[this.currentIndex].flightNo,
};
);
// 筛选重复的航班:【重复规则】航班号 + 加减天数 + 航线有同样的就认为是重复
let repeat = this.tableData.filter(
(item) =>
item.flightNo == this.tableData[this.currentIndex].flightNo &&
item.calculateDay == this.tableData[this.currentIndex].calculateDay &&
item.flightRoute == this.tableData[this.currentIndex].flightRoute
); // 筛选重复的航班
);
// 出现重复的返回
if (repeat.length > 1) {
this.msgError("航班顺位已重复");
return;
}
let params = {
fltNo: this.tableData[this.currentIndex].flightNo,
};
// 航班号输入框失焦时判断有没有航班号,有航班号调用航线查询
if (params.fltNo) {
this.getQueryRouteByFltNo(params);
this.getQueryRouteByFltNo(params); // 航线查询
} else {
this.tableData[this.currentIndex].flightRoute = "";
this.tableData[this.currentIndex].routeList = [];
......@@ -715,7 +673,7 @@ export default {
let include = this.cargoType.filter((item) =>
arr.some((val) => val == item.chineseName)
); // 查询已被勾选的类别
this.checkboxCargoType = include; //已勾选申报类别的数据
this.checkboxCargoType = include; // 已勾选申报类别的数据
this.queryForm.declarationCategory = arr.join(";");
},
// 失焦事件
......
import { debounce } from "@/utils";
export default {
directives: {
// 处理加减天数
"input-filter": {
bind: function (el, binding, { context }) {
el.handler = function (event) {
context.calculateDay(event);
};
el.addEventListener("input", el.handler);
},
unbind: function (el) {
el.removeEventListener("input", el.handler);
},
},
},
methods: {
// 防抖函数处理加减天数校验
calculateDay: debounce(function (...args) {
// 判断有没有值
if (args.length) {
// 判断传过来的是不是一个对象
const { target } = args[0];
// 是不是一个数字
if (isNaN(Number(target.value))) {
this.msgError("请输入有效数字");
target.value = "";
} else {
// 非数字时
if (Number(target.value) < -7) {
this.msgError("加减天数最小不能大于7天");
target.value = "";
} else if (Number(target.value) > 7) {
this.msgError("加减天数最大不能大于7天");
target.value = "";
} else if (/[\.]/.test(Number(target.value))) {
// 浮点数时
this.msgError("加减天数只能为整数");
target.value = "";
}
}
target.dispatchEvent(new Event("input"));
}
}, 800),
// 获取字典
getObj({ serviceCode }) {
let service_Code = [];
......