fix(培训签到):签到明细列口径调整——学员列显示「姓名 工号」、签到时间显示北京时间时分秒(新增 fmtBeijingTimeSec)、方式列显示中文(企微扫码/代扫码补录);代扫码补录学员下拉同步显示姓名
deploy-hxtesting / build-and-deploy (push) Successful in 1m5s

This commit is contained in:
runny committed 2026-11-25 16:10:23 +08:00
1 parent eb09f8235b
commit 9e00af1905
2 files changed
+35 -8

No files matched your search

+19
View File
@@ -17,6 +17,17 @@ const BEIJING_CLOCK = new Intl.DateTimeFormat('zh-CN', {
hour12: false,
})
const BEIJING_DATETIME_SEC = new Intl.DateTimeFormat('zh-CN', {
timeZone: 'Asia/Shanghai',
year: 'numeric',
month: '2-digit',
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
second: '2-digit',
hour12: false,
})
/** fmtBeijingTime 任意时间戳 → 北京时间「YYYY/MM/DD HH:mm」(无秒);空/非法输入返回空串。 */
export function fmtBeijingTime(raw: string | number | Date | null | undefined): string {
if (raw === null || raw === undefined || raw === '') return ''
@@ -32,3 +43,11 @@ export function fmtBeijingClock(raw: string | number | Date | null | undefined):
if (Number.isNaN(date.getTime())) return ''
return BEIJING_CLOCK.format(date)
}
/** fmtBeijingTimeSec 北京时间「YYYY/MM/DD HH:mm:ss」(带秒;签到明细等需秒级精度的场景)。 */
export function fmtBeijingTimeSec(raw: string | number | Date | null | undefined): string {
if (raw === null || raw === undefined || raw === '') return ''
const date = raw instanceof Date ? raw : new Date(raw)
if (Number.isNaN(date.getTime())) return ''
return BEIJING_DATETIME_SEC.format(date)
}
@@ -114,6 +114,8 @@
</div>
<t-table :data="pagedRecords" :columns="recordColumns" row-key="id" size="small" :loading="loading">
<template #member="{ row }">{{ memberLabel(row.member_id) }}</template>
<template #signed_at="{ row }">{{ fmtRecordTime(row.signed_at) }}</template>
<template #channel="{ row }">{{ channelText(row.channel) }}</template>
<template #status="{ row }">
<t-tag :theme="statusTheme(row.status)" variant="light" size="small">{{ statusText(row.status) }}</t-tag>
<t-tag v-for="f in row.abnormal_flags || []" :key="f" theme="danger" variant="outline" size="small" class="flag-tag">{{ flagText(f) }}</t-tag>
@@ -200,7 +202,7 @@ import {
type TrainingSignRecord,
unwrap,
} from '@/api/training'
import { fmtBeijingTime } from '@/utils/datetime'
import { fmtBeijingTime, fmtBeijingTimeSec } from '@/utils/datetime'
import TrainingPagination from './TrainingPagination.vue'
import { useTrainingPager } from './useTrainingPager'
@@ -261,6 +263,12 @@ const statusTheme = (s: string) => ({
normal: 'success', late: 'warning', abnormal: 'danger', outside: 'danger', duplicate: 'danger', missing: 'default',
}[s] || 'default')
// 签到明细列展示口径(000165):
// 签到时间 → 北京时间「YYYY/MM/DD HH:mm:ss」(带秒)
// 方式 → 中文(企微扫码/代扫码补录),未知值回退原文
const fmtRecordTime = (raw: string | null) => fmtBeijingTimeSec(raw) || '—'
const channelText = (c: string) => ({ wecom_scan: '企微扫码', proxy: '代扫码/补录' }[c] || c)
// 签到二维码:内容为学员扫码签到页链接(携带 token),本地生成不依赖外网服务;
// 签到码刷新/切换场次后自动重绘。
const signQrUrl = ref('')
@@ -360,11 +368,12 @@ const proxyVisible = ref(false)
const proxyMemberId = ref('')
const proxyLoading = ref(false)
// 学员展示口径(000165):「姓名 工号」;未入名册时回退 member_id 前缀
const memberLabel = (memberId: string) => memberLabels.value[memberId] || memberId
const memberLabelText = (m: TrainingMember) => {
const role = (m.post || '').trim()
return `${m.employee_no || '-'} ${role ? ` · ${role}` : ''}`
}
const memberLabelText = (m: TrainingMember) =>
[m.user_name || m.employee_no || '-', m.employee_no && m.user_name ? m.employee_no : '']
.filter(Boolean)
.join(' ')
const loadAll = async () => {
loading.value = true
@@ -380,10 +389,9 @@ const loadAll = async () => {
if (memberItems.length) {
members.value = memberItems
const labels: Record<string, string> = {}
const deptNames: Record<string, string> = {}
for (const mem of members.value) {
labels[mem.id] = `${mem.employee_no || '-'} ${mem.post || ''}`.trim() || mem.id.slice(0, 8)
if (mem.dept_id) deptNames[mem.dept_id] = deptNames[mem.dept_id] || ''
// 签到明细学员列(000165):「姓名 工号」,无姓名时回退工号
labels[mem.id] = [mem.user_name || '', mem.employee_no || ''].filter(Boolean).join(' ') || mem.id.slice(0, 8)
}
memberLabels.value = labels
}