feat(优化):年培训计划:已确认行的删除按钮、勾选框、批量删除均仅超级管理员可见/可用;提示文案随角色变化
deploy-hxtesting / build-and-deploy (push) Successful in 1m14s
deploy-hxtesting / build-and-deploy (push) Successful in 1m14s
课程管理:canDeleteCourse 超管不限状态/部门(已审核/已发布行可删,确认弹窗文案区分);批量删除按钮超管可见 月培训计划:已发布行的「删除」仅超管可见(普通维护角色仍只能删未发布计划),行内确认弹窗替代原 window.confirm,失败时透出后端文案 Training.vue:canManageTabs 加入 super_admin,纯超管(未兼其他角色)也能进入这三个页面执行删除
This commit is contained in:
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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user