index.vue 4.22 KB
<template>
    <div class="headerLayout">
      <div class="tabList flex-1">
          <div v-for="(item,index) in buttenList" :key="index" @click="change(index)">
              <el-button class="tabButton" size="mini" :class="num==index?'is-active':''">{{item}}</el-button>
          </div>
      </div>
      <h3 class="flex-1">企业运行图谱</h3>
      <div class="flex-1 header-right-box">
        <div class="time">{{nowDate | moment("YYYY/MM/DD")}} {{nowDate | moment("HH:mm:ss")}} 星期{{week | weekFilter}}</div>
        <div class="right-menu">
          <el-dropdown class="avatar-container" trigger="click">
            <div class="avatar-wrapper">
              <img src="~@/assets/img/timg.jpg" class="user-avatar">
              <i class="el-icon-caret-bottom" />
            </div>
            <el-dropdown-menu slot="dropdown" class="user-dropdown">
              <router-link to="/">
                <el-dropdown-item>
                  Home
                </el-dropdown-item>
              </router-link>
              <el-dropdown-item divided @click.native="logout">
                <span style="display:block; width: 60px">Log Out</span>
              </el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </div>
      </div>
    </div>
</template>

<script>
export default {
  data () {
    return {
      screenWidth: document.body.clientWidth,
      num: 0,
      nowDate: '',
      week: '',
      hour: '',
      monthData: {
        id: 'dataByMonth',
        xData: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
        yData: [70, 90, 110, 108, 100, 110, 130, 140, 150, 120, 110, 98],
        colors: ['RGBA(27, 157, 247, 1)', 'RGBA(30, 201, 251, 1)']
      },
      buttenList: ['概况', '运营', '商机', '客户', '组织人才', '管理端']
    }
  },
  filters: {
    weekFilter: function (value) {
      let nvalue = ''
      switch (value) {
        case 1:
          nvalue = '一'
          break
        case 2:
          nvalue = '二'
          break
        case 3:
          nvalue = '三'
          break
        case 4:
          nvalue = '四'
          break
        case 5:
          nvalue = '五'
          break
        case 6:
          nvalue = '六'
          break
        case 0:
          nvalue = '日'
          break
      }
      return nvalue
    }
  },
  watch: {
    screenwidth (val) {
      if (!this.timer) {
        this.screenWidth = val
        this.timer = true
        const that = this
        setTimeout(function () {
          console.log(that.screenWidth)
          that.timer = false
        }, 400)
      }
    }
  },
  mounted () {
    this.init()
    this.getDate()
    const that = this
    window.onresize = () => {
      return (() => {
        window.screenWidth = document.body.clientWidth
        that.screenWidth = window.screenWidth
      })()
    }
  },
  methods: {
    logout () {
      this.$router.push('/login')
    },
    init () {
      this.num = sessionStorage.getItem('num')
      const user = JSON.parse(sessionStorage.getItem('user'))
      if (user.role === 1) {
        this.buttenList.push('管理端')
      }
    },
    getDate () {
      const vm = this
      this.nowDate = new Date()
      this.week = new Date().getDay()
      setTimeout(function () {
        vm.getDate()
      }, 1000)
    },
    change (index) {
      this.num = index
      sessionStorage.setItem('num', index)
      const token = sessionStorage.getItem('token')
      switch (index) {
        case 0:
          this.$router.replace('/index')
          break
        case 1:
          this.$router.replace('/content/operation/page')
          break
        case 2:
          this.$router.replace('/content/business/page')
          break
        case 3:
          this.$router.replace('/content/client/page')
          break
        case 4:
          this.$router.replace('/content/organization/page')
          break
        case 5:
          window.open('http://111.203.232.175:8085/#/dashboard?token=' + token)
          // window.open('http://localhost:9528/#/dashboard?token=' + token)
      }
    }
  }
}
</script>

<style lang="scss" scoped>
  @import '~@/assets/fonts/font.css';
  @import '~@/assets/style/headerLayout.scss';
</style>