<template> <normal-table ref="normalTable" :data="list" :query="listQuery" :columns="columns" :list-loading="listLoading" :options="options" size="small" > <template slot="btns"> <el-date-picker v-model="timeRange" type="datetimerange" range-separator="至" size="small" :picker-options="pickerOptions" value-format="yyyy-MM-dd HH:mm:ss" start-placeholder="123开始时间" end-placeholder="结束时间" @change="fetchDeviceType" /> </template> </normal-table> </template> <script> import { digdataList } from '@/api/device/deviceTypeDetail' export default { name: 'ListDigData', data() { return { timeRange: '', listQuery: { devcode: '', beginTime: '', endTime: '' }, pickerOptions: { shortcuts: [{ text: '最近一周', onClick(picker) { const end = new Date() const start = new Date() start.setTime(start.getTime() - 3600 * 1000 * 24 * 7) picker.$emit('pick', [start, end]) } }, { text: '最近一个月', onClick(picker) { const end = new Date() const start = new Date() start.setTime(start.getTime() - 3600 * 1000 * 24 * 30) picker.$emit('pick', [start, end]) } }, { text: '最近三个月', onClick(picker) { const end = new Date() const start = new Date() start.setTime(start.getTime() - 3600 * 1000 * 24 * 90) picker.$emit('pick', [start, end]) } }] }, // 是否需要序号列 options: { needIndex: false }, columns: [ { text: '噪声值', value: 'ddata', align: 'center' }, { text: '上报时间', value: 'uptime', align: 'center' }, { text: '开挖状态', value: 'status', align: 'center' } ], // 显示列 list: [], listLoading: false } }, created() { this.fetchDeviceType() }, mounted() { this.$refs.normalTable.initColumnsState(false) }, methods: { initData: function(row = null) { this.listQuery.devcode = row.devcode }, fetchDeviceType(val) { this.listLoading = true if (val !== undefined) { this.listQuery.startTime = val[0] this.listQuery.endTime = val[1] } digdataList(this.listQuery).then(response => { this.list = response.data this.listLoading = false }) } } } </script> <style rel="stylesheet/scss" lang="scss" scoped> .el-date-editor--datetimerange.el-input, .el-date-editor--datetimerange.el-input__inner{ width: 340px; } </style>