<t-navbar title="{{i18n.offlineTreatment.title}}" left-arrow />
  <t-tabs value="{{currentTab}}" bind:change="onTabChange">
    <t-tab-panel label="全部" value=""></t-tab-panel>
    <t-tab-panel label="{{i18n.offlineTreatment.ing}}" value="0"></t-tab-panel>
    <t-tab-panel label="{{i18n.offlineTreatment.finish}}" value="1"></t-tab-panel>
  </t-tabs>
  <scroll-view class="page-container" scroll-y>
    <view wx:if="{{isLoading}}">
      <t-loading theme="spinner" text="加载中..." size="24" />
    </view>
   <view wx:elif="{{treatmentList.length>0}}">
      <block wx:for="{{treatmentList}}" wx:key="id">
        <view class="treatment-detail-card {{item.isHighlighted ? 'treatment-detail-card--highlighted' : ''}}" bindtap="onRecord" data-id="{{item.id}}">
          <view>
            <view class="row between" wx:if="{{item.conditioningProgramName}}">
              <text class="label bold">项目：{{item.conditioningProgramName}}</text>
            </view>
            <view class="row" wx:if="{{item.operateBy}}">
              <text class="sub-label">开具人：</text>
              {{item.operateBy}}
            </view>
            <view class="row" wx:if="{{item.estimatedStartDate}}">
              <text class="sub-label">开始时间：</text>
              {{item.estimatedStartDate}}
            </view>
            <view class="row">
              <text class="sub-label">频次：</text>
              每{{item.frequencyType}}天{{item.frequencyMeasure}}{{item.convertUnit?item.convertUnit: '次'}}
            </view>
            <view class="row">
              <text class="sub-label">下次时间：</text>
              {{item.arrangeDate?item.arrangeDate: '-'}} {{item.arrangeTime ?item.arrangeTime: ''}}{{item.applyTime?'(已预约)':''}}
            </view>
            <view class="row" wx:if="{{item.pieTime}}">
              <text class="sub-label">机构：</text>
              {{item.conditioningProgramSupplierName || '-'}}
            </view>
            <view class="divider"></view>
          </view>
          <view>
            <view class="status" style="color:{{item.status === 'doing' ? '#F44336' : '#43A047'}}">
              {{item.progress === '0' ? '进行中' : '已完成'}}
            </view>
            <view class="center">{{item.finishCount}}/{{item.totalMeasure}}</view>
            <!-- 预约按钮/标签 -->
            <view class="appointment-action" wx:if="{{item.progress === '0'}}">
              <!-- 已预约：显示标签 -->
              <view class="appointment-tag" wx:if="{{item.applyTime}}">
                已预约
              </view>
              <!-- 未预约：显示按钮 -->
              <view class="appointment-btn" wx:else catchtap="goAppointment" data-id="{{item.id}}"
               data-item="{{item}}">
                去预约
              </view>
            </view>
          </view>
        </view>
      </block>
    </view>
    <view wx:elif="{{!isLoading && treatmentList.length === 0}}">
      <t-empty icon="info-circle-filled" description="暂无数据" />
    </view>
    <!-- 底部安全区占位 -->
    <view class="safe-bottom-spacer"></view>
  </scroll-view>