import request from '@/utils/http' export type BizType = | 'presign' | 'cell_storage' | 'research_donation' | 'pilot_service' | 'basic_experiment' export const bizLabels: Record = { presign: '预签约', cell_storage: '细胞存储', research_donation: '科研捐赠', pilot_service: '中试服务', basic_experiment: '基础实验' } export type ProjectOption = { id: string projectName: string projectNo: string teamId: string teamName: string disabled?: boolean } export type ProjectRecord = Record export type AssignmentBizType = Exclude export interface AssignmentRecord { id: string bizType: AssignmentBizType bizNo: string | null status: string projectId: string | null projectName: string | null teamId: string | null teamName: string | null createTime: string | null sampleCodes?: string motherName?: string motherPhone?: string hospitalName?: string salesUserName?: string collectionDate?: string donationDate?: string applicationName?: string | null channelName?: string | null serviceOrderName?: string | null patientName?: string patientPhone?: string projectTitle?: string | null customerName?: string | null customerContact?: string | null customerPhone?: string | null } const base = '/web/admin/project-management' export const fetchProjectOptions = (params: { bizType?: BizType keyword?: string usage?: 'filter' currentProjectId?: string }) => request.get<{ list: ProjectOption[]; required: boolean }>({ url: '/project-management/options', params }) export const fetchProjectReferences = () => request.get<{ users: ProjectRecord[]; regions: ProjectRecord[]; hospitals: ProjectRecord[] }>({ url: `${base}/references` }) export const fetchManagementList = (kind: 'teams' | 'projects', params: Record) => request.get<{ list: ProjectRecord[]; total: number }>({ url: `${base}/${kind}`, params }) export const fetchManagementDetail = (kind: 'teams' | 'projects', id: string) => request.get({ url: `${base}/${kind}/${id}` }) export const saveManagement = (kind: 'teams' | 'projects', data: ProjectRecord, id?: string) => id ? request.put({ url: `${base}/${kind}/${id}`, data }) : request.post({ url: `${base}/${kind}`, data }) export const deleteManagement = (kind: 'teams' | 'projects', id: string) => request.del({ url: `${base}/${kind}/${id}` }) export const fetchProjectStatistics = (params: Record) => request.get<{ items: ProjectRecord[] totals: ProjectRecord unassignedTotals: ProjectRecord presignTotal: number }>({ url: `${base}/statistics`, params }) export const fetchProjectRecords = (params: Record) => request.get<{ list: ProjectRecord[]; total: number; statusCounts: Record }>({ url: `${base}/records`, params }) export const fetchAssignmentRecords = (params: Record) => request.get<{ list: AssignmentRecord[]; total: number; statusCounts: Record }>({ url: `${base}/assignments/records`, params }) export const previewAssignment = (data: ProjectRecord) => request.post<{ records: ProjectRecord[] }>({ url: `${base}/assignments/preview`, data }) export const saveAssignment = (data: ProjectRecord) => request.post({ url: `${base}/assignments`, data }) export const fetchAssignmentHistory = (params: ProjectRecord) => request.get<{ list: ProjectRecord[] }>({ url: `${base}/assignments/history`, params })