feat(任务中心): 任务中心列表接口

This commit is contained in:
baiqi 2024-10-12 17:25:59 +08:00 committed by Craftsman
parent 772cd67117
commit 2738398318
23 changed files with 582 additions and 679 deletions

View File

@ -1,239 +0,0 @@
import MSR from '@/api/http';
import {
batchDisableScheduleOrgTaskUrl,
batchDisableScheduleProTaskUrl,
batchDisableScheduleSysTaskUrl,
batchEnableScheduleOrgTaskUrl,
batchEnableScheduleProTaskUrl,
batchEnableScheduleSysTaskUrl,
batchStopRealOrdApiUrl,
batchStopRealProjectApiUrl,
batchStopRealSystemApiUrl,
deleteScheduleOrgTaskUrl,
deleteScheduleProTaskUrl,
deleteScheduleSysTaskUrl,
enableSchedule,
enableScheduleOrgTaskUrl,
enableScheduleProTaskUrl,
enableScheduleSysTaskUrl,
orgRealTotal,
orgScheduleTotal,
projectRealTotal,
projectScheduleTotal,
scheduleOrgCenterListUrl,
scheduleProCenterListUrl,
scheduleSysCenterListUrl,
stopRealOrdApiUrl,
stopRealOrgPlanUrl,
stopRealProjectApiUrl,
stopRealProjectPlanUrl,
stopRealSysApiUrl,
stopRealSysPlanUrl,
systemRealTotal,
systemScheduleTotal,
taskOrgPlanRealCenterListUrl,
taskOrgRealCenterListUrl,
taskProPlanRealCenterListUrl,
taskProRealCenterListUrl,
taskSysPlanRealCenterListUrl,
taskSysRealCenterListUrl,
updateScheduleOrgTaskUrl,
updateScheduleProTaskUrl,
updateScheduleSysTaskUrl,
} from '@/api/requrls/project-management/taskCenter';
import type { CommonList, TableQueryParams } from '@/models/common';
import type { RealTaskCenterApiCaseItem, TimingTaskCenterApiCaseItem } from '@/models/projectManagement/taskCenter';
import { TaskCenterEnum } from '@/enums/taskCenter';
// 实时任务
export function getRealSysApiCaseList(data: TableQueryParams) {
return MSR.post<CommonList<RealTaskCenterApiCaseItem>>({ url: taskSysRealCenterListUrl, data });
}
export function batchStopRealSystemApi(data: TableQueryParams) {
return MSR.post<CommonList<RealTaskCenterApiCaseItem>>({ url: batchStopRealSystemApiUrl, data });
}
export function getRealOrdApiCaseList(data: TableQueryParams) {
return MSR.post<CommonList<RealTaskCenterApiCaseItem>>({ url: taskOrgRealCenterListUrl, data });
}
export function batchStopRealOrdApi(data: TableQueryParams) {
return MSR.post<CommonList<RealTaskCenterApiCaseItem>>({ url: batchStopRealOrdApiUrl, data });
}
export function getRealProApiCaseList(data: TableQueryParams) {
return MSR.post<CommonList<RealTaskCenterApiCaseItem>>({ url: taskProRealCenterListUrl, data });
}
export function batchStopRealProjectApi(data: TableQueryParams) {
return MSR.post<CommonList<RealTaskCenterApiCaseItem>>({ url: batchStopRealProjectApiUrl, data });
}
export function stopRealSysApi(moduleType: keyof typeof TaskCenterEnum, id: string) {
return MSR.get({ url: `${stopRealSysApiUrl}/${moduleType}/${id}` });
}
export function stopRealOrdApi(moduleType: keyof typeof TaskCenterEnum, id: string) {
return MSR.get({ url: `${stopRealOrdApiUrl}/${moduleType}/${id}` });
}
export function stopRealProjectApi(moduleType: keyof typeof TaskCenterEnum, id: string) {
return MSR.get({ url: `${stopRealProjectApiUrl}/${moduleType}/${id}` });
}
// 定时任务
export function getScheduleSysApiCaseList(data: TableQueryParams) {
return MSR.post<CommonList<TimingTaskCenterApiCaseItem>>({ url: scheduleSysCenterListUrl, data });
}
export function getScheduleOrgApiCaseList(data: TableQueryParams) {
return MSR.post<CommonList<TimingTaskCenterApiCaseItem>>({ url: scheduleOrgCenterListUrl, data });
}
export function getScheduleProApiCaseList(data: TableQueryParams) {
return MSR.post<CommonList<TimingTaskCenterApiCaseItem>>({ url: scheduleProCenterListUrl, data });
}
// 系统删除定时任务
export function deleteScheduleSysTask(moduleType: keyof typeof TaskCenterEnum, id: string) {
return MSR.get({ url: `${deleteScheduleSysTaskUrl}/${moduleType}/${id}` });
}
// 组织删除定时任务
export function deleteScheduleOrgTask(moduleType: keyof typeof TaskCenterEnum, id: string) {
return MSR.get({ url: `${deleteScheduleOrgTaskUrl}/${moduleType}/${id}` });
}
// 项目删除定时任务
export function deleteScheduleProTask(moduleType: keyof typeof TaskCenterEnum, id: string) {
return MSR.get({ url: `${deleteScheduleProTaskUrl}/${moduleType}/${id}` });
}
// 系统启用定时任务
export function enableScheduleSysTask(moduleType: keyof typeof TaskCenterEnum, id: string) {
return MSR.get({ url: `${enableScheduleSysTaskUrl}/${moduleType}/${id}` });
}
// 组织启用定时任务
export function enableScheduleOrgTask(moduleType: keyof typeof TaskCenterEnum, id: string) {
return MSR.get({ url: `${enableScheduleOrgTaskUrl}/${moduleType}/${id}` });
}
// 项目启用定时任务
export function enableScheduleProTask(moduleType: keyof typeof TaskCenterEnum, id: string) {
return MSR.get({ url: `${enableScheduleProTaskUrl}/${moduleType}/${id}` });
}
// 系统更新定时任务规则
export function updateRunRules(moduleType: keyof typeof TaskCenterEnum, id: string, data: string) {
return MSR.post({ url: `${updateScheduleSysTaskUrl}/${moduleType}/${id}`, data });
}
// 组织更新定时任务规则
export function updateRunRulesOrg(moduleType: keyof typeof TaskCenterEnum, id: string, data: string) {
return MSR.post({ url: `${updateScheduleOrgTaskUrl}/${moduleType}/${id}`, data });
}
// 项目更新定时任务规则
export function updateRunRulesPro(moduleType: keyof typeof TaskCenterEnum, id: string, data: string) {
return MSR.post({ url: `${updateScheduleProTaskUrl}/${moduleType}/${id}`, data });
}
// 系统批量开启定时任务
export function batchEnableScheduleSysTask(data: TableQueryParams) {
return MSR.post({ url: `${batchEnableScheduleSysTaskUrl}`, data });
}
// 组织批量开启定时任务
export function batchEnableScheduleOrgTask(data: TableQueryParams) {
return MSR.post({ url: `${batchEnableScheduleOrgTaskUrl}`, data });
}
// 项目批量开启定时任务
export function batchEnableScheduleProTask(data: TableQueryParams) {
return MSR.post({ url: `${batchEnableScheduleProTaskUrl}`, data });
}
// 系统批量关闭定时任务
export function batchDisableScheduleSysTask(data: TableQueryParams) {
return MSR.post({ url: `${batchDisableScheduleSysTaskUrl}`, data });
}
// 组织批量关闭定时任务
export function batchDisableScheduleOrgTask(data: TableQueryParams) {
return MSR.post({ url: `${batchDisableScheduleOrgTaskUrl}`, data });
}
// 项目批量关闭定时任务
export function batchDisableScheduleProTask(data: TableQueryParams) {
return MSR.post({ url: `${batchDisableScheduleProTaskUrl}`, data });
}
export function switchSchedule(id: string) {
return MSR.get({ url: `${enableSchedule}/${id}` });
}
export function getSystemScheduleTotal() {
return MSR.get({ url: `${systemScheduleTotal}` });
}
export function getOrgScheduleTotal() {
return MSR.get({ url: `${orgScheduleTotal}` });
}
export function getProjectScheduleTotal() {
return MSR.get({ url: `${projectScheduleTotal}` });
}
export function getSystemRealTotal() {
return MSR.get({ url: `${systemRealTotal}` });
}
export function getOrgRealTotal() {
return MSR.get({ url: `${orgRealTotal}` });
}
export function getProjectRealTotal() {
return MSR.get({ url: `${projectRealTotal}` });
}
// 实时任务 测试计划
export function getRealSysPlanList(data: TableQueryParams) {
return MSR.post<CommonList<RealTaskCenterApiCaseItem>>({ url: taskSysPlanRealCenterListUrl, data });
}
export function getRealOrgPlanList(data: TableQueryParams) {
return MSR.post<CommonList<RealTaskCenterApiCaseItem>>({ url: taskOrgPlanRealCenterListUrl, data });
}
export function getRealProPlanList(data: TableQueryParams) {
return MSR.post<CommonList<RealTaskCenterApiCaseItem>>({ url: taskProPlanRealCenterListUrl, data });
}
export function stopRealSysPlan(id: string) {
return MSR.get({ url: `${stopRealSysPlanUrl}/${id}` });
}
export function stopRealOrgPlan(id: string) {
return MSR.get({ url: `${stopRealOrgPlanUrl}/${id}` });
}
export function stopRealProPlan(id: string) {
return MSR.get({ url: `${stopRealProjectPlanUrl}/${id}` });
}
export function batchStopRealSysPlan(data: TableQueryParams) {
return MSR.post({ url: `${stopRealSysPlanUrl}`, data });
}
export function batchStopRealOrgPlan(data: TableQueryParams) {
return MSR.post({ url: `${stopRealOrgPlanUrl}`, data });
}
export function batchStopRealProPlan(data: TableQueryParams) {
return MSR.post({ url: `${stopRealProjectPlanUrl}`, data });
}
export default {};

View File

@ -0,0 +1,91 @@
import MSR from '@/api/http/index';
import {
organizationExecuteTaskDetailListUrl,
organizationExecuteTaskListUrl,
organizationExecuteTaskStatisticsUrl,
organizationScheduleListUrl,
projectExecuteTaskDetailListUrl,
projectExecuteTaskListUrl,
projectExecuteTaskStatisticsUrl,
projectScheduleTaskListUrl,
scheduleProCenterListUrl,
systemExecuteTaskDetailListUrl,
systemExecuteTaskListUrl,
systemExecuteTaskStatisticsUrl,
systemScheduleListUrl,
} from '@/api/requrls/taskCenter';
import type { CommonList, TableQueryParams } from '@/models/common';
import type { TimingTaskCenterApiCaseItem } from '@/models/projectManagement/taskCenter';
import type {
TaskCenterStatisticsItem,
TaskCenterSystemTaskItem,
TaskCenterTaskDetailItem,
TaskCenterTaskDetailParams,
TaskCenterTaskItem,
} from '@/models/taskCenter';
// 项目任务-系统后台任务列表
export function getProjectScheduleList(data: TableQueryParams) {
return MSR.post<CommonList<TaskCenterSystemTaskItem>>({ url: projectScheduleTaskListUrl, data });
}
// 项目任务-获取任务详情列表
export function getProjectExecuteTaskDetailList(data: TaskCenterTaskDetailParams) {
return MSR.post<CommonList<TaskCenterTaskDetailItem>>({ url: projectExecuteTaskDetailListUrl, data });
}
// 项目任务-获取任务列表
export function getProjectExecuteTaskList(data: TableQueryParams) {
return MSR.post<CommonList<TaskCenterTaskItem>>({ url: projectExecuteTaskListUrl, data });
}
// 项目任务-获取任务统计
export function getProjectExecuteTaskStatistics(data: string[]) {
return MSR.post<TaskCenterStatisticsItem[]>({ url: projectExecuteTaskStatisticsUrl, data });
}
// 接口测试-定时任务列表
export function getScheduleProApiCaseList(data: TableQueryParams) {
return MSR.post<CommonList<TimingTaskCenterApiCaseItem>>({ url: scheduleProCenterListUrl, data });
}
// 系统任务-系统后台任务列表
export function getSystemScheduleList(data: TableQueryParams) {
return MSR.post<CommonList<TaskCenterSystemTaskItem>>({ url: systemScheduleListUrl, data });
}
// 系统任务-获取任务详情列表
export function getSystemExecuteTaskDetailList(data: TaskCenterTaskDetailParams) {
return MSR.post<CommonList<TaskCenterTaskDetailItem>>({ url: systemExecuteTaskDetailListUrl, data });
}
// 系统任务-获取任务列表
export function getSystemExecuteTaskList(data: TableQueryParams) {
return MSR.post<CommonList<TaskCenterTaskItem>>({ url: systemExecuteTaskListUrl, data });
}
// 系统任务-获取任务统计
export function getSystemExecuteTaskStatistics(data: string[]) {
return MSR.post<TaskCenterStatisticsItem[]>({ url: systemExecuteTaskStatisticsUrl, data });
}
// 组织任务-系统后台任务列表
export function getOrganizationScheduleList(data: TableQueryParams) {
return MSR.post<CommonList<TaskCenterSystemTaskItem>>({ url: organizationScheduleListUrl, data });
}
// 组织任务-获取任务详情列表
export function getOrganizationExecuteTaskDetailList(data: TaskCenterTaskDetailParams) {
return MSR.post<CommonList<TaskCenterTaskDetailItem>>({ url: organizationExecuteTaskDetailListUrl, data });
}
// 组织任务-获取任务列表
export function getOrganizationExecuteTaskList(data: TableQueryParams) {
return MSR.post<CommonList<TaskCenterTaskItem>>({ url: organizationExecuteTaskListUrl, data });
}
// 组织任务-获取任务统计
export function getOrganizationExecuteTaskStatistics(data: string[]) {
return MSR.post<TaskCenterStatisticsItem[]>({ url: organizationExecuteTaskStatisticsUrl, data });
}

View File

@ -1,86 +0,0 @@
// 系统管理
// 任务中心-实时任务-接口用例/场景
export const taskSysRealCenterListUrl = '/task/center/api/system/real-time/page';
// 系统-任务中心-定时任务列表
export const scheduleSysCenterListUrl = '/task/center/system/schedule/page';
// 系统-任务中心-删除定时任务
// export const deleteScheduleSysTaskUrl = '/task/center/schedule/delete';
// 系统接口用例和场景停止实时任务
export const batchStopRealSystemApiUrl = '/task/center/api/system/stop';
export const enableSchedule = '/task/center/schedule/switch';
// 组织管理
// 任务中心-实时任务-接口用例/场景
export const taskOrgRealCenterListUrl = '/task/center/api/org/real-time/page';
// 组织接口用例和场景停止实时任务
export const batchStopRealOrdApiUrl = '/task/center/api/org/stop';
// 系统-任务中心-定时任务列表
export const scheduleOrgCenterListUrl = '/task/center/org/schedule/page';
// 项目管理
// 任务中心-实时任务-接口用例/场景
export const taskProRealCenterListUrl = '/task/center/api/project/real-time/page';
// 项目-任务中心-定时任务列表
export const scheduleProCenterListUrl = '/task/center/project/schedule/page';
// 项目-任务中心-实时任务列表
export const batchStopRealProjectApiUrl = '/task/center/api/project/stop';
// 停止单个任务(系统)
export const stopRealSysApiUrl = '/task/center/api/system/stop';
// 停止单个任务(组织)
export const stopRealOrdApiUrl = '/task/center/api/org/stop';
// 停止单个任务(项目)
export const stopRealProjectApiUrl = '/task/center/api/project/stop';
// 更新定时任务运行规则
export const updateRunRulesUrl = '/task/center/schedule/update';
// 系统定时任务 删除
export const deleteScheduleSysTaskUrl = '/task/center/system/schedule/delete';
// 组织定时任务 删除
export const deleteScheduleOrgTaskUrl = '/task/center/org/schedule/delete';
// 项目定时任务 删除
export const deleteScheduleProTaskUrl = '/task/center/project/schedule/delete';
// 系统定时任务 启用
export const enableScheduleSysTaskUrl = '/task/center/system/schedule/switch';
// 组织定时任务 启用
export const enableScheduleOrgTaskUrl = '/task/center/org/schedule/switch';
// 项目定时任务 启用
export const enableScheduleProTaskUrl = '/task/center/project/schedule/switch';
// 系统定时任务 更新
export const updateScheduleSysTaskUrl = '/task/center/system/schedule/update';
// 组织定时任务 更新
export const updateScheduleOrgTaskUrl = '/task/center/org/schedule/update';
// 项目定时任务 更新
export const updateScheduleProTaskUrl = '/task/center/project/schedule/update';
// 系统定时任务 批量开启
export const batchEnableScheduleSysTaskUrl = '/task/center/system/schedule/batch-enable';
// 组织定时任务 批量开启
export const batchEnableScheduleOrgTaskUrl = '/task/center/org/schedule/batch-enable';
// 项目定时任务 批量开启
export const batchEnableScheduleProTaskUrl = '/task/center/project/schedule/batch-enable';
// 系统定时任务 批量关闭
export const batchDisableScheduleSysTaskUrl = '/task/center/system/schedule/batch-disable';
// 组织定时任务 批量关闭
export const batchDisableScheduleOrgTaskUrl = '/task/center/org/schedule/batch-disable';
// 项目定时任务 批量关闭
export const batchDisableScheduleProTaskUrl = '/task/center/project/schedule/batch-disable';
export const systemScheduleTotal = '/task/center/system/schedule/total';
export const orgScheduleTotal = '/task/center/org/schedule/total';
export const projectScheduleTotal = '/task/center/project/schedule/total';
export const systemRealTotal = '/task/center/system/real/total';
export const orgRealTotal = '/task/center/org/real/total';
export const projectRealTotal = '/task/center/project/real/total';
export const taskSysPlanRealCenterListUrl = '/task/center/plan/system/real-time/page';
export const taskOrgPlanRealCenterListUrl = '/task/center/plan/org/real-time/page';
export const taskProPlanRealCenterListUrl = '/task/center/plan/project/real-time/page';
export const stopRealSysPlanUrl = '/task/center/plan/system/stop';
export const stopRealOrgPlanUrl = '/task/center/plan/org/stop';
export const stopRealProjectPlanUrl = '/task/center/plan/project/stop';

View File

@ -0,0 +1,16 @@
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 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 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'; // 系统任务-获取任务统计

View File

@ -25,7 +25,7 @@
.ms-task-center-drawer {
.arco-drawer-body {
padding-top: 0;
:deep(.arco-tabs-tab) {
.arco-tabs-tab {
margin-left: 0;
}
}

View File

@ -19,3 +19,17 @@ export enum ExecutionMethodsLabel {
API = 'project.taskCenter.interfaceCall', // 接口调用
BATCH = 'project.taskCenter.batchExecution', // 批量执行
}
export enum ExecuteStatusEnum {
PENDING = 'PENDING', // 待执行
RUNNING = 'RUNNING', // 执行中
COMPLETED = 'COMPLETED', // 执行完成
RERUNNING = 'RERUNNING', // 失败重跑
STOPPED = 'STOPPED', // 执行中止
}
export enum ExecuteResultEnum {
SUCCESS = 'SUCCESS',
ERROR = 'ERROR',
FAKE_ERROR = 'FAKE_ERROR',
}

View File

@ -194,7 +194,7 @@ export default {
'common.updateUserName': '更新人',
'common.updateTime': '更新时间',
'common.belongProject': '所属项目',
'common.belongOrg': '所属项目',
'common.belongOrg': '所属组织',
'common.noMatchData': '暂无匹配数据',
'common.name': '名称',
'common.stopped': '已停止',

View File

@ -0,0 +1,79 @@
import type { TableQueryParams } from './common';
export interface TaskCenterSystemTaskItem {
organizationName: string; // 所属组织名称
projectName: string; // 所属项目名称
projectId: string; // 项目ID
organizationId: string; // 组织ID
id: string;
taskName: string;
resourceId: string; // 资源ID
num: number;
resourceType: string; // 资源类型
value: string;
nextTime: number;
enable: boolean;
createUserId: string;
createUserName: string;
createTime: number;
}
export interface TaskCenterTaskDetailParams extends TableQueryParams {
taskId: string;
resourcePoolId: string;
}
export interface TaskCenterTaskItem {
id: string;
num: number;
taskName: string;
status: string; // 执行状态
caseCount: number;
result: string; // 执行结果
taskType: string; // 任务类型
resourceId: string;
triggerMode: string; // 触发方式
projectId: string;
organizationId: string;
createTime: number;
createUser: string;
startTime: number;
endTime: number;
organizationName: string; // 所属组织名称
projectName: string; // 所属项目名称
createUserName: string; // 创建人
}
export interface TaskCenterTaskDetailItem {
id: string;
taskId: string; // 任务ID
resourceId: string;
resourceName: string;
taskOrigin: string; // 任务来源
status: string; // 执行状态
result: string; // 执行结果
resourcePoolId: string; // 资源池ID
resourcePoolNode: string; // 资源池节点
resourceType: string; // 资源类型
projectId: string;
organizationId: string;
threadId: string; // 线程ID
startTime: number;
endTime: number;
executor: string;
taskName: string;
userName: string;
resourcePoolName: string;
triggerMode: string; // 触发方式
lineNum: number;
}
export interface TaskCenterStatisticsItem {
id: string;
executeRate: number; // 执行率
successCount: number; // 成功数
errorCount: number; // 失败数
fakeErrorCount: number; // 误报数
pendingCount: number; // 待执行数
caseTotal: number; // 用例总数
}

View File

@ -373,7 +373,7 @@
importDefinition,
switchDefinitionSchedule,
} from '@/api/modules/api-test/management';
import { getScheduleProApiCaseList } from '@/api/modules/project-management/taskCenter';
import { getScheduleProApiCaseList } from '@/api/modules/taskCenter';
import { useI18n } from '@/hooks/useI18n';
import useAppStore from '@/store/modules/app';
import useUserStore from '@/store/modules/user';

View File

@ -9,4 +9,8 @@
import TaskCenter from '@/views/taskCenter/index.vue';
</script>
<style scoped></style>
<style lang="less" scoped>
:deep(.ms-taskCenter-content) {
padding: 0 16px;
}
</style>

View File

@ -10,35 +10,7 @@
</script>
<style scoped lang="less">
.box {
display: flex;
height: 100%;
.left {
padding: 24px;
width: 252px;
height: 100%;
border-right: 1px solid var(--color-text-n8);
.item {
padding: 0 20px;
height: 38px;
font-size: 14px;
line-height: 38px;
border-radius: 4px;
cursor: pointer;
&.active {
background: rgb(var(--primary-1));
}
}
}
.right {
width: calc(100% - 300px);
flex-grow: 1; /* 自适应 */
height: 100%;
}
}
.no-content {
:deep(.arco-tabs-content) {
padding-top: 0;
}
:deep(.ms-taskCenter-content) {
padding: 0 16px;
}
</style>

View File

@ -57,7 +57,7 @@
import { ReportExecStatus } from '@/enums/apiEnum';
import { executeResultMap } from './utils';
import { executeResultMap } from './config';
const props = defineProps<{
id: string;

View File

@ -32,35 +32,50 @@
v-on="propsEvent"
@batch-action="handleTableBatch"
>
<template #executeStatus="{ record }">
<execStatus :status="record.executeStatus" />
<template #status="{ record }">
<execStatus :status="record.status" />
</template>
<template #[FilterSlotNameEnum.GLOBAL_TASK_CENTER_EXEC_STATUS]="{ filterContent }">
<execStatus :status="filterContent.value" />
</template>
<template #executeResult="{ record }">
<executionStatus :status="record.executeResult" />
<template #result="{ record }">
<executionStatus :status="record.result" />
</template>
<template #[FilterSlotNameEnum.GLOBAL_TASK_CENTER_EXEC_RESULT]="{ filterContent }">
<executionStatus :status="filterContent.value" />
</template>
<template #node="{ record }">
<div>{{ record.node }}</div>
<template #triggerMode="{ record }">
{{ t(executeMethodMap[record.triggerMode]) }}
</template>
<template #resourcePoolNode="{ record }">
<div>{{ record.resourcePoolNode }}</div>
<a-tooltip :content="t('ms.taskCenter.nodeErrorTip')">
<icon-exclamation-circle-fill class="!text-[rgb(var(--warning-6))]" :size="18" />
</a-tooltip>
</template>
<template #action="{ record }">
<MsButton v-permission="['SYSTEM_USER:READ+DELETE']" @click="stopTask(record)">
<MsButton
v-if="[ExecuteStatusEnum.RUNNING, ExecuteStatusEnum.RERUNNING].includes(record.status)"
v-permission="['SYSTEM_USER:READ+DELETE']"
@click="stopTask(record)"
>
{{ t('common.stop') }}
</MsButton>
<MsButton v-permission="['SYSTEM_USER:READ+DELETE']" @click="deleteTask(record)">
<MsButton v-else v-permission="['SYSTEM_USER:READ+DELETE']" @click="deleteTask(record)">
{{ t('common.delete') }}
</MsButton>
<MsButton v-permission="['SYSTEM_USER:READ+DELETE']" @click="rerunTask(record)">
<MsButton
v-if="record.status === ExecuteStatusEnum.COMPLETED && record.result === ExecuteResultEnum.ERROR"
v-permission="['SYSTEM_USER:READ+DELETE']"
@click="rerunTask(record)"
>
{{ t('ms.taskCenter.rerun') }}
</MsButton>
<MsButton v-permission="['SYSTEM_USER:READ+DELETE']" @click="checkExecuteResult(record)">
<MsButton
v-if="record.status === ExecuteStatusEnum.COMPLETED"
v-permission="['SYSTEM_USER:READ+DELETE']"
@click="checkExecuteResult(record)"
>
{{ t('ms.taskCenter.executeResult') }}
</MsButton>
</template>
@ -85,6 +100,11 @@
import executionStatus from './executionStatus.vue';
import scenarioExecuteResultDrawer from './scenarioExecuteResultDrawer.vue';
import {
getOrganizationExecuteTaskDetailList,
getProjectExecuteTaskDetailList,
getSystemExecuteTaskDetailList,
} from '@/api/modules/taskCenter';
import { useI18n } from '@/hooks/useI18n';
import useModal from '@/hooks/useModal';
import useTableStore from '@/hooks/useTableStore';
@ -93,11 +113,13 @@
import { TableKeyEnum } from '@/enums/tableEnum';
import { FilterSlotNameEnum } from '@/enums/tableFilterEnum';
import { ExecuteResultEnum, ExecuteStatusEnum } from '@/enums/taskCenter';
import { executeMethodMap, executeResultMap, executeStatusMap } from './utils';
import { executeMethodMap, executeResultMap, executeStatusMap } from './config';
const props = defineProps<{
type: 'system' | 'project' | 'org';
id?: string;
}>();
const { t } = useI18n();
@ -113,24 +135,27 @@
const columns: MsTableColumn = [
{
title: t('ms.taskCenter.taskID'),
dataIndex: 'num',
width: 100,
dataIndex: 'taskId',
width: 180,
columnSelectorDisabled: true,
showTooltip: true,
fixed: 'left',
},
{
title: 'ms.taskCenter.taskName',
dataIndex: 'name',
dataIndex: 'taskName',
showTooltip: true,
width: 200,
fixed: 'left',
},
{
title: 'ms.taskCenter.executeStatus',
dataIndex: 'executeStatus',
slotName: 'executeStatus',
dataIndex: 'status',
slotName: 'status',
width: 100,
filterConfig: {
options: Object.keys(executeStatusMap).map((key) => ({
label: t(executeStatusMap[key].label),
label: t(executeStatusMap[key as ExecuteStatusEnum].label),
value: key,
})),
filterSlotName: FilterSlotNameEnum.GLOBAL_TASK_CENTER_EXEC_STATUS,
@ -138,7 +163,7 @@
},
{
title: 'ms.taskCenter.executeMethod',
dataIndex: 'executeMethod',
dataIndex: 'triggerMode',
width: 100,
filterConfig: {
options: Object.keys(executeMethodMap).map((key) => ({
@ -150,8 +175,8 @@
},
{
title: 'ms.taskCenter.executeResult',
dataIndex: 'executeResult',
slotName: 'executeResult',
dataIndex: 'result',
slotName: 'result',
width: 100,
filterConfig: {
options: Object.keys(executeResultMap).map((key) => ({
@ -164,24 +189,24 @@
},
{
title: 'ms.taskCenter.resourcePool',
dataIndex: 'resourcePools',
dataIndex: 'resourcePoolName',
isStringTag: true,
isTag: true,
},
{
title: 'ms.taskCenter.node',
dataIndex: 'node',
slotName: 'node',
dataIndex: 'resourcePoolNode',
slotName: 'resourcePoolNode',
width: 100,
},
{
title: 'ms.taskCenter.queue',
dataIndex: 'queue',
dataIndex: 'lineNum',
width: 100,
},
{
title: 'ms.taskCenter.threadID',
dataIndex: 'threadID',
dataIndex: 'threadId',
width: 100,
},
{
@ -202,17 +227,23 @@
sorter: true,
},
},
{
title: 'ms.taskCenter.operationUser',
dataIndex: 'executor',
width: 100,
showTooltip: true,
},
{
title: 'common.operation',
slotName: 'action',
dataIndex: 'operation',
fixed: 'right',
width: 220,
width: 180,
},
];
if (props.type === 'system') {
columns.splice(1, 0, [
columns.splice(2, 0, [
{
title: 'common.belongProject',
dataIndex: 'belongProject',
@ -227,7 +258,7 @@
},
]);
} else if (props.type === 'org') {
columns.splice(1, 0, [
columns.splice(2, 0, [
{
title: 'common.belongProject',
dataIndex: 'belongProject',
@ -237,8 +268,6 @@
]);
}
await tableStore.initColumn(TableKeyEnum.TASK_CENTER_CASE_TASK_DETAIL, columns, 'drawer');
const tableBatchActions = {
baseAction: [
{
@ -255,29 +284,15 @@
},
],
};
const currentExecuteTaskDetailList = {
system: getSystemExecuteTaskDetailList,
project: getProjectExecuteTaskDetailList,
org: getOrganizationExecuteTaskDetailList,
}[props.type];
const { propsRes, propsEvent, loadList, setLoadListParams, resetSelector } = useTable(
() =>
Promise.resolve({
list: [
{
id: '1',
num: 10086,
name: 'test',
belongProject: 'test',
belongOrg: 'test',
executeStatus: 'PENDING',
executeMethod: '手动执行',
executeResult: 'SUCCESS',
resourcePools: ['test'],
node: '11.11.1',
queue: '10',
threadID: '1736',
startExecuteTime: 1629782400000,
endExecuteTime: 1629782400000,
},
],
total: 1,
}),
currentExecuteTaskDetailList,
{
tableKey: TableKeyEnum.TASK_CENTER_CASE_TASK_DETAIL,
scroll: { x: '1000px' },
@ -289,6 +304,7 @@
(item) => {
return {
...item,
resourcePoolName: [item.resourcePoolName],
startExecuteTime: dayjs(item.startExecuteTime).format('YYYY-MM-DD HH:mm:ss'),
endExecuteTime: dayjs(item.endExecuteTime).format('YYYY-MM-DD HH:mm:ss'),
};
@ -304,7 +320,7 @@
* 删除任务
*/
function deleteTask(record?: any, isBatch?: boolean, params?: BatchActionQueryParams) {
let title = t('ms.taskCenter.deleteTaskTitle', { name: characterLimit(record?.name) });
let title = t('ms.taskCenter.deleteTaskTitle', { name: characterLimit(record?.taskName) });
let selectIds = [record?.id || ''];
if (isBatch) {
title = t('ms.taskCenter.deleteCaseTaskTitle', {
@ -343,7 +359,7 @@
}
function stopTask(record?: any, isBatch?: boolean, params?: BatchActionQueryParams) {
let title = t('ms.taskCenter.stopTaskTitle', { name: characterLimit(record?.name) });
let title = t('ms.taskCenter.stopTaskTitle', { name: characterLimit(record?.taskName) });
let selectIds = [record?.id || ''];
if (isBatch) {
title = t('ms.taskCenter.batchStopTaskTitle', {
@ -412,8 +428,13 @@
}
onMounted(() => {
loadList();
if (props.id) {
keyword.value = props.id;
}
searchTask();
});
await tableStore.initColumn(TableKeyEnum.TASK_CENTER_CASE_TASK_DETAIL, columns, 'drawer');
</script>
<style lang="less" scoped></style>

View File

@ -9,7 +9,7 @@
@press-enter="searchTask"
@clear="searchTask"
/>
<MsTag no-margin size="large" :tooltip-disabled="true" class="cursor-pointer" theme="outline" @click="searchTask">
<MsTag no-margin size="large" :tooltip-disabled="true" class="cursor-pointer" theme="outline" @click="refresh">
<MsIcon class="text-[16px] text-[var(color-text-4)]" :size="32" type="icon-icon_reset_outlined" />
</MsTag>
</div>
@ -19,40 +19,41 @@
v-on="propsEvent"
@batch-action="handleTableBatch"
>
<template #num="{ record }">
<template #id="{ record }">
<a-button type="text" class="max-w-full justify-start px-0" @click="showTaskDetail(record.id)">
<div class="one-line-text">
{{ record.num }}
</div>
<a-tooltip :content="record.id">
<div class="one-line-text">
{{ record.id }}
</div>
</a-tooltip>
</a-button>
</template>
<template #executeStatus="{ record }">
<execStatus :status="record.executeStatus" />
<template #status="{ record }">
<execStatus :status="record.status" />
</template>
<template #[FilterSlotNameEnum.GLOBAL_TASK_CENTER_EXEC_STATUS]="{ filterContent }">
<execStatus :status="filterContent.value" />
</template>
<template #executeResult="{ record }">
<executionStatus :status="record.executeResult" />
<template #result="{ record }">
<executionStatus :status="record.result" />
</template>
<template #[FilterSlotNameEnum.GLOBAL_TASK_CENTER_EXEC_RESULT]="{ filterContent }">
<executionStatus :status="filterContent.value" />
</template>
<template #executeFinishedRate="{ record }">
<template #triggerMode="{ record }">
{{ t(executeMethodMap[record.triggerMode]) }}
</template>
<template #executeRate="{ record }">
<a-popover trigger="hover" position="bottom">
<div>{{ record.executeFinishedRate }}</div>
<div>{{ record.executeRate }}%</div>
<template #content>
<div class="flex w-[130px] flex-col gap-[8px]">
<div class="ms-taskCenter-execute-rate-item">
<div class="ms-taskCenter-execute-rate-item-label">{{ t('ms.taskCenter.passThreshold') }}</div>
<div class="ms-taskCenter-execute-rate-item-value">{{ record.passThreshold }}</div>
</div>
<div class="ms-taskCenter-execute-rate-item">
<div class="ms-taskCenter-execute-rate-item-label">
{{ record.testPlanId ? t('ms.taskCenter.executeFinishedRate') : t('ms.taskCenter.executeProgress') }}
{{ t('ms.taskCenter.executeFinishedRate') }}
</div>
<div class="ms-taskCenter-execute-rate-item-value">
{{ `${((record.unExecuteCount / record.caseCount) * 100).toFixed(2)}%` }}
{{ `${record.executeRate}%` }}
</div>
</div>
<div class="ms-taskCenter-execute-rate-item">
@ -62,7 +63,7 @@
></div>
{{ t(executeFinishedRateMap.UN_EXECUTE.label) }}
</div>
<div class="ms-taskCenter-execute-rate-item-value">{{ record.unExecuteCount }}</div>
<div class="ms-taskCenter-execute-rate-item-value">{{ record.pendingCount }}</div>
</div>
<div class="ms-taskCenter-execute-rate-item">
<div class="ms-taskCenter-execute-rate-item-label">
@ -82,16 +83,6 @@
</div>
<div class="ms-taskCenter-execute-rate-item-value">{{ record.fakeErrorCount }}</div>
</div>
<div v-if="record.testPlanId" class="ms-taskCenter-execute-rate-item">
<div class="ms-taskCenter-execute-rate-item-label">
<div
:class="`ms-taskCenter-execute-rate-item-label-point`"
:style="{ backgroundColor: executeFinishedRateMap.BLOCK.color }"
></div>
{{ t(executeFinishedRateMap.BLOCK.label) }}
</div>
<div class="ms-taskCenter-execute-rate-item-value">{{ record.blockCount }}</div>
</div>
<div class="ms-taskCenter-execute-rate-item">
<div class="ms-taskCenter-execute-rate-item-label">
<div
@ -106,17 +97,29 @@
</a-popover>
</template>
<template #action="{ record }">
<MsButton v-permission="['SYSTEM_USER:READ+DELETE']" @click="stopTask(record)">
<MsButton
v-if="[ExecuteStatusEnum.RUNNING, ExecuteStatusEnum.RERUNNING].includes(record.status)"
v-permission="['SYSTEM_USER:READ+DELETE']"
@click="stopTask(record)"
>
{{ t('common.stop') }}
</MsButton>
<MsButton v-permission="['SYSTEM_USER:READ+DELETE']" @click="deleteTask(record)">
<MsButton v-else v-permission="['SYSTEM_USER:READ+DELETE']" @click="deleteTask(record)">
{{ t('common.delete') }}
</MsButton>
<MsButton v-permission="['SYSTEM_USER:READ+DELETE']" @click="rerunTask(record)">
<MsButton
v-if="record.status === ExecuteStatusEnum.COMPLETED && record.result === ExecuteResultEnum.ERROR"
v-permission="['SYSTEM_USER:READ+DELETE']"
@click="rerunTask(record)"
>
{{ t('ms.taskCenter.rerun') }}
</MsButton>
<MsButton v-permission="['SYSTEM_USER:READ+DELETE']" @click="checkReport(record)">
{{ t('ms.taskCenter.checkReport') }}
<MsButton
v-if="record.status === ExecuteStatusEnum.COMPLETED"
v-permission="['SYSTEM_USER:READ+DELETE']"
@click="checkReport(record)"
>
{{ t('ms.taskCenter.executeResult') }}
</MsButton>
</template>
</ms-base-table>
@ -135,6 +138,14 @@
import execStatus from './execStatus.vue';
import executionStatus from './executionStatus.vue';
import {
getOrganizationExecuteTaskList,
getOrganizationExecuteTaskStatistics,
getProjectExecuteTaskList,
getProjectExecuteTaskStatistics,
getSystemExecuteTaskList,
getSystemExecuteTaskStatistics,
} from '@/api/modules/taskCenter';
import { useI18n } from '@/hooks/useI18n';
import useModal from '@/hooks/useModal';
import useTableStore from '@/hooks/useTableStore';
@ -143,12 +154,16 @@
import { TableKeyEnum } from '@/enums/tableEnum';
import { FilterSlotNameEnum } from '@/enums/tableFilterEnum';
import { ExecuteResultEnum, ExecuteStatusEnum } from '@/enums/taskCenter';
import { executeFinishedRateMap, executeMethodMap, executeResultMap, executeStatusMap } from './utils';
import { executeFinishedRateMap, executeMethodMap, executeResultMap, executeStatusMap } from './config';
const props = defineProps<{
type: 'system' | 'project' | 'org';
}>();
const emit = defineEmits<{
(e: 'goDetail', id: string): void;
}>();
const { t } = useI18n();
const { openModal } = useModal();
@ -160,25 +175,27 @@
const columns: MsTableColumn = [
{
title: 'ID',
dataIndex: 'num',
slotName: 'num',
width: 100,
dataIndex: 'id',
slotName: 'id',
width: 180,
columnSelectorDisabled: true,
fixed: 'left',
},
{
title: 'ms.taskCenter.taskName',
dataIndex: 'name',
dataIndex: 'taskName',
showTooltip: true,
width: 200,
fixed: 'left',
},
{
title: 'ms.taskCenter.executeStatus',
dataIndex: 'executeStatus',
slotName: 'executeStatus',
dataIndex: 'status',
slotName: 'status',
width: 90,
filterConfig: {
options: Object.keys(executeStatusMap).map((key) => ({
label: t(executeStatusMap[key].label),
label: t(executeStatusMap[key as ExecuteStatusEnum].label),
value: key,
})),
filterSlotName: FilterSlotNameEnum.GLOBAL_TASK_CENTER_EXEC_STATUS,
@ -186,7 +203,8 @@
},
{
title: 'ms.taskCenter.executeMethod',
dataIndex: 'executeMethod',
dataIndex: 'triggerMode',
slotName: 'triggerMode',
width: 90,
filterConfig: {
options: Object.keys(executeMethodMap).map((key) => ({
@ -198,8 +216,8 @@
},
{
title: 'ms.taskCenter.executeResult',
dataIndex: 'executeResult',
slotName: 'executeResult',
dataIndex: 'result',
slotName: 'result',
width: 90,
filterConfig: {
options: Object.keys(executeResultMap).map((key) => ({
@ -217,8 +235,8 @@
},
{
title: 'ms.taskCenter.executeFinishedRate',
dataIndex: 'executeFinishedRate',
slotName: 'executeFinishedRate',
dataIndex: 'executeRate',
slotName: 'executeRate',
width: 100,
},
{
@ -248,18 +266,24 @@
sorter: true,
},
},
{
title: 'ms.taskCenter.operationUser',
dataIndex: 'createUser',
width: 100,
showTooltip: true,
},
{
title: 'common.operation',
slotName: 'action',
dataIndex: 'operation',
fixed: 'right',
width: 220,
width: 180,
},
];
if (props.type === 'system') {
columns.splice(
1,
2,
0,
{
title: 'common.belongProject',
@ -275,7 +299,7 @@
}
);
} else if (props.type === 'org') {
columns.splice(1, 0, {
columns.splice(2, 0, {
title: 'common.belongProject',
dataIndex: 'belongProject',
showTooltip: true,
@ -283,6 +307,18 @@
});
}
const currentExecuteTaskList = {
system: getSystemExecuteTaskList,
project: getProjectExecuteTaskList,
org: getOrganizationExecuteTaskList,
}[props.type];
const currentExecuteTaskStatistics = {
system: getSystemExecuteTaskStatistics,
project: getProjectExecuteTaskStatistics,
org: getOrganizationExecuteTaskStatistics,
}[props.type];
const tableBatchActions = {
baseAction: [
{
@ -300,33 +336,7 @@
],
};
const { propsRes, propsEvent, loadList, setLoadListParams, resetSelector } = useTable(
() =>
Promise.resolve({
list: [
{
id: '1',
num: 10086,
name: '测试任务',
belongProject: '测试项目',
belongOrg: '测试组织',
executeStatus: 'PENDING',
executeMethod: '手动执行',
executeResult: 'SUCCESS',
caseCount: 100,
executeFinishedRate: '100%',
startTime: 1630000000000,
createTime: 1630000000000,
endTime: 1630000000000,
passThreshold: '100%',
unExecuteCount: 0,
successCount: 100,
fakeErrorCount: 0,
blockCount: 0,
errorCount: 0,
},
],
total: 1,
}),
currentExecuteTaskList,
{
tableKey: TableKeyEnum.TASK_CENTER_CASE_TASK,
scroll: { x: '1000px' },
@ -350,14 +360,14 @@
}
function showTaskDetail(id: string) {
console.log('showTaskDetail', id);
emit('goDetail', id);
}
/**
* 删除任务
*/
function deleteTask(record?: any, isBatch?: boolean, params?: BatchActionQueryParams) {
let title = t('ms.taskCenter.deleteTaskTitle', { name: characterLimit(record?.name) });
let title = t('ms.taskCenter.deleteTaskTitle', { name: characterLimit(record?.taskName) });
let selectIds = [record?.id || ''];
if (isBatch) {
title = t('ms.taskCenter.deleteCaseTaskTitle', {
@ -396,7 +406,7 @@
}
function stopTask(record?: any, isBatch?: boolean, params?: BatchActionQueryParams) {
let title = t('ms.taskCenter.stopTaskTitle', { name: characterLimit(record?.name) });
let title = t('ms.taskCenter.stopTaskTitle', { name: characterLimit(record?.taskName) });
let selectIds = [record?.id || ''];
if (isBatch) {
title = t('ms.taskCenter.batchStopTaskTitle', {
@ -458,8 +468,34 @@
console.log('checkReport', record);
}
onMounted(() => {
loadList();
async function initTaskStatistics() {
try {
const res = await currentExecuteTaskStatistics(propsRes.value.data.map((item) => item.id));
res.forEach((item) => {
const target = propsRes.value.data.find((task) => task.id === item.id);
if (target) {
target.executeRate = item.executeRate;
target.pendingCount = item.pendingCount;
target.successCount = item.successCount;
target.fakeErrorCount = item.fakeErrorCount;
target.errorCount = item.errorCount;
target.caseTotal = item.caseTotal;
}
});
} catch (error) {
// eslint-disable-next-line no-console
console.log(error);
}
}
async function refresh() {
await loadList();
initTaskStatistics();
}
onMounted(async () => {
await loadList();
initTaskStatistics();
});
await tableStore.initColumn(TableKeyEnum.TASK_CENTER_CASE_TASK, columns, 'drawer');

View File

@ -0,0 +1,90 @@
import type { ExecuteStatusEnum } from '@/enums/taskCenter';
// 执行结果
export const executeResultMap: Record<string, any> = {
SUCCESS: {
icon: 'icon-icon_succeed_colorful',
label: 'common.success',
color: 'rgb(var(--success-6))',
},
ERROR: {
icon: 'icon-icon_close_colorful',
label: 'common.fail',
color: 'rgb(var(--danger-6))',
},
FAKE_ERROR: {
icon: 'icon-icon_warning_colorful',
label: 'common.fakeError',
color: 'rgb(var(--warning-6))',
},
};
// 执行完成率
export const executeFinishedRateMap: Record<string, any> = {
SUCCESS: {
label: 'common.success',
color: 'rgb(var(--success-6))',
},
ERROR: {
label: 'common.fail',
color: 'rgb(var(--danger-6))',
},
FAKE_ERROR: {
label: 'common.fakeError',
color: 'rgb(var(--warning-6))',
},
BLOCK: {
label: 'common.block',
color: 'rgb(179,121,200)',
},
UN_EXECUTE: {
label: 'common.unExecute',
color: 'var(--color-text-4)',
},
};
// 执行状态
export const executeStatusMap: Record<ExecuteStatusEnum, any> = {
PENDING: {
label: 'common.unExecute',
color: 'var(--color-text-n8)',
class: '!text-[var(--color-text-1)]',
},
RUNNING: {
label: 'common.running',
color: 'rgb(var(--link-2))',
class: '!text-[rgb(var(--link-6))]',
},
STOPPED: {
label: 'common.stopped',
color: 'rgb(var(--warning-2))',
class: '!text-[rgb(var(--warning-6))]',
},
COMPLETED: {
label: 'common.completed',
color: 'rgb(var(--success-2))',
class: '!text-[rgb(var(--success-6))]',
},
RERUNNING: {
label: 'ms.taskCenter.failRerun',
color: 'rgb(var(--link-2))',
class: '!text-[rgb(var(--link-6))]',
},
};
// 执行方式
export const executeMethodMap: Record<string, any> = {
MANUAL: 'ms.taskCenter.execute',
BATCH: 'ms.taskCenter.batchExecute',
API: 'ms.taskCenter.interfaceCall',
SCHEDULE: 'ms.taskCenter.scheduledTask',
};
// 系统后台任务类型
export const scheduleTaskTypeMap: Record<string, any> = {
API_IMPORT: 'ms.taskCenter.apiImport',
API_SCENARIO: 'ms.taskCenter.apiScenario',
BUG_SYNC: 'ms.taskCenter.thirdPartSync',
DEMAND_SYNC: 'ms.taskCenter.thirdPartSync',
TEST_PLAN: 'menu.testPlan',
};

View File

@ -13,7 +13,7 @@
import { ReportExecStatus } from '@/enums/apiEnum';
import { executeStatusMap } from './utils';
import { executeStatusMap } from './config';
const props = defineProps<{
status: ReportExecStatus;

View File

@ -24,7 +24,7 @@
import { TaskCenterEnum } from '@/enums/taskCenter';
import { executeResultMap } from './utils';
import { executeResultMap } from './config';
const { t } = useI18n();
const props = defineProps<{

View File

@ -67,7 +67,7 @@
import { ReportExecStatus } from '@/enums/apiEnum';
import { executeResultMap } from './utils';
import { executeResultMap } from './config';
const props = defineProps<{
id: string;

View File

@ -16,12 +16,25 @@
<ms-base-table
v-bind="propsRes"
:action-config="tableBatchActions"
no-disable
v-on="propsEvent"
@batch-action="handleTableBatch"
>
<template #num="{ record }">
<a-button type="text" class="max-w-full justify-start px-0" @click="openTask(record.id)">
<a-tooltip :content="record.id">
<div class="one-line-text">
{{ record.num }}
</div>
</a-tooltip>
</a-button>
</template>
<template #status="{ record }">
<a-switch v-model:model-value="record.enable" size="small"></a-switch>
</template>
<template #resourceType="{ record }">
{{ t(scheduleTaskTypeMap[record.resourceType]) }}
</template>
<template #action="{ record }">
<MsButton v-permission="['SYSTEM_USER:READ+DELETE']" @click="deleteTask(record)">
{{ t('common.delete') }}
@ -41,6 +54,7 @@
import useTable from '@/components/pure/ms-table/useTable';
import MsTag from '@/components/pure/ms-tag/ms-tag.vue';
import { getOrganizationScheduleList, getProjectScheduleList, getSystemScheduleList } from '@/api/modules/taskCenter';
import { useI18n } from '@/hooks/useI18n';
import useModal from '@/hooks/useModal';
import useTableStore from '@/hooks/useTableStore';
@ -49,6 +63,12 @@
import { TableKeyEnum } from '@/enums/tableEnum';
import { scheduleTaskTypeMap } from './config';
const props = defineProps<{
type: 'system' | 'project' | 'org';
}>();
const { t } = useI18n();
const { openModal } = useModal();
const tableStore = useTableStore();
@ -60,13 +80,16 @@
{
title: 'ID',
dataIndex: 'num',
slotName: 'num',
width: 100,
fixed: 'left',
},
{
title: 'ms.taskCenter.taskName',
dataIndex: 'name',
dataIndex: 'taskName',
showTooltip: true,
width: 200,
fixed: 'left',
},
{
title: 'common.status',
@ -76,19 +99,20 @@
},
{
title: 'ms.taskCenter.type',
dataIndex: 'type',
slotName: 'type',
dataIndex: 'resourceType',
slotName: 'resourceType',
width: 120,
},
{
title: 'ms.taskCenter.runRule',
dataIndex: 'rule',
width: 100,
dataIndex: 'value',
width: 120,
},
{
title: 'ms.taskCenter.operationUser',
dataIndex: 'operationUser',
width: 100,
dataIndex: 'createUserName',
width: 150,
showTooltip: true,
},
{
title: 'ms.taskCenter.operationTime',
@ -125,6 +149,32 @@
width: 60,
},
];
if (props.type === 'system') {
columns.splice(1, 0, [
{
title: 'common.belongProject',
dataIndex: 'belongProject',
showTooltip: true,
width: 100,
},
{
title: 'common.belongOrg',
dataIndex: 'belongOrg',
showTooltip: true,
width: 100,
},
]);
} else if (props.type === 'org') {
columns.splice(1, 0, [
{
title: 'common.belongProject',
dataIndex: 'belongProject',
showTooltip: true,
width: 100,
},
]);
}
await tableStore.initColumn(TableKeyEnum.TASK_CENTER_SYSTEM_TASK, columns, 'drawer');
const tableBatchActions = {
@ -139,26 +189,15 @@
},
],
};
const currentScheduleList = {
system: getSystemScheduleList,
org: getOrganizationScheduleList,
project: getProjectScheduleList,
}[props.type];
const { propsRes, propsEvent, loadList, setLoadListParams, resetSelector } = useTable(
() =>
Promise.resolve({
list: [
{
id: '1',
num: 10086,
name: '测试任务',
status: 'success',
type: 'API 导入',
rule: '每 1 小时',
enable: true,
operationUser: 'admin',
operationTime: '2021-09-01 12:00:00',
lastFinishTime: '2021-09-01 12:00:00',
nextExecuteTime: '2021-09-01 12:00:00',
},
],
total: 1,
}),
currentScheduleList,
{
tableKey: TableKeyEnum.TASK_CENTER_SYSTEM_TASK,
scroll: { x: '100%' },
@ -186,7 +225,7 @@
* 删除任务
*/
function deleteTask(record?: any, isBatch?: boolean, params?: BatchActionQueryParams) {
let title = t('ms.taskCenter.deleteTaskTitle', { name: characterLimit(record?.name) });
let title = t('ms.taskCenter.deleteTaskTitle', { name: characterLimit(record?.taskName) });
let selectIds = [record?.id || ''];
if (isBatch) {
title = t('ms.taskCenter.deleteTimeTaskTitle', {

View File

@ -1,148 +0,0 @@
import type { MsTableColumnData } from '@/components/pure/ms-table/type';
import { useI18n } from '@/hooks/useI18n';
import { useAppStore } from '@/store';
import useLicenseStore from '@/store/modules/setting/license';
import { hasAnyPermission } from '@/utils/permission';
import { TableKeyEnum } from '@/enums/tableEnum';
import { FilterRemoteMethodsEnum } from '@/enums/tableFilterEnum';
const { t } = useI18n();
// 执行结果
export const executeResultMap: Record<string, any> = {
SUCCESS: {
icon: 'icon-icon_succeed_colorful',
label: 'common.success',
color: 'rgb(var(--success-6))',
},
ERROR: {
icon: 'icon-icon_close_colorful',
label: 'common.fail',
color: 'rgb(var(--danger-6))',
},
FAKE_ERROR: {
icon: 'icon-icon_warning_colorful',
label: 'common.fakeError',
color: 'rgb(var(--warning-6))',
},
};
// 执行完成率
export const executeFinishedRateMap: Record<string, any> = {
SUCCESS: {
label: 'common.success',
color: 'rgb(var(--success-6))',
},
ERROR: {
label: 'common.fail',
color: 'rgb(var(--danger-6))',
},
FAKE_ERROR: {
label: 'common.fakeError',
color: 'rgb(var(--warning-6))',
},
BLOCK: {
label: 'common.block',
color: 'rgb(179,121,200)',
},
UN_EXECUTE: {
label: 'common.unExecute',
color: 'var(--color-text-4)',
},
};
// 执行状态
export const executeStatusMap: Record<string, any> = {
PENDING: {
label: 'common.unExecute',
color: 'var(--color-text-n8)',
class: '!text-[var(--color-text-1)]',
},
RUNNING: {
label: 'common.running',
color: 'rgb(var(--link-2))',
class: '!text-[rgb(var(--link-6))]',
},
STOPPED: {
label: 'common.stopped',
color: 'rgb(var(--warning-2))',
class: '!text-[rgb(var(--warning-6))]',
},
COMPLETED: {
label: 'common.completed',
color: 'rgb(var(--success-2))',
class: '!text-[rgb(var(--success-6))]',
},
RERUNNING: {
label: 'ms.taskCenter.failRerun',
color: 'rgb(var(--link-2))',
class: '!text-[rgb(var(--link-6))]',
},
};
// 执行方式
export const executeMethodMap: Record<string, any> = {
MANUAL: 'ms.taskCenter.execute',
BATCH: 'ms.taskCenter.batchExecute',
API: 'ms.taskCenter.interfaceCall',
SCHEDULE: 'ms.taskCenter.scheduledTask',
};
export type Group = 'system' | 'organization' | 'project';
export function getOrgColumns(): MsTableColumnData {
const licenseStore = useLicenseStore();
const config: MsTableColumnData = {
title: 'project.belongOrganization',
dataIndex: 'organizationIds',
slotName: 'organizationName',
showDrag: true,
width: 200,
showInTable: true,
};
if (licenseStore.hasLicense()) {
config.filterConfig = {
mode: 'remote',
remoteMethod: FilterRemoteMethodsEnum.SYSTEM_ORGANIZATION_LIST,
placeholderText: t('project.taskCenter.filterOrgPlaceholderText'),
};
}
return config;
}
export function getProjectColumns(key: TableKeyEnum): MsTableColumnData {
const appStore = useAppStore();
const systemKey = [
TableKeyEnum.TASK_CENTER_CASE_TASK,
TableKeyEnum.TASK_SCHEDULE_TASK_API_IMPORT_SYSTEM,
TableKeyEnum.TASK_SCHEDULE_TASK_API_SCENARIO_SYSTEM,
];
const filterKeyPermission = systemKey.includes(key)
? hasAnyPermission(['SYSTEM_ORGANIZATION_PROJECT:READ'])
: hasAnyPermission(['ORGANIZATION_PROJECT:READ']);
const remoteMethod = systemKey.includes(key)
? FilterRemoteMethodsEnum.SYSTEM_PROJECT_LIST
: FilterRemoteMethodsEnum.SYSTEM_ORGANIZATION_PROJECT;
const config: MsTableColumnData = {
title: 'project.belongProject',
dataIndex: 'projectIds',
slotName: 'projectName',
showDrag: true,
width: 200,
showInTable: true,
};
if (filterKeyPermission && remoteMethod) {
config.filterConfig = {
mode: 'remote',
loadOptionParams: {
organizationId: appStore.currentOrgId,
},
remoteMethod,
placeholderText: t('project.taskCenter.filterProPlaceholderText'),
};
}
return config;
}

View File

@ -4,11 +4,13 @@
<a-tab-pane v-for="item of tabList" :key="item.value" :title="item.label" />
</a-tabs>
<a-divider margin="0"></a-divider>
<Suspense>
<caseTaskTable v-if="activeTab === TaskCenterEnum.CASE" :type="props.type" />
<caseTaskDetailTable v-else-if="activeTab === TaskCenterEnum.DETAIL" :type="props.type" />
<systemTaskTable v-else-if="activeTab === TaskCenterEnum.BACKEND" />
</Suspense>
<div class="ms-taskCenter-content">
<Suspense>
<caseTaskTable v-if="activeTab === TaskCenterEnum.CASE" :type="props.type" @go-detail="goTaskDetail" />
<caseTaskDetailTable v-else-if="activeTab === TaskCenterEnum.DETAIL" :id="activeTaskId" :type="props.type" />
<systemTaskTable v-else-if="activeTab === TaskCenterEnum.BACKEND" :type="props.type" />
</Suspense>
</div>
</div>
</template>
@ -47,6 +49,12 @@
]);
const activeTab = ref<TaskCenterEnum>((route.query.type as TaskCenterEnum) || TaskCenterEnum.CASE);
const activeTaskId = ref('');
function goTaskDetail(id: string) {
activeTaskId.value = id;
activeTab.value = TaskCenterEnum.DETAIL;
}
</script>
<style scoped lang="less">

View File

@ -50,4 +50,7 @@ export default {
'ms.taskCenter.scheduledTask': 'Scheduled Execution',
'ms.taskCenter.batchCaseTask': 'Batch Case Execution Task',
'ms.taskCenter.batchScenarioTask': 'Batch Scenario Execution Task',
'ms.taskCenter.apiImport': 'API Import',
'ms.taskCenter.apiScenario': 'Api Scenario',
'ms.taskCenter.thirdPartSync': 'Third-party sync',
};

View File

@ -50,4 +50,7 @@ export default {
'ms.taskCenter.scheduledTask': '定时执行',
'ms.taskCenter.batchCaseTask': '用例批量执行任务',
'ms.taskCenter.batchScenarioTask': '场景批量执行任务',
'ms.taskCenter.apiImport': 'API导入',
'ms.taskCenter.apiScenario': '接口场景',
'ms.taskCenter.thirdPartSync': '第三方同步',
};