Newer
Older
XuZhouCallCenterFront / src / layout / components / Sidebar / Item.vue
StephanieGitHub on 21 Apr 2020 1 KB MOD:侧边栏加数量提醒
<template>
  <div>
    <svg-icon v-if="icon" :icon-class="icon"/>
    <span v-if="title" slot="title">{{ title }}<span v-if="count">【{{ count }}】</span></span>
  </div>
</template>
<script>
import { getCount } from '@/api/callCase'
export default {
  name: 'MenuItem',
  // functional: true,
  props: {
    icon: {
      type: String,
      default: ''
    },
    title: {
      type: String,
      default: ''
    },
    meta: {
      type: Object,
      default: null
    }
  },
  data() {
    return {
      count: 0
    }
  },
  created() {
    // 如果需要提醒
    // if (this.meta.remind) {
    //   this.getRealtimeData()
    //   this.clock()
    // }
  },
  methods: {
    clock() {
      const that = this
      setInterval(function() {
        that.getRealtimeData()
      }, 60000)
    },
    getRealtimeData() {
      getCount(this.meta.type).then(response => {
        if (response.code === 200) {
          response.count = 2
          this.count = response.count
        }
      })
    }
  }
  // render(h, context) {
  //   const { icon, title } = context.props
  //   const vnodes = []
  //
  //   if (icon) {
  //     vnodes.push(<svg-icon icon-class={icon}/>)
  //   }
  //
  //   if (title) {
  //     vnodes.push(<span slot='title'>{(title)}</span>)
  //   }
  //   return vnodes
  // }
}
</script>