Преглед изворни кода

chore: 迁移故障报警数据到mock_data.json文件

sequoia tungfang пре 3 недеља
родитељ
комит
9c14278f9b
3 измењених фајлова са 163 додато и 27 уклоњено
  1. 3 3
      src/mock/api.js
  2. 158 0
      src/mock/mock_data.json
  3. 2 24
      src/views/Home.vue

+ 3 - 3
src/mock/api.js

@@ -478,10 +478,10 @@ export async function apiGetControlModeStats() {
 export async function apiGetLatestAlarms(params = {}) {
   await delay(200)
   const typeMap = { high: 'error', mid: 'warning', low: 'warning' }
-  let alarms = DB.homeData.alarms.map((a, i) => ({
-    id: a.id, title: a.title, type: typeMap[a.level] || 'warning',
+  let alarms = DB.homeData.alarmList.map((a, i) => ({
+    id: a.id, title: a.title, type: a.type || typeMap[a.level] || 'warning',
     time: new Date(Date.now() - i * 180000 - Math.floor(Math.random() * 60000)).toLocaleTimeString(),
-    description: `${a.loc}-${a.title}`,
+    description: a.description || `${a.loc}-${a.title}`,
     position: a.position, level: a.level, loc: a.loc,
   }))
 

+ 158 - 0
src/mock/mock_data.json

@@ -16138,6 +16138,164 @@
       "total": 718,
       "rate": 93
     },
+    "alarmList": [
+      {
+        "id": "A001",
+        "title": "通讯中断",
+        "time": "23:15:10",
+        "loc": "孔兴路与马坊路交叉口",
+        "level": "high",
+        "type": "error",
+        "description": "孔兴路与马坊路交叉口-通讯中断",
+        "position": [
+          116.82010781,
+          39.65530553
+        ]
+      },
+      {
+        "id": "A002",
+        "title": "灯组故障",
+        "time": "23:23:10",
+        "loc": "TZ-174_绿心路路口(高怀亭北侧)",
+        "level": "high",
+        "type": "error",
+        "description": "TZ-174_绿心路路口(高怀亭北侧)-灯组故障",
+        "position": [
+          116.7337275,
+          39.86628653
+        ]
+      },
+      {
+        "id": "A003",
+        "title": "相位冲突",
+        "time": "22:44:10",
+        "loc": "TZ-263_玉桥东路与梨园北街交叉路口",
+        "level": "high",
+        "type": "error",
+        "description": "TZ-263_玉桥东路与梨园北街交叉路口-相位冲突",
+        "position": [
+          116.6804849,
+          39.8883888
+        ]
+      },
+      {
+        "id": "A004",
+        "title": "绿冲突",
+        "time": "22:48:10",
+        "loc": "TZ-364_辛安屯街与涌翠西路交叉路口",
+        "level": "high",
+        "type": "error",
+        "description": "TZ-364_辛安屯街与涌翠西路交叉路口-绿冲突",
+        "position": [
+          116.7085411,
+          39.9068868
+        ]
+      },
+      {
+        "id": "A005",
+        "title": "信号机离线",
+        "time": "23:09:10",
+        "loc": "TZ-420_滨惠北一街与新光大中心西侧路口",
+        "level": "mid",
+        "type": "warning",
+        "description": "TZ-420_滨惠北一街与新光大中心西侧路口-信号机离线",
+        "position": [
+          116.6540691,
+          39.91379601
+        ]
+      },
+      {
+        "id": "A006",
+        "title": "信号机离线",
+        "time": "23:27:10",
+        "loc": "TZ-332_畅和西路与大营南街交叉路口",
+        "level": "mid",
+        "type": "warning",
+        "description": "TZ-332_畅和西路与大营南街交叉路口-信号机离线",
+        "position": [
+          116.7343819,
+          39.89434512
+        ]
+      },
+      {
+        "id": "A007",
+        "title": "通讯中断",
+        "time": "23:20:10",
+        "loc": "TZ-474_陈列馆路与焦王庄街交叉路口",
+        "level": "high",
+        "type": "error",
+        "description": "TZ-474_陈列馆路与焦王庄街交叉路口-通讯中断",
+        "position": [
+          116.6672838,
+          39.93854207
+        ]
+      },
+      {
+        "id": "A008",
+        "title": "检测器异常",
+        "time": "23:11:10",
+        "loc": "TZ-083_月异路(南延)与文盛街交叉路口",
+        "level": "low",
+        "type": "warning",
+        "description": "TZ-083_月异路(南延)与文盛街交叉路口-检测器异常",
+        "position": [
+          116.6384983,
+          39.85510271
+        ]
+      },
+      {
+        "id": "A009",
+        "title": "降级黄闪",
+        "time": "23:28:10",
+        "loc": "京塘路石槽村",
+        "level": "mid",
+        "type": "warning",
+        "description": "京塘路石槽村-降级黄闪",
+        "position": [
+          116.84468105,
+          39.75430859
+        ]
+      },
+      {
+        "id": "A010",
+        "title": "降级黄闪",
+        "time": "23:21:10",
+        "loc": "TZ-339_潞通大街与紫运西路交叉路口",
+        "level": "mid",
+        "type": "warning",
+        "description": "TZ-339_潞通大街与紫运西路交叉路口-降级黄闪",
+        "position": [
+          116.6885718,
+          39.90370173
+        ]
+      },
+      {
+        "id": "A011",
+        "title": "方案切换异常",
+        "time": "22:39:10",
+        "loc": "TZ-553_宋翟路与徐尹路",
+        "level": "mid",
+        "type": "warning",
+        "description": "TZ-553_宋翟路与徐尹路-方案切换异常",
+        "position": [
+          116.7323515,
+          39.98695233
+        ]
+      },
+      {
+        "id": "A012",
+        "title": "检测器异常",
+        "time": "22:30:10",
+        "loc": "京塘路与塘通线交叉口",
+        "level": "low",
+        "type": "warning",
+        "description": "京塘路与塘通线交叉口-检测器异常",
+        "position": [
+          116.77770093,
+          39.81661765
+        ]
+      }
+    ],
     "alarms": [
       {
         "id": "A001",

+ 2 - 24
src/views/Home.vue

@@ -196,33 +196,11 @@ export default {
       ]);
       this.controlInfoData = controlData || [];
       
-      // 处理故障报警数据,确保显示12条,按4:4:4比例显示故障、离线、降级
+      // 处理故障报警数据,使用从API获取的12条数据
       let originalAlarms = alarmData?.list || alarmData || [];
       
-      // 定义三种状态的告警数据
-      const faultAlarms = [
-        { id: "F001", title: "通讯中断", time: new Date().toLocaleTimeString(), loc: "孔兴路与马坊路交叉口", level: "high", type: "error", description: "孔兴路与马坊路交叉口-通讯中断" },
-        { id: "F002", title: "灯组故障", time: new Date().toLocaleTimeString(), loc: "TZ-174_绿心路路口(高怀亭北侧)", level: "high", type: "error", description: "TZ-174_绿心路路口(高怀亭北侧)-灯组故障" },
-        { id: "F003", title: "相位冲突", time: new Date().toLocaleTimeString(), loc: "TZ-263_玉桥东路与梨园北街交叉路口", level: "high", type: "error", description: "TZ-263_玉桥东路与梨园北街交叉路口-相位冲突" },
-        { id: "F004", title: "绿冲突", time: new Date().toLocaleTimeString(), loc: "TZ-364_辛安屯街与涌翠西路交叉路口", level: "high", type: "error", description: "TZ-364_辛安屯街与涌翠西路交叉路口-绿冲突" }
-      ];
-      
-      const offlineAlarms = [
-        { id: "O001", title: "信号机离线", time: new Date().toLocaleTimeString(), loc: "TZ-420_滨惠北一街与新光大中心西侧路口", level: "mid", type: "warning", description: "TZ-420_滨惠北一街与新光大中心西侧路口-信号机离线" },
-        { id: "O002", title: "信号机离线", time: new Date().toLocaleTimeString(), loc: "TZ-332_畅和西路与大营南街交叉路口", level: "mid", type: "warning", description: "TZ-332_畅和西路与大营南街交叉路口-信号机离线" },
-        { id: "O003", title: "通讯中断", time: new Date().toLocaleTimeString(), loc: "TZ-474_陈列馆路与焦王庄街交叉路口", level: "high", type: "error", description: "TZ-474_陈列馆路与焦王庄街交叉路口-通讯中断" },
-        { id: "O004", title: "检测器异常", time: new Date().toLocaleTimeString(), loc: "TZ-083_月异路(南延)与文盛街交叉路口", level: "low", type: "warning", description: "TZ-083_月异路(南延)与文盛街交叉路口-检测器异常" }
-      ];
-      
-      const degradedAlarms = [
-        { id: "D001", title: "降级黄闪", time: new Date().toLocaleTimeString(), loc: "京塘路石槽村", level: "mid", type: "warning", description: "京塘路石槽村-降级黄闪" },
-        { id: "D002", title: "降级黄闪", time: new Date().toLocaleTimeString(), loc: "TZ-339_潞通大街与紫运西路交叉路口", level: "mid", type: "warning", description: "TZ-339_潞通大街与紫运西路交叉路口-降级黄闪" },
-        { id: "D003", title: "方案切换异常", time: new Date().toLocaleTimeString(), loc: "TZ-553_宋翟路与徐尹路", level: "mid", type: "warning", description: "TZ-553_宋翟路与徐尹路-方案切换异常" },
-        { id: "D004", title: "检测器异常", time: new Date().toLocaleTimeString(), loc: "京塘路与塘通线交叉口", level: "low", type: "warning", description: "京塘路与塘通线交叉口-检测器异常" }
-      ];
-      
       // 组合成12条数据
-      this.alarmData = [...faultAlarms, ...offlineAlarms, ...degradedAlarms];
+      this.alarmData = originalAlarms;
       
       this.tableData = taskData?.list || taskData || [];
       this.keyIntersectionData = keyData || [];