<template>
  <div class="normal-card">
    <search @searchActive="searchActive" @clearData="clearData" v-if="tool.checkAuth($route.name,'read')"></search>
    <div class="content">
      <list :list="list" v-if="tool.checkAuth($route.name,'read')"></list>
      <div class="page">
        <pagination :total="total"
                    :pageSize="param.content.pageSize"
                    :currentPage="param.content.pageNumber"
                    @pageChange="pageChange">
        </pagination>
      </div>
    </div>
  </div>
</template>

<script>
import Pagination from '@/components/pagination/Pagination'
import List from '@/SManagement/notice/compoents/list'
import search from '@/components/search/index'
export default {
  name: "Index",
  data() {
    return {
      param:{
        "accesstoken": "2686aade24d20b15bbaa177dc35e638c",
        "classname": "saletool.notice.notice",
        "method": "queryNoticeList",
        "content": {
          "nocache": true,
          "pageNumber": 1,
          "pageSize": 10,
          "where":{
              "condition":""
          }
        }
      },
      searchTitle: '',
      list:[],
      total:0,
      currentPage:0,
    };
  },
  components: {
    Pagination,
    List,
    search,
  },
  created() {
    this.getNoticeData()
  },
  mounted() {},
  methods: {
    //获取通告列表
    getNoticeData() {
      this.$api.requested(this.param).then(res =>{
      this.list = res.data
      this.total = res.total
      })
    },
    pageChange(val) {
      this.param.content.pageNumber = val
      this.getNoticeData()
    },

    searchActive(data) {
      if(!data) return 
      this.param.content.where.condition = data.trim()
      this.$api.requested(this.param).then(res =>{
      this.list = res.data
      this.total = res.total
      })
    },
    clearData() {
      this.param.content.where.condition = ''
      this.getNoticeData()
    },
  }
};
</script>
<style scoped>
*{
  box-sizing: border-box;
}
.normal-card {
  min-height: 100%;
  padding: 20px 0 50px 30px;
  font-family: PingFang SC-Regular;
}
.normal-card .search {
  width: 320px;
  height: 36px;
}
.el-pagination {
  position: absolute;
  right: 16px;
  bottom: 0;
}
</style>