<template>
  <div class="app-container">
    <el-tabs v-model="activeTab" @tab-click="changeTab">
      <el-tab-pane label="采购单据" name="purchase">
        <SoIndex :so-by-type="soByType"/>
      </el-tab-pane>
      <el-tab-pane label="急件单据" name="urgentPurchase">
        <SoIndex :so-by-type="soByType" :goods-yes="true"/>
      </el-tab-pane>
      <el-tab-pane label="作废单据" name="voidPurchase">
        <SoVoid :so-by-type="soByType" />
      </el-tab-pane>
      <el-tab-pane label="采购明细" name="detailPurchase">
        <SoiTable :so-by-type="soByType" />
      </el-tab-pane>
      <el-tab-pane label="采购单" name="purchaseCreate">
        <SoInfo :so-by-type="soByType" :so-type="soType"/>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>

<script>

import SoInfo from "@/views/repair/stockOperate/Components/SoInfo.vue";
import SoIndex from "@/views/repair/stockOperate/Components/SoIndex.vue";
import SoVoid from "@/views/repair/stockOperate/Components/SoVoid.vue";
import SoiTable from "@/views/repair/stockOperate/Components/SoiTable.vue";

export default {
  name: "InStock",
  components: {
    SoiTable,
    SoVoid,
    SoIndex,
    SoInfo
  },
  data() {
    return {
      activeTab: "purchase",
      soByType: true,
      soType: null
    }
  },
  created() {
    this.isType()
    this.init()
  },
  methods: {
    // 判断是什么单据，决定字段的属性、展示否等
    async isType() {
      const url = this.$route.path
      this.soByType = url.includes("soi")
    },
    // 判断是点进来的还是跳转过来的
    async init(){
      const active = this.$route.query.active
      if (active){
        this.activeTab = active
      }
      const soType = this.$route.query.soType
      if (soType){
        this.soType = soType
      }
    },
    changeTab(tab, event){
      // if (this.soType){
      //   this.$router.push("/repair/stock/repair-soi")
      // }
    }
  }
}
</script>

<style scoped lang="scss">

</style>
