Elements-SY

modify

......@@ -782,29 +782,37 @@ export default {
notDestinationSite,
}
) {
let locationVal, notLocationVal, repeat, validate;
let locationVal,
notLocationVal,
locationRepeat,
validateLocation,
destinationSiteRepeat;
if (isLocation == "1") {
// 分隔字符串并且转数组&去除数组空字符串
locationVal = location.split(";").filter((str) => str !== "");
// 是否有重复的
repeat = new Set(locationVal).size !== locationVal.length;
locationRepeat = new Set(locationVal).size !== locationVal.length;
// 校验校验开头以字母或者数字开头的/^[a-zA-Z0-9]*$/
validate = locationVal.every((item) => /^[a-zA-Z0-9]*$/.test(item));
validateLocation = locationVal.every((item) =>
/^[a-zA-Z0-9]*$/.test(item)
);
} else {
notLocationVal = notLocation.split(";").filter((str) => str !== "");
repeat = new Set(notLocationVal).size !== notLocationVal.length;
validate = locationVal.every((item) => /^[a-zA-Z0-9]*$/.test(item));
locationRepeat = new Set(notLocationVal).size !== notLocationVal.length;
validateLocation = locationVal.every((item) =>
/^[a-zA-Z0-9]*$/.test(item)
);
}
if (repeat) {
if (locationRepeat) {
this.routesInfo[index].locationError = "填写的目的地已重复";
this.$set(this.routesInfo, index, this.routesInfo[index]);
}
if (!validate) {
if (!validateLocation) {
this.routesInfo[index].locationError =
"目的地之间用分号分隔,例:P1;P2;P3";
this.$set(this.routesInfo, index, this.routesInfo[index]);
}
if (!repeat && validate) {
if (!locationRepeat && validateLocation) {
this.routesInfo[index].locationError = "";
this.$set(this.routesInfo, index, this.routesInfo[index]);
}
......