<template>
  <div class="inspect-driver">
    <el-tabs v-model="activeName" type="border-card">
      <el-tab-pane label="未分配" name="index">
        <allocated :adminList="adminList" :statusList="statusList" :activeName="activeName" v-if="activeName=='index'"
                   :typeList="typeList"  :equipmentTypeList="equipmentTypeList"></allocated>
      </el-tab-pane>
      <el-tab-pane v-if="isAdmin||btnRule.some(btn=>btn=='assignedList')" label="已分配" name="assignedList">
        <allocated :adminList="adminList" :statusList="statusList" :activeName="activeName"
                   v-if="activeName=='assignedList'" :typeList="typeList"  :equipmentTypeList="equipmentTypeList"></allocated>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>

<script>
  import inspectApi from '@/api/business/inspect'
  import allocated from './allocated'
  import {mapGetters} from "vuex";

  export default {
    name: "inspect-driver",
    data() {
      return {
        activeName: 'index',
        typeList: {},
        equipmentTypeList:{},
        adminList: [],
        statusList: {}
      }
    },
    components: {allocated},
    created() {
    },
    computed: {
      ...mapGetters(["btnRule", "isAdmin"])
    },
    mounted() {
      this.getBaseData()
    },
    methods: {
      getBaseData() {
        inspectApi.basicData().then(res => {
          const {areaList, statusList, adminList, typeList,equipmentTypeList} = res.data
          this.equipmentTypeList=equipmentTypeList?equipmentTypeList:{}
          this.typeList = typeList ? typeList : {}
          this.statusList = statusList ? statusList : {}
          this.adminList = adminList ? adminList : []
        }).catch(e => {
          this.typeList = {}
          this.equipmentTypeList={}
          this.statusList = {}
          this.adminList = []
        })
      }
    }
  }
</script>

<style lang="less">
  .inspect-driver {
    width: 100%;
  }
</style>
