From bb0c2658531ec5d11d09d389b5362d516ad73d28 Mon Sep 17 00:00:00 2001 From: Yangwl <1726150332@qq.com> Date: Wed, 21 May 2025 18:15:43 +0800 Subject: [PATCH] =?UTF-8?q?=E9=BB=91=E8=9A=8A=E9=A6=99=E8=BD=A6=E9=97=B4?= =?UTF-8?q?=E7=94=9F=E4=BA=A7=E7=9B=91=E6=8E=A7=E7=9C=8B=E6=9D=BF=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Yangwl <1726150332@qq.com> --- src/api/device/faultReport.js | 10 +++ src/views/cs/index.vue | 120 ++++++++++++++-------------------- 2 files changed, 60 insertions(+), 70 deletions(-) diff --git a/src/api/device/faultReport.js b/src/api/device/faultReport.js index ad5344f..186779f 100644 --- a/src/api/device/faultReport.js +++ b/src/api/device/faultReport.js @@ -9,6 +9,16 @@ export function listFaultReport(query) { }); } +// 查询故障报修列表 +export function getCsRepairlist(query) { + return request({ + url: '/device/faultReport/getCsRepairlist', + method: 'get', + params: query + }); +} + + // 查询故障报修详细 export function getFaultReport(orderId) { return request({ diff --git a/src/views/cs/index.vue b/src/views/cs/index.vue index bf39099..433c199 100644 --- a/src/views/cs/index.vue +++ b/src/views/cs/index.vue @@ -193,16 +193,18 @@ import {getDailyReportNew} from "../../api/mes/reportWork"; import moment from 'moment'; +import { getCsRepairlist } from "@/api/device/faultReport"; export default { data() { return { - url: "ws://192.168.202.34:9208/websocket/message", + url:"ws://localhost:9208/websocket/message", message: "", text_content: "", scrollText: "", repairOrders:[], ws: null, + timer: null, // 查询参数 queryParams: { timeArray: [], @@ -397,6 +399,15 @@ export default { ] } }, + + mounted() { + this.getDate(); + this.timer = setInterval(() => { + this.getlistFaultReport(); + }, 10000); + this.startAutoScroll(); + }, + methods: { Fungetdate(num) { var dd = new Date(); @@ -463,90 +474,59 @@ export default { tableBody.scrollTop = scrollTop } - }, 50) // 调整时间间隔控制滚动速度 + }, 3000) // 调整时间间隔控制滚动速度 }, stopAutoScroll() { clearInterval(this.scrollInterval) }, - join() { - const wsuri = this.url; - this.ws = new WebSocket(wsuri); - const self = this; - this.ws.onopen = function (event) { - self.text_content = self.text_content + "已经打开连接!" + "\n"; - }; - this.ws.onmessage = function (event) { - self.text_content = event.data + "\n"; - console.log(self.text_content); - try { - // 解析JSON数据 - const receivedData = JSON.parse(event.data) - if (Array.isArray(receivedData)) { - // 更新响应式数据 - this.repairOrders = receivedData.map(item => ({ - ...item, - })) - const descList = receivedData.map(item => - `${item.params?.equipmentName || '未知'} ${item.orderDesc || '无故障描述'} 维修人:${item.orderRepairmanName}` - ); - this.scrollText = descList.join('★★★★★★★★'); // 用两个全角空格分隔 + //设备故障信息 + getlistFaultReport(){ + const _this = this; + const param ={ + pageNum: 1, + pageSize: 20 + } + getCsRepairlist(param).then((response) => { + if (response) { + console.log(response) + // 更新响应式数据 + this.repairOrders = response.map(item => ({ + ...item, + })) + const descList = response.map(item => + `${item.params?.equipmentName || '未知'} ${item.params?.auxiliaryequipmentName || '未知'} ${item.orderDesc || '无故障描述'}` + ); + this.scrollText = descList.join('★★★★★★★★'); // 用两个全角空格分隔 // 提取所有有效的设备名称 - const activeEquipmentNames = new Set( - receivedData - .map(item => item.params?.equipmentName) - .filter(name => name) - ); + const activeEquipmentNames = new Set( + response.map(item => item.params?.equipmentName) + .filter(name => name) + ); - // 更新infoData的高亮状态 - this.infoData.forEach((item, index) => { - if (activeEquipmentNames.has(item.equipmentName)) { - // 响应式设置alpha - this.$set(this.infoData[index], 'alpha', '#CB4C4C80'); - } else { - // 移除alpha属性 - if (this.infoData[index].hasOwnProperty('alpha')) { - this.$delete(this.infoData[index], 'alpha'); - } + // 更新infoData的高亮状态 + this.infoData.forEach((item, index) => { + if (activeEquipmentNames.has(item.equipmentName)) { + // 响应式设置alpha + this.$set(this.infoData[index], 'alpha', '#CB4C4C80'); + } else { + // 移除alpha属性 + if (this.infoData[index].hasOwnProperty('alpha')) { + this.$delete(this.infoData[index], 'alpha'); } - }); - - } else { - console.warn('收到非数组格式数据:', receivedData) - } - } catch (error) { - console.error("JSON parsing failed:", error) - this.$notify.error({ title: '数据错误', message: '接收数据格式异常' }) + } + }); } - }.bind(this);; - this.ws.onclose = function (event) { - self.text_content = self.text_content + "已经关闭连接!" + "\n"; - }; - }, - exit() { - if (this.ws) { - this.ws.close(); - this.ws = null; - } - }, - send() { - if (this.ws) { - this.ws.send(this.message); - } else { - alert("未连接到服务器"); - } + }) }, }, created(){ - this.join(); + }, - mounted() { - this.getDate(); - this.startAutoScroll(); - }, + beforeDestroy() { this.stopAutoScroll() }, @@ -999,7 +979,7 @@ export default { .scroll-title-content { position: absolute; white-space: nowrap; - animation: scroll 15s linear infinite; + animation: scroll 15s linear infinite; /* 将15s改为30s使速度减半 */ font-size: 18px; color: #00f7ff; line-height: 30px;