|
@@ -18,6 +18,25 @@ export type NewDrugType =
|
|
|
| 'tcm'
|
|
| 'tcm'
|
|
|
| 'tcm_injection';
|
|
| 'tcm_injection';
|
|
|
|
|
|
|
|
|
|
+/** 后端 `type` 字段,对应字典:智慧传承系统-新药类型 */
|
|
|
|
|
+export type NewDrugTypeDTO = '0' | '1' | '2' | '3' | '4';
|
|
|
|
|
+
|
|
|
|
|
+const NEW_DRUG_TYPE_TO_DTO: Record<NewDrugType, NewDrugTypeDTO> = {
|
|
|
|
|
+ tcm: '0',
|
|
|
|
|
+ tcm_injection: '1',
|
|
|
|
|
+ chemical: '2',
|
|
|
|
|
+ biological: '3',
|
|
|
|
|
+ other: '4',
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+const NEW_DRUG_TYPE_FROM_DTO: Record<NewDrugTypeDTO, NewDrugType> = {
|
|
|
|
|
+ '0': 'tcm',
|
|
|
|
|
+ '1': 'tcm_injection',
|
|
|
|
|
+ '2': 'chemical',
|
|
|
|
|
+ '3': 'biological',
|
|
|
|
|
+ '4': 'other',
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
export const NEW_DRUG_TYPE_OPTIONS = [
|
|
export const NEW_DRUG_TYPE_OPTIONS = [
|
|
|
{ label: '中药', value: 'tcm', color: 'success' },
|
|
{ label: '中药', value: 'tcm', color: 'success' },
|
|
|
{ label: '中药注射剂', value: 'tcm_injection', color: 'success' },
|
|
{ label: '中药注射剂', value: 'tcm_injection', color: 'success' },
|
|
@@ -34,32 +53,71 @@ export function getNewDrugTypeLabel(type?: NewDrugType) {
|
|
|
return NEW_DRUG_TYPE_OPTIONS.find((item) => item.value === type)?.label ?? '';
|
|
return NEW_DRUG_TYPE_OPTIONS.find((item) => item.value === type)?.label ?? '';
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+export function decodeNewDrugType(type?: number | string): NewDrugType {
|
|
|
|
|
+ const normalized = type?.toString();
|
|
|
|
|
+ if (
|
|
|
|
|
+ normalized === '0' ||
|
|
|
|
|
+ normalized === '1' ||
|
|
|
|
|
+ normalized === '2' ||
|
|
|
|
|
+ normalized === '3' ||
|
|
|
|
|
+ normalized === '4'
|
|
|
|
|
+ ) {
|
|
|
|
|
+ return NEW_DRUG_TYPE_FROM_DTO[normalized];
|
|
|
|
|
+ }
|
|
|
|
|
+ return 'tcm';
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+function encodeNewDrugType(type: NewDrugType): NewDrugTypeDTO {
|
|
|
|
|
+ return NEW_DRUG_TYPE_TO_DTO[type];
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
export function formatValidUntil(validUntil?: string, longTerm?: boolean) {
|
|
export function formatValidUntil(validUntil?: string, longTerm?: boolean) {
|
|
|
if (longTerm) return '长期有效';
|
|
if (longTerm) return '长期有效';
|
|
|
return validUntil || '-';
|
|
return validUntil || '-';
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+function formatDateTime(date: string) {
|
|
|
|
|
+ if (!date) return date;
|
|
|
|
|
+ if (/^\d{4}-\d{2}-\d{2}$/.test(date)) {
|
|
|
|
|
+ return `${date}T00:00:00`;
|
|
|
|
|
+ }
|
|
|
|
|
+ return date;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+function formatDateOnly(dateTime?: string) {
|
|
|
|
|
+ if (!dateTime) return '';
|
|
|
|
|
+ return dateTime.slice(0, 10);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
// ---------------------------------------------------------------------------
|
|
// ---------------------------------------------------------------------------
|
|
|
// DTO
|
|
// DTO
|
|
|
// ---------------------------------------------------------------------------
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
+/** 新药证书 DTO,对应 `OutcomeNewdrugCertificateDetail` */
|
|
|
export interface NewDrugCertificateDTO extends AuditRecordDTO {
|
|
export interface NewDrugCertificateDTO extends AuditRecordDTO {
|
|
|
id?: number | string;
|
|
id?: number | string;
|
|
|
|
|
+ status?: string;
|
|
|
|
|
+ remark?: string;
|
|
|
personalStudioId?: number | string;
|
|
personalStudioId?: number | string;
|
|
|
- approvalNumber?: string;
|
|
|
|
|
- name?: string;
|
|
|
|
|
- drugType?: NewDrugType;
|
|
|
|
|
- applicant?: string;
|
|
|
|
|
- approvalDate?: string;
|
|
|
|
|
- validUntil?: string;
|
|
|
|
|
- longTerm?: boolean;
|
|
|
|
|
fileUrl?: string;
|
|
fileUrl?: string;
|
|
|
|
|
+ downloadCount?: number;
|
|
|
|
|
+ browseCount?: number;
|
|
|
|
|
+ commentCount?: number;
|
|
|
|
|
+ praiseCount?: number;
|
|
|
|
|
+ approvalCode?: string;
|
|
|
|
|
+ name?: string;
|
|
|
|
|
+ /** 新药类型,详见字典:智慧传承系统-新药类型 */
|
|
|
|
|
+ type?: NewDrugTypeDTO | string;
|
|
|
|
|
+ applyCompany?: string;
|
|
|
|
|
+ approvalTime?: string;
|
|
|
|
|
+ expirationTime?: string;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
export interface NewDrugCertificateQueryDTO {
|
|
export interface NewDrugCertificateQueryDTO {
|
|
|
mixture?: string;
|
|
mixture?: string;
|
|
|
personalStudioId?: number | string;
|
|
personalStudioId?: number | string;
|
|
|
- drugType?: NewDrugType;
|
|
|
|
|
|
|
+ type?: NewDrugTypeDTO | string;
|
|
|
|
|
+ status?: string;
|
|
|
pageNum?: number;
|
|
pageNum?: number;
|
|
|
pageSize?: number;
|
|
pageSize?: number;
|
|
|
}
|
|
}
|
|
@@ -113,17 +171,20 @@ export const NewDrugCertificateVOSchema = z.object({
|
|
|
export function decodeNewDrugCertificate(
|
|
export function decodeNewDrugCertificate(
|
|
|
dto: NewDrugCertificateDTO,
|
|
dto: NewDrugCertificateDTO,
|
|
|
): NewDrugCertificateVO {
|
|
): NewDrugCertificateVO {
|
|
|
|
|
+ const expirationTime = dto.expirationTime;
|
|
|
|
|
+ const longTerm = !expirationTime;
|
|
|
|
|
+
|
|
|
return {
|
|
return {
|
|
|
...decodeAuditRecord(dto),
|
|
...decodeAuditRecord(dto),
|
|
|
id: dto.id?.toString(),
|
|
id: dto.id?.toString(),
|
|
|
workroomId: dto.personalStudioId?.toString() ?? '',
|
|
workroomId: dto.personalStudioId?.toString() ?? '',
|
|
|
- approvalNumber: dto.approvalNumber ?? '',
|
|
|
|
|
|
|
+ approvalNumber: dto.approvalCode ?? '',
|
|
|
name: dto.name ?? '',
|
|
name: dto.name ?? '',
|
|
|
- drugType: dto.drugType ?? 'tcm',
|
|
|
|
|
- applicant: dto.applicant ?? '',
|
|
|
|
|
- approvalDate: dto.approvalDate ?? '',
|
|
|
|
|
- validUntil: dto.validUntil,
|
|
|
|
|
- longTerm: dto.longTerm ?? false,
|
|
|
|
|
|
|
+ drugType: decodeNewDrugType(dto.type),
|
|
|
|
|
+ applicant: dto.applyCompany ?? '',
|
|
|
|
|
+ approvalDate: formatDateOnly(dto.approvalTime),
|
|
|
|
|
+ validUntil: longTerm ? undefined : formatDateOnly(expirationTime),
|
|
|
|
|
+ longTerm,
|
|
|
pdfUrl: dto.fileUrl,
|
|
pdfUrl: dto.fileUrl,
|
|
|
};
|
|
};
|
|
|
}
|
|
}
|
|
@@ -134,24 +195,28 @@ export function encodeNewDrugCertificateQuery(
|
|
|
return {
|
|
return {
|
|
|
mixture: query.keyword || undefined,
|
|
mixture: query.keyword || undefined,
|
|
|
personalStudioId: query.workroomId,
|
|
personalStudioId: query.workroomId,
|
|
|
- drugType: query.drugType || undefined,
|
|
|
|
|
|
|
+ type: query.drugType ? encodeNewDrugType(query.drugType) : undefined,
|
|
|
};
|
|
};
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
export function encodeNewDrugCertificate(
|
|
export function encodeNewDrugCertificate(
|
|
|
vo: NewDrugCertificateSubmitVO,
|
|
vo: NewDrugCertificateSubmitVO,
|
|
|
): NewDrugCertificateDTO {
|
|
): NewDrugCertificateDTO {
|
|
|
|
|
+ let expirationTime: string | undefined;
|
|
|
|
|
+ if (!vo.longTerm && vo.validUntil) {
|
|
|
|
|
+ expirationTime = formatDateTime(vo.validUntil);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
return {
|
|
return {
|
|
|
id: vo.id,
|
|
id: vo.id,
|
|
|
personalStudioId: vo.workroomId,
|
|
personalStudioId: vo.workroomId,
|
|
|
- approvalNumber: vo.approvalNumber,
|
|
|
|
|
|
|
+ fileUrl: vo.pdfUrl ?? '',
|
|
|
|
|
+ approvalCode: vo.approvalNumber,
|
|
|
name: vo.name,
|
|
name: vo.name,
|
|
|
- drugType: vo.drugType,
|
|
|
|
|
- applicant: vo.applicant,
|
|
|
|
|
- approvalDate: vo.approvalDate,
|
|
|
|
|
- validUntil: vo.longTerm ? undefined : vo.validUntil,
|
|
|
|
|
- longTerm: vo.longTerm,
|
|
|
|
|
- fileUrl: vo.pdfUrl,
|
|
|
|
|
|
|
+ type: encodeNewDrugType(vo.drugType),
|
|
|
|
|
+ applyCompany: vo.applicant,
|
|
|
|
|
+ approvalTime: formatDateTime(vo.approvalDate),
|
|
|
|
|
+ expirationTime,
|
|
|
};
|
|
};
|
|
|
}
|
|
}
|
|
|
|
|
|