<view class="page">
  <view class="head-tip">仅记录派单、退款、模板等重要操作，不含普通查看</view>
  <view class="tabs">
    <view class="tab {{tab === 'audit' ? 'on' : ''}}" data-tab="audit" bindtap="switchTab">操作日志</view>
    <view class="tab {{tab === 'rank' ? 'on' : ''}}" data-tab="rank" bindtap="switchTab">客服排行</view>
  </view>
  <block wx:if="{{tab === 'audit'}}">
    <view class="summary" wx:if="{{total > 0}}">共 {{total}} 条重要操作</view>
    <view class="item {{item.canJumpOrder ? 'item-link' : ''}}" wx:for="{{auditList}}" wx:key="id"
          bindtap="goOrderDetail" data-item="{{item}}">
      <view class="item-hd flexb">
        <text class="act">{{item.action_label || item.action}}</text>
        <text class="amount" wx:if="{{item.amount}}">¥{{item.amount}}</text>
      </view>
      <view class="operator">
        <text class="tag {{item.operator_type === 'STAFF' ? 'tag-staff' : 'tag-owner'}}">
          {{item.role_name || (item.operator_type === 'STAFF' ? '客服' : '老板')}}
        </text>
        <text class="name">{{item.operator_name}}</text>
        <text class="uid">ID:{{item.operator_user_id}}</text>
      </view>
      <text class="meta">{{item.time}}</text>
      <text class="res" wx:if="{{item.resource_id}}">订单：{{item.resource_id}}</text>
      <text class="jump-tip" wx:if="{{item.canJumpOrder}}">点击查看订单详情 ›</text>
      <text class="remark" wx:if="{{item.remark}}">{{item.remark}}</text>
    </view>
    <view class="load-tip" wx:if="{{loading}}">加载中...</view>
    <view class="load-tip" wx:elif="{{hasMore && auditList.length}}">上拉加载更多</view>
    <view class="empty" wx:if="{{!loading && auditList.length === 0}}">暂无操作日志</view>
  </block>
  <block wx:else>
    <view class="item" wx:for="{{rankList}}" wx:key="member_id">
      <text class="rank">#{{item.rank}} {{item.display_name}}</text>
      <text class="meta">派单 {{item.dispatch_count}} 单 · ¥{{item.dispatch_amount}}</text>
      <text class="meta">结单 {{item.settle_count}} 单 · ¥{{item.settle_amount}}</text>
    </view>
    <view class="empty" wx:if="{{rankList.length === 0}}">暂无排行数据</view>
  </block>
</view>
