liuyu
2 小时以前 82a74ba0402ab546ba524d23ce62198c4d00d2f7
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
import type {
  TrainRecordCatalogDetail,
  TrainRecordCatalogItem,
  TrainRecordCatalogQuery,
  TrainRecordListItem,
  TrainRecordPageQuery,
} from './types';
 
function delay<T>(data: T, ms = 220): Promise<T> {
  return new Promise((resolve) => setTimeout(() => resolve(data), ms));
}
 
const listStore: TrainRecordListItem[] = [
  {
    id: 'tr1',
    archiveNo: 'AR20180184',
    postDate: '2018-12-24',
    userName: 'mkj',
    deptName: '测试组',
    postName: '',
    partPostName: '',
    major: '',
    education: '',
    techTitle: '',
    hireDate: '',
    leaveDate: '',
  },
  {
    id: 'tr2',
    archiveNo: 'AR20190522',
    postDate: '2019-05-22',
    userName: '张三',
    deptName: '质量管理部',
    postName: 'QA专员',
    partPostName: '',
    major: '药学',
    education: '本科',
    techTitle: '工程师',
    hireDate: '2019-05-22',
    leaveDate: '',
  },
  {
    id: 'tr3',
    archiveNo: 'AR20200311',
    postDate: '2020-03-11',
    userName: '李四',
    deptName: '分析实验室',
    postName: '分析员',
    partPostName: '安全员',
    major: '化学',
    education: '硕士',
    techTitle: '助理工程师',
    hireDate: '2020-03-11',
    leaveDate: '',
  },
];
 
const catalogStore: Record<string, TrainRecordCatalogItem[]> = {
  tr1: [
    {
      id: 'c1',
      recordNo: 'TT2019040134',
      trainType: '临时培训',
      trainContent: '测试在线考试0415',
      trainMode: '在线学习',
      trainerName: 'mkj',
      evalMode: '在线考试',
      trainResult: 0,
      passFlag: '0',
      trainDate: '2019-04-15',
    },
    {
      id: 'c2',
      recordNo: 'TT2019040135',
      trainType: '临时培训',
      trainContent: 'test001',
      trainMode: '在线学习',
      trainerName: 'LIMS系统管理员',
      evalMode: '在线考试',
      trainResult: 80,
      passFlag: '1',
      trainDate: '2019-04-15',
    },
    {
      id: 'c3',
      recordNo: 'TT2018120019',
      trainType: '临时培训',
      trainContent: '发布任务测试',
      trainMode: '在线学习',
      trainerName: 'mkj',
      evalMode: '无需考核',
      trainResult: '',
      passFlag: '1',
      trainDate: '2018-12-26',
    },
    {
      id: 'c4',
      recordNo: 'TT2019010101',
      trainType: '临时培训',
      trainContent: '熟悉玻思韬',
      trainMode: '在线学习',
      trainerName: '王代丰',
      evalMode: '无需考核',
      trainResult: '',
      passFlag: '1',
      trainDate: '2019-01-18',
    },
    {
      id: 'c5',
      recordNo: 'TT2019060208',
      trainType: '临时培训',
      trainContent: 'BLS0004 物料发放规范 02版',
      trainMode: '集中授课',
      trainerName: '梁兆丰',
      evalMode: '在线考试',
      trainResult: 80,
      passFlag: '1',
      trainDate: '2019-06-20',
    },
    {
      id: 'c6',
      recordNo: 'TT2026090101',
      trainType: '年度培训',
      trainContent: '2026-药物警戒年度培训',
      trainMode: '在线学习',
      trainerName: '潘志通',
      evalMode: '在线考试',
      trainResult: 86,
      passFlag: '1',
      trainDate: '2026-09-01',
    },
  ],
  tr2: [
    {
      id: 'c7',
      recordNo: 'TT2025120575',
      trainType: '临时培训',
      trainContent: '再确认测试',
      trainMode: '课堂教学',
      trainerName: 'mkj',
      evalMode: '在线考试',
      trainResult: 100,
      passFlag: '1',
      trainDate: '2025-12-22',
    },
  ],
  tr3: [
    {
      id: 'c8',
      recordNo: 'TT2026060155',
      trainType: '年度培训',
      trainContent: 'GMP基础知识培训',
      trainMode: '集中授课',
      trainerName: '王代丰',
      evalMode: '在线考试',
      trainResult: 72,
      passFlag: '0',
      trainDate: '2026-06-15',
    },
  ],
};
 
export function mockQueryTrainRecords(params: TrainRecordPageQuery) {
  let list = [...listStore];
  if (params.archiveNo && params.archiveNo !== 'null') {
    const kw = params.archiveNo.trim().toLowerCase();
    list = list.filter((x) => x.archiveNo.toLowerCase().includes(kw));
  }
  if (params.keyword && params.keyword !== 'null') {
    const kw = params.keyword.trim().toLowerCase();
    list = list.filter(
      (x) =>
        (x.userName || '').toLowerCase().includes(kw) ||
        (x.deptName || '').toLowerCase().includes(kw) ||
        (x.archiveNo || '').toLowerCase().includes(kw),
    );
  }
  const currentPage = Number(params.currentPage || 1);
  const pageSize = Number(params.pageSize || 20);
  const start = (currentPage - 1) * pageSize;
  return delay({
    list: list.slice(start, start + pageSize),
    pagination: { total: list.length, currentPage, pageSize },
  });
}
 
export function mockGetTrainRecordCatalog(query: TrainRecordCatalogQuery): Promise<TrainRecordCatalogDetail> {
  const person = listStore.find((x) => x.id === query.recordId);
  if (!person) return Promise.reject(new Error('培训记录不存在'));
  let list = [...(catalogStore[query.recordId] || [])];
  if (query.startDate) {
    list = list.filter((x) => !x.trainDate || x.trainDate >= query.startDate!);
  }
  if (query.endDate) {
    list = list.filter((x) => !x.trainDate || x.trainDate <= query.endDate!);
  }
  return delay({
    id: person.id,
    userName: person.userName,
    archiveNo: person.archiveNo,
    list,
  });
}