<template>
  <view class="page">
    <view class="content">
      <view class="group">
        <button class="button" v-if="true" @click="onHandleClick(0)">
          <uni-icons type="list" size="35" />
          <view>项目列表</view>
        </button>
        <button class="button" v-if="true" @click="onHandleClick(1)">
          <uni-icons type="checkmarkempty" size="35" />
          <view>项目审核</view>
        </button>
        <button class="button" v-if="true" @click="onHandleClick(2)">
          <uni-icons type="calendar" size="35" />
          <view>工时上报</view>
        </button>
        <button class="button" v-if="true" @click="onHandleClick(3)">
          <uni-icons type="auth" size="35" />
          <view>工时审批</view>
        </button>
        <button class="button" v-if="true" @click="onHandleClick(4)">
          <uni-icons type="calendar" size="35" />
          <view>项目日志</view>
        </button>
        <view class="button empty"></view>
      </view> </view
  ></view>
</template>

<script>
import { queryUser } from "@/services/index";

export default {
  data() {
    return { user: {} };
  },
  onShow() {
    this.getCurrentUser();
  },
  computed: {
    permission() {
      let permission = {};
      this.user?.Permissions.forEach((item) => {
        permission = {
          ...permission,
          ...item.Menus,
        };
      });
      return permission;
    },
  },
  methods: {
    onHandleClick(index) {
      switch (index) {
        case 0:
          uni.navigateTo({
            url: "../Project/list",
          });
          break;
        case 1:
          uni.navigateTo({
            url: "../Project/list?auth=true",
          });
          break;
        case 2:
          uni.navigateTo({
            url: "../WorkingHours/index",
          });
          break;
        case 3:
          uni.navigateTo({
            url: "../WorkingHours/audit",
          });
          break;
        case 4:
          uni.navigateTo({
            url: "../daily/daily",
          });
          break;
      }
    },
    async getCurrentUser() {
      let res = {};
      res = await queryUser();
      this.user = res.data;
    },
  },
};
</script>

<style lang="less" scoped>
.content {
  display: flex;
  justify-content: center;
}

.group {
  width: 90%;
  padding: 5%;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  background-color: #ffffff;
  height: 800rpx;
}
.button {
  width: 40%;
  margin: 5%;
  height: 280rpx;
  font-size: 32rpx;
  &.empty {
    visibility: hidden;
    height: 0px;
  }
}
</style>
