<template>
  <view class="workbench-container">
    <custom-nav-bar>
      <view class="workbench-title" slot="left">
        <text>工作台</text>
      </view>
    </custom-nav-bar>
    <view class="entry-list">
      <view class="entry-item" @click="goReportWork">
        <image class="entry-icon" src="/static/images/baogong.png" mode="aspectFit" />
        <text class="entry-text">每日报工</text>
      </view>
      <view class="entry-item" @click="goConstruction">
        <image class="entry-icon" src="/static/images/shigong.png" mode="aspectFit" />
        <text class="entry-text">施工进度</text>
      </view>
      <view class="entry-item" @click="goTask">
        <image class="entry-icon" src="/static/images/task.png" mode="aspectFit"></image>
        <text class="entry-text">任务中心</text>
      </view>
      <view class="entry-item" @click="goSchedule">
        <image class="entry-icon" src="/static/images/paichan.png" mode="aspectFit"></image>
        <text class="entry-text">项目排产</text>
      </view>
    </view>
  </view>
</template>

<script>
import CustomNavBar from '@/components/CustomNavBar/index.vue';
import { getUserProfile } from '@/api/oa/user.js';

export default {
  name: "WorkbenchIndex",
  components: {
    CustomNavBar,
  },
  onShow() {
    console.log('页面onLoad被调用');
    // 页面加载时调用getUserProfile
    this.fetchUserProfile();
  },
  methods: {
    // 获取用户个人信息
    async fetchUserProfile() {
      console.log('fetchUserProfile方法开始执行');
      try {
        console.log('开始调用getUserProfile API');
        const response = await getUserProfile();
        console.log('用户个人信息:', response);
        // 这里可以根据需要处理返回的用户信息
      } catch (error) {
        console.error('获取用户个人信息失败:', error);
      }
    },
    goReportWork() {
      uni.navigateTo({ 
        url: '/pages/workbench/reportWork/reportWork'
      });
    },
    goConstruction() {
      uni.navigateTo({
        url: '/pages/workbench/construction/construction'
      });
    },
    goTask() {
      uni.navigateTo({
        url: '/pages/workbench/task/task'
      })
    },
    goSchedule() {
      uni.navigateTo({
        url: '/pages/workbench/reportSchedule/reportSchedule'
      })
    }
  },
};
</script>

<style lang="scss" scoped>
.workbench-container {
  min-height: 100vh;
  background: #fff;
  display: flex;
  flex-direction: column;
}
.workbench-title {
  padding-left: 44rpx;
  font-size: 40rpx;
  font-weight: 600;
  color: #0c1c33;
}
.entry-list {
  display: flex;
  flex-direction: column;
  margin-top: 40rpx;
}
.entry-item {
  display: flex;
  flex-direction: row;
  align-items: center;
  padding: 32rpx 44rpx;
  background: #fff;
}
.entry-icon {
  width: 56rpx;
  height: 56rpx;
  margin-right: 32rpx;
}
.entry-text {
  color: #333;
  font-size: 32rpx;
}
.divider {
  height: 1px;
  background: #f0f0f0;
  margin-left: 44rpx;
  margin-right: 44rpx;
}
</style>
