<template>
  <div class="contact-us">
    <router-view />
    <template v-if="!$route.params.id">
      <cy-comm-table
        ref="commTable"
        v-loading="loading"
        :columns="columns"
        :data="tableData"
        :count="total"
        :table-options="tableOptions"
      />
    </template>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
import indexTable from './indexTable'
import { queryContactList } from '@/api/contactUs/index'
export default {
  name: 'ContactUsHome',
  mixins: [indexTable],
  data() {
    return {
      loading: false,
      tableData: [],
      page: 1,
      size: 10,
      total: 0
    }
  },
  computed: {
    ...mapGetters([
      'name'
    ])
  },
  mounted() {
    this.fetchData()
  },
  methods: {
    fetchData() {
      this.loading = true
      const params = {
        page: this.page || 1,
        rows: this.size || 10
      }
      queryContactList(params).then((res) => {
        this.tableData = res.rows
        this.loading = false
        this.total = res.total
      })
    },
    handlerOperate(type, row, msg) {
      if (type === 'see') {
        this.$router.push({
          path: '/contactus/detail',
          query: {
            id: row.id
          }
        })
      }
    }
  }
}
</script>

<style lang="scss" scoped>
.contact-us {

}
</style>
