machine-management-content.html 44 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  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. :root {
  12. --primary: #4CAF50;
  13. --primary-dark: #388E3C;
  14. --primary-light: #A5D6A7;
  15. --primary-bg: #F1F8E9;
  16. --success: #4CAF50;
  17. --warning: #FFC107;
  18. --danger: #F44336;
  19. --info: #2196F3;
  20. --disabled: #9E9E9E;
  21. --border: #E0E0E0;
  22. --text-primary: #212121;
  23. --text-secondary: #757575;
  24. --radius: 8px;
  25. }
  26. /* 全局样式重置 */
  27. * {
  28. margin: 0;
  29. padding: 0;
  30. box-sizing: border-box;
  31. }
  32. /* 移除所有固定定位和绝对定位元素 */
  33. .fixed,
  34. .absolute,
  35. [style*="position: fixed"],
  36. [style*="position: absolute"] {
  37. display: none !important;
  38. }
  39. /* 移除所有圆形按钮和浮动元素 */
  40. .circle,
  41. .rounded-full,
  42. .floating,
  43. [class*="circle"],
  44. [class*="round"],
  45. [class*="float"] {
  46. display: none !important;
  47. }
  48. /* 确保内容不会溢出 */
  49. html, body {
  50. overflow-x: hidden;
  51. position: relative;
  52. }
  53. /* 移除所有可能的遮罩层 */
  54. [class*="overlay"],
  55. [class*="mask"],
  56. [style*="z-index: 9999"] {
  57. display: none !important;
  58. }
  59. /* 重置默认样式 */
  60. html, body {
  61. margin: 0;
  62. padding: 0;
  63. font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  64. height: 100%;
  65. position: relative;
  66. }
  67. body {
  68. background-color: #f5f7f9;
  69. color: var(--text-primary);
  70. overflow-x: hidden;
  71. padding-top: 70px;
  72. }
  73. /* 防止重复菜单 - 修改选择器避免影响按钮和模态框 */
  74. body > div:not(.page-container):not(.modal):not(#machineModal),
  75. iframe#sidebar,
  76. div.system-menu,
  77. [id^="system-menu"],
  78. [class^="system-menu"],
  79. #admin-sidebar,
  80. .menu-popup,
  81. .user-avatar-circle {
  82. display: none !important;
  83. }
  84. /* 移除可能影响按钮和模态框的全局样式 */
  85. .circle-btn,
  86. .floating-circle,
  87. .round-button,
  88. .scroll-top-btn,
  89. .help-btn,
  90. .chat-btn {
  91. display: none !important;
  92. }
  93. /* 模态框样式 */
  94. .modal {
  95. display: none;
  96. position: fixed;
  97. top: 0;
  98. left: 0;
  99. right: 0;
  100. bottom: 0;
  101. width: 100%;
  102. height: 100%;
  103. background-color: rgba(0, 0, 0, 0.5);
  104. z-index: 99999;
  105. opacity: 0;
  106. visibility: hidden;
  107. transition: opacity 0.3s ease, visibility 0.3s ease;
  108. }
  109. .modal.show {
  110. display: block !important;
  111. opacity: 1 !important;
  112. visibility: visible !important;
  113. }
  114. .modal-dialog {
  115. position: fixed;
  116. top: 50%;
  117. left: 50%;
  118. transform: translate(-50%, -50%);
  119. width: 90%;
  120. max-width: 800px;
  121. margin-top: 20px;
  122. background: #fff;
  123. border-radius: 8px;
  124. z-index: 100000;
  125. box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  126. }
  127. .modal-content {
  128. background: #fff;
  129. border-radius: 8px;
  130. overflow: hidden;
  131. position: relative;
  132. }
  133. .modal-header {
  134. padding: 16px 24px;
  135. border-bottom: 1px solid #e0e0e0;
  136. display: flex;
  137. align-items: center;
  138. justify-content: space-between;
  139. background: #fff;
  140. position: sticky;
  141. top: 0;
  142. z-index: 1;
  143. }
  144. .modal-close {
  145. padding: 8px;
  146. background: none;
  147. border: none;
  148. cursor: pointer;
  149. font-size: 20px;
  150. color: #666;
  151. display: flex;
  152. align-items: center;
  153. justify-content: center;
  154. border-radius: 4px;
  155. transition: all 0.3s;
  156. }
  157. .modal-close:hover {
  158. background-color: rgba(0, 0, 0, 0.05);
  159. color: #333;
  160. }
  161. .modal-title {
  162. font-size: 18px;
  163. font-weight: 500;
  164. color: #333;
  165. margin: 0;
  166. }
  167. .modal-body {
  168. padding: 24px;
  169. max-height: calc(100vh - 200px);
  170. overflow-y: auto;
  171. background: #fff;
  172. }
  173. .modal-footer {
  174. padding: 16px 24px;
  175. border-top: 1px solid #e0e0e0;
  176. display: flex;
  177. justify-content: flex-end;
  178. gap: 12px;
  179. background: #fff;
  180. }
  181. /* 页面容器 */
  182. .page-container {
  183. padding: 20px;
  184. max-width: 1600px;
  185. margin: 0 auto;
  186. margin-top: 60px;
  187. position: relative;
  188. z-index: 1;
  189. }
  190. /* 页面标题和操作按钮容器 */
  191. .page-header {
  192. display: flex;
  193. justify-content: space-between;
  194. align-items: center;
  195. margin-bottom: 20px;
  196. position: relative;
  197. z-index: 5;
  198. }
  199. /* 卡片样式 */
  200. .card {
  201. background-color: white;
  202. border-radius: 8px;
  203. box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  204. overflow: hidden;
  205. }
  206. /* 表格样式 */
  207. .table-container {
  208. position: relative;
  209. position: relative;
  210. overflow-x: auto;
  211. position: relative;
  212. scrollbar-width: thin;
  213. scrollbar-color: #e0e0e0 #f5f7f9;
  214. padding-bottom: 8px;
  215. }
  216. .table-container::-webkit-scrollbar {
  217. height: 8px;
  218. }
  219. .table-container::-webkit-scrollbar-track {
  220. background: #f5f7f9;
  221. }
  222. .table-container::-webkit-scrollbar-thumb {
  223. background-color: #e0e0e0;
  224. border-radius: 4px;
  225. }
  226. .scroll-controls {
  227. display: flex;
  228. justify-content: flex-end;
  229. margin-bottom: 8px;
  230. gap: 8px;
  231. }
  232. .scroll-btn {
  233. display: flex;
  234. align-items: center;
  235. justify-content: center;
  236. width: 36px;
  237. height: 36px;
  238. background: white;
  239. border: 1px solid #e5e7eb;
  240. border-radius: 4px;
  241. cursor: pointer;
  242. box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  243. transition: all 0.2s;
  244. }
  245. .scroll-btn:hover {
  246. background-color: #f9fafb;
  247. border-color: #d1d5db;
  248. }
  249. .scroll-btn:disabled {
  250. opacity: 0.5;
  251. cursor: not-allowed;
  252. }
  253. table {
  254. width: 100%;
  255. border-collapse: separate;
  256. border-spacing: 0;
  257. table-layout: fixed;
  258. }
  259. th {
  260. white-space: nowrap;
  261. position: relative;
  262. overflow: visible;
  263. max-width: none;
  264. text-overflow: clip;
  265. white-space: nowrap;
  266. position: relative;
  267. background-color: #f9fafb;
  268. padding: 12px;
  269. text-align: center;
  270. font-weight: 500;
  271. font-size: 14px;
  272. color: #6b7280;
  273. border-bottom: 1px solid #e5e7eb;
  274. white-space: nowrap;
  275. min-width: 120px;
  276. position: sticky;
  277. top: 0;
  278. z-index: 10;
  279. box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  280. border-right: 1px solid #f0f0f0;
  281. }
  282. /* 稍微调整列宽 */
  283. th:nth-child(1), td:nth-child(1) { min-width: 140px; width: 140px; } /* 农机编号 */
  284. th:nth-child(2), td:nth-child(2) { min-width: 180px; width: 180px; } /* 农机名称 */
  285. th:nth-child(3), td:nth-child(3) { min-width: 140px; width: 140px; } /* 所属农场 */
  286. th:nth-child(4), td:nth-child(4) { min-width: 100px; width: 100px; } /* 所属区域 */
  287. th:nth-child(5), td:nth-child(5) { min-width: 100px; width: 100px; } /* 类型 */
  288. th:nth-child(6), td:nth-child(6) { min-width: 100px; width: 100px; } /* 厂家 */
  289. th:nth-child(7), td:nth-child(7) { min-width: 100px; width: 100px; } /* 型号 */
  290. th:nth-child(8), td:nth-child(8) { min-width: 100px; width: 100px; } /* 在线状态 */
  291. th:nth-child(9), td:nth-child(9) { min-width: 100px; width: 100px; } /* 当前状态 */
  292. th:nth-child(10), td:nth-child(10) { min-width: 140px; width: 140px; } /* 当前任务 */
  293. th:nth-child(11), td:nth-child(11) { min-width: 140px; width: 140px; } /* 当前地块 */
  294. th:nth-child(12), td:nth-child(12) { min-width: 100px; width: 100px; } /* 负责人 */
  295. th:nth-child(13), td:nth-child(13) { min-width: 120px; width: 120px; } /* 启用时间 */
  296. th:nth-child(14), td:nth-child(14) { min-width: 120px; width: 120px; } /* 生产日期 */
  297. th:nth-child(15), td:nth-child(15) { min-width: 100px; width: 100px; } /* 保养状态 */
  298. th:nth-child(16), td:nth-child(16) { min-width: 100px; width: 100px; } /* 定位状态 */
  299. th:nth-child(17), td:nth-child(17) { min-width: 80px; width: 80px; } /* 报警次数 */
  300. th:nth-child(18), td:nth-child(18) { min-width: 100px; width: 100px; } /* 操作 */
  301. th:first-child {
  302. position: sticky;
  303. left: 0;
  304. z-index: 20;
  305. border-right: 1px solid #e5e7eb;
  306. text-align: left;
  307. background-color: #f1f5f9;
  308. }
  309. th:last-child {
  310. position: sticky;
  311. right: 0;
  312. z-index: 20;
  313. border-left: 1px solid #e5e7eb;
  314. text-align: center;
  315. background-color: #f1f5f9;
  316. }
  317. td {
  318. white-space: nowrap;
  319. max-width: 200px;
  320. overflow: hidden;
  321. text-overflow: ellipsis;
  322. white-space: nowrap;
  323. max-width: 200px;
  324. overflow: hidden;
  325. text-overflow: ellipsis;
  326. padding: 12px;
  327. border-bottom: 1px solid #e5e7eb;
  328. white-space: nowrap;
  329. text-align: center;
  330. border-right: 1px solid #f0f0f0;
  331. }
  332. td:first-child {
  333. position: sticky;
  334. left: 0;
  335. background: white;
  336. z-index: 5;
  337. border-right: 1px solid #e5e7eb;
  338. text-align: left;
  339. font-weight: 500;
  340. }
  341. td:last-child {
  342. position: sticky;
  343. right: 0;
  344. background: white;
  345. z-index: 5;
  346. border-left: 1px solid #e5e7eb;
  347. text-align: center;
  348. min-width: 130px;
  349. width: 130px;
  350. box-shadow: -2px 0 4px rgba(0,0,0,0.05);
  351. }
  352. tr:hover td:first-child {
  353. background-color: #f3f4f6;
  354. }
  355. tr:hover td:last-child {
  356. background-color: #f3f4f6;
  357. }
  358. /* 按钮样式 */
  359. .btn {
  360. display: inline-flex;
  361. align-items: center;
  362. justify-content: center;
  363. padding: 8px 16px;
  364. border-radius: 4px;
  365. font-weight: 500;
  366. cursor: pointer;
  367. transition: all 0.2s;
  368. position: relative;
  369. z-index: 10;
  370. }
  371. .btn-primary {
  372. background-color: #4CAF50;
  373. color: white;
  374. }
  375. .btn-primary:hover {
  376. background-color: #388E3C;
  377. }
  378. .btn-default {
  379. background-color: white;
  380. border: 1px solid #d1d5db;
  381. color: #374151;
  382. }
  383. .btn-default:hover {
  384. background-color: #f9fafb;
  385. }
  386. .btn-danger {
  387. background-color: #ef4444;
  388. color: white;
  389. }
  390. .btn-danger:hover {
  391. background-color: #dc2626;
  392. }
  393. .btn-icon {
  394. margin-right: 4px;
  395. }
  396. .btn-sm {
  397. padding: 5px 10px;
  398. font-size: 12px;
  399. border-radius: 4px;
  400. transition: all 0.2s;
  401. }
  402. .view-btn {
  403. background-color: #e6f7ff;
  404. color: #1890ff;
  405. border: 1px solid #91d5ff;
  406. }
  407. .view-btn:hover {
  408. background-color: #bae7ff;
  409. }
  410. .edit-btn {
  411. background-color: #f6ffed;
  412. color: #52c41a;
  413. border: 1px solid #b7eb8f;
  414. }
  415. .edit-btn:hover {
  416. background-color: #d9f7be;
  417. }
  418. /* 表单控件样式 */
  419. .form-control {
  420. display: block;
  421. width: 100%;
  422. padding: 8px 12px;
  423. font-size: 14px;
  424. line-height: 1.5;
  425. color: #374151;
  426. background-color: #fff;
  427. border: 1px solid #d1d5db;
  428. border-radius: 4px;
  429. transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
  430. }
  431. .form-control:focus {
  432. border-color: #4CAF50;
  433. outline: 0;
  434. box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.1);
  435. }
  436. /* 搜索框样式 */
  437. .search-input {
  438. min-width: 280px;
  439. padding: 8px 12px;
  440. padding-right: 36px;
  441. border: 2px solid #e5e7eb;
  442. border-radius: 6px;
  443. transition: all 0.2s;
  444. }
  445. .search-input:focus {
  446. outline: none;
  447. border-color: #4CAF50;
  448. box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.1);
  449. }
  450. .search-input::placeholder {
  451. color: #9ca3af;
  452. }
  453. /* 状态标签样式 */
  454. .badge {
  455. display: inline-block;
  456. padding: 4px 8px;
  457. border-radius: 12px;
  458. font-size: 12px;
  459. font-weight: 500;
  460. min-width: 60px;
  461. }
  462. .badge-success {
  463. background-color: #d1fae5;
  464. color: #065f46;
  465. }
  466. .badge-warning {
  467. background-color: #fef3c7;
  468. color: #92400e;
  469. }
  470. .badge-danger {
  471. background-color: #fee2e2;
  472. color: #b91c1c;
  473. }
  474. .badge-info {
  475. background-color: #e0f2fe;
  476. color: #0369a1;
  477. }
  478. /* 表单组样式 */
  479. .form-group {
  480. margin-bottom: 16px;
  481. }
  482. .form-label {
  483. display: block;
  484. margin-bottom: 4px;
  485. font-size: 14px;
  486. color: #4b5563;
  487. }
  488. /* 分页样式 */
  489. .pagination {
  490. display: flex;
  491. align-items: center;
  492. gap: 8px;
  493. }
  494. .page-item {
  495. display: inline-flex;
  496. align-items: center;
  497. justify-content: center;
  498. min-width: 32px;
  499. height: 32px;
  500. padding: 0 8px;
  501. border-radius: 4px;
  502. background-color: #fff;
  503. border: 1px solid #d1d5db;
  504. color: #374151;
  505. font-size: 14px;
  506. cursor: pointer;
  507. transition: all 0.2s;
  508. }
  509. .page-item:hover {
  510. background-color: #f9fafb;
  511. }
  512. .page-item.active {
  513. background-color: #4CAF50;
  514. border-color: #4CAF50;
  515. color: #fff;
  516. }
  517. .page-item.disabled {
  518. opacity: 0.5;
  519. cursor: not-allowed;
  520. }
  521. </style>
  522. </head>
  523. <body>
  524. <div class="page-container">
  525. <!-- 页面标题和操作按钮 -->
  526. <div class="page-header">
  527. <h1 class="text-2xl font-bold">农机管理</h1>
  528. <div class="flex gap-2">
  529. <button class="btn btn-primary" id="addMachineBtn">
  530. <i class="iconfont icon-plus btn-icon"></i>
  531. 添加农机
  532. </button>
  533. <button class="btn btn-default" id="refreshBtn">
  534. <i class="iconfont icon-reload btn-icon"></i>
  535. 刷新
  536. </button>
  537. </div>
  538. </div>
  539. <!-- 搜索和筛选区域 -->
  540. <div class="card mb-6 p-4">
  541. <div class="grid grid-cols-1 md:grid-cols-4 gap-4">
  542. <div class="relative">
  543. <input type="text" class="search-input w-full" id="searchInput" placeholder="搜索农机编号/名称">
  544. <i class="iconfont icon-search absolute right-3 top-1/2 -translate-y-1/2 text-gray-400"></i>
  545. </div>
  546. <div>
  547. <select class="form-control" id="machineTypeFilter">
  548. <option value="">全部类型</option>
  549. <option value="tractor">拖拉机</option>
  550. <option value="harvester">收割机</option>
  551. <option value="seeder">播种机</option>
  552. <option value="sprayer">喷雾机</option>
  553. <option value="other">其他</option>
  554. </select>
  555. </div>
  556. <div>
  557. <select class="form-control" id="statusFilter">
  558. <option value="">全部状态</option>
  559. <option value="online">在线</option>
  560. <option value="offline">离线</option>
  561. <option value="maintenance">维护中</option>
  562. <option value="fault">故障</option>
  563. </select>
  564. </div>
  565. <div>
  566. <select class="form-control" id="farmFilter">
  567. <option value="">全部农场</option>
  568. <option value="farm1">智慧农场一号</option>
  569. <option value="farm2">智慧农场二号</option>
  570. <option value="farm3">智慧农场三号</option>
  571. </select>
  572. </div>
  573. </div>
  574. </div>
  575. <!-- 农机列表 -->
  576. <div class="card">
  577. <div class="scroll-controls">
  578. <button type="button" class="scroll-btn" id="scrollLeftBtn" disabled>
  579. <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">
  580. <path d="M15 18l-6-6 6-6"/>
  581. </svg>
  582. </button>
  583. <button type="button" class="scroll-btn" id="scrollRightBtn">
  584. <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">
  585. <path d="M9 18l6-6-6-6"/>
  586. </svg>
  587. </button>
  588. </div>
  589. <div class="table-container" id="tableContainer">
  590. <table class="table-fixed-right table-fixed-right table-fixed-right">
  591. <thead>
  592. <tr>
  593. <th>农机编号</th>
  594. <th>农机名称</th>
  595. <th class="min-w-[120px]">所属农场</th>
  596. <th class="min-w-[100px]">所属区域</th>
  597. <th>类型</th>
  598. <th class="min-w-[100px]">厂家</th>
  599. <th>型号</th>
  600. <th>在线状态</th>
  601. <th>当前状态</th>
  602. <th>当前任务</th>
  603. <th>当前地块</th>
  604. <th class="min-w-[100px]">负责人</th>
  605. <th>启用时间</th>
  606. <th>生产日期</th>
  607. <th>保养状态</th>
  608. <th>定位状态</th>
  609. <th>报警次数</th>
  610. <th class="min-w-[150px]">操作</th>
  611. </tr>
  612. </thead>
  613. <tbody>
  614. <tr>
  615. <td>M20230001</td>
  616. <td>
  617. <div class="flex items-center">
  618. <img src="../assets/images/tractor.png" alt="拖拉机" class="w-10 h-10 mr-3 rounded-md object-cover">
  619. <div>
  620. <div class="font-medium">东方红-LX1000</div>
  621. <div class="text-xs text-gray-500">拖拉机</div>
  622. </div>
  623. </div>
  624. </td>
  625. <td>智慧农场一号</td>
  626. <td>东区</td>
  627. <td>拖拉机</td>
  628. <td>东方红</td>
  629. <td>LX1000</td>
  630. <td><span class="badge badge-success">在线</span></td>
  631. <td><span class="badge badge-info">作业中</span></td>
  632. <td>稻田耕种</td>
  633. <td>东区A-12</td>
  634. <td>张三</td>
  635. <td>2023-01-15</td>
  636. <td>2022-12-10</td>
  637. <td><span class="badge badge-success">正常</span></td>
  638. <td><span class="badge badge-success">良好</span></td>
  639. <td>0</td>
  640. <td>
  641. <div class="flex gap-2 justify-center">
  642. <button class="btn btn-sm view-btn" data-id="M20230001">
  643. <i class="iconfont icon-eye"></i>
  644. 管理
  645. </button>
  646. <button class="btn btn-sm edit-btn" data-id="M20230001">
  647. <i class="iconfont icon-edit"></i>
  648. 编辑
  649. </button>
  650. </div>
  651. </td>
  652. </tr>
  653. <tr>
  654. <td>M20230002</td>
  655. <td>
  656. <div class="flex items-center">
  657. <img src="../assets/images/harvester.png" alt="收割机" class="w-10 h-10 mr-3 rounded-md object-cover">
  658. <div>
  659. <div class="font-medium">雷沃-GE70</div>
  660. <div class="text-xs text-gray-500">收割机</div>
  661. </div>
  662. </div>
  663. </td>
  664. <td>智慧农场二号</td>
  665. <td>西区</td>
  666. <td>收割机</td>
  667. <td>雷沃</td>
  668. <td>GE70</td>
  669. <td><span class="badge badge-warning">离线</span></td>
  670. <td><span class="badge badge-warning">维护中</span></td>
  671. <td>-</td>
  672. <td>-</td>
  673. <td>李四</td>
  674. <td>2023-02-20</td>
  675. <td>2022-11-25</td>
  676. <td><span class="badge badge-warning">需保养</span></td>
  677. <td><span class="badge badge-warning">异常</span></td>
  678. <td>2</td>
  679. <td>
  680. <div class="flex gap-2 justify-center">
  681. <button class="btn btn-sm view-btn" data-id="M20230002">
  682. <i class="iconfont icon-eye"></i>
  683. 管理
  684. </button>
  685. <button class="btn btn-sm edit-btn" data-id="M20230002">
  686. <i class="iconfont icon-edit"></i>
  687. 编辑
  688. </button>
  689. </div>
  690. </td>
  691. </tr>
  692. <tr>
  693. <td>M20230003</td>
  694. <td>
  695. <div class="flex items-center">
  696. <img src="../assets/images/sprayer.png" alt="喷雾机" class="w-10 h-10 mr-3 rounded-md object-cover">
  697. <div>
  698. <div class="font-medium">科乐收-KS2000</div>
  699. <div class="text-xs text-gray-500">喷雾机</div>
  700. </div>
  701. </div>
  702. </td>
  703. <td>智慧农场一号</td>
  704. <td>南区</td>
  705. <td>喷雾机</td>
  706. <td>科乐收</td>
  707. <td>KS2000</td>
  708. <td><span class="badge badge-danger">离线</span></td>
  709. <td><span class="badge badge-danger">故障</span></td>
  710. <td>-</td>
  711. <td>-</td>
  712. <td>王五</td>
  713. <td>2023-03-10</td>
  714. <td>2023-01-05</td>
  715. <td><span class="badge badge-danger">待修复</span></td>
  716. <td><span class="badge badge-danger">无信号</span></td>
  717. <td>5</td>
  718. <td>
  719. <div class="flex gap-2 justify-center">
  720. <button class="btn btn-sm view-btn" data-id="M20230003">
  721. <i class="iconfont icon-eye"></i>
  722. 管理
  723. </button>
  724. <button class="btn btn-sm edit-btn" data-id="M20230003">
  725. <i class="iconfont icon-edit"></i>
  726. 编辑
  727. </button>
  728. </div>
  729. </td>
  730. </tr>
  731. <tr>
  732. <td>M20230004</td>
  733. <td>
  734. <div class="flex items-center">
  735. <img src="../assets/images/tractor.png" alt="拖拉机" class="w-10 h-10 mr-3 rounded-md object-cover">
  736. <div>
  737. <div class="font-medium">约翰迪尔-8R</div>
  738. <div class="text-xs text-gray-500">拖拉机</div>
  739. </div>
  740. </div>
  741. </td>
  742. <td>智慧农场三号</td>
  743. <td>北区</td>
  744. <td>拖拉机</td>
  745. <td>约翰迪尔</td>
  746. <td>8R</td>
  747. <td><span class="badge badge-success">在线</span></td>
  748. <td><span class="badge badge-success">待命</span></td>
  749. <td>-</td>
  750. <td>-</td>
  751. <td>赵六</td>
  752. <td>2023-04-05</td>
  753. <td>2023-02-15</td>
  754. <td><span class="badge badge-success">正常</span></td>
  755. <td><span class="badge badge-success">良好</span></td>
  756. <td>0</td>
  757. <td>
  758. <div class="flex gap-2 justify-center">
  759. <button class="btn btn-sm view-btn" data-id="M20230004">
  760. <i class="iconfont icon-eye"></i>
  761. 管理
  762. </button>
  763. <button class="btn btn-sm edit-btn" data-id="M20230004">
  764. <i class="iconfont icon-edit"></i>
  765. 编辑
  766. </button>
  767. </div>
  768. </td>
  769. </tr>
  770. <tr>
  771. <td>M20230005</td>
  772. <td>
  773. <div class="flex items-center">
  774. <img src="../assets/images/seeder.png" alt="播种机" class="w-10 h-10 mr-3 rounded-md object-cover">
  775. <div>
  776. <div class="font-medium">克拉斯-C600</div>
  777. <div class="text-xs text-gray-500">播种机</div>
  778. </div>
  779. </div>
  780. </td>
  781. <td>智慧农场二号</td>
  782. <td>中区</td>
  783. <td>播种机</td>
  784. <td>克拉斯</td>
  785. <td>C600</td>
  786. <td><span class="badge badge-success">在线</span></td>
  787. <td><span class="badge badge-info">作业中</span></td>
  788. <td>小麦播种</td>
  789. <td>中区B-08</td>
  790. <td>马七</td>
  791. <td>2023-05-20</td>
  792. <td>2023-03-10</td>
  793. <td><span class="badge badge-success">正常</span></td>
  794. <td><span class="badge badge-success">良好</span></td>
  795. <td>1</td>
  796. <td>
  797. <div class="flex gap-2 justify-center">
  798. <button class="btn btn-sm view-btn" data-id="M20230005">
  799. <i class="iconfont icon-eye"></i>
  800. 管理
  801. </button>
  802. <button class="btn btn-sm edit-btn" data-id="M20230005">
  803. <i class="iconfont icon-edit"></i>
  804. 编辑
  805. </button>
  806. </div>
  807. </td>
  808. </tr>
  809. </tbody>
  810. </table>
  811. </div>
  812. <!-- 分页 -->
  813. <div class="flex justify-between items-center p-4 border-t border-gray-200">
  814. <div class="text-sm text-gray-600">
  815. 共 <span class="text-primary font-medium">24</span> 条记录
  816. </div>
  817. <div class="pagination">
  818. <button class="page-item disabled">上一页</button>
  819. <button class="page-item active">1</button>
  820. <button class="page-item">2</button>
  821. <button class="page-item">3</button>
  822. <button class="page-item">下一页</button>
  823. </div>
  824. </div>
  825. </div>
  826. </div>
  827. <!-- 添加/编辑农机模态框 -->
  828. <div class="modal" id="machineModal">
  829. <div class="modal-dialog">
  830. <div class="modal-content">
  831. <div class="modal-header">
  832. <h5 class="modal-title" id="modalTitle">添加农机</h5>
  833. <button type="button" class="modal-close" id="closeModal">
  834. <i class="iconfont icon-close"></i>
  835. </button>
  836. </div>
  837. <div class="modal-body">
  838. <form id="machineForm">
  839. <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
  840. <div class="form-group">
  841. <label class="form-label" for="machineCode">农机编号</label>
  842. <input type="text" class="form-control" id="machineCode" placeholder="请输入农机编号">
  843. </div>
  844. <div class="form-group">
  845. <label class="form-label" for="machineName">农机名称</label>
  846. <input type="text" class="form-control" id="machineName" placeholder="请输入农机名称">
  847. </div>
  848. <div class="form-group">
  849. <label class="form-label" for="machineType">农机类型</label>
  850. <select class="form-control" id="machineType">
  851. <option value="">请选择农机类型</option>
  852. <option value="tractor">拖拉机</option>
  853. <option value="harvester">收割机</option>
  854. <option value="seeder">播种机</option>
  855. <option value="sprayer">喷雾机</option>
  856. <option value="other">其他</option>
  857. </select>
  858. </div>
  859. <div class="form-group">
  860. <label class="form-label" for="machineModel">农机型号</label>
  861. <input type="text" class="form-control" id="machineModel" placeholder="请输入农机型号">
  862. </div>
  863. <div class="form-group">
  864. <label class="form-label" for="machineFarm">所属农场</label>
  865. <select class="form-control" id="machineFarm">
  866. <option value="">请选择所属农场</option>
  867. <option value="farm1">智慧农场一号</option>
  868. <option value="farm2">智慧农场二号</option>
  869. <option value="farm3">智慧农场三号</option>
  870. </select>
  871. </div>
  872. <div class="form-group">
  873. <label class="form-label" for="machineManager">负责人</label>
  874. <select class="form-control" id="machineManager">
  875. <option value="">请选择负责人</option>
  876. <option value="user1">张三</option>
  877. <option value="user2">李四</option>
  878. <option value="user3">王五</option>
  879. </select>
  880. </div>
  881. <div class="form-group">
  882. <label class="form-label" for="machineStatus">使用状态</label>
  883. <select class="form-control" id="machineStatus">
  884. <option value="online">在线</option>
  885. <option value="offline">离线</option>
  886. <option value="maintenance">维护中</option>
  887. <option value="fault">故障</option>
  888. </select>
  889. </div>
  890. <div class="form-group">
  891. <label class="form-label" for="purchaseDate">购买日期</label>
  892. <input type="date" class="form-control" id="purchaseDate">
  893. </div>
  894. </div>
  895. <div class="form-group">
  896. <label class="form-label" for="machineDesc">农机描述</label>
  897. <textarea class="form-control" id="machineDesc" rows="4" placeholder="请输入农机描述信息"></textarea>
  898. </div>
  899. </form>
  900. </div>
  901. <div class="modal-footer">
  902. <button type="button" class="btn btn-default" id="cancelBtn">取消</button>
  903. <button type="button" class="btn btn-primary" id="saveBtn">保存</button>
  904. </div>
  905. </div>
  906. </div>
  907. </div>
  908. <script>
  909. document.addEventListener("DOMContentLoaded", function() {
  910. // 初始化表格滚动功能
  911. function initTableScroll() {
  912. const tableContainer = document.querySelector(".table-container");
  913. if (!tableContainer) return;
  914. const scrollLeftBtn = document.querySelector(".table-scroll-left");
  915. const scrollRightBtn = document.querySelector(".table-scroll-right");
  916. if (!scrollLeftBtn || !scrollRightBtn) return;
  917. // 检查表格是否需要水平滚动
  918. function checkTableOverflow() {
  919. if (tableContainer.scrollWidth > tableContainer.clientWidth) {
  920. tableContainer.classList.add("has-overflow");
  921. } else {
  922. tableContainer.classList.remove("has-overflow");
  923. }
  924. }
  925. // 左右滚动按钮点击事件
  926. scrollLeftBtn.addEventListener("click", function() {
  927. tableContainer.scrollLeft -= 150;
  928. });
  929. scrollRightBtn.addEventListener("click", function() {
  930. tableContainer.scrollLeft += 150;
  931. });
  932. // 初始检查和窗口大小变化时检查
  933. checkTableOverflow();
  934. window.addEventListener("resize", checkTableOverflow);
  935. // 滚动事件处理
  936. tableContainer.addEventListener("scroll", function() {
  937. // 根据滚动位置显示/隐藏滚动按钮
  938. if (tableContainer.scrollLeft <= 10) {
  939. scrollLeftBtn.style.opacity = "0.5";
  940. } else {
  941. scrollLeftBtn.style.opacity = "1";
  942. }
  943. if (tableContainer.scrollLeft >= tableContainer.scrollWidth - tableContainer.clientWidth - 10) {
  944. scrollRightBtn.style.opacity = "0.5";
  945. } else {
  946. scrollRightBtn.style.opacity = "1";
  947. }
  948. });
  949. // 初始触发滚动事件,设置初始按钮状态
  950. tableContainer.dispatchEvent(new Event("scroll"));
  951. }
  952. // 初始化表格滚动
  953. initTableScroll(); document.addEventListener('DOMContentLoaded', function() {
  954. // 获取元素
  955. const addMachineBtn = document.getElementById('addMachineBtn');
  956. const refreshBtn = document.getElementById('refreshBtn');
  957. const machineModal = document.getElementById('machineModal');
  958. const closeModal = document.getElementById('closeModal');
  959. const cancelBtn = document.getElementById('cancelBtn');
  960. const saveBtn = document.getElementById('saveBtn');
  961. const modalTitle = document.getElementById('modalTitle');
  962. const machineForm = document.getElementById('machineForm');
  963. const editBtns = document.querySelectorAll('.edit-btn');
  964. const viewBtns = document.querySelectorAll('.view-btn');
  965. // 表格滚动控制
  966. const tableContainer = document.getElementById('tableContainer');
  967. const scrollLeftBtn = document.getElementById('scrollLeftBtn');
  968. const scrollRightBtn = document.getElementById('scrollRightBtn');
  969. // 滚动按钮事件
  970. scrollLeftBtn.addEventListener('click', function() {
  971. tableContainer.scrollLeft -= 300;
  972. });
  973. scrollRightBtn.addEventListener('click', function() {
  974. tableContainer.scrollLeft += 300;
  975. });
  976. // 监听滚动事件更新按钮状态
  977. tableContainer.addEventListener('scroll', function() {
  978. // 更新左右滚动按钮状态
  979. scrollLeftBtn.disabled = tableContainer.scrollLeft <= 0;
  980. scrollRightBtn.disabled = tableContainer.scrollLeft + tableContainer.clientWidth >= tableContainer.scrollWidth;
  981. });
  982. // 初始化滚动按钮状态
  983. function updateScrollButtons() {
  984. scrollLeftBtn.disabled = tableContainer.scrollLeft <= 0;
  985. scrollRightBtn.disabled = tableContainer.scrollLeft + tableContainer.clientWidth >= tableContainer.scrollWidth;
  986. }
  987. // 页面加载和窗口大小变化时更新按钮状态
  988. window.addEventListener('resize', updateScrollButtons);
  989. updateScrollButtons();
  990. // 打开添加农机模态框
  991. addMachineBtn.addEventListener('click', function() {
  992. modalTitle.textContent = '添加农机';
  993. machineForm.reset();
  994. machineModal.classList.add('show');
  995. });
  996. // 关闭模态框
  997. function closeModalFunc() {
  998. machineModal.classList.remove('show');
  999. }
  1000. closeModal.addEventListener('click', closeModalFunc);
  1001. cancelBtn.addEventListener('click', closeModalFunc);
  1002. // 编辑按钮点击事件
  1003. editBtns.forEach(btn => {
  1004. btn.addEventListener('click', function() {
  1005. const machineId = this.getAttribute('data-id');
  1006. modalTitle.textContent = '编辑农机';
  1007. // 这里应该根据ID获取农机信息并填充表单
  1008. // 模拟填充表单
  1009. document.getElementById('machineCode').value = machineId;
  1010. document.getElementById('machineName').value = this.closest('tr').querySelector('.font-medium').textContent;
  1011. document.getElementById('machineType').value = this.closest('tr').cells[2].textContent.toLowerCase();
  1012. document.getElementById('machineFarm').value = 'farm1';
  1013. document.getElementById('machineManager').value = 'user1';
  1014. document.getElementById('machineStatus').value = 'online';
  1015. machineModal.classList.add('show');
  1016. });
  1017. });
  1018. // 查看按钮点击事件
  1019. viewBtns.forEach(btn => {
  1020. btn.addEventListener('click', function() {
  1021. const machineId = this.getAttribute('data-id');
  1022. // 跳转到农机详情页
  1023. window.location.href = `machine-detail.html?id=${machineId}`;
  1024. });
  1025. });
  1026. // 保存按钮点击事件
  1027. saveBtn.addEventListener('click', function() {
  1028. // 模拟保存操作
  1029. alert('保存成功!');
  1030. closeModalFunc();
  1031. });
  1032. // 刷新按钮点击事件
  1033. refreshBtn.addEventListener('click', function() {
  1034. // 模拟刷新操作
  1035. alert('数据已刷新!');
  1036. });
  1037. });
  1038. </script>
  1039. </body>
  1040. </html>