feat(优化):年培训计划:已确认行的删除按钮、勾选框、批量删除均仅超级管理员可见/可用;提示文案随角色变化
deploy-hxtesting / build-and-deploy (push) Successful in 1m14s

课程管理:canDeleteCourse 超管不限状态/部门(已审核/已发布行可删,确认弹窗文案区分);批量删除按钮超管可见
月培训计划:已发布行的「删除」仅超管可见(普通维护角色仍只能删未发布计划),行内确认弹窗替代原 window.confirm,失败时透出后端文案
Training.vue:canManageTabs 加入 super_admin,纯超管(未兼其他角色)也能进入这三个页面执行删除
This commit is contained in:
runny committed 2026-11-26 17:06:37 +08:00
1 parent a448598df5
commit 2f1cda34da
19 files changed
+589 -278

No files matched your search

@@ -36,54 +36,64 @@
<span class="course-filter-count">共 {{ filteredCourses.length }} 门</span>
</div>
<t-table :data="pagedCourses" :columns="courseColumns" row-key="id" size="small" :loading="loading">
<template #plan_code="{ row }">{{ row.plan_code || '-' }}</template>
<template #name="{ row }">
<span class="course-name-link clamp-2" title="点击前往培训签到" @click="goSignTab(row)">{{ row.name }}</span>
<!-- 课程已下线(000163):关联课程管理条目 offline 时标注(计划行保留,
学习入口提示「该课程已下线」) -->
<t-tag v-if="row.library_offline" theme="danger" variant="outline" size="small" class="offline-flag">课程已下线</t-tag>
</template>
<template #mode="{ row }">
<t-tag :theme="row.mode === 'online' ? 'primary' : 'default'" variant="light" size="small" :class="{ 'course-tag-offline': row.mode !== 'online' }">
{{ row.mode === 'online' ? '线上' : '线下' }}
</t-tag>
</template>
<template #type="{ row }">{{ typeText(row.type) }}</template>
<template #reporter="{ row }"><span class="clamp-2">{{ row.reporter_dept_name || '-' }}</span></template>
<template #teachTime="{ row }"><span class="clamp-2">{{ teachTimeText(row) }}</span></template>
<template #plannedTime="{ row }"><span class="clamp-2">{{ row.planned_time || '-' }}</span></template>
<template #lecturer="{ row }">{{ lectNameMap[row.lecturer_id] || row.lecturer_name || row.lecturer_external || '-' }}</template>
<template #location="{ row }"><span class="clamp-2">{{ courseLocation(row) || '-' }}</span></template>
<template #expected="{ row }">{{ row.actual_count ?? 0 }}/{{ row.expected_count ?? 0 }} 人</template>
<template #learnStatus="{ row }">
<t-tag
:theme="learnStatusTheme(row.learning_status)"
variant="light" size="small" class="status-link"
@click="goStudyStatus(row, 'learning')"
>{{ learnStatusText(row.learning_status) }}</t-tag>
</template>
<template #examStatus="{ row }">
<t-tag
:theme="examStatusTheme(row.exam_status)"
variant="light" size="small" class="status-link"
@click="goStudyStatus(row, 'exam')"
>{{ examStatusText(row.exam_status) }}</t-tag>
</template>
<template #status="{ row }">
<t-tag :theme="statusTheme(row.status)" variant="light" size="small">{{ statusText(row.status) }}</t-tag>
</template>
<template #op="{ row }">
<t-button
v-if="canManage && row.status !== 'published'"
variant="text" theme="primary" size="small" :disabled="saving"
@click="onPublish(row)"
>发布</t-button>
<t-button variant="text" size="small" @click="openDetail(row)">调整</t-button>
<t-button variant="text" size="small" @click="openChangeLogs(row)">记录</t-button>
<t-button v-if="canManage" variant="text" theme="danger" size="small" @click="onDelete(row)">删除</t-button>
</template>
</t-table>
<!-- 表格滚动区:面板满屏,筛选/表头/分页固定,仅数据行滚动(height=100% 启用固定表头) -->
<div class="table-scroll">
<t-table :data="pagedCourses" :columns="courseColumns" row-key="id" size="small" height="100%" :loading="loading">
<template #plan_code="{ row }">{{ row.plan_code || '-' }}</template>
<template #name="{ row }">
<span class="course-name-link clamp-2" title="点击前往培训签到" @click="goSignTab(row)">{{ row.name }}</span>
<!-- 课程已下线(000163):关联课程管理条目 offline 时标注(计划行保留,
学习入口提示「该课程已下线」) -->
<t-tag v-if="row.library_offline" theme="danger" variant="outline" size="small" class="offline-flag">课程已下线</t-tag>
</template>
<template #mode="{ row }">
<t-tag :theme="row.mode === 'online' ? 'primary' : 'default'" variant="light" size="small" :class="{ 'course-tag-offline': row.mode !== 'online' }">
{{ row.mode === 'online' ? '线上' : '线下' }}
</t-tag>
</template>
<template #type="{ row }">{{ typeText(row.type) }}</template>
<template #reporter="{ row }"><span class="clamp-2">{{ row.reporter_dept_name || '-' }}</span></template>
<template #teachTime="{ row }"><span class="clamp-2">{{ teachTimeText(row) }}</span></template>
<template #plannedTime="{ row }"><span class="clamp-2">{{ row.planned_time || '-' }}</span></template>
<template #lecturer="{ row }">{{ lectNameMap[row.lecturer_id] || row.lecturer_name || row.lecturer_external || '-' }}</template>
<template #location="{ row }"><span class="clamp-2">{{ courseLocation(row) || '-' }}</span></template>
<template #expected="{ row }">{{ row.actual_count ?? 0 }}/{{ row.expected_count ?? 0 }} 人</template>
<template #learnStatus="{ row }">
<t-tag
:theme="learnStatusTheme(row.learning_status)"
variant="light" size="small" class="status-link"
@click="goStudyStatus(row, 'learning')"
>{{ learnStatusText(row.learning_status) }}</t-tag>
</template>
<template #examStatus="{ row }">
<t-tag
:theme="examStatusTheme(row.exam_status)"
variant="light" size="small" class="status-link"
@click="goStudyStatus(row, 'exam')"
>{{ examStatusText(row.exam_status) }}</t-tag>
</template>
<template #status="{ row }">
<t-tag :theme="statusTheme(row.status)" variant="light" size="small">{{ statusText(row.status) }}</t-tag>
</template>
<template #op="{ row }">
<t-button
v-if="canManage && row.status !== 'published'"
variant="text" theme="primary" size="small" :disabled="saving"
@click="onPublish(row)"
>发布</t-button>
<t-button variant="text" size="small" @click="openDetail(row)">调整</t-button>
<t-button variant="text" size="small" @click="openChangeLogs(row)">记录</t-button>
<!-- 已发布计划仅超级管理员职称角色可删(后端 DeleteCourse 同口径兜底);
普通维护角色仅可删未发布计划 -->
<t-popconfirm
v-if="isSuperAdmin || (canManage && row.status !== 'published')"
content="确定删除该培训计划?" theme="danger" @confirm="onDelete(row)"
>
<t-button variant="text" theme="danger" size="small">删除</t-button>
</t-popconfirm>
</template>
</t-table>
</div>
<!-- 共用分页(000163):默认每页 15 条 -->
<TrainingPagination v-model:current="coursePage" v-model:page-size="coursePageSize" :total="courseTotal" />
</div>
@@ -585,6 +595,9 @@ const props = defineProps<{ roles: string[]; admin?: boolean }>()
// 课程维护:人事/课长/讲师(roles 已按权限组展开,经理经课长继承自动命中);
// 纯讲师的课程列表范围由后端按 lecturer_id 强制收窄。
const canManage = computed(() => props.admin || props.roles.some((r) => r === 'hr' || r === 'supervisor' || r === 'lecturer'))
// 超级管理员职称角色(super_admin):已发布计划的终态删除权唯一入口
// (roles 已按权限组展开,自定义角色继承「超级管理员」权限组后同样命中)
const isSuperAdmin = computed(() => props.roles.includes('super_admin'))
// 纯讲师视角隐藏「按讲师查询」筛选(列表已固定为自己的课程)
const isLecturerOnly = computed(() => !canManage.value || (props.roles.includes('lecturer') && !props.roles.some((r) => r === 'hr' || r === 'supervisor' || r === 'exec')))
const router = useRouter()
@@ -1619,13 +1632,13 @@ const onPublish = async (row: TrainingCourse) => {
}
const onDelete = async (row: TrainingCourse) => {
if (!window.confirm(`确认删除计划「${row.name}」?`)) return
try {
await deleteCourse(row.id)
MessagePlugin.success('已删除')
loadAll()
} catch {
MessagePlugin.error('删除失败')
} catch (e: any) {
// 已发布计划仅超级管理员可删,后端拦截时透出统一文案
MessagePlugin.error(apiErrorMessage(e, '删除失败'))
}
}
@@ -1914,6 +1927,12 @@ watch(() => route?.query?.courseId, openDetailFromRoute)
.training-form-hints-below();
}
// 满屏列表布局(000164):页头固定,面板占满页身剩余高度,
// 筛选区/表头/分页固定,仅表格数据区滚动
.course-panel {
.training-fill-panel();
}
.form-hint {
margin-top: 8px;
color: var(--td-text-color-placeholder);