field-management-content.html 66 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>地块管理 - 内容页面</title>
  7. <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css">
  8. <link rel="stylesheet" href="https://at.alicdn.com/t/font_3114978_qe0b39no76.css">
  9. <link rel="stylesheet" href="../assets/css/global.css">
  10. <style>
  11. :root {
  12. --primary: #4CAF50;
  13. --primary-dark: #388E3C;
  14. --primary-light: #A5D6A7;
  15. --primary-bg: #F1F8E9;
  16. --success: #4CAF50;
  17. --warning: #FFC107;
  18. --danger: #F44336;
  19. --info: #2196F3;
  20. --disabled: #9E9E9E;
  21. --border: #E0E0E0;
  22. --text-primary: #212121;
  23. --text-secondary: #757575;
  24. --radius: 8px;
  25. }
  26. /* 全局样式重置 */
  27. * {
  28. margin: 0;
  29. padding: 0;
  30. box-sizing: border-box;
  31. }
  32. /* 移除所有固定定位和绝对定位元素 */
  33. .fixed,
  34. .absolute,
  35. [style*="position: fixed"],
  36. [style*="position: absolute"] {
  37. display: none !important;
  38. }
  39. /* 移除所有圆形按钮和浮动元素 */
  40. .circle,
  41. .rounded-full,
  42. .floating,
  43. [class*="circle"],
  44. [class*="round"],
  45. [class*="float"] {
  46. display: none !important;
  47. }
  48. /* 确保内容不会溢出 */
  49. html, body {
  50. overflow-x: hidden;
  51. position: relative;
  52. }
  53. /* 移除所有可能的遮罩层 */
  54. [class*="overlay"],
  55. [class*="mask"],
  56. [style*="z-index: 9999"] {
  57. display: none !important;
  58. }
  59. /* 重置默认样式 */
  60. html, body {
  61. margin: 0;
  62. padding: 0;
  63. font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  64. height: 100%;
  65. position: relative;
  66. }
  67. body {
  68. background-color: #f5f7f9;
  69. color: var(--text-primary);
  70. overflow-x: hidden;
  71. padding-top: 15px;
  72. }
  73. /* 防止重复菜单 - 修改选择器避免影响按钮和模态框 */
  74. body > div:not(.page-container):not(.modal):not(#fieldModal),
  75. iframe#sidebar,
  76. div.system-menu,
  77. [id^="system-menu"],
  78. [class^="system-menu"],
  79. #admin-sidebar,
  80. .menu-popup,
  81. .user-avatar-circle {
  82. display: none !important;
  83. }
  84. /* 移除可能影响按钮和模态框的全局样式 */
  85. .circle-btn,
  86. .floating-circle,
  87. .round-button,
  88. .scroll-top-btn,
  89. .help-btn,
  90. .chat-btn {
  91. display: none !important;
  92. }
  93. /* 模态框样式 */
  94. .modal {
  95. display: none;
  96. position: fixed;
  97. top: 0;
  98. left: 0;
  99. right: 0;
  100. bottom: 0;
  101. width: 100%;
  102. height: 100%;
  103. background-color: rgba(0, 0, 0, 0.5);
  104. z-index: 99999;
  105. opacity: 0;
  106. visibility: hidden;
  107. transition: opacity 0.3s ease, visibility 0.3s ease;
  108. }
  109. .modal.show {
  110. display: block !important;
  111. opacity: 1 !important;
  112. visibility: visible !important;
  113. }
  114. .modal-dialog {
  115. position: fixed;
  116. top: 50%;
  117. left: 50%;
  118. transform: translate(-50%, -50%);
  119. width: 90%;
  120. max-width: 800px;
  121. margin-top: 20px;
  122. background: #fff;
  123. border-radius: 8px;
  124. z-index: 100000;
  125. box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  126. }
  127. .modal-content {
  128. background: #fff;
  129. border-radius: 8px;
  130. overflow: hidden;
  131. position: relative;
  132. }
  133. .modal-header {
  134. padding: 16px 24px;
  135. border-bottom: 1px solid #e0e0e0;
  136. display: flex;
  137. align-items: center;
  138. justify-content: space-between;
  139. background: #fff;
  140. position: sticky;
  141. top: 0;
  142. z-index: 1;
  143. }
  144. .modal-close {
  145. padding: 8px;
  146. background: none;
  147. border: none;
  148. cursor: pointer;
  149. font-size: 20px;
  150. color: #666;
  151. display: flex;
  152. align-items: center;
  153. justify-content: center;
  154. border-radius: 4px;
  155. transition: all 0.3s;
  156. }
  157. .modal-close:hover {
  158. background-color: rgba(0, 0, 0, 0.05);
  159. color: #333;
  160. }
  161. .modal-title {
  162. font-size: 18px;
  163. font-weight: 500;
  164. color: #333;
  165. margin: 0;
  166. }
  167. .modal-body {
  168. padding: 24px;
  169. max-height: calc(100vh - 200px);
  170. overflow-y: auto;
  171. background: #fff;
  172. }
  173. .modal-footer {
  174. padding: 16px 24px;
  175. border-top: 1px solid #e0e0e0;
  176. display: flex;
  177. justify-content: flex-end;
  178. gap: 12px;
  179. background: #fff;
  180. }
  181. .form-grid {
  182. display: grid;
  183. grid-template-columns: repeat(2, 1fr);
  184. gap: 20px;
  185. }
  186. .form-group {
  187. margin-bottom: 0;
  188. }
  189. .form-label {
  190. display: block;
  191. margin-bottom: 8px;
  192. font-size: 14px;
  193. color: #333;
  194. }
  195. .form-input {
  196. width: 100%;
  197. padding: 8px 12px;
  198. border: 1px solid #ddd;
  199. border-radius: 4px;
  200. font-size: 14px;
  201. transition: all 0.3s;
  202. }
  203. .form-input:focus {
  204. border-color: var(--primary);
  205. box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.1);
  206. outline: none;
  207. }
  208. .required {
  209. color: #f44336;
  210. margin-left: 4px;
  211. }
  212. /* 确保所有按钮可点击 */
  213. .action-btn,
  214. .btn,
  215. button {
  216. cursor: pointer !important;
  217. pointer-events: auto !important;
  218. position: relative;
  219. z-index: 1;
  220. }
  221. /* 移除可能影响按钮的样式 */
  222. body > div:not(.page-container):not(.modal):not(#fieldModal) {
  223. display: none !important;
  224. }
  225. /* 确保所有操作按钮可见和可交互 */
  226. .action-btn,
  227. #addFieldBtn,
  228. .btn-primary,
  229. .btn-outline,
  230. .modal button {
  231. visibility: visible !important;
  232. opacity: 1 !important;
  233. display: inline-flex !important;
  234. pointer-events: auto !important;
  235. }
  236. /* 页面容器 */
  237. .page-container {
  238. max-width: 100%;
  239. padding: 24px;
  240. padding-top: 42px;
  241. margin: 0;
  242. box-sizing: border-box;
  243. position: relative;
  244. z-index: 1;
  245. }
  246. /* 页面标题和操作按钮容器 */
  247. .page-header {
  248. display: flex;
  249. justify-content: space-between;
  250. align-items: center;
  251. margin-bottom: 20px;
  252. padding-bottom: 16px;
  253. border-bottom: 1px solid var(--border);
  254. padding-top: 10px;
  255. position: relative;
  256. }
  257. /* 添加新增按钮的特定样式 */
  258. .add-button-container {
  259. position: relative;
  260. z-index: 9999;
  261. }
  262. #addFieldBtn {
  263. position: relative;
  264. z-index: 9999 !important;
  265. visibility: visible !important;
  266. opacity: 1 !important;
  267. display: inline-flex !important;
  268. cursor: pointer;
  269. pointer-events: auto !important;
  270. }
  271. .page-title {
  272. font-size: 22px;
  273. font-weight: 600;
  274. position: relative;
  275. color: var(--text-primary);
  276. display: flex;
  277. align-items: center;
  278. margin: 0;
  279. }
  280. .page-title::before {
  281. content: "";
  282. width: 4px;
  283. height: 22px;
  284. background-color: var(--primary);
  285. margin-right: 8px;
  286. border-radius: 2px;
  287. }
  288. .search-card {
  289. background-color: #fff;
  290. border-radius: var(--radius);
  291. box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  292. padding: 16px;
  293. margin-bottom: 20px;
  294. }
  295. .search-input {
  296. width: 100%;
  297. border: 1px solid var(--border);
  298. border-radius: 4px;
  299. padding: 6px 12px;
  300. font-size: 13px;
  301. transition: all 0.3s;
  302. height: 32px;
  303. }
  304. .search-input:focus {
  305. border-color: var(--primary);
  306. box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.1);
  307. outline: none;
  308. }
  309. .form-select {
  310. width: 100%;
  311. padding: 6px 24px 6px 10px;
  312. border: 1px solid var(--border);
  313. border-radius: 4px;
  314. background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23757575' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  315. background-repeat: no-repeat;
  316. background-position: right 8px center;
  317. background-size: 14px;
  318. -webkit-appearance: none;
  319. -moz-appearance: none;
  320. appearance: none;
  321. font-size: 13px;
  322. color: #333;
  323. height: 32px;
  324. line-height: 1.2;
  325. }
  326. .form-select:focus {
  327. border-color: var(--primary);
  328. box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.1);
  329. outline: none;
  330. }
  331. /* 调整搜索区按钮样式 */
  332. .search-card .btn {
  333. height: 32px;
  334. padding: 0 16px;
  335. font-size: 13px;
  336. }
  337. .search-card .btn-icon {
  338. font-size: 14px;
  339. }
  340. /* 调整间距 */
  341. .search-card .grid.gap-4 {
  342. gap: 12px;
  343. }
  344. /* 调整搜索图标大小和位置 */
  345. .search-input + button .iconfont {
  346. font-size: 14px;
  347. }
  348. /* 调整日期输入框样式 */
  349. .search-card input[type="date"] {
  350. height: 32px;
  351. font-size: 13px;
  352. padding: 6px 10px;
  353. }
  354. /* 添加placeholder样式 */
  355. .search-input::placeholder {
  356. color: #999;
  357. font-size: 13px;
  358. }
  359. /* 调整select的placeholder颜色 */
  360. .form-select option:first-child {
  361. color: #999;
  362. }
  363. .table-card {
  364. background-color: #fff;
  365. border-radius: var(--radius);
  366. box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  367. overflow: hidden;
  368. position: relative;
  369. }
  370. .table-container {
  371. overflow-x: auto;
  372. border-radius: var(--radius);
  373. max-height: calc(100vh - 320px);
  374. min-height: 400px;
  375. overflow-y: auto;
  376. position: relative;
  377. scrollbar-width: thin;
  378. scrollbar-color: #cbd5e1 #f1f5f9;
  379. }
  380. .table-container::-webkit-scrollbar {
  381. height: 6px;
  382. width: 6px;
  383. }
  384. .table-container::-webkit-scrollbar-track {
  385. background: #f1f5f9;
  386. border-radius: 3px;
  387. }
  388. .table-container::-webkit-scrollbar-thumb {
  389. background: #cbd5e1;
  390. border-radius: 3px;
  391. }
  392. .table-container::-webkit-scrollbar-thumb:hover {
  393. background: #94a3b8;
  394. }
  395. .badge {
  396. display: inline-flex;
  397. align-items: center;
  398. padding: 2px 8px;
  399. border-radius: 12px;
  400. font-size: 12px;
  401. font-weight: 500;
  402. line-height: 1.5;
  403. }
  404. .badge-success {
  405. background-color: #dcfce7;
  406. color: #15803d;
  407. }
  408. .badge-warning {
  409. background-color: #fef9c3;
  410. color: #854d0e;
  411. }
  412. .badge-danger {
  413. background-color: #fee2e2;
  414. color: #b91c1c;
  415. }
  416. .badge-icon {
  417. margin-right: 4px;
  418. font-size: 12px;
  419. }
  420. .action-group {
  421. display: flex;
  422. gap: 8px;
  423. flex-wrap: wrap;
  424. padding: 4px 0;
  425. }
  426. .action-group + .action-group {
  427. margin-top: 4px;
  428. padding-top: 4px;
  429. border-top: 1px solid #f0f0f0;
  430. }
  431. .action-btn {
  432. display: inline-flex;
  433. align-items: center;
  434. justify-content: center;
  435. padding: 4px 8px;
  436. font-size: 13px;
  437. line-height: 1;
  438. color: #666;
  439. background: transparent;
  440. border: none;
  441. border-radius: 4px;
  442. cursor: pointer;
  443. transition: all 0.2s;
  444. white-space: nowrap;
  445. text-decoration: none;
  446. -webkit-appearance: none;
  447. -moz-appearance: none;
  448. appearance: none;
  449. }
  450. .action-btn:hover {
  451. color: var(--primary);
  452. background-color: rgba(76, 175, 80, 0.1);
  453. }
  454. .action-btn:focus {
  455. outline: none;
  456. }
  457. .action-btn i {
  458. margin-right: 4px;
  459. font-size: 14px;
  460. }
  461. .action-btn.view:hover {
  462. color: var(--primary);
  463. background-color: rgba(76, 175, 80, 0.1);
  464. }
  465. .action-btn.edit:hover {
  466. color: var(--info);
  467. background-color: rgba(33, 150, 243, 0.1);
  468. }
  469. .action-btn.delete:hover {
  470. color: var(--danger);
  471. background-color: rgba(244, 67, 54, 0.1);
  472. }
  473. /* 确保最后一列的操作按钮容器没有背景 */
  474. tr td:last-child {
  475. background: none !important;
  476. }
  477. .pagination {
  478. display: flex;
  479. align-items: center;
  480. gap: 8px;
  481. margin-top: 20px;
  482. }
  483. .pagination .page-item {
  484. width: 32px;
  485. height: 32px;
  486. display: inline-flex;
  487. align-items: center;
  488. justify-content: center;
  489. border-radius: 4px;
  490. cursor: pointer;
  491. font-size: 14px;
  492. transition: all 0.2s;
  493. }
  494. .pagination .page-item:hover {
  495. background-color: #f5f5f5;
  496. }
  497. .pagination .page-item.active {
  498. background-color: var(--primary);
  499. color: white;
  500. }
  501. .pagination .page-item.disabled {
  502. color: #ccc;
  503. cursor: not-allowed;
  504. }
  505. .count-badge {
  506. display: inline-flex;
  507. align-items: center;
  508. gap: 4px;
  509. font-size: 13px;
  510. color: #475569;
  511. padding: 2px 4px;
  512. }
  513. .count-badge i {
  514. color: #64748b;
  515. font-size: 13px;
  516. }
  517. /* 新增按钮容器样式 */
  518. .add-button-container {
  519. position: relative;
  520. z-index: 9999;
  521. }
  522. /* 新增按钮的特定样式 */
  523. #addFieldBtn {
  524. position: relative;
  525. z-index: 9999 !important;
  526. visibility: visible !important;
  527. opacity: 1 !important;
  528. display: inline-flex !important;
  529. cursor: pointer;
  530. pointer-events: auto !important;
  531. }
  532. /* 防止页面滚动 */
  533. body.modal-open {
  534. overflow: hidden;
  535. }
  536. @media (max-width: 768px) {
  537. .form-grid {
  538. grid-template-columns: 1fr;
  539. }
  540. .modal-dialog {
  541. margin: 10px;
  542. width: auto;
  543. }
  544. }
  545. /* 表格样式优化 */
  546. table {
  547. width: 100%;
  548. border-collapse: separate;
  549. border-spacing: 0;
  550. font-size: 13px;
  551. table-layout: fixed;
  552. background: transparent !important;
  553. }
  554. /* 表格行样式 */
  555. tr {
  556. background: none !important;
  557. }
  558. tr::before,
  559. tr::after {
  560. display: none !important;
  561. content: none !important;
  562. background: none !important;
  563. }
  564. /* 表格单元格基础样式 */
  565. th, td {
  566. position: relative;
  567. background: none !important;
  568. border-radius: 0 !important;
  569. -webkit-border-radius: 0 !important;
  570. -moz-border-radius: 0 !important;
  571. }
  572. td {
  573. padding: 12px 16px;
  574. border-bottom: 1px solid #e2e8f0;
  575. color: #1e293b;
  576. line-height: 1.4;
  577. vertical-align: middle;
  578. }
  579. /* 确保操作列没有任何装饰 */
  580. td:last-child {
  581. background: none !important;
  582. border-radius: 0 !important;
  583. -webkit-border-radius: 0 !important;
  584. -moz-border-radius: 0 !important;
  585. }
  586. td:last-child::before,
  587. td:last-child::after {
  588. display: none !important;
  589. content: none !important;
  590. background: none !important;
  591. }
  592. /* 操作按钮组容器样式 */
  593. .action-group {
  594. display: flex;
  595. gap: 6px;
  596. flex-wrap: wrap;
  597. justify-content: flex-start;
  598. background: none !important;
  599. position: relative;
  600. border-radius: 0 !important;
  601. -webkit-border-radius: 0 !important;
  602. -moz-border-radius: 0 !important;
  603. }
  604. .action-group::before,
  605. .action-group::after {
  606. display: none !important;
  607. content: none !important;
  608. background: none !important;
  609. }
  610. /* 操作按钮样式 */
  611. .action-btn {
  612. padding: 4px 8px;
  613. background: none !important;
  614. color: #64748b;
  615. cursor: pointer !important;
  616. transition: all 0.2s;
  617. display: inline-flex;
  618. align-items: center;
  619. border: none !important;
  620. font-size: 12px;
  621. line-height: 1;
  622. position: relative;
  623. outline: none !important;
  624. box-shadow: none !important;
  625. -webkit-appearance: none !important;
  626. -moz-appearance: none !important;
  627. appearance: none !important;
  628. border-radius: 4px !important;
  629. -webkit-border-radius: 4px !important;
  630. -moz-border-radius: 4px !important;
  631. text-decoration: none !important;
  632. }
  633. .action-btn::before,
  634. .action-btn::after {
  635. display: none !important;
  636. content: none !important;
  637. background: none !important;
  638. }
  639. /* 鼠标悬停效果 */
  640. .action-btn:hover {
  641. color: var(--primary);
  642. background-color: rgba(241, 245, 249, 0.9) !important;
  643. }
  644. .action-btn.edit:hover {
  645. color: #0284c7;
  646. background-color: rgba(240, 249, 255, 0.9) !important;
  647. }
  648. .action-btn.delete:hover {
  649. color: #dc2626;
  650. background-color: rgba(254, 242, 242, 0.9) !important;
  651. }
  652. /* 按钮图标样式 */
  653. .action-btn i {
  654. margin-right: 4px;
  655. font-size: 14px;
  656. display: inline-flex;
  657. align-items: center;
  658. justify-content: center;
  659. background: none !important;
  660. }
  661. /* 移除所有可能的装饰性样式 */
  662. .action-btn,
  663. .action-btn:focus,
  664. .action-btn:hover,
  665. .action-btn:active,
  666. .action-group,
  667. td,
  668. tr,
  669. th {
  670. text-decoration: none !important;
  671. -webkit-appearance: none !important;
  672. -moz-appearance: none !important;
  673. appearance: none !important;
  674. }
  675. /* 确保表格行交替背景色正确 */
  676. tbody tr:hover {
  677. background-color: #f8fafc !important;
  678. }
  679. tbody tr:hover td {
  680. background: none !important;
  681. }
  682. /* 移除所有可能的轮廓和装饰 */
  683. *:focus {
  684. outline: none !important;
  685. }
  686. /* 确保按钮组之间的间距正确 */
  687. .action-group + .action-group {
  688. margin-top: 4px;
  689. border-top: none !important;
  690. background: none !important;
  691. }
  692. /* 移除滚动按钮相关样式 */
  693. #scrollLeftBtn,
  694. #scrollRightBtn {
  695. display: none !important;
  696. }
  697. .w-8,
  698. .h-8,
  699. .shadow-md {
  700. display: none !important;
  701. }
  702. /* 表格容器相关样式 */
  703. .table-container-wrapper {
  704. position: relative;
  705. padding: 0 40px;
  706. }
  707. .scroll-button {
  708. position: absolute;
  709. top: 50%;
  710. transform: translateY(-50%);
  711. width: 32px;
  712. height: 32px;
  713. background: #fff;
  714. border: 1px solid #e5e7eb;
  715. border-radius: 50%;
  716. display: flex;
  717. align-items: center;
  718. justify-content: center;
  719. cursor: pointer;
  720. box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  721. z-index: 10;
  722. transition: all 0.2s;
  723. }
  724. .scroll-button:hover {
  725. background: #f9fafb;
  726. border-color: #d1d5db;
  727. }
  728. .scroll-button:disabled {
  729. opacity: 0.5;
  730. cursor: not-allowed;
  731. }
  732. .scroll-button.left {
  733. left: 4px;
  734. }
  735. .scroll-button.right {
  736. right: 4px;
  737. }
  738. .scroll-button i {
  739. font-size: 16px;
  740. color: #6b7280;
  741. }
  742. /* 确保操作按钮在一行 */
  743. .action-group {
  744. display: flex;
  745. gap: 8px;
  746. flex-wrap: nowrap;
  747. white-space: nowrap;
  748. }
  749. /* 调整表格滚动容器 */
  750. .table-container {
  751. overflow-x: auto;
  752. scrollbar-width: thin;
  753. scrollbar-color: #cbd5e1 #f1f5f9;
  754. -ms-overflow-style: none;
  755. scroll-behavior: smooth;
  756. }
  757. .table-container::-webkit-scrollbar {
  758. height: 6px;
  759. }
  760. .table-container::-webkit-scrollbar-track {
  761. background: #f1f5f9;
  762. border-radius: 3px;
  763. }
  764. .table-container::-webkit-scrollbar-thumb {
  765. background: #cbd5e1;
  766. border-radius: 3px;
  767. }
  768. .table-container::-webkit-scrollbar-thumb:hover {
  769. background: #94a3b8;
  770. }
  771. /* 调整表格最后一列宽度 */
  772. table th:last-child,
  773. table td:last-child {
  774. min-width: 200px;
  775. width: 200px;
  776. }
  777. </style>
  778. </head>
  779. <body>
  780. <div class="page-container">
  781. <!-- 页面标题和操作按钮 -->
  782. <div class="page-header">
  783. <div class="flex items-center">
  784. <h1 class="page-title">地块管理</h1>
  785. </div>
  786. <div class="add-button-container">
  787. <button type="button"
  788. class="btn btn-primary"
  789. id="addFieldBtn"
  790. onclick="showModalDialog(event)">
  791. <i class="iconfont icon-plus btn-icon"></i>新增地块
  792. </button>
  793. </div>
  794. </div>
  795. <!-- 搜索和筛选区域 -->
  796. <div class="search-card">
  797. <div class="grid grid-cols-1 gap-4">
  798. <div class="grid grid-cols-1 md:grid-cols-4 lg:grid-cols-6 gap-4">
  799. <!-- 搜索框 -->
  800. <div class="md:col-span-2 lg:col-span-2">
  801. <div class="relative">
  802. <input type="text" class="search-input" placeholder="请输入地块编号、名称、位置关键词">
  803. <button class="absolute right-2 top-1/2 transform -translate-y-1/2 text-gray-400 focus:outline-none">
  804. <i class="iconfont icon-search"></i>
  805. </button>
  806. </div>
  807. </div>
  808. <!-- 筛选项第一行 -->
  809. <div class="md:col-span-1 lg:col-span-1">
  810. <select class="form-select">
  811. <option value="">所属农场</option>
  812. <option value="1">智慧农场一号</option>
  813. <option value="2">智慧农场二号</option>
  814. <option value="3">智慧农场三号</option>
  815. <option value="4">有机蔬菜基地</option>
  816. <option value="5">生态果园基地</option>
  817. </select>
  818. </div>
  819. <div class="md:col-span-1 lg:col-span-1">
  820. <select class="form-select">
  821. <option value="">所属区域</option>
  822. <option value="1">东区</option>
  823. <option value="2">西区</option>
  824. <option value="3">南区</option>
  825. <option value="4">北区</option>
  826. </select>
  827. </div>
  828. <div class="md:col-span-1 lg:col-span-1">
  829. <select class="form-select">
  830. <option value="">使用状态</option>
  831. <option value="1">使用中</option>
  832. <option value="2">维护中</option>
  833. <option value="0">未使用</option>
  834. </select>
  835. </div>
  836. <div class="md:col-span-1 lg:col-span-1">
  837. <select class="form-select">
  838. <option value="">土壤类型</option>
  839. <option value="1">黏土</option>
  840. <option value="2">沙质土</option>
  841. <option value="3">壤土</option>
  842. <option value="4">沙壤土</option>
  843. <option value="5">其他</option>
  844. </select>
  845. </div>
  846. </div>
  847. <!-- 筛选项第二行 -->
  848. <div class="grid grid-cols-1 md:grid-cols-4 lg:grid-cols-6 gap-4">
  849. <div class="md:col-span-1 lg:col-span-1">
  850. <select class="form-select">
  851. <option value="">灌溉方式</option>
  852. <option value="1">喷灌</option>
  853. <option value="2">滴灌</option>
  854. <option value="3">微喷灌</option>
  855. <option value="4">漫灌</option>
  856. <option value="5">其他</option>
  857. </select>
  858. </div>
  859. <div class="md:col-span-1 lg:col-span-1">
  860. <select class="form-select">
  861. <option value="">种植作物</option>
  862. <optgroup label="粮食作物">
  863. <option value="101">水稻</option>
  864. <option value="102">小麦</option>
  865. <option value="103">玉米</option>
  866. <option value="104">大豆</option>
  867. <option value="105">高粱</option>
  868. <option value="106">谷子</option>
  869. </optgroup>
  870. <optgroup label="经济作物">
  871. <option value="201">棉花</option>
  872. <option value="202">油菜</option>
  873. <option value="203">花生</option>
  874. <option value="204">芝麻</option>
  875. <option value="205">甘蔗</option>
  876. <option value="206">烟草</option>
  877. <option value="207">茶叶</option>
  878. <option value="208">药材</option>
  879. </optgroup>
  880. <optgroup label="果树作物">
  881. <option value="301">葡萄</option>
  882. <option value="302">苹果</option>
  883. <option value="303">梨</option>
  884. <option value="304">桃</option>
  885. <option value="305">柑橘</option>
  886. <option value="306">枣</option>
  887. <option value="307">猕猴桃</option>
  888. <option value="308">石榴</option>
  889. <option value="309">杏</option>
  890. </optgroup>
  891. <optgroup label="蔬菜作物">
  892. <option value="401">叶菜类</option>
  893. <option value="402">根茎类</option>
  894. <option value="403">瓜果类</option>
  895. <option value="404">豆类</option>
  896. <option value="405">茄果类</option>
  897. <option value="406">葱蒜类</option>
  898. </optgroup>
  899. <optgroup label="其他作物">
  900. <option value="901">饲料作物</option>
  901. <option value="902">观赏作物</option>
  902. <option value="903">食用菌</option>
  903. <option value="999">其他</option>
  904. </optgroup>
  905. </select>
  906. </div>
  907. <div class="md:col-span-1 lg:col-span-1">
  908. <div class="relative">
  909. <input type="text" class="search-input" placeholder="负责人">
  910. </div>
  911. </div>
  912. <div class="md:col-span-1 lg:col-span-1">
  913. <div class="relative">
  914. <input type="date" class="search-input" placeholder="创建日期">
  915. </div>
  916. </div>
  917. <div class="md:col-span-2 lg:col-span-2 flex justify-end items-center gap-2">
  918. <button class="btn btn-primary">
  919. <i class="iconfont icon-search btn-icon"></i>查询
  920. </button>
  921. <button class="btn btn-outline">
  922. <i class="iconfont icon-refresh btn-icon"></i>重置
  923. </button>
  924. </div>
  925. </div>
  926. </div>
  927. </div>
  928. <!-- 表格列表 -->
  929. <div class="table-card">
  930. <div class="relative table-container-wrapper">
  931. <!-- 左滑动按钮 -->
  932. <button type="button" class="scroll-button left" id="scrollLeftBtn" disabled>
  933. <i class="iconfont icon-left"></i>
  934. </button>
  935. <!-- 右滑动按钮 -->
  936. <button type="button" class="scroll-button right" id="scrollRightBtn">
  937. <i class="iconfont icon-right"></i>
  938. </button>
  939. <!-- 表格容器 -->
  940. <div class="table-container" id="tableContainer">
  941. <table>
  942. <thead>
  943. <tr>
  944. <th class="whitespace-nowrap min-w-[120px]">地块编号</th>
  945. <th class="whitespace-nowrap min-w-[120px]">地块名称</th>
  946. <th class="whitespace-nowrap min-w-[120px]">所属农场</th>
  947. <th class="whitespace-nowrap min-w-[100px]">所属区域</th>
  948. <th class="whitespace-nowrap min-w-[100px]">地块类型</th>
  949. <th class="whitespace-nowrap min-w-[90px]">面积(亩)</th>
  950. <th class="whitespace-nowrap min-w-[120px]">种植作物</th>
  951. <th class="whitespace-nowrap min-w-[100px]">土壤类型</th>
  952. <th class="whitespace-nowrap min-w-[100px]">灌溉方式</th>
  953. <th class="whitespace-nowrap min-w-[100px]">使用状态</th>
  954. <th class="whitespace-nowrap min-w-[100px]">绑定设备</th>
  955. <th class="whitespace-nowrap min-w-[100px]">绑定人员</th>
  956. <th class="whitespace-nowrap min-w-[100px]">负责人</th>
  957. <th class="whitespace-nowrap min-w-[120px]">创建时间</th>
  958. <th class="whitespace-nowrap min-w-[120px]">上次更新</th>
  959. <th class="whitespace-nowrap min-w-[180px]">操作</th>
  960. </tr>
  961. </thead>
  962. <tbody>
  963. <tr>
  964. <td>FK20230001</td>
  965. <td>东区水稻田A</td>
  966. <td>智慧农场一号</td>
  967. <td>东区</td>
  968. <td>水田</td>
  969. <td>120</td>
  970. <td>水稻</td>
  971. <td>黏土</td>
  972. <td>喷灌</td>
  973. <td>
  974. <span class="badge badge-success">
  975. <i class="iconfont icon-check-circle badge-icon"></i>使用中
  976. </span>
  977. </td>
  978. <td>
  979. <span class="count-badge">
  980. <i class="iconfont icon-device"></i>3
  981. </span>
  982. </td>
  983. <td>
  984. <span class="count-badge">
  985. <i class="iconfont icon-user"></i>2
  986. </span>
  987. </td>
  988. <td>张三</td>
  989. <td>2023-05-15</td>
  990. <td>2023-06-20</td>
  991. <td>
  992. <div class="action-group">
  993. <button type="button" class="action-btn view" title="地块管理">
  994. <i class="iconfont icon-eye"></i>管理
  995. </button>
  996. <button type="button" class="action-btn edit" title="编辑地块">
  997. <i class="iconfont icon-edit"></i>编辑
  998. </button>
  999. <button type="button" class="action-btn delete" title="删除地块">
  1000. <i class="iconfont icon-delete"></i>删除
  1001. </button>
  1002. </div>
  1003. </td>
  1004. </tr>
  1005. <tr>
  1006. <td>FK20230002</td>
  1007. <td>西区蔬菜园B</td>
  1008. <td>有机蔬菜基地</td>
  1009. <td>西区</td>
  1010. <td>菜地</td>
  1011. <td>85</td>
  1012. <td>青菜、萝卜</td>
  1013. <td>沙质土</td>
  1014. <td>滴灌</td>
  1015. <td>
  1016. <span class="badge badge-success">
  1017. <i class="iconfont icon-check-circle badge-icon"></i>使用中
  1018. </span>
  1019. </td>
  1020. <td>
  1021. <span class="count-badge">
  1022. <i class="iconfont icon-device"></i>2
  1023. </span>
  1024. </td>
  1025. <td>
  1026. <span class="count-badge">
  1027. <i class="iconfont icon-user"></i>1
  1028. </span>
  1029. </td>
  1030. <td>李四</td>
  1031. <td>2023-05-18</td>
  1032. <td>2023-06-25</td>
  1033. <td>
  1034. <div class="action-group">
  1035. <button type="button" class="action-btn view" title="地块管理">
  1036. <i class="iconfont icon-eye"></i>管理
  1037. </button>
  1038. <button type="button" class="action-btn edit" title="编辑地块">
  1039. <i class="iconfont icon-edit"></i>编辑
  1040. </button>
  1041. <button type="button" class="action-btn delete" title="删除地块">
  1042. <i class="iconfont icon-delete"></i>删除
  1043. </button>
  1044. </div>
  1045. </td>
  1046. </tr>
  1047. <tr>
  1048. <td>FK20230003</td>
  1049. <td>南区果园C</td>
  1050. <td>生态果园基地</td>
  1051. <td>南区</td>
  1052. <td>果园</td>
  1053. <td>200</td>
  1054. <td>苹果</td>
  1055. <td>壤土</td>
  1056. <td>微喷灌</td>
  1057. <td>
  1058. <span class="badge badge-warning">
  1059. <i class="iconfont icon-warning badge-icon"></i>维护中
  1060. </span>
  1061. </td>
  1062. <td>
  1063. <span class="count-badge">
  1064. <i class="iconfont icon-device"></i>5
  1065. </span>
  1066. </td>
  1067. <td>
  1068. <span class="count-badge">
  1069. <i class="iconfont icon-user"></i>3
  1070. </span>
  1071. </td>
  1072. <td>王五</td>
  1073. <td>2023-05-20</td>
  1074. <td>2023-07-05</td>
  1075. <td>
  1076. <div class="action-group">
  1077. <button type="button" class="action-btn view" title="地块管理">
  1078. <i class="iconfont icon-eye"></i>管理
  1079. </button>
  1080. <button type="button" class="action-btn edit" title="编辑地块">
  1081. <i class="iconfont icon-edit"></i>编辑
  1082. </button>
  1083. <button type="button" class="action-btn delete" title="删除地块">
  1084. <i class="iconfont icon-delete"></i>删除
  1085. </button>
  1086. </div>
  1087. </td>
  1088. </tr>
  1089. <tr>
  1090. <td>FK20230004</td>
  1091. <td>北区小麦田D</td>
  1092. <td>智慧农场二号</td>
  1093. <td>北区</td>
  1094. <td>旱地</td>
  1095. <td>160</td>
  1096. <td>小麦</td>
  1097. <td>沙壤土</td>
  1098. <td>漫灌</td>
  1099. <td>
  1100. <span class="badge badge-danger">
  1101. <i class="iconfont icon-close-circle badge-icon"></i>未使用
  1102. </span>
  1103. </td>
  1104. <td>
  1105. <span class="count-badge">
  1106. <i class="iconfont icon-device"></i>0
  1107. </span>
  1108. </td>
  1109. <td>
  1110. <span class="count-badge">
  1111. <i class="iconfont icon-user"></i>0
  1112. </span>
  1113. </td>
  1114. <td>赵六</td>
  1115. <td>2023-06-10</td>
  1116. <td>2023-07-15</td>
  1117. <td>
  1118. <div class="action-group">
  1119. <button type="button" class="action-btn view" title="地块管理">
  1120. <i class="iconfont icon-eye"></i>管理
  1121. </button>
  1122. <button type="button" class="action-btn edit" title="编辑地块">
  1123. <i class="iconfont icon-edit"></i>编辑
  1124. </button>
  1125. <button type="button" class="action-btn delete" title="删除地块">
  1126. <i class="iconfont icon-delete"></i>删除
  1127. </button>
  1128. </div>
  1129. </td>
  1130. </tr>
  1131. </tbody>
  1132. </table>
  1133. </div>
  1134. </div>
  1135. <!-- 分页 -->
  1136. <div class="flex justify-between items-center px-6 py-4">
  1137. <div class="text-sm text-gray-600">
  1138. 共 <span class="text-primary font-medium">24</span> 条记录
  1139. </div>
  1140. <div class="pagination">
  1141. <div class="page-item disabled">
  1142. <i class="iconfont icon-left"></i>
  1143. </div>
  1144. <div class="page-item active">1</div>
  1145. <div class="page-item">2</div>
  1146. <div class="page-item">3</div>
  1147. <div class="page-item">
  1148. <i class="iconfont icon-right"></i>
  1149. </div>
  1150. </div>
  1151. </div>
  1152. </div>
  1153. </div>
  1154. <!-- 新增/编辑地块模态框 -->
  1155. <div id="fieldModal" class="modal hidden">
  1156. <div class="modal-backdrop"></div>
  1157. <div class="modal-dialog">
  1158. <div class="modal-content">
  1159. <!-- 模态框头部 -->
  1160. <div class="modal-header">
  1161. <h3 class="modal-title">新增地块</h3>
  1162. <button type="button" class="modal-close" id="closeModal">
  1163. <i class="iconfont icon-close"></i>
  1164. </button>
  1165. </div>
  1166. <!-- 模态框内容 -->
  1167. <div class="modal-body">
  1168. <form id="fieldForm">
  1169. <div class="form-grid">
  1170. <div class="form-group">
  1171. <label class="form-label">地块名称<span class="required">*</span></label>
  1172. <input type="text" name="fieldName" class="form-input" required>
  1173. </div>
  1174. <div class="form-group">
  1175. <label class="form-label">地块编号</label>
  1176. <input type="text" name="fieldCode" class="form-input" placeholder="自动生成" disabled>
  1177. </div>
  1178. <div class="form-group">
  1179. <label class="form-label">所属农场<span class="required">*</span></label>
  1180. <select name="farmId" class="form-input" required>
  1181. <option value="">请选择农场</option>
  1182. <option value="1">智慧农场一号</option>
  1183. <option value="2">智慧农场二号</option>
  1184. <option value="3">智慧农场三号</option>
  1185. <option value="4">有机蔬菜基地</option>
  1186. <option value="5">生态果园基地</option>
  1187. </select>
  1188. </div>
  1189. <div class="form-group">
  1190. <label class="form-label">所属区域<span class="required">*</span></label>
  1191. <select name="fieldArea" class="form-input" required>
  1192. <option value="">请选择区域</option>
  1193. <option value="1">东区</option>
  1194. <option value="2">西区</option>
  1195. <option value="3">南区</option>
  1196. <option value="4">北区</option>
  1197. </select>
  1198. </div>
  1199. <div class="form-group">
  1200. <label class="form-label">地块类型<span class="required">*</span></label>
  1201. <select name="fieldType" class="form-input" required>
  1202. <option value="">请选择类型</option>
  1203. <option value="1">水田</option>
  1204. <option value="2">旱地</option>
  1205. <option value="3">果园</option>
  1206. <option value="4">菜地</option>
  1207. <option value="5">其他</option>
  1208. </select>
  1209. </div>
  1210. <div class="form-group">
  1211. <label class="form-label">面积(亩)<span class="required">*</span></label>
  1212. <input type="number" name="fieldSize" class="form-input" required>
  1213. </div>
  1214. <div class="form-group">
  1215. <label class="form-label">负责人</label>
  1216. <select name="manager" class="form-input">
  1217. <option value="">请选择负责人</option>
  1218. <option value="1">张三</option>
  1219. <option value="2">李四</option>
  1220. <option value="3">王五</option>
  1221. <option value="4">赵六</option>
  1222. </select>
  1223. </div>
  1224. <div class="form-group">
  1225. <label class="form-label">种植作物</label>
  1226. <select name="crops" class="form-input">
  1227. <option value="">请选择作物</option>
  1228. <optgroup label="粮食作物">
  1229. <option value="101">水稻</option>
  1230. <option value="102">小麦</option>
  1231. <option value="103">玉米</option>
  1232. <option value="104">大豆</option>
  1233. <option value="105">高粱</option>
  1234. <option value="106">谷子</option>
  1235. </optgroup>
  1236. <optgroup label="经济作物">
  1237. <option value="201">棉花</option>
  1238. <option value="202">油菜</option>
  1239. <option value="203">花生</option>
  1240. <option value="204">芝麻</option>
  1241. <option value="205">甘蔗</option>
  1242. <option value="206">烟草</option>
  1243. <option value="207">茶叶</option>
  1244. <option value="208">药材</option>
  1245. </optgroup>
  1246. <optgroup label="果树作物">
  1247. <option value="301">葡萄</option>
  1248. <option value="302">苹果</option>
  1249. <option value="303">梨</option>
  1250. <option value="304">桃</option>
  1251. <option value="305">柑橘</option>
  1252. <option value="306">枣</option>
  1253. <option value="307">猕猴桃</option>
  1254. <option value="308">石榴</option>
  1255. <option value="309">杏</option>
  1256. </optgroup>
  1257. <optgroup label="蔬菜作物">
  1258. <option value="401">叶菜类</option>
  1259. <option value="402">根茎类</option>
  1260. <option value="403">瓜果类</option>
  1261. <option value="404">豆类</option>
  1262. <option value="405">茄果类</option>
  1263. <option value="406">葱蒜类</option>
  1264. </optgroup>
  1265. <optgroup label="其他作物">
  1266. <option value="901">饲料作物</option>
  1267. <option value="902">观赏作物</option>
  1268. <option value="903">食用菌</option>
  1269. <option value="999">其他</option>
  1270. </optgroup>
  1271. </select>
  1272. </div>
  1273. <div class="form-group">
  1274. <label class="form-label">土壤类型</label>
  1275. <select name="soilType" class="form-input">
  1276. <option value="">请选择</option>
  1277. <option value="1">黏土</option>
  1278. <option value="2">沙质土</option>
  1279. <option value="3">壤土</option>
  1280. <option value="4">沙壤土</option>
  1281. <option value="5">其他</option>
  1282. </select>
  1283. </div>
  1284. <div class="form-group">
  1285. <label class="form-label">灌溉方式</label>
  1286. <select name="irrigationType" class="form-input">
  1287. <option value="">请选择</option>
  1288. <option value="1">喷灌</option>
  1289. <option value="2">滴灌</option>
  1290. <option value="3">微喷灌</option>
  1291. <option value="4">漫灌</option>
  1292. <option value="5">其他</option>
  1293. </select>
  1294. </div>
  1295. <div class="form-group">
  1296. <label class="form-label">使用状态</label>
  1297. <select name="status" class="form-input">
  1298. <option value="1">使用中</option>
  1299. <option value="2">维护中</option>
  1300. <option value="0">未使用</option>
  1301. <option value="3">闲置中</option>
  1302. <option value="4">待开发</option>
  1303. </select>
  1304. </div>
  1305. </div>
  1306. <div class="form-group mt-4">
  1307. <label class="form-label">地块描述</label>
  1308. <textarea name="description" class="form-input" rows="4"></textarea>
  1309. </div>
  1310. </form>
  1311. </div>
  1312. <!-- 模态框底部 -->
  1313. <div class="modal-footer">
  1314. <button type="button" class="btn btn-outline" id="cancelBtn">取消</button>
  1315. <button type="button" class="btn btn-primary" id="saveBtn">保存</button>
  1316. </div>
  1317. </div>
  1318. </div>
  1319. </div>
  1320. <script>
  1321. // 页面跳转函数
  1322. function navigateTo(type, id) {
  1323. switch(type) {
  1324. case 'view':
  1325. window.location.href = `../pages/field-detail.html?id=${id}`;
  1326. break;
  1327. case 'edit':
  1328. window.location.href = `../pages/field-edit.html?id=${id}`;
  1329. break;
  1330. }
  1331. }
  1332. // 全局函数,用于显示模态框
  1333. function showModalDialog(event, type = 'add', rowData = null) {
  1334. console.log('showModalDialog called', {type, rowData});
  1335. try {
  1336. if (event) {
  1337. event.preventDefault();
  1338. event.stopPropagation();
  1339. }
  1340. const modal = document.getElementById('fieldModal');
  1341. if (!modal) {
  1342. console.error('Modal not found');
  1343. return;
  1344. }
  1345. // 设置模态框标题
  1346. const modalTitle = modal.querySelector('.modal-title');
  1347. if (modalTitle) {
  1348. modalTitle.textContent = type === 'edit' ? '编辑地块' : '新增地块';
  1349. }
  1350. // 如果是编辑模式,预填充表单数据
  1351. if (type === 'edit') {
  1352. // 这里使用模拟数据,实际项目中应该从后端获取
  1353. const mockFieldData = {
  1354. fieldName: '西区蔬菜园B',
  1355. fieldCode: 'FK20230002',
  1356. farmId: '4', // 有机蔬菜基地
  1357. fieldArea: '2', // 西区
  1358. fieldType: '4', // 菜地
  1359. fieldSize: '85',
  1360. manager: '2', // 李四
  1361. crops: '401', // 叶菜类
  1362. soilType: '2', // 沙质土
  1363. irrigationType: '2', // 滴灌
  1364. status: '1', // 使用中
  1365. description: '这是一个示例地块描述。'
  1366. };
  1367. const form = document.getElementById('fieldForm');
  1368. if (form) {
  1369. Object.keys(mockFieldData).forEach(key => {
  1370. const input = form.elements[key];
  1371. if (input) {
  1372. input.value = mockFieldData[key];
  1373. }
  1374. });
  1375. }
  1376. }
  1377. // 显示模态框
  1378. modal.style.cssText = 'display: block !important; opacity: 1 !important; visibility: visible !important;';
  1379. modal.classList.remove('hidden');
  1380. modal.classList.add('show');
  1381. document.body.classList.add('modal-open');
  1382. } catch (error) {
  1383. console.error('Error in showModalDialog:', error);
  1384. }
  1385. }
  1386. document.addEventListener('DOMContentLoaded', function() {
  1387. console.log('DOM Content Loaded');
  1388. // 添加按钮点击事件
  1389. const addButton = document.getElementById('addFieldBtn');
  1390. if (addButton) {
  1391. addButton.addEventListener('click', e => showModalDialog(e, 'add'));
  1392. }
  1393. // 为所有操作按钮添加事件监听
  1394. document.querySelectorAll('.action-btn').forEach(btn => {
  1395. btn.addEventListener('click', function(e) {
  1396. e.preventDefault();
  1397. e.stopPropagation();
  1398. let type = 'add';
  1399. if (this.classList.contains('view')) {
  1400. type = 'view';
  1401. navigateTo(type, this.getAttribute('data-id'));
  1402. } else if (this.classList.contains('edit')) {
  1403. type = 'edit';
  1404. showModalDialog(e, type, {id: this.getAttribute('data-id')});
  1405. } else if (this.classList.contains('delete')) {
  1406. if (confirm('确认要删除该地块吗?')) {
  1407. console.log('删除地块:', this.getAttribute('data-id'));
  1408. // 这里添加删除逻辑
  1409. }
  1410. }
  1411. });
  1412. });
  1413. // 模态框关闭逻辑
  1414. const modal = document.getElementById('fieldModal');
  1415. const closeBtn = document.getElementById('closeModal');
  1416. const cancelBtn = document.getElementById('cancelBtn');
  1417. const form = document.getElementById('fieldForm');
  1418. function hideModal(e) {
  1419. if (e) {
  1420. e.preventDefault();
  1421. e.stopPropagation();
  1422. }
  1423. if (!modal) return;
  1424. // 强制隐藏模态框
  1425. modal.style.cssText = 'display: none !important; opacity: 0 !important; visibility: hidden !important;';
  1426. modal.classList.remove('show');
  1427. modal.classList.add('hidden');
  1428. document.body.classList.remove('modal-open');
  1429. // 重置表单
  1430. if (form) {
  1431. form.reset();
  1432. const inputs = form.querySelectorAll('input, select, textarea');
  1433. inputs.forEach(input => {
  1434. input.disabled = false;
  1435. input.style.borderColor = '#ddd';
  1436. });
  1437. }
  1438. }
  1439. // 关闭按钮事件
  1440. if (closeBtn) {
  1441. closeBtn.onclick = hideModal;
  1442. }
  1443. // 取消按钮事件
  1444. if (cancelBtn) {
  1445. cancelBtn.onclick = hideModal;
  1446. }
  1447. // 点击背景关闭
  1448. if (modal) {
  1449. modal.onclick = function(e) {
  1450. if (e.target === modal || e.target.classList.contains('modal-backdrop')) {
  1451. hideModal(e);
  1452. }
  1453. };
  1454. }
  1455. // 保存按钮点击事件
  1456. const saveBtn = document.getElementById('saveBtn');
  1457. if (saveBtn) {
  1458. saveBtn.onclick = function(e) {
  1459. e.preventDefault();
  1460. e.stopPropagation();
  1461. if (!form) return;
  1462. const requiredFields = form.querySelectorAll('[required]');
  1463. let isValid = true;
  1464. requiredFields.forEach(field => {
  1465. if (!field.value.trim()) {
  1466. field.style.borderColor = '#f44336';
  1467. isValid = false;
  1468. } else {
  1469. field.style.borderColor = '#ddd';
  1470. }
  1471. });
  1472. if (!isValid) {
  1473. alert('请填写必填项');
  1474. return;
  1475. }
  1476. alert('地块信息保存成功');
  1477. hideModal(e);
  1478. };
  1479. }
  1480. // 防止表单提交
  1481. if (form) {
  1482. form.onsubmit = function(e) {
  1483. e.preventDefault();
  1484. return false;
  1485. };
  1486. }
  1487. // 获取滚动相关元素
  1488. const tableContainer = document.getElementById('tableContainer');
  1489. const scrollLeftBtn = document.getElementById('scrollLeftBtn');
  1490. const scrollRightBtn = document.getElementById('scrollRightBtn');
  1491. // 更新滚动按钮状态
  1492. function updateScrollButtons() {
  1493. if (tableContainer) {
  1494. const { scrollLeft, scrollWidth, clientWidth } = tableContainer;
  1495. // 更新左滚动按钮状态
  1496. if (scrollLeftBtn) {
  1497. scrollLeftBtn.disabled = scrollLeft <= 0;
  1498. }
  1499. // 更新右滚动按钮状态
  1500. if (scrollRightBtn) {
  1501. scrollRightBtn.disabled = scrollLeft + clientWidth >= scrollWidth;
  1502. }
  1503. }
  1504. }
  1505. // 初始化滚动按钮状态
  1506. updateScrollButtons();
  1507. // 监听滚动事件
  1508. if (tableContainer) {
  1509. tableContainer.addEventListener('scroll', updateScrollButtons);
  1510. }
  1511. // 左滚动按钮点击事件
  1512. if (scrollLeftBtn) {
  1513. scrollLeftBtn.addEventListener('click', () => {
  1514. if (tableContainer) {
  1515. tableContainer.scrollLeft -= 200; // 每次滚动200px
  1516. }
  1517. });
  1518. }
  1519. // 右滚动按钮点击事件
  1520. if (scrollRightBtn) {
  1521. scrollRightBtn.addEventListener('click', () => {
  1522. if (tableContainer) {
  1523. tableContainer.scrollLeft += 200; // 每次滚动200px
  1524. }
  1525. });
  1526. }
  1527. // 监听窗口大小变化
  1528. window.addEventListener('resize', updateScrollButtons);
  1529. });
  1530. // 添加全局错误处理
  1531. window.onerror = function(msg, url, line, col, error) {
  1532. console.error('Global error:', {msg, url, line, col, error});
  1533. return false;
  1534. };
  1535. </script>
  1536. </body>
  1537. </html>