<template>
  <div class="inventoryReportList-wrap">
    <!-- 标签页 -->
    <div style="background-color: #fff;margin-bottom: 5px;">
      <a-tabs :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>
    </div>
    <a-card size="small" :bordered="false" >
      <a-spin :spinning="spinning" tip="Loading...">
        <inventoryOrder v-show="nowKey=='1'" @spinning="spinningFun" />
        <inventoryDetail v-show="nowKey=='2'" @spinning="spinningFun" />
      </a-spin>
    </a-card>
  </div>
</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{
    .ant-tabs-bar{
      margin:0 !important;
    }
	}
</style>
