field-management-backup.html 36 KB

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