feat(training): 企业培训迭代:核验权限收窄、课程发布状态与培训中心改版
需求域: - 需求导入修复内/外培训与外部讲师落库;按模板标题年入库(年-月一致) - 核验确认收窄为「需求归属部门+经理职称角色」,越权提示联系部门经理 - 确认转月计划后自动推送讲师/课长维护;导入后自动推送部门经理核验(站内+企微) 课程域: - 课程管理发布状态字段(迁移000154)+发布/下线;培训中心「和信课程」目录 - 需求讲师改选后回写课程管理;确认同步带出适合人员/课件/试题 - 月计划详情课件/试题更换(上传/知识库选择/题库换绑)回写课程管理, 无关联条目的存量计划自动创建课程条目 模板与表单: - 教育训练需求表:适合人员/内-外培训口径;部门联动课程下拉; 适合人员/讲师按所选课程自动带出;在线提报课程下拉(本部门)自动带出分类/讲师/适合人员 页面与权限: - 培训中心页签重组(和信课程/我的培训/我的考试),移除线上/线下页签 - 数据驾驶舱迁侧栏(职称角色之下);职称角色迁至更多工具配置中心之后 - 配置中心/职称角色对经理开放;页签「职称角色」更名「角色权限」 - 修复年度下拉空白(TDesign options 需对象数组)、月计划列表地点兜底 其他: 培训预览端口修正与 dev:training 脚本;tmp-extract-duckdb 加入 gitignore
This commit is contained in:
1 parent
aae041a0b4
commit
242dd7e1a6
47 files changed
+5882
-1134
No files matched your search
@@ -10,7 +10,7 @@
|
||||
</h2>
|
||||
<t-tag v-if="myRoleLabel" theme="primary" variant="light">{{ myRoleLabel }}</t-tag>
|
||||
</div>
|
||||
<!-- 工作台视图切换:课程 / 个人成长 / 数据驾驶舱(驾驶舱仅培训管理角色可见) -->
|
||||
<!-- 工作台视图切换:课程 / 个人成长(数据驾驶舱已迁侧栏,000158) -->
|
||||
<nav v-if="isWorkbench" class="workbench-switch" aria-label="工作台视图切换">
|
||||
<button
|
||||
v-for="t in workbenchSwitchTabs"
|
||||
@@ -26,7 +26,7 @@
|
||||
<p class="training-subtitle">{{ activeTabMeta.desc }}</p>
|
||||
</header>
|
||||
|
||||
<!-- 子页(工作台/培训计划/…/配置中心)由侧栏「企业培训」分组导航,此处按路由 tab 参数渲染 -->
|
||||
<!-- 子页(培训中心/年培训计划/…/配置中心)由侧栏「企业培训」分组导航,此处按路由 tab 参数渲染 -->
|
||||
<t-alert
|
||||
v-if="sessionExpired"
|
||||
class="training-session-alert"
|
||||
@@ -35,15 +35,24 @@
|
||||
description="培训数据未丢失。请重新登录后刷新本页即可查看。"
|
||||
/>
|
||||
<div class="training-body">
|
||||
<!-- 工作台:课程(默认)/个人成长/数据驾驶舱 三视图自由切换 -->
|
||||
<!-- 工作台:课程(默认)/个人成长 两视图切换;数据驾驶舱已迁侧栏(000158) -->
|
||||
<WorkbenchPanel v-if="activeTab === 'dashboard'" :roles="myRoles" :admin="isAdmin" :tab="workbenchTab" />
|
||||
<!-- 数据驾驶舱独立子页(000158):与工作台驾驶舱视图同源,非管理角色回落课程目录 -->
|
||||
<template v-else-if="activeTab === 'data-dashboard'">
|
||||
<WorkbenchPanel v-if="canSeeWorkbenchDashboard" :roles="myRoles" :admin="isAdmin" tab="dashboard" />
|
||||
<t-empty v-else class="training-empty" description="数据驾驶舱仅人事/课长/经理可见" />
|
||||
</template>
|
||||
<template v-else-if="activeTab === 'plan'">
|
||||
<PlanPanel v-if="canManageTabs" :roles="myRoles" :admin="isAdmin" />
|
||||
<t-empty v-else class="training-empty" description="培训计划仅课长/经理/人事可见" />
|
||||
</template>
|
||||
<template v-else-if="activeTab === 'course'">
|
||||
<CoursePanel v-if="canManageTabs" :roles="myRoles" :admin="isAdmin" />
|
||||
<t-empty v-else class="training-empty" description="课程维护仅课长/经理/人事/讲师可见,学员请前往工作台课程目录" />
|
||||
<t-empty v-else class="training-empty" description="月培训计划仅课长/经理/人事/讲师可见,学员请前往培训中心课程目录" />
|
||||
</template>
|
||||
<template v-else-if="activeTab === 'library'">
|
||||
<LibraryPanel v-if="canManageTabs" :roles="myRoles" :admin="isAdmin" />
|
||||
<t-empty v-else class="training-empty" description="课程管理仅课长/经理/人事/讲师可见" />
|
||||
</template>
|
||||
<template v-else-if="activeTab === 'sign'">
|
||||
<SignPanel v-if="canManageTabs" :roles="myRoles" :admin="isAdmin" />
|
||||
@@ -51,12 +60,14 @@
|
||||
</template>
|
||||
<StudyPanel v-else-if="activeTab === 'study'" :roles="myRoles" :admin="isAdmin" />
|
||||
<template v-else-if="activeTab === 'members'">
|
||||
<MemberPanel v-if="isAdmin" />
|
||||
<t-empty v-else class="training-empty" description="职称角色维护仅人事可见" />
|
||||
<!-- 职称角色对经理开放(000159):与配置中心「角色权限」页签同口径 -->
|
||||
<MemberPanel v-if="canManageConfig" />
|
||||
<t-empty v-else class="training-empty" description="职称角色维护仅人事/经理可见" />
|
||||
</template>
|
||||
<template v-else-if="activeTab === 'rules'">
|
||||
<RulePanel v-if="isAdmin" />
|
||||
<t-empty v-else class="training-empty" description="配置中心仅人事可见" />
|
||||
<!-- 配置中心对经理开放(000158):经理与人事同权查看/维护培训规则 -->
|
||||
<RulePanel v-if="canManageConfig" />
|
||||
<t-empty v-else class="training-empty" description="配置中心仅人事/经理可见" />
|
||||
</template>
|
||||
<WorkbenchPanel v-else :roles="myRoles" :admin="isAdmin" :tab="workbenchTab" />
|
||||
</div>
|
||||
@@ -72,6 +83,7 @@ import ResourceIcon from '@/components/icons/ResourceIcon.vue'
|
||||
import WorkbenchPanel from './components/WorkbenchPanel.vue'
|
||||
import PlanPanel from './components/PlanPanel.vue'
|
||||
import CoursePanel from './components/CoursePanel.vue'
|
||||
import LibraryPanel from './components/LibraryPanel.vue'
|
||||
import SignPanel from './components/SignPanel.vue'
|
||||
import MemberPanel from './components/MemberPanel.vue'
|
||||
import StudyPanel from './components/StudyPanel.vue'
|
||||
@@ -79,10 +91,14 @@ import RulePanel from './components/RulePanel.vue'
|
||||
import { expandRoles, fetchRoleDict, getMyProfile, roleLabelOf, type TrainingMember, type TrainingRoleDef } from '@/api/training'
|
||||
|
||||
// 与侧栏「企业培训」分组文案一致;title 同时用于页头显示当前页签名
|
||||
// 「学习考试」已移出侧栏导航,路由保留(学习/考试状态列点击等场景仍可直达)
|
||||
const TRAINING_TABS_META: Record<string, { title: string; desc: string }> = {
|
||||
dashboard: { title: '工作台', desc: '培训运营总览、待办与达成率一览' },
|
||||
plan: { title: '培训计划', desc: '年度培训需求收集与汇总(可切换年度)' },
|
||||
course: { title: '培训课程', desc: '课程资产库、场次安排与学员名单;课件自动同步知识库' },
|
||||
dashboard: { title: '培训中心', desc: '培训运营总览、待办与达成率一览' },
|
||||
// 数据驾驶舱(000158):侧栏独立子页,内容与工作台驾驶舱视图同源
|
||||
'data-dashboard': { title: '数据驾驶舱', desc: '部门培训达成率排名、讲师积分榜与月度盘点' },
|
||||
plan: { title: '年培训计划', desc: '年度培训需求收集与汇总(可切换年度)' },
|
||||
course: { title: '月培训计划', desc: '月度培训计划排期、场次安排与学员名单;课程从课程管理选择,计划编号自动生成' },
|
||||
library: { title: '课程管理', desc: '课程资产库维护:编号/课程名称/说明/分类/类型/线上线下/讲师/时长/课件/试题' },
|
||||
sign: { title: '培训签到', desc: '签到码生成、签到明细复核与佐证导出' },
|
||||
study: { title: '学习考试', desc: '我的课程学习、课程学习情况、课程考试情况与 AI 课程分析' },
|
||||
members: { title: '职称角色', desc: '名册来自「组织架构」,此处维护员工职称角色' },
|
||||
@@ -117,6 +133,10 @@ const canManageTabs = computed(() =>
|
||||
isAdmin.value ||
|
||||
myRoles.value.some((r) => ['hr', 'supervisor', 'exec', 'lecturer'].includes(r)))
|
||||
|
||||
// 配置中心门槛(000158):人事/空间管理员之外,经理职称角色同权查看与维护。
|
||||
const canManageConfig = computed(() =>
|
||||
isAdmin.value || myRoles.value.some((r) => r === 'exec'))
|
||||
|
||||
// 页头角色标签:展示实际分配的角色(非权限展开),文案取自配置中心字典
|
||||
const myRoleLabel = computed(() =>
|
||||
rawRoles.value.map((r) => roleLabelOf(r, roleDict.value)).join(' / '))
|
||||
@@ -130,9 +150,9 @@ const activeTab = computed(() => {
|
||||
})
|
||||
|
||||
const activeTabMeta = computed(() => {
|
||||
// 工作台三视图:页头标题/副标题跟随当前视图(课程视图与设计稿一致使用「培训课程」)
|
||||
// 工作台三视图:页头标题/副标题跟随当前视图(课程视图「培训中心」,000154)
|
||||
if (activeTab.value === 'dashboard') {
|
||||
if (workbenchTab.value === 'course') return { title: '培训课程', desc: '课件/题库上传后自动同步知识库,可对话问答' }
|
||||
if (workbenchTab.value === 'course') return { title: '培训中心', desc: '和信课程目录、我的培训与我的考试' }
|
||||
if (workbenchTab.value === 'growth') return { title: '工作台', desc: '个人成长进阶 · 能力模型与成就任务总览' }
|
||||
return TRAINING_TABS_META.dashboard
|
||||
}
|
||||
@@ -148,12 +168,12 @@ const canSeeWorkbenchDashboard = computed(
|
||||
() => isAdmin.value || myRoles.value.some((r) => r === 'hr' || r === 'supervisor' || r === 'exec'),
|
||||
)
|
||||
|
||||
// 页头视图切换(000158):数据驾驶舱已迁侧栏独立子页,工作台仅保留课程/个人成长
|
||||
const workbenchSwitchTabs = computed(() => {
|
||||
const list: { key: WorkbenchView; label: string }[] = [
|
||||
{ key: 'course', label: '课程' },
|
||||
{ key: 'growth', label: '个人成长' },
|
||||
]
|
||||
if (canSeeWorkbenchDashboard.value) list.push({ key: 'dashboard', label: '数据驾驶舱' })
|
||||
return list
|
||||
})
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div class="course-catalog">
|
||||
<!-- 工具行:范围页签(全部/线上/线下/我的课程) + 搜索 -->
|
||||
<!-- 工具行:范围页签(和信课程/我的培训/我的考试,000154) + 搜索 -->
|
||||
<div class="catalog-toolbar">
|
||||
<div class="catalog-filter" role="tablist" aria-label="课程范围">
|
||||
<button
|
||||
@@ -23,19 +23,41 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 汇总行:与设计稿一致(共 N 门 · 线上 / 线下 / 本月新增或课件数)。
|
||||
待维护 = 我主讲且「草稿」状态的课程数(2026-11 需求;>0 时用与「草稿」一致的橙色提醒)。
|
||||
待开始 = 已排期且开课时间未到的课程数(按「我的课程」口径:我主讲/我参加,2026-11 需求)。 -->
|
||||
<!-- 汇总行:随页签切换口径。
|
||||
我的培训:待维护 = 我主讲且「草稿」的课程数;待开始 = 已排期且开课时间未到的课程数。 -->
|
||||
<div class="catalog-stats">
|
||||
{{ statsText }}
|
||||
<span class="catalog-stats__maintain" :class="{ 'is-alert': maintainCount > 0 }">待维护 {{ maintainCount }} 门</span>
|
||||
<span class="catalog-stats__pending" :class="{ 'is-info': pendingStartCount > 0 }">待开始 {{ pendingStartCount }} 门</span>
|
||||
<template v-if="filter === 'mine'">
|
||||
<span class="catalog-stats__maintain" :class="{ 'is-alert': maintainCount > 0 }">待维护 {{ maintainCount }} 门</span>
|
||||
<span class="catalog-stats__pending" :class="{ 'is-info': pendingStartCount > 0 }">待开始 {{ pendingStartCount }} 门</span>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<!-- 课程卡片网格 -->
|
||||
<t-loading :loading="loading" class="catalog-grid-wrap">
|
||||
<!-- 我的考试:与我相关的考试记录列表(000154) -->
|
||||
<t-loading v-if="filter === 'exam'" :loading="loading" class="catalog-grid-wrap">
|
||||
<t-table :data="examRows" :columns="examColumns" row-key="id" size="small">
|
||||
<template #course_name="{ row }">{{ row.course_name || row.paper_name || '-' }}</template>
|
||||
<template #score="{ row }">
|
||||
<span :class="row.passed ? 'exam-score is-good' : 'exam-score is-bad'">{{ row.score ?? '—' }}</span>
|
||||
</template>
|
||||
<template #pass_line="{ row }">{{ row.pass_score || '-' }} / {{ row.total_score || '-' }}</template>
|
||||
<template #submitted_at="{ row }">{{ fmtExamTime(row.submitted_at) }}</template>
|
||||
</t-table>
|
||||
<t-empty v-if="!loading && !examRows.length" class="catalog-empty" description="暂无考试记录,参加随堂考试后此处展示成绩" />
|
||||
</t-loading>
|
||||
|
||||
<!-- 课程卡片网格(和信课程/我的培训) -->
|
||||
<t-loading v-else :loading="loading" class="catalog-grid-wrap">
|
||||
<div class="catalog-grid">
|
||||
<article v-for="card in visibleCards" :key="card.id" class="course-card" role="link" tabindex="0" @click="openCourse(card)" @keydown.enter="openCourse(card)">
|
||||
<article
|
||||
v-for="card in visibleCards"
|
||||
:key="card.id"
|
||||
class="course-card"
|
||||
role="link"
|
||||
tabindex="0"
|
||||
@click="openCourse(card)"
|
||||
@keydown.enter="openCourse(card)"
|
||||
>
|
||||
<div class="course-card__cover" :class="card.mode === 'online' ? 'is-online' : 'is-offline'">
|
||||
<svg v-if="card.mode === 'online'" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="5" width="18" height="12" rx="2"/><path d="m10 8.6 4 2.4-4 2.4z"/><path d="M8 21h8M12 17v4"/></svg>
|
||||
<svg v-else viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"><path d="M4 17.5V5a1.6 1.6 0 0 1 1.6-1.6h9A1.6 1.6 0 0 1 16.2 5v12.5"/><path d="M4 17.5A2.5 2.5 0 0 0 6.5 20h9.7"/><path d="M16.2 8.2H19a1.4 1.4 0 0 1 1.4 1.4v3.1a2.3 2.3 0 1 1-4.6 0V9.6"/><path d="M7.5 7h5M7.5 10h5"/></svg>
|
||||
@@ -46,7 +68,7 @@
|
||||
<t-tag :theme="card.mode === 'online' ? 'primary' : 'success'" variant="light" size="small" :class="{ 'course-tag-offline': card.mode !== 'online' }">
|
||||
{{ card.mode === 'online' ? '线上课程' : '线下课程' }}
|
||||
</t-tag>
|
||||
<!-- [2026-11 需求]「我的课程」角色标记:区分我要进行培训(我主讲,橙色)/ 我要参加(蓝绿色)的课程 -->
|
||||
<!-- 「我的培训」角色标记:区分我要进行培训(我主讲,橙色)/ 我要参加(蓝绿色)的课程 -->
|
||||
<t-tag
|
||||
v-if="card.roleTag"
|
||||
:theme="card.roleTag === 'teach' ? 'warning' : 'primary'"
|
||||
@@ -70,7 +92,11 @@
|
||||
</div>
|
||||
</article>
|
||||
</div>
|
||||
<t-empty v-if="!loading && !visibleCards.length" class="catalog-empty" :description="filter === 'mine' ? '暂无与我相关的课程' : '暂无课程'" />
|
||||
<t-empty
|
||||
v-if="!loading && !visibleCards.length"
|
||||
class="catalog-empty"
|
||||
:description="filter === 'mine' ? '暂无与我相关的课程' : '暂无已发布课程(课程管理发布后在此展示)'"
|
||||
/>
|
||||
</t-loading>
|
||||
</div>
|
||||
</template>
|
||||
@@ -81,11 +107,15 @@ import { useRouter } from 'vue-router'
|
||||
import {
|
||||
getMyProfile,
|
||||
listCourses,
|
||||
listCourseLibrary,
|
||||
listMyExamRecords,
|
||||
listMyLearningTasks,
|
||||
listSessions,
|
||||
type LearningTask,
|
||||
type MyExamRecord,
|
||||
type TrainingCourse,
|
||||
type TrainingCourseSession,
|
||||
type TrainingLibraryCourse,
|
||||
type TrainingMember,
|
||||
unwrap,
|
||||
} from '@/api/training'
|
||||
@@ -94,8 +124,10 @@ const props = defineProps<{ roles: string[]; admin?: boolean }>()
|
||||
|
||||
const router = useRouter()
|
||||
// 卡片点击 → 课程学习详情页(课件在线预览 + 随堂考试);
|
||||
// 未发布课程(我任讲师的草稿/待审)无学习视角,点击直达维护。
|
||||
// 未发布课程(我任讲师的草稿/待审)无学习视角,点击直达维护;
|
||||
// 和信课程卡片为课程资产展示(000154),无学习页不跳转。
|
||||
const openCourse = (card: CatalogCard) => {
|
||||
if (card.kind === 'library') return
|
||||
if (card.unpublished) {
|
||||
goMaintain(card.id)
|
||||
return
|
||||
@@ -110,26 +142,44 @@ const goMaintain = (courseId: string) => {
|
||||
|
||||
const loading = ref(false)
|
||||
const courses = ref<TrainingCourse[]>([])
|
||||
// 课程维护视角(不带 scope=student)的我名下课程:纯讲师含草稿,供「我的课程」与待维护统计
|
||||
// 课程维护视角(不带 scope=student)的我名下课程:纯讲师含草稿,供「我的培训」与待维护统计
|
||||
const lecturerCourses = ref<TrainingCourse[]>([])
|
||||
const myProfile = ref<TrainingMember | null>(null)
|
||||
const myTasks = ref<LearningTask[]>([])
|
||||
const sessions = ref<TrainingCourseSession[]>([])
|
||||
// 课程管理资产(000154):「和信课程」目录 = 课程管理已发布且部门范围覆盖查看人的课程
|
||||
const libraryItems = ref<TrainingLibraryCourse[]>([])
|
||||
// 我的考试记录(000154):「我的考试」页签数据源
|
||||
const myExamRecords = ref<MyExamRecord[]>([])
|
||||
|
||||
const FILTERS = [
|
||||
{ key: 'all', label: '全部课程' },
|
||||
{ key: 'online', label: '线上课程' },
|
||||
{ key: 'offline', label: '线下课程' },
|
||||
{ key: 'mine', label: '我的课程' },
|
||||
{ key: 'hexin', label: '和信课程' },
|
||||
{ key: 'mine', label: '我的培训' },
|
||||
{ key: 'exam', label: '我的考试' },
|
||||
] as const
|
||||
// 工作台进目录默认落在「我的课程」(2026-11 需求:与我相关的课优先展示)
|
||||
// 工作台进目录默认落在「我的培训」(与我相关的课优先展示)
|
||||
const filter = ref<string>('mine')
|
||||
const keyword = ref('')
|
||||
|
||||
// 目录页面向全体员工:仅展示已发布课程(草稿/待审在「培训课程」维护)
|
||||
const publishedCourses = computed(() => courses.value.filter((c) => c.status === 'published'))
|
||||
|
||||
// 「和信课程」(000154):课程管理中已发布、且部门范围覆盖查看人的课程
|
||||
// (所属部门为空 = 全员课程;有部门则需与我的部门一致)
|
||||
const myDeptId = computed(() => myProfile.value?.dept_id || '')
|
||||
const hexinCourses = computed<TrainingLibraryCourse[]>(() =>
|
||||
libraryItems.value.filter(
|
||||
(c) => c.publish_status === 'published' && (!c.owner_dept_id || !myDeptId.value || c.owner_dept_id === myDeptId.value),
|
||||
),
|
||||
)
|
||||
|
||||
const statsText = computed(() => {
|
||||
if (filter.value === 'exam') return `共 ${myExamRecords.value.length} 场考试`
|
||||
if (filter.value === 'hexin') {
|
||||
const list = hexinCourses.value
|
||||
const online = list.filter((c) => c.mode === 'online').length
|
||||
return `共 ${list.length} 门课程 · 线上 ${online} 门 · 线下 ${list.length - online} 门`
|
||||
}
|
||||
const list = publishedCourses.value
|
||||
const online = list.filter((c) => c.mode === 'online').length
|
||||
const offline = list.length - online
|
||||
@@ -252,27 +302,68 @@ interface CatalogCard {
|
||||
maintainable: boolean
|
||||
/** 未发布(草稿/待审)的讲师课程:无学习视角,点击直达维护 */
|
||||
unpublished: boolean
|
||||
/** [2026-11 需求]「我的课程」角色标记:teach=我主讲 / attend=我参加(其余视图不标记) */
|
||||
/** 卡片来源:plan=月计划课程(可点进学习页) / library=课程管理资产(000154,仅展示) */
|
||||
kind: 'plan' | 'library'
|
||||
/** 「我的培训」角色标记:teach=我主讲 / attend=我参加(其余视图不标记) */
|
||||
roleTag?: 'teach' | 'attend'
|
||||
}
|
||||
|
||||
// 「我的考试」表格列(000154):与我相关的考试记录
|
||||
const examColumns = [
|
||||
{ colKey: 'course_name', title: '课程/试卷' },
|
||||
{ colKey: 'score', title: '成绩', width: 90 },
|
||||
{ colKey: 'pass_line', title: '及格/总分', width: 110 },
|
||||
{ colKey: 'submitted_at', title: '交卷时间', width: 170 },
|
||||
]
|
||||
const fmtExamTime = (raw?: string | null) => {
|
||||
if (!raw) return '-'
|
||||
const d = new Date(raw)
|
||||
return Number.isNaN(d.getTime()) ? String(raw) : d.toLocaleString('zh-CN', { hour12: false })
|
||||
}
|
||||
// 「我的考试」行数据(带搜索过滤)
|
||||
const examRows = computed<MyExamRecord[]>(() => {
|
||||
const kw = keyword.value.trim().toLowerCase()
|
||||
if (!kw) return myExamRecords.value
|
||||
return myExamRecords.value.filter(
|
||||
(r) => (r.course_name || '').toLowerCase().includes(kw) || (r.paper_name || '').toLowerCase().includes(kw),
|
||||
)
|
||||
})
|
||||
|
||||
// 卡片元信息与底部进度条:
|
||||
// 线上 = 我的学习任务状态(已完成/学习中/待学习/已逾期),进度条只表达确定状态,不虚构百分比;
|
||||
// 线下 = 真实排期进度(已完成场次/已排期场次)。
|
||||
// 未发布的讲师课程(仅「我的课程」视图可见)以草稿/待审态展示。
|
||||
// 未发布的讲师课程(仅「我的培训」视图可见)以草稿/待审态展示。
|
||||
const visibleCards = computed<CatalogCard[]>(() => {
|
||||
const kw = keyword.value.trim().toLowerCase()
|
||||
// 数据源:全部/线上/线下 = 已发布目录;我的课程 = 我相关的已发布课 + 我任讲师的课(含未发布,已发布的按 id 去重)
|
||||
// 和信课程(000154):课程管理已发布课程(资产卡片,仅展示)
|
||||
if (filter.value === 'hexin') {
|
||||
return hexinCourses.value
|
||||
.filter((c) => !kw || c.name.toLowerCase().includes(kw) || (c.category || '').toLowerCase().includes(kw))
|
||||
.map((c) => ({
|
||||
id: c.id,
|
||||
name: c.name,
|
||||
mode: c.mode === 'online' ? 'online' : 'offline',
|
||||
meta: [c.category, c.type === 'elective' ? '选修' : '必修', c.hours ? `${c.hours} 学时` : '', c.suitable_members]
|
||||
.filter(Boolean)
|
||||
.join(' · '),
|
||||
state: '已发布',
|
||||
stateClass: 'is-good',
|
||||
barWidth: '0%',
|
||||
barClass: '',
|
||||
maintainable: false,
|
||||
unpublished: false,
|
||||
kind: 'library' as const,
|
||||
}))
|
||||
}
|
||||
// 数据源:我的培训 = 我相关的已发布课 + 我任讲师的课(含未发布,已发布的按 id 去重)
|
||||
let source = publishedCourses.value
|
||||
if (filter.value === 'mine') source = myCoursesSource.value
|
||||
let list = source.filter((c) => {
|
||||
if (filter.value === 'online' && c.mode !== 'online') return false
|
||||
if (filter.value === 'offline' && c.mode !== 'offline') return false
|
||||
if (filter.value === 'mine' && !isMyCourse(c) && !isMyTeaching(c)) return false
|
||||
if (kw && !(c.name.toLowerCase().includes(kw) || (c.tags || []).some((t) => String(t).toLowerCase().includes(kw)))) return false
|
||||
return true
|
||||
})
|
||||
// [2026-11 需求] 「我的课程」排序:需关注的课程(我主讲未发布/缺课件)置顶,
|
||||
// 「我的培训」排序:需关注的课程(我主讲未发布/缺课件)置顶,
|
||||
// 其余按与当前时间的邻近度升序(临近开课/结课的在前,无时间锚点的排最后)
|
||||
if (filter.value === 'mine') {
|
||||
const now = Date.now()
|
||||
@@ -292,7 +383,7 @@ const visibleCards = computed<CatalogCard[]>(() => {
|
||||
const head = [c.post_scope, typeText(c), `${c.hours} 学时`, c.exam_enabled ? '随堂考试' : ''].filter(Boolean).join(' · ')
|
||||
const maintainable = isMyTeaching(c) && canMaintainCourses.value
|
||||
const unpublished = c.status !== 'published'
|
||||
// [2026-11 需求]「我的课程」角色标记:我主讲(优先) / 我参加,其余视图不标记
|
||||
// 「我的培训」角色标记:我主讲(优先) / 我参加,其余视图不标记
|
||||
const roleTag = filter.value === 'mine' ? (isMyTeaching(c) ? ('teach' as const) : ('attend' as const)) : undefined
|
||||
// 未发布讲师课:无学习任务与排期进度,展示草稿/待审 + 计划时间(需求确认同步)
|
||||
if (unpublished) {
|
||||
@@ -308,24 +399,19 @@ const visibleCards = computed<CatalogCard[]>(() => {
|
||||
barClass: '',
|
||||
maintainable,
|
||||
unpublished,
|
||||
kind: 'plan' as const,
|
||||
roleTag,
|
||||
}
|
||||
}
|
||||
if (c.mode === 'online') {
|
||||
const task = myTaskByCourse.value.get(c.id)
|
||||
const status = task?.status || 'pending'
|
||||
const stateMap: Record<string, { state: string; cls: string }> = {
|
||||
done: { state: '已完成', cls: 'is-good' },
|
||||
doing: { state: '学习中', cls: 'is-doing' },
|
||||
overdue: { state: '已逾期', cls: 'is-bad' },
|
||||
pending: { state: '待学习', cls: '' },
|
||||
}
|
||||
const cur = status === 'done' ? { state: '已完成', cls: 'is-good', width: '100%', bar: 'is-done' }
|
||||
: status === 'doing' ? { state: '学习中', cls: 'is-doing', width: '100%', bar: 'is-doing-bar' }
|
||||
: status === 'overdue' ? { state: '已逾期', cls: 'is-bad', width: '0%', bar: '' }
|
||||
: { state: '待学习', cls: '', width: '0%', bar: '' }
|
||||
const materials = c.material_ids?.length ? ` · 课件 ${c.material_ids.length} 个` : ''
|
||||
return { id: c.id, name: c.name, mode: c.mode, meta: `${head}${materials}`, state: cur.state, stateClass: cur.cls, barWidth: cur.width, barClass: cur.bar, maintainable, unpublished, roleTag }
|
||||
return { id: c.id, name: c.name, mode: c.mode, meta: `${head}${materials}`, state: cur.state, stateClass: cur.cls, barWidth: cur.width, barClass: cur.bar, maintainable, unpublished, kind: 'plan' as const, roleTag }
|
||||
}
|
||||
const sess = (sessionByCourse.value.get(c.id) || []).sort((a, b) => String(a.start_at).localeCompare(String(b.start_at)))
|
||||
const finished = sess.filter((s) => s.status === 'finished').length
|
||||
@@ -343,6 +429,7 @@ const visibleCards = computed<CatalogCard[]>(() => {
|
||||
barClass: ratio >= 100 ? 'is-done' : '',
|
||||
maintainable,
|
||||
unpublished,
|
||||
kind: 'plan' as const,
|
||||
roleTag,
|
||||
}
|
||||
})
|
||||
@@ -352,21 +439,27 @@ const loadAll = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
// 讲师/管理角色额外拉维护视角课程(纯讲师=自己名下含草稿;管理=全部,下方按讲师 id 过滤),
|
||||
// 供「我的课程」展示我主讲(含未发布)课程与「待维护」统计;纯学员无此视角,跳过。
|
||||
// 供「我的培训」展示我主讲(含未发布)课程与「待维护」统计;纯学员无此视角,跳过。
|
||||
const needMaintainView = props.admin || props.roles.some((r) => ['hr', 'supervisor', 'exec', 'lecturer'].includes(r))
|
||||
const [c, t, s, me, lc] = await Promise.all([
|
||||
const [c, t, s, me, lc, lib, exams] = await Promise.all([
|
||||
// 学员目录视图:scope=student 统一走已发布课程口径(讲师账号的学习视角不受课程维护范围影响)
|
||||
listCourses({ page_size: 100, scope: 'student' }),
|
||||
listMyLearningTasks().catch(() => null),
|
||||
listSessions({ year: 0, month: 0, scope: 'student' }).catch(() => null),
|
||||
getMyProfile().catch(() => null),
|
||||
needMaintainView ? listCourses({ page_size: 100 }).catch(() => null) : Promise.resolve(null),
|
||||
// 和信课程目录(000154):课程管理已发布课程
|
||||
listCourseLibrary({ page_size: 500 }).catch(() => null),
|
||||
// 我的考试记录(000154)
|
||||
listMyExamRecords().catch(() => null),
|
||||
])
|
||||
courses.value = unwrap(c)?.items || []
|
||||
myTasks.value = (t && unwrap(t)) || []
|
||||
sessions.value = (s && unwrap(s)) || []
|
||||
myProfile.value = (me && unwrap(me)) || null
|
||||
lecturerCourses.value = (lc && unwrap(lc)?.items) || []
|
||||
libraryItems.value = (lib && unwrap(lib)?.items) || []
|
||||
myExamRecords.value = (exams && unwrap(exams)) || []
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
@@ -480,6 +573,19 @@ onMounted(loadAll)
|
||||
padding: 48px 0;
|
||||
}
|
||||
|
||||
// 「我的考试」成绩列:及格绿/不及格红
|
||||
.exam-score {
|
||||
font-weight: 600;
|
||||
|
||||
&.is-good {
|
||||
color: var(--td-success-color);
|
||||
}
|
||||
|
||||
&.is-bad {
|
||||
color: var(--td-error-color);
|
||||
}
|
||||
}
|
||||
|
||||
.course-card {
|
||||
background: var(--td-bg-color-container);
|
||||
border: 1px solid var(--td-component-stroke);
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -4,13 +4,16 @@
|
||||
<div class="panel-box">
|
||||
<div class="panel-box__header">
|
||||
<span class="panel-box__title plan-title-row">
|
||||
年度需求收集({{ selectedYear }})
|
||||
年度需求收集
|
||||
<!-- 年份下拉用 t-option 槽渲染:TDesign :options 需 {label,value} 对象,
|
||||
直接传 number[] 会渲染空白选项(无法选中) -->
|
||||
<t-select
|
||||
v-model="selectedYear"
|
||||
class="year-select"
|
||||
:options="yearOptions"
|
||||
@change="onYearChange"
|
||||
/>
|
||||
>
|
||||
<t-option v-for="y in yearOptions" :key="y" :value="y" :label="String(y)" />
|
||||
</t-select>
|
||||
</span>
|
||||
<div class="panel-box__actions">
|
||||
<t-button v-if="canManage" theme="primary" @click="openCollect">收集下年度计划</t-button>
|
||||
@@ -18,10 +21,10 @@
|
||||
<t-button v-if="canManage" variant="outline" @click="importDemandsVisible = true">批量导入</t-button>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 搜索:状态 / 部门 / 课程名称模糊;批量确认/删除与查询条件同行 -->
|
||||
<!-- 搜索:状态 / 部门 / 课程名称模糊;批量确认(仅本部门经理)/删除与查询条件同行 -->
|
||||
<div class="demand-search">
|
||||
<t-select v-model="demandSearch.state" clearable placeholder="状态" style="width: 110px">
|
||||
<t-option label="待校验" value="pending" />
|
||||
<t-option label="待核验" value="pending" />
|
||||
<t-option label="已确认" value="confirmed" />
|
||||
<t-option label="已修正" value="fixed" />
|
||||
</t-select>
|
||||
@@ -37,7 +40,7 @@
|
||||
/>
|
||||
<t-button variant="outline" @click="loadDemands">查询</t-button>
|
||||
<t-button variant="outline" @click="onResetDemandSearch">重置</t-button>
|
||||
<t-button v-if="canManage" theme="primary" variant="outline" :disabled="!selectedDemandKeys.length" :loading="batchSaving" @click="onBatchConfirm">批量确认</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>
|
||||
</div>
|
||||
@@ -50,10 +53,17 @@
|
||||
: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>
|
||||
<template #planned_time="{ row }">{{ (row.planned_time || '').slice(0, 10) || '-' }}</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>
|
||||
@@ -68,13 +78,13 @@
|
||||
</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-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
|
||||
v-if="canManage"
|
||||
v-if="canConfirm"
|
||||
variant="text" theme="primary" size="small" @click="onConfirmDemand(row)"
|
||||
>确认</t-button>
|
||||
<t-button
|
||||
@@ -91,30 +101,54 @@
|
||||
<!-- 提报需求弹窗(编辑态复用:部门按提报人自动获取) -->
|
||||
<t-dialog v-model:visible="demandFormVisible" :header="demandDialogTitle" width="560">
|
||||
<t-form :data="demandForm" label-width="90" @submit="onSaveDemand">
|
||||
<t-form-item v-if="demandForm.id" label="编号" name="code">
|
||||
<t-input :value="demandCodeDisplay" disabled />
|
||||
</t-form-item>
|
||||
<t-form-item label="课程名称" name="course_name" required>
|
||||
<t-input v-model="demandForm.course_name" placeholder="请输入课程名称" />
|
||||
<!-- 000156:从课程管理选择本部门课程(自动带出分类/讲师/适合人员),也可直接填写新课程 -->
|
||||
<t-select
|
||||
v-model="demandForm.course_name"
|
||||
clearable
|
||||
filterable
|
||||
creatable
|
||||
:loading="libraryLoading"
|
||||
placeholder="从课程管理选择本部门课程,或直接填写新课程"
|
||||
style="width: 100%"
|
||||
@change="onDemandCourseChange"
|
||||
>
|
||||
<t-option
|
||||
v-for="c in deptCourseOptions"
|
||||
:key="c.id"
|
||||
:value="c.name"
|
||||
:label="`${c.name}${c.category ? `(${c.category})` : ''}`"
|
||||
/>
|
||||
</t-select>
|
||||
</t-form-item>
|
||||
<t-form-item label="分类" name="category">
|
||||
<t-input :value="demandForm.category" disabled placeholder="随所选课程自动带出" />
|
||||
</t-form-item>
|
||||
<t-form-item label="所属部门" name="dept_id">
|
||||
<t-input :value="deptDisplay" disabled placeholder="提交时按提报人所在部门自动获取" />
|
||||
</t-form-item>
|
||||
<t-form-item label="参加人员" name="post_scope">
|
||||
<t-input v-model="demandForm.post_scope" placeholder="可填写多个参加人员,用、或,分隔(选填)" />
|
||||
<t-form-item label="适合人员" name="post_scope">
|
||||
<t-input v-model="demandForm.post_scope" placeholder="可填写多个适合人员,用、或,分隔(选填)" />
|
||||
</t-form-item>
|
||||
<t-form-item label="计划培训时间" name="planned_time">
|
||||
<t-date-picker
|
||||
v-model="demandForm.planned_time"
|
||||
format="YYYY-MM-DD"
|
||||
<t-form-item label="计划培训月份" name="planned_month">
|
||||
<t-select
|
||||
v-model="demandForm.planned_month"
|
||||
clearable
|
||||
placeholder="选填,精确到日期;确认后同步到培训课程"
|
||||
placeholder="选填,只需选到月份;确认后同步到培训课程"
|
||||
style="width: 100%"
|
||||
/>
|
||||
>
|
||||
<t-option v-for="m in 12" :key="m" :label="`${m} 月`" :value="m" />
|
||||
</t-select>
|
||||
</t-form-item>
|
||||
<t-form-item label="内/外培训" name="train_type">
|
||||
<t-radio-group v-model="demandForm.train_type" variant="default-filled">
|
||||
<t-radio-button value="">未选择</t-radio-button>
|
||||
<t-radio-button value="内部">内部</t-radio-button>
|
||||
<t-radio-button value="外部">外部</t-radio-button>
|
||||
</t-radio-group>
|
||||
<!-- 下拉选择(000154):内部/外部,清空即未选择 -->
|
||||
<t-select v-model="demandForm.train_type" clearable placeholder="从下拉选择内部或外部(选填)" style="width: 100%">
|
||||
<t-option label="内部" value="内部" />
|
||||
<t-option label="外部" value="外部" />
|
||||
</t-select>
|
||||
</t-form-item>
|
||||
<t-form-item label="厂区" name="plant">
|
||||
<t-input v-model="demandForm.plant" placeholder="如:三厂(选填)" />
|
||||
@@ -158,15 +192,15 @@
|
||||
<t-textarea
|
||||
v-model="importDemandsText"
|
||||
:autosize="{ minRows: 6 }"
|
||||
placeholder="或粘贴需求行:课程名称[,计划培训时间如 2026-11-19] (支持中英文逗号)"
|
||||
placeholder="或粘贴需求行:课程名称[,计划培训月份如 3] (支持中英文逗号)"
|
||||
/>
|
||||
<div class="form-hint">模板列对应:编号/部门/课程名称/参加人员/地点/培訓費用/內外培訓(内部或外部)/计划培训时间(如 2026-11-19)/讲师/备注;参加人员可填多人(、/,分隔),讲师可填系统员工(按姓名自动匹配并带出部门)或外部讲师姓名;未指定部门的需求导入后为「待校验」,由人事确认补全。</div>
|
||||
<div class="form-hint">模板列对应:编号/部门/课程名称/适合人员/地点/培訓費用/内/外培训(内部或外部,下拉选择)/计划培训月份(1~12,下拉选择)/讲师/备注;适合人员可填多人(、/,分隔),讲师可填系统员工(按姓名自动匹配并带出部门)或外部讲师姓名;导入后统一为「待核验」,由部门经理核验确认。</div>
|
||||
<template #footer>
|
||||
<t-button theme="primary" :loading="saving" @click="onImportDemands">导入粘贴内容</t-button>
|
||||
</template>
|
||||
</t-dialog>
|
||||
|
||||
<!-- 收集下年度计划:发送模板 + 推送人员(默认人事与各课长,可增删),确认后站内+企微批量推送 -->
|
||||
<!-- 收集下年度计划:发送模板 + 推送人员(默认各课长,可增删),确认后站内+企微批量推送 -->
|
||||
<t-dialog v-model:visible="collectVisible" :header="`收集下年度计划(${nextYear})`" width="560">
|
||||
<div class="collect-section-title">发送模板</div>
|
||||
<div class="collect-template-row">
|
||||
@@ -179,13 +213,13 @@
|
||||
multiple
|
||||
filterable
|
||||
clearable
|
||||
placeholder="默认各部门经理、主管、文员,可修改添加删除"
|
||||
placeholder="默认各课长,可修改添加删除"
|
||||
style="width: 100%"
|
||||
:loading="membersLoading"
|
||||
>
|
||||
<t-option v-for="m in members" :key="m.user_id" :value="m.user_id" :label="memberLabel(m)" />
|
||||
</t-select>
|
||||
<div class="form-hint">默认勾选各部门经理、主管、文员;可自行添加或移除推送人员。</div>
|
||||
<div class="form-hint">默认勾选各课长;可自行添加或移除推送人员。</div>
|
||||
<div class="collect-section-title">通知内容</div>
|
||||
<t-textarea v-model="collectForm.content" :autosize="{ minRows: 3 }" />
|
||||
<template #footer>
|
||||
@@ -208,6 +242,8 @@ import {
|
||||
deleteDemand,
|
||||
getMyProfile,
|
||||
importDemands,
|
||||
listCourseLibrary,
|
||||
listDemandYears,
|
||||
listDemands,
|
||||
listDepts,
|
||||
listLecturers,
|
||||
@@ -215,6 +251,7 @@ import {
|
||||
saveDemand,
|
||||
type TrainingDept,
|
||||
type TrainingDemand,
|
||||
type TrainingLibraryCourse,
|
||||
type TrainingLecturerOption,
|
||||
type TrainingMember,
|
||||
unwrap,
|
||||
@@ -224,35 +261,59 @@ const props = defineProps<{ roles: string[]; admin?: boolean }>()
|
||||
|
||||
// 计划管理(录入/推送/排课):人事/课长(roles 已按权限组展开,经理自动命中课长)
|
||||
const canManage = computed(() => props.admin || props.roles.some((r) => r === 'hr' || r === 'supervisor'))
|
||||
// 核验确认入口:经理职称角色可见(空间管理员直通,便于授权引导);
|
||||
// 实际可确认范围按行校验(本部门+经理,000154),越权点击统一提示联系部门经理。
|
||||
const canConfirm = computed(() => props.admin || props.roles.some((r) => r === 'exec'))
|
||||
// 行级确认权限:需求归属部门=本人所在部门,且本人具有经理职称角色。
|
||||
const canConfirmDemand = (row: TrainingDemand) =>
|
||||
canConfirm.value && Boolean(row.dept_id) && row.dept_id === myDeptId.value
|
||||
|
||||
const now = new Date()
|
||||
const currentYear = now.getFullYear()
|
||||
|
||||
// 年度需求收集:可切换年度查看各年的收集汇总(近 4 年 + 明年)
|
||||
// 年度需求收集:年份下拉为需求库实际年份(降序),默认展示最新一年(无数据回退当前年)
|
||||
const selectedYear = ref(currentYear)
|
||||
const yearOptions = Array.from({ length: 6 }, (_, i) => currentYear - 4 + i)
|
||||
const yearOptions = ref<number[]>([])
|
||||
const onYearChange = () => loadDemands()
|
||||
|
||||
const loading = ref(false)
|
||||
const saving = ref(false)
|
||||
const demands = ref<TrainingDemand[]>([])
|
||||
|
||||
// 表单/搜索数据源:部门树、讲师名册
|
||||
// 表单/搜索数据源:部门树、讲师名册、课程管理条目(课程名称下拉,000156)
|
||||
const depts = ref<TrainingDept[]>([])
|
||||
const lecturers = ref<TrainingLecturerOption[]>([])
|
||||
const libraryCourses = ref<TrainingLibraryCourse[]>([])
|
||||
const libraryLoading = ref(false)
|
||||
const myDeptName = ref('')
|
||||
// 本人所在部门 id:行级确认权限校验用(需求归属部门须与本人一致)
|
||||
const myDeptId = ref('')
|
||||
|
||||
// 本部门课程(000156):课程名称下拉仅列所属部门课程——新建按提报人部门,
|
||||
// 编辑按需求归属部门(人事代改他部门需求时同样联动);部门为空回退全部课程
|
||||
const deptCourseOptions = computed(() => {
|
||||
const deptId = demandForm.value.id
|
||||
? demands.value.find((d) => d.id === demandForm.value.id)?.dept_id || myDeptId.value
|
||||
: myDeptId.value
|
||||
return deptId
|
||||
? libraryCourses.value.filter((c) => c.owner_dept_id === deptId)
|
||||
: libraryCourses.value
|
||||
})
|
||||
|
||||
const demandFormVisible = ref(false)
|
||||
const importDemandsVisible = ref(false)
|
||||
const importDemandsText = ref('')
|
||||
|
||||
// 搜索条件:已确认按人工确认(status)过滤,待校验/已修正按规则校验状态(check_status)
|
||||
// 搜索条件:已确认按人工确认(status)过滤,待核验/已修正按规则校验状态(check_status)
|
||||
const demandSearch = ref({ state: '', dept_id: '', keyword: '' })
|
||||
|
||||
const demandForm = ref({
|
||||
id: '',
|
||||
course_name: '',
|
||||
planned_time: '',
|
||||
// 分类随所选课程自动带出(000156),确认后经需求→课程同步落到课程侧标签
|
||||
category: '',
|
||||
// 计划培训月份(1~12,选填):提交时与收集年度合成 planned_time「YYYY-M」
|
||||
planned_month: '' as '' | number,
|
||||
session_count: 1,
|
||||
train_type: '',
|
||||
plant: '',
|
||||
@@ -263,6 +324,22 @@ const demandForm = ref({
|
||||
remark: '',
|
||||
})
|
||||
|
||||
// 选定课程自动带出(000156):分类/适合人员/讲师随课程回填,均可再改;
|
||||
// 改选讲师保存后由后端同步回写课程管理(课程管理讲师随需求追加为所选人员)
|
||||
const onDemandCourseChange = (name: unknown) => {
|
||||
const course = libraryCourses.value.find((c) => c.name === name)
|
||||
if (!course) return
|
||||
demandForm.value.category = course.category || ''
|
||||
if (course.suitable_members) demandForm.value.post_scope = course.suitable_members
|
||||
const lecturerValue = course.lecturer_id || course.lecturer_external || ''
|
||||
if (lecturerValue) {
|
||||
if (!lecturers.value.some((l) => l.id === lecturerValue)) {
|
||||
lecturers.value = [...lecturers.value, { id: lecturerValue, name: course.lecturer_name || lecturerValue }]
|
||||
}
|
||||
demandForm.value.lecturer = lecturerValue
|
||||
}
|
||||
}
|
||||
|
||||
// 讲师解析:名册 id 直接用;名册姓名映射为对应 id;否则作为外部讲师姓名落 lecturer_external
|
||||
const resolveLecturer = (value: string): { lecturer_id: string; lecturer_external: string } => {
|
||||
const v = (value || '').trim()
|
||||
@@ -275,6 +352,12 @@ const resolveLecturer = (value: string): { lecturer_id: string; lecturer_externa
|
||||
|
||||
const demandDialogTitle = computed(() => (demandForm.value.id ? '编辑培训需求' : '在线提报培训需求'))
|
||||
|
||||
// 编辑态展示年计划编号(服务端生成,不可改)
|
||||
const demandCodeDisplay = computed(() => {
|
||||
const row = demands.value.find((d) => d.id === demandForm.value.id)
|
||||
return row?.code || '-'
|
||||
})
|
||||
|
||||
const deptMap = computed(() => {
|
||||
const m: Record<string, string> = {}
|
||||
for (const d of depts.value) m[d.id] = d.name
|
||||
@@ -292,11 +375,13 @@ const deptDisplay = computed(() => {
|
||||
|
||||
const demandColumns = [
|
||||
{ colKey: 'row-select', type: 'multiple', width: 44, disabled: ({ row }: { row: TrainingDemand }) => row.status === 'confirmed' },
|
||||
// 年计划编号(AP-<year>-####,创建时由服务端生成)
|
||||
{ colKey: 'code', title: '编号', width: 130 },
|
||||
{ colKey: 'course_name', title: '课程名称' },
|
||||
{ colKey: 'dept_name', title: '部门', width: 100 },
|
||||
{ colKey: 'post_scope', title: '参加人员', width: 140 },
|
||||
{ colKey: 'post_scope', title: '适合人员', width: 140 },
|
||||
{ colKey: 'lecturer_name', title: '讲师', width: 100 },
|
||||
{ colKey: 'planned_time', title: '计划培训时间', width: 110 },
|
||||
{ colKey: 'planned_time', title: '计划培训月份', width: 110 },
|
||||
{ colKey: 'train_type', title: '内/外培训', width: 90 },
|
||||
{ colKey: 'location', title: '地点', width: 100 },
|
||||
{ colKey: 'remark', title: '备注', minWidth: 140 },
|
||||
@@ -315,11 +400,17 @@ const onBatchConfirm = async () => {
|
||||
MessagePlugin.warning('请先勾选未确认的需求')
|
||||
return
|
||||
}
|
||||
// 000154:批量确认仅作用于本人可确认的需求(本部门+经理),越权行全部跳过
|
||||
const allowed = rows.filter(canConfirmDemand)
|
||||
if (!allowed.length) {
|
||||
MessagePlugin.warning('暂无权限,请联系部门经理~')
|
||||
return
|
||||
}
|
||||
batchSaving.value = true
|
||||
let ok = 0
|
||||
let fail = 0
|
||||
try {
|
||||
for (const row of rows) {
|
||||
for (const row of allowed) {
|
||||
try {
|
||||
await confirmDemand(row.id)
|
||||
ok += 1
|
||||
@@ -327,7 +418,11 @@ const onBatchConfirm = async () => {
|
||||
fail += 1
|
||||
}
|
||||
}
|
||||
MessagePlugin.success(`批量确认完成:成功 ${ok} 条${fail ? `,失败 ${fail} 条` : ''};已确认需求已自动生成草稿课程到培训课程`)
|
||||
const skipped = rows.length - allowed.length
|
||||
MessagePlugin.success(
|
||||
`批量确认完成:成功 ${ok} 条${fail ? `,失败 ${fail} 条` : ''}` +
|
||||
`${skipped ? `,跳过 ${skipped} 条非本部门需求` : ''};已确认需求已自动生成草稿课程到培训课程`,
|
||||
)
|
||||
selectedDemandKeys.value = []
|
||||
loadAll()
|
||||
} finally {
|
||||
@@ -378,6 +473,20 @@ const loadDemands = async () => {
|
||||
demands.value = unwrap(d)?.items || []
|
||||
}
|
||||
|
||||
// 年份下拉数据源:需求库实际年份(降序)。resetSelection=true 时默认选中最新一年
|
||||
// (首次进入);后续刷新仅在当前选中年份已无数据时回退最新,避免打断用户选择。
|
||||
const loadDemandYears = async (resetSelection = false) => {
|
||||
try {
|
||||
const years = unwrap<number[]>(await listDemandYears()) || []
|
||||
yearOptions.value = years
|
||||
if (years.length && (resetSelection || !years.includes(selectedYear.value))) {
|
||||
selectedYear.value = years[0]
|
||||
}
|
||||
} catch {
|
||||
/* 年份拉取失败保留当前选择,列表按当前年份照常查询 */
|
||||
}
|
||||
}
|
||||
|
||||
const onResetDemandSearch = () => {
|
||||
demandSearch.value = { state: '', dept_id: '', keyword: '' }
|
||||
loadDemands()
|
||||
@@ -385,20 +494,33 @@ const onResetDemandSearch = () => {
|
||||
|
||||
// 表单下拉与提报人部门(一次性加载,失败不阻塞主列表)
|
||||
const loadFormOptions = async () => {
|
||||
libraryLoading.value = true
|
||||
try {
|
||||
const [d, l, me] = await Promise.all([listDepts(), listLecturers(), getMyProfile()])
|
||||
const [d, l, me, lib] = await Promise.all([
|
||||
listDepts(),
|
||||
listLecturers(),
|
||||
getMyProfile(),
|
||||
listCourseLibrary({ page_size: 500 }).catch(() => null),
|
||||
])
|
||||
depts.value = unwrap(d) || []
|
||||
lecturers.value = unwrap(l) || []
|
||||
libraryCourses.value = (lib && unwrap(lib))?.items || []
|
||||
const member = unwrap(me)
|
||||
if (member?.dept_id) myDeptName.value = deptMap.value[member.dept_id] || ''
|
||||
if (member?.dept_id) {
|
||||
myDeptId.value = member.dept_id
|
||||
myDeptName.value = deptMap.value[member.dept_id] || ''
|
||||
}
|
||||
} catch {
|
||||
/* 忽略:仅影响下拉可选项 */
|
||||
} finally {
|
||||
libraryLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const loadAll = async () => {
|
||||
const loadAll = async (resetYearSelection = false) => {
|
||||
loading.value = true
|
||||
try {
|
||||
await loadDemandYears(resetYearSelection)
|
||||
await loadDemands()
|
||||
} finally {
|
||||
loading.value = false
|
||||
@@ -409,7 +531,8 @@ const onOpenDemandForm = () => {
|
||||
demandForm.value = {
|
||||
id: '',
|
||||
course_name: '',
|
||||
planned_time: '',
|
||||
category: '',
|
||||
planned_month: '',
|
||||
session_count: 1,
|
||||
train_type: '',
|
||||
plant: '',
|
||||
@@ -421,16 +544,31 @@ const onOpenDemandForm = () => {
|
||||
demandFormVisible.value = true
|
||||
}
|
||||
|
||||
// 计划培训月份回显:从「YYYY-M」取月份;旧日期格式(YYYY-MM-DD)无法映射月份留空
|
||||
const plannedMonthOfValue = (value: string): '' | number => {
|
||||
const m = (value || '').trim().match(/^\d{4}-(\d{1,2})$/)
|
||||
const month = m ? Number(m[1]) : 0
|
||||
return month >= 1 && month <= 12 ? month : ''
|
||||
}
|
||||
|
||||
// 编辑旧数据兜底:原计划培训时间为旧日期格式且未重新选择月份时,保存保留原值
|
||||
const editOriginalPlanned = ref({ planned_time: '', expect_month: 0 })
|
||||
|
||||
const onEditDemand = (row: TrainingDemand) => {
|
||||
// 讲师回显:系统员工(id)或外部姓名;不在名册的值追加临时选项避免显示裸 ID
|
||||
const lecturerValue = row.lecturer_id || row.lecturer_external || ''
|
||||
if (lecturerValue && !lecturers.value.some((l) => l.id === lecturerValue)) {
|
||||
lecturers.value = [...lecturers.value, { id: lecturerValue, name: row.lecturer_name || lecturerValue }]
|
||||
}
|
||||
editOriginalPlanned.value = {
|
||||
planned_time: row.planned_time || '',
|
||||
expect_month: row.expect_month || 0,
|
||||
}
|
||||
demandForm.value = {
|
||||
id: row.id,
|
||||
course_name: row.course_name,
|
||||
planned_time: row.planned_time || '',
|
||||
category: row.category || '',
|
||||
planned_month: plannedMonthOfValue(row.planned_time || ''),
|
||||
session_count: row.session_count || 1,
|
||||
train_type: row.train_type || '',
|
||||
plant: row.plant || '',
|
||||
@@ -449,15 +587,21 @@ const onSaveDemand = async () => {
|
||||
}
|
||||
saving.value = true
|
||||
try {
|
||||
// 计划培训时间只保留年月日入库;讲师解析为 id 或外部姓名
|
||||
const { lecturer, ...rest } = demandForm.value
|
||||
// 计划培训月份与收集年度合成「YYYY-M」入库,并回填期望月份;
|
||||
// 编辑旧数据且未选月份时保留原计划培训值;讲师解析为 id 或外部姓名
|
||||
const { lecturer, planned_month, ...rest } = demandForm.value
|
||||
const month = Number(planned_month) || 0
|
||||
const isEdit = Boolean(demandForm.value.id)
|
||||
await saveDemand({
|
||||
...rest,
|
||||
...resolveLecturer(lecturer),
|
||||
planned_time: plannedTimeOf(demandForm.value.planned_time),
|
||||
planned_time: month
|
||||
? `${selectedYear.value}-${month}`
|
||||
: (isEdit ? editOriginalPlanned.value.planned_time : ''),
|
||||
expect_month: month || (isEdit ? editOriginalPlanned.value.expect_month : 0) || undefined,
|
||||
year: selectedYear.value,
|
||||
})
|
||||
MessagePlugin.success(demandForm.value.id ? '需求已更新' : '需求已提交,待人事确认')
|
||||
MessagePlugin.success(demandForm.value.id ? '需求已更新' : '需求已提交,待核验')
|
||||
demandFormVisible.value = false
|
||||
loadAll()
|
||||
} catch (e: any) {
|
||||
@@ -486,17 +630,19 @@ const onImportDemands = async () => {
|
||||
const items: Partial<TrainingDemand>[] = []
|
||||
const skipped: string[] = []
|
||||
lines.forEach((line, idx) => {
|
||||
// 兼容中英文逗号(\uFF0C)与制表符拆分:课程名称[,计划培训时间]
|
||||
// 兼容中英文逗号(\uFF0C)与制表符拆分:课程名称[,计划培训月份]
|
||||
const parts = line.split(/[,\uFF0C\t]/).map((s) => s.trim())
|
||||
const courseName = parts[0] || ''
|
||||
if (!courseName) {
|
||||
skipped.push(String(idx + 1))
|
||||
return
|
||||
}
|
||||
const { planned, month } = plannedMonthFromValue(parts[1] || '', selectedYear.value)
|
||||
items.push({
|
||||
course_name: courseName,
|
||||
year: selectedYear.value,
|
||||
planned_time: plannedTimeFromRow({ v: parts[1] || '' }, 'v', selectedYear.value) || undefined,
|
||||
planned_time: planned || undefined,
|
||||
expect_month: month || undefined,
|
||||
})
|
||||
})
|
||||
if (!items.length) {
|
||||
@@ -519,41 +665,34 @@ const onImportDemands = async () => {
|
||||
}
|
||||
|
||||
// ---- 教育训练需求表模板导入(docs/moban,经 /templates/ 下发) ----
|
||||
// 模板表头:编号/部门/课程名称/参加人员/地点/培訓費用/內外培訓/计划培训时间/讲师/备注,
|
||||
// 讲师按员工档案姓名匹配(带出部门)、非系统员工落外部讲师姓名,计划培训时间只保留年月日。
|
||||
// 模板表头:编号/部门/课程名称/适合人员/地点/培訓費用/内/外培训/计划培训月份(1~12)/讲师/备注,
|
||||
// 讲师按员工档案姓名匹配(带出部门)、非系统员工落外部讲师姓名,计划培训月份按「收集年度-月份」入库。
|
||||
|
||||
const onDownloadDemandTemplate = () => downloadTrainingTemplate(DEMAND_TEMPLATE_KEY)
|
||||
|
||||
// 计划培训时间入库格式:只保留年月日(YYYY-MM-DD)
|
||||
const plannedTimeOf = (value: string) => (value || '').trim().slice(0, 10)
|
||||
|
||||
// 从模板 Excel「计划培训时间」列解析计划培训时间:兼容 2026/6/8、2026-6-8、
|
||||
// 2026年6月8日、6/8(年份缺省取当前收集年度)及"11"这类纯月份(归一到当月 1 日);
|
||||
// 尾随时分忽略(入库只到日);越界或解析失败返回空串
|
||||
const plannedTimeFromRow = (row: Record<string, string>, timeCol: string, fallbackYear: number): string => {
|
||||
const raw = (row[timeCol] || '').trim()
|
||||
if (!raw) return ''
|
||||
const pad = (n: string) => n.padStart(2, '0')
|
||||
const validDate = (m: string, d: string) => {
|
||||
const month = Number(m)
|
||||
const day = Number(d)
|
||||
return month >= 1 && month <= 12 && day >= 1 && day <= 31
|
||||
// 计划培训月份解析:兼容 1~12 纯月份数字(1、12月)与旧日期格式(2027-1、
|
||||
// 2026/6/8、2026年6月8日等取其月份);年份统一取收集年度(模板标题年),
|
||||
// 入库 planned_time=「YYYY-M」(如 2027-1);无法解析返回空。
|
||||
const plannedMonthFromValue = (raw: string, fallbackYear: number): { planned: string; month: number } => {
|
||||
const v = (raw || '').trim()
|
||||
if (!v) return { planned: '', month: 0 }
|
||||
const full = v.match(/^20\d{2}[-/.年]\s*(\d{1,2})/)
|
||||
if (full) {
|
||||
const month = Number(full[1])
|
||||
if (month >= 1 && month <= 12) return { planned: `${fallbackYear}-${month}`, month }
|
||||
}
|
||||
const full = raw.match(/(\d{4})[./\-\s年]*(\d{1,2})[./\-\s月]*(\d{1,2})日?/)
|
||||
if (full && validDate(full[2], full[3])) {
|
||||
return `${full[1]}-${pad(full[2])}-${pad(full[3])}`
|
||||
const monthOnly = v.match(/^(\d{1,2})\s*月?$/)
|
||||
if (monthOnly) {
|
||||
const month = Number(monthOnly[1])
|
||||
if (month >= 1 && month <= 12) return { planned: `${fallbackYear}-${month}`, month }
|
||||
}
|
||||
const short = raw.match(/(\d{1,2})[./月](\d{1,2})日?/)
|
||||
if (short && validDate(short[1], short[2])) {
|
||||
return `${fallbackYear}-${pad(short[1])}-${pad(short[2])}`
|
||||
}
|
||||
const monthOnly = raw.match(/^(\d{1,2})\s*月?$/)
|
||||
if (monthOnly && Number(monthOnly[1]) >= 1 && Number(monthOnly[1]) <= 12) {
|
||||
return `${fallbackYear}-${pad(monthOnly[1])}-01`
|
||||
}
|
||||
return ''
|
||||
return { planned: '', month: 0 }
|
||||
}
|
||||
|
||||
// 模板 Excel 列取值:新「计划培训月份」列优先,兼容旧「计划培训时间」列模板
|
||||
const plannedMonthFromRow = (row: Record<string, string>, fallbackYear: number) =>
|
||||
plannedMonthFromValue((row['计划培训月份'] || row['计划培训时间'] || '').trim(), fallbackYear)
|
||||
|
||||
const onImportDemandExcel = async (e: Event) => {
|
||||
const input = e.target as HTMLInputElement
|
||||
const file = input.files?.[0]
|
||||
@@ -564,10 +703,21 @@ const onImportDemandExcel = async (e: Event) => {
|
||||
// 定位含「课程名称」表头的工作表(模板首两行为公司/表题合并单元格);
|
||||
// 表头键做空白归一(兼容「地 点」等内含空格的列名,否则该列会被静默丢弃)
|
||||
let dataRows: Record<string, string>[] | null = null
|
||||
// 模板标题年(000157):标题行「2027 年度教育训练需求表」的年份优先于年份下拉——
|
||||
// 模板面向下一年度收集,导入按标题年入库(需求年份与计划培训「年-月」一致)
|
||||
let titleYear = selectedYear.value
|
||||
for (const name of wb.SheetNames) {
|
||||
const sheetRows = XLSX.utils.sheet_to_json<string[]>(wb.Sheets[name], { header: 1, raw: false, defval: '' })
|
||||
const headerIdx = sheetRows.findIndex((r) => r.some((c) => String(c).trim() === '课程名称'))
|
||||
if (headerIdx < 0) continue
|
||||
for (const r of sheetRows.slice(0, Math.max(headerIdx, 1))) {
|
||||
const hit = (r || []).map((c) => String(c)).find((s) => /20\d{2}/.test(s) && s.includes('年'))
|
||||
const m = hit?.match(/20\d{2}/)
|
||||
if (m) {
|
||||
titleYear = Number(m[0])
|
||||
break
|
||||
}
|
||||
}
|
||||
const header = (sheetRows[headerIdx] || []).map((c) => String(c).trim().replace(/\s+/g, ''))
|
||||
dataRows = sheetRows.slice(headerIdx + 1).map((arr) => {
|
||||
const row: Record<string, string> = {}
|
||||
@@ -638,18 +788,22 @@ const onImportDemandExcel = async (e: Event) => {
|
||||
externalLecturers += 1
|
||||
}
|
||||
}
|
||||
// 计划培训月份:新「计划培训月份」列(1~12)优先,兼容旧「计划培训时间」列;
|
||||
// 年份取模板标题年(000157),入库「YYYY-M」并回填期望月份
|
||||
const plannedMonth = plannedMonthFromRow(row, titleYear)
|
||||
items.push({
|
||||
course_name: courseName,
|
||||
year: selectedYear.value,
|
||||
year: titleYear,
|
||||
plant: (row['厂区'] || '').trim(),
|
||||
session_count: Number.parseInt(row['次数'] || '') || 1,
|
||||
location: (row['地点'] || '').trim(),
|
||||
post_scope: (row['参加人员'] || '').trim(),
|
||||
train_type: (row['內/外培訓'] || row['内/外培训'] || '').trim(),
|
||||
post_scope: (row['适合人员'] || row['参加人员'] || '').trim(),
|
||||
train_type: (row['内/外培训'] || row['內/外培訓'] || '').trim(),
|
||||
lecturer_id: lecturerId,
|
||||
lecturer_external: lecturerExternal || undefined,
|
||||
dept_id: deptId,
|
||||
planned_time: plannedTimeFromRow(row, '计划培训时间', selectedYear.value) || undefined,
|
||||
planned_time: plannedMonth.planned || undefined,
|
||||
expect_month: plannedMonth.month || undefined,
|
||||
remark: (row['备注'] || '').trim(),
|
||||
})
|
||||
})
|
||||
@@ -659,16 +813,19 @@ const onImportDemandExcel = async (e: Event) => {
|
||||
}
|
||||
saving.value = true
|
||||
try {
|
||||
await importDemands(items)
|
||||
const imported = unwrap(await importDemands(items)) as { imported: number; notified?: number } | null
|
||||
MessagePlugin.success(
|
||||
`已从模板导入 ${items.length} 条需求` +
|
||||
`已从模板导入 ${items.length} 条需求(${titleYear}年度)` +
|
||||
(lecturerHits || externalLecturers
|
||||
? `,讲师匹配 ${lecturerHits} 人${externalLecturers ? `,外部讲师 ${externalLecturers} 人` : ''}`
|
||||
: '') +
|
||||
(deptFromLecturer ? `(其中 ${deptFromLecturer} 条部门按讲师带出)` : '') +
|
||||
(skippedRows ? `,另有 ${skippedRows} 行未填课程名称已跳过` : ''),
|
||||
(skippedRows ? `,另有 ${skippedRows} 行未填课程名称已跳过` : '') +
|
||||
(imported?.notified ? `,已推送 ${imported.notified} 位部门经理核验` : ''),
|
||||
)
|
||||
importDemandsVisible.value = false
|
||||
// 导入年份与当前查看年份不同(模板为下一年度)时切到导入年份展示
|
||||
if (titleYear !== selectedYear.value) selectedYear.value = titleYear
|
||||
loadAll()
|
||||
} catch {
|
||||
MessagePlugin.error('导入失败,请稍后重试')
|
||||
@@ -681,6 +838,11 @@ const onImportDemandExcel = async (e: Event) => {
|
||||
}
|
||||
|
||||
const onConfirmDemand = async (row: TrainingDemand) => {
|
||||
// 000154:仅需求归属部门的经理可确认,其余人员点击统一提示
|
||||
if (!canConfirmDemand(row)) {
|
||||
MessagePlugin.warning('暂无权限,请联系部门经理~')
|
||||
return
|
||||
}
|
||||
try {
|
||||
await confirmDemand(row.id)
|
||||
MessagePlugin.success('已确认,草稿课程已自动生成到培训课程')
|
||||
@@ -702,11 +864,13 @@ const collectForm = ref({ userIds: [] as string[], content: '' })
|
||||
const memberLabel = (m: TrainingMember) =>
|
||||
[m.user_name || m.employee_no, m.post, m.dept_name].filter(Boolean).join(' · ') || m.id.slice(0, 8)
|
||||
|
||||
// 默认推送人员:人事与各课长(supervisor;存量文员经别名按课长对待)
|
||||
const DEFAULT_COLLECT_ROLES = ['hr', 'supervisor']
|
||||
// 默认推送人员:各课长(supervisor;存量文员 clerk 经别名按课长对待)
|
||||
const DEFAULT_COLLECT_ROLES = ['supervisor']
|
||||
const defaultCollectUserIds = () =>
|
||||
members.value
|
||||
.filter((m) => (m.roles || []).some((r) => DEFAULT_COLLECT_ROLES.includes(r)))
|
||||
.filter((m) =>
|
||||
(m.roles || []).some((r) => DEFAULT_COLLECT_ROLES.includes(r === 'clerk' ? 'supervisor' : r)),
|
||||
)
|
||||
.map((m) => m.user_id)
|
||||
|
||||
const openCollect = async () => {
|
||||
@@ -754,7 +918,8 @@ const onSendCollect = async () => {
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
loadAll()
|
||||
// 首次进入:年份默认选中需求库最新一年并展示该年数据
|
||||
loadAll(true)
|
||||
loadFormOptions()
|
||||
})
|
||||
</script>
|
||||
@@ -770,6 +935,12 @@ onMounted(() => {
|
||||
}
|
||||
}
|
||||
|
||||
// 已确认行不做整行置灰:t-table 行选择列 disabled 命中时会加 __row--disabled
|
||||
// 类(整行 text-color-disabled),业务上已确认行仅禁止勾选,文字保持正常色
|
||||
:deep(.t-table__row--disabled) {
|
||||
color: var(--td-text-color-primary);
|
||||
}
|
||||
|
||||
// 标题行内嵌年度切换下拉
|
||||
.plan-title-row {
|
||||
display: inline-flex;
|
||||
@@ -842,7 +1013,7 @@ onMounted(() => {
|
||||
font-size: var(--app-text-md);
|
||||
}
|
||||
|
||||
// 参加人员/备注等长文本单元格:单行省略,t-tooltip 悬停显示全部
|
||||
// 适合人员/备注等长文本单元格:单行省略,t-tooltip 悬停显示全部
|
||||
.cell-ellipsis {
|
||||
display: block;
|
||||
overflow: hidden;
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
<template>
|
||||
<div class="rule-panel">
|
||||
<!-- 卡片1:职称角色 · 角色与权限(点选式维护,自定义角色勾选权限分配即生效) -->
|
||||
<!-- [2026-11 需求] 配置中心 tab 化:角色权限/业务规则(含业务参数与课程分类)/推送管理(推送提醒配置+推送记录)/导入模板 -->
|
||||
<t-tabs v-model="activeTab" class="rule-tabs">
|
||||
<t-tab-panel value="roles" label="角色权限">
|
||||
<!-- 角色权限 · 角色与权限(点选式维护,自定义角色勾选权限分配即生效) -->
|
||||
<div class="panel-box">
|
||||
<div class="panel-box__header">
|
||||
<span class="panel-box__title">职称角色 · 角色与权限</span>
|
||||
<span class="panel-box__title">角色权限 · 角色与权限</span>
|
||||
<t-button variant="outline" size="small" @click="openRoleDialog()">新增角色</t-button>
|
||||
</div>
|
||||
<t-table :data="roleRows" :columns="roleColumns" row-key="key" size="small" :loading="roleLoading">
|
||||
@@ -40,15 +43,18 @@
|
||||
系统角色不可删除,展示名与权限分配可改;「权限分配」= 继承所选权限组的全部接口与页面权限,勾选多个取并集。学员为全员默认角色,无需配置。
|
||||
</div>
|
||||
</div>
|
||||
</t-tab-panel>
|
||||
|
||||
<!-- 卡片2:业务规则(全部点选式表单,不再手写 JSON) -->
|
||||
<!-- 业务规则:签到/评分/积分/达标线/滚动等业务规则与业务参数 + 课程分类字典 + 高级配置兜底 -->
|
||||
<t-tab-panel value="rules" label="业务规则">
|
||||
<!-- 业务规则(全部点选式表单,不再手写 JSON) -->
|
||||
<div class="panel-box">
|
||||
<div class="panel-box__header">
|
||||
<span class="panel-box__title">业务规则</span>
|
||||
<t-button variant="outline" size="small" :loading="seeding" @click="onSeed">初始化默认配置</t-button>
|
||||
</div>
|
||||
<div class="panel-box__sub">点选即可修改,每项保存后立即生效;未保存的修改不生效。</div>
|
||||
<div v-for="schema in RULE_SCHEMAS" :key="schema.key" class="rule-section">
|
||||
<div v-for="schema in ruleSchemas" :key="schema.key" class="rule-section">
|
||||
<div class="rule-section__head">
|
||||
<span class="rule-section__title">{{ schema.title }}</span>
|
||||
<span class="rule-section__desc">{{ schema.desc }}</span>
|
||||
@@ -99,6 +105,35 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 课程分类:rule-configs course_category_dict,课程管理筛选/表单下拉选项来源 -->
|
||||
<div class="panel-box">
|
||||
<div class="panel-box__header">
|
||||
<span class="panel-box__title">课程分类</span>
|
||||
<t-button variant="outline" size="small" :disabled="!categoriesDirty" :loading="categoriesSaving" @click="onSaveCategories">保存</t-button>
|
||||
</div>
|
||||
<div class="panel-box__sub">课程管理列表「按分类查询」与「新增课程」弹窗的分类下拉选项;预设之外可在课程表单直接输入自定义分类。</div>
|
||||
<div class="category-editor">
|
||||
<t-tag
|
||||
v-for="c in categoryDraft"
|
||||
:key="c"
|
||||
theme="primary"
|
||||
variant="light"
|
||||
closable
|
||||
@close="onRemoveCategory(c)"
|
||||
>{{ c }}</t-tag>
|
||||
<t-input
|
||||
v-model="categoryInput"
|
||||
class="category-input"
|
||||
size="small"
|
||||
clearable
|
||||
placeholder="输入新分类后回车或点添加"
|
||||
@enter="onAddCategory"
|
||||
/>
|
||||
<t-button variant="outline" size="small" :disabled="!categoryInput.trim()" @click="onAddCategory">添加</t-button>
|
||||
<t-button variant="text" theme="primary" size="small" class="category-reset" @click="onResetCategories">恢复默认</t-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 高级配置:未提供点选表单的规则键,保留 JSON 编辑兜底 -->
|
||||
<div v-if="advancedRows.length" class="panel-box">
|
||||
<div class="panel-box__header">
|
||||
@@ -115,8 +150,64 @@
|
||||
</template>
|
||||
</t-table>
|
||||
</div>
|
||||
</t-tab-panel>
|
||||
|
||||
<!-- 卡片3:推送记录(逐人企微/站内投递明细;手动触发周一讲师提醒) -->
|
||||
<!-- 推送管理:推送提醒参数配置 + 推送投递记录 -->
|
||||
<t-tab-panel value="notify" label="推送管理">
|
||||
<!-- 推送提醒配置(与业务规则同款点选式表单) -->
|
||||
<div class="panel-box">
|
||||
<div class="panel-box__header">
|
||||
<span class="panel-box__title">推送提醒配置</span>
|
||||
</div>
|
||||
<div class="panel-box__sub">点选即可修改,每项保存后立即生效;未保存的修改不生效。</div>
|
||||
<div v-for="schema in notifySchemas" :key="schema.key" class="rule-section">
|
||||
<div class="rule-section__head">
|
||||
<span class="rule-section__title">{{ schema.title }}</span>
|
||||
<span class="rule-section__desc">{{ schema.desc }}</span>
|
||||
<t-button
|
||||
variant="outline"
|
||||
size="small"
|
||||
:disabled="!isDirty(schema.key)"
|
||||
:loading="savingKey === schema.key"
|
||||
@click="onSaveRule(schema.key)"
|
||||
>保存</t-button>
|
||||
</div>
|
||||
<div class="rule-section__fields">
|
||||
<div
|
||||
v-for="field in schema.fields"
|
||||
:key="field.key"
|
||||
class="rule-field"
|
||||
:class="{ 'rule-field--block': field.type === 'text' }"
|
||||
>
|
||||
<span class="rule-field__label">{{ field.label }}</span>
|
||||
<t-input-number
|
||||
v-if="field.type === 'number'"
|
||||
v-model="ruleValues[schema.key][field.key]"
|
||||
:min="field.min"
|
||||
:max="field.max"
|
||||
theme="normal"
|
||||
size="small"
|
||||
class="rule-field__input"
|
||||
/>
|
||||
<t-switch
|
||||
v-else-if="field.type === 'switch'"
|
||||
v-model="ruleValues[schema.key][field.key]"
|
||||
/>
|
||||
<t-textarea
|
||||
v-else
|
||||
v-model="ruleValues[schema.key][field.key]"
|
||||
:autosize="{ minRows: 2, maxRows: 4 }"
|
||||
:placeholder="field.placeholder"
|
||||
class="rule-field__textarea"
|
||||
/>
|
||||
<span v-if="field.unit" class="rule-field__unit">{{ field.unit }}</span>
|
||||
<span v-if="field.vars" class="rule-field__vars">可用变量:{{ field.vars }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 推送记录(逐人企微/站内投递明细;手动触发周一讲师提醒) -->
|
||||
<div class="panel-box">
|
||||
<div class="panel-box__header">
|
||||
<span class="panel-box__title">推送记录</span>
|
||||
@@ -151,12 +242,15 @@
|
||||
展示最近 {{ pushLogs.length }} 条;pending/sending=排队与投递中,sent=企微已送达,skipped=收件人未绑定企微等跳过,dead=重试耗尽,空=仅站内通知。
|
||||
</div>
|
||||
</div>
|
||||
</t-tab-panel>
|
||||
|
||||
<!-- 卡片4:导入模板管理(上传自定义 Excel 模板替换内置默认) -->
|
||||
<!-- 导入模板:上传自定义 Excel 模板替换内置默认 -->
|
||||
<t-tab-panel value="templates" label="导入模板">
|
||||
<!-- 导入模板管理(上传自定义 Excel 模板替换内置默认) -->
|
||||
<div class="panel-box">
|
||||
<div class="panel-box__header">
|
||||
<span class="panel-box__title">导入模板</span>
|
||||
<span class="panel-box__sub">上传后,培训计划批量导入与题库 Excel 导入的下载入口即刻使用新模板</span>
|
||||
<span class="panel-box__sub">上传后,培训计划批量导入、题库 Excel 导入与课程管理批量导入的下载入口即刻使用新模板</span>
|
||||
</div>
|
||||
<t-table :data="templates" :columns="templateColumns" row-key="template_key" size="small" :loading="templateLoading">
|
||||
<template #file_name="{ row }">
|
||||
@@ -189,11 +283,13 @@
|
||||
@change="onUploadFile"
|
||||
/>
|
||||
</div>
|
||||
</t-tab-panel>
|
||||
</t-tabs>
|
||||
|
||||
<!-- 角色编辑弹窗 -->
|
||||
<t-dialog
|
||||
v-model:visible="roleDialogVisible"
|
||||
:header="roleForm.mode === 'add' ? '新增职称角色' : `编辑职称角色 · ${roleForm.label || roleForm.key}`"
|
||||
:header="roleForm.mode === 'add' ? '新增角色' : `编辑角色 · ${roleForm.label || roleForm.key}`"
|
||||
width="480"
|
||||
>
|
||||
<t-form label-width="88px">
|
||||
@@ -244,6 +340,8 @@
|
||||
import { computed, onMounted, ref, watch } from 'vue'
|
||||
import { MessagePlugin } from 'tdesign-vue-next'
|
||||
import {
|
||||
COURSE_CATEGORY_DICT_RULE_KEY,
|
||||
DEFAULT_COURSE_CATEGORIES,
|
||||
ROLE_DICT_RULE_KEY,
|
||||
deleteTrainingTemplate,
|
||||
fetchRoleDict,
|
||||
@@ -265,6 +363,9 @@ import {
|
||||
import { fmtBeijingTime } from '@/utils/datetime'
|
||||
import { downloadTrainingTemplate } from '../trainingTemplates'
|
||||
|
||||
// [2026-11 需求] 配置中心 tab 切换(角色权限/业务规则/推送管理/导入模板)
|
||||
const activeTab = ref('roles')
|
||||
|
||||
const loading = ref(false)
|
||||
const saving = ref(false)
|
||||
const editVisible = ref(false)
|
||||
@@ -393,6 +494,8 @@ interface RuleSchemaDesc {
|
||||
title: string
|
||||
desc: string
|
||||
fields: RuleFieldDesc[]
|
||||
// group:notify = 推送提醒类配置,配置中心归入「推送管理」tab;缺省归「业务规则」tab。
|
||||
group?: 'notify'
|
||||
// serialize UI 表单值 → tr_rule_configs 落库值(默认原样 JSON);
|
||||
// notify_remind_days(数组)/notify_push_enabled(bool) 等非对象契约用。
|
||||
serialize?: (v: Record<string, any>) => any
|
||||
@@ -439,6 +542,7 @@ const RULE_SCHEMAS: RuleSchemaDesc[] = [
|
||||
// (training_scheduler.go loadNotifyConfig);原 remind_policy(t3/t1/third_week/
|
||||
// month_end)从未被后端读取,由本卡替换(third_week/month_end 无实现,随卡移除)。
|
||||
key: 'notify_remind_days',
|
||||
group: 'notify',
|
||||
title: '开课提醒时点',
|
||||
desc: '调度器按提前天数生成讲师授课提醒;学员开课通知由场次"通知方式"决定(立即或前一天),不受本项影响',
|
||||
fields: [
|
||||
@@ -457,6 +561,7 @@ const RULE_SCHEMAS: RuleSchemaDesc[] = [
|
||||
},
|
||||
{
|
||||
key: 'notify_push_enabled',
|
||||
group: 'notify',
|
||||
title: '企微推送总开关',
|
||||
desc: '关闭后新产生的通知只保留站内流水,不再推送企业微信;已入队消息不受影响',
|
||||
fields: [{ key: 'enabled', label: '启用企微推送', type: 'switch' }],
|
||||
@@ -466,6 +571,7 @@ const RULE_SCHEMAS: RuleSchemaDesc[] = [
|
||||
},
|
||||
{
|
||||
key: 'notify_weekly_lecturer',
|
||||
group: 'notify',
|
||||
title: '周一讲师未完成提醒',
|
||||
desc: '每周一上午向当月仍有未结束场次的讲师推送汇总提醒(标题带第 N 周);讲师场次全部结束即自动停推',
|
||||
fields: [
|
||||
@@ -482,6 +588,7 @@ const RULE_SCHEMAS: RuleSchemaDesc[] = [
|
||||
// [2026-11 需求] 提醒推送文案可编辑:各提醒场景的标题/内容模板,保存后新推送即刻生效;
|
||||
// {占位符} 渲染时替换为实际值,清空保存即恢复内置默认文案(后端空值回落默认)。
|
||||
key: 'notify_text_templates',
|
||||
group: 'notify',
|
||||
title: '提醒推送文案',
|
||||
desc: '各提醒推送的标题与内容模板,支持 {占位符} 替换实际值;清空并保存即恢复内置默认文案,对保存后的新推送生效',
|
||||
fields: [
|
||||
@@ -565,6 +672,58 @@ const DEFAULT_RULE_VALUES: Record<string, Record<string, any>> = {
|
||||
|
||||
const RULE_SCHEMA_KEYS = new Set(RULE_SCHEMAS.map((s) => s.key))
|
||||
|
||||
// tab 分组:业务规则(签到/评分/积分/达标线/滚动)与推送提醒(notify_*)各自成 tab
|
||||
const ruleSchemas = RULE_SCHEMAS.filter((s) => s.group !== 'notify')
|
||||
const notifySchemas = RULE_SCHEMAS.filter((s) => s.group === 'notify')
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// 课程分类(course_category_dict):课程管理筛选/表单下拉选项字典,
|
||||
// tag 列表增删 + 保存;保存后课程管理页下次拉取即生效。
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
const categoryDraft = ref<string[]>([])
|
||||
const categorySnapshot = ref('[]')
|
||||
const categoryInput = ref('')
|
||||
const categoriesSaving = ref(false)
|
||||
const categoriesDirty = computed(() => JSON.stringify(categoryDraft.value) !== categorySnapshot.value)
|
||||
|
||||
const onAddCategory = () => {
|
||||
const name = categoryInput.value.trim()
|
||||
if (!name) return
|
||||
if (categoryDraft.value.some((c) => c === name)) {
|
||||
MessagePlugin.warning(`分类「${name}」已存在`)
|
||||
return
|
||||
}
|
||||
categoryDraft.value = [...categoryDraft.value, name]
|
||||
categoryInput.value = ''
|
||||
}
|
||||
|
||||
const onRemoveCategory = (name: string) => {
|
||||
categoryDraft.value = categoryDraft.value.filter((c) => c !== name)
|
||||
}
|
||||
|
||||
// 恢复默认分类(仅改草稿,点「保存」后落库生效)
|
||||
const onResetCategories = () => {
|
||||
categoryDraft.value = [...DEFAULT_COURSE_CATEGORIES]
|
||||
}
|
||||
|
||||
const onSaveCategories = async () => {
|
||||
if (!categoryDraft.value.length) {
|
||||
MessagePlugin.warning('至少保留一个分类')
|
||||
return
|
||||
}
|
||||
categoriesSaving.value = true
|
||||
try {
|
||||
await saveRuleConfig(COURSE_CATEGORY_DICT_RULE_KEY, { categories: categoryDraft.value })
|
||||
categorySnapshot.value = JSON.stringify(categoryDraft.value)
|
||||
MessagePlugin.success('课程分类已保存并生效')
|
||||
} catch (err: any) {
|
||||
MessagePlugin.error(err?.response?.data?.message || '保存失败')
|
||||
} finally {
|
||||
categoriesSaving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const ruleValues = ref<Record<string, Record<string, any>>>({})
|
||||
const savedSnapshot = ref<Record<string, string>>({})
|
||||
const savingKey = ref('')
|
||||
@@ -594,8 +753,15 @@ const applyConfigs = (configs: TrainingRuleConfig[]) => {
|
||||
ruleValues.value = values
|
||||
savedSnapshot.value = snapshot
|
||||
advancedRows.value = configs.filter(
|
||||
(c) => !RULE_SCHEMA_KEYS.has(c.rule_key) && c.rule_key !== ROLE_DICT_RULE_KEY,
|
||||
(c) => !RULE_SCHEMA_KEYS.has(c.rule_key) && c.rule_key !== ROLE_DICT_RULE_KEY && c.rule_key !== COURSE_CATEGORY_DICT_RULE_KEY,
|
||||
)
|
||||
// 课程分类字典:有专属卡片,缺省回退默认分类(与 fetchCourseCategories 同口径)
|
||||
const categoryRaw = configs.find((c) => c.rule_key === COURSE_CATEGORY_DICT_RULE_KEY)?.rule_value?.categories
|
||||
const categories = Array.isArray(categoryRaw)
|
||||
? categoryRaw.filter((c): c is string => typeof c === 'string' && !!c.trim())
|
||||
: [...DEFAULT_COURSE_CATEGORIES]
|
||||
categoryDraft.value = categories
|
||||
categorySnapshot.value = JSON.stringify(categories)
|
||||
}
|
||||
|
||||
const loadAll = async () => {
|
||||
@@ -853,6 +1019,29 @@ watch(pushScene, () => loadPushLogs())
|
||||
display: none;
|
||||
}
|
||||
|
||||
// ---- tab 化布局:tab 内容区与 panel-box 间距 ----
|
||||
.rule-tabs {
|
||||
:deep(.t-tab-panel) {
|
||||
padding: 12px 0 0;
|
||||
}
|
||||
}
|
||||
|
||||
// ---- 课程分类(tag 列表增删编辑) ----
|
||||
.category-editor {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.category-input {
|
||||
width: 220px;
|
||||
}
|
||||
|
||||
.category-reset {
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.form-hint {
|
||||
margin-top: 8px;
|
||||
color: var(--td-text-color-placeholder);
|
||||
|
||||
@@ -3,12 +3,15 @@
|
||||
* 模板按业务键管理:配置中心上传的自定义版本存后端 tr_templates 并全端生效,
|
||||
* 未上传时由后端回退内置默认(docs/moban 随二进制分发)。
|
||||
* - demand_collection 教育训练需求表模板.xlsx(2026-11 起的系统内置默认,
|
||||
* 含「计划培训时间」列):培训计划「年度需求收集 → 批量导入」使用;
|
||||
* 列:编号/部门/课程名称/参加人员/地点/培訓費用/內外培訓/计划培训时间/讲师/备注;
|
||||
* 后端下载时按新布局注入组织架构下拉(部门 B/参加人员 D/讲师 I)。
|
||||
* 含「计划培训月份」列):培训计划「年度需求收集 → 批量导入」使用;
|
||||
* 列:编号/部门/课程名称/参加人员/地点/培訓費用/內外培訓/计划培训月份/讲师/备注;
|
||||
* 后端下载时动态注入:标题年份=下一年度、课程名称下拉(课程管理 C)、
|
||||
* 计划培训月份下拉(1~12 H)、部门/讲师下拉(部门 B/讲师 I)。
|
||||
* - question_bank 部门培训课程试题(题库导入版)模板.xlsx:
|
||||
* 「题库与考试 → Excel 批量导入」与「培训课程 → 创建课程 → 关联题库」指引使用;
|
||||
* 工作表:单选题/多选题/判断题,列:题目/课程名称/难度/正确答案/答案A..答案L。
|
||||
* - course_library 课程管理导入模板.xlsx:「课程管理 → 批量导入」使用;
|
||||
* 列:课程名称/说明/分类/类型/线上,线下/讲师/时长(学时)/课件。
|
||||
*/
|
||||
import { downloadTrainingTemplateFile, type TrainingTemplateKey } from '@/api/training'
|
||||
import { MessagePlugin } from 'tdesign-vue-next'
|
||||
@@ -17,16 +20,19 @@ export type { TrainingTemplateKey }
|
||||
|
||||
export const DEMAND_TEMPLATE_KEY: TrainingTemplateKey = 'demand_collection'
|
||||
export const QUESTION_TEMPLATE_KEY: TrainingTemplateKey = 'question_bank'
|
||||
export const COURSE_LIBRARY_TEMPLATE_KEY: TrainingTemplateKey = 'course_library'
|
||||
|
||||
export const TRAINING_TEMPLATE_LABELS: Record<TrainingTemplateKey, string> = {
|
||||
demand_collection: '教育训练需求表模板',
|
||||
question_bank: '部门培训课程试题(题库导入版)模板',
|
||||
course_library: '课程管理导入模板',
|
||||
}
|
||||
|
||||
// 兜底保存扩展名与内置默认文件一致(后端返回的 fileName 缺失时用)。
|
||||
const TRAINING_TEMPLATE_EXT: Record<TrainingTemplateKey, string> = {
|
||||
demand_collection: '.xlsx',
|
||||
question_bank: '.xlsx',
|
||||
course_library: '.xlsx',
|
||||
}
|
||||
|
||||
// 触发浏览器保存 Blob(带登录态经接口下载;fileName 可传列表接口返回的实际文件名)
|
||||
|
||||
Reference in new issue
Block a user