<template>
  <scroll-view class="workbench-scroll" scroll-y>
    <view class="workbench-card">
      <view class="header">
        <text class="title">工作台</text>
<!--        <view class="search-box" @click="goToSearch">-->
<!--          <text class="search-icon">🔍</text>-->
<!--          <text class="placeholder">搜索</text>-->
<!--        </view>-->
      </view>

      <view class="grid">
        <view
          class="grid-item"
          v-for="item in items"
          :key="item.key"
          @click="handleClick(item)"
        >
          <view class="icon-wrapper">
            <image class="icon-image" :src="item.icon" mode="aspectFit" />
          </view>
          <text class="item-text">{{ item.text }}</text>
        </view>
      </view>
    </view>
  </scroll-view>
</template>

<script setup>
import { ref } from 'vue';

const items = ref([
  { key: 'verify', text: '审批管理', icon: '/static/workbench/verify.png' },
  // { key: 'customer', text: '客户管理', icon: '/static/workbench/customer.png' },
  { key: 'project', text: '项目管理', icon: '/static/workbench/project.png' },
  { key: 'task', text: '任务管理', icon: '/static/workbench/task.png' },
  // { key: 'schedule', text: '日程管理', icon: '/static/workbench/schedule.png' },
  { key: 'contact', text: '通讯录', icon: '/static/workbench/contact.png' },
  { key: 'notice', text: '公告管理', icon: '/static/workbench/notice.png' },
  { key: 'wechat', text: '工作微信', icon: '/static/workbench/wechat.png' }
]);

const goToSearch = () => {
  // 预留搜索页
};

const handleClick = (item) => {
  if (item.key === 'verify') {
    // 跳转到延期审核列表
    uni.navigateTo({
      url: '/pages/verify/list/index?bstType=UPDATE_TASK'
    });
    return;
  }
  if (item.key === 'task') {
    uni.navigateTo({
      url: '/pages/task/manage/index'
    });
    return;
  }
  if (item.key === 'customer') {
    uni.switchTab({ url: '/pages/index/index' });
    return;
  }
  if (item.key === 'project') {
    uni.navigateTo({
      url: '/pages/project/list/index'
    });
    return;
  }
  if (item.key === 'notice') {
    uni.navigateTo({
      url: '/pages/notice/list/index'
    });
    return;
  }


  // 其他入口占位
  uni.showToast({ title: '开发中', icon: 'none' });
};
</script>

<style lang="scss" scoped>
.workbench-scroll {
  width: 100%;
  height: 100vh;
  background: #f5f5f5;
}

.workbench-card {
  margin: 16px;
  padding: 16px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.title {
  font-size: 16px;
  font-weight: 600;
  color: #333;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: #f5f6f7;
  border-radius: 16px;
}
.search-icon {
  font-size: 14px;
}
.placeholder {
  font-size: 12px;
  color: #aaa;
}

.grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px 10px;
  margin-top: 8px;
}

.grid-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.icon-wrapper {
  width: 45px;
  height: 45px;
  //border-radius: 50%;
  //background: #2885ff;
  //display: flex;
  //align-items: center;
  //justify-content: center;
  //overflow: hidden;
}
.icon-image {
  width: 100%;
  height: 100%;
  //object-fit: contain;
  //padding: 8px;
}

.item-text {
  font-size: 12px;
  color: #333;
}
</style>


