| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221 |
- import type { MedicalCaseLibraryVO } from '#/api/outcome';
- import { getPopupContainer } from '@vben/utils';
- import { defineEditShell } from '#/adapter/shell/edit';
- import { defineGrid } from '#/adapter/vxe-table';
- import { listDiseaseMethod, listSymptomMethod } from '#/api/common';
- import {
- editMedicalCaseLibraryMethod,
- getMedicalCaseLibraryMethod,
- listMedicalCaseLibraryMethod,
- MedicalCaseLibraryVOSchema,
- } from '#/api/outcome';
- const genderOptions = [
- { label: '男', value: '1' },
- { label: '女', value: '2' },
- ] as const;
- function maskPatientName(name?: string) {
- if (!name) return '';
- if (name.length <= 1) return `${name}*`;
- return `${name[0]}${'*'.repeat(name.length - 1)}`;
- }
- function formatGender(cellValue?: string) {
- return genderOptions.find((item) => item.value === cellValue)?.label ?? '';
- }
- function formatPatientInfo({ row }: { row: MedicalCaseLibraryVO }) {
- const gender = formatGender(row.patient?.gender);
- const age = row.patient?.age == null ? '' : `${row.patient.age}岁`;
- const profile = [age, gender].filter(Boolean).join(' / ');
- return profile;
- }
- export const medicalCaseLibraryGrid = defineGrid<MedicalCaseLibraryVO>({
- scope: 'outcome.medicalCaseLibrary',
- query: listMedicalCaseLibraryMethod,
- form: {
- showCollapseButton: false,
- wrapperClass: 'grid-cols-1',
- },
- fields: [
- {
- component: 'Input',
- fieldName: 'keyword',
- labelWidth: 0,
- componentProps: {
- allowClear: true,
- placeholder: '搜索患者姓名、病名或医生...',
- },
- },
- ],
- columns: (col) => [
- col.seq({ title: '编号', width: 80 }),
- {
- field: 'patient.name',
- title: '患者信息',
- minWidth: 140,
- align: 'center',
- slots: { default: 'patientInfo' },
- },
- {
- field: 'disease.name',
- title: '病名',
- minWidth: 100,
- },
- {
- field: 'syndrome.name',
- title: '证型',
- minWidth: 140,
- },
- {
- field: 'doctor',
- title: '医生',
- width: 120,
- },
- {
- field: 'firstVisitDate',
- title: '首次就诊日期',
- width: 130,
- },
- {
- field: 'video.url',
- title: '关联视频',
- width: 100,
- slots: { default: 'linkedVideo' },
- },
- {
- field: 'createdAt',
- title: '创建日期',
- width: 120,
- formatter: ({ cellValue }) =>
- cellValue ? String(cellValue).slice(0, 10) : '',
- },
- col.actions(['view', 'edit', 'delete'], 160),
- ],
- });
- export const medicalCaseLibraryForm = defineEditShell<MedicalCaseLibraryVO>({
- scope: 'outcome.medicalCaseLibrary',
- title: '医案',
- submit: editMedicalCaseLibraryMethod,
- load: getMedicalCaseLibraryMethod,
- shell: {
- type: 'modal',
- class: '!w-[640px]',
- },
- form: {
- layout: 'vertical',
- wrapperClass: 'grid-cols-2',
- },
- schema: [
- {
- component: 'Input',
- fieldName: 'patient.name',
- label: '患者姓名',
- formItemClass: 'col-span-2',
- componentProps: {
- placeholder: '请输入患者姓名',
- },
- rules: MedicalCaseLibraryVOSchema.shape.patient.shape.name,
- },
- {
- component: 'Select',
- fieldName: 'patient.gender',
- label: '性别',
- componentProps: {
- allowClear: true,
- class: 'w-full',
- options: [...genderOptions],
- placeholder: '请选择性别',
- getPopupContainer,
- },
- rules: MedicalCaseLibraryVOSchema.shape.patient.shape.gender,
- },
- {
- component: 'InputNumber',
- fieldName: 'patient.age',
- label: '年龄',
- componentProps: {
- min: 0,
- max: 150,
- placeholder: '请输入年龄',
- class: 'w-full',
- },
- rules: MedicalCaseLibraryVOSchema.shape.patient.shape.age,
- },
- {
- component: 'Input',
- fieldName: 'patient.idCard',
- label: '身份证号',
- formItemClass: 'col-span-2',
- componentProps: {
- placeholder: '请输入身份证号',
- },
- },
- {
- component: 'ApiSelectPageList',
- fieldName: 'disease.name',
- label: '病名',
- formItemClass: 'col-span-2',
- componentProps: {
- api: listDiseaseMethod,
- fieldNames: { label: 'name', value: 'name' },
- placeholder: '请选择病名',
- getPopupContainer,
- },
- rules: MedicalCaseLibraryVOSchema.shape.disease.shape.name,
- },
- {
- component: 'ApiSelectPageList',
- fieldName: 'syndrome.name',
- label: '证型',
- formItemClass: 'col-span-2',
- componentProps: {
- api: listSymptomMethod,
- fieldNames: { label: 'name', value: 'name' },
- placeholder: '请选择证型',
- getPopupContainer,
- },
- rules: MedicalCaseLibraryVOSchema.shape.syndrome.shape.name,
- },
- {
- component: 'Input',
- fieldName: 'doctor',
- label: '医生',
- formItemClass: 'col-span-2',
- componentProps: {
- placeholder: '请输入医生姓名',
- },
- rules: MedicalCaseLibraryVOSchema.shape.doctor,
- },
- {
- component: 'DatePicker',
- fieldName: 'firstVisitDate',
- label: '首次就诊日期',
- formItemClass: 'col-span-2',
- componentProps: {
- class: 'w-full',
- format: 'YYYY-MM-DD',
- placeholder: '年 / 月 / 日',
- valueFormat: 'YYYY-MM-DD',
- getPopupContainer,
- },
- rules: MedicalCaseLibraryVOSchema.shape.firstVisitDate,
- },
- {
- component: 'Input',
- fieldName: 'workroomId',
- dependencies: {
- show: false,
- triggerFields: ['workroomId'],
- },
- rules: MedicalCaseLibraryVOSchema.shape.workroomId,
- },
- ],
- });
- export { formatGender, formatPatientInfo, maskPatientName };
|