<template>
  <div>
    <el-dialog title="查看关联盲票" :visible.sync="associationShow" :before-close="close">
      <el-table :data="associationData">
        <el-table-column property="boxId" label="盲票组Id" min-width="250" align="center"></el-table-column>
        <el-table-column property="title" label="盲票组名称" min-width="250" align="center"></el-table-column>
        <el-table-column property="status" label="状态" min-width="250" align="center">
          <template slot-scope="{row}">
            {{ row.status && JSON.parse(row.status).desc }}
          </template>
        </el-table-column>
      </el-table>
      <pagination :total="total" :page.sync="pageParams.pageNum" :limit.sync="pageParams.pageSize"
                  @pagination="getList()"/>
    </el-dialog>
  </div>
</template>

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

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

  }
}
</script>

<style lang="scss" scoped>

</style>
