选修课管理

This commit is contained in:
2026-09-20 14:26:52 +08:00
parent 9f0c0ac873
commit a566a26fec
4 changed files with 312 additions and 11 deletions
@@ -392,16 +392,41 @@ export default {
this.$message.success('操作成功')
this.loadRows()
})
.catch(err => {
this.$message.error((err && err.message) || '操作失败')
})
.catch(() => {})
},
/** 手动合班前置校验:科目/学时/课类型/成绩分制必须相同 */
mergeIncompatibleReason(rows) {
const first = rows[0]
const diffs = []
const courses = [...new Set(rows.map(r => r.kcmc || r.kbh || ''))].filter(Boolean)
if (rows.some(r => r.kbh !== first.kbh)) {
diffs.push('科目不同(' + (courses.join('、') || '课号不一致') + ')')
}
if (rows.some(r => r.xs !== first.xs)) {
diffs.push('学时不同')
}
if (rows.some(r => r.klx !== first.klx)) {
diffs.push('课类型不同')
}
const norm = v => (v == null || v === '' ? '' : String(v).trim())
if (rows.some(r => norm(r.cjfz) !== norm(first.cjfz))) {
diffs.push('成绩分制不同')
}
if (!diffs.length) return ''
return '不能手动合班:' + diffs.join(';') + '。请选择同一科目、同一学时、同一课类型、同一成绩分制的行(通常是不同学员队的同一门课)'
},
handleMerge() {
const bhList = this.selection.map(r => r.bh)
if (bhList.length < 2) {
const selected = this.selection
if (selected.length < 2) {
this.$message.warning('请至少选择两行进行合班')
return
}
const reason = this.mergeIncompatibleReason(selected)
if (reason) {
this.$message.warning(reason)
return
}
const bhList = selected.map(r => r.bh)
this.$confirm(`把选中的 ${bhList.length} 行合成一个班?`, '手动合班', { type: 'warning' })
.then(() => this.reload(taskBookMerge(bhList).then(res => {
this.$message.info(`已合入编组 ${res.data}`)