Forráskód Böngészése

fix(@six/wisdom-legacy): 成果管理 - 院内制剂页面接口对接

cmj 2 napja
szülő
commit
d07d031b09

+ 5 - 5
apps/wisdom-legacy/src/api/outcome/hospital-preparation.api.ts

@@ -50,7 +50,7 @@ export function listHospitalPreparationMethod(...args: PageQueryMethodArgs) {
     encodeHospitalPreparationQuery,
   );
   return httpClient.Post(
-    `/wis-pc/outcome/hospitalPreparationManage/page`,
+    `/wis-pc/outcome/ilpnManage/page`,
     { ...params, ...data },
     {
       params,
@@ -69,7 +69,7 @@ export function createHospitalPreparationMethod(
   }
 
   return httpClient.Post(
-    `/wis-pc/outcome/hospitalPreparationManage/add`,
+    `/wis-pc/outcome/ilpnManage/add`,
     encodeHospitalPreparation(vo),
     {
       name: 'outcome-hospital-preparation:edit',
@@ -87,7 +87,7 @@ export function updateHospitalPreparationMethod(
   }
 
   return httpClient.Post(
-    `/wis-pc/outcome/hospitalPreparationManage/update`,
+    `/wis-pc/outcome/ilpnManage/update`,
     encodeHospitalPreparation(vo),
     {
       name: 'outcome-hospital-preparation:edit',
@@ -112,7 +112,7 @@ export function getHospitalPreparationMethod(
   }
 
   return httpClient.Post(
-    `/wis-pc/outcome/hospitalPreparationManage/detail/${vo.id}`,
+    `/wis-pc/outcome/ilpnManage/detail/${vo.id}`,
     {},
     {
       hitSource: /^outcome-hospital-preparation:edit/,
@@ -130,7 +130,7 @@ export function deleteHospitalPreparationMethod(
   }
 
   return httpClient.Post(
-    `/wis-pc/outcome/hospitalPreparationManage/delete/${vo.id}`,
+    `/wis-pc/outcome/ilpnManage/delete/${vo.id}`,
     {},
     {
       name: 'outcome-hospital-preparation:delete',

+ 48 - 52
apps/wisdom-legacy/src/api/outcome/hospital-preparation.mock.ts

@@ -1,5 +1,4 @@
 import type {
-  DosageForm,
   HospitalPreparationDTO,
   HospitalPreparationSubmitVO,
   HospitalPreparationVO,
@@ -17,7 +16,7 @@ import {
 } from './hospital-preparation.schema';
 
 /** 后端接口就绪后改为 false */
-export const USE_HOSPITAL_PREPARATION_MOCK = true;
+export const USE_HOSPITAL_PREPARATION_MOCK = false;
 
 type MethodLike<T> = PromiseLike<T> & {
   send?: (force?: boolean) => PromiseLike<T>;
@@ -31,63 +30,63 @@ const SEED_RECORDS: Omit<
   'createTime' | 'id' | 'personalStudioId' | 'updateTime'
 >[] = [
   {
-    preparationNumber: 'YN2023001',
+    code: 'YN2023001',
     name: '健脾和胃颗粒',
-    dosageForm: 'granules',
-    mainIngredients: '党参、白术、茯苓、甘草等',
-    indications: '用于脾胃虚弱,食少便溏',
-    approvalDate: '2023-06-15',
-    status: true,
+    type: '0',
+    mainIngredient: '党参、白术、茯苓、甘草等',
+    indication: '用于脾胃虚弱,食少便溏',
+    approvalTime: '2023-06-15T00:00:00',
+    status: '0',
     fileUrl: MOCK_PDF_URL,
   },
   {
-    preparationNumber: 'YN2024002',
+    code: 'YN2024002',
     name: '清肝明目丸',
-    dosageForm: 'pills',
-    mainIngredients: '菊花、决明子、枸杞子、熟地黄等',
-    indications: '用于肝火上炎,目赤肿痛',
-    approvalDate: '2024-03-20',
-    status: true,
+    type: '1',
+    mainIngredient: '菊花、决明子、枸杞子、熟地黄等',
+    indication: '用于肝火上炎,目赤肿痛',
+    approvalTime: '2024-03-20T00:00:00',
+    status: '0',
     fileUrl: MOCK_PDF_URL,
   },
   {
-    preparationNumber: 'YN2022003',
+    code: 'YN2022003',
     name: '止咳化痰口服液',
-    dosageForm: 'oral_liquid',
-    mainIngredients: '川贝、枇杷叶、桔梗、甘草等',
-    indications: '用于咳嗽痰多,胸闷气促',
-    approvalDate: '2022-11-10',
-    status: false,
+    type: '2',
+    mainIngredient: '川贝、枇杷叶、桔梗、甘草等',
+    indication: '用于咳嗽痰多,胸闷气促',
+    approvalTime: '2022-11-10T00:00:00',
+    status: '1',
     fileUrl: MOCK_PDF_URL,
   },
   {
-    preparationNumber: 'YN2023004',
+    code: 'YN2023004',
     name: '温阳散寒汤',
-    dosageForm: 'decoction',
-    mainIngredients: '附子、干姜、肉桂、甘草等',
-    indications: '用于阳虚寒凝,四肢不温',
-    approvalDate: '2023-09-08',
-    status: true,
+    type: '3',
+    mainIngredient: '附子、干姜、肉桂、甘草等',
+    indication: '用于阳虚寒凝,四肢不温',
+    approvalTime: '2023-09-08T00:00:00',
+    status: '0',
     fileUrl: MOCK_PDF_URL,
   },
   {
-    preparationNumber: 'YN2024005',
+    code: 'YN2024005',
     name: '润肤止痒膏',
-    dosageForm: 'cream',
-    mainIngredients: '苦参、白鲜皮、地肤子、冰片等',
-    indications: '用于湿疹瘙痒,皮肤干燥',
-    approvalDate: '2024-01-12',
-    status: true,
+    type: '4',
+    mainIngredient: '苦参、白鲜皮、地肤子、冰片等',
+    indication: '用于湿疹瘙痒,皮肤干燥',
+    approvalTime: '2024-01-12T00:00:00',
+    status: '0',
     fileUrl: MOCK_PDF_URL,
   },
   {
-    preparationNumber: 'YN2023006',
+    code: 'YN2023006',
     name: '益气复脉颗粒',
-    dosageForm: 'granules',
-    mainIngredients: '黄芪、党参、麦冬、五味子',
-    indications: '用于气阴两虚,心悸气短',
-    approvalDate: '2023-04-22',
-    status: false,
+    type: '0',
+    mainIngredient: '黄芪、党参、麦冬、五味子',
+    indication: '用于气阴两虚,心悸气短',
+    approvalTime: '2023-04-22T00:00:00',
+    status: '1',
     fileUrl: MOCK_PDF_URL,
   },
 ];
@@ -104,8 +103,8 @@ function createInitialStore(): HospitalPreparationDTO[] {
       ...seed,
       id: String(index + 1),
       personalStudioId: '327477138296832',
-      preparationNumber: `YN${year}${String(index + 1).padStart(3, '0')}`,
-      approvalDate: `${year}-${month}-${day}`,
+      code: `YN${year}${String(index + 1).padStart(3, '0')}`,
+      approvalTime: `${year}-${month}-${day}T00:00:00`,
       createTime: `2026-${month}-${day}T10:00:00`,
       updateTime: `2026-05-${day}T10:00:00`,
     });
@@ -129,9 +128,9 @@ function matchKeyword(record: HospitalPreparationDTO, keyword?: string) {
   if (!keyword) return true;
   const text = [
     record.name,
-    record.preparationNumber,
-    record.mainIngredients,
-    record.indications,
+    record.code,
+    record.mainIngredient,
+    record.indication,
   ]
     .filter(Boolean)
     .join(' ');
@@ -143,15 +142,12 @@ function matchWorkroom(record: HospitalPreparationDTO, workroomId?: string) {
   return String(record.personalStudioId ?? '') === String(workroomId);
 }
 
-function matchDosageForm(
-  record: HospitalPreparationDTO,
-  dosageForm?: DosageForm,
-) {
-  if (!dosageForm) return true;
-  return record.dosageForm === dosageForm;
+function matchDosageForm(record: HospitalPreparationDTO, type?: string) {
+  if (!type) return true;
+  return record.type === type;
 }
 
-function matchStatus(record: HospitalPreparationDTO, status?: boolean) {
+function matchStatus(record: HospitalPreparationDTO, status?: string) {
   if (status === undefined) return true;
   return record.status === status;
 }
@@ -171,14 +167,14 @@ export function mockListHospitalPreparationMethod(
   const pageSize = Number(params.pageSize ?? 10);
   const keyword = data.mixture;
   const workroomId = data.personalStudioId?.toString();
-  const dosageForm = data.dosageForm;
+  const type = data.type;
   const status = data.status;
 
   const filtered = store.filter(
     (record) =>
       matchKeyword(record, keyword) &&
       matchWorkroom(record, workroomId) &&
-      matchDosageForm(record, dosageForm) &&
+      matchDosageForm(record, type) &&
       matchStatus(record, status),
   );
   const start = (pageNum - 1) * pageSize;

+ 89 - 31
apps/wisdom-legacy/src/api/outcome/hospital-preparation.schema.ts

@@ -4,7 +4,12 @@ import type {
 } from '#/request/schema/audit-record';
 
 import { z } from '#/adapter/form';
-import { decodeList } from '#/request/schema';
+import {
+  decodeList,
+  decodeZeroFlag,
+  encodeZeroFlag,
+  encodeZeroFlagOptional,
+} from '#/request/schema';
 import { decodeAuditRecord } from '#/request/schema/audit-record';
 
 // ---------------------------------------------------------------------------
@@ -18,6 +23,25 @@ export type DosageForm =
   | 'oral_liquid'
   | 'pills';
 
+/** 后端 `type` 字段,对应字典:智慧传承系统-剂型 */
+export type DosageFormTypeDTO = '0' | '1' | '2' | '3' | '4';
+
+const DOSAGE_FORM_TO_DTO: Record<DosageForm, DosageFormTypeDTO> = {
+  granules: '0',
+  pills: '1',
+  oral_liquid: '2',
+  decoction: '3',
+  cream: '4',
+};
+
+const DOSAGE_FORM_FROM_DTO: Record<DosageFormTypeDTO, DosageForm> = {
+  '0': 'granules',
+  '1': 'pills',
+  '2': 'oral_liquid',
+  '3': 'decoction',
+  '4': 'cream',
+};
+
 export const DOSAGE_FORM_OPTIONS = [
   { label: '颗粒剂', value: 'granules', color: 'processing' },
   { label: '丸剂', value: 'pills', color: 'processing' },
@@ -43,28 +67,66 @@ export function getDosageFormLabel(form?: DosageForm) {
   return DOSAGE_FORM_OPTIONS.find((item) => item.value === form)?.label ?? '';
 }
 
+export function decodeDosageFormType(type?: number | string): DosageForm {
+  const normalized = type?.toString();
+  if (
+    normalized === '0' ||
+    normalized === '1' ||
+    normalized === '2' ||
+    normalized === '3' ||
+    normalized === '4'
+  ) {
+    return DOSAGE_FORM_FROM_DTO[normalized];
+  }
+  return 'granules';
+}
+
+function encodeDosageFormType(form: DosageForm): DosageFormTypeDTO {
+  return DOSAGE_FORM_TO_DTO[form];
+}
+
+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,对应 `OutcomeInternalPreparationDetail` */
 export interface HospitalPreparationDTO extends AuditRecordDTO {
   id?: number | string;
+  status?: string;
+  remark?: string;
   personalStudioId?: number | string;
-  preparationNumber?: string;
-  name?: string;
-  dosageForm?: DosageForm;
-  mainIngredients?: string;
-  indications?: string;
-  approvalDate?: string;
-  status?: boolean;
   fileUrl?: string;
+  downloadCount?: number;
+  browseCount?: number;
+  commentCount?: number;
+  praiseCount?: number;
+  code?: string;
+  name?: string;
+  /** 剂型,详见字典:智慧传承系统-剂型 */
+  type?: DosageFormTypeDTO | string;
+  mainIngredient?: string;
+  indication?: string;
+  approvalTime?: string;
 }
 
 export interface HospitalPreparationQueryDTO {
   mixture?: string;
   personalStudioId?: number | string;
-  dosageForm?: DosageForm;
-  status?: boolean;
+  type?: DosageFormTypeDTO | string;
+  status?: string;
   pageNum?: number;
   pageSize?: number;
 }
@@ -125,29 +187,25 @@ export function decodeHospitalPreparation(
     ...decodeAuditRecord(dto),
     id: dto.id?.toString(),
     workroomId: dto.personalStudioId?.toString() ?? '',
-    preparationNumber: dto.preparationNumber ?? '',
+    preparationNumber: dto.code ?? '',
     name: dto.name ?? '',
-    dosageForm: dto.dosageForm ?? 'granules',
-    mainIngredients: dto.mainIngredients ?? '',
-    indications: dto.indications ?? '',
-    approvalDate: dto.approvalDate ?? '',
-    status: dto.status ?? true,
+    dosageForm: decodeDosageFormType(dto.type),
+    mainIngredients: dto.mainIngredient ?? '',
+    indications: dto.indication ?? '',
+    approvalDate: formatDateOnly(dto.approvalTime),
+    status: decodeZeroFlag(dto.status),
     pdfUrl: dto.fileUrl,
   };
 }
 
 export function encodeHospitalPreparationQuery(
-  query: Partial<HospitalPreparationQueryVO & Record<string, unknown>>,
+  query: Partial<HospitalPreparationQueryVO>,
 ): HospitalPreparationQueryDTO {
-  const status = query.status as boolean | string | undefined;
   return {
-    mixture: query.keyword || undefined,
+    mixture: query.keyword,
     personalStudioId: query.workroomId,
-    dosageForm: query.dosageForm || undefined,
-    status:
-      status === '' || status === undefined || status === null
-        ? undefined
-        : Boolean(status),
+    type: query.dosageForm ? encodeDosageFormType(query.dosageForm) : undefined,
+    status: encodeZeroFlagOptional(query.status),
   };
 }
 
@@ -157,14 +215,14 @@ export function encodeHospitalPreparation(
   return {
     id: vo.id,
     personalStudioId: vo.workroomId,
-    preparationNumber: vo.preparationNumber,
+    fileUrl: vo.pdfUrl ?? '',
+    code: vo.preparationNumber,
     name: vo.name,
-    dosageForm: vo.dosageForm,
-    mainIngredients: vo.mainIngredients,
-    indications: vo.indications,
-    approvalDate: vo.approvalDate,
-    status: vo.status,
-    fileUrl: vo.pdfUrl,
+    type: encodeDosageFormType(vo.dosageForm),
+    mainIngredient: vo.mainIngredients,
+    indication: vo.indications,
+    approvalTime: formatDateTime(vo.approvalDate),
+    status: encodeZeroFlag(vo.status),
   };
 }
 

+ 1 - 2
apps/wisdom-legacy/src/views/outcome/HospitalPreparationList.vue

@@ -23,13 +23,12 @@ const { Grid, Edit, actions, grid } = useGridPage(hospitalPreparationGrid, {
   params: { workroomId: () => workroomId.value },
   edit: editModal(HospitalPreparationEdit),
   delete: deleteHospitalPreparationMethod,
-  view: ({ row }: { row: HospitalPreparationVO }) => {
+  view: (row: HospitalPreparationVO) => {
     if (row.pdfUrl) {
       window.open(row.pdfUrl, '_blank');
     } else {
       message.warning('暂无附件');
     }
-    return void 0;
   },
 });
 

+ 1 - 0
apps/wisdom-legacy/src/views/outcome/hospital-preparation.data.ts

@@ -145,6 +145,7 @@ export const hospitalPreparationForm = defineEditShell<HospitalPreparationVO>({
       label: '剂型',
       defaultValue: 'granules',
       componentProps: {
+        class: 'w-full',
         options: [...DOSAGE_FORM_OPTIONS],
         placeholder: '请选择剂型',
         getPopupContainer,