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
@@ -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 }) => {
|
||||
|
||||
Reference in new issue
Block a user