<!--
 * @Descripttion: 当前组件信息
 * @version: 1.0.0
 * @Author: 无尘
 * @Date: 2019-10-25 14:05:56
 * @LastEditors: 无尘
 * @LastEditTime: 2019-10-31 11:11:00
 -->
<!--
  <card-list-table :tableData="tableData" @delCard="delCard"></card-list-table>
  import cardListTable from '@/components/app/card-list-table
 -->

<template>
  <div>
    <el-table class="select-table" ref="multipleTable" :data="tableData" tooltip-effect="dark" style="width: calc(100% - 3px);">
      <el-table-column prop="" label="卡券名称" show-overflow-tooltip>
        <template slot-scope="scope">
          {{ scope.row.cardName }}
        </template>
      </el-table-column>

      <el-table-column prop="" label="卡券类型">
        <template slot-scope="scope">
          <span v-if="scope.row.cardType == 0">抵金券</span>
          <span v-if="scope.row.cardType == 1">折扣券</span>
          <span v-if="scope.row.cardType == 2">兑换券</span>
        </template>
      </el-table-column>
      <el-table-column prop="" label="有效期" show-overflow-tooltip>
        <template slot-scope="scope">{{ scope.row.effectDateString || '--' }}</template>
      </el-table-column>
      <el-table-column prop="" label="库存">
        <template slot-scope="scope">
          <div>{{ scope.row.couponStock }}</div>
        </template>
      </el-table-column>
      <el-table-column prop="" label="操作" show-overflow-tooltip>
        <template slot-scope="scope">
          <el-button type="text" size="small" @click="toEdit(scope.$index, scope.row)">编辑</el-button>
          <el-button type="text" size="small" @click="toDel(scope.$index, scope.row)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>
<script>
export default {
  name: 'card-list-table',
  props: {
    tableData: {
      type: [Array, Object],
      default() {
        return [];
      }
    },
    activeTab: {
      type: [String, Number],
      default() {
        return '51';
      }
    }
  },
  data() {
    return {};
  },
  methods: {
    /**
     * 删除
     */
    toDel(index, row) {
      const that = this;
      that
        .$confirm('是否要删除选中的分类?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        })
        .then(() => {
          that.$emit('delCard', row.coupCardId);
        })
        .catch(() => {});
    },
    /**
     * 编辑卡券
     */
    toEdit(index, row) {
      const that = this;
      that.$router.push(`/newCard?activeTab=${that.activeTab}&appIcon=${this.$route.query.appIcon}&coupCardId=${row.coupCardId}`);
    }
  }
};
</script>
<style lang="less" scoped></style>
