// 统计模块模拟数据 // 响应字段与 /opo/totals/* 返回的 Totals(opo统计) 对象保持一致 // mock 模式下由 statistics.js 返回,页面逻辑无需区分数据来源 const REGIONS = ['青岛地区', '日照地区', '济南地区', '烟台地区', '威海地区', '潍坊地区', '临沂地区']; const MONTHS = ['2024-01', '2024-02', '2024-03', '2024-04', '2024-05', '2024-06']; const YEARS = ['2022', '2023', '2024']; const ORGANS = ['全肝', '肾脏', '心脏', '肺', '胰腺', '眼角膜']; const BLOOD_TYPES = ['A', 'B', 'O', 'AB']; const AGE_GROUPS = ['1', '2', '3', '4']; // 确定性伪随机,保证每次渲染数据一致 function createRand(seed) { let s = seed % 2147483647; if (s <= 0) s += 2147483646; return function () { s = (s * 16807) % 2147483647; return (s - 1) / 2147483646; }; } // 案例趋势(月份维度) function mockCaseTrend() { const r = createRand(11); return MONTHS.map((m) => { const potential = 40 + Math.round(r() * 40); return { donateTime: m, potentialCount: potential, completeCount: Math.round(potential * (0.6 + r() * 0.2)), totalCount: potential }; }); } // 案例趋势(地区维度) function mockCaseTrendArea() { const r = createRand(22); return REGIONS.map((area) => { const potential = 30 + Math.round(r() * 70); return { area, potentialCount: potential, completeCount: Math.round(potential * (0.6 + r() * 0.2)) }; }); } // 案例明细(地区 x 月份) function mockCaseTrendMoon() { const r = createRand(33); const rows = []; REGIONS.forEach((area) => { MONTHS.forEach((m) => { const potential = 5 + Math.round(r() * 15); rows.push({ area, donateTime: m, potentialCount: potential, completeCount: Math.round(potential * (0.5 + r() * 0.4)), totalCount: potential }); }); }); return rows; } // 平均年龄 function mockCaseAvgAge() { return [{ avgAge: 45.6 }]; } // 性别与血型分布 function mockCaseBloodType() { const r = createRand(44); return BLOOD_TYPES.map((boodType) => { const man = 20 + Math.round(r() * 30); const woman = 20 + Math.round(r() * 30); return { boodType, manCount: man, womanCount: woman, boodTypeCount: man + woman }; }); } // 捐献者年龄性别分布 function mockCaseSex() { const r = createRand(55); return AGE_GROUPS.map((ageGroup) => ({ ageGroup, manCount: 15 + Math.round(r() * 40), womanCount: 15 + Math.round(r() * 40) })); } // 捐献器官统计明细(年份 x 器官 x 地区) function mockOrgan() { const r = createRand(66); const rows = []; YEARS.forEach((year) => { ORGANS.forEach((organName) => { REGIONS.forEach((area) => { const get = 10 + Math.round(r() * 40); rows.push({ donateTime: year, organName, area, getCount: get, useCount: Math.round(get * (0.7 + r() * 0.25)) }); }); }); }); return rows; } // 器官获取/移植趋势(月份维度) function mockOrganMoon() { const r = createRand(77); return MONTHS.map((m) => { const get = 50 + Math.round(r() * 60); return { donateTime: m, getCount: get, useCount: Math.round(get * (0.75 + r() * 0.2)) }; }); } // 器官类型分布 function mockOrganType() { const r = createRand(88); return ORGANS.map((organName) => { const get = 40 + Math.round(r() * 80); return { organName, getCount: get, useCount: Math.round(get * (0.75 + r() * 0.2)) }; }); } // 总统计(总潜在捐献案例 / 总完成捐献数) function mockTotalsAll() { return [{ totalPotential: 486, totalCompletion: 327 }]; } // 案例明细列表(trendList) function mockTrendList() { const r = createRand(99); const NAMES = ['张三', '李四', '王五', '赵六', '陈七', '刘八', '周九']; const HOSPITALS = ['青岛大学附属医院', '青岛市立医院', '青岛市中心医院', '山东大学齐鲁医院(青岛)']; const DEATHS = ['脑外伤', '心搏骤停', '脑血管意外', '颅脑肿瘤', '缺氧性脑病']; const WORKFLOWS = [1, 2, 3, 4, 5, 6, 7, 99]; return NAMES.map((name, i) => { const month = MONTHS[i % MONTHS.length]; const day = String(1 + Math.floor(r() * 27)).padStart(2, '0'); return { id: 1000 + i, caseNo: `C${month.replace('-', '')}00${i + 1}`, name, inpatientNo: `ZY${month.replace('-', '')}00${i + 1}`, workflow: WORKFLOWS[i % WORKFLOWS.length], organName: ORGANS[i % ORGANS.length], donatetime: `${month}-${day} 10:30`, deathReason: DEATHS[i % DEATHS.length], treatmentHospitalName: HOSPITALS[i % HOSPITALS.length] }; }); } // 器官移植总统计(数据概览) function mockOrganTotals() { return [{ totalGet: 486, totalTransplant: 398, totalRecycle: 12, totalDiscard: 76 }]; } // 捐献器官统计明细列表(器官明细详情) function mockOrganList() { const r = createRand(111); const NAMES = ['张三', '李四', '王五', '赵六', '陈七', '刘八']; const HOSPITALS = ['青岛大学附属医院', '青岛市立医院', '青岛市中心医院']; const DOCTORS = ['李医生', '张医生', '王医生']; const RECIPIENTS = ['王明', '陈强', '刘伟', '赵刚']; const STATUS = [1, 1, 2, 3]; return NAMES.map((name, i) => { const year = YEARS[i % YEARS.length]; const month = String(1 + Math.floor(r() * 12)).padStart(2, '0'); const st = STATUS[i % STATUS.length]; return { id: 2000 + i, caseNo: `O${year}00${i + 1}`, name, organName: ORGANS[i % ORGANS.length], registerCountyName: REGIONS[i % REGIONS.length], donateYear: year, transplantstate: st, organGetTime: `${year}-${month}-15 10:30`, transplantTime: st === 1 ? `${year}-${month}-15 13:20` : '', notgetreason: st === 3 ? '器官质量不合格' : '', transplantName: st === 1 ? RECIPIENTS[i % RECIPIENTS.length] : '', hospitalName: HOSPITALS[i % HOSPITALS.length], transplantDoct: DOCTORS[i % DOCTORS.length] }; }); } const MOCK_MAP = { '/opo/totals/caseTrend': mockCaseTrend, '/opo/totals/caseTrendArea': mockCaseTrendArea, '/opo/totals/caseTrendMoon': mockCaseTrendMoon, '/opo/totals/caseAvgAge': mockCaseAvgAge, '/opo/totals/caseBloodType': mockCaseBloodType, '/opo/totals/caseSex': mockCaseSex, '/opo/totals/organ': mockOrgan, '/opo/totals/organMoon': mockOrganMoon, '/opo/totals/organType': mockOrganType, '/opo/totals/totals': mockTotalsAll, '/opo/totals/trendList': mockTrendList, '/opo/totals/organTotals': mockOrganTotals, '/opo/totals/organList': mockOrganList }; export function mockTotals(url) { const fn = MOCK_MAP[url]; return fn ? fn() : []; }