From 0d18a8b25d9dc4995aa18d7c564e90d76f483185 Mon Sep 17 00:00:00 2001
From: tuqin <tuqin@tuqin.cn>
Date: 星期三, 28 十月 2026 10:11:57 +0800
Subject: [PATCH] feat(无人值守): 远程控制可视化——二次确认弹窗(协议/地址/当前状态)、执行进度、三态结果、通讯日志弹窗、记录列表加耗时与日志入口

---
 src/views/environmentAccess/deviceMonitor/index.vue |  184 ++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 169 insertions(+), 15 deletions(-)

diff --git a/src/views/environmentAccess/deviceMonitor/index.vue b/src/views/environmentAccess/deviceMonitor/index.vue
index a048443..307499f 100644
--- a/src/views/environmentAccess/deviceMonitor/index.vue
+++ b/src/views/environmentAccess/deviceMonitor/index.vue
@@ -234,24 +234,66 @@
           <el-table-column prop="operateTime" label="涓嬪彂鏃堕棿" width="170" align="center">
             <template #default="{ row }">{{ formatDateTime(row.operateTime) }}</template>
           </el-table-column>
-          <el-table-column prop="deviceName" label="璁惧" width="160" />
-          <el-table-column label="鎺у埗鎸囦护" width="110" align="center">
+          <el-table-column prop="deviceName" label="璁惧" width="150" />
+          <el-table-column label="鎺у埗鎸囦护" width="100" align="center">
             <template #default="{ row }">{{ controlCommandText(row.controlCommand) }}</template>
           </el-table-column>
-          <el-table-column prop="controlType" label="鎺у埗绫诲瀷" width="110" align="center" />
-          <el-table-column prop="commandSource" label="鎸囦护鏉ユ簮" width="110" align="center" />
-          <el-table-column prop="operator" label="鎿嶄綔浜�" width="110" align="center" />
-          <el-table-column label="鎵ц缁撴灉" width="110" align="center">
+          <el-table-column prop="controlType" label="鎺у埗绫诲瀷" width="100" align="center" />
+          <el-table-column prop="operator" label="鎿嶄綔浜�" width="100" align="center" />
+          <el-table-column label="鎵ц缁撴灉" width="140" align="center">
             <template #default="{ row }">
-              <el-tag :type="row.execResult === '0' ? 'success' : 'danger'" size="small">
-                {{ row.execResult === '0' ? '鎴愬姛' : '澶辫触' }}
+              <!-- 鎵ц缁撴灉涓夋�侊細鎴愬姛 / 宸插彈鐞�(妯℃嫙) / 澶辫触 -->
+              <el-tag v-if="row.execResult === '0' && isSimulate(row)" type="warning" size="small">
+                宸插彈鐞嗭紙妯℃嫙锛�
               </el-tag>
+              <el-tag v-else-if="row.execResult === '0'" type="success" size="small">鎵ц鎴愬姛</el-tag>
+              <el-tag v-else-if="row.execResult === '2'" type="info" size="small">涓嬪彂涓�</el-tag>
+              <el-tag v-else type="danger" size="small">鎵ц澶辫触</el-tag>
             </template>
           </el-table-column>
-          <el-table-column prop="resultMsg" label="缁撴灉璇存槑" min-width="200" show-overflow-tooltip />
+          <el-table-column label="鑰楁椂" width="90" align="center">
+            <template #default="{ row }">{{ row.execDuration != null ? row.execDuration + " ms" : "-" }}</template>
+          </el-table-column>
+          <el-table-column prop="resultMsg" label="缁撴灉璇存槑" min-width="220" show-overflow-tooltip />
+          <el-table-column label="鎿嶄綔" width="90" align="center" fixed="right">
+            <template #default="{ row }">
+              <el-button link type="primary" size="small" @click="showControlDetail(row)">閫氳鏃ュ織</el-button>
+            </template>
+          </el-table-column>
         </el-table>
       </el-tab-pane>
     </el-tabs>
+
+    <!-- ==================== 杩滅▼鎺у埗鎵ц缁撴灉 ==================== -->
+    <el-dialog v-model="controlResultVisible" title="杩滅▼鎺у埗鎵ц缁撴灉" width="700px" top="8vh">
+      <div class="ctrl-result">
+        <div class="ctrl-result-head" :class="controlResult.execResult === '0' ? 'ok' : 'fail'">
+          <span class="ctrl-result-icon">{{ controlResult.execResult === '0' ? '鉁�' : '鉁�' }}</span>
+          <span>{{ controlResult.deviceName }} 路 {{ controlResult.action }}</span>
+        </div>
+        <el-descriptions :column="2" border size="small">
+          <el-descriptions-item label="鎵ц缁撴灉">
+            <el-tag v-if="controlResult.execResult === '0' && controlResult.simulate" type="warning" size="small">
+              鎸囦护宸插彈鐞嗭紙妯℃嫙妯″紡锛�
+            </el-tag>
+            <el-tag v-else-if="controlResult.execResult === '0'" type="success" size="small">鎵ц鎴愬姛</el-tag>
+            <el-tag v-else-if="controlResult.execResult === '2'" type="info" size="small">涓嬪彂涓�</el-tag>
+            <el-tag v-else type="danger" size="small">鎵ц澶辫触</el-tag>
+          </el-descriptions-item>
+          <el-descriptions-item label="鎵ц鑰楁椂">{{ controlResult.duration }} ms</el-descriptions-item>
+          <el-descriptions-item label="鎵ц妯″紡" :span="2">
+            <el-tag v-if="controlResult.simulate" type="warning" size="small">妯℃嫙妯″紡 鈥斺�� 鏈帴鍏ョ幇鍦鸿澶囷紝鎸囦护鏈疄闄呭啓鍏ヨ澶�</el-tag>
+            <el-tag v-else type="success" size="small">鐪熷疄涓嬪彂 鈥斺�� 宸插啓鍏ヨ澶囨帶鍒跺瘎瀛樺櫒</el-tag>
+          </el-descriptions-item>
+          <el-descriptions-item label="缁撴灉璇存槑" :span="2">{{ controlResult.resultMsg || "-" }}</el-descriptions-item>
+        </el-descriptions>
+        <div class="ctrl-log-title">閫氳鏃ュ織</div>
+        <pre class="ctrl-log">{{ controlResult.detail || "锛堟棤鏃ュ織锛�" }}</pre>
+      </div>
+      <template #footer>
+        <el-button type="primary" @click="controlResultVisible = false">鐭ラ亾浜�</el-button>
+      </template>
+    </el-dialog>
 
     <!-- ==================== 璁惧寮圭獥 ==================== -->
     <el-dialog v-model="deviceDialog" :title="deviceForm.id ? '缂栬緫鐩戞帶璁惧' : '鏂板鐩戞帶璁惧'" width="760px"
@@ -457,7 +499,7 @@
 
 <script setup>
 import { onMounted, onUnmounted, reactive, ref } from "vue";
-import { ElMessageBox, ElNotification } from "element-plus";
+import { ElLoading, ElMessageBox, ElNotification } from "element-plus";
 import Echarts from "@/components/Echarts/echarts.vue";
 import {
   addMonitorDevice,
@@ -569,19 +611,68 @@
   }).catch(() => {});
 };
 const controlDevice = (row, command) => {
+  const actionText = command === "stop" ? "杩滅▼鍋滄満" : command === "restart" ? "杩滅▼閲嶅惎" : "杩滅▼鍚姩";
+  const runText = row.runStatus === "1" ? "杩愯涓�" : "宸插仠鏈�";
   ElMessageBox.confirm(
-    `纭瀵广��${row.deviceName}銆嶆墽琛�${command === "stop" ? "杩滅▼鍋滄満" : "杩滅▼鍚姩"}鎿嶄綔锛焋,
-    "杩滅▼鎺у埗",
-    { type: "warning" }
+    `<div style="line-height:1.9">
+       <div>璁惧锛�<b>${row.deviceName || "-"}</b></div>
+       <div>閫氳鍗忚锛�${row.commProtocol || "鏈厤缃�"}</div>
+       <div>璁惧鍦板潃锛�${row.ipAddress || "鏈厤缃�"}</div>
+       <div>褰撳墠鐘舵�侊細${runText}</div>
+       <div style="margin-top:8px">鎵ц鍔ㄤ綔锛�<b style="color:#e6a23c">${actionText}</b></div>
+       <div style="margin-top:8px;color:#909399;font-size:12px">绯荤粺灏嗗皾璇曡繛鎺ヨ澶囧苟涓嬪彂鎸囦护锛屾墽琛岃繃绋嬩細璁板綍鍦ㄩ�氳鏃ュ織涓�</div>
+     </div>`,
+    "杩滅▼鎺у埗纭",
+    {
+      type: "warning",
+      dangerouslyUseHTMLString: true,
+      confirmButtonText: "纭鎵ц",
+      cancelButtonText: "鍙栨秷",
+    }
   ).then(() => {
+    const loading = ElLoading.service({ lock: true, text: "姝e湪杩炴帴璁惧骞朵笅鍙戞寚浠も��", background: "rgba(0,0,0,0.4)" });
+    const startAt = Date.now();
     remoteControlDevice({ deviceId: row.id, command })
       .then((res) => {
-        proxy.$modal.msgSuccess(res.data?.resultMsg || "鎸囦护宸蹭笅鍙�");
+        const data = (res && res.data) || {};
+        showControlResult({
+          deviceName: row.deviceName,
+          action: actionText,
+          execResult: data.execResult,
+          resultMsg: data.resultMsg || "",
+          duration: data.execDuration != null ? data.execDuration : Date.now() - startAt,
+          detail: data.execDetail || "",
+        });
         loadDevice();
         loadOverview();
+        loadControl();
       })
-      .catch(() => {});
+      .catch(() => {})
+      .finally(() => loading.close());
   }).catch(() => {});
+};
+
+// ==================== 杩滅▼鎺у埗鎵ц缁撴灉寮圭獥 ====================
+const controlResultVisible = ref(false);
+const controlResult = ref({});
+const isSimulate = (row) =>
+  /妯℃嫙妯″紡/.test(row.resultMsg || "") || /妯℃嫙妯″紡/.test(row.execDetail || "");
+
+const showControlResult = (data) => {
+  controlResult.value = { ...data, simulate: isSimulate(data) };
+  controlResultVisible.value = true;
+};
+
+/** 浠庢帶鍒惰褰曢噷鏌ョ湅閫氳鏃ュ織 */
+const showControlDetail = (row) => {
+  showControlResult({
+    deviceName: row.deviceName,
+    action: controlCommandText(row.controlCommand),
+    execResult: row.execResult,
+    resultMsg: row.resultMsg || "",
+    duration: row.execDuration != null ? row.execDuration : 0,
+    detail: row.execDetail || "",
+  });
 };
 
 // ==================== 鎸囨爣 ====================
@@ -828,6 +919,69 @@
 </script>
 
 <style scoped lang="scss">
+/* ============ 杩滅▼鎺у埗鎵ц缁撴灉寮圭獥 ============ */
+.ctrl-result {
+  font-size: 13px;
+}
+.ctrl-result-head {
+  display: flex;
+  align-items: center;
+  gap: 10px;
+  font-size: 15px;
+  font-weight: 600;
+  padding: 10px 14px;
+  border-radius: 6px;
+  margin-bottom: 14px;
+
+  &.ok {
+    color: #067d3c;
+    background: #eafaf1;
+    border: 1px solid #b7ebd0;
+  }
+  &.fail {
+    color: #c0392b;
+    background: #fef0f0;
+    border: 1px solid #fbc4c4;
+  }
+}
+.ctrl-result-icon {
+  display: inline-flex;
+  align-items: center;
+  justify-content: center;
+  width: 22px;
+  height: 22px;
+  border-radius: 50%;
+  color: #fff;
+  font-size: 13px;
+  background: #67c23a;
+
+  .ctrl-result-head.fail & {
+    background: #f56c6c;
+  }
+}
+.ctrl-log-title {
+  font-size: 14px;
+  font-weight: 600;
+  color: #303133;
+  border-left: 3px solid #409eff;
+  padding-left: 8px;
+  margin: 16px 0 8px;
+}
+.ctrl-log {
+  margin: 0;
+  padding: 12px 14px;
+  background: #1e1e1e;
+  color: #d4d4d4;
+  border-radius: 6px;
+  font-family: Consolas, Monaco, "Courier New", monospace;
+  font-size: 12px;
+  line-height: 1.7;
+  max-height: 260px;
+  overflow: auto;
+  white-space: pre-wrap;
+  word-break: break-all;
+}
+
 .monitor-page {
   .overview-row {
     display: flex;

--
Gitblit v1.9.3