<template>
  <view>
    <CuNavbar :isBack="false" title="我的">
      <template #right>
        <view class="h-full flex-center">
          <image
            @click="goPath('/pages/setting/index')"
            class="w-32rpx h-32rpx"
            src="/static/images/setting.svg"
          ></image>
        </view>
      </template>
    </CuNavbar>
    <view class="px-base space-y-15rpx mt-30rpx">
      <view class="card" v-for="(item, i) in opList" :key="i">
        <TitleComp :title="item.title"></TitleComp>
        <view class="grid grid-cols-3 mt-20rpx gap-20rpx">
          <template v-for="(child, ii) in item.children" :key="ii">
            <OpItem
              :data="child"
              v-if="child?.rouls ? checkPermission(child.rouls) : true"
            ></OpItem>
          </template>
        </view>
      </view>
    </view>
  </view>
</template>
<script setup>
import TitleComp from '@/components/title-comp/index'
import OpItem from './components/op-item.vue'
import CuNavbar from '@/components/cu-navbar/index'
import checkPermission from '@/utils/permission'

const opList = [
  {
    title: '门店数据',
    children: [
      {
        icon: 'order',
        title: '业绩数据',
        url: '/pages/data/performance/index',
      },
      {
        icon: 'folder',
        title: '提成数据',
        url: '/pages/data/brokerage/index',
      },
    ],
  },
  {
    title: '办公管理',
    children: [
      {
        icon: 'photo-fill',
        title: '员工管理',
        url: '/pages/user/index',
        rouls: ['admin'],
      },
      {
        icon: 'lock',
        title: '我的任务',
        url: '/pages/task/index',
      },
      {
        icon: 'home-fill',
        title: '报销管理',
        url: '/pages/expense-account/index',
      },
      {
        icon: 'map-fill',
        title: '升职申请',
        url: '/pages/work/list',
      },
      {
        icon: 'grid-fill',
        title: '补卡申请',
        url: '/pages/make-card/list',
      },
      {
        icon: 'car',
        title: '请假申请',
        url: '/pages/ask-leave/list',
      },
      {
        icon: 'setting-fill',
        title: '出差报备',
        url: '/pages/business/list',
      },
      {
        icon: 'server-man',
        title: '加班报备',
        url: '/pages/overtime/list',
      },
      {
        icon: 'camera',
        title: '合同管理',
        url: '/pages/contract/list',
      },
    ],
  },
  {
    title: '天天向上',
    children: [
      {
        icon: 'account',
        title: '培训课件',
        url: '/pages/train-books/index',
      },
      {
        icon: 'twitte',
        title: '培训考试',
        url: '/pages/examination/index',
      },
    ],
  },
]

const goPath = (url) => {
  uni.navigateTo({
    url,
  })
}
</script>
