room@default.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  1. <script setup lang="ts">
  2. import ReportAnalysisEdit from '@/components/ReportAnalysisEdit.vue';
  3. import ReportHistoryPreview from '@/components/ReportHistoryPreview.vue';
  4. import type { ReportModel } from '@/model';
  5. import { patientMethod, patientTags } from '@/request/api/patient.api';
  6. import {
  7. confirmSchemeMethod,
  8. indicatorByReportIdMethod,
  9. reportMethod,
  10. reportSchemeMethod,
  11. reportsMethod,
  12. } from '@/request/api/report.api';
  13. import PatientCardWidget from '@/widgets/PatientCardWidget.vue';
  14. import PatientTagWidget from '@/widgets/PatientTagWidget.vue';
  15. import ReportCardWidget from '@/widgets/ReportCardWidget.vue';
  16. import ReportSchemeCardWidget from '@/widgets/ReportSchemeCardWidget.vue';
  17. import { ArrowDownOutlined, ArrowUpOutlined } from '@ant-design/icons-vue';
  18. import { useElementSize } from '@vueuse/core';
  19. import { useRouteQuery } from '@vueuse/router';
  20. import { invalidateCache } from 'alova';
  21. import { actionDelegationMiddleware, useRequest, useWatcher } from 'alova/client';
  22. import { h } from 'vue';
  23. import { useRouter } from 'vue-router';
  24. import { RecycleScroller } from 'vue-virtual-scroller';
  25. import { VxeUI } from 'vxe-pc-ui';
  26. const patientId = useRouteQuery<string>('patientId');
  27. const reportId = useRouteQuery<string>('reportId');
  28. const reportCollapsed = ref(true);
  29. const schemeCollapsed = ref(false);
  30. const { data: patient, loading: patientLoading } = useWatcher(
  31. () => patientMethod(patientId.value),
  32. [ patientId ],
  33. {
  34. initialData: {}, immediate: true,
  35. middleware: (_, next) => { if ( patientId.value ) next(); },
  36. },
  37. ).onSuccess(() => {
  38. reportCollapsed.value = true;
  39. schemeCollapsed.value = false;
  40. unref(patientCardRef.value?.elementTarget)?.scrollIntoView({ behavior: 'smooth', block: 'start', inline: 'nearest' });
  41. });
  42. const { data: tags, loading: tagsLoading, send: loadTags } = useWatcher(
  43. () => patientTags(patientId.value),
  44. [ patientId ],
  45. {
  46. initialData: [], immediate: true,
  47. middleware: (_, next) => { if ( patientId.value ) next(); },
  48. },
  49. );
  50. const { data: reports, loading: reportsLoading } = useWatcher(
  51. () => reportsMethod(patientId.value),
  52. [ patientId ],
  53. {
  54. initialData: [], immediate: true,
  55. middleware: (_, next) => { if ( patientId.value ) next(); },
  56. },
  57. );
  58. const { data: report, loading: reportLoading, send: loadReport } = useWatcher(
  59. () => reportMethod(reportId.value!),
  60. [ reportId ],
  61. {
  62. initialData: {}, immediate: true,
  63. middleware: (_, next) => { if ( reportId.value ) next(); },
  64. },
  65. );
  66. const { data: indicator, loading: indicatorLoading } = useWatcher(
  67. () => indicatorByReportIdMethod(reportId.value!),
  68. [ reportId ],
  69. {
  70. initialData: [], immediate: true,
  71. middleware: (_, next) => {
  72. if ( reportId.value ) return actionDelegationMiddleware('updatePatientIndicator')(_, next);
  73. },
  74. },
  75. );
  76. const { data: scheme, loading: schemeLoading, send: schemeRefresh } = useWatcher(
  77. () => reportSchemeMethod(reportId.value!),
  78. [ reportId ],
  79. {
  80. initialData: {}, immediate: true,
  81. middleware: (_, next) => { if ( reportId.value ) next(); },
  82. },
  83. );
  84. const { loading: confirmSchemeLoading, send: confirmScheme } = useRequest(
  85. () => confirmSchemeMethod(reportId.value),
  86. { immediate: false },
  87. ).onSuccess(() => {
  88. loadReport(reportId.value!);
  89. });
  90. watchEffect(() => {
  91. if ( !reportId.value ) {
  92. report.value = {} as any;
  93. scheme.value = {} as any;
  94. }
  95. });
  96. const router = useRouter();
  97. function handle(model: ReportModel) {
  98. router.replace({
  99. path: router.currentRoute.value.path,
  100. query: { ...router.currentRoute.value.query, patientId: patientId.value, reportId: model.id },
  101. });
  102. }
  103. function schemeRefreshHandle(id?: string) {
  104. invalidateCache(reportSchemeMethod(reportId.value!));
  105. schemeRefresh().then(() => nextTick()).then(() => {
  106. if ( id ) {
  107. document.querySelector(`#scrollable_scheme_${ id }`)?.scrollIntoView(
  108. { behavior: 'smooth', block: 'start', inline: 'nearest' });
  109. }
  110. });
  111. }
  112. const analysisReportPreviewOpening = ref();
  113. const historyReportPreviewOpening = ref();
  114. function openHistoryPreviewHandle() {
  115. const id = `drawer:report-history:preview`;
  116. const onDestroy = () => { VxeUI.drawer.close(id); };
  117. onDestroy();
  118. VxeUI.drawer.open({
  119. id,
  120. title: `健康档案`,
  121. maskClosable: true,
  122. escClosable: true,
  123. padding: false,
  124. width: window.innerWidth - 256,
  125. slots: {
  126. default() {
  127. return h(ReportHistoryPreview, {
  128. patient: patient.value,
  129. report: reports.value[ 0 ],
  130. onDestroy,
  131. });
  132. },
  133. },
  134. onHide() {
  135. VxeUI.modal.close();
  136. historyReportPreviewOpening.value = false;
  137. },
  138. });
  139. }
  140. function openAnalysisEditHandle() {
  141. const id = `drawer:report-analysis:edit`;
  142. const onDestroy = () => { VxeUI.drawer.close(id); };
  143. VxeUI.drawer.open({
  144. id,
  145. title: `信息采集`,
  146. maskClosable: true,
  147. escClosable: true,
  148. padding: false,
  149. width: window.innerWidth - 256,
  150. slots: {
  151. default() {
  152. return h(ReportAnalysisEdit, {
  153. patient: patient.value,
  154. report: report.value,
  155. onDestroy,
  156. });
  157. },
  158. },
  159. onHide() {
  160. VxeUI.modal.close();
  161. analysisReportPreviewOpening.value = false;
  162. },
  163. });
  164. }
  165. const patientCardRef = ref<HTMLElement & { elementTarget: HTMLElement }>();
  166. const { height } = useElementSize(patientCardRef);
  167. </script>
  168. <template>
  169. <div id="page-container-scroller" class="page-container flex flex-row">
  170. <div class="page-container-main flex-auto flex flex-col">
  171. <div class="area">
  172. <PatientCardWidget ref="patientCardRef" :dataset="patient" :loading="patientLoading" />
  173. <ReportCardWidget :dataset="report" :loading="reportLoading" collapsible v-model:collapsed="reportCollapsed">
  174. <template #analysis v-if="report.analysable">
  175. <a-button
  176. type="primary" size="small"
  177. :loading="analysisReportPreviewOpening"
  178. @click="analysisReportPreviewOpening = true;openAnalysisEditHandle()"
  179. >
  180. 信息采集
  181. </a-button>
  182. </template>
  183. <a-card class="card background no-bordered-8" size="small" title="指标信息" :loading="indicatorLoading">
  184. <a-descriptions v-if="indicator?.length" :column="3" size="small">
  185. <a-descriptions-item v-for="item in indicator" :key="item.id" :label="item.name">
  186. <div v-if="item.value">
  187. <span>{{ item.value }}</span>
  188. <span v-if="item.unit">{{ item.unit }}</span>
  189. <ArrowUpOutlined class="icon" v-if="item.records?.[0]?.abnormal === 1" />
  190. <ArrowDownOutlined class="icon" v-if="item.records?.[0]?.abnormal === -1" />
  191. </div>
  192. <span v-else>-</span>
  193. </a-descriptions-item>
  194. </a-descriptions>
  195. <div v-else style="padding-bottom: 8px;">暂无数据</div>
  196. </a-card>
  197. </ReportCardWidget>
  198. </div>
  199. <div class="area flex-auto" v-if="report?.scheme?.show">
  200. <ReportSchemeCardWidget
  201. :dataset="scheme" :loading="schemeLoading" :editable="report?.scheme?.editable"
  202. v-model:collapsed="schemeCollapsed"
  203. @refresh="schemeRefreshHandle($event)"
  204. >
  205. <template #footer v-if="report?.scheme?.editable">
  206. <div style="padding: 8px;background-color: #fff;text-align: center;">
  207. <a-button type="primary" :loading="confirmSchemeLoading" @click="confirmScheme()">确认</a-button>
  208. </div>
  209. </template>
  210. </ReportSchemeCardWidget>
  211. </div>
  212. <a-result class="area" v-if="!patientId" style="background-color: #fff;" status="warning" title="未选择用户">
  213. <template #extra>
  214. <div>请在左侧重新选择</div>
  215. </template>
  216. </a-result>
  217. <a-result class="area" v-else-if="!reportId" style="background-color: #fff;" status="warning"
  218. title="暂无健康分析"
  219. >
  220. <template #extra>
  221. <div>请重新选择</div>
  222. </template>
  223. </a-result>
  224. </div>
  225. <div class="page-container-aside flex-none flex flex-col">
  226. <PatientTagWidget
  227. style="min-height: 112px;flex: none"
  228. :style="{height: `${height}px`}"
  229. :dataset="tags" :loading="tagsLoading"
  230. editable @refresh="loadTags()"
  231. />
  232. <div class="flex-auto flex flex-col overflow-hidden">
  233. <div class="card__header flex justify-between items-center">
  234. <div class="card__title flex-none">
  235. <span>报告记录</span>
  236. <a-spin v-if="reportsLoading" size="small" style="margin-left: 4px;" />
  237. </div>
  238. <a-button type="primary" size="small" :disabled="!reportId"
  239. :loading="reportLoading || historyReportPreviewOpening"
  240. @click="historyReportPreviewOpening = true;openHistoryPreviewHandle();"
  241. >
  242. 健康档案
  243. </a-button>
  244. </div>
  245. <div class="flex-auto overflow-auto" style="background-color: #f1f1f1;">
  246. <a-empty v-if="!reportsLoading && !reports.length" />
  247. <RecycleScroller v-else ref="scroller" class="record-scroller" key-field="id"
  248. :items="reports" :item-size="40"
  249. >
  250. <template v-slot="{ item }">
  251. <div class="record-item flex justify-center items-center h-40px cursor-pointer"
  252. :class="{active: reportId == item.id}"
  253. @click="handle(item)"
  254. >
  255. {{ item.time }}
  256. </div>
  257. </template>
  258. </RecycleScroller>
  259. </div>
  260. </div>
  261. </div>
  262. </div>
  263. </template>
  264. <style scoped lang="scss">
  265. @import "@/themes/report-card";
  266. .page-container {
  267. background-color: #dfe0eb;
  268. max-height: var(--page-main-container);
  269. }
  270. .page-container-main {
  271. overflow-y: auto;
  272. > .area {
  273. margin-left: 12px;
  274. margin-bottom: 12px;
  275. background-color: #fff;
  276. &:last-of-type {
  277. margin-bottom: 0;
  278. }
  279. }
  280. }
  281. .page-container-aside {
  282. width: 256px;
  283. background-color: #fff;
  284. }
  285. .record-scroller {
  286. width: 100%;
  287. height: 100%;
  288. .record-item {
  289. padding: 4px 8px;
  290. color: #333;
  291. border-bottom: 1px solid #e5e5e5;
  292. &:hover,
  293. &.active {
  294. color: #fff;
  295. background-color: #999;
  296. }
  297. }
  298. }
  299. .ant-empty {
  300. margin: 24px;
  301. }
  302. </style>