bloodPressureAbnormal.vue 5.2 KB

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