Commit 5661063ac2d802a3482b2f63e0b6192ef7556e68

Authored by ww
1 parent cda6a183

fix(DEFECT-1227): 修复客户角色只拥有可视化管理的查看权限

... ... @@ -4,7 +4,7 @@ import { defineStore } from 'pinia';
4 4 import { pinia as store } from '@/store';
5 5 import { RoleEnum } from '@/enums/external/roleEnum';
6 6 import { JWT_TOKEN_KEY, REFRESH_TOKEN_KEY, ROLES_KEY, SHARE_JWT_TOKEN_KEY, SHARE_REFRESH_TOKEN_KEY, USER_INFO_KEY } from '@/enums/external/cacheEnum';
7   -import { getAuthCache, getJwtToken, getRefreshToken, setAuthCache } from '@/utils/external/auth';
  7 +import { getAuthCache, getJwtToken, getRefreshToken, getUserInfo, setAuthCache } from '@/utils/external/auth';
8 8 import {
9 9 LoginParams,
10 10 LoginResultModel,
... ... @@ -43,7 +43,7 @@ export const useUserStore = defineStore({
43 43 enterPriseInfo: storage.get('enterPriseInfo') || null,
44 44
45 45 // user info
46   - userInfo: null,
  46 + userInfo: getUserInfo() || null,
47 47 userUpdateInfo: null,
48 48 // token
49 49 jwtToken: getJwtToken() as string || undefined,
... ...
1 1 import { Persistent, BasicKeys } from '@/utils/external/cache/persistent';
2   -import { CacheTypeEnum, SHARE_JWT_TOKEN_KEY, SHARE_REFRESH_TOKEN_KEY } from '@/enums/external/cacheEnum';
  2 +import { CacheTypeEnum, SHARE_JWT_TOKEN_KEY, SHARE_REFRESH_TOKEN_KEY, USER_INFO_KEY } from '@/enums/external/cacheEnum';
3 3 import projectSetting from '@/settings/external/projectSetting';
4 4 import { JWT_TOKEN_KEY, REFRESH_TOKEN_KEY } from '@/enums/external/cacheEnum';
  5 +import { UserInfo } from '/#/external/store';
5 6
6 7 const { permissionCacheType } = projectSetting;
7 8 const isLocal = permissionCacheType === CacheTypeEnum.LOCAL;
... ... @@ -30,7 +31,11 @@ export function getRefreshToken(): string {
30 31 export function getShareJwtToken(): string {
31 32 return getAuthCache(SHARE_JWT_TOKEN_KEY);
32 33 }
  34 +
33 35 export function getShareRefreshToken(): string {
34 36 return getAuthCache(SHARE_REFRESH_TOKEN_KEY);
35 37 }
36 38
  39 +export function getUserInfo(): UserInfo {
  40 + return getAuthCache(USER_INFO_KEY)
  41 +}
... ...
... ... @@ -31,7 +31,7 @@
31 31 </n-tooltip>
32 32 <n-divider vertical />
33 33 <!-- 保存 -->
34   - <n-tooltip placement="bottom" trigger="hover">
  34 + <n-tooltip v-if="!isCustomerUser" placement="bottom" trigger="hover">
35 35 <template #trigger>
36 36 <div class="save-btn">
37 37 <n-button size="small" type="primary" ghost @click="dataSyncUpdate()">
... ... @@ -64,6 +64,7 @@ import { HistoryStackEnum } from '@/store/modules/chartHistoryStore/chartHistory
64 64 import { useSyncRemote } from '../../../hooks/external/useRemote.hook'
65 65 import { useChartLayoutStore } from '@/store/modules/chartLayoutStore/chartLayoutStore'
66 66 import { ChartLayoutStoreEnum } from '@/store/modules/chartLayoutStore/chartLayoutStore.d'
  67 +import { useRole } from '@/views/chart/hooks/external/business/useRole'
67 68
68 69 const { LayersIcon, BarChartIcon, PrismIcon, HomeIcon, ArrowBackIcon, ArrowForwardIcon } = icon.ionicons5
69 70 const { setItem } = useChartLayoutStore()
... ... @@ -71,6 +72,7 @@ const { getLayers, getCharts, getDetails } = toRefs(useChartLayoutStore())
71 72 const chartEditStore = useChartEditStore()
72 73 const chartHistoryStore = useChartHistoryStore()
73 74 const { dataSyncUpdate } = useSyncRemote()
  75 +const { isCustomerUser } = useRole()
74 76
75 77 interface ItemType<T> {
76 78 key: T
... ...
  1 +import { RoleEnum } from '@/enums/external/roleEnum';
  2 +import { useUserStore } from '@/store/external/modules/user';
  3 +import { computed, unref } from 'vue';
  4 +
  5 +export const useRole = () => {
  6 + const userStore = useUserStore();
  7 +
  8 + const getRole = computed(() => {
  9 + return userStore.userInfo?.roles![0] as RoleEnum;
  10 + });
  11 +
  12 + const isPlatformAdmin = computed(() => {
  13 + return unref(getRole) === RoleEnum.PLATFORM_ADMIN;
  14 + });
  15 +
  16 + const isCustomerUser = computed(() => {
  17 + return unref(getRole) === RoleEnum.CUSTOMER_USER;
  18 + });
  19 +
  20 + const isTenantAdmin = computed(() => {
  21 + return unref(getRole) === RoleEnum.TENANT_ADMIN;
  22 + });
  23 +
  24 + const isSysadmin = computed(() => {
  25 + return unref(getRole) === RoleEnum.SYS_ADMIN;
  26 + });
  27 +
  28 + return { getRole, isPlatformAdmin, isCustomerUser, isTenantAdmin, isSysadmin };
  29 +};
... ...
1 1 import { fetchRouteParamsLocation, JSONStringify, JSONParse } from '@/utils'
2 2 import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
3 3 import { ProjectInfoEnum } from '@/store/external/modules/projectInfo.d'
4   -import { onUnmounted } from 'vue'
  4 +import { onUnmounted, unref } from 'vue'
5 5 import { saveInterval } from '@/settings/designSetting'
6 6 import throttle from 'lodash/throttle'
7 7 import html2canvas from 'html2canvas'
... ... @@ -11,6 +11,7 @@ import { SyncEnum } from '@/enums/external/editPageEnum'
11 11 import { useProjectInfoStore } from '@/store/external/modules/projectInfo'
12 12 import { useSync } from '../useSync.hook'
13 13 import { BaseUpdateContentParams, DateViewConfigurationInfoType } from '@/api/external/contentSave/model/contentModel'
  14 +import { useRole } from './business/useRole'
14 15
15 16 /**
16 17 * * base64转file
... ... @@ -37,6 +38,7 @@ export const useSyncRemote = () => {
37 38 const chartEditStore = useChartEditStore()
38 39 const projectInfoStore = useProjectInfoStore()
39 40 const { updateComponent } = useSync()
  41 + const { isCustomerUser } = useRole()
40 42
41 43 /**
42 44 * * 赋值全局数据
... ... @@ -71,6 +73,10 @@ export const useSyncRemote = () => {
71 73 // 数据保存
72 74 const dataSyncUpdate = throttle(async (updateImg = true) => {
73 75 if (!fetchRouteParamsLocation()) return
  76 +
  77 + // 客户角色只有查看权限
  78 + if (unref(isCustomerUser)) return
  79 +
74 80 const { dataViewId, state, organizationId, dataViewName, dataViewContent } = projectInfoStore.getProjectInfo
75 81
76 82 if (dataViewId === null || dataViewId === '') {
... ...