<!--pages/farmers/farmers.wxml-->
<view class="farmers-container">
  <!-- 标题栏 -->
  <view class="header">
    <text class="title">养殖户管理</text>
  </view>

  <!-- 筛选标签 -->
  <view class="filter-tabs">
    <view 
      class="tab-item {{activeTab === 'all' ? 'active' : ''}}"
      data-tab="all"
      bindtap="onTabChange"
    >
      <text>全部</text>
    </view>
    <view 
      class="tab-item {{activeTab === 'active' ? 'active' : ''}}"
      data-tab="active"
      bindtap="onTabChange"
    >
      <text>正常</text>
    </view>
    <view 
      class="tab-item {{activeTab === 'pending' ? 'active' : ''}}"
      data-tab="pending"
      bindtap="onTabChange"
    >
      <text>待审核</text>
    </view>
    <view 
      class="tab-item {{activeTab === 'inactive' ? 'active' : ''}}"
      data-tab="inactive"
      bindtap="onTabChange"
    >
      <text>停用</text>
    </view>
  </view>

  <!-- 搜索栏 -->
  <view class="search-section">
    <view class="search-bar">
      <view class="search-input-wrapper">
        <input 
          class="search-input" 
          placeholder="搜索养殖户姓名或农场名称"
          value="{{searchKeyword}}"
          bindinput="onSearchInput"
          bindconfirm="onSearch"
        />
        <view class="search-btn" bindtap="onSearch">
          <text class="search-icon">🔍</text>
        </view>
      </view>
      <view class="add-btn" bindtap="onAddFarmer">
        <text class="add-icon">+</text>
        <text class="add-text">新增</text>
      </view>
    </view>
  </view>

  <!-- 养殖户列表 -->
  <view class="farmer-list">
    <view 
      class="farmer-item" 
      wx:for="{{farmers}}" 
      wx:key="id"
      data-id="{{item.id}}"
      bindtap="onFarmerTap"
    >
      <!-- 养殖户标题 -->
      <view class="farmer-title">{{item.name}} - {{item.farmName}}</view>
      
      <!-- 养殖户信息 -->
      <view class="farmer-info">
        <view class="info-row">
          <text class="info-label">负责人：</text>
          <text class="info-value">{{item.name}}</text>
        </view>
        
        <view class="info-row">
          <text class="info-label">当前状态：</text>
          <view class="status-tag {{item.status}}">
            <text>{{item.status === 'active' ? '正常' : item.status === 'pending' ? '待审核' : '停用'}}</text>
          </view>
        </view>
        
        <view class="info-row">
          <text class="info-label">联系电话：</text>
          <text class="info-value">{{item.phone}}</text>
        </view>
        
        <view class="info-row">
          <text class="info-label">牲畜数量：</text>
          <text class="info-value">{{item.animalCount}}头</text>
        </view>
        
        <view class="info-row">
          <text class="info-label">农场地址：</text>
          <text class="info-value">{{item.address}}</text>
        </view>
        
        <view class="info-row">
          <text class="info-label">注册时间：</text>
          <text class="info-value">{{item.registerTime}}</text>
        </view>
      </view>
    </view>
  </view>

  <!-- 加载状态 -->
  <view class="loading-state" wx:if="{{loading}}">
    <text class="loading-text">加载中...</text>
  </view>

  <!-- 空状态 -->
  <view class="empty-state" wx:if="{{!loading && farmers.length === 0}}">
    <image class="empty-icon" src="/images/empty.png" />
    <text class="empty-text">暂无养殖户数据</text>
    <view class="empty-btn" bindtap="onAddFarmer">
      <text>添加养殖户</text>
    </view>
  </view>
</view>