From b25dac9ce64c5988a9e546c9c80413e9b666e4e2 Mon Sep 17 00:00:00 2001
From: Crunchy <3114200645@qq.com>
Date: 星期六, 14 六月 2025 16:49:38 +0800
Subject: [PATCH] 设备数采的数据以列表的格式展示,时间,车间,设备作为筛选条件
---
src/api/equipment/equipment.js | 23 ++++++-
src/views/equipment/mqtt-history/index.vue | 139 ++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 159 insertions(+), 3 deletions(-)
diff --git a/src/api/equipment/equipment.js b/src/api/equipment/equipment.js
index 7b86def..143aa37 100644
--- a/src/api/equipment/equipment.js
+++ b/src/api/equipment/equipment.js
@@ -1,6 +1,6 @@
/*
- * @Descripttion:
- * @version:
+ * @Descripttion:
+ * @version:
* @Author: zt_lc
* @Date: 2022-02-10 14:24:32
* @LastEditors: zt_lc
@@ -90,4 +90,21 @@
method: 'get',
params: query
})
-}
\ No newline at end of file
+}
+
+
+export function mqttPage(query) {
+ return request({
+ url: '/mes/mqtt/page',
+ method: 'get',
+ params: query
+ })
+}
+
+export function getEquipmentSensors(query) {
+ return request({
+ url: '/mes/mqtt/getEquipmentSensors',
+ method: 'get',
+ params: query
+ })
+}
diff --git a/src/views/equipment/mqtt-history/index.vue b/src/views/equipment/mqtt-history/index.vue
new file mode 100644
index 0000000..3252f0b
--- /dev/null
+++ b/src/views/equipment/mqtt-history/index.vue
@@ -0,0 +1,139 @@
+<template>
+ <div>
+ <basic-container>
+ <el-form label-width="100px" :inline="true">
+ <el-form-item label="璁惧锛�" required>
+ <el-select v-model="search.deviceId" placeholder="璇烽�夋嫨">
+ <el-option
+ v-for="item in options"
+ :key="item.value"
+ :label="item.name"
+ :value="item.device_id"
+ >
+ </el-option>
+ </el-select>
+ </el-form-item>
+ <el-form-item label="鏃堕棿锛�">
+ <el-date-picker
+ v-model="search.collectionTime"
+ type="datetime"
+ placeholder="閫夋嫨鏃ユ湡鏃堕棿"
+ >
+ </el-date-picker>
+ </el-form-item>
+ <el-form-item>
+ <el-button type="primary" @click="searchFun">鏌ヨ</el-button>
+ </el-form-item>
+ </el-form>
+ </basic-container>
+ <basic-container>
+ <el-table
+ :data="tableData"
+ style="width: 100%"
+ height="calc(100vh - 27vh)"
+ >
+ <el-table-column type="index" label="搴忓彿"></el-table-column>
+ <el-table-column prop="collectionTime" label="閲囬泦鏃堕棿">
+ </el-table-column>
+ <el-table-column label="璁惧鍚嶇О">
+ <template slot-scope="scope">
+ <!-- 浣跨敤璁$畻灞炴�ф垨鏂规硶鏌ユ壘鍖归厤椤� -->
+ {{ getMatchedName(scope.row.dataStream) }}
+ </template>
+ </el-table-column>
+ <el-table-column prop="dataStream" label="璁惧缂栧彿" >
+ </el-table-column>
+ <el-table-column prop="value" label="鍙傛暟鍊�"> </el-table-column>
+ </el-table>
+ <el-pagination
+ @size-change="handleSizeChange"
+ @current-change="handleCurrentChange"
+ :current-page="1"
+ :page-sizes="[100, 200, 300, 400]"
+ :page-size="search.size"
+ layout="->, total, sizes, prev, pager, next, jumper"
+ :total="search.total"
+ >
+ </el-pagination>
+ </basic-container>
+ </div>
+</template>
+
+<script>
+import {
+ getDeviceId,
+ getEquipmentSensors,
+ mqttPage
+} from '@/api/equipment/equipment'
+
+export default {
+ data() {
+ return {
+ currentPage: 1,
+ options: [],
+ tableData: [],
+ equipmentSensorsList: [],
+ search: {
+ size: 100,
+ current: 1,
+ total: 0,
+ deviceId: null,
+ collectionTime: null
+ }
+ }
+ },
+ // 鍒濆鍖栬皟鐢� 鏌ヨ璁惧 鎶樼嚎鍥炬暟鎹�
+ async created() {
+ await this.getDeviceIdFun()
+ await this.getPage()
+ },
+ methods: {
+ // 鏌ユ壘鍖归厤鐨勮澶囧悕绉�
+ getMatchedName(dataStream) {
+ // 閬嶅巻璁惧浼犳劅鍣ㄥ垪琛�
+ const matchedItem = this.equipmentSensorsList.find((item) => {
+ return item.dataStream === dataStream
+ })
+
+ // 杩斿洖鍖归厤鐨勪腑鏂囧悕绉版垨榛樿鍊�
+ return matchedItem ? matchedItem.nameCn : '鏈壘鍒拌澶�'
+ },
+ searchFun() {
+ this.tableData = []
+ this.getEquipmentSensors()
+ this.getPage()
+ },
+ handleSizeChange(val) {
+ this.search.size = val
+ this.getPage()
+ },
+ handleCurrentChange(val) {
+ this.search.current = val
+ this.getPage()
+ },
+ // 鑾峰彇璁惧涓嬫媺妗�
+ async getDeviceIdFun() {
+ await getDeviceId().then(async (res) => {
+ this.options = res.data.data
+ this.search.deviceId = this.options[0].device_id
+ await this.getEquipmentSensors()
+ })
+ },
+ getPage() {
+ mqttPage(this.search).then((res) => {
+ this.tableData = res.data.data.content
+ this.search.total = res.data.data.totalElements
+ })
+ },
+ async getEquipmentSensors() {
+ await getEquipmentSensors({ deviceId: this.search.deviceId }).then(
+ (response) => {
+ this.equipmentSensorsList = response.data.data
+ }
+ )
+ }
+ }
+}
+</script>
+
+<style></style>
--
Gitblit v1.9.3