<template>
  <tab-bar class="bar">
    <tab-bar-item :curTab="curTab" :path="tab.path" v-for="tab in tabList" :key="tab.path">
      <template v-slot:item-text>
        <div class="title-style">{{ tab.title }}</div>
      </template>
      <template v-slot:item-icon>
        <image class="hengxian" mode="widthFix" :src="tab.icon"/>
      </template>
      <template v-slot:item-icon-active>
        <image class="hengxian" mode="widthFix" :src="tab.icon"/>
      </template>
    </tab-bar-item>
    <!--    <tab-bar-item path="GX" activeColor="black" style="border-right: solid #A2A3A5">-->
    <!--      <template v-slot:item-text>-->
    <!--        <div class="title-style">工序</div>-->
    <!--      </template>-->
    <!--      <template v-slot:item-icon><img class="hengxian" :src="require('@/static/icons/png/gx.png')" alt=""></template>-->
    <!--      <template v-slot:item-icon-active><img class="hengxian" :src="require('@/static/icons/png/gx.png')" alt="">-->
    <!--      </template>-->
    <!--    </tab-bar-item>-->
    <!--    <tab-bar-item path="QC">-->
    <!--      <template v-slot:item-text>-->
    <!--        <div class="title-style">质量</div>-->
    <!--      </template>-->
    <!--      <template v-slot:item-icon>-->
    <!--        <image class="hengxian" mode="widthFix" :src="require('@/static/icons/png/qc.png')"/>-->
    <!--      </template>-->
    <!--      <template v-slot:item-icon-active>-->
    <!--        <image class="hengxian" mode="widthFix" :src="require('@/static/icons/png/qc.png')"/>-->
    <!--      </template>-->
    <!--    </tab-bar-item>-->
    <!--        <tab-bar-item path="DV" activeColor="black">-->
    <!--            <template v-slot:item-text><div class="title-style">设备</div></template>-->
    <!--            <template v-slot:item-icon><img class="hengxian" :src="require('@/static/icons/png/dev.png')" alt=""></template>-->
    <!--            <template v-slot:item-icon-active><img class="hengxian" :src="require('@/static/icons/png/dev.png')" alt=""></template>-->
    <!--        </tab-bar-item>-->
  </tab-bar>
</template>

<script>
import i18n from '../../lang/index'

import TabBar from "@/components/TabBar/TabBar.vue";
import TabBarItem from "@/components/TabBar/TabBarItem.vue";

export default {
  name: "TabHeader",
  components: {
    TabBar,
    TabBarItem
  },
  data() {
    return {
      curTab: 'PRO',
      proImg: require('@/static/icons/png/pro.png')
    }
  },
  computed: {
    tabList () {
      if (this.isWaiXie) {
        return [{
          path: 'PRO',
          title: i18n.t('外协'),
          icon: require('@/static/icons/png/wx.png')
        }]
      } else {
        return [{
          path: 'PRO',
          title: i18n.t('生产'),
          icon: require('@/static/icons/png/pro.png')
        }]
      }
    },
    isWaiXie() {
      if ((!this.vuex_workunit && this.vuex_workunitList && this.vuex_workunitList[0] && this.vuex_workunitList[0].workunitId === 1) || (this.vuex_workunit && this.vuex_workunit.workunitId === 1))
        return true
      return false
    }
  },
  created() {
    uni.$on('switchTab', (indexCode) => {
      this.curTab = indexCode;
    })
  },
}
</script>

<style scoped>
.title-style {
  font-weight: bold;
  margin: auto;
  text-align: center;
  cursor: pointer;
  line-height: 30px;
  font-size: 40rpx;
}


.hengxian {
  width: 35px;
}

.divider {
  background-color: #b9bdbd;
  margin: 5px 0px;
  height: 70px;
}

.Hline {
  background-image: linear-gradient(to right, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.75), rgba(0, 0, 0, 0));
  width: 1px; /*设置宽高*/
  vertical-align: middle;
  height: 80%;
  position: relative; /*调整位置*/
  left: 150px;
  float: left; /*让此div与前面的并排显示*/
}

.style-two {
  align: center;
  width: 80%;
  margin: 0 auto;
  border: 0;
  height: 1px;
  background-image: linear-gradient(to right, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.75), rgba(0, 0, 0, 0));
}
</style>
