<template>
  <div>
    <el-card :body-style="{ padding: '5px' }" style="margin-bottom:5px">
      <header-box :search="search" @searchClick='getData' @resetClick='resetClick' />
    </el-card>
    <el-card :body-style="{ padding: '5px' }">
      <!-- <div style="text-align:right;padding:5px 10px ">
        <el-button @click="warehousingClick" size="mini" v-if="showButtons.ware" type="primary">入库</el-button>
      </div> -->
      <content-box :tableData='tableData' :loading='tableLoading' :pagination='pagination' @refreshTable="getData" />
    </el-card>
    <warehousing-dia :wareStatus='wareStatus' @cancel='cancel' @getData='getData' />
  </div>
</template>
<script>
  import headerBox from "./components/header.vue"
  import contentBox from "./components/content.vue"
  import warehousingDia from "./components/warehousingDia.vue"
  import {
    clearObjValue,
    dateFormat,
  } from "@/utils/common"
  import {
    mapState
  } from "vuex";
  export default {
    data() {
      return {
        search: {
          storageTime: "",
          labelId: ""
        },
        wareStatus: false
      }
    },
    computed: {
      ...mapState({
        tableData: (state) => state.fileStorage.tableData,
        pagination: (state) => state.fileStorage.pagination,
        showButtons: (state) => state.fileStorage.showButtons,
      }),
      tableLoading: {
        get() {
          return this.$store.state.fileStorage.tableLoading;
        },
        set(val) {
          this.$store.state.fileStorage.tableLoading = val;
        },
      },
    },
    components: {
      headerBox,
      contentBox,
      warehousingDia
    },
    methods: {
      getData() {
        this.params = {
          state: 1,
          page: this.pagination.pageNum,
          limit: this.pagination.pageSize,
          storageTime: this.search.storageTime ? dateFormat(this.search.storageTime) : "",
          labelId: this.search.labelId,
        }
        this.$store.dispatch('fileStorage/getData', this.params)
      },
      resetClick() {
        clearObjValue(this.search)
      },
      warehousingClick() {
        this.wareStatus = true
      },
      cancel() {
        this.wareStatus = false
      }
    },
    created() {
      let btnData = {
        menuid: this.$getMenuId(sessionStorage.getItem("routerIdList"), this.$route.path),
        roleid: sessionStorage.getItem("roleid")
      }
      this.$store.dispatch("fileStorage/getButtonList", btnData);
      this.getData()
    }

  }

</script>``
