根据用户权限动态调整页面索引,页面显示与导航栏匹配。
This commit is contained in:
parent
0f9e53b453
commit
a94360dc4e
|
|
@ -1,18 +1,18 @@
|
||||||
<template>
|
<template>
|
||||||
<view>
|
<view>
|
||||||
<!-- 顶部Tabs栏(只在非客户管理、我的、月度考核页面显示) -->
|
<!-- 顶部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>
|
<uv-tabs :list="topTabs" :current="topTabValue" @click="clickTab"></uv-tabs>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 内容区域 -->
|
<!-- 内容区域 -->
|
||||||
<view class="content-wrapper">
|
<view class="content-wrapper">
|
||||||
<!-- 客户管理(底部导航栏选中时显示,使用 v-show 避免组件销毁重建) -->
|
<!-- 客户管理(底部导航栏选中时显示,使用 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>
|
<template v-else>
|
||||||
|
|
@ -36,7 +36,7 @@
|
||||||
</view>
|
</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" />
|
<AddEventModal :show="showAdd" @ok="addEvent" @cancel="showAdd = false" />
|
||||||
|
|
@ -143,14 +143,35 @@ function addEvent(e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const value=ref(0);
|
const value=ref(0);
|
||||||
let admin_bst=ref(false);
|
const admin_bst=ref(false);
|
||||||
|
|
||||||
|
// 动态计算各个页面的索引
|
||||||
|
const rankingIndex = computed(() => 4); // 月度考核固定为索引2(如果有权限)
|
||||||
|
const customerManagementIndex = computed(() => 2); // 客户管理:有权限时为3,无权限时为2
|
||||||
|
const myIndex = computed(() => 3); // 我的:有权限时为4,无权限时为3
|
||||||
|
|
||||||
|
// 判断是否显示顶部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(() => {
|
onMounted(() => {
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
console.log('当前 token:', userStore.token);
|
console.log('当前 token:', userStore.token);
|
||||||
let roles = userStore.getUserInfo.roles
|
let roles = userStore.getUserInfo.roles
|
||||||
admin_bst = roles.some((role) => ['admin', 'sys_admin','bst'].includes(role));
|
admin_bst.value = roles.some((role) => ['admin', 'sys_admin','bst'].includes(role));
|
||||||
console.log('admin_bst',admin_bst);
|
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');
|
const needRefresh = uni.getStorageSync('customerListNeedRefresh');
|
||||||
if (needRefresh) {
|
if (needRefresh) {
|
||||||
|
|
@ -192,8 +213,8 @@ onShow(() => {
|
||||||
|
|
||||||
// 触底加载更多(仅在客户管理页面时生效)
|
// 触底加载更多(仅在客户管理页面时生效)
|
||||||
onReachBottom(() => {
|
onReachBottom(() => {
|
||||||
// 只有在客户管理页面(value === 3)时才触发加载更多
|
// 只有在客户管理页面时才触发加载更多
|
||||||
if (value.value === 3 && customerManagementRef.value) {
|
if (value.value === customerManagementIndex.value && customerManagementRef.value) {
|
||||||
customerManagementRef.value.winB_LoadMore();
|
customerManagementRef.value.winB_LoadMore();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user