<template>
  <div class="companyCollectionPaymentDetail-wrap">
    <a-page-header :ghost="false" :backIcon="false" class="companyCollectionPaymentDetail-cont" >
      <!-- 自定义的二级文字标题 -->
      <template slot="subTitle">
        <a id="companyCollectionPaymentDetail-back-btn" href="javascript:;" @click="handleBack"><a-icon type="left" /> 返回列表</a>
        <p style=" display: inline-block;margin: 0 0 0 60px;color: #000;font-size: 16px;font-weight: 600;">单号：{{ (basicInfoData&&basicInfoData.unitSettleNo) || '--' }}</p>
      </template>
      <!-- 操作区，位于 title 行的行尾 -->
      <template slot="extra">
        <a-button key="2" id="companyCollectionPaymentDetail-preview-btn">打印预览</a-button>
        <a-button key="1" type="primary" id="companyCollectionPaymentDetail-print-btn">快速打印</a-button>
      </template>
    </a-page-header>
    <!-- 基础信息 -->
    <a-card size="small" :bordered="false" class="companyCollectionPaymentDetail-cont">
      <a-collapse :activeKey="['1']">
        <a-collapse-panel key="1" header="基础信息">
          <a-descriptions :column="3">
            <a-descriptions-item label="单位名称">箭冠营销中心</a-descriptions-item>
            <a-descriptions-item label="单位类型">箭冠营销中心</a-descriptions-item>
            <a-descriptions-item label="结算类型">箭冠营销中心</a-descriptions-item>
            <a-descriptions-item label="收款金额">2</a-descriptions-item>
            <a-descriptions-item label="折让金额">20</a-descriptions-item>
            <a-descriptions-item label="结算金额">￥120.36</a-descriptions-item>
            <a-descriptions-item label="结算时间">3</a-descriptions-item>
            <a-descriptions-item label="操作人">4</a-descriptions-item>
            <a-descriptions-item label="结算方式">￥11.2</a-descriptions-item>
          </a-descriptions>
        </a-collapse-panel>
      </a-collapse>
    </a-card>
    <!-- 收款明细 -->
    <a-card size="small" :bordered="false" class="companyCollectionPaymentDetail-cont">
      <a-collapse :activeKey="['1']">
        <a-collapse-panel key="1" header="收款明细">
          <!-- alert -->
          <a-alert type="info" showIcon style="margin-bottom:15px">
            <div slot="message">共 <strong>6</strong> 条明细，金额合计 <strong>￥{{ (productTotal&&productTotal.totalAmount) || 0 }}</strong> ，结算金额合计 <strong>￥{{ (productTotal&&productTotal.settleAmount) || 0 }}</strong> </div>
          </a-alert>
          <!-- 列表 -->
          <s-table
            class="sTable"
            ref="table"
            size="default"
            :rowKey="(record) => record.id"
            :columns="columns"
            :data="loadData"
            bordered>
          </s-table>
        </a-collapse-panel>
      </a-collapse>
    </a-card>
  </div>
</template>

<script>
import { STable, VSelect } from '@/components'
import { settleUnitDetailList, settleUnitDetail } from '@/api/settle'
export default {
  components: { STable, VSelect },
  data () {
    return {
      // 表头
      columns: [
        { title: '序号', dataIndex: 'no', align: 'center' },
        { title: '单据号', dataIndex: 'bizNo', align: 'center', customRender: function (text) { return text || '--' } },
        { title: '类型', dataIndex: 'bizTypeDictValue', align: 'center', customRender: function (text) { return text || '--' } },
        { title: '金额', dataIndex: 'totalAmount', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
        { title: '结算金额', dataIndex: 'settleAmount', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
      ],
      // 加载数据方法 必须为 Promise 对象
      loadData: parameter => {
        this.disabled = true
        return settleUnitDetailList(Object.assign(parameter, this.queryParam)).then(res => {
          const data = res.data
          const no = (data.pageNo - 1) * data.pageSize
          for (var i = 0; i < data.list.length; i++) {
            data.list[i].no = no + i + 1
          }
          this.disabled = false
          return data
        })
      },
      basicInfoData: null //  基本信息
    }
  },
  methods: {
    //  返回列表
    handleBack () {
      this.$router.push({ path: '/financialManagement/companyCollectionPayment/list' })
    },
    // 详情
    getDetail () {
      settleUnitDetail({ id: this.$route.params.id }).then(res => {
        if (res.status == 200) {
          this.basicInfoData = res.data
        } else {
          this.basicInfoData = null
        }
      })
    }
  },
  beforeRouteEnter (to, from, next) {
    next(vm => {
      vm.getDetail()
    })
  }
}
</script>

<style lang="less">
  .companyCollectionPaymentDetail-cont{
    margin-bottom: 15px;
  }
</style>
