<template>
  <div>
    <el-table
      :data="tableData"
      border
      size="small"
      style="width: 100%">
      <el-table-column
        prop="itemname"
        label="产品"
        width="itemname">
      </el-table-column>
      <el-table-column
        prop="qty"
        label="数量"
        width="90">
      </el-table-column>
      <el-table-column
        prop="marketprice"
        label="牌价"
        width="90">
      </el-table-column>
      <el-table-column
        prop="discountrate"
        label="折扣"
        width="90">
      </el-table-column>
      <el-table-column
        prop="price"
        label="单价"
        width="90">
        <template slot-scope="scope">
          {{tool.formatAmount(scope.row.price,2)}}
        </template>
      </el-table-column>
      <el-table-column
        prop="amount"
        label="金额"
        width="100">
        <template slot-scope="scope">
          <span>{{tool.formatAmount(scope.row.amount,2)}}</span>
        </template>
      </el-table-column>
      <el-table-column
        prop="rebate_discountrate"
        label="居间产品折扣"
        width="150">
      </el-table-column>
      <el-table-column
        prop="rebate_price"
        label="居间产品单价"
        width="150">
        <template slot-scope="scope">
          <span>{{tool.formatAmount(scope.row.rebate_price,2)}}</span>
        </template>
      </el-table-column>
      <el-table-column
        prop="rebate_unit_price"
        label="居间单价"
        width="120">
        <template slot-scope="scope">
          <span>{{tool.formatAmount(scope.row.rebate_unit_price,2)}}</span>
        </template>
      </el-table-column>
      <el-table-column
        prop="rebate"
        label="居间费"
        width="120">
        <template slot-scope="scope">
          <span>{{tool.formatAmount(scope.row.rebate,2)}}</span>
        </template>
      </el-table-column>
    </el-table>
    <div class="container normal-panel" style="text-align:right">
      <el-pagination
        background
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="currentPage"
        :page-sizes="[20, 50, 100, 200]"
        layout="total,sizes, prev, pager, next, jumper"
        :total="total">
      </el-pagination>
    </div>
  </div>
</template>

<script>
export default {
  data () {
    return {
      rebHeadData:{},
      tableData:[],
      param:{
        "pageNumber": 1,
        "pageSize": 20,
      },
      total:0,
      currentPage:0
    }
  },
  methods:{
    async listData () {
      const res = await this.$api.requested({
        "id": "20230105092302",
        "content": {
          "sa_rebatesettlementid": this.$route.query.id,
          "pageNumber": this.param.pageNumber,
          "pageSize": this.param.pageSize,
          "where": {
            "condition": ""
          }
        },
      })
      this.tableData = res.data
      this.total = res.total
      this.currentPage = res.pageNumber
    },
    handleSizeChange(val) {
      this.param.pageSize = val
      this.listData()
    },
    handleCurrentChange(val) {
      this.param.pageNumber = val
      this.listData()
    },
  },
  mounted () {
    this.listData()
  }
}

</script>
<style>
</style>