// 模拟死亡判定数据 const mockDeathJudgmentData = [ { id: 1, hospitalNo: "D202312001", donorName: "张三", gender: "0", age: 45, diagnosis: "脑外伤", deathReason: "brain_death", deathTime: "2023-12-01 14:30:00", judgmentDoctor: "王医生", judgmentDescription: "经过多次脑死亡判定,符合脑死亡临床诊断标准", registrant: "李协调员", registrationTime: "2023-12-01 15:00:00", createTime: "2023-12-01 10:00:00" }, { id: 2, hospitalNo: "D202312002", donorName: "李四", gender: "1", age: 38, diagnosis: "心脏骤停", deathReason: "heart_death", deathTime: "2023-12-02 09:15:00", judgmentDoctor: "刘医生", judgmentDescription: "心死亡判定,心电图呈直线,无自主呼吸", registrant: "张协调员", registrationTime: "2023-12-02 10:00:00", createTime: "2023-12-02 08:30:00" }, { id: 3, hospitalNo: "D202312003", donorName: "王五", gender: "0", age: 52, diagnosis: "脑梗死", deathReason: "brain_death", deathTime: "2023-12-03 16:45:00", judgmentDoctor: "陈医生", judgmentDescription: "脑干功能完全丧失,符合脑死亡标准", registrant: "赵协调员", registrationTime: "2023-12-03 17:20:00", createTime: "2023-12-03 14:00:00" }, { id: 4, hospitalNo: "D202312004", donorName: "赵六", gender: "1", age: 29, diagnosis: "多发伤", deathReason: "other", deathTime: "2023-12-04 11:20:00", judgmentDoctor: "孙医生", judgmentDescription: "创伤性休克导致多器官功能衰竭", registrant: "钱协调员", registrationTime: "2023-12-04 12:00:00", createTime: "2023-12-04 09:45:00" }, { id: 5, hospitalNo: "D202312005", donorName: "孙七", gender: "0", age: 61, diagnosis: "脑肿瘤", deathReason: "brain_death", deathTime: "2023-12-05 13:10:00", judgmentDoctor: "周医生", judgmentDescription: "颅内压增高导致脑疝形成", registrant: "吴协调员", registrationTime: "2023-12-05 13:45:00", createTime: "2023-12-05 10:30:00" } ]; // 模拟附件数据 const mockAttachmentData = [ { id: 1, judgmentId: 1, type: "1", typeName: "脑死亡判定表", fileName: "脑死亡判定表_202312001.pdf", fileSize: 2548321, uploadTime: "2023-12-01 14:35:00", uploader: "王医生", fileUrl: "/attachments/brain_death_1.pdf" }, { id: 2, judgmentId: 1, type: "2", typeName: "脑电图评估表", fileName: "脑电图评估表_202312001.docx", fileSize: 512345, uploadTime: "2023-12-01 15:20:00", uploader: "李医生", fileUrl: "/attachments/eeg_1.docx" }, { id: 3, judgmentId: 2, type: "7", typeName: "心死亡判定表", fileName: "心死亡判定表_202312002.pdf", fileSize: 1892345, uploadTime: "2023-12-02 09:30:00", uploader: "刘医生", fileUrl: "/attachments/heart_death_2.pdf" }, { id: 4, judgmentId: 3, type: "1", typeName: "脑死亡判定表", fileName: "脑死亡判定表_202312003.pdf", fileSize: 3124567, uploadTime: "2023-12-03 17:00:00", uploader: "陈医生", fileUrl: "/attachments/brain_death_3.pdf" }, { id: 5, judgmentId: 3, type: "4", typeName: "经颅多普勒超声评估记录", fileName: "经颅多普勒_202312003.xlsx", fileSize: 845672, uploadTime: "2023-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] || "未知类型"; }