import * as api from '@/api/manage.js'
import { mapGetters } from 'vuex'
import { getRouters } from '@/api/settle'
export default {
  data() {
    return {
      waitApprovalNum: '',
      receiveApprovalNum: '',
      defaultTabItem: 'dashboard',
      topList: [
        {
          name: '看板',
          path: 'summaryDashboard'
        },
        {
          name: '代办',
          path: 'dashboard'
        },
        {
          name: '已办',
          path: 'hasIndex'
        },
        {
          name: '抄送查阅/操作',
          path: 'receiveIndex'
        }
        // {
        //   name: '商品审核',
        //   path: 'goodsCheck',
        // },
        // {
        //   name: '产品审核',
        //   path: 'productCheck',
        // },
      ],
      roleMenu: []
    }
  },
  computed: {
    ...mapGetters(['name', 'user'])
  },
  created() {
    this.getRoles()
  },
  methods: {
    getApprovalStatus() {
      api.waitApprovalNum().then((res) => {
        this.waitApprovalNum = res.data
      })
      api.receiveApprovalNum().then((res) => {
        this.receiveApprovalNum = res.data
      })
    },
    getRoles() {
      return new Promise((resolve, reject) => {
        getRouters().then((res) => {
          this.roleMenu = res.data || []
          if (!this.roleMenu.find((item) => item.routeName === 'summaryDashboard')) {
            this.topList.splice(0, 1)
            if (this.$route.name === 'SummaryDashboard') {
              this.$router.replace({
                name: 'Dashboard'
              })
            }
            reject()
            return
          }
          resolve()
        })
      })
    }
  }
}
