<template>
  <el-dialog title="查看内容" :visible.sync="dialogVisible" width="500px" @close="cancelSubmit()">
    <div v-loading="loading">
      <div>
        <el-input placeholder="请输入关键词搜索" prefix-icon="el-icon-search" v-model="search" class="mr10 w220" clearable @keyup.enter.native="getSearchList" @clear="getSearchList"></el-input>
      </div>
      <el-table :data="tableData" class="mt20">
        <el-table-column label="卡号" prop="paramOne"></el-table-column>
        <el-table-column label="卡密/券码" prop="paramTwo"></el-table-column>
        <el-table-column label="当前状态" prop="statusFlag">
          <template slot-scope="scope">{{ scope.row.statusFlag === 0 ? '未兑换' : '已兑换' }}</template>
        </el-table-column>
        <el-table-column label="用户/会员" prop="name"></el-table-column>
      </el-table>
      <div class="pagination-conteiner" style="background:#fff;" v-show="total > 0">
        <div class="pagination" style="text-align: right;">
          <dm-pagination background small @current-change="getTableList" :current-page.sync="currentPage" :page-size="pageSize" layout="prev, pager, next" :total="total" v-if="total != 0"> </dm-pagination>
        </div>
      </div>
    </div>
    <div slot="footer" class="dialog-footer"></div>
  </el-dialog>
</template>

<script>
// import request from '../service/request.js';
import api from '@/api/gift.js';
const { virtualCardList } = api;
export default {
  props: {
    dialogId: {
      type: String,
      default() {
        return '';
      }
    }
  },
  data() {
    return {
      dialogVisible: false,
      loading: false,
      currentPage: 1,
      pageSize: 10,
      total: '',
      tableData: [],
    };
  },
  mounted() {
    this.dialogVisible = true;
    this.giftId = this.dialogId;
    this.getTableList();
  },
  methods: {
    getTableList(){
      console.log('查看内容');
      this.loading = true;
      let params = {
        id: this.giftId,
        key: '',
        pageSize: this.pageSize,
        pageNum: this.currentPage
      };
      virtualCardList(params).then(res =>{
        console.log(res);
        this.tableData = res.result.result || [];
        this.total = res.result.totalCount;
      }).finally(() => this.loading = false);
    },
    // submitProNanme() {
    //   this.dialogVisible = false;
    //   // setInterval(() => {
    //   this.$emit('closeUploadDetail');
    //   // }, 10);
    // },
    // 取消修改
    cancelSubmit() {
      this.dialogVisible = false;
      setInterval(() => {
        this.$emit('closeUploadDetail');
      }, 10);
    }
  }
};
</script>
<style scoped></style>
