StepPage.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. <script setup lang="ts">
  2. import type { UploaderAfterRead, UploaderFileListItem } from 'vant';
  3. import { useRequest } from 'alova/client';
  4. import { getDataMethod } from '@/api/pda.api.ts';
  5. import { uploadMethod } from '@/api/file.api.ts';
  6. import { useStepStore } from '@/stores';
  7. import { useStep } from '@/core/hook/useStep.ts';
  8. import { type ScanData, useScan } from '@/core/hook/useScan.ts';
  9. const stepStore = useStepStore();
  10. const { dataset, id, mode } = storeToRefs(stepStore);
  11. const loaded = computed(() => !!id.value);
  12. const keyword = ref('');
  13. const tabIndex = ref(0);
  14. const { menu, tabTitle, next, prev } = useStep(mode, id);
  15. watchEffect(() => {
  16. keyword.value = id.value;
  17. nextTick(() => {
  18. tabIndex.value = id.value ? 3 : 0;
  19. if (!id.value) {
  20. stepStore.$reset();
  21. step.value?.reset?.();
  22. files.value = []
  23. scanValue.value = ''
  24. }
  25. });
  26. });
  27. const step = useTemplateRef<{ scan?: (data: ScanData) => void; reset?: () => void; }>('step');
  28. const { scanValue, scan } = useScan((data) => {
  29. /* 组件内扫描按钮 */
  30. if (tabIndex.value === 3 && typeof step.value?.scan === 'function') {
  31. scanValue.value = data.code;
  32. step.value.scan(data);
  33. } else {
  34. keyword.value = data.code;
  35. onSearch();
  36. }
  37. });
  38. const { loading, send: search } = useRequest(getDataMethod, { immediate: false })
  39. .onSuccess(({ data }) => {
  40. dataset.value = data;
  41. next(dataset.value.no);
  42. })
  43. .onError(() => {
  44. keyword.value = '';
  45. });
  46. function onSearch() {
  47. const value = keyword.value?.trim?.();
  48. if (value) {
  49. search(value, mode.value);
  50. } else {
  51. showNotify({ message: '请使用设备按钮进行扫码', type: 'warning' });
  52. }
  53. }
  54. function onBack() {
  55. prev();
  56. }
  57. const files = ref<UploaderFileListItem[]>([]);
  58. const picture = computed(() => files.value.filter((file) => file.status === 'done' && file.url != null).map((file) => file.url));
  59. const afterRead: UploaderAfterRead = async (listItem) => {
  60. if (listItem && !Array.isArray(listItem)) listItem = [listItem];
  61. for (const item of listItem) {
  62. if (!item?.file) continue;
  63. item.status = 'uploading';
  64. item.message = '上传中...';
  65. try {
  66. item.url = await uploadMethod(item.file!);
  67. item.status = 'done';
  68. } catch (error) {
  69. console.error('[file] 文件上传失败', error);
  70. item.status = 'failed';
  71. }
  72. }
  73. };
  74. </script>
  75. <template>
  76. <div class="page page__home flex flex-col size-full">
  77. <van-toast :show="loading" type="loading" forbid-click message="查询中..." />
  78. <header class="flex-none">
  79. <van-nav-bar :title="menu?.title" left-text="返回" left-arrow @click-left="onBack()" />
  80. <van-search v-model="keyword" input-align="center" placeholder="请使用设备按钮进行扫码" @search="onSearch()" :readonly="loaded" :show-action="loaded" @cancel="onBack()" />
  81. </header>
  82. <van-tabs class="content flex-auto overflow-hidden" v-model:active="tabIndex">
  83. <van-tab title="就诊信息">
  84. <van-cell-group>
  85. <van-cell title="患者" :value="dataset?.patient?.name" />
  86. <van-cell title="性别" :value="dataset?.patient?.gender" />
  87. <van-cell title="年龄" :value="dataset?.patient?.age" />
  88. <van-cell title="手机号" :value="dataset?.patient?.phone" />
  89. <van-cell title="医院" :value="dataset?.patient?.hospital" />
  90. <van-cell title="门诊/住院" :value="dataset?.patient?.category" />
  91. <van-cell title="科室/病区" :value="[dataset?.patient?.department, dataset?.patient?.area].filter((v) => !!v).join('/')" />
  92. <van-cell title="病床" :value="dataset?.patient?.bed" />
  93. <van-cell title="临床诊断" :value="dataset?.patient?.name" />
  94. <van-cell title="开方医生" :value="dataset?.doctor?.name" />
  95. </van-cell-group>
  96. </van-tab>
  97. <van-tab title="处方信息">
  98. <van-cell-group>
  99. <van-cell title="处方类型" :value="dataset?.prescription?.category" />
  100. <van-cell title="处方状态" :value="dataset?.order?.state" />
  101. <van-cell title="总金额" :value="dataset?.prescription?.totalPrice" />
  102. <van-cell title="剂型" :value="dataset?.prescription?.dosageForm" />
  103. <van-cell title="剂数" :value="dataset?.prescription?.count" />
  104. <van-cell title="处方用法" :value="dataset?.prescription?.method" />
  105. <van-cell title="服药频次" :value="dataset?.prescription?.frequency" />
  106. <van-cell title="服药时间" :value="dataset?.prescription?.frequencyTime" />
  107. <van-cell title="煎药量" :value="dataset?.prescription?.volume" />
  108. <van-cell title="是否代煎" :value="dataset?.prescription?.decoction" />
  109. <van-cell title="开方医生备注" :value="dataset?.prescription?.remark1" />
  110. <van-cell title="配送方式" :value="dataset?.prescription?.dispatch?.method" />
  111. <van-cell title="收货人" :value="dataset?.prescription?.dispatch?.name" />
  112. <van-cell title="收货电话" :value="dataset?.prescription?.dispatch?.phone" />
  113. <van-cell title="收货地址" :value="dataset?.prescription?.dispatch?.address" value-class="flex-2" />
  114. <van-cell title="嘱托" :value="dataset?.prescription?.entrust" />
  115. <van-cell title="药师备注" :value="dataset?.prescription?.remark2" />
  116. </van-cell-group>
  117. </van-tab>
  118. <van-tab title="药品信息">
  119. <table class="min-w-[600px] w-full">
  120. <thead>
  121. <tr>
  122. <th scope="col"></th>
  123. <th scope="col">药品名称</th>
  124. <th scope="col">药品规格</th>
  125. <th scope="col">剂量</th>
  126. <th scope="col">单位</th>
  127. <th scope="col">用法</th>
  128. <th scope="col">零售价</th>
  129. <th scope="col">产地</th>
  130. <th scope="col">小计</th>
  131. </tr>
  132. </thead>
  133. <tbody>
  134. <tr v-for="(medicine, index) in dataset?.medicines" :key="medicine.id">
  135. <th scope="row">{{ index + 1 }}</th>
  136. <td class="w-24">{{ medicine.name }}</td>
  137. <td>{{ medicine.size }}</td>
  138. <td style="text-align: right">{{ medicine.dosage }}</td>
  139. <td>{{ medicine.unit }}</td>
  140. <td>{{ medicine.usage }}</td>
  141. <td>{{ medicine.place }}</td>
  142. <td style="text-align: right">{{ medicine.unitPrice }}</td>
  143. <td style="text-align: right">{{ medicine.totalPrice }}</td>
  144. </tr>
  145. </tbody>
  146. </table>
  147. </van-tab>
  148. <van-tab :title="tabTitle" :disabled="!loaded">
  149. <router-view>
  150. <component ref="step" :is="menu?.component" @back="onBack()">
  151. <template v-slot:scanner="{ title, disabled }">
  152. <van-field
  153. :label="title"
  154. :readonly="disabled"
  155. placeholder="请使用设备按钮进行扫码"
  156. right-icon="scan"
  157. @click-right-icon="!disabled && scan()"
  158. v-model="scanValue"
  159. @update:model-value="scan($event)"
  160. />
  161. </template>
  162. <template v-slot:uploader="{ disabled }">
  163. <van-field label="拍照上传">
  164. <template #input>
  165. <van-uploader v-model="files" :after-read="afterRead" :disabled="disabled" capture="camera" />
  166. </template>
  167. </van-field>
  168. </template>
  169. <template v-slot:submit="{ title, submitting, submit }">
  170. <div class="flex my-4 px-4 gap-4" id="bottom-handle">
  171. <van-button type="primary" block :loading="submitting" @click="submit(picture)">{{ title }}</van-button>
  172. </div>
  173. </template>
  174. </component>
  175. </router-view>
  176. </van-tab>
  177. </van-tabs>
  178. </div>
  179. </template>
  180. <style scoped lang="scss">
  181. .content {
  182. display: flex;
  183. flex-direction: column;
  184. :deep(.van-tabs__wrap) {
  185. flex: none;
  186. }
  187. :deep(.van-tabs__content) {
  188. flex: auto;
  189. overflow: auto;
  190. }
  191. //--van-cell-text-color: #fff
  192. --van-cell-value-color: var(--van-text-color);
  193. --van-cell-text-color: var(--van-text-color-2);
  194. table {
  195. border-collapse: collapse;
  196. border: 2px solid rgb(140 140 140);
  197. font-size: 14px;
  198. letter-spacing: 1px;
  199. }
  200. thead,
  201. tfoot {
  202. background-color: rgb(228 240 245);
  203. }
  204. th,
  205. td {
  206. border: 1px solid rgb(160 160 160);
  207. padding: 8px 10px;
  208. text-align: center;
  209. }
  210. }
  211. </style>
  212. <style>
  213. .flex-2 {
  214. flex: 2;
  215. }
  216. </style>