| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920 |
- <!DOCTYPE html>
- <html lang="zh-CN">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>地块管理 - 爱智农</title>
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css">
- <link rel="stylesheet" href="https://at.alicdn.com/t/font_3114978_qe0b39no76.css">
- <link rel="stylesheet" href="../assets/css/global.css">
- <style>
- :root {
- --primary: #4CAF50;
- --primary-dark: #388E3C;
- --primary-light: #A5D6A7;
- --primary-bg: #F1F8E9;
- --success: #4CAF50;
- --warning: #FFC107;
- --danger: #F44336;
- --info: #2196F3;
- --disabled: #9E9E9E;
- --border: #E0E0E0;
- --text-primary: #212121;
- --text-secondary: #757575;
- --radius: 8px;
- }
-
- body {
- font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
- background-color: #f5f7f9;
- color: var(--text-primary);
- margin: 0;
- padding: 0;
- min-height: 100vh;
- padding-top: 15px;
- }
-
- .page-container {
- padding: 20px;
- position: relative;
- min-height: 100vh;
- width: 100%;
- max-width: 1400px;
- margin: 0 auto;
- box-sizing: border-box;
- }
-
- /* 防止重复菜单 */
- body > div:not(.page-container):not(.modal):not(#fieldModal),
- iframe#sidebar,
- div.system-menu,
- [id^="system-menu"],
- [class^="system-menu"],
- #admin-sidebar,
- .menu-popup,
- .user-avatar-circle {
- display: none !important;
- }
-
- /* 防止右侧白圈和浮动元素 */
- .circle-btn,
- .floating-circle,
- .round-button,
- .scroll-top-btn,
- [class*="round"],
- [class*="circle"],
- .help-btn,
- .chat-btn,
- body > .btn,
- body > button,
- body > div:not(.page-container):not(.modal) {
- display: none !important;
- }
-
- /* 页面标题和操作按钮容器 */
- .page-header {
- display: flex;
- justify-content: space-between;
- align-items: center;
- margin-bottom: 20px;
- padding-bottom: 16px;
- border-bottom: 1px solid #e0e0e0;
- }
-
- .card {
- background-color: white;
- border-radius: 8px;
- box-shadow: 0 2px 8px rgba(0,0,0,0.05);
- margin-bottom: 20px;
- }
-
- .table-container {
- position: relative;
- position: relative;
- overflow-x: auto;
- position: relative;
- }
-
- .table-scroll-container {
- overflow-x: auto;
- margin-left: 150px; /* 第一列宽度 */
- position: relative;
- }
-
- table {
- width: 100%;
- border-collapse: separate;
- border-spacing: 0;
- table-layout: fixed;
- }
-
- thead {
- position: sticky;
- top: 0;
- z-index: 10;
- background-color: #f9fafb;
- }
-
- th, td {
- white-space: nowrap;
- max-width: 200px;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- max-width: 200px;
- overflow: hidden;
- text-overflow: ellipsis;
- padding: 12px 16px;
- text-align: left;
- white-space: nowrap;
- }
-
- th {
- white-space: nowrap;
- position: relative;
- overflow: visible;
- max-width: none;
- text-overflow: clip;
- white-space: nowrap;
- position: relative;
- background-color: #f9fafb;
- font-weight: 500;
- color: #6b7280;
- border-bottom: 1px solid #e5e7eb;
- }
-
- td {
- white-space: nowrap;
- max-width: 200px;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- max-width: 200px;
- overflow: hidden;
- text-overflow: ellipsis;
- border-bottom: 1px solid #e5e7eb;
- }
-
- tr:hover {
-
- tr:hover td:last-child {
- background-color: #f9fafb;
- }
-
- /* 固定最后一列(操作列)样式 */
- .table-fixed-right {
- position: relative;
- }
-
- .table-fixed-right th:last-child,
- .table-fixed-right td:last-child {
- position: sticky;
- right: 0;
- z-index: 2;
- background-color: white;
- box-shadow: -5px 0 5px -5px rgba(0, 0, 0, 0.1);
- }
-
- .table-fixed-right th:last-child {
- background-color: #f9fafb;
- }
-
- /* 表格滚动控件 */
- .table-scroll-controls {
- display: none;
- position: absolute;
- top: 50%;
- transform: translateY(-50%);
- width: 100%;
- pointer-events: none;
- z-index: 3;
- }
-
- .table-scroll-btn {
- position: absolute;
- width: 32px;
- height: 32px;
- border-radius: 50%;
- background-color: rgba(255, 255, 255, 0.9);
- color: #4CAF50;
- border: 1px solid #e0e0e0;
- display: flex;
- align-items: center;
- justify-content: center;
- cursor: pointer;
- pointer-events: auto;
- box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
- z-index: 4;
- }
-
- .table-scroll-left {
- left: 10px;
- }
-
- .table-scroll-right {
- right: 10px;
- }
-
- .has-overflow .table-scroll-controls {
- display: block;
- } background-color: #f9fafb;
- }
-
- /* 固定第一列 */
- .table-container .fixed-column {
- position: absolute;
- left: 0;
- top: auto;
- width: 150px;
- background-color: white;
- z-index: 5;
- border-right: 1px solid #e5e7eb;
- }
-
- .table-container .fixed-column-header {
- position: sticky;
- top: 0;
- z-index: 15;
- background-color: #f9fafb;
- }
-
- /* 固定最后一列 */
- .fixed-last-column {
- position: absolute;
- right: 0;
- top: auto;
- width: 150px;
- background-color: white;
- z-index: 5;
- border-left: 1px solid #e5e7eb;
- }
-
- .fixed-last-column-header {
- position: sticky;
- top: 0;
- z-index: 15;
- background-color: #f9fafb;
- }
-
- /* 滚动控制 */
- .horizontal-scroll-controls {
- display: flex;
- justify-content: center;
- margin-top: 8px;
- gap: 8px;
- }
-
- .scroll-button {
- background-color: #f3f4f6;
- border: 1px solid #d1d5db;
- border-radius: 4px;
- padding: 4px 8px;
- cursor: pointer;
- }
-
- .scroll-button:hover {
- background-color: #e5e7eb;
- }
-
- .btn {
- display: inline-flex;
- align-items: center;
- justify-content: center;
- padding: 8px 16px;
- border-radius: 4px;
- font-weight: 500;
- cursor: pointer;
- transition: all 0.2s;
- }
-
- .btn-primary {
- background-color: #4CAF50;
- color: white;
- }
-
- .btn-primary:hover {
- background-color: #388E3C;
- }
-
- .btn-default {
- background-color: white;
- border: 1px solid #d1d5db;
- color: #374151;
- }
-
- .btn-default:hover {
- background-color: #f9fafb;
- }
-
- .btn-sm {
- padding: 4px 8px;
- font-size: 12px;
- }
-
- .search-box {
- display: flex;
- gap: 8px;
- }
-
- .input {
- padding: 8px 12px;
- border: 1px solid #d1d5db;
- border-radius: 4px;
- flex-grow: 1;
- }
-
- .select {
- padding: 8px 12px;
- border: 1px solid #d1d5db;
- border-radius: 4px;
- background-color: white;
- min-width: 120px;
- }
-
- .badge {
- display: inline-block;
- padding: 2px 8px;
- border-radius: 9999px;
- font-size: 12px;
- font-weight: 500;
- }
-
- .badge-success {
- background-color: #d1fae5;
- color: #065f46;
- }
-
- .badge-warning {
- background-color: #fef3c7;
- color: #92400e;
- }
-
- .badge-danger {
- background-color: #fee2e2;
- color: #b91c1c;
- }
-
- /* 表单样式 */
- .form-group {
- margin-bottom: 16px;
- }
-
- .form-label {
- display: block;
- margin-bottom: 4px;
- font-weight: 500;
- }
-
- .form-input {
- width: 100%;
- padding: 8px 12px;
- border: 1px solid #d1d5db;
- border-radius: 4px;
- }
-
- .grid-2 {
- display: grid;
- grid-template-columns: 1fr 1fr;
- gap: 16px;
- }
-
- /* 筛选条件样式 */
- .filter-group {
- display: flex;
- flex-wrap: wrap;
- gap: 10px;
- margin-bottom: 15px;
- padding-bottom: 15px;
- border-bottom: 1px dashed #e5e7eb;
- }
-
- .filter-group:last-child {
- border-bottom: none;
- margin-bottom: 0;
- padding-bottom: 0;
- }
-
- .filter-item {
- display: flex;
- align-items: center;
- min-width: 180px;
- }
-
- .filter-label {
- color: #6b7280;
- font-size: 13px;
- min-width: 70px;
- }
- </style>
- </head>
- <body>
- <div class="page-container">
- <div class="page-header">
- <h1 class="text-2xl font-bold">地块管理</h1>
-
- <div class="flex gap-2">
- <button class="btn btn-primary" id="addFieldBtn">
- <i class="iconfont icon-plus" style="margin-right: 4px;"></i>
- 新增地块
- </button>
- <button class="btn btn-default" id="importBtn">
- <i class="iconfont icon-upload" style="margin-right: 4px;"></i>
- 导入
- </button>
- <button class="btn btn-default" id="exportBtn">
- <i class="iconfont icon-download" style="margin-right: 4px;"></i>
- 导出
- </button>
- </div>
- </div>
-
- <div class="card p-6">
- <div class="filter-group">
- <div class="filter-item">
- <span class="filter-label">地块编号:</span>
- <input type="text" class="input" placeholder="请输入地块编号关键词">
- </div>
-
- <div class="filter-item">
- <span class="filter-label">地块名称:</span>
- <input type="text" class="input" placeholder="请输入地块名称关键词">
- </div>
-
- <div class="ml-auto">
- <button class="btn btn-primary">
- <i class="iconfont icon-search" style="margin-right: 4px;"></i>
- 搜索
- </button>
- <button class="btn btn-default ml-2">
- <i class="iconfont icon-reload" style="margin-right: 4px;"></i>
- 重置
- </button>
- </div>
- </div>
-
- <div class="filter-group">
- <div class="filter-item">
- <span class="filter-label">所属农场:</span>
- <select class="select">
- <option value="">全部</option>
- <option value="east">东区智慧农场</option>
- <option value="west">西区智慧农场</option>
- <option value="south">南区智慧农场</option>
- <option value="center">中心监测农场</option>
- </select>
- </div>
-
- <div class="filter-item">
- <span class="filter-label">地块类型:</span>
- <select class="select">
- <option value="">全部</option>
- <option value="greenhouse">大棚</option>
- <option value="field">露天农田</option>
- <option value="orchard">果园</option>
- <option value="paddy">水稻田</option>
- </select>
- </div>
-
- <div class="filter-item">
- <span class="filter-label">主要作物:</span>
- <select class="select">
- <option value="">全部</option>
- <option value="rice">水稻</option>
- <option value="wheat">小麦</option>
- <option value="corn">玉米</option>
- <option value="vegetable">蔬菜</option>
- <option value="fruit">水果</option>
- </select>
- </div>
-
- <div class="filter-item">
- <span class="filter-label">状态:</span>
- <select class="select">
- <option value="">全部</option>
- <option value="cultivating">种植中</option>
- <option value="fallow">休耕</option>
- <option value="preparing">准备中</option>
- <option value="harvested">已收获</option>
- </select>
- </div>
- </div>
- </div>
-
- <div class="card">
- <div class="table-container">
- <!-- 固定第一列 -->
- <table class="fixed-column">
- <thead>
- <tr>
- <th class="fixed-column-header">地块编号</th>
- </tr>
- </thead>
- <tbody>
- <tr><td>FIELD20230001</td></tr>
- <tr><td>FIELD20230002</td></tr>
- <tr><td>FIELD20230003</td></tr>
- <tr><td>FIELD20230004</td></tr>
- <tr><td>FIELD20230005</td></tr>
- </tbody>
- </table>
-
- <div class="table-scroll-container" id="tableScrollContainer">
- <table>
- <thead>
- <tr>
- <th class="min-w-[120px]">地块名称</th>
- <th class="min-w-[120px]">所属农场</th>
- <th class="min-w-[100px]">地块类型</th>
- <th class="min-w-[120px]">主要作物</th>
- <th class="min-w-[90px]">面积(亩)</th>
- <th class="min-w-[150px]">地理位置</th>
- <th class="min-w-[100px]">开垦日期</th>
- <th class="min-w-[80px]">状态</th>
- <th class="min-w-[80px]">设备数量</th>
- <th class="min-w-[100px]">负责人</th>
- <th class="fixed-last-column-header">操作</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>A区大棚3号</td>
- <td>东区智慧农场</td>
- <td>大棚</td>
- <td>蔬菜(西红柿)</td>
- <td>3.5</td>
- <td>东经121.45,北纬31.22</td>
- <td>2023-01-15</td>
- <td><span class="badge badge-success">种植中</span></td>
- <td>5</td>
- <td>张大力</td>
- <td class="fixed-last-column">
- <div class="flex gap-2">
- <button class="btn btn-sm btn-default view-btn" data-id="FIELD20230001">
- <i class="iconfont icon-eye"></i>
- 查看
- </button>
- <button class="btn btn-sm btn-default edit-btn" data-id="FIELD20230001">
- <i class="iconfont icon-edit"></i>
- 编辑
- </button>
- </div>
- </td>
- </tr>
- <tr>
- <td>B区稻田2号</td>
- <td>西区智慧农场</td>
- <td>水稻田</td>
- <td>水稻</td>
- <td>15.2</td>
- <td>东经121.47,北纬31.24</td>
- <td>2023-02-20</td>
- <td><span class="badge badge-success">种植中</span></td>
- <td>8</td>
- <td>李耕田</td>
- <td class="fixed-last-column">
- <div class="flex gap-2">
- <button class="btn btn-sm btn-default view-btn" data-id="FIELD20230002">
- <i class="iconfont icon-eye"></i>
- 查看
- </button>
- <button class="btn btn-sm btn-default edit-btn" data-id="FIELD20230002">
- <i class="iconfont icon-edit"></i>
- 编辑
- </button>
- </div>
- </td>
- </tr>
- <tr>
- <td>C区果园1号</td>
- <td>南区智慧农场</td>
- <td>果园</td>
- <td>水果(葡萄)</td>
- <td>8.7</td>
- <td>东经121.42,北纬31.18</td>
- <td>2023-03-10</td>
- <td><span class="badge badge-warning">准备中</span></td>
- <td>6</td>
- <td>王果农</td>
- <td class="fixed-last-column">
- <div class="flex gap-2">
- <button class="btn btn-sm btn-default view-btn" data-id="FIELD20230003">
- <i class="iconfont icon-eye"></i>
- 查看
- </button>
- <button class="btn btn-sm btn-default edit-btn" data-id="FIELD20230003">
- <i class="iconfont icon-edit"></i>
- 编辑
- </button>
- </div>
- </td>
- </tr>
- <tr>
- <td>A区大棚1号</td>
- <td>东区智慧农场</td>
- <td>大棚</td>
- <td>蔬菜(黄瓜)</td>
- <td>2.8</td>
- <td>东经121.44,北纬31.21</td>
- <td>2023-04-05</td>
- <td><span class="badge badge-danger">休耕</span></td>
- <td>3</td>
- <td>张大力</td>
- <td class="fixed-last-column">
- <div class="flex gap-2">
- <button class="btn btn-sm btn-default view-btn" data-id="FIELD20230004">
- <i class="iconfont icon-eye"></i>
- 查看
- </button>
- <button class="btn btn-sm btn-default edit-btn" data-id="FIELD20230004">
- <i class="iconfont icon-edit"></i>
- 编辑
- </button>
- </div>
- </td>
- </tr>
- <tr>
- <td>监测区1号</td>
- <td>中心监测农场</td>
- <td>露天农田</td>
- <td>玉米</td>
- <td>10.5</td>
- <td>东经121.46,北纬31.23</td>
- <td>2023-05-20</td>
- <td><span class="badge badge-success">种植中</span></td>
- <td>10</td>
- <td>赵监测</td>
- <td class="fixed-last-column">
- <div class="flex gap-2">
- <button class="btn btn-sm btn-default view-btn" data-id="FIELD20230005">
- <i class="iconfont icon-eye"></i>
- 查看
- </button>
- <button class="btn btn-sm btn-default edit-btn" data-id="FIELD20230005">
- <i class="iconfont icon-edit"></i>
- 编辑
- </button>
- </div>
- </td>
- </tr>
- </tbody>
- </table>
- </div>
- </div>
-
- <!-- 水平滚动控制 -->
- <div class="horizontal-scroll-controls p-2">
- <button class="scroll-button" id="scrollLeftBtn">
- <i class="iconfont icon-left"></i> 左滑
- </button>
- <button class="scroll-button" id="scrollRightBtn">
- 右滑 <i class="iconfont icon-right"></i>
- </button>
- </div>
-
- <div class="p-4 border-t border-gray-200 flex justify-between items-center">
- <div class="text-sm text-gray-500">显示 1 至 5,共 24 条记录</div>
- <div class="flex gap-1">
- <button class="btn btn-sm btn-default" disabled><</button>
- <button class="btn btn-sm btn-primary">1</button>
- <button class="btn btn-sm btn-default">2</button>
- <button class="btn btn-sm btn-default">3</button>
- <button class="btn btn-sm btn-default">4</button>
- <button class="btn btn-sm btn-default">5</button>
- <button class="btn btn-sm btn-default">></button>
- </div>
- </div>
- </div>
-
- <!-- 地块表单弹窗 -->
- <div class="modal" id="fieldModal" style="display: none;">
- <div class="modal-dialog">
- <div class="modal-content">
- <div class="modal-header">
- <h3 class="modal-title">添加地块</h3>
- <button type="button" class="modal-close" id="closeModal">×</button>
- </div>
- <div class="modal-body">
- <form id="fieldForm">
- <div class="grid-2">
- <div class="form-group">
- <label class="form-label">地块编号</label>
- <input type="text" class="form-input" id="fieldId" placeholder="输入地块编号">
- </div>
- <div class="form-group">
- <label class="form-label">地块名称</label>
- <input type="text" class="form-input" id="fieldName" placeholder="输入地块名称">
- </div>
- </div>
- <div class="grid-2">
- <div class="form-group">
- <label class="form-label">所属农场</label>
- <select class="form-input" id="farmId">
- <option value="">请选择所属农场</option>
- <option value="east">东区智慧农场</option>
- <option value="west">西区智慧农场</option>
- <option value="south">南区智慧农场</option>
- <option value="center">中心监测农场</option>
- </select>
- </div>
- <div class="form-group">
- <label class="form-label">地块类型</label>
- <select class="form-input" id="fieldType">
- <option value="">请选择地块类型</option>
- <option value="greenhouse">大棚</option>
- <option value="field">露天农田</option>
- <option value="orchard">果园</option>
- <option value="paddy">水稻田</option>
- </select>
- </div>
- </div>
- <div class="grid-2">
- <div class="form-group">
- <label class="form-label">主要作物</label>
- <input type="text" class="form-input" id="mainCrop" placeholder="输入主要作物">
- </div>
- <div class="form-group">
- <label class="form-label">面积(亩)</label>
- <input type="number" step="0.1" class="form-input" id="area" placeholder="输入面积">
- </div>
- </div>
- <div class="form-group">
- <label class="form-label">地理位置</label>
- <input type="text" class="form-input" id="location" placeholder="输入地理位置坐标">
- </div>
- <div class="grid-2">
- <div class="form-group">
- <label class="form-label">开垦日期</label>
- <input type="date" class="form-input" id="startDate">
- </div>
- <div class="form-group">
- <label class="form-label">状态</label>
- <select class="form-input" id="status">
- <option value="cultivating">种植中</option>
- <option value="fallow">休耕</option>
- <option value="preparing">准备中</option>
- <option value="harvested">已收获</option>
- </select>
- </div>
- </div>
- <div class="form-group">
- <label class="form-label">负责人</label>
- <input type="text" class="form-input" id="manager" placeholder="输入负责人姓名">
- </div>
- <div class="form-group">
- <label class="form-label">备注</label>
- <textarea class="form-input" id="remarks" rows="3" placeholder="输入备注信息"></textarea>
- </div>
- </form>
- </div>
- <div class="modal-footer">
- <button type="button" class="btn btn-default" id="cancelBtn">取消</button>
- <button type="button" class="btn btn-primary" id="saveBtn">保存</button>
- </div>
- </div>
- </div>
- </div>
- </div>
-
- <script>
- document.addEventListener("DOMContentLoaded", function() {
- // 初始化表格滚动功能
- function initTableScroll() {
- const tableContainer = document.querySelector(".table-container");
- if (!tableContainer) return;
-
- const scrollLeftBtn = document.querySelector(".table-scroll-left");
- const scrollRightBtn = document.querySelector(".table-scroll-right");
-
- if (!scrollLeftBtn || !scrollRightBtn) return;
-
- // 检查表格是否需要水平滚动
- function checkTableOverflow() {
- if (tableContainer.scrollWidth > tableContainer.clientWidth) {
- tableContainer.classList.add("has-overflow");
- } else {
- tableContainer.classList.remove("has-overflow");
- }
- }
-
- // 左右滚动按钮点击事件
- scrollLeftBtn.addEventListener("click", function() {
- tableContainer.scrollLeft -= 150;
- });
-
- scrollRightBtn.addEventListener("click", function() {
- tableContainer.scrollLeft += 150;
- });
-
- // 初始检查和窗口大小变化时检查
- checkTableOverflow();
- window.addEventListener("resize", checkTableOverflow);
-
- // 滚动事件处理
- tableContainer.addEventListener("scroll", function() {
- // 根据滚动位置显示/隐藏滚动按钮
- if (tableContainer.scrollLeft <= 10) {
- scrollLeftBtn.style.opacity = "0.5";
- } else {
- scrollLeftBtn.style.opacity = "1";
- }
-
- if (tableContainer.scrollLeft >= tableContainer.scrollWidth - tableContainer.clientWidth - 10) {
- scrollRightBtn.style.opacity = "0.5";
- } else {
- scrollRightBtn.style.opacity = "1";
- }
- });
-
- // 初始触发滚动事件,设置初始按钮状态
- tableContainer.dispatchEvent(new Event("scroll"));
- }
-
- // 初始化表格滚动
- initTableScroll(); // 表格水平滚动控制
- document.getElementById('scrollLeftBtn').addEventListener('click', function() {
- const scrollContainer = document.getElementById('tableScrollContainer');
- scrollContainer.scrollBy({ left: -200, behavior: 'smooth' });
- });
-
- document.getElementById('scrollRightBtn').addEventListener('click', function() {
- const scrollContainer = document.getElementById('tableScrollContainer');
- scrollContainer.scrollBy({ left: 200, behavior: 'smooth' });
- });
-
- // 添加地块按钮点击事件
- document.getElementById('addFieldBtn').addEventListener('click', function() {
- document.getElementById('fieldModal').style.display = 'block';
- setTimeout(() => {
- document.getElementById('fieldModal').classList.add('show');
- }, 10);
- });
-
- // 关闭模态框
- document.getElementById('closeModal').addEventListener('click', function() {
- closeModal();
- });
-
- // 取消按钮点击事件
- document.getElementById('cancelBtn').addEventListener('click', function() {
- closeModal();
- });
-
- // 保存按钮点击事件
- document.getElementById('saveBtn').addEventListener('click', function() {
- alert('地块信息已保存');
- closeModal();
- });
-
- // 关闭模态框函数
- function closeModal() {
- document.getElementById('fieldModal').classList.remove('show');
- setTimeout(() => {
- document.getElementById('fieldModal').style.display = 'none';
- }, 300);
- }
-
- // 编辑按钮点击事件
- const editBtns = document.querySelectorAll('.edit-btn');
- editBtns.forEach(function(btn) {
- btn.addEventListener('click', function() {
- const fieldId = this.getAttribute('data-id');
- document.querySelector('.modal-title').textContent = '编辑地块';
- document.getElementById('fieldModal').style.display = 'block';
- setTimeout(() => {
- document.getElementById('fieldModal').classList.add('show');
- }, 10);
- // 这里可以根据fieldId加载地块信息
- });
- });
-
- // 查看按钮点击事件
- const viewBtns = document.querySelectorAll('.view-btn');
- viewBtns.forEach(function(btn) {
- btn.addEventListener('click', function() {
- const fieldId = this.getAttribute('data-id');
- window.location.href = `field-detail.html?id=${fieldId}`;
- });
- });
-
- // 表格行特效
- const tableRows = document.querySelectorAll('tbody tr');
- tableRows.forEach(row => {
- row.addEventListener('mouseenter', function() {
- const index = Array.from(this.parentNode.children).indexOf(this);
- const fixedRows = document.querySelectorAll('.fixed-column tbody tr');
- if (fixedRows[index]) {
- fixedRows[index].classList.add('bg-gray-100');
- }
- });
-
- row.addEventListener('mouseleave', function() {
- const index = Array.from(this.parentNode.children).indexOf(this);
- const fixedRows = document.querySelectorAll('.fixed-column tbody tr');
- if (fixedRows[index]) {
- fixedRows[index].classList.remove('bg-gray-100');
- }
- });
- });
- </script>
- </body>
- </html>
|