device-alarm.html.backup 45 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115
  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;
  18. overflow-y: auto;
  19. overflow-x: hidden;
  20. min-height: 100%;
  21. }
  22. .page-container {
  23. padding: 20px;
  24. padding-top: 60px; /* 添加顶部边距,为按钮留出空间 */
  25. position: relative;
  26. min-height: 100vh;
  27. width: 100%;
  28. max-width: 100%;
  29. box-sizing: border-box;
  30. }
  31. .card {
  32. background-color: white;
  33. border-radius: 8px;
  34. box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  35. }
  36. .table-container {
  37. position: relative;
  38. overflow-x: auto;
  39. }
  40. table {
  41. width: 100%;
  42. border-collapse: separate;
  43. border-spacing: 0;
  44. }
  45. th {
  46. white-space: nowrap;
  47. position: relative;
  48. overflow: visible;
  49. max-width: none;
  50. text-overflow: clip;
  51. background-color: #f9fafb;
  52. padding: 12px 16px;
  53. text-align: left;
  54. font-weight: 500;
  55. color: #6b7280;
  56. border-bottom: 1px solid #e5e7eb;
  57. }
  58. td {
  59. white-space: nowrap;
  60. max-width: 200px;
  61. overflow: hidden;
  62. text-overflow: ellipsis;
  63. padding: 12px 16px;
  64. border-bottom: 1px solid #e5e7eb;
  65. }
  66. tr:hover {
  67. background-color: #f9fafb;
  68. }
  69. tr:hover td:last-child {
  70. background-color: #f9fafb;
  71. }
  72. /* 固定最后一列(操作列)样式 */
  73. .table-fixed-right {
  74. position: relative;
  75. }
  76. .table-fixed-right th:last-child,
  77. .table-fixed-right td:last-child {
  78. position: sticky;
  79. right: 0;
  80. z-index: 2;
  81. background-color: white;
  82. box-shadow: -5px 0 5px -5px rgba(0, 0, 0, 0.1);
  83. }
  84. .table-fixed-right th:last-child {
  85. background-color: #f9fafb;
  86. }
  87. /* 表格滚动控件 */
  88. .table-scroll-controls {
  89. display: none;
  90. position: absolute;
  91. top: 50%;
  92. transform: translateY(-50%);
  93. width: 100%;
  94. pointer-events: none;
  95. z-index: 3;
  96. }
  97. .table-scroll-btn {
  98. position: absolute;
  99. width: 32px;
  100. height: 32px;
  101. border-radius: 50%;
  102. background-color: rgba(255, 255, 255, 0.9);
  103. color: #4CAF50;
  104. border: 1px solid #e0e0e0;
  105. display: flex;
  106. align-items: center;
  107. justify-content: center;
  108. cursor: pointer;
  109. pointer-events: auto;
  110. box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  111. z-index: 4;
  112. }
  113. .table-scroll-left {
  114. left: 10px;
  115. }
  116. .table-scroll-right {
  117. right: 10px;
  118. }
  119. .has-overflow .table-scroll-controls {
  120. display: block;
  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. /* 修复按钮被遮挡的问题 */
  329. .action-buttons {
  330. position: relative;
  331. z-index: 1000 !important;
  332. }
  333. </style>
  334. </head>
  335. <body>
  336. <div class="page-container responsive-container">
  337. <div class="flex justify-between items-center mb-6">
  338. <h1 class="text-2xl font-bold">设备告警信息</h1>
  339. <div class="flex gap-2 action-buttons">
  340. <button class="btn btn-default">
  341. <i class="iconfont icon-reload btn-icon"></i>
  342. 刷新数据
  343. </button>
  344. <button class="btn btn-primary" style="position: relative; z-index: 1000;">
  345. <i class="iconfont icon-setting btn-icon"></i>
  346. 告警设置
  347. </button>
  348. </div>
  349. </div>
  350. <div class="card p-6 mb-6">
  351. <div class="grid grid-cols-1 md:grid-cols-4 gap-4 mb-4">
  352. <!-- 设备编号 -->
  353. <div class="form-group md:col-span-2 flex items-center gap-2">
  354. <label class="text-sm text-gray-600 whitespace-nowrap">设备编号</label>
  355. <input type="text" class="input w-full" placeholder="请输入设备编号关键词">
  356. </div>
  357. <!-- 设备名称 -->
  358. <div class="form-group md:col-span-2 flex items-center gap-2">
  359. <label class="text-sm text-gray-600 whitespace-nowrap">设备名称</label>
  360. <input type="text" class="input w-full" placeholder="请输入设备名称关键词">
  361. </div>
  362. <!-- 告警等级 -->
  363. <div class="form-group md:col-span-2 flex items-center gap-2">
  364. <label class="text-sm text-gray-600 whitespace-nowrap">告警等级</label>
  365. <select class="select w-full">
  366. <option value="">所有告警等级</option>
  367. <option value="urgent">紧急</option>
  368. <option value="warning">警告</option>
  369. <option value="notice">提示</option>
  370. </select>
  371. </div>
  372. <!-- 设备类型 -->
  373. <div class="form-group md:col-span-2 flex items-center gap-2">
  374. <label class="text-sm text-gray-600 whitespace-nowrap">设备类型</label>
  375. <select class="select w-full">
  376. <option value="">所有设备类型</option>
  377. <option value="sensor">传感器</option>
  378. <option value="camera">摄像设备</option>
  379. <option value="controller">控制器</option>
  380. <option value="weather">气象设备</option>
  381. </select>
  382. </div>
  383. <!-- 所属地块 -->
  384. <div class="form-group md:col-span-2 flex items-center gap-2">
  385. <label class="text-sm text-gray-600 whitespace-nowrap">所属地块</label>
  386. <select class="select w-full">
  387. <option value="">所有地块</option>
  388. <option value="east1">东区1号地块</option>
  389. <option value="east2">东区2号地块</option>
  390. <option value="west1">西区1号地块</option>
  391. <option value="south3">南区3号地块</option>
  392. <option value="north1">北区1号地块</option>
  393. </select>
  394. </div>
  395. <!-- 所属农场 -->
  396. <div class="form-group md:col-span-2 flex items-center gap-2">
  397. <label class="text-sm text-gray-600 whitespace-nowrap">所属农场</label>
  398. <select class="select w-full">
  399. <option value="">所有农场</option>
  400. <option value="demo">示范农场</option>
  401. <option value="smart">智慧农场</option>
  402. </select>
  403. </div>
  404. <!-- 告警时间 -->
  405. <div class="form-group md:col-span-2">
  406. <label class="block text-sm text-gray-600 mb-1">告警时间</label>
  407. <div class="flex gap-2 items-center">
  408. <input type="date" class="input w-full" placeholder="开始日期">
  409. <span class="text-gray-400">至</span>
  410. <input type="date" class="input w-full" placeholder="结束日期">
  411. </div>
  412. </div>
  413. <!-- 处理状态 -->
  414. <div class="form-group md:col-span-2 flex items-center gap-2">
  415. <label class="text-sm text-gray-600 whitespace-nowrap">处理状态</label>
  416. <select class="select w-full">
  417. <option value="">所有状态</option>
  418. <option value="1">已处理</option>
  419. <option value="0">未处理</option>
  420. <option value="2">处理中</option>
  421. </select>
  422. </div>
  423. </div>
  424. <div class="flex justify-end gap-4">
  425. <button class="btn btn-primary">
  426. <i class="iconfont icon-search btn-icon"></i>
  427. 搜索
  428. </button>
  429. <button class="btn btn-default">
  430. <i class="iconfont icon-reload btn-icon"></i>
  431. 重置
  432. </button>
  433. </div>
  434. </div>
  435. <div class="grid grid-cols-1 md:grid-cols-4 gap-6 mb-6">
  436. <div class="card p-4 text-center">
  437. <div class="text-gray-500 mb-1">今日告警总数</div>
  438. <div class="text-3xl font-bold text-gray-800">24</div>
  439. <div class="text-sm text-gray-400 mt-1">较昨日 +8</div>
  440. </div>
  441. <div class="card p-4 text-center">
  442. <div class="text-gray-500 mb-1">紧急告警</div>
  443. <div class="text-3xl font-bold text-red-600">5</div>
  444. <div class="text-sm text-gray-400 mt-1">未处理:2</div>
  445. </div>
  446. <div class="card p-4 text-center">
  447. <div class="text-gray-500 mb-1">警告</div>
  448. <div class="text-3xl font-bold text-yellow-600">12</div>
  449. <div class="text-sm text-gray-400 mt-1">未处理:4</div>
  450. </div>
  451. <div class="card p-4 text-center">
  452. <div class="text-gray-500 mb-1">提示信息</div>
  453. <div class="text-3xl font-bold text-blue-600">7</div>
  454. <div class="text-sm text-gray-400 mt-1">未处理:1</div>
  455. </div>
  456. </div>
  457. <div class="card">
  458. <div class="table-container">
  459. <div class="table-scroll-controls">
  460. <button class="table-scroll-btn table-scroll-left">
  461. <i class="iconfont icon-left"></i>
  462. </button>
  463. <button class="table-scroll-btn table-scroll-right">
  464. <i class="iconfont icon-right"></i>
  465. </button>
  466. </div>
  467. <table class="table-fixed-right">
  468. <thead>
  469. <tr>
  470. <th>告警ID</th>
  471. <th>告警等级</th>
  472. <th>设备名称</th>
  473. <th>设备编号</th>
  474. <th>设备类型</th>
  475. <th>所属地块</th>
  476. <th>所属农场</th>
  477. <th>告警内容</th>
  478. <th>告警时间</th>
  479. <th>处理状态</th>
  480. <th>处理人</th>
  481. <th>处理时间</th>
  482. <th class="min-w-[150px]">操作</th>
  483. </tr>
  484. </thead>
  485. <tbody>
  486. <tr>
  487. <td>ALM-20230001</td>
  488. <td><span class="badge badge-danger">紧急</span></td>
  489. <td>土壤传感器 #2</td>
  490. <td>SNS-20230002</td>
  491. <td>传感器</td>
  492. <td>东区2号地块</td>
  493. <td>示范农场</td>
  494. <td>电池电量过低,即将无法工作</td>
  495. <td>2023-05-15 10:25:36</td>
  496. <td><span class="badge badge-danger">未处理</span></td>
  497. <td>-</td>
  498. <td>-</td>
  499. <td>
  500. <div class="flex gap-2">
  501. <button class="btn btn-default btn-sm view-btn" data-id="1">
  502. <i class="iconfont icon-eye btn-icon"></i>
  503. 查看
  504. </button>
  505. <button class="btn btn-primary btn-sm handle-btn" data-id="1" onclick="processAlarm(this)">
  506. <i class="iconfont icon-check btn-icon"></i>
  507. 处理
  508. </button>
  509. </div>
  510. </td>
  511. </tr>
  512. <tr>
  513. <td>ALM-20230002</td>
  514. <td><span class="badge badge-warning">警告</span></td>
  515. <td>摄像头 #3</td>
  516. <td>CAM-20230003</td>
  517. <td>摄像设备</td>
  518. <td>西区1号地块</td>
  519. <td>示范农场</td>
  520. <td>信号弱,视频画面不稳定</td>
  521. <td>2023-05-15 09:18:42</td>
  522. <td><span class="badge badge-warning">处理中</span></td>
  523. <td>张三</td>
  524. <td>2023-05-15 10:20:15</td>
  525. <td>
  526. <div class="flex gap-2">
  527. <button class="btn btn-default btn-sm view-btn" data-id="2">
  528. <i class="iconfont icon-eye btn-icon"></i>
  529. 查看
  530. </button>
  531. <button class="btn btn-primary btn-sm handle-btn" data-id="2" onclick="processAlarm(this)">
  532. <i class="iconfont icon-check btn-icon"></i>
  533. 处理
  534. </button>
  535. </div>
  536. </td>
  537. </tr>
  538. <tr>
  539. <td>ALM-20230003</td>
  540. <td><span class="badge badge-danger">紧急</span></td>
  541. <td>水位传感器 #1</td>
  542. <td>WLV-20230001</td>
  543. <td>传感器</td>
  544. <td>南区3号地块</td>
  545. <td>智慧农场</td>
  546. <td>水位超过预警线,可能发生溢出</td>
  547. <td>2023-05-15 08:45:20</td>
  548. <td><span class="badge badge-success">已处理</span></td>
  549. <td>李四</td>
  550. <td>2023-05-15 09:30:42</td>
  551. <td>
  552. <div class="flex gap-2">
  553. <button class="btn btn-default btn-sm view-btn" data-id="3">
  554. <i class="iconfont icon-eye btn-icon"></i>
  555. 查看
  556. </button>
  557. </div>
  558. </td>
  559. </tr>
  560. <tr>
  561. <td>ALM-20230004</td>
  562. <td><span class="badge badge-warning">警告</span></td>
  563. <td>气象站 #1</td>
  564. <td>WEA-20230001</td>
  565. <td>气象设备</td>
  566. <td>北区1号地块</td>
  567. <td>智慧农场</td>
  568. <td>湿度传感器异常,读数不稳定</td>
  569. <td>2023-05-14 17:32:15</td>
  570. <td><span class="badge badge-danger">未处理</span></td>
  571. <td>-</td>
  572. <td>-</td>
  573. <td>
  574. <div class="flex gap-2">
  575. <button class="btn btn-default btn-sm view-btn" data-id="4">
  576. <i class="iconfont icon-eye btn-icon"></i>
  577. 查看
  578. </button>
  579. <button class="btn btn-primary btn-sm handle-btn" data-id="4" onclick="processAlarm(this)">
  580. <i class="iconfont icon-check btn-icon"></i>
  581. 处理
  582. </button>
  583. </div>
  584. </td>
  585. </tr>
  586. <tr>
  587. <td>ALM-20230005</td>
  588. <td><span class="badge badge-primary" style="background-color: #dbeafe; color: #1e40af;">提示</span></td>
  589. <td>自动灌溉控制器 #1</td>
  590. <td>IRR-20230001</td>
  591. <td>控制器</td>
  592. <td>东区1号地块</td>
  593. <td>示范农场</td>
  594. <td>设备需要例行维护检查</td>
  595. <td>2023-05-14 14:10:08</td>
  596. <td><span class="badge badge-success">已处理</span></td>
  597. <td>王五</td>
  598. <td>2023-05-14 16:45:20</td>
  599. <td>
  600. <div class="flex gap-2">
  601. <button class="btn btn-default btn-sm view-btn" data-id="5">
  602. <i class="iconfont icon-eye btn-icon"></i>
  603. 查看
  604. </button>
  605. </div>
  606. </td>
  607. </tr>
  608. </tbody>
  609. </table>
  610. </div>
  611. <div class="p-4 flex justify-between items-center">
  612. <div class="text-sm text-gray-500">
  613. 共 <span class="font-medium">24</span> 条记录,每页 <span class="font-medium">10</span> 条
  614. </div>
  615. <div class="pagination">
  616. <div class="pagination-item disabled">
  617. <i class="iconfont icon-left"></i>
  618. </div>
  619. <div class="pagination-item active">1</div>
  620. <div class="pagination-item">2</div>
  621. <div class="pagination-item">3</div>
  622. <div class="pagination-item">
  623. <i class="iconfont icon-right"></i>
  624. </div>
  625. </div>
  626. </div>
  627. </div>
  628. </div>
  629. <!-- 告警详情弹窗 -->
  630. <div class="modal-overlay" id="alarmDetailModal">
  631. <div class="modal">
  632. <div class="modal-header">
  633. <h3 class="modal-title">告警详情</h3>
  634. <div class="modal-close" id="closeDetailModal">&times;</div>
  635. </div>
  636. <div class="modal-body">
  637. <div class="p-4 mb-4 bg-red-50 alarm-type-urgent">
  638. <div class="flex justify-between items-center mb-2">
  639. <span class="badge badge-danger">紧急</span>
  640. <span class="text-sm text-gray-500">2023-05-15 10:25:36</span>
  641. </div>
  642. <h3 class="text-lg font-bold mb-2">电池电量过低,即将无法工作</h3>
  643. <p class="text-gray-600 mb-2">土壤传感器 #2 (SNS-20230002) 电池电量低于10%,请尽快更换电池,否则设备将在24小时内无法正常工作。</p>
  644. <div class="flex justify-between text-sm text-gray-500">
  645. <span>告警ID: ALM-20230001</span>
  646. <span>设备位置: 东区2号地块</span>
  647. </div>
  648. </div>
  649. <div class="mb-4">
  650. <h4 class="font-medium mb-2">设备信息</h4>
  651. <div class="grid grid-cols-2 gap-4">
  652. <div>
  653. <div class="text-xs text-gray-500 mb-1">设备ID</div>
  654. <div class="font-medium">SNS-20230002</div>
  655. </div>
  656. <div>
  657. <div class="text-xs text-gray-500 mb-1">设备类型</div>
  658. <div class="font-medium">土壤传感器</div>
  659. </div>
  660. <div>
  661. <div class="text-xs text-gray-500 mb-1">安装位置</div>
  662. <div class="font-medium">东区2号地块</div>
  663. </div>
  664. <div>
  665. <div class="text-xs text-gray-500 mb-1">安装时间</div>
  666. <div class="font-medium">2023-01-20</div>
  667. </div>
  668. </div>
  669. </div>
  670. <div class="mb-4">
  671. <h4 class="font-medium mb-2">告警状态</h4>
  672. <div class="mb-1 flex justify-between">
  673. <span>当前状态</span>
  674. <span class="font-medium text-red-600">未处理</span>
  675. </div>
  676. <div class="mb-1 flex justify-between">
  677. <span>处理人</span>
  678. <span class="font-medium">-</span>
  679. </div>
  680. <div class="mb-1 flex justify-between">
  681. <span>处理时间</span>
  682. <span class="font-medium">-</span>
  683. </div>
  684. </div>
  685. <div>
  686. <h4 class="font-medium mb-2">处理记录</h4>
  687. <div class="text-center text-gray-500 py-4">
  688. 暂无处理记录
  689. </div>
  690. </div>
  691. </div>
  692. <div class="modal-footer">
  693. <button class="btn btn-default" id="cancelDetailBtn">关闭</button>
  694. </div>
  695. </div>
  696. </div>
  697. <!-- 处理告警弹窗 -->
  698. <div class="modal-overlay" id="alarmHandleModal">
  699. <div class="modal">
  700. <div class="modal-header">
  701. <h3 class="modal-title">处理告警</h3>
  702. <div class="modal-close" id="closeHandleModal">&times;</div>
  703. </div>
  704. <div class="modal-body">
  705. <div class="p-4 mb-4 bg-red-50 alarm-type-urgent">
  706. <div class="flex justify-between items-center mb-2">
  707. <span class="badge badge-danger alarm-level">紧急</span>
  708. <span class="text-sm text-gray-500 alarm-time">2023-05-15 10:25:36</span>
  709. </div>
  710. <h3 class="text-lg font-bold mb-2 alarm-content">电池电量过低,即将无法工作</h3>
  711. <div class="flex flex-col gap-1">
  712. <div class="flex">
  713. <span class="text-sm text-gray-600 w-20">设备名称:</span>
  714. <span class="text-sm font-medium alarm-device-name">土壤传感器 #2</span>
  715. </div>
  716. <div class="flex">
  717. <span class="text-sm text-gray-600 w-20">设备编号:</span>
  718. <span class="text-sm font-medium alarm-device-id">SNS-20230002</span>
  719. </div>
  720. <div class="flex">
  721. <span class="text-sm text-gray-600 w-20">设备类型:</span>
  722. <span class="text-sm font-medium alarm-device-type">传感器</span>
  723. </div>
  724. <div class="flex">
  725. <span class="text-sm text-gray-600 w-20">所属地块:</span>
  726. <span class="text-sm font-medium alarm-field">东区2号地块</span>
  727. </div>
  728. <div class="flex">
  729. <span class="text-sm text-gray-600 w-20">所属农场:</span>
  730. <span class="text-sm font-medium alarm-farm">示范农场</span>
  731. </div>
  732. </div>
  733. </div>
  734. <div class="form-group mb-4">
  735. <label class="block font-medium mb-1">处理结果</label>
  736. <select class="w-full border border-gray-300 rounded p-2 focus:outline-none focus:ring-2 focus:ring-green-500 focus:border-transparent" id="handleResult">
  737. <option value="1">已处理</option>
  738. <option value="3">忽略</option>
  739. <option value="4">非故障</option>
  740. </select>
  741. </div>
  742. <div class="form-group mb-4">
  743. <label class="block font-medium mb-1">处理备注</label>
  744. <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="请输入处理备注..." id="handleRemark"></textarea>
  745. </div>
  746. <div class="form-group mb-4">
  747. <label class="block font-medium mb-1">附件上传</label>
  748. <div class="flex items-center">
  749. <label class="flex items-center justify-center px-4 py-2 border border-gray-300 rounded cursor-pointer hover:bg-gray-100">
  750. <i class="iconfont icon-upload mr-2"></i>
  751. <span>选择文件</span>
  752. <input type="file" class="hidden" id="attachmentUpload" multiple>
  753. </label>
  754. <span class="ml-3 text-sm text-gray-500" id="fileCount">未选择文件</span>
  755. </div>
  756. <div class="mt-2" id="fileList"></div>
  757. </div>
  758. <div class="form-group">
  759. <label class="flex items-center">
  760. <input type="checkbox" class="mr-2" id="notifyRelated">
  761. <span>通知相关人员</span>
  762. </label>
  763. </div>
  764. </div>
  765. <div class="modal-footer">
  766. <button class="btn btn-default" id="cancelHandleBtn">取消</button>
  767. <button class="btn btn-primary" id="submitHandleBtn">提交</button>
  768. </div>
  769. </div>
  770. </div>
  771. <script>
  772. // 定义全局函数,方便直接在HTML中调用
  773. function showAlarmModal(btn) {
  774. console.log("处理按钮被点击 (直接调用)", btn);
  775. const alarmId = btn.getAttribute('data-id');
  776. const row = btn.closest('tr');
  777. // 获取当前行数据
  778. const alarmLevel = row.querySelector('td:nth-child(2) .badge').textContent;
  779. const deviceName = row.querySelector('td:nth-child(3)').textContent;
  780. const deviceId = row.querySelector('td:nth-child(4)').textContent;
  781. const deviceType = row.querySelector('td:nth-child(5)').textContent;
  782. const field = row.querySelector('td:nth-child(6)').textContent;
  783. const farm = row.querySelector('td:nth-child(7)').textContent;
  784. const alarmContent = row.querySelector('td:nth-child(8)').textContent;
  785. const alarmTime = row.querySelector('td:nth-child(9)').textContent;
  786. // 填充模态框数据
  787. const modal = document.getElementById('alarmHandleModal');
  788. modal.querySelector('.alarm-level').textContent = alarmLevel;
  789. modal.querySelector('.alarm-time').textContent = alarmTime;
  790. modal.querySelector('.alarm-content').textContent = alarmContent;
  791. modal.querySelector('.alarm-device-name').textContent = deviceName;
  792. modal.querySelector('.alarm-device-id').textContent = deviceId;
  793. modal.querySelector('.alarm-device-type').textContent = deviceType;
  794. modal.querySelector('.alarm-field').textContent = field;
  795. modal.querySelector('.alarm-farm').textContent = farm;
  796. // 根据告警等级设置背景样式
  797. const alarmBox = modal.querySelector('.p-4.mb-4');
  798. if (alarmLevel.includes('紧急')) {
  799. alarmBox.className = 'p-4 mb-4 bg-red-50 alarm-type-urgent';
  800. modal.querySelector('.alarm-level').className = 'badge badge-danger alarm-level';
  801. } else if (alarmLevel.includes('警告')) {
  802. alarmBox.className = 'p-4 mb-4 bg-yellow-50 alarm-type-warning';
  803. modal.querySelector('.alarm-level').className = 'badge badge-warning alarm-level';
  804. } else {
  805. alarmBox.className = 'p-4 mb-4 bg-blue-50 alarm-type-notice';
  806. modal.querySelector('.alarm-level').className = 'badge badge-primary alarm-level';
  807. }
  808. // 记录当前操作的行
  809. modal.setAttribute('data-row', Array.from(row.parentNode.children).indexOf(row));
  810. // 重置表单
  811. document.getElementById('handleResult').value = '1';
  812. document.getElementById('handleRemark').value = '';
  813. document.getElementById('fileCount').textContent = '未选择文件';
  814. document.getElementById('fileList').innerHTML = '';
  815. document.getElementById('notifyRelated').checked = false;
  816. document.getElementById('attachmentUpload').value = '';
  817. // 显示模态框
  818. modal.style.display = 'flex';
  819. }
  820. // 全局处理告警按钮点击函数 - 保留兼容性
  821. function handleAlarmBtn(btn) {
  822. console.log('处理按钮点击 - handleAlarmBtn调用', btn);
  823. showAlarmModal(btn);
  824. }
  825. document.addEventListener("DOMContentLoaded", function() {
  826. // 初始化表格滚动功能
  827. function initTableScroll() {
  828. const tableContainer = document.querySelector(".table-container");
  829. if (!tableContainer) return;
  830. const scrollLeftBtn = document.querySelector(".table-scroll-left");
  831. const scrollRightBtn = document.querySelector(".table-scroll-right");
  832. if (!scrollLeftBtn || !scrollRightBtn) return;
  833. // 检查表格是否需要水平滚动
  834. function checkTableOverflow() {
  835. if (tableContainer.scrollWidth > tableContainer.clientWidth) {
  836. tableContainer.classList.add("has-overflow");
  837. } else {
  838. tableContainer.classList.remove("has-overflow");
  839. }
  840. }
  841. // 左右滚动按钮点击事件
  842. scrollLeftBtn.addEventListener("click", function() {
  843. tableContainer.scrollLeft -= 150;
  844. });
  845. scrollRightBtn.addEventListener("click", function() {
  846. tableContainer.scrollLeft += 150;
  847. });
  848. // 初始检查和窗口大小变化时检查
  849. checkTableOverflow();
  850. window.addEventListener("resize", checkTableOverflow);
  851. // 滚动事件处理
  852. tableContainer.addEventListener("scroll", function() {
  853. // 根据滚动位置显示/隐藏滚动按钮
  854. if (tableContainer.scrollLeft <= 10) {
  855. scrollLeftBtn.style.opacity = "0.5";
  856. } else {
  857. scrollLeftBtn.style.opacity = "1";
  858. }
  859. if (tableContainer.scrollLeft >= tableContainer.scrollWidth - tableContainer.clientWidth - 10) {
  860. scrollRightBtn.style.opacity = "0.5";
  861. } else {
  862. scrollRightBtn.style.opacity = "1";
  863. }
  864. });
  865. // 初始触发滚动事件,设置初始按钮状态
  866. tableContainer.dispatchEvent(new Event("scroll"));
  867. }
  868. // 初始化表格滚动
  869. initTableScroll();
  870. // 告警详情弹窗
  871. const alarmDetailModal = document.getElementById('alarmDetailModal');
  872. const closeDetailModal = document.getElementById('closeDetailModal');
  873. const cancelDetailBtn = document.getElementById('cancelDetailBtn');
  874. // 查看告警详情
  875. document.querySelectorAll('.view-btn').forEach(function(btn) {
  876. btn.onclick = function() {
  877. const alarmId = this.getAttribute('data-id');
  878. alarmDetailModal.style.display = 'flex';
  879. // 实际应用中应该根据ID获取告警详情
  880. };
  881. });
  882. // 关闭详情弹窗
  883. function closeDetailModal() {
  884. alarmDetailModal.style.display = 'none';
  885. }
  886. closeDetailModal.onclick = closeDetailModal;
  887. cancelDetailBtn.onclick = closeDetailModal;
  888. // 告警处理弹窗
  889. const alarmHandleModal = document.getElementById('alarmHandleModal');
  890. const closeHandleModal = document.getElementById('closeHandleModal');
  891. const cancelHandleBtn = document.getElementById('cancelHandleBtn');
  892. const submitHandleBtn = document.getElementById('submitHandleBtn');
  893. // 不需要再为处理按钮绑定事件,因为已经通过inline onclick属性绑定了showAlarmModal函数
  894. console.log('处理按钮数量:', document.querySelectorAll('.handle-btn').length);
  895. // 文件上传处理
  896. const attachmentUpload = document.getElementById('attachmentUpload');
  897. attachmentUpload.addEventListener('change', function() {
  898. const fileCount = this.files.length;
  899. const fileCountElem = document.getElementById('fileCount');
  900. const fileListElem = document.getElementById('fileList');
  901. if (fileCount > 0) {
  902. fileCountElem.textContent = `已选择 ${fileCount} 个文件`;
  903. fileListElem.innerHTML = '';
  904. Array.from(this.files).forEach(file => {
  905. const fileItem = document.createElement('div');
  906. fileItem.className = 'flex items-center gap-2 mt-1';
  907. fileItem.innerHTML = `
  908. <i class="iconfont icon-file text-gray-500"></i>
  909. <span class="text-sm">${file.name}</span>
  910. <span class="text-xs text-gray-500">(${formatFileSize(file.size)})</span>
  911. `;
  912. fileListElem.appendChild(fileItem);
  913. });
  914. } else {
  915. fileCountElem.textContent = '未选择文件';
  916. fileListElem.innerHTML = '';
  917. }
  918. });
  919. // 格式化文件大小
  920. function formatFileSize(bytes) {
  921. if (bytes < 1024) return bytes + ' B';
  922. if (bytes < 1024 * 1024) return (bytes / 1024).toFixed(1) + ' KB';
  923. return (bytes / (1024 * 1024)).toFixed(1) + ' MB';
  924. }
  925. // 关闭处理弹窗
  926. function closeHandleModal() {
  927. alarmHandleModal.style.display = 'none';
  928. }
  929. closeHandleModal.onclick = closeHandleModal;
  930. cancelHandleBtn.onclick = closeHandleModal;
  931. // 提交处理
  932. submitHandleBtn.onclick = function() {
  933. const modal = document.getElementById('alarmHandleModal');
  934. const rowIndex = parseInt(modal.getAttribute('data-row'));
  935. const tbody = document.querySelector('table tbody');
  936. const row = tbody.children[rowIndex];
  937. if (row) {
  938. const statusCell = row.querySelector('td:nth-child(10)');
  939. const handlePersonCell = row.querySelector('td:nth-child(11)');
  940. const handleTimeCell = row.querySelector('td:nth-child(12)');
  941. const operationCell = row.querySelector('td:nth-child(13)');
  942. // 更新状态
  943. const result = document.getElementById('handleResult').value;
  944. let statusText = '已处理';
  945. let statusClass = 'badge-success';
  946. if (result === '3') {
  947. statusText = '已忽略';
  948. statusClass = 'badge-warning';
  949. } else if (result === '4') {
  950. statusText = '非故障';
  951. statusClass = 'badge-primary';
  952. }
  953. statusCell.innerHTML = `<span class="badge ${statusClass}">${statusText}</span>`;
  954. // 更新处理人和时间
  955. const currentDate = new Date();
  956. const dateStr = currentDate.toLocaleDateString('zh-CN', {
  957. year: 'numeric',
  958. month: '2-digit',
  959. day: '2-digit',
  960. hour: '2-digit',
  961. minute: '2-digit',
  962. second: '2-digit',
  963. hour12: false
  964. }).replace(/\//g, '-');
  965. handlePersonCell.textContent = '当前用户'; // 实际应用中应为登录用户名
  966. handleTimeCell.textContent = dateStr;
  967. // 更新操作按钮 - 已处理的只保留查看按钮
  968. const btnContainer = operationCell.querySelector('div');
  969. const viewBtn = operationCell.querySelector('.view-btn').cloneNode(true);
  970. btnContainer.innerHTML = '';
  971. btnContainer.appendChild(viewBtn);
  972. }
  973. alert('告警处理已提交');
  974. closeHandleModal();
  975. };
  976. // 点击弹窗外部关闭弹窗
  977. window.addEventListener('click', function(e) {
  978. if (e.target === alarmDetailModal) {
  979. closeDetailModal();
  980. }
  981. if (e.target === alarmHandleModal) {
  982. closeHandleModal();
  983. }
  984. });
  985. });
  986. </script>
  987. </body>
  988. </html>