|
|
@@ -170,13 +170,31 @@ async function loadDetail() {
|
|
|
...data,
|
|
|
punchLocation: raw.punchLocation || raw.location || ''
|
|
|
}
|
|
|
- items.value = (data.items || []).map((it) => ({
|
|
|
- ...it,
|
|
|
- needPhoto: it.needPhoto === '1' || it.needPhoto === true,
|
|
|
- result: undefined,
|
|
|
- reason: '',
|
|
|
- photos: []
|
|
|
- }))
|
|
|
+ items.value = (data.items || []).map((it) => {
|
|
|
+ const base: any = {
|
|
|
+ ...it,
|
|
|
+ needPhoto: it.needPhoto === '1' || it.needPhoto === true
|
|
|
+ }
|
|
|
+ if (readonly.value) {
|
|
|
+ // readonly 模式:保留后端返回的已打卡数据
|
|
|
+ // - checkResult: '0' 正常 / '1' 异常 → 映射成 NORMAL/ABNORMAL 给模板用
|
|
|
+ // - photos: 后端 record_item.photos(逗号分隔,可能为空)
|
|
|
+ // - problemCount / remark: 透传
|
|
|
+ base.result =
|
|
|
+ (it as any).checkResult === '0' ? 'NORMAL'
|
|
|
+ : (it as any).checkResult === '1' ? 'ABNORMAL'
|
|
|
+ : undefined
|
|
|
+ base.reason = (it as any).remark || ''
|
|
|
+ const photos = (it as any).photos as string | undefined
|
|
|
+ base.photos = photos ? photos.split(',').filter(Boolean) : []
|
|
|
+ } else {
|
|
|
+ // 编辑模式:清空用户态字段,让用户重新填
|
|
|
+ base.result = undefined
|
|
|
+ base.reason = ''
|
|
|
+ base.photos = []
|
|
|
+ }
|
|
|
+ return base
|
|
|
+ })
|
|
|
}
|
|
|
} catch (e: any) {
|
|
|
// 接口失败:清空数据 + 错误提示(不再使用假数据)
|