fix customer tab
This commit is contained in:
@@ -135,27 +135,39 @@ type TabItem = {
|
||||
value: string;
|
||||
icon: string;
|
||||
text: string;
|
||||
permission?: string;
|
||||
permission?: string | string[];
|
||||
permissionMode?: "and" | "or";
|
||||
};
|
||||
|
||||
const tabVal = ref(route.path);
|
||||
const tabList: TabItem[] = [
|
||||
{ value: "/customers", icon: "usergroup", text: "客户" },
|
||||
{
|
||||
value: "/customers",
|
||||
icon: "usergroup",
|
||||
text: "客户",
|
||||
permission: [permissionCodes.customer.create, permissionCodes.eventRecord.create]
|
||||
},
|
||||
{ value: "/store", icon: "shop-3", text: "门店", permission: permissionCodes.stat.read },
|
||||
{ value: "/management", icon: "setting-1", text: "管理" }
|
||||
];
|
||||
const list = computed(() => tabList.filter(item => !item.permission || userStore.hasPermissions(item.permission)));
|
||||
const list = computed(() => tabList.filter(item => !item.permission || userStore.hasPermissions(item.permission, item.permissionMode)));
|
||||
|
||||
watch(() => route.path, (newPath: string) => {
|
||||
tabVal.value = resolveTabValue(newPath);
|
||||
}, { immediate: true });
|
||||
|
||||
watch(list, () => {
|
||||
async function syncVisibleTab(): Promise<void> {
|
||||
const visiblePath = resolveVisibleTabValue(route.path);
|
||||
if (tabVal.value !== visiblePath) {
|
||||
tabVal.value = visiblePath;
|
||||
}
|
||||
}, { immediate: true });
|
||||
|
||||
if (route.path === "/customers" && visiblePath !== "/customers") {
|
||||
await router.replace(visiblePath);
|
||||
}
|
||||
}
|
||||
|
||||
watch(list, syncVisibleTab, { immediate: true });
|
||||
|
||||
function resolveTabValue(path: string): string {
|
||||
if (path.startsWith("/customers")) {
|
||||
|
||||
Reference in New Issue
Block a user