export const getMedalList = async () => { return [ { id: 1, activaFlag: "Y", confeMode: "4", confeSubKno: "SORG", medalObjName: "授予分行机构", createTm: "2025-11-26T11:17:09.000Z", creatorNo: "046083", filePicUrl: "/getUrl?fileId=3d6457ca-3d05-463f-8acd-d5a56d773c40", limitQtyFlag: "Y", limitTmFlag: "Y", medalDesc: "", medalName: "阿萨德", medalNo: "SORG419ABFE1ADE9", medalQty: 13, issuedQty: 2, tmUnitType: "D", updateStaffNo: "046083", updateTm: "2025-12-30T13:10:44.000Z", wearDurat: 12 }, { id: 2, activaFlag: "Y", confeMode: "4", confeSubKno: "CU", medalObjName: "授予客户经理", createTm: "2025-11-26T11:17:09.000Z", creatorNo: "046083", filePicUrl: "/getUrl?fileId=7661069b-aeb9-450b-aa78-3192d53e4e10", limitQtyFlag: "N", limitTmFlag: "N", medalDesc: "", medalName: "1111", medalNo: "CU41990D4501B5", medalQty: 0, issuedQty: 0, tmUnitType: "", updateStaffNo: "046083", updateTm: "2025-12-30T13:10:44.000Z", wearDurat: 0 }, { id: 3, activaFlag: "N", confeMode: "4", confeSubKno: "CU", medalObjName: "授予客户经理", createTm: "2025-11-26T11:17:09.000Z", creatorNo: "046083", filePicUrl: "/getUrl?fileId=3d6457ca-3d05-463f-8acd-d5a56d773c40", limitQtyFlag: "Y", limitTmFlag: "Y", medalDesc: "", medalName: "测试勋章", medalNo: "CU419917C23D9C", medalQty: 999, issuedQty: 0, tmUnitType: "D", updateStaffNo: "046083", updateTm: "2025-11-26T11:10:44.000Z", wearDurat: 12 } ]; }; type MedalUser = { id: string; displayName: string; userNo: string; }; let cachedUserPool: MedalUser[] | null = null; function getUserPool(): MedalUser[] { if (cachedUserPool) return cachedUserPool; const surnames = ["赵", "钱", "孙", "李", "周", "吴", "郑", "王", "冯", "陈", "褚", "卫", "蒋", "沈", "韩", "杨", "朱", "秦", "尤", "许", "何", "吕", "施", "张", "孔", "曹", "严", "华", "金", "魏", "陶", "姜"]; const givenNames = ["一", "二", "三", "四", "五", "六", "七", "八", "九", "十", "子", "文", "宇", "浩", "欣", "婷", "磊", "楠", "敏", "静", "伟", "强", "明", "杰", "晨", "洋", "雪", "雨", "峰", "超"]; const list: MedalUser[] = []; const count = 200; for (let i = 0; i < count; i += 1) { const displayName = `${surnames[i % surnames.length]}${givenNames[i % givenNames.length]}${givenNames[(i + 7) % givenNames.length]}`; const userNo = String(200000 + i).padStart(6, "0"); list.push({ id: userNo, displayName, userNo }); } cachedUserPool = list; return list; } export const getMedalUserList = async (medalNo?: string) => { // 这里可以根据 medalNo 过滤或获取特定数据,目前仅作为示例接收参数 // console.log("Fetching users for medal:", medalNo); const list = getUserPool(); // 模拟已发放用户(取前10个) const issuedUsers = list.slice(0, 10); return { allUsers: list, issuedUsers }; }; function toInt(value: unknown, fallback: number): number { if (typeof value === "number" && Number.isFinite(value)) return Math.floor(value); if (typeof value === "string" && value.trim() !== "") { const parsed = Number.parseInt(value, 10); if (Number.isFinite(parsed)) return parsed; } return fallback; } function toStringArray(value: unknown): string[] { if (Array.isArray(value)) return value.map(String).map((s) => s.trim()).filter(Boolean); if (typeof value === "string") { const trimmed = value.trim(); if (!trimmed) return []; return trimmed.split(",").map((s) => s.trim()).filter(Boolean); } return []; } export const getCandidateUserPage = async (input: { page?: unknown; pageSize?: unknown; keyword?: unknown; excludeUserNos?: unknown; }) => { const pageSize = Math.max(1, Math.min(200, toInt(input.pageSize, 10))); const page = Math.max(1, toInt(input.page, 1)); const keyword = typeof input.keyword === "string" ? input.keyword.trim() : ""; const excludeUserNos = new Set(toStringArray(input.excludeUserNos)); const pool = getUserPool(); const filtered = pool.filter((u) => { if (excludeUserNos.has(u.userNo)) return false; if (!keyword) return true; return u.displayName.includes(keyword) || u.userNo.includes(keyword); }); const total = filtered.length; const start = (page - 1) * pageSize; const list = filtered.slice(start, start + pageSize); return { list, total, page, pageSize }; };