根据用户权限动态调整页面索引,页面显示与导航栏匹配。

This commit is contained in:
WindowBird 2025-11-13 11:12:26 +08:00
parent 0f9e53b453
commit a94360dc4e

View File

@ -1,18 +1,18 @@
<template>
<view>
<!-- 顶部Tabs栏只在非客户管理我的月度考核页面显示 -->
<view class="fixed-tabs" v-if="value !== 3 && value !== 4 && value !== 2">
<view class="fixed-tabs" v-if="shouldShowTopTabs">
<uv-tabs :list="topTabs" :current="topTabValue" @click="clickTab"></uv-tabs>
</view>
<!-- 内容区域 -->
<view class="content-wrapper">
<!-- 客户管理底部导航栏选中时显示使用 v-show 避免组件销毁重建 -->
<CustomerManagement v-if="value === 3" ref="customerManagementRef" />
<CustomerManagement v-if="value === customerManagementIndex" ref="customerManagementRef" />
<!-- 我的 -->
<My v-else-if="value === 4" />
<My v-else-if="value === myIndex" />
<!-- 月度考核排行榜 -->
<RankingBoard v-else-if="value === 2" />
<RankingBoard v-else-if="admin_bst && value === rankingIndex" />
<!-- 其他内容底部导航栏未选中客户管理时显示 -->
<template v-else>
@ -36,7 +36,7 @@
</view>
<!-- 悬浮新建按钮只在日程编辑页显示 -->
<FabPlus v-if="topTabValue === 0 && value !== 3 && value !== 4 && value !== 2" @click="handleAddClick" />
<FabPlus v-if="topTabValue === 0 && shouldShowTopTabs" @click="handleAddClick" />
<!-- 新建日程弹窗保留以备后用 -->
<AddEventModal :show="showAdd" @ok="addEvent" @cancel="showAdd = false" />
@ -143,14 +143,35 @@ function addEvent(e) {
}
const value=ref(0);
let admin_bst=ref(false);
const admin_bst=ref(false);
//
const rankingIndex = computed(() => 4); // 2
const customerManagementIndex = computed(() => 2); // 32
const myIndex = computed(() => 3); // 43
// Tabs
const shouldShowTopTabs = computed(() => {
if (value.value === customerManagementIndex.value || value.value === myIndex.value) {
return false;
}
if (admin_bst.value && value.value === rankingIndex.value) {
return false;
}
return true;
});
watch(value, (newValue, oldValue) => {
console.log('值变化:', oldValue, '→', newValue)
})
//
onMounted(() => {
const userStore = useUserStore();
console.log('当前 token:', userStore.token);
let roles = userStore.getUserInfo.roles
admin_bst = roles.some((role) => ['admin', 'sys_admin','bst'].includes(role));
console.log('admin_bst',admin_bst);
admin_bst.value = roles.some((role) => ['admin', 'sys_admin','bst'].includes(role));
console.log('admin_bst',admin_bst.value);
//
@ -178,7 +199,7 @@ onShow(() => {
}
//
if (value.value === 3 && customerManagementRef.value) {
if (value.value === customerManagementIndex.value && customerManagementRef.value) {
//
const needRefresh = uni.getStorageSync('customerListNeedRefresh');
if (needRefresh) {
@ -192,8 +213,8 @@ onShow(() => {
//
onReachBottom(() => {
// value === 3
if (value.value === 3 && customerManagementRef.value) {
//
if (value.value === customerManagementIndex.value && customerManagementRef.value) {
customerManagementRef.value.winB_LoadMore();
}
});