From 54de60fc3e98ad17f280ae1c8c5ee7fcb32891d3 Mon Sep 17 00:00:00 2001
From: tuqin <tuqin@tuqin.cn>
Date: 星期四, 29 十月 2026 14:52:45 +0800
Subject: [PATCH] feat(LIMS): 采集清洗 + 监控告警前端

---
 src/views/lims/realtimeMonitor/index.vue |  158 +++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 141 insertions(+), 17 deletions(-)

diff --git a/src/views/lims/realtimeMonitor/index.vue b/src/views/lims/realtimeMonitor/index.vue
index a78d262..0c0dd98 100644
--- a/src/views/lims/realtimeMonitor/index.vue
+++ b/src/views/lims/realtimeMonitor/index.vue
@@ -38,6 +38,8 @@
       </div>
       <div>
         <el-button type="primary" @click="openForm('add')">鏂板鐩戞帶</el-button>
+        <el-button type="success" plain @click="doCheckAll">鍏ㄩ噺妫�鏌�</el-button>
+        <el-button type="warning" plain @click="openAlerts">鍛婅璁板綍 <span v-if="alertStat.pending > 0">({{ alertStat.pending }})</span></el-button>
         <el-button @click="handleOut">瀵煎嚭</el-button>
         <el-button type="danger" plain @click="handleDelete">鍒犻櫎</el-button>
       </div>
@@ -296,6 +298,52 @@
       </template>
     </el-dialog>
   </div>
+
+    <!-- ===== 鍛婅璁板綍鎶藉眽 ===== -->
+    <el-drawer v-model="alertVisible" title="鍛婅璁板綍" size="960px" destroy-on-close>
+      <div style="margin-bottom: 12px; display: flex; gap: 16px; font-size: 14px">
+        <span>寰呭鐞� <el-tag type="danger" size="small">{{ alertStat.pending || 0 }}</el-tag></span>
+        <span>澶勭悊涓� <el-tag type="warning" size="small">{{ alertStat.handling || 0 }}</el-tag></span>
+        <span>宸插鐞� <el-tag type="success" size="small">{{ alertStat.resolved || 0 }}</el-tag></span>
+        <span style="margin-left: auto">绱ф�� {{ alertStat.levelHigh || 0 }} / 閲嶈 {{ alertStat.levelMedium || 0 }} / 涓�鑸� {{ alertStat.levelLow || 0 }}</span>
+      </div>
+      <el-table :data="alertData" :loading="alertLoading" border size="small" max-height="560">
+        <el-table-column prop="alertTime" label="鍛婅鏃堕棿" width="160" />
+        <el-table-column prop="monitorTarget" label="鐩戞帶瀵硅薄" width="150" show-overflow-tooltip />
+        <el-table-column prop="alertLevel" label="绾у埆" width="80">
+          <template #default="{ row }">
+            <el-tag :type="row.alertLevel === 'high' ? 'danger' : row.alertLevel === 'medium' ? 'warning' : 'info'" size="small">{{ alertLevelText(row.alertLevel) }}</el-tag>
+          </template>
+        </el-table-column>
+        <el-table-column prop="alertValue" label="瑙﹀彂鍊�" width="100">
+          <template #default="{ row }">{{ row.alertValue }}{{ row.unit || "" }}</template>
+        </el-table-column>
+        <el-table-column prop="alertMessage" label="鍛婅鎻忚堪" show-overflow-tooltip />
+        <el-table-column prop="status" label="鐘舵��" width="90">
+          <template #default="{ row }">
+            <el-tag :type="alertStatusTag(row.status)" size="small">{{ alertStatusText(row.status) }}</el-tag>
+          </template>
+        </el-table-column>
+        <el-table-column prop="handler" label="澶勭悊浜�" width="90" />
+        <el-table-column label="鎿嶄綔" width="90" align="center">
+          <template #default="{ row }">
+            <el-button v-if="row.status === 'pending' || row.status === 'handling'" link type="primary" @click="doHandleAlert(row)">澶勭悊</el-button>
+            <span v-else style="color: #909399">鈥�</span>
+          </template>
+        </el-table-column>
+      </el-table>
+      <div style="margin-top: 12px; text-align: right">
+        <el-pagination
+          v-model:current-page="alertQuery.pageNum"
+          v-model:page-size="alertQuery.pageSize"
+          :total="alertTotal"
+          :page-sizes="[20, 50, 100]"
+          layout="total, sizes, prev, pager, next"
+          @current-change="loadAlerts"
+          @size-change="loadAlerts"
+        />
+      </div>
+    </el-drawer>
 </template>
 
 <script setup>
@@ -308,8 +356,9 @@
   listRealtimeMonitor,
   updateRealtimeMonitor,
 } from "@/api/lims/realtimeMonitor.js";
-import { ElMessageBox } from "element-plus";
+import { ElMessage, ElMessageBox } from "element-plus";
 import { userListNoPage } from "@/api/system/user.js";
+import { checkMonitor, checkAllMonitors, listAlerts, handleAlert, getMonitorDashboard } from "@/api/lims/realtimeMonitor";
 import useUserStore from "@/store/modules/user";
 const { proxy } = getCurrentInstance();
 const userStore = useUserStore();
@@ -380,22 +429,15 @@
     width: 100,
   },
   {
-    dataType: "action",
-    label: "鎿嶄綔",
-    align: "center",
-    fixed: 'right',
-    operation: [
-      {
-        name: "缂栬緫",
-        type: "text",
-        clickFun: (row) => {
-          openForm("edit", row);
-        },
-        disabled: (row) => {
-          return row.maintainer !== userStore.nickName
-        }
-      },
-    ],
+      dataType: "action",
+      label: "鎿嶄綔",
+      align: "center",
+      fixed: 'right',
+      width: 200,
+      operation: [
+        { name: "妫�鏌�", type: "text", clickFun: (row) => { doCheck(row); } },
+        { name: "缂栬緫", type: "text", clickFun: (row) => { openForm("edit", row); } },
+      ],
   },
 ]);
 const tableData = ref([]);
@@ -574,7 +616,89 @@
   return `${year}-${month}-${day}`;
 }
 
+// ==================== 鈶� 棰勮鍒ゅ畾涓庡憡璀﹂棴鐜� ====================
+const alertVisible = ref(false);
+const alertData = ref([]);
+const alertLoading = ref(false);
+const alertTotal = ref(0);
+const alertQuery = ref({ pageNum: 1, pageSize: 20 });
+const alertStat = ref({ pending: 0, handling: 0, resolved: 0, levelHigh: 0, levelMedium: 0, levelLow: 0, total: 0 });
+const dashboard = ref({ total: 0, alerting: 0, warning: 0, normal: 0 });
+
+const ALERT_STATUS = { pending: "寰呭鐞�", handling: "澶勭悊涓�", resolved: "宸插鐞�", ignored: "宸插拷鐣�" };
+const ALERT_LEVEL = { high: "绱ф��", medium: "閲嶈", low: "涓�鑸�" };
+const alertStatusText = (s) => ALERT_STATUS[s] || s || "鈥�";
+const alertLevelText = (s) => ALERT_LEVEL[s] || s || "鈥�";
+const alertStatusTag = (s) => (s === "pending" ? "danger" : s === "handling" ? "warning" : s === "resolved" ? "success" : "info");
+
+// 妫�鏌ュ崟涓洃鎺ч」
+const doCheck = (row) => {
+  checkMonitor(row.id).then((res) => {
+    const d = res.data || {};
+    if (d.alerts > 0) {
+      ElMessage.warning("妫�娴嬪埌瓒婇檺锛屽凡鐢熸垚鍛婅");
+    } else if (d.suppressed > 0) {
+      ElMessage.info("瓒婇檺浣嗗凡鏈夋湭澶勭悊鍛婅锛屾湭閲嶅鐢熸垚");
+    } else {
+      ElMessage.success("褰撳墠鍊兼甯�");
+    }
+    getList();
+    loadDashboard();
+  });
+};
+
+// 鍏ㄩ噺妫�鏌�
+const doCheckAll = () => {
+  checkAllMonitors(500).then((res) => {
+    const d = res.data || {};
+    ElMessage.success(`鎵弿 ${d.scanned || 0} 涓洃鎺ч」锛屾柊澧炲憡璀� ${d.alerts || 0} 鏉);
+    getList();
+    loadDashboard();
+  });
+};
+
+// 鍛婅鍒楄〃
+const openAlerts = () => {
+  alertQuery.value = { pageNum: 1, pageSize: 20 };
+  alertVisible.value = true;
+  loadAlerts();
+};
+const loadAlerts = () => {
+  alertLoading.value = true;
+  listAlerts(alertQuery.value).then((res) => {
+    alertLoading.value = false;
+    alertData.value = res.data.records || [];
+    alertTotal.value = res.data.total || 0;
+  }).catch(() => (alertLoading.value = false));
+};
+
+// 鐪嬫澘涓庣粺璁�
+const loadDashboard = () => {
+  getMonitorDashboard().then((res) => {
+    const d = res.data || {};
+    dashboard.value = d;
+    if (d.alerts) alertStat.value = d.alerts;
+  });
+};
+
+// 澶勭悊鍛婅
+const doHandleAlert = (row) => {
+  ElMessageBox.prompt("璇峰~鍐欏鐞嗘帾鏂斤紙閫夊~锛�", `澶勭悊鍛婅锛�${row.monitorTarget || row.monitorCode}`, {
+    inputPlaceholder: "濡� 宸查�氱煡杩愮淮璋冩暣鍙傛暟",
+    confirmButtonText: "纭宸插鐞�",
+    cancelButtonText: "鍙栨秷",
+  }).then(({ value }) => {
+    handleAlert({ alertId: row.id, status: "resolved", measure: value }).then((res) => {
+      ElMessage.success(res.msg || "宸插鐞�");
+      loadAlerts();
+      loadDashboard();
+      getList();
+    });
+  }).catch(() => {});
+};
+
 onMounted(() => {
+  loadDashboard();
   getList();
 });
 </script>

--
Gitblit v1.9.3