<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="openShelvesClick" size="mini" v-if="showButtons.put" type="primary">上架</el-button>
      </div>
      <content-box @refreshTable="getData" :tableData='tableData' :loading='tableLoading' :pagination='pagination'
        @handleSelectionChange='handleSelectionChange' />
    </el-card>
    <el-dialog title="选择上架区域" v-dialogDrag ref="diaFrom" :close-on-click-modal="false" :visible.sync="shelvesStatus"
      width="70%" top="10px" :before-close="cancel">
      <shelves-dia :qu1='qu1' :qu2='qu2' :lie1='lie1' :lie2='lie2' :mian1='mian1' :mian2='mian2' :mian3='mian3'
        :fondsList="fondsList" :mian4='mian4' :jie1='jie1' :jie2='jie2' :ceng1='ceng1' :ceng2='ceng2' :dangan='dangan'
        :shelvesStatus='shelvesStatus' :multipleSelection='multipleSelection' :storeHomes='storeHomes'
        :firstList='firstList' :secondList='secondList' :thirdList='thirdList' :fourthList='fourthList'
        :fifthList='fifthList' :sixthList='sixthList' :addressObj='addressObj' @cancel='cancel' @getData='getData'
        @roomClick='roomClick' @changeQu='changeQu' @changeLie='changeLie' @changeMian='changeMian'
        @changeJie='changeJie' @changeCeng='changeCeng' />
    </el-dialog>
  </div>
</template>
<script>
  import headerBox from "./components/header.vue"
  import contentBox from "./components/content.vue"
  import shelvesDia from "./components/shelvesDia.vue"
  import fileDia from "./components/fileDia.vue"
  import {
    mapState
  } from "vuex";
  import {
    listStore,
    onFile
  } from "@/api/intelligent-warehouse/warehouse-management/file-onShelves"
  import {
    getFondWithPage
  } from "@/api/system-management/allAdministration";
  import {
    mixin
  } from "@/mixins/imgSave";
  import {
    loading,
    loadingClose,
    clearObjValue,
    dateFormat,
    message,
  } from "@/utils/common"
  export default {
    mixins: [mixin],
    data() {
      return {
        search: {
          storageTime: "",
          labelId: ""
        },
        params: {},
        shelvesStatus: false,
        //库房

        //选择的对象
        multipleSelection: [],
        fondsList: [],
      }
    },
    computed: {
      ...mapState({
        tableData: (state) => state.fileOnShelves.tableData,
        pagination: (state) => state.fileOnShelves.pagination,
        paginationT: (state) => state.fileOnShelves.paginationT,
        showButtons: (state) => state.fileOnShelves.showButtons,
      }),
      tableLoading: {
        get() {
          return this.$store.state.fileOnShelves.tableLoading;
        },
        set(val) {
          this.$store.state.fileOnShelves.tableLoading = val;
        },
      },
    },
    components: {
      headerBox,
      contentBox,
      shelvesDia,
      fileDia
    },
    methods: {
      handleSelectionChange(val) {
        this.multipleSelection = val;
      },
      getFonds() {
        getFondWithPage({
          limit: 1000
        }).then(res => {
          this.fondsList = res.body.list;
        });
      },
      getData() {
        this.tableLoading = true
        this.params = {
          storageTime: this.search.storageTime ? dateFormat(this.search.storageTime) : "",
          labelId: this.search.labelId,
          state: 1,
          page: this.pagination.pageNum,
          limit: this.pagination.pageSize,
        }
        this.$store.dispatch('fileOnShelves/getData', this.params).catch(err => {
          this.tableLoading = false
        })
      },
      openShelvesClick() {
        if (!this.multipleSelection.length) {
          message('warning', '请先选择要上架的档案盒', 3000)
          return
        }
        this.ShelvesClick()
        this.shelvesStatus = true
      },

      cancel() {
        this.shelvesStatus = false
      },

      resetClick() {
        clearObjValue(this.search)
      }
    },
    created() {
      this.getFonds()
      let btnData = {
        menuid: this.$getMenuId(sessionStorage.getItem("routerIdList"), this.$route.path),
        roleid: sessionStorage.getItem("roleid")
      }
      this.$store.dispatch("fileOnShelves/getButtonList", btnData);
      this.getData()
      // this.ShelvesClick()
    },
    beforeDestroy() {
      this.sixthList = []
    }
  }

</script>
