<template>
  <div>
    <el-card style="margin-bottom:5px" :body-style="{ padding: '8px' }">
      <header-box :headerForm="search" @searchClick="getData">
      </header-box>
    </el-card>
    <el-card :body-style="{ padding: '5px' }">
      <content-box :loading="loading" :tableData="tableData" :pagination="pagination" :themeClass="themeClass"
        :ruleForm="ruleForm" :showButtons="showButtons" @getData="getData" @openDialog="openDialog" @refreshTable="getData">
      </content-box>
    </el-card>
  </div>
</template>
<script>
  import {
    message,
    clearObjValue
  } from "@/utils/common";
  import headerBox from "./components/header";
  import contentBox from "./components/content";
  import {
    mapState
  } from "vuex";
  export default {
    data() {
      return {
        search: {
          subjectName: "",
        },
        params: {},

      }
    },
    computed: {
      ...mapState({
        tableData: (state) => state.editingTopics.tableData,
        pagination: (state) => state.editingTopics.pagination,
        themeClass: (state) => state.editingTopics.themeClass,
        ruleForm: (state) => state.editingTopics.ruleForm,
        showButtons: (state) => state.editingTopics.showButtons,
      }),
      loading: {
        get() {
          return this.$store.state.editingTopics.loading;
        },
        set(val) {
          this.$store.state.editingTopics.loading = val;
        },
      },
    },
    components: {
      headerBox,
      contentBox
    },
    methods: {
      getData() {
        this.loading = true
        this.params = {
          subjectName: this.search.subjectName,
          page: this.pagination.pageNum,
          limit: this.pagination.pageSize,
          state: 0,
        }
        this.$store.dispatch('editingTopics/getData', this.params).catch(err => {
          this.loading = false
        })
      },
      openDialog() {},

    },
    created() {
      let btnData = {
        menuid: this.$getMenuId(sessionStorage.getItem("routerIdList"), this.$route.path),
        roleid: sessionStorage.getItem("roleid")
      }
      this.$store.dispatch("editingTopics/getButtonList", btnData);
      this.getData()
      this.$store.dispatch('editingTopics/getthemeClass')
    }
  }

</script>
