<template>
  <div class="activityList">
    <div class="el-card__header">
      <span>活动管理</span>
      <div style="display: flex;flex-direction: row;align-items: center">
        <el-button type="primary" class="el-button--small" @click="addRecharge">新增</el-button>
      </div>
    </div>
    <div class="content">
      <div style="display: flex;flex-direction: row;align-items: center">
        <div class="block">
          <div class="searchInput" style="width:250px">
            <el-input style="display:inline-block;width:225px;height:30px"
                      placeholder="请输入活动名称搜索"
                      v-model="msg.Title"
                      size="small"
                      @clear="getList"
                      @keyup.enter.native="getList"
                      clearable>
            </el-input>
            <span @click="getList" class="el-icon-search" style="color:#979dad;font-size:14px;position:relative;top:1px"></span>
          </div>
          <span>领奖方式</span>
          <el-select class="w100" @change="getList()" style="margin-right: 10px;"
                     v-model="msg.PrizeType" size="small" placeholder="请选择">
            <el-option label="不限" :value="0"></el-option>
            <el-option v-for="item in platList" :key="item.Id" :label="item.Name" :value="item.Id">
            </el-option>
          </el-select>
        </div>
      </div>
    </div>


    <div style="padding: 20px;background: #fff;">
      <el-table
        :data="tableData"
        header-cell-class-name="headClass"
        style="width: 100%"
        border
      >

        <el-table-column
          prop="ID"
          label="ID"
          width="100">
        </el-table-column>

        <el-table-column
          prop="Title"
          label="活动信息">

        </el-table-column>
        <el-table-column
          prop="HeXiao"
          label="活动时间">
          <template slot-scope="scope">

            <div flex="dir:left cross:center">
              {{scope.row.StartDateStr}}
            </div>
            <div flex="dir:left cross:center">
              {{scope.row.EndDateStr}}
            </div>
          </template>

        </el-table-column>



        <el-table-column
          label="领奖方式"
          prop="PrizeTypeStr">

        </el-table-column>
        <el-table-column
          label="领奖地址"
          prop="PrizeAddress">

        </el-table-column>
        <el-table-column
          label="奖品说明"
          prop="Description">

        </el-table-column>
        <el-table-column
          label="问卷调查份数"
          prop="SurveyNum">

        </el-table-column>



        <el-table-column
          fixed="right"
          label="操作"
          width="180"
        >
          <template slot-scope="scope">
            <el-tooltip class="item" effect="dark" content="意见调查表" placement="top" >
              <img src="../../assets/img/setup/send.png" alt="" class="imgstyle" @click="grant(scope.row)">
            </el-tooltip>
            <el-tooltip class="item" effect="dark" content="编辑" placement="top" >
              <img src="../../assets/img/setup/edit.png" alt="" class="imgstyle" @click="Edit(scope.row)">
            </el-tooltip>
            <el-tooltip class="item" effect="dark" content="删除" placement="top" >
              <img src="../../assets/img/setup/del.png" alt="" class="imgstyle" @click="delete_b(scope.row)">
            </el-tooltip>
          </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="count">
      </el-pagination>
    </div>
  </div>
</template>

<script>
  export default {
    name: "activityList",
    data(){
      return{
        msg:{
          pageIndex:1,
          pageSize:20,
          PrizeType:0,
          Title:'',
        },
        tableData:[],
        count:0,
        loading:false,
        platList:[],
      }
    },
    created(){
      this.getDateList();
      this.GetPrizeTypeEnumList()
    },
    methods:{
      getDateList(){
        this.loading=true;
        this.apipost("/api/Survey/GetActivitySurveyPageList", this.msg, res => {
          this.loading=false;
          if(res.data.resultCode==1){
            this.tableData = res.data.data.pageData;
            this.count = res.data.data.count;
          }else {
            this.Info(res.data.message);
          }

        })
      },
      GetPrizeTypeEnumList(){
        this.apipost("/api/Survey/GetPrizeTypeEnumList", {}, res => {
          if(res.data.resultCode==1){
            this.platList = res.data.data
          }else {
            this.Info(res.data.message);
          }

        })
      },
      addRecharge(){
        this.$router.push('/addActivity');

      },
      grant(row){
        this.$router.push({
          name: 'questionnaireList',
          query: {
            ID:row.ID,
            blank: "y"
          }
        });
      },
      Edit(row){
        this.$router.push({
          name: 'addActivity',
          query: {
            ID:row.ID,
            blank: "y"
          }
        });
      },
      delete_b(row){
        let that=this;
        that.Confirm("是否删除?", function () {
          that.apipost(
            "/api/Survey/DelActivitySurvey",
            {ID:row.ID},
            res => {
              if (res.data.resultCode == 1) {
                that.Success(res.data.message);
                that.getDateList();
              } else {
                that.Error(res.data.message);
              }
            },
          );
        });
      },
      SetUp(){
        this.$router.push('/rechargeSet');
      },
      getList(){
        this.msg.pageIndex = 1
        this.getDateList()
      },
      dianswitch(row){
        this.apipost("/api/Education/UpdatePickupType", {'Id':row.ID}, res => {
          if(res.data.resultCode==1){
            this.Success(res.data.message);
          }else {
            this.Info(res.data.message);
          }

        })
      },
      handleCurrentChange(val) {
        this.msg.pageIndex = val;
        this.getDateList();
      },
    },
  }
</script>

<style >
  .activityList .el-card__header{
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    background: #fff;

  }
  .activityList .el-button--small{
    padding: 9px 15px;
  }
  .activityList .content .searchInput{
    border: 1px solid #DCDFE6;
    border-radius: 4px;
    margin-left: 20px;
  }
  .activityList .content .searchInput .el-input__inner{
    border:none;outline:none;
    height: 30px;
    line-height: 30px;
  }
  .activityList .content .searchInput{
    line-height: normal;
    display: inline-table;
    border-collapse: separate;
    border-spacing: 0;
    width:250px;
  }
  .activityList .content{
    background: #fff;
    margin-top:10px;
    padding: 15px;
    box-sizing: border-box;
  }
  .activityList .app-image{
    background-position: center center;
    width: 50px;
    height: 50px;
    border-radius:0%;
    float: left;
    margin-right: 8px;
  }
</style>
