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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
| // 模拟死亡判定数据
| const mockDeathJudgmentData = [
| {
| id: 1,
| hospitalNo: "D202512001",
| donorName: "张三",
| gender: "0",
| age: 45,
| diagnosis: "脑外伤",
| deathReason: "brain_death",
| deathTime: "2025-12-01 14:30:00",
| judgmentDoctor: "王医生",
| judgmentDescription: "经过多次脑死亡判定,符合脑死亡临床诊断标准",
| registrant: "李协调员",
| registrationTime: "2025-12-01 15:00:00",
| createTime: "2025-12-01 10:00:00"
| },
| {
| id: 2,
| hospitalNo: "D202512002",
| donorName: "李四",
| gender: "1",
| age: 38,
| diagnosis: "心脏骤停",
| deathReason: "heart_death",
| deathTime: "2025-12-02 09:15:00",
| judgmentDoctor: "刘医生",
| judgmentDescription: "心死亡判定,心电图呈直线,无自主呼吸",
| registrant: "张协调员",
| registrationTime: "2025-12-02 10:00:00",
| createTime: "2025-12-02 08:30:00"
| },
| {
| id: 3,
| hospitalNo: "D202512003",
| donorName: "王五",
| gender: "0",
| age: 52,
| diagnosis: "脑梗死",
| deathReason: "brain_death",
| deathTime: "2025-12-03 16:45:00",
| judgmentDoctor: "陈医生",
| judgmentDescription: "脑干功能完全丧失,符合脑死亡标准",
| registrant: "赵协调员",
| registrationTime: "2025-12-03 17:20:00",
| createTime: "2025-12-03 14:00:00"
| },
| {
| id: 4,
| hospitalNo: "D202512004",
| donorName: "赵六",
| gender: "1",
| age: 29,
| diagnosis: "多发伤",
| deathReason: "other",
| deathTime: "2025-12-04 11:20:00",
| judgmentDoctor: "孙医生",
| judgmentDescription: "创伤性休克导致多器官功能衰竭",
| registrant: "钱协调员",
| registrationTime: "2025-12-04 12:00:00",
| createTime: "2025-12-04 09:45:00"
| },
| {
| id: 5,
| hospitalNo: "D202512005",
| donorName: "孙七",
| gender: "0",
| age: 61,
| diagnosis: "脑肿瘤",
| deathReason: "brain_death",
| deathTime: "2025-12-05 13:10:00",
| judgmentDoctor: "周医生",
| judgmentDescription: "颅内压增高导致脑疝形成",
| registrant: "吴协调员",
| registrationTime: "2025-12-05 13:45:00",
| createTime: "2025-12-05 10:30:00"
| }
| ];
|
| // 模拟附件数据
| const mockAttachmentData = [
| {
| id: 1,
| judgmentId: 1,
| type: "1",
| typeName: "脑死亡判定表",
| fileName: "脑死亡判定表_202512001.pdf",
| fileSize: 2548321,
| uploadTime: "2025-12-01 14:35:00",
| uploader: "王医生",
| fileUrl: "/attachments/brain_death_1.pdf"
| },
| {
| id: 2,
| judgmentId: 1,
| type: "2",
| typeName: "脑电图评估表",
| fileName: "脑电图评估表_202512001.docx",
| fileSize: 512345,
| uploadTime: "2025-12-01 15:20:00",
| uploader: "李医生",
| fileUrl: "/attachments/eeg_1.docx"
| },
| {
| id: 3,
| judgmentId: 2,
| type: "7",
| typeName: "心死亡判定表",
| fileName: "心死亡判定表_202512002.pdf",
| fileSize: 1892345,
| uploadTime: "2025-12-02 09:30:00",
| uploader: "刘医生",
| fileUrl: "/attachments/heart_death_2.pdf"
| },
| {
| id: 4,
| judgmentId: 3,
| type: "1",
| typeName: "脑死亡判定表",
| fileName: "脑死亡判定表_202512003.pdf",
| fileSize: 3124567,
| uploadTime: "2025-12-03 17:00:00",
| uploader: "陈医生",
| fileUrl: "/attachments/brain_death_3.pdf"
| },
| {
| id: 5,
| judgmentId: 3,
| type: "4",
| typeName: "经颅多普勒超声评估记录",
| fileName: "经颅多普勒_202512003.xlsx",
| fileSize: 845672,
| uploadTime: "2025-12-03 17:15:00",
| uploader: "张技师",
| fileUrl: "/attachments/tcd_3.xlsx"
| }
| ];
|
| // 模拟API响应延迟
| const delay = (ms = 500) => new Promise(resolve => setTimeout(resolve, ms));
|
| // 查询死亡判定列表
| export const listDeathJudgment = async (queryParams = {}) => {
| await delay();
|
| const {
| pageNum = 1,
| pageSize = 10,
| hospitalNo,
| donorName,
| deathReason,
| deathTimeRange = []
| } = queryParams;
|
| // 过滤数据
| let filteredData = mockDeathJudgmentData.filter(item => {
| let match = true;
|
| if (hospitalNo && !item.hospitalNo.includes(hospitalNo)) {
| match = false;
| }
|
| if (donorName && !item.donorName.includes(donorName)) {
| match = false;
| }
|
| if (deathReason && item.deathReason !== deathReason) {
| match = false;
| }
|
| if (deathTimeRange.length === 2) {
| const deathTime = new Date(item.deathTime);
| const startTime = new Date(deathTimeRange[0]);
| const endTime = new Date(deathTimeRange[1]);
| endTime.setDate(endTime.getDate() + 1);
|
| if (deathTime < startTime || deathTime >= endTime) {
| match = false;
| }
| }
|
| return match;
| });
|
| // 分页
| const startIndex = (pageNum - 1) * pageSize;
| const endIndex = startIndex + parseInt(pageSize);
| const paginatedData = filteredData.slice(startIndex, endIndex);
|
| return {
| code: 200,
| message: "success",
| data: {
| rows: paginatedData,
| total: filteredData.length,
| pageNum: parseInt(pageNum),
| pageSize: parseInt(pageSize)
| }
| };
| };
|
| // 获取死亡判定详细信息
| export const getDeathJudgmentDetail = async (id) => {
| await delay();
|
| const detail = mockDeathJudgmentData.find(item => item.id == id);
|
| if (detail) {
| // 获取该判定对应的附件
| const attachments = mockAttachmentData.filter(item => item.judgmentId == id);
|
| return {
| code: 200,
| message: "success",
| data: {
| ...detail,
| attachments
| }
| };
| } else {
| return {
| code: 404,
| message: "死亡判定记录不存在"
| };
| }
| };
|
| // 新增死亡判定
| export const addDeathJudgment = async (data) => {
| await delay();
|
| const newId = Math.max(...mockDeathJudgmentData.map(item => item.id)) + 1;
| const hospitalNo = `D${new Date().getFullYear()}${String(new Date().getMonth() + 1).padStart(2, '0')}${String(newId).padStart(3, '0')}`;
|
| const newRecord = {
| ...data,
| id: newId,
| hospitalNo,
| registrationTime: new Date().toISOString().replace('T', ' ').substring(0, 19),
| createTime: new Date().toISOString().replace('T', ' ').substring(0, 19)
| };
|
| // 模拟添加到数据
| mockDeathJudgmentData.unshift(newRecord);
|
| return {
| code: 200,
| message: "新增成功",
| data: newRecord
| };
| };
|
| // 修改死亡判定
| export const updateDeathJudgment = async (data) => {
| await delay();
|
| const index = mockDeathJudgmentData.findIndex(item => item.id == data.id);
|
| if (index !== -1) {
| mockDeathJudgmentData[index] = {
| ...mockDeathJudgmentData[index],
| ...data,
| updateTime: new Date().toISOString().replace('T', ' ').substring(0, 19)
| };
|
| return {
| code: 200,
| message: "修改成功",
| data: mockDeathJudgmentData[index]
| };
| } else {
| return {
| code: 404,
| message: "死亡判定记录不存在"
| };
| }
| };
|
| // 删除死亡判定
| export const delDeathJudgment = async (ids) => {
| await delay();
|
| const idArray = Array.isArray(ids) ? ids : [ids];
|
| idArray.forEach(id => {
| const index = mockDeathJudgmentData.findIndex(item => item.id == id);
| if (index !== -1) {
| mockDeathJudgmentData.splice(index, 1);
|
| // 同时删除对应的附件记录
| const attachmentIndex = mockAttachmentData.findIndex(item => item.judgmentId == id);
| while (attachmentIndex !== -1) {
| mockAttachmentData.splice(attachmentIndex, 1);
| }
| }
| });
|
| return {
| code: 200,
| message: "删除成功"
| };
| };
|
| // 导出死亡判定
| export const exportDeathJudgment = async (queryParams) => {
| await delay(1000);
|
| // 模拟导出功能
| const { data } = await listDeathJudgment(queryParams);
|
| return {
| code: 200,
| message: "导出成功",
| data: {
| fileName: `死亡判定数据_${new Date().getTime()}.xlsx`,
| downloadUrl: "/api/export/deathJudgment"
| }
| };
| };
|
| // 附件相关API
| export const uploadAttachment = async (file, judgmentId, type) => {
| await delay(1500);
|
| const newAttachment = {
| id: Math.max(...mockAttachmentData.map(item => item.id), 0) + 1,
| judgmentId: parseInt(judgmentId),
| type: type,
| typeName: getTypeName(type),
| fileName: file.name,
| fileSize: file.size,
| uploadTime: new Date().toISOString().replace('T', ' ').substring(0, 19),
| uploader: "当前用户",
| fileUrl: URL.createObjectURL(file)
| };
|
| mockAttachmentData.push(newAttachment);
|
| return {
| code: 200,
| message: "上传成功",
| data: newAttachment
| };
| };
|
| export const deleteAttachment = async (attachmentId) => {
| await delay();
|
| const index = mockAttachmentData.findIndex(item => item.id == attachmentId);
|
| if (index !== -1) {
| mockAttachmentData.splice(index, 1);
|
| return {
| code: 200,
| message: "删除成功"
| };
| } else {
| return {
| code: 404,
| message: "附件不存在"
| };
| }
| };
|
| export const getAttachments = async (judgmentId) => {
| await delay();
|
| const attachments = mockAttachmentData.filter(item => item.judgmentId == judgmentId);
|
| return {
| code: 200,
| message: "success",
| data: attachments
| };
| };
|
| // 辅助函数
| function getTypeName(type) {
| const typeMap = {
| "1": "脑死亡判定表",
| "2": "脑电图评估表",
| "3": "短潜伏期体感诱发电位评估表",
| "4": "经颅多普勒超声评估记录",
| "5": "卫健委脑损伤质控中心 - 临床综合评估表",
| "6": "UW评分表",
| "7": "心死亡判定表"
| };
|
| return typeMap[type] || "未知类型";
| }
|
|