<template>
  <div class="pa-3 white fill-height d-flex flex-column">
    <contact-us-search :type-lists="typeLists" @contactUsSearch="contactUsSearch" />
    <contact-us-date :lists="lists" :pagination="pagination" @contactUsSearch="contactUsSearch" />
  </div>
</template>

<script>
import ContactUsSearch from 'components/Contact/ContactUsSearch.vue';
import ContactUsDate from 'components/Contact/ContactDate.vue';
import { contactUsSearch } from 'config/api';
import { mapActions } from 'vuex';

export default {
  name: 'Contact',
  components: {
    ContactUsSearch,
    ContactUsDate,
  },

  data() {
    return {
      lists: [],
      pagination: { current: 1, pageSize: 10 },
      typeLists: [],
    };
  },

  async created() {

    await this.contactUsSearch();
  },

  methods: {
    ...mapActions(['getSelModelSearch']),

    /**
     * 后台查询修改
     * 
     */
    async contactUsSearch(condition) {
      try {
        const params = {
          param: {
            pageNum: (condition && condition.current) || 1,
            pageSize: (condition && condition.pageSize) || 10,
          },
        };
      
        const res = await contactUsSearch(params);
        const { code, msg, data } = res.data;
        if (code === 200) {
          this.lists = data.list;
          console.log("========>是否获取到数据")
          const paper = { ...this.pagination };
          paper.current = data.pageNum;
          paper.total = +data.total;
          paper.pageSize = data.pageSize;
          this.pagination = paper;
        } else {
          throw msg || '获取失败';
        }
      } catch (error) {
        this.$message.error(error);
      }
    },
  },
};
</script>
