forked from liweijie/education
通过AI比对原操作文档,生成系统功能完善方案,根据方案进行增补,完善从学期新增到最终的排课功能
This commit is contained in:
@@ -442,6 +442,10 @@ export default {
|
||||
cellClass(wIdx, col) {
|
||||
const classes = []
|
||||
if (this.selectedKeys.includes(this.cellKey(wIdx, col.colIndex))) classes.push('is-selected')
|
||||
// 班历:班次日期范围外的格子不可排,给出明确视觉提示
|
||||
if (this.mode === 'class' && this.isOutOfRange(wIdx, col.dayIndex)) {
|
||||
classes.push('is-out-of-range')
|
||||
}
|
||||
const ev = this.getEvent(wIdx, col.colIndex)
|
||||
// 可排课的全部白色;不可排课且事件名非空才标红
|
||||
if (ev && ev.name && !ev.schedulable) {
|
||||
@@ -449,6 +453,30 @@ export default {
|
||||
}
|
||||
return classes
|
||||
},
|
||||
// 时间格对应的实际日期
|
||||
cellDate(wIdx, dayIndex) {
|
||||
if (!this.calendarStart) return null
|
||||
const d = new Date(this.calendarStart)
|
||||
d.setDate(this.calendarStart.getDate() + wIdx * 7 + dayIndex)
|
||||
return d
|
||||
},
|
||||
// 班历只有 [开学日期, 结束日期] 内的格子会落库,范围外的格子无法保存
|
||||
isOutOfRange(wIdx, dayIndex) {
|
||||
if (!this.startDate || !this.endDate) return false
|
||||
const d = this.cellDate(wIdx, dayIndex)
|
||||
if (!d) return false
|
||||
const at = v => new Date(v.getFullYear(), v.getMonth(), v.getDate()).getTime()
|
||||
return at(d) < at(this.startDate) || at(d) > at(this.endDate)
|
||||
},
|
||||
// 返回所选时间格里落在班次日期范围外的格子数
|
||||
countOutOfRangeSelected() {
|
||||
let n = 0
|
||||
this.selectedKeys.forEach(key => {
|
||||
const pos = this.parseCellKey(key)
|
||||
if (pos && this.isOutOfRange(pos.wIdx, pos.dayIndex)) n++
|
||||
})
|
||||
return n
|
||||
},
|
||||
/* ---------- 点击 / 拖拽多选 ---------- */
|
||||
onGridMouseDown(e) {
|
||||
const cell = e.target.closest('.sce-cell')
|
||||
@@ -548,6 +576,14 @@ export default {
|
||||
this.$message.warning('请输入事件名')
|
||||
return
|
||||
}
|
||||
// 班历只在班次日期范围内落库,范围外的格子直接提示,避免落成含糊的“保存失败”
|
||||
if (this.mode === 'class') {
|
||||
const outside = this.countOutOfRangeSelected()
|
||||
if (outside > 0) {
|
||||
this.$message.warning(`所选 ${outside} 个时间格在班次日期范围外,不可排课`)
|
||||
return
|
||||
}
|
||||
}
|
||||
const keys = [...this.selectedKeys]
|
||||
keys.forEach(key => {
|
||||
const prev = this.events[key]
|
||||
@@ -876,6 +912,14 @@ export default {
|
||||
// 可排课白色,不可排课且有事件标红
|
||||
&.no-schedule { background: #fde2e2; }
|
||||
|
||||
// 班历:班次日期范围外的格子不可排
|
||||
&.is-out-of-range {
|
||||
background: #f4f4f5;
|
||||
cursor: not-allowed;
|
||||
|
||||
.sce-date-num { color: #dcdfe6; }
|
||||
}
|
||||
|
||||
&.is-selected {
|
||||
outline: 2px solid var(--edu-green-primary, #00875a);
|
||||
outline-offset: -2px;
|
||||
|
||||
Reference in New Issue
Block a user