<template>
  <div class="container-search">
    <el-card>
      <div class="search-top">
        <span>近7天热词</span>
        <div>
          <a :href="exportUser" download>
            <el-button type="primary">下载明细</el-button>
          </a>
        </div>
      </div>
    </el-card>
    <el-card style="margin-top: 20px">
      <el-table style="width: 100%" border :data="searchList">
        <el-table-column label="排序" align="center" width="84" prop="Sort">
        </el-table-column>
        <el-table-column align="center" label="关键词"  prop="KeyWord"> </el-table-column>
        <el-table-column align="center" label="搜索次数"  prop="KeyWordNum"> </el-table-column>
      </el-table>
      <el-pagination
        @current-change="handleCurrentChange"
        background
        layout="pager"
        :page-size="12"
        :total="total"
      >
      </el-pagination>
    </el-card>
  </div>
</template>

<script>
import { raiInterface } from "@/api/api.js";
export default {
  name: "",
  components: {},
  props: {},
  data() {
    return {
      PageSize: 12,
      CurrentIndex: 1,
      searchList: [],
      total:0
    };
  },
  computed: {
    // 导出地址
    exportUser() {
      return (
        process.env.API_ROOT + "/cygx/hostKeyword/download?"+localStorage.getItem('auth')||''
      );
    },
  },
  watch: {},
  created() {
    
  },
  mounted() {
    this.applyList()
  },
  methods: {
     applyList() {
      raiInterface.hostKeyword({
        PageSize:this.PageSize,
        CurrentIndex:this.CurrentIndex,
      }).then((res=>{
        if(res.Ret === 200){
          this.total=res.Data.Paging.Totals
          this.searchList=res.Data.List
        }       
      }))
    },
     handleCurrentChange(val) {
       this.CurrentIndex=val;
       this.applyList()
    }
  },
};
</script>
<style scoped lang="scss">
.container-search {
  .search-top {
    display: flex;
    justify-content: space-between;
    span {
      width: 122px;
      height: 40px;
      background: #f0f2f5;
      opacity: 1;
      line-height: 40px;
      text-align: center;
      color: #666666;
    }
  }
  .el-pagination {
    margin-top: 20px;
    text-align: right;
  }
}
</style>
