fix(bug):1.帮我检查一下平台中有多少处显示部门地方这种“e10-、、、、”字样拿掉不要显示
deploy-hxtesting / build-and-deploy (push) Successful in 1m28s
deploy-hxtesting / build-and-deploy (push) Successful in 1m28s
2.月培训计划发布时授课时间默认空着点击【发布】时提示先维护授课时间,(不要默认年培训计划) 3.授课地点默认“年度计划”所设置的授课地点,如果年培训计划没有维护发布时也要必填 4.点击【发布】时要校验参加人员不能为空!默认为所属部门下的人员~ 认真阅读相关代码~
This commit is contained in:
1 parent
6cdcc4f221
commit
858c352991
16 files changed
+421
-89
No files matched your search
@@ -684,6 +684,8 @@ import {
|
||||
type TenantInvitation,
|
||||
} from '@/api/tenant/invitations'
|
||||
import { docsUrl } from '@/utils/docsUrl'
|
||||
// 部门名展示清洗:剥离企微同步残留的「e10-<ID>」字样(2026-11 需求)
|
||||
import { cleanDeptName } from '@/utils/deptName'
|
||||
import {
|
||||
listAuditLog,
|
||||
type AuditLog,
|
||||
@@ -981,7 +983,8 @@ async function loadMembers() {
|
||||
await loadMembers()
|
||||
return
|
||||
}
|
||||
members.value = resp.data.members ?? []
|
||||
// 2026-11 需求:部门列剥离企微同步残留的「e10-<ID>」字样
|
||||
members.value = (resp.data.members ?? []).map((m) => ({ ...m, dept_name: cleanDeptName(m.dept_name) }))
|
||||
membersTotal.value = total
|
||||
if (typeof resp.data.page === 'number' && resp.data.page > 0) {
|
||||
membersPage.value = resp.data.page
|
||||
|
||||
@@ -81,7 +81,8 @@
|
||||
>{{ card.roleTag === 'teach' ? '我主讲' : '我参加' }}</t-tag>
|
||||
</div>
|
||||
<h3 class="course-card__name" :title="card.name">{{ card.name }}</h3>
|
||||
<p class="course-card__meta" :title="card.meta">{{ card.meta }}</p>
|
||||
<!-- 悬停提示给完整名单/类型学时(metaTitle),单行 meta 只展示前 2 名参加人员与时间地点 -->
|
||||
<p class="course-card__meta" :title="card.metaTitle || card.meta">{{ card.meta }}</p>
|
||||
<div class="course-card__foot">
|
||||
<div class="course-card__bar" :class="card.barClass"><i :style="{ width: card.barWidth }"></i></div>
|
||||
<span class="course-card__state" :class="card.stateClass">{{ card.state }}</span>
|
||||
@@ -117,8 +118,8 @@
|
||||
<p class="course-learning__meta">
|
||||
{{
|
||||
[
|
||||
learningCourse.owner_dept_name,
|
||||
learningCourse.suitable_members,
|
||||
cleanDeptNameText(learningCourse.owner_dept_name),
|
||||
cleanDeptNameText(learningCourse.suitable_members),
|
||||
learningCourse.lecturer_name,
|
||||
learningCourse.hours ? `${learningCourse.hours} 学时` : '',
|
||||
]
|
||||
@@ -156,6 +157,8 @@ import { MessagePlugin } from 'tdesign-vue-next'
|
||||
import DocumentPreview from '@/components/document-preview.vue'
|
||||
import TrainingPagination from './TrainingPagination.vue'
|
||||
import { useTrainingPager } from './useTrainingPager'
|
||||
// 部门名展示清洗:剥离企微同步残留的「e10-<ID>」字样(2026-11 需求)
|
||||
import { cleanDeptNameText } from '@/utils/deptName'
|
||||
import {
|
||||
downloadCourseLibraryMaterial,
|
||||
getMyProfile,
|
||||
@@ -395,6 +398,24 @@ const fmtMonthDay = (raw: string | null) => {
|
||||
const d = new Date(raw)
|
||||
return `${d.getMonth() + 1}月${d.getDate()}日`
|
||||
}
|
||||
// 场次排期展示:M月D日 HH:mm(2026-11 需求:卡片带上具体开课时间;解析失败回退原文)
|
||||
const fmtSessionTime = (raw: string | null) => {
|
||||
if (!raw) return ''
|
||||
const d = new Date(raw)
|
||||
if (Number.isNaN(d.getTime())) return String(raw)
|
||||
const p = (n: number) => String(n).padStart(2, '0')
|
||||
return `${d.getMonth() + 1}月${d.getDate()}日 ${p(d.getHours())}:${p(d.getMinutes())}`
|
||||
}
|
||||
// [2026-11 需求] 参加人员展示:名单过长时卡片 meta 最多展示 2 人,其余以「...」
|
||||
// 收尾;完整名单放进 metaTitle(悬停卡片可见),避免长名单把时间/地点挤出单行 meta
|
||||
const participantHeadOf = (postScope: string | null | undefined) => {
|
||||
const names = cleanDeptNameText(postScope).split('、').filter(Boolean)
|
||||
if (!names.length) return { text: '', full: '' }
|
||||
return {
|
||||
text: `参加:${names.slice(0, 2).join('、')}${names.length > 2 ? '...' : ''}`,
|
||||
full: `参加:${names.join('、')}`,
|
||||
}
|
||||
}
|
||||
|
||||
// [2026-11 需求] 「我的课程」排序时间锚点:最近场次排期优先,其次授课时间/计划时间/创建时间;
|
||||
// 月份粒度(YYYY-MM)展开为当月 1 日,无可用时间返回 NaN(排序时落到最后)
|
||||
@@ -419,6 +440,8 @@ interface CatalogCard {
|
||||
name: string
|
||||
mode: string
|
||||
meta: string
|
||||
/** meta 悬停提示全文(参加人员完整名单+类型/学时;缺省回退 meta 本身) */
|
||||
metaTitle?: string
|
||||
state: string
|
||||
stateClass: string
|
||||
barWidth: string
|
||||
@@ -468,7 +491,7 @@ const visibleCards = computed<CatalogCard[]>(() => {
|
||||
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]
|
||||
meta: [c.category, c.type === 'elective' ? '选修' : '必修', c.hours ? `${c.hours} 学时` : '', cleanDeptNameText(c.suitable_members)]
|
||||
.filter(Boolean)
|
||||
.join(' · '),
|
||||
state: '已发布',
|
||||
@@ -505,9 +528,13 @@ const visibleCards = computed<CatalogCard[]>(() => {
|
||||
}
|
||||
return list
|
||||
.map((c) => {
|
||||
// meta 首段为参加人员文案(post_scope),加「参加:」前缀——裸名字会被误读成讲师名
|
||||
// (讲师身份以「我主讲」角标为准,角标判定口径见 isMyTeaching)。
|
||||
const head = [c.post_scope ? `参加:${c.post_scope}` : '', typeText(c), `${c.hours} 学时`, c.exam_enabled ? '随堂考试' : ''].filter(Boolean).join(' · ')
|
||||
// meta 首段为参加人员文案(post_scope,2026-11 需求:最多展示 2 人其余「...」,
|
||||
// 完整名单与类型/学时/考试移入 metaTitle 悬停提示),时间与地点紧随其后 ——
|
||||
// 单行 meta 尾部不再被长名单截断。
|
||||
const participant = participantHeadOf(c.post_scope)
|
||||
const courseInfo = [typeText(c), c.hours ? `${c.hours} 学时` : '', c.exam_enabled ? '随堂考试' : '']
|
||||
.filter(Boolean)
|
||||
.join(' · ')
|
||||
const maintainable = isMyTeaching(c) && canMaintainCourses.value
|
||||
const unpublished = c.status !== 'published'
|
||||
// 「我的培训」角色标记:我主讲(优先) / 我参加,其余视图不标记
|
||||
@@ -515,11 +542,13 @@ const visibleCards = computed<CatalogCard[]>(() => {
|
||||
// 未发布讲师课:无学习任务与排期进度,展示草稿/待审 + 计划时间(需求确认同步)
|
||||
if (unpublished) {
|
||||
const planText = c.planned_time || (c.teach_time && !/^\d{4}-\d{2}$/.test(c.teach_time) ? c.teach_time : '')
|
||||
const schedule = planText ? `计划 ${fmtMonthDay(planText)}` : ''
|
||||
return {
|
||||
id: c.id,
|
||||
name: c.name,
|
||||
mode: c.mode,
|
||||
meta: `${head}${planText ? ` · 计划 ${fmtMonthDay(planText)}` : ''}`,
|
||||
meta: [participant.text, schedule].filter(Boolean).join(' · '),
|
||||
metaTitle: [participant.full, courseInfo, schedule].filter(Boolean).join(' · '),
|
||||
state: c.status === 'pending' ? '待审' : '草稿',
|
||||
stateClass: 'is-warn',
|
||||
barWidth: '0%',
|
||||
@@ -537,19 +566,35 @@ const visibleCards = computed<CatalogCard[]>(() => {
|
||||
: 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, kind: 'plan' as const, roleTag }
|
||||
const materials = c.material_ids?.length ? `课件 ${c.material_ids.length} 个` : ''
|
||||
return {
|
||||
id: c.id,
|
||||
name: c.name,
|
||||
mode: c.mode,
|
||||
meta: [participant.text, materials].filter(Boolean).join(' · '),
|
||||
metaTitle: [participant.full, courseInfo, materials].filter(Boolean).join(' · '),
|
||||
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
|
||||
const next = sess.find((s) => s.status === 'scheduled' && s.start_at)
|
||||
const scheduleText = next ? `${fmtMonthDay(next.start_at)} ${next.location || '线下授课'}` : finished ? `已完成 ${finished} 场` : '待排期'
|
||||
// [2026-11 需求] 时间地点随卡片展示:最近一场排期的开课时间(含时分)与授课地点
|
||||
const scheduleText = next ? `${fmtSessionTime(next.start_at)} ${next.location || '线下授课'}` : finished ? `已完成 ${finished} 场` : '待排期'
|
||||
const ratio = sess.length ? Math.round((finished / sess.length) * 100) : 0
|
||||
return {
|
||||
id: c.id,
|
||||
name: c.name,
|
||||
mode: c.mode,
|
||||
meta: `${head} · ${scheduleText}`,
|
||||
meta: [participant.text, scheduleText].filter(Boolean).join(' · '),
|
||||
metaTitle: [participant.full, courseInfo, scheduleText].filter(Boolean).join(' · '),
|
||||
state: next ? '已排期' : finished ? '已结课' : '待排期',
|
||||
stateClass: next ? 'is-doing' : finished ? 'is-good' : '',
|
||||
barWidth: `${ratio}%`,
|
||||
|
||||
@@ -94,6 +94,8 @@ import {
|
||||
unwrap,
|
||||
} from '@/api/training'
|
||||
import { fmtBeijingTime } from '@/utils/datetime'
|
||||
// 部门名展示清洗:剥离企微同步残留的「e10-<ID>」字样(2026-11 需求)
|
||||
import { cleanDeptName } from '@/utils/deptName'
|
||||
import TrainingPagination from './TrainingPagination.vue'
|
||||
import { useTrainingPager } from './useTrainingPager'
|
||||
|
||||
@@ -181,7 +183,9 @@ const loadTasks = async () => {
|
||||
taskLoading.value = true
|
||||
try {
|
||||
const res = await listCourseLearningTasks(courseId.value)
|
||||
rows.value = unwrap(res) || []
|
||||
// 2026-11 需求:部门列/部门筛选剥离企微同步残留的「e10-<ID>」字样(行装载处
|
||||
// 统一清洗,列表展示、部门筛选下拉与过滤同源生效)
|
||||
rows.value = (unwrap<CourseLearningTask[]>(res) || []).map((r) => ({ ...r, dept_name: cleanDeptName(r.dept_name) }))
|
||||
} catch {
|
||||
rows.value = []
|
||||
} finally {
|
||||
|
||||
@@ -154,7 +154,7 @@
|
||||
上传/更换(回写课程管理主数据并作为本次培训课件/试题,000165 复测起
|
||||
课件/试题变更不再回「待审核」,课程保持已审核可直接发布) -->
|
||||
<t-form-item label="适合人员">
|
||||
<t-input :value="formLibraryCourse?.suitable_members || '-'" disabled placeholder="随所选课程带出" />
|
||||
<t-input :value="cleanDeptNameText(formLibraryCourse?.suitable_members) || '-'" disabled placeholder="随所选课程带出" />
|
||||
</t-form-item>
|
||||
<t-form-item label="课件">
|
||||
<div class="asset-row">
|
||||
@@ -243,8 +243,15 @@
|
||||
<t-input-number v-model="form.credits" :min="0" :step="0.5" :disabled="!form.library_course_id" style="width: 48%; margin-left: 4%" />
|
||||
</t-form-item>
|
||||
<t-form-item v-if="form.mode === 'offline'" label="授课时间">
|
||||
<!-- format 同时决定输入显示与时间面板列数(只出时:分,不出秒) -->
|
||||
<t-date-picker v-model="form.start_at" enable-time-picker format="YYYY-MM-DD HH:mm" style="width: 100%" />
|
||||
<!-- format 同时决定输入显示与时间面板列数(只出时:分,不出秒);禁选过去时间(2026-11 需求) -->
|
||||
<t-date-picker
|
||||
v-model="form.start_at"
|
||||
enable-time-picker
|
||||
format="YYYY-MM-DD HH:mm"
|
||||
:disable-date="teachingTimeDisableDate"
|
||||
:disable-time="teachingTimeDisableTime"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</t-form-item>
|
||||
<t-form-item v-if="form.mode === 'offline'" label="授课地点">
|
||||
<t-input v-model="form.location" placeholder="如:3号厂房 · 二楼培训室" />
|
||||
@@ -371,7 +378,15 @@
|
||||
</t-form-item>
|
||||
<template v-if="editForm.mode === 'offline'">
|
||||
<t-form-item label="授课时间">
|
||||
<t-date-picker v-model="editForm.start_at" enable-time-picker format="YYYY-MM-DD HH:mm" :disabled="!canManage" style="width: 100%" />
|
||||
<t-date-picker
|
||||
v-model="editForm.start_at"
|
||||
enable-time-picker
|
||||
format="YYYY-MM-DD HH:mm"
|
||||
:disabled="!canManage"
|
||||
:disable-date="teachingTimeDisableDate"
|
||||
:disable-time="teachingTimeDisableTime"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</t-form-item>
|
||||
<t-form-item label="授课地点">
|
||||
<t-input v-model="editForm.location" :disabled="!canManage" placeholder="如:3号厂房 · 二楼培训室" />
|
||||
@@ -446,7 +461,7 @@
|
||||
</t-form-item>
|
||||
<!-- 课程资产侧信息(000156):随所选课程带出;课件/试题支持更换,更换后回写课程管理对应课程 -->
|
||||
<t-form-item label="适合人员">
|
||||
<t-input :value="activeLibraryCourse?.suitable_members || '-'" disabled placeholder="随所选课程带出(课程管理维护)" />
|
||||
<t-input :value="cleanDeptNameText(activeLibraryCourse?.suitable_members) || '-'" disabled placeholder="随所选课程带出(课程管理维护)" />
|
||||
</t-form-item>
|
||||
<t-form-item label="课件">
|
||||
<div class="asset-row">
|
||||
@@ -606,6 +621,8 @@ import {
|
||||
unwrap,
|
||||
} from '@/api/training'
|
||||
import { fmtBeijingTime } from '@/utils/datetime'
|
||||
// 部门名展示清洗:剥离企微同步残留的「e10-<ID>」字样(2026-11 需求)
|
||||
import { cleanDeptName, cleanDeptNameText } from '@/utils/deptName'
|
||||
import { apiErrorMessage, get } from '@/utils/request'
|
||||
import TrainingPagination from './TrainingPagination.vue'
|
||||
import { plannedMonthSortKey, useTrainingPager } from './useTrainingPager'
|
||||
@@ -1075,9 +1092,12 @@ const lecturerDisplay = (lecturerId: string) => {
|
||||
const row = activeCourse.value
|
||||
return row?.lecturer_external || '-'
|
||||
}
|
||||
// 部门 id 集合 → 名称(随课程管理「所属部门」带出,只读展示)
|
||||
// 部门 id 集合 → 名称(随课程管理「所属部门」带出,只读展示;
|
||||
// 2026-11 需求:e10-<ID> 残留部门已从部门表过滤,查不到的 id 直接跳过,不再回显原文)
|
||||
const deptNamesOf = (ids: string[] | undefined) => {
|
||||
const list = (ids || []).map((id) => depts.value.find((d) => d.id === id)?.name || id).filter(Boolean)
|
||||
const list = (ids || [])
|
||||
.map((id) => cleanDeptName(depts.value.find((d) => d.id === id)?.name))
|
||||
.filter(Boolean)
|
||||
return list.length ? list.join('、') : '-'
|
||||
}
|
||||
|
||||
@@ -1454,7 +1474,11 @@ const loadAll = async () => {
|
||||
listCourseLibrary({ page_size: 500, scope: 'plan' }).catch(() => null),
|
||||
listQuestionBanks({ page_size: 200 }).catch(() => null),
|
||||
])
|
||||
courses.value = unwrap(c)?.items || []
|
||||
courses.value = (unwrap<{ items: TrainingCourse[] }>(c)?.items || []).map((row) => ({
|
||||
...row,
|
||||
// 2026-11 需求:上报部门剥离企微同步残留的「e10-<ID>」字样
|
||||
reporter_dept_name: cleanDeptName(row.reporter_dept_name),
|
||||
}))
|
||||
depts.value = unwrap(d) || []
|
||||
members.value = m || []
|
||||
lecturers.value = (l && unwrap(l)) || []
|
||||
@@ -1640,45 +1664,61 @@ const onSaveDraft = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
const onPublish = async (row: TrainingCourse) => {
|
||||
// 与后端同口径的前置校验(000161):线上必须有课件;线下须有讲师(外部姓名
|
||||
// 亦可)/授课时间/授课地点;两者均须已设置参加人员且关联课程已审核
|
||||
// 参加人员是否已有效设置(2026-11 需求:发布时校验参加人员不能为空):
|
||||
// 学员名单有人(应到人数=各场次名单去重成员数,列表接口计算)即已设置;
|
||||
// 否则 post_scope 姓名须至少一人匹配到员工名册 —— 需求确认同步的 post_scope
|
||||
// 是「适合人员」部门名串(匹配不到任何员工),不算已设置参加人员
|
||||
const courseHasParticipants = (row: TrainingCourse) => {
|
||||
if ((row.expected_count ?? 0) > 0) return true
|
||||
const names = (row.post_scope || '').split(/[、,,;;\s]+/).map((s) => s.trim()).filter(Boolean)
|
||||
if (!names.length) return false
|
||||
const nameSet = new Set(members.value.map((m) => m.user_name || m.employee_no).filter(Boolean))
|
||||
return names.some((n) => nameSet.has(n))
|
||||
}
|
||||
|
||||
// 发布前置校验(与后端 PublishCourse 同口径):返回首个不满足项的提示文案
|
||||
// (不带课程名前缀,调用方统一拼「「课程名」+原因」),null 表示可发布。
|
||||
// 单个「发布」与「批量发布」共用,批量逐条透出失败原因。
|
||||
const publishBlockReason = async (row: TrainingCourse): Promise<string | null> => {
|
||||
if (row.mode === 'online') {
|
||||
// 线上计划须已登记课件:计划自带课件或课程管理课件(名称登记/文件/知识库
|
||||
// 文档,000156 随所选课程带出)任一有值;查询失败时交由后端校验兜底
|
||||
try {
|
||||
const res = await listMaterials(row.id)
|
||||
if (!(unwrap(res) || []).length) {
|
||||
// 计划未自带课件时回退课程管理课件(名称登记/文件/知识库文档,
|
||||
// 000156 随所选课程带出,详情弹窗「更换」也回写主数据)与后端同口径
|
||||
const lc = libraryCourses.value.find((c) => c.id === (row.library_course_id || ''))
|
||||
const hasLibCourseware = !!(lc?.material_name || lc?.file_name || lc?.knowledge_id)
|
||||
if (!hasLibCourseware) {
|
||||
MessagePlugin.warning(`「${row.name}」是线上计划,发布前需先登记课件资料`)
|
||||
return
|
||||
}
|
||||
if (!hasLibCourseware) return '是线上计划,发布前需先登记课件资料'
|
||||
}
|
||||
} catch {
|
||||
/* 查询失败时交由后端校验兜底 */
|
||||
}
|
||||
} else {
|
||||
if (!row.lecturer_id && !row.lecturer_external) {
|
||||
MessagePlugin.warning(`「${row.name}」是线下计划,发布前需先在「调整」中指定讲师`)
|
||||
return
|
||||
return '是线下计划,发布前需先在「调整」中指定讲师'
|
||||
}
|
||||
// 授课时间/地点与列表展示同口径(场次排期优先,课程级字段兜底):存量草稿
|
||||
// 课程级字段为空但场次已排期时不再误报「未设置」(2026-11-26 复测修复,
|
||||
// 后端 PublishCourse 同口径兜底)
|
||||
// 后端 PublishCourse 同口径兜底);2026-11 需求:授课时间不再默认年培训计划,
|
||||
// 未维护时发布即在此拦截提示先维护
|
||||
const session = firstUsableSession(row)
|
||||
if (!row.teach_time && !session?.start_at) {
|
||||
MessagePlugin.warning(`「${row.name}」是线下计划,发布前需先在「调整」中设置授课时间`)
|
||||
return
|
||||
return '是线下计划,发布前需先在「调整」中设置授课时间'
|
||||
}
|
||||
if (!courseLocation(row)) {
|
||||
MessagePlugin.warning(`「${row.name}」是线下计划,发布前需先在「调整」中设置授课地点`)
|
||||
return
|
||||
return '是线下计划,发布前需先在「调整」中设置授课地点'
|
||||
}
|
||||
}
|
||||
if (!row.post_scope) {
|
||||
MessagePlugin.warning(`「${row.name}」发布前需先在「调整」中设置参加人员`)
|
||||
if (!courseHasParticipants(row)) {
|
||||
return '发布前需先设置参加人员,不能为空(打开「调整」默认为所属部门下的人员,确认后保存再发布)'
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
const onPublish = async (row: TrainingCourse) => {
|
||||
const reason = await publishBlockReason(row)
|
||||
if (reason) {
|
||||
MessagePlugin.warning(`「${row.name}」${reason}`)
|
||||
return
|
||||
}
|
||||
try {
|
||||
@@ -1712,8 +1752,9 @@ const courseSelectionDisabledKeys = computed(() =>
|
||||
)
|
||||
|
||||
const onBatchPublish = async () => {
|
||||
// 仅可发布未发布行(已发布行跳过);线上课课件/线下课讲师/时间/地点/参加人员
|
||||
// 等业务校验由后端 PublishCourse 逐条兜底,失败行透出原因
|
||||
// 仅可发布未发布行(已发布行跳过);每行先过与单个发布同口径的前置校验
|
||||
// (线上课件/线下讲师/授课时间/授课地点/参加人员,2026-11 需求),再调发布接口,
|
||||
// 失败行透出原因(后端 PublishCourse 仍逐条兜底)
|
||||
const rows = filteredCourses.value.filter(
|
||||
(r) => selectedCourseKeys.value.includes(r.id) && r.status !== 'published',
|
||||
)
|
||||
@@ -1726,6 +1767,11 @@ const onBatchPublish = async () => {
|
||||
const failed: string[] = []
|
||||
try {
|
||||
for (const row of rows) {
|
||||
const reason = await publishBlockReason(row)
|
||||
if (reason) {
|
||||
failed.push(`「${row.name}」${reason}`)
|
||||
continue
|
||||
}
|
||||
try {
|
||||
await publishCourse(row.id)
|
||||
ok += 1
|
||||
@@ -1801,12 +1847,12 @@ const openDetail = async (row: TrainingCourse) => {
|
||||
// 000165 复测:打开详情即回源课程管理最新信息(他人刚更新的课件/试题名称跟随变更);
|
||||
// 计划未挂接条目时按课程名补挂既有条目,避免资产维护另建重复空条目
|
||||
void refreshDetailLibraryCourse(row)
|
||||
// 授课时间回填:优先课程授课时间(期望月份默认值 YYYY-MM 展开为当月 1 日),否则回退最近场次排期
|
||||
// 授课时间默认空着(2026-11 需求:不再从年培训计划/期望月份造默认值,
|
||||
// 存量课程落库的「YYYY-MM」也不再展开为「当月1日09:00」;仅回退真实维护过的
|
||||
// 场次排期 —— 需求确认草稿的默认场次无排期即留空,发布时强制先维护)
|
||||
const list = courseSessions.value[row.id] || []
|
||||
const nearest = list.find((s) => s.status === 'scheduled' && s.start_at) || list.find((s) => s.start_at) || list[0]
|
||||
if (row.mode === 'offline' && row.teach_time) {
|
||||
editForm.value.start_at = teachTimeToPicker(row.teach_time)
|
||||
} else if (nearest) {
|
||||
if (row.mode === 'offline' && nearest?.start_at) {
|
||||
editForm.value.start_at = fmtPicker(nearest.start_at)
|
||||
}
|
||||
if (nearest) {
|
||||
@@ -1819,10 +1865,11 @@ const openDetail = async (row: TrainingCourse) => {
|
||||
const matchedIds = members.value
|
||||
.filter((m) => participantNames.includes(m.user_name || ''))
|
||||
.map((m) => m.id)
|
||||
// [2026-11 需求] 参加人员为空但已选「适用部门」时,打开即自动带入部门人员
|
||||
// (推送与应培名单以「参加人员」为准,带入后可增删)
|
||||
// [2026-11 需求] 参加人员默认为「所属部门」下的人员:post_scope 有文本但一个
|
||||
// 姓名都匹配不到员工(需求确认同步的 post_scope 是「适合人员」部门名串,非真实
|
||||
// 参加人员)时同样按部门兜底带入,打开弹窗即见部门人员,可增删
|
||||
const deptIds = (row.dept_ids as unknown as string[]) || []
|
||||
const prefillIds = matchedIds.length || participantNames.length
|
||||
const prefillIds = matchedIds.length
|
||||
? matchedIds
|
||||
: deptIds.length ? members.value.filter((m) => deptIds.includes(m.dept_id)).map((m) => m.id) : []
|
||||
demandSync.value = { participantIds: prefillIds, initialIds: [] }
|
||||
@@ -1831,9 +1878,9 @@ const openDetail = async (row: TrainingCourse) => {
|
||||
participantPostIds.value = []
|
||||
// 初始解析结果(按人员模式下与预选一致),保存时据此判断选择是否变化
|
||||
demandSync.value.initialIds = resolvedParticipantMembers.value.map((m) => m.id)
|
||||
if (row.mode === 'offline' && !editForm.value.start_at && row.planned_time) {
|
||||
editForm.value.start_at = `${(row.planned_time || '').slice(0, 10)} 00:00`
|
||||
}
|
||||
// 2026-11 需求:授课时间不再从「计划培训时间」造默认值(YYYY-MM 塞进日期选择器
|
||||
// 也无法解析),留空由用户维护,发布时强制校验;
|
||||
// 授课地点保留需求确认同步值兜底(默认取年培训计划所设置的授课地点)
|
||||
if (row.mode === 'offline' && !editForm.value.location && row.location) {
|
||||
editForm.value.location = row.location
|
||||
}
|
||||
@@ -1869,9 +1916,26 @@ const fmtPicker = (iso: string | null) => {
|
||||
return `${d.getFullYear()}-${p(d.getMonth() + 1)}-${p(d.getDate())} ${p(d.getHours())}:${p(d.getMinutes())}:${p(d.getSeconds())}`
|
||||
}
|
||||
|
||||
// 月份粒度的授课时间(YYYY-MM,需求期望月份默认值)展开为日期选择器可用的当月 1 日
|
||||
const teachTimeToPicker = (value: string) =>
|
||||
/^\d{4}-\d{2}$/.test(value) ? `${value}-01 09:00:00` : value
|
||||
// ---- 授课时间禁选过去时间(2026-11 需求,创建/调整弹窗同口径) ----
|
||||
// 日期面板禁用今天之前的日期;选中的是「今天」时,时间面板再禁用已过去的时:分。
|
||||
// disableTime 收到的是当前选中值解析出的时间对象 —— 仅当选中值落在当前小时时
|
||||
// 才禁用已过去的分钟,选其他小时(含今天未来小时)的分钟列不受影响。
|
||||
const teachingTimeDisableDate = (d: Date | string) => {
|
||||
const t = typeof d === 'string' ? new Date(d.replace(/-/g, '/')).getTime() : d.getTime()
|
||||
return Number.isFinite(t) ? t < new Date().setHours(0, 0, 0, 0) : false
|
||||
}
|
||||
const teachingTimeDisableTime = (selected: Date) => {
|
||||
const now = new Date()
|
||||
const sel = new Date(selected)
|
||||
if (Number.isNaN(sel.getTime()) || sel.toDateString() !== now.toDateString()) return {}
|
||||
const hour: number[] = []
|
||||
for (let h = 0; h < now.getHours(); h++) hour.push(h)
|
||||
const minute: number[] = []
|
||||
if (sel.getHours() === now.getHours()) {
|
||||
for (let m = 0; m < now.getMinutes(); m++) minute.push(m)
|
||||
}
|
||||
return { hour, minute }
|
||||
}
|
||||
|
||||
// 授课时间入库格式:线下取日期选择器(去秒),线上留空(长期)
|
||||
const teachTimeOf = (form: { mode: string; start_at: string }) => {
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
<div class="panel-box">
|
||||
<div class="panel-box__title">年度需求收集进度(各部门)</div>
|
||||
<div v-for="row in hrData.demand_progress || []" :key="row.dept_id" class="progress-row">
|
||||
<span class="progress-row__name">{{ row.dept_name || '未分组' }}</span>
|
||||
<span class="progress-row__name">{{ cleanDeptName(row.dept_name) || '未分组' }}</span>
|
||||
<t-progress class="progress-row__bar" :percentage="row.percent" />
|
||||
<span class="progress-row__meta">{{ row.done }}/{{ row.total }} 门</span>
|
||||
</div>
|
||||
@@ -92,7 +92,7 @@
|
||||
<div class="panel-box">
|
||||
<div class="panel-box__title">部门培训达成率排名(年度累计)</div>
|
||||
<div v-for="row in execData.dept_ranking || []" :key="row.dept_id" class="progress-row">
|
||||
<span class="progress-row__name">{{ row.dept_name || '未分组' }}</span>
|
||||
<span class="progress-row__name">{{ cleanDeptName(row.dept_name) || '未分组' }}</span>
|
||||
<t-progress class="progress-row__bar" :percentage="row.percent" />
|
||||
<span class="progress-row__meta">{{ row.percent }}%</span>
|
||||
</div>
|
||||
@@ -104,7 +104,7 @@
|
||||
<span>
|
||||
<t-tag :theme="idx === 0 ? 'warning' : 'default'" variant="light" size="small">{{ idx + 1 }}</t-tag>
|
||||
{{ row.name }}
|
||||
<span v-if="row.dept_name" class="muted">{{ row.dept_name }}</span>
|
||||
<span v-if="cleanDeptName(row.dept_name)" class="muted">{{ cleanDeptName(row.dept_name) }}</span>
|
||||
</span>
|
||||
<span class="rank-score">{{ row.total }} 分</span>
|
||||
</div>
|
||||
@@ -126,6 +126,8 @@
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
import { MessagePlugin } from 'tdesign-vue-next'
|
||||
import { getDeptDashboard, getExecDashboard, getHRDashboard, settleLecturerScores, unwrap, type DashboardData } from '@/api/training'
|
||||
// 部门名展示清洗:剥离企微同步残留的「e10-<ID>」字样(2026-11 需求)
|
||||
import { cleanDeptName } from '@/utils/deptName'
|
||||
|
||||
const props = defineProps<{ roles: string[]; admin?: boolean }>()
|
||||
|
||||
|
||||
@@ -537,6 +537,8 @@ import * as XLSX from 'xlsx'
|
||||
import { COURSE_LIBRARY_TEMPLATE_KEY, QUESTION_TEMPLATE_KEY, downloadTrainingTemplate } from '../trainingTemplates'
|
||||
import { apiErrorMessage, get } from '@/utils/request'
|
||||
import { fmtBeijingTime } from '@/utils/datetime'
|
||||
// 部门名展示清洗:剥离企微同步残留的「e10-<ID>」字样(2026-11 需求)
|
||||
import { cleanDeptName, cleanDeptNameText } from '@/utils/deptName'
|
||||
import TrainingPagination from './TrainingPagination.vue'
|
||||
import { useTrainingPager } from './useTrainingPager'
|
||||
import {
|
||||
@@ -746,13 +748,15 @@ const permToFields = () => {
|
||||
}
|
||||
|
||||
// 列表「课程权限」列展示文本:perm 两列解析为「部门、人员」;存量行回退原文本
|
||||
// (2026-11 需求:e10-<ID> 残留部门已从部门表过滤,查不到的 id 跳过不回显原文)
|
||||
const permissionText = (row: TrainingLibraryCourse) => {
|
||||
if ((row.perm_dept_ids || '').trim() || (row.perm_user_ids || '').trim()) {
|
||||
const deptNames = (row.perm_dept_ids || '').split(',').filter(Boolean).map((id) => depts.value.find((d) => d.id === id)?.name || id)
|
||||
const deptNames = (row.perm_dept_ids || '').split(',').filter(Boolean)
|
||||
.map((id) => cleanDeptName(depts.value.find((d) => d.id === id)?.name)).filter(Boolean)
|
||||
const userNames = (row.perm_user_ids || '').split(',').filter(Boolean).map(memberDisplayName)
|
||||
return [...deptNames, ...userNames].join('、')
|
||||
}
|
||||
return row.suitable_members || ''
|
||||
return cleanDeptNameText(row.suitable_members)
|
||||
}
|
||||
|
||||
// 课程权限是否已设置(审核前置,000163:权限必填)
|
||||
@@ -867,14 +871,19 @@ const loadAll = async () => {
|
||||
// 本人档案:新增课程「所属部门」默认当前登录用户所在部门
|
||||
getMyProfile().catch(() => null),
|
||||
])
|
||||
items.value = unwrap(lib)?.items || []
|
||||
// 2026-11 需求:主办部门列/适合人员剥离企微同步残留的「e10-<ID>」字样
|
||||
items.value = (unwrap<{ items: TrainingLibraryCourse[] }>(lib)?.items || []).map((row) => ({
|
||||
...row,
|
||||
owner_dept_name: cleanDeptName(row.owner_dept_name),
|
||||
suitable_members: cleanDeptNameText(row.suitable_members),
|
||||
}))
|
||||
members.value = m || []
|
||||
depts.value = (d && unwrap(d)) || []
|
||||
configCategories.value = cats
|
||||
const meBody = me && unwrap(me)
|
||||
myDeptId.value = meBody?.dept_id || ''
|
||||
myUserId.value = meBody?.user_id || ''
|
||||
meDeptName.value = meBody?.dept_name || ''
|
||||
meDeptName.value = cleanDeptName(meBody?.dept_name)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
|
||||
@@ -261,6 +261,8 @@ import { computed, onMounted, ref, watch } from 'vue'
|
||||
import { MessagePlugin } from 'tdesign-vue-next'
|
||||
import * as XLSX from 'xlsx'
|
||||
import { fmtBeijingTime } from '@/utils/datetime'
|
||||
// 部门名展示清洗:剥离企微同步残留的「e10-<ID>」字样(2026-11 需求)
|
||||
import { cleanDeptNameText } from '@/utils/deptName'
|
||||
import { DEMAND_TEMPLATE_KEY, downloadTrainingTemplate } from '../trainingTemplates'
|
||||
import { apiErrorMessage } from '@/utils/request'
|
||||
import TrainingPagination from './TrainingPagination.vue'
|
||||
@@ -550,6 +552,11 @@ const loadDemands = async () => {
|
||||
const d = await listDemands(buildDemandQuery())
|
||||
// 000163:按计划培训月份倒序(2027-12 → 2027-1,无计划培训时间的排最后)
|
||||
const items = (unwrap(d)?.items || []) as TrainingDemand[]
|
||||
// 2026-11 需求:部门列/适合人员剥离企微同步残留的「e10-<ID>」字样
|
||||
for (const it of items) {
|
||||
it.dept_name = cleanDeptNameText(it.dept_name)
|
||||
it.post_scope = cleanDeptNameText(it.post_scope)
|
||||
}
|
||||
demands.value = items.slice()
|
||||
.sort((a, b) => plannedMonthSortKey(b.planned_time) - plannedMonthSortKey(a.planned_time))
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user