<template>
  <div>
    <el-dialog title="查看卡密" :visible.sync="camiloShow" :before-close="close">
      <el-table :data="camiloData">
        <el-table-column property="cardNo" label="卡号" min-width="250" align="center">
          <template slot-scope="{row}">
            {{ row.cardNo?row.cardNo:'--' }}
          </template>
        </el-table-column>
        <el-table-column property="cardPwd" label="密码（激活码）" min-width="250" align="center"></el-table-column>
      </el-table>
      <pagination :total="total" :page.sync="pageParams.pageNum" :limit.sync="pageParams.pageSize"
                  @pagination="getList()"/>
    </el-dialog>
  </div>
</template>

<script>
import {cradCamiloList} from "../../api/business/goods";

export default {
  name: "camilo",
  props: {
    camiloShow: {
      type: Boolean,
      default: true
    },
    camiloGoodsId: {
      type: Number,
      default: 0
    },
  },
  data() {
    return {
      pageParams: {
        pageNum: 1,
        pageSize: 10
      },
      loading: false,
      camiloData: [],
      total: 0,
    };
  },
  mounted() {
    this.getList()
  },
  methods: {
    close() {
      this.$emit('cancel')
    },
    getList() {
      if (this.loading) {
        return
      }
      this.loading = true
      cradCamiloList('pageNum=' + this.pageParams.pageNum + '&pageSize=' + this.pageParams.pageSize + '&', {goodsId: this.camiloGoodsId}).then(res => {
        this.loading = false
        if (res.code === 0) {
          this.camiloData = res.rows
          this.total = res.total
        }
      }).catch(() => {
        this.loading = false
      })
    },

  }
}
</script>

<style lang="scss" scoped>

</style>
