|
|
@@ -65,25 +65,41 @@
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="row_radio_group">
|
|
|
- <el-radio-group v-model="change_type" size="large">
|
|
|
+ <el-radio-group v-model="change_type" size="large" @change="typeChange">
|
|
|
<el-radio label="echarts">图表</el-radio>
|
|
|
<el-radio label="table">表格</el-radio>
|
|
|
</el-radio-group>
|
|
|
</div>
|
|
|
<div class="data_container">
|
|
|
- <baseEcharts v-if="change_type === 'echarts'" />
|
|
|
+ <baseEcharts v-if="change_type === 'echarts'" :unit="groupUnit" :datas="echartsData" />
|
|
|
<template v-if="change_type === 'table'">
|
|
|
<div class="data_table_box">
|
|
|
<el-table :data="tableData" height="100%" style="width: 100%">
|
|
|
- <el-table-column prop="key1" label="检测时间" />
|
|
|
- <el-table-column prop="key2" label="传感器名称" />
|
|
|
- <el-table-column prop="key3" label="原始值" />
|
|
|
- <el-table-column prop="key4" label="检测值" />
|
|
|
- <el-table-column prop="key5" label="报警信息" />
|
|
|
+ <el-table-column prop="date" label="检测时间" />
|
|
|
+ <el-table-column prop="sensorName" label="传感器名称" />
|
|
|
+ <el-table-column prop="ysValue" label="原始值" />
|
|
|
+ <el-table-column prop="jcValue" label="检测值">
|
|
|
+ <template #default="scope">
|
|
|
+ {{ scope.row.jcValue + groupUnit }}
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="bjInfo" label="报警信息">
|
|
|
+ <template #default="scope">
|
|
|
+ {{ scope.row.bjInfo ? scope.row.bjInfo : '-' }}
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
</el-table>
|
|
|
</div>
|
|
|
<div class="data_page_box">
|
|
|
- <el-pagination background layout="total, prev, pager, next" :total="1000" :page-size="30" />
|
|
|
+ <el-pagination
|
|
|
+ background
|
|
|
+ layout="total, prev, pager, next"
|
|
|
+ :total="searchForm.total"
|
|
|
+ :page-size="searchForm.size"
|
|
|
+ :current-page="searchForm.current"
|
|
|
+ @size-change="sizesUpdate"
|
|
|
+ @current-change="pagesUpdate"
|
|
|
+ />
|
|
|
</div>
|
|
|
</template>
|
|
|
</div>
|
|
|
@@ -116,6 +132,7 @@ onMounted(() => {
|
|
|
|
|
|
//获取分组列表
|
|
|
const groupList = ref([])
|
|
|
+const groupUnit = ref('°C')
|
|
|
const getGroupList = async () => {
|
|
|
groupList.value = []
|
|
|
const { data } = await mainApi.getGroupList({
|
|
|
@@ -125,18 +142,21 @@ const getGroupList = async () => {
|
|
|
groupList.value = res
|
|
|
if (res.length > 0) {
|
|
|
searchForm.value.sensorId = res[0].sensorId
|
|
|
+ groupUnit.value = res[0].numericalUnit
|
|
|
getTableData().then()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//分组切换
|
|
|
const groupListChange = () => {
|
|
|
+ searchForm.value.current = 1
|
|
|
getTableData()
|
|
|
}
|
|
|
|
|
|
//日期时间范围
|
|
|
const dateTime = ref([sevenDay, toDay])
|
|
|
const dateTimeChange = (val) => {
|
|
|
+ searchForm.value.current = 1
|
|
|
if (val && val.length > 0) {
|
|
|
searchForm.value.startTime = val[0] + ' 00:00:00'
|
|
|
searchForm.value.endTime = val[1] + ' 23:59:59'
|
|
|
@@ -149,18 +169,55 @@ const searchForm = ref({
|
|
|
sensorId: null,
|
|
|
startTime: sevenDay + ' 00:00:00',
|
|
|
endTime: toDay + ' 23:59:59',
|
|
|
+ total: 1000,
|
|
|
+ size: 30,
|
|
|
+ current: 1,
|
|
|
})
|
|
|
|
|
|
-//表格或图表数据
|
|
|
-const tableData = []
|
|
|
-const getTableData = async () => {
|
|
|
- tableData.value = []
|
|
|
- const { data } = await mainApi.getSensorsList(searchForm.value)
|
|
|
- tableData.value = getArrValue(data)
|
|
|
+//条数改变
|
|
|
+const sizesUpdate = (val) => {
|
|
|
+ searchForm.value.size = val
|
|
|
+ getTableData()
|
|
|
}
|
|
|
|
|
|
+const pagesUpdate = (val) => {
|
|
|
+ searchForm.value.current = val
|
|
|
+ getTableData()
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
//类型
|
|
|
const change_type = ref('echarts')
|
|
|
+const typeChange = () => {
|
|
|
+ searchForm.value.current = 1
|
|
|
+ getTableData()
|
|
|
+}
|
|
|
+
|
|
|
+//表格或图表数据
|
|
|
+const tableData = ref([])
|
|
|
+const echartsData = ref({ name: '', date: [], data: [] })
|
|
|
+const getTableData = async () => {
|
|
|
+ const type = change_type.value
|
|
|
+ if (type === 'echarts') {
|
|
|
+ echartsData.value = { name: '', date: [], data: [] }
|
|
|
+ let newData = { name: '', date: [], data: [] }
|
|
|
+ const { data } = await mainApi.getChartList(searchForm.value)
|
|
|
+ const res = getArrValue(data)
|
|
|
+ if (res.length > 0) {
|
|
|
+ newData.name = res[0].sensorName
|
|
|
+ }
|
|
|
+ for (let i = 0; i < res.length; i++) {
|
|
|
+ newData.date.push(res[i].date)
|
|
|
+ newData.data.push(res[i].jcValue)
|
|
|
+ }
|
|
|
+ echartsData.value = newData
|
|
|
+ } else if (type === 'table') {
|
|
|
+ tableData.value = []
|
|
|
+ const { data } = await mainApi.getPageList(searchForm.value)
|
|
|
+ tableData.value = getArrValue(data?.records)
|
|
|
+ searchForm.value.total = data?.total ?? 0
|
|
|
+ }
|
|
|
+}
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss">
|