<el-time-picker
is-range
v-model="item.value"
range-separator="至"
start-placeholder="开始时间"
end-placeholder="结束时间"
format="HH:mm" //时分
value-format="HH:mm" //时分
placeholder="选择时间范围"
@change="changeTime"
>
//判断时间段是否有一致的
changeTime(e) {
console.log(e);
const nowDate = new Date();
let that = this;
console.log(that.settingInfo.businessHourArr);
var a = 0;
var b = 0;
var c = 0;
var d = 0;
that.settingInfo.businessHourArr.forEach(item => {
if (item.value != null) {
c++;
}
})
that.settingInfo.businessHourArr.forEach(function (item, index) {
if (c > 1) {
if (item.value != null) {
var start1 = '2021-5-1 ' + item.value[0] + ':00';
var end1 = '2021-5-1 ' + item.value[1] + ':00';
var start2 = '2021-5-1 ' + e[0] + ':00';
var end2 = '2021-5-1 ' + e[1] + ':00';
if (item.value[0] == e[0] && item.value[1] == e[1]) {
a = index
d++;
} else if (((Date.parse(start1) <= Date.parse(start2) && Date.parse(start2) <= Date
.parse(end1)) || (Date.parse(start1) <= Date.parse(end2) && Date.parse(
end2) <= Date.parse(end1)) || (Date.parse(start2) <= Date.parse(start1) &&
Date.parse(end2) >= Date.parse(end1)))) {
b++;
} else {
}
}
}
})
if (b > 0) {
that.settingInfo.businessHourArr[a].value = null;
that.$message('营业时间格式错误,请重新录入.');
}
if (d > 1) {
that.settingInfo.businessHourArr[a].value = null;
that.$message('营业时间格式错误,请重新录入.');
}
},
ElementUI el-time-picker只显示小时、分钟
最新推荐文章于 2024-08-30 09:51:20 发布