| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188 |
- <template>
- <!-- 报警、告警 -->
- <view :style="{height:(heightfield - 30) + 'px',}">
- <view class="card_time_row">
- <view class="time_picker">
- <view class="time_title">开始时间</view>
- <uni-datetime-picker style="width: 210rpx;" type="datetime" :clear-icon="false" v-model="startTime"
- @change="maskClick" />
- </view>
- <view class="time_picker">
- <view class="time_title">结束时间</view>
- <uni-datetime-picker style="width: 210rpx;" type="datetime" :clear-icon="false" v-model="endTime"
- @change="maskClick" />
- </view>
- </view>
- <view class="card_layout">
- <view class="facility_card">
- <view class="card_title_name">报警类型</view>
- <scroll-view class="scroll-view" :style="{height:leftHeight + 'px'}" :scroll-y="true"
- @scrolltolower="loadMore">
- <view class="item_title_name" v-for="(item, index) in tableData" :key="index">
- {{item.name}}
- </view>
- </scroll-view>
- </view>
- <view class="table_card_data">
- <uni-table ref="table" :loading="loading" border emptyText="暂无更多数据">
- <uni-tr>
- <uni-th width="10" align="center"></uni-th>
- <uni-th width="60" align="center">保存时间</uni-th>
- <uni-th width="60" align="center">上传状态</uni-th>
- <uni-th align="center">报警消息</uni-th>
- </uni-tr>
- <uni-tr v-for="(item, index) in tableData" :key="index">
- <uni-td align="center">{{ index + 1 }}</uni-td>
- <uni-td align="center">{{ item.date }}</uni-td>
- <uni-td align="center">
- <view class="name">{{ item.name }}</view>
- </uni-td>
- <uni-td align="center">{{ item.name }}</uni-td>
- </uni-tr>
- </uni-table>
- </view>
- </view>
- </view>
- </template>
- <script>
- import tablelist from './tableData.js'
- export default {
- props: {
- heightfield: {
- type: Number,
- default () {
- return 0
- }
- },
- },
- data() {
- return {
- loading: false,
- tableData: tablelist,
- startTime: this.getDateTime(new Date()),
- endTime: this.getDateTime(new Date()),
- leftHeight: 0,
- }
- },
- watch: {
- // demo 是要深度监听的值
- heightfield: {
- handler(newVal, oldVal) {
- if (newVal) {
- this.$nextTick(() => {
- let topHeight = 0
- const navbar = uni.createSelectorQuery().select('.card_layout')
- navbar.boundingClientRect(data => {
- topHeight = data.height
- }).exec()
- let titleHeight = 0
- const titleBar = uni.createSelectorQuery().select('.card_title_name')
- titleBar.boundingClientRect(data => {
- titleHeight = data.height
- }).exec()
- this.leftHeight = topHeight - titleHeight
- })
- }
- },
- immediate: true,
- deep: true
- }
- },
- mounted() {},
- methods: {
- maskClick(event) {
- console.log(event, 264)
- },
- // 滚动加载更多
- loadMore() {
- console.log(3214)
- },
- getDateTime(date, addZero = true) {
- return `${this.getDate(date, addZero)} ${this.getTime(date, addZero)}`
- },
- getDate(date, addZero = true) {
- date = new Date(date)
- const year = date.getFullYear()
- const month = date.getMonth() + 1
- const day = date.getDate()
- return `${year}-${addZero ? this.addZero(month) : month}-${addZero ? this.addZero(day) : day}`
- },
- getTime(date, addZero = true) {
- date = new Date(date)
- const hour = date.getHours()
- const minute = date.getMinutes()
- const second = date.getSeconds()
- return this.hideSecond ?
- `${addZero ? this.addZero(hour) : hour}:${addZero ? this.addZero(minute) : minute}` :
- `${addZero ? this.addZero(hour) : hour}:${addZero ? this.addZero(minute) : minute}:${addZero ? this.addZero(second) : second}`
- },
- addZero(num) {
- if (num < 10) {
- num = `0${num}`
- }
- return num
- }
- }
- }
- </script>
- <style lang="scss">
- .card_time_row {
- position: sticky;
- top: 0px;
- background-color: #fff;
- z-index: 2;
- display: flex;
- align-items: center;
- padding: 10rpx 10rpx;
- }
- .time_picker {
- display: flex;
- align-items: center;
- margin-right: 20rpx;
- }
- .time_title {
- font-size: 8px;
- margin-right: 10rpx;
- }
- .card_layout {
- display: flex;
- margin-left: 10rpx;
- height: calc(100% - 20rpx);
- }
- .facility_card {
- width: 140rpx;
- height: 100%;
- flex: none;
- border: 1rpx solid #EBEEF5;
- }
- .scroll-view {
- overflow-y: auto;
- }
- .card_title_name {
- padding: 8rpx;
- font-size: 8px;
- background-color: #EBEEF5;
- }
- .item_title_name {
- padding: 6rpx;
- font-size: 8px;
- border-bottom: 1rpx solid #EBEEF5;
- }
- .table_card_data {
- overflow-y: auto;
- width: 100%;
- height: 100%;
- border-top: 1px solid #EBEEF5;
- border-bottom: 1px solid #EBEEF5;
- }
- </style>
|