<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" @refreshTable="getData"
        :themeClass="themeClass" :showButtons="showButtons">
      </content-box>
    </el-card>
  </div>
</template>
<script>
  import headerBox from "./components/header";
  import contentBox from "./components/content";
  import {
    mapState
  } from "vuex";
  export default {
    components: {
      headerBox,
      contentBox
    },
    data() {
      return {
        search: {
          title: "",
        }
      }
    },
    computed: {
      ...mapState({
        tableData: (state) => state.taskAllocation.tableData,
        pagination: (state) => state.taskAllocation.pagination,
        themeClass: (state) => state.taskAllocation.themeClass,
        showButtons: (state) => state.taskAllocation.showButtons,
      }),
      loading: {
        get() {
          return this.$store.state.taskAllocation.loading;
        },
        set(val) {
          this.$store.state.taskAllocation.loading = val;
        },
      },
    },
    methods: {
      getData() {
        this.loading = true;
        this.params = {
          page: this.pagination.pageNum,
          limit: this.pagination.pageSize,
          title: this.search.title,
          state: 2,
        };
        this.$store.dispatch('taskAllocation/getData', this.params).catch(res => {
          this.loading = false;
        })
      }
    },
    created() {
      let btnData = {
        menuid: this.$getMenuId(sessionStorage.getItem("routerIdList"), this.$route.path),
        roleid: sessionStorage.getItem("roleid")
      }
      this.$store.dispatch("taskAllocation/getButtonList", btnData);
      this.getData()
      this.$store.dispatch('taskAllocation/getthemeClass')
      this.$store.dispatch('taskAllocation/getUser')
    }
  }

</script>
