刘光辉
119 分钟以前 cf11e63b659afcc9792ab3e395f1b45d844431a8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
import type {
  TmsRecordDetail,
  TmsRecordIncomplete,
  TmsRecordPageQuery,
  TmsRecordProgress,
  TmsRecordSignQr,
} from '#/views/x/tms/record/types';
 
import { defHttp } from '#/api/request';
 
/** 正式路径:/api/tms/record/** */
const prefix = '/api/tms/record';
 
async function unwrapData<T>(promise: Promise<any>): Promise<T> {
  const res = await promise;
  if (res && typeof res === 'object' && 'data' in res && ('code' in res || 'msg' in res)) {
    return res.data as T;
  }
  return res as T;
}
 
export function getTmsRecordList(params: TmsRecordPageQuery) {
  return unwrapData<{ list: any[]; pagination: Record<string, any> }>(
    defHttp.get({ url: `${prefix}/list`, params }),
  );
}
 
export function getTmsRecordDetail(id: string) {
  return unwrapData<TmsRecordDetail>(defHttp.get({ url: `${prefix}/${id}` }));
}
 
/** 实时参与进度 */
export function getTmsRecordProgress(id: string) {
  return unwrapData<TmsRecordProgress>(defHttp.get({ url: `${prefix}/${id}/progress` }));
}
 
/** 未完成人员清单(按部门排序) */
export function getTmsRecordIncomplete(id: string) {
  return unwrapData<TmsRecordIncomplete[]>(defHttp.get({ url: `${prefix}/${id}/incomplete` }));
}
 
/** 应提问人数 */
export function getTmsRecordQuizCount(id: string) {
  return unwrapData<number>(defHttp.get({ url: `${prefix}/${id}/quiz-count` }));
}
 
/** 查看学员提问答卷 */
export function getTmsRecordQuizAnswers(id: string, userId: string) {
  return unwrapData<{
    recordId?: string;
    taskId?: string;
    userId?: string;
    userName?: string;
    totalScore?: number;
    passFlag?: string;
    quizTime?: string;
    items?: Array<{
      id?: string;
      sortNo?: number;
      question?: string;
      userAnswer?: string;
      refAnswer?: string;
      score?: number;
      correct?: boolean;
    }>;
  }>(defHttp.get({ url: `${prefix}/${id}/quiz-answers`, params: { userId } }));
}
 
export function getTmsRecordSignQr(id: string) {
  return unwrapData<TmsRecordSignQr>(defHttp.get({ url: `${prefix}/${id}/sign-qr` }));
}
 
/** 扫码签到落库 */
export function scanSignTmsRecord(data: { qrContent: string; signMode?: string }) {
  return unwrapData<{
    signTime?: string;
    bizStatus?: string;
    signed?: boolean;
    message?: string;
    canExam?: boolean;
    examTip?: string;
    needQuiz?: boolean;
    quizQuestions?: Array<{ id?: string; sortNo?: number; question?: string }>;
    personTaskId?: string;
  }>(defHttp.post({ url: `${prefix}/scan-sign`, data }));
}
 
export function updateTmsRecord(id: string, data: Record<string, any>) {
  return unwrapData(defHttp.put({ url: `${prefix}/${id}`, data }));
}
 
export function archiveTmsRecords(ids: string[]) {
  return unwrapData<number>(defHttp.post({ url: `${prefix}/archive`, data: { ids } }));
}
 
export function markReadyByCloseTime() {
  return unwrapData<number>(defHttp.post({ url: `${prefix}/mark-ready-by-close` }));
}
 
/** 待归档 → 可归档 */
export function promoteTmsRecordsToReady(ids: string[]) {
  return unwrapData<number>(defHttp.post({ url: `${prefix}/promote-ready`, data: { ids } }));
}
 
/** 可归档 → 待归档(临时联调) */
export function restoreTmsRecordsToPending(ids: string[]) {
  return unwrapData<number>(defHttp.post({ url: `${prefix}/restore-pending`, data: { ids } }));
}
 
/** 无人完成作废 → invalid */
export function markInvalidTmsRecords(ids: string[]) {
  return unwrapData<number>(defHttp.post({ url: `${prefix}/mark-invalid`, data: { ids } }));
}
 
export function deleteTmsRecords(ids: string[]) {
  return unwrapData(defHttp.delete({ url: `${prefix}`, data: { ids } }));
}