uricAcidAbnormal.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. <template>
  2. <view>
  3. <myTabbar :tabList="tabList" :current="activeTab" @change="changeTab" />
  4. <!-- <swiper :current="activeTab" @change="onSwiperChange" :style="'height:' + clientHeight + 'px;'">
  5. <swiper-item v-for="(tab,index) in tabList" :key="index"> -->
  6. <scroll-view scroll-y="true" :style="'height:' + clientHeight + 'px;'" @scrolltolower="scrolltolower">
  7. <template v-if="list &&list.length > 0">
  8. <abnormalList :abnormalList="abnormalList" :unit="'umol/L'" :type="'ua'" @monthChange="monthChange">
  9. <template v-slot:default="slotProps">
  10. <view :class="'slotview status'+slotProps.data.status" v-if="slotProps.data.status == 1">
  11. <text>高</text><text>风险</text>
  12. </view>
  13. <view :class="'slotview status'+slotProps.data.status" v-else>
  14. {{_typeText(slotProps.data.status)}}
  15. </view>
  16. </template>
  17. </abnormalList>
  18. </template>
  19. <view v-else>
  20. <myEmpty />
  21. </view>
  22. <!-- <view class="loading">
  23. <view class="tips" v-if="loadings === '0'">这是我的底线了~</view>
  24. <view class="tips" v-else-if="loadings === '1'">上拉加载更多...</view>
  25. <view class="imgs" v-else-if="loadings === '2'">
  26. <image src="load.png" mode=""></image>
  27. <text>加载中...</text>
  28. </view>
  29. </view> -->
  30. </scroll-view>
  31. <!-- </swiper-item>
  32. </swiper> -->
  33. </view>
  34. </template>
  35. <script>
  36. import abnormalList from "@/pages_watch/components/abnormalList/abnormalList.vue"
  37. import { uaPageList } from "@/api/pages_watch/healthMonitoring.js"
  38. import myTabbar from "@/pages_watch/components/myTabbar/myTabbar.vue"
  39. import myEmpty from "@/pages_watch/components/myEmpty/myEmpty.vue"
  40. export default {
  41. components: {
  42. abnormalList,
  43. myEmpty,
  44. myTabbar
  45. },
  46. data() {
  47. return {
  48. loading: false,
  49. isMore: true,
  50. activeTab: 0,
  51. tabList: [{
  52. id: 0,
  53. name: '全部'
  54. }, {
  55. id: 1,
  56. name: '高风险'
  57. }, {
  58. id: 2,
  59. name: '不良'
  60. },{
  61. id: 3,
  62. name: '正常'
  63. }],
  64. clientHeight: 0,
  65. scrollViewId: 'scrollView0',
  66. queryParam: {
  67. startTime: undefined,
  68. endTime: undefined,
  69. deviceId: undefined,
  70. status: '',
  71. pageSize: 10,
  72. pageNum: 1,
  73. },
  74. total: 0,
  75. abnormalList: {},
  76. list: [],
  77. }
  78. },
  79. computed: {
  80. _typeText() {
  81. const txt = {
  82. 2: '高风险',
  83. 1: '不良',
  84. 0: '正常',
  85. }
  86. return (type) => {
  87. return txt[type] || ''
  88. }
  89. }
  90. },
  91. onLoad(option) {
  92. this.queryParam.startTime = option.startTime
  93. this.queryParam.endTime = option.endTime
  94. this.queryParam.deviceId = uni.getStorageSync("deviceId")
  95. this.refresh()
  96. },
  97. onReady() {
  98. uni.getSystemInfo({
  99. success: (res) => {
  100. this.clientHeight = res.windowHeight - uni.upx2px(100);
  101. }
  102. })
  103. },
  104. methods: {
  105. changeTab(e) {
  106. this.activeTab = e.index;
  107. this.refresh()
  108. },
  109. // swiper划动
  110. onSwiperChange(e) {
  111. this.changeIdx(e.detail.current);
  112. },
  113. // 更新当前页
  114. changeIdx(index) {
  115. if (this.activeTab === index) return;
  116. this.activeTab = index;
  117. this.scrollViewId = 'scrollView' + this.activeTab;
  118. this.refresh()
  119. },
  120. // 获取数据
  121. getList() {
  122. this.loading = true
  123. this.queryParam.status = this.activeTab > 0 ? this.activeTab - 1 : ''
  124. uaPageList(this.queryParam).then(res => {
  125. this.loading = false
  126. if (res.code == 0) {
  127. let list = res.rows && res.rows.length > 0 ? res.rows : []
  128. this.list = this.list.concat(list)
  129. this.total = res.total
  130. this.queryParam.pageNum++
  131. if (this.list.length >= this.total) {
  132. this.isMore = false
  133. }
  134. this.resetData(this.list)
  135. }
  136. }).catch(() => {
  137. this.loading = false
  138. })
  139. },
  140. resetData(array) {
  141. this.abnormalList = array.reduce((acc, obj) => {
  142. const [year, month] = obj.createTime.split(' ')[0].split('-');
  143. const date = obj.createTime.split(' ')[0];
  144. if (!acc[`${year}-${month}`]) {
  145. acc[`${year}-${month}`] = {};
  146. }
  147. if (!acc[`${year}-${month}`][date]) {
  148. acc[`${year}-${month}`][date] = [];
  149. }
  150. obj.num = obj.val
  151. acc[`${year}-${month}`][date].push(obj);
  152. return acc;
  153. }, {});
  154. },
  155. refresh() {
  156. this.loading = false
  157. this.isMore = true
  158. this.queryParam.pageNum = 1
  159. this.list = []
  160. this.getList()
  161. },
  162. // 滚动到底部
  163. scrolltolower() {
  164. if (this.isMore) {
  165. this.getList()
  166. }
  167. },
  168. // 改变月份(时间范围:查询选中的月份-现在的月份) 2024-07
  169. monthChange(month) {
  170. const date = month + "-01 00:00:00"
  171. this.queryParam.startTime = this.$timeFormat(date, "yyyy/mm/dd hh:MM:ss")
  172. this.queryParam.endTime = this.$timeFormat(new Date(), "yyyy/mm/dd hh:MM:ss")
  173. this.refresh()
  174. }
  175. }
  176. }
  177. </script>
  178. <style lang="scss" scoped>
  179. @mixin u-flex($flexD, $alignI, $justifyC) {
  180. display: flex;
  181. flex-direction: $flexD;
  182. align-items: $alignI;
  183. justify-content: $justifyC;
  184. }
  185. .status2 {
  186. background: #FF5558;
  187. }
  188. .status1 {
  189. background: #FFB992;
  190. }
  191. .status0 {
  192. background: #52D087;
  193. }
  194. .slotview {
  195. display: inline-block;
  196. flex-shrink: 0;
  197. width: 72rpx;
  198. height: 72rpx;
  199. border-radius: 50%;
  200. overflow: hidden;
  201. font-size: 20rpx;
  202. color: #FFFFFF;
  203. text-align: center;
  204. padding: 10rpx;
  205. @include u-flex(column, center, center);
  206. box-sizing: border-box;
  207. margin-right: 18rpx;
  208. }
  209. </style>