<template>
  <div class="verificationMember depositCenter">
    <div class="head-title">
      储蓄卡列表
      <el-button @click="addDeposit" style="float:right;margin-top: -5px;" size="small" type="primary">新增储值卡</el-button>
    </div>
    <div class="content">
      <div>
        <div class="searchInput">
          <el-input style="display:inline-block;width:225px;height:30px" placeholder="请输入存储卡名称"
            @keyup.enter.native="msg.pageIndex=1,getList()" @clear="msg.pageIndex=1,getList()" v-model="msg.Name"
            size="small" clearable>
          </el-input>
          <span @click="msg.pageIndex=1,getList()" class="el-icon-search"
            style="color:#979dad;font-size:14px;position:relative;top:1px"></span>
        </div>
      </div>
      <el-table :data="tableData" :loading="loading" border style="width: 100%;margin:20px 0">
        <el-table-column prop="ID" label="编号">
        </el-table-column>
        <el-table-column prop="Name" label="名称">
        </el-table-column>
        <el-table-column prop="SalePrice" label="售价">
        </el-table-column>
        <el-table-column prop="CouponIco" label="封面">
          <template slot-scope="scope">
            <img :src="scope.row.CouponIco" style="width:40px;" alt="" />
          </template>
        </el-table-column>
        <el-table-column prop="DepositPrice" label="金额">
        </el-table-column>
        <el-table-column prop="IndateDay" label="有效期天数">
        </el-table-column>
        <el-table-column prop="address" width="200" label="操作">
          <template slot-scope="scope">
            <img @click="Edit(scope.row)" style="width:32px;height:32px" src="../../assets/img/userman/edit.png" alt="">
            <img @click="Delete(scope.row)" style="width:32px;height:32px;margin:0 10px"
              src="../../assets/img/userman/del.png" alt="">
          </template>
        </el-table-column>
      </el-table>
      <el-pagination style="text-align:right" background @current-change="handleCurrentChange" :page-size="msg.pageSize"
        layout="prev, pager, next" :current-page.sync="msg.pageIndex" :total="total">
      </el-pagination>
    </div>
  </div>
</template>
<script>
  export default {
    data() {
      return {
        msg: {
          Name: '', //存储卡名称
          pageIndex: 1,
          pageSize: 15,
        },
        total: 0,
        rules: {},
        loading: false,
        tableData: []
      };
    },
    created() {
      this.getList();
    },
    methods: {
      getList() {
        this.loading = true;
        this.apipost("/api/Coupon/GetDepositPageList", this.msg, res => {
          this.loading = false;
          if (res.data.resultCode == 1) {
            this.total = res.data.data.count;
            let pageData = res.data.data.pageData;
            this.tableData = pageData;
          }
        })
      },
      handleCurrentChange(val) {
        this.msg.pageIndex = val;
        this.getList();
      },
      //修改储蓄卡
      Edit(item) {
        this.$router.push({
          name: "editDeposit",
          query: {
            blank: "y",
            ID: item.ID
          },
        });
      },
      //新增储值卡
      addDeposit() {
        this.$router.push({
          name: "editDeposit",
          query: {
            blank: "y",
          },
        });
      },
      //删除储蓄卡
      Delete(item) {
        let that = this;
        that.Confirm("是否删除?", function () {
          that.apipost(
            "/api/Coupon/DelDeposit", {
              Id: item.ID
            },
            res => {
              if (res.data.resultCode == 1) {
                that.Success(res.data.message);
                that.getList();
              } else {
                that.Error(res.data.message);
              }
            },
          );
        });

      }
    },
    mounted() {

    }
  };

</script>
<style>
  .depositCenter .content .searchInput {
    border: 1px solid #DCDFE6;
    border-radius: 4px;
  }

  .depositCenter .content .searchInput .el-input__inner {
    border: none;
    outline: none;
    height: 30px;
    line-height: 30px;
  }

  .depositCenter .content .searchInput {
    line-height: normal;
    display: inline-table;
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    width: 250px;
    margin-right: 20px;
  }

  .depositCenter .content {
    background: #fff;
    margin-top: 10px;
    padding: 20px;
    box-sizing: border-box;
  }

</style>
