medical-case-library.data.ts 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. import type { MedicalCaseLibraryVO } from '#/api/outcome';
  2. import { getPopupContainer } from '@vben/utils';
  3. import { defineEditShell } from '#/adapter/shell/edit';
  4. import { defineGrid } from '#/adapter/vxe-table';
  5. import { listDiseaseMethod, listSymptomMethod } from '#/api/common';
  6. import {
  7. editMedicalCaseLibraryMethod,
  8. getMedicalCaseLibraryMethod,
  9. listMedicalCaseLibraryMethod,
  10. MedicalCaseLibraryVOSchema,
  11. } from '#/api/outcome';
  12. const genderOptions = [
  13. { label: '男', value: '1' },
  14. { label: '女', value: '2' },
  15. ] as const;
  16. function maskPatientName(name?: string) {
  17. if (!name) return '';
  18. if (name.length <= 1) return `${name}*`;
  19. return `${name[0]}${'*'.repeat(name.length - 1)}`;
  20. }
  21. function formatGender(cellValue?: string) {
  22. return genderOptions.find((item) => item.value === cellValue)?.label ?? '';
  23. }
  24. function formatPatientInfo({ row }: { row: MedicalCaseLibraryVO }) {
  25. const gender = formatGender(row.patient?.gender);
  26. const age = row.patient?.age == null ? '' : `${row.patient.age}岁`;
  27. const profile = [age, gender].filter(Boolean).join(' / ');
  28. return profile;
  29. }
  30. export const medicalCaseLibraryGrid = defineGrid<MedicalCaseLibraryVO>({
  31. scope: 'outcome.medicalCaseLibrary',
  32. query: listMedicalCaseLibraryMethod,
  33. form: {
  34. showCollapseButton: false,
  35. wrapperClass: 'grid-cols-1',
  36. },
  37. fields: [
  38. {
  39. component: 'Input',
  40. fieldName: 'keyword',
  41. labelWidth: 0,
  42. componentProps: {
  43. allowClear: true,
  44. placeholder: '搜索患者姓名、病名或医生...',
  45. },
  46. },
  47. ],
  48. columns: (col) => [
  49. col.seq({ title: '编号', width: 80 }),
  50. {
  51. field: 'patient.name',
  52. title: '患者信息',
  53. minWidth: 140,
  54. align: 'center',
  55. slots: { default: 'patientInfo' },
  56. },
  57. {
  58. field: 'disease.name',
  59. title: '病名',
  60. minWidth: 100,
  61. },
  62. {
  63. field: 'syndrome.name',
  64. title: '证型',
  65. minWidth: 140,
  66. },
  67. {
  68. field: 'doctor',
  69. title: '医生',
  70. width: 120,
  71. },
  72. {
  73. field: 'firstVisitDate',
  74. title: '首次就诊日期',
  75. width: 130,
  76. },
  77. {
  78. field: 'video.url',
  79. title: '关联视频',
  80. width: 100,
  81. slots: { default: 'linkedVideo' },
  82. },
  83. {
  84. field: 'createdAt',
  85. title: '创建日期',
  86. width: 120,
  87. formatter: ({ cellValue }) =>
  88. cellValue ? String(cellValue).slice(0, 10) : '',
  89. },
  90. col.actions(['view', 'edit', 'delete'], 160),
  91. ],
  92. });
  93. export const medicalCaseLibraryForm = defineEditShell<MedicalCaseLibraryVO>({
  94. scope: 'outcome.medicalCaseLibrary',
  95. title: '医案',
  96. submit: editMedicalCaseLibraryMethod,
  97. load: getMedicalCaseLibraryMethod,
  98. shell: {
  99. type: 'modal',
  100. class: '!w-[640px]',
  101. },
  102. form: {
  103. layout: 'vertical',
  104. wrapperClass: 'grid-cols-2',
  105. },
  106. schema: [
  107. {
  108. component: 'Input',
  109. fieldName: 'patient.name',
  110. label: '患者姓名',
  111. formItemClass: 'col-span-2',
  112. componentProps: {
  113. placeholder: '请输入患者姓名',
  114. },
  115. rules: MedicalCaseLibraryVOSchema.shape.patient.shape.name,
  116. },
  117. {
  118. component: 'Select',
  119. fieldName: 'patient.gender',
  120. label: '性别',
  121. componentProps: {
  122. allowClear: true,
  123. class: 'w-full',
  124. options: [...genderOptions],
  125. placeholder: '请选择性别',
  126. getPopupContainer,
  127. },
  128. rules: MedicalCaseLibraryVOSchema.shape.patient.shape.gender,
  129. },
  130. {
  131. component: 'InputNumber',
  132. fieldName: 'patient.age',
  133. label: '年龄',
  134. componentProps: {
  135. min: 0,
  136. max: 150,
  137. placeholder: '请输入年龄',
  138. class: 'w-full',
  139. },
  140. rules: MedicalCaseLibraryVOSchema.shape.patient.shape.age,
  141. },
  142. {
  143. component: 'Input',
  144. fieldName: 'patient.idCard',
  145. label: '身份证号',
  146. formItemClass: 'col-span-2',
  147. componentProps: {
  148. placeholder: '请输入身份证号',
  149. },
  150. },
  151. {
  152. component: 'ApiSelectPageList',
  153. fieldName: 'disease.name',
  154. label: '病名',
  155. formItemClass: 'col-span-2',
  156. componentProps: {
  157. api: listDiseaseMethod,
  158. fieldNames: { label: 'name', value: 'name' },
  159. placeholder: '请选择病名',
  160. getPopupContainer,
  161. },
  162. rules: MedicalCaseLibraryVOSchema.shape.disease.shape.name,
  163. },
  164. {
  165. component: 'ApiSelectPageList',
  166. fieldName: 'syndrome.name',
  167. label: '证型',
  168. formItemClass: 'col-span-2',
  169. componentProps: {
  170. api: listSymptomMethod,
  171. fieldNames: { label: 'name', value: 'name' },
  172. placeholder: '请选择证型',
  173. getPopupContainer,
  174. },
  175. rules: MedicalCaseLibraryVOSchema.shape.syndrome.shape.name,
  176. },
  177. {
  178. component: 'Input',
  179. fieldName: 'doctor',
  180. label: '医生',
  181. formItemClass: 'col-span-2',
  182. componentProps: {
  183. placeholder: '请输入医生姓名',
  184. },
  185. rules: MedicalCaseLibraryVOSchema.shape.doctor,
  186. },
  187. {
  188. component: 'DatePicker',
  189. fieldName: 'firstVisitDate',
  190. label: '首次就诊日期',
  191. formItemClass: 'col-span-2',
  192. componentProps: {
  193. class: 'w-full',
  194. format: 'YYYY-MM-DD',
  195. placeholder: '年 / 月 / 日',
  196. valueFormat: 'YYYY-MM-DD',
  197. getPopupContainer,
  198. },
  199. rules: MedicalCaseLibraryVOSchema.shape.firstVisitDate,
  200. },
  201. {
  202. component: 'Input',
  203. fieldName: 'workroomId',
  204. dependencies: {
  205. show: false,
  206. triggerFields: ['workroomId'],
  207. },
  208. rules: MedicalCaseLibraryVOSchema.shape.workroomId,
  209. },
  210. ],
  211. });
  212. export { formatGender, formatPatientInfo, maskPatientName };