| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037 |
- <!DOCTYPE html>
- <html lang="zh-CN" class="iframe-content">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>设备告警信息 - 爱智农</title>
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css">
- <link rel="stylesheet" href="https://at.alicdn.com/t/font_3114978_qe0b39no76.css">
- <link rel="stylesheet" href="../assets/css/global.css">
- <style>
- body {
- font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
- background-color: #f5f7f9;
- color: #333;
- margin: 0;
- padding: 0;
- height: auto;
- overflow-y: auto;
- overflow-x: hidden;
- min-height: 100%;
- }
-
- .page-container {
- padding: 20px;
- padding-top: 70px; /* 添加顶部边距,为按钮留出空间 */
- position: relative;
- min-height: 100vh;
- width: 100%;
- max-width: 100%;
- box-sizing: border-box;
- }
-
- .card {
- background-color: white;
- border-radius: 8px;
- box-shadow: 0 2px 8px rgba(0,0,0,0.05);
- }
-
- .table-container {
- position: relative;
- overflow-x: auto;
- }
-
- table {
- width: 100%;
- border-collapse: separate;
- border-spacing: 0;
- }
-
- th {
- white-space: nowrap;
- position: relative;
- overflow: visible;
- max-width: none;
- text-overflow: clip;
- background-color: #f9fafb;
- padding: 12px 16px;
- text-align: left;
- font-weight: 500;
- color: #6b7280;
- border-bottom: 1px solid #e5e7eb;
- }
-
- td {
- white-space: nowrap;
- max-width: 200px;
- overflow: hidden;
- text-overflow: ellipsis;
- padding: 12px 16px;
- border-bottom: 1px solid #e5e7eb;
- }
-
- tr:hover {
- background-color: #f9fafb;
- }
-
- tr:hover td:last-child {
- background-color: #f9fafb;
- }
-
- /* 固定最后一列(操作列)样式 */
- .table-fixed-right {
- position: relative;
- }
-
- .table-fixed-right th:last-child,
- .table-fixed-right td:last-child {
- position: sticky;
- right: 0;
- z-index: 2;
- background-color: white;
- box-shadow: -5px 0 5px -5px rgba(0, 0, 0, 0.1);
- }
-
- .table-fixed-right th:last-child {
- background-color: #f9fafb;
- }
-
- /* 表格滚动控件 */
- .table-scroll-controls {
- display: none;
- position: absolute;
- top: 50%;
- transform: translateY(-50%);
- width: 100%;
- pointer-events: none;
- z-index: 3;
- }
-
- .table-scroll-btn {
- position: absolute;
- width: 32px;
- height: 32px;
- border-radius: 50%;
- background-color: rgba(255, 255, 255, 0.9);
- color: #4CAF50;
- border: 1px solid #e0e0e0;
- display: flex;
- align-items: center;
- justify-content: center;
- cursor: pointer;
- pointer-events: auto;
- box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
- z-index: 4;
- }
-
- .table-scroll-left {
- left: 10px;
- }
-
- .table-scroll-right {
- right: 10px;
- }
-
- .has-overflow .table-scroll-controls {
- display: block;
- }
-
- .btn {
- display: inline-flex;
- align-items: center;
- justify-content: center;
- padding: 8px 16px;
- border-radius: 4px;
- font-weight: 500;
- cursor: pointer;
- transition: all 0.2s;
- }
-
- .btn-primary {
- background-color: #4CAF50;
- color: white;
- }
-
- .btn-primary:hover {
- background-color: #388E3C;
- }
-
- .btn-default {
- background-color: white;
- border: 1px solid #d1d5db;
- color: #374151;
- }
-
- .btn-default:hover {
- background-color: #f9fafb;
- }
-
- .btn-danger {
- background-color: #ef4444;
- color: white;
- }
-
- .btn-danger:hover {
- background-color: #dc2626;
- }
-
- .btn-warning {
- background-color: #f59e0b;
- color: white;
- }
-
- .btn-warning:hover {
- background-color: #d97706;
- }
-
- .btn-sm {
- padding: 4px 8px;
- font-size: 12px;
- }
-
- .btn-icon {
- margin-right: 4px;
- }
-
- /* 搜索表单样式 */
- .search-form {
- display: grid;
- grid-template-columns: repeat(4, 1fr);
- gap: 16px;
- }
-
- @media (max-width: 1200px) {
- .search-form {
- grid-template-columns: repeat(3, 1fr);
- }
- }
-
- @media (max-width: 992px) {
- .search-form {
- grid-template-columns: repeat(2, 1fr);
- }
- }
-
- @media (max-width: 640px) {
- .search-form {
- grid-template-columns: 1fr;
- }
- }
-
- .search-form-item {
- display: flex;
- flex-direction: column;
- gap: 4px;
- }
-
- .search-form-label {
- font-size: 14px;
- color: #6b7280;
- margin-bottom: 4px;
- }
-
- .search-form-actions {
- display: flex;
- justify-content: flex-end;
- gap: 12px;
- margin-top: 24px;
- grid-column: 1 / -1;
- }
-
- /* 日期选择器样式 */
- .date-range {
- display: flex;
- gap: 8px;
- }
-
- .date-input {
- padding: 8px 12px;
- border: 1px solid #d1d5db;
- border-radius: 4px;
- flex-grow: 1;
- width: 100%;
- cursor: pointer;
- background-color: white;
- }
-
- .input {
- padding: 8px 12px;
- border: 1px solid #d1d5db;
- border-radius: 4px;
- flex-grow: 1;
- }
-
- .input:focus {
- outline: none;
- border-color: #4CAF50;
- box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.2);
- }
-
- /* 多选下拉框样式 */
- .select-container {
- position: relative;
- width: 100%;
- }
-
- .select {
- padding: 8px 12px;
- border: 1px solid #d1d5db;
- border-radius: 4px;
- background-color: white;
- width: 100%;
- appearance: none;
- background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
- background-repeat: no-repeat;
- background-position: right 8px center;
- background-size: 16px;
- padding-right: 32px;
- }
-
- .select:focus {
- outline: none;
- border-color: #4CAF50;
- box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.2);
- }
-
- .select[multiple] {
- padding: 6px;
- overflow-y: auto;
- max-height: 120px;
- }
-
- /* 多选选项样式 */
- .select[multiple] option {
- padding: 6px 8px;
- margin: 2px 0;
- border-radius: 3px;
- cursor: pointer;
- }
-
- .select[multiple] option:checked {
- background-color: rgba(76, 175, 80, 0.2);
- color: #333;
- }
-
- .select[multiple] option:hover {
- background-color: rgba(76, 175, 80, 0.1);
- }
-
- .modal-overlay {
- position: fixed;
- top: 0;
- left: 0;
- right: 0;
- bottom: 0;
- background-color: rgba(0, 0, 0, 0.5);
- display: flex;
- align-items: center;
- justify-content: center;
- z-index: 50;
- display: none;
- }
-
- .modal {
- background-color: white;
- border-radius: 8px;
- width: 100%;
- max-width: 600px;
- box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
- }
-
- .modal-header {
- padding: 16px 24px;
- border-bottom: 1px solid #e5e7eb;
- display: flex;
- align-items: center;
- justify-content: space-between;
- }
-
- .modal-title {
- font-size: 18px;
- font-weight: 500;
- }
-
- .modal-close {
- cursor: pointer;
- font-size: 20px;
- }
-
- .modal-body {
- padding: 24px;
- }
-
- .modal-footer {
- padding: 16px 24px;
- border-top: 1px solid #e5e7eb;
- display: flex;
- justify-content: flex-end;
- gap: 8px;
- }
-
- .badge {
- display: inline-block;
- padding: 2px 8px;
- border-radius: 9999px;
- font-size: 12px;
- font-weight: 500;
- }
-
- .badge-success {
- background-color: #d1fae5;
- color: #065f46;
- }
-
- .badge-warning {
- background-color: #fef3c7;
- color: #92400e;
- }
-
- .badge-danger {
- background-color: #fee2e2;
- color: #b91c1c;
- }
-
- .pagination {
- display: flex;
- align-items: center;
- justify-content: flex-end;
- gap: 4px;
- }
-
- .pagination-item {
- display: inline-flex;
- align-items: center;
- justify-content: center;
- width: 32px;
- height: 32px;
- border-radius: 4px;
- cursor: pointer;
- transition: all 0.2s;
- }
-
- .pagination-item:hover {
- background-color: #f3f4f6;
- }
-
- .pagination-item.active {
- background-color: #4CAF50;
- color: white;
- }
-
- .pagination-item.disabled {
- color: #9ca3af;
- cursor: not-allowed;
- }
-
- .timeline {
- position: relative;
- padding-left: 32px;
- }
-
- .timeline-item {
- position: relative;
- padding-bottom: 16px;
- }
-
- .timeline-item:last-child {
- padding-bottom: 0;
- }
-
- .timeline-item::before {
- content: "";
- position: absolute;
- left: -24px;
- top: 6px;
- width: 12px;
- height: 12px;
- border-radius: 50%;
- background-color: #4CAF50;
- z-index: 1;
- }
-
- .timeline-item::after {
- content: "";
- position: absolute;
- left: -19px;
- top: 18px;
- width: 2px;
- height: calc(100% - 18px);
- background-color: #e5e7eb;
- }
-
- .timeline-item:last-child::after {
- display: none;
- }
-
- .timeline-time {
- font-size: 12px;
- color: #6b7280;
- margin-bottom: 2px;
- }
-
- .alarm-type-urgent {
- border-left: 4px solid #ef4444;
- }
-
- .alarm-type-warning {
- border-left: 4px solid #f59e0b;
- }
-
- .alarm-type-notice {
- border-left: 4px solid #3b82f6;
- }
-
- /* 修复按钮被遮挡的问题 */
- .action-buttons {
- position: relative;
- z-index: 1000 !important;
- }
-
- /* 多选框样式 */
- select[multiple] {
- height: auto;
- min-height: 38px;
- padding: 4px 8px;
- }
-
- select[multiple] option {
- padding: 4px 8px;
- margin: 2px 0;
- border-radius: 2px;
- }
-
- select[multiple] option:checked {
- background-color: rgba(76, 175, 80, 0.1);
- color: #4CAF50;
- }
-
- /* 日期选择器样式 */
- input[type="date"] {
- padding: 8px 12px;
- border: 1px solid #d1d5db;
- border-radius: 4px;
- }
-
- input[type="date"]:focus {
- outline: none;
- border-color: #4CAF50;
- box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.2);
- }
- </style>
- </head>
- <body>
- <div class="page-container responsive-container">
- <div class="flex justify-between items-center mb-6">
- <h1 class="text-2xl font-bold">设备告警信息</h1>
-
- <div class="flex gap-2 action-buttons">
- <button class="btn btn-default">
- <i class="iconfont icon-reload btn-icon"></i>
- 刷新数据
- </button>
- <button class="btn btn-primary" style="position: relative; z-index: 1000;">
- <i class="iconfont icon-setting btn-icon"></i>
- 告警设置
- </button>
- </div>
- </div>
-
- <div class="card p-4 mb-6">
- <div class="search-form">
- <!-- 设备编号 关键词搜索 -->
- <div class="search-form-item">
- <label class="search-form-label">设备编号:</label>
- <input type="text" class="input flex-1" placeholder="请输入设备编号关键词">
- </div>
-
- <!-- 设备名称 关键词搜索 -->
- <div class="search-form-item">
- <label class="search-form-label">设备名称:</label>
- <input type="text" class="input flex-1" placeholder="请输入设备名称关键词">
- </div>
-
- <!-- 告警等级 下拉框多选 -->
- <div class="search-form-item">
- <label class="search-form-label">设备类型:</label>
- <select class="select flex-1">
- <option value="">全部</option>
- <option value="sensor">传感器</option>
- <option value="camera">摄像设备</option>
- <option value="controller">控制器</option>
- <option value="weather">气象设备</option>
- </select>
- </div>
-
- <!-- 所属农场 -->
- <div class="search-form-item">
- <label class="search-form-label">所属农场:</label>
- <select class="select flex-1">
- <option value="">全部</option>
- <option value="demo">示范农场</option>
- <option value="smart">智慧农场</option>
- </select>
- </div>
-
- <!-- 所属地块 -->
- <div class="search-form-item">
- <label class="search-form-label">所属地块:</label>
- <select class="select flex-1">
- <option value="">全部</option>
- <option value="east1">东区1号地块</option>
- <option value="east2">东区2号地块</option>
- <option value="west1">西区1号地块</option>
- <option value="south3">南区3号地块</option>
- <option value="north1">北区1号地块</option>
- </select>
- </div>
-
- <!-- 设备状态 -->
- <div class="search-form-item">
- <label class="search-form-label">设备状态:</label>
- <select class="select flex-1">
- <option value="">全部</option>
- <option value="1">已处理</option>
- <option value="0">未处理</option>
- <option value="2">处理中</option>
- </select>
- </div>
-
- <!-- 搜索按钮区域 -->
- <div class="search-form-actions">
- <button class="btn btn-primary">
- <i class="iconfont icon-search btn-icon"></i>
- 搜索
- </button>
- <button class="btn btn-default">
- <i class="iconfont icon-reload btn-icon"></i>
- 重置
- </button>
- </div>
- </div>
- </div>
-
- <div class="card">
- <div class="table-container">
- <div class="table-scroll-controls">
- <button class="table-scroll-btn table-scroll-left">
- <i class="iconfont icon-left"></i>
- </button>
- <button class="table-scroll-btn table-scroll-right">
- <i class="iconfont icon-right"></i>
- </button>
- </div>
- <table class="table-fixed-right">
- <thead>
- <tr>
- <th>告警ID</th>
- <th>告警等级</th>
- <th>设备名称</th>
- <th>设备编号</th>
- <th>设备类型</th>
- <th>所属地块</th>
- <th>所属农场</th>
- <th>告警内容</th>
- <th>告警时间</th>
- <th>处理状态</th>
- <th>处理人</th>
- <th>处理时间</th>
- <th class="min-w-[150px]">操作</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>ALM-20230001</td>
- <td><span class="badge badge-danger">紧急</span></td>
- <td>土壤传感器 #2</td>
- <td>SNS-20230002</td>
- <td>传感器</td>
- <td>东区2号地块</td>
- <td>示范农场</td>
- <td>电池电量过低,即将无法工作</td>
- <td>2023-05-15 10:25:36</td>
- <td><span class="badge badge-danger">未处理</span></td>
- <td>-</td>
- <td>-</td>
- <td>
- <div class="flex gap-2">
- <button class="btn btn-default btn-sm view-btn" data-id="1">
- <i class="iconfont icon-eye btn-icon"></i>
- 查看
- </button>
- <button class="btn btn-primary btn-sm handle-btn" data-id="1">
- <i class="iconfont icon-check btn-icon"></i>
- 处理
- </button>
- </div>
- </td>
- </tr>
- <tr>
- <td>ALM-20230002</td>
- <td><span class="badge badge-warning">警告</span></td>
- <td>摄像头 #3</td>
- <td>CAM-20230003</td>
- <td>摄像设备</td>
- <td>西区1号地块</td>
- <td>示范农场</td>
- <td>信号弱,视频画面不稳定</td>
- <td>2023-05-15 09:18:42</td>
- <td><span class="badge badge-warning">处理中</span></td>
- <td>张三</td>
- <td>2023-05-15 10:20:15</td>
- <td>
- <div class="flex gap-2">
- <button class="btn btn-default btn-sm view-btn" data-id="2">
- <i class="iconfont icon-eye btn-icon"></i>
- 查看
- </button>
- <button class="btn btn-primary btn-sm handle-btn" data-id="2">
- <i class="iconfont icon-check btn-icon"></i>
- 处理
- </button>
- </div>
- </td>
- </tr>
- <tr>
- <td>ALM-20230003</td>
- <td><span class="badge badge-danger">紧急</span></td>
- <td>水位传感器 #1</td>
- <td>WLV-20230001</td>
- <td>传感器</td>
- <td>南区3号地块</td>
- <td>智慧农场</td>
- <td>水位超过预警线,可能发生溢出</td>
- <td>2023-05-15 08:45:20</td>
- <td><span class="badge badge-success">已处理</span></td>
- <td>李四</td>
- <td>2023-05-15 09:30:42</td>
- <td>
- <div class="flex gap-2">
- <button class="btn btn-default btn-sm view-btn" data-id="3">
- <i class="iconfont icon-eye btn-icon"></i>
- 查看
- </button>
- </div>
- </td>
- </tr>
- <tr>
- <td>ALM-20230004</td>
- <td><span class="badge badge-warning">警告</span></td>
- <td>气象站 #1</td>
- <td>WEA-20230001</td>
- <td>气象设备</td>
- <td>北区1号地块</td>
- <td>智慧农场</td>
- <td>湿度传感器异常,读数不稳定</td>
- <td>2023-05-14 17:32:15</td>
- <td><span class="badge badge-danger">未处理</span></td>
- <td>-</td>
- <td>-</td>
- <td>
- <div class="flex gap-2">
- <button class="btn btn-default btn-sm view-btn" data-id="4">
- <i class="iconfont icon-eye btn-icon"></i>
- 查看
- </button>
- <button class="btn btn-primary btn-sm handle-btn" data-id="4">
- <i class="iconfont icon-check btn-icon"></i>
- 处理
- </button>
- </div>
- </td>
- </tr>
- <tr>
- <td>ALM-20230005</td>
- <td><span class="badge badge-primary" style="background-color: #dbeafe; color: #1e40af;">提示</span></td>
- <td>自动灌溉控制器 #1</td>
- <td>IRR-20230001</td>
- <td>控制器</td>
- <td>东区1号地块</td>
- <td>示范农场</td>
- <td>设备需要例行维护检查</td>
- <td>2023-05-14 14:10:08</td>
- <td><span class="badge badge-success">已处理</span></td>
- <td>王五</td>
- <td>2023-05-14 16:45:20</td>
- <td>
- <div class="flex gap-2">
- <button class="btn btn-default btn-sm view-btn" data-id="5">
- <i class="iconfont icon-eye btn-icon"></i>
- 查看
- </button>
- </div>
- </td>
- </tr>
- </tbody>
- </table>
- </div>
-
- <div class="p-4 flex justify-between items-center">
- <div class="text-sm text-gray-500">
- 共 <span class="font-medium">24</span> 条记录,每页 <span class="font-medium">10</span> 条
- </div>
-
- <div class="pagination">
- <div class="pagination-item disabled">
- <i class="iconfont icon-left"></i>
- </div>
- <div class="pagination-item active">1</div>
- <div class="pagination-item">2</div>
- <div class="pagination-item">3</div>
- <div class="pagination-item">
- <i class="iconfont icon-right"></i>
- </div>
- </div>
- </div>
- </div>
- </div>
-
- <!-- 告警详情弹窗 -->
- <div class="modal-overlay" id="alarmDetailModal">
- <div class="modal">
- <div class="modal-header">
- <h3 class="modal-title">告警详情</h3>
- <div class="modal-close" id="closeDetailModal">×</div>
- </div>
- <div class="modal-body">
- <div class="p-4 mb-4 bg-red-50 alarm-type-urgent">
- <div class="flex justify-between items-center mb-2">
- <span class="badge badge-danger">紧急</span>
- <span class="text-sm text-gray-500">2023-05-15 10:25:36</span>
- </div>
- <h3 class="text-lg font-bold mb-2">电池电量过低,即将无法工作</h3>
- <p class="text-gray-600 mb-2">土壤传感器 #2 (SNS-20230002) 电池电量低于10%,请尽快更换电池,否则设备将在24小时内无法正常工作。</p>
- <div class="flex justify-between text-sm text-gray-500">
- <span>告警ID: ALM-20230001</span>
- <span>设备位置: 东区2号地块</span>
- </div>
- </div>
-
- <div class="mb-4">
- <h4 class="font-medium mb-2">设备信息</h4>
- <div class="grid grid-cols-2 gap-4">
- <div>
- <div class="text-xs text-gray-500 mb-1">设备ID</div>
- <div class="font-medium">SNS-20230002</div>
- </div>
- <div>
- <div class="text-xs text-gray-500 mb-1">设备类型</div>
- <div class="font-medium">土壤传感器</div>
- </div>
- <div>
- <div class="text-xs text-gray-500 mb-1">安装位置</div>
- <div class="font-medium">东区2号地块</div>
- </div>
- <div>
- <div class="text-xs text-gray-500 mb-1">安装时间</div>
- <div class="font-medium">2023-01-20</div>
- </div>
- </div>
- </div>
-
- <div class="mb-4">
- <h4 class="font-medium mb-2">告警状态</h4>
- <div class="mb-1 flex justify-between">
- <span>当前状态</span>
- <span class="font-medium text-red-600">未处理</span>
- </div>
- <div class="mb-1 flex justify-between">
- <span>处理人</span>
- <span class="font-medium">-</span>
- </div>
- <div class="mb-1 flex justify-between">
- <span>处理时间</span>
- <span class="font-medium">-</span>
- </div>
- </div>
-
- <div>
- <h4 class="font-medium mb-2">处理记录</h4>
- <div class="text-center text-gray-500 py-4">
- 暂无处理记录
- </div>
- </div>
- </div>
- <div class="modal-footer">
- <button class="btn btn-default" id="cancelDetailBtn">关闭</button>
- </div>
- </div>
- </div>
-
- <!-- 处理告警弹窗 -->
- <div class="modal-overlay" id="alarmHandleModal">
- <div class="modal">
- <div class="modal-header">
- <h3 class="modal-title">处理告警</h3>
- <div class="modal-close" id="closeHandleModal">×</div>
- </div>
- <div class="modal-body">
- <div class="p-4 mb-4 bg-red-50 alarm-type-urgent">
- <h3 class="text-lg font-bold mb-2">电池电量过低,即将无法工作</h3>
- <p class="text-gray-600">土壤传感器 #2 (SNS-20230002)</p>
- </div>
-
- <div class="form-group mb-4">
- <label class="block font-medium mb-1">处理状态</label>
- <select class="w-full border border-gray-300 rounded p-2 focus:outline-none focus:ring-2 focus:ring-green-500 focus:border-transparent">
- <option value="1">已处理</option>
- <option value="2">处理中</option>
- <option value="3">忽略</option>
- </select>
- </div>
-
- <div class="form-group mb-4">
- <label class="block font-medium mb-1">处理方式</label>
- <select class="w-full border border-gray-300 rounded p-2 focus:outline-none focus:ring-2 focus:ring-green-500 focus:border-transparent">
- <option value="replace">更换设备</option>
- <option value="repair">维修设备</option>
- <option value="battery">更换电池</option>
- <option value="restart">重启设备</option>
- <option value="other">其他</option>
- </select>
- </div>
-
- <div class="form-group mb-4">
- <label class="block font-medium mb-1">处理说明</label>
- <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>
- </div>
-
- <div class="form-group">
- <label class="flex items-center">
- <input type="checkbox" class="mr-2">
- <span>通知相关人员</span>
- </label>
- </div>
- </div>
- <div class="modal-footer">
- <button class="btn btn-default" id="cancelHandleBtn">取消</button>
- <button class="btn btn-primary" id="submitHandleBtn">提交</button>
- </div>
- </div>
- </div>
-
- <script>
- document.addEventListener("DOMContentLoaded", function() {
- // 初始化表格滚动功能
- function initTableScroll() {
- const tableContainer = document.querySelector(".table-container");
- if (!tableContainer) return;
-
- const scrollLeftBtn = document.querySelector(".table-scroll-left");
- const scrollRightBtn = document.querySelector(".table-scroll-right");
-
- if (!scrollLeftBtn || !scrollRightBtn) return;
-
- // 检查表格是否需要水平滚动
- function checkTableOverflow() {
- if (tableContainer.scrollWidth > tableContainer.clientWidth) {
- tableContainer.classList.add("has-overflow");
- } else {
- tableContainer.classList.remove("has-overflow");
- }
- }
-
- // 左右滚动按钮点击事件
- scrollLeftBtn.addEventListener("click", function() {
- tableContainer.scrollLeft -= 150;
- });
-
- scrollRightBtn.addEventListener("click", function() {
- tableContainer.scrollLeft += 150;
- });
-
- // 初始检查和窗口大小变化时检查
- checkTableOverflow();
- window.addEventListener("resize", checkTableOverflow);
-
- // 滚动事件处理
- tableContainer.addEventListener("scroll", function() {
- // 根据滚动位置显示/隐藏滚动按钮
- if (tableContainer.scrollLeft <= 10) {
- scrollLeftBtn.style.opacity = "0.5";
- } else {
- scrollLeftBtn.style.opacity = "1";
- }
-
- if (tableContainer.scrollLeft >= tableContainer.scrollWidth - tableContainer.clientWidth - 10) {
- scrollRightBtn.style.opacity = "0.5";
- } else {
- scrollRightBtn.style.opacity = "1";
- }
- });
-
- // 初始触发滚动事件,设置初始按钮状态
- tableContainer.dispatchEvent(new Event("scroll"));
- }
-
- // 初始化表格滚动
- initTableScroll();
-
- // 告警详情弹窗
- const alarmDetailModal = document.getElementById('alarmDetailModal');
- const closeDetailModal = document.getElementById('closeDetailModal');
- const cancelDetailBtn = document.getElementById('cancelDetailBtn');
- const viewBtns = document.querySelectorAll('.view-btn');
-
- // 查看告警详情
- viewBtns.forEach(btn => {
- btn.addEventListener('click', function() {
- const alarmId = this.getAttribute('data-id');
- alarmDetailModal.style.display = 'flex';
-
- // 实际应用中应该根据ID获取告警详情
- });
- });
-
- // 关闭详情弹窗
- function closeDetailModal() {
- alarmDetailModal.style.display = 'none';
- }
-
- closeDetailModal.addEventListener('click', closeDetailModal);
- cancelDetailBtn.addEventListener('click', closeDetailModal);
-
- // 告警处理弹窗
- const alarmHandleModal = document.getElementById('alarmHandleModal');
- const closeHandleModal = document.getElementById('closeHandleModal');
- const cancelHandleBtn = document.getElementById('cancelHandleBtn');
- const submitHandleBtn = document.getElementById('submitHandleBtn');
- const handleBtns = document.querySelectorAll('.handle-btn');
-
- // 处理告警
- handleBtns.forEach(btn => {
- btn.addEventListener('click', function() {
- const alarmId = this.getAttribute('data-id');
- alarmHandleModal.style.display = 'flex';
-
- // 实际应用中应该根据ID获取告警详情
- });
- });
-
- // 关闭处理弹窗
- function closeHandleModal() {
- alarmHandleModal.style.display = 'none';
- }
-
- closeHandleModal.addEventListener('click', closeHandleModal);
- cancelHandleBtn.addEventListener('click', closeHandleModal);
-
- // 提交处理
- submitHandleBtn.addEventListener('click', function() {
- alert('告警处理已提交');
- closeHandleModal();
- // 实际应用中应该提交处理信息到后端
- });
-
- // 点击弹窗外部关闭弹窗
- window.addEventListener('click', function(e) {
- if (e.target === alarmDetailModal) {
- closeDetailModal();
- }
- if (e.target === alarmHandleModal) {
- closeHandleModal();
- }
- });
- });
- </script>
- </body>
- </html>
|