abnormalPageList.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <template>
  2. <scroll-view scroll-y="true" :style="'height:' + clientHeight + 'px;'" @scrolltolower="scrolltolower">
  3. <template v-if="list &&list.length > 0">
  4. <abnormalList :abnormalList="abnormalList" :unit="'mmHg'" :type="'bp'"
  5. @monthChange="monthChange">
  6. <template v-slot:default="slotProps">
  7. <view :class="'slotview status'+slotProps.data.status">
  8. {{_typeText(slotProps.data.status)}}</view>
  9. </template>
  10. </abnormalList>
  11. </template>
  12. <view v-else>
  13. <myEmpty />
  14. </view>
  15. </scroll-view>
  16. </template>
  17. <script>
  18. import abnormalList from "@/pages_watch/components/abnormalList/abnormalList.vue"
  19. import myEmpty from "@/pages_watch/components/myEmpty/myEmpty.vue"
  20. import {bpInfoPage} from "@/api/pages_watch/healthMonitoring.js";
  21. export default {
  22. props: {
  23. clientHeight: {
  24. type: Number,
  25. default: 0
  26. }
  27. },
  28. components: {
  29. abnormalList,
  30. myEmpty
  31. },
  32. data() {
  33. return {
  34. activeTab: 0,
  35. loading: false,
  36. isMore: true,
  37. queryParam: {
  38. startTime: undefined,
  39. endTime: undefined,
  40. deviceId: undefined,
  41. status: undefined,
  42. pageSize: 10,
  43. pageNum: 1,
  44. },
  45. total: 0,
  46. abnormalList: {},
  47. list: [],
  48. }
  49. },
  50. methods: {
  51. // 获取数据
  52. getList() {
  53. this.loading = true
  54. this.queryParam.status = this.activeTab > 0 ? this.activeTab : undefined
  55. this.queryParam.deviceId = uni.getStorageSync("deviceId")
  56. bpInfoPage(this.queryParam).then(res => {
  57. this.loading = false
  58. if (res.code == 0) {
  59. let list = res.rows && res.rows.length > 0 ? res.rows : []
  60. this.list = this.list.concat(list)
  61. this.total = res.total
  62. this.queryParam.pageNum++
  63. if (this.list.length >= this.total) {
  64. this.isMore = false
  65. }
  66. this.resetData(this.list)
  67. }
  68. }).catch(() => {
  69. this.loading = false
  70. })
  71. },
  72. resetData(array) {
  73. this.abnormalList = array.reduce((acc, obj) => {
  74. const [year, month] = obj.createTime.split(' ')[0].split('-');
  75. const date = obj.createTime.split(' ')[0];
  76. if (!acc[`${year}-${month}`]) {
  77. acc[`${year}-${month}`] = {};
  78. }
  79. if (!acc[`${year}-${month}`][date]) {
  80. acc[`${year}-${month}`][date] = [];
  81. }
  82. obj.num = obj.sbp + '/' + obj.dbp
  83. acc[`${year}-${month}`][date].push(obj);
  84. return acc;
  85. }, {});
  86. },
  87. refresh(activeTab) {
  88. this.activeTab = activeTab || this.activeTab
  89. this.loading = false
  90. this.isMore = true
  91. this.queryParam.pageNum = 1
  92. this.list = []
  93. this.getList()
  94. },
  95. // 滚动到底部
  96. scrolltolower() {
  97. if (this.isMore) {
  98. this.getList()
  99. }
  100. },
  101. // 改变月份(时间范围:查询选中的月份-现在的月份) 2024-07
  102. monthChange(month) {
  103. const date = month + "-01 00:00:00"
  104. this.queryParam.startTime = this.$timeFormat(date, "yyyy/mm/dd hh:MM:ss")
  105. this.queryParam.endTime = this.$timeFormat(new Date(), "yyyy/mm/dd hh:MM:ss")
  106. this.refresh()
  107. }
  108. }
  109. }
  110. </script>
  111. <style lang="scss" scoped>
  112. </style>