diff --git a/frontend/src/api/modules/project-management/menuManagement.ts b/frontend/src/api/modules/project-management/menuManagement.ts new file mode 100644 index 0000000000..4320a45b1f --- /dev/null +++ b/frontend/src/api/modules/project-management/menuManagement.ts @@ -0,0 +1,60 @@ +import MSR from '@/api/http/index'; +import * as Url from '@/api/requrls/project-management/menuManagement'; +import type { MenuTableListItem, MenuTableListParams } from '@/models/projectManagement/menuManagement'; +import { MenuEnum } from '@/enums/commonEnum'; + +import { TableQueryParams, CommonList } from '@/models/common'; + +const tableList: MenuTableListItem[] = [ + 'workstation', + 'loadTest', + 'testPlan', + 'bugManagement', + 'caseManagement', + 'apiTest', + 'uiTest', +].map((item, index) => { + return { module: item, moduleEnable: index % 2 === 0 }; +}); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +export function postTabletList(data: TableQueryParams) { + // return MSR.post>({ url: Url.getMenuListUrl, data }); + const result: CommonList = { + list: tableList, + total: tableList.length, + pageSize: 10, + current: 1, + }; + return Promise.resolve(result); +} + +export function postUpdateMenu(data: MenuTableListParams) { + let suffix = ''; + switch (data.type) { + case MenuEnum.workstation: + suffix = 'workstation'; + break; + case MenuEnum.testPlan: + suffix = 'test-plan'; + break; + case MenuEnum.bugManagement: + suffix = 'issue'; + break; + case MenuEnum.caseManagement: + suffix = 'case'; + break; + case MenuEnum.apiTest: + suffix = 'api'; + break; + case MenuEnum.uiTest: + suffix = 'uiTest'; + break; + default: + suffix = 'performance-test'; + break; + } + return MSR.post({ url: `${Url.updateConfigByMenuTypeUrl}${suffix}`, data }); +} + +export default {}; diff --git a/frontend/src/api/requrls/project-management/menuManagement.ts b/frontend/src/api/requrls/project-management/menuManagement.ts new file mode 100644 index 0000000000..98283f9d11 --- /dev/null +++ b/frontend/src/api/requrls/project-management/menuManagement.ts @@ -0,0 +1,4 @@ +export const getConfigByMenuTypeUrl = '/project/application/'; +export const updateConfigByMenuTypeUrl = '/project/application/update/'; +// 获取表格最外层的数据 +export const getMenuListUrl = '/project/application/module-setting/'; diff --git a/frontend/src/components/pure/ms-table/base-table.vue b/frontend/src/components/pure/ms-table/base-table.vue index efb0232d41..30e5e3f879 100644 --- a/frontend/src/components/pure/ms-table/base-table.vue +++ b/frontend/src/components/pure/ms-table/base-table.vue @@ -143,6 +143,10 @@ +
{ rowKey: string; // 表格行的key rowId // 表格列 - 详见 TableColumn https://arco.design/web-vue/components/table-column; columns: MsTableColumnData[]; + showPagination?: boolean; // 是否显示分页 size?: 'mini' | 'small' | 'default' | 'large'; // 表格尺寸 scroll?: { x?: number | string; diff --git a/frontend/src/components/pure/ms-table/useTable.ts b/frontend/src/components/pure/ms-table/useTable.ts index 23971af5ad..6ab3879308 100644 --- a/frontend/src/components/pure/ms-table/useTable.ts +++ b/frontend/src/components/pure/ms-table/useTable.ts @@ -8,6 +8,7 @@ import type { TableData } from '@arco-design/web-vue'; import type { TableQueryParams, CommonList } from '@/models/common'; import { SelectAllEnum } from '@/enums/tableEnum'; import type { MsTableProps, MsTableDataItem, MsTableColumn, MsTableErrorStatus, SetPaginationPrams } from './type'; +import { set } from 'nprogress'; export interface Pagination { current: number; @@ -151,52 +152,82 @@ export default function useTableProps( // 加载分页列表数据 const loadList = async () => { - const { current, pageSize } = propsRes.value.msPagination as Pagination; - const { rowKey, selectorStatus, excludeKeys } = propsRes.value; - setLoading(true); - try { - const data = await loadListFunc({ - current, - pageSize, - sort: sortItem.value, - filter: filterItem.value, - keyword: keyword.value, - ...loadListParams.value, - }); - const tmpArr = data.list; - (propsRes.value.data as MsTableDataItem[]) = tmpArr.map((item) => { - if (item.updateTime) { - item.updateTime = dayjs(item.updateTime).format('YYYY-MM-DD HH:mm:ss'); - } - if (item.createTime) { - item.createTime = dayjs(item.createTime).format('YYYY-MM-DD HH:mm:ss'); - } - if (dataTransform) { - item = dataTransform(item); - } - if (selectorStatus === SelectAllEnum.ALL) { - if (!excludeKeys.has(item[rowKey])) { - setTableSelected(item[rowKey]); + if (propsRes.value.showPagination) { + const { current, pageSize } = propsRes.value.msPagination as Pagination; + const { rowKey, selectorStatus, excludeKeys } = propsRes.value; + try { + setLoading(true); + const data = await loadListFunc({ + current, + pageSize, + sort: sortItem.value, + filter: filterItem.value, + keyword: keyword.value, + ...loadListParams.value, + }); + const tmpArr = data.list; + (propsRes.value.data as MsTableDataItem[]) = tmpArr.map((item) => { + if (item.updateTime) { + item.updateTime = dayjs(item.updateTime).format('YYYY-MM-DD HH:mm:ss'); } + if (item.createTime) { + item.createTime = dayjs(item.createTime).format('YYYY-MM-DD HH:mm:ss'); + } + if (dataTransform) { + item = dataTransform(item); + } + if (selectorStatus === SelectAllEnum.ALL) { + if (!excludeKeys.has(item[rowKey])) { + setTableSelected(item[rowKey]); + } + } + return item; + }); + if (data.total === 0) { + setTableErrorStatus('empty'); + } else { + setTableErrorStatus(false); + } + setPagination({ current: data.current, total: data.total }); + return data; + } catch (err) { + setTableErrorStatus('error'); + } finally { + setLoading(false); + // debug 模式下打印属性 + if (propsRes.value.debug && import.meta.env.DEV) { + // eslint-disable-next-line no-console + // console.log('Table propsRes: ', propsRes.value); } - - return item; - }); - if (data.total === 0) { - setTableErrorStatus('empty'); - } else { - setTableErrorStatus(false); } - setPagination({ current: data.current, total: data.total }); - return data; - } catch (err) { - setTableErrorStatus('error'); - } finally { - setLoading(false); - // debug 模式下打印属性 - if (propsRes.value.debug && import.meta.env.DEV) { - // eslint-disable-next-line no-console - // console.log('Table propsRes: ', propsRes.value); + } else { + // 没分页的情况下,直接调用loadListFunc + try { + setLoading(true); + const data = await loadListFunc({ keyword: keyword.value, ...loadListParams.value }); + if (data.total === 0) { + setTableErrorStatus('empty'); + return; + } + setTableErrorStatus(false); + const tmpArr = data.list; + (propsRes.value.data as MsTableDataItem[]) = tmpArr.map((item) => { + if (item.updateTime) { + item.updateTime = dayjs(item.updateTime).format('YYYY-MM-DD HH:mm:ss'); + } + if (item.createTime) { + item.createTime = dayjs(item.createTime).format('YYYY-MM-DD HH:mm:ss'); + } + if (dataTransform) { + item = dataTransform(item); + } + return item; + }); + return data; + } catch (err) { + setTableErrorStatus('error'); + } finally { + setLoading(false); } } }; diff --git a/frontend/src/enums/commonEnum.ts b/frontend/src/enums/commonEnum.ts index ce895f9702..dc39b87026 100644 --- a/frontend/src/enums/commonEnum.ts +++ b/frontend/src/enums/commonEnum.ts @@ -9,4 +9,14 @@ export enum AuthScopeEnum { PROJECT = 'PROJECT', } +export enum MenuEnum { + workstation = 'workstation', + loadTest = 'loadTest', + testPlan = 'testPlan', + bugManagement = 'bugManagement', + caseManagement = 'caseManagement', + apiTest = 'apiTest', + uiTest = 'uiTest', +} + export default {}; diff --git a/frontend/src/models/common.ts b/frontend/src/models/common.ts index bbef7c2a5b..709baafcb3 100644 --- a/frontend/src/models/common.ts +++ b/frontend/src/models/common.ts @@ -9,9 +9,9 @@ export default interface CommonResponse { // 表格查询 export interface TableQueryParams { // 当前页 - current: number; + current?: number; // 每页条数 - pageSize: number; + pageSize?: number; // 排序仅针对单个字段 sort?: object; // 排序仅针对单个字段 diff --git a/frontend/src/models/projectManagement/menuManagement.ts b/frontend/src/models/projectManagement/menuManagement.ts new file mode 100644 index 0000000000..18b3526814 --- /dev/null +++ b/frontend/src/models/projectManagement/menuManagement.ts @@ -0,0 +1,13 @@ +import { MenuEnum } from '@/enums/commonEnum'; + +export interface MenuTableListItem { + module: string; + moduleEnable: boolean; + moduleDesc?: string; +} + +export interface MenuTableListParams { + projectId: string; + type: MenuEnum; + typeValue: boolean; +} diff --git a/frontend/src/views/project-management/projectAndPermission/menuManagement/index.vue b/frontend/src/views/project-management/projectAndPermission/menuManagement/index.vue index 2142131263..caecc4724d 100644 --- a/frontend/src/views/project-management/projectAndPermission/menuManagement/index.vue +++ b/frontend/src/views/project-management/projectAndPermission/menuManagement/index.vue @@ -1,9 +1,110 @@ diff --git a/frontend/src/views/project-management/projectAndPermission/menuManagement/locale/en-US.ts b/frontend/src/views/project-management/projectAndPermission/menuManagement/locale/en-US.ts new file mode 100644 index 0000000000..415a7a0b4f --- /dev/null +++ b/frontend/src/views/project-management/projectAndPermission/menuManagement/locale/en-US.ts @@ -0,0 +1,3 @@ +export default { + 'project.menu.management': 'Add Member', +}; diff --git a/frontend/src/views/project-management/projectAndPermission/menuManagement/locale/zh-CN.ts b/frontend/src/views/project-management/projectAndPermission/menuManagement/locale/zh-CN.ts new file mode 100644 index 0000000000..a1d941d2db --- /dev/null +++ b/frontend/src/views/project-management/projectAndPermission/menuManagement/locale/zh-CN.ts @@ -0,0 +1,7 @@ +export default { + 'project.menu.management': '菜单管理', + 'project.menu.manageTip': + '可根据使用场景配置各功能开关关闭后,将隐藏功能入口,成员无法访问该功能和数据;已产生的数据不够此规则影响;再次开启时,即恢复至关闭前状态', + 'project.menu.name': '菜单名称', + 'project.menu.description': '描述', +}; diff --git a/frontend/src/views/project-management/projectAndPermission/userGroup/projectUserGroup.vue b/frontend/src/views/project-management/projectAndPermission/userGroup/projectUserGroup.vue index 0512a843b3..d5be4c29c0 100644 --- a/frontend/src/views/project-management/projectAndPermission/userGroup/projectUserGroup.vue +++ b/frontend/src/views/project-management/projectAndPermission/userGroup/projectUserGroup.vue @@ -93,6 +93,9 @@