OrdersList.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <!-- 全部医嘱 / 需处理 -->
  2. <template>
  3. <view class="table-scroll-container-OL">
  4. <view class="content-wrap">
  5. <view
  6. v-if="tableData.length > 0"
  7. class="exe-item"
  8. v-for="(item, index) in tableData"
  9. :key="index">
  10. <Detailtem
  11. :data="item"
  12. v-slot="data">
  13. <view
  14. v-if="data.visible"
  15. @tap="showDetail(item)"
  16. class="item-right-li milt">
  17. <text class="priamry">执行明细</text>
  18. <van-icon name="arrow" />
  19. </view>
  20. </Detailtem>
  21. </view>
  22. <!-- 暂无数据组件:默认样式 -->
  23. <no-data v-if="tableData.length === 0"></no-data>
  24. <DetailList
  25. :visibleDetail="visibleDetail"
  26. :close="() => (visibleDetail = false)"
  27. :detailData="detailData" />
  28. </view>
  29. </view>
  30. </template>
  31. <script setup>
  32. import { ref, watch, onMounted, nextTick } from 'vue';
  33. import { $http } from '../../../config/https';
  34. import NoData from './NoData.vue';
  35. import Util from '../../../utils/util.js';
  36. import Detailtem from './Detailtem.vue';
  37. import DetailList from './DetailList.vue';
  38. const props = defineProps({
  39. activeTab: {type: Number,default: 0},
  40. patNo:{type: String ,default: ''},
  41. });
  42. const userData = ref(uni.getStorageSync('userData') || {});
  43. const visibleDetail = ref(false); // 详情显示
  44. const detailData = ref('');
  45. // 执行列表数据
  46. const tableData = ref([]);
  47. //获取医嘱列表数据
  48. const getPatYZInfo = (code) => {
  49. $http.post('urlDeault',this, {
  50. code: '04220025',
  51. data: {
  52. params: [{
  53. "hospID": userData.value.hospID,
  54. "sheetCode": code ? code :"QBYZ",
  55. "locID": userData.value.locID,
  56. "stDate": '',
  57. "stTime": "00:00:00",
  58. "endDate": '',
  59. "endTime": "23:59:59",
  60. "patients": [props.patNo]
  61. }]
  62. },
  63. success: function(res) {
  64. if (+res.errorCode === 0) {
  65. // 执行转换
  66. const transformedData = transformOrderData(res.result.order);
  67. tableData.value = transformedData;
  68. }
  69. },
  70. });
  71. }
  72. /**
  73. * 处理医嘱数据,转换为指定格式的数组
  74. * @param {Array} originalData 原始医嘱数据数组
  75. * @returns {Array} 转换后的格式化数组
  76. */
  77. const transformOrderData =(originalData)=> {
  78. // 定义type可选值,用于随机分配
  79. const typeOptions = ['primary', 'warning', 'default', 'success','error'];
  80. // 处理空数据情况
  81. if (!Array.isArray(originalData) || originalData.length === 0) {
  82. return [];
  83. }
  84. // 封装单个item转换为exeMedications项的逻辑(复用)
  85. const getMedicationItem = (item) => {
  86. return {
  87. name: item.medDesc || '', // 赋值medDesc
  88. useArr: (item.ordText || '')
  89. .split('^') // 按^拆分
  90. // .filter(part => part.trim() !== '') // 过滤空值
  91. .map((part,index) => ({
  92. label: part.trim(),
  93. type: index === 5 ? 'warning' : 'primary'
  94. }))
  95. };
  96. };
  97. // 遍历原始数据进行转换
  98. return originalData.map(item => {
  99. // 1. 计算已执行数量和总数量,生成showNum
  100. const totalExecCount = Array.isArray(item.execInfos) ? item.execInfos.length : 0;
  101. const executedCount = Array.isArray(item.execInfos)
  102. ? item.execInfos.filter(exec => exec.statusDesc === '已执行').length
  103. : 0;
  104. const showNum = `${executedCount}/${totalExecCount}`;
  105. // 2. 处理exeMedications:先加当前item,再加children里的所有item
  106. const exeMedications = [];
  107. // 先添加当前item的medication
  108. exeMedications.push(getMedicationItem(item));
  109. // 再添加children数组中的所有item(判断children存在且为数组)
  110. if (Array.isArray(item.children) && item.children.length > 0) {
  111. item.children.forEach(child => {
  112. exeMedications.push(getMedicationItem(child));
  113. });
  114. }
  115. // 3. 处理exeTimes:过滤未执行的execInfos,提取时间并设置state
  116. const unExecutedInfos = Array.isArray(item.execInfos)
  117. ? item.execInfos.filter(exec => exec.statusDesc === '未执行')
  118. : [];
  119. // 4. 组装最终对象
  120. return {
  121. exeDateTime: item.execTime || '', // execTime赋值给exeDateTime
  122. showNum,
  123. exeMedications,
  124. execInfos: item.execInfos,
  125. startDeteTime: item.ordStartDateTime.slice(5, 16),
  126. endDeteTime: item.ordStopDateTime.slice(5, 16),
  127. ordID: item.ordID
  128. };
  129. });
  130. }
  131. watch(
  132. () => props.activeTab,
  133. (newVal) => {
  134. if (newVal === 0) return;
  135. const currentType = +newVal === 1 ? 'QBYZ' : 'HandlerOrder';
  136. getPatYZInfo(currentType);
  137. },
  138. { immediate: true, deep: true },
  139. );
  140. // 查看详情
  141. const showDetail = (data) => {
  142. visibleDetail.value = true;
  143. detailData.value = data;
  144. };
  145. </script>
  146. <style scoped>
  147. @import url(../common.css);
  148. </style>