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

+9 -3
View File
@@ -1250,22 +1250,28 @@ export const ROLE_DICT_RULE_KEY = 'role_dict'
export const TRAINEE_LABEL = '学员'
/** 系统默认职称角色(与后端 DefaultRoleDict 一致;字典缺失/损坏时兜底)。
* 角色体系 v2:学员(隐式)/课长/经理/人事/讲师;经理继承课长全部权限并叠加审批决策。 */
* 角色体系 v2:学员(隐式)/课长/经理/人事/讲师;经理继承课长全部权限并叠加审批决策。
* v2.1 增补超级管理员:不继承任何权限组,仅承载终态数据(已确认需求/已审核课程/
* 已发布计划)的删除权,组织架构「设置角色」可分配。 */
export const DEFAULT_ROLE_DICT: TrainingRoleDef[] = [
{ key: 'hr', label: '人事', short: '人事', system: true },
{ key: 'supervisor', label: '课长', short: '课长', system: true },
{ key: 'lecturer', label: '讲师', short: '讲师', system: true },
{ key: 'exec', label: '经理', short: '经理', system: true, inherits: ['supervisor'] },
{ key: 'super_admin', label: '超级管理员', short: '超管', system: true },
]
/** 存量角色别名:部门文员(clerk)已移除,按课长对待(与后端 LegacyRoleAlias 同构) */
const LEGACY_ROLE_ALIAS: Record<string, string> = { clerk: 'supervisor' }
/** 角色体系 v2 升级判定:经理(exec)必须继承课长,否则视为旧字典(与后端 NeedsRoleDictUpgrade 同构) */
/** 角色体系升级判定(与后端 NeedsRoleDictUpgrade 同构):
* 经理(exec)未继承课长视为 v1 旧字典;v2 口径但缺 v2.1 增补的超级管理员
* 同样需要读时升级补齐(存量租户免迁移)。 */
export function needsRoleDictUpgrade(dict: TrainingRoleDef[]): boolean {
const mgr = dict.find((r) => r.key === 'exec')
if (!mgr) return true
return !(mgr.inherits || []).includes('supervisor')
if (!(mgr.inherits || []).includes('supervisor')) return true
return !dict.some((r) => r.key === 'super_admin')
}
/** v1 存量字典升级为 v2 视图(与后端 UpgradeRoleDictV2 同构,幂等):
+75 -36
View File
@@ -21,14 +21,17 @@
<span class="panel-box__title">部门</span>
<t-button theme="primary" @click="openCreateDept">新增部门</t-button>
</div>
<t-table :data="pagedDepts" :columns="deptColumns" row-key="id" size="small">
<template #op="{ row }">
<div class="op-group">
<t-button variant="text" theme="primary" size="small" @click="onEditDept(row)">修改</t-button>
<t-button variant="text" theme="danger" size="small" @click="onDeleteDept(row)">删除</t-button>
</div>
</template>
</t-table>
<!-- 表格滚动区:面板满屏,表头/分页固定,仅数据行滚动(height=100% 启用固定表头) -->
<div class="table-scroll">
<t-table :data="pagedDepts" :columns="deptColumns" row-key="id" size="small" height="100%">
<template #op="{ row }">
<div class="op-group">
<t-button variant="text" theme="primary" size="small" @click="onEditDept(row)">修改</t-button>
<t-button variant="text" theme="danger" size="small" @click="onDeleteDept(row)">删除</t-button>
</div>
</template>
</t-table>
</div>
<!-- 共用分页(000164):默认每页 15 条 -->
<TrainingPagination v-model:current="deptPage" v-model:page-size="deptPageSize" :total="deptTotal" />
</div>
@@ -66,32 +69,35 @@
<t-button theme="primary" @click="importVisible = true">批量导入</t-button>
</div>
</div>
<t-table :data="pagedEmployees" :columns="employeeColumns" row-key="id" size="small" :loading="loading">
<template #user_name="{ row }">
<t-tooltip :content="employeeName(row)" :disabled="!employeeName(row)">
<span class="employee-name">{{ employeeName(row) || '-' }}</span>
</t-tooltip>
</template>
<template #dept_name="{ row }">{{ row.dept_name || '-' }}</template>
<template #wecom_userid="{ row }">
<span :class="row.wecom_userid ? '' : 'wecom-missing'">{{ row.wecom_userid || '未绑定' }}</span>
</template>
<template #roles="{ row }">
<t-tag v-for="r in row.roles || []" :key="r" variant="light" size="small" class="role-tag">{{ roleText(r) }}</t-tag>
</template>
<template #status="{ row }">
<t-tag v-if="row.status === 'active'" theme="success" variant="light" size="small">在职</t-tag>
<t-tag v-else-if="row.status === 'inactive'" theme="danger" variant="light" size="small">离职</t-tag>
<t-tag v-else theme="default" variant="light" size="small">{{ row.status || '-' }}</t-tag>
</template>
<template #op="{ row }">
<div class="op-group">
<t-button variant="text" theme="primary" size="small" @click="onEditEmployee(row)">修改</t-button>
<t-button v-if="canManage" variant="text" theme="primary" size="small" @click="openWecom(row)">企微账号</t-button>
<t-button v-if="canManage" variant="text" theme="primary" size="small" @click="openRoles(row)">设置角色</t-button>
</div>
</template>
</t-table>
<!-- 表格滚动区:面板满屏,表头/分页固定,仅数据行滚动(height=100% 启用固定表头) -->
<div class="table-scroll">
<t-table :data="pagedEmployees" :columns="employeeColumns" row-key="id" size="small" height="100%" :loading="loading">
<template #user_name="{ row }">
<t-tooltip :content="employeeName(row)" :disabled="!employeeName(row)">
<span class="employee-name">{{ employeeName(row) || '-' }}</span>
</t-tooltip>
</template>
<template #dept_name="{ row }">{{ row.dept_name || '-' }}</template>
<template #wecom_userid="{ row }">
<span :class="row.wecom_userid ? '' : 'wecom-missing'">{{ row.wecom_userid || '未绑定' }}</span>
</template>
<template #roles="{ row }">
<t-tag v-for="r in row.roles || []" :key="r" variant="light" size="small" class="role-tag">{{ roleText(r) }}</t-tag>
</template>
<template #status="{ row }">
<t-tag v-if="row.status === 'active'" theme="success" variant="light" size="small">在职</t-tag>
<t-tag v-else-if="row.status === 'inactive'" theme="danger" variant="light" size="small">离职</t-tag>
<t-tag v-else theme="default" variant="light" size="small">{{ row.status || '-' }}</t-tag>
</template>
<template #op="{ row }">
<div class="op-group">
<t-button variant="text" theme="primary" size="small" @click="onEditEmployee(row)">修改</t-button>
<t-button v-if="canManage" variant="text" theme="primary" size="small" @click="openWecom(row)">企微账号</t-button>
<t-button v-if="canManage" variant="text" theme="primary" size="small" @click="openRoles(row)">设置角色</t-button>
</div>
</template>
</t-table>
</div>
<!-- 共用分页(000164):默认每页 15 条 -->
<TrainingPagination v-model:current="employeePage" v-model:page-size="employeePageSize" :total="employeeTotal" />
</div>
@@ -854,15 +860,23 @@ onMounted(() => {
}
// 分栏:部门列收窄为固定宽度(000164,原 3fr 过宽且编码列留白明显),
// 员工档案占剩余全部宽度;窄屏退化为单列
// 员工档案占剩余全部宽度;窄屏退化为单列。
// 满屏布局(000164 布局诉求):栅格占满页身剩余高度,两面板各自内部滚动 ——
// 面板头(标题/操作/查找)/表头/分页固定,仅表格数据区滚动;窄屏单列回退整页滚动
.org-layout {
display: grid;
grid-template-columns: 280px minmax(0, 1fr);
// 满屏关键:行高锁定为容器高(grid 行默认 auto 会被内容撑开,面板 height:100%
// 的百分比链随之失效,表头/分页固定就不生效了)
grid-template-rows: minmax(0, 1fr);
gap: 12px;
align-items: start;
height: 100%;
min-height: 0;
@media (max-width: 900px) {
grid-template-columns: 1fr;
grid-template-rows: none;
height: auto;
}
// 000164 栅格子项收敛:员工档案表格/工具行较宽,缺省 min-width 会把
@@ -875,6 +889,31 @@ onMounted(() => {
.panel-box {
.training-panel-box();
.org-layout & {
display: flex;
flex-direction: column;
height: 100%;
@media (max-width: 900px) {
height: auto;
}
}
// 面板头固定,表格滚动区撑满剩余高度(表格 height=100% 启用 TDesign 固定表头;
// .t-table 根也要撑满 100%,否则百分比退化为内容高、表头固定不生效)
.org-layout & > .table-scroll {
flex: 1;
min-height: 0;
> .t-table {
height: 100%;
}
}
.org-layout & > .training-pagination {
flex-shrink: 0;
}
}
.form-hint {
+2 -2
View File
@@ -124,11 +124,11 @@ const isAdmin = computed(() =>
myRoles.value.some((r) => r === 'hr') ||
authStore.hasRole('admin'))
// 培训管理页签(培训计划/培训课程/培训签到)门槛:课长/经理/人事/讲师
// 培训管理页签(培训计划/培训课程/培训签到)门槛:课长/经理/人事/讲师/超级管理员
// (myRoles 已按权限组展开,自定义角色继承系统角色后自动生效)。
const canManageTabs = computed(() =>
isAdmin.value ||
myRoles.value.some((r) => ['hr', 'supervisor', 'exec', 'lecturer'].includes(r)))
myRoles.value.some((r) => ['hr', 'supervisor', 'exec', 'lecturer', 'super_admin'].includes(r)))
// 配置中心门槛(000158):人事/空间管理员之外,经理职称角色同权查看与维护。
const canManageConfig = computed(() =>
@@ -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);
@@ -46,97 +46,103 @@
<span v-if="selectedKeys.length" class="library-filter-count">已选 {{ selectedKeys.length }} 项</span>
</div>
<t-table
v-model:selected-row-keys="selectedKeys"
:data="pagedItems" :columns="columns" row-key="id" size="small" :loading="loading"
>
<template #code="{ row }">{{ row.code || '-' }}</template>
<template #name="{ row }"><span class="clamp-2">{{ row.name }}</span></template>
<template #description="{ row }">
<t-tooltip v-if="row.description" :content="row.description">
<span class="cell-ellipsis">{{ row.description }}</span>
</t-tooltip>
<span v-else>-</span>
</template>
<template #category="{ row }">
<t-tag v-if="row.category" theme="primary" variant="light" size="small">{{ row.category }}</t-tag>
<span v-else>-</span>
</template>
<template #type="{ row }">
<t-tag :theme="row.type === 'elective' ? 'default' : 'warning'" variant="light" size="small">
{{ row.type === 'elective' ? '选修课' : '必修课' }}
</t-tag>
</template>
<template #mode="{ row }">
<t-tag :theme="row.mode === 'online' ? 'primary' : 'default'" variant="light" size="small">
{{ row.mode === 'online' ? '线上' : '线下' }}
</t-tag>
</template>
<template #lecturer="{ row }">{{ lecturerText(row) }}</template>
<template #hours="{ row }">{{ row.hours ? `${row.hours} 学时` : '-' }}</template>
<template #owner_dept="{ row }">
<span v-if="row.owner_dept_name" class="cell-ellipsis" :title="row.owner_dept_name">{{ row.owner_dept_name }}</span>
<span v-else>-</span>
</template>
<template #suitable_members="{ row }">
<!-- 课程权限(000163,原「适合人员」):部门+人员展示文本 -->
<span v-if="permissionText(row)" class="cell-ellipsis" :title="permissionText(row)">{{ permissionText(row) }}</span>
<span v-else>-</span>
</template>
<template #material="{ row }">
<!-- 课件只展示有/无:有=已上传文件或已挂接知识库课件,点击直达课件管理抽屉 -->
<t-tag v-if="hasMaterial(row)" theme="success" variant="light" size="small" class="cell-link" @click="openMaterialDrawer(row)">有</t-tag>
<t-tag v-else theme="default" variant="light" size="small">无</t-tag>
</template>
<template #question="{ row }">
<!-- 试题只展示有/无:有=课程已关联题库,点击直达试题管理抽屉 -->
<t-tag v-if="(row.question_bank_count || 0) > 0" theme="success" variant="light" size="small" class="cell-link" @click="openQuestions(row)">有</t-tag>
<t-tag v-else theme="default" variant="light" size="small">无</t-tag>
</template>
<template #created_at="{ row }">{{ fmtBeijingTime(row.created_at) || '-' }}</template>
<!-- 创建人(联查 users):记录课程由谁录入 -->
<template #creator_name="{ row }">{{ row.creator_name || '-' }}</template>
<template #publish_status="{ row }">
<t-tag
:theme="row.publish_status === 'published' ? 'success' : row.publish_status === 'offline' ? 'default' : 'warning'"
variant="light" size="small"
>{{ publishStatusText(row.publish_status) }}</t-tag>
</template>
<!-- 审核状态(000157/000163):新增/编辑后待审核,课长/经理审核确认后
即自动发布(无需再点发布) -->
<template #verify_status="{ row }">
<t-tag :theme="row.verify_status === 'confirmed' ? 'success' : 'warning'" variant="light" size="small">
{{ row.verify_status === 'confirmed' ? '已审核' : '待审核' }}
</t-tag>
</template>
<template #op="{ row }">
<t-button v-if="canEditCourse(row)" variant="text" theme="primary" size="small" @click="openForm(row)">编辑</t-button>
<t-button variant="text" size="small" @click="openMaterialDrawer(row)">课件</t-button>
<t-button variant="text" size="small" @click="openQuestions(row)">试题</t-button>
<t-popconfirm
v-if="canVerifyCourse(row)"
content="审核通过后将立即发布(权限范围内的部门和人员可在培训中心/培训计划中查看),确认审核通过?" theme="primary"
@confirm="onVerify(row)"
>
<t-button variant="text" theme="primary" size="small">审核</t-button>
</t-popconfirm>
<!-- 下线(000163):下线后课程不能再被使用 —— 和信课程撤回、计划不可
再选用、已建计划学习时提示「该课程已下线」;存量培训计划保留 -->
<t-popconfirm
v-if="canManage && row.publish_status === 'published'"
content="下线后该课程不能再被使用:培训中心「和信课程」不再展示,培训计划不可再选用,已建计划学习时提示「该课程已下线」(已有培训计划不会消失)。确定下线?" theme="danger"
@confirm="onSetPublishStatus(row, 'offline')"
>
<t-button variant="text" theme="danger" size="small">下线</t-button>
</t-popconfirm>
<!-- 表格滚动区:面板满屏,筛选/表头/分页固定,仅数据行滚动(height=100% 启用固定表头) -->
<div class="table-scroll">
<t-table
v-model:selected-row-keys="selectedKeys"
:data="pagedItems" :columns="columns" row-key="id" size="small" height="100%" :loading="loading"
>
<template #code="{ row }">{{ row.code || '-' }}</template>
<template #name="{ row }"><span class="clamp-2">{{ row.name }}</span></template>
<template #description="{ row }">
<t-tooltip v-if="row.description" :content="row.description">
<span class="cell-ellipsis">{{ row.description }}</span>
</t-tooltip>
<span v-else>-</span>
</template>
<template #category="{ row }">
<t-tag v-if="row.category" theme="primary" variant="light" size="small">{{ row.category }}</t-tag>
<span v-else>-</span>
</template>
<template #type="{ row }">
<t-tag :theme="row.type === 'elective' ? 'default' : 'warning'" variant="light" size="small">
{{ row.type === 'elective' ? '选修课' : '必修课' }}
</t-tag>
</template>
<template #mode="{ row }">
<t-tag :theme="row.mode === 'online' ? 'primary' : 'default'" variant="light" size="small">
{{ row.mode === 'online' ? '线上' : '线下' }}
</t-tag>
</template>
<template #lecturer="{ row }">{{ lecturerText(row) }}</template>
<template #hours="{ row }">{{ row.hours ? `${row.hours} 学时` : '-' }}</template>
<template #owner_dept="{ row }">
<span v-if="row.owner_dept_name" class="cell-ellipsis" :title="row.owner_dept_name">{{ row.owner_dept_name }}</span>
<span v-else>-</span>
</template>
<template #suitable_members="{ row }">
<!-- 课程权限(000163,原「适合人员」):部门+人员展示文本 -->
<span v-if="permissionText(row)" class="cell-ellipsis" :title="permissionText(row)">{{ permissionText(row) }}</span>
<span v-else>-</span>
</template>
<template #material="{ row }">
<!-- 课件只展示有/无:有=已上传文件或已挂接知识库课件,点击直达课件管理抽屉 -->
<t-tag v-if="hasMaterial(row)" theme="success" variant="light" size="small" class="cell-link" @click="openMaterialDrawer(row)">有</t-tag>
<t-tag v-else theme="default" variant="light" size="small">无</t-tag>
</template>
<template #question="{ row }">
<!-- 试题只展示有/无:有=课程已关联题库,点击直达试题管理抽屉 -->
<t-tag v-if="(row.question_bank_count || 0) > 0" theme="success" variant="light" size="small" class="cell-link" @click="openQuestions(row)">有</t-tag>
<t-tag v-else theme="default" variant="light" size="small">无</t-tag>
</template>
<template #created_at="{ row }">{{ fmtBeijingTime(row.created_at) || '-' }}</template>
<!-- 创建人(联查 users):记录课程由谁录入 -->
<template #creator_name="{ row }">{{ row.creator_name || '-' }}</template>
<template #publish_status="{ row }">
<t-tag
:theme="row.publish_status === 'published' ? 'success' : row.publish_status === 'offline' ? 'default' : 'warning'"
variant="light" size="small"
>{{ publishStatusText(row.publish_status) }}</t-tag>
</template>
<!-- 审核状态(000157/000163):新增/编辑后待审核,课长/经理审核确认后
即自动发布(无需再点发布) -->
<template #verify_status="{ row }">
<t-tag :theme="row.verify_status === 'confirmed' ? 'success' : 'warning'" variant="light" size="small">
{{ row.verify_status === 'confirmed' ? '已审核' : '待审核' }}
</t-tag>
</template>
<template #op="{ row }">
<t-button v-if="canEditCourse(row)" variant="text" theme="primary" size="small" @click="openForm(row)">编辑</t-button>
<t-button variant="text" size="small" @click="openMaterialDrawer(row)">课件</t-button>
<t-button variant="text" size="small" @click="openQuestions(row)">试题</t-button>
<t-popconfirm
v-if="canVerifyCourse(row)"
content="审核通过后将立即发布(权限范围内的部门和人员可在培训中心/培训计划中查看),确认审核通过?" theme="primary"
@confirm="onVerify(row)"
>
<t-button variant="text" theme="primary" size="small">审核</t-button>
</t-popconfirm>
<!-- 下线(000163):下线后课程不能再被使用 —— 和信课程撤回、计划不可
再选用、已建计划学习时提示「该课程已下线」;存量培训计划保留 -->
<t-popconfirm
v-if="canManage && row.publish_status === 'published'"
content="下线后该课程不能再被使用:培训中心「和信课程」不再展示,培训计划不可再选用,已建计划学习时提示「该课程已下线」(已有培训计划不会消失)。确定下线?" theme="danger"
@confirm="onSetPublishStatus(row, 'offline')"
>
<t-button variant="text" theme="danger" size="small">下线</t-button>
</t-popconfirm>
<t-popconfirm
v-if="canDeleteCourse(row)"
content="仅待审核状态的课程可删除,确定删除该课程?已创建的月培训计划不受影响。" theme="danger" @confirm="onDelete(row)"
:content="row.verify_status === 'pending'
? '确定删除该课程?已创建的月培训计划不受影响。'
: '该课程已审核,删除后已创建的月培训计划不受影响但课程不可恢复,确定删除?'"
theme="danger" @confirm="onDelete(row)"
>
<t-button variant="text" theme="danger" size="small">删除</t-button>
</t-popconfirm>
</template>
</t-table>
<t-button variant="text" theme="danger" size="small">删除</t-button>
</t-popconfirm>
</template>
</t-table>
</div>
<!-- 共用分页(000163):默认每页 15 条 -->
<TrainingPagination v-model:current="itemPage" v-model:page-size="itemPageSize" :total="itemTotal" />
</div>
@@ -725,16 +731,19 @@ const hasPermSet = (row: TrainingLibraryCourse) =>
// 审核/删除权限(000157):严格限「本部门课长/经理」——人事/空间管理员一律无
// 跨部门审核/删除权(roles 已按权限组展开,经理经课长继承自动命中 supervisor)。
const canVerify = computed(() => props.roles.includes('supervisor'))
const canDelete = canVerify
// 超级管理员职称角色(super_admin):终态数据删除权唯一入口,已审核/已发布课程
// 与跨部门均可删(后端 DeleteCourseLibraryItem 同口径兜底);审核权不放宽
const isSuperAdmin = computed(() => props.roles.includes('super_admin'))
const canDelete = computed(() => canVerify.value || isSuperAdmin.value)
// 仅本部门「待审核」课程可审核/删除;与后端 callerVerifyDeptScope 同口径:
// 无部门身份或课程所属部门与本人不一致时一律不可操作。
// 无部门身份或课程所属部门与本人不一致时一律不可操作。超级管理员不限状态/部门。
const canVerifyCourse = (row: TrainingLibraryCourse) =>
canVerify.value &&
row.verify_status === 'pending' &&
Boolean(myDeptId.value) &&
Boolean(row.owner_dept_id) &&
row.owner_dept_id === myDeptId.value
const canDeleteCourse = canVerifyCourse
const canDeleteCourse = (row: TrainingLibraryCourse) => isSuperAdmin.value || canVerifyCourse(row)
// 编辑权限:维护角色可编辑可见课程;无维护角色的学员仅可编辑「与我相关」课程
// (本人创建或本人授课,后端兜底校验同口径)
@@ -1057,10 +1066,11 @@ const onBatchVerify = async () => {
}
const onBatchDelete = async () => {
// 与后端口径一致:仅本部门待审核行提交(已审核/越权行跳过)
// 与后端口径一致:普通角色仅本部门待审核行提交(已审核/越权行跳过);
// 超级管理员不限状态/部门(canDeleteCourse 按角色过滤,终态行可整批删除)
const rows = filteredItems.value.filter((r) => selectedKeys.value.includes(r.id) && canDeleteCourse(r))
if (!rows.length) {
MessagePlugin.warning('请先勾选本部门待审核状态的课程')
MessagePlugin.warning(isSuperAdmin.value ? '请先勾选要删除的课程' : '请先勾选本部门待审核状态的课程')
return
}
batchSaving.value = true
@@ -1897,6 +1907,10 @@ onMounted(loadAll)
.panel-box {
.training-panel-box();
}
// 满屏列表布局(000164):页头固定,面板占满页身剩余高度,
// 筛选区/表头/分页固定,仅表格数据区滚动
.training-fill-panel();
}
.library-filters {
@@ -41,49 +41,52 @@
<t-button variant="outline" @click="onSearchDemands">查询</t-button>
<t-button variant="outline" @click="onResetDemandSearch">重置</t-button>
<t-button v-if="canConfirm" theme="primary" variant="outline" :disabled="!selectedDemandKeys.length" :loading="batchSaving" @click="onBatchConfirm">批量确认</t-button>
<t-button v-if="canManage" theme="danger" variant="outline" :disabled="!selectedDemandKeys.length" :loading="batchSaving" @click="onBatchDelete">批量删除</t-button>
<span class="demand-selected-hint">已选 {{ selectedDemandKeys.length }} 项(可批量确认/删除未确认需求)</span>
<t-button v-if="canManage || isSuperAdmin" theme="danger" variant="outline" :disabled="!selectedDemandKeys.length" :loading="batchSaving" @click="onBatchDelete">批量删除</t-button>
<span class="demand-selected-hint">已选 {{ selectedDemandKeys.length }} 项(可批量确认/删除未确认需求{{ isSuperAdmin ? ';超级管理员可删除已确认需求' : '' }})</span>
</div>
<t-table
v-model:selected-row-keys="selectedDemandKeys"
:data="pagedDemands"
:columns="demandColumns"
row-key="id"
size="small"
:loading="loading"
>
<template #dept_name="{ row }">{{ row.dept_name || '-' }}</template>
<template #code="{ row }">
<t-tooltip v-if="row.code" :content="row.code">
<span class="cell-ellipsis">{{ row.code }}</span>
</t-tooltip>
<span v-else>-</span>
</template>
<template #lecturer_name="{ row }">{{ row.lecturer_name || '-' }}</template>
<!-- 计划培训月份入库格式「YYYY-M」(如 2027-1),原样展示 -->
<template #planned_time="{ row }">{{ row.planned_time || '-' }}</template>
<template #location="{ row }">{{ row.location || '-' }}</template>
<!-- 适合人员/备注可能很长:单行省略,悬停浮出全部内容 -->
<template #post_scope="{ row }">
<t-tooltip v-if="row.post_scope" :content="row.post_scope">
<span class="cell-ellipsis">{{ row.post_scope }}</span>
</t-tooltip>
<span v-else>-</span>
</template>
<template #remark="{ row }">
<t-tooltip v-if="row.remark" :content="row.remark">
<span class="cell-ellipsis">{{ row.remark }}</span>
</t-tooltip>
<span v-else>-</span>
</template>
<!-- 创建人(提报人姓名)/创建时间:记录需求由谁何时录入 -->
<template #submitter_name="{ row }">{{ row.submitter_name || '-' }}</template>
<template #created_at="{ row }">{{ fmtBeijingTime(row.created_at) || '-' }}</template>
<template #check_status="{ row }">
<t-tag v-if="row.check_status === 'passed'" theme="success" variant="light" size="small">已确认</t-tag>
<t-tag v-else-if="row.check_status === 'pending'" theme="warning" variant="light" size="small">待核验</t-tag>
<t-tag v-else theme="default" variant="light" size="small">已修正</t-tag>
</template>
<!-- 表格滚动区:面板满屏,筛选/表头/分页固定,仅数据行滚动(height=100% 启用固定表头) -->
<div class="table-scroll">
<t-table
v-model:selected-row-keys="selectedDemandKeys"
:data="pagedDemands"
:columns="demandColumns"
row-key="id"
size="small"
height="100%"
:loading="loading"
>
<template #dept_name="{ row }">{{ row.dept_name || '-' }}</template>
<template #code="{ row }">
<t-tooltip v-if="row.code" :content="row.code">
<span class="cell-ellipsis">{{ row.code }}</span>
</t-tooltip>
<span v-else>-</span>
</template>
<template #lecturer_name="{ row }">{{ row.lecturer_name || '-' }}</template>
<!-- 计划培训月份入库格式「YYYY-M」(如 2027-1),原样展示 -->
<template #planned_time="{ row }">{{ row.planned_time || '-' }}</template>
<template #location="{ row }">{{ row.location || '-' }}</template>
<!-- 适合人员/备注可能很长:单行省略,悬停浮出全部内容 -->
<template #post_scope="{ row }">
<t-tooltip v-if="row.post_scope" :content="row.post_scope">
<span class="cell-ellipsis">{{ row.post_scope }}</span>
</t-tooltip>
<span v-else>-</span>
</template>
<template #remark="{ row }">
<t-tooltip v-if="row.remark" :content="row.remark">
<span class="cell-ellipsis">{{ row.remark }}</span>
</t-tooltip>
<span v-else>-</span>
</template>
<!-- 创建人(提报人姓名)/创建时间:记录需求由谁何时录入 -->
<template #submitter_name="{ row }">{{ row.submitter_name || '-' }}</template>
<template #created_at="{ row }">{{ fmtBeijingTime(row.created_at) || '-' }}</template>
<template #check_status="{ row }">
<t-tag v-if="row.check_status === 'passed'" theme="success" variant="light" size="small">已确认</t-tag>
<t-tag v-else-if="row.check_status === 'pending'" theme="warning" variant="light" size="small">待核验</t-tag>
<t-tag v-else theme="default" variant="light" size="small">已修正</t-tag>
</template>
<template #op="{ row }">
<template v-if="row.status !== 'confirmed'">
<t-button
@@ -97,8 +100,16 @@
<t-button variant="text" theme="danger" size="small">删除</t-button>
</t-popconfirm>
</template>
<!-- 已确认需求纳入年度排期,普通角色不可删;超级管理员职称角色放开终态删除 -->
<t-popconfirm
v-else-if="isSuperAdmin"
content="该需求已确认,删除后不可恢复,确定删除?" theme="danger" @confirm="onDeleteDemand(row)"
>
<t-button variant="text" theme="danger" size="small">删除</t-button>
</t-popconfirm>
</template>
</t-table>
</t-table>
</div>
<!-- 共用分页(000163):默认每页 15 条 -->
<TrainingPagination v-model:current="demandPage" v-model:page-size="demandPageSize" :total="demandTotal" />
</div>
@@ -421,8 +432,14 @@ const deptDisplay = computed(() => {
return myDeptName.value
})
const demandColumns = [
{ colKey: 'row-select', type: 'multiple', width: 44, disabled: ({ row }: { row: TrainingDemand }) => row.status === 'confirmed' },
// 超级管理员职称角色(super_admin):终态数据(已确认需求等)删除权唯一入口;
// roles 已按权限组展开,自定义角色继承「超级管理员」权限组后同样命中
const isSuperAdmin = computed(() => props.roles.includes('super_admin'))
// 已确认行默认禁止勾选(批量确认/删除仅作用于未确认需求);超级管理员可勾选
// 以批量删除,故勾选禁用按角色动态计算(computed 随 props.roles 就绪刷新)
const demandColumns = computed(() => [
{ colKey: 'row-select', type: 'multiple', width: 44, disabled: ({ row }: { row: TrainingDemand }) => row.status === 'confirmed' && !isSuperAdmin.value },
// 年计划编号(AP-<year>-####,创建时由服务端生成)
{ colKey: 'code', title: '编号', width: 130 },
{ colKey: 'course_name', title: '课程名称' },
@@ -439,7 +456,7 @@ const demandColumns = [
// 状态/操作固定在列表右侧,横向滚动时始终可见
{ colKey: 'check_status', title: '状态', width: 84, fixed: 'right' },
{ colKey: 'op', title: '操作', width: 160, fixed: 'right' },
]
])
// 批量确认/删除(仅作用于未确认需求,已确认行不可勾选)
const selectedDemandKeys = ref<string[]>([])
@@ -482,9 +499,11 @@ const onBatchConfirm = async () => {
}
const onBatchDelete = async () => {
const rows = demands.value.filter((d) => selectedDemandKeys.value.includes(d.id) && d.status !== 'confirmed')
// 勾选口径:未确认行全员可勾;已确认行仅超级管理员可勾(isSuperAdmin 放开勾选),
// 后端按行校验终态删除权,越权行整批报错提示
const rows = demands.value.filter((d) => selectedDemandKeys.value.includes(d.id))
if (!rows.length) {
MessagePlugin.warning('请先勾选未确认的需求')
MessagePlugin.warning('请先勾选要删除的需求')
return
}
batchSaving.value = true
@@ -1043,6 +1062,12 @@ onMounted(() => {
.training-form-hints-below();
}
// 满屏列表布局(000164):页头固定,面板占满页身剩余高度,
// 筛选区/表头/分页固定,仅表格数据区滚动
.plan-panel {
.training-fill-panel();
}
// 已确认行不做整行置灰:t-table 行选择列 disabled 命中时会加 __row--disabled
// 类(整行 text-color-disabled),业务上已确认行仅禁止勾选,文字保持正常色
:deep(.t-table__row--disabled) {
@@ -1052,8 +1052,30 @@ watch(pushScene, () => loadPushLogs())
display: none;
}
// ---- tab 化布局:tab 内容区与 panel-box 间距 ----
// ---- tab 化布局:页头与页签条固定,仅 tab 内容区滚动(000164 布局诉求) ----
.rule-panel {
height: 100%;
min-height: 0;
display: flex;
flex-direction: column;
}
.rule-tabs {
flex: 1;
min-height: 0;
display: flex;
flex-direction: column;
:deep(.t-tabs__header) {
flex-shrink: 0;
}
:deep(.t-tabs__content) {
flex: 1;
min-height: 0;
overflow-y: auto;
}
:deep(.t-tab-panel) {
padding: 12px 0 0;
}
+39
View File
@@ -124,6 +124,45 @@
}
}
// 列表页满屏布局(年培训计划/月培训计划/课程管理):页头(标题)固定不动,
// 面板占满页身剩余高度,内部「面板标题/筛选区/分页」固定,仅表格数据区滚动。
// 约定:panel-box 收为 flex 列,表格外包一层 .table-scroll(flex:1 撑满剩余
// 高度),表格传 height="100%" 启用 TDesign 固定表头(thead sticky + 数据行滚动)。
.training-fill-panel() {
height: 100%;
min-height: 0;
display: flex;
flex-direction: column;
> .panel-box {
flex: 1;
min-height: 0;
display: flex;
flex-direction: column;
}
> .panel-box > .panel-box__header,
> .panel-box > .panel-box__sub {
flex-shrink: 0;
}
> .panel-box > .table-scroll {
flex: 1;
min-height: 0;
// 满屏关键:TDesign 的 height="100%" 落在内部 .t-table__content 上,而其父级
// .t-table 根默认 auto 高,百分比会退化为内容高(表头固定不生效);给根也撑满
// 100% 形成确定高度链,数据区才会真正滚动
> .t-table {
height: 100%;
}
}
> .panel-box > .training-pagination {
flex-shrink: 0;
}
}
// 内容卡片:对齐知识库 resource-card 规范(描边 + 8px 圆角 + 容器底色)
.training-panel-box() {
background: var(--td-bg-color-container);