Elements-SY

modify

......@@ -72,28 +72,34 @@
</el-radio-group>
</el-col>
<el-col :span="10">
<el-input
v-if="item.isLocation == '1'"
:disabled="pageName || status"
type="textarea"
v-model="item.location"
:rows="4"
placeholder="始发站之间用回车符分隔"
style="width: 500px"
@blur="location({ index, item, $event })"
>
</el-input>
<el-input
v-else
:disabled="pageName || status"
type="textarea"
v-model="item.notLocation"
:rows="4"
placeholder="始发站之间用回车符分隔"
style="width: 500px"
@blur="notLocation({ index, item, $event })"
>
</el-input>
<span style="width: 500px; display: block">
<el-input
v-show="item.isLocation == '1'"
:disabled="pageName || status"
type="textarea"
v-model="item.location"
:rows="4"
placeholder="始发站之间用回车符分隔"
@blur="location({ index, item, $event })"
>
</el-input>
<el-input
v-show="item.isLocation == '2'"
:disabled="pageName || status"
type="textarea"
v-model="item.notLocation"
:rows="4"
placeholder="始发站之间用回车符分隔"
@blur="notLocation({ index, item, $event })"
>
</el-input>
</span>
<div class="form-item-error-block">
<span
class="el-form-item__error"
v-text="item.locationError"
></span>
</div>
</el-col>
</el-form-item>
</el-col>
......@@ -110,30 +116,36 @@
</el-radio-group>
</el-col>
<el-col :span="10">
<el-input
v-if="item.isDestinationSite == '1'"
:disabled="pageName || status"
type="textarea"
v-model="item.destinationSite"
:rows="4"
placeholder="目的站之间用回车符分隔"
style="width: 500px"
@blur="destinationSite({ index, item, $event })"
>
</el-input>
<el-input
v-else
:disabled="pageName || status"
type="textarea"
v-model="item.notDestinationSite"
:rows="4"
placeholder="目的站之间用回车符分隔"
style="width: 500px"
@blur="
notDestinationSite({ index, item, $event })
"
>
</el-input>
<span style="width: 500px; display: block">
<el-input
v-show="item.isDestinationSite == '1'"
:disabled="pageName || status"
type="textarea"
v-model="item.destinationSite"
:rows="4"
placeholder="目的站之间用回车符分隔"
@blur="destinationSite({ index, item, $event })"
>
</el-input>
<el-input
v-show="item.isDestinationSite == '2'"
:disabled="pageName || status"
type="textarea"
v-model="item.notDestinationSite"
:rows="4"
placeholder="目的站之间用回车符分隔"
@blur="
notDestinationSite({ index, item, $event })
"
>
</el-input>
</span>
<div class="form-item-error-block">
<span
class="el-form-item__error"
v-text="destinationSiteError"
></span>
</div>
</el-col>
</el-form-item>
</el-col>
......@@ -149,6 +161,10 @@
@blur="includeUrsa({ index, item, $event })"
>
</el-input>
<span
class="el-form-item__error"
v-text="ursaError"
></span>
</el-form-item>
</el-col>
<el-col :span="10">
......@@ -162,6 +178,12 @@
@blur="notIncludeUrsa({ index, item, $event })"
>
</el-input>
<div class="form-item-error-block">
<span
class="el-form-item__error"
v-text="notUrsaError"
></span>
</div>
</el-form-item>
</el-col>
</el-col>
......
......@@ -12,6 +12,10 @@ export default {
queryForm: {
// 表单参数
},
locationError: "URSA包含", // 始发站
destinationSiteError: "", // 目的站
ursaError: "", // URSA包含
notUrsaError: "", // URSA不包含
};
},
computed: {
......@@ -766,47 +770,58 @@ export default {
blurEvent({ originOfFlightNo }) {
this.queryForm.originOfFlightNo = this.upCase(originOfFlightNo);
},
validateLocation({ isLocation, location, notLocation }) {
let locationVal,
notLocationVal,
repeat,
validateLocation,
validateNotlocation;
// 校验目的地
validateLocation(
index,
{
isLocation,
location,
notLocation,
isDestinationSite,
destinationSite,
notDestinationSite,
}
) {
let locationVal, notLocationVal, repeat, validate;
if (isLocation == "1") {
// 分隔字符串并且转数组&去除数组空字符串
locationVal = location.split(";").filter((str) => str !== "");
// 是否有重复的
repeat = new Set(locationVal).size !== locationVal.length;
// 校验校验开头以字母或者数字开头的/^[a-zA-Z0-9]*$/
validateLocation = locationVal.every((item) =>
/^[a-zA-Z0-9]*$/.test(item)
);
validate = locationVal.every((item) => /^[a-zA-Z0-9]*$/.test(item));
} else {
notLocationVal = notLocation.split(";").filter((str) => str !== "");
repeat = new Set(notLocationVal).size !== notLocationVal.length;
validateNotlocation = locationVal.every((item) =>
/^[a-zA-Z0-9]*$/.test(item)
);
validate = locationVal.every((item) => /^[a-zA-Z0-9]*$/.test(item));
}
if (repeat) {
this.routesInfo[index].locationError = "填写的目的地已重复";
this.$set(this.routesInfo, index, this.routesInfo[index]);
}
if (!validate) {
this.routesInfo[index].locationError =
"目的地之间用分号分隔,例:P1;P2;P3";
this.$set(this.routesInfo, index, this.routesInfo[index]);
}
if (!repeat && validate) {
this.routesInfo[index].locationError = "";
this.$set(this.routesInfo, index, this.routesInfo[index]);
}
},
// 包含始发站失焦事件
locationBur({ index, item }) {
/*
对于单选框这种,不论是勾选哪一个两则都使用一个布尔值;
// 校验:只能字母和数组组合,不能有重复的,包含中不能有包含的
*/
// console.log(this.routesInfo);
// console.log("locationBur", index, item);
// 不为空的时候做校验
// if (item.location || item.notLocation) {
// this.validateLocation(item);
// }
if (item.location) {
this.validateLocation(index, item);
}
},
// 不包含始发站失焦事件
notLocationBur({ index, item }) {
// console.log("notLocationBur", index, item);
if (item.notLocation) {
this.validateLocation(index, item);
}
},
// 包含目的站失焦事件
destinationSiteBur({ index, item }) {
......