| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139 |
- <!DOCTYPE html>
- <html lang="zh-CN">
- <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>
- :root {
- --primary: #4CAF50;
- --primary-dark: #388E3C;
- --primary-light: #A5D6A7;
- --primary-bg: #F1F8E9;
- --success: #4CAF50;
- --warning: #FFC107;
- --danger: #F44336;
- --info: #2196F3;
- --disabled: #9E9E9E;
- --border: #E0E0E0;
- --text-primary: #212121;
- --text-secondary: #757575;
- --radius: 8px;
- }
-
- /* 全局样式重置 */
- * {
- margin: 0;
- padding: 0;
- box-sizing: border-box;
- }
- /* 移除所有固定定位和绝对定位元素 */
- .fixed,
- .absolute,
- [style*="position: fixed"],
- [style*="position: absolute"] {
- display: none !important;
- }
- /* 移除所有圆形按钮和浮动元素 */
- .circle,
- .rounded-full,
- .floating,
- [class*="circle"],
- [class*="round"],
- [class*="float"] {
- display: none !important;
- }
- /* 确保内容不会溢出 */
- html, body {
- overflow-x: hidden;
- position: relative;
- }
- /* 移除所有可能的遮罩层 */
- [class*="overlay"],
- [class*="mask"],
- [style*="z-index: 9999"] {
- display: none !important;
- }
-
- /* 重置默认样式 */
- html, body {
- margin: 0;
- padding: 0;
- font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
- height: 100%;
- position: relative;
- }
-
- body {
- background-color: #f5f7f9;
- color: var(--text-primary);
- overflow-x: hidden;
- padding-top: 70px;
- }
-
- /* 防止重复菜单 - 修改选择器避免影响按钮和模态框 */
- body > div:not(.page-container):not(.modal):not(#machineModal),
- iframe#sidebar,
- div.system-menu,
- [id^="system-menu"],
- [class^="system-menu"],
- #admin-sidebar,
- .menu-popup,
- .user-avatar-circle {
- display: none !important;
- }
-
- /* 移除可能影响按钮和模态框的全局样式 */
- .circle-btn,
- .floating-circle,
- .round-button,
- .scroll-top-btn,
- .help-btn,
- .chat-btn {
- display: none !important;
- }
- /* 模态框样式 */
- .modal {
- display: none;
- position: fixed;
- top: 0;
- left: 0;
- right: 0;
- bottom: 0;
- width: 100%;
- height: 100%;
- background-color: rgba(0, 0, 0, 0.5);
- z-index: 99999;
- opacity: 0;
- visibility: hidden;
- transition: opacity 0.3s ease, visibility 0.3s ease;
- }
- .modal.show {
- display: block !important;
- opacity: 1 !important;
- visibility: visible !important;
- }
- .modal-dialog {
- position: fixed;
- top: 50%;
- left: 50%;
- transform: translate(-50%, -50%);
- width: 90%;
- max-width: 800px;
- margin-top: 20px;
- background: #fff;
- border-radius: 8px;
- z-index: 100000;
- box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
- }
- .modal-content {
- background: #fff;
- border-radius: 8px;
- overflow: hidden;
- position: relative;
- }
- .modal-header {
- padding: 16px 24px;
- border-bottom: 1px solid #e0e0e0;
- display: flex;
- align-items: center;
- justify-content: space-between;
- background: #fff;
- position: sticky;
- top: 0;
- z-index: 1;
- }
- .modal-close {
- padding: 8px;
- background: none;
- border: none;
- cursor: pointer;
- font-size: 20px;
- color: #666;
- display: flex;
- align-items: center;
- justify-content: center;
- border-radius: 4px;
- transition: all 0.3s;
- }
- .modal-close:hover {
- background-color: rgba(0, 0, 0, 0.05);
- color: #333;
- }
- .modal-title {
- font-size: 18px;
- font-weight: 500;
- color: #333;
- margin: 0;
- }
- .modal-body {
- padding: 24px;
- max-height: calc(100vh - 200px);
- overflow-y: auto;
- background: #fff;
- }
- .modal-footer {
- padding: 16px 24px;
- border-top: 1px solid #e0e0e0;
- display: flex;
- justify-content: flex-end;
- gap: 12px;
- background: #fff;
- }
- /* 页面容器 */
- .page-container {
- padding: 20px;
- max-width: 1600px;
- margin: 0 auto;
- margin-top: 60px;
- position: relative;
- z-index: 1;
- }
- /* 页面标题和操作按钮容器 */
- .page-header {
- display: flex;
- justify-content: space-between;
- align-items: center;
- margin-bottom: 20px;
- position: relative;
- z-index: 5;
- }
- /* 卡片样式 */
- .card {
- background-color: white;
- border-radius: 8px;
- box-shadow: 0 2px 8px rgba(0,0,0,0.05);
- overflow: hidden;
- }
- /* 表格样式 */
- .table-container {
- position: relative;
- position: relative;
- overflow-x: auto;
- position: relative;
- scrollbar-width: thin;
- scrollbar-color: #e0e0e0 #f5f7f9;
- padding-bottom: 8px;
- }
- .table-container::-webkit-scrollbar {
- height: 8px;
- }
- .table-container::-webkit-scrollbar-track {
- background: #f5f7f9;
- }
- .table-container::-webkit-scrollbar-thumb {
- background-color: #e0e0e0;
- border-radius: 4px;
- }
- .scroll-controls {
- display: flex;
- justify-content: flex-end;
- margin-bottom: 8px;
- gap: 8px;
- }
- .scroll-btn {
- display: flex;
- align-items: center;
- justify-content: center;
- width: 36px;
- height: 36px;
- background: white;
- border: 1px solid #e5e7eb;
- border-radius: 4px;
- cursor: pointer;
- box-shadow: 0 1px 2px rgba(0,0,0,0.05);
- transition: all 0.2s;
- }
- .scroll-btn:hover {
- background-color: #f9fafb;
- border-color: #d1d5db;
- }
- .scroll-btn:disabled {
- opacity: 0.5;
- cursor: not-allowed;
- }
- table {
- width: 100%;
- border-collapse: separate;
- border-spacing: 0;
- table-layout: fixed;
- }
- th {
- white-space: nowrap;
- position: relative;
- overflow: visible;
- max-width: none;
- text-overflow: clip;
- white-space: nowrap;
- position: relative;
- background-color: #f9fafb;
- padding: 12px;
- text-align: center;
- font-weight: 500;
- font-size: 14px;
- color: #6b7280;
- border-bottom: 1px solid #e5e7eb;
- white-space: nowrap;
- min-width: 120px;
- position: sticky;
- top: 0;
- z-index: 10;
- box-shadow: 0 1px 2px rgba(0,0,0,0.05);
- border-right: 1px solid #f0f0f0;
- }
- /* 稍微调整列宽 */
- th:nth-child(1), td:nth-child(1) { min-width: 140px; width: 140px; } /* 农机编号 */
- th:nth-child(2), td:nth-child(2) { min-width: 180px; width: 180px; } /* 农机名称 */
- th:nth-child(3), td:nth-child(3) { min-width: 140px; width: 140px; } /* 所属农场 */
- th:nth-child(4), td:nth-child(4) { min-width: 100px; width: 100px; } /* 所属区域 */
- th:nth-child(5), td:nth-child(5) { min-width: 100px; width: 100px; } /* 类型 */
- th:nth-child(6), td:nth-child(6) { min-width: 100px; width: 100px; } /* 厂家 */
- th:nth-child(7), td:nth-child(7) { min-width: 100px; width: 100px; } /* 型号 */
- th:nth-child(8), td:nth-child(8) { min-width: 100px; width: 100px; } /* 在线状态 */
- th:nth-child(9), td:nth-child(9) { min-width: 100px; width: 100px; } /* 当前状态 */
- th:nth-child(10), td:nth-child(10) { min-width: 140px; width: 140px; } /* 当前任务 */
- th:nth-child(11), td:nth-child(11) { min-width: 140px; width: 140px; } /* 当前地块 */
- th:nth-child(12), td:nth-child(12) { min-width: 100px; width: 100px; } /* 负责人 */
- th:nth-child(13), td:nth-child(13) { min-width: 120px; width: 120px; } /* 启用时间 */
- th:nth-child(14), td:nth-child(14) { min-width: 120px; width: 120px; } /* 生产日期 */
- th:nth-child(15), td:nth-child(15) { min-width: 100px; width: 100px; } /* 保养状态 */
- th:nth-child(16), td:nth-child(16) { min-width: 100px; width: 100px; } /* 定位状态 */
- th:nth-child(17), td:nth-child(17) { min-width: 80px; width: 80px; } /* 报警次数 */
- th:nth-child(18), td:nth-child(18) { min-width: 100px; width: 100px; } /* 操作 */
- th:first-child {
- position: sticky;
- left: 0;
- z-index: 20;
- border-right: 1px solid #e5e7eb;
- text-align: left;
- background-color: #f1f5f9;
- }
-
- th:last-child {
- position: sticky;
- right: 0;
- z-index: 20;
- border-left: 1px solid #e5e7eb;
- text-align: center;
- background-color: #f1f5f9;
- }
- td {
- white-space: nowrap;
- max-width: 200px;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- max-width: 200px;
- overflow: hidden;
- text-overflow: ellipsis;
- padding: 12px;
- border-bottom: 1px solid #e5e7eb;
- white-space: nowrap;
- text-align: center;
- border-right: 1px solid #f0f0f0;
- }
- td:first-child {
- position: sticky;
- left: 0;
- background: white;
- z-index: 5;
- border-right: 1px solid #e5e7eb;
- text-align: left;
- font-weight: 500;
- }
-
- td:last-child {
- position: sticky;
- right: 0;
- background: white;
- z-index: 5;
- border-left: 1px solid #e5e7eb;
- text-align: center;
- min-width: 130px;
- width: 130px;
- box-shadow: -2px 0 4px rgba(0,0,0,0.05);
- }
- tr:hover td:first-child {
- background-color: #f3f4f6;
- }
-
- tr:hover td:last-child {
- background-color: #f3f4f6;
- }
- /* 按钮样式 */
- .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;
- position: relative;
- z-index: 10;
- }
- .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-icon {
- margin-right: 4px;
- }
- .btn-sm {
- padding: 5px 10px;
- font-size: 12px;
- border-radius: 4px;
- transition: all 0.2s;
- }
- .view-btn {
- background-color: #e6f7ff;
- color: #1890ff;
- border: 1px solid #91d5ff;
- }
-
- .view-btn:hover {
- background-color: #bae7ff;
- }
-
- .edit-btn {
- background-color: #f6ffed;
- color: #52c41a;
- border: 1px solid #b7eb8f;
- }
-
- .edit-btn:hover {
- background-color: #d9f7be;
- }
- /* 表单控件样式 */
- .form-control {
- display: block;
- width: 100%;
- padding: 8px 12px;
- font-size: 14px;
- line-height: 1.5;
- color: #374151;
- background-color: #fff;
- border: 1px solid #d1d5db;
- border-radius: 4px;
- transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
- }
- .form-control:focus {
- border-color: #4CAF50;
- outline: 0;
- box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.1);
- }
- /* 搜索框样式 */
- .search-input {
- min-width: 280px;
- padding: 8px 12px;
- padding-right: 36px;
- border: 2px solid #e5e7eb;
- border-radius: 6px;
- transition: all 0.2s;
- }
- .search-input:focus {
- outline: none;
- border-color: #4CAF50;
- box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.1);
- }
- .search-input::placeholder {
- color: #9ca3af;
- }
- /* 状态标签样式 */
- .badge {
- display: inline-block;
- padding: 4px 8px;
- border-radius: 12px;
- font-size: 12px;
- font-weight: 500;
- min-width: 60px;
- }
- .badge-success {
- background-color: #d1fae5;
- color: #065f46;
- }
- .badge-warning {
- background-color: #fef3c7;
- color: #92400e;
- }
- .badge-danger {
- background-color: #fee2e2;
- color: #b91c1c;
- }
- .badge-info {
- background-color: #e0f2fe;
- color: #0369a1;
- }
- /* 表单组样式 */
- .form-group {
- margin-bottom: 16px;
- }
- .form-label {
- display: block;
- margin-bottom: 4px;
- font-size: 14px;
- color: #4b5563;
- }
- /* 分页样式 */
- .pagination {
- display: flex;
- align-items: center;
- gap: 8px;
- }
- .page-item {
- display: inline-flex;
- align-items: center;
- justify-content: center;
- min-width: 32px;
- height: 32px;
- padding: 0 8px;
- border-radius: 4px;
- background-color: #fff;
- border: 1px solid #d1d5db;
- color: #374151;
- font-size: 14px;
- cursor: pointer;
- transition: all 0.2s;
- }
- .page-item:hover {
- background-color: #f9fafb;
- }
- .page-item.active {
- background-color: #4CAF50;
- border-color: #4CAF50;
- color: #fff;
- }
- .page-item.disabled {
- opacity: 0.5;
- cursor: not-allowed;
- }
- </style>
- </head>
- <body>
- <div class="page-container">
- <!-- 页面标题和操作按钮 -->
- <div class="page-header">
- <h1 class="text-2xl font-bold">农机管理</h1>
- <div class="flex gap-2">
- <button class="btn btn-primary" id="addMachineBtn">
- <i class="iconfont icon-plus btn-icon"></i>
- 添加农机
- </button>
- <button class="btn btn-default" id="refreshBtn">
- <i class="iconfont icon-reload btn-icon"></i>
- 刷新
- </button>
- </div>
- </div>
- <!-- 搜索和筛选区域 -->
- <div class="card mb-6 p-4">
- <div class="grid grid-cols-1 md:grid-cols-4 gap-4">
- <div class="relative">
- <input type="text" class="search-input w-full" id="searchInput" placeholder="搜索农机编号/名称">
- <i class="iconfont icon-search absolute right-3 top-1/2 -translate-y-1/2 text-gray-400"></i>
- </div>
- <div>
- <select class="form-control" id="machineTypeFilter">
- <option value="">全部类型</option>
- <option value="tractor">拖拉机</option>
- <option value="harvester">收割机</option>
- <option value="seeder">播种机</option>
- <option value="sprayer">喷雾机</option>
- <option value="other">其他</option>
- </select>
- </div>
- <div>
- <select class="form-control" id="statusFilter">
- <option value="">全部状态</option>
- <option value="online">在线</option>
- <option value="offline">离线</option>
- <option value="maintenance">维护中</option>
- <option value="fault">故障</option>
- </select>
- </div>
- <div>
- <select class="form-control" id="farmFilter">
- <option value="">全部农场</option>
- <option value="farm1">智慧农场一号</option>
- <option value="farm2">智慧农场二号</option>
- <option value="farm3">智慧农场三号</option>
- </select>
- </div>
- </div>
- </div>
- <!-- 农机列表 -->
- <div class="card">
- <div class="scroll-controls">
- <button type="button" class="scroll-btn" id="scrollLeftBtn" disabled>
- <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
- <path d="M15 18l-6-6 6-6"/>
- </svg>
- </button>
- <button type="button" class="scroll-btn" id="scrollRightBtn">
- <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
- <path d="M9 18l6-6-6-6"/>
- </svg>
- </button>
- </div>
- <div class="table-container" id="tableContainer">
- <table class="table-fixed-right table-fixed-right table-fixed-right">
- <thead>
- <tr>
- <th>农机编号</th>
- <th>农机名称</th>
- <th class="min-w-[120px]">所属农场</th>
- <th class="min-w-[100px]">所属区域</th>
- <th>类型</th>
- <th class="min-w-[100px]">厂家</th>
- <th>型号</th>
- <th>在线状态</th>
- <th>当前状态</th>
- <th>当前任务</th>
- <th>当前地块</th>
- <th class="min-w-[100px]">负责人</th>
- <th>启用时间</th>
- <th>生产日期</th>
- <th>保养状态</th>
- <th>定位状态</th>
- <th>报警次数</th>
- <th class="min-w-[150px]">操作</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>M20230001</td>
- <td>
- <div class="flex items-center">
- <img src="../assets/images/tractor.png" alt="拖拉机" class="w-10 h-10 mr-3 rounded-md object-cover">
- <div>
- <div class="font-medium">东方红-LX1000</div>
- <div class="text-xs text-gray-500">拖拉机</div>
- </div>
- </div>
- </td>
- <td>智慧农场一号</td>
- <td>东区</td>
- <td>拖拉机</td>
- <td>东方红</td>
- <td>LX1000</td>
- <td><span class="badge badge-success">在线</span></td>
- <td><span class="badge badge-info">作业中</span></td>
- <td>稻田耕种</td>
- <td>东区A-12</td>
- <td>张三</td>
- <td>2023-01-15</td>
- <td>2022-12-10</td>
- <td><span class="badge badge-success">正常</span></td>
- <td><span class="badge badge-success">良好</span></td>
- <td>0</td>
- <td>
- <div class="flex gap-2 justify-center">
- <button class="btn btn-sm view-btn" data-id="M20230001">
- <i class="iconfont icon-eye"></i>
- 管理
- </button>
- <button class="btn btn-sm edit-btn" data-id="M20230001">
- <i class="iconfont icon-edit"></i>
- 编辑
- </button>
- </div>
- </td>
- </tr>
- <tr>
- <td>M20230002</td>
- <td>
- <div class="flex items-center">
- <img src="../assets/images/harvester.png" alt="收割机" class="w-10 h-10 mr-3 rounded-md object-cover">
- <div>
- <div class="font-medium">雷沃-GE70</div>
- <div class="text-xs text-gray-500">收割机</div>
- </div>
- </div>
- </td>
- <td>智慧农场二号</td>
- <td>西区</td>
- <td>收割机</td>
- <td>雷沃</td>
- <td>GE70</td>
- <td><span class="badge badge-warning">离线</span></td>
- <td><span class="badge badge-warning">维护中</span></td>
- <td>-</td>
- <td>-</td>
- <td>李四</td>
- <td>2023-02-20</td>
- <td>2022-11-25</td>
- <td><span class="badge badge-warning">需保养</span></td>
- <td><span class="badge badge-warning">异常</span></td>
- <td>2</td>
- <td>
- <div class="flex gap-2 justify-center">
- <button class="btn btn-sm view-btn" data-id="M20230002">
- <i class="iconfont icon-eye"></i>
- 管理
- </button>
- <button class="btn btn-sm edit-btn" data-id="M20230002">
- <i class="iconfont icon-edit"></i>
- 编辑
- </button>
- </div>
- </td>
- </tr>
- <tr>
- <td>M20230003</td>
- <td>
- <div class="flex items-center">
- <img src="../assets/images/sprayer.png" alt="喷雾机" class="w-10 h-10 mr-3 rounded-md object-cover">
- <div>
- <div class="font-medium">科乐收-KS2000</div>
- <div class="text-xs text-gray-500">喷雾机</div>
- </div>
- </div>
- </td>
- <td>智慧农场一号</td>
- <td>南区</td>
- <td>喷雾机</td>
- <td>科乐收</td>
- <td>KS2000</td>
- <td><span class="badge badge-danger">离线</span></td>
- <td><span class="badge badge-danger">故障</span></td>
- <td>-</td>
- <td>-</td>
- <td>王五</td>
- <td>2023-03-10</td>
- <td>2023-01-05</td>
- <td><span class="badge badge-danger">待修复</span></td>
- <td><span class="badge badge-danger">无信号</span></td>
- <td>5</td>
- <td>
- <div class="flex gap-2 justify-center">
- <button class="btn btn-sm view-btn" data-id="M20230003">
- <i class="iconfont icon-eye"></i>
- 管理
- </button>
- <button class="btn btn-sm edit-btn" data-id="M20230003">
- <i class="iconfont icon-edit"></i>
- 编辑
- </button>
- </div>
- </td>
- </tr>
- <tr>
- <td>M20230004</td>
- <td>
- <div class="flex items-center">
- <img src="../assets/images/tractor.png" alt="拖拉机" class="w-10 h-10 mr-3 rounded-md object-cover">
- <div>
- <div class="font-medium">约翰迪尔-8R</div>
- <div class="text-xs text-gray-500">拖拉机</div>
- </div>
- </div>
- </td>
- <td>智慧农场三号</td>
- <td>北区</td>
- <td>拖拉机</td>
- <td>约翰迪尔</td>
- <td>8R</td>
- <td><span class="badge badge-success">在线</span></td>
- <td><span class="badge badge-success">待命</span></td>
- <td>-</td>
- <td>-</td>
- <td>赵六</td>
- <td>2023-04-05</td>
- <td>2023-02-15</td>
- <td><span class="badge badge-success">正常</span></td>
- <td><span class="badge badge-success">良好</span></td>
- <td>0</td>
- <td>
- <div class="flex gap-2 justify-center">
- <button class="btn btn-sm view-btn" data-id="M20230004">
- <i class="iconfont icon-eye"></i>
- 管理
- </button>
- <button class="btn btn-sm edit-btn" data-id="M20230004">
- <i class="iconfont icon-edit"></i>
- 编辑
- </button>
- </div>
- </td>
- </tr>
- <tr>
- <td>M20230005</td>
- <td>
- <div class="flex items-center">
- <img src="../assets/images/seeder.png" alt="播种机" class="w-10 h-10 mr-3 rounded-md object-cover">
- <div>
- <div class="font-medium">克拉斯-C600</div>
- <div class="text-xs text-gray-500">播种机</div>
- </div>
- </div>
- </td>
- <td>智慧农场二号</td>
- <td>中区</td>
- <td>播种机</td>
- <td>克拉斯</td>
- <td>C600</td>
- <td><span class="badge badge-success">在线</span></td>
- <td><span class="badge badge-info">作业中</span></td>
- <td>小麦播种</td>
- <td>中区B-08</td>
- <td>马七</td>
- <td>2023-05-20</td>
- <td>2023-03-10</td>
- <td><span class="badge badge-success">正常</span></td>
- <td><span class="badge badge-success">良好</span></td>
- <td>1</td>
- <td>
- <div class="flex gap-2 justify-center">
- <button class="btn btn-sm view-btn" data-id="M20230005">
- <i class="iconfont icon-eye"></i>
- 管理
- </button>
- <button class="btn btn-sm edit-btn" data-id="M20230005">
- <i class="iconfont icon-edit"></i>
- 编辑
- </button>
- </div>
- </td>
- </tr>
- </tbody>
- </table>
- </div>
- <!-- 分页 -->
- <div class="flex justify-between items-center p-4 border-t border-gray-200">
- <div class="text-sm text-gray-600">
- 共 <span class="text-primary font-medium">24</span> 条记录
- </div>
- <div class="pagination">
- <button class="page-item disabled">上一页</button>
- <button class="page-item active">1</button>
- <button class="page-item">2</button>
- <button class="page-item">3</button>
- <button class="page-item">下一页</button>
- </div>
- </div>
- </div>
- </div>
- <!-- 添加/编辑农机模态框 -->
- <div class="modal" id="machineModal">
- <div class="modal-dialog">
- <div class="modal-content">
- <div class="modal-header">
- <h5 class="modal-title" id="modalTitle">添加农机</h5>
- <button type="button" class="modal-close" id="closeModal">
- <i class="iconfont icon-close"></i>
- </button>
- </div>
- <div class="modal-body">
- <form id="machineForm">
- <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
- <div class="form-group">
- <label class="form-label" for="machineCode">农机编号</label>
- <input type="text" class="form-control" id="machineCode" placeholder="请输入农机编号">
- </div>
- <div class="form-group">
- <label class="form-label" for="machineName">农机名称</label>
- <input type="text" class="form-control" id="machineName" placeholder="请输入农机名称">
- </div>
- <div class="form-group">
- <label class="form-label" for="machineType">农机类型</label>
- <select class="form-control" id="machineType">
- <option value="">请选择农机类型</option>
- <option value="tractor">拖拉机</option>
- <option value="harvester">收割机</option>
- <option value="seeder">播种机</option>
- <option value="sprayer">喷雾机</option>
- <option value="other">其他</option>
- </select>
- </div>
- <div class="form-group">
- <label class="form-label" for="machineModel">农机型号</label>
- <input type="text" class="form-control" id="machineModel" placeholder="请输入农机型号">
- </div>
- <div class="form-group">
- <label class="form-label" for="machineFarm">所属农场</label>
- <select class="form-control" id="machineFarm">
- <option value="">请选择所属农场</option>
- <option value="farm1">智慧农场一号</option>
- <option value="farm2">智慧农场二号</option>
- <option value="farm3">智慧农场三号</option>
- </select>
- </div>
- <div class="form-group">
- <label class="form-label" for="machineManager">负责人</label>
- <select class="form-control" id="machineManager">
- <option value="">请选择负责人</option>
- <option value="user1">张三</option>
- <option value="user2">李四</option>
- <option value="user3">王五</option>
- </select>
- </div>
- <div class="form-group">
- <label class="form-label" for="machineStatus">使用状态</label>
- <select class="form-control" id="machineStatus">
- <option value="online">在线</option>
- <option value="offline">离线</option>
- <option value="maintenance">维护中</option>
- <option value="fault">故障</option>
- </select>
- </div>
- <div class="form-group">
- <label class="form-label" for="purchaseDate">购买日期</label>
- <input type="date" class="form-control" id="purchaseDate">
- </div>
- </div>
- <div class="form-group">
- <label class="form-label" for="machineDesc">农机描述</label>
- <textarea class="form-control" id="machineDesc" rows="4" placeholder="请输入农机描述信息"></textarea>
- </div>
- </form>
- </div>
- <div class="modal-footer">
- <button type="button" class="btn btn-default" id="cancelBtn">取消</button>
- <button type="button" class="btn btn-primary" id="saveBtn">保存</button>
- </div>
- </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(); document.addEventListener('DOMContentLoaded', function() {
- // 获取元素
- const addMachineBtn = document.getElementById('addMachineBtn');
- const refreshBtn = document.getElementById('refreshBtn');
- const machineModal = document.getElementById('machineModal');
- const closeModal = document.getElementById('closeModal');
- const cancelBtn = document.getElementById('cancelBtn');
- const saveBtn = document.getElementById('saveBtn');
- const modalTitle = document.getElementById('modalTitle');
- const machineForm = document.getElementById('machineForm');
- const editBtns = document.querySelectorAll('.edit-btn');
- const viewBtns = document.querySelectorAll('.view-btn');
-
- // 表格滚动控制
- const tableContainer = document.getElementById('tableContainer');
- const scrollLeftBtn = document.getElementById('scrollLeftBtn');
- const scrollRightBtn = document.getElementById('scrollRightBtn');
-
- // 滚动按钮事件
- scrollLeftBtn.addEventListener('click', function() {
- tableContainer.scrollLeft -= 300;
- });
-
- scrollRightBtn.addEventListener('click', function() {
- tableContainer.scrollLeft += 300;
- });
-
- // 监听滚动事件更新按钮状态
- tableContainer.addEventListener('scroll', function() {
- // 更新左右滚动按钮状态
- scrollLeftBtn.disabled = tableContainer.scrollLeft <= 0;
- scrollRightBtn.disabled = tableContainer.scrollLeft + tableContainer.clientWidth >= tableContainer.scrollWidth;
- });
-
- // 初始化滚动按钮状态
- function updateScrollButtons() {
- scrollLeftBtn.disabled = tableContainer.scrollLeft <= 0;
- scrollRightBtn.disabled = tableContainer.scrollLeft + tableContainer.clientWidth >= tableContainer.scrollWidth;
- }
-
- // 页面加载和窗口大小变化时更新按钮状态
- window.addEventListener('resize', updateScrollButtons);
- updateScrollButtons();
- // 打开添加农机模态框
- addMachineBtn.addEventListener('click', function() {
- modalTitle.textContent = '添加农机';
- machineForm.reset();
- machineModal.classList.add('show');
- });
- // 关闭模态框
- function closeModalFunc() {
- machineModal.classList.remove('show');
- }
- closeModal.addEventListener('click', closeModalFunc);
- cancelBtn.addEventListener('click', closeModalFunc);
- // 编辑按钮点击事件
- editBtns.forEach(btn => {
- btn.addEventListener('click', function() {
- const machineId = this.getAttribute('data-id');
- modalTitle.textContent = '编辑农机';
- // 这里应该根据ID获取农机信息并填充表单
- // 模拟填充表单
- document.getElementById('machineCode').value = machineId;
- document.getElementById('machineName').value = this.closest('tr').querySelector('.font-medium').textContent;
- document.getElementById('machineType').value = this.closest('tr').cells[2].textContent.toLowerCase();
- document.getElementById('machineFarm').value = 'farm1';
- document.getElementById('machineManager').value = 'user1';
- document.getElementById('machineStatus').value = 'online';
-
- machineModal.classList.add('show');
- });
- });
- // 查看按钮点击事件
- viewBtns.forEach(btn => {
- btn.addEventListener('click', function() {
- const machineId = this.getAttribute('data-id');
- // 跳转到农机详情页
- window.location.href = `machine-detail.html?id=${machineId}`;
- });
- });
- // 保存按钮点击事件
- saveBtn.addEventListener('click', function() {
- // 模拟保存操作
- alert('保存成功!');
- closeModalFunc();
- });
- // 刷新按钮点击事件
- refreshBtn.addEventListener('click', function() {
- // 模拟刷新操作
- alert('数据已刷新!');
- });
- });
- </script>
- </body>
- </html>
|