<route lang="json5">
{
  style: {
    navigationStyle: 'custom',
    disableScroll: true
  }
}
</route>
<template>
  <view class="h-100vh flex flex-col">
    <TopNavigation :title="index === 0 ? '发起申请' : '审批'"></TopNavigation>
    <ApplicationList v-if="index === 0" :list="applicationListData"></ApplicationList>
    <ApprovalRecords v-else></ApprovalRecords>
    <CustomTabBar :list="list" :default-index="index" @change="change"></CustomTabBar>
  </view>
</template>

<script setup lang="ts">
  import { TabBarItem } from '@/typings'
  import ApplicationList from '@/pages/approval/components/ApplicationList.vue'
  import ApprovalRecords from '@/pages/approval/components/ApprovalRecords.vue'

  const index = ref<number>(0)

  const list: Array<TabBarItem> = [
    {
      title: '新申请',
      icon: 'home'
    },
    {
      title: '审批中心',
      icon: 'home'
    }
  ]

  const applicationListData = ref<Array<object>>([
    {
      groupId: 138603,
      groupName: '出勤休假',
      sort: 1,
      processDefs: [
        {
          processDefId: 249155,
          processDefName: '请假',
          icon: 'https://file.hikvisionmall.com/test1/image/f39c654cd30a48d28ddf37e4b64de57a.png',
          version: '1735128632'
        },
        {
          processDefId: 249156,
          processDefName: '补卡',
          icon: 'https://file.hikvisionmall.com/test1/image/26209b6732f2439fae3c6dd34a39145e.png',
          version: '1704439843'
        },
        {
          processDefId: 249158,
          processDefName: '外出',
          icon: 'https://file.hikvisionmall.com/test1/image/5c76288745dd47a38c9e1093d9737976.png',
          version: '1704439843'
        },
        {
          processDefId: 249157,
          processDefName: '出差',
          icon: 'https://file.hikvisionmall.com/test1/image/df75579e70c2435e9f78d04fc401b451.png',
          version: '1704439843'
        },
        {
          processDefId: 347336,
          processDefName: '加班',
          icon: 'https://file.hikvisionmall.com/test1/image/e4f21377ea2443b3856b07674ba41c2a.png',
          version: '1711368134'
        },
        {
          processDefId: 891737,
          processDefName: '调休',
          icon: 'https://file.hikvisionmall.com/prod/image/3d134cc9657e4816ad6aa8ef206fbc89.png',
          version: '1735128832'
        }
      ]
    },
    {
      groupId: 341473,
      groupName: 'test',
      sort: 2,
      processDefs: [
        {
          processDefId: 924255,
          processDefName: 'test1',
          icon: 'https://file.hikvisionmall.com/prod/image/3d134cc9657e4816ad6aa8ef206fbc89.png',
          version: '1736480449'
        }
      ]
    },
    {
      groupId: 138604,
      groupName: '其他',
      sort: 999,
      processDefs: [
        {
          processDefId: 466818,
          processDefName: '访客预约',
          icon: 'https://file.hikmall.com/prod/image/5300a838119d462b9e1c17489603b6d8.png',
          version: '1715675086'
        }
      ]
    }
  ])

  onLoad(options => {
    if (options.index) {
      index.value = Number(options.index)
    }
  })

  const change = (data: object) => {
    index.value = data.value
  }
</script>
