学期校历

This commit is contained in:
2026-08-28 14:45:19 +08:00
parent d37c05aaad
commit fa2832cf3b
2 changed files with 29 additions and 122 deletions
@@ -265,7 +265,14 @@ export default {
},
watch: {
'form.kxrq': 'calculateWeeks',
'form.jsrq': 'calculateWeeks'
'form.jsrq': 'calculateWeeks',
// 新增时选择学期类型后,自动带出开学/结束日期
'form.xq'(val) {
if (this.isAdd) this.autoFillDatesForXq()
},
'form.xn'(val) {
if (this.isAdd) this.autoFillDatesForXq()
}
},
methods: {
/** 顶栏切换当前学期后自动刷新 */
@@ -286,6 +293,23 @@ export default {
if (xn === undefined || xn === null || xn === '' || !xq) return ''
return String(xn) + String(xq)
},
/** 根据学年+学期类型自动带出开学/结束日期(春季01:2-5月,夏季02:6-8月,秋季03:9-12月) */
autoFillDatesForXq() {
const xn = this.form.xn
const xq = this.form.xq
if (xn === undefined || xn === null || xn === '') return
const year = Number(xn)
const pad = m => `${year}-${String(m).padStart(2, '0')}`
const rules = {
'01': { start: pad(2) + '-01', end: pad(5) + '-31' },
'02': { start: pad(6) + '-01', end: pad(8) + '-31' },
'03': { start: pad(9) + '-01', end: pad(12) + '-31' }
}
const rule = rules[xq]
if (!rule) return
this.form.kxrq = rule.start
this.form.jsrq = rule.end
},
/** 学期代号 -> 学期名称(如 202601 -> 2026年春季学期) */
getSemesterName(nd) {
if (!nd) return ''