|
@@ -11,19 +11,28 @@
|
|
<!-- 历史日志数据表格 -->
|
|
<!-- 历史日志数据表格 -->
|
|
<div class="history-container">
|
|
<div class="history-container">
|
|
<div class="date-picker-container">
|
|
<div class="date-picker-container">
|
|
|
|
+ <el-radio-group v-model="historyDateRangeType" @change="chengDateRangeType">
|
|
|
|
+ <el-radio-button label="1">最近半小时</el-radio-button>
|
|
|
|
+ <el-radio-button label="2">最近1小时</el-radio-button>
|
|
|
|
+ <el-radio-button label="3">最近12小时</el-radio-button>
|
|
|
|
+ </el-radio-group>
|
|
<el-date-picker
|
|
<el-date-picker
|
|
- v-model="historyDateRange"
|
|
|
|
|
|
+ v-model="params.dateRange"
|
|
|
|
+ :disabled-date="disabledDate"
|
|
type="datetimerange"
|
|
type="datetimerange"
|
|
range-separator="至"
|
|
range-separator="至"
|
|
start-placeholder="开始日期"
|
|
start-placeholder="开始日期"
|
|
end-placeholder="结束日期"
|
|
end-placeholder="结束日期"
|
|
format="YYYY-MM-DD HH:mm:ss"
|
|
format="YYYY-MM-DD HH:mm:ss"
|
|
value-format="YYYY-MM-DD HH:mm:ss"
|
|
value-format="YYYY-MM-DD HH:mm:ss"
|
|
- @change="fetchHistoryData"
|
|
|
|
|
|
+ @change="dateRangeChange()"
|
|
|
|
+ style="width: 220px"
|
|
/>
|
|
/>
|
|
- <el-button type="primary" @click="exportData">导出</el-button>
|
|
|
|
|
|
+ <el-button type="primary" @click="exportData"
|
|
|
|
+ ><el-icon><Download /></el-icon>导出</el-button
|
|
|
|
+ >
|
|
</div>
|
|
</div>
|
|
- <el-table :data="historyData" border style="width: 100%" v-loading="historyLoading">
|
|
|
|
|
|
+ <el-table :data="historyData" border style="width: 100%" v-loading="historyLoading" max-height="calc(90vh - 300px)">
|
|
<el-table-column prop="ts" label="时间" align="center" />
|
|
<el-table-column prop="ts" label="时间" align="center" />
|
|
<el-table-column prop="value" label="属性值" align="center" />
|
|
<el-table-column prop="value" label="属性值" align="center" />
|
|
<el-table-column prop="unit" label="数据单位" align="center">
|
|
<el-table-column prop="unit" label="数据单位" align="center">
|
|
@@ -53,20 +62,24 @@ import { ref, reactive, watch, nextTick } from 'vue'
|
|
import api from '/@/api/device'
|
|
import api from '/@/api/device'
|
|
import * as echarts from 'echarts'
|
|
import * as echarts from 'echarts'
|
|
import dayjs from 'dayjs'
|
|
import dayjs from 'dayjs'
|
|
-import { ElMessage } from 'element-plus'
|
|
|
|
|
|
+import { Download } from '@element-plus/icons-vue'
|
|
|
|
|
|
const data = ref({ name: '', key: '', unit: '' })
|
|
const data = ref({ name: '', key: '', unit: '' })
|
|
|
|
+const historyDateRangeType = ref('1')
|
|
const loading = ref(false)
|
|
const loading = ref(false)
|
|
const isShowDialog = ref(false)
|
|
const isShowDialog = ref(false)
|
|
const chartRef = ref<HTMLElement | null>(null)
|
|
const chartRef = ref<HTMLElement | null>(null)
|
|
let chartInstance: echarts.ECharts | null = null
|
|
let chartInstance: echarts.ECharts | null = null
|
|
const lineData = ref([])
|
|
const lineData = ref([])
|
|
|
|
|
|
|
|
+const disabledDate = (time: Date) => {
|
|
|
|
+ return time.getTime() > Date.now()
|
|
|
|
+}
|
|
|
|
+
|
|
// 新增 Tab 相关状态
|
|
// 新增 Tab 相关状态
|
|
const activeTab = ref('trend')
|
|
const activeTab = ref('trend')
|
|
const historyData = ref([])
|
|
const historyData = ref([])
|
|
const historyLoading = ref(false)
|
|
const historyLoading = ref(false)
|
|
-const historyDateRange = ref([dayjs().subtract(1, 'hour').format('YYYY-MM-DD HH:mm:ss'), dayjs().format('YYYY-MM-DD HH:mm:ss')])
|
|
|
|
const currentPage = ref(1)
|
|
const currentPage = ref(1)
|
|
const pageSize = ref(10)
|
|
const pageSize = ref(10)
|
|
const totalItems = ref(0)
|
|
const totalItems = ref(0)
|
|
@@ -75,9 +88,25 @@ const params = reactive({
|
|
productKey: '',
|
|
productKey: '',
|
|
deviceKey: '',
|
|
deviceKey: '',
|
|
properties: '',
|
|
properties: '',
|
|
- dateRange: [dayjs().subtract(1, 'hour').format('YYYY-MM-DD HH:mm:ss'), dayjs().format('YYYY-MM-DD HH:mm:ss')],
|
|
|
|
|
|
+ dateRange: [dayjs().subtract(30, 'minute').format('YYYY-MM-DD HH:mm:ss'), dayjs().format('YYYY-MM-DD HH:mm:ss')],
|
|
})
|
|
})
|
|
|
|
|
|
|
|
+function chengDateRangeType(type: string) {
|
|
|
|
+ if (type === '1') {
|
|
|
|
+ params.dateRange = [dayjs().subtract(30, 'minute').format('YYYY-MM-DD HH:mm:ss'), dayjs().format('YYYY-MM-DD HH:mm:ss')]
|
|
|
|
+ } else if (type === '2') {
|
|
|
|
+ params.dateRange = [dayjs().subtract(1, 'hour').format('YYYY-MM-DD HH:mm:ss'), dayjs().format('YYYY-MM-DD HH:mm:ss')]
|
|
|
|
+ } else if (type === '3') {
|
|
|
|
+ params.dateRange = [dayjs().subtract(12, 'hour').format('YYYY-MM-DD HH:mm:ss'), dayjs().format('YYYY-MM-DD HH:mm:ss')]
|
|
|
|
+ }
|
|
|
|
+ fetchHistoryData()
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+function dateRangeChange() {
|
|
|
|
+ historyDateRangeType.value = ''
|
|
|
|
+ fetchHistoryData()
|
|
|
|
+}
|
|
|
|
+
|
|
// 初始化图表
|
|
// 初始化图表
|
|
const initChart = () => {
|
|
const initChart = () => {
|
|
if (chartRef.value) {
|
|
if (chartRef.value) {
|
|
@@ -191,7 +220,7 @@ const fetchHistoryData = () => {
|
|
productKey: params.productKey,
|
|
productKey: params.productKey,
|
|
deviceKey: params.deviceKey,
|
|
deviceKey: params.deviceKey,
|
|
propertyKey: params.properties,
|
|
propertyKey: params.properties,
|
|
- dateRange: historyDateRange.value,
|
|
|
|
|
|
+ dateRange: params.dateRange,
|
|
pageNum: currentPage.value,
|
|
pageNum: currentPage.value,
|
|
pageSize: pageSize.value,
|
|
pageSize: pageSize.value,
|
|
}
|
|
}
|
|
@@ -227,7 +256,7 @@ const exportData = () => {
|
|
productKey: params.productKey,
|
|
productKey: params.productKey,
|
|
deviceKey: params.deviceKey,
|
|
deviceKey: params.deviceKey,
|
|
propertyKey: params.properties,
|
|
propertyKey: params.properties,
|
|
- dateRange: historyDateRange.value,
|
|
|
|
|
|
+ dateRange: params.dateRange,
|
|
pageNum: currentPage.value,
|
|
pageNum: currentPage.value,
|
|
pageSize: pageSize.value,
|
|
pageSize: pageSize.value,
|
|
}
|
|
}
|
|
@@ -327,7 +356,8 @@ const openDialog = (row: any, deviceKey: string, productKey: string) => {
|
|
params.properties = row.key
|
|
params.properties = row.key
|
|
|
|
|
|
// 重置日期范围
|
|
// 重置日期范围
|
|
- historyDateRange.value = [dayjs().subtract(1, 'hour').format('YYYY-MM-DD HH:mm:ss'), dayjs().format('YYYY-MM-DD HH:mm:ss')]
|
|
|
|
|
|
+ historyDateRangeType.value = '1'
|
|
|
|
+ params.dateRange = [dayjs().subtract(30, 'minute').format('YYYY-MM-DD HH:mm:ss'), dayjs().format('YYYY-MM-DD HH:mm:ss')]
|
|
data.value = row
|
|
data.value = row
|
|
isShowDialog.value = true
|
|
isShowDialog.value = true
|
|
loading.value = true
|
|
loading.value = true
|
|
@@ -359,6 +389,7 @@ defineExpose({ openDialog })
|
|
display: flex;
|
|
display: flex;
|
|
justify-content: space-between;
|
|
justify-content: space-between;
|
|
margin-bottom: 15px;
|
|
margin-bottom: 15px;
|
|
|
|
+ gap: 15px;
|
|
}
|
|
}
|
|
|
|
|
|
.pagination-container {
|
|
.pagination-container {
|