<template>
  <a-card size="small" :bordered="false" class="inventoryReportList-wrap">
    <a-spin :spinning="spinning" tip="Loading...">
      <!-- 标签页 -->
      <a-tabs type="card" :default-active-key="nowKey" @change="handleTabChange" class="inventoryReportList-tabs ">
        <a-tab-pane v-for="item in tabPaneData" :key="item.val">
          <span slot="tab">{{ item.name }}</span>
        </a-tab-pane>
      </a-tabs>
      <inventoryOrder v-show="nowKey=='1'" @spinning="spinningFun" />
      <inventoryDetail v-show="nowKey=='2'" @spinning="spinningFun" />
    </a-spin>
  </a-card>
</template>

<script>
import { commonMixin } from '@/utils/mixin'
import inventoryOrder from './inventoryOrder.vue'
import inventoryDetail from './inventoryDetail.vue'
export default {
  components: { inventoryOrder, inventoryDetail },
  mixins: [commonMixin],
  data () {
    return {
      spinning: false,
      tabPaneData: [
        { name: '盘点单报表', val: '1' },
        { name: '盘点盈亏明细报表', val: '2' }
      ],
      nowKey: '1'
    }
  },
  methods: {
    spinningFun (val) {
      this.spinning = val
    },
    // tab切换
    handleTabChange (key) {
      this.nowKey = key
    }
  },
  mounted () {
    if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
      this.nowKey = '1'
    }
  },
  activated () {
    // 如果是新页签打开，则重置当前页面
    if (this.$store.state.app.isNewTab) {
      this.nowKey = '1'
    }
  },
  beforeRouteEnter (to, from, next) {
    next(vm => {})
  }
}
</script>
<style lang="less">
	.inventoryReportList-wrap{
		.inventoryReportList-tabs.ant-tabs.ant-tabs-card .ant-tabs-card-bar .ant-tabs-nav-container{
      height: 30px!important;
		}
    .inventoryReportList-tabs.ant-tabs.ant-tabs-card .ant-tabs-card-bar .ant-tabs-tab-active{
      height: 30px!important;
    }
    .inventoryReportList-tabs.ant-tabs.ant-tabs-card .ant-tabs-card-bar .ant-tabs-tab{
      line-height: 26px!important;
      height: 30px!important;
    }
	}
</style>
