From 1efff33806f86c7e7623a4a127a0a3ccd66b01ab Mon Sep 17 00:00:00 2001
From: tuqin <tuqin@tuqin.cn>
Date: 星期四, 22 十月 2026 12:15:58 +0800
Subject: [PATCH] feat(无人值守): 远程监控增加监测趋势曲线、巡检路径支持调整巡检顺序

---
 src/views/environmentAccess/deviceMonitor/index.vue                   |   98 ++++++++++++++++++++++++++++++++
 src/api/environmentAccess/deviceMonitor.js                            |    4 +
 src/views/environmentAccess/intelligentInspectionManagement/index.vue |   76 ++++++++++++++++++++-----
 3 files changed, 162 insertions(+), 16 deletions(-)

diff --git a/src/api/environmentAccess/deviceMonitor.js b/src/api/environmentAccess/deviceMonitor.js
index ab6b02a..a35ba35 100644
--- a/src/api/environmentAccess/deviceMonitor.js
+++ b/src/api/environmentAccess/deviceMonitor.js
@@ -38,6 +38,10 @@
 export function reportMonitorData(params) {
   return request({ url: "/environmentAccess/monitorDataReport", method: "post", params });
 }
+// 鐩戞祴鍘嗗彶鏁版嵁(瓒嬪娍鏇茬嚎)
+export function listMonitorDataHistory(params) {
+  return request({ url: "/environmentAccess/monitorDataHistory", method: "get", params });
+}
 
 // ==================== 鎶ヨ ====================
 export function listMonitorAlarm(query) {
diff --git a/src/views/environmentAccess/deviceMonitor/index.vue b/src/views/environmentAccess/deviceMonitor/index.vue
index 19a2b29..a048443 100644
--- a/src/views/environmentAccess/deviceMonitor/index.vue
+++ b/src/views/environmentAccess/deviceMonitor/index.vue
@@ -90,9 +90,10 @@
                   <el-table-column label="鏈�鍚庨噰闆嗘椂闂�" width="180" align="center">
                     <template #default="{ row: metric }">{{ formatDateTime(metric.lastCollectTime) }}</template>
                   </el-table-column>
-                  <el-table-column label="鎿嶄綔" width="140" align="center">
+                  <el-table-column label="鎿嶄綔" width="200" align="center">
                     <template #default="{ row: metric }">
                       <el-button link type="primary" @click="openReportDialog(row, metric)">涓婃姤鏁版嵁</el-button>
+                      <el-button link type="primary" @click="openTrendDialog(row, metric)">瓒嬪娍</el-button>
                     </template>
                   </el-table-column>
                 </el-table>
@@ -424,12 +425,40 @@
         <el-button type="primary" :loading="reportLoading" @click="submitReportData">涓婃姤</el-button>
       </template>
     </el-dialog>
+
+    <!-- ==================== 鐩戞祴瓒嬪娍 ==================== -->
+    <el-dialog v-model="trendDialog" title="鐩戞祴瓒嬪娍" width="880px">
+      <div class="trend-header">
+        <span class="trend-device">{{ trendForm.deviceName }} 路 {{ trendForm.metricName }}</span>
+        <el-radio-group v-model="trendRange" size="small" @change="loadTrend">
+          <el-radio-button value="1">杩�1澶�</el-radio-button>
+          <el-radio-button value="7">杩�7澶�</el-radio-button>
+          <el-radio-button value="30">杩�30澶�</el-radio-button>
+        </el-radio-group>
+      </div>
+      <div v-if="trendData.length" style="width: 100%">
+        <Echarts
+          :chartStyle="trendChartStyle"
+          :grid="trendGrid"
+          :xAxis="trendXAxis"
+          :yAxis="trendYAxis"
+          :series="trendSeries"
+          :tooltip="trendTooltip"
+          style="height: 340px"
+        />
+      </div>
+      <el-empty v-else description="璇ユ椂闂存鏆傛棤閲囬泦鏁版嵁锛屽彲鍦ㄤ笂鏂规寚鏍囬噷鍏堜笂鎶ヤ竴鏉″啀鐪嬭秼鍔�" />
+      <template #footer>
+        <el-button @click="trendDialog = false">鍏抽棴</el-button>
+      </template>
+    </el-dialog>
   </div>
 </template>
 
 <script setup>
 import { onMounted, onUnmounted, reactive, ref } from "vue";
 import { ElMessageBox, ElNotification } from "element-plus";
+import Echarts from "@/components/Echarts/echarts.vue";
 import {
   addMonitorDevice,
   addMonitorMetric,
@@ -440,6 +469,7 @@
   handleMonitorAlarm,
   listMonitorAlarm,
   listMonitorControl,
+  listMonitorDataHistory,
   listMonitorDevice,
   listMonitorMetric,
   reportMonitorData,
@@ -606,6 +636,62 @@
   return metric.thresholdMax !== null && metric.thresholdMax !== undefined && value > Number(metric.thresholdMax);
 };
 const metricAlarmClass = (metric) => (isMetricAlarm(metric) ? "danger-text" : "");
+
+// ==================== 鐩戞祴瓒嬪娍 ====================
+const trendDialog = ref(false);
+const trendRange = ref("1");
+const trendData = ref([]);
+const trendForm = reactive({ deviceId: null, deviceName: "", metricCode: "", metricName: "", unit: "" });
+const trendChartStyle = { width: "100%", height: "100%" };
+const trendGrid = { left: "3%", right: "4%", bottom: "10%", top: "12%", containLabel: true };
+const trendTooltip = { trigger: "axis" };
+const trendXAxis = ref([{ type: "category", data: [], axisLabel: { rotate: 20 } }]);
+const trendYAxis = ref([{ type: "value", scale: true }]);
+const trendSeries = ref([]);
+
+const toDateTimeStr = (d) => {
+  const pad = (n) => String(n).padStart(2, "0");
+  return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())} ${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}`;
+};
+
+const openTrendDialog = (device, metric) => {
+  trendForm.deviceId = device.id;
+  trendForm.deviceName = device.deviceName;
+  trendForm.metricCode = metric.metricCode;
+  trendForm.metricName = metric.metricName;
+  trendForm.unit = metric.unit || "";
+  trendRange.value = "1";
+  trendDialog.value = true;
+  loadTrend();
+};
+
+const loadTrend = () => {
+  const days = Number(trendRange.value || 1);
+  const end = new Date();
+  const start = new Date(end.getTime() - days * 24 * 3600 * 1000);
+  listMonitorDataHistory({
+    deviceId: trendForm.deviceId,
+    metricCode: trendForm.metricCode,
+    startTime: toDateTimeStr(start),
+    endTime: toDateTimeStr(end),
+  }).then((res) => {
+    const list = res.data || [];
+    trendData.value = list;
+    trendXAxis.value[0].data = list.map((item) => formatDateTime(item.collectTime).substring(5, 16));
+    trendSeries.value = [
+      {
+        name: trendForm.metricName + (trendForm.unit ? `(${trendForm.unit})` : ""),
+        type: "line",
+        smooth: true,
+        symbol: "circle",
+        symbolSize: 6,
+        data: list.map((item) => Number(item.metricValue)),
+        itemStyle: { color: "#409EFF" },
+        areaStyle: { opacity: 0.12 },
+      },
+    ];
+  });
+};
 
 // ==================== 鏁版嵁涓婃姤 ====================
 const reportDialog = ref(false);
@@ -804,5 +890,15 @@
   .metric-actions {
     margin-bottom: 10px;
   }
+  .trend-header {
+    display: flex;
+    align-items: center;
+    justify-content: space-between;
+    margin-bottom: 12px;
+    .trend-device {
+      font-weight: 600;
+      color: #303133;
+    }
+  }
 }
 </style>
diff --git a/src/views/environmentAccess/intelligentInspectionManagement/index.vue b/src/views/environmentAccess/intelligentInspectionManagement/index.vue
index 1296a88..0fb8862 100644
--- a/src/views/environmentAccess/intelligentInspectionManagement/index.vue
+++ b/src/views/environmentAccess/intelligentInspectionManagement/index.vue
@@ -266,17 +266,23 @@
             </el-form-item>
           </el-col>
         </el-row>
-        <el-form-item label="宸℃鐐逛綅(鎸夐�夋嫨椤哄簭渚濇宸℃)锛�">
+        <el-form-item label="宸℃鐐逛綅(鎸夊簭鍙蜂緷娆″贰妫�锛屽彲涓婁笅璋冩暣椤哄簭)锛�">
           <el-select v-model="routePointIds" multiple filterable style="width: 100%"
                      placeholder="璇烽�夋嫨宸℃鐐逛綅">
             <el-option v-for="item in allPointList" :key="item.id"
                        :label="`${item.pointName}锛�${item.areaName || '鏈垎鍖�'}锛塦" :value="item.id" />
           </el-select>
-          <div class="point-order">
-            <span class="label">宸℃椤哄簭锛�</span>
-            <el-tag v-for="(name, index) in selectedPointNames" :key="index" size="small" style="margin-right: 6px">
-              {{ index + 1 }}. {{ name }}
-            </el-tag>
+          <div class="point-order-editor">
+            <div v-for="(name, index) in selectedPointNames" :key="index" class="order-item">
+              <span class="seq">{{ index + 1 }}</span>
+              <span class="name">{{ name }}</span>
+              <span class="ops">
+                <el-button link type="primary" :disabled="index === 0" @click="movePoint(index, -1)">涓婄Щ</el-button>
+                <el-button link type="primary" :disabled="index === routePointIds.length - 1"
+                           @click="movePoint(index, 1)">涓嬬Щ</el-button>
+                <el-button link type="danger" @click="removePointAt(index)">绉婚櫎</el-button>
+              </span>
+            </div>
             <span v-if="selectedPointNames.length === 0" class="sub-text">灏氭湭閫夋嫨鐐逛綅</span>
           </div>
         </el-form-item>
@@ -602,6 +608,26 @@
   });
 });
 
+/** 璋冩暣宸℃椤哄簭锛歞irection = -1 涓婄Щ / 1 涓嬬Щ */
+const movePoint = (index, direction) => {
+  const list = [...routePointIds.value];
+  const target = index + direction;
+  if (target < 0 || target >= list.length) {
+    return;
+  }
+  const tmp = list[index];
+  list[index] = list[target];
+  list[target] = tmp;
+  routePointIds.value = list;
+};
+
+/** 浠庡贰妫�椤哄簭涓Щ闄ゆ煇涓偣浣� */
+const removePointAt = (index) => {
+  const list = [...routePointIds.value];
+  list.splice(index, 1);
+  routePointIds.value = list;
+};
+
 const loadRoute = () => {
   routeLoading.value = true;
   listInspectionRoute({ ...routeQuery, current: 1, size: 500 })
@@ -845,16 +871,36 @@
     color: #909399;
     font-size: 13px;
   }
-  .point-order {
+  .point-order-editor {
     margin-top: 8px;
-    display: flex;
-    align-items: center;
-    flex-wrap: wrap;
-    gap: 4px;
-    .label {
-      color: #606266;
-      font-size: 13px;
-      margin-right: 4px;
+    .order-item {
+      display: flex;
+      align-items: center;
+      gap: 10px;
+      padding: 4px 8px;
+      border: 1px solid #ebeef5;
+      border-radius: 4px;
+      margin-bottom: 6px;
+      background: #fafafa;
+      .seq {
+        width: 22px;
+        height: 22px;
+        line-height: 22px;
+        text-align: center;
+        border-radius: 50%;
+        background: #409eff;
+        color: #fff;
+        font-size: 12px;
+        flex: 0 0 auto;
+      }
+      .name {
+        flex: 1;
+        color: #303133;
+        font-size: 13px;
+      }
+      .ops {
+        flex: 0 0 auto;
+      }
     }
   }
   .record-summary {

--
Gitblit v1.9.3