<template>
  <div class="navbar">
    <hamburger :toggle-click="toggleSideBar" :is-active="sidebar.opened" class="hamburger-container" />

    <breadcrumb class="breadcrumb-container" />

     <Cti ref="ctiRef"/> 

    <div class="right-menu">
      <template v-if="device!=='mobile'">
        
      

        <el-tooltip content="全屏" effect="dark" placement="bottom">
          <screenfull class="right-menu-item" />
        </el-tooltip>

        <el-tooltip content="布局大小" effect="dark" placement="bottom">
          <size-select class="right-menu-item" />
        </el-tooltip>

        <el-tooltip content="通知中心" effect="dark" placement="bottom">
          <notice class="right-menu-item" />
        </el-tooltip>
      </template>

      <el-dropdown class="avatar-container right-menu-item" trigger="click">
        <div class="avatar-wrapper">
          <img :src="avatar+'?imageView2/1/w/80/h/80'" class="user-avatar">
          <i class="el-icon-caret-bottom" />
        </div>
        <el-dropdown-menu slot="dropdown">
          <router-link to="/">
            <el-dropdown-item>
              首页
            </el-dropdown-item>
          </router-link>
          <el-dropdown-item divided>
            <router-link to="/profile/password">
              密码修改
            </router-link>
          </el-dropdown-item>
          <el-dropdown-item divided>
            <span style="display:block;" @click="logout">退出</span>
          </el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
    </div>

 <div class="toggle-panel" @click="togglePanel"><i class="el-icon-phone-outline"></i>展开/关闭通话面板</div>
 <!-- 关闭时是否销毁弹框 -->
 <!-- :destroy-on-close="true" -->
 
 <el-dialog
  :visible.sync="panelVisible"
  :close-on-click-modal="true" 
  width="86%"
  :modal="true"
  :show-close="false"  
  top="50px"
  custom-class="telphone-dialog"
  >
  <div class="panel-wrapper">
    <!-- 客户信息 -->
    <div class="customer-wrapper">
      <el-card>
       <customerPanel ref="customerPanel" />
      </el-card>
    </div>
    <!-- 通话信息 工单信息 -->
    <div class="right-panel-wrapper">
      <div class="telphone-wrapper">
      <el-card v-if="panelType=='IB'||panelType=='OB'" style="margin-bottom:10px">

    <addCalllogIB ref="addCalllogIBRef" v-if="panelType=='IB'" />
    <addCalllogOB ref="addCalllogOBRef" v-if="panelType=='OB'" />
     </el-card>
      </div>
      <el-card>
       <addTicket ref="addTicketRef" />
      </el-card>
    </div>
  </div>
  
</el-dialog>


</div>

 
</template>

<script>
import { mapGetters } from 'vuex'
import Breadcrumb from '@/components/Breadcrumb'
import Hamburger from '@/components/Hamburger'
import Screenfull from '@/components/Screenfull'
import SizeSelect from '@/components/SizeSelect'
import Notice from '@/components/Notice'
import CustomerPanel from '../../components/customerPanel'
import AddCalllogIB from '../../components/addCalllogIB'
import AddCalllogOB from '../../components/addCalllogOB'
import AddTicket from '../../components/addTicket'
import { mapState } from 'vuex' 
import Cti from './Cti'
export default {
   data() {
        return {
         
            
        }},
 
  components: {
    Breadcrumb,
    Hamburger,
    Screenfull,
    SizeSelect,
    Notice,
    CustomerPanel,
    AddCalllogIB,
    AddCalllogOB,
    AddTicket,
    Cti
  },
  computed: {
    ...mapGetters([
      'sidebar',
      'name',
      'avatar',
      'device'
    ]),
    panelVisible:{
      get(){
 return this.$store.state.panel.panelVisible;
      },
      set(value){
  this.$store.commit('updatePanel',value);
      }
     
    },
   
    panelType(){
      return this.$store.state.panel.panelType;
    },
  },
  created(){
  console.log(this.$store); 
  },
  methods: {
    toggleSideBar() {
      this.$store.dispatch('toggleSideBar')
    },
    logout() {
      this.$store.dispatch('LogOut').then(() => {
        this.$router.push(`/login?redirect=${this.$route.fullPath}`)
      })
    },
    togglePanel(){
        this.$store.commit('togglePanel');
    }
  }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
.navbar {
  height: 50px;
  line-height: 50px;
  border-radius: 0px !important;
  .hamburger-container {
    line-height: 58px;
    height: 50px;
    float: left;
    padding: 0 10px;
  }
  .breadcrumb-container{
    float: left;
  }
  .errLog-container {
    display: inline-block;
    vertical-align: top;
  }
  .right-menu {
    float: right;
    height: 100%;
    &:focus{
     outline: none;
    }
    .right-menu-item {
      display: inline-block;
      margin: 0 8px;
      vertical-align: top;
    }
    .avatar-container {
      height: 50px;
      margin-right: 30px;
      .avatar-wrapper {
        cursor: pointer;
        margin-top: 5px;
        position: relative;
        .user-avatar {
          width: 40px;
          height: 40px;
          border-radius: 10px;
        }
        .el-icon-caret-bottom {
          position: absolute;
          right: -20px;
          top: 25px;
          font-size: 12px;
        }
      }
    }
  }

  .toggle-panel{
    float: right;
    margin-right:20px;
    // z-index:3000;
    // position: relative;
  }
  .toggle-panel:hover{
    cursor: pointer;
  }
  >>> .telphone-dialog{
    margin-left:210px!important;
    margin-right:0!important;
    // position: fixed;
    min-height: 500px;
    min-width: 1500px;
    
  }
   >>> .el-dialog__header{
   padding:10px 0px; 
  }
  >>> .el-dialog__body{
    padding:0 20px;
  }
  .panel-wrapper{
    display: flex;
    min-width:1200px;
    padding: 10px;
  }
  .customer-wrapper{
    margin-right:20px;
    flex: 1.3;
  }
  .right-panel-wrapper{
    flex:1;
    min-width: 500px;
  }
  .telphone-wrapper{
    //margin-bottom:20px;
    margin-top: 0px;
  }
}
</style>
