Selaa lähdekoodia

feat(@six/smart-pharmacy): 智慧药事系统第一版煎药中心管理接口对接

cmj 1 kuukausi sitten
vanhempi
commit
d9a1ea1757

+ 39 - 0
apps/smart-pharmacy/src/api/method/system.ts

@@ -7,10 +7,12 @@ import {
   fromOrganization,
   fromProject,
   fromRole,
+  fromTisane,
   fromUser,
   toOrganization,
   toProject,
   toRole,
+  toTisane,
   toUser,
 } from '#/api/model';
 import {
@@ -83,6 +85,21 @@ export namespace SystemModel {
     remark?: string;
   }
 
+  /** 煎药中心 */
+  export interface Tisane extends TransformRecord {
+    id: string;
+    name: string;
+    code?: string;
+    /** 类型展示文案 */
+    type?: string;
+    enterpriseType?: number;
+    institutionId?: string;
+    relatedOrganizations?: string;
+    enterpriseId?: string;
+    relatedEnterprise?: string;
+    remark?: string;
+  }
+
   export interface Menu {
     type: 'button' | 'catalog' | 'menu';
     id: string;
@@ -336,6 +353,28 @@ export function deleteOrganizationsMethod(
   });
 }
 
+/** 获取煎药中心分页列表 */
+export function listMedicineCentersMethod(
+  page = 1,
+  size = 20,
+  query?: Partial<SystemModel.Tisane>,
+) {
+  return http.get<TransformList<SystemModel.Tisane>, TransformList>(
+    `/manager/tcmp-pc/medicine/list`,
+    {
+      params: { pageNum: page, pageSize: size, ...toTisane(query) },
+      cacheFor: 0,
+      transform({ items, ...data }) {
+        const rows = items ?? [];
+        return {
+          ...data,
+          items: rows.map((item) => fromTisane(item)),
+        };
+      },
+    },
+  );
+}
+
 export function getMenusMethod() {
   return http.post<SystemModel.Menu[], TransformData[]>(
     `/admin/menu/allMenu`,

+ 1 - 0
apps/smart-pharmacy/src/api/model/index.ts

@@ -5,6 +5,7 @@ export * from './doctor';
 export * from './organization';
 export * from './project';
 export * from './role';
+export * from './tisane';
 export * from './user';
 export function fromRow(data?: TransformData): TransformRecord {
   const createUser = data?.createUser;

+ 58 - 0
apps/smart-pharmacy/src/api/model/tisane.ts

@@ -0,0 +1,58 @@
+import type { SystemModel, TransformData } from '#/api';
+
+import { fromRow } from '#/api/model';
+
+const ENTERPRISE_TYPE_LABEL: Record<number, string> = {
+  1: '企业煎药中心',
+  2: '第三方煎药中心',
+};
+
+export function getEnterpriseTypeLabel(type?: number | string): string {
+  if (type === undefined || type === null || type === '') return '-';
+  const key = Number(type);
+  return ENTERPRISE_TYPE_LABEL[key] ?? String(type);
+}
+
+export function fromTisane(data?: TransformData): SystemModel.Tisane {
+  const id = data?.id === undefined || data?.id === null ? '' : String(data.id);
+  const enterpriseType = data?.enterpriseType;
+  return {
+    ...fromRow({
+      ...data,
+      id,
+      createUser: data?.createBy ?? data?.createUser,
+      createTime: data?.createTime,
+    }),
+    id,
+    name: data?.centerName ?? data?.name,
+    code: data?.centerCode ?? data?.code,
+    enterpriseType,
+    type: getEnterpriseTypeLabel(enterpriseType),
+    institutionId:
+      data?.institutionId === undefined || data?.institutionId === null
+        ? undefined
+        : String(data.institutionId),
+    relatedOrganizations: data?.institutionName ?? data?.relatedOrganizations,
+    enterpriseId:
+      data?.enterpriseId === undefined || data?.enterpriseId === null
+        ? undefined
+        : String(data.enterpriseId),
+    relatedEnterprise: data?.enterpriseName ?? data?.relatedEnterprise,
+    remark: data?.remark,
+    createUser: data?.createBy ?? data?.createUser,
+  };
+}
+
+export function toTisane(data?: Partial<SystemModel.Tisane>): TransformData {
+  return {
+    id: data?.id || void 0,
+    centerName: data?.name,
+    centerCode: data?.code,
+    enterpriseType: data?.enterpriseType,
+    institutionId: data?.institutionId,
+    institutionName: data?.relatedOrganizations,
+    enterpriseId: data?.enterpriseId,
+    enterpriseName: data?.relatedEnterprise,
+    remark: data?.remark,
+  };
+}

+ 10 - 47
apps/smart-pharmacy/src/views/system/tisane/data.ts

@@ -1,13 +1,11 @@
 import type { VxeTableGridOptions } from '@vben/plugins/vxe-table';
 
 import type { VbenFormSchema } from '#/adapter/form';
-import type { OnActionClickFn } from '#/adapter/vxe-table';
 import type { SystemModel } from '#/api/method/system';
 
-import { listOrganizationsMethodAll } from '#/api/method/system';
 import { $t } from '#/locales';
 
-export function useUserSearchFormSchema(): VbenFormSchema[] {
+export function useTisaneSearchFormSchema(): VbenFormSchema[] {
   return [
     {
       component: 'Input',
@@ -15,38 +13,20 @@ export function useUserSearchFormSchema(): VbenFormSchema[] {
       label: $t('system.tisane.name'),
     },
     {
-      component: 'Select',
-      fieldName: 'status',
+      component: 'Input',
+      fieldName: 'relatedEnterprise',
       label: $t('system.tisane.relatedEnterprise'),
-      componentProps: {
-        options: [
-          {
-            label: '医疗机构1',
-            value: 1,
-          },
-          {
-            label: '医疗机构2',
-            value: 0,
-          },
-          {
-            label: '医疗机构3',
-            value: 2,
-          },
-        ],
-      },
     },
   ];
 }
 
-export function useUserTableColumns<T = SystemModel.Organization>(
-  onActionClick?: OnActionClickFn<T>,
-): VxeTableGridOptions<T>['columns'] {
+export function useTisaneTableColumns(): VxeTableGridOptions<SystemModel.Tisane>['columns'] {
   return [
     { type: 'seq', title: $t('table.column.seq'), width: 50 },
     {
       field: 'name',
       title: $t('system.tisane.name'),
-      minWidth: 100,
+      minWidth: 120,
     },
     {
       field: 'code',
@@ -56,17 +36,17 @@ export function useUserTableColumns<T = SystemModel.Organization>(
     {
       field: 'type',
       title: $t('system.tisane.type'),
-      minWidth: 100,
+      minWidth: 120,
     },
     {
       field: 'relatedOrganizations',
       title: $t('system.tisane.relatedOrganization'),
-      minWidth: 100,
+      minWidth: 120,
     },
     {
       field: 'relatedEnterprise',
       title: $t('system.tisane.relatedEnterprise'),
-      minWidth: 100,
+      minWidth: 120,
     },
     {
       field: 'remark',
@@ -76,33 +56,16 @@ export function useUserTableColumns<T = SystemModel.Organization>(
     {
       field: 'createTime',
       title: $t('system.tisane.createTime'),
-      minWidth: 100,
+      minWidth: 160,
     },
     {
       field: 'createUser',
       title: $t('system.tisane.createUser'),
       minWidth: 100,
     },
-    {
-      align: 'center',
-      // cellRender: {
-      //   attrs: {
-      //     nameField: 'name',
-      //     nameTitle: $t('system.user._'),
-      //     onClick: onActionClick,
-      //   },
-      //   name: 'CellOperation',
-      // },
-      field: 'operation',
-      fixed: 'right',
-      title: $t('table.column.operation'),
-      width: 130,
-    },
   ];
 }
 
-export function useUserFormSchema(
-  current?: Pick<SystemModel.Organization, 'id' | 'name'>,
-): VbenFormSchema[] {
+export function useTisaneFormSchema(): VbenFormSchema[] {
   return [];
 }

+ 12 - 71
apps/smart-pharmacy/src/views/system/tisane/list.vue

@@ -5,8 +5,9 @@ import type { SystemModel } from '#/api';
 import { Page, useVbenModal } from '@vben/common-ui';
 
 import { useVbenVxeGrid } from '#/adapter/vxe-table';
+import { listMedicineCentersMethod } from '#/api';
 
-import { useUserSearchFormSchema, useUserTableColumns } from './data';
+import { useTisaneSearchFormSchema, useTisaneTableColumns } from './data';
 import Form from './modules/form.vue';
 
 const [FormModal, formModalApi] = useVbenModal({
@@ -16,90 +17,30 @@ const [FormModal, formModalApi] = useVbenModal({
 
 const [Grid, gridApi] = useVbenVxeGrid({
   formOptions: {
-    schema: useUserSearchFormSchema(),
+    schema: useTisaneSearchFormSchema(),
     submitOnChange: true,
   },
   gridOptions: {
-    columns: useUserTableColumns(),
+    columns: useTisaneTableColumns(),
     height: 'auto',
     keepSource: true,
-    // proxyConfig: {
-    //   ajax: {
-    //     query({ page }, formValues) {
-    //       return listOrganizationsMethod(
-    //         page.currentPage,
-    //         page.pageSize,
-    //         formValues,
-    //       );
-    //     },
-    //   },
-    // },
-    // rowConfig: {
-    //   keyField: 'id',
-    // },
-
     proxyConfig: {
       ajax: {
-        query() {
-          return Promise.resolve({
-            Data: {
-              TotalRecordCount: 3,
-
-              Items: [
-                {
-                  pid: '1',
-                  name: '重药煎药中心华东区',
-                  code: 'cyeast',
-                  createUser: 'createUser',
-                  createTime: '2025-10-26 11:23:21',
-                  type: '企业煎药中心',
-                  remark: '备注1',
-                  relatedOrganizations: '医疗机构1',
-                  relatedEnterprise: '浙江药业公司',
-                },
-                {
-                  pid: '2',
-                  name: '煎药中心1',
-                  code: 'jyzhongxin1',
-                  createUser: 'createUser',
-                  createTime: '2025-10-26 11:23:21',
-                  type: '第三方煎药中心',
-                  remark: '备注2',
-                  relatedOrganizations: '医疗机构2',
-                  relatedEnterprise: '重药控股有限公司',
-                },
-                {
-                  pid: '3',
-                  name: '煎药中心2',
-                  code: 'jyzhongxin2',
-                  createUser: 'createUser',
-                  createTime: '2025-10-26 11:23:21',
-                  type: '第三方煎药中心',
-                  remark: '备注333',
-                  relatedOrganizations: '医疗机构3',
-                  relatedEnterprise: '重药控股有限公司',
-                },
-              ],
-            },
-
-            ResultCode: 0,
-          });
+        query({ page }, formValues) {
+          return listMedicineCentersMethod(
+            page.currentPage,
+            page.pageSize,
+            formValues,
+          );
         },
       },
-
-      response: {
-        result: 'Data.Items',
-        total: 'Data.TotalRecordCount',
-      },
     },
-
     rowConfig: {
-      keyField: 'pid',
+      keyField: 'id',
     },
-  } as VxeTableGridOptions<SystemModel.User>,
+  } as VxeTableGridOptions<SystemModel.Tisane>,
 });
 
-// 刷新
 function onRefresh() {
   gridApi.query();
 }

+ 16 - 7
apps/smart-pharmacy/src/views/system/tisane/modules/form.vue

@@ -10,20 +10,19 @@ import { Button } from 'ant-design-vue';
 import { useVbenForm } from '#/adapter/form';
 import { $t } from '#/locales';
 
-import { useUserFormSchema } from '../data';
+import { useTisaneFormSchema } from '../data';
 
 const emit = defineEmits(['success']);
 
-const formData = ref<SystemModel.Organization>();
+const formData = ref<SystemModel.Tisane>();
 const getTitle = computed(() => {
   return formData.value?.id
-    ? $t('ui.actionTitle.edit', [$t('system.organization._')])
-    : $t('ui.actionTitle.create', [$t('system.organization._')]);
+    ? $t('ui.actionTitle.edit', [$t('system.tisane._')])
+    : $t('ui.actionTitle.create', [$t('system.tisane._')]);
 });
 
 const [Form, formApi] = useVbenForm({
-  // layout: 'vertical',
-  schema: useUserFormSchema(),
+  schema: useTisaneFormSchema(),
   showDefaultActions: false,
 });
 
@@ -32,7 +31,17 @@ function resetForm() {
   formApi.setValues(formData.value || {});
 }
 
-const [Modal, modalApi] = useVbenModal({});
+const [Modal, modalApi] = useVbenModal({
+  onOpenChange(isOpen) {
+    if (isOpen) {
+      const data = modalApi.getData<SystemModel.Tisane>();
+      if (data) {
+        formData.value = data;
+        formApi.setValues(formData.value);
+      }
+    }
+  },
+});
 </script>
 
 <template>