|
|
|
@ -68,14 +68,6 @@
|
|
|
|
<el-form-item>
|
|
|
|
<el-form-item>
|
|
|
|
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
|
|
|
|
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
|
|
|
|
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
|
|
|
|
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
|
|
|
|
<el-button
|
|
|
|
|
|
|
|
type="primary"
|
|
|
|
|
|
|
|
plain
|
|
|
|
|
|
|
|
@click="openForm('create')"
|
|
|
|
|
|
|
|
v-hasPermi="['iot:mqtt-data-record:create']"
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
<Icon icon="ep:plus" class="mr-5px" /> 新增
|
|
|
|
|
|
|
|
</el-button>
|
|
|
|
|
|
|
|
<el-button
|
|
|
|
<el-button
|
|
|
|
type="success"
|
|
|
|
type="success"
|
|
|
|
plain
|
|
|
|
plain
|
|
|
|
@ -89,14 +81,15 @@
|
|
|
|
</el-form>
|
|
|
|
</el-form>
|
|
|
|
</ContentWrap>
|
|
|
|
</ContentWrap>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 列表 -->
|
|
|
|
<!-- 列表和看板 -->
|
|
|
|
<ContentWrap>
|
|
|
|
<ContentWrap>
|
|
|
|
<el-tabs v-model="activeName" @tab-click="handleTabClick">
|
|
|
|
<el-tabs v-model="activeName" @tab-click="handleTabClick">
|
|
|
|
<el-tab-pane label="数据" name="" />
|
|
|
|
<el-tab-pane label="数据" name="data" />
|
|
|
|
<el-tab-pane label="看板" name="0" />
|
|
|
|
<el-tab-pane label="看板" name="dashboard" />
|
|
|
|
</el-tabs>
|
|
|
|
</el-tabs>
|
|
|
|
|
|
|
|
|
|
|
|
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
|
|
|
|
<!-- 数据列表 -->
|
|
|
|
|
|
|
|
<el-table v-if="activeName === 'data'" v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
|
|
|
|
<el-table-column label="ID" align="center" prop="id" />
|
|
|
|
<el-table-column label="ID" align="center" prop="id" />
|
|
|
|
<el-table-column label="设备" align="center" prop="deviceName" />
|
|
|
|
<el-table-column label="设备" align="center" prop="deviceName" />
|
|
|
|
<el-table-column label="属性" align="center" prop="attribute" />
|
|
|
|
<el-table-column label="属性" align="center" prop="attribute" />
|
|
|
|
@ -130,24 +123,32 @@
|
|
|
|
</el-table>
|
|
|
|
</el-table>
|
|
|
|
<!-- 分页 -->
|
|
|
|
<!-- 分页 -->
|
|
|
|
<Pagination
|
|
|
|
<Pagination
|
|
|
|
|
|
|
|
v-if="activeName === 'data'"
|
|
|
|
:total="total"
|
|
|
|
:total="total"
|
|
|
|
v-model:page="queryParams.pageNo"
|
|
|
|
v-model:page="queryParams.pageNo"
|
|
|
|
v-model:limit="queryParams.pageSize"
|
|
|
|
v-model:limit="queryParams.pageSize"
|
|
|
|
@pagination="getList"
|
|
|
|
@pagination="getList"
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
</ContentWrap>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 看板图表 -->
|
|
|
|
|
|
|
|
<div v-if="activeName === 'dashboard'" class="dashboard-container">
|
|
|
|
|
|
|
|
<p>dewewe</p>
|
|
|
|
|
|
|
|
<div ref="chartRef" class="chart-container"></div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</ContentWrap>
|
|
|
|
</template>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
|
<script setup lang="ts">
|
|
|
|
import { dateFormatter } from '@/utils/formatTime'
|
|
|
|
import { dateFormatter } from '@/utils/formatTime'
|
|
|
|
import download from '@/utils/download'
|
|
|
|
import download from '@/utils/download'
|
|
|
|
import { MqttDataRecordApi, MqttDataRecordVO } from '@/api/iot/mqttdatarecord'
|
|
|
|
import { MqttDataRecordApi, MqttDataRecordVO } from '@/api/iot/mqttdatarecord'
|
|
|
|
|
|
|
|
import { DeviceApi, DeviceVO } from "@/api/iot/device"
|
|
|
|
import {DeviceApi, DeviceVO} from "@/api/iot/device";
|
|
|
|
import { MqttRecordApi } from "@/api/iot/mqttrecord"
|
|
|
|
import {MqttRecordApi} from "@/api/iot/mqttrecord";
|
|
|
|
import { TabsPaneContext } from "element-plus"
|
|
|
|
import {TabsPaneContext} from "element-plus";
|
|
|
|
import * as echarts from 'echarts'
|
|
|
|
|
|
|
|
import { onMounted, ref, reactive, watch } from 'vue'
|
|
|
|
|
|
|
|
|
|
|
|
/** 设备数据记录 列表 */
|
|
|
|
/** 设备数据记录 列表 */
|
|
|
|
defineOptions({ name: 'MqttDataRecord' })
|
|
|
|
defineOptions({ name: 'MqttDataRecord' })
|
|
|
|
@ -159,6 +160,8 @@ const loading = ref(true) // 列表的加载中
|
|
|
|
const list = ref<MqttDataRecordVO[]>([]) // 列表的数据
|
|
|
|
const list = ref<MqttDataRecordVO[]>([]) // 列表的数据
|
|
|
|
const deviceList = ref<DeviceVO[]>([])
|
|
|
|
const deviceList = ref<DeviceVO[]>([])
|
|
|
|
const deviceAttrList = ref<string[]>([])
|
|
|
|
const deviceAttrList = ref<string[]>([])
|
|
|
|
|
|
|
|
const chartRef = ref<HTMLElement>()
|
|
|
|
|
|
|
|
let chart: echarts.ECharts | null = null
|
|
|
|
|
|
|
|
|
|
|
|
const total = ref(0) // 列表的总页数
|
|
|
|
const total = ref(0) // 列表的总页数
|
|
|
|
const queryParams = reactive({
|
|
|
|
const queryParams = reactive({
|
|
|
|
@ -173,15 +176,19 @@ const queryParams = reactive({
|
|
|
|
})
|
|
|
|
})
|
|
|
|
const queryFormRef = ref() // 搜索的表单
|
|
|
|
const queryFormRef = ref() // 搜索的表单
|
|
|
|
const exportLoading = ref(false) // 导出的加载中
|
|
|
|
const exportLoading = ref(false) // 导出的加载中
|
|
|
|
|
|
|
|
const activeName = ref('data') // 当前激活的tab
|
|
|
|
|
|
|
|
|
|
|
|
/** 查询列表 */
|
|
|
|
/** 查询列表 */
|
|
|
|
const getList = async () => {
|
|
|
|
const getList = async () => {
|
|
|
|
loading.value = true
|
|
|
|
loading.value = true
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
console.log(queryParams)
|
|
|
|
|
|
|
|
const data = await MqttDataRecordApi.getMqttDataRecordPage2(queryParams)
|
|
|
|
const data = await MqttDataRecordApi.getMqttDataRecordPage2(queryParams)
|
|
|
|
list.value = data.list
|
|
|
|
list.value = data.list
|
|
|
|
total.value = data.total
|
|
|
|
total.value = data.total
|
|
|
|
|
|
|
|
// 如果当前在看板tab,更新图表
|
|
|
|
|
|
|
|
if (activeName.value === 'dashboard') {
|
|
|
|
|
|
|
|
updateChart()
|
|
|
|
|
|
|
|
}
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
loading.value = false
|
|
|
|
loading.value = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -222,24 +229,64 @@ const handleExport = async () => {
|
|
|
|
await message.exportConfirm()
|
|
|
|
await message.exportConfirm()
|
|
|
|
// 发起导出
|
|
|
|
// 发起导出
|
|
|
|
exportLoading.value = true
|
|
|
|
exportLoading.value = true
|
|
|
|
const data = await MqttDataRecordApi.exportMqttDataRecord(queryParams)
|
|
|
|
const data = await MqttDataRecordApi.getMqttDataRecordPage2(queryParams)
|
|
|
|
download.excel(data, '设备数据记录.xls')
|
|
|
|
download.excel(data, '设备数据记录.xls')
|
|
|
|
} catch {
|
|
|
|
} catch {
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
exportLoading.value = false
|
|
|
|
exportLoading.value = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** tab 切换 */
|
|
|
|
|
|
|
|
const handleTabClick = (tab: TabsPaneContext) => {
|
|
|
|
|
|
|
|
if (tab.paneName === 'dashboard') {
|
|
|
|
|
|
|
|
// 切换到看板时初始化图表
|
|
|
|
|
|
|
|
if (!chart) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** 监听数据变化,更新图表 */
|
|
|
|
|
|
|
|
watch(() => list.value, () => {
|
|
|
|
|
|
|
|
if (activeName.value === 'dashboard') {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}, { deep: true })
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let timer: any = null;
|
|
|
|
/** 初始化 **/
|
|
|
|
/** 初始化 **/
|
|
|
|
onMounted(async () => {
|
|
|
|
onMounted(async () => {
|
|
|
|
deviceList.value = await DeviceApi.getDeviceList()
|
|
|
|
deviceList.value = await DeviceApi.getDeviceList()
|
|
|
|
|
|
|
|
|
|
|
|
getList()
|
|
|
|
getList()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
timer = setInterval(async () => {
|
|
|
|
|
|
|
|
const data = await MqttDataRecordApi.getMqttDataRecordPage2(queryParams)
|
|
|
|
|
|
|
|
list.value = data.list
|
|
|
|
|
|
|
|
total.value = data.total
|
|
|
|
|
|
|
|
}, 5000);
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
/** tab 切换 */
|
|
|
|
// 组件卸载时销毁图表
|
|
|
|
let activeName = ''
|
|
|
|
onUnmounted(() => {
|
|
|
|
const handleTabClick = (tab: TabsPaneContext) => {
|
|
|
|
if (timer) {
|
|
|
|
console.log(tab.paneName)
|
|
|
|
clearInterval(timer);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (chart) {
|
|
|
|
|
|
|
|
chart.dispose()
|
|
|
|
|
|
|
|
chart = null
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
</script>
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
|
|
|
.dashboard-container {
|
|
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
|
|
height: 500px;
|
|
|
|
|
|
|
|
margin-top: 20px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.chart-container {
|
|
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
|
|
height: 100%;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
</style>
|
|
|
|
|