From bdf9fe47ececf4e144a94af6914d013ccee0f315 Mon Sep 17 00:00:00 2001 From: baiqi Date: Thu, 17 Oct 2024 18:05:06 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E4=BB=BB=E5=8A=A1=E4=B8=AD=E5=BF=83):=20?= =?UTF-8?q?=E6=89=A7=E8=A1=8C=E4=BA=A4=E4=BA=92&=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E4=B8=AD=E5=BF=83=E9=83=A8=E5=88=86=E6=93=8D=E4=BD=9C=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E8=81=94=E8=B0=83&=E8=B7=B3=E8=BD=AC=E4=BA=A4?= =?UTF-8?q?=E4=BA=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/api/modules/taskCenter.ts | 61 ++++ frontend/src/api/requrls/taskCenter.ts | 21 +- .../business/ms-rich-message/index.vue | 28 ++ frontend/src/components/pure/navbar/index.vue | 13 + frontend/src/enums/commonEnum.ts | 4 + frontend/src/enums/taskCenter.ts | 15 + frontend/src/locale/en-US/common.ts | 1 + frontend/src/locale/zh-CN/common.ts | 1 + frontend/src/models/taskCenter.ts | 10 +- frontend/src/store/index.ts | 3 +- frontend/src/store/modules/app/types.ts | 6 +- frontend/src/store/modules/global/index.ts | 20 ++ frontend/src/store/modules/global/types.ts | 11 + .../api-test/management/components/import.vue | 144 +------- .../components/importTaskDrawer.vue | 165 ++++++++++ .../src/views/api-test/management/index.vue | 7 + .../views/api-test/management/locale/en-US.ts | 2 + .../views/api-test/management/locale/zh-CN.ts | 2 + .../scenario/components/batchRunModal.vue | 36 +- .../component/batchTaskReportDrawer.vue | 14 +- .../component/caseTaskDetailTable.vue | 83 ++++- .../taskCenter/component/caseTaskTable.vue | 310 +++++++++++------- .../taskCenter/component/executionStatus.vue | 2 +- .../taskCenter/component/systemTaskTable.vue | 39 ++- frontend/src/views/taskCenter/index.vue | 25 +- frontend/src/views/taskCenter/locale/en-US.ts | 4 +- frontend/src/views/taskCenter/locale/zh-CN.ts | 2 + .../testPlan/components/planTable.vue | 190 +++++++---- .../detail/apiCase/components/caseTable.vue | 67 +++- .../apiScenario/components/scenarioTable.vue | 67 +++- 30 files changed, 982 insertions(+), 371 deletions(-) create mode 100644 frontend/src/components/business/ms-rich-message/index.vue create mode 100644 frontend/src/store/modules/global/index.ts create mode 100644 frontend/src/store/modules/global/types.ts create mode 100644 frontend/src/views/api-test/management/components/importTaskDrawer.vue diff --git a/frontend/src/api/modules/taskCenter.ts b/frontend/src/api/modules/taskCenter.ts index 661e34de43..7d7c88add5 100644 --- a/frontend/src/api/modules/taskCenter.ts +++ b/frontend/src/api/modules/taskCenter.ts @@ -1,23 +1,34 @@ import MSR from '@/api/http/index'; import { + organizationDeleteTaskUrl, organizationExecuteTaskDetailListUrl, organizationExecuteTaskListUrl, organizationExecuteTaskStatisticsUrl, organizationScheduleListUrl, + organizationStopTaskUrl, + organizationTaskCenterResourcePoolsUrl, + projectDeleteTaskUrl, projectExecuteTaskDetailListUrl, projectExecuteTaskListUrl, projectExecuteTaskStatisticsUrl, projectScheduleTaskListUrl, + projectStopTaskUrl, + projectTaskCenterResourcePoolsUrl, scheduleProCenterListUrl, + systemDeleteTaskUrl, systemExecuteTaskDetailListUrl, systemExecuteTaskListUrl, systemExecuteTaskStatisticsUrl, + systemResourcePoolStatusUrl, systemScheduleListUrl, + systemStopTaskUrl, + systemTaskCenterResourcePoolsUrl, } from '@/api/requrls/taskCenter'; import type { CommonList, TableQueryParams } from '@/models/common'; import type { TimingTaskCenterApiCaseItem } from '@/models/projectManagement/taskCenter'; import type { + TaskCenterResourcePoolStatus, TaskCenterStatisticsItem, TaskCenterSystemTaskItem, TaskCenterTaskDetailItem, @@ -45,6 +56,21 @@ export function getProjectExecuteTaskStatistics(data: string[]) { return MSR.post({ url: projectExecuteTaskStatisticsUrl, data }); } +// 项目任务-获取资源池列表 +export function getProjectTaskCenterResourcePools() { + return MSR.get({ url: projectTaskCenterResourcePoolsUrl }); +} + +// 项目任务-停止任务 +export function projectStopTask(id: string) { + return MSR.get({ url: `${projectStopTaskUrl}/${id}` }); +} + +// 项目任务-删除任务 +export function projectDeleteTask(id: string) { + return MSR.get({ url: `${projectDeleteTaskUrl}/${id}` }); +} + // 接口测试-定时任务列表 export function getScheduleProApiCaseList(data: TableQueryParams) { return MSR.post>({ url: scheduleProCenterListUrl, data }); @@ -70,6 +96,26 @@ export function getSystemExecuteTaskStatistics(data: string[]) { return MSR.post({ url: systemExecuteTaskStatisticsUrl, data }); } +// 系统任务-获取资源池列表 +export function getSystemTaskCenterResourcePools() { + return MSR.get({ url: systemTaskCenterResourcePoolsUrl }); +} + +// 系统任务-停止任务 +export function systemStopTask(id: string) { + return MSR.get({ url: `${systemStopTaskUrl}/${id}` }); +} + +// 系统任务-删除任务 +export function systemDeleteTask(id: string) { + return MSR.get({ url: `${systemDeleteTaskUrl}/${id}` }); +} + +// 任务中心-资源池状态 +export function getResourcePoolsStatus(data: string[]) { + return MSR.post({ url: systemResourcePoolStatusUrl, data }); +} + // 组织任务-系统后台任务列表 export function getOrganizationScheduleList(data: TableQueryParams) { return MSR.post>({ url: organizationScheduleListUrl, data }); @@ -89,3 +135,18 @@ export function getOrganizationExecuteTaskList(data: TableQueryParams) { export function getOrganizationExecuteTaskStatistics(data: string[]) { return MSR.post({ url: organizationExecuteTaskStatisticsUrl, data }); } + +// 组织任务-获取资源池列表 +export function getOrgTaskCenterResourcePools() { + return MSR.get({ url: organizationTaskCenterResourcePoolsUrl }); +} + +// 组织任务-停止任务 +export function organizationStopTask(id: string) { + return MSR.get({ url: `${organizationStopTaskUrl}/${id}` }); +} + +// 组织任务-删除任务 +export function organizationDeleteTask(id: string) { + return MSR.get({ url: `${organizationDeleteTaskUrl}/${id}` }); +} diff --git a/frontend/src/api/requrls/taskCenter.ts b/frontend/src/api/requrls/taskCenter.ts index 8f33fcd66f..88d6e90854 100644 --- a/frontend/src/api/requrls/taskCenter.ts +++ b/frontend/src/api/requrls/taskCenter.ts @@ -2,15 +2,24 @@ export const projectScheduleTaskListUrl = '/project/task-center/schedule/page'; export const projectExecuteTaskStatisticsUrl = '/project/task-center/exec-task/statistics'; // 项目任务-获取任务统计 export const projectExecuteTaskListUrl = '/project/task-center/exec-task/page'; // 项目任务-任务列表 export const projectExecuteTaskDetailListUrl = '/project/task-center/exec-task/item/page'; // 项目任务-任务详情列表 -// 项目-任务中心-定时任务列表 -export const scheduleProCenterListUrl = '/task/center/project/schedule/page'; +export const scheduleProCenterListUrl = '/task/center/project/schedule/page'; // 项目-任务中心-定时任务列表 +export const projectTaskCenterResourcePoolsUrl = '/project/task-center/resource-pool/options'; // 项目-任务中心-获取资源池列表 +export const projectStopTaskUrl = '/project/task-center/exec-task/stop'; // 项目-任务中心-停止任务 +export const projectDeleteTaskUrl = '/project/task-center/exec-task/delete'; // 项目-任务中心-删除任务 export const systemScheduleListUrl = '/system/task-center/schedule/page'; // 系统任务-系统后台任务列表 export const systemExecuteTaskListUrl = '/system/task-center/exec-task/page'; // 系统任务-执行任务列表 export const systemExecuteTaskDetailListUrl = '/system/task-center/exec-task/item/page'; // 系统任务-执行任务详情列表 export const systemExecuteTaskStatisticsUrl = '/system/task-center/exec-task/statistics'; // 系统任务-获取任务统计 +export const systemTaskCenterResourcePoolsUrl = '/system/task-center/resource-pool/options'; // 系统任务-获取资源池列表 +export const systemStopTaskUrl = '/system/task-center/exec-task/stop'; // 系统任务-停止任务 +export const systemDeleteTaskUrl = '/system/task-center/exec-task/delete'; // 系统任务-删除任务 +export const systemResourcePoolStatusUrl = '/system/task-center/resource-pool/status'; // 系统任务-资源池状态 -export const organizationScheduleListUrl = '/organization/task-center/schedule/page'; // 系统任务-系统后台任务列表 -export const organizationExecuteTaskListUrl = '/organization/task-center/exec-task/page'; // 系统任务-执行任务列表 -export const organizationExecuteTaskDetailListUrl = '/organization/task-center/exec-task/item/page'; // 系统任务-执行任务详情列表 -export const organizationExecuteTaskStatisticsUrl = '/organization/task-center/exec-task/statistics'; // 系统任务-获取任务统计 +export const organizationScheduleListUrl = '/organization/task-center/schedule/page'; // 组织任务-系统后台任务列表 +export const organizationExecuteTaskListUrl = '/organization/task-center/exec-task/page'; // 组织任务-执行任务列表 +export const organizationExecuteTaskDetailListUrl = '/organization/task-center/exec-task/item/page'; // 组织任务-执行任务详情列表 +export const organizationExecuteTaskStatisticsUrl = '/organization/task-center/exec-task/statistics'; // 组织任务-获取任务统计 +export const organizationTaskCenterResourcePoolsUrl = '/organization/task-center/resource-pool/options'; // 组织任务-获取资源池列表 +export const organizationStopTaskUrl = '/organization/task-center/exec-task/stop'; // 组织任务-停止任务 +export const organizationDeleteTaskUrl = '/organization/task-center/exec-task/delete'; // 组织任务-删除任务 diff --git a/frontend/src/components/business/ms-rich-message/index.vue b/frontend/src/components/business/ms-rich-message/index.vue new file mode 100644 index 0000000000..1bf4c6108f --- /dev/null +++ b/frontend/src/components/business/ms-rich-message/index.vue @@ -0,0 +1,28 @@ + + + diff --git a/frontend/src/components/pure/navbar/index.vue b/frontend/src/components/pure/navbar/index.vue index b577e57695..8e61deac6c 100644 --- a/frontend/src/components/pure/navbar/index.vue +++ b/frontend/src/components/pure/navbar/index.vue @@ -193,9 +193,12 @@ import { LOCALE_OPTIONS } from '@/locale'; import useLocale from '@/locale/useLocale'; import useAppStore from '@/store/modules/app'; + import useGlobalStore from '@/store/modules/global'; import useUserStore from '@/store/modules/user'; import { getFirstRouteNameByPermission, hasAnyPermission } from '@/utils/permission'; + import { GlobalEventNameEnum } from '@/enums/commonEnum'; + import { IconInfoCircle } from '@arco-design/web-vue/es/icon'; import type { LocaleType } from '#/global'; @@ -208,6 +211,7 @@ const appStore = useAppStore(); const userStore = useUserStore(); + const globalStore = useGlobalStore(); const route = useRoute(); const router = useRouter(); const { t } = useI18n(); @@ -291,6 +295,15 @@ function goTaskCenter() { taskCenterVisible.value = true; } + watch( + () => globalStore.getGlobalEvent, + (event) => { + if (event && event.id && event.name === GlobalEventNameEnum.OPEN_TASK_CENTER) { + goTaskCenter(); + } + } + ); + function goMessageCenter() { messageCenterVisible.value = true; } diff --git a/frontend/src/enums/commonEnum.ts b/frontend/src/enums/commonEnum.ts index 16f7aa5970..8b9556c5a0 100644 --- a/frontend/src/enums/commonEnum.ts +++ b/frontend/src/enums/commonEnum.ts @@ -40,3 +40,7 @@ export enum TagUpdateTypeEnum { APPEND = 'APPEND', CLEAR = 'CLEAR', } + +export enum GlobalEventNameEnum { + OPEN_TASK_CENTER = 'openTaskCenter', +} diff --git a/frontend/src/enums/taskCenter.ts b/frontend/src/enums/taskCenter.ts index 0d8728ccb3..a129ff0b5d 100644 --- a/frontend/src/enums/taskCenter.ts +++ b/frontend/src/enums/taskCenter.ts @@ -33,3 +33,18 @@ export enum ExecuteResultEnum { ERROR = 'ERROR', FAKE_ERROR = 'FAKE_ERROR', } + +export enum ExecuteTriggerMode { + MANUAL = 'MANUAL', + BATCH = 'BATCH', + API = 'API', + SCHEDULE = 'SCHEDULE', +} + +export enum ExecuteTaskType { + API_IMPORT = 'API_IMPORT', + API_SCENARIO = 'API_SCENARIO', + BUG_SYNC = 'BUG_SYNC', + DEMAND_SYNC = 'DEMAND_SYNC', + TEST_PLAN = 'TEST_PLAN', +} diff --git a/frontend/src/locale/en-US/common.ts b/frontend/src/locale/en-US/common.ts index f71ee99a38..3b6f801d1e 100644 --- a/frontend/src/locale/en-US/common.ts +++ b/frontend/src/locale/en-US/common.ts @@ -216,4 +216,5 @@ export default { 'common.currentUser': 'Current user', 'common.type': 'Type', 'common.batchUpdate': 'Updated to', + 'common.checkDetail': 'View details', }; diff --git a/frontend/src/locale/zh-CN/common.ts b/frontend/src/locale/zh-CN/common.ts index ba8a9ee065..d5f509e033 100644 --- a/frontend/src/locale/zh-CN/common.ts +++ b/frontend/src/locale/zh-CN/common.ts @@ -216,4 +216,5 @@ export default { 'common.currentUser': '当前用户', 'common.type': '类型', 'common.batchUpdate': '更新为', + 'common.checkDetail': '查看详情', }; diff --git a/frontend/src/models/taskCenter.ts b/frontend/src/models/taskCenter.ts index be914047ff..6da743a917 100644 --- a/frontend/src/models/taskCenter.ts +++ b/frontend/src/models/taskCenter.ts @@ -1,3 +1,5 @@ +import type { ExecuteTriggerMode } from '@/enums/taskCenter'; + import type { TableQueryParams } from './common'; export interface TaskCenterSystemTaskItem { @@ -32,7 +34,7 @@ export interface TaskCenterTaskItem { result: string; // 执行结果 taskType: string; // 任务类型 resourceId: string; - triggerMode: string; // 触发方式 + triggerMode: ExecuteTriggerMode; // 执行方式 projectId: string; organizationId: string; createTime: number; @@ -42,6 +44,7 @@ export interface TaskCenterTaskItem { organizationName: string; // 所属组织名称 projectName: string; // 所属项目名称 createUserName: string; // 创建人 + [key: string]: any; } export interface TaskCenterTaskDetailItem { @@ -77,3 +80,8 @@ export interface TaskCenterStatisticsItem { pendingCount: number; // 待执行数 caseTotal: number; // 用例总数 } + +export interface TaskCenterResourcePoolStatus { + id: string; + status: boolean; // 状态, true: 正常, false: 异常 +} diff --git a/frontend/src/store/index.ts b/frontend/src/store/index.ts index b6afde796d..66f65c741c 100644 --- a/frontend/src/store/index.ts +++ b/frontend/src/store/index.ts @@ -5,11 +5,12 @@ import useTableStore from '@/hooks/useTableStore'; import useAppStore from './modules/app'; import useVisitStore from './modules/app/visit'; import useMinderStore from './modules/components/minder-editor'; +import useGlobalStore from './modules/global'; import useUserStore from './modules/user'; import { debouncePlugin } from './plugins'; import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'; const pinia = createPinia().use(debouncePlugin).use(piniaPluginPersistedstate); -export { useAppStore, useMinderStore, useTableStore, useUserStore, useVisitStore }; +export { useAppStore, useGlobalStore, useMinderStore, useTableStore, useUserStore, useVisitStore }; export default pinia; diff --git a/frontend/src/store/modules/app/types.ts b/frontend/src/store/modules/app/types.ts index ebed07159f..30065dd080 100644 --- a/frontend/src/store/modules/app/types.ts +++ b/frontend/src/store/modules/app/types.ts @@ -12,10 +12,10 @@ export interface AppState { navbar: boolean; menu: boolean; hideMenu: boolean; - menuCollapse: boolean; + menuCollapse: boolean; // 菜单是否折叠 footer: boolean; menuWidth: number; - collapsedWidth: number; + collapsedWidth: number; // 菜单折叠宽度 globalSettings: boolean; device: string; tabBar: boolean; @@ -45,7 +45,7 @@ export interface AppState { ordList: { id: string; name: string }[]; envList: EnvironmentItem[]; currentEnvConfig?: EnvConfig; // 当前环境配置信息 - fileMaxSize: number; + fileMaxSize: number; // 文件上传最大限制 } export interface UploadFileTaskState { diff --git a/frontend/src/store/modules/global/index.ts b/frontend/src/store/modules/global/index.ts new file mode 100644 index 0000000000..eed00e9c86 --- /dev/null +++ b/frontend/src/store/modules/global/index.ts @@ -0,0 +1,20 @@ +import { defineStore } from 'pinia'; + +import type { GlobalState, GlobalStateEvent } from './types'; + +const useGlobalStore = defineStore('global', { + state: (): GlobalState => ({ + globalEvent: undefined, + }), + getters: { + getGlobalEvent(state: GlobalState) { + return state.globalEvent; + }, + }, + actions: { + dispatchGlobalEvent(event: GlobalStateEvent) { + this.globalEvent = event; + }, + }, +}); +export default useGlobalStore; diff --git a/frontend/src/store/modules/global/types.ts b/frontend/src/store/modules/global/types.ts new file mode 100644 index 0000000000..b55312d6b0 --- /dev/null +++ b/frontend/src/store/modules/global/types.ts @@ -0,0 +1,11 @@ +import type { GlobalEventNameEnum } from '@/enums/commonEnum'; + +export interface GlobalStateEvent { + id: string; + name: GlobalEventNameEnum; + params?: Record; +} + +export interface GlobalState { + globalEvent?: GlobalStateEvent; +} diff --git a/frontend/src/views/api-test/management/components/import.vue b/frontend/src/views/api-test/management/components/import.vue index 4ff2c52ed2..7971157e64 100644 --- a/frontend/src/views/api-test/management/components/import.vue +++ b/frontend/src/views/api-test/management/components/import.vue @@ -214,7 +214,7 @@ :max-length="255" class="w-[550px]" > - + {{ t('apiTestManagement.timeTaskList') }} @@ -328,52 +328,20 @@ - -
- -
- - - -
+ + diff --git a/frontend/src/views/api-test/management/index.vue b/frontend/src/views/api-test/management/index.vue index af8477faa1..c7dfba6e41 100644 --- a/frontend/src/views/api-test/management/index.vue +++ b/frontend/src/views/api-test/management/index.vue @@ -47,6 +47,7 @@ :active-module="activeModule" popup-container="#managementContainer" @done="handleImportDone" + @open-task-drawer="taskDrawerVisible = true" /> + diff --git a/frontend/src/views/taskCenter/component/caseTaskDetailTable.vue b/frontend/src/views/taskCenter/component/caseTaskDetailTable.vue index bf25b4e751..01c5113baa 100644 --- a/frontend/src/views/taskCenter/component/caseTaskDetailTable.vue +++ b/frontend/src/views/taskCenter/component/caseTaskDetailTable.vue @@ -49,8 +49,8 @@