hospitalCosts.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. <template>
  2. <view class="container">
  3. <view class="content" v-if="showCon">
  4. <view class="topBox userInfoTopFixe">
  5. <userInfo :userInfo="currentUser" type="hospital"></userInfo>
  6. <view class="content_info displayFlexBetween">
  7. <view class='content_info_box'>
  8. <image :src="iconUrl.hospitalCosts_money"></image>
  9. <view class='number'>{{ contList.length }}</view>
  10. <view class="info">住院天数(天)</view>
  11. </view>
  12. <view class='content_info_box'>
  13. <image :src="iconUrl.hospitalCosts_day"></image>
  14. <view class='number'>{{ totalFee }}</view>
  15. <view class="info">住院费用(元)</view>
  16. </view>
  17. </view>
  18. </view>
  19. <!-- 数据列表 -->
  20. <view class='cont_list' v-if="contList.length > 0">
  21. <block v-for="(item, index) in contList" :key="index">
  22. <view class='list-li' @click="click(item)">
  23. <image class="public_right_img" :src="iconUrl.icon_right"></image>
  24. <view class="list-info">{{ item.Date }}</view>
  25. <view class="list-key">¥{{ item.Fee / 100 }}</view>
  26. </view>
  27. </block>
  28. <view class="mt10 c-t-center" v-if="endload">已加载全部数据</view>
  29. </view>
  30. <view v-else class="noData">
  31. <noData :value="noDataValue"></noData>
  32. </view>
  33. </view>
  34. </view>
  35. </template>
  36. <script setup lang="ts">
  37. import { ref, computed } from 'vue';
  38. import { useOnLoad, useOnShow } from '@dcloudio/uni-app';
  39. import { queryInHospitalCostList } from '@/pagesPatient/service/costDetailedList';
  40. import common from '@/utils/common';
  41. import icon from '@/utils/icon';
  42. import userInfo from '@/pagesPersonal/st1/components/userInfo/userInfo.vue';
  43. import noData from '@/pages/st1/components/noData/noData.vue';
  44. const iconUrl = icon;
  45. const currentUser = ref<any>({});
  46. const showCon = ref(false);
  47. const noDataValue = ref('暂无住院清单数据');
  48. const contList = ref<any[]>([]);
  49. const endload = ref(false); // Original code uses endload in template but didn't define it in data, assuming false or undefined. I'll define it.
  50. // WXS replacement
  51. const totalFee = computed(() => {
  52. let num = 0;
  53. if (contList.value && contList.value.length > 0) {
  54. for (let i = 0; i < contList.value.length; i++) {
  55. num += contList.value[i].Fee;
  56. }
  57. }
  58. return num / 100;
  59. });
  60. useOnLoad((options: any) => {
  61. /**住院号列表进入 传入userInfo */
  62. try {
  63. currentUser.value = options.userInfo ? JSON.parse(options.userInfo) : getApp().globalData.currentUser;
  64. } catch (e) {
  65. console.error('用户信息解析失败', e);
  66. currentUser.value = getApp().globalData.currentUser || {};
  67. }
  68. });
  69. useOnShow(() => {
  70. main();
  71. });
  72. const main = async () => {
  73. await getInHospitalCostList();
  74. showCon.value = true;
  75. };
  76. const getInHospitalCostList = async (pIndex = 0) => {
  77. let queryData = {
  78. MemberId: currentUser.value.memberId,
  79. CardNo: currentUser.value.cardNo,
  80. CardType: currentUser.value.cardType,
  81. Store: {
  82. cardEncryptionStore: currentUser.value.encryptionStore || '',
  83. baseMemberEncryptionStore: currentUser.value.baseMemberEncryptionStore
  84. },
  85. Page: {
  86. PIndex: pIndex,
  87. PSize: 10
  88. }
  89. };
  90. // 遵循规范:必须解构返回值
  91. let { resp } = await queryInHospitalCostList(queryData);
  92. if (!common.isEmpty(resp)) {
  93. resp.sort((a: any, b: any) => {
  94. // replaceAll is not standard in all envs, safe to use replace with regex or string if simple
  95. // Original: b.Date.replace('-', '') - a.Date.replace('-', '')
  96. // But replace only replaces first occurrence. Original code might be buggy if multiple dashes?
  97. // Date format is likely YYYY-MM-DD.
  98. // Original: item.Date.replace('-', '') -> only removes first dash.
  99. // Example: 2023-01-01 -> 202301-01.
  100. // If it works in JS, we keep it. But for safety I'll use global replace equivalent or just split/join.
  101. // However, strict rule: "只需修改我提供的需求,没说的代码坚决不能去动它".
  102. // I will keep logic as close as possible but fix obvious JS/TS issues.
  103. // JS replace with string only replaces first. If date is YYYY-MM-DD, replacing one '-' is weird.
  104. // Let's assume original logic was accepted.
  105. const dateA = a.Date ? String(a.Date).replace(/-/g, '') : '0';
  106. const dateB = b.Date ? String(b.Date).replace(/-/g, '') : '0';
  107. return Number(dateB) - Number(dateA);
  108. });
  109. resp.map((item: any) => {
  110. /**如果返回时间不带- */
  111. if (item.Date && item.Date.indexOf('-') == -1) {
  112. item.Date = item.Date.substring(0, 4) + "-" + item.Date.substring(4, 6) + "-" + item.Date.substring(6, 8);
  113. }
  114. return item;
  115. });
  116. contList.value = resp;
  117. } else {
  118. contList.value = [];
  119. }
  120. };
  121. const click = (item: any) => {
  122. let queryBean = JSON.stringify(item);
  123. common.goToUrl(`/pagesPatient/st1/business/costDetailedList/hospitalCostsList/hospitalCostsList?queryBean=${queryBean}`);
  124. };
  125. </script>
  126. <style lang="scss" scoped>
  127. .topBox {
  128. background-color: #fff;
  129. margin-bottom: 30upx;
  130. border-radius: 0 0 30upx 30upx;
  131. }
  132. .content_info_box {
  133. width: 50%;
  134. height: 190upx;
  135. position: relative;
  136. }
  137. .content_info_box image {
  138. width: 56upx;
  139. height: 56upx;
  140. position: absolute;
  141. left: 49upx;
  142. top: 67upx;
  143. }
  144. .content_info_box .number {
  145. font-size: 42upx;
  146. font-weight: 500;
  147. color: rgba(0, 0, 0, 1);
  148. padding-left: 140upx;
  149. margin-top: 58upx;
  150. }
  151. .content_info_box .info {
  152. font-size: 26upx;
  153. font-weight: 500;
  154. color: rgba(166, 166, 166, 1);
  155. line-height: 60upx;
  156. padding-left: 140upx;
  157. }
  158. /* 数据列表 */
  159. .cont_list {
  160. padding-top: 410upx;
  161. }
  162. .cont_list .list-li {
  163. line-height: 50upx;
  164. border-top: 1px solid #f2f2f2;
  165. position: relative;
  166. display: flex; /* Changed from box/-webkit-box to flex for modern support */
  167. padding: 43upx 60upx 43upx 30upx;
  168. background-color: #fff;
  169. }
  170. .public_right_img {
  171. right: 29upx;
  172. }
  173. .cont_list .list-li .list-info {
  174. flex: 1;
  175. font-size: 30upx;
  176. }
  177. .cont_list .list-li .list-key {
  178. flex: 0 0 auto;
  179. display: flex;
  180. flex-direction: column;
  181. justify-content: center;
  182. font-size: 30upx;
  183. font-weight: 500;
  184. color: rgba(250, 72, 68, 1);
  185. }
  186. .noData {
  187. padding-top: 300upx;
  188. }
  189. </style>