选修课管理

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
+1 -1
View File
@@ -77,7 +77,7 @@ service.interceptors.response.use(res => {
// 未设置状态码则默认成功状态
const code = res.data.code || 200
// 获取错误信息
const msg = errorCode[code] || res.data.msg || errorCode['default']
const msg = errorCode[code] || res.data.msg || res.data.message || errorCode['default']
// 二进制数据则直接返回
if (res.request.responseType === 'blob' || res.request.responseType === 'arraybuffer') {
return res.data
@@ -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}`)