Files
zkxw/web-admin/src/api/project-management.ts
T
zlwu 6e682f8d18 fix(project): identify storage and donation assignments by sample codes
Replace order number columns with batched sample codes and support sample keyword searches without duplicating parent records. Preserve tenant and soft-delete boundaries, existing assignment writes and preview identifiers.

Related to issue #13. Independent static review completed; tests authored but not run under user self-test arrangement.
2026-11-04 14:27:57 +08:00

100 lines
3.5 KiB
TypeScript

import request from '@/utils/http'
export type BizType =
| 'presign'
| 'cell_storage'
| 'research_donation'
| 'pilot_service'
| 'basic_experiment'
export const bizLabels: Record<BizType, string> = {
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<string, any>
export type AssignmentBizType = Exclude<BizType, 'presign'>
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<string, unknown>) =>
request.get<{ list: ProjectRecord[]; total: number }>({ url: `${base}/${kind}`, params })
export const fetchManagementDetail = (kind: 'teams' | 'projects', id: string) =>
request.get<ProjectRecord>({ 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<string, unknown>) =>
request.get<{
items: ProjectRecord[]
totals: ProjectRecord
unassignedTotals: ProjectRecord
presignTotal: number
}>({ url: `${base}/statistics`, params })
export const fetchProjectRecords = (params: Record<string, unknown>) =>
request.get<{ list: ProjectRecord[]; total: number; statusCounts: Record<string, number> }>({
url: `${base}/records`,
params
})
export const fetchAssignmentRecords = (params: Record<string, unknown>) =>
request.get<{ list: AssignmentRecord[]; total: number; statusCounts: Record<string, number> }>({
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 })