From 68a9b7e950f0be5222f8cd70c87e56f2ca72c891 Mon Sep 17 00:00:00 2001 From: zch Date: Wed, 2 Jul 2025 20:12:34 +0800 Subject: [PATCH] =?UTF-8?q?refactor(ems):=20=E4=BC=98=E5=8C=96=E7=8E=AF?= =?UTF-8?q?=E5=A2=83=E7=9B=91=E6=B5=8B=E6=95=B0=E6=8D=AE=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 为表格添加 stripe、border 样式,优化视觉效果 -调整记录时间列宽度,确保时间信息完整显示 - 移除操作按钮,改为只显示时间信息 - 优化父节点点击逻辑,过滤无效子节点 - 调整设备类型获取方式,提高数据准确性 - 重置查询条件时,默认设置时间范围为昨天8点到今天8点 --- .../ems/record/recordIOTInstant/index.vue | 62 ++++++++++--------- 1 file changed, 33 insertions(+), 29 deletions(-) diff --git a/src/views/ems/record/recordIOTInstant/index.vue b/src/views/ems/record/recordIOTInstant/index.vue index 76178ba..d0bb5bc 100644 --- a/src/views/ems/record/recordIOTInstant/index.vue +++ b/src/views/ems/record/recordIOTInstant/index.vue @@ -187,7 +187,7 @@ - + @@ -214,25 +214,10 @@ label="噪声(dB)" align="center" prop="noise" width="100"> - - - - + + @@ -455,18 +440,23 @@ export default { // 判断是否为父节点(有children属性) if (data.children && data.children.length > 0) { - // 父节点:收集所有子节点的code - this.queryParams.monitorIds = data.children.map(child => child.code); - console.log('点击父节点:', data.label, '子节点codes:', this.queryParams.monitorIds); + // 父节点:收集所有子节点的code,过滤掉空值 + this.queryParams.monitorIds = data.children + .filter(child => child.code) + .map(child => child.code); + + // 父节点的type应该与子节点一致,取第一个有效子节点的type + const firstValidChild = data.children.find(child => child.type); + this.selectedNodeType = firstValidChild ? firstValidChild.type : data.type; + + console.log('点击父节点:', data.label, '节点type:', data.type, '子节点codes:', this.queryParams.monitorIds, '使用type:', this.selectedNodeType); } else { // 子节点:使用单个设备code this.queryParams.monitorId = data.code; - console.log('点击子节点:', data.label, 'code:', data.code); + this.selectedNodeType = data.type; + console.log('点击子节点:', data.label, 'code:', data.code, 'type:', this.selectedNodeType); } - // 存储当前选中节点的type,用于控制列显示 - this.selectedNodeType = data.type; - console.log('选中节点类型:', this.selectedNodeType); this.handleQuery(); }, @@ -485,8 +475,8 @@ export default { } - // 如果没有选中节点,则获取所有设备ID - if (!this.queryParams.monitorId) { + // 如果既没有选中单个节点,也没有选中父节点,则获取所有设备ID + if (!this.queryParams.monitorId && (!this.queryParams.monitorIds || this.queryParams.monitorIds.length === 0)) { this.queryParams.monitorIds = this.getAllMonitorIds(this.monitorInfoOptions); } @@ -494,6 +484,13 @@ export default { this.recordIotenvInstantList = response.rows; this.total = response.total; this.loading = false; + + // 调试信息:检查返回的数据 + console.log('查询结果:', response.rows); + console.log('当前选中节点类型:', this.selectedNodeType); + if (response.rows && response.rows.length > 0) { + console.log('第一条记录的时间字段:', response.rows[0].recodeTime); + } }); }, // 取消按钮 @@ -529,7 +526,14 @@ export default { /** 重置按钮操作 */ resetQuery() { this.resetForm("queryForm"); - this.daterangeCollectTime = []; + + // 重置时间范围为默认值(昨天8:00:00到今天8:00:00) + const nowDate = new Date(); + const today = parseTime(new Date(), '{y}-{m}-{d}') + const lastDate = new Date(); + lastDate.setDate(nowDate.getDate() - 1) + const yesterday = parseTime(lastDate, '{y}-{m}-{d}') + this.daterangeRecordTime = [yesterday + ' 08:00:00', today + ' 08:00:00']; // 重置选中节点类型和查询条件 this.selectedNodeType = null;