index.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. <template>
  2. <div>
  3. <div class="mx-2 mb-6" v-for="item in basicData" :key="item.type">
  4. <DescCard
  5. :icon="item.icon"
  6. :title="item.title"
  7. :type="item.type"
  8. :data="item.data"
  9. @icon="callIcon"
  10. :id="info.id"
  11. />
  12. </div>
  13. <FormModal @register="registerModal" @success="callSuccess" />
  14. </div>
  15. </template>
  16. <script setup lang="ts">
  17. import { ref, reactive } from 'vue';
  18. import DescCard from '/@/components/XTCard/src/DescCard.vue';
  19. import { BasicData } from './data';
  20. import { onMounted } from 'vue';
  21. import { useModal } from '/@/components/Modal';
  22. import FormModal from './FormModal.vue';
  23. import { archivesPatientBasicDetail } from '/@/api/biz/archives/patientBasicApi';
  24. import { archivesVascularAccessQueryCurrent } from '/@/api/biz/archives/vascularAccessApi';
  25. import {
  26. archivesDiagnosisHistoryQueryListSingle,
  27. archivesDiagnosisHistoryQueryListMulti,
  28. } from '@/api/biz/archives/diagnosisHistoryApi';
  29. import { listDictModelBatch } from '/@/api/common';
  30. import { formatDictColor, formatDictFontColor, formatDictTags, formatDictValue } from '/@/utils';
  31. import dayjs from 'dayjs';
  32. import { nanoid } from 'nanoid';
  33. import { DiagnosisEnum } from '../diagnosisHistory/data';
  34. const props = defineProps({
  35. info: {
  36. type: Object,
  37. default: () => {},
  38. } as any,
  39. });
  40. const bizDictOptions = reactive({
  41. gender: [],
  42. cardType: [],
  43. bloodType: [],
  44. type: [],
  45. infectiousDiseases: [],
  46. accessType: [],
  47. });
  48. const bizDictData = ref([
  49. { key: 'gender', dictCode: 'pb_sex' },
  50. { key: 'cardType', dictCode: 'pb_card' },
  51. { key: 'bloodType', dictCode: 'pb_blood' },
  52. { key: 'type', dictCode: 'pb_type' },
  53. { key: 'infectiousDiseases', dictCode: 'pb_epidemic' },
  54. { key: 'accessType', dictCode: 'va_type' },
  55. { key: 'dt', dictCode: 'dt' },
  56. { key: 'allergic', dictCode: 'allergic' },
  57. { key: 'allergic_food', dictCode: 'allergic_food' },
  58. { key: 'allergic_touch', dictCode: 'allergic_touch' },
  59. { key: 'allergic_air', dictCode: 'allergic_air' },
  60. { key: 'allergic_inject', dictCode: 'allergic_inject' },
  61. { key: 'contagious_status', dictCode: 'contagious_status' },
  62. { key: 'pb_epidemic', dictCode: 'pb_epidemic' },
  63. { key: 'complications', dictCode: 'complications' },
  64. { key: 'complications_breath', dictCode: 'complications_breath' },
  65. { key: 'complications_blood', dictCode: 'complications_blood' },
  66. { key: 'complications_incretion', dictCode: 'complications_incretion' },
  67. { key: 'clinic', dictCode: 'clinic' },
  68. { key: 'clinic_breath', dictCode: 'clinic_breath' },
  69. { key: 'clinic_heart', dictCode: 'clinic_heart' },
  70. { key: 'clinic_blood', dictCode: 'clinic_blood' },
  71. { key: 'clinic_hbgr', dictCode: 'clinic_hbgr' },
  72. { key: 'pathological', dictCode: 'pathological' },
  73. { key: 'pathological_breath', dictCode: 'pathological_breath' },
  74. { key: 'pathological_heart', dictCode: 'pathological_heart' },
  75. { key: 'pathological_blood', dictCode: 'pathological_blood' },
  76. { key: 'pathological_hbgr', dictCode: 'pathological_hbgr' },
  77. { key: 'ckd', dictCode: 'ckd' },
  78. { key: 'ckd_breath', dictCode: 'ckd_breath' },
  79. { key: 'ckd_heart', dictCode: 'ckd_heart' },
  80. { key: 'ckd_blood', dictCode: 'ckd_blood' },
  81. { key: 'ckd_hbgr', dictCode: 'ckd_hbgr' },
  82. ]);
  83. onMounted(async () => {
  84. const res = await listDictModelBatch(bizDictData.value.map(ele => ele.dictCode));
  85. for (const i in res) {
  86. const filter = bizDictData.value.filter(ele => ele.dictCode == i)[0];
  87. bizDictOptions[filter.key] = res[i];
  88. }
  89. await getData();
  90. });
  91. const [registerModal, { openModal }] = useModal();
  92. const basicData = ref(BasicData);
  93. // 获取数据
  94. async function getData() {
  95. const res = await archivesPatientBasicDetail(props.info?.id);
  96. basicData.value[0].data = basicData.value[0].data.map(ele => {
  97. if (ele.dict) {
  98. ele.value = formatDictValue(bizDictOptions[ele.field], res[ele.field]);
  99. } else {
  100. ele.value = res[ele.field];
  101. }
  102. if (ele.dictField) {
  103. ele[ele.dictField] = formatDictValue(bizDictOptions[ele.dictName], res[ele.dictName]);
  104. }
  105. if (Array.isArray(ele.tags)) {
  106. if (res[ele.field]?.length) {
  107. const value = res[ele.field].map(v => {
  108. return {
  109. value: v,
  110. };
  111. });
  112. ele.tags = formatDictTags(bizDictOptions[ele.field], value);
  113. ele.value = ele.hiddenValue ? '' : res[ele.field];
  114. }
  115. }
  116. // if (ele.field == 'age') {
  117. // ele.value = dayjs().diff(res['birthday'], 'year') || 1;
  118. // }
  119. if (ele.field == 'birthday') {
  120. ele.value = dayjs(res['birthday']).format('YYYY-MM-DD');
  121. }
  122. return ele;
  123. });
  124. console.log(
  125. '🚀 ~ file: index.vue:127 ~ getData ~ basicData.value[0].data:',
  126. basicData.value[0].data,
  127. );
  128. const vascularAccessRes = await archivesVascularAccessQueryCurrent(props.info?.id);
  129. basicData.value[1].data =
  130. (vascularAccessRes &&
  131. basicData.value[1].data.map(ele => {
  132. if (ele.field == 'type') {
  133. ele.value = formatDictValue(bizDictOptions['accessType'], vascularAccessRes[ele.field]);
  134. } else {
  135. ele.value = vascularAccessRes[ele.field];
  136. }
  137. return ele;
  138. })) ||
  139. [];
  140. basicData.value[2].data = [];
  141. // 诊断记录
  142. const DiagnosisHistoryMulti = await archivesDiagnosisHistoryQueryListMulti(props.info?.id);
  143. console.log(
  144. '🚀 ~ file: index.vue:158 ~ getData ~ DiagnosisHistoryMulti:',
  145. DiagnosisHistoryMulti,
  146. );
  147. // basicData.value[2].data =
  148. // (DiagnosisHistoryMulti &&
  149. // basicData.value[2].data.map(ele => {
  150. // const detail = DiagnosisHistoryMulti[ele.field][0];
  151. // console.log('detail', ele.field, detail);
  152. // // const content = detail['multiContent'][0];
  153. // detail['multiContent'].forEach(content => {
  154. // if (detail.type == 'elseRemark') {
  155. // ele.value = content['remark'];
  156. // // ele.span = 12;
  157. // ele.field = 'elseRemark';
  158. // ele.title = '其他诊断';
  159. // return ele;
  160. // }
  161. // if (!content.type) {
  162. // return ele;
  163. // }
  164. // ele.value = formatDictValue(bizDictOptions[detail.type], content['type']);
  165. // ele.tags = content.multiName.map(mEle => {
  166. // return {
  167. // id: nanoid(),
  168. // label: formatDictValue(bizDictOptions[content.type], mEle),
  169. // fontColor: formatDictFontColor(bizDictOptions[detail.type], content.type),
  170. // bgColor: formatDictColor(bizDictOptions[detail.type], content.type),
  171. // };
  172. // });
  173. // // ele.span = 12;
  174. // return ele;
  175. // });
  176. // })) ||
  177. // [];
  178. // const mapData = [];
  179. for (const i in DiagnosisHistoryMulti) {
  180. // console.log('🚀 ~ file: index.vue:178 ~ getData ~ i:', i);
  181. getDiagnosisMulti(DiagnosisHistoryMulti[i], i);
  182. }
  183. const firstDialysisRes = await archivesDiagnosisHistoryQueryListSingle(props.info?.id);
  184. const firstDialysisResContent = firstDialysisRes.firstDialysis?.content[0];
  185. basicData.value[2].data.unshift({
  186. field: 'first',
  187. label: '首次透析111',
  188. value: firstDialysisResContent?.recordTime
  189. ? dayjs(firstDialysisResContent?.recordTime).format('YYYY-MM-DD')
  190. : '',
  191. tags: [
  192. {
  193. id: nanoid(5),
  194. label: formatDictValue(bizDictOptions['dt'], firstDialysisResContent?.contentType),
  195. type: 'success',
  196. },
  197. ],
  198. });
  199. }
  200. function getDiagnosisMulti(data, field) {
  201. if (data && data.length) {
  202. data.forEach(detail => {
  203. detail['multiContent'].forEach(content => {
  204. const obj = {} as any;
  205. obj.field = field + '_field';
  206. obj.label = DiagnosisEnum[field];
  207. if (field == DiagnosisEnum.elseRemark_field) {
  208. obj.value = content['remark'];
  209. } else {
  210. if (!content.type) return;
  211. obj.value = formatDictValue(bizDictOptions[detail.type], content['type']);
  212. obj.tags = content.multiName.map(mEle => {
  213. return {
  214. id: nanoid(),
  215. label: formatDictValue(bizDictOptions[content.type], mEle),
  216. fontColor: formatDictFontColor(bizDictOptions[detail.type], content.type),
  217. bgColor: formatDictColor(bizDictOptions[detail.type], content.type),
  218. };
  219. });
  220. }
  221. // obj.span = 12;
  222. basicData.value[2].data.push(obj);
  223. });
  224. });
  225. }
  226. }
  227. // 回调
  228. function callIcon(data) {
  229. console.log('🚀 ~ file: index.vue:16 ~ callIcon ~ data:', data);
  230. openModal(true, {
  231. isUpdate: true,
  232. record: data,
  233. });
  234. }
  235. async function callSuccess(data) {
  236. console.log('🚀 ~ file: index.vue:39 ~ handleSuccess ~ data:', data);
  237. await getData();
  238. }
  239. </script>
  240. <style lang="less" scoped></style>