<template>
  <div>
    <el-table
    ref="table"
      :data="list"
      style="width: 100%"
      border
      size="mini"
      highlight-current-row
      @selection-change="onSelection"
      @row-click="activeRow">
      <el-table-column
        type="selection"
        align="center">
      </el-table-column>
      <el-table-column
        prop="sa_invoicebillid"
        label="发票ID"
        width="180">
      </el-table-column>
      <el-table-column
        prop="sumtaxincludedamount"
        label="发票金额"
        width="180">
      </el-table-column>
      <el-table-column
        prop="invoiceserialnum"
        label="发票流水号">
      </el-table-column>
      <el-table-column
        prop="invoicecode"
        label="发票代码">
      </el-table-column>
      <el-table-column
        prop="invoiceno"
        label="发票号码">
      </el-table-column>
      <el-table-column
        prop="remarks"
        label="反馈消息">
      </el-table-column>
      <el-table-column
        prop="status"
        label="发票状态">
      </el-table-column>
      <!-- <el-table-column
        fixed="right"
        label="操作"
        width="90">
        <template slot-scope="scope">
          <el-button v-if="tool.checkAuth($route.name,'editBlueInvioce')" @click="deleteRow(scope.row)" type="text" size="mini" :disabled="status !== '新建'">删 除</el-button>
        </template>
      </el-table-column> -->
    </el-table>
    <div class="container" style="text-align:right">
      <el-pagination
        background
        small
        @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 {
  props:['status'],
  data () {
    return {
      param:{
        "id": "20221223153403",
        "pageNumber":1,
        "pageSize":20,
        "content": {
          "sa_invoiceapplyid":this.$route.query.id,
          "where":{
            "rb":0
          }
        }
      },
      list:[],
      total:0,
      currentPage:0,
    }
  },
  methods:{
    async listData () {
      const res = await this.$api.requested(this.param)
      this.list = res.data
      this.total = res.total
      this.currentPage = res.pageNumber
      if (res.data.length > 0) {
        this.activeRow(res.data[0])
        this.$refs.table.setCurrentRow(this.list[0])
      }
    },
    handleSizeChange(val) {
      // console.log(`每页 ${val} 条`);
      this.param.content.pageSize = val
      this.listData()
    },
    handleCurrentChange(val) {
      // console.log(`当前页: ${val}`);
      this.param.content.pageNumber = val
      this.listData()
    },
    activeRow (row) {
      this.$emit('activeRow',row)
    },
    onSelection (selection) {
      this.$emit('selection',selection)
    },
    async deleteRow (row) {
      const res = await this.$api.requested({
        "id": "20221223160103",
        "content": {
          "sa_invoicebillids":[row.sa_invoicebillid]
        }
      })
      this.tool.showMessage(res,()=>{
        this.listData()
      })
    }
  },
  mounted () {
    this.listData()
  }
}

</script>
<style>
</style>