// 模拟器官分配数据 const mockOrganAllocationData = [ { id: 1, hospitalNo: "D202512001", caseNo: "C202512001", donorName: "张三", gender: "2", age: 45, birthDate: "1978-05-15", diagnosis: "脑外伤", allocationStatus: "allocated", allocationTime: "2025-12-01 16:30:00", registrant: "李协调员", registrationTime: "2025-12-01 15:00:00", createTime: "2025-12-01 10:00:00" }, { id: 2, hospitalNo: "D202512002", caseNo: "C202512002", donorName: "李四", gender: "1", age: 38, birthDate: "1985-08-22", diagnosis: "心脏骤停", allocationStatus: "allocated", allocationTime: "2025-12-02 11:20:00", registrant: "张协调员", registrationTime: "2025-12-02 10:00:00", createTime: "2025-12-02 08:30:00" }, { id: 3, hospitalNo: "D202512003", caseNo: "C202512003", donorName: "王五", gender: "2", age: 52, birthDate: "1971-03-10", diagnosis: "脑梗死", allocationStatus: "pending", allocationTime: "", registrant: "赵协调员", registrationTime: "2025-12-03 17:20:00", createTime: "2025-12-03 14:00:00" } ]; // 模拟器官分配记录数据 const mockAllocationRecordData = [ { id: 1, allocationId: 1, organName: "肝脏", organNo: "L001", caseNo: "C202512001", systemNo: "AL202512001", applicantTime: "2025-12-01 17:00:00", recipientName: "王", transplantHospitalNo: "H1001", transplantHospitalName: "青岛大学附属医院", reallocationReason: "", organState: 1 }, { id: 2, allocationId: 1, organName: "肾脏", organNo: "K001", caseNo: "C202512001", systemNo: "AL202512002", applicantTime: "2025-12-01 17:30:00", recipientName: "李", transplantHospitalNo: "H1002", transplantHospitalName: "青岛市市立医院", reallocationReason: "", organState: 1 }, { id: 3, allocationId: 1, organName: "心脏", organNo: "H001", caseNo: "C202512001", systemNo: "AL202512003", applicantTime: "2025-12-01 18:00:00", recipientName: "张", transplantHospitalNo: "H1003", transplantHospitalName: "山东大学齐鲁医院", reallocationReason: "", organState: 1 } ]; // 模拟医院数据 const mockHospitalData = [ { id: 1, hospitalNo: "H1001", hospitalName: "青岛大学附属医院", type: "4" }, { id: 2, hospitalNo: "H1002", hospitalName: "青岛市市立医院", type: "4" }, { id: 3, hospitalNo: "H1003", hospitalName: "山东大学齐鲁医院", type: "4" }, { id: 4, hospitalNo: "H1004", hospitalName: "青岛市中心医院", type: "4" }, { id: 5, hospitalNo: "H1005", hospitalName: "青岛市海慈医疗集团", type: "4" } ]; // 模拟器官类型字典 const mockOrganDict = [ { value: "L001", label: "肝脏" }, { value: "K001", label: "肾脏" }, { value: "H001", label: "心脏" }, { value: "L002", label: "肺脏" }, { value: "P001", label: "胰腺" }, { value: "I001", label: "小肠" }, { value: "C001", label: "角膜" } ]; // 模拟API响应延迟 const delay = (ms = 500) => new Promise(resolve => setTimeout(resolve, ms)); // 查询器官分配列表 export const listOrganAllocation = async (queryParams = {}) => { await delay(); const { pageNum = 1, pageSize = 10, hospitalNo, donorName, allocationStatus } = queryParams; // 过滤数据 let filteredData = mockOrganAllocationData.filter(item => { let match = true; if (hospitalNo && !item.hospitalNo.includes(hospitalNo)) { match = false; } if (donorName && !item.donorName.includes(donorName)) { match = false; } if (allocationStatus && item.allocationStatus !== allocationStatus) { 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 getOrganAllocationDetail = async (id) => { await delay(); const detail = mockOrganAllocationData.find(item => item.id == id); if (detail) { // 获取分配记录 const allocationRecords = mockAllocationRecordData.filter(item => item.allocationId == id); return { code: 200, message: "success", data: { ...detail, allocationRecords } }; } else { return { code: 404, message: "器官分配记录不存在" }; } }; // 新增器官分配 export const addOrganAllocation = async (data) => { await delay(); const newId = Math.max(...mockOrganAllocationData.map(item => item.id), 0) + 1; const hospitalNo = `D${new Date().getFullYear()}${String(new Date().getMonth() + 1).padStart(2, '0')}${String(newId).padStart(3, '0')}`; const caseNo = `C${new Date().getFullYear()}${String(new Date().getMonth() + 1).padStart(2, '0')}${String(newId).padStart(3, '0')}`; const newRecord = { ...data, id: newId, hospitalNo, caseNo, registrationTime: new Date().toISOString().replace('T', ' ').substring(0, 19), createTime: new Date().toISOString().replace('T', ' ').substring(0, 19) }; mockOrganAllocationData.unshift(newRecord); return { code: 200, message: "新增成功", data: newRecord }; }; // 修改器官分配 export const updateOrganAllocation = async (data) => { await delay(); const index = mockOrganAllocationData.findIndex(item => item.id == data.id); if (index !== -1) { mockOrganAllocationData[index] = { ...mockOrganAllocationData[index], ...data, updateTime: new Date().toISOString().replace('T', ' ').substring(0, 19) }; return { code: 200, message: "修改成功", data: mockOrganAllocationData[index] }; } else { return { code: 404, message: "器官分配记录不存在" }; } }; // 删除器官分配 export const delOrganAllocation = async (ids) => { await delay(); const idArray = Array.isArray(ids) ? ids : [ids]; idArray.forEach(id => { const index = mockOrganAllocationData.findIndex(item => item.id == id); if (index !== -1) { mockOrganAllocationData.splice(index, 1); } }); return { code: 200, message: "删除成功" }; }; // 保存器官分配记录 export const saveAllocationRecords = async (allocationId, records) => { await delay(); // 删除该分配ID的所有记录 const existingIndexes = []; mockAllocationRecordData.forEach((item, index) => { if (item.allocationId == allocationId) { existingIndexes.push(index); } }); // 从后往前删除避免索引问题 existingIndexes.reverse().forEach(index => { mockAllocationRecordData.splice(index, 1); }); // 添加新记录 records.forEach(record => { const newId = Math.max(...mockAllocationRecordData.map(item => item.id), 0) + 1; mockAllocationRecordData.push({ ...record, id: newId, allocationId: allocationId }); }); return { code: 200, message: "保存成功", data: records }; }; // 获取医院列表 export const getHospitalList = async () => { await delay(); return { code: 200, message: "success", data: mockHospitalData }; }; // 获取器官字典 export const getOrganDict = async () => { await delay(); return { code: 200, message: "success", data: mockOrganDict }; }; export default { listOrganAllocation, getOrganAllocationDetail, addOrganAllocation, updateOrganAllocation, delOrganAllocation, saveAllocationRecords, getHospitalList, getOrganDict };