<template>
  <div class="app-container">
    <el-tabs v-model="activeTab">
      <el-tab-pane label="待完成工单" name="unFinish">
        <TicketManagerItem :is-finish="false" :user-role="userRole"/>
      </el-tab-pane>
      <el-tab-pane label="已完成工单" name="finish">
        <TicketManagerItem :is-finish="true" :user-role="userRole"/>
      </el-tab-pane>
      <el-tab-pane label="配件申请单" name="getApply" v-if="userRole !== 'repair_staff'">
        <TicketWares :type="true" :user-role="userRole"/>
      </el-tab-pane>
      <el-tab-pane name="finishGetWares" label="领料确认" v-if="userRole === 'repair_staff'">
        <GetAndBackWares :type="true" />
      </el-tab-pane>
      <el-tab-pane label="退料确认" name="finishBackWares" v-if="userRole === 'repair_staff'">
        <GetAndBackWares :type="false" />
      </el-tab-pane>
      <el-tab-pane :label="userRole === 'service_advisor' ? '可交车工单' : '待总检工单'" name="unInspection" v-if="userRole !== 'repair_staff'">
        <TicketFinishManager :user-role="userRole" />
      </el-tab-pane>
<!--      <el-tab-pane label="退料申请单" name="backApply">-->
<!--        <TicketWares :type="false" :user-role="userRole"/>-->
<!--      </el-tab-pane>-->
    </el-tabs>
  </div>
</template>

<script>
import TicketManagerItem from "@/views/repair/tickets/Components/TicketManagerItem.vue";
import {getUserRole} from "@/api/repair/tickets/Tickets";
import TicketWares from "@/views/repair/tickets/Components/TicketWares.vue";
import GetAndBackWares from "@/views/repair/tickets/form/GetAndBackWares.vue";
import TicketFinishManager from "@/views/repair/tickets/form/TicketFinishManager.vue";

export default {
  name: "TicketManager",
  components: {TicketFinishManager, GetAndBackWares, TicketWares, TicketManagerItem},
  data() {
    return {
      activeTab: 'unFinish',
      userRole: "",
      exportRole:[3, 4]
    }
  },
  created() {
    this.judgeUserRole()
  },
  methods: {
    // 获得当前登录用户的角色信息
    async judgeUserRole(){
      const res = await getUserRole()
      this.userRole = res.data
    }
  }
}
</script>

<style scoped lang="scss">

</style>
