142 lines
3.4 KiB
TypeScript
142 lines
3.4 KiB
TypeScript
import request from '@/utils/http'
|
|
|
|
type PageList<T> = {
|
|
list: T[]
|
|
total: number
|
|
page: number
|
|
pageSize: number
|
|
totalPages: number
|
|
}
|
|
|
|
export type ResearchDonationRow = Record<string, unknown>
|
|
|
|
// 列表
|
|
export function fetchResearchDonationList(params?: {
|
|
page?: number
|
|
pageSize?: number
|
|
keyword?: string
|
|
donationStatus?: string
|
|
createTimeStart?: string
|
|
createTimeEnd?: string
|
|
sampleCollectTimeStart?: string
|
|
sampleCollectTimeEnd?: string
|
|
}) {
|
|
return request.get<PageList<ResearchDonationRow>>({
|
|
url: '/web/admin/research-donations',
|
|
params
|
|
})
|
|
}
|
|
|
|
// 下一捐赠样本编码(KYJZ+YYYYMM+0001 递增)
|
|
export function fetchNextDonationSampleCode(params?: { pendingCodes?: string }) {
|
|
return request.get<{ sampleCode: string }>({
|
|
url: '/web/admin/research-donations/next-sample-code',
|
|
params
|
|
})
|
|
}
|
|
|
|
// 详情
|
|
export function fetchResearchDonationDetail(id: string) {
|
|
return request.get<{
|
|
donation: Record<string, unknown>
|
|
party: Record<string, unknown> | null
|
|
collection: Record<string, unknown> | null
|
|
samples: Array<Record<string, unknown>> | null
|
|
attachments?: Array<Record<string, unknown>>
|
|
}>({
|
|
url: `/web/admin/research-donations/${id}`
|
|
})
|
|
}
|
|
|
|
// 创建
|
|
export function fetchCreateResearchDonation(data: Record<string, unknown>) {
|
|
return request.post({
|
|
url: '/web/admin/research-donations',
|
|
data,
|
|
showSuccessMessage: true
|
|
})
|
|
}
|
|
|
|
// 更新
|
|
export function fetchUpdateResearchDonation(id: string, data: Record<string, unknown>) {
|
|
return request.put({
|
|
url: `/web/admin/research-donations/${id}`,
|
|
data,
|
|
showSuccessMessage: true
|
|
})
|
|
}
|
|
|
|
// 删除
|
|
export function fetchDeleteResearchDonation(id: string) {
|
|
return request.del({
|
|
url: `/web/admin/research-donations/${id}`,
|
|
showSuccessMessage: true
|
|
})
|
|
}
|
|
|
|
// 批量删除
|
|
export function fetchBatchDeleteResearchDonation(ids: string[]) {
|
|
return request.post({
|
|
url: '/web/admin/research-donations/batch-delete',
|
|
data: { ids },
|
|
showSuccessMessage: true
|
|
})
|
|
}
|
|
|
|
// 审核列表
|
|
export function fetchResearchDonationAuditList(params?: {
|
|
page?: number
|
|
pageSize?: number
|
|
keyword?: string
|
|
auditStatus?: string
|
|
researchDonationId?: string
|
|
}) {
|
|
return request.get<PageList<Record<string, unknown>>>({
|
|
url: '/web/admin/research-donations/audits',
|
|
params
|
|
})
|
|
}
|
|
|
|
// 提交审核
|
|
export function fetchSubmitDonationAudit(
|
|
donationId: string,
|
|
data: { auditStatus: string; auditRemark?: string },
|
|
options?: { showSuccessMessage?: boolean }
|
|
) {
|
|
return request.post({
|
|
url: `/web/admin/research-donations/${donationId}/audit`,
|
|
data,
|
|
showSuccessMessage: options?.showSuccessMessage ?? true
|
|
})
|
|
}
|
|
|
|
// 状态变更
|
|
export function fetchDonationStatusChange(
|
|
donationId: string,
|
|
data: { newStatus: string; desc?: string; timeVal?: string; voidType?: string }
|
|
) {
|
|
return request.post({
|
|
url: `/web/admin/research-donations/${donationId}/status-change`,
|
|
data,
|
|
showSuccessMessage: true
|
|
})
|
|
}
|
|
|
|
// 从细胞存储转化
|
|
export function fetchConvertFromStorage(protocolId: string) {
|
|
return request.post({
|
|
url: '/web/admin/research-donations/convert-from-storage',
|
|
data: { protocolId },
|
|
showSuccessMessage: true
|
|
})
|
|
}
|
|
|
|
// 转为细胞存储
|
|
export function fetchConvertToStorage(donationId: string, data?: { desc?: string }) {
|
|
return request.post({
|
|
url: `/web/admin/research-donations/${donationId}/convert-to-storage`,
|
|
data: data || {},
|
|
showSuccessMessage: true
|
|
})
|
|
}
|