Fix course conflic logic
This commit is contained in:
parent
a3471b4f1d
commit
6ea1bbf9c0
@ -8,35 +8,25 @@ var coursesList = {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
'getTime': function (timeString) {
|
'getTime': function (timeString) {
|
||||||
if (timeString == null) {
|
let num;
|
||||||
return ""
|
const timeRegex = new RegExp(/^\d[\da-z]*[a-z]$/);
|
||||||
}
|
return timeRegex.test(timeString)
|
||||||
|
? [...timeString].reduce((res, c) => {
|
||||||
ans = []
|
if (Number.isInteger(+c)) {
|
||||||
number = ""
|
num = c;
|
||||||
for (var i of timeString) {
|
return res;
|
||||||
if (i >= "0" && i <= "9") {
|
} else {
|
||||||
number = i
|
return [...res, num + c];
|
||||||
} else if (i >= "a" && i <= "z") {
|
}
|
||||||
ans.push(number + i)
|
}, [])
|
||||||
}
|
: [];
|
||||||
else {
|
|
||||||
ans.push(timeString)
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ans
|
|
||||||
},
|
},
|
||||||
'isOK': function (course) {
|
'isOK': function (course) {
|
||||||
var time = this.getTime(course.time)
|
var time = this.getTime(course.time)
|
||||||
// console.log(course.name, " ", time)
|
// console.log(course.name, " ", time)
|
||||||
for (t of time) {
|
const isConflict = time.some((t) => this.selectedTime.includes(t))
|
||||||
for (st of this.selectedTime) {
|
|
||||||
if (t == st)
|
return time.length && !isConflict
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
},
|
},
|
||||||
'log': function (name, data) {
|
'log': function (name, data) {
|
||||||
console.log(name, data)
|
console.log(name, data)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user