device-management.html 117 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142
  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. body {
  27. font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  28. background-color: #f5f7f9;
  29. color: var(--text-primary);
  30. margin: 0;
  31. padding: 0;
  32. min-height: 100vh;
  33. padding-top: 70px; /* 确保内容不被系统导航栏遮挡 */
  34. }
  35. .page-container {
  36. padding: 20px;
  37. position: relative;
  38. min-height: 100vh;
  39. width: 100%;
  40. max-width: 1400px;
  41. margin: 0 auto;
  42. box-sizing: border-box;
  43. }
  44. .card {
  45. background-color: white;
  46. border-radius: 8px;
  47. box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  48. margin-bottom: 20px;
  49. }
  50. .table-container {
  51. position: relative;
  52. position: relative;
  53. overflow-x: auto;
  54. position: relative;
  55. }
  56. table {
  57. width: 100%;
  58. border-collapse: separate;
  59. border-spacing: 0;
  60. }
  61. th {
  62. white-space: nowrap;
  63. position: relative;
  64. overflow: visible;
  65. max-width: none;
  66. text-overflow: clip;
  67. white-space: nowrap;
  68. position: relative;
  69. background-color: #f9fafb;
  70. padding: 12px 16px;
  71. text-align: left;
  72. font-weight: 500;
  73. color: #6b7280;
  74. border-bottom: 1px solid #e5e7eb;
  75. white-space: nowrap;
  76. position: relative;
  77. }
  78. td {
  79. white-space: nowrap;
  80. max-width: 200px;
  81. overflow: hidden;
  82. text-overflow: ellipsis;
  83. white-space: nowrap;
  84. max-width: 200px;
  85. overflow: hidden;
  86. text-overflow: ellipsis;
  87. padding: 12px 16px;
  88. border-bottom: 1px solid #e5e7eb;
  89. white-space: nowrap;
  90. max-width: 200px;
  91. overflow: hidden;
  92. text-overflow: ellipsis;
  93. }
  94. /* 固定最后一列(操作列)样式 */
  95. .table-fixed-right {
  96. position: relative;
  97. }
  98. .table-fixed-right th:last-child,
  99. .table-fixed-right td:last-child {
  100. position: sticky;
  101. right: 0;
  102. z-index: 2;
  103. background-color: white;
  104. box-shadow: -5px 0 5px -5px rgba(0, 0, 0, 0.1);
  105. }
  106. .table-fixed-right th:last-child {
  107. background-color: #f9fafb;
  108. }
  109. /* 表格滚动控件 */
  110. .table-scroll-controls {
  111. display: none;
  112. position: absolute;
  113. top: 50%;
  114. transform: translateY(-50%);
  115. width: 100%;
  116. pointer-events: none;
  117. z-index: 3;
  118. }
  119. .table-scroll-btn {
  120. position: absolute;
  121. width: 32px;
  122. height: 32px;
  123. border-radius: 50%;
  124. background-color: rgba(255, 255, 255, 0.9);
  125. color: #4CAF50;
  126. border: 1px solid #e0e0e0;
  127. display: flex;
  128. align-items: center;
  129. justify-content: center;
  130. cursor: pointer;
  131. pointer-events: auto;
  132. box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  133. z-index: 4;
  134. }
  135. .table-scroll-left {
  136. left: 10px;
  137. }
  138. .table-scroll-right {
  139. right: 10px;
  140. }
  141. .has-overflow .table-scroll-controls {
  142. display: block;
  143. }
  144. tr:hover {
  145. background-color: #f9fafb;
  146. }
  147. tr:hover td:last-child {
  148. background-color: #f9fafb;
  149. }
  150. .btn {
  151. display: inline-flex;
  152. align-items: center;
  153. justify-content: center;
  154. padding: 8px 16px;
  155. border-radius: 4px;
  156. font-weight: 500;
  157. cursor: pointer;
  158. transition: all 0.2s;
  159. }
  160. .btn-primary {
  161. background-color: #4CAF50;
  162. color: white;
  163. }
  164. .btn-primary:hover {
  165. background-color: #388E3C;
  166. }
  167. .btn-default {
  168. background-color: white;
  169. border: 1px solid #d1d5db;
  170. color: #374151;
  171. }
  172. .btn-default:hover {
  173. background-color: #f9fafb;
  174. }
  175. .btn-sm {
  176. padding: 4px 8px;
  177. font-size: 12px;
  178. }
  179. .search-box {
  180. display: flex;
  181. gap: 8px;
  182. }
  183. .input {
  184. padding: 8px 12px;
  185. border: 1px solid #d1d5db;
  186. border-radius: 4px;
  187. flex-grow: 1;
  188. }
  189. .select {
  190. padding: 8px 12px;
  191. border: 1px solid #d1d5db;
  192. border-radius: 4px;
  193. background-color: white;
  194. min-width: 120px;
  195. }
  196. .badge {
  197. display: inline-block;
  198. padding: 2px 8px;
  199. border-radius: 9999px;
  200. font-size: 12px;
  201. font-weight: 500;
  202. }
  203. .badge-success {
  204. background-color: #d1fae5;
  205. color: #065f46;
  206. }
  207. .badge-warning {
  208. background-color: #fef3c7;
  209. color: #92400e;
  210. }
  211. .badge-danger {
  212. background-color: #fee2e2;
  213. color: #b91c1c;
  214. }
  215. .page-header {
  216. display: flex;
  217. justify-content: space-between;
  218. align-items: center;
  219. margin-bottom: 20px;
  220. padding-bottom: 16px;
  221. border-bottom: 1px solid #e0e0e0;
  222. }
  223. .pagination {
  224. display: flex;
  225. align-items: center;
  226. justify-content: flex-end;
  227. gap: 4px;
  228. }
  229. .pagination-item {
  230. display: inline-flex;
  231. align-items: center;
  232. justify-content: center;
  233. width: 32px;
  234. height: 32px;
  235. border-radius: 4px;
  236. cursor: pointer;
  237. transition: all 0.2s;
  238. }
  239. .pagination-item:hover {
  240. background-color: #f3f4f6;
  241. }
  242. .pagination-item.active {
  243. background-color: #4CAF50;
  244. color: white;
  245. }
  246. .pagination-item.disabled {
  247. color: #9ca3af;
  248. cursor: not-allowed;
  249. }
  250. .modal-overlay {
  251. position: fixed;
  252. top: 0;
  253. left: 0;
  254. right: 0;
  255. bottom: 0;
  256. background-color: rgba(0, 0, 0, 0.5);
  257. display: flex;
  258. align-items: center;
  259. justify-content: center;
  260. z-index: 50;
  261. display: none;
  262. }
  263. .modal {
  264. background-color: white;
  265. border-radius: 8px;
  266. width: 100%;
  267. max-width: 600px;
  268. box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  269. }
  270. .modal-header {
  271. padding: 16px 24px;
  272. border-bottom: 1px solid #e5e7eb;
  273. display: flex;
  274. align-items: center;
  275. justify-content: space-between;
  276. }
  277. .modal-title {
  278. font-size: 18px;
  279. font-weight: 500;
  280. }
  281. .modal-close {
  282. cursor: pointer;
  283. font-size: 20px;
  284. }
  285. .modal-body {
  286. padding: 24px;
  287. }
  288. .modal-footer {
  289. padding: 16px 24px;
  290. border-top: 1px solid #e5e7eb;
  291. display: flex;
  292. justify-content: flex-end;
  293. gap: 8px;
  294. }
  295. .form-group {
  296. margin-bottom: 16px;
  297. }
  298. .form-label {
  299. display: block;
  300. margin-bottom: 4px;
  301. font-weight: 500;
  302. }
  303. .form-input {
  304. width: 100%;
  305. padding: 8px 12px;
  306. border: 1px solid #d1d5db;
  307. border-radius: 4px;
  308. }
  309. .grid-2 {
  310. display: grid;
  311. grid-template-columns: 1fr 1fr;
  312. gap: 16px;
  313. }
  314. /* 搜索条件样式 */
  315. .filter-group {
  316. display: flex;
  317. flex-wrap: wrap;
  318. gap: 10px;
  319. margin-bottom: 15px;
  320. padding-bottom: 15px;
  321. border-bottom: 1px dashed #e5e7eb;
  322. }
  323. .filter-group:last-child {
  324. border-bottom: none;
  325. margin-bottom: 0;
  326. padding-bottom: 0;
  327. }
  328. .filter-item {
  329. display: flex;
  330. align-items: center;
  331. min-width: 180px;
  332. }
  333. .filter-label {
  334. color: #6b7280;
  335. font-size: 13px;
  336. min-width: 70px;
  337. }
  338. .date-filter {
  339. display: flex;
  340. align-items: center;
  341. }
  342. .date-filter input {
  343. width: 140px;
  344. }
  345. .filter-divider {
  346. color: #9ca3af;
  347. margin: 0 4px;
  348. }
  349. </style>
  350. </head>
  351. <body>
  352. <div class="page-container">
  353. <div class="page-header">
  354. <h1 class="text-2xl font-bold">设备管理列表</h1>
  355. <div class="flex gap-2">
  356. <button class="btn btn-primary" id="addDeviceBtn">
  357. <i class="iconfont icon-plus" style="margin-right: 4px;"></i>
  358. 新增设备
  359. </button>
  360. <button class="btn btn-default" id="importBtn">
  361. <i class="iconfont icon-upload" style="margin-right: 4px;"></i>
  362. 导入
  363. </button>
  364. <button class="btn btn-default" id="exportBtn">
  365. <i class="iconfont icon-download" style="margin-right: 4px;"></i>
  366. 导出
  367. </button>
  368. </div>
  369. </div>
  370. <div class="card p-6">
  371. <div class="filter-group">
  372. <div class="filter-item" style="min-width: 300px;">
  373. <span class="filter-label">设备编号:</span>
  374. <input type="text" class="input w-full" placeholder="请输入设备编号关键词">
  375. </div>
  376. <div class="filter-item" style="min-width: 300px;">
  377. <span class="filter-label">设备名称:</span>
  378. <input type="text" class="input w-full" placeholder="请输入设备名称关键词">
  379. </div>
  380. <div class="ml-auto">
  381. <button class="btn btn-primary">
  382. <i class="iconfont icon-search" style="margin-right: 4px;"></i>
  383. 搜索
  384. </button>
  385. <button class="btn btn-default ml-2">
  386. <i class="iconfont icon-reload" style="margin-right: 4px;"></i>
  387. 重置
  388. </button>
  389. </div>
  390. </div>
  391. <div class="filter-group">
  392. <div class="filter-item">
  393. <span class="filter-label">设备类型:</span>
  394. <select class="select">
  395. <option value="">全部</option>
  396. <option value="sensor">传感器</option>
  397. <option value="camera">摄像头</option>
  398. <option value="controller">控制器</option>
  399. <option value="weather">气象设备</option>
  400. </select>
  401. </div>
  402. <div class="filter-item">
  403. <span class="filter-label">所属农场:</span>
  404. <select class="select">
  405. <option value="">全部</option>
  406. <option value="east">东区智慧农场</option>
  407. <option value="west">西区智慧农场</option>
  408. <option value="south">南区智慧农场</option>
  409. <option value="center">中心监测农场</option>
  410. </select>
  411. </div>
  412. <div class="filter-item">
  413. <span class="filter-label">所属地块:</span>
  414. <select class="select">
  415. <option value="">全部</option>
  416. <option value="a-3">A区大棚3号</option>
  417. <option value="a-1">A区大棚1号</option>
  418. <option value="b-2">B区稻田2号</option>
  419. <option value="c-1">C区果园1号</option>
  420. <option value="m-1">监测区1号</option>
  421. </select>
  422. </div>
  423. <div class="filter-item">
  424. <span class="filter-label">设备状态:</span>
  425. <select class="select">
  426. <option value="">全部</option>
  427. <option value="1">在线</option>
  428. <option value="0">离线</option>
  429. <option value="2">故障</option>
  430. <option value="3">维护中</option>
  431. </select>
  432. </div>
  433. </div>
  434. </div>
  435. <div class="card">
  436. <div class="table-container">
  437. <div class="table-scroll-controls">
  438. <button class="table-scroll-btn table-scroll-left">
  439. <i class="iconfont icon-left"></i>
  440. </button>
  441. <button class="table-scroll-btn table-scroll-right">
  442. <i class="iconfont icon-right"></i>
  443. </button>
  444. </div>
  445. <table class="table-fixed-right">
  446. <thead>
  447. <tr>
  448. <th class="min-w-[120px]">设备编号</th>
  449. <th class="min-w-[120px]">设备名称</th>
  450. <th class="min-w-[100px]">设备类型</th>
  451. <th class="min-w-[120px]">所属地块</th>
  452. <th class="min-w-[120px]">所属农场</th>
  453. <th class="min-w-[100px]">设备型号</th>
  454. <th class="min-w-[100px]">厂家</th>
  455. <th class="min-w-[100px]">安装日期</th>
  456. <th class="min-w-[80px]">状态</th>
  457. <th class="min-w-[150px]">最后活动时间</th>
  458. <th class="min-w-[150px]">操作</th>
  459. </tr>
  460. </thead>
  461. <tbody>
  462. <tr>
  463. <td>DEV20230001</td>
  464. <td>温湿度传感器-A1</td>
  465. <td>传感器</td>
  466. <td>A区大棚3号</td>
  467. <td>东区智慧农场</td>
  468. <td>TS-100A</td>
  469. <td>智农科技</td>
  470. <td>2023-01-15</td>
  471. <td><span class="badge badge-success">在线</span></td>
  472. <td>2023-10-15 14:30</td>
  473. <td>
  474. <div class="flex gap-2">
  475. <button class="btn btn-sm btn-default view-btn" data-id="DEV20230001">
  476. <i class="iconfont icon-eye"></i>
  477. 查看
  478. </button>
  479. <button class="btn btn-sm btn-default edit-btn" data-id="DEV20230001">
  480. <i class="iconfont icon-edit"></i>
  481. 编辑
  482. </button>
  483. <button class="btn btn-sm btn-default delete-btn" data-id="DEV20230001" style="color: #F44336;">
  484. <i class="iconfont icon-delete"></i>
  485. 删除
  486. </button>
  487. </div>
  488. </td>
  489. </tr>
  490. <tr>
  491. <td>DEV20230002</td>
  492. <td>土壤湿度检测仪-B1</td>
  493. <td>传感器</td>
  494. <td>B区稻田2号</td>
  495. <td>西区智慧农场</td>
  496. <td>SM-200B</td>
  497. <td>农达科技</td>
  498. <td>2023-02-20</td>
  499. <td><span class="badge badge-warning">离线</span></td>
  500. <td>2023-10-10 09:15</td>
  501. <td>
  502. <div class="flex gap-2">
  503. <button class="btn btn-sm btn-default view-btn" data-id="DEV20230002">
  504. <i class="iconfont icon-eye"></i>
  505. 查看
  506. </button>
  507. <button class="btn btn-sm btn-default edit-btn" data-id="DEV20230002">
  508. <i class="iconfont icon-edit"></i>
  509. 编辑
  510. </button>
  511. <button class="btn btn-sm btn-default delete-btn" data-id="DEV20230002" style="color: #F44336;">
  512. <i class="iconfont icon-delete"></i>
  513. 删除
  514. </button>
  515. </div>
  516. </td>
  517. </tr>
  518. <tr>
  519. <td>DEV20230003</td>
  520. <td>气象站-C1</td>
  521. <td>气象设备</td>
  522. <td>监测区1号</td>
  523. <td>中心监测农场</td>
  524. <td>WS-500C</td>
  525. <td>科沃电子</td>
  526. <td>2023-03-10</td>
  527. <td><span class="badge badge-success">在线</span></td>
  528. <td>2023-10-16 10:25</td>
  529. <td>
  530. <div class="flex gap-2">
  531. <button class="btn btn-sm btn-default view-btn" data-id="DEV20230003">
  532. <i class="iconfont icon-eye"></i>
  533. 查看
  534. </button>
  535. <button class="btn btn-sm btn-default edit-btn" data-id="DEV20230003">
  536. <i class="iconfont icon-edit"></i>
  537. 编辑
  538. </button>
  539. <button class="btn btn-sm btn-default delete-btn" data-id="DEV20230003" style="color: #F44336;">
  540. <i class="iconfont icon-delete"></i>
  541. 删除
  542. </button>
  543. </div>
  544. </td>
  545. </tr>
  546. <tr>
  547. <td>DEV20230004</td>
  548. <td>智能灌溉控制器-D1</td>
  549. <td>控制器</td>
  550. <td>C区果园1号</td>
  551. <td>南区智慧农场</td>
  552. <td>IC-300D</td>
  553. <td>水利通</td>
  554. <td>2023-04-05</td>
  555. <td><span class="badge badge-danger">故障</span></td>
  556. <td>2023-10-12 18:40</td>
  557. <td>
  558. <div class="flex gap-2">
  559. <button class="btn btn-sm btn-default view-btn" data-id="DEV20230004">
  560. <i class="iconfont icon-eye"></i>
  561. 查看
  562. </button>
  563. <button class="btn btn-sm btn-default edit-btn" data-id="DEV20230004">
  564. <i class="iconfont icon-edit"></i>
  565. 编辑
  566. </button>
  567. <button class="btn btn-sm btn-default delete-btn" data-id="DEV20230004" style="color: #F44336;">
  568. <i class="iconfont icon-delete"></i>
  569. 删除
  570. </button>
  571. </div>
  572. </td>
  573. </tr>
  574. <tr>
  575. <td>DEV20230005</td>
  576. <td>作物监控摄像头-E1</td>
  577. <td>摄像头</td>
  578. <td>A区大棚1号</td>
  579. <td>东区智慧农场</td>
  580. <td>CC-400E</td>
  581. <td>视界科技</td>
  582. <td>2023-05-20</td>
  583. <td><span class="badge badge-success">在线</span></td>
  584. <td>2023-10-16 11:05</td>
  585. <td>
  586. <div class="flex gap-2">
  587. <button class="btn btn-sm btn-default view-btn" data-id="DEV20230005">
  588. <i class="iconfont icon-eye"></i>
  589. 查看
  590. </button>
  591. <button class="btn btn-sm btn-default edit-btn" data-id="DEV20230005">
  592. <i class="iconfont icon-edit"></i>
  593. 编辑
  594. </button>
  595. <button class="btn btn-sm btn-default delete-btn" data-id="DEV20230005" style="color: #F44336;">
  596. <i class="iconfont icon-delete"></i>
  597. 删除
  598. </button>
  599. </div>
  600. </td>
  601. </tr>
  602. </tbody>
  603. </table>
  604. </div>
  605. <div class="p-4 border-t border-gray-200 flex justify-between items-center">
  606. <div class="text-sm text-gray-500">显示 1 至 5,共 24 条记录</div>
  607. <div class="pagination">
  608. <div class="pagination-item disabled">&lt;</div>
  609. <div class="pagination-item active">1</div>
  610. <div class="pagination-item">2</div>
  611. <div class="pagination-item">3</div>
  612. <div class="pagination-item">4</div>
  613. <div class="pagination-item">5</div>
  614. <div class="pagination-item">&gt;</div>
  615. </div>
  616. </div>
  617. </div>
  618. <!-- 设备表单弹窗 -->
  619. <div class="modal-overlay" id="deviceModal">
  620. <div class="modal">
  621. <div class="modal-header">
  622. <div class="modal-title">添加设备</div>
  623. <div class="modal-close" id="closeModal">&times;</div>
  624. </div>
  625. <div class="modal-body">
  626. <form id="deviceForm">
  627. <div class="grid-2">
  628. <div class="form-group">
  629. <label class="form-label">设备编号</label>
  630. <input type="text" class="form-input" id="deviceId" placeholder="输入设备编号">
  631. </div>
  632. <div class="form-group">
  633. <label class="form-label">设备名称</label>
  634. <input type="text" class="form-input" id="deviceName" placeholder="输入设备名称">
  635. </div>
  636. </div>
  637. <div class="grid-2">
  638. <div class="form-group">
  639. <label class="form-label">设备类型</label>
  640. <select class="form-input" id="deviceType">
  641. <option value="">请选择设备类型</option>
  642. <option value="sensor">传感器</option>
  643. <option value="camera">摄像头</option>
  644. <option value="controller">控制器</option>
  645. <option value="weather">气象设备</option>
  646. </select>
  647. </div>
  648. <div class="form-group">
  649. <label class="form-label">所属农场</label>
  650. <select class="form-input" id="deviceFarm">
  651. <option value="">请选择所属农场</option>
  652. <option value="east">东区智慧农场</option>
  653. <option value="west">西区智慧农场</option>
  654. <option value="south">南区智慧农场</option>
  655. <option value="center">中心监测农场</option>
  656. </select>
  657. </div>
  658. </div>
  659. <div class="grid-2">
  660. <div class="form-group">
  661. <label class="form-label">设备型号</label>
  662. <input type="text" class="form-input" id="deviceModel" placeholder="输入设备型号">
  663. </div>
  664. <div class="form-group">
  665. <label class="form-label">厂家</label>
  666. <input type="text" class="form-input" id="deviceManufacturer" placeholder="输入厂家名称">
  667. </div>
  668. </div>
  669. <div class="form-group">
  670. <label class="form-label">安装日期</label>
  671. <input type="date" class="form-input" id="installDate">
  672. </div>
  673. <div class="grid-2">
  674. <div class="form-group">
  675. <label class="form-label">GPS经度</label>
  676. <input type="number" step="0.000001" class="form-input" id="deviceLongitude" placeholder="输入经度(如:120.1619)">
  677. </div>
  678. <div class="form-group">
  679. <label class="form-label">GPS纬度</label>
  680. <input type="number" step="0.000001" class="form-input" id="deviceLatitude" placeholder="输入纬度(如:30.2922)">
  681. </div>
  682. </div>
  683. <div class="form-group">
  684. <label class="form-label">设备描述</label>
  685. <textarea class="form-input" id="deviceDesc" rows="3" placeholder="输入设备描述"></textarea>
  686. </div>
  687. </form>
  688. </div>
  689. <div class="modal-footer">
  690. <button class="btn btn-default" id="cancelBtn">取消</button>
  691. <button class="btn btn-primary" id="saveBtn">保存</button>
  692. </div>
  693. </div>
  694. </div>
  695. <!-- 删除确认弹窗 -->
  696. <div class="modal-overlay" id="deleteModal">
  697. <div class="modal" style="max-width: 400px;">
  698. <div class="modal-header">
  699. <div class="modal-title">删除确认</div>
  700. <div class="modal-close" id="closeDeleteModal">&times;</div>
  701. </div>
  702. <div class="modal-body">
  703. <p class="mb-2">确定要删除该设备吗?</p>
  704. <p class="text-gray-500 text-sm">设备编号:<span id="deleteDeviceId"></span></p>
  705. <p class="text-gray-500 text-sm">设备名称:<span id="deleteDeviceName"></span></p>
  706. </div>
  707. <div class="modal-footer">
  708. <button class="btn btn-default" id="cancelDeleteBtn">取消</button>
  709. <button class="btn btn-danger" id="confirmDeleteBtn" style="background-color: #F44336; color: white;">确认删除</button>
  710. </div>
  711. </div>
  712. </div>
  713. <!-- 设备详情弹窗 -->
  714. <div class="modal-overlay" id="deviceDetailModal" style="z-index: 60;">
  715. <div class="modal" style="max-width: 800px; max-height: 85vh; overflow: hidden; display: flex; flex-direction: column;">
  716. <div class="modal-header">
  717. <div class="modal-title">设备详情</div>
  718. <div class="modal-close" id="closeDetailModal">&times;</div>
  719. </div>
  720. <div class="flex border-b border-gray-200">
  721. <div class="cursor-pointer px-6 py-3 font-medium text-sm border-b-2 border-green-500 text-green-600 tab-btn active" data-tab="basic-info">基本信息</div>
  722. <div class="cursor-pointer px-6 py-3 font-medium text-sm text-gray-500 tab-btn" data-tab="real-time-data">实时数据</div>
  723. </div>
  724. <div class="modal-body flex-grow overflow-y-auto" style="max-height: calc(85vh - 120px);">
  725. <!-- 基本信息 Tab -->
  726. <div class="tab-content active" id="basic-info">
  727. <div class="grid grid-cols-2 gap-6">
  728. <div class="card p-6 bg-white rounded-lg shadow-sm">
  729. <h3 class="text-lg font-medium text-gray-800 mb-4">设备基础信息</h3>
  730. <div class="space-y-4">
  731. <div class="flex items-center">
  732. <span class="text-gray-500 w-24">设备编号:</span>
  733. <span id="detail-device-id" class="font-medium text-gray-800"></span>
  734. </div>
  735. <div class="flex items-center">
  736. <span class="text-gray-500 w-24">设备名称:</span>
  737. <span id="detail-device-name" class="font-medium text-gray-800"></span>
  738. </div>
  739. <div class="flex items-center">
  740. <span class="text-gray-500 w-24">设备类型:</span>
  741. <span id="detail-device-type" class="font-medium text-gray-800"></span>
  742. </div>
  743. <div class="flex items-center">
  744. <span class="text-gray-500 w-24">设备型号:</span>
  745. <span id="detail-device-model" class="font-medium text-gray-800"></span>
  746. </div>
  747. <div class="flex items-center">
  748. <span class="text-gray-500 w-24">制造厂商:</span>
  749. <span id="detail-manufacturer" class="font-medium text-gray-800"></span>
  750. </div>
  751. </div>
  752. </div>
  753. <div class="card p-6 bg-white rounded-lg shadow-sm">
  754. <h3 class="text-lg font-medium text-gray-800 mb-4">位置信息</h3>
  755. <div class="space-y-4">
  756. <div class="flex items-center">
  757. <span class="text-gray-500 w-24">所属农场:</span>
  758. <span id="detail-farm" class="font-medium text-gray-800"></span>
  759. </div>
  760. <div class="flex items-center">
  761. <span class="text-gray-500 w-24">所属地块:</span>
  762. <span id="detail-plot" class="font-medium text-gray-800"></span>
  763. </div>
  764. <div class="flex items-center">
  765. <span class="text-gray-500 w-24">安装日期:</span>
  766. <span id="detail-install-date" class="font-medium text-gray-800"></span>
  767. </div>
  768. <div class="flex items-center">
  769. <span class="text-gray-500 w-24">GPS坐标:</span>
  770. <span id="detail-gps" class="font-medium text-gray-800">30.2922° N, 120.1619° E</span>
  771. </div>
  772. </div>
  773. </div>
  774. <div class="card p-6 bg-white rounded-lg shadow-sm col-span-2">
  775. <h3 class="text-lg font-medium text-gray-800 mb-4">运行状态</h3>
  776. <div class="grid grid-cols-2 gap-8">
  777. <div class="space-y-4">
  778. <div class="flex items-center">
  779. <span class="text-gray-500 w-24">当前状态:</span>
  780. <span id="detail-status" class="font-medium"></span>
  781. </div>
  782. <div class="flex items-center">
  783. <span class="text-gray-500 w-24">最近活动:</span>
  784. <span id="detail-last-active" class="font-medium text-gray-800"></span>
  785. </div>
  786. </div>
  787. <div class="space-y-4">
  788. <div class="flex items-center">
  789. <span class="text-gray-500 w-24">电量状态:</span>
  790. <div class="flex-1">
  791. <div class="w-full bg-gray-200 rounded-full h-2.5">
  792. <div id="detail-battery" class="bg-green-500 h-2.5 rounded-full" style="width: 85%"></div>
  793. </div>
  794. </div>
  795. <span class="ml-2 text-sm text-gray-500" id="detail-battery-text">85%</span>
  796. </div>
  797. <div class="flex items-center">
  798. <span class="text-gray-500 w-24">信号强度:</span>
  799. <div class="flex items-end space-x-1">
  800. <div class="h-3 w-1.5 bg-green-500 rounded-t"></div>
  801. <div class="h-4 w-1.5 bg-green-500 rounded-t"></div>
  802. <div class="h-5 w-1.5 bg-green-500 rounded-t"></div>
  803. <div class="h-6 w-1.5 bg-green-500 rounded-t"></div>
  804. <div class="h-7 w-1.5 bg-gray-300 rounded-t"></div>
  805. </div>
  806. <span class="ml-2 text-sm text-gray-500">良好</span>
  807. </div>
  808. </div>
  809. </div>
  810. </div>
  811. </div>
  812. </div>
  813. <!-- 实时数据 Tab -->
  814. <div class="tab-content hidden" id="real-time-data">
  815. <!-- 摄像头设备视图 -->
  816. <div id="camera-view" class="device-type-view hidden">
  817. <div class="grid grid-cols-1 md:grid-cols-4 gap-6">
  818. <!-- 左侧视频区域 -->
  819. <div class="md:col-span-3">
  820. <div class="card p-6 bg-white rounded-lg shadow-sm">
  821. <div class="flex justify-between items-center mb-4">
  822. <h3 class="text-lg font-medium text-gray-800">实时视频</h3>
  823. <div class="flex space-x-2">
  824. <button class="bg-gray-500 text-white p-2 rounded-md">
  825. <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
  826. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 10l4.553-2.276A1 1 0 0121 8.618v6.764a1 1 0 01-1.447.894L15 14M5 18h8a2 2 0 002-2V8a2 2 0 00-2-2H5a2 2 0 00-2 2v8a2 2 0 002 2z" />
  827. </svg>
  828. </button>
  829. <button class="bg-gray-500 text-white p-2 rounded-md">
  830. <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
  831. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z" />
  832. </svg>
  833. </button>
  834. </div>
  835. </div>
  836. <div class="aspect-video bg-gray-100 rounded-md flex items-center justify-center border border-gray-200">
  837. <!-- SVG占位符 -->
  838. <svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 24 24" fill="none" stroke="#9ca3af" stroke-width="1" stroke-linecap="round" stroke-linejoin="round">
  839. <rect x="2" y="2" width="20" height="20" rx="2.18" ry="2.18"></rect>
  840. <line x1="7" y1="2" x2="7" y2="22"></line>
  841. <line x1="17" y1="2" x2="17" y2="22"></line>
  842. <line x1="2" y1="12" x2="22" y2="12"></line>
  843. <line x1="2" y1="7" x2="7" y2="7"></line>
  844. <line x1="2" y1="17" x2="7" y2="17"></line>
  845. <line x1="17" y1="17" x2="22" y2="17"></line>
  846. <line x1="17" y1="7" x2="22" y2="7"></line>
  847. </svg>
  848. </div>
  849. </div>
  850. </div>
  851. <!-- 右侧云台控制 -->
  852. <div class="md:col-span-1">
  853. <div class="card p-6 bg-white rounded-lg shadow-sm h-full">
  854. <h3 class="text-lg font-medium text-gray-800 mb-6">云台控制</h3>
  855. <!-- 方向控制 -->
  856. <div class="flex flex-col items-center mb-6">
  857. <!-- 上 -->
  858. <button class="bg-gray-200 hover:bg-gray-300 rounded-full p-3 mb-4 transition-colors">
  859. <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 text-gray-700" fill="none" viewBox="0 0 24 24" stroke="currentColor">
  860. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 15l7-7 7 7" />
  861. </svg>
  862. </button>
  863. <!-- 左右 -->
  864. <div class="flex justify-between w-full mb-4">
  865. <button class="bg-gray-200 hover:bg-gray-300 rounded-full p-3 transition-colors">
  866. <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 text-gray-700" fill="none" viewBox="0 0 24 24" stroke="currentColor">
  867. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 19l-7-7m0 0l7-7m-7 7h18" />
  868. </svg>
  869. </button>
  870. <button class="bg-gray-200 hover:bg-gray-300 rounded-full p-3 transition-colors">
  871. <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 text-gray-700" fill="none" viewBox="0 0 24 24" stroke="currentColor">
  872. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M14 5l7 7m0 0l-7 7m7-7H3" />
  873. </svg>
  874. </button>
  875. </div>
  876. <!-- 下 -->
  877. <button class="bg-gray-200 hover:bg-gray-300 rounded-full p-3 transition-colors">
  878. <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 text-gray-700" fill="none" viewBox="0 0 24 24" stroke="currentColor">
  879. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7" />
  880. </svg>
  881. </button>
  882. </div>
  883. <!-- 缩放控制 -->
  884. <div class="space-y-6">
  885. <div>
  886. <label class="block text-sm text-gray-600 mb-2">缩放</label>
  887. <div class="flex items-center">
  888. <span class="text-gray-500 mr-2">-</span>
  889. <input type="range" min="1" max="10" value="1" class="w-full accent-blue-500">
  890. <span class="text-gray-500 ml-2">+</span>
  891. </div>
  892. </div>
  893. <!-- 焦距控制 -->
  894. <div>
  895. <label class="block text-sm text-gray-600 mb-2">焦距</label>
  896. <div class="flex items-center">
  897. <span class="text-gray-500 mr-2">-</span>
  898. <input type="range" min="1" max="10" value="5" class="w-full accent-blue-500">
  899. <span class="text-gray-500 ml-2">+</span>
  900. </div>
  901. </div>
  902. </div>
  903. </div>
  904. </div>
  905. </div>
  906. </div>
  907. <!-- 传感器设备视图 -->
  908. <div id="sensor-view" class="device-type-view hidden">
  909. <div class="grid grid-cols-1 gap-6">
  910. <!-- 实时读数卡片 -->
  911. <div class="card p-6 bg-white rounded-lg shadow-sm">
  912. <div class="flex justify-between items-center mb-4">
  913. <h3 class="text-lg font-medium text-gray-800">实时读数</h3>
  914. <div class="text-xs text-gray-500">最后更新: <span id="sensor-last-update">2023-10-16 15:45</span></div>
  915. </div>
  916. <div class="grid grid-cols-2 md:grid-cols-4 gap-4">
  917. <div class="bg-gray-50 p-4 rounded-lg text-center">
  918. <div class="text-4xl font-bold text-green-600 mb-1" id="sensor-value-1">26.5</div>
  919. <div class="text-sm text-gray-500">温度 (°C)</div>
  920. </div>
  921. <div class="bg-gray-50 p-4 rounded-lg text-center">
  922. <div class="text-4xl font-bold text-blue-600 mb-1" id="sensor-value-2">65%</div>
  923. <div class="text-sm text-gray-500">湿度</div>
  924. </div>
  925. <div class="bg-gray-50 p-4 rounded-lg text-center">
  926. <div class="text-4xl font-bold text-amber-600 mb-1" id="sensor-value-3">782</div>
  927. <div class="text-sm text-gray-500">光照 (lux)</div>
  928. </div>
  929. <div class="bg-gray-50 p-4 rounded-lg text-center">
  930. <div class="text-4xl font-bold text-purple-600 mb-1" id="sensor-value-4">25%</div>
  931. <div class="text-sm text-gray-500">土壤湿度</div>
  932. </div>
  933. </div>
  934. </div>
  935. <!-- 数据统计图 -->
  936. <div class="card p-6 bg-white rounded-lg shadow-sm">
  937. <div class="flex flex-wrap justify-between items-center mb-4">
  938. <h3 class="text-lg font-medium text-gray-800 mb-2 sm:mb-0">数据统计图</h3>
  939. <div class="flex flex-wrap items-center gap-3">
  940. <!-- 指标选择 -->
  941. <div class="flex items-center">
  942. <span class="text-sm text-gray-500 mr-2">指标:</span>
  943. <select id="chart-indicator" class="text-sm border border-gray-300 rounded px-2 py-1">
  944. <option value="all">全部指标</option>
  945. <option value="temperature">温度</option>
  946. <option value="humidity">湿度</option>
  947. <option value="light">光照</option>
  948. <option value="soil">土壤湿度</option>
  949. </select>
  950. </div>
  951. <!-- 时间范围 -->
  952. <div class="flex space-x-1">
  953. <button class="time-range-btn bg-gray-200 hover:bg-gray-300 text-xs px-3 py-1.5 rounded-full" data-range="24h">24小时</button>
  954. <button class="time-range-btn bg-green-500 text-white text-xs px-3 py-1.5 rounded-full" data-range="7d">7天</button>
  955. <button class="time-range-btn bg-gray-200 hover:bg-gray-300 text-xs px-3 py-1.5 rounded-full" data-range="30d">30天</button>
  956. </div>
  957. </div>
  958. </div>
  959. <!-- 图表容器 -->
  960. <div class="chart-container h-80 bg-gray-50 rounded-lg">
  961. <canvas id="sensor-chart"></canvas>
  962. </div>
  963. <!-- 图表图例 -->
  964. <div class="flex flex-wrap gap-4 mt-4 justify-center">
  965. <div class="flex items-center">
  966. <span class="w-3 h-3 rounded-full bg-green-500 mr-1"></span>
  967. <span class="text-xs text-gray-600">温度</span>
  968. </div>
  969. <div class="flex items-center">
  970. <span class="w-3 h-3 rounded-full bg-blue-500 mr-1"></span>
  971. <span class="text-xs text-gray-600">湿度</span>
  972. </div>
  973. <div class="flex items-center">
  974. <span class="w-3 h-3 rounded-full bg-amber-500 mr-1"></span>
  975. <span class="text-xs text-gray-600">光照</span>
  976. </div>
  977. <div class="flex items-center">
  978. <span class="w-3 h-3 rounded-full bg-purple-500 mr-1"></span>
  979. <span class="text-xs text-gray-600">土壤湿度</span>
  980. </div>
  981. </div>
  982. <!-- 数据统计信息 -->
  983. <div class="grid grid-cols-2 md:grid-cols-4 gap-4 mt-6">
  984. <div class="bg-white p-4 rounded-lg shadow-sm">
  985. <div class="text-sm text-gray-500 mb-1">平均温度</div>
  986. <div class="text-2xl font-medium text-gray-800 mb-1">24.8 °C</div>
  987. <div class="text-xs text-green-600 flex items-center">
  988. <svg xmlns="http://www.w3.org/2000/svg" class="h-3 w-3 mr-1" viewBox="0 0 20 20" fill="currentColor">
  989. <path fill-rule="evenodd" d="M12 7a1 1 0 110-2h5a1 1 0 011 1v5a1 1 0 11-2 0V8.414l-4.293 4.293a1 1 0 01-1.414 0L8 10.414l-4.293 4.293a1 1 0 01-1.414-1.414l5-5a1 1 0 011.414 0L11 10.586 14.586 7H12z" clip-rule="evenodd" />
  990. </svg>
  991. 2.5%
  992. </div>
  993. </div>
  994. <div class="bg-white p-4 rounded-lg shadow-sm">
  995. <div class="text-sm text-gray-500 mb-1">平均湿度</div>
  996. <div class="text-2xl font-medium text-gray-800 mb-1">63.2%</div>
  997. <div class="text-xs text-red-600 flex items-center">
  998. <svg xmlns="http://www.w3.org/2000/svg" class="h-3 w-3 mr-1" viewBox="0 0 20 20" fill="currentColor">
  999. <path fill-rule="evenodd" d="M12 13a1 1 0 100 2h5a1 1 0 001-1v-5a1 1 0 10-2 0v2.586l-4.293-4.293a1 1 0 00-1.414 0L8 9.586 3.707 5.293a1 1 0 00-1.414 1.414l5 5a1 1 0 001.414 0L11 9.414 14.586 13H12z" clip-rule="evenodd" />
  1000. </svg>
  1001. 1.8%
  1002. </div>
  1003. </div>
  1004. <div class="bg-white p-4 rounded-lg shadow-sm">
  1005. <div class="text-sm text-gray-500 mb-1">平均光照</div>
  1006. <div class="text-2xl font-medium text-gray-800 mb-1">756 lux</div>
  1007. <div class="text-xs text-green-600 flex items-center">
  1008. <svg xmlns="http://www.w3.org/2000/svg" class="h-3 w-3 mr-1" viewBox="0 0 20 20" fill="currentColor">
  1009. <path fill-rule="evenodd" d="M12 7a1 1 0 110-2h5a1 1 0 011 1v5a1 1 0 11-2 0V8.414l-4.293 4.293a1 1 0 01-1.414 0L8 10.414l-4.293 4.293a1 1 0 01-1.414-1.414l5-5a1 1 0 011.414 0L11 10.586 14.586 7H12z" clip-rule="evenodd" />
  1010. </svg>
  1011. 5.2%
  1012. </div>
  1013. </div>
  1014. <div class="bg-white p-4 rounded-lg shadow-sm">
  1015. <div class="text-sm text-gray-500 mb-1">平均土壤湿度</div>
  1016. <div class="text-2xl font-medium text-gray-800 mb-1">28.5%</div>
  1017. <div class="text-xs text-green-600 flex items-center">
  1018. <svg xmlns="http://www.w3.org/2000/svg" class="h-3 w-3 mr-1" viewBox="0 0 20 20" fill="currentColor">
  1019. <path fill-rule="evenodd" d="M12 7a1 1 0 110-2h5a1 1 0 011 1v5a1 1 0 11-2 0V8.414l-4.293 4.293a1 1 0 01-1.414 0L8 10.414l-4.293 4.293a1 1 0 01-1.414-1.414l5-5a1 1 0 011.414 0L11 10.586 14.586 7H12z" clip-rule="evenodd" />
  1020. </svg>
  1021. 3.1%
  1022. </div>
  1023. </div>
  1024. </div>
  1025. </div>
  1026. </div>
  1027. </div>
  1028. <!-- 气象站设备视图 -->
  1029. <div id="weather-view" class="device-type-view hidden">
  1030. <div class="grid grid-cols-1 gap-6">
  1031. <!-- 实时气象数据卡片 -->
  1032. <div class="card p-6 bg-white rounded-lg shadow-sm">
  1033. <div class="flex justify-between items-center mb-4">
  1034. <h3 class="text-lg font-medium text-gray-800">实时气象数据</h3>
  1035. <div class="text-xs text-gray-500">最后更新: <span id="weather-last-update">2023-10-16 15:50</span></div>
  1036. </div>
  1037. <div class="grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4">
  1038. <div class="bg-gray-50 p-4 rounded-lg flex items-center">
  1039. <div class="text-red-500 mr-3">
  1040. <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
  1041. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 10l7-7m0 0l7 7m-7-7v18" />
  1042. </svg>
  1043. </div>
  1044. <div>
  1045. <div class="text-sm text-gray-500">气温</div>
  1046. <div class="text-xl font-medium text-gray-800">24.8 °C</div>
  1047. </div>
  1048. </div>
  1049. <div class="bg-gray-50 p-4 rounded-lg flex items-center">
  1050. <div class="text-blue-500 mr-3">
  1051. <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
  1052. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17.657 18.657A8 8 0 016.343 7.343S7 9 9 10c0-2 .5-5 2.986-7C14 5 16.09 5.777 17.656 7.343A7.975 7.975 0 0120 13a7.975 7.975 0 01-2.343 5.657z" />
  1053. </svg>
  1054. </div>
  1055. <div>
  1056. <div class="text-sm text-gray-500">湿度</div>
  1057. <div class="text-xl font-medium text-gray-800">76%</div>
  1058. </div>
  1059. </div>
  1060. <div class="bg-gray-50 p-4 rounded-lg flex items-center">
  1061. <div class="text-blue-600 mr-3">
  1062. <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
  1063. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 14l-7 7m0 0l-7-7m7 7V3" />
  1064. </svg>
  1065. </div>
  1066. <div>
  1067. <div class="text-sm text-gray-500">降雨量</div>
  1068. <div class="text-xl font-medium text-gray-800">2.5 mm</div>
  1069. </div>
  1070. </div>
  1071. <div class="bg-gray-50 p-4 rounded-lg flex items-center">
  1072. <div class="text-amber-500 mr-3">
  1073. <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
  1074. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 19l9 2-9-18-9 18 9-2zm0 0v-8" />
  1075. </svg>
  1076. </div>
  1077. <div>
  1078. <div class="text-sm text-gray-500">风向</div>
  1079. <div class="text-xl font-medium text-gray-800">东北</div>
  1080. </div>
  1081. </div>
  1082. <div class="bg-gray-50 p-4 rounded-lg flex items-center">
  1083. <div class="text-purple-500 mr-3">
  1084. <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
  1085. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17.657 18.657A8 8 0 016.343 7.343S7 9 9 10c0-2 .5-5 2.986-7C14 5 16.09 5.777 17.656 7.343A7.975 7.975 0 0120 13a7.975 7.975 0 01-2.343 5.657z" />
  1086. </svg>
  1087. </div>
  1088. <div>
  1089. <div class="text-sm text-gray-500">风速</div>
  1090. <div class="text-xl font-medium text-gray-800">3.2 m/s</div>
  1091. </div>
  1092. </div>
  1093. <div class="bg-gray-50 p-4 rounded-lg flex items-center">
  1094. <div class="text-indigo-500 mr-3">
  1095. <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
  1096. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 15a4 4 0 004 4h9a5 5 0 10-.1-9.999 5.002 5.002 0 10-9.78 2.096A4.001 4.001 0 003 15z" />
  1097. </svg>
  1098. </div>
  1099. <div>
  1100. <div class="text-sm text-gray-500">气压</div>
  1101. <div class="text-xl font-medium text-gray-800">1013 hPa</div>
  1102. </div>
  1103. </div>
  1104. <div class="bg-gray-50 p-4 rounded-lg flex items-center">
  1105. <div class="text-green-500 mr-3">
  1106. <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
  1107. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z" />
  1108. </svg>
  1109. </div>
  1110. <div>
  1111. <div class="text-sm text-gray-500">光照</div>
  1112. <div class="text-xl font-medium text-gray-800">12500 lux</div>
  1113. </div>
  1114. </div>
  1115. </div>
  1116. </div>
  1117. <!-- 数据统计图 -->
  1118. <div class="card p-6 bg-white rounded-lg shadow-sm">
  1119. <div class="flex flex-wrap justify-between items-center mb-4">
  1120. <h3 class="text-lg font-medium text-gray-800 mb-2 sm:mb-0">气象数据统计图</h3>
  1121. <div class="flex flex-wrap items-center gap-3">
  1122. <!-- 指标选择 -->
  1123. <div class="flex items-center">
  1124. <span class="text-sm text-gray-500 mr-2">指标:</span>
  1125. <select id="weather-chart-indicator" class="text-sm border border-gray-300 rounded px-2 py-1">
  1126. <option value="all">全部指标</option>
  1127. <option value="temperature">气温</option>
  1128. <option value="humidity">湿度</option>
  1129. <option value="rainfall">降雨量</option>
  1130. <option value="windspeed">风速</option>
  1131. <option value="pressure">气压</option>
  1132. <option value="light">光照</option>
  1133. </select>
  1134. </div>
  1135. <!-- 时间范围 -->
  1136. <div class="flex space-x-1">
  1137. <button class="weather-time-range-btn bg-gray-200 hover:bg-gray-300 text-xs px-3 py-1.5 rounded-full" data-range="24h">24小时</button>
  1138. <button class="weather-time-range-btn bg-green-500 text-white text-xs px-3 py-1.5 rounded-full" data-range="7d">7天</button>
  1139. <button class="weather-time-range-btn bg-gray-200 hover:bg-gray-300 text-xs px-3 py-1.5 rounded-full" data-range="30d">30天</button>
  1140. </div>
  1141. </div>
  1142. </div>
  1143. <!-- 图表容器 -->
  1144. <div class="chart-container h-80 bg-gray-50 rounded-lg">
  1145. <canvas id="weather-chart"></canvas>
  1146. </div>
  1147. <!-- 图表图例 -->
  1148. <div class="flex flex-wrap gap-4 mt-4 justify-center">
  1149. <div class="flex items-center">
  1150. <span class="w-3 h-3 rounded-full bg-red-500 mr-1"></span>
  1151. <span class="text-xs text-gray-600">气温</span>
  1152. </div>
  1153. <div class="flex items-center">
  1154. <span class="w-3 h-3 rounded-full bg-blue-500 mr-1"></span>
  1155. <span class="text-xs text-gray-600">湿度</span>
  1156. </div>
  1157. <div class="flex items-center">
  1158. <span class="w-3 h-3 rounded-full bg-blue-600 mr-1"></span>
  1159. <span class="text-xs text-gray-600">降雨量</span>
  1160. </div>
  1161. <div class="flex items-center">
  1162. <span class="w-3 h-3 rounded-full bg-purple-500 mr-1"></span>
  1163. <span class="text-xs text-gray-600">风速</span>
  1164. </div>
  1165. </div>
  1166. <!-- 数据统计信息 -->
  1167. <div class="grid grid-cols-2 md:grid-cols-4 gap-4 mt-6">
  1168. <div class="bg-white p-4 rounded-lg shadow-sm">
  1169. <div class="text-sm text-gray-500 mb-1">平均气温</div>
  1170. <div class="text-2xl font-medium text-gray-800 mb-1">22.4 °C</div>
  1171. <div class="text-xs text-green-600 flex items-center">
  1172. <svg xmlns="http://www.w3.org/2000/svg" class="h-3 w-3 mr-1" viewBox="0 0 20 20" fill="currentColor">
  1173. <path fill-rule="evenodd" d="M12 7a1 1 0 110-2h5a1 1 0 011 1v5a1 1 0 11-2 0V8.414l-4.293 4.293a1 1 0 01-1.414 0L8 10.414l-4.293 4.293a1 1 0 01-1.414-1.414l5-5a1 1 0 011.414 0L11 10.586 14.586 7H12z" clip-rule="evenodd" />
  1174. </svg>
  1175. 1.8%
  1176. </div>
  1177. </div>
  1178. <div class="bg-white p-4 rounded-lg shadow-sm">
  1179. <div class="text-sm text-gray-500 mb-1">平均湿度</div>
  1180. <div class="text-2xl font-medium text-gray-800 mb-1">68.5%</div>
  1181. <div class="text-xs text-red-600 flex items-center">
  1182. <svg xmlns="http://www.w3.org/2000/svg" class="h-3 w-3 mr-1" viewBox="0 0 20 20" fill="currentColor">
  1183. <path fill-rule="evenodd" d="M12 13a1 1 0 100 2h5a1 1 0 001-1v-5a1 1 0 10-2 0v2.586l-4.293-4.293a1 1 0 00-1.414 0L8 9.586 3.707 5.293a1 1 0 00-1.414 1.414l5 5a1 1 0 001.414 0L11 9.414 14.586 13H12z" clip-rule="evenodd" />
  1184. </svg>
  1185. 2.3%
  1186. </div>
  1187. </div>
  1188. <div class="bg-white p-4 rounded-lg shadow-sm">
  1189. <div class="text-sm text-gray-500 mb-1">累计降雨量</div>
  1190. <div class="text-2xl font-medium text-gray-800 mb-1">18.5 mm</div>
  1191. <div class="text-xs text-green-600 flex items-center">
  1192. <svg xmlns="http://www.w3.org/2000/svg" class="h-3 w-3 mr-1" viewBox="0 0 20 20" fill="currentColor">
  1193. <path fill-rule="evenodd" d="M12 7a1 1 0 110-2h5a1 1 0 011 1v5a1 1 0 11-2 0V8.414l-4.293 4.293a1 1 0 01-1.414 0L8 10.414l-4.293 4.293a1 1 0 01-1.414-1.414l5-5a1 1 0 011.414 0L11 10.586 14.586 7H12z" clip-rule="evenodd" />
  1194. </svg>
  1195. 12.4%
  1196. </div>
  1197. </div>
  1198. <div class="bg-white p-4 rounded-lg shadow-sm">
  1199. <div class="text-sm text-gray-500 mb-1">平均风速</div>
  1200. <div class="text-2xl font-medium text-gray-800 mb-1">2.8 m/s</div>
  1201. <div class="text-xs text-red-600 flex items-center">
  1202. <svg xmlns="http://www.w3.org/2000/svg" class="h-3 w-3 mr-1" viewBox="0 0 20 20" fill="currentColor">
  1203. <path fill-rule="evenodd" d="M12 13a1 1 0 100 2h5a1 1 0 001-1v-5a1 1 0 10-2 0v2.586l-4.293-4.293a1 1 0 00-1.414 0L8 9.586 3.707 5.293a1 1 0 00-1.414 1.414l5 5a1 1 0 001.414 0L11 9.414 14.586 13H12z" clip-rule="evenodd" />
  1204. </svg>
  1205. 0.7%
  1206. </div>
  1207. </div>
  1208. </div>
  1209. </div>
  1210. </div>
  1211. </div>
  1212. <!-- 控制器设备视图 -->
  1213. <div id="controller-view" class="device-type-view hidden">
  1214. <div class="grid grid-cols-2 gap-4">
  1215. <div class="card p-4">
  1216. <h3 class="font-medium text-gray-700 mb-4">控制状态</h3>
  1217. <div class="space-y-4">
  1218. <div class="flex justify-between items-center pb-3 border-b">
  1219. <span class="flex items-center">
  1220. <span class="mr-2 h-3 w-3 rounded-full bg-green-500"></span>
  1221. 水泵1#
  1222. </span>
  1223. <span class="badge badge-success">运行中</span>
  1224. </div>
  1225. <div class="flex justify-between items-center pb-3 border-b">
  1226. <span class="flex items-center">
  1227. <span class="mr-2 h-3 w-3 rounded-full bg-red-500"></span>
  1228. 水泵2#
  1229. </span>
  1230. <span class="badge badge-danger">已停止</span>
  1231. </div>
  1232. <div class="flex justify-between items-center pb-3 border-b">
  1233. <span class="flex items-center">
  1234. <span class="mr-2 h-3 w-3 rounded-full bg-green-500"></span>
  1235. 风机
  1236. </span>
  1237. <span class="badge badge-success">运行中</span>
  1238. </div>
  1239. <div class="flex justify-between items-center pb-3 border-b">
  1240. <span class="flex items-center">
  1241. <span class="mr-2 h-3 w-3 rounded-full bg-amber-500"></span>
  1242. 灌溉阀门
  1243. </span>
  1244. <span class="badge badge-warning">部分开启</span>
  1245. </div>
  1246. <div class="flex justify-between items-center">
  1247. <span class="flex items-center">
  1248. <span class="mr-2 h-3 w-3 rounded-full bg-red-500"></span>
  1249. 照明系统
  1250. </span>
  1251. <span class="badge badge-danger">已关闭</span>
  1252. </div>
  1253. </div>
  1254. </div>
  1255. <div class="card p-4">
  1256. <h3 class="font-medium text-gray-700 mb-4">运行参数</h3>
  1257. <div class="space-y-4">
  1258. <div>
  1259. <label class="block text-sm text-gray-600 mb-1">系统工作模式</label>
  1260. <select class="form-input bg-gray-100" disabled>
  1261. <option selected>自动模式</option>
  1262. <option>手动模式</option>
  1263. <option>定时模式</option>
  1264. <option>智能模式</option>
  1265. </select>
  1266. </div>
  1267. <div>
  1268. <label class="block text-sm text-gray-600 mb-1">水泵1#流量</label>
  1269. <div class="flex items-center">
  1270. <div class="w-full bg-gray-200 rounded-full h-2.5">
  1271. <div class="bg-green-500 h-2.5 rounded-full" style="width: 65%"></div>
  1272. </div>
  1273. <span class="ml-2 text-sm">65%</span>
  1274. </div>
  1275. </div>
  1276. <div>
  1277. <label class="block text-sm text-gray-600 mb-1">风机转速</label>
  1278. <div class="flex items-center">
  1279. <div class="w-full bg-gray-200 rounded-full h-2.5">
  1280. <div class="bg-green-500 h-2.5 rounded-full" style="width: 80%"></div>
  1281. </div>
  1282. <span class="ml-2 text-sm">80%</span>
  1283. </div>
  1284. </div>
  1285. <div>
  1286. <label class="block text-sm text-gray-600 mb-1">阀门开度</label>
  1287. <div class="flex items-center">
  1288. <div class="w-full bg-gray-200 rounded-full h-2.5">
  1289. <div class="bg-amber-500 h-2.5 rounded-full" style="width: 45%"></div>
  1290. </div>
  1291. <span class="ml-2 text-sm">45%</span>
  1292. </div>
  1293. </div>
  1294. </div>
  1295. </div>
  1296. <div class="col-span-2 card p-4">
  1297. <h3 class="font-medium text-gray-700 mb-4">运行记录</h3>
  1298. <table class="min-w-full">
  1299. <thead>
  1300. <tr>
  1301. <th class="py-2 px-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">时间</th>
  1302. <th class="py-2 px-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">事件类型</th>
  1303. <th class="py-2 px-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">操作人员</th>
  1304. <th class="py-2 px-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">详情</th>
  1305. </tr>
  1306. </thead>
  1307. <tbody class="bg-white divide-y divide-gray-200 text-sm">
  1308. <tr>
  1309. <td class="py-2 px-3">2023-10-16 14:30</td>
  1310. <td class="py-2 px-3">自动启动</td>
  1311. <td class="py-2 px-3">系统</td>
  1312. <td class="py-2 px-3">根据传感器数据,水泵1#自动启动</td>
  1313. </tr>
  1314. <tr>
  1315. <td class="py-2 px-3">2023-10-16 12:15</td>
  1316. <td class="py-2 px-3">手动调整</td>
  1317. <td class="py-2 px-3">张农艺师</td>
  1318. <td class="py-2 px-3">调整风机转速至80%</td>
  1319. </tr>
  1320. <tr>
  1321. <td class="py-2 px-3">2023-10-16 09:30</td>
  1322. <td class="py-2 px-3">自动关闭</td>
  1323. <td class="py-2 px-3">系统</td>
  1324. <td class="py-2 px-3">灌溉完成,阀门自动关闭</td>
  1325. </tr>
  1326. <tr>
  1327. <td class="py-2 px-3">2023-10-16 08:00</td>
  1328. <td class="py-2 px-3">系统检查</td>
  1329. <td class="py-2 px-3">系统</td>
  1330. <td class="py-2 px-3">日常自检完成,所有系统正常</td>
  1331. </tr>
  1332. </tbody>
  1333. </table>
  1334. </div>
  1335. </div>
  1336. </div>
  1337. </div>
  1338. </div>
  1339. </div>
  1340. </div>
  1341. </div>
  1342. <script>
  1343. // 添加设备按钮点击事件
  1344. document.getElementById('addDeviceBtn').addEventListener('click', function() {
  1345. document.getElementById('deviceModal').style.display = 'flex';
  1346. });
  1347. // 初始化表格滚动功能
  1348. function initTableScroll() {
  1349. const tableContainer = document.querySelector('.table-container');
  1350. const scrollLeftBtn = document.querySelector('.table-scroll-left');
  1351. const scrollRightBtn = document.querySelector('.table-scroll-right');
  1352. // 检查表格是否需要水平滚动
  1353. function checkTableOverflow() {
  1354. if (tableContainer.scrollWidth > tableContainer.clientWidth) {
  1355. tableContainer.classList.add('has-overflow');
  1356. } else {
  1357. tableContainer.classList.remove('has-overflow');
  1358. }
  1359. }
  1360. // 左右滚动按钮点击事件
  1361. scrollLeftBtn.addEventListener('click', function() {
  1362. tableContainer.scrollLeft -= 150;
  1363. });
  1364. scrollRightBtn.addEventListener('click', function() {
  1365. tableContainer.scrollLeft += 150;
  1366. });
  1367. // 初始检查和窗口大小变化时检查
  1368. checkTableOverflow();
  1369. window.addEventListener('resize', checkTableOverflow);
  1370. // 滚动事件处理
  1371. tableContainer.addEventListener('scroll', function() {
  1372. // 根据滚动位置显示/隐藏滚动按钮
  1373. if (tableContainer.scrollLeft <= 10) {
  1374. scrollLeftBtn.style.opacity = '0.5';
  1375. } else {
  1376. scrollLeftBtn.style.opacity = '1';
  1377. }
  1378. if (tableContainer.scrollLeft >= tableContainer.scrollWidth - tableContainer.clientWidth - 10) {
  1379. scrollRightBtn.style.opacity = '0.5';
  1380. } else {
  1381. scrollRightBtn.style.opacity = '1';
  1382. }
  1383. });
  1384. // 初始触发滚动事件,设置初始按钮状态
  1385. tableContainer.dispatchEvent(new Event('scroll'));
  1386. }
  1387. // 页面加载完成后初始化表格滚动
  1388. window.addEventListener('load', initTableScroll);
  1389. // 关闭模态框
  1390. document.getElementById('closeModal').addEventListener('click', function() {
  1391. document.getElementById('deviceModal').style.display = 'none';
  1392. });
  1393. // 取消按钮点击事件
  1394. document.getElementById('cancelBtn').addEventListener('click', function() {
  1395. document.getElementById('deviceModal').style.display = 'none';
  1396. });
  1397. // 保存按钮点击事件
  1398. document.getElementById('saveBtn').addEventListener('click', function() {
  1399. alert('设备信息已保存');
  1400. document.getElementById('deviceModal').style.display = 'none';
  1401. });
  1402. // 编辑按钮点击事件
  1403. const editBtns = document.querySelectorAll('.edit-btn');
  1404. editBtns.forEach(function(btn) {
  1405. btn.addEventListener('click', function() {
  1406. const deviceId = this.getAttribute('data-id');
  1407. document.getElementById('deviceModal').style.display = 'flex';
  1408. document.querySelector('.modal-title').textContent = '编辑设备';
  1409. // 根据表格行数据填充表单
  1410. const row = this.closest('tr');
  1411. const cells = row.querySelectorAll('td');
  1412. // 填充表单字段
  1413. document.getElementById('deviceId').value = cells[0].textContent;
  1414. document.getElementById('deviceName').value = cells[1].textContent;
  1415. // 设备类型
  1416. const deviceTypeSelect = document.getElementById('deviceType');
  1417. Array.from(deviceTypeSelect.options).forEach(option => {
  1418. if (option.text === cells[2].textContent) {
  1419. option.selected = true;
  1420. }
  1421. });
  1422. // 所属农场
  1423. const deviceFarmSelect = document.getElementById('deviceFarm');
  1424. Array.from(deviceFarmSelect.options).forEach(option => {
  1425. if (option.text === cells[4].textContent) {
  1426. option.selected = true;
  1427. }
  1428. });
  1429. // 设备型号、厂家、安装日期
  1430. document.getElementById('deviceModel').value = cells[5].textContent;
  1431. document.getElementById('deviceManufacturer').value = cells[6].textContent;
  1432. document.getElementById('installDate').value = formatDateForInput(cells[7].textContent);
  1433. // 填充GPS坐标(从详情中获取)
  1434. const gpsText = document.getElementById('detail-gps').textContent;
  1435. if (gpsText) {
  1436. const [latitude, longitude] = gpsText.split(',').map(coord => {
  1437. return parseFloat(coord.replace(/[°NS\s]/g, ''));
  1438. });
  1439. document.getElementById('deviceLatitude').value = latitude || '';
  1440. document.getElementById('deviceLongitude').value = longitude || '';
  1441. } else {
  1442. document.getElementById('deviceLatitude').value = '';
  1443. document.getElementById('deviceLongitude').value = '';
  1444. }
  1445. });
  1446. });
  1447. // 日期格式化工具函数(将 "YYYY-MM-DD" 格式化为 date input 所需格式)
  1448. function formatDateForInput(dateString) {
  1449. // 假设输入格式为 "YYYY-MM-DD"
  1450. // HTML date input 也使用 "YYYY-MM-DD" 格式,所以可以直接返回
  1451. return dateString;
  1452. }
  1453. // 查看按钮点击事件
  1454. const viewBtns = document.querySelectorAll('.view-btn');
  1455. viewBtns.forEach(function(btn) {
  1456. btn.addEventListener('click', function() {
  1457. const deviceId = this.getAttribute('data-id');
  1458. // 获取设备所在行的数据
  1459. const row = this.closest('tr');
  1460. const cells = row.querySelectorAll('td');
  1461. // 填充基本信息
  1462. document.getElementById('detail-device-id').textContent = cells[0].textContent;
  1463. document.getElementById('detail-device-name').textContent = cells[1].textContent;
  1464. document.getElementById('detail-device-type').textContent = cells[2].textContent;
  1465. document.getElementById('detail-device-model').textContent = cells[5].textContent;
  1466. document.getElementById('detail-manufacturer').textContent = cells[6].textContent;
  1467. document.getElementById('detail-farm').textContent = cells[4].textContent;
  1468. document.getElementById('detail-plot').textContent = cells[3].textContent;
  1469. document.getElementById('detail-install-date').textContent = cells[7].textContent;
  1470. // 设置设备状态
  1471. const statusText = cells[8].querySelector('span').textContent;
  1472. document.getElementById('detail-status').textContent = statusText;
  1473. if (statusText === '在线') {
  1474. document.getElementById('detail-status').innerHTML = '<span class="badge badge-success">在线</span>';
  1475. } else if (statusText === '离线') {
  1476. document.getElementById('detail-status').innerHTML = '<span class="badge badge-warning">离线</span>';
  1477. } else if (statusText === '故障') {
  1478. document.getElementById('detail-status').innerHTML = '<span class="badge badge-danger">故障</span>';
  1479. } else {
  1480. document.getElementById('detail-status').innerHTML = '<span class="badge badge-secondary">维护中</span>';
  1481. }
  1482. // 设置最后活动时间
  1483. document.getElementById('detail-last-active').textContent = cells[9].textContent;
  1484. // 根据设备类型显示对应的实时数据视图
  1485. const deviceType = cells[2].textContent;
  1486. const deviceTypeViews = document.querySelectorAll('.device-type-view');
  1487. deviceTypeViews.forEach(function(view) {
  1488. view.classList.add('hidden');
  1489. });
  1490. // 根据设备类型显示对应的视图
  1491. if (deviceType === '摄像头') {
  1492. document.getElementById('camera-view').classList.remove('hidden');
  1493. } else if (deviceType === '传感器') {
  1494. document.getElementById('sensor-view').classList.remove('hidden');
  1495. // 可以根据不同传感器类型设置不同的示例数据
  1496. if (cells[1].textContent.includes('温湿度')) {
  1497. document.getElementById('sensor-value-1').textContent = '26.5';
  1498. document.getElementById('sensor-value-2').textContent = '65%';
  1499. } else if (cells[1].textContent.includes('土壤')) {
  1500. document.getElementById('sensor-value-4').textContent = '35%';
  1501. }
  1502. } else if (deviceType === '气象设备') {
  1503. document.getElementById('weather-view').classList.remove('hidden');
  1504. } else if (deviceType === '控制器') {
  1505. document.getElementById('controller-view').classList.remove('hidden');
  1506. }
  1507. // 显示设备详情弹窗
  1508. document.getElementById('deviceDetailModal').style.display = 'flex';
  1509. // 默认显示基本信息标签页
  1510. document.querySelector('.tab-btn[data-tab="basic-info"]').click();
  1511. });
  1512. });
  1513. // 删除按钮点击事件
  1514. const deleteBtns = document.querySelectorAll('.delete-btn');
  1515. deleteBtns.forEach(function(btn) {
  1516. btn.addEventListener('click', function() {
  1517. const deviceId = this.getAttribute('data-id');
  1518. const row = this.closest('tr');
  1519. const cells = row.querySelectorAll('td');
  1520. // 显示删除确认弹窗
  1521. document.getElementById('deleteDeviceId').textContent = cells[0].textContent;
  1522. document.getElementById('deleteDeviceName').textContent = cells[1].textContent;
  1523. document.getElementById('deleteModal').style.display = 'flex';
  1524. // 保存当前行引用,用于确认删除时使用
  1525. document.getElementById('confirmDeleteBtn').setAttribute('data-row', row.rowIndex);
  1526. });
  1527. });
  1528. // 关闭删除确认弹窗
  1529. document.getElementById('closeDeleteModal').addEventListener('click', function() {
  1530. document.getElementById('deleteModal').style.display = 'none';
  1531. });
  1532. // 取消删除
  1533. document.getElementById('cancelDeleteBtn').addEventListener('click', function() {
  1534. document.getElementById('deleteModal').style.display = 'none';
  1535. });
  1536. // 确认删除
  1537. document.getElementById('confirmDeleteBtn').addEventListener('click', function() {
  1538. const rowIndex = this.getAttribute('data-row');
  1539. const table = document.querySelector('tbody');
  1540. const rowToDelete = table.rows[rowIndex-1]; // -1 因为 rowIndex 是从 1 开始计数的
  1541. if (rowToDelete) {
  1542. rowToDelete.remove();
  1543. }
  1544. document.getElementById('deleteModal').style.display = 'none';
  1545. // 显示删除成功提示
  1546. alert('设备已成功删除');
  1547. });
  1548. // 设备详情相关功能
  1549. // 关闭设备详情弹窗
  1550. document.getElementById('closeDetailModal').addEventListener('click', function() {
  1551. document.getElementById('deviceDetailModal').style.display = 'none';
  1552. });
  1553. // 切换设备详情标签页
  1554. const tabBtns = document.querySelectorAll('.tab-btn');
  1555. tabBtns.forEach(function(btn) {
  1556. btn.addEventListener('click', function() {
  1557. // 移除所有标签按钮的活动状态
  1558. tabBtns.forEach(b => {
  1559. b.classList.remove('active', 'border-b-2', 'border-green-500', 'text-green-600');
  1560. b.classList.add('text-gray-500');
  1561. });
  1562. // 为当前按钮添加活动状态
  1563. this.classList.add('active', 'border-b-2', 'border-green-500', 'text-green-600');
  1564. this.classList.remove('text-gray-500');
  1565. // 隐藏所有内容面板
  1566. const tabContents = document.querySelectorAll('.tab-content');
  1567. tabContents.forEach(function(content) {
  1568. content.classList.add('hidden');
  1569. });
  1570. // 显示当前选中的内容面板
  1571. const targetTab = this.getAttribute('data-tab');
  1572. document.getElementById(targetTab).classList.remove('hidden');
  1573. });
  1574. });
  1575. </script>
  1576. <!-- Chart.js Library -->
  1577. <script src="https://cdn.jsdelivr.net/npm/chart.js@3.9.1/dist/chart.min.js"></script>
  1578. <!-- Chart Initialization -->
  1579. <script>
  1580. document.addEventListener('DOMContentLoaded', function() {
  1581. // 初始化图表
  1582. const initSensorChart = function() {
  1583. const ctx = document.getElementById('sensor-chart');
  1584. // 如果图表容器不存在,直接返回
  1585. if (!ctx) return;
  1586. // 模拟数据
  1587. const timeLabels = [];
  1588. const temperatureData = [];
  1589. const humidityData = [];
  1590. const lightData = [];
  1591. const soilData = [];
  1592. // 生成过去7天的日期标签和数据
  1593. const now = new Date();
  1594. for (let i = 6; i >= 0; i--) {
  1595. const date = new Date(now);
  1596. date.setDate(date.getDate() - i);
  1597. timeLabels.push(`${date.getMonth() + 1}/${date.getDate()}`);
  1598. // 生成模拟数据
  1599. temperatureData.push(Math.round((20 + Math.random() * 10) * 10) / 10);
  1600. humidityData.push(Math.round((50 + Math.random() * 30) * 10) / 10);
  1601. lightData.push(Math.round(500 + Math.random() * 500));
  1602. soilData.push(Math.round((20 + Math.random() * 15) * 10) / 10);
  1603. }
  1604. // 创建图表
  1605. const sensorChart = new Chart(ctx, {
  1606. type: 'line',
  1607. data: {
  1608. labels: timeLabels,
  1609. datasets: [
  1610. {
  1611. label: '温度 (°C)',
  1612. data: temperatureData,
  1613. borderColor: '#4CAF50',
  1614. backgroundColor: 'rgba(76, 175, 80, 0.1)',
  1615. borderWidth: 2,
  1616. tension: 0.3,
  1617. fill: true
  1618. },
  1619. {
  1620. label: '湿度 (%)',
  1621. data: humidityData,
  1622. borderColor: '#2196F3',
  1623. backgroundColor: 'rgba(33, 150, 243, 0.1)',
  1624. borderWidth: 2,
  1625. tension: 0.3,
  1626. fill: true
  1627. },
  1628. {
  1629. label: '光照 (lux)',
  1630. data: lightData,
  1631. borderColor: '#FFC107',
  1632. backgroundColor: 'rgba(255, 193, 7, 0.1)',
  1633. borderWidth: 2,
  1634. tension: 0.3,
  1635. fill: true,
  1636. hidden: true
  1637. },
  1638. {
  1639. label: '土壤湿度 (%)',
  1640. data: soilData,
  1641. borderColor: '#9C27B0',
  1642. backgroundColor: 'rgba(156, 39, 176, 0.1)',
  1643. borderWidth: 2,
  1644. tension: 0.3,
  1645. fill: true,
  1646. hidden: true
  1647. }
  1648. ]
  1649. },
  1650. options: {
  1651. responsive: true,
  1652. maintainAspectRatio: false,
  1653. plugins: {
  1654. legend: {
  1655. display: false
  1656. },
  1657. tooltip: {
  1658. mode: 'index',
  1659. intersect: false
  1660. }
  1661. },
  1662. scales: {
  1663. x: {
  1664. grid: {
  1665. display: false
  1666. }
  1667. },
  1668. y: {
  1669. grid: {
  1670. color: 'rgba(0, 0, 0, 0.05)'
  1671. },
  1672. beginAtZero: false
  1673. }
  1674. }
  1675. }
  1676. });
  1677. // 指标选择事件处理
  1678. document.getElementById('chart-indicator').addEventListener('change', function() {
  1679. const selectedValue = this.value;
  1680. // 重置所有数据集的可见性
  1681. if (selectedValue === 'all') {
  1682. sensorChart.data.datasets[0].hidden = false;
  1683. sensorChart.data.datasets[1].hidden = false;
  1684. sensorChart.data.datasets[2].hidden = true;
  1685. sensorChart.data.datasets[3].hidden = true;
  1686. } else {
  1687. sensorChart.data.datasets[0].hidden = selectedValue !== 'temperature';
  1688. sensorChart.data.datasets[1].hidden = selectedValue !== 'humidity';
  1689. sensorChart.data.datasets[2].hidden = selectedValue !== 'light';
  1690. sensorChart.data.datasets[3].hidden = selectedValue !== 'soil';
  1691. }
  1692. sensorChart.update();
  1693. });
  1694. // 时间范围按钮事件处理
  1695. const timeRangeBtns = document.querySelectorAll('.time-range-btn');
  1696. timeRangeBtns.forEach(function(btn) {
  1697. btn.addEventListener('click', function() {
  1698. // 更新按钮样式
  1699. timeRangeBtns.forEach(b => {
  1700. b.classList.remove('bg-green-500', 'text-white');
  1701. b.classList.add('bg-gray-200');
  1702. });
  1703. this.classList.remove('bg-gray-200');
  1704. this.classList.add('bg-green-500', 'text-white');
  1705. // 根据选择的时间范围更新图表数据
  1706. const range = this.getAttribute('data-range');
  1707. let newLabels = [];
  1708. let newTempData = [];
  1709. let newHumidityData = [];
  1710. let newLightData = [];
  1711. let newSoilData = [];
  1712. // 根据选择的时间范围生成新数据
  1713. const now = new Date();
  1714. let days = 7;
  1715. if (range === '24h') {
  1716. days = 1;
  1717. // 生成24小时的数据
  1718. for (let i = 0; i < 24; i += 2) {
  1719. const hour = i.toString().padStart(2, '0') + ':00';
  1720. newLabels.push(hour);
  1721. newTempData.push(Math.round((20 + Math.random() * 10) * 10) / 10);
  1722. newHumidityData.push(Math.round((50 + Math.random() * 30) * 10) / 10);
  1723. newLightData.push(Math.round(500 + Math.random() * 500));
  1724. newSoilData.push(Math.round((20 + Math.random() * 15) * 10) / 10);
  1725. }
  1726. } else if (range === '30d') {
  1727. days = 30;
  1728. // 生成30天的数据
  1729. for (let i = 29; i >= 0; i -= 2) {
  1730. const date = new Date(now);
  1731. date.setDate(date.getDate() - i);
  1732. newLabels.push(`${date.getMonth() + 1}/${date.getDate()}`);
  1733. newTempData.push(Math.round((20 + Math.random() * 10) * 10) / 10);
  1734. newHumidityData.push(Math.round((50 + Math.random() * 30) * 10) / 10);
  1735. newLightData.push(Math.round(500 + Math.random() * 500));
  1736. newSoilData.push(Math.round((20 + Math.random() * 15) * 10) / 10);
  1737. }
  1738. } else {
  1739. // 7天的数据
  1740. for (let i = 6; i >= 0; i--) {
  1741. const date = new Date(now);
  1742. date.setDate(date.getDate() - i);
  1743. newLabels.push(`${date.getMonth() + 1}/${date.getDate()}`);
  1744. newTempData.push(Math.round((20 + Math.random() * 10) * 10) / 10);
  1745. newHumidityData.push(Math.round((50 + Math.random() * 30) * 10) / 10);
  1746. newLightData.push(Math.round(500 + Math.random() * 500));
  1747. newSoilData.push(Math.round((20 + Math.random() * 15) * 10) / 10);
  1748. }
  1749. }
  1750. // 更新图表数据
  1751. sensorChart.data.labels = newLabels;
  1752. sensorChart.data.datasets[0].data = newTempData;
  1753. sensorChart.data.datasets[1].data = newHumidityData;
  1754. sensorChart.data.datasets[2].data = newLightData;
  1755. sensorChart.data.datasets[3].data = newSoilData;
  1756. sensorChart.update();
  1757. });
  1758. });
  1759. return sensorChart;
  1760. };
  1761. // 当点击实时数据标签页时初始化图表
  1762. document.querySelectorAll('.tab-btn').forEach(function(btn) {
  1763. btn.addEventListener('click', function() {
  1764. if (this.getAttribute('data-tab') === 'real-time-data') {
  1765. setTimeout(function() {
  1766. initSensorChart();
  1767. }, 100);
  1768. }
  1769. });
  1770. });
  1771. // 当查看按钮点击时,为传感器类型设备初始化图表
  1772. document.querySelectorAll('.view-btn').forEach(function(btn) {
  1773. btn.addEventListener('click', function() {
  1774. setTimeout(function() {
  1775. if (!document.getElementById('sensor-view').classList.contains('hidden')) {
  1776. initSensorChart();
  1777. }
  1778. if (!document.getElementById('weather-view').classList.contains('hidden')) {
  1779. initWeatherChart();
  1780. }
  1781. }, 300);
  1782. });
  1783. });
  1784. // 初始化气象图表
  1785. const initWeatherChart = function() {
  1786. const ctx = document.getElementById('weather-chart');
  1787. // 如果图表容器不存在,直接返回
  1788. if (!ctx) return;
  1789. // 模拟数据
  1790. const timeLabels = [];
  1791. const temperatureData = [];
  1792. const humidityData = [];
  1793. const rainfallData = [];
  1794. const windSpeedData = [];
  1795. // 生成过去7天的日期标签和数据
  1796. const now = new Date();
  1797. for (let i = 6; i >= 0; i--) {
  1798. const date = new Date(now);
  1799. date.setDate(date.getDate() - i);
  1800. timeLabels.push(`${date.getMonth() + 1}/${date.getDate()}`);
  1801. // 生成模拟数据
  1802. temperatureData.push(Math.round((18 + Math.random() * 10) * 10) / 10);
  1803. humidityData.push(Math.round((60 + Math.random() * 30) * 10) / 10);
  1804. rainfallData.push(Math.round(Math.random() * 10 * 10) / 10);
  1805. windSpeedData.push(Math.round((1 + Math.random() * 4) * 10) / 10);
  1806. }
  1807. // 创建图表
  1808. const weatherChart = new Chart(ctx, {
  1809. type: 'line',
  1810. data: {
  1811. labels: timeLabels,
  1812. datasets: [
  1813. {
  1814. label: '气温 (°C)',
  1815. data: temperatureData,
  1816. borderColor: '#EF4444',
  1817. backgroundColor: 'rgba(239, 68, 68, 0.1)',
  1818. borderWidth: 2,
  1819. tension: 0.3,
  1820. fill: true
  1821. },
  1822. {
  1823. label: '湿度 (%)',
  1824. data: humidityData,
  1825. borderColor: '#3B82F6',
  1826. backgroundColor: 'rgba(59, 130, 246, 0.1)',
  1827. borderWidth: 2,
  1828. tension: 0.3,
  1829. fill: true
  1830. },
  1831. {
  1832. label: '降雨量 (mm)',
  1833. data: rainfallData,
  1834. borderColor: '#2563EB',
  1835. backgroundColor: 'rgba(37, 99, 235, 0.1)',
  1836. borderWidth: 2,
  1837. tension: 0.3,
  1838. fill: true,
  1839. hidden: true
  1840. },
  1841. {
  1842. label: '风速 (m/s)',
  1843. data: windSpeedData,
  1844. borderColor: '#8B5CF6',
  1845. backgroundColor: 'rgba(139, 92, 246, 0.1)',
  1846. borderWidth: 2,
  1847. tension: 0.3,
  1848. fill: true,
  1849. hidden: true
  1850. }
  1851. ]
  1852. },
  1853. options: {
  1854. responsive: true,
  1855. maintainAspectRatio: false,
  1856. plugins: {
  1857. legend: {
  1858. display: false
  1859. },
  1860. tooltip: {
  1861. mode: 'index',
  1862. intersect: false
  1863. }
  1864. },
  1865. scales: {
  1866. x: {
  1867. grid: {
  1868. display: false
  1869. }
  1870. },
  1871. y: {
  1872. grid: {
  1873. color: 'rgba(0, 0, 0, 0.05)'
  1874. },
  1875. beginAtZero: false
  1876. }
  1877. }
  1878. }
  1879. });
  1880. // 指标选择事件处理
  1881. document.getElementById('weather-chart-indicator').addEventListener('change', function() {
  1882. const selectedValue = this.value;
  1883. // 重置所有数据集的可见性
  1884. if (selectedValue === 'all') {
  1885. weatherChart.data.datasets[0].hidden = false;
  1886. weatherChart.data.datasets[1].hidden = false;
  1887. weatherChart.data.datasets[2].hidden = true;
  1888. weatherChart.data.datasets[3].hidden = true;
  1889. } else {
  1890. weatherChart.data.datasets[0].hidden = selectedValue !== 'temperature';
  1891. weatherChart.data.datasets[1].hidden = selectedValue !== 'humidity';
  1892. weatherChart.data.datasets[2].hidden = selectedValue !== 'rainfall';
  1893. weatherChart.data.datasets[3].hidden = selectedValue !== 'windspeed';
  1894. }
  1895. weatherChart.update();
  1896. });
  1897. // 时间范围按钮事件处理
  1898. const weatherTimeRangeBtns = document.querySelectorAll('.weather-time-range-btn');
  1899. weatherTimeRangeBtns.forEach(function(btn) {
  1900. btn.addEventListener('click', function() {
  1901. // 更新按钮样式
  1902. weatherTimeRangeBtns.forEach(b => {
  1903. b.classList.remove('bg-green-500', 'text-white');
  1904. b.classList.add('bg-gray-200');
  1905. });
  1906. this.classList.remove('bg-gray-200');
  1907. this.classList.add('bg-green-500', 'text-white');
  1908. // 根据选择的时间范围更新图表数据
  1909. const range = this.getAttribute('data-range');
  1910. let newLabels = [];
  1911. let newTempData = [];
  1912. let newHumidityData = [];
  1913. let newRainfallData = [];
  1914. let newWindSpeedData = [];
  1915. // 根据选择的时间范围生成新数据
  1916. const now = new Date();
  1917. if (range === '24h') {
  1918. // 生成24小时的数据
  1919. for (let i = 0; i < 24; i += 2) {
  1920. const hour = i.toString().padStart(2, '0') + ':00';
  1921. newLabels.push(hour);
  1922. newTempData.push(Math.round((18 + Math.random() * 10) * 10) / 10);
  1923. newHumidityData.push(Math.round((60 + Math.random() * 30) * 10) / 10);
  1924. newRainfallData.push(Math.round(Math.random() * 5 * 10) / 10);
  1925. newWindSpeedData.push(Math.round((1 + Math.random() * 4) * 10) / 10);
  1926. }
  1927. } else if (range === '30d') {
  1928. // 生成30天的数据
  1929. for (let i = 29; i >= 0; i -= 2) {
  1930. const date = new Date(now);
  1931. date.setDate(date.getDate() - i);
  1932. newLabels.push(`${date.getMonth() + 1}/${date.getDate()}`);
  1933. newTempData.push(Math.round((18 + Math.random() * 10) * 10) / 10);
  1934. newHumidityData.push(Math.round((60 + Math.random() * 30) * 10) / 10);
  1935. newRainfallData.push(Math.round(Math.random() * 15 * 10) / 10);
  1936. newWindSpeedData.push(Math.round((1 + Math.random() * 4) * 10) / 10);
  1937. }
  1938. } else {
  1939. // 7天的数据
  1940. for (let i = 6; i >= 0; i--) {
  1941. const date = new Date(now);
  1942. date.setDate(date.getDate() - i);
  1943. newLabels.push(`${date.getMonth() + 1}/${date.getDate()}`);
  1944. newTempData.push(Math.round((18 + Math.random() * 10) * 10) / 10);
  1945. newHumidityData.push(Math.round((60 + Math.random() * 30) * 10) / 10);
  1946. newRainfallData.push(Math.round(Math.random() * 10 * 10) / 10);
  1947. newWindSpeedData.push(Math.round((1 + Math.random() * 4) * 10) / 10);
  1948. }
  1949. }
  1950. // 更新图表数据
  1951. weatherChart.data.labels = newLabels;
  1952. weatherChart.data.datasets[0].data = newTempData;
  1953. weatherChart.data.datasets[1].data = newHumidityData;
  1954. weatherChart.data.datasets[2].data = newRainfallData;
  1955. weatherChart.data.datasets[3].data = newWindSpeedData;
  1956. weatherChart.update();
  1957. });
  1958. });
  1959. return weatherChart;
  1960. };
  1961. });
  1962. </script>
  1963. </body>
  1964. </html>