刘光辉
4 小时以前 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
import { defHttp } from '#/api/request';
 
const prefix = '/api/tms/train-stats';
 
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 interface TrainStatsQuery {
  startTimeFrom?: string;
  startTimeTo?: string;
  deptId?: string;
  category?: string;
  evalMode?: string;
  groupBy?: 'dept' | 'category' | 'evalMode' | string;
  /** 明细下钻维度编码 */
  dimCode?: string;
}
 
export interface TrainStatsRow {
  dimCode?: string;
  dimName?: string;
  sessionCount?: number;
  personCount?: number;
  signedCount?: number;
  passedCount?: number;
  signRate?: number;
  passRate?: number;
}
 
export interface TrainStatsDetailRow {
  recordId?: string;
  recordNo?: string;
  subject?: string;
  category?: string;
  evalMode?: string;
  startTime?: string;
  endTime?: string;
  personCount?: number;
  signedCount?: number;
  passedCount?: number;
  signRate?: number;
  passRate?: number;
}
 
export function getTrainStatsList(params: TrainStatsQuery) {
  return unwrapData<TrainStatsRow[]>(defHttp.get({ url: `${prefix}/list`, params }));
}
 
export function getTrainStatsDetail(params: TrainStatsQuery) {
  return unwrapData<TrainStatsDetailRow[]>(defHttp.get({ url: `${prefix}/detail`, params }));
}
 
export function exportTrainStats(data: TrainStatsQuery) {
  return defHttp.post(
    {
      url: `${prefix}/export`,
      data,
      responseType: 'blob',
    },
    {
      isReturnNativeResponse: true,
      isTransformResponse: false,
    },
  );
}