<template>
  <div class="mb-60">
    <van-nav-bar title="资源管理" left-arrow @click-left="onClickLeft" />
    <van-tabs
      v-model:active="active"
      shrink
      line-width="60px"
      color="#59B4FF"
      title-active-color="#59B4FF"
    >
      <van-tab title="财务管理">
        <!-- 财务管理页面 -->
        <div class="bg-white p-4 mt-5 flex text-gray-500 flex-col d_jump">
          <div>
            <span class="font-semibold" id="finance-manage">财务管理</span>
            <span class="ml-2">对项目预算、奖金进行配置</span>
          </div>
          <Search />
          <FinanceManage />
        </div>
        <!-- 财务审批页面 -->
        <div class="bg-white p-4 mt-5 flex text-gray-500 flex-col d_jump">
          <div>
            <span class="font-semibold" id="finance-audit">财务审批</span>
            <span class="ml-2">对员工提交的申请进行审批</span>
          </div>
          <Search />
          <FinanceExamine />
        </div>
        <!-- 财务统计页面 -->
        <div class="bg-white p-4 mt-5 flex text-gray-500 flex-col d_jump">
          <div>
            <span class="font-semibold" id="finance-statistical">财务统计</span>
            <span class="ml-2">财务明细统计查看</span>
          </div>
          <img src="public/statistics.png" class="w-full" />
        </div>
      </van-tab>
      <van-tab title="角色管理">角色管理</van-tab>
      <van-tab title="任务管理">任务管理</van-tab>
      <van-tab title="成员管理">成员管理</van-tab>
    </van-tabs>

    <div class="menu">
      <a href="#finance-manage">财务管理</a>
      <a href="#finance-audit">财务审批</a>
      <a href="#finance-statistical">财务统计</a>
    </div>
  </div>
</template>

<script>
export default {
  layout: 'default',
};
</script>

<script setup>
import { ref, onMounted, nextTick } from 'vue';
const active = ref(0);

onMounted(async () => {
  scrollToElementByHash();
});

// 根据hash值跳转到指定位置
async function scrollToElementByHash() {
  await nextTick();
  const hash = window.location.hash;
  if (!hash) return;
  const scrollDom = document.querySelector(hash);
  document.body.scrollTop = scrollDom.offsetTop;
  document.documentElement.scrollTop = scrollDom.offsetTop;
  window.pageYOffset = scrollDom.offsetTop;
}

function onClickLeft() {
  console.log('返回上一页');
}
</script>

<style lang="less">
.van-nav-bar__content {
  background-color: #eee;
}
.van-icon-arrow-left:before {
  color: #000;
}
</style>
<style scoped lang="less">
.menu {
  position: fixed;
  right: 0;
  bottom: 15px;
  z-index: 99;
}
.menu a {
  display: block;
  width: 72px;
  color: #fff;
  background: rgba(25, 137, 250, 0.6);
  padding: 8px 20px;
  border-radius: 30px 0 0 30px;
  margin-bottom: 15px;
}
</style>
