<template>
  <div id="inboundRequests">
    <el-card shadow="never" v-loading="loading">
      <search @search="reload" :activeName="activeName" ref="searchRef">
      </search>
      <el-tabs type="border-card" v-model="activeName" @tab-click="handleClick">
        <el-tab-pane label="入库" name="入库">
          <tgTable
            v-if="activeName == '入库'"
            ref="tableRef"
            type="1"
          ></tgTable>
        </el-tab-pane>
        <el-tab-pane label="出库" name="出库">
          <tgTable
            v-if="activeName == '出库'"
            ref="tableRef"
            type="2"
          ></tgTable>
        </el-tab-pane>
        <el-tab-pane label="出入库明细表" name="出入库明细表">
          <allTable
            v-if="activeName == '出入库明细表'"
            ref="tableRef"
          ></allTable>
        </el-tab-pane>
      </el-tabs>
    </el-card>
  </div>
</template>

<script>
  import search from './components/search.vue';
  import tgDetails from './components/tgDetails.vue';
  import tgTable from './components/tgTable.vue';
  import allTable from './components/allTable.vue';
  export default {
    components: {
      search,
      tgDetails,
      tgTable,
      allTable
    },
    data() {
      return {
        activeName: '入库',
        loading: false
      };
    },
    created() {},
    methods: {
      handleClick(tab) {
        this.activeName = tab.name;
        this.$refs.tableRef && this.$refs.tableRef.reload(tab.name);
      },
      /* 刷新表格 */
      reload(where) {
        this.$refs.tableRef.reload(where);
      }
    }
  };
</script>

<style lang="scss" scoped>
  #inboundRequests {
    height: calc(100vh - 96px);
    width: 100%;
    :deep(.el-card) {
      height: 100%;
      .el-card__body {
        height: 100%;
        box-sizing: border-box;
        display: flex;
        flex-direction: column;
        .el-tabs {
          flex: 1;
          display: flex;
          flex-direction: column;
          .el-tabs__content {
            flex: 1;
            .el-tab-pane {
              height: 100%;
            }
          }
        }
        .el-form-item {
          margin-bottom: 5px !important;
        }
      }
    }
  }
</style>
