diff --git a/frontend/src/views/training/components/CoursePanel.vue b/frontend/src/views/training/components/CoursePanel.vue
index efc2618..3bf03c0 100644
--- a/frontend/src/views/training/components/CoursePanel.vue
+++ b/frontend/src/views/training/components/CoursePanel.vue
@@ -34,11 +34,26 @@
重置
共 {{ filteredCourses.length }} 门
+
+ 批量发布
+ 批量删除
+ 已选 {{ selectedCourseKeys.length }} 项
-
+
{{ row.plan_code || '-' }}
{{ row.name }}
@@ -1234,6 +1249,8 @@ watch(
)
const courseColumns = [
+ // 批量勾选列(000165 复测):配合批量发布/批量删除
+ { colKey: 'row-select', type: 'multiple', width: 44 },
// 左侧列不固定(000154):计划编号/课程名称随横向滚动,状态/操作仍固定右侧
// 000165 复测列序:授课时间/计划培训时间前移至课程名称之后,讲师/地点次之,
// 形式/类型/学时/上报部门后移(关注信息优先)
@@ -1682,6 +1699,81 @@ const onDelete = async (row: TrainingCourse) => {
}
}
+// ---- 批量发布/批量删除(000165 复测):与课程管理批量审核同口径 —— 前端循环
+// 单条接口,逐条透出失败原因;勾选禁用与行内按钮权限同口径 ----
+const selectedCourseKeys = ref([])
+const batchSaving = ref(false)
+
+// 已发布计划:普通维护角色不可再发布也不可删,勾选置灰(仅超管可勾选后删除)
+const courseSelectionDisabledKeys = computed(() =>
+ isSuperAdmin.value ? [] : filteredCourses.value.filter((r) => r.status === 'published').map((r) => r.id),
+)
+
+const onBatchPublish = async () => {
+ // 仅可发布未发布行(已发布行跳过);线上课课件/线下课讲师/时间/地点/参加人员
+ // 等业务校验由后端 PublishCourse 逐条兜底,失败行透出原因
+ const rows = filteredCourses.value.filter(
+ (r) => selectedCourseKeys.value.includes(r.id) && r.status !== 'published',
+ )
+ if (!rows.length) {
+ MessagePlugin.warning('请先勾选待发布状态的计划')
+ return
+ }
+ batchSaving.value = true
+ let ok = 0
+ const failed: string[] = []
+ try {
+ for (const row of rows) {
+ try {
+ await publishCourse(row.id)
+ ok += 1
+ } catch (e: any) {
+ failed.push(`「${row.name}」${apiErrorMessage(e, '发布失败')}`)
+ }
+ }
+ if (ok) MessagePlugin.success(`批量发布完成:成功 ${ok} 条${failed.length ? `,失败 ${failed.length} 条` : ''}`)
+ if (failed.length) {
+ // 失败原因逐条透出(最多展示 3 条,避免长提示刷屏)
+ MessagePlugin.warning(failed.slice(0, 3).join(';') + (failed.length > 3 ? ` 等 ${failed.length} 条失败` : ''))
+ }
+ selectedCourseKeys.value = []
+ loadAll()
+ } finally {
+ batchSaving.value = false
+ }
+}
+
+const onBatchDelete = async () => {
+ // 删除口径与行内按钮一致:已发布计划仅超级管理员可删(普通维护角色仅未发布行),
+ // 非超管勾选面板已把已发布行置灰;后端 DeleteCourse 逐条兜底
+ const rows = filteredCourses.value.filter((r) => selectedCourseKeys.value.includes(r.id))
+ if (!rows.length) {
+ MessagePlugin.warning('请先勾选要删除的计划')
+ return
+ }
+ batchSaving.value = true
+ let ok = 0
+ const failed: string[] = []
+ try {
+ for (const row of rows) {
+ try {
+ await deleteCourse(row.id)
+ ok += 1
+ } catch (e: any) {
+ failed.push(`「${row.name}」${apiErrorMessage(e, '删除失败')}`)
+ }
+ }
+ if (ok) MessagePlugin.success(`批量删除完成:成功 ${ok} 条${failed.length ? `,失败 ${failed.length} 条` : ''}`)
+ if (failed.length) {
+ MessagePlugin.warning(failed.slice(0, 3).join(';') + (failed.length > 3 ? ` 等 ${failed.length} 条失败` : ''))
+ }
+ selectedCourseKeys.value = []
+ loadAll()
+ } finally {
+ batchSaving.value = false
+ }
+}
+
const openDetail = async (row: TrainingCourse) => {
activeCourse.value = row
sessionsVisible.value = true