Elements-SY

modify

......@@ -13,11 +13,118 @@ export const inputBlurValidate = {
methods: {
// 最小件数失焦事件
inputBlurMinPieces({ target }) {
this.validateNumOfPieces(target.value, "minNumOfPieces");
// 件数最小值和最大值都为空的情况下
if (
this.queryForm.minNumOfPieces == "" &&
this.queryForm.maxNumOfPieces == ""
) {
this.validateForm = true;
this.$refs.minNumOfPieces.innerHTML = "";
}
// 鼠标聚焦最小件数,最小件数无值的情况下去校验最大件数
if (target.value == "" && this.queryForm.maxNumOfPieces) {
if (/^[1-9]\d*$/.test(Number(this.queryForm.maxNumOfPieces))) {
this.validateForm = true;
this.$refs.minNumOfPieces.innerHTML = "";
} else {
this.validateForm = false;
this.$refs.minNumOfPieces.innerHTML = "请输入有效件数";
}
}
// 最小件数有值的情况下
if (target.value && Number(target.value) > 0) {
if (/^[1-9]\d*$/.test(Number(target.value))) {
if (this.queryForm.maxNumOfPieces) {
if (
Number(this.queryForm.maxNumOfPieces) <
Number(this.queryForm.minNumOfPieces)
) {
this.validateForm = false;
this.$refs.minNumOfPieces.innerHTML = "最小件数不得大于最大件数";
} else if (
/^[1-9]\d*$/.test(Number(this.queryForm.maxNumOfPieces))
) {
this.validateForm = true;
this.$refs.minNumOfPieces.innerHTML = "";
} else {
this.validateForm = false;
this.$refs.minNumOfPieces.innerHTML = "请输入有效件数";
}
} else {
this.validateForm = true;
this.$refs.minNumOfPieces.innerHTML = "";
}
} else {
this.validateForm = false;
this.$refs.minNumOfPieces.innerHTML = "请输入有效件数";
}
} else {
if (target.value && isNaN(target.value)) {
this.validateForm = false;
this.$refs.minNumOfPieces.innerHTML = "请输入有效件数";
}
if (target.value && Number(target.value) < 1) {
this.validateForm = false;
this.$refs.minNumOfPieces.innerHTML = "请输入有效件数";
}
}
},
// 最大件数失焦事件
inputBlurMaxPieces({ target }) {
this.validateNumOfPieces(target.value, "maxNumOfPieces");
// 件数最小值和最大值都为空的情况下
if (
this.queryForm.minNumOfPieces == "" &&
this.queryForm.maxNumOfPieces == ""
) {
this.validateForm = true;
this.$refs.minNumOfPieces.innerHTML = "";
}
// 鼠标聚焦最大件数,最大件数无值的情况下去校验最小件数
if (target.value == "" && this.queryForm.minNumOfPieces) {
if (/^[1-9]\d*$/.test(Number(this.queryForm.minNumOfPieces))) {
this.validateForm = true;
this.$refs.minNumOfPieces.innerHTML = "";
} else {
this.validateForm = false;
this.$refs.minNumOfPieces.innerHTML = "请输入有效件数";
}
}
if (target.value && Number(target.value) > 0) {
if (/^[1-9]\d*$/.test(Number(target.value))) {
if (this.queryForm.minNumOfPieces) {
if (
Number(this.queryForm.maxNumOfPieces) <
Number(this.queryForm.minNumOfPieces)
) {
this.validateForm = false;
this.$refs.minNumOfPieces.innerHTML = "最小件数不得大于最大件数";
} else if (
/^[1-9]\d*$/.test(Number(this.queryForm.minNumOfPieces))
) {
this.validateForm = true;
this.$refs.minNumOfPieces.innerHTML = "";
} else {
this.validateForm = false;
this.$refs.minNumOfPieces.innerHTML = "请输入有效件数";
}
} else {
this.validateForm = true;
this.$refs.minNumOfPieces.innerHTML = "";
}
} else {
this.validateForm = false;
this.$refs.minNumOfPieces.innerHTML = "请输入有效件数";
}
} else {
if (target.value && isNaN(target.value)) {
this.validateForm = false;
this.$refs.minNumOfPieces.innerHTML = "请输入有效件数";
}
if (target.value && Number(target.value) < 1) {
this.validateForm = false;
this.$refs.minNumOfPieces.innerHTML = "请输入有效件数";
}
}
},
// 最小重量失焦事件
inputBlurMinWeight({ target }) {
......@@ -70,7 +177,7 @@ export const inputBlurValidate = {
this.validateForm = false;
this.$refs.minWeight.innerHTML = "请输入有效重量,小数保留5位";
}
if (Number(target.value) < 0) {
if (target.value && Number(target.value) < 0) {
this.validateForm = false;
this.$refs.minWeight.innerHTML = "请输入有效重量,小数保留5位";
}
......@@ -127,7 +234,7 @@ export const inputBlurValidate = {
this.validateForm = false;
this.$refs.minWeight.innerHTML = "请输入有效重量,小数保留5位";
}
if (Number(target.value) < 0) {
if (target.value && Number(target.value) < 0) {
this.validateForm = false;
this.$refs.minWeight.innerHTML = "请输入有效重量,小数保留5位";
}
......@@ -190,7 +297,7 @@ export const inputBlurValidate = {
this.$refs.minCNYCustomVal.innerHTML =
"请输入有效申报价值,小数保留2位";
}
if (Number(target.value) < 0) {
if (target.value && Number(target.value) < 0) {
this.validateForm = false;
this.$refs.minCNYCustomVal.innerHTML =
"请输入有效申报价值,小数保留2位";
......@@ -255,7 +362,7 @@ export const inputBlurValidate = {
this.$refs.minCNYCustomVal.innerHTML =
"请输入有效申报价值,小数保留2位";
}
if (Number(target.value) < 0) {
if (target.value && Number(target.value) < 0) {
this.validateForm = false;
this.$refs.minCNYCustomVal.innerHTML =
"请输入有效申报价值,小数保留2位";
......@@ -321,7 +428,7 @@ export const inputBlurValidate = {
this.$refs.minSUDCustomVal.innerHTML =
"请输入有效申报价值,小数保留2位";
}
if (Number(target.value) < 0) {
if (target.value && Number(target.value) < 0) {
this.validateForm = false;
this.$refs.minSUDCustomVal.innerHTML =
"请输入有效申报价值,小数保留2位";
......@@ -388,128 +495,12 @@ export const inputBlurValidate = {
this.$refs.minSUDCustomVal.innerHTML =
"请输入有效申报价值,小数保留2位";
}
if (Number(target.value) < 0) {
if (target.value && Number(target.value) < 0) {
this.validateForm = false;
this.$refs.minSUDCustomVal.innerHTML =
"请输入有效申报价值,小数保留2位";
}
}
},
// 校验件数方法 【件数可以为空但件数不得为0】只能输入正整数
validateNumOfPieces(value, pieces) {
if (value.toString().length) {
// 获取当前输入框有值的情况下
this.queryForm[pieces] = Number(value);
let markPieces = false;
if (pieces == "minNumOfPieces" || pieces == "maxNumOfPieces") {
// 最大件数和最小件数都不为空的情况下
if (
this.queryForm.minNumOfPieces.toString() != "" &&
this.queryForm.maxNumOfPieces.toString() != ""
) {
this.validateForm = true;
this.$refs.minNumOfPieces.innerHTML = "";
markPieces = true;
} else {
markPieces = false;
}
}
if (/^\d+$/.test(this.queryForm[pieces])) {
if (markPieces) {
//当最大件数和最小件数都不为空的情况下,最大件数小于最小件数的时候
if (this.queryForm.maxNumOfPieces < this.queryForm.minNumOfPieces) {
if (Array.isArray(this.$refs.minNumOfPieces)) {
this.msgError("最小件数不得大于最大件数");
this.validateForm = false;
} else {
this.$refs.minNumOfPieces.innerHTML = "";
this.$refs.minNumOfPieces.innerHTML =
"最小件数不得大于最大件数";
this.validateForm = false;
}
}
//当最大件数和最小件数都不为空的情况下,最大件数和最小件数小于1的时候
else if (
this.queryForm.minNumOfPieces < 1 ||
this.queryForm.maxNumOfPieces < 1
) {
if (Array.isArray(this.$refs.minNumOfPieces)) {
this.msgError("最小件数和最大件数不能小于1");
this.validateForm = false;
} else {
this.$refs.minNumOfPieces.innerHTML = "";
this.$refs.minNumOfPieces.innerHTML =
"最小件数和最大件数不能小于1";
this.validateForm = false;
}
}
//当最大件数和最小件数都不为空的情况下,最大件数和最小件数满足大于1左区间小于等于右区间的时候
else {
this.$refs.minNumOfPieces.innerHTML = "";
this.validateForm = true;
}
} else {
// 当左右区间其中一个有值的情况下
if (value.length) {
if (Number(value) < 1) {
if (Array.isArray(this.$refs.minNumOfPieces)) {
this.msgError("件数不得小于1");
this.$refs.minNumOfPieces.innerHTML = "";
this.$refs.minNumOfPieces.innerHTML = "件数不得小于1";
this.validateForm = false;
} else {
this.msgError("件数不得小于1");
this.$refs.minNumOfPieces.innerHTML = "";
this.$refs.minNumOfPieces.innerHTML = "件数不得小于1";
this.validateForm = false;
}
} else {
if (!Array.isArray(this.$refs.minNumOfPieces)) {
this.$refs.minNumOfPieces.innerHTML = "";
this.validateForm = true;
}
}
}
}
} else {
if (Array.isArray(this.$refs.minNumOfPieces)) {
this.msgError("请输入有效件数");
} else {
this.queryForm[pieces] = value;
this.$refs.minNumOfPieces.innerHTML = "";
this.$refs.minNumOfPieces.innerHTML = "请输入有效件数";
}
this.validateForm = false;
}
} else {
// 【左右区间不是都有值的情况下】
// 最小件数为空最大件数有值的情况下
if (pieces == "minNumOfPieces" && this.queryForm.maxNumOfPieces > 0) {
this.$refs.minNumOfPieces.innerHTML = "";
this.validateForm = true;
} else {
this.$refs.minNumOfPieces.innerHTML = "";
this.$refs.minNumOfPieces.innerHTML = "最大件数不得小于1";
this.validateForm = false;
}
// 最大件数为空最小件数有值的情况下
if (pieces == "maxNumOfPieces" && this.queryForm.minNumOfPieces > 0) {
this.$refs.minNumOfPieces.innerHTML = "";
this.validateForm = true;
} else {
this.$refs.minNumOfPieces.innerHTML = "";
this.validateForm = true;
}
// 左右区间 都为空的情况下
if (
this.queryForm.minNumOfPieces.toString().length == 0 &&
this.queryForm.maxNumOfPieces.toString().length == 0
) {
this.$refs.minNumOfPieces.innerHTML = "";
this.validateForm = true;
}
}
return this.validateForm;
},
},
};
......
......@@ -716,6 +716,7 @@ export default {
this.id++;
this.tableData.unshift({
id: this.id,
statusMark: true, // 作为是否为新增
flightNo: "", // 航班号
calculateDay: "", // 航班日期//+1 -1
flightRoute: "", // 航线
......@@ -735,7 +736,7 @@ export default {
},
// 删除
deleBtn(item, $index) {
console.log("删除:", item, $index);
// console.log("删除:", item, $index);
this.tableData.splice($index, 1);
},
// 类别
......@@ -752,22 +753,37 @@ export default {
this.queryForm.originOfFlightNo
);
},
/*
如果是编辑,那么添加航班顺位时
*/
// 表单提交
submitForm(formName) {
this.$refs[formName].validate((valid) => {
if (valid && this.validateForm) {
this.tableData.map((item, i) => {
item.priority = ++i;
});
// 爆仓是否继续配舱
const newtTableData = JSON.parse(JSON.stringify(this.tableData));
const tableData = newtTableData;
tableData.filter((item) => {
tableData.map((item, i) => {
// 爆仓是否继续配舱
if (item.permitOverweight == false) {
item.permitOverweight = "N";
} else {
item.permitOverweight = "Y";
}
// // 作为是否为新增
// if (item.hasOwnProperty("statusMark")) {
// delete item.id;
// }
if (item.hasOwnProperty("routeList")) {
delete item.routeList;
}
item.priority = ++i;
return item;
});
// 新增时没有id说明有statusMark字段,则删除statusMark属性
tableData.map((item) => {
if (!item.hasOwnProperty("id")) {
delete item.statusMark;
}
});
// 校验ET86配舱航班顺位维度
let fltNo = this.tableData.some((item) => item.flightNo == ""); // 通过遍历判断航班顺位列表有没有填写的航班号
......@@ -817,11 +833,6 @@ export default {
this.postAdd(queryParmas); // 新增
} else {
if (this.validateForm) {
queryParmas.flightRankDtoList.map((item) => {
if (item.hasOwnProperty("routeList")) {
delete item.routeList;
}
});
this.postUpdate(queryParmas); // 修改
}
}
......
......@@ -111,7 +111,7 @@ export default {
}
}
},
// Ursa校验 使用JavaScript写一个匹配字母的表达式
// Ursa校验
validateUrsa(ursaMark, ursa) {
// 分隔字符串并且转数组&去除数组空字符串
let ursaList = ursa.split(";").filter((str) => str !== "");
......