| | |
| | | <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" |
| | |
| | | |
| | | <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, |
| | |
| | | }).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: "正在连接设备并下发指令…", 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 || "", |
| | | }); |
| | | }; |
| | | |
| | | // ==================== 指标 ==================== |
| | |
| | | </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; |