From cf727afa850496f3a239907fab342b4bd3ff77fc Mon Sep 17 00:00:00 2001 From: zhengyiming <540361168@qq.com> Date: 星期一, 04 八月 2025 18:22:13 +0800 Subject: [PATCH] fix: 修改功能模块 --- config/openapi.json | 2 src/services/api/resource.ts | 20 src/views/CPersonManage/components/CPersonDetailDialog.vue | 5 src/utils/module/index.ts | 9 src/constants/module.ts | 8 src/services/api/typings.d.ts | 252 ++++++++++++++-- src/services/api/dictionary.ts | 6 src/utils/oss/index.ts | 11 src/store/modules/user.ts | 4 types/api.d.ts | 33 -- src/utils/request/index.ts | 14 src/services/api/menu.ts | 26 + .env.development | 2 /dev/null | 86 ----- vite.config.ts | 4 src/services/api/index.ts | 6 src/views/System/components/AddOrEditModuleDialog.vue | 8 src/services/api/role.ts | 54 +++ src/store/modules/permission.ts | 92 +++--- src/views/System/ModuleManage.vue | 199 ++++++++----- src/constants/apiEnum.ts | 16 + src/constants/index.ts | 1 src/services/api/auth.ts | 20 + 23 files changed, 546 insertions(+), 332 deletions(-) diff --git a/.env.development b/.env.development index 81bd198..9d6ad13 100644 --- a/.env.development +++ b/.env.development @@ -11,7 +11,7 @@ VITE_ROUTER_HISTORY = "h5" # 寮�鍙戠幆澧冨悗绔湴鍧� -VITE_PROXY_DOMAIN_REAL = "http://localhost:44340/" +VITE_PROXY_DOMAIN_REAL = "http://localhost:53780/" # VITE_PROXY_DOMAIN_REAL = "http://118.178.252.28:8752/" diff --git a/config/openapi.json b/config/openapi.json index 5659300..524dda8 100644 --- a/config/openapi.json +++ b/config/openapi.json @@ -2,7 +2,7 @@ "config": [ { "requestLibPath": "import { request } from '@/utils/request'", - "schemaPath": "https://localhost:44340/swagger/Default/swagger.json", + "schemaPath": "http://localhost:53780/swagger/Default/swagger.json", "serversPath": "./src/services", "enumStyle": "enum", "enumFilePath": "../../constants/apiEnum.ts" diff --git a/src/components/Dialog/OperateHistoryLogByTypeDialog.vue b/src/components/Dialog/OperateHistoryLogByTypeDialog.vue deleted file mode 100644 index 9aaf2a5..0000000 --- a/src/components/Dialog/OperateHistoryLogByTypeDialog.vue +++ /dev/null @@ -1,86 +0,0 @@ -<template> - <ProDialog - title="鏃ュ織" - v-model="innerVisible" - destroy-on-close - draggable - bodyNoPaddingBottom - @close="onDialogClose" - > - <ProDialogTableWrapper :height="500"> - <ProTableV2 v-bind="proTableProps" :columns="extraColumns" :showOperationColumn="false"> - <template #functionColumn>{{ props.functionModule }}</template> - </ProTableV2> - </ProDialogTableWrapper> - <template #footer> - <span class="dialog-footer"> - <el-button @click="innerVisible = false" type="primary">纭� 瀹�</el-button> - </span> - </template> - </ProDialog> -</template> - -<script setup lang="ts"> -import { ProDialog, ProTableV2, ProDialogTableWrapper } from '@bole-core/components'; -import { useTableLogListByType } from '@/hooks'; -import { OperateHistoryTypeEnum } from '@/constants'; - -defineOptions({ - name: 'OperateHistoryLogByTypeDialog', -}); - -type Props = { - modelValue: boolean; - relationId: string; - operateHistoryType?: OperateHistoryTypeEnum; - - functionModule?: string; -}; - -const props = withDefaults(defineProps<Props>(), { - modelValue: false, -}); - -const emit = defineEmits<{ - (e: 'update:modelValue', value: boolean): void; - (e: 'onConfirm'): void; -}>(); - -const innerVisible = computed({ - get() { - return props.modelValue; - }, - set(val) { - emit('update:modelValue', val); - }, -}); - -watch( - () => props.modelValue, - async (visible, oldVisible) => { - if (!oldVisible && visible) { - await getList(); - state.loading = false; - } - } -); - -function onDialogClose() { - state.loading = true; -} - -const functionModuleColumns: API.CustomModuleColumnDto[] = [ - { id: '0', enCode: 'functionColumn', name: '鍔熻兘妯″潡' }, -]; - -const extraColumns = computed(() => { - return props.functionModule - ? functionModuleColumns.concat(OperateHistoryTableColumns) - : OperateHistoryTableColumns; -}); - -const { getList, proTableProps, state, OperateHistoryTableColumns } = useTableLogListByType({ - relationId: toRef(props, 'relationId'), - operateHistoryType: toRef(props, 'operateHistoryType'), -}); -</script> diff --git a/src/constants/apiEnum.ts b/src/constants/apiEnum.ts index 30a5660..eeb9c95 100644 --- a/src/constants/apiEnum.ts +++ b/src/constants/apiEnum.ts @@ -41,6 +41,22 @@ Descending = 1, } +/** 瑙掕壊鎺ュ彛鏁版嵁鏉冮檺 */ +export enum EnumRoleWebApiDataPower { + /**鑷畾涔� */ + Custom = 1, + /**鏌ヨ涓汉鍒涘缓鏁版嵁 */ + Creator = 10, + /**鏌ヨ褰撳墠閮ㄩ棬鏁版嵁 */ + CurrentDepartment = 20, + /**鏌ヨ褰撳墠鍙婁笅绾ч儴闂ㄦ暟鎹� */ + NestingDepartment = 21, + /**鏌ヨ褰撳墠浼佷笟鎵�鏈夋暟鎹� */ + CurrentEnterprise = 30, + /**鏌ヨ鎵�鏈� */ + All = 999, +} + /** 鐢ㄦ埛绫诲瀷 */ export enum EnumUserType { /**涓汉 */ diff --git a/src/constants/index.ts b/src/constants/index.ts index 5dd6368..461b547 100644 --- a/src/constants/index.ts +++ b/src/constants/index.ts @@ -12,3 +12,4 @@ export * from './dic'; export * from './enterprise'; export * from './cPerson'; +export * from './apiEnum'; diff --git a/src/constants/module.ts b/src/constants/module.ts index 798ceca..2a88c44 100644 --- a/src/constants/module.ts +++ b/src/constants/module.ts @@ -1,3 +1,5 @@ +import { defineColumns } from '@bole-core/components'; + export enum SubModuleType { MenuButton = 1, /** @@ -90,7 +92,7 @@ [SubModuleType.Column]: FastColumnList, }; -export const ModuleColumns: API.CustomModuleColumnDto[] = [ +export const ModuleColumns = defineColumns([ { id: '1', enCode: 'name', @@ -110,7 +112,7 @@ }, { id: '4', - enCode: 'path', + enCode: 'url', name: '璺敱鍦板潃', }, { @@ -131,4 +133,4 @@ name: '鏈夋晥', width: 80, }, -]; +]); diff --git a/src/services/api/auth.ts b/src/services/api/auth.ts index 27f5cb5..5c04818 100644 --- a/src/services/api/auth.ts +++ b/src/services/api/auth.ts @@ -2,11 +2,25 @@ // @ts-ignore import { request } from '@/utils/request'; -/** 瀵嗙爜鐧诲綍 POST /api/user/auth/passwordLogin */ -export async function authPasswordLogin( - body: API.PasswordLoginCommand, +/** 鑾峰彇闃块噷浜慜SS鎺堟潈淇℃伅 GET /api/user/auth/getAliyunOSSAcs */ +export async function getAliyunOSSAcs( + // 鍙犲姞鐢熸垚鐨凱aram绫诲瀷 (闈瀊ody鍙傛暟swagger榛樿娌℃湁鐢熸垚瀵硅薄) + params: API.APIgetAliyunOSSAcsParams, options?: API.RequestConfig ) { + return request<API.GetAliyunOSSAcsQueryResult>('/api/user/auth/getAliyunOSSAcs', { + method: 'GET', + params: { + ...params, + query: undefined, + ...params['query'], + }, + ...(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', headers: { diff --git a/src/services/api/dictionary.ts b/src/services/api/dictionary.ts index 3d209df..8ceca42 100644 --- a/src/services/api/dictionary.ts +++ b/src/services/api/dictionary.ts @@ -2,13 +2,13 @@ // @ts-ignore import { request } from '@/utils/request'; -/** 鑾峰彇瀛楀吀鏁版嵁鍒嗛〉鍒楄〃 GET /api/main/dictionary/getDictionaryDatas */ -export async function dictionaryGetDictionaryDatas( +/** 鑾峰彇瀛楀吀鏁版嵁鍒嗛〉鍒楄〃 POST /api/main/dictionary/getDictionaryDatas */ +export async function getDictionaryDatas( body: API.GetDictionaryDatasQuery, options?: API.RequestConfig ) { return request<API.GetDictionaryDatasQueryResult>('/api/main/dictionary/getDictionaryDatas', { - method: 'GET', + method: 'POST', headers: { 'Content-Type': 'application/json-patch+json', }, diff --git a/src/services/api/index.ts b/src/services/api/index.ts index b373538..e96a264 100644 --- a/src/services/api/index.ts +++ b/src/services/api/index.ts @@ -2,13 +2,15 @@ /* eslint-disable */ // API 鏇存柊鏃堕棿锛� // API 鍞竴鏍囪瘑锛� +import * as dictionary from './dictionary'; import * as auth from './auth'; import * as menu from './menu'; import * as resource from './resource'; -import * as dictionary from './dictionary'; +import * as role from './role'; export default { + dictionary, auth, menu, resource, - dictionary, + role, }; diff --git a/src/services/api/menu.ts b/src/services/api/menu.ts index d122313..04034d5 100644 --- a/src/services/api/menu.ts +++ b/src/services/api/menu.ts @@ -3,7 +3,7 @@ import { request } from '@/utils/request'; /** 鍒犻櫎鑿滃崟 DELETE /api/user/menu/deleteMenu */ -export async function menuDeleteMenu(body: API.DeleteMenuCommand, options?: API.RequestConfig) { +export async function deleteMenu(body: API.DeleteMenuCommand, options?: API.RequestConfig) { return request<number>('/api/user/menu/deleteMenu', { method: 'DELETE', headers: { @@ -15,31 +15,37 @@ } /** 鏌ヨ鑿滃崟璇︽儏 GET /api/user/menu/getMenu */ -export async function menuGetMenu(body: API.GetMenuQuery, options?: API.RequestConfig) { +export async function getMenu( + // 鍙犲姞鐢熸垚鐨凱aram绫诲瀷 (闈瀊ody鍙傛暟swagger榛樿娌℃湁鐢熸垚瀵硅薄) + params: API.APIgetMenuParams, + options?: API.RequestConfig +) { return request<API.GetMenuQueryResult>('/api/user/menu/getMenu', { method: 'GET', - headers: { - 'Content-Type': 'application/json-patch+json', + params: { + ...params, }, - data: body, ...(options || {}), }); } /** 鏌ヨ鑿滃崟鍒楄〃 GET /api/user/menu/getMenus */ -export async function menuGetMenus(body: API.GetMenusQuery, options?: API.RequestConfig) { +export async function getMenus( + // 鍙犲姞鐢熸垚鐨凱aram绫诲瀷 (闈瀊ody鍙傛暟swagger榛樿娌℃湁鐢熸垚瀵硅薄) + params: API.APIgetMenusParams, + options?: API.RequestConfig +) { return request<API.GetMenusQueryResultItem[]>('/api/user/menu/getMenus', { method: 'GET', - headers: { - 'Content-Type': 'application/json-patch+json', + params: { + ...params, }, - data: body, ...(options || {}), }); } /** 淇濆瓨鑿滃崟 POST /api/user/menu/saveMenu */ -export async function menuSaveMenu(body: API.SaveMenuCommand, options?: API.RequestConfig) { +export async function saveMenu(body: API.SaveMenuCommand, options?: API.RequestConfig) { return request<string>('/api/user/menu/saveMenu', { method: 'POST', headers: { diff --git a/src/services/api/resource.ts b/src/services/api/resource.ts index 92b3b47..dc3ef94 100644 --- a/src/services/api/resource.ts +++ b/src/services/api/resource.ts @@ -3,31 +3,31 @@ import { request } from '@/utils/request'; /** 鑾峰彇璧勬簮瀛楁 GET /api/user/resource/getResourceFields */ -export async function resourceGetResourceFields( - body: API.GetResourceFieldsQuery, +export async function getResourceFields( + // 鍙犲姞鐢熸垚鐨凱aram绫诲瀷 (闈瀊ody鍙傛暟swagger榛樿娌℃湁鐢熸垚瀵硅薄) + params: API.APIgetResourceFieldsParams, options?: API.RequestConfig ) { return request<API.GetResourceFieldsQueryResultItem[]>('/api/user/resource/getResourceFields', { method: 'GET', - headers: { - 'Content-Type': 'application/json-patch+json', + params: { + ...params, }, - data: body, ...(options || {}), }); } /** 鑾峰彇璧勬簮鍒楄〃 GET /api/user/resource/getResources */ -export async function resourceGetResources( - body: API.GetResourcesQuery, +export async function getResources( + // 鍙犲姞鐢熸垚鐨凱aram绫诲瀷 (闈瀊ody鍙傛暟swagger榛樿娌℃湁鐢熸垚瀵硅薄) + params: API.APIgetResourcesParams, options?: API.RequestConfig ) { return request<API.GetResourcesQueryResultItem[]>('/api/user/resource/getResources', { method: 'GET', - headers: { - 'Content-Type': 'application/json-patch+json', + params: { + ...params, }, - data: body, ...(options || {}), }); } diff --git a/src/services/api/role.ts b/src/services/api/role.ts new file mode 100644 index 0000000..13b983d --- /dev/null +++ b/src/services/api/role.ts @@ -0,0 +1,54 @@ +/* eslint-disable */ +// @ts-ignore +import { request } from '@/utils/request'; + +/** 鍒犻櫎瑙掕壊 DELETE /api/user/role/deleteRole */ +export async function deleteRole(body: API.DeleteRoleCommand, options?: API.RequestConfig) { + return request<number>('/api/user/role/deleteRole', { + method: 'DELETE', + headers: { + 'Content-Type': 'application/json-patch+json', + }, + data: body, + ...(options || {}), + }); +} + +/** 鏌ヨ瑙掕壊璇︽儏 GET /api/user/role/getRole */ +export async function getRole( + // 鍙犲姞鐢熸垚鐨凱aram绫诲瀷 (闈瀊ody鍙傛暟swagger榛樿娌℃湁鐢熸垚瀵硅薄) + params: API.APIgetRoleParams, + options?: API.RequestConfig +) { + return request<API.GetRoleQueryResult>('/api/user/role/getRole', { + method: 'GET', + params: { + ...params, + }, + ...(options || {}), + }); +} + +/** 鏌ヨ瑙掕壊鍒楄〃 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', + headers: { + 'Content-Type': 'application/json-patch+json', + }, + data: body, + ...(options || {}), + }); +} + +/** 淇濆瓨瑙掕壊 POST /api/user/role/saveRole */ +export async function saveRole(body: API.SaveRoleCommand, options?: API.RequestConfig) { + return request<string>('/api/user/role/saveRole', { + method: 'POST', + headers: { + 'Content-Type': 'application/json-patch+json', + }, + data: body, + ...(options || {}), + }); +} diff --git a/src/services/api/typings.d.ts b/src/services/api/typings.d.ts index 5317b70..8510633 100644 --- a/src/services/api/typings.d.ts +++ b/src/services/api/typings.d.ts @@ -3,7 +3,52 @@ [key: string]: any; } + interface APIgetAliyunOSSAcsParams { + query?: GetAliyunOSSAcsQuery; + } + + interface APIgetMenuParams { + /** Id */ + id?: string; + /** 瑙掕壊Id */ + roleId?: string; + } + + interface APIgetMenusParams { + /** 鐢ㄦ埛绫诲瀷 */ + userType?: EnumUserType; + /** 瀹㈡埛绔被鍨� */ + clientType?: EnumClientType; + /** 瑙掕壊Id */ + roleId?: string; + } + + interface APIgetResourceFieldsParams { + /** Id */ + id?: string; + } + + interface APIgetResourcesParams { + /** 寰湇鍔� */ + service?: string; + /** 璇锋眰鏂瑰紡 */ + method?: EnumWebApiMethod; + /** 鍏抽敭瀛� */ + keywords?: string; + /** 瑙掕壊Id */ + roleId?: string; + } + + interface APIgetRoleParams { + /** Id */ + id?: string; + } + interface DeleteMenuCommand { + ids: string[]; + } + + interface DeleteRoleCommand { ids: string[]; } @@ -43,6 +88,21 @@ Descending = 1, } + enum EnumRoleWebApiDataPower { + /**鑷畾涔� */ + Custom = 1, + /**鏌ヨ涓汉鍒涘缓鏁版嵁 */ + Creator = 10, + /**鏌ヨ褰撳墠閮ㄩ棬鏁版嵁 */ + CurrentDepartment = 20, + /**鏌ヨ褰撳墠鍙婁笅绾ч儴闂ㄦ暟鎹� */ + NestingDepartment = 21, + /**鏌ヨ褰撳墠浼佷笟鎵�鏈夋暟鎹� */ + CurrentEnterprise = 30, + /**鏌ヨ鎵�鏈� */ + All = 999, + } + enum EnumUserType { /**涓汉 */ Personal = 10, @@ -63,16 +123,36 @@ Delete = 40, } + interface FriendlyResultGetAliyunOSSAcsQueryResult { + /** 璺熻釜Id */ + traceId?: string; + /** 鐘舵�佺爜 */ + code?: number; + /** 閿欒鐮� */ + errorCode?: string; + data?: GetAliyunOSSAcsQueryResult; + /** 鎵ц鎴愬姛 */ + success?: boolean; + /** 閿欒淇℃伅 */ + msg?: any; + /** 闄勫姞鏁版嵁 */ + extras?: any; + /** 鏃堕棿鎴� */ + timestamp?: number; + } + interface FriendlyResultGetDictionaryDatasQueryResult { /** 璺熻釜Id */ traceId?: string; /** 鐘舵�佺爜 */ code?: number; + /** 閿欒鐮� */ + errorCode?: string; data?: GetDictionaryDatasQueryResult; /** 鎵ц鎴愬姛 */ success?: boolean; /** 閿欒淇℃伅 */ - errors?: any; + msg?: any; /** 闄勫姞鏁版嵁 */ extras?: any; /** 鏃堕棿鎴� */ @@ -84,11 +164,31 @@ traceId?: string; /** 鐘舵�佺爜 */ code?: number; + /** 閿欒鐮� */ + errorCode?: string; data?: GetMenuQueryResult; /** 鎵ц鎴愬姛 */ success?: boolean; /** 閿欒淇℃伅 */ - errors?: any; + msg?: any; + /** 闄勫姞鏁版嵁 */ + extras?: any; + /** 鏃堕棿鎴� */ + timestamp?: number; + } + + interface FriendlyResultGetRoleQueryResult { + /** 璺熻釜Id */ + traceId?: string; + /** 鐘舵�佺爜 */ + code?: number; + /** 閿欒鐮� */ + errorCode?: string; + data?: GetRoleQueryResult; + /** 鎵ц鎴愬姛 */ + success?: boolean; + /** 閿欒淇℃伅 */ + msg?: any; /** 闄勫姞鏁版嵁 */ extras?: any; /** 鏃堕棿鎴� */ @@ -100,12 +200,14 @@ traceId?: string; /** 鐘舵�佺爜 */ code?: number; + /** 閿欒鐮� */ + errorCode?: string; /** 鏁版嵁 */ data?: string; /** 鎵ц鎴愬姛 */ success?: boolean; /** 閿欒淇℃伅 */ - errors?: any; + msg?: any; /** 闄勫姞鏁版嵁 */ extras?: any; /** 鏃堕棿鎴� */ @@ -117,12 +219,14 @@ traceId?: string; /** 鐘舵�佺爜 */ code?: number; + /** 閿欒鐮� */ + errorCode?: string; /** 鏁版嵁 */ data?: number; /** 鎵ц鎴愬姛 */ success?: boolean; /** 閿欒淇℃伅 */ - errors?: any; + msg?: any; /** 闄勫姞鏁版嵁 */ extras?: any; /** 鏃堕棿鎴� */ @@ -134,12 +238,14 @@ traceId?: string; /** 鐘舵�佺爜 */ code?: number; + /** 閿欒鐮� */ + errorCode?: string; /** 鏁版嵁 */ data?: GetMenusQueryResultItem[]; /** 鎵ц鎴愬姛 */ success?: boolean; /** 閿欒淇℃伅 */ - errors?: any; + msg?: any; /** 闄勫姞鏁版嵁 */ extras?: any; /** 鏃堕棿鎴� */ @@ -151,12 +257,14 @@ traceId?: string; /** 鐘舵�佺爜 */ code?: number; + /** 閿欒鐮� */ + errorCode?: string; /** 鏁版嵁 */ data?: GetResourceFieldsQueryResultItem[]; /** 鎵ц鎴愬姛 */ success?: boolean; /** 閿欒淇℃伅 */ - errors?: any; + msg?: any; /** 闄勫姞鏁版嵁 */ extras?: any; /** 鏃堕棿鎴� */ @@ -168,12 +276,32 @@ traceId?: string; /** 鐘舵�佺爜 */ code?: number; + /** 閿欒鐮� */ + errorCode?: string; /** 鏁版嵁 */ data?: GetResourcesQueryResultItem[]; /** 鎵ц鎴愬姛 */ success?: boolean; /** 閿欒淇℃伅 */ - errors?: any; + msg?: any; + /** 闄勫姞鏁版嵁 */ + extras?: any; + /** 鏃堕棿鎴� */ + timestamp?: number; + } + + interface FriendlyResultPagedListQueryResultGetRolesQueryResultItem { + /** 璺熻釜Id */ + traceId?: string; + /** 鐘舵�佺爜 */ + code?: number; + /** 閿欒鐮� */ + errorCode?: string; + data?: PagedListQueryResultGetRolesQueryResultItem; + /** 鎵ц鎴愬姛 */ + success?: boolean; + /** 閿欒淇℃伅 */ + msg?: any; /** 闄勫姞鏁版嵁 */ extras?: any; /** 鏃堕棿鎴� */ @@ -185,15 +313,27 @@ traceId?: string; /** 鐘舵�佺爜 */ code?: number; + /** 閿欒鐮� */ + errorCode?: string; data?: PasswordLoginCommandCallback; /** 鎵ц鎴愬姛 */ success?: boolean; /** 閿欒淇℃伅 */ - errors?: any; + msg?: any; /** 闄勫姞鏁版嵁 */ extras?: any; /** 鏃堕棿鎴� */ timestamp?: number; + } + + type GetAliyunOSSAcsQuery = Record<string, any>; + + interface GetAliyunOSSAcsQueryResult { + expiration?: string; + ossAccessSecret?: string; + ossAccessKeyId?: string; + securityToken?: string; + requestId?: string; } interface GetDictionaryDatasQuery { @@ -206,16 +346,13 @@ data?: GetDictionaryDatasQueryResultItem[]; } - type GetDictionaryDatasQueryResultItem = true; - - interface GetMenuQuery { - /** Id */ - id?: string; - } + type GetDictionaryDatasQueryResultItem = Record<string, any>; interface GetMenuQueryResult { /** Id */ id?: string; + /** 鏄惁閫夋嫨锛堢敤鎴疯鑹叉巿鏉冿級 */ + isChecked?: boolean; userType?: EnumUserType; clientType?: EnumClientType; /** 涓婄骇Id */ @@ -247,6 +384,8 @@ interface GetMenuQueryResultButton { /** Id */ id?: string; + /** 鏄惁閫夋嫨锛堢敤鎴疯鑹叉巿鏉冿級 */ + isChecked?: boolean; /** 缂栧彿 */ code?: string; /** 鍚嶇О */ @@ -271,6 +410,8 @@ interface GetMenuQueryResultField { /** Id */ id?: string; + /** 鏄惁閫夋嫨锛堢敤鎴疯鑹叉巿鏉冿級 */ + isChecked?: boolean; /** 缂栧彿 */ code?: string; /** 鍚嶇О */ @@ -292,18 +433,15 @@ fields?: GetMenuQueryResultField[]; } - interface GetMenusQuery { - userType?: EnumUserType; - clientType?: EnumClientType; - } - interface GetMenusQueryResultItem { /** Id */ id?: string; + /** 鏄惁閫夋嫨锛堢敤鎴疯鑹叉巿鏉冿級 */ + isChecked?: boolean; /** 涓婄骇Id */ parentId?: string; /** 涓嬬骇 */ - childrens?: GetMenusQueryResultItem[]; + children?: GetMenusQueryResultItem[]; /** 缂栧彿 */ code?: string; /** 鍚嶇О */ @@ -326,11 +464,6 @@ remark?: string; } - interface GetResourceFieldsQuery { - /** Id */ - id?: string; - } - interface GetResourceFieldsQueryResultItem { /** 缂栧彿 */ code?: string; @@ -338,17 +471,11 @@ name?: string; } - interface GetResourcesQuery { - /** 寰湇鍔� */ - service?: string; - method?: EnumWebApiMethod; - /** 鍏抽敭瀛� */ - keywords?: string; - } - interface GetResourcesQueryResultItem { /** Id */ id?: string; + /** 鏄惁閫変腑锛堢敤浜庤鑹叉巿鏉冿級 */ + isChecked?: boolean; /** 寰湇鍔� */ service?: string; /** 缂栧彿 */ @@ -364,6 +491,44 @@ responseTypeName?: string; } + interface GetRoleQueryResult { + /** Id */ + id?: string; + /** 鍚嶇О */ + name?: string; + userType?: EnumUserType; + clientType?: EnumClientType; + /** 鏈�浣庣骇鍒� */ + minLevel?: number; + /** 鑿滃崟Id */ + menuIds?: string[]; + /** 璧勬簮 */ + resources?: GetRoleQueryResultResource[]; + } + + interface GetRoleQueryResultResource { + /** 璧勬簮Id */ + resourceId?: string; + dataPower?: EnumRoleWebApiDataPower; + } + + interface GetRolesQuery { + pageModel?: PagedListQueryPageModel; + userType?: EnumUserType; + clientType?: EnumClientType; + } + + interface GetRolesQueryResultItem { + /** Id */ + id?: string; + /** 鍚嶇О */ + name?: string; + userType?: EnumUserType; + clientType?: EnumClientType; + /** 鏈�浣庣骇鍒� */ + minLevel?: number; + } + interface PagedListQueryPageModel { /** 琛屾暟 */ rows?: number; @@ -377,6 +542,12 @@ /** 灞炴�� */ property?: string; order?: EnumPagedListOrder; + } + + interface PagedListQueryResultGetRolesQueryResultItem { + pageModel?: PagedListQueryResultPageModel; + /** 鏁版嵁 */ + data?: GetRolesQueryResultItem[]; } interface PagedListQueryResultPageModel { @@ -484,4 +655,19 @@ /** 瀛楁 */ fields?: SaveMenuCommandField[]; } + + interface SaveRoleCommand { + /** Id */ + id?: string; + /** 鍚嶇О */ + name?: string; + userType?: EnumUserType; + clientType?: EnumClientType; + /** 鏈�浣庣骇鍒� */ + minLevel?: number; + /** 鑿滃崟Id */ + menuIds?: string[]; + /** 璧勬簮 */ + resources?: GetRoleQueryResultResource[]; + } } diff --git a/src/store/modules/permission.ts b/src/store/modules/permission.ts index 6aa2a72..fa8e73a 100644 --- a/src/store/modules/permission.ts +++ b/src/store/modules/permission.ts @@ -3,6 +3,7 @@ // import { RouteConfigs } from "@/layout/types"; import { constantRoutes, Route } from '@/router'; import { addAsyncRoutes, ascending } from '@/router/utils'; +import * as menuServices from '@/services/api/menu'; export interface PermissonState { routes: Route[]; @@ -26,11 +27,16 @@ getModuleList() { return new Promise<Route[]>(async (resolve, reject) => { try { - // const res = await baseModuleServices.getCurrentUserModuleList({ - // showLoading: false, - // }); - const res = []; - const accessedRoutes = ascending(addAsyncRoutes(formatModuleList(res, null))); // createAccessedRoutes(userMenuList, userInfo) + const res = await menuServices.getMenus( + { + userType: EnumUserType.Operation, + clientType: EnumClientType.PcWeb, + }, + { + showLoading: false, + } + ); + const accessedRoutes = ascending(addAsyncRoutes(formatModuleList(res))); // createAccessedRoutes(userMenuList, userInfo) //@ts-ignore accessedRoutes.push({ path: '/:pathMatch(.*)*', redirect: '/404', hidden: true }); @@ -55,47 +61,41 @@ return usePermissionStore(store); } -function formatModuleList(moduleList: API.ModuleDto[], parentId: string | null) { - const treeModuleList: Route[] = []; - if (moduleList.length > 0) { - moduleList.forEach((item) => { - if (item.parentId === parentId) { - const isRootModule = !item.parentId && item.isMenu === 1; - //@ts-ignore - const asyncRoute: Route = isRootModule - ? { - path: formatPath(item.path), - name: item.enCode, - redirect: 'noRedirect', - alwaysShow: true, - hidden: item.isMenu !== 1, - meta: { - title: item.name, - icon: item.icon, - moduleId: item.id, - rank: item?.sortCode, - rootMenu: true, - }, - } - : { - path: formatPath(item.path), - name: item.enCode, - hidden: item.isMenu !== 1, - alwaysShow: true, - meta: { - title: item.name, - moduleId: item.id, - noCache: !item.isCache, - rank: item?.sortCode, - }, - }; - const children = formatModuleList(moduleList, item.id); - asyncRoute.children = children; - treeModuleList.push(asyncRoute); - } - }); - } - return treeModuleList; +function formatModuleList(moduleList: API.GetMenusQueryResultItem[]) { + return moduleList.map((item) => { + const isRootModule = !item.parentId && item.type == EnumMenuType.Menu; + //@ts-ignore + let asyncRoute: Route = isRootModule + ? { + path: formatPath(item.url), + name: item.code, + redirect: 'noRedirect', + alwaysShow: true, + hidden: item.type != EnumMenuType.Menu, + meta: { + title: item.name, + icon: item.icon, + moduleId: item.id, + rank: item?.sort, + rootMenu: true, + }, + } + : { + path: formatPath(item.url), + name: item.code, + hidden: item.type != EnumMenuType.Menu, + alwaysShow: true, + meta: { + title: item.name, + moduleId: item.id, + noCache: !item.isCache, + rank: item?.sort, + }, + }; + const children = formatModuleList(item.children); + asyncRoute.children = children; + return asyncRoute; + }); } function formatPath(path: string) { diff --git a/src/store/modules/user.ts b/src/store/modules/user.ts index 40aa7bf..85c8aae 100644 --- a/src/store/modules/user.ts +++ b/src/store/modules/user.ts @@ -58,7 +58,7 @@ // 鐢ㄦ埛鐧诲叆 async loginByUsername(params: API.PasswordLoginCommand) { - let res = await authServices.authPasswordLogin( + let res = await authServices.passwordLogin( { ...params, password: md5Encrypt(params.password), @@ -107,7 +107,7 @@ Object.assign(this, getDefaultState()); }, - async refreshToken(params: API.AccessRefreshToken) { + async refreshToken(params: any) { return Promise.resolve({ accessToken: '1222', expiresIn: 1000 * 60 * 24 * 60, diff --git a/src/utils/module/index.ts b/src/utils/module/index.ts index 17586a4..03f682d 100644 --- a/src/utils/module/index.ts +++ b/src/utils/module/index.ts @@ -3,13 +3,14 @@ export * from './tree'; -export type TreeModuleDtoGroupDto = API.ModuleDto & { +export type TreeModuleDtoGroupDto = API.GetMenusQueryResultItem & { children?: TreeModuleDtoGroupDto[]; parentNode?: TreeModuleDtoGroupDto; + hasCheck?: boolean; }; export class ModuleUtils { - static convertToModuleGroup(data: API.ModuleDto[]) { + static convertToModuleGroup(data: API.GetMenusQueryResultItem[]) { const moduleTreeStore = new TreeStore<TreeModuleDtoGroupDto>({ data: TreeStore.formatListToTree(data, null), }); @@ -59,7 +60,7 @@ if (module) { const moduleTreeNode = moduleTreeStore.getNode(module.id); const siblingsNodes = moduleTreeNode.parent.childNodes; - return siblingsNodes[siblingsNodes.length - 1].data.sortCode; + return siblingsNodes[siblingsNodes.length - 1].data.sort; } else { return moduleTreeStore.root.childNodes.length; } @@ -72,7 +73,7 @@ const moduleTreeNode = moduleTreeStore.getNode(module.id); const childNodes = moduleTreeNode.childNodes; const lastChildNode = childNodes[childNodes.length - 1]; - return lastChildNode ? lastChildNode.data.sortCode : 0; + return lastChildNode ? lastChildNode.data.sort : 0; } static getParentModule( diff --git a/src/utils/oss/index.ts b/src/utils/oss/index.ts index eb13a61..76efceb 100644 --- a/src/utils/oss/index.ts +++ b/src/utils/oss/index.ts @@ -1,15 +1,18 @@ import { BoleOss } from '@bole-core/core'; import { loadEnv } from '@build/index'; import AliOSS from 'ali-oss'; +import * as authServices from '@/services/api/auth'; export class OssManager { private static OssInstance: BoleOss; private static async getOssSTS() { - return Promise.resolve({}); - // return await accountServices.getOssSTS({ - // showLoading: false, - // }); + return await authServices.getAliyunOSSAcs( + {}, + { + showLoading: false, + } + ); } public static async getOssInstance() { diff --git a/src/utils/request/index.ts b/src/utils/request/index.ts index 6cca864..16e6e6e 100644 --- a/src/utils/request/index.ts +++ b/src/utils/request/index.ts @@ -14,7 +14,7 @@ const RefreshTokenUrl = '/GetTokenByRefreshToken'; /** 璇锋眰鐧藉悕鍗曪紝鏀剧疆涓�浜涗笉闇�瑕乼oken鐨勬帴鍙o紙閫氳繃璁剧疆璇锋眰鐧藉悕鍗曪紝闃叉token杩囨湡鍚庡啀璇锋眰閫犳垚鐨勬寰幆闂锛� */ -const whiteList = [RefreshTokenUrl, '/GetToken']; +const whiteList = [RefreshTokenUrl, '/passwordLogin']; let loadingInstance: ReturnType<typeof Loading.service>; @@ -55,9 +55,13 @@ success: boolean; data: any; /** + * http鐘舵�佸悧 + */ + code?: number; + /** * 閿欒鐮� */ - error?: number; + errorCode?: string; /** * 閿欒淇℃伅 */ @@ -74,7 +78,7 @@ } interface ErrorInfo { - errorCode?: number; + errorCode?: string; errorMessage?: string; showType?: ErrorShowType; data: any; @@ -156,7 +160,7 @@ // 閿欒鎶涘嚭 errorThrower: (res) => { - const { success, data, error: errorCode, msg, showType } = res; + const { success, data, errorCode, msg, showType } = res; if (!success) { const error: any = new Error(msg); error.name = 'BizError'; @@ -236,7 +240,7 @@ endLoading(); - return getResponse ? response : (response.data as any).result; + return getResponse ? response : response.data.data; }, (error) => { endLoading(); diff --git a/src/views/CPersonManage/components/CPersonDetailDialog.vue b/src/views/CPersonManage/components/CPersonDetailDialog.vue index 45a2fe2..e1e3b09 100644 --- a/src/views/CPersonManage/components/CPersonDetailDialog.vue +++ b/src/views/CPersonManage/components/CPersonDetailDialog.vue @@ -56,6 +56,7 @@ ProFormImageUpload, ProFormRadio, ProFormInputNumber, + defineColumns, } from '@bole-core/components'; import { OrderInputType } from '@bole-core/core'; import _ from 'lodash'; @@ -90,7 +91,7 @@ (e: 'onCancel'): void; }>(); -const column: API.CustomModuleColumnDto[] = [ +const column = defineColumns([ { id: '1', enCode: 'enterpirseName', @@ -131,7 +132,7 @@ enCode: 'contractUrl', name: '鐢靛瓙鍚堝悓', }, -]; +]); watch( () => visible.value, diff --git a/src/views/System/ModuleManage.vue b/src/views/System/ModuleManage.vue index 9aa4d8c..40f8562 100644 --- a/src/views/System/ModuleManage.vue +++ b/src/views/System/ModuleManage.vue @@ -6,7 +6,7 @@ <div class="query-filter-list-item"> <SearchInput v-model="state.searchValue" - placeholder="瑙掕壊鍚嶇О" + placeholder="鑿滃崟鍚嶇О" @on-click-search="handleSearch" @keyup.enter="handleSearch()" > @@ -45,18 +45,18 @@ </template> <template v-else-if="column.property === 'isMenu'"> <el-switch - v-model="row.isMenu" + :modelValue="row.type === EnumMenuType.Menu" + :onUpdate:modelValue="(v: boolean) =>{ + row.type=v?EnumMenuType.Menu:EnumMenuType.Page + }" inline-prompt - :active-value="1" - :inactive-value="0" @change="(v: number) => handleChangeStatus(v, row, 'isMenu')" ></el-switch> </template> <template v-else-if="column.property === 'enabledMark'"> <el-switch - v-model="row.enabledMark" - :active-value="1" - :inactive-value="0" + :modelValue="!row.isDisabled" + :onUpdate:modelValue="(v: boolean) => row.isDisabled =!v" @change="(v: number) => handleChangeStatus(v, row, 'enabledMark')" ></el-switch> </template> @@ -95,14 +95,22 @@ OperationBtnType, SearchInput, } from '@bole-core/components'; -import { ModuleUtils, TreeModuleDtoGroupDto, Message, TreeStore } from '@/utils'; +import { ModuleUtils, TreeModuleDtoGroupDto, Message, TreeStore, flattenTree } from '@/utils'; import { TableInstance } from 'element-plus'; -import { SubModuleType, SubModuleTitle, SubModuleKey, FastBtn, ModuleColumns } from '@/constants'; +import { + SubModuleType, + SubModuleTitle, + SubModuleKey, + FastBtn, + ModuleColumns, + EnumMenuType, +} from '@/constants'; import SubModuleEditDrawer from './components/SubModuleEditDrawer.vue'; import AddOrEditModuleDialog from './components/AddOrEditModuleDialog.vue'; import { useDebounceFn } from '@vueuse/core'; import _ from 'lodash'; import { useReset } from '@bole-core/core'; +import * as menuServices from '@/services/api/menu'; defineOptions({ name: 'ModuleManage', @@ -189,8 +197,8 @@ sortCode: 0, path: '', isCache: true, - isMenu: 1, - enabledMark: 1, + isMenu: true, + enabledMark: true, showCacheSelect: false, showIconSelect: false, showSubMenuIconSelect: false, @@ -198,10 +206,10 @@ title: '', }; const editForm = reactive({ ...BaseFormData }); -const currentDialogModule = ref<TreeModuleDtoGroupDto>({}); +const currentDialogModule = ref<API.GetMenuQueryResult>({}); //drawer const drawerVisible = ref(false); -const currentDrawerModule = ref<TreeModuleDtoGroupDto>({}); +const currentDrawerModule = ref<API.GetMenuQueryResult>({}); const drawerState = reactive<{ type: SubModuleType; tableData: ValueOf<API.AllSubModule>; @@ -215,10 +223,16 @@ }); async function getAllModule() { try { - let res = await baseModuleServices.getAllModuleList({ - showLoading: !state.loading, - }); - const treeStore = ModuleUtils.convertToModuleGroup(res); + let res = await menuServices.getMenus( + { + userType: EnumUserType.Operation, + clientType: EnumClientType.PcWeb, + }, + { + showLoading: false, + } + ); + const treeStore = ModuleUtils.convertToModuleGroup(flattenTree(res)); moduleTreeStore.value = treeStore; originModuleTree.value = [...treeStore.data]; } catch (error) {} @@ -234,16 +248,21 @@ statusType: T ) { try { - let params = { - ..._.omit(data, ['children', 'parentNode']), - [statusType]: value, - }; - await baseModuleServices.addOrEditModule(params); + // let params = { + // ..._.omit(data, ['children', 'parentNode']), + // [statusType]: value, + // }; + // await baseModuleServices.addOrEditModule(params); } catch (error) { Message.errorMessage('鎿嶄綔澶辫触'); } } -function openDialog(options: { + +async function getMenu(id: string) { + return await menuServices.getMenu({ id: id }); +} + +async function openDialog(options: { module?: TreeModuleDtoGroupDto; showCacheSelect: boolean; showIconSelect: boolean; @@ -252,46 +271,48 @@ parentId: string; baseSortCode?: number; }) { - const { - module, - showCacheSelect, - showIconSelect, - showSubMenuIconSelect, - showParentSelect, - parentId, - baseSortCode, - } = options; - if (module) { - currentDialogModule.value = module; - useSetReactive(editForm, { - title: `${module.name}缂栬緫`, - enCode: module.enCode, - name: module.name, - icon: module.icon, - sortCode: module.sortCode, - path: module.path, - isMenu: module.isMenu, - enabledMark: module.enabledMark, - parentId: parentId, + try { + const { + module, showCacheSelect, showIconSelect, showSubMenuIconSelect, showParentSelect, - isCache: module.isCache, - }); - } else { - currentDialogModule.value = {}; - useSetReactive(editForm, BaseFormData, { - title: '鏂板鍔熻兘妯″潡', - parentId: parentId, - showCacheSelect, - showIconSelect, - showSubMenuIconSelect, - showParentSelect, - sortCode: baseSortCode, - }); - } - editDialogFormVisible.value = true; + parentId, + baseSortCode, + } = options; + if (module) { + currentDialogModule.value = await getMenu(module.id); + useSetReactive(editForm, { + title: `${module.name}缂栬緫`, + enCode: module.code, + name: module.name, + icon: module.icon, + sortCode: module.sort, + path: module.url, + isMenu: module.type == EnumMenuType.Menu, + enabledMark: !module.isDisabled, + parentId: parentId, + showCacheSelect, + showIconSelect, + showSubMenuIconSelect, + showParentSelect, + isCache: module.isCache, + }); + } else { + currentDialogModule.value = {}; + useSetReactive(editForm, BaseFormData, { + title: '鏂板鍔熻兘妯″潡', + parentId: parentId, + showCacheSelect, + showIconSelect, + showSubMenuIconSelect, + showParentSelect, + sortCode: baseSortCode, + }); + } + editDialogFormVisible.value = true; + } catch (error) {} } function handleAddOrEditRootModule(module?: TreeModuleDtoGroupDto) { const showCacheSelect = false; @@ -341,16 +362,17 @@ } async function handleAddOrEditModule() { try { - let params: API.ModuleDto = { - enCode: editForm.enCode, + let params: API.SaveMenuCommand = { + userType: EnumUserType.Operation, + clientType: EnumClientType.PcWeb, + code: editForm.enCode, name: editForm.name, - sortCode: editForm.sortCode, - path: editForm.path, - // isCache: true, - isMenu: editForm.isMenu, - enabledMark: editForm.enabledMark, + type: editForm.isMenu ? EnumMenuType.Menu : EnumMenuType.Page, + visitLevel: EnumMenuVisitLevel.NeedPower, icon: editForm.icon, - // parentId:, + url: editForm.path, + isDisabled: !editForm.enabledMark, + sort: editForm.sortCode, }; if (editForm.showCacheSelect) { params.isCache = editForm.isCache; @@ -360,8 +382,9 @@ } if (currentDialogModule.value.id) { params.id = currentDialogModule.value.id; + params.groups = currentDialogModule.value.groups; } - const res = await baseModuleServices.addOrEditModule(params); + const res = await saveMenu(params); if (res) { Message.successMessage('淇濆瓨鎴愬姛'); getAllModule(); @@ -370,28 +393,46 @@ } catch (e) {} } +async function saveMenu(params: API.SaveMenuCommand) { + try { + const res = await menuServices.saveMenu(params); + if (res) { + Message.successMessage('淇濆瓨鎴愬姛'); + getAllModule(); + editDialogFormVisible.value = false; + return res; + } + } catch (error) {} +} + async function handleDelete(module: TreeModuleDtoGroupDto) { try { await Message.deleteMessage(); - const res = await baseModuleServices.deleteModule({ id: module.id }); + const res = await menuServices.deleteMenu({ ids: [module.id] }); if (res) { Message.successMessage('鍒犻櫎鎴愬姛'); getAllModule(); } } catch (error) {} } -function openDrawer(module: TreeModuleDtoGroupDto, type: SubModuleType) { - drawerState.type = type; - currentDrawerModule.value = module; - getBaseModuleGetAllSubModule(module, type); +async function openDrawer(module: TreeModuleDtoGroupDto, type: SubModuleType) { + try { + drawerState.type = type; + currentDrawerModule.value = await getMenu(module.id); + await nextTick(); + getBaseModuleGetAllSubModule(module, type); + } catch (error) {} } async function getBaseModuleGetAllSubModule(module: TreeModuleDtoGroupDto, type: SubModuleType) { try { - let params = { - moduleId: module.id, - }; - const res = await baseModuleServices.getAllSubModule(params); - drawerState.tableData = res[SubModuleKey[type]]; + const defaultGroup = currentDrawerModule.value.groups.find((g) => g.group === 'default'); + if (type === SubModuleType.Column) { + drawerState.tableData = defaultGroup.fields; + } else { + drawerState.tableData = defaultGroup.buttonLocations.find( + (b) => b.location === SubModuleKey[type] + ); + } drawerVisible.value = true; } catch (error) {} } @@ -411,7 +452,7 @@ } function getDefaultSortCode() { return drawerState.tableData.length > 0 - ? drawerState.tableData[drawerState.tableData.length - 1].sortCode + 1 + ? drawerState.tableData[drawerState.tableData.length - 1].sort + 1 : 0; } function handleBatchAddColumn(keys: string[]) { diff --git a/src/views/System/components/AddOrEditModuleDialog.vue b/src/views/System/components/AddOrEditModuleDialog.vue index 0714c25..5d8d01a 100644 --- a/src/views/System/components/AddOrEditModuleDialog.vue +++ b/src/views/System/components/AddOrEditModuleDialog.vue @@ -57,10 +57,10 @@ <el-switch v-model="editForm.isCache" /> </el-form-item> <el-form-item label="鑿滃崟" prop="isMenu"> - <el-switch :active-value="1" :inactive-value="0" v-model="editForm.isMenu" /> + <el-switch v-model="editForm.isMenu" /> </el-form-item> <el-form-item label="鏈夋晥" prop="enabledMark"> - <el-switch :active-value="1" :inactive-value="0" v-model="editForm.enabledMark" /> + <el-switch v-model="editForm.enabledMark" /> </el-form-item> </el-form> <template #footer> @@ -93,8 +93,8 @@ sortCode: number; path: string; isCache: boolean; - isMenu: number; - enabledMark: number; + isMenu: boolean; + enabledMark: boolean; showCacheSelect: boolean; showIconSelect: boolean; showSubMenuIconSelect: boolean; diff --git a/types/api.d.ts b/types/api.d.ts index a095b00..1061075 100644 --- a/types/api.d.ts +++ b/types/api.d.ts @@ -14,38 +14,5 @@ customErrorHandler?: (error: any) => boolean; } - interface ModuleButtonDto { - isEdit?: boolean; - } - interface ModuleColumnDto { - isEdit?: boolean; - fixed?: boolean | 'left' | 'right'; - needTips?: boolean; - } - - interface CustomModuleColumnDto extends ModuleColumnDto { - id: string; - enCode: string; - name: string; - } - - interface DepartmentTree { - leaf?: boolean; - } - interface StationTree { - leaf?: boolean; - } - - interface RoleList { - //鏄惁鏄鎴风 - isClient?: boolean; - } - - interface AreaTreeNode extends AreaDto { - children?: AreaTreeNode[]; - } - interface GetSearchSettingList { - children?: GetSearchSettingList[]; - } } diff --git a/vite.config.ts b/vite.config.ts index e6d3e8c..a3c29ca 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -56,7 +56,9 @@ // 鏈嶅姟绔覆鏌� server: { // 鏄惁寮�鍚� https - // https: false, + // https: { + + // }, // 绔彛鍙� port: VITE_PORT, host: '0.0.0.0', -- Gitblit v1.9.1