<!--pages/projects/projects.wxml-->
<view class="projects-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 === 'supervision' ? 'active' : ''}}"
      data-tab="supervision"
      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 === 'completed' ? 'active' : ''}}"
      data-tab="completed"
      bindtap="onTabChange"
    >
      <text>已结项</text>
    </view>
  </view>

  <!-- 项目列表 -->
  <view class="project-list">
    <view 
      class="project-item" 
      wx:for="{{projects}}" 
      wx:key="id"
      data-project-id="{{item.id}}"
      bindtap="viewProjectDetail"
    >
      <!-- 项目标题 -->
      <view class="project-title">{{item.farmName}}</view>
      
      <!-- 项目信息 -->
      <view class="project-info">
        <view class="info-row">
          <text class="info-label">法人/负责人：</text>
          <text class="info-value">{{item.loanOfficer || '1'}}</text>
        </view>
        
        <view class="info-row">
          <text class="info-label">当前状态：</text>
          <view class="status-tag {{item.status}}">
            <text>{{item.statusText}}</text>
          </view>
        </view>
        
        <view class="info-row">
          <text class="info-label">监管对象：</text>
          <text class="info-value">{{item.supervisionObject}}</text>
        </view>
        
        <view class="info-row">
          <text class="info-label">监管数量：</text>
          <text class="info-value">{{item.supervisionQuantity}}</text>
        </view>
        
        <view class="info-row">
          <text class="info-label">监管周期：</text>
          <text class="info-value">{{item.supervisionPeriod}}</text>
        </view>
        
        <view class="info-row">
          <text class="info-label">监管金额：</text>
          <text class="info-value">{{item.supervisionAmount}}元</text>
        </view>
        
        <view class="info-row">
          <text class="info-label">起止时间：</text>
          <text class="info-value">{{item.startTime}} 至 {{item.endTime}}</text>
        </view>
        
        <!-- 设备信息 -->
        <view class="device-info" wx:if="{{item.showDeviceInfo}}">
          <view class="device-row">
            <text class="device-label">脚环：</text>
            <text class="device-value">{{item.earTag || 0}}</text>
          </view>
          <view class="device-row">
            <text class="device-label">耳标：</text>
            <text class="device-value">{{item.earTag || 0}}</text>
          </view>
          <view class="device-row">
            <text class="device-label">项圈：</text>
            <text class="device-value">{{item.collar || 0}}</text>
          </view>
          <view class="device-row">
            <text class="device-label">主机：</text>
            <text class="device-value">{{item.host || 0}}</text>
          </view>
          <view class="device-row">
            <text class="device-label">饲喂机：</text>
            <text class="device-value">0</text>
          </view>
        </view>
      </view>
    </view>
  </view>

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

  <!-- 空状态 -->
  <view class="empty-state" wx:if="{{!loading && projects.length === 0}}">
    <text class="empty-icon">📋</text>
    <text class="empty-text">暂无项目数据</text>
  </view>
</view>