<page-plugin isAuth="{{authInfo['SF_ERP_SALE_ORDERS_VIEW']}}" loading="{{loading}}"
  is-login="{{isLogin}}" bind:handleLogin="handleLogin">

  <total-bar-plugin customStyle="flex-direction: column;">
    <view class="item">
      <text class="item-label">经销商：</text>
      <text class="item-value">{{info.custom_name}}</text>
    </view>
    <view class="item">
      <text class="item-label">单据日期：</text>
      <text class="item-value">{{info.document_date}}</text>
    </view>
    <view class="item">
      <text class="item-label">自定义单号：</text>
      <text class="item-value">{{info.custom_order_no}}</text>
    </view>
    <view class="item">
      <text class="item-label">销售人员：</text>
      <text class="item-value">{{info.sales_name}}</text>
    </view>
    <view class="item">
      <text class="item-label">客户名称：</text>
      <text class="item-value">{{info.end_user_name}}</text>
    </view>
    <view class="item">
      <text class="item-label">客户手机：</text>
      <text class="item-value">{{info.end_user_phone}}</text>
    </view>
    <view class="item">
      <text class="item-label">客户地址：</text>
      <text class="item-value">{{info.end_user_address}}</text>
    </view>
    <view class="item">
      <text class="item-label">备注：</text>
      <text class="item-value">{{info.comments}}</text>
    </view>
    <view class="item">
      <text class="item-label">优惠率：</text>
      <text class="item-value">{{info.discount_rate}}%</text>
    </view>
    <view class="item">
      <text class="item-label">收款优惠：</text>
      <text class="item-value">{{info.discount_money}}</text>
    </view>
    <view class="item">
      <text class="item-label">优惠后金额：</text>
      <text class="item-value">{{info.discount_last_money}}</text>
    </view>
  </total-bar-plugin>

  <!-- <t-cell title="Excel附件" left-icon="file-excel"
    custom-style="padding-left:0;padding-right:0;position: sticky;top: 0;" arrow
    bind:tap="onPreview2" /> -->

  <t-cell title="附件" left-icon="file"
    custom-style="padding-left:0;padding-right:0;position: sticky;top: 0;z-index:1" />
  <view style="border: 1px solid #ddd;border-radius: 8rpx;padding: 8rpx;">
    <block wx:for="{{files}}" wx:key="index">
      <t-cell title="{{item.file_name}}" hover="{{item._file_type != 'file'}}"
        arrow="{{item._file_type != 'file'}}" bind:tap="onPreview" data-index="{{index}}">
        <!-- <block wx:if="{{item._file_type != 'image'}}">
          <t-icon slot="left-icon" name="{{fileIcon[item._file_type]}}" color="#999" size="96rpx" />
        </block> -->
      </t-cell>
    </block>
  </view>

  <t-cell wx:if="{{ detail.length }}" title="订单明细" left-icon="article" note="{{detail.length}}条"
    custom-style="padding-left:0;padding-right:0;position: sticky;top: 0;z-index:1" />
  <card-plugin wx:for="{{ detail }}" wx:key="detail_id">
    <view slot="header">{{ item.goods_name }}</view>
    <view slot="content">
      <card-item-plugin label="规格" value="{{item.goods_spec}}" />
      <card-item-plugin label="多属性" value="{{item.attr_name}}" />
      <card-item-plugin label="单位" value="{{item.unit_ch_name}}" />
      <card-item-plugin label="数量" value="{{item.nums}}" />
      <card-item-plugin label="单价" value="{{item.unit_price}}" />
      <card-item-plugin label="金额" value="{{item.price}}" />
      <card-item-plugin label="税率" value="{{item.tax_rate}}%" />
      <card-item-plugin label="税额" value="{{item.tax_money}}" />
      <card-item-plugin label="价税合计" value="{{item.tax_last_money}}" />
      <card-item-plugin label="备注" value="{{item.comments}}" />
    </view>
  </card-plugin>
</page-plugin>