<template>
  <div class="global">
    <div class="mainContainer">
      <el-tabs v-if="isShow" v-model="activeName" @tab-click="handleClick">
        <el-tab-pane label="已发起" name="Initiated"></el-tab-pane>
        <el-tab-pane label="待处理" name="Pending">
          <span slot="label" v-if="this.pendingCount!=0">待处理({{pendingCount}})</span>
            <span slot="label" v-if="this.pendingCount==0">待处理</span>
        </el-tab-pane>
        <el-tab-pane label="已处理" name="Processed">
           <span slot="label" v-if="this.proCount!=0">已处理({{proCount}})</span>
           <span slot="label" v-if="this.proCount==0">待处理</span>
        </el-tab-pane>
       
      </el-tabs>
      <div id="main">
        <router-view />
      </div>
    </div>
  </div>
</template>
<script>
import { pending } from "@/api/daiBan/index"
export default {
  name: "DaiBanTabs",
  data() {
    return {
      userInfo:{},
      //已处理数量
      proCount:0,
      //待处理数量
      pendingCount:0,
      activeName: "Initiated",
      isShow:true,
    }
  },
  mounted() {
   
     //获取当前缓存的登录用户信息
    this.userInfo = JSON.parse(localStorage.getItem("userInfo"))
    console.log(this.userInfo, "this.userInfo.....")
    this.activeName = this.$route.name;
    console.log(Event,'????????????');

    console.log(this.$route)
    if (this.$route.name == "IniDetails" ||this.$route.name == "PenDetails"||this.$route.name == "ProDetails") {
      this.isShow = false
    } else {
      this.isShow = true
    }
     this.proCount = JSON.parse(localStorage.getItem("proCount"));
     this.pendingCount=JSON.parse(localStorage.getItem("pendingCount"));
    
    this.bus.$on('pendingCount', ()=>
    {
      this.getPending();
    })
    this.getPending();
  },
  methods: {
    handleClick(tab, event) {
      this.$router.push({
        name: tab.name,
      })
    },


     //待处理列表数据
    getPending() {
      var condition = {
        userId: this.userInfo.uid,
      }
      condition = JSON.stringify(condition)
      var data = {
        pageIndex:1,
        pageSize: 10,
        condition: condition,
      }
      
      pending(data).then((res) => {
        if (res.code == 200) {
          console.log(res)
    
       
          this.pendingCount= res.data.total;
        
         

        }
      })
    },

  },
}
</script>
<style lang="scss" scoped>
</style>