<template>
  <div>
    <el-table
      :data="list"
      style="width: 100%"
      border
      size="mini">
      <el-table-column
        prop="sonum"
        label="订单号"
        width="180">
      </el-table-column>
      <el-table-column
        prop="goodscode"
        label="商品编码"
        width="180">
      </el-table-column>
      <el-table-column
        prop="goodsname"
        label="商品名称">
      </el-table-column>
      <el-table-column
        prop="spectype"
        label="规格型号">
      </el-table-column>
      <el-table-column
        prop="unit"
        label="单位">
      </el-table-column>
      <el-table-column
        prop="num"
        label="数量">
      </el-table-column>
      <el-table-column
        prop="price"
        label="含税单价">
        <template slot-scope="scope">
          <p style="color:red;font-weight:500">¥&nbsp;{{tool.formatAmount(scope.row.price,2)}}</p>
        </template>
      </el-table-column>
      <el-table-column
        prop="taxrate"
        label="税率">
      </el-table-column>
      <!-- <el-table-column label="操作" width="90" fixed="right">
        <template slot-scope="scope">
         
          <el-button v-if="tool.checkAuth($route.name,'editBlueInvioce')" :disabled="status !== '新建'" size="small" type="text" @click="deleteRow(scope.row)">删 除</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'],
  components:{
  },
  data () {
    return {
      param:{
        "id": 20221228101203,
        "content": {
          "sa_invoicebillid":0,
          "where":{
              "condition":""
          }
        }
      },
      list:[],
      total:0,
      currentPage:0,
    }
  },
  methods:{
    async listData (id) {
      this.param.content.sa_invoicebillid = id
      const res = await this.$api.requested(this.param)
      this.list = res.data
      this.total = res.total
      this.currentPage = res.pageNumber
    },
    handleSizeChange(val) {
      // console.log(`每页 ${val} 条`);
      this.param.content.pageSize = val
      this.listData()
    },
    handleCurrentChange(val) {
      // console.log(`当前页: ${val}`);
      this.param.content.pageNumber = val
      this.listData()
    },
    // 删除明细
    async deleteRow (row) {
      const res = await this.$api.requested({
        "id": "20221228101303",
        "content": {
          "sa_invoicebill_itemids":[row.sa_invoicebill_itemid]
        }
      })
      this.tool.showMessage(res,()=>{
        this.listData(this.param.content.sa_invoicebillid)
      })
    },
    onSuccess (refreshParent) {
      this.listData(this.param.content.sa_invoicebillid)
      if (refreshParent) {
        this.$emit('onSuccess')
      }
    }
  },
  mounted () {
  }
}

</script>
<style>
</style>