<template>
  <div class="dashboard-container">
    <!--<div class="dashboard-text">欢迎您，{{ name }}</div>-->
    <el-row>
      <el-col v-if="hasPerm('/case/workList')" :span="8">
        <wait-handle style="height:100%" @detail="goWaitHandle"/>
      </el-col>
      <el-col v-if="hasPerm('/workSuperviseList')" :span="8">
        <wait-supervise style="height:100%" @detail="goWaitSupervise"/>
      </el-col>
      <el-col v-if="hasPerm('/workMonitorList')" :span="8">
        <wait-monitor style="height:100%" @detail="goWaitMonitor"/>
      </el-col>
      <el-col v-if="hasPerm('/checkSuperviseList')" :span="8">
        <wait-supervise-check style="height:100%" @detail="goWaitSuperviseCheck"/>
      </el-col>
      <el-col v-if="hasPerm('/checkMonitorList')" :span="8">
        <wait-monitor-check style="height:100%" @detail="goWaitMonitorCheck"/>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
import WaitHandle from './components/waitHandle'
import { caseRemind } from '@/api/callCase'
import WaitSupervise from './components/waitSupervise'
import WaitMonitor from './components/waitMonitor'
import WaitSuperviseCheck from './components/waitSuperviseCheck'
import WaitMonitorCheck from './components/waitMonitorCheck'

export default {
  name: 'Dashboard',
  components: { WaitMonitorCheck, WaitSuperviseCheck, WaitMonitor, WaitSupervise, WaitHandle },
  computed: {
    ...mapGetters([
      'name',
      'roleNames',
      'roleTips',
      'area'
    ])
  },
  mounted() {
    this.fetchCaseRemind()
  },
  activated() {
    console.log('actived')
  },
  methods: {
    // 工单提醒
    fetchCaseRemind() {
      caseRemind().then(response => {
        if (response.code === 200) {
          if (response.data.length > 0) {
            let message = ''
            for (const item of response.data) {
              message += '您有' + item.num + '条' + item.type + '<br/>'
            }
            this.$notify.warning({
              title: '待办',
              dangerouslyUseHTMLString: true,
              message: message,
              duration: 0,
              position: 'bottom-right'
            })
          }
        }
      })
    },
    goWaitHandle() {
      this.$router.push('/waitForHandle')
    },
    goWaitSupervise() {
      this.$router.push('/workSuperviseList')
    },
    goWaitSuperviseCheck() {
      this.$router.push('/checkSuperviseList')
    },
    goWaitMonitor() {
      this.$router.push('/workMonitorList')
    },
    goWaitMonitorCheck() {
      this.$router.push('/checkMonitorList')
    }

  }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
.dashboard {
  &-container {
    margin: 30px;
  }
  &-text {
    font-size: 30px;
    line-height: 46px;
  }
}
</style>
