device-alarm.html 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853
  1. <!DOCTYPE html>
  2. <html lang="zh-CN" class="iframe-content">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>设备告警信息 - 爱智农</title>
  7. <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css">
  8. <link rel="stylesheet" href="https://at.alicdn.com/t/font_3114978_qe0b39no76.css">
  9. <link rel="stylesheet" href="../assets/css/global.css">
  10. <style>
  11. body {
  12. font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  13. background-color: #f5f7f9;
  14. color: #333;
  15. margin: 0;
  16. padding: 0;
  17. height: auto; overflow-y: auto; overflow-x: hidden;
  18. min-height: 100%;
  19. }
  20. .page-container {
  21. padding: 20px;
  22. position: relative;
  23. min-height: 100vh; width: 100%; max-width: 100%; box-sizing: border-box;
  24. }
  25. .card {
  26. background-color: white;
  27. border-radius: 8px;
  28. box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  29. }
  30. .table-container {
  31. position: relative;
  32. position: relative;
  33. overflow-x: auto;
  34. }
  35. table {
  36. width: 100%;
  37. border-collapse: separate;
  38. border-spacing: 0;
  39. }
  40. th {
  41. white-space: nowrap;
  42. position: relative;
  43. overflow: visible;
  44. max-width: none;
  45. text-overflow: clip;
  46. white-space: nowrap;
  47. position: relative;
  48. background-color: #f9fafb;
  49. padding: 12px 16px;
  50. text-align: left;
  51. font-weight: 500;
  52. color: #6b7280;
  53. border-bottom: 1px solid #e5e7eb;
  54. }
  55. td {
  56. white-space: nowrap;
  57. max-width: 200px;
  58. overflow: hidden;
  59. text-overflow: ellipsis;
  60. white-space: nowrap;
  61. max-width: 200px;
  62. overflow: hidden;
  63. text-overflow: ellipsis;
  64. padding: 12px 16px;
  65. border-bottom: 1px solid #e5e7eb;
  66. }
  67. tr:hover {
  68. tr:hover td:last-child {
  69. background-color: #f9fafb;
  70. }
  71. /* 固定最后一列(操作列)样式 */
  72. .table-fixed-right {
  73. position: relative;
  74. }
  75. .table-fixed-right th:last-child,
  76. .table-fixed-right td:last-child {
  77. position: sticky;
  78. right: 0;
  79. z-index: 2;
  80. background-color: white;
  81. box-shadow: -5px 0 5px -5px rgba(0, 0, 0, 0.1);
  82. }
  83. .table-fixed-right th:last-child {
  84. background-color: #f9fafb;
  85. }
  86. /* 表格滚动控件 */
  87. .table-scroll-controls {
  88. display: none;
  89. position: absolute;
  90. top: 50%;
  91. transform: translateY(-50%);
  92. width: 100%;
  93. pointer-events: none;
  94. z-index: 3;
  95. }
  96. .table-scroll-btn {
  97. position: absolute;
  98. width: 32px;
  99. height: 32px;
  100. border-radius: 50%;
  101. background-color: rgba(255, 255, 255, 0.9);
  102. color: #4CAF50;
  103. border: 1px solid #e0e0e0;
  104. display: flex;
  105. align-items: center;
  106. justify-content: center;
  107. cursor: pointer;
  108. pointer-events: auto;
  109. box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  110. z-index: 4;
  111. }
  112. .table-scroll-left {
  113. left: 10px;
  114. }
  115. .table-scroll-right {
  116. right: 10px;
  117. }
  118. .has-overflow .table-scroll-controls {
  119. display: block;
  120. } background-color: #f9fafb;
  121. }
  122. .btn {
  123. display: inline-flex;
  124. align-items: center;
  125. justify-content: center;
  126. padding: 8px 16px;
  127. border-radius: 4px;
  128. font-weight: 500;
  129. cursor: pointer;
  130. transition: all 0.2s;
  131. }
  132. .btn-primary {
  133. background-color: #4CAF50;
  134. color: white;
  135. }
  136. .btn-primary:hover {
  137. background-color: #388E3C;
  138. }
  139. .btn-default {
  140. background-color: white;
  141. border: 1px solid #d1d5db;
  142. color: #374151;
  143. }
  144. .btn-default:hover {
  145. background-color: #f9fafb;
  146. }
  147. .btn-danger {
  148. background-color: #ef4444;
  149. color: white;
  150. }
  151. .btn-danger:hover {
  152. background-color: #dc2626;
  153. }
  154. .btn-warning {
  155. background-color: #f59e0b;
  156. color: white;
  157. }
  158. .btn-warning:hover {
  159. background-color: #d97706;
  160. }
  161. .btn-sm {
  162. padding: 4px 8px;
  163. font-size: 12px;
  164. }
  165. .btn-icon {
  166. margin-right: 4px;
  167. }
  168. .search-box {
  169. display: flex;
  170. gap: 8px;
  171. }
  172. .input {
  173. padding: 8px 12px;
  174. border: 1px solid #d1d5db;
  175. border-radius: 4px;
  176. flex-grow: 1;
  177. }
  178. .input:focus {
  179. outline: none;
  180. border-color: #4CAF50;
  181. box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.2);
  182. }
  183. .select {
  184. padding: 8px 12px;
  185. border: 1px solid #d1d5db;
  186. border-radius: 4px;
  187. background-color: white;
  188. }
  189. .modal-overlay {
  190. position: fixed;
  191. top: 0;
  192. left: 0;
  193. right: 0;
  194. bottom: 0;
  195. background-color: rgba(0, 0, 0, 0.5);
  196. display: flex;
  197. align-items: center;
  198. justify-content: center;
  199. z-index: 50;
  200. display: none;
  201. }
  202. .modal {
  203. background-color: white;
  204. border-radius: 8px;
  205. width: 100%;
  206. max-width: 600px;
  207. box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  208. }
  209. .modal-header {
  210. padding: 16px 24px;
  211. border-bottom: 1px solid #e5e7eb;
  212. display: flex;
  213. align-items: center;
  214. justify-content: space-between;
  215. }
  216. .modal-title {
  217. font-size: 18px;
  218. font-weight: 500;
  219. }
  220. .modal-close {
  221. cursor: pointer;
  222. font-size: 20px;
  223. }
  224. .modal-body {
  225. padding: 24px;
  226. }
  227. .modal-footer {
  228. padding: 16px 24px;
  229. border-top: 1px solid #e5e7eb;
  230. display: flex;
  231. justify-content: flex-end;
  232. gap: 8px;
  233. }
  234. .badge {
  235. display: inline-block;
  236. padding: 2px 8px;
  237. border-radius: 9999px;
  238. font-size: 12px;
  239. font-weight: 500;
  240. }
  241. .badge-success {
  242. background-color: #d1fae5;
  243. color: #065f46;
  244. }
  245. .badge-warning {
  246. background-color: #fef3c7;
  247. color: #92400e;
  248. }
  249. .badge-danger {
  250. background-color: #fee2e2;
  251. color: #b91c1c;
  252. }
  253. .pagination {
  254. display: flex;
  255. align-items: center;
  256. justify-content: flex-end;
  257. gap: 4px;
  258. }
  259. .pagination-item {
  260. display: inline-flex;
  261. align-items: center;
  262. justify-content: center;
  263. width: 32px;
  264. height: 32px;
  265. border-radius: 4px;
  266. cursor: pointer;
  267. transition: all 0.2s;
  268. }
  269. .pagination-item:hover {
  270. background-color: #f3f4f6;
  271. }
  272. .pagination-item.active {
  273. background-color: #4CAF50;
  274. color: white;
  275. }
  276. .pagination-item.disabled {
  277. color: #9ca3af;
  278. cursor: not-allowed;
  279. }
  280. .timeline {
  281. position: relative;
  282. padding-left: 32px;
  283. }
  284. .timeline-item {
  285. position: relative;
  286. padding-bottom: 16px;
  287. }
  288. .timeline-item:last-child {
  289. padding-bottom: 0;
  290. }
  291. .timeline-item::before {
  292. content: "";
  293. position: absolute;
  294. left: -24px;
  295. top: 6px;
  296. width: 12px;
  297. height: 12px;
  298. border-radius: 50%;
  299. background-color: #4CAF50;
  300. z-index: 1;
  301. }
  302. .timeline-item::after {
  303. content: "";
  304. position: absolute;
  305. left: -19px;
  306. top: 18px;
  307. width: 2px;
  308. height: calc(100% - 18px);
  309. background-color: #e5e7eb;
  310. }
  311. .timeline-item:last-child::after {
  312. display: none;
  313. }
  314. .timeline-time {
  315. font-size: 12px;
  316. color: #6b7280;
  317. margin-bottom: 2px;
  318. }
  319. .alarm-type-urgent {
  320. border-left: 4px solid #ef4444;
  321. }
  322. .alarm-type-warning {
  323. border-left: 4px solid #f59e0b;
  324. }
  325. .alarm-type-notice {
  326. border-left: 4px solid #3b82f6;
  327. }
  328. </style>
  329. </head>
  330. <body>
  331. <div class="page-container responsive-container">
  332. <div class="flex justify-between items-center mb-6">
  333. <h1 class="text-2xl font-bold">设备告警信息</h1>
  334. <div class="flex gap-2">
  335. <button class="btn btn-default">
  336. <i class="iconfont icon-reload btn-icon"></i>
  337. 刷新数据
  338. </button>
  339. <button class="btn btn-primary">
  340. <i class="iconfont icon-setting btn-icon"></i>
  341. 告警设置
  342. </button>
  343. </div>
  344. </div>
  345. <div class="card p-6 mb-6">
  346. <div class="flex flex-wrap gap-4">
  347. <div class="search-box flex-grow">
  348. <input type="text" class="input" placeholder="请输入设备名称/编号/告警内容">
  349. <button class="btn btn-primary">
  350. <i class="iconfont icon-search btn-icon"></i>
  351. 搜索
  352. </button>
  353. <button class="btn btn-default">
  354. <i class="iconfont icon-reload btn-icon"></i>
  355. 重置
  356. </button>
  357. </div>
  358. <div class="flex gap-2">
  359. <select class="select">
  360. <option value="">所有告警等级</option>
  361. <option value="urgent">紧急</option>
  362. <option value="warning">警告</option>
  363. <option value="notice">提示</option>
  364. </select>
  365. <select class="select">
  366. <option value="">所有处理状态</option>
  367. <option value="1">已处理</option>
  368. <option value="0">未处理</option>
  369. <option value="2">处理中</option>
  370. </select>
  371. </div>
  372. </div>
  373. </div>
  374. <div class="grid grid-cols-1 md:grid-cols-4 gap-6 mb-6">
  375. <div class="card p-4 text-center">
  376. <div class="text-gray-500 mb-1">今日告警总数</div>
  377. <div class="text-3xl font-bold text-gray-800">24</div>
  378. <div class="text-sm text-gray-400 mt-1">较昨日 +8</div>
  379. </div>
  380. <div class="card p-4 text-center">
  381. <div class="text-gray-500 mb-1">紧急告警</div>
  382. <div class="text-3xl font-bold text-red-600">5</div>
  383. <div class="text-sm text-gray-400 mt-1">未处理:2</div>
  384. </div>
  385. <div class="card p-4 text-center">
  386. <div class="text-gray-500 mb-1">警告</div>
  387. <div class="text-3xl font-bold text-yellow-600">12</div>
  388. <div class="text-sm text-gray-400 mt-1">未处理:4</div>
  389. </div>
  390. <div class="card p-4 text-center">
  391. <div class="text-gray-500 mb-1">提示信息</div>
  392. <div class="text-3xl font-bold text-blue-600">7</div>
  393. <div class="text-sm text-gray-400 mt-1">未处理:1</div>
  394. </div>
  395. </div>
  396. <div class="card">
  397. <div class="table-container">
  398. <table>
  399. <thead>
  400. <tr>
  401. <th>告警ID</th>
  402. <th>告警等级</th>
  403. <th class="min-w-[120px]">设备名称</th>
  404. <th class="min-w-[100px]">设备类型</th>
  405. <th>告警内容</th>
  406. <th>告警时间</th>
  407. <th>处理状态</th>
  408. <th>处理人</th>
  409. <th class="min-w-[150px]">操作</th>
  410. </tr>
  411. </thead>
  412. <tbody>
  413. <tr>
  414. <td>ALM-20230001</td>
  415. <td><span class="badge badge-danger">紧急</span></td>
  416. <td>土壤传感器 #2</td>
  417. <td>传感器</td>
  418. <td>电池电量过低,即将无法工作</td>
  419. <td>2023-05-15 10:25:36</td>
  420. <td><span class="badge badge-danger">未处理</span></td>
  421. <td>-</td>
  422. <td>
  423. <div class="flex gap-2">
  424. <button class="btn btn-default btn-sm view-btn" data-id="1">
  425. <i class="iconfont icon-eye btn-icon"></i>
  426. 查看
  427. </button>
  428. <button class="btn btn-primary btn-sm handle-btn" data-id="1">
  429. <i class="iconfont icon-check btn-icon"></i>
  430. 处理
  431. </button>
  432. </div>
  433. </td>
  434. </tr>
  435. <tr>
  436. <td>ALM-20230002</td>
  437. <td><span class="badge badge-warning">警告</span></td>
  438. <td>摄像头 #3</td>
  439. <td>摄像设备</td>
  440. <td>信号弱,视频画面不稳定</td>
  441. <td>2023-05-15 09:18:42</td>
  442. <td><span class="badge badge-warning">处理中</span></td>
  443. <td>张三</td>
  444. <td>
  445. <div class="flex gap-2">
  446. <button class="btn btn-default btn-sm view-btn" data-id="2">
  447. <i class="iconfont icon-eye btn-icon"></i>
  448. 查看
  449. </button>
  450. <button class="btn btn-primary btn-sm handle-btn" data-id="2">
  451. <i class="iconfont icon-check btn-icon"></i>
  452. 处理
  453. </button>
  454. </div>
  455. </td>
  456. </tr>
  457. <tr>
  458. <td>ALM-20230003</td>
  459. <td><span class="badge badge-danger">紧急</span></td>
  460. <td>水位传感器 #1</td>
  461. <td>传感器</td>
  462. <td>水位超过预警线,可能发生溢出</td>
  463. <td>2023-05-15 08:45:20</td>
  464. <td><span class="badge badge-success">已处理</span></td>
  465. <td>李四</td>
  466. <td>
  467. <div class="flex gap-2">
  468. <button class="btn btn-default btn-sm view-btn" data-id="3">
  469. <i class="iconfont icon-eye btn-icon"></i>
  470. 查看
  471. </button>
  472. </div>
  473. </td>
  474. </tr>
  475. <tr>
  476. <td>ALM-20230004</td>
  477. <td><span class="badge badge-warning">警告</span></td>
  478. <td>气象站 #1</td>
  479. <td>气象设备</td>
  480. <td>湿度传感器异常,读数不稳定</td>
  481. <td>2023-05-14 17:32:15</td>
  482. <td><span class="badge badge-danger">未处理</span></td>
  483. <td>-</td>
  484. <td>
  485. <div class="flex gap-2">
  486. <button class="btn btn-default btn-sm view-btn" data-id="4">
  487. <i class="iconfont icon-eye btn-icon"></i>
  488. 查看
  489. </button>
  490. <button class="btn btn-primary btn-sm handle-btn" data-id="4">
  491. <i class="iconfont icon-check btn-icon"></i>
  492. 处理
  493. </button>
  494. </div>
  495. </td>
  496. </tr>
  497. <tr>
  498. <td>ALM-20230005</td>
  499. <td><span class="badge badge-primary" style="background-color: #dbeafe; color: #1e40af;">提示</span></td>
  500. <td>自动灌溉控制器 #1</td>
  501. <td>控制器</td>
  502. <td>设备需要例行维护检查</td>
  503. <td>2023-05-14 14:10:08</td>
  504. <td><span class="badge badge-success">已处理</span></td>
  505. <td>王五</td>
  506. <td>
  507. <div class="flex gap-2">
  508. <button class="btn btn-default btn-sm view-btn" data-id="5">
  509. <i class="iconfont icon-eye btn-icon"></i>
  510. 查看
  511. </button>
  512. </div>
  513. </td>
  514. </tr>
  515. </tbody>
  516. </table>
  517. </div>
  518. <div class="p-4 flex justify-between items-center">
  519. <div class="text-sm text-gray-500">
  520. 共 <span class="font-medium">24</span> 条记录,每页 <span class="font-medium">10</span> 条
  521. </div>
  522. <div class="pagination">
  523. <div class="pagination-item disabled">
  524. <i class="iconfont icon-left"></i>
  525. </div>
  526. <div class="pagination-item active">1</div>
  527. <div class="pagination-item">2</div>
  528. <div class="pagination-item">3</div>
  529. <div class="pagination-item">
  530. <i class="iconfont icon-right"></i>
  531. </div>
  532. </div>
  533. </div>
  534. </div>
  535. </div>
  536. <!-- 告警详情弹窗 -->
  537. <div class="modal-overlay" id="alarmDetailModal">
  538. <div class="modal">
  539. <div class="modal-header">
  540. <h3 class="modal-title">告警详情</h3>
  541. <div class="modal-close" id="closeDetailModal">&times;</div>
  542. </div>
  543. <div class="modal-body">
  544. <div class="p-4 mb-4 bg-red-50 alarm-type-urgent">
  545. <div class="flex justify-between items-center mb-2">
  546. <span class="badge badge-danger">紧急</span>
  547. <span class="text-sm text-gray-500">2023-05-15 10:25:36</span>
  548. </div>
  549. <h3 class="text-lg font-bold mb-2">电池电量过低,即将无法工作</h3>
  550. <p class="text-gray-600 mb-2">土壤传感器 #2 (SNS-20230002) 电池电量低于10%,请尽快更换电池,否则设备将在24小时内无法正常工作。</p>
  551. <div class="flex justify-between text-sm text-gray-500">
  552. <span>告警ID: ALM-20230001</span>
  553. <span>设备位置: 东区2号地块</span>
  554. </div>
  555. </div>
  556. <div class="mb-4">
  557. <h4 class="font-medium mb-2">设备信息</h4>
  558. <div class="grid grid-cols-2 gap-4">
  559. <div>
  560. <div class="text-xs text-gray-500 mb-1">设备ID</div>
  561. <div class="font-medium">SNS-20230002</div>
  562. </div>
  563. <div>
  564. <div class="text-xs text-gray-500 mb-1">设备类型</div>
  565. <div class="font-medium">土壤传感器</div>
  566. </div>
  567. <div>
  568. <div class="text-xs text-gray-500 mb-1">安装位置</div>
  569. <div class="font-medium">东区2号地块</div>
  570. </div>
  571. <div>
  572. <div class="text-xs text-gray-500 mb-1">安装时间</div>
  573. <div class="font-medium">2023-01-20</div>
  574. </div>
  575. </div>
  576. </div>
  577. <div class="mb-4">
  578. <h4 class="font-medium mb-2">告警状态</h4>
  579. <div class="mb-1 flex justify-between">
  580. <span>当前状态</span>
  581. <span class="font-medium text-red-600">未处理</span>
  582. </div>
  583. <div class="mb-1 flex justify-between">
  584. <span>处理人</span>
  585. <span class="font-medium">-</span>
  586. </div>
  587. <div class="mb-1 flex justify-between">
  588. <span>处理时间</span>
  589. <span class="font-medium">-</span>
  590. </div>
  591. </div>
  592. <div>
  593. <h4 class="font-medium mb-2">处理记录</h4>
  594. <div class="text-center text-gray-500 py-4">
  595. 暂无处理记录
  596. </div>
  597. </div>
  598. </div>
  599. <div class="modal-footer">
  600. <button class="btn btn-default" id="cancelDetailBtn">关闭</button>
  601. </div>
  602. </div>
  603. </div>
  604. <!-- 处理告警弹窗 -->
  605. <div class="modal-overlay" id="alarmHandleModal">
  606. <div class="modal">
  607. <div class="modal-header">
  608. <h3 class="modal-title">处理告警</h3>
  609. <div class="modal-close" id="closeHandleModal">&times;</div>
  610. </div>
  611. <div class="modal-body">
  612. <div class="p-4 mb-4 bg-red-50 alarm-type-urgent">
  613. <h3 class="text-lg font-bold mb-2">电池电量过低,即将无法工作</h3>
  614. <p class="text-gray-600">土壤传感器 #2 (SNS-20230002)</p>
  615. </div>
  616. <div class="form-group mb-4">
  617. <label class="block font-medium mb-1">处理状态</label>
  618. <select class="w-full border border-gray-300 rounded p-2 focus:outline-none focus:ring-2 focus:ring-green-500 focus:border-transparent">
  619. <option value="1">已处理</option>
  620. <option value="2">处理中</option>
  621. <option value="3">忽略</option>
  622. </select>
  623. </div>
  624. <div class="form-group mb-4">
  625. <label class="block font-medium mb-1">处理方式</label>
  626. <select class="w-full border border-gray-300 rounded p-2 focus:outline-none focus:ring-2 focus:ring-green-500 focus:border-transparent">
  627. <option value="replace">更换设备</option>
  628. <option value="repair">维修设备</option>
  629. <option value="battery">更换电池</option>
  630. <option value="restart">重启设备</option>
  631. <option value="other">其他</option>
  632. </select>
  633. </div>
  634. <div class="form-group mb-4">
  635. <label class="block font-medium mb-1">处理说明</label>
  636. <textarea class="w-full border border-gray-300 rounded p-2 focus:outline-none focus:ring-2 focus:ring-green-500 focus:border-transparent" rows="3" placeholder="请输入处理说明..."></textarea>
  637. </div>
  638. <div class="form-group">
  639. <label class="flex items-center">
  640. <input type="checkbox" class="mr-2">
  641. <span>通知相关人员</span>
  642. </label>
  643. </div>
  644. </div>
  645. <div class="modal-footer">
  646. <button class="btn btn-default" id="cancelHandleBtn">取消</button>
  647. <button class="btn btn-primary" id="submitHandleBtn">提交</button>
  648. </div>
  649. </div>
  650. </div>
  651. <script>
  652. document.addEventListener("DOMContentLoaded", function() {
  653. // 初始化表格滚动功能
  654. function initTableScroll() {
  655. const tableContainer = document.querySelector(".table-container");
  656. if (!tableContainer) return;
  657. const scrollLeftBtn = document.querySelector(".table-scroll-left");
  658. const scrollRightBtn = document.querySelector(".table-scroll-right");
  659. if (!scrollLeftBtn || !scrollRightBtn) return;
  660. // 检查表格是否需要水平滚动
  661. function checkTableOverflow() {
  662. if (tableContainer.scrollWidth > tableContainer.clientWidth) {
  663. tableContainer.classList.add("has-overflow");
  664. } else {
  665. tableContainer.classList.remove("has-overflow");
  666. }
  667. }
  668. // 左右滚动按钮点击事件
  669. scrollLeftBtn.addEventListener("click", function() {
  670. tableContainer.scrollLeft -= 150;
  671. });
  672. scrollRightBtn.addEventListener("click", function() {
  673. tableContainer.scrollLeft += 150;
  674. });
  675. // 初始检查和窗口大小变化时检查
  676. checkTableOverflow();
  677. window.addEventListener("resize", checkTableOverflow);
  678. // 滚动事件处理
  679. tableContainer.addEventListener("scroll", function() {
  680. // 根据滚动位置显示/隐藏滚动按钮
  681. if (tableContainer.scrollLeft <= 10) {
  682. scrollLeftBtn.style.opacity = "0.5";
  683. } else {
  684. scrollLeftBtn.style.opacity = "1";
  685. }
  686. if (tableContainer.scrollLeft >= tableContainer.scrollWidth - tableContainer.clientWidth - 10) {
  687. scrollRightBtn.style.opacity = "0.5";
  688. } else {
  689. scrollRightBtn.style.opacity = "1";
  690. }
  691. });
  692. // 初始触发滚动事件,设置初始按钮状态
  693. tableContainer.dispatchEvent(new Event("scroll"));
  694. }
  695. // 初始化表格滚动
  696. initTableScroll(); document.addEventListener('DOMContentLoaded', function() {
  697. // 告警详情弹窗
  698. const alarmDetailModal = document.getElementById('alarmDetailModal');
  699. const closeDetailModal = document.getElementById('closeDetailModal');
  700. const cancelDetailBtn = document.getElementById('cancelDetailBtn');
  701. const viewBtns = document.querySelectorAll('.view-btn');
  702. // 查看告警详情
  703. viewBtns.forEach(btn => {
  704. btn.addEventListener('click', function() {
  705. const alarmId = this.getAttribute('data-id');
  706. alarmDetailModal.style.display = 'flex';
  707. // 实际应用中应该根据ID获取告警详情
  708. });
  709. });
  710. // 关闭详情弹窗
  711. function closeDetailModal() {
  712. alarmDetailModal.style.display = 'none';
  713. }
  714. closeDetailModal.addEventListener('click', closeDetailModal);
  715. cancelDetailBtn.addEventListener('click', closeDetailModal);
  716. // 告警处理弹窗
  717. const alarmHandleModal = document.getElementById('alarmHandleModal');
  718. const closeHandleModal = document.getElementById('closeHandleModal');
  719. const cancelHandleBtn = document.getElementById('cancelHandleBtn');
  720. const submitHandleBtn = document.getElementById('submitHandleBtn');
  721. const handleBtns = document.querySelectorAll('.handle-btn');
  722. // 处理告警
  723. handleBtns.forEach(btn => {
  724. btn.addEventListener('click', function() {
  725. const alarmId = this.getAttribute('data-id');
  726. alarmHandleModal.style.display = 'flex';
  727. // 实际应用中应该根据ID获取告警详情
  728. });
  729. });
  730. // 关闭处理弹窗
  731. function closeHandleModal() {
  732. alarmHandleModal.style.display = 'none';
  733. }
  734. closeHandleModal.addEventListener('click', closeHandleModal);
  735. cancelHandleBtn.addEventListener('click', closeHandleModal);
  736. // 提交处理
  737. submitHandleBtn.addEventListener('click', function() {
  738. alert('告警处理已提交');
  739. closeHandleModal();
  740. // 实际应用中应该提交处理信息到后端
  741. });
  742. // 点击弹窗外部关闭弹窗
  743. window.addEventListener('click', function(e) {
  744. if (e.target === alarmDetailModal) {
  745. closeDetailModal();
  746. }
  747. if (e.target === alarmHandleModal) {
  748. closeHandleModal();
  749. }
  750. });
  751. });
  752. </script>
  753. </body>
  754. </html>