index.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. <template>
  2. <!-- 报警、告警 -->
  3. <view :style="{height:(heightfield - 30) + 'px',}">
  4. <view class="card_time_row">
  5. <view class="time_picker">
  6. <view class="time_title">开始时间</view>
  7. <uni-datetime-picker style="width: 210rpx;" type="datetime" :clear-icon="false" v-model="startTime"
  8. @change="maskClick" />
  9. </view>
  10. <view class="time_picker">
  11. <view class="time_title">结束时间</view>
  12. <uni-datetime-picker style="width: 210rpx;" type="datetime" :clear-icon="false" v-model="endTime"
  13. @change="maskClick" />
  14. </view>
  15. </view>
  16. <view class="card_layout">
  17. <view class="facility_card">
  18. <view class="card_title_name">报警类型</view>
  19. <scroll-view class="scroll-view" :style="{height:leftHeight + 'px'}" :scroll-y="true"
  20. @scrolltolower="loadMore">
  21. <view class="item_title_name" v-for="(item, index) in tableData" :key="index">
  22. {{item.name}}
  23. </view>
  24. </scroll-view>
  25. </view>
  26. <view class="table_card_data">
  27. <uni-table ref="table" :loading="loading" border emptyText="暂无更多数据">
  28. <uni-tr>
  29. <uni-th width="10" align="center"></uni-th>
  30. <uni-th width="60" align="center">保存时间</uni-th>
  31. <uni-th width="60" align="center">上传状态</uni-th>
  32. <uni-th align="center">报警消息</uni-th>
  33. </uni-tr>
  34. <uni-tr v-for="(item, index) in tableData" :key="index">
  35. <uni-td align="center">{{ index + 1 }}</uni-td>
  36. <uni-td align="center">{{ item.date }}</uni-td>
  37. <uni-td align="center">
  38. <view class="name">{{ item.name }}</view>
  39. </uni-td>
  40. <uni-td align="center">{{ item.name }}</uni-td>
  41. </uni-tr>
  42. </uni-table>
  43. </view>
  44. </view>
  45. </view>
  46. </template>
  47. <script>
  48. import tablelist from './tableData.js'
  49. export default {
  50. props: {
  51. heightfield: {
  52. type: Number,
  53. default () {
  54. return 0
  55. }
  56. },
  57. },
  58. data() {
  59. return {
  60. loading: false,
  61. tableData: tablelist,
  62. startTime: this.getDateTime(new Date()),
  63. endTime: this.getDateTime(new Date()),
  64. leftHeight: 0,
  65. }
  66. },
  67. watch: {
  68. // demo 是要深度监听的值
  69. heightfield: {
  70. handler(newVal, oldVal) {
  71. if (newVal) {
  72. this.$nextTick(() => {
  73. let topHeight = 0
  74. const navbar = uni.createSelectorQuery().select('.card_layout')
  75. navbar.boundingClientRect(data => {
  76. topHeight = data.height
  77. }).exec()
  78. let titleHeight = 0
  79. const titleBar = uni.createSelectorQuery().select('.card_title_name')
  80. titleBar.boundingClientRect(data => {
  81. titleHeight = data.height
  82. }).exec()
  83. this.leftHeight = topHeight - titleHeight
  84. })
  85. }
  86. },
  87. immediate: true,
  88. deep: true
  89. }
  90. },
  91. mounted() {},
  92. methods: {
  93. maskClick(event) {
  94. console.log(event, 264)
  95. },
  96. // 滚动加载更多
  97. loadMore() {
  98. console.log(3214)
  99. },
  100. getDateTime(date, addZero = true) {
  101. return `${this.getDate(date, addZero)} ${this.getTime(date, addZero)}`
  102. },
  103. getDate(date, addZero = true) {
  104. date = new Date(date)
  105. const year = date.getFullYear()
  106. const month = date.getMonth() + 1
  107. const day = date.getDate()
  108. return `${year}-${addZero ? this.addZero(month) : month}-${addZero ? this.addZero(day) : day}`
  109. },
  110. getTime(date, addZero = true) {
  111. date = new Date(date)
  112. const hour = date.getHours()
  113. const minute = date.getMinutes()
  114. const second = date.getSeconds()
  115. return this.hideSecond ?
  116. `${addZero ? this.addZero(hour) : hour}:${addZero ? this.addZero(minute) : minute}` :
  117. `${addZero ? this.addZero(hour) : hour}:${addZero ? this.addZero(minute) : minute}:${addZero ? this.addZero(second) : second}`
  118. },
  119. addZero(num) {
  120. if (num < 10) {
  121. num = `0${num}`
  122. }
  123. return num
  124. }
  125. }
  126. }
  127. </script>
  128. <style lang="scss">
  129. .card_time_row {
  130. position: sticky;
  131. top: 0px;
  132. background-color: #fff;
  133. z-index: 2;
  134. display: flex;
  135. align-items: center;
  136. padding: 10rpx 10rpx;
  137. }
  138. .time_picker {
  139. display: flex;
  140. align-items: center;
  141. margin-right: 20rpx;
  142. }
  143. .time_title {
  144. font-size: 8px;
  145. margin-right: 10rpx;
  146. }
  147. .card_layout {
  148. display: flex;
  149. margin-left: 10rpx;
  150. height: calc(100% - 20rpx);
  151. }
  152. .facility_card {
  153. width: 140rpx;
  154. height: 100%;
  155. flex: none;
  156. border: 1rpx solid #EBEEF5;
  157. }
  158. .scroll-view {
  159. overflow-y: auto;
  160. }
  161. .card_title_name {
  162. padding: 8rpx;
  163. font-size: 8px;
  164. background-color: #EBEEF5;
  165. }
  166. .item_title_name {
  167. padding: 6rpx;
  168. font-size: 8px;
  169. border-bottom: 1rpx solid #EBEEF5;
  170. }
  171. .table_card_data {
  172. overflow-y: auto;
  173. width: 100%;
  174. height: 100%;
  175. border-top: 1px solid #EBEEF5;
  176. border-bottom: 1px solid #EBEEF5;
  177. }
  178. </style>