From c5025e19c37bcb0ec0d07e979ebe9c1ca7840753 Mon Sep 17 00:00:00 2001
From: zhengyiming <540361168@qq.com>
Date: 星期二, 05 八月 2025 17:29:28 +0800
Subject: [PATCH] fix: 修改功能模块
---
src/views/Permission/RoleManage.vue | 198 ++++++++----
src/views/Permission/components/AddOrEditRoleDialog.vue | 6
src/constants/apiEnumText.ts | 16 +
src/services/api/resource.ts | 4
src/hooks/dic.ts | 3
src/constants/module.ts | 4
.eslintrc-auto-import.json | 4
src/services/api/typings.d.ts | 20 +
src/hooks/menu.ts | 89 +++++
src/hooks/useAccess.ts | 7
src/services/api/dictionary.ts | 2
src/constants/enum.ts | 17 -
src/hooks/index.ts | 1
pnpm-lock.yaml | 8
src/utils/request/index.ts | 3
src/services/api/menu.ts | 14
src/views/Permission/components/dialogAuthorizeV2.vue | 376 +++++++++++++++++++++++++
src/services/api/role.ts | 8
package.json | 2
src/views/System/ModuleManage.vue | 51 ++
auto-imports.d.ts | 8
src/views/Permission/components/dialogAuthorize.vue | 31 +-
src/constants/apiEnum.ts | 4
src/services/api/auth.ts | 21 +
24 files changed, 741 insertions(+), 156 deletions(-)
diff --git a/.eslintrc-auto-import.json b/.eslintrc-auto-import.json
index 1673209..9e9f385 100644
--- a/.eslintrc-auto-import.json
+++ b/.eslintrc-auto-import.json
@@ -9,8 +9,6 @@
"Component": true,
"ComponentPublicInstance": true,
"ComputedRef": true,
- "DataRangeEnum": true,
- "DataRangeEnumText": true,
"DirectiveBinding": true,
"EditorType": true,
"EditorTypeText": true,
@@ -26,6 +24,8 @@
"EnumResourceController": true,
"EnumResourceMethod": true,
"EnumRoleWebApiDataPower": true,
+ "EnumRoleWebApiDataPowerText": true,
+ "EnumRoleWebApiDataPowerTextForFilter": true,
"EnumUserType": true,
"EnumUserTypeText": true,
"ExtractDefaultPropTypes": true,
diff --git a/auto-imports.d.ts b/auto-imports.d.ts
index ee03656..92e91a2 100644
--- a/auto-imports.d.ts
+++ b/auto-imports.d.ts
@@ -30,6 +30,8 @@
const EnumResourceController: typeof import('./src/constants/apiEnum')['EnumResourceController']
const EnumResourceMethod: typeof import('./src/constants/apiEnum')['EnumResourceMethod']
const EnumRoleWebApiDataPower: typeof import('./src/constants/apiEnum')['EnumRoleWebApiDataPower']
+ const EnumRoleWebApiDataPowerText: typeof import('./src/constants/apiEnumText')['EnumRoleWebApiDataPowerText']
+ const EnumRoleWebApiDataPowerTextForFilter: typeof import('./src/constants/apiEnumText')['EnumRoleWebApiDataPowerTextForFilter']
const EnumUserType: typeof import('./src/constants/apiEnum')['EnumUserType']
const EnumUserTypeText: typeof import('./src/constants/apiEnumText')['EnumUserTypeText']
const EnumWebApiMethod: typeof import('./src/constants/apiEnum')['EnumWebApiMethod']
@@ -176,7 +178,7 @@
export type { EnterpriseConfigureType, FlexEnterpriseSettingStatus, FlexEnterpriseStatus, VerifyStatus, FlexEnterpriseCertificationStatus, MessageChannelEnum, SignChannelEnum, ChargeTypeEnum, EnterpriseConfigureType, FlexEnterpriseSettingStatus, FlexEnterpriseStatus, VerifyStatus, FlexEnterpriseCertificationStatus, MessageChannelEnum, SignChannelEnum, ChargeTypeEnum } from './src/constants/enterprise'
import('./src/constants/enterprise')
// @ts-ignore
- export type { AreaType, DataRangeEnum, AuthorizeType, Gender, AreaType, DataRangeEnum, AuthorizeType, Gender } from './src/constants/enum'
+ export type { AreaType, AuthorizeType, Gender, AreaType, AuthorizeType, Gender } from './src/constants/enum'
import('./src/constants/enum')
// @ts-ignore
export type { SubModuleType, FastBtn, SubModuleType } from './src/constants/module'
@@ -203,8 +205,6 @@
readonly BooleanOptions: UnwrapRef<typeof import('./src/constants/enum')['BooleanOptions']>
readonly ChargeTypeEnum: UnwrapRef<typeof import('./src/constants/enterprise')['ChargeTypeEnum']>
readonly ChargeTypeEnumText: UnwrapRef<typeof import('./src/constants/enterprise')['ChargeTypeEnumText']>
- readonly DataRangeEnum: UnwrapRef<typeof import('./src/constants/enum')['DataRangeEnum']>
- readonly DataRangeEnumText: UnwrapRef<typeof import('./src/constants/enum')['DataRangeEnumText']>
readonly EditorType: UnwrapRef<typeof import('./src/constants/editor')['EditorType']>
readonly EditorTypeText: UnwrapRef<typeof import('./src/constants/editor')['EditorTypeText']>
readonly EffectScope: UnwrapRef<typeof import('vue')['EffectScope']>
@@ -219,6 +219,8 @@
readonly EnumResourceController: UnwrapRef<typeof import('./src/constants/apiEnum')['EnumResourceController']>
readonly EnumResourceMethod: UnwrapRef<typeof import('./src/constants/apiEnum')['EnumResourceMethod']>
readonly EnumRoleWebApiDataPower: UnwrapRef<typeof import('./src/constants/apiEnum')['EnumRoleWebApiDataPower']>
+ readonly EnumRoleWebApiDataPowerText: UnwrapRef<typeof import('./src/constants/apiEnumText')['EnumRoleWebApiDataPowerText']>
+ readonly EnumRoleWebApiDataPowerTextForFilter: UnwrapRef<typeof import('./src/constants/apiEnumText')['EnumRoleWebApiDataPowerTextForFilter']>
readonly EnumUserType: UnwrapRef<typeof import('./src/constants/apiEnum')['EnumUserType']>
readonly EnumUserTypeText: UnwrapRef<typeof import('./src/constants/apiEnumText')['EnumUserTypeText']>
readonly FastButtonMap: UnwrapRef<typeof import('./src/constants/module')['FastButtonMap']>
diff --git a/package.json b/package.json
index f06148a..27af38c 100644
--- a/package.json
+++ b/package.json
@@ -22,7 +22,7 @@
"dependencies": {
"@bole-12333/chat-kit": "latest",
"@bole-12333/customer-chat": "latest",
- "@bole-core/components": "^1.3.12",
+ "@bole-core/components": "^1.3.13",
"@bole-core/core": "latest",
"@bole-core/pretty-layout": "latest",
"@bole-core/sass-utils": "latest",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index b3acd80..a2eeea9 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -20,8 +20,8 @@
specifier: latest
version: 1.0.3(@bole-12333/chat-kit@1.0.1)(@tiptap/core@2.1.13)(@tiptap/extension-document@2.1.13)(@tiptap/extension-image@2.1.13)(@tiptap/extension-mention@2.1.13)(@tiptap/extension-paragraph@2.1.13)(@tiptap/extension-placeholder@2.1.13)(@tiptap/extension-text@2.1.13)(@tiptap/pm@2.1.13)(@tiptap/suggestion@2.1.13)(dayjs@1.11.6)(vue@3.5.11)
'@bole-core/components':
- specifier: ^1.3.12
- version: 1.3.12(@bole-core/core@1.0.2)(@bole-core/sass-utils@0.0.1)(@element-plus/icons-vue@2.3.1)(@tanstack/vue-query@4.37.1)(@videojs-player/vue@1.0.0)(@vueuse/core@11.1.0)(@vueuse/shared@11.1.0)(dayjs@1.11.6)(element-plus@2.8.4)(lodash@4.17.21)(mitt@3.0.0)(senin-help@1.0.5)(senin-vue@1.0.4)(video.js@7.20.3)(vue-component-type-helpers@2.1.6)(vue@3.5.11)
+ specifier: ^1.3.13
+ version: 1.3.13(@bole-core/core@1.0.2)(@bole-core/sass-utils@0.0.1)(@element-plus/icons-vue@2.3.1)(@tanstack/vue-query@4.37.1)(@videojs-player/vue@1.0.0)(@vueuse/core@11.1.0)(@vueuse/shared@11.1.0)(dayjs@1.11.6)(element-plus@2.8.4)(lodash@4.17.21)(mitt@3.0.0)(senin-help@1.0.5)(senin-vue@1.0.4)(video.js@7.20.3)(vue-component-type-helpers@2.1.6)(vue@3.5.11)
'@bole-core/core':
specifier: latest
version: 1.0.2(@ywwlmm/openapi@0.0.3)(ali-oss@6.21.0)(axios@1.7.7)(dayjs@1.11.6)(element-plus@2.8.4)(file-saver@2.0.5)(jszip@3.10.1)(lodash@4.17.21)(senior-request@1.0.1)(vue-router@4.4.5)(vue@3.5.11)(xlsx-style@0.8.13)(xlsx@0.18.5)
@@ -1895,8 +1895,8 @@
vue: 3.5.11(typescript@4.8.4)
dev: false
- /@bole-core/components@1.3.12(@bole-core/core@1.0.2)(@bole-core/sass-utils@0.0.1)(@element-plus/icons-vue@2.3.1)(@tanstack/vue-query@4.37.1)(@videojs-player/vue@1.0.0)(@vueuse/core@11.1.0)(@vueuse/shared@11.1.0)(dayjs@1.11.6)(element-plus@2.8.4)(lodash@4.17.21)(mitt@3.0.0)(senin-help@1.0.5)(senin-vue@1.0.4)(video.js@7.20.3)(vue-component-type-helpers@2.1.6)(vue@3.5.11):
- resolution: {integrity: sha512-TBWzg41B+1CTyVUhPNnULx3xQNhgnON8j8s+3uB8pRWHBHE2m+jSCSkE7IsmaSW3jSteTVeNdVCN2XKOIJ2PYQ==}
+ /@bole-core/components@1.3.13(@bole-core/core@1.0.2)(@bole-core/sass-utils@0.0.1)(@element-plus/icons-vue@2.3.1)(@tanstack/vue-query@4.37.1)(@videojs-player/vue@1.0.0)(@vueuse/core@11.1.0)(@vueuse/shared@11.1.0)(dayjs@1.11.6)(element-plus@2.8.4)(lodash@4.17.21)(mitt@3.0.0)(senin-help@1.0.5)(senin-vue@1.0.4)(video.js@7.20.3)(vue-component-type-helpers@2.1.6)(vue@3.5.11):
+ resolution: {integrity: sha512-14vVgnE0syul+Zdn1IRdRQYjfbP0WdyTW4QQPN8+5eoWZ/b9AL/0lWt15otFFdfUcOf7/uTtkPm8bsw4dOgphg==}
peerDependencies:
'@bole-core/core': '*'
'@bole-core/sass-utils': '*'
diff --git a/src/constants/apiEnum.ts b/src/constants/apiEnum.ts
index a1f0c28..87b2651 100644
--- a/src/constants/apiEnum.ts
+++ b/src/constants/apiEnum.ts
@@ -36,9 +36,9 @@
/** 鍒嗛〉鍒楄〃鎺掑簭 */
export enum EnumPagedListOrder {
/**鍗囧簭 */
- Ascending = 0,
+ Asc = 0,
/**闄嶅簭 */
- Descending = 1,
+ Desc = 1,
}
/** 璧勬簮鎺у埗鍣� */
diff --git a/src/constants/apiEnumText.ts b/src/constants/apiEnumText.ts
index 7f42b04..392c27d 100644
--- a/src/constants/apiEnumText.ts
+++ b/src/constants/apiEnumText.ts
@@ -1,4 +1,4 @@
-import { EnumClientType, EnumUserType } from './apiEnum';
+import { EnumClientType, EnumUserType, EnumRoleWebApiDataPower } from './apiEnum';
export const EnumClientTypeText = {
[EnumClientType.PcWeb]: '鐢佃剳缃戦〉',
@@ -10,3 +10,17 @@
[EnumUserType.Enterprise]: '浼佷笟',
[EnumUserType.Operation]: '杩愯惀',
};
+
+export const EnumRoleWebApiDataPowerText = {
+ [EnumRoleWebApiDataPower.Custom]: '鑷畾涔�',
+ [EnumRoleWebApiDataPower.Creator]: '涓汉鏁版嵁',
+ [EnumRoleWebApiDataPower.CurrentDepartment]: '褰撳墠閮ㄩ棬鏁版嵁',
+ [EnumRoleWebApiDataPower.NestingDepartment]: '褰撳墠鍙婁笅绾ч儴闂ㄦ暟鎹�',
+ [EnumRoleWebApiDataPower.CurrentEnterprise]: '褰撳墠浼佷笟鎵�鏈夋暟鎹�',
+ [EnumRoleWebApiDataPower.All]: '鍏ㄩ儴鏁版嵁',
+};
+
+export const EnumRoleWebApiDataPowerTextForFilter = {
+ [EnumRoleWebApiDataPower.Creator]: '涓汉鏁版嵁',
+ [EnumRoleWebApiDataPower.All]: '鍏ㄩ儴鏁版嵁',
+};
diff --git a/src/constants/enum.ts b/src/constants/enum.ts
index 6cc4c11..d0aa578 100644
--- a/src/constants/enum.ts
+++ b/src/constants/enum.ts
@@ -17,23 +17,6 @@
Town,
}
-// 鏁版嵁鍙鑼冨洿
-export enum DataRangeEnum {
- /**
- * 鍏ㄩ儴鏁版嵁
- */
- All = 100,
- /**
- * 涓汉鏁版嵁
- */
- Person = 10,
-}
-
-export const DataRangeEnumText = {
- [DataRangeEnum.All]: '鍏ㄩ儴鏁版嵁',
- [DataRangeEnum.Person]: '涓汉鏁版嵁',
-};
-
export enum AuthorizeType {
Role = 1,
User,
diff --git a/src/constants/module.ts b/src/constants/module.ts
index 2a88c44..52a669d 100644
--- a/src/constants/module.ts
+++ b/src/constants/module.ts
@@ -101,12 +101,12 @@
},
{
id: '2',
- enCode: 'enCode',
+ enCode: 'code',
name: '缂栧彿',
},
{
id: '3',
- enCode: 'sortCode',
+ enCode: 'sort',
name: '鎺掑簭',
width: 80,
},
diff --git a/src/hooks/dic.ts b/src/hooks/dic.ts
index f896744..25dd1c8 100644
--- a/src/hooks/dic.ts
+++ b/src/hooks/dic.ts
@@ -1,5 +1,4 @@
-import { useQuery } from '@tanstack/vue-query';
-import { useQueryClient } from '@tanstack/vue-query';
+import { useQuery, useQueryClient } from '@tanstack/vue-query';
import { SearchType } from '@/constants';
type UseSearchSettingTypeOptions = {
diff --git a/src/hooks/index.ts b/src/hooks/index.ts
index bc2b519..32c8db8 100644
--- a/src/hooks/index.ts
+++ b/src/hooks/index.ts
@@ -7,3 +7,4 @@
export * from './useUser';
export * from './help';
export * from './dic';
+export * from './menu';
diff --git a/src/hooks/menu.ts b/src/hooks/menu.ts
new file mode 100644
index 0000000..33baff4
--- /dev/null
+++ b/src/hooks/menu.ts
@@ -0,0 +1,89 @@
+import * as menuServices from '@/services/api/menu';
+import { flattenTree } from '@/utils';
+import { DaPengAccessAdapter } from '@bole-core/components';
+import { useQuery, useQueryClient } from '@tanstack/vue-query';
+
+type UseMenusOptions = {
+ params: MaybeRef<API.APIgetMenusParams>;
+ enabled?: MaybeRef<boolean>;
+};
+
+export function useMenus({ params, enabled = true }: UseMenusOptions) {
+ const queryClient = useQueryClient();
+
+ const { data, refetch } = useQuery({
+ queryKey: ['menuServices/getMenus', params],
+ queryFn: async () => {
+ return await menuServices.getMenus(unref(params), {
+ showLoading: false,
+ });
+ },
+ placeholderData: () => [] as API.GetMenusQueryResultItem[],
+ staleTime: Infinity,
+ enabled: enabled,
+ });
+
+ const flattenMenus = computed(() => flattenTree(data.value));
+
+ function getMenuById(id: string) {
+ return flattenMenus.value.find((item) => item.id === id);
+ }
+
+ return {
+ menusTree: data,
+ refetch,
+ getMenuById,
+ };
+}
+
+type UseMenuOptions = {
+ params: MaybeRef<API.APIgetMenuParams>;
+ enabled?: MaybeRef<boolean>;
+};
+
+export function useMenu({ params, enabled = true }: UseMenuOptions) {
+ const queryClient = useQueryClient();
+
+ const { data, refetch } = useQuery({
+ queryKey: ['menuServices/getMenu', params],
+ queryFn: async () => {
+ return await menuServices.getMenu(unref(params), {
+ showLoading: false,
+ });
+ },
+ placeholderData: () => ({} as API.GetMenuQueryResult),
+ enabled: enabled,
+ });
+
+ const menuDefaultGroup = computed(
+ () => DaPengAccessAdapter.getMenuGroupAdapter(data.value?.groups ?? []) ?? {}
+ );
+
+ const menuFields = computed(() => {
+ return menuDefaultGroup.value.fields ?? [];
+ });
+
+ const menuPageButtons = computed(() => {
+ const pageButtonLocation = DaPengAccessAdapter.getButtonLocationAdapter(
+ menuDefaultGroup.value,
+ SubModuleKey[SubModuleType.PageButton]
+ );
+ return pageButtonLocation?.buttons ?? [];
+ });
+
+ const menuDataButtons = computed(() => {
+ const pageButtonLocation = DaPengAccessAdapter.getButtonLocationAdapter(
+ menuDefaultGroup.value,
+ SubModuleKey[SubModuleType.DataButton]
+ );
+ return pageButtonLocation?.buttons ?? [];
+ });
+
+ return {
+ menu: data,
+ refetch,
+ menuFields,
+ menuPageButtons,
+ menuDataButtons,
+ };
+}
diff --git a/src/hooks/useAccess.ts b/src/hooks/useAccess.ts
index 7ae5280..0c61411 100644
--- a/src/hooks/useAccess.ts
+++ b/src/hooks/useAccess.ts
@@ -33,7 +33,12 @@
return useBoleAccess({
queryKey: ['baseModuleServices/getCurrentSubModuleList', { moduleId }],
service: async () => {
- const res = await menuServices.getMenu({ id: moduleId });
+ const res = await menuServices.getMenu(
+ { id: moduleId },
+ {
+ showLoading: false,
+ }
+ );
return DaPengAccessAdapter.menuAdapter({ groups: res.groups, moduleId });
},
...options,
diff --git a/src/services/api/auth.ts b/src/services/api/auth.ts
index ddc31b1..db28f67 100644
--- a/src/services/api/auth.ts
+++ b/src/services/api/auth.ts
@@ -2,7 +2,7 @@
// @ts-ignore
import { request } from '@/utils/request';
-/** 姝ゅ鍚庣娌℃湁鎻愪緵娉ㄩ噴 GET /api/user/auth/getAliyunOSSAcs */
+/** 鑾峰彇闃块噷浜慜SS鎺堟潈淇℃伅 GET /api/user/auth/getAliyunOSSAcs */
export async function getAliyunOSSAcs(
// 鍙犲姞鐢熸垚鐨凱aram绫诲瀷 (闈瀊ody鍙傛暟swagger榛樿娌℃湁鐢熸垚瀵硅薄)
params: API.APIgetAliyunOSSAcsParams,
@@ -19,7 +19,24 @@
});
}
-/** 姝ゅ鍚庣娌℃湁鎻愪緵娉ㄩ噴 POST /api/user/auth/passwordLogin */
+/** 鑾峰彇褰撳墠鐧诲綍鐢ㄦ埛鑿滃崟 GET /api/user/auth/getCurrentLogierMenus */
+export async function getCurrentLogierMenus(
+ // 鍙犲姞鐢熸垚鐨凱aram绫诲瀷 (闈瀊ody鍙傛暟swagger榛樿娌℃湁鐢熸垚瀵硅薄)
+ params: API.APIgetCurrentLogierMenusParams,
+ options?: API.RequestConfig
+) {
+ return request<API.GetMenusQueryResultItem[]>('/api/user/auth/getCurrentLogierMenus', {
+ method: 'GET',
+ params: {
+ ...params,
+ request: undefined,
+ ...params['request'],
+ },
+ ...(options || {}),
+ });
+}
+
+/** 瀵嗙爜鐧诲綍 POST /api/user/auth/passwordLogin */
export async function passwordLogin(body: API.PasswordLoginCommand, options?: API.RequestConfig) {
return request<API.PasswordLoginCommandCallback>('/api/user/auth/passwordLogin', {
method: 'POST',
diff --git a/src/services/api/dictionary.ts b/src/services/api/dictionary.ts
index 2ffaa0f..961750b 100644
--- a/src/services/api/dictionary.ts
+++ b/src/services/api/dictionary.ts
@@ -2,7 +2,7 @@
// @ts-ignore
import { request } from '@/utils/request';
-/** 姝ゅ鍚庣娌℃湁鎻愪緵娉ㄩ噴 POST /api/main/dictionary/getDictionaryDatas */
+/** 鑾峰彇瀛楀吀鏁版嵁鍒嗛〉鍒楄〃 POST /api/main/dictionary/getDictionaryDatas */
export async function getDictionaryDatas(
body: API.GetDictionaryDatasQuery,
options?: API.RequestConfig
diff --git a/src/services/api/menu.ts b/src/services/api/menu.ts
index 9823244..c0caa44 100644
--- a/src/services/api/menu.ts
+++ b/src/services/api/menu.ts
@@ -2,7 +2,7 @@
// @ts-ignore
import { request } from '@/utils/request';
-/** 姝ゅ鍚庣娌℃湁鎻愪緵娉ㄩ噴 DELETE /api/user/menu/deleteMenu */
+/** 鍒犻櫎鑿滃崟 DELETE /api/user/menu/deleteMenu */
export async function deleteMenu(body: API.DeleteMenuCommand, options?: API.RequestConfig) {
return request<number>('/api/user/menu/deleteMenu', {
method: 'DELETE',
@@ -14,7 +14,7 @@
});
}
-/** 姝ゅ鍚庣娌℃湁鎻愪緵娉ㄩ噴 GET /api/user/menu/getMenu */
+/** 鏌ヨ鑿滃崟璇︽儏 GET /api/user/menu/getMenu */
export async function getMenu(
// 鍙犲姞鐢熸垚鐨凱aram绫诲瀷 (闈瀊ody鍙傛暟swagger榛樿娌℃湁鐢熸垚瀵硅薄)
params: API.APIgetMenuParams,
@@ -29,7 +29,7 @@
});
}
-/** 姝ゅ鍚庣娌℃湁鎻愪緵娉ㄩ噴 GET /api/user/menu/getMenus */
+/** 鏌ヨ鑿滃崟鍒楄〃 GET /api/user/menu/getMenus */
export async function getMenus(
// 鍙犲姞鐢熸垚鐨凱aram绫诲瀷 (闈瀊ody鍙傛暟swagger榛樿娌℃湁鐢熸垚瀵硅薄)
params: API.APIgetMenusParams,
@@ -44,7 +44,7 @@
});
}
-/** 姝ゅ鍚庣娌℃湁鎻愪緵娉ㄩ噴 POST /api/user/menu/saveMenu */
+/** 淇濆瓨鑿滃崟 POST /api/user/menu/saveMenu */
export async function saveMenu(body: API.SaveMenuCommand, options?: API.RequestConfig) {
return request<string>('/api/user/menu/saveMenu', {
method: 'POST',
@@ -56,7 +56,7 @@
});
}
-/** 姝ゅ鍚庣娌℃湁鎻愪緵娉ㄩ噴 POST /api/user/menu/saveMenuButton */
+/** 淇濆瓨鑿滃崟鎸夐挳 POST /api/user/menu/saveMenuButton */
export async function saveMenuButton(body: API.SaveMenuButtonCommand, options?: API.RequestConfig) {
return request<string>('/api/user/menu/saveMenuButton', {
method: 'POST',
@@ -68,7 +68,7 @@
});
}
-/** 姝ゅ鍚庣娌℃湁鎻愪緵娉ㄩ噴 POST /api/user/menu/saveMenuField */
+/** 淇濆瓨鑿滃崟瀛楁 POST /api/user/menu/saveMenuField */
export async function saveMenuField(body: API.SaveMenuFieldCommand, options?: API.RequestConfig) {
return request<string>('/api/user/menu/saveMenuField', {
method: 'POST',
@@ -80,7 +80,7 @@
});
}
-/** 姝ゅ鍚庣娌℃湁鎻愪緵娉ㄩ噴 PUT /api/user/menu/setMenuSwitch */
+/** 璁剧疆鑿滃崟鍒囨崲淇℃伅 PUT /api/user/menu/setMenuSwitch */
export async function setMenuSwitch(body: API.SetMenuSwitchCommand, options?: API.RequestConfig) {
return request<number>('/api/user/menu/setMenuSwitch', {
method: 'PUT',
diff --git a/src/services/api/resource.ts b/src/services/api/resource.ts
index f01100b..dc3ef94 100644
--- a/src/services/api/resource.ts
+++ b/src/services/api/resource.ts
@@ -2,7 +2,7 @@
// @ts-ignore
import { request } from '@/utils/request';
-/** 姝ゅ鍚庣娌℃湁鎻愪緵娉ㄩ噴 GET /api/user/resource/getResourceFields */
+/** 鑾峰彇璧勬簮瀛楁 GET /api/user/resource/getResourceFields */
export async function getResourceFields(
// 鍙犲姞鐢熸垚鐨凱aram绫诲瀷 (闈瀊ody鍙傛暟swagger榛樿娌℃湁鐢熸垚瀵硅薄)
params: API.APIgetResourceFieldsParams,
@@ -17,7 +17,7 @@
});
}
-/** 姝ゅ鍚庣娌℃湁鎻愪緵娉ㄩ噴 GET /api/user/resource/getResources */
+/** 鑾峰彇璧勬簮鍒楄〃 GET /api/user/resource/getResources */
export async function getResources(
// 鍙犲姞鐢熸垚鐨凱aram绫诲瀷 (闈瀊ody鍙傛暟swagger榛樿娌℃湁鐢熸垚瀵硅薄)
params: API.APIgetResourcesParams,
diff --git a/src/services/api/role.ts b/src/services/api/role.ts
index 765dcfe..36ede2e 100644
--- a/src/services/api/role.ts
+++ b/src/services/api/role.ts
@@ -2,7 +2,7 @@
// @ts-ignore
import { request } from '@/utils/request';
-/** 姝ゅ鍚庣娌℃湁鎻愪緵娉ㄩ噴 DELETE /api/user/role/deleteRole */
+/** 鍒犻櫎瑙掕壊 DELETE /api/user/role/deleteRole */
export async function deleteRole(body: API.DeleteRoleCommand, options?: API.RequestConfig) {
return request<number>('/api/user/role/deleteRole', {
method: 'DELETE',
@@ -14,7 +14,7 @@
});
}
-/** 姝ゅ鍚庣娌℃湁鎻愪緵娉ㄩ噴 GET /api/user/role/getRole */
+/** 鏌ヨ瑙掕壊璇︽儏 GET /api/user/role/getRole */
export async function getRole(
// 鍙犲姞鐢熸垚鐨凱aram绫诲瀷 (闈瀊ody鍙傛暟swagger榛樿娌℃湁鐢熸垚瀵硅薄)
params: API.APIgetRoleParams,
@@ -29,7 +29,7 @@
});
}
-/** 姝ゅ鍚庣娌℃湁鎻愪緵娉ㄩ噴 POST /api/user/role/getRoles */
+/** 鏌ヨ瑙掕壊鍒嗛〉鍒楄〃 POST /api/user/role/getRoles */
export async function getRoles(body: API.GetRolesQuery, options?: API.RequestConfig) {
return request<API.PagedListQueryResultGetRolesQueryResultItem>('/api/user/role/getRoles', {
method: 'POST',
@@ -41,7 +41,7 @@
});
}
-/** 姝ゅ鍚庣娌℃湁鎻愪緵娉ㄩ噴 POST /api/user/role/saveRole */
+/** 淇濆瓨瑙掕壊 POST /api/user/role/saveRole */
export async function saveRole(body: API.SaveRoleCommand, options?: API.RequestConfig) {
return request<string>('/api/user/role/saveRole', {
method: 'POST',
diff --git a/src/services/api/typings.d.ts b/src/services/api/typings.d.ts
index d97b45f..5773566 100644
--- a/src/services/api/typings.d.ts
+++ b/src/services/api/typings.d.ts
@@ -8,6 +8,11 @@
request?: GetAliyunOSSAcsQuery;
}
+ interface APIgetCurrentLogierMenusParams {
+ /** 鑾峰彇褰撳墠鐧诲綍鐢ㄦ埛鑿滃崟 */
+ request?: GetCurrentLogierMenusQuery;
+ }
+
interface APIgetMenuParams {
/** Id */
id?: string;
@@ -82,9 +87,9 @@
enum EnumPagedListOrder {
/**鍗囧簭 */
- Ascending = 0,
+ Asc = 0,
/**闄嶅簭 */
- Descending = 1,
+ Desc = 1,
}
enum EnumResourceController {
@@ -348,6 +353,8 @@
requestId?: string;
}
+ type GetCurrentLogierMenusQuery = Record<string, any>;
+
interface GetDictionaryDatasQuery {
pageModel?: PagedListQueryPageModel;
}
@@ -511,6 +518,9 @@
clientType?: EnumClientType;
/** 鏈�浣庣骇鍒� */
minLevel?: number;
+ dataPower?: EnumRoleWebApiDataPower;
+ /** 澶囨敞 */
+ remark?: string;
/** 鑿滃崟Id */
menuIds?: string[];
/** 璧勬簮 */
@@ -538,6 +548,9 @@
clientType?: EnumClientType;
/** 鏈�浣庣骇鍒� */
minLevel?: number;
+ dataPower?: EnumRoleWebApiDataPower;
+ /** 澶囨敞 */
+ remark?: string;
}
interface PagedListQueryPageModel {
@@ -728,6 +741,9 @@
clientType?: EnumClientType;
/** 鏈�浣庣骇鍒� */
minLevel?: number;
+ dataPower?: EnumRoleWebApiDataPower;
+ /** 澶囨敞 */
+ remark?: string;
/** 鑿滃崟Id */
menuIds?: string[];
/** 璧勬簮 */
diff --git a/src/utils/request/index.ts b/src/utils/request/index.ts
index 16e6e6e..b48c7ce 100644
--- a/src/utils/request/index.ts
+++ b/src/utils/request/index.ts
@@ -203,7 +203,7 @@
return new Promise((resolve) => {
if (userInfo.accessToken && $config.withCredentials) {
$config.headers['Authorization'] = 'Bearer ' + userInfo.accessToken;
- $config.headers['X-Authorizatio'] = 'Bearer ' + userInfo.refreshToken;
+ $config.headers['X-Authorization'] = 'Bearer ' + userInfo.refreshToken;
resolve($config);
} else {
resolve($config);
@@ -231,6 +231,7 @@
const userStore = useUserStoreHook();
if (response.headers['x-access-token']) {
+ console.log('response: ', response);
userStore.setToken(response.headers['access-token']);
userStore.setUserInfo({
accessToken: response.headers['access-token'],
diff --git a/src/views/Permission/RoleManage.vue b/src/views/Permission/RoleManage.vue
index 1310cee..5143ab0 100644
--- a/src/views/Permission/RoleManage.vue
+++ b/src/views/Permission/RoleManage.vue
@@ -4,6 +4,22 @@
<ProTableQueryFilterBar @on-reset="reset">
<template #query>
<QueryFilterItem>
+ <FieldRadio
+ v-model="extraParamState.clientType"
+ :value-enum="EnumClientTypeText"
+ buttonStyle
+ @change="getList()"
+ />
+ </QueryFilterItem>
+ <QueryFilterItem>
+ <FieldRadio
+ v-model="extraParamState.userType"
+ :value-enum="EnumUserTypeText"
+ buttonStyle
+ @change="getList()"
+ />
+ </QueryFilterItem>
+ <QueryFilterItem>
<SearchInput
v-model="extraParamState.queryCondition"
style="width: 200px"
@@ -28,7 +44,7 @@
</ProTableV2>
</AppContainer>
<AddOrEditRoleDialog v-bind="dialogProps" />
- <DialogAuthorize v-model:authorizeId="rowState.authorizeId" authorizeType="Role" />
+ <DialogAuthorizeV2 v-bind="dialogAuthorizeProps" authorizeType="Role" />
<!-- <DialogMember v-model:visibleId="rowState.setMemberRoleId" /> -->
</LoadingLayout>
</template>
@@ -44,12 +60,14 @@
QueryFilterItem,
useTable,
useFormDialog,
+ FieldRadio,
} from '@bole-core/components';
import { useAccess, useAllRoleList } from '@/hooks';
-import { Message, OrderInputType } from '@bole-core/core';
+import { Message } from '@bole-core/core';
import AddOrEditRoleDialog from './components/AddOrEditRoleDialog.vue';
-import { DataRangeEnum, DataRangeEnumText } from '@/constants';
-import DialogAuthorize from './components/dialogAuthorize.vue';
+import { EnumClientTypeText, EnumUserTypeText } from '@/constants';
+import DialogAuthorizeV2 from './components/dialogAuthorizeV2.vue';
+import * as roleServices from '@/services/api/role';
defineOptions({
name: 'RoleManage',
@@ -78,8 +96,6 @@
operationBtnMap,
});
-const { refetch } = useAllRoleList();
-
const BaseState = {
loading: true,
};
@@ -100,47 +116,52 @@
} = useTable(
async ({ pageIndex, pageSize }, extraParamState) => {
try {
- // let params: API.GetRolesInput = {
- // pageModel: {
- // rows: pageSize,
- // page: pageIndex,
- // orderInput: [{ property: 'sequence', order: OrderInputType.Asc }],
- // },
- // queryCondition: extraParamState.queryCondition,
- // };
- // let res = await userServices.getRoles(params, {
- // showLoading: !state.loading,
- // });
- // return {
- // data: res.data,
- // pageModel: {
- // rows: pageSize,
- // page: pageIndex,
- // totalCount: res.pageModel.totalCount,
- // },
- // };
- return {};
+ let params: API.GetRolesQuery = {
+ pageModel: {
+ rows: pageSize,
+ page: pageIndex,
+ orderInput: extraParamState.orderInput,
+ },
+ userType: extraParamState.userType,
+ clientType: extraParamState.clientType,
+ };
+ let res = await roleServices.getRoles(params, {
+ showLoading: !state.loading,
+ });
+ return res;
} catch (error) {}
},
{
defaultExtraParams: {
queryCondition: '',
+ orderInput: [{ property: 'id', order: EnumPagedListOrder.Desc }],
+ userType: EnumUserType.Operation,
+ clientType: EnumClientType.PcWeb,
},
- queryKey: ['userRoleServices/getRoles'],
+ queryKey: ['roleServices/getRoles'],
+ columnsRenderProps: {
+ dataPower: { type: 'enum', valueEnum: EnumRoleWebApiDataPowerText },
+ },
}
);
-function openDialog(row?: API.RoleInfo) {
- if (row) {
- handleEdit({
- id: row.id,
- name: row.name,
- remark: row.remark,
- dataRange: row.dataRange,
- });
- } else {
- handleAdd();
- }
+async function openDialog(row?: API.GetRolesQueryResultItem) {
+ try {
+ if (row) {
+ const detail = await roleServices.getRole({ id: row.id });
+ handleEdit({
+ id: row.id,
+ name: row.name,
+ remark: row.remark,
+ userType: row.userType,
+ clientType: row.clientType,
+ dataRange: row.dataPower,
+ detail: detail,
+ });
+ } else {
+ handleAdd();
+ }
+ } catch (error) {}
}
const { dialogProps, handleAdd, handleEdit, editForm, dialogState } = useFormDialog({
@@ -149,49 +170,52 @@
id: '',
name: '',
remark: '',
- dataRange: DataRangeEnum.All,
+ userType: EnumUserType.Operation,
+ clientType: EnumClientType.PcWeb,
+ dataRange: EnumRoleWebApiDataPower.All,
+ detail: null as API.GetRoleQueryResult,
},
});
async function handleAddOrEdit() {
try {
const isEdit = editForm.id;
- // let params: API.CreateOrUpdateRoleInput = {
- // name: editForm.name,
- // remark: editForm.remark,
- // dataRange: editForm.dataRange,
- // };
- // let res;
- // if (isEdit) {
- // params.id = editForm.id;
- // res = await userServices.updateRole(params);
- // } else {
- // res = await userServices.createRole(params);
- // }
- // if (res) {
- // Message.successMessage('鎿嶄綔鎴愬姛');
- // getList(isEdit ? paginationState.pageIndex : 1);
- // refetch({ type: 'inactive' });
- // }
+ let params: API.SaveRoleCommand = {
+ name: editForm.name,
+ remark: editForm.remark,
+ dataPower: editForm.dataRange,
+ userType: editForm.userType,
+ clientType: editForm.clientType,
+ };
+ if (isEdit) {
+ params = {
+ ...editForm.detail,
+ ...params,
+ };
+ }
+ let res = await roleServices.saveRole(params);
+ if (res) {
+ Message.successMessage('鎿嶄綔鎴愬姛');
+ getList(isEdit ? paginationState.pageIndex : 1);
+ }
} catch (error) {}
}
-async function handleDeleteRole(row: API.RoleInfo) {
+async function handleDeleteRole(row: API.GetRolesQueryResultItem) {
try {
- // await Message.deleteMessage();
- // let params = {
- // id: row.id,
- // };
- // let res = await userServices.deleteRole(params);
- // if (res) {
- // Message.successMessage('鎿嶄綔鎴愬姛');
- // getList(paginationState.pageIndex);
- // refetch({ type: 'inactive' });
- // }
+ await Message.deleteMessage();
+ let params: API.DeleteRoleCommand = {
+ ids: [row.id],
+ };
+ let res = await roleServices.deleteRole(params);
+ if (res) {
+ Message.successMessage('鎿嶄綔鎴愬姛');
+ getList(paginationState.pageIndex);
+ }
} catch (error) {}
}
-async function roleEnableOrForbid(row: API.RoleInfo) {
+async function roleEnableOrForbid(row: API.GetRolesQueryResultItem) {
try {
// await Message.tipMessage(`鏄惁${!row.isEnable ? '鍚敤' : '绂佺敤'}瑙掕壊`);
// let res = await userServices.roleEnableOrForbid({
@@ -212,8 +236,42 @@
setMemberRoleId: '',
});
-function openAuthorizeDialog(row: API.IdentityRoleDto) {
- rowState.authorizeId = row.id;
+const {
+ dialogProps: dialogAuthorizeProps,
+ handleAdd: handleAuthorizeAdd,
+ editForm: authorizeForm,
+} = useFormDialog({
+ onConfirm: handleAuthorize,
+ defaultFormParams: {
+ detail: null as API.GetRoleQueryResult,
+ },
+});
+
+async function openAuthorizeDialog(row: API.GetRolesQueryResultItem) {
+ try {
+ const detail = await roleServices.getRole({ id: row.id });
+ handleAuthorizeAdd({
+ detail: detail,
+ });
+ } catch (error) {}
+}
+
+async function handleAuthorize(selectedMenuIds: string[], resourceIds: string[]) {
+ try {
+ // let params: API.SaveRoleCommand = {
+ // ...authorizeForm.detail,
+ // menuIds: selectedMenuIds,
+ // resources: resourceIds.map((x) => ({
+ // resourceId: x,
+ // dataPower: EnumRoleWebApiDataPower.All,
+ // })),
+ // };
+ // let res = await roleServices.saveRole(params);
+ // if (res) {
+ // Message.successMessage('鎿嶄綔鎴愬姛');
+ // getList(paginationState.pageIndex);
+ // }
+ } catch (error) {}
}
// function openMemberDialog(row: API.IdentityRoleDto) {
diff --git a/src/views/Permission/components/AddOrEditRoleDialog.vue b/src/views/Permission/components/AddOrEditRoleDialog.vue
index acd5753..dde0eef 100644
--- a/src/views/Permission/components/AddOrEditRoleDialog.vue
+++ b/src/views/Permission/components/AddOrEditRoleDialog.vue
@@ -13,7 +13,7 @@
<ProFormItemV2 label="鏁版嵁鍙鑼冨洿" prop="dataRange">
<ProFormRadio
v-model="form.dataRange"
- :value-enum="DataRangeEnumText"
+ :value-enum="EnumRoleWebApiDataPowerTextForFilter"
:buttonStyle="false"
></ProFormRadio>
</ProFormItemV2>
@@ -45,7 +45,7 @@
ProFormRadio,
ProFormTextArea,
} from '@bole-core/components';
-import { DataRangeEnumText, DataRangeEnum } from '@/constants';
+import { EnumRoleWebApiDataPowerTextForFilter } from '@/constants';
defineOptions({
name: 'AddOrEditRoleDialog',
@@ -58,7 +58,7 @@
title?: string;
name: string;
remark: string;
- dataRange: DataRangeEnum;
+ dataRange: EnumRoleWebApiDataPower;
};
};
diff --git a/src/views/Permission/components/dialogAuthorize.vue b/src/views/Permission/components/dialogAuthorize.vue
index 9a7a467..68dc429 100644
--- a/src/views/Permission/components/dialogAuthorize.vue
+++ b/src/views/Permission/components/dialogAuthorize.vue
@@ -166,7 +166,6 @@
render() {
const { typeTip, isMenu } = this;
const tipText = isMenu ? `鑿滃崟` : '椤甸潰';
- console.log(typeTip);
return h(
'span',
{
@@ -269,12 +268,12 @@
}),
};
- const result = await baseModuleServices.addAuthorizeModule(data);
- if (result) {
- Message.successMessage('鎺堟潈鎴愬姛锛�');
- } else {
- Message.errorMessage('鎺堟潈澶辫触锛�');
- }
+ // const result = await baseModuleServices.addAuthorizeModule(data);
+ // if (result) {
+ // Message.successMessage('鎺堟潈鎴愬姛锛�');
+ // } else {
+ // Message.errorMessage('鎺堟潈澶辫触锛�');
+ // }
handleClose();
} catch (error) {}
}
@@ -337,12 +336,12 @@
id,
};
- const result = await baseModuleServices.getUserOrRoleModuleList(data);
+ // const result = await baseModuleServices.getUserOrRoleModuleList(data);
- state.sysModules = getTree(result, null);
- elModuleTree.value.setCheckedKeys(result.filter((x) => x.hasCheck).map((x) => x.id));
+ // state.sysModules = getTree(result, null);
+ // elModuleTree.value.setCheckedKeys(result.filter((x) => x.hasCheck).map((x) => x.id));
- initAuthorizeInfo(result, 1);
+ // initAuthorizeInfo(result, 1);
getExtendsByRoleOrUser(data);
}
@@ -371,11 +370,11 @@
async function getExtendsByRoleOrUser(data) {
try {
- let result = await baseModuleServices.getUserOrRoleSubModuleList(data);
- const { pageButton, dataButton, column } = result;
- initAuthorizeInfo(pageButton, 2, 'pageButton');
- initAuthorizeInfo(dataButton, 3, 'dataButton');
- initAuthorizeInfo(column, 4, 'dataColumn');
+ // let result = await baseModuleServices.getUserOrRoleSubModuleList(data);
+ // const { pageButton, dataButton, column } = result;
+ // initAuthorizeInfo(pageButton, 2, 'pageButton');
+ // initAuthorizeInfo(dataButton, 3, 'dataButton');
+ // initAuthorizeInfo(column, 4, 'dataColumn');
} catch (error) {
console.log(error);
}
diff --git a/src/views/Permission/components/dialogAuthorizeV2.vue b/src/views/Permission/components/dialogAuthorizeV2.vue
new file mode 100644
index 0000000..d52af8e
--- /dev/null
+++ b/src/views/Permission/components/dialogAuthorizeV2.vue
@@ -0,0 +1,376 @@
+<template>
+ <ProDialog
+ class="custom-dialog"
+ width="55%"
+ :title="dialogTitle"
+ v-model="visible"
+ :top="'10vh'"
+ :close-on-click-modal="false"
+ :close-on-press-escape="false"
+ >
+ <div class="authorize-wrapper">
+ <div class="container-wrapper left-wrapper">
+ <el-scrollbar>
+ <el-tree
+ class="companyTree"
+ :data="menusTree"
+ :props="{
+ children: 'children',
+ label: 'name',
+ }"
+ node-key="id"
+ :expand-on-click-node="false"
+ :highlight-current="true"
+ default-expand-all
+ show-checkbox
+ ref="moduleTree"
+ :default-checked-keys="checkedModules"
+ >
+ <template #default="{ node }">
+ <div class="custom-tree-node">
+ <type-tip :isMenu="node.data.type === EnumMenuType.Menu" />
+ <div class="node-text" @click="handleSelectModule(node.data)">
+ {{ node.label }}
+ </div>
+ </div>
+ </template>
+ </el-tree>
+ </el-scrollbar>
+ </div>
+
+ <div class="container-wrapper">
+ <div class="type-wrapper">
+ {{ SubModuleTitle[SubModuleType.PageButton] }}
+ </div>
+ <el-scrollbar>
+ <el-tree
+ v-show="!!state.currentMenuId"
+ :data="[
+ {
+ name: '鍏ㄩ��',
+ id: 'pageButtonAll',
+ children: menuPageButtons,
+ },
+ ]"
+ :props="{
+ children: 'children',
+ label: 'name',
+ }"
+ node-key="id"
+ :expand-on-click-node="false"
+ :highlight-current="true"
+ default-expand-all
+ show-checkbox
+ ref="pageButtonTree"
+ :default-checked-keys="checkedPageButton"
+ >
+ <template #default="{ node }">
+ <div class="custom-tree-node">
+ <span>{{ node.label }}</span>
+ </div>
+ </template>
+ </el-tree>
+ </el-scrollbar>
+ </div>
+
+ <div class="container-wrapper">
+ <div class="type-wrapper">
+ {{ SubModuleTitle[SubModuleType.DataButton] }}
+ </div>
+ <el-scrollbar>
+ <el-tree
+ v-show="!!state.currentMenuId"
+ :data="[
+ {
+ name: '鍏ㄩ��',
+ id: 'dataButtonAll',
+ children: menuDataButtons,
+ },
+ ]"
+ :props="{
+ children: 'children',
+ label: 'name',
+ }"
+ node-key="id"
+ :expand-on-click-node="false"
+ :highlight-current="true"
+ default-expand-all
+ show-checkbox
+ ref="dataButtonTree"
+ :default-checked-keys="checkedDataButton"
+ >
+ <template #default="{ node }">
+ <div class="custom-tree-node">
+ <span>{{ node.label }}</span>
+ </div>
+ </template>
+ </el-tree>
+ </el-scrollbar>
+ </div>
+
+ <div class="container-wrapper">
+ <div class="type-wrapper">
+ {{ SubModuleTitle[SubModuleType.Column] }}
+ </div>
+ <el-scrollbar>
+ <el-tree
+ v-show="!!state.currentMenuId"
+ :data="[
+ {
+ name: '鍏ㄩ��',
+ id: 'dataColumnAll',
+ children: menuFields,
+ },
+ ]"
+ :props="{
+ children: 'children',
+ label: 'name',
+ }"
+ node-key="id"
+ :expand-on-click-node="false"
+ :highlight-current="true"
+ default-expand-all
+ show-checkbox
+ ref="dataColumnTree"
+ :default-checked-keys="checkedDataColumn"
+ >
+ <template #default="{ node }">
+ <div class="custom-tree-node">
+ <span>{{ node.label }}</span>
+ </div>
+ </template>
+ </el-tree>
+ </el-scrollbar>
+ </div>
+ </div>
+ <template #footer>
+ <span class="dialog-footer">
+ <el-button @click="visible = false">鍙栨秷</el-button>
+ <el-button type="primary" @click="handleConfirm" class="btn-submit"> 纭畾 </el-button>
+ </span>
+ </template>
+ </ProDialog>
+</template>
+
+<script setup lang="ts">
+import { Message } from '@bole-core/core';
+import { AuthorizeType, SubModuleType, SubModuleTitle, EnumMenuType } from '@/constants';
+import { getTree } from '@/utils';
+import { TreeInstance } from 'element-plus';
+import { ProDialog } from '@bole-core/components';
+import { useMenus, useMenu } from '@/hooks';
+
+const TypeTip = defineComponent({
+ name: 'TypeTip',
+ props: ['isMenu'],
+ render() {
+ const { isMenu } = this;
+ const tipText = isMenu ? `鑿滃崟` : '椤甸潰';
+ return h(
+ 'span',
+ {
+ class: 'tip-text',
+ style: {
+ color: '#EB6100',
+ },
+ },
+ '[' + tipText + ']'
+ );
+ },
+});
+
+type Props = {
+ authorizeType: 'Role' | 'User';
+};
+
+const props = withDefaults(defineProps<Props>(), {});
+
+const visible = defineModel({ type: Boolean });
+
+type Form = {
+ title?: string;
+ detail: API.GetRoleQueryResult;
+};
+
+const form = defineModel<Form>('form');
+
+const emit = defineEmits<{
+ (e: 'onConfirm', selectedMenuIds: string[], resourceIds: string[]): void;
+ (e: 'onCancel'): void;
+}>();
+
+type CheckedResourceItem = {
+ resourceId: string;
+ menuId: string;
+ resourceType: SubModuleType;
+};
+
+const state = reactive({
+ currentMenuId: '',
+ checkedInfo: [] as CheckedResourceItem[],
+});
+
+watch(visible, (newVal) => {
+ if (newVal) {
+ state.currentMenuId = '';
+ state.checkedInfo = [];
+ }
+});
+
+const dialogTitle = computed(() =>
+ props.authorizeType === 'Role' ? '瑙掕壊鍔熻兘鎺堟潈' : '璐﹀彿鍔熻兘鎺堟潈'
+);
+
+const moduleTree = useTemplateRef<TreeInstance>('moduleTree');
+const pageButtonTree = useTemplateRef<TreeInstance>('pageButtonTree');
+const dataButtonTree = useTemplateRef<TreeInstance>('dataButtonTree');
+const dataColumnTree = useTemplateRef<TreeInstance>('dataColumnTree');
+
+const { menusTree, getMenuById } = useMenus({
+ params: computed(() => ({
+ userType: form.value.detail?.userType,
+ clientType: form.value.detail?.clientType,
+ roleId: form.value.detail?.id,
+ })),
+ enabled: computed(() => !!form.value.detail?.id),
+});
+
+const { menuFields, menuPageButtons, menuDataButtons } = useMenu({
+ params: computed(() => ({
+ id: state.currentMenuId,
+ roleId: form.value.detail?.id,
+ })),
+ enabled: computed(() => !!state.currentMenuId),
+});
+
+const checkedModules = computed(() => {
+ if (form.value.detail) {
+ return form.value.detail.menuIds;
+ }
+ return [];
+});
+
+const checkedPageButton = computed(() => initChecked(SubModuleType.PageButton));
+const checkedDataButton = computed(() => initChecked(SubModuleType.DataButton));
+const checkedDataColumn = computed(() => initChecked(SubModuleType.Column));
+
+function initChecked(type: SubModuleType) {
+ return state.checkedInfo.filter((x) => x.resourceType === type).map((x) => x.resourceId);
+}
+
+function handleSelectModule(menu: API.GetMenusQueryResultItem) {
+ const modules1 =
+ dataButtonTree &&
+ dataButtonTree.value.getCheckedKeys(true).map((x) => {
+ return {
+ resourceType: SubModuleType.DataButton,
+ resourceId: x,
+ menuId: menu.id,
+ } as CheckedResourceItem;
+ });
+
+ const modules2 =
+ pageButtonTree &&
+ pageButtonTree.value.getCheckedKeys(true).map((x) => {
+ return {
+ resourceType: SubModuleType.PageButton,
+ resourceId: x,
+ menuId: menu.id,
+ } as CheckedResourceItem;
+ });
+
+ const modules3 =
+ dataColumnTree &&
+ dataColumnTree.value.getCheckedKeys(true).map((x) => {
+ return {
+ resourceType: SubModuleType.Column,
+ resourceId: x,
+ menuId: menu.id,
+ } as CheckedResourceItem;
+ });
+
+ const checkExtends = state.checkedInfo.filter(
+ (x) => x.menuId !== menu.id && x.menuId !== undefined
+ );
+
+ if (modules1 && modules1.length) {
+ checkExtends.push(...modules1);
+ }
+ if (modules2 && modules2.length) {
+ checkExtends.push(...modules2);
+ }
+ if (modules3 && modules3.length) {
+ checkExtends.push(...modules3);
+ }
+
+ state.checkedInfo = checkExtends;
+ state.currentMenuId = menu.id;
+}
+
+function handleConfirm() {
+ const selectedMenuIds = moduleTree.value.getCheckedNodes(false, true).map((x) => x.id);
+ console.log('selectedMenuIds: ', selectedMenuIds);
+ handleSelectModule(getMenuById(state.currentMenuId));
+ const resourceIds = state.checkedInfo.map((x) => x.resourceId);
+ console.log('resourceIds: ', resourceIds);
+ emit('onConfirm', selectedMenuIds, resourceIds);
+}
+</script>
+
+<style lang="scss" scoped>
+:deep(.custom-dialog) {
+ min-width: 900px;
+}
+
+.authorize-wrapper {
+ display: flex;
+
+ height: 500px;
+ border-bottom: 2px solid #f5f5f5;
+ background: #dddddd;
+
+ .container-wrapper {
+ width: calc(25%);
+ border-right: 2px solid #f5f5f5;
+ // margin-right: 7px;
+ background: #ffffff;
+
+ .type-wrapper {
+ display: flex;
+ justify-content: flex-start;
+ align-items: center;
+ padding: 10px 16px;
+ border-bottom: 2px solid #f5f5f5;
+ color: #333333;
+ }
+
+ &:last-of-type {
+ margin-right: 0px;
+ }
+
+ &.left-wrapper {
+ margin-right: 7px;
+ padding-top: 10px;
+ width: calc(35% - 7px);
+
+ :deep(.el-scrollbar) {
+ width: 100%;
+ height: 98%;
+ }
+ }
+
+ :deep(.el-scrollbar) {
+ width: 100%;
+ height: calc(98% - 43px);
+
+ .el-scrollbar__wrap {
+ overflow: auto;
+
+ .custom-tree-node {
+ display: flex;
+ }
+ }
+ }
+ }
+}
+</style>
diff --git a/src/views/System/ModuleManage.vue b/src/views/System/ModuleManage.vue
index c35f3b4..5a20161 100644
--- a/src/views/System/ModuleManage.vue
+++ b/src/views/System/ModuleManage.vue
@@ -3,6 +3,22 @@
<AppContainer>
<ProTableQueryFilterBar @on-reset="handleReset">
<template #query>
+ <QueryFilterItem>
+ <FieldRadio
+ v-model="state.clientType"
+ :value-enum="EnumClientTypeText"
+ buttonStyle
+ @change="getAllModule()"
+ />
+ </QueryFilterItem>
+ <QueryFilterItem>
+ <FieldRadio
+ v-model="state.userType"
+ :value-enum="EnumUserTypeText"
+ buttonStyle
+ @change="getAllModule()"
+ />
+ </QueryFilterItem>
<div class="query-filter-list-item">
<SearchInput
v-model="state.searchValue"
@@ -50,14 +66,14 @@
row.type=v?EnumMenuType.Menu:EnumMenuType.Page
}"
inline-prompt
- @change="(v: number) => handleChangeStatus(v, row, 'isMenu')"
+ @change="(v: boolean) => handleChangeStatus(v, row, 'isMenu')"
></el-switch>
</template>
<template v-else-if="column.property === 'enabledMark'">
<el-switch
:modelValue="!row.isDisabled"
:onUpdate:modelValue="(v: boolean) => row.isDisabled =!v"
- @change="(v: number) => handleChangeStatus(v, row, 'enabledMark')"
+ @change="(v: boolean) => handleChangeStatus(v, row, 'enabledMark')"
></el-switch>
</template>
</template>
@@ -94,6 +110,8 @@
LoadingLayout,
OperationBtnType,
SearchInput,
+ QueryFilterItem,
+ FieldRadio,
} from '@bole-core/components';
import { ModuleUtils, TreeModuleDtoGroupDto, Message, TreeStore, flattenTree } from '@/utils';
import { TableInstance } from 'element-plus';
@@ -246,23 +264,30 @@
}
type StatusEventType = {
isCache: boolean;
- isMenu: number;
- enabledMark: number;
+ isMenu: boolean;
+ enabledMark: boolean;
};
async function handleChangeStatus<T extends keyof StatusEventType>(
- value: StatusEventType[T],
+ value: boolean,
data: TreeModuleDtoGroupDto,
statusType: T
) {
try {
- // let params = {
- // ..._.omit(data, ['children', 'parentNode']),
- // [statusType]: value,
- // };
- // await baseModuleServices.addOrEditModule(params);
- } catch (error) {
- Message.errorMessage('鎿嶄綔澶辫触');
- }
+ let params: API.SetMenuSwitchCommand = {
+ ids: [data.id],
+ type: data.type,
+ isDisabled: data.isDisabled,
+ isCache: data.isCache,
+ };
+ if (statusType === 'isMenu') {
+ params.type = value ? EnumMenuType.Menu : EnumMenuType.Page;
+ } else if (statusType === 'isCache') {
+ params.isCache = value;
+ } else {
+ params.isDisabled = !value;
+ }
+ await menuServices.setMenuSwitch(params);
+ } catch (error) {}
}
async function getMenu(id: string) {
--
Gitblit v1.9.1