device-management-content.html 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846
  1. <!DOCTYPE html>
  2. <html lang="zh-CN" class="iframe-content">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>设备管理列表 - 爱智农</title>
  7. <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css">
  8. <link rel="stylesheet" href="https://at.alicdn.com/t/font_3114978_qe0b39no76.css">
  9. <link rel="stylesheet" href="../assets/css/global.css">
  10. <style>
  11. :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. height: auto; overflow-y: auto; overflow-x: hidden;
  33. min-height: 100%;
  34. overflow-y: auto;
  35. overflow-x: hidden;
  36. padding-top: 70px; /* 增加顶部填充,确保内容不被系统导航栏遮挡 */
  37. }
  38. /* 内容页面框架 */
  39. #content-frame {
  40. width: 100%;
  41. height: 100%;
  42. border: none;
  43. overflow: hidden;
  44. margin-top: 0; /* 移除顶部外边距 */
  45. padding-top: 0; /* 移除顶部内边距 */
  46. }
  47. /* 移除白色圆形按钮 */
  48. .circle-btn,
  49. .floating-button,
  50. .round-button,
  51. button[class*='circle'],
  52. div[class*='circle'],
  53. [class*='float-btn'],
  54. body > div:not(#app),
  55. body > button {
  56. display: none !important;
  57. visibility: hidden !important;
  58. opacity: 0 !important;
  59. position: absolute !important;
  60. top: -9999px !important;
  61. left: -9999px !important;
  62. z-index: -9999 !important;
  63. pointer-events: none !important;
  64. }
  65. .page-container {
  66. padding: 20px;
  67. position: relative;
  68. min-height: 100vh;
  69. width: 100%;
  70. max-width: 100%;
  71. box-sizing: border-box;
  72. padding-top: 20px; /* 减少顶部内边距,因为body已经有较大的padding-top */
  73. display: block !important; /* 确保容器可见 */
  74. visibility: visible !important; /* 确保容器可见 */
  75. z-index: 5; /* 确保层级足够高 */
  76. }
  77. /* 防止重复菜单,但允许页面容器显示 */
  78. body > div:not(.page-container):not(.modal-overlay),
  79. iframe#sidebar,
  80. div.system-menu,
  81. [id^="system-menu"],
  82. [class^="system-menu"],
  83. #admin-sidebar,
  84. .menu-popup,
  85. .user-avatar-circle {
  86. display: none !important;
  87. }
  88. /* 防止右侧白圈和浮动元素,但允许页面内容显示 */
  89. .circle-btn,
  90. .floating-circle,
  91. .round-button,
  92. .scroll-top-btn,
  93. [class*="circle-button"],
  94. [class*="float-circle"],
  95. .help-btn,
  96. .chat-btn {
  97. display: none !important;
  98. }
  99. /* 页面标题和操作按钮容器 */
  100. .page-header {
  101. display: flex;
  102. justify-content: space-between;
  103. align-items: center;
  104. margin-bottom: 20px;
  105. padding-bottom: 16px;
  106. border-bottom: 1px solid #e0e0e0;
  107. padding-top: 10px;
  108. position: relative;
  109. z-index: 10;
  110. }
  111. /* 添加新增按钮的特定样式 */
  112. .button-container {
  113. position: relative;
  114. z-index: 20;
  115. }
  116. #addDeviceBtn,
  117. #importBtn,
  118. #exportBtn {
  119. position: relative;
  120. z-index: 5;
  121. height: 38px;
  122. visibility: visible !important;
  123. opacity: 1 !important;
  124. display: inline-flex !important;
  125. }
  126. .card {
  127. background-color: white;
  128. border-radius: 8px;
  129. box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  130. }
  131. .table-container {
  132. position: relative;
  133. position: relative;
  134. overflow-x: auto;
  135. }
  136. table {
  137. width: 100%;
  138. border-collapse: separate;
  139. border-spacing: 0;
  140. }
  141. th {
  142. white-space: nowrap;
  143. position: relative;
  144. overflow: visible;
  145. max-width: none;
  146. text-overflow: clip;
  147. white-space: nowrap;
  148. position: relative;
  149. background-color: #f9fafb;
  150. padding: 12px 16px;
  151. text-align: left;
  152. font-weight: 500;
  153. color: #6b7280;
  154. border-bottom: 1px solid #e5e7eb;
  155. }
  156. td {
  157. white-space: nowrap;
  158. max-width: 200px;
  159. overflow: hidden;
  160. text-overflow: ellipsis;
  161. white-space: nowrap;
  162. max-width: 200px;
  163. overflow: hidden;
  164. text-overflow: ellipsis;
  165. padding: 12px 16px;
  166. border-bottom: 1px solid #e5e7eb;
  167. }
  168. tr:hover {
  169. tr:hover td:last-child {
  170. background-color: #f9fafb;
  171. }
  172. /* 固定最后一列(操作列)样式 */
  173. .table-fixed-right {
  174. position: relative;
  175. }
  176. .table-fixed-right th:last-child,
  177. .table-fixed-right td:last-child {
  178. position: sticky;
  179. right: 0;
  180. z-index: 2;
  181. background-color: white;
  182. box-shadow: -5px 0 5px -5px rgba(0, 0, 0, 0.1);
  183. }
  184. .table-fixed-right th:last-child {
  185. background-color: #f9fafb;
  186. }
  187. /* 表格滚动控件 */
  188. .table-scroll-controls {
  189. display: none;
  190. position: absolute;
  191. top: 50%;
  192. transform: translateY(-50%);
  193. width: 100%;
  194. pointer-events: none;
  195. z-index: 3;
  196. }
  197. .table-scroll-btn {
  198. position: absolute;
  199. width: 32px;
  200. height: 32px;
  201. border-radius: 50%;
  202. background-color: rgba(255, 255, 255, 0.9);
  203. color: #4CAF50;
  204. border: 1px solid #e0e0e0;
  205. display: flex;
  206. align-items: center;
  207. justify-content: center;
  208. cursor: pointer;
  209. pointer-events: auto;
  210. box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  211. z-index: 4;
  212. }
  213. .table-scroll-left {
  214. left: 10px;
  215. }
  216. .table-scroll-right {
  217. right: 10px;
  218. }
  219. .has-overflow .table-scroll-controls {
  220. display: block;
  221. } background-color: #f9fafb;
  222. }
  223. .btn {
  224. display: inline-flex;
  225. align-items: center;
  226. justify-content: center;
  227. padding: 8px 16px;
  228. border-radius: 4px;
  229. font-weight: 500;
  230. cursor: pointer;
  231. transition: all 0.2s;
  232. }
  233. .btn-primary {
  234. background-color: #4CAF50;
  235. color: white;
  236. }
  237. .btn-primary:hover {
  238. background-color: #388E3C;
  239. }
  240. .btn-default {
  241. background-color: white;
  242. border: 1px solid #d1d5db;
  243. color: #374151;
  244. }
  245. .btn-default:hover {
  246. background-color: #f9fafb;
  247. }
  248. .btn-danger {
  249. background-color: #ef4444;
  250. color: white;
  251. }
  252. .btn-danger:hover {
  253. background-color: #dc2626;
  254. }
  255. .btn-sm {
  256. padding: 4px 8px;
  257. font-size: 12px;
  258. }
  259. .btn-icon {
  260. margin-right: 4px;
  261. }
  262. .search-box {
  263. display: flex;
  264. gap: 8px;
  265. }
  266. .input {
  267. padding: 8px 12px;
  268. border: 1px solid #d1d5db;
  269. border-radius: 4px;
  270. flex-grow: 1;
  271. }
  272. .input:focus {
  273. outline: none;
  274. border-color: #4CAF50;
  275. box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.2);
  276. }
  277. .select {
  278. padding: 8px 12px;
  279. border: 1px solid #d1d5db;
  280. border-radius: 4px;
  281. background-color: white;
  282. }
  283. .modal-overlay {
  284. position: fixed;
  285. top: 0;
  286. left: 0;
  287. right: 0;
  288. bottom: 0;
  289. background-color: rgba(0, 0, 0, 0.5);
  290. display: flex;
  291. align-items: center;
  292. justify-content: center;
  293. z-index: 50;
  294. display: none;
  295. }
  296. .modal {
  297. background-color: white;
  298. border-radius: 8px;
  299. width: 100%;
  300. max-width: 600px;
  301. box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  302. }
  303. .modal-header {
  304. padding: 16px 24px;
  305. border-bottom: 1px solid #e5e7eb;
  306. display: flex;
  307. align-items: center;
  308. justify-content: space-between;
  309. }
  310. .modal-title {
  311. font-size: 18px;
  312. font-weight: 500;
  313. }
  314. .modal-close {
  315. cursor: pointer;
  316. font-size: 20px;
  317. }
  318. .modal-body {
  319. padding: 24px;
  320. }
  321. .modal-footer {
  322. padding: 16px 24px;
  323. border-top: 1px solid #e5e7eb;
  324. display: flex;
  325. justify-content: flex-end;
  326. gap: 8px;
  327. }
  328. .form-group {
  329. margin-bottom: 16px;
  330. }
  331. .form-label {
  332. display: block;
  333. margin-bottom: 4px;
  334. font-weight: 500;
  335. }
  336. .form-input {
  337. width: 100%;
  338. padding: 8px 12px;
  339. border: 1px solid #d1d5db;
  340. border-radius: 4px;
  341. }
  342. .form-input:focus {
  343. outline: none;
  344. border-color: #4CAF50;
  345. box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.2);
  346. }
  347. .badge {
  348. display: inline-block;
  349. padding: 2px 8px;
  350. border-radius: 9999px;
  351. font-size: 12px;
  352. font-weight: 500;
  353. }
  354. .badge-success {
  355. background-color: #d1fae5;
  356. color: #065f46;
  357. }
  358. .badge-warning {
  359. background-color: #fef3c7;
  360. color: #92400e;
  361. }
  362. .badge-danger {
  363. background-color: #fee2e2;
  364. color: #b91c1c;
  365. }
  366. .pagination {
  367. display: flex;
  368. align-items: center;
  369. justify-content: flex-end;
  370. gap: 4px;
  371. }
  372. .pagination-item {
  373. display: inline-flex;
  374. align-items: center;
  375. justify-content: center;
  376. width: 32px;
  377. height: 32px;
  378. border-radius: 4px;
  379. cursor: pointer;
  380. transition: all 0.2s;
  381. }
  382. .pagination-item:hover {
  383. background-color: #f3f4f6;
  384. }
  385. .pagination-item.active {
  386. background-color: #4CAF50;
  387. color: white;
  388. }
  389. .pagination-item.disabled {
  390. color: #9ca3af;
  391. cursor: not-allowed;
  392. }
  393. .grid-2 {
  394. display: grid;
  395. grid-template-columns: 1fr 1fr;
  396. gap: 16px;
  397. }
  398. </style>
  399. </head>
  400. <body>
  401. <div class="page-container responsive-container">
  402. <div class="flex justify-between items-center mb-6 page-header">
  403. <h1 class="text-2xl font-bold">设备管理列表</h1>
  404. <div class="flex gap-2 button-container">
  405. <button class="btn btn-primary" id="addDeviceBtn">
  406. <i class="iconfont icon-plus btn-icon"></i>
  407. 新增设备
  408. </button>
  409. <button class="btn btn-default" id="importBtn">
  410. <i class="iconfont icon-import btn-icon"></i>
  411. 导入
  412. </button>
  413. <button class="btn btn-default" id="exportBtn">
  414. <i class="iconfont icon-export btn-icon"></i>
  415. 导出
  416. </button>
  417. </div>
  418. </div>
  419. <div class="card p-6 mb-6">
  420. <div class="flex flex-wrap gap-4">
  421. <div class="search-box flex-grow">
  422. <input type="text" class="input" placeholder="请输入设备名称/编号/位置">
  423. <button class="btn btn-primary">
  424. <i class="iconfont icon-search btn-icon"></i>
  425. 搜索
  426. </button>
  427. <button class="btn btn-default">
  428. <i class="iconfont icon-reload btn-icon"></i>
  429. 重置
  430. </button>
  431. </div>
  432. <div class="flex gap-2">
  433. <select class="select">
  434. <option value="">所有设备类型</option>
  435. <option value="sensor">传感器</option>
  436. <option value="camera">摄像头</option>
  437. <option value="controller">控制器</option>
  438. <option value="weather">气象设备</option>
  439. </select>
  440. <select class="select">
  441. <option value="">所有状态</option>
  442. <option value="1">在线</option>
  443. <option value="0">离线</option>
  444. <option value="2">维护中</option>
  445. </select>
  446. </div>
  447. </div>
  448. </div>
  449. <!-- 添加设备列表表格 -->
  450. <div class="card">
  451. <div class="table-container">
  452. <table>
  453. <thead>
  454. <tr>
  455. <th>设备ID</th>
  456. <th class="min-w-[120px]">设备名称</th>
  457. <th class="min-w-[100px]">设备类型</th>
  458. <th>所在位置</th>
  459. <th class="min-w-[100px]">安装日期</th>
  460. <th class="min-w-[80px]">状态</th>
  461. <th>最后活动</th>
  462. <th class="min-w-[150px]">操作</th>
  463. </tr>
  464. </thead>
  465. <tbody>
  466. <tr>
  467. <td>DEV20230001</td>
  468. <td>温湿度传感器-A1</td>
  469. <td>传感器</td>
  470. <td>东区大棚A区</td>
  471. <td>2023-01-15</td>
  472. <td><span class="badge badge-success">在线</span></td>
  473. <td>2023-10-15 14:30</td>
  474. <td>
  475. <div class="flex gap-2">
  476. <button class="btn btn-sm btn-default view-btn" data-id="DEV20230001">
  477. <i class="iconfont icon-eye"></i>
  478. 查看
  479. </button>
  480. <button class="btn btn-sm btn-default edit-btn" data-id="DEV20230001">
  481. <i class="iconfont icon-edit"></i>
  482. 编辑
  483. </button>
  484. </div>
  485. </td>
  486. </tr>
  487. <tr>
  488. <td>DEV20230002</td>
  489. <td>土壤湿度检测仪-B1</td>
  490. <td>传感器</td>
  491. <td>西区稻田B区</td>
  492. <td>2023-02-20</td>
  493. <td><span class="badge badge-warning">离线</span></td>
  494. <td>2023-10-10 09:15</td>
  495. <td>
  496. <div class="flex gap-2">
  497. <button class="btn btn-sm btn-default view-btn" data-id="DEV20230002">
  498. <i class="iconfont icon-eye"></i>
  499. 查看
  500. </button>
  501. <button class="btn btn-sm btn-default edit-btn" data-id="DEV20230002">
  502. <i class="iconfont icon-edit"></i>
  503. 编辑
  504. </button>
  505. </div>
  506. </td>
  507. </tr>
  508. <tr>
  509. <td>DEV20230003</td>
  510. <td>气象站-C1</td>
  511. <td>气象设备</td>
  512. <td>中心监测站</td>
  513. <td>2023-03-10</td>
  514. <td><span class="badge badge-success">在线</span></td>
  515. <td>2023-10-16 10:25</td>
  516. <td>
  517. <div class="flex gap-2">
  518. <button class="btn btn-sm btn-default view-btn" data-id="DEV20230003">
  519. <i class="iconfont icon-eye"></i>
  520. 查看
  521. </button>
  522. <button class="btn btn-sm btn-default edit-btn" data-id="DEV20230003">
  523. <i class="iconfont icon-edit"></i>
  524. 编辑
  525. </button>
  526. </div>
  527. </td>
  528. </tr>
  529. <tr>
  530. <td>DEV20230004</td>
  531. <td>智能灌溉控制器-D1</td>
  532. <td>控制器</td>
  533. <td>南区果园</td>
  534. <td>2023-04-05</td>
  535. <td><span class="badge badge-danger">故障</span></td>
  536. <td>2023-10-12 18:40</td>
  537. <td>
  538. <div class="flex gap-2">
  539. <button class="btn btn-sm btn-default view-btn" data-id="DEV20230004">
  540. <i class="iconfont icon-eye"></i>
  541. 查看
  542. </button>
  543. <button class="btn btn-sm btn-default edit-btn" data-id="DEV20230004">
  544. <i class="iconfont icon-edit"></i>
  545. 编辑
  546. </button>
  547. </div>
  548. </td>
  549. </tr>
  550. <tr>
  551. <td>DEV20230005</td>
  552. <td>作物监控摄像头-E1</td>
  553. <td>摄像头</td>
  554. <td>东区大棚B区</td>
  555. <td>2023-05-20</td>
  556. <td><span class="badge badge-success">在线</span></td>
  557. <td>2023-10-16 11:05</td>
  558. <td>
  559. <div class="flex gap-2">
  560. <button class="btn btn-sm btn-default view-btn" data-id="DEV20230005">
  561. <i class="iconfont icon-eye"></i>
  562. 查看
  563. </button>
  564. <button class="btn btn-sm btn-default edit-btn" data-id="DEV20230005">
  565. <i class="iconfont icon-edit"></i>
  566. 编辑
  567. </button>
  568. </div>
  569. </td>
  570. </tr>
  571. </tbody>
  572. </table>
  573. </div>
  574. <!-- 分页 -->
  575. <div class="p-4 border-t border-gray-200 flex justify-between items-center">
  576. <div class="text-sm text-gray-500">显示 1 至 5,共 24 条记录</div>
  577. <div class="pagination">
  578. <div class="pagination-item disabled">&lt;</div>
  579. <div class="pagination-item active">1</div>
  580. <div class="pagination-item">2</div>
  581. <div class="pagination-item">3</div>
  582. <div class="pagination-item">4</div>
  583. <div class="pagination-item">5</div>
  584. <div class="pagination-item">&gt;</div>
  585. </div>
  586. </div>
  587. </div>
  588. <!-- 设备表单弹窗 -->
  589. <div class="modal-overlay" id="deviceModal">
  590. <div class="modal">
  591. <div class="modal-header">
  592. <div class="modal-title">添加设备</div>
  593. <div class="modal-close" id="closeModal">&times;</div>
  594. </div>
  595. <div class="modal-body">
  596. <form id="deviceForm">
  597. <div class="grid-2">
  598. <div class="form-group">
  599. <label class="form-label">设备ID</label>
  600. <input type="text" class="form-input" id="deviceId" placeholder="输入设备ID">
  601. </div>
  602. <div class="form-group">
  603. <label class="form-label">设备名称</label>
  604. <input type="text" class="form-input" id="deviceName" placeholder="输入设备名称">
  605. </div>
  606. </div>
  607. <div class="grid-2">
  608. <div class="form-group">
  609. <label class="form-label">设备类型</label>
  610. <select class="form-input" id="deviceType">
  611. <option value="">请选择设备类型</option>
  612. <option value="sensor">传感器</option>
  613. <option value="camera">摄像头</option>
  614. <option value="controller">控制器</option>
  615. <option value="weather">气象设备</option>
  616. </select>
  617. </div>
  618. <div class="form-group">
  619. <label class="form-label">所在位置</label>
  620. <input type="text" class="form-input" id="deviceLocation" placeholder="输入设备位置">
  621. </div>
  622. </div>
  623. <div class="grid-2">
  624. <div class="form-group">
  625. <label class="form-label">安装日期</label>
  626. <input type="date" class="form-input" id="installDate">
  627. </div>
  628. <div class="form-group">
  629. <label class="form-label">状态</label>
  630. <select class="form-input" id="deviceStatus">
  631. <option value="1">在线</option>
  632. <option value="0">离线</option>
  633. <option value="2">维护中</option>
  634. </select>
  635. </div>
  636. </div>
  637. <div class="form-group">
  638. <label class="form-label">设备描述</label>
  639. <textarea class="form-input" id="deviceDesc" rows="3" placeholder="输入设备描述"></textarea>
  640. </div>
  641. </form>
  642. </div>
  643. <div class="modal-footer">
  644. <button class="btn btn-default" id="cancelBtn">取消</button>
  645. <button class="btn btn-primary" id="saveBtn">保存</button>
  646. </div>
  647. </div>
  648. </div>
  649. </div>
  650. <script>
  651. document.addEventListener("DOMContentLoaded", function() {
  652. // 初始化表格滚动功能
  653. function initTableScroll() {
  654. const tableContainer = document.querySelector(".table-container");
  655. if (!tableContainer) return;
  656. const scrollLeftBtn = document.querySelector(".table-scroll-left");
  657. const scrollRightBtn = document.querySelector(".table-scroll-right");
  658. if (!scrollLeftBtn || !scrollRightBtn) return;
  659. // 检查表格是否需要水平滚动
  660. function checkTableOverflow() {
  661. if (tableContainer.scrollWidth > tableContainer.clientWidth) {
  662. tableContainer.classList.add("has-overflow");
  663. } else {
  664. tableContainer.classList.remove("has-overflow");
  665. }
  666. }
  667. // 左右滚动按钮点击事件
  668. scrollLeftBtn.addEventListener("click", function() {
  669. tableContainer.scrollLeft -= 150;
  670. });
  671. scrollRightBtn.addEventListener("click", function() {
  672. tableContainer.scrollLeft += 150;
  673. });
  674. // 初始检查和窗口大小变化时检查
  675. checkTableOverflow();
  676. window.addEventListener("resize", checkTableOverflow);
  677. // 滚动事件处理
  678. tableContainer.addEventListener("scroll", function() {
  679. // 根据滚动位置显示/隐藏滚动按钮
  680. if (tableContainer.scrollLeft <= 10) {
  681. scrollLeftBtn.style.opacity = "0.5";
  682. } else {
  683. scrollLeftBtn.style.opacity = "1";
  684. }
  685. if (tableContainer.scrollLeft >= tableContainer.scrollWidth - tableContainer.clientWidth - 10) {
  686. scrollRightBtn.style.opacity = "0.5";
  687. } else {
  688. scrollRightBtn.style.opacity = "1";
  689. }
  690. });
  691. // 初始触发滚动事件,设置初始按钮状态
  692. tableContainer.dispatchEvent(new Event("scroll"));
  693. }
  694. // 初始化表格滚动
  695. initTableScroll(); // 添加设备按钮点击事件
  696. document.getElementById('addDeviceBtn').addEventListener('click', function() {
  697. document.getElementById('deviceModal').style.display = 'flex';
  698. });
  699. // 关闭模态框
  700. document.getElementById('closeModal').addEventListener('click', function() {
  701. document.getElementById('deviceModal').style.display = 'none';
  702. });
  703. // 取消按钮点击事件
  704. document.getElementById('cancelBtn').addEventListener('click', function() {
  705. document.getElementById('deviceModal').style.display = 'none';
  706. });
  707. // 保存按钮点击事件
  708. document.getElementById('saveBtn').addEventListener('click', function() {
  709. alert('设备信息已保存');
  710. document.getElementById('deviceModal').style.display = 'none';
  711. });
  712. // 编辑按钮点击事件
  713. const editBtns = document.querySelectorAll('.edit-btn');
  714. editBtns.forEach(function(btn) {
  715. btn.addEventListener('click', function() {
  716. const deviceId = this.getAttribute('data-id');
  717. document.getElementById('deviceModal').style.display = 'flex';
  718. document.querySelector('.modal-title').textContent = '编辑设备';
  719. // 这里可以根据deviceId加载设备信息
  720. });
  721. });
  722. // 查看按钮点击事件
  723. const viewBtns = document.querySelectorAll('.view-btn');
  724. viewBtns.forEach(function(btn) {
  725. btn.addEventListener('click', function() {
  726. const deviceId = this.getAttribute('data-id');
  727. alert('查看设备详情:' + deviceId);
  728. // 这里可以跳转到设备详情页面
  729. });
  730. });
  731. // 监听来自父页面的消息
  732. window.addEventListener('message', function(event) {
  733. if (event.data === 'parentReady') {
  734. console.log('父页面已就绪,内容页面显示完成');
  735. // 可以在这里添加需要在父页面加载完成后执行的代码
  736. }
  737. });
  738. // 确保页面在iframe中正确显示
  739. document.addEventListener('DOMContentLoaded', function() {
  740. // 显示页面内容,以防被CSS规则隐藏
  741. document.querySelector('.page-container').style.display = 'block';
  742. document.querySelector('.page-container').style.visibility = 'visible';
  743. document.querySelector('.page-container').style.opacity = '1';
  744. // 强制刷新布局
  745. setTimeout(function() {
  746. const tables = document.querySelectorAll('table');
  747. tables.forEach(table => {
  748. table.style.display = 'none';
  749. setTimeout(() => {
  750. table.style.display = 'table';
  751. }, 10);
  752. });
  753. // 再次确保内容可见
  754. document.body.style.display = 'block';
  755. document.body.style.visibility = 'visible';
  756. document.body.style.opacity = '1';
  757. }, 100);
  758. });
  759. </script>
  760. </body>
  761. </html>