feat(training): 需求联动课程管理、适合人员多选、跨空间参与与计划讲师回写(000158-000161)
000158 需求单联动课程管理: - tr_demands 新增 library_course_id:填报/导入按课程名称在课程管理精准匹配, 命中自动关联,未命中自动新增待核验课程(000157 流转,发布前须签核完成); 匹配/建档失败整批回滚并透出原因,不静默跳过 - 需求所属部门强制为填报人本人部门:新建按提报人档案落库(忽略请求值防绕过, 无部门档案阻断),编辑保留原部门;批量导入按 Excel「部门」列做归属校验 - 编辑时课程名未变保留原课程关联,全量更新不误清 000159 适合人员部门多选: - tr_course_library.suitable_members 拓宽至 VARCHAR(512):存「、」分隔多部门名 或「全部」,存量单值/自由文本兼容(分隔符匹配时归一) - 课程管理/需求表单改多选交互,「全部」与具体部门互斥 000160 企业培训跨空间参与: - 培训域数据空间按员工档案归属解析(当前空间有培训档案优先,否则回落最早 在职档案所在空间),路由组 TrainingTenantResolution 中间件统一注入 - 中间件同步回落请求上下文执行租户:课件文件流(GetKnowledgeFile)、培训 知识库 ensure 等 ctx 租户链路落在档案空间;caller 身份保持当前工作区, 授权口径不变(修复跨空间学员课件预览 403「Permission denied」与文件流 404) - 课程学习详情页课件预览统一走培训域文件流(/training/materials/:id/file), 不再请求知识库守卫路由(/knowledge/:id/preview);附空间解析中间件单元测试 - 培训中心「和信课程」目录(scope=catalog):已发布 + 适合人员覆盖即可见; 卡片点开即学(课件在线预览抽屉 + 下载);计划无材料行时以课程管理条目 合成课件回退取流 - /training/members/me 联查返回部门名,支撑适合人员匹配与表单默认值 000161 计划讲师回写与发布校验: - 月培训计划讲师计划侧可改,改动回写课程管理主数据并重置待核验(发布前须 重新签核),同步补讲师 lecturer 角色绑定 - 发布必填校验:关联课程管理且已签核、参加人员;线下计划另需授课时间/地点/ 讲师(线上计划豁免);跨场次名单去重成员数校验
This commit is contained in:
1 parent
3c8b595064
commit
0819f8c4d1
24 files changed
+1084
-202
No files matched your search
@@ -162,6 +162,8 @@ export interface TrainingDemand {
|
||||
dept_id: string
|
||||
submitter_id: string
|
||||
course_name: string
|
||||
/** 需求所填课程自动匹配的课程管理条目 id(000158:填报/导入时按名称精准匹配,未命中自动新增待核验课程) */
|
||||
library_course_id?: string
|
||||
/** 厂区(模板列:厂区,如 三厂) */
|
||||
plant: string
|
||||
/** 培训分类(模板列:分类,如 知识/技能/安全) */
|
||||
@@ -185,7 +187,7 @@ export interface TrainingDemand {
|
||||
check_status: 'pending' | 'passed' | 'fixed'
|
||||
check_msg: string
|
||||
status: string
|
||||
/** 联查展示字段:部门名称/讲师姓名/创建人姓名(提报人,联查 users 只读) */
|
||||
/** 部门名称(列表联查 org_depts 只读;导入载荷另携带 Excel「部门」列原始值,000158 后端据此做导入人部门归属校验) */
|
||||
dept_name?: string
|
||||
lecturer_name?: string
|
||||
submitter_name?: string
|
||||
|
||||
@@ -57,14 +57,6 @@
|
||||
active
|
||||
fill-height
|
||||
/>
|
||||
<DocumentPreview
|
||||
v-else-if="current && isDoc(current)"
|
||||
:knowledge-id="current.knowledge_id"
|
||||
:file-type="previewKind(current)"
|
||||
:file-name="current.name"
|
||||
active
|
||||
fill-height
|
||||
/>
|
||||
<t-empty
|
||||
v-else-if="current"
|
||||
class="preview-empty"
|
||||
@@ -209,7 +201,6 @@ const previewKind = (m: TrainingMaterial) => {
|
||||
return 'unsupported'
|
||||
}
|
||||
const isVideo = (m: TrainingMaterial) => previewKind(m) === 'video' || (!m.knowledge_id && !!m.file_key)
|
||||
const isDoc = (m: TrainingMaterial) => !isVideo(m) && (m.knowledge_id || m.file_key)
|
||||
|
||||
const kindIcon = (m: TrainingMaterial) => {
|
||||
const kind = previewKind(m)
|
||||
@@ -225,28 +216,27 @@ const stopHeartbeat = () => {
|
||||
docPercentStep = 0
|
||||
}
|
||||
|
||||
// 打开课件:文档带 knowledge_id 时走知识库流(DocumentPreview 自带拉取);
|
||||
// 视频/仅 file_key 的课件统一走课件文件流(blob 播放/渲染)。
|
||||
// 打开课件:统一走培训域课件文件流(blob 播放/渲染)。不走知识库文档预览
|
||||
// 通道(/knowledge/:id/preview):该通道按调用方所在空间做知识库鉴权,000160
|
||||
// 跨空间学员(培训数据在档案空间)会被 403「Permission denied」拦截;培训域
|
||||
// 文件流按解析后的培训租户服务端取文件,与下载/和信课程抽屉同口径。
|
||||
const openMaterial = async (m: TrainingMaterial) => {
|
||||
if (current.value?.id === m.id) return
|
||||
stopHeartbeat()
|
||||
current.value = m
|
||||
docBlob.value = null
|
||||
if (!m.knowledge_id && !m.file_key) return
|
||||
if (isVideo(m) || !m.knowledge_id) {
|
||||
previewLoading.value = true
|
||||
try {
|
||||
docBlob.value = await downloadMaterialFile(m.id)
|
||||
if (isVideo(m)) bindVideoHeartbeat()
|
||||
} catch {
|
||||
MessagePlugin.error('课件文件加载失败,请稍后重试')
|
||||
current.value = null
|
||||
} finally {
|
||||
previewLoading.value = false
|
||||
}
|
||||
return
|
||||
previewLoading.value = true
|
||||
try {
|
||||
docBlob.value = await downloadMaterialFile(m.id)
|
||||
if (isVideo(m)) bindVideoHeartbeat()
|
||||
else startDocHeartbeat(m)
|
||||
} catch {
|
||||
MessagePlugin.error('课件文件加载失败,请稍后重试')
|
||||
current.value = null
|
||||
} finally {
|
||||
previewLoading.value = false
|
||||
}
|
||||
startDocHeartbeat(m)
|
||||
}
|
||||
|
||||
// ---- 学习进度心跳 ----
|
||||
|
||||
@@ -116,10 +116,12 @@ const authStore = useAuthStore()
|
||||
// 职称角色字典(配置中心可配);myRoles = 实际分配角色按「权限分配」传递展开后的
|
||||
// 权限并集 —— 各子页既有 canXxx 判断因此对自定义角色自动生效,无需逐一修改。
|
||||
const roleDict = ref<TrainingRoleDef[]>([])
|
||||
const loadRoleDict = () =>
|
||||
fetchRoleDict().then((d) => {
|
||||
roleDict.value = d
|
||||
})
|
||||
const myRoles = computed(() => expandRoles(rawRoles.value, roleDict.value))
|
||||
fetchRoleDict().then((d) => {
|
||||
roleDict.value = d
|
||||
})
|
||||
loadRoleDict()
|
||||
|
||||
// 空间 Admin/Owner 视同培训管理角色(与后端 requireRoles 的 bypass 一致),
|
||||
// 保证冷启动时管理员即可进入职称角色/配置中心子页完成首批授权。
|
||||
@@ -213,6 +215,15 @@ const loadProfile = async () => {
|
||||
onMounted(() => {
|
||||
loadProfile()
|
||||
})
|
||||
|
||||
// 侧栏在企业培训各子页间切换时复用同一页面实例(不重挂载):本人职称角色可能刚在
|
||||
// 「职称角色」子页被分配/回收,角色权限字典可能刚在「配置中心」子页被修改。切换
|
||||
// 子页时重取这两项,否则各子页会沿用挂载时的旧 myRoles —— 例如刚给自己分配了
|
||||
// 课长,课程管理的核验/删除按钮却不出现,须整页刷新才生效。
|
||||
watch(activeTab, () => {
|
||||
loadProfile()
|
||||
loadRoleDict()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
|
||||
@@ -98,13 +98,57 @@
|
||||
:description="filter === 'mine' ? '暂无与我相关的课程' : '暂无已发布课程(课程管理发布后在此展示)'"
|
||||
/>
|
||||
</t-loading>
|
||||
|
||||
<!-- 课程学习抽屉(000160):和信课程卡片点开即学 —— 课件在线预览 + 下载 -->
|
||||
<t-drawer
|
||||
v-model:visible="learningVisible"
|
||||
:header="learningCourse?.name || '课程学习'"
|
||||
size="860px"
|
||||
:footer="false"
|
||||
>
|
||||
<div v-if="learningCourse" class="course-learning">
|
||||
<p class="course-learning__meta">
|
||||
{{
|
||||
[
|
||||
learningCourse.owner_dept_name,
|
||||
learningCourse.suitable_members,
|
||||
learningCourse.lecturer_name,
|
||||
learningCourse.hours ? `${learningCourse.hours} 学时` : '',
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(' · ')
|
||||
}}
|
||||
</p>
|
||||
<t-loading :loading="learningLoading" text="课件加载中...">
|
||||
<DocumentPreview
|
||||
v-if="learningBlob"
|
||||
:source-blob="learningBlob"
|
||||
:file-type="learningFileType"
|
||||
:file-name="learningCourse.file_name || learningCourse.name"
|
||||
:active="learningVisible"
|
||||
fill-height
|
||||
/>
|
||||
<t-empty
|
||||
v-else-if="!learningLoading"
|
||||
class="catalog-empty"
|
||||
:description="learningCourse.file_name ? '课件加载失败,可下载后本地查看' : '该课程未上传课件,请联系讲师或人事补充'"
|
||||
/>
|
||||
</t-loading>
|
||||
<div v-if="learningCourse.file_name" class="course-learning__actions">
|
||||
<t-button variant="outline" theme="primary" @click="onDownloadLearningMaterial">下载课件</t-button>
|
||||
</div>
|
||||
</div>
|
||||
</t-drawer>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { MessagePlugin } from 'tdesign-vue-next'
|
||||
import DocumentPreview from '@/components/document-preview.vue'
|
||||
import {
|
||||
downloadCourseLibraryMaterial,
|
||||
getMyProfile,
|
||||
listCourses,
|
||||
listCourseLibrary,
|
||||
@@ -125,9 +169,13 @@ const props = defineProps<{ roles: string[]; admin?: boolean }>()
|
||||
const router = useRouter()
|
||||
// 卡片点击 → 课程学习详情页(课件在线预览 + 随堂考试);
|
||||
// 未发布课程(我任讲师的草稿/待审)无学习视角,点击直达维护;
|
||||
// 和信课程卡片为课程资产展示(000154),无学习页不跳转。
|
||||
// 和信课程卡片点开即学(000160):打开课件在线预览抽屉。
|
||||
const openCourse = (card: CatalogCard) => {
|
||||
if (card.kind === 'library') return
|
||||
if (card.kind === 'library') {
|
||||
const course = hexinCourses.value.find((c) => c.id === card.id)
|
||||
if (course) openLibraryCourse(course)
|
||||
return
|
||||
}
|
||||
if (card.unpublished) {
|
||||
goMaintain(card.id)
|
||||
return
|
||||
@@ -140,6 +188,52 @@ const goMaintain = (courseId: string) => {
|
||||
router.push({ path: '/platform/training/course', query: { courseId } })
|
||||
}
|
||||
|
||||
// ---- 和信课程学习抽屉(000160):点开卡片 → 课件在线预览 + 下载 ----
|
||||
const learningVisible = ref(false)
|
||||
const learningCourse = ref<TrainingLibraryCourse | null>(null)
|
||||
const learningBlob = ref<Blob | null>(null)
|
||||
const learningLoading = ref(false)
|
||||
// 预览组件按扩展名分派渲染器(pptx/pdf/docx/图片/文本...)
|
||||
const learningFileType = computed(() => {
|
||||
const name = learningCourse.value?.file_name || ''
|
||||
const dot = name.lastIndexOf('.')
|
||||
return dot >= 0 ? name.slice(dot + 1).toLowerCase() : ''
|
||||
})
|
||||
|
||||
const openLibraryCourse = (course: TrainingLibraryCourse) => {
|
||||
learningCourse.value = course
|
||||
learningBlob.value = null
|
||||
learningVisible.value = true
|
||||
if (!course.file_name) return
|
||||
learningLoading.value = true
|
||||
downloadCourseLibraryMaterial(course.id)
|
||||
.then((blob) => {
|
||||
learningBlob.value = blob
|
||||
})
|
||||
.catch(() => {
|
||||
learningBlob.value = null
|
||||
})
|
||||
.finally(() => {
|
||||
learningLoading.value = false
|
||||
})
|
||||
}
|
||||
|
||||
const onDownloadLearningMaterial = async () => {
|
||||
const course = learningCourse.value
|
||||
if (!course?.file_name) return
|
||||
try {
|
||||
const blob = await downloadCourseLibraryMaterial(course.id)
|
||||
const url = URL.createObjectURL(blob)
|
||||
const a = document.createElement('a')
|
||||
a.href = url
|
||||
a.download = course.file_name || `${course.name}课件`
|
||||
a.click()
|
||||
URL.revokeObjectURL(url)
|
||||
} catch {
|
||||
MessagePlugin.error('课件下载失败')
|
||||
}
|
||||
}
|
||||
|
||||
const loading = ref(false)
|
||||
const courses = ref<TrainingCourse[]>([])
|
||||
// 课程维护视角(不带 scope=student)的我名下课程:纯讲师含草稿,供「我的培训」与待维护统计
|
||||
@@ -164,13 +258,24 @@ const keyword = ref('')
|
||||
// 目录页面向全体员工:仅展示已发布课程(草稿/待审在「培训课程」维护)
|
||||
const publishedCourses = computed(() => courses.value.filter((c) => c.status === 'published'))
|
||||
|
||||
// 「和信课程」(000154):课程管理中已发布、且部门范围覆盖查看人的课程
|
||||
// (所属部门为空 = 全员课程;有部门则需与我的部门一致)
|
||||
// 「和信课程」(000160):已发布 + 适合人员覆盖查看人 —— 「全部」全员可见;
|
||||
// 000159 多部门口径:值按「、」拆分(逗号/分号兼容归一)后与查看人部门名做
|
||||
// 成员匹配;未设置适合人员的存量课程沿用原部门范围口径(所属部门为空 = 全员,
|
||||
// 否则须与我的部门一致)。后端 scope=catalog 已按同口径过滤,此处保留客户端兜底。
|
||||
const myDeptId = computed(() => myProfile.value?.dept_id || '')
|
||||
const myDeptName = computed(() => (myProfile.value?.dept_name || '').trim())
|
||||
const hexinCourses = computed<TrainingLibraryCourse[]>(() =>
|
||||
libraryItems.value.filter(
|
||||
(c) => c.publish_status === 'published' && (!c.owner_dept_id || !myDeptId.value || c.owner_dept_id === myDeptId.value),
|
||||
),
|
||||
libraryItems.value.filter((c) => {
|
||||
if (c.publish_status !== 'published') return false
|
||||
const suitableNames = (c.suitable_members || '')
|
||||
.split(/[、,,;;]/)
|
||||
.map((s) => s.trim())
|
||||
.filter(Boolean)
|
||||
if (suitableNames.length) {
|
||||
return suitableNames.includes('全部') || (!!myDeptName.value && suitableNames.includes(myDeptName.value))
|
||||
}
|
||||
return !c.owner_dept_id || !myDeptId.value || c.owner_dept_id === myDeptId.value
|
||||
}),
|
||||
)
|
||||
|
||||
const statsText = computed(() => {
|
||||
@@ -448,8 +553,9 @@ const loadAll = async () => {
|
||||
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),
|
||||
// 和信课程目录(000160):scope=catalog —— 已发布 + 适合人员覆盖查看人
|
||||
// (全部/本部门;未设置沿用部门范围口径),不按维护角色收窄,全体员工同源
|
||||
listCourseLibrary({ page_size: 500, scope: 'catalog' }).catch(() => null),
|
||||
// 我的考试记录(000154)
|
||||
listMyExamRecords().catch(() => null),
|
||||
])
|
||||
@@ -573,6 +679,26 @@ onMounted(loadAll)
|
||||
padding: 48px 0;
|
||||
}
|
||||
|
||||
// 课程学习抽屉(000160):元信息行 + 预览主体 + 下载操作
|
||||
.course-learning {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
min-height: 100%;
|
||||
|
||||
&__meta {
|
||||
margin: 0;
|
||||
color: var(--td-text-color-secondary);
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
&__actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 8px;
|
||||
}
|
||||
}
|
||||
|
||||
// 「我的考试」成绩列:及格绿/不及格红
|
||||
.exam-score {
|
||||
font-weight: 600;
|
||||
|
||||
@@ -71,7 +71,7 @@
|
||||
variant="text" theme="primary" size="small" :disabled="saving"
|
||||
@click="onPublish(row)"
|
||||
>发布</t-button>
|
||||
<t-button variant="text" size="small" @click="openDetail(row)">详情</t-button>
|
||||
<t-button variant="text" size="small" @click="openDetail(row)">调整</t-button>
|
||||
<t-button variant="text" size="small" @click="openChangeLogs(row)">记录</t-button>
|
||||
<t-button v-if="canManage" variant="text" theme="danger" size="small" @click="onDelete(row)">删除</t-button>
|
||||
</template>
|
||||
@@ -195,16 +195,16 @@
|
||||
</template>
|
||||
</t-dialog>
|
||||
|
||||
<!-- 计划详情:计划编号展示 + 课程名称(课程管理选择,信息锁定) + 六项授课安排维护 -->
|
||||
<t-dialog v-model:visible="sessionsVisible" :header="`计划详情 · ${activeCourse?.name || ''}`" width="760" :footer="false">
|
||||
<!-- 计划调整:计划编号展示 + 课程名称/讲师(000161 可调整,讲师改动回写课程管理并重置待核验) + 六项授课安排维护 -->
|
||||
<t-dialog v-model:visible="sessionsVisible" :header="`计划调整 · ${activeCourse?.name || ''}`" width="760" :footer="false">
|
||||
<t-form label-width="90" class="detail-form">
|
||||
<t-form-item label="计划编号">
|
||||
<t-input :value="activeCourse?.plan_code || '-'" disabled />
|
||||
</t-form-item>
|
||||
<t-form-item label="课程名称">
|
||||
<!-- 未关联课程管理的计划可选定课程(选定后信息锁定);已关联直接锁定展示 -->
|
||||
<!-- 000161 可切换关联课程:改选即换 library_course_id,类型/形式随新课程带出;
|
||||
讲师改动保存后回写课程管理并重置待核验,发布前须重新签核 -->
|
||||
<t-select
|
||||
v-if="!activeCourse?.library_course_id"
|
||||
v-model="editForm.library_course_id"
|
||||
:disabled="!canManage"
|
||||
clearable
|
||||
@@ -215,13 +215,23 @@
|
||||
>
|
||||
<t-option v-for="c in libraryCourses" :key="c.id" :value="c.id" :label="`${c.name}${c.category ? `(${c.category})` : ''}`" />
|
||||
</t-select>
|
||||
<t-input v-else :value="editForm.name" disabled />
|
||||
</t-form-item>
|
||||
<t-form-item label="类型">
|
||||
<t-input :value="formTypeDisplay" disabled />
|
||||
</t-form-item>
|
||||
<t-form-item label="讲师">
|
||||
<t-input :value="lecturerDisplay(editForm.lecturer_id)" disabled placeholder="随课程带出" />
|
||||
<!-- 000161 计划侧可改讲师:名册选择或直接输入外部讲师姓名 -->
|
||||
<t-select
|
||||
v-model="editForm.lecturer_id"
|
||||
:disabled="!canManage"
|
||||
clearable
|
||||
filterable
|
||||
creatable
|
||||
placeholder="从讲师名册选择或直接输入外部讲师姓名"
|
||||
style="width: 100%"
|
||||
>
|
||||
<t-option v-for="l in lecturers" :key="l.id" :label="l.name" :value="l.id" />
|
||||
</t-select>
|
||||
</t-form-item>
|
||||
<t-form-item label="所属部门">
|
||||
<t-input :value="deptNamesOf(editForm.dept_ids)" disabled placeholder="随课程带出" />
|
||||
@@ -1159,19 +1169,40 @@ const onSave = async () => {
|
||||
}
|
||||
|
||||
const onPublish = async (row: TrainingCourse) => {
|
||||
// 与后端同口径的前置校验:线上必须有课件,线下必须有讲师
|
||||
// 与后端同口径的前置校验(000161):线上必须有课件;线下须有讲师(外部姓名
|
||||
// 亦可)/授课时间/授课地点;两者均须已设置参加人员且关联课程已签核
|
||||
if (row.mode === 'online') {
|
||||
try {
|
||||
const res = await listMaterials(row.id)
|
||||
if (!(unwrap(res) || []).length) {
|
||||
MessagePlugin.warning(`「${row.name}」是线上计划,发布前需先登记课件资料`)
|
||||
return
|
||||
// 计划未自带课件时回退课程管理课件(名称登记/文件/知识库文档,
|
||||
// 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
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
/* 查询失败时交由后端校验兜底 */
|
||||
}
|
||||
} else if (!row.lecturer_id) {
|
||||
MessagePlugin.warning(`「${row.name}」是线下计划,发布前需先在「详情」中指定讲师`)
|
||||
} else {
|
||||
if (!row.lecturer_id && !row.lecturer_external) {
|
||||
MessagePlugin.warning(`「${row.name}」是线下计划,发布前需先在「调整」中指定讲师`)
|
||||
return
|
||||
}
|
||||
if (!row.teach_time) {
|
||||
MessagePlugin.warning(`「${row.name}」是线下计划,发布前需先在「调整」中设置授课时间`)
|
||||
return
|
||||
}
|
||||
if (!row.location) {
|
||||
MessagePlugin.warning(`「${row.name}」是线下计划,发布前需先在「调整」中设置授课地点`)
|
||||
return
|
||||
}
|
||||
}
|
||||
if (!row.post_scope) {
|
||||
MessagePlugin.warning(`「${row.name}」发布前需先在「调整」中设置参加人员`)
|
||||
return
|
||||
}
|
||||
try {
|
||||
@@ -1339,42 +1370,55 @@ const ensureCourseSession = async (
|
||||
// 学员名单以「参加人员」为准同步(适用部门选择时已自动带入,可增删)。
|
||||
// 详情保存载荷(000158 抽取复用):UpdateCourse 为全量列更新,未编辑字段必须
|
||||
// 回填原值,否则 tags/material_ids 会写 NULL,status/exam_enabled 会被零值覆盖。
|
||||
const detailSavePayload = (row: TrainingCourse) => ({
|
||||
id: row.id,
|
||||
code: row.code,
|
||||
name: editForm.value.name,
|
||||
mode: editForm.value.mode,
|
||||
type: editForm.value.type,
|
||||
hours: editForm.value.hours,
|
||||
credits: editForm.value.credits,
|
||||
exam_enabled: row.exam_enabled,
|
||||
dept_ids: editForm.value.dept_ids,
|
||||
lecturer_id: editForm.value.lecturer_id || undefined,
|
||||
// 参加人员:详情表单可编辑,保存随课程信息落库并同步场次学员名单
|
||||
post_scope: resolvedParticipantMembers.value.map((m) => m.user_name || m.employee_no).join('、'),
|
||||
description: row.description,
|
||||
material_ids: row.material_ids,
|
||||
tags: row.tags,
|
||||
status: row.status,
|
||||
teach_time: teachTimeOf(editForm.value),
|
||||
planned_time: row.planned_time || '',
|
||||
// 其余需求确认同步字段原样透传(详情表单不编辑,防止保存时被零值覆盖丢失)
|
||||
train_type: row.train_type || '',
|
||||
plant: row.plant || '',
|
||||
location: row.location || '',
|
||||
session_count: row.session_count || 0,
|
||||
lecturer_external: row.lecturer_external || '',
|
||||
remark: row.remark || '',
|
||||
// 课程管理关联(未关联的存量计划可在此选定课程;关联后服务端锁定带出字段)
|
||||
library_course_id: editForm.value.library_course_id || row.library_course_id || '',
|
||||
})
|
||||
// 000161 讲师解析:名册 id 直接用;非名册值(creatable 直接输入)按外部讲师姓名落库
|
||||
const resolveDetailLecturer = (row: TrainingCourse) => {
|
||||
const v = (editForm.value.lecturer_id || '').trim()
|
||||
if (!v) return { lecturerId: '', external: row.lecturer_external || '' }
|
||||
if (lecturers.value.some((l) => l.id === v)) return { lecturerId: v, external: '' }
|
||||
return { lecturerId: '', external: v }
|
||||
}
|
||||
|
||||
const detailSavePayload = (row: TrainingCourse) => {
|
||||
const lecturer = resolveDetailLecturer(row)
|
||||
return ({
|
||||
id: row.id,
|
||||
code: row.code,
|
||||
name: editForm.value.name,
|
||||
mode: editForm.value.mode,
|
||||
type: editForm.value.type,
|
||||
hours: editForm.value.hours,
|
||||
credits: editForm.value.credits,
|
||||
exam_enabled: row.exam_enabled,
|
||||
dept_ids: editForm.value.dept_ids,
|
||||
lecturer_id: lecturer.lecturerId || undefined,
|
||||
// 参加人员:详情表单可编辑,保存随课程信息落库并同步场次学员名单
|
||||
post_scope: resolvedParticipantMembers.value.map((m) => m.user_name || m.employee_no).join('、'),
|
||||
description: row.description,
|
||||
material_ids: row.material_ids,
|
||||
tags: row.tags,
|
||||
status: row.status,
|
||||
teach_time: teachTimeOf(editForm.value),
|
||||
planned_time: row.planned_time || '',
|
||||
// 其余需求确认同步字段原样透传(详情表单不编辑,防止保存时被零值覆盖丢失)
|
||||
train_type: row.train_type || '',
|
||||
plant: row.plant || '',
|
||||
location: row.location || '',
|
||||
session_count: row.session_count || 0,
|
||||
// 000161 讲师计划侧可改:名册 id 或外部讲师姓名
|
||||
lecturer_external: lecturer.external,
|
||||
remark: row.remark || '',
|
||||
// 课程管理关联(000161 可切换;切换后类型/形式随新课程带出)
|
||||
library_course_id: editForm.value.library_course_id || row.library_course_id || '',
|
||||
})
|
||||
}
|
||||
|
||||
const onSaveDetail = async () => {
|
||||
const row = activeCourse.value
|
||||
if (!row) return
|
||||
// 讲师随课程管理锁定:缺失时提示去课程管理维护(发布时后端也会强制校验)
|
||||
if (row.mode === 'offline' && !editForm.value.lecturer_id) {
|
||||
MessagePlugin.warning('当前课程未指定讲师,请先前往「课程管理」维护讲师')
|
||||
// 线下计划须指定讲师(名册 id 或外部姓名;发布时后端也会强制校验)
|
||||
const lecturer = resolveDetailLecturer(row)
|
||||
if (editForm.value.mode === 'offline' && !lecturer.lecturerId && !lecturer.external) {
|
||||
MessagePlugin.warning('线下计划需先指定讲师(从名册选择或输入外部讲师姓名)')
|
||||
return
|
||||
}
|
||||
detailSaving.value = true
|
||||
@@ -1388,7 +1432,7 @@ const onSaveDetail = async () => {
|
||||
await saveCourse(detailSavePayload(row))
|
||||
const sessionOpts = {
|
||||
mode: editForm.value.mode,
|
||||
lecturerId: editForm.value.lecturer_id || undefined,
|
||||
lecturerId: lecturer.lecturerId || undefined,
|
||||
startAt: editForm.value.start_at,
|
||||
location: editForm.value.location,
|
||||
hours: editForm.value.hours,
|
||||
@@ -1402,7 +1446,7 @@ const onSaveDetail = async () => {
|
||||
end_at: editForm.value.start_at ? new Date(new Date(editForm.value.start_at).getTime() + editForm.value.hours * 3600 * 1000).toISOString() : '',
|
||||
location: editForm.value.location,
|
||||
capacity: existing?.capacity ?? 0,
|
||||
lecturer_id: editForm.value.lecturer_id || undefined,
|
||||
lecturer_id: lecturer.lecturerId || undefined,
|
||||
// [2026-11 推学员] 编辑排课时同步通知方式
|
||||
notify_mode: editForm.value.notify_mode,
|
||||
})
|
||||
@@ -1426,8 +1470,8 @@ const onSaveDetail = async () => {
|
||||
)
|
||||
sessionsVisible.value = false
|
||||
loadAll()
|
||||
} catch {
|
||||
MessagePlugin.error('保存失败,请稍后重试')
|
||||
} catch (e: any) {
|
||||
MessagePlugin.error(apiErrorMessage(e, '保存失败,请稍后重试'))
|
||||
} finally {
|
||||
detailSaving.value = false
|
||||
}
|
||||
|
||||
@@ -142,8 +142,12 @@
|
||||
<t-input v-model="form.name" placeholder="请输入课程名称" />
|
||||
</t-form-item>
|
||||
<t-form-item label="所属部门">
|
||||
<!-- 对应需求表「主办单位」:从组织架构部门选择(批量导入按部门名匹配) -->
|
||||
<t-select v-model="form.owner_dept_id" clearable filterable placeholder="从组织架构选择所属部门(选填)" style="width: 100%">
|
||||
<!-- 对应需求表「主办单位」:锁定为创建人(当前登录人)所属部门,不可修改
|
||||
(000160,服务端同口径强制;无部门档案时可手动选择) -->
|
||||
<t-select
|
||||
v-model="form.owner_dept_id" :disabled="Boolean(myDeptId)" :clearable="!myDeptId"
|
||||
filterable :placeholder="myDeptId ? '创建人所属部门(不可修改)' : '从组织架构选择所属部门(选填)'" style="width: 100%"
|
||||
>
|
||||
<t-option v-for="d in depts" :key="d.id" :value="d.id" :label="d.name" />
|
||||
</t-select>
|
||||
</t-form-item>
|
||||
@@ -151,8 +155,14 @@
|
||||
<t-textarea v-model="form.description" placeholder="课程内容简介(选填)" :autosize="{ minRows: 2 }" />
|
||||
</t-form-item>
|
||||
<t-form-item label="适合人员">
|
||||
<!-- 对应需求表「参加人员」:自由文本,如:财会人员 -->
|
||||
<t-input v-model="form.suitable_members" placeholder="适合参加的人员(选填),如:财会人员" />
|
||||
<!-- 000159 部门多选口径:归属部门(可多选)或「全部」(互斥);发布后
|
||||
培训中心按此展示给对应人员,存量自由文本值回显为选项 -->
|
||||
<t-select
|
||||
v-model="suitableList" clearable filterable multiple
|
||||
placeholder="选择部门(可多选),或选「全部」" style="width: 100%"
|
||||
>
|
||||
<t-option v-for="opt in suitableOptions" :key="opt" :value="opt" :label="opt" />
|
||||
</t-select>
|
||||
</t-form-item>
|
||||
<t-form-item label="分类">
|
||||
<!-- creatable:配置中心「课程分类」预设之外,可直接输入新分类并保存 -->
|
||||
@@ -468,7 +478,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
import { computed, onMounted, ref, watch } from 'vue'
|
||||
import { MessagePlugin } from 'tdesign-vue-next'
|
||||
import * as XLSX from 'xlsx'
|
||||
import { COURSE_LIBRARY_TEMPLATE_KEY, QUESTION_TEMPLATE_KEY, downloadTrainingTemplate } from '../trainingTemplates'
|
||||
@@ -525,6 +535,34 @@ const configCategories = ref<string[]>([])
|
||||
const myDeptId = ref('')
|
||||
// 本人用户 id:学员「与我相关」课程的编辑权限判断(创建人/讲师为本人)
|
||||
const myUserId = ref('')
|
||||
// 本人部门名(000160):「适合人员」默认值 = 创建人所属部门名;经 me 的
|
||||
// dept_name 联查字段直取,回退本地部门名册映射。
|
||||
const myDeptName = computed(() => {
|
||||
const fromMe = (meDeptName.value || '').trim()
|
||||
if (fromMe) return fromMe
|
||||
const hit = depts.value.find((d) => d.id === myDeptId.value)
|
||||
return hit?.name || ''
|
||||
})
|
||||
// /training/members/me 联查返回的部门名(handler 000160 起填充)
|
||||
const meDeptName = ref('')
|
||||
// 「适合人员」下拉选项(000160/000159 多选口径):全部 + 各部门名;存量自由文本值保留可选
|
||||
const suitableOptions = computed(() => {
|
||||
const opts = ['全部', ...depts.value.map((d) => d.name)]
|
||||
for (const v of splitSuitable(form.value.suitable_members)) {
|
||||
if (!opts.includes(v)) opts.push(v)
|
||||
}
|
||||
return opts
|
||||
})
|
||||
// 适合人员多选值(000159):form.suitable_members 存「、」join 后的落库串,
|
||||
// 选项交互走本数组;「全部」与具体部门互斥(勾全部清部门,勾部门移除全部)。
|
||||
const suitableList = ref<string[]>([])
|
||||
const splitSuitable = (v: string) =>
|
||||
(v || '').split(/[、,,;;]/).map((s) => s.trim()).filter(Boolean)
|
||||
watch(suitableList, (list, prev) => {
|
||||
if (list.includes('全部') && list.length > 1) {
|
||||
suitableList.value = (prev || []).includes('全部') ? list.filter((v) => v !== '全部') : ['全部']
|
||||
}
|
||||
})
|
||||
|
||||
// 核验/删除权限(000157):严格限「本部门课长/经理」——人事/空间管理员一律无
|
||||
// 跨部门核验/删除权(roles 已按权限组展开,经理经课长继承自动命中 supervisor)。
|
||||
@@ -618,6 +656,7 @@ const loadAll = async () => {
|
||||
const meBody = me && unwrap(me)
|
||||
myDeptId.value = meBody?.dept_id || ''
|
||||
myUserId.value = meBody?.user_id || ''
|
||||
meDeptName.value = meBody?.dept_name || ''
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
@@ -739,10 +778,11 @@ const openForm = (row?: TrainingLibraryCourse) => {
|
||||
id: row?.id || '',
|
||||
code: row?.code || '',
|
||||
name: row?.name || '',
|
||||
// 新增默认当前登录用户所在部门;编辑保持原部门
|
||||
// 新增默认当前登录用户所在部门(锁定不可改);编辑保持原部门
|
||||
owner_dept_id: row?.owner_dept_id || (row ? '' : myDeptId.value),
|
||||
description: row?.description || '',
|
||||
suitable_members: row?.suitable_members || '',
|
||||
// 适合人员(000160):新增默认创建人所属部门名,可改「全部」或其他部门
|
||||
suitable_members: row?.suitable_members || (row ? '' : myDeptName.value),
|
||||
category: row?.category || '',
|
||||
type: row?.type === 'elective' ? 'elective' : 'required',
|
||||
mode: row?.mode === 'online' ? 'online' : 'offline',
|
||||
@@ -752,6 +792,8 @@ const openForm = (row?: TrainingLibraryCourse) => {
|
||||
file_name: row?.file_name || '',
|
||||
clear_file: false,
|
||||
}
|
||||
// 适合人员多选回显(000159):落库串「、」join → 数组;新增默认本部门
|
||||
suitableList.value = splitSuitable(form.value.suitable_members)
|
||||
formVisible.value = true
|
||||
}
|
||||
|
||||
@@ -771,6 +813,8 @@ const onSave = async () => {
|
||||
saving.value = true
|
||||
try {
|
||||
const lecturer = resolveLecturer(form.value.lecturer.trim())
|
||||
// 适合人员多选 → 「、」join 落库(000159);「全部」与部门互斥由 watch 保证
|
||||
form.value.suitable_members = suitableList.value.join('、')
|
||||
const res = await saveCourseLibraryItem({
|
||||
id: form.value.id || undefined,
|
||||
name: form.value.name.trim(),
|
||||
|
||||
@@ -126,15 +126,24 @@
|
||||
:label="`${c.name}${c.category ? `(${c.category})` : ''}`"
|
||||
/>
|
||||
</t-select>
|
||||
<!-- 000158:提交时按名称精准匹配课程管理,未命中自动新增待核验课程 -->
|
||||
<div class="form-hint">提交时按名称精准匹配课程管理;未匹配到将自动新增该课程(待审核),经课长/经理签核后方可发布</div>
|
||||
</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="提交时按提报人所在部门自动获取" />
|
||||
<!-- 000158:所属部门必须为填报人本人部门,服务端强制按提报人部门落库 -->
|
||||
<t-input :value="deptDisplay" disabled placeholder="自动带出提报人所在部门(不可修改)" />
|
||||
</t-form-item>
|
||||
<t-form-item label="适合人员" name="post_scope">
|
||||
<t-input v-model="demandForm.post_scope" placeholder="可填写多个适合人员,用、或,分隔(选填)" />
|
||||
<!-- 000159 部门多选口径:归属部门(可多选)或「全部」(互斥),自动建档随需求带入课程 -->
|
||||
<t-select
|
||||
v-model="demandSuitableList" clearable filterable multiple
|
||||
placeholder="选择部门(可多选),或选「全部」(选填)" style="width: 100%"
|
||||
>
|
||||
<t-option v-for="opt in demandSuitableOptions" :key="opt" :value="opt" :label="opt" />
|
||||
</t-select>
|
||||
</t-form-item>
|
||||
<t-form-item label="计划培训月份" name="planned_month">
|
||||
<t-select
|
||||
@@ -197,7 +206,7 @@
|
||||
:autosize="{ minRows: 6 }"
|
||||
placeholder="或粘贴需求行:课程名称[,计划培训月份如 3] (支持中英文逗号)"
|
||||
/>
|
||||
<div class="form-hint">模板列对应:编号/部门/课程名称/适合人员/地点/内/外培训(下拉选择内部或外部)/计划培训月份(1~12,下拉选择)/讲师/备注;费用列已移除;备注右侧为「调研维度与培训策划要求」说明列,无需填写;适合人员可填多人(、/,分隔),讲师可填系统员工(按姓名自动匹配并带出部门)或外部讲师姓名;导入后统一为「待核验」,由部门经理核验确认。</div>
|
||||
<div class="form-hint">模板列对应:编号/部门/课程名称/适合人员/地点/内/外培训(下拉选择内部或外部)/计划培训月份(1~12,下拉选择)/讲师/备注;费用列已移除;备注右侧为「调研维度与培训策划要求」说明列,无需填写;适合人员可填多人(、/,分隔),讲师可填系统员工(按姓名自动匹配)或外部讲师姓名;部门列必须为导入人本人部门,留空默认本人部门,其余部门整批拒绝导入;课程按名称精准匹配课程管理,未匹配到自动新增该课程(待审核);导入后统一为「待核验」,由部门经理核验确认。</div>
|
||||
<template #footer>
|
||||
<t-button theme="primary" :loading="saving" @click="onImportDemands">导入粘贴内容</t-button>
|
||||
</template>
|
||||
@@ -235,7 +244,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
import { computed, onMounted, ref, watch } from 'vue'
|
||||
import { MessagePlugin } from 'tdesign-vue-next'
|
||||
import * as XLSX from 'xlsx'
|
||||
import { fmtBeijingTime } from '@/utils/datetime'
|
||||
@@ -332,13 +341,35 @@ const demandForm = ref({
|
||||
remark: '',
|
||||
})
|
||||
|
||||
// 适合人员多选值(000159 部门多选口径):form.post_scope 存「、」join 后的串,
|
||||
// 选项交互走本数组;「全部」与具体部门互斥。
|
||||
const demandSuitableList = ref<string[]>([])
|
||||
const splitSuitable = (v: string) =>
|
||||
(v || '').split(/[、,,;;]/).map((s) => s.trim()).filter(Boolean)
|
||||
watch(demandSuitableList, (list, prev) => {
|
||||
if (list.includes('全部') && list.length > 1) {
|
||||
demandSuitableList.value = (prev || []).includes('全部') ? list.filter((v) => v !== '全部') : ['全部']
|
||||
}
|
||||
})
|
||||
// 适合人员选项:全部 + 各部门名(存量自由文本值保留可选)
|
||||
const demandSuitableOptions = computed(() => {
|
||||
const opts = ['全部', ...depts.value.map((d) => d.name)]
|
||||
for (const v of splitSuitable(demandForm.value.post_scope)) {
|
||||
if (!opts.includes(v)) opts.push(v)
|
||||
}
|
||||
return opts
|
||||
})
|
||||
|
||||
// 选定课程自动带出(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
|
||||
if (course.suitable_members) {
|
||||
demandForm.value.post_scope = course.suitable_members
|
||||
demandSuitableList.value = splitSuitable(course.suitable_members)
|
||||
}
|
||||
const lecturerValue = course.lecturer_id || course.lecturer_external || ''
|
||||
if (lecturerValue) {
|
||||
if (!lecturers.value.some((l) => l.id === lecturerValue)) {
|
||||
@@ -552,6 +583,7 @@ const onOpenDemandForm = () => {
|
||||
lecturer: '',
|
||||
remark: '',
|
||||
}
|
||||
demandSuitableList.value = []
|
||||
demandFormVisible.value = true
|
||||
}
|
||||
|
||||
@@ -588,6 +620,8 @@ const onEditDemand = (row: TrainingDemand) => {
|
||||
lecturer: lecturerValue,
|
||||
remark: row.remark || '',
|
||||
}
|
||||
// 适合人员多选回显(000159):落库串「、」join → 数组
|
||||
demandSuitableList.value = splitSuitable(demandForm.value.post_scope)
|
||||
demandFormVisible.value = true
|
||||
}
|
||||
|
||||
@@ -599,10 +633,14 @@ const onSaveDemand = async () => {
|
||||
saving.value = true
|
||||
try {
|
||||
// 计划培训月份与收集年度合成「YYYY-M」入库,并回填期望月份;
|
||||
// 编辑旧数据且未选月份时保留原计划培训值;讲师解析为 id 或外部姓名
|
||||
// 编辑旧数据且未选月份时保留原计划培训值;讲师解析为 id 或外部姓名;
|
||||
// 适合人员多选 → 「、」join 落库(000159)
|
||||
const { lecturer, planned_month, ...rest } = demandForm.value
|
||||
rest.post_scope = demandSuitableList.value.join('、')
|
||||
const month = Number(planned_month) || 0
|
||||
const isEdit = Boolean(demandForm.value.id)
|
||||
// 课程管理中是否已有同名课程(000158:无则提交时自动新增待核验课程)
|
||||
const courseExisted = libraryCourses.value.some((c) => c.name === demandForm.value.course_name)
|
||||
await saveDemand({
|
||||
...rest,
|
||||
...resolveLecturer(lecturer),
|
||||
@@ -612,7 +650,13 @@ const onSaveDemand = async () => {
|
||||
expect_month: month || (isEdit ? editOriginalPlanned.value.expect_month : 0) || undefined,
|
||||
year: selectedYear.value,
|
||||
})
|
||||
MessagePlugin.success(demandForm.value.id ? '需求已更新' : '需求已提交,待核验')
|
||||
MessagePlugin.success(
|
||||
demandForm.value.id
|
||||
? '需求已更新'
|
||||
: courseExisted
|
||||
? '需求已提交,待核验'
|
||||
: `需求已提交,待核验;课程《${demandForm.value.course_name}》已自动新增到课程管理(待审核)`,
|
||||
)
|
||||
demandFormVisible.value = false
|
||||
loadAll()
|
||||
} catch (e: any) {
|
||||
@@ -668,8 +712,9 @@ const onImportDemands = async () => {
|
||||
importDemandsVisible.value = false
|
||||
importDemandsText.value = ''
|
||||
loadAll()
|
||||
} catch {
|
||||
MessagePlugin.error('导入失败,请检查格式')
|
||||
} catch (e: any) {
|
||||
// 透出后端校验详情(000158:部门归属/课程自动匹配等口径错误)
|
||||
MessagePlugin.error(apiErrorMessage(e, '导入失败,请检查格式'))
|
||||
} finally {
|
||||
saving.value = false
|
||||
}
|
||||
@@ -747,7 +792,8 @@ const onImportDemandExcel = async (e: Event) => {
|
||||
let skippedRows = 0
|
||||
let lecturerHits = 0
|
||||
let externalLecturers = 0
|
||||
let deptFromLecturer = 0
|
||||
// 部门口径(000158):Excel 全部行必须为导入人本人部门,前端预检不过不提交
|
||||
const deptViolations: string[] = []
|
||||
// 讲师按**全部在职员工**姓名匹配(不限于讲师名册;名单即 openCollect 的员工档案),
|
||||
// 匹配不到的姓名作为外部讲师落 lecturer_external,列表讲师列照常显示
|
||||
const ensureMembers = async () => {
|
||||
@@ -763,24 +809,23 @@ const onImportDemandExcel = async (e: Event) => {
|
||||
}
|
||||
}
|
||||
await ensureMembers()
|
||||
dataRows.forEach((row) => {
|
||||
dataRows.forEach((row, idx) => {
|
||||
const courseName = (row['课程名称'] || '').trim()
|
||||
if (!courseName) {
|
||||
skippedRows += 1
|
||||
return
|
||||
}
|
||||
// 部门单位(收集模板)/主办单位(旧版)/部门(需求表模板)按部门名册匹配;未匹配留空
|
||||
// 部门单位(收集模板)/主办单位(旧版)/部门(需求表模板)按部门名册匹配;
|
||||
// 000158:行部门必须为导入人本人部门——非空但未匹配到、或与本人部门
|
||||
// 不一致即记违规,整批拒绝;部门列留空的行由后端默认导入人部门。
|
||||
let deptId = ''
|
||||
let deptMatched = false
|
||||
const deptName = (row['部门单位'] || row['主办单位'] || row['部门'] || '').trim()
|
||||
if (deptName) {
|
||||
const hit = depts.value.find((d) => d.name === deptName) || depts.value.find((d) => deptName.includes(d.name))
|
||||
if (hit) {
|
||||
deptId = hit.id
|
||||
deptMatched = true
|
||||
}
|
||||
if (hit) deptId = hit.id
|
||||
if (!deptId || deptId !== myDeptId.value) deptViolations.push(`第${idx + 1}行(${deptName})`)
|
||||
}
|
||||
// 讲师:员工档案姓名精确匹配→关联并在列表带出姓名,行内部门未匹配时带出讲师部门;
|
||||
// 讲师:员工档案姓名精确匹配→关联并在列表带出姓名;
|
||||
// 非系统员工→落外部讲师姓名,讲师列照常显示
|
||||
let lecturerId = ''
|
||||
let lecturerExternal = ''
|
||||
@@ -790,10 +835,6 @@ const onImportDemandExcel = async (e: Event) => {
|
||||
if (hit && hit.user_id) {
|
||||
lecturerId = hit.user_id
|
||||
lecturerHits += 1
|
||||
if (!deptMatched && hit.dept_id) {
|
||||
deptId = hit.dept_id
|
||||
deptFromLecturer += 1
|
||||
}
|
||||
} else {
|
||||
lecturerExternal = lecturerName
|
||||
externalLecturers += 1
|
||||
@@ -813,6 +854,7 @@ const onImportDemandExcel = async (e: Event) => {
|
||||
lecturer_id: lecturerId,
|
||||
lecturer_external: lecturerExternal || undefined,
|
||||
dept_id: deptId,
|
||||
dept_name: deptName || undefined,
|
||||
planned_time: plannedMonth.planned || undefined,
|
||||
expect_month: plannedMonth.month || undefined,
|
||||
remark: (row['备注'] || '').trim(),
|
||||
@@ -822,24 +864,36 @@ const onImportDemandExcel = async (e: Event) => {
|
||||
MessagePlugin.warning('模板中没有可导入的课程行,请先填写课程名称')
|
||||
return
|
||||
}
|
||||
// 000158:存在非本人部门的行时整批拒绝(后端同口径兜底校验)
|
||||
if (deptViolations.length) {
|
||||
MessagePlugin.error(
|
||||
`导入失败:${deptViolations.join('、')}部门与您所在部门(${myDeptName.value || '未知'})不一致,仅可导入本人部门的需求表`,
|
||||
)
|
||||
return
|
||||
}
|
||||
saving.value = true
|
||||
try {
|
||||
const imported = unwrap(await importDemands(items)) as { imported: number; notified?: number } | null
|
||||
const imported = unwrap(await importDemands(items)) as {
|
||||
imported: number
|
||||
notified?: number
|
||||
courses_created?: number
|
||||
} | null
|
||||
MessagePlugin.success(
|
||||
`已从模板导入 ${items.length} 条需求(${titleYear}年度)` +
|
||||
(lecturerHits || externalLecturers
|
||||
? `,讲师匹配 ${lecturerHits} 人${externalLecturers ? `,外部讲师 ${externalLecturers} 人` : ''}`
|
||||
: '') +
|
||||
(deptFromLecturer ? `(其中 ${deptFromLecturer} 条部门按讲师带出)` : '') +
|
||||
(skippedRows ? `,另有 ${skippedRows} 行未填课程名称已跳过` : '') +
|
||||
(imported?.courses_created ? `,自动新增待审核课程 ${imported.courses_created} 门` : '') +
|
||||
(imported?.notified ? `,已推送 ${imported.notified} 位部门经理核验` : ''),
|
||||
)
|
||||
importDemandsVisible.value = false
|
||||
// 导入年份与当前查看年份不同(模板为下一年度)时切到导入年份展示
|
||||
if (titleYear !== selectedYear.value) selectedYear.value = titleYear
|
||||
loadAll()
|
||||
} catch {
|
||||
MessagePlugin.error('导入失败,请稍后重试')
|
||||
} catch (e: any) {
|
||||
// 透出后端校验详情(000158:部门归属/课程自动匹配等口径错误)
|
||||
MessagePlugin.error(apiErrorMessage(e, '导入失败,请稍后重试'))
|
||||
} finally {
|
||||
saving.value = false
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user