From 8cc901ed214f3885b34a07d0520fbcfd50063439 Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期三, 19 十一月 2025 14:30:39 +0800
Subject: [PATCH] fix: 完成绞线自检,生产确认等功能新增

---
 src/pages/index/index.vue |   46 +++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 43 insertions(+), 3 deletions(-)

diff --git a/src/pages/index/index.vue b/src/pages/index/index.vue
index 2df7101..747bfa2 100644
--- a/src/pages/index/index.vue
+++ b/src/pages/index/index.vue
@@ -18,8 +18,8 @@
     </wd-notice-bar>
     <!-- 蹇嵎瀵艰埅 -->
     <wd-grid clickable :column="1" class="mt-2">
-      <view v-for="(item, index) in navList">
-        <wd-grid-item v-if="item.show" :key="index" use-slot link-type="navigateTo" :url="item.url">
+      <view v-for="(item, index) in navList" :key="index">
+        <wd-grid-item v-if="item.show" use-slot link-type="navigateTo" :url="item.url">
           <view class="p-2">
             <image class="w-72rpx h-72rpx rounded-8rpx" :src="item.icon" />
           </view>
@@ -87,11 +87,13 @@
 </template>
 
 <script setup lang="ts">
-import { reactive } from "vue";
+import { reactive, computed } from "vue";
 import { dayjs, useMessage, useToast } from "wot-design-uni";
 import LogAPI, { VisitStatsVO } from "@/api/system/log";
 import WorkerCallingCard from "@/components/worker-calling-card/index.vue";
 import HomeApi from "@/api/home";
+import { useUserStore } from "@/store/modules/user";
+import { setTeamId, setPrepareId } from "@/utils/cache";
 
 const visitStatsData = ref<VisitStatsVO>({
   todayUvCount: 0,
@@ -104,6 +106,22 @@
 
 const message = useMessage();
 const toast = useToast();
+
+// 鑾峰彇褰撳墠鐧诲綍鐢ㄦ埛淇℃伅
+const userStore = useUserStore();
+const userInfo: any = computed(() => userStore.userInfo);
+
+// 鍒ゆ柇鏄惁涓哄贰妫�鍛樿鑹�
+const isInspector = computed(() => {
+  if (!userInfo.value || !userInfo.value.roles || !Array.isArray(userInfo.value.roles)) {
+    return false;
+  }
+  console.log(
+    "userInfo.value.roles",
+    userInfo.value.roles.some((role: any) => role.roleKey === "qualitative-inspector")
+  );
+  return userInfo.value.roles.some((role: any) => role.roleKey === "qualitative-inspector");
+});
 
 const fileProgress = reactive({
   show: false,
@@ -177,6 +195,12 @@
     url: "/pages/timely/index",
     show: false,
   },
+  {
+    icon: "/static/icons/routingInspection.png",
+    title: "宸℃",
+    url: "/pages/routingInspection/index",
+    show: false,
+  },
 ]);
 
 // 鍔犺浇璁块棶缁熻鏁版嵁
@@ -225,11 +249,27 @@
 const init = async () => {
   checkVersion();
   const { data } = await HomeApi.getIndex();
+
+  // 瀛樺偍鐝粍ID鍜岀敓浜у噯澶嘔D
+  if (data) {
+    if (data.team) {
+      setTeamId(data.team);
+    }
+    if (data.prepareId) {
+      setPrepareId(data.prepareId);
+    }
+  }
+
+  // 鍒ゆ柇鏄惁涓哄贰妫�鍛樿鑹�
   if (data.deviceGroupName == "鏃舵晥缁�") {
     navList[1].show = true;
   } else {
     navList[0].show = true;
   }
+  if (isInspector.value) {
+    // 濡傛灉鏄贰妫�鍛橈紝鏄剧ず宸℃鑿滃崟
+    navList[2].show = true;
+  }
 };
 
 /**

--
Gitblit v1.9.3