field-management.html 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798
  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: 15px;
  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. /* 防止重复菜单 */
  45. body > div:not(.page-container):not(.modal):not(#fieldModal),
  46. iframe#sidebar,
  47. div.system-menu,
  48. [id^="system-menu"],
  49. [class^="system-menu"],
  50. #admin-sidebar,
  51. .menu-popup,
  52. .user-avatar-circle {
  53. display: none !important;
  54. }
  55. /* 防止右侧白圈和浮动元素 */
  56. .circle-btn,
  57. .floating-circle,
  58. .round-button,
  59. .scroll-top-btn,
  60. [class*="round"],
  61. [class*="circle"],
  62. .help-btn,
  63. .chat-btn,
  64. body > .btn,
  65. body > button,
  66. body > div:not(.page-container):not(.modal) {
  67. display: none !important;
  68. }
  69. /* 页面标题和操作按钮容器 */
  70. .page-header {
  71. display: flex;
  72. justify-content: space-between;
  73. align-items: center;
  74. margin-bottom: 20px;
  75. padding-bottom: 16px;
  76. border-bottom: 1px solid #e0e0e0;
  77. }
  78. .card {
  79. background-color: white;
  80. border-radius: 8px;
  81. box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  82. margin-bottom: 20px;
  83. }
  84. .table-container {
  85. position: relative;
  86. position: relative;
  87. overflow-x: auto;
  88. position: relative;
  89. }
  90. table {
  91. width: 100%;
  92. border-collapse: separate;
  93. border-spacing: 0;
  94. }
  95. th {
  96. white-space: nowrap;
  97. position: relative;
  98. overflow: visible;
  99. max-width: none;
  100. text-overflow: clip;
  101. white-space: nowrap;
  102. position: relative;
  103. background-color: #f9fafb;
  104. padding: 12px 16px;
  105. text-align: left;
  106. font-weight: 500;
  107. color: #6b7280;
  108. border-bottom: 1px solid #e5e7eb;
  109. white-space: nowrap;
  110. position: relative;
  111. }
  112. td {
  113. white-space: nowrap;
  114. max-width: 200px;
  115. overflow: hidden;
  116. text-overflow: ellipsis;
  117. white-space: nowrap;
  118. max-width: 200px;
  119. overflow: hidden;
  120. text-overflow: ellipsis;
  121. padding: 12px 16px;
  122. border-bottom: 1px solid #e5e7eb;
  123. white-space: nowrap;
  124. max-width: 200px;
  125. overflow: hidden;
  126. text-overflow: ellipsis;
  127. }
  128. /* 固定最后一列(操作列)样式 */
  129. .table-fixed-right {
  130. position: relative;
  131. }
  132. .table-fixed-right th:last-child,
  133. .table-fixed-right td:last-child {
  134. position: sticky;
  135. right: 0;
  136. z-index: 2;
  137. background-color: white;
  138. box-shadow: -5px 0 5px -5px rgba(0, 0, 0, 0.1);
  139. }
  140. .table-fixed-right th:last-child {
  141. background-color: #f9fafb;
  142. }
  143. /* 表格滚动控件 */
  144. .table-scroll-controls {
  145. display: none;
  146. position: absolute;
  147. top: 50%;
  148. transform: translateY(-50%);
  149. width: 100%;
  150. pointer-events: none;
  151. z-index: 3;
  152. }
  153. .table-scroll-btn {
  154. position: absolute;
  155. width: 32px;
  156. height: 32px;
  157. border-radius: 50%;
  158. background-color: rgba(255, 255, 255, 0.9);
  159. color: #4CAF50;
  160. border: 1px solid #e0e0e0;
  161. display: flex;
  162. align-items: center;
  163. justify-content: center;
  164. cursor: pointer;
  165. pointer-events: auto;
  166. box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  167. z-index: 4;
  168. }
  169. .table-scroll-left {
  170. left: 10px;
  171. }
  172. .table-scroll-right {
  173. right: 10px;
  174. }
  175. .has-overflow .table-scroll-controls {
  176. display: block;
  177. }
  178. tr:hover {
  179. background-color: #f9fafb;
  180. }
  181. tr:hover td:last-child {
  182. background-color: #f9fafb;
  183. }
  184. .btn {
  185. display: inline-flex;
  186. align-items: center;
  187. justify-content: center;
  188. padding: 8px 16px;
  189. border-radius: 4px;
  190. font-weight: 500;
  191. cursor: pointer;
  192. transition: all 0.2s;
  193. }
  194. .btn-primary {
  195. background-color: #4CAF50;
  196. color: white;
  197. }
  198. .btn-primary:hover {
  199. background-color: #388E3C;
  200. }
  201. .btn-default {
  202. background-color: white;
  203. border: 1px solid #d1d5db;
  204. color: #374151;
  205. }
  206. .btn-default:hover {
  207. background-color: #f9fafb;
  208. }
  209. .btn-sm {
  210. padding: 4px 8px;
  211. font-size: 12px;
  212. }
  213. .search-box {
  214. display: flex;
  215. gap: 8px;
  216. }
  217. .input {
  218. padding: 8px 12px;
  219. border: 1px solid #d1d5db;
  220. border-radius: 4px;
  221. flex-grow: 1;
  222. }
  223. .select {
  224. padding: 8px 12px;
  225. border: 1px solid #d1d5db;
  226. border-radius: 4px;
  227. background-color: white;
  228. min-width: 120px;
  229. }
  230. .badge {
  231. display: inline-block;
  232. padding: 2px 8px;
  233. border-radius: 9999px;
  234. font-size: 12px;
  235. font-weight: 500;
  236. }
  237. .badge-success {
  238. background-color: #d1fae5;
  239. color: #065f46;
  240. }
  241. .badge-warning {
  242. background-color: #fef3c7;
  243. color: #92400e;
  244. }
  245. .badge-danger {
  246. background-color: #fee2e2;
  247. color: #b91c1c;
  248. }
  249. /* 表单样式 */
  250. .form-group {
  251. margin-bottom: 16px;
  252. }
  253. .form-label {
  254. display: block;
  255. margin-bottom: 4px;
  256. font-weight: 500;
  257. }
  258. .form-input {
  259. width: 100%;
  260. padding: 8px 12px;
  261. border: 1px solid #d1d5db;
  262. border-radius: 4px;
  263. }
  264. .grid-2 {
  265. display: grid;
  266. grid-template-columns: 1fr 1fr;
  267. gap: 16px;
  268. }
  269. /* 筛选条件样式 */
  270. .filter-group {
  271. display: flex;
  272. flex-wrap: wrap;
  273. gap: 10px;
  274. margin-bottom: 15px;
  275. padding-bottom: 15px;
  276. border-bottom: 1px dashed #e5e7eb;
  277. }
  278. .filter-group:last-child {
  279. border-bottom: none;
  280. margin-bottom: 0;
  281. padding-bottom: 0;
  282. }
  283. .filter-item {
  284. display: flex;
  285. align-items: center;
  286. min-width: 180px;
  287. }
  288. .filter-label {
  289. color: #6b7280;
  290. font-size: 13px;
  291. min-width: 70px;
  292. }
  293. </style>
  294. </head>
  295. <body>
  296. <div class="page-container">
  297. <div class="page-header">
  298. <h1 class="text-2xl font-bold">地块管理</h1>
  299. <div class="flex gap-2">
  300. <button class="btn btn-primary" id="addFieldBtn">
  301. <i class="iconfont icon-plus" style="margin-right: 4px;"></i>
  302. 新增地块
  303. </button>
  304. <button class="btn btn-default" id="importBtn">
  305. <i class="iconfont icon-upload" style="margin-right: 4px;"></i>
  306. 导入
  307. </button>
  308. <button class="btn btn-default" id="exportBtn">
  309. <i class="iconfont icon-download" style="margin-right: 4px;"></i>
  310. 导出
  311. </button>
  312. </div>
  313. </div>
  314. <div class="card p-6">
  315. <div class="filter-group">
  316. <div class="filter-item">
  317. <span class="filter-label">地块编号:</span>
  318. <input type="text" class="input" placeholder="请输入地块编号关键词">
  319. </div>
  320. <div class="filter-item">
  321. <span class="filter-label">地块名称:</span>
  322. <input type="text" class="input" placeholder="请输入地块名称关键词">
  323. </div>
  324. <div class="ml-auto">
  325. <button class="btn btn-primary">
  326. <i class="iconfont icon-search" style="margin-right: 4px;"></i>
  327. 搜索
  328. </button>
  329. <button class="btn btn-default ml-2">
  330. <i class="iconfont icon-reload" style="margin-right: 4px;"></i>
  331. 重置
  332. </button>
  333. </div>
  334. </div>
  335. <div class="filter-group">
  336. <div class="filter-item">
  337. <span class="filter-label">所属农场:</span>
  338. <select class="select">
  339. <option value="">全部</option>
  340. <option value="east">东区智慧农场</option>
  341. <option value="west">西区智慧农场</option>
  342. <option value="south">南区智慧农场</option>
  343. <option value="center">中心监测农场</option>
  344. </select>
  345. </div>
  346. <div class="filter-item">
  347. <span class="filter-label">地块类型:</span>
  348. <select class="select">
  349. <option value="">全部</option>
  350. <option value="greenhouse">大棚</option>
  351. <option value="field">露天农田</option>
  352. <option value="orchard">果园</option>
  353. <option value="paddy">水稻田</option>
  354. </select>
  355. </div>
  356. <div class="filter-item">
  357. <span class="filter-label">主要作物:</span>
  358. <select class="select">
  359. <option value="">全部</option>
  360. <option value="rice">水稻</option>
  361. <option value="wheat">小麦</option>
  362. <option value="corn">玉米</option>
  363. <option value="vegetable">蔬菜</option>
  364. <option value="fruit">水果</option>
  365. </select>
  366. </div>
  367. <div class="filter-item">
  368. <span class="filter-label">状态:</span>
  369. <select class="select">
  370. <option value="">全部</option>
  371. <option value="cultivating">种植中</option>
  372. <option value="fallow">休耕</option>
  373. <option value="preparing">准备中</option>
  374. <option value="harvested">已收获</option>
  375. </select>
  376. </div>
  377. </div>
  378. </div>
  379. <div class="card">
  380. <div class="table-container">
  381. <div class="table-scroll-controls">
  382. <button class="table-scroll-btn table-scroll-left">
  383. <i class="iconfont icon-left"></i>
  384. </button>
  385. <button class="table-scroll-btn table-scroll-right">
  386. <i class="iconfont icon-right"></i>
  387. </button>
  388. </div>
  389. <table class="table-fixed-right">
  390. <thead>
  391. <tr>
  392. <th class="min-w-[120px]">地块编号</th>
  393. <th class="min-w-[120px]">地块名称</th>
  394. <th class="min-w-[120px]">所属农场</th>
  395. <th class="min-w-[100px]">地块类型</th>
  396. <th class="min-w-[120px]">主要作物</th>
  397. <th class="min-w-[90px]">面积(亩)</th>
  398. <th class="min-w-[150px]">地理位置</th>
  399. <th class="min-w-[100px]">开垦日期</th>
  400. <th class="min-w-[80px]">状态</th>
  401. <th class="min-w-[80px]">设备数量</th>
  402. <th class="min-w-[80px]">负责人</th>
  403. <th class="min-w-[150px]">操作</th>
  404. </tr>
  405. </thead>
  406. <tbody>
  407. <tr>
  408. <td>FIELD20230001</td>
  409. <td>A区大棚3号</td>
  410. <td>东区智慧农场</td>
  411. <td>大棚</td>
  412. <td>蔬菜(西红柿)</td>
  413. <td>3.5</td>
  414. <td>东经121.45,北纬31.22</td>
  415. <td>2023-01-15</td>
  416. <td><span class="badge badge-success">种植中</span></td>
  417. <td>5</td>
  418. <td>张大力</td>
  419. <td>
  420. <div class="flex gap-2">
  421. <button class="btn btn-sm btn-default view-btn" data-id="FIELD20230001">
  422. <i class="iconfont icon-eye"></i>
  423. 查看
  424. </button>
  425. <button class="btn btn-sm btn-default edit-btn" data-id="FIELD20230001">
  426. <i class="iconfont icon-edit"></i>
  427. 编辑
  428. </button>
  429. </div>
  430. </td>
  431. </tr>
  432. <tr>
  433. <td>FIELD20230002</td>
  434. <td>B区稻田2号</td>
  435. <td>西区智慧农场</td>
  436. <td>水稻田</td>
  437. <td>水稻</td>
  438. <td>15.2</td>
  439. <td>东经121.47,北纬31.24</td>
  440. <td>2023-02-20</td>
  441. <td><span class="badge badge-success">种植中</span></td>
  442. <td>8</td>
  443. <td>李耕田</td>
  444. <td>
  445. <div class="flex gap-2">
  446. <button class="btn btn-sm btn-default view-btn" data-id="FIELD20230002">
  447. <i class="iconfont icon-eye"></i>
  448. 查看
  449. </button>
  450. <button class="btn btn-sm btn-default edit-btn" data-id="FIELD20230002">
  451. <i class="iconfont icon-edit"></i>
  452. 编辑
  453. </button>
  454. </div>
  455. </td>
  456. </tr>
  457. <tr>
  458. <td>FIELD20230003</td>
  459. <td>C区果园1号</td>
  460. <td>南区智慧农场</td>
  461. <td>果园</td>
  462. <td>水果(葡萄)</td>
  463. <td>8.7</td>
  464. <td>东经121.42,北纬31.18</td>
  465. <td>2023-03-10</td>
  466. <td><span class="badge badge-warning">准备中</span></td>
  467. <td>6</td>
  468. <td>王果农</td>
  469. <td>
  470. <div class="flex gap-2">
  471. <button class="btn btn-sm btn-default view-btn" data-id="FIELD20230003">
  472. <i class="iconfont icon-eye"></i>
  473. 查看
  474. </button>
  475. <button class="btn btn-sm btn-default edit-btn" data-id="FIELD20230003">
  476. <i class="iconfont icon-edit"></i>
  477. 编辑
  478. </button>
  479. </div>
  480. </td>
  481. </tr>
  482. <tr>
  483. <td>FIELD20230004</td>
  484. <td>A区大棚1号</td>
  485. <td>东区智慧农场</td>
  486. <td>大棚</td>
  487. <td>蔬菜(黄瓜)</td>
  488. <td>2.8</td>
  489. <td>东经121.44,北纬31.21</td>
  490. <td>2023-04-05</td>
  491. <td><span class="badge badge-danger">休耕</span></td>
  492. <td>3</td>
  493. <td>张大力</td>
  494. <td>
  495. <div class="flex gap-2">
  496. <button class="btn btn-sm btn-default view-btn" data-id="FIELD20230004">
  497. <i class="iconfont icon-eye"></i>
  498. 查看
  499. </button>
  500. <button class="btn btn-sm btn-default edit-btn" data-id="FIELD20230004">
  501. <i class="iconfont icon-edit"></i>
  502. 编辑
  503. </button>
  504. </div>
  505. </td>
  506. </tr>
  507. <tr>
  508. <td>FIELD20230005</td>
  509. <td>监测区1号</td>
  510. <td>中心监测农场</td>
  511. <td>露天农田</td>
  512. <td>玉米</td>
  513. <td>10.5</td>
  514. <td>东经121.46,北纬31.23</td>
  515. <td>2023-05-20</td>
  516. <td><span class="badge badge-success">种植中</span></td>
  517. <td>10</td>
  518. <td>赵监测</td>
  519. <td>
  520. <div class="flex gap-2">
  521. <button class="btn btn-sm btn-default view-btn" data-id="FIELD20230005">
  522. <i class="iconfont icon-eye"></i>
  523. 查看
  524. </button>
  525. <button class="btn btn-sm btn-default edit-btn" data-id="FIELD20230005">
  526. <i class="iconfont icon-edit"></i>
  527. 编辑
  528. </button>
  529. </div>
  530. </td>
  531. </tr>
  532. </tbody>
  533. </table>
  534. </div>
  535. <div class="p-4 border-t border-gray-200 flex justify-between items-center">
  536. <div class="text-sm text-gray-500">显示 1 至 5,共 24 条记录</div>
  537. <div class="flex gap-1">
  538. <button class="btn btn-sm btn-default" disabled>&lt;</button>
  539. <button class="btn btn-sm btn-primary">1</button>
  540. <button class="btn btn-sm btn-default">2</button>
  541. <button class="btn btn-sm btn-default">3</button>
  542. <button class="btn btn-sm btn-default">4</button>
  543. <button class="btn btn-sm btn-default">5</button>
  544. <button class="btn btn-sm btn-default">&gt;</button>
  545. </div>
  546. </div>
  547. </div>
  548. <!-- 地块表单弹窗 -->
  549. <div class="modal" id="fieldModal" style="display: none;">
  550. <div class="modal-dialog">
  551. <div class="modal-content">
  552. <div class="modal-header">
  553. <h3 class="modal-title">添加地块</h3>
  554. <button type="button" class="modal-close" id="closeModal">&times;</button>
  555. </div>
  556. <div class="modal-body">
  557. <form id="fieldForm">
  558. <div class="grid-2">
  559. <div class="form-group">
  560. <label class="form-label">地块编号</label>
  561. <input type="text" class="form-input" id="fieldId" placeholder="输入地块编号">
  562. </div>
  563. <div class="form-group">
  564. <label class="form-label">地块名称</label>
  565. <input type="text" class="form-input" id="fieldName" placeholder="输入地块名称">
  566. </div>
  567. </div>
  568. <div class="grid-2">
  569. <div class="form-group">
  570. <label class="form-label">所属农场</label>
  571. <select class="form-input" id="farmId">
  572. <option value="">请选择所属农场</option>
  573. <option value="east">东区智慧农场</option>
  574. <option value="west">西区智慧农场</option>
  575. <option value="south">南区智慧农场</option>
  576. <option value="center">中心监测农场</option>
  577. </select>
  578. </div>
  579. <div class="form-group">
  580. <label class="form-label">地块类型</label>
  581. <select class="form-input" id="fieldType">
  582. <option value="">请选择地块类型</option>
  583. <option value="greenhouse">大棚</option>
  584. <option value="field">露天农田</option>
  585. <option value="orchard">果园</option>
  586. <option value="paddy">水稻田</option>
  587. </select>
  588. </div>
  589. </div>
  590. <div class="grid-2">
  591. <div class="form-group">
  592. <label class="form-label">主要作物</label>
  593. <input type="text" class="form-input" id="mainCrop" placeholder="输入主要作物">
  594. </div>
  595. <div class="form-group">
  596. <label class="form-label">面积(亩)</label>
  597. <input type="number" step="0.1" class="form-input" id="area" placeholder="输入面积">
  598. </div>
  599. </div>
  600. <div class="form-group">
  601. <label class="form-label">地理位置</label>
  602. <input type="text" class="form-input" id="location" placeholder="输入地理位置坐标">
  603. </div>
  604. <div class="grid-2">
  605. <div class="form-group">
  606. <label class="form-label">开垦日期</label>
  607. <input type="date" class="form-input" id="startDate">
  608. </div>
  609. <div class="form-group">
  610. <label class="form-label">状态</label>
  611. <select class="form-input" id="status">
  612. <option value="cultivating">种植中</option>
  613. <option value="fallow">休耕</option>
  614. <option value="preparing">准备中</option>
  615. <option value="harvested">已收获</option>
  616. </select>
  617. </div>
  618. </div>
  619. <div class="form-group">
  620. <label class="form-label">负责人</label>
  621. <input type="text" class="form-input" id="manager" placeholder="输入负责人姓名">
  622. </div>
  623. <div class="form-group">
  624. <label class="form-label">备注</label>
  625. <textarea class="form-input" id="remarks" rows="3" placeholder="输入备注信息"></textarea>
  626. </div>
  627. </form>
  628. </div>
  629. <div class="modal-footer">
  630. <button type="button" class="btn btn-default" id="cancelBtn">取消</button>
  631. <button type="button" class="btn btn-primary" id="saveBtn">保存</button>
  632. </div>
  633. </div>
  634. </div>
  635. </div>
  636. </div>
  637. <script>
  638. // 添加地块按钮点击事件
  639. document.getElementById('addFieldBtn').addEventListener('click', function() {
  640. document.getElementById('fieldModal').style.display = 'block';
  641. setTimeout(() => {
  642. document.getElementById('fieldModal').classList.add('show');
  643. }, 10);
  644. });
  645. // 初始化表格滚动功能
  646. function initTableScroll() {
  647. const tableContainer = document.querySelector('.table-container');
  648. const scrollLeftBtn = document.querySelector('.table-scroll-left');
  649. const scrollRightBtn = document.querySelector('.table-scroll-right');
  650. // 检查表格是否需要水平滚动
  651. function checkTableOverflow() {
  652. if (tableContainer.scrollWidth > tableContainer.clientWidth) {
  653. tableContainer.classList.add('has-overflow');
  654. } else {
  655. tableContainer.classList.remove('has-overflow');
  656. }
  657. }
  658. // 左右滚动按钮点击事件
  659. scrollLeftBtn.addEventListener('click', function() {
  660. tableContainer.scrollLeft -= 150;
  661. });
  662. scrollRightBtn.addEventListener('click', function() {
  663. tableContainer.scrollLeft += 150;
  664. });
  665. // 初始检查和窗口大小变化时检查
  666. checkTableOverflow();
  667. window.addEventListener('resize', checkTableOverflow);
  668. // 滚动事件处理
  669. tableContainer.addEventListener('scroll', function() {
  670. // 根据滚动位置显示/隐藏滚动按钮
  671. if (tableContainer.scrollLeft <= 10) {
  672. scrollLeftBtn.style.opacity = '0.5';
  673. } else {
  674. scrollLeftBtn.style.opacity = '1';
  675. }
  676. if (tableContainer.scrollLeft >= tableContainer.scrollWidth - tableContainer.clientWidth - 10) {
  677. scrollRightBtn.style.opacity = '0.5';
  678. } else {
  679. scrollRightBtn.style.opacity = '1';
  680. }
  681. });
  682. // 初始触发滚动事件,设置初始按钮状态
  683. tableContainer.dispatchEvent(new Event('scroll'));
  684. }
  685. // 页面加载完成后初始化表格滚动
  686. window.addEventListener('load', initTableScroll);
  687. // 关闭模态框
  688. document.getElementById('closeModal').addEventListener('click', function() {
  689. closeModal();
  690. });
  691. // 取消按钮点击事件
  692. document.getElementById('cancelBtn').addEventListener('click', function() {
  693. closeModal();
  694. });
  695. // 保存按钮点击事件
  696. document.getElementById('saveBtn').addEventListener('click', function() {
  697. alert('地块信息已保存');
  698. closeModal();
  699. });
  700. // 关闭模态框函数
  701. function closeModal() {
  702. document.getElementById('fieldModal').classList.remove('show');
  703. setTimeout(() => {
  704. document.getElementById('fieldModal').style.display = 'none';
  705. }, 300);
  706. }
  707. // 编辑按钮点击事件
  708. const editBtns = document.querySelectorAll('.edit-btn');
  709. editBtns.forEach(function(btn) {
  710. btn.addEventListener('click', function() {
  711. const fieldId = this.getAttribute('data-id');
  712. document.querySelector('.modal-title').textContent = '编辑地块';
  713. document.getElementById('fieldModal').style.display = 'block';
  714. setTimeout(() => {
  715. document.getElementById('fieldModal').classList.add('show');
  716. }, 10);
  717. // 这里可以根据fieldId加载地块信息
  718. });
  719. });
  720. // 查看按钮点击事件
  721. const viewBtns = document.querySelectorAll('.view-btn');
  722. viewBtns.forEach(function(btn) {
  723. btn.addEventListener('click', function() {
  724. const fieldId = this.getAttribute('data-id');
  725. window.location.href = `field-detail.html?id=${fieldId}`;
  726. });
  727. });
  728. </script>
  729. </body>
  730. </html>