<template>
  <div class="app-container">
    <div id="printBox">
      <el-card ref="print" class="box-card" style="margin: 0 auto;">
        <div class="refund-item">
          <el-row :gutter="24" class="box-row">
            <el-col :span="6"><b>下单时间：</b> {{ order.orderTime }}</el-col>
            <el-col :span="6"><b>订单编号(ID)：</b> {{ order.orderNo + '(' + order.orderId + ')' }}</el-col>
            <el-col :span="6"><b>订单状态：</b>
              <template v-if="['11','12','13','21','22','23','31','32','33'].indexOf(order.status)>=0">
                <el-tag type="success" size="small">交易中</el-tag>
              </template>
              <template v-else>
                <el-tag :type="order.status*1===6?'info':''" size="small">{{ order.status | orderStatusFilter }}</el-tag>
              </template>
            </el-col>
          </el-row>
          <el-row :gutter="24" class="box-row">
            <el-col :span="6"><b>收款状态：</b>
              <el-tag v-if="order.receiptStatus*1===1" type="danger" size="small">待收款</el-tag>
              <el-tag v-if="order.receiptStatus*1===2" type="warning" size="small">部分收款</el-tag>
              <el-tag v-if="order.receiptStatus*1===3" type="success" size="small">已收款</el-tag>
            </el-col>
            <el-col :span="6"><b>付款状态：</b>
              <el-tag v-if="order.payStatus*1===1" type="danger" size="small">待付款</el-tag>
              <el-tag v-if="order.payStatus*1===2" type="warning" size="small">部分付款</el-tag>
              <el-tag v-if="order.payStatus*1===3" type="success" size="small">已付款</el-tag>
            </el-col>
            <el-col :span="6"><b>结算状态：</b>
              <el-tag v-if="order.settleStatus*1===1" type="danger" size="small">未结算</el-tag>
              <el-tag v-if="order.settleStatus*1===2" type="warning" size="small">部分结算</el-tag>
              <el-tag v-if="order.settleStatus*1===3" type="success" size="small">已结算</el-tag>
            </el-col>
          </el-row>
          <el-row :gutter="24" class="box-row">
            <el-col :span="6"><b>机构名称：</b> {{ order.clubName }}</el-col>
            <el-col :span="4"><b>收货人：</b> {{ order.receiver }}</el-col>
            <el-col :span="4"><b>手机：</b> {{ order.mobile }}</el-col>
            <el-col :span="10"><b>地址：</b> {{ order.address }}</el-col>
          </el-row>
          <el-row :gutter="24" class="box-row">
            <el-col :span="6"><b>订单金额：</b> ¥{{ order.payTotalFee | amountfilters }}</el-col>
            <el-col :span="4"><b>应收金额：</b> ¥{{ order.payableAmount | amountfilters }}</el-col>
            <el-col :span="4"><b>运费：</b> {{ order.postageInfo }}</el-col>
            <el-col :span="10"><b>退款总额：</b> ¥{{ order.refundFee | amountfilters }}</el-col>
          </el-row>
        </div>
        <div class="refund-item">
          <h1 class="refund-item-title">结算记录</h1>
          <el-table :data="settleRecord" border fit highlight-current-row :header-cell-style="{background:'#e9f3f7',color:'#606266'}">
            <el-table-column label="序号" align="center" width="50">
              <template slot-scope="scope">{{ scope.$index + 1 }}</template>
            </el-table-column>
            <el-table-column label="子订单ID" align="center" prop="shopOrderId" />
            <el-table-column label="结算时间" align="center" prop="settleTime" />
            <el-table-column label="供应商结算金额" align="center" prop="shouldSettleShop" />
            <el-table-column label="丽格结算金额" align="center" prop="shouldSettleOrganize" />
            <el-table-column label="采美结算金额" align="center" prop="shouldSettleCm" />
          </el-table>
        </div>
      </el-card>
    </div>
  </div>
</template>

<script>
import { organizeSettleRecord } from '@/api/finance'
export default {
  name: 'PaysettleRecord',
  filters: {
    statusFilter(status) {
      const map = {
        0: '待付款',
        1: '已付款',
        2: '审核不通过'
      }
      return map[status]
    }
  },
  data() {
    return {
      order: {},
      settleRecord: []
    }
  },
  computed: {
    orderId: function() {
      return this.$route.query.orderId * 1
    }
  },
  created() {
    this.organizeSettleRecord()
  },
  methods: {
    async organizeSettleRecord() {
      try {
        const res = await organizeSettleRecord(this.orderId)
        this.order = res.data.order
        this.settleRecord = res.data.settleRecord
      } catch (error) {
        console.log('error', error)
      }
    },
    backToList() {
      this.$store.dispatch('tagsView/delView', this.$route).then(() => {
        this.$nextTick(() => {
          this.$router.replace({
            path: '/finance/paysettle-list'
          })
        })
      })
    }
  }
}
</script>

<style scoped>
  .app-title{
    line-height: 36px;
    font-size: 26px;
    font-weight: bold;
    color: #409EFF;
    text-align: center;
  }
  .box-card{
    margin-top: 20px;
    font-size: 14px;
  }
  .box-row{
    padding: 10px 0;
  }
  .box-row .dropdown{
    margin-top: -10px;
  }
  .refund-item{
    padding: 10px 0;
  }
  .refund-item-title{
    line-height: 24px;
    font-size: 14px;
    color: #409EFF;
  }
  .order-item{
    background:#f7f7f7;
    margin-bottom: 20px;
    padding: 10px 15px;
    border-radius: 5px;
  }
  .product-row{
    padding: 10px 0;
    background: #EBEEF5;
    border-top: 1px dashed #DCDFE6;
  }
  .op-item{
    padding: 5px 0;
  }
  .el-span-warning{
  color: #E6A23C;
}
.el-span-success{
  color: #67C23A;
}
.el-span-danger{
  color: #F56C6C;
}
</style>

