<template>
  <div class="leo-dec-list-table" v-loading="loading">
    <el-table :data="tableData" stripe style="width: 100%;">
      <el-table-column label="订单编号" prop="ORDER_SN"></el-table-column>
      <el-table-column label="注册会员" v-if="type==='ZC'">
        <template slot-scope="scope">
          {{scope.row.INSERT_USER_NAME}}<br>
        </template>
      </el-table-column>
      <el-table-column label="报单金额" prop="DEC_AMOUNT" v-if="type!=='OR'"></el-table-column>
      <el-table-column label="报单PV" prop="DEC_PV" v-if="type!=='OR'"></el-table-column>
      <el-table-column label="订货单金额" prop="ORDER_AMOUNT" v-if="type==='OR'"></el-table-column>
      <el-table-column label="订货单PV" prop="ORDER_PV" v-if="type==='OR'"></el-table-column>
      <el-table-column label="支付钱包">
        <template slot-scope="scope">
          {{paidType[scope.row.PAID_WALLET].title}}<br>
        </template>
      </el-table-column>
      <el-table-column label="返利PV" v-if="type==='OR'">
        <template slot-scope="scope">
          {{scope.row.FL_PV}}<br>
        </template>
      </el-table-column>
      <el-table-column label="补贴PV" v-if="type==='OR'">
        <template slot-scope="scope">
          {{scope.row.BT_PV}}<br>
        </template>
      </el-table-column>
      <el-table-column label="报单期数" prop="PERIOD_NUM"></el-table-column>
      <el-table-column label="创建时间">
        <template slot-scope="scope">
          {{tool.formatDate(scope.row.CREATED_AT)}}<br>
        </template>
      </el-table-column>
    </el-table>
    <div class="white-box-footer">
      <pagination :total="totalCount" :page_size="pageSize" @size-change="handleSizeChange" @current-change="handleCurrentChange"></pagination>
    </div>
  </div>
</template>

<script>
import network from '@/utils/network'
import tool from '@/utils/tool'
import baseInfo from '@/utils/baseInfo'
import Pagination from '@/components/Pagination'

export default {
  name: 'leo-dec-list-table',
  components: {Pagination},
  props: {
    type: {
      type: String,
      default: 'ZC'
    },
  },
  mounted () {
    this.getData()
  },
  data () {
    return {
      tableData: null,
      loading: true,
      currentPage: 1,
      totalPages: 1,
      totalCount: 1,
      pageSize: 20,
      tool: tool,
      paidType: baseInfo.shopWalletType(),
    }
  },
  methods: {
    handleCurrentChange (page) {
      this.getData(page, this.pageSize)
    },
    handleSizeChange (pageSize) {
      this.getData(this.currentPage, pageSize)
    },
    getData (page, pageSize) {
      network.getPageData(this, 'finance/dec-list', page, pageSize, {decType: this.type})
    },
  }
}
</script>

<style scoped>

</style>