# 趋势表格添加时间选择
This commit is contained in:
parent
dd6032672e
commit
39e670743c
|
@ -30,6 +30,24 @@
|
||||||
</el-row>
|
</el-row>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
</el-tabs>
|
</el-tabs>
|
||||||
|
|
||||||
|
<div class="filter-container">
|
||||||
|
<div class="date-selector filter-item">
|
||||||
|
<el-date-picker
|
||||||
|
v-model="dateRange"
|
||||||
|
size="small"
|
||||||
|
type="daterange"
|
||||||
|
align="right"
|
||||||
|
:range-separator="$t('counter.to')"
|
||||||
|
:start-placeholder="$t('counter.start_date')"
|
||||||
|
:end-placeholder="$t('counter.end_date')"
|
||||||
|
:picker-options="pickerOptions"
|
||||||
|
value-format="yyyy-MM-dd"
|
||||||
|
@change="handleDateSelect"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<el-button class="filter-item" size="small" type="primary" v-waves icon="el-icon-search" @click="handleFilter">{{$t('table.search')}}</el-button>
|
||||||
|
</div>
|
||||||
|
|
||||||
<el-table
|
<el-table
|
||||||
v-show="!showHumiture"
|
v-show="!showHumiture"
|
||||||
|
@ -94,7 +112,7 @@
|
||||||
<el-pagination background
|
<el-pagination background
|
||||||
:current-page="1"
|
:current-page="1"
|
||||||
:page-sizes="[10,20,30,50]"
|
:page-sizes="[10,20,30,50]"
|
||||||
:page-size="20"
|
:page-size="deviceHistoryListQuery.limit"
|
||||||
layout="total, sizes, prev, pager, next, jumper"
|
layout="total, sizes, prev, pager, next, jumper"
|
||||||
:total="tempTotal" @size-change="handleTempSizeChange" @current-change="handleTempCurrentChange" />
|
:total="tempTotal" @size-change="handleTempSizeChange" @current-change="handleTempCurrentChange" />
|
||||||
</div>
|
</div>
|
||||||
|
@ -102,6 +120,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import waves from '@/directive/waves' // 水波纹指令
|
||||||
import { fetchDeviceList, fetchDeviceLogsHistory, fetchDeviceTempLog } from '@/api/counter'
|
import { fetchDeviceList, fetchDeviceLogsHistory, fetchDeviceTempLog } from '@/api/counter'
|
||||||
import Screen from './components/screen'
|
import Screen from './components/screen'
|
||||||
import Chart from './components/chart'
|
import Chart from './components/chart'
|
||||||
|
@ -114,6 +133,9 @@ export default {
|
||||||
Chart,
|
Chart,
|
||||||
Humiture
|
Humiture
|
||||||
},
|
},
|
||||||
|
directives: {
|
||||||
|
waves
|
||||||
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
lineChartData: {
|
lineChartData: {
|
||||||
|
@ -139,8 +161,16 @@ export default {
|
||||||
limit: 20,
|
limit: 20,
|
||||||
ordering: '-create_time'
|
ordering: '-create_time'
|
||||||
},
|
},
|
||||||
|
deviceHistoryListQuery: {
|
||||||
|
page: 1,
|
||||||
|
limit: 20,
|
||||||
|
device_id: undefined,
|
||||||
|
start: undefined,
|
||||||
|
end: undefined
|
||||||
|
},
|
||||||
listLoading: true,
|
listLoading: true,
|
||||||
tempLoading: true,
|
tempLoading: true,
|
||||||
|
device_id: undefined,
|
||||||
deviceLogs: [],
|
deviceLogs: [],
|
||||||
deviceTempLogs: [],
|
deviceTempLogs: [],
|
||||||
deviceTempTableLogs: [],
|
deviceTempTableLogs: [],
|
||||||
|
@ -151,7 +181,9 @@ export default {
|
||||||
showScreen: true,
|
showScreen: true,
|
||||||
showChart: false,
|
showChart: false,
|
||||||
showHumiture: false,
|
showHumiture: false,
|
||||||
flag: false
|
flag: false,
|
||||||
|
pickerOptions: null,
|
||||||
|
dateRange: undefined
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
|
@ -175,6 +207,7 @@ export default {
|
||||||
})
|
})
|
||||||
this.lineChartData.total.historyData = this.lineChartData.total.historyData.reverse()
|
this.lineChartData.total.historyData = this.lineChartData.total.historyData.reverse()
|
||||||
this.lineChartData.total.xAxis = dateList.reverse()
|
this.lineChartData.total.xAxis = dateList.reverse()
|
||||||
|
this.logsTotal = response.data.count
|
||||||
this.listLoading = false
|
this.listLoading = false
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
@ -227,21 +260,38 @@ export default {
|
||||||
coordinate(row, column) {
|
coordinate(row, column) {
|
||||||
return row.longitude + ', ' + row.latitude
|
return row.longitude + ', ' + row.latitude
|
||||||
},
|
},
|
||||||
|
handleDateSelect(value) {
|
||||||
|
if (value === null) {
|
||||||
|
this.deviceHistoryListQuery.start = undefined
|
||||||
|
this.deviceHistoryListQuery.end = undefined
|
||||||
|
} else {
|
||||||
|
const [start, end] = value
|
||||||
|
this.deviceHistoryListQuery.start = start
|
||||||
|
this.deviceHistoryListQuery.end = end
|
||||||
|
}
|
||||||
|
},
|
||||||
|
handleFilter() {
|
||||||
|
this.deviceHistoryListQuery.page = 1
|
||||||
|
this.getDeviceLogsHistory(this.deviceHistoryListQuery)
|
||||||
|
},
|
||||||
handleCurrentChange(page) {
|
handleCurrentChange(page) {
|
||||||
this.listLoading = true
|
this.listLoading = true
|
||||||
const device_id = this.$store.getters.deviceID
|
this.deviceHistoryListQuery.device_id = this.device_id
|
||||||
this.getDeviceLogsTableHistory({ device_id, page, limit: 20 })
|
this.deviceHistoryListQuery.page = page
|
||||||
|
// this.getDeviceLogsTableHistory(this.deviceHistoryListQuery)
|
||||||
|
this.getDeviceLogsHistory(this.deviceHistoryListQuery)
|
||||||
},
|
},
|
||||||
handleSizeChange(page) {
|
handleSizeChange(val) {
|
||||||
this.listLoading = true
|
this.listLoading = true
|
||||||
const device_id = this.$store.getters.deviceID
|
this.deviceHistoryListQuery.device_id = this.device_id
|
||||||
this.getDeviceLogsTableHistory({ device_id, page, limit: 20 })
|
this.deviceHistoryListQuery.limit = val
|
||||||
|
// this.getDeviceLogsTableHistory(this.deviceHistoryListQuery)
|
||||||
|
this.getDeviceLogsHistory(this.deviceHistoryListQuery)
|
||||||
},
|
},
|
||||||
handleTempCurrentChange(page) {
|
handleTempCurrentChange(page) {
|
||||||
this.tempLoading = true
|
this.tempLoading = true
|
||||||
this.deviceTempListQuery.page = page
|
this.deviceTempListQuery.page = page
|
||||||
this.deviceTempListQuery.device_id = device_id
|
this.deviceTempListQuery.device_id = this.device_id
|
||||||
const device_id = this.$store.getters.deviceID
|
|
||||||
this.getDeviceTempTableLog(this.deviceTempListQuery)
|
this.getDeviceTempTableLog(this.deviceTempListQuery)
|
||||||
},
|
},
|
||||||
handleTempSizeChange(page) {
|
handleTempSizeChange(page) {
|
||||||
|
@ -266,16 +316,54 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
const device_id = this.$store.getters.deviceID
|
this.device_id = this.$store.getters.deviceID
|
||||||
this.deviceTempListQuery.device_id = device_id
|
this.deviceHistoryListQuery.device_id = this.device_id
|
||||||
this.getDevices({ device_id })
|
this.deviceTempListQuery.device_id = this.device_id
|
||||||
this.getDeviceLogsTableHistory({ device_id, limit: 20 })
|
this.getDevices({ device_id: this.device_id })
|
||||||
this.getDeviceTempLog({ device_id, last_day: 1, limit: 30 })
|
this.getDeviceLogsTableHistory({ device_id: this.device_id, limit: 20 })
|
||||||
|
this.getDeviceTempLog({ device_id: this.device_id, last_day: 1, limit: 30 })
|
||||||
this.getDeviceTempTableLog(this.deviceTempListQuery)
|
this.getDeviceTempTableLog(this.deviceTempListQuery)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.date-selector {
|
||||||
|
margin-left: 10px;
|
||||||
|
}
|
||||||
|
.date-selector /deep/ .el-date-editor .el-range-separator {
|
||||||
|
margin-right: 10px !important;
|
||||||
|
}
|
||||||
|
@media only screen and (max-width: 768px) {
|
||||||
|
.filter-container {
|
||||||
|
display: block;
|
||||||
|
.filter-item {
|
||||||
|
margin-bottom: 10px;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
.date-selector {
|
||||||
|
margin-left: 0;
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
.time-selector {
|
||||||
|
margin-left: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
@media only screen and (max-width: 500px) {
|
||||||
|
.el-date-range-picker {
|
||||||
|
width: 100% !important;
|
||||||
|
}
|
||||||
|
.el-date-range-picker__content {
|
||||||
|
float: none;
|
||||||
|
width: 80%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
.v-enter, .v-leave-to {
|
.v-enter, .v-leave-to {
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
|
|
Loading…
Reference in New Issue