ReportHistoryPreview.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  1. <script setup lang="ts">
  2. import RecordsAnalysisPreview from '@/components/RecordsAnalysisPreview.vue';
  3. import RecordsIndicatorPreview from '@/components/RecordsIndicatorPreview.vue';
  4. import RecordsPatientPreview from '@/components/RecordsPatientPreview.vue';
  5. import ReportPreview from '@/components/ReportPreview.vue';
  6. import ReportSchemePreview from '@/components/ReportSchemePreview.vue';
  7. import type { PatientModel, ReportModel, ReportSchemeItemModel } from '@/model';
  8. import { patientMethod, patientTags } from '@/request/api/patient.api';
  9. import { indicatorByPatientIdMethod, reportMethod, reportSchemeMethod } from '@/request/api/report.api';
  10. import PatientCardWidget from '@/widgets/PatientCardWidget.vue';
  11. import PatientTagWidget from '@/widgets/PatientTagWidget.vue';
  12. import ReportIndicatorWidget from '@/widgets/ReportIndicatorWidget.vue';
  13. import ReportSchemeCardWidget from '@/widgets/ReportSchemeCardWidget.vue';
  14. import { useElementSize } from '@vueuse/core';
  15. import { useWatcher } from 'alova/client';
  16. import { Button } from 'ant-design-vue';
  17. import { h } from 'vue';
  18. import { VxeUI } from 'vxe-pc-ui';
  19. const props = defineProps<{
  20. patient: Partial<PatientModel>;
  21. report: Partial<ReportModel>;
  22. }>();
  23. const emits = defineEmits<{
  24. destroy: [];
  25. }>();
  26. const patientId = computed(() => props.patient?.id);
  27. const reportId = computed(() => props.report?.id);
  28. const { data: patient, loading: patientLoading } = useWatcher(
  29. () => patientMethod(patientId.value!),
  30. [ () => props.patient?.id ],
  31. {
  32. initialData: { ...props.patient }, immediate: true,
  33. middleware: (_, next) => { if ( patientId.value ) next(); },
  34. },
  35. );
  36. const { data: tags, loading: tagsLoading, send: loadTags } = useWatcher(
  37. () => patientTags(patientId.value!),
  38. [ patientId ],
  39. {
  40. initialData: [], immediate: true,
  41. middleware: (_, next) => { if ( patientId.value ) next(); },
  42. },
  43. );
  44. const { data: report, loading: reportLoading } = useWatcher(
  45. () => reportMethod(reportId.value!),
  46. [ reportId ],
  47. {
  48. initialData: { ...props.report }, immediate: true,
  49. middleware: (_, next) => { if ( reportId.value ) next(); },
  50. },
  51. );
  52. const { data: scheme, loading: schemeLoading } = useWatcher(
  53. () => reportSchemeMethod(reportId.value!),
  54. [ reportId ],
  55. {
  56. initialData: {}, immediate: true,
  57. middleware: (_, next) => { if ( reportId.value ) next(); },
  58. },
  59. );
  60. const { data: indicator, loading: indicatorLoading } = useWatcher(
  61. () => indicatorByPatientIdMethod(patientId.value!),
  62. [ () => props.patient?.id ],
  63. {
  64. initialData: [], immediate: true,
  65. middleware: (_, next) => { if ( patientId.value ) next(); },
  66. },
  67. );
  68. function openPatientRecordsPreviewHandle() {
  69. const id = `modal:record-patient:preview`;
  70. const onDestroy = () => { VxeUI.modal.close(id); };
  71. onDestroy();
  72. VxeUI.modal.open({
  73. id, remember: true,
  74. showMaximize: true, mask: false, lockView: false, padding: false,
  75. resize: true, width: Math.floor(window.innerWidth * 0.5), height: Math.floor(window.innerHeight * 0.5),
  76. escClosable: true, maskClosable: true,
  77. title: `基础信息更新记录`,
  78. slots: {
  79. default() {
  80. return h(RecordsPatientPreview, {
  81. patient: patient.value,
  82. onDestroy,
  83. });
  84. },
  85. },
  86. });
  87. }
  88. function openAnalysisRecordsPreviewHandle() {
  89. const id = `modal:record-analysis:preview`;
  90. const onDestroy = () => { VxeUI.modal.close(id); };
  91. onDestroy();
  92. VxeUI.modal.open({
  93. id, remember: true,
  94. showMaximize: true, mask: false, lockView: false, padding: false,
  95. resize: true, width: Math.floor(window.innerWidth * 0.5), height: Math.floor(window.innerHeight * 0.5),
  96. escClosable: true, maskClosable: true,
  97. title: `健康状况更新记录`,
  98. slots: {
  99. default() {
  100. return h(RecordsAnalysisPreview, {
  101. patient: patient.value,
  102. onDestroy,
  103. });
  104. },
  105. },
  106. });
  107. }
  108. function openIndicatorRecordsPreviewHandle() {
  109. const id = `modal:record-indicator:preview`;
  110. const onDestroy = () => { VxeUI.modal.close(id); };
  111. onDestroy();
  112. VxeUI.modal.open({
  113. id, remember: true,
  114. showMaximize: true, mask: false, lockView: false, padding: false,
  115. resize: true, width: Math.floor(window.innerWidth * 0.5), height: Math.floor(window.innerHeight * 0.5),
  116. escClosable: true, maskClosable: true,
  117. title: `指标信息更新记录`,
  118. slots: {
  119. default() {
  120. return h(RecordsIndicatorPreview, {
  121. patient: patient.value,
  122. onDestroy,
  123. });
  124. },
  125. },
  126. });
  127. }
  128. function openSchemeItemPreviewHandle(value: ReportSchemeItemModel) {
  129. const id = `drawer:scheme:preview`;
  130. const onDestroy = () => { VxeUI.drawer.close(id); };
  131. onDestroy();
  132. VxeUI.drawer.open({
  133. id,
  134. title: [ value.category, value.name ].filter(Boolean).join(': '),
  135. maskClosable: true,
  136. escClosable: true,
  137. padding: false,
  138. slots: {
  139. default() {
  140. return h(ReportSchemePreview, {
  141. value,
  142. onDestroy,
  143. });
  144. },
  145. },
  146. });
  147. }
  148. const reportType = ref<'analysis' | 'scheme'>('analysis');
  149. const analysisReportPreviewOpening = ref(false);
  150. const schemeReportPreviewOpening = ref(false);
  151. function openReportPreviewHandle(type: 'analysis' | 'scheme') {
  152. reportType.value = type;
  153. const id = `drawer:report:preview`;
  154. const onDestroy = () => { VxeUI.drawer.close(id); };
  155. VxeUI.drawer.open({
  156. id,
  157. maskClosable: true,
  158. escClosable: true,
  159. padding: false,
  160. width: window.innerWidth - 256,
  161. slots: {
  162. title() {
  163. switch ( reportType.value ) {
  164. case 'analysis':
  165. return `${ patient.value.name } 的健康分析报告`;
  166. case 'scheme':
  167. return `${ patient.value.name } 的调理方案`;
  168. default:
  169. return '';
  170. }
  171. },
  172. default() {
  173. return h(ReportPreview, {
  174. patient: patient.value,
  175. report: report.value,
  176. scheme: scheme.value,
  177. type: reportType.value,
  178. 'onUpdate:reportId': (value: string) => {},
  179. 'onUpdate:type': (value: 'analysis' | 'scheme') => { reportType.value = value; },
  180. onDestroy,
  181. });
  182. },
  183. corner() {
  184. const { next, label } = {
  185. analysis: { next: 'scheme' as const, label: '调理方案' },
  186. scheme: { next: 'analysis' as const, label: '健康分析报告' },
  187. }[ reportType.value ];
  188. return h(Button, {
  189. type: 'primary', size: 'small',
  190. onClick() { reportType.value = next; },
  191. }, label,
  192. );
  193. },
  194. },
  195. onHide() {
  196. VxeUI.modal.close();
  197. analysisReportPreviewOpening.value = false;
  198. schemeReportPreviewOpening.value = false;
  199. },
  200. });
  201. }
  202. const patientCardRef = ref<HTMLElement>();
  203. const { height } = useElementSize(patientCardRef);
  204. </script>
  205. <template>
  206. <div id="page-container-scroller" class="page-container flex flex-col">
  207. <div style="display: flex">
  208. <PatientCardWidget style="flex: auto" ref="patientCardRef" :dataset="patient" :loading="patientLoading">
  209. <template #tool-bar>
  210. <a-button type="primary" size="small" :disabled="!patientId" @click="openPatientRecordsPreviewHandle()">
  211. 更新记录
  212. </a-button>
  213. </template>
  214. </PatientCardWidget>
  215. <PatientTagWidget
  216. :style="{height: `${height}px`, minHeight: '112px'}" style="flex: none;width: 256px"
  217. :dataset="tags" :loading="tagsLoading"
  218. editable @refresh="loadTags()"
  219. />
  220. </div>
  221. <div class="card report-card" ref="container">
  222. <div class="card__header sticky flex justify-between items-center">
  223. <div class="card__title">
  224. <span>健康状况</span>
  225. <a-spin v-if="reportLoading" size="small" style="margin-left: 4px;" />
  226. <a-space style="margin-left: 8px">
  227. <a-button type="primary" size="small" :disabled="!reportId" @click="openAnalysisRecordsPreviewHandle()">
  228. 更新记录
  229. </a-button>
  230. </a-space>
  231. </div>
  232. </div>
  233. <div class="card__content">
  234. <a-row>
  235. <a-col :span="12">
  236. <a-card class="card no-bordered" size="small" style="background-color: #f7f7f7">
  237. <a-descriptions :column="1">
  238. <a-descriptions-item v-if="report?.pickedSymptom" label="症状信息">
  239. {{ report.pickedSymptom }}
  240. </a-descriptions-item>
  241. <a-descriptions-item v-if="report?.algorithmInferSymptom" label="联想症状">
  242. {{ report.algorithmInferSymptom }}
  243. </a-descriptions-item>
  244. </a-descriptions>
  245. </a-card>
  246. </a-col>
  247. <a-col :span="12">
  248. <a-space style="margin-left: 8px;">
  249. <a-image v-if="report?.upImg" :width="200" :height="200" :src="report.upImg" :preview="true" />
  250. <a-image v-if="report?.downImg" :width="200" :height="200" :src="report.downImg" :preview="true" />
  251. <a-image v-if="report?.faceImg" :width="200" :height="200" :src="report.faceImg" :preview="true" />
  252. </a-space>
  253. </a-col>
  254. </a-row>
  255. </div>
  256. </div>
  257. <div class="card report-card" ref="container">
  258. <div class="card__header sticky flex justify-between items-center">
  259. <div class="card__title">
  260. <span>健康分析报告</span>
  261. <a-spin v-if="reportLoading" size="small" style="margin-left: 4px;" />
  262. <a-space style="margin-left: 8px">
  263. <a-button
  264. type="primary" size="small" :disabled="!reportId" :loading="schemeReportPreviewOpening"
  265. @click="schemeReportPreviewOpening = true; openReportPreviewHandle('analysis');"
  266. >报告详情
  267. </a-button>
  268. </a-space>
  269. </div>
  270. </div>
  271. <div class="card__content">
  272. <a-row>
  273. <a-col :span="12">
  274. <a-card class="card no-bordered" size="small" style="background-color: #f7f7f7">
  275. <a-descriptions :column="3">
  276. <a-descriptions-item v-if="report?.willillStateName" label="健康状态">
  277. {{ report.willillStateName }}
  278. </a-descriptions-item>
  279. <a-descriptions-item v-if="report?.willillDegreeName" label="程度" :span="2">
  280. {{ report.willillDegreeName }}
  281. </a-descriptions-item>
  282. <a-descriptions-item v-if="report?.willillFunctionName" label="表现">
  283. {{ report.willillFunctionName }}
  284. </a-descriptions-item>
  285. <a-descriptions-item v-if="report?.constitutionGroupName" label="体质" :span="2">
  286. {{ report.constitutionGroupName }}
  287. </a-descriptions-item>
  288. </a-descriptions>
  289. </a-card>
  290. </a-col>
  291. </a-row>
  292. </div>
  293. </div>
  294. <ReportSchemeCardWidget :dataset="scheme" :loading="schemeLoading" :editable="false" />
  295. <ReportIndicatorWidget :dataset="indicator" :loading="indicatorLoading">
  296. <template #tool-bar>
  297. <a-button type="primary" size="small" :disabled="!patientId" @click="openIndicatorRecordsPreviewHandle()">
  298. 更新记录
  299. </a-button>
  300. </template>
  301. </ReportIndicatorWidget>
  302. </div>
  303. </template>
  304. <style scoped lang="scss">
  305. @import "@/themes/report-card";
  306. .scheme-tag-item {
  307. margin-right: 0;
  308. cursor: pointer;
  309. span:nth-of-type(2)::before {
  310. content: ":";
  311. margin-left: 2px;
  312. margin-right: 4px;
  313. }
  314. }
  315. </style>