fix(任务中心): bugFix

This commit is contained in:
baiqi 2024-10-25 11:09:32 +08:00 committed by Craftsman
parent 1ee17c14bf
commit 53982f7bee
10 changed files with 104 additions and 26 deletions

View File

@ -184,9 +184,9 @@ export interface SetPaginationPrams {
export interface BatchActionQueryParams { export interface BatchActionQueryParams {
excludeIds?: string[]; // 排除的id excludeIds?: string[]; // 排除的id
selectedIds?: string[]; selectedIds?: string[];
selectIds?: string[]; // 选中的id
selectAll: boolean; // 是否跨页全选 selectAll: boolean; // 是否跨页全选
params?: TableQueryParams; // 查询参数 params?: TableQueryParams; // 查询参数
currentSelectCount?: number; // 当前选中的数量 currentSelectCount?: number; // 当前选中的数量
condition?: any; // 查询条件 condition?: any; // 查询条件
[key: string]: any;
} }

View File

@ -23,6 +23,8 @@ export enum FilterSlotNameEnum {
GLOBAL_TASK_CENTER_EXEC_RESULT = 'GLOBAL_TASK_CENTER_EXEC_RESULT', // 任务中心-执行结果 GLOBAL_TASK_CENTER_EXEC_RESULT = 'GLOBAL_TASK_CENTER_EXEC_RESULT', // 任务中心-执行结果
GLOBAL_TASK_CENTER_EXEC_METHOD = 'GLOBAL_TASK_CENTER_EXEC_METHOD', // 任务中心-执行方式 GLOBAL_TASK_CENTER_EXEC_METHOD = 'GLOBAL_TASK_CENTER_EXEC_METHOD', // 任务中心-执行方式
GLOBAL_TASK_CENTER_SYSTEM_TASK_TYPE = 'GLOBAL_TASK_CENTER_SYSTEM_TASK_TYPE', // 任务中心-后台任务类型 GLOBAL_TASK_CENTER_SYSTEM_TASK_TYPE = 'GLOBAL_TASK_CENTER_SYSTEM_TASK_TYPE', // 任务中心-后台任务类型
GLOBAL_TASK_CENTER_SYSTEM_TASK_STATUS = 'GLOBAL_TASK_CENTER_SYSTEM_TASK_STATUS', // 任务中心-后台任务状态
GLOBAL_TASK_CENTER_BELONG_PROJECT = 'GLOBAL_TASK_CENTER_BELONG_PROJECT', // 任务中心-所属项目
} }
export enum FilterRemoteMethodsEnum { export enum FilterRemoteMethodsEnum {

View File

@ -68,7 +68,7 @@ const useAppStore = defineStore('app', {
}, },
packageType: '', packageType: '',
projectList: [] as ProjectListItem[], projectList: [] as ProjectListItem[],
ordList: [], orgList: [],
envList: [], envList: [],
currentEnvConfig: undefined, currentEnvConfig: undefined,
fileMaxSize: 50, fileMaxSize: 50,
@ -231,8 +231,8 @@ const useAppStore = defineStore('app', {
/** /**
* *
*/ */
setOrdList(ordList: { id: string; name: string }[]) { setOrdList(orgList: { id: string; name: string }[]) {
this.ordList = ordList; this.orgList = orgList;
}, },
/** /**
* *

View File

@ -42,7 +42,7 @@ export interface AppState {
currentMenuConfig: string[]; currentMenuConfig: string[];
packageType: string; packageType: string;
projectList: ProjectListItem[]; projectList: ProjectListItem[];
ordList: { id: string; name: string }[]; orgList: { id: string; name: string }[];
envList: EnvironmentItem[]; envList: EnvironmentItem[];
currentEnvConfig?: EnvConfig; // 当前环境配置信息 currentEnvConfig?: EnvConfig; // 当前环境配置信息
fileMaxSize: number; // 文件上传最大限制 fileMaxSize: number; // 文件上传最大限制

View File

@ -24,7 +24,7 @@
@drag-change="changeHandler" @drag-change="changeHandler"
> >
<template #num="{ record }"> <template #num="{ record }">
<div> <div class="flex items-center">
<MsButton type="text" class="float-left" style="margin-right: 4px" @click="openScenarioTab(record)"> <MsButton type="text" class="float-left" style="margin-right: 4px" @click="openScenarioTab(record)">
{{ record.num }} {{ record.num }}
</MsButton> </MsButton>

View File

@ -136,7 +136,7 @@
import executeButton from '@/views/api-test/components/executeButton.vue'; import executeButton from '@/views/api-test/components/executeButton.vue';
import ScenarioTable from '@/views/api-test/scenario/components/scenarioTable.vue'; import ScenarioTable from '@/views/api-test/scenario/components/scenarioTable.vue';
import { localExecuteApiDebug, stopExecute, stopLocalExecute } from '@/api/modules/api-test/common'; import { localExecuteApiDebug, stopLocalExecute } from '@/api/modules/api-test/common';
import { import {
addScenario, addScenario,
debugScenario, debugScenario,
@ -146,6 +146,7 @@
updateScenario, updateScenario,
} from '@/api/modules/api-test/scenario'; } from '@/api/modules/api-test/scenario';
import { getSocket } from '@/api/modules/project-management/commonScript'; import { getSocket } from '@/api/modules/project-management/commonScript';
import { projectStopTask } from '@/api/modules/taskCenter/project';
import { useI18n } from '@/hooks/useI18n'; import { useI18n } from '@/hooks/useI18n';
import useLeaveTabUnSaveCheck from '@/hooks/useLeaveTabUnSaveCheck'; import useLeaveTabUnSaveCheck from '@/hooks/useLeaveTabUnSaveCheck';
import useShortcutSave from '@/hooks/useShortcutSave'; import useShortcutSave from '@/hooks/useShortcutSave';
@ -258,6 +259,7 @@
}); });
} }
const executeTaskId = ref('');
/** /**
* 实际执行函数 * 实际执行函数
* @param executeParams 执行参数 * @param executeParams 执行参数
@ -326,6 +328,7 @@
}), }),
}); });
} }
executeTaskId.value = res.taskInfo?.taskId;
if (executeType === 'localExec' && localExecuteUrl.value) { if (executeType === 'localExec' && localExecuteUrl.value) {
// debug // debug
await localExecuteApiDebug(localExecuteUrl.value, res); await localExecuteApiDebug(localExecuteUrl.value, res);
@ -385,7 +388,7 @@
ScenarioStepType.API_SCENARIO ScenarioStepType.API_SCENARIO
); );
} else { } else {
await stopExecute(activeScenarioTab.value.reportId, ScenarioStepType.API_SCENARIO); await projectStopTask(executeTaskId.value);
} }
} catch (error) { } catch (error) {
// eslint-disable-next-line no-console // eslint-disable-next-line no-console

View File

@ -148,7 +148,7 @@
const orgName = computed(() => { const orgName = computed(() => {
if (licenseStore.hasLicense()) { if (licenseStore.hasLicense()) {
return appStore.ordList.find((item: any) => item.id === appStore.currentOrgId)?.name; return appStore.orgList.find((item: any) => item.id === appStore.currentOrgId)?.name;
} }
return '默认组织'; return '默认组织';
}); });

View File

@ -21,7 +21,7 @@
:virtual-list-props="{ height: 200 }" :virtual-list-props="{ height: 200 }"
strictly strictly
label-path-mode label-path-mode
@clear="searchTask" @clear="clearResourcePools"
@popup-visible-change="handleResourcePoolVisibleChange" @popup-visible-change="handleResourcePoolVisibleChange"
@change="handleResourcePoolChange" @change="handleResourcePoolChange"
> >
@ -317,6 +317,13 @@
showTooltip: true, showTooltip: true,
width: 200, width: 200,
showDrag: true, showDrag: true,
filterConfig: {
options: appStore.projectList.map((item) => ({
label: item.name,
value: item.id,
})),
filterSlotName: FilterSlotNameEnum.GLOBAL_TASK_CENTER_BELONG_PROJECT,
},
}, },
{ {
title: 'common.belongOrg', title: 'common.belongOrg',
@ -324,6 +331,13 @@
showTooltip: true, showTooltip: true,
width: 200, width: 200,
showDrag: true, showDrag: true,
filterConfig: {
options: appStore.orgList.map((item) => ({
label: item.name,
value: item.id,
})),
filterSlotName: FilterSlotNameEnum.GLOBAL_TASK_CENTER_BELONG_PROJECT,
},
} }
); );
} else if (props.type === 'org') { } else if (props.type === 'org') {
@ -333,6 +347,13 @@
showTooltip: true, showTooltip: true,
width: 200, width: 200,
showDrag: true, showDrag: true,
filterConfig: {
options: appStore.projectList.map((item) => ({
label: item.name,
value: item.id,
})),
filterSlotName: FilterSlotNameEnum.GLOBAL_TASK_CENTER_BELONG_PROJECT,
},
}); });
} }
@ -407,6 +428,12 @@
} }
} }
function clearResourcePools() {
resourcePoolIds.value = new Set([]);
resourcePoolNodes.value = new Set([]);
searchTask();
}
function handleResourcePoolChange(value: string[]) { function handleResourcePoolChange(value: string[]) {
if (resourcePool.value.length < value.length) { if (resourcePool.value.length < value.length) {
// //
@ -455,12 +482,10 @@
function stopTask(record?: TaskCenterTaskDetailItem, isBatch?: boolean, params?: BatchActionQueryParams) { function stopTask(record?: TaskCenterTaskDetailItem, isBatch?: boolean, params?: BatchActionQueryParams) {
let title = t('ms.taskCenter.stopTaskTitle', { name: characterLimit(record?.taskName) }); let title = t('ms.taskCenter.stopTaskTitle', { name: characterLimit(record?.taskName) });
let selectIds = [record?.id || ''];
if (isBatch) { if (isBatch) {
title = t('ms.taskCenter.batchStopTaskTitle', { title = t('ms.taskCenter.batchStopTaskTitle', {
count: params?.currentSelectCount || tableSelected.value.length, count: params?.currentSelectCount || tableSelected.value.length,
}); });
selectIds = tableSelected.value as string[];
} }
openModal({ openModal({
type: 'warning', type: 'warning',
@ -476,7 +501,7 @@
try { try {
if (isBatch) { if (isBatch) {
await currentBatchStopTask({ await currentBatchStopTask({
selectIds, selectIds: params?.selectedIds || [],
selectAll: !!params?.selectAll, selectAll: !!params?.selectAll,
excludeIds: params?.excludeIds || [], excludeIds: params?.excludeIds || [],
...getTableQueryParams(), ...getTableQueryParams(),
@ -586,7 +611,7 @@
if (queue) { if (queue) {
item.lineNum = queue; item.lineNum = queue;
} else if ( } else if (
[ExecuteStatusEnum.COMPLETED, ExecuteStatusEnum.STOPPED].includes(item.status) || [ExecuteStatusEnum.COMPLETED, ExecuteStatusEnum.STOPPED, ExecuteStatusEnum.RUNNING].includes(item.status) ||
!item.resourcePoolNode !item.resourcePoolNode
) { ) {
item.lineNum = '-'; item.lineNum = '-';

View File

@ -238,8 +238,6 @@
const appStore = useAppStore(); const appStore = useAppStore();
const keyword = ref(''); const keyword = ref('');
const tableSelected = ref<string[]>([]);
const batchModalParams = ref();
const columns: MsTableColumn = [ const columns: MsTableColumn = [
{ {
title: 'ms.taskCenter.taskID', title: 'ms.taskCenter.taskID',
@ -381,6 +379,13 @@
showTooltip: true, showTooltip: true,
showDrag: true, showDrag: true,
width: 200, width: 200,
filterConfig: {
options: appStore.projectList.map((item) => ({
label: item.name,
value: item.id,
})),
filterSlotName: FilterSlotNameEnum.GLOBAL_TASK_CENTER_BELONG_PROJECT,
},
}, },
{ {
title: 'common.belongOrg', title: 'common.belongOrg',
@ -388,6 +393,13 @@
showTooltip: true, showTooltip: true,
showDrag: true, showDrag: true,
width: 200, width: 200,
filterConfig: {
options: appStore.orgList.map((item) => ({
label: item.name,
value: item.id,
})),
filterSlotName: FilterSlotNameEnum.GLOBAL_TASK_CENTER_BELONG_PROJECT,
},
} }
); );
} else if (props.type === 'org') { } else if (props.type === 'org') {
@ -397,6 +409,13 @@
showTooltip: true, showTooltip: true,
showDrag: true, showDrag: true,
width: 200, width: 200,
filterConfig: {
options: appStore.projectList.map((item) => ({
label: item.name,
value: item.id,
})),
filterSlotName: FilterSlotNameEnum.GLOBAL_TASK_CENTER_BELONG_PROJECT,
},
}); });
} }
@ -542,12 +561,10 @@
*/ */
function deleteTask(record?: TaskCenterTaskItem, isBatch?: boolean, params?: BatchActionQueryParams) { function deleteTask(record?: TaskCenterTaskItem, isBatch?: boolean, params?: BatchActionQueryParams) {
let title = t('ms.taskCenter.deleteTaskTitle', { name: characterLimit(record?.taskName) }); let title = t('ms.taskCenter.deleteTaskTitle', { name: characterLimit(record?.taskName) });
let selectIds = [record?.id || ''];
if (isBatch) { if (isBatch) {
title = t('ms.taskCenter.deleteCaseTaskTitle', { title = t('ms.taskCenter.deleteCaseTaskTitle', {
count: params?.currentSelectCount || tableSelected.value.length, count: params?.currentSelectCount || (params?.selectedIds || []).length,
}); });
selectIds = tableSelected.value as string[];
} }
openModal({ openModal({
type: 'error', type: 'error',
@ -563,7 +580,7 @@
try { try {
if (isBatch) { if (isBatch) {
await currentBatchDeleteTask({ await currentBatchDeleteTask({
selectIds, selectIds: params?.selectedIds || [],
selectAll: !!params?.selectAll, selectAll: !!params?.selectAll,
excludeIds: params?.excludeIds || [], excludeIds: params?.excludeIds || [],
...getTableQueryParams(), ...getTableQueryParams(),
@ -600,12 +617,10 @@
*/ */
function stopTask(record?: TaskCenterTaskItem, isBatch?: boolean, params?: BatchActionQueryParams) { function stopTask(record?: TaskCenterTaskItem, isBatch?: boolean, params?: BatchActionQueryParams) {
let title = t('ms.taskCenter.stopTaskTitle', { name: characterLimit(record?.taskName) }); let title = t('ms.taskCenter.stopTaskTitle', { name: characterLimit(record?.taskName) });
let selectIds = [record?.id || ''];
if (isBatch) { if (isBatch) {
title = t('ms.taskCenter.batchStopTaskTitle', { title = t('ms.taskCenter.batchStopTaskTitle', {
count: params?.currentSelectCount || tableSelected.value.length, count: params?.currentSelectCount || (params?.selectedIds || []).length,
}); });
selectIds = tableSelected.value as string[];
} }
openModal({ openModal({
type: 'warning', type: 'warning',
@ -618,7 +633,7 @@
try { try {
if (isBatch) { if (isBatch) {
await currentBatchStopTask({ await currentBatchStopTask({
selectIds, selectIds: params?.selectedIds || [],
selectAll: !!params?.selectAll, selectAll: !!params?.selectAll,
excludeIds: params?.excludeIds || [], excludeIds: params?.excludeIds || [],
...getTableQueryParams(), ...getTableQueryParams(),
@ -643,8 +658,6 @@
* @param event 批量操作事件对象 * @param event 批量操作事件对象
*/ */
function handleTableBatch(event: BatchActionParams, params: BatchActionQueryParams) { function handleTableBatch(event: BatchActionParams, params: BatchActionQueryParams) {
tableSelected.value = params.selectedIds || [];
batchModalParams.value = params;
switch (event.eventTag) { switch (event.eventTag) {
case 'delete': case 'delete':
deleteTask(undefined, true, params); deleteTask(undefined, true, params);
@ -745,6 +758,7 @@
} else if ([ExecuteTaskType.TEST_PLAN_GROUP, ExecuteTaskType.TEST_PLAN].includes(record.taskType)) { } else if ([ExecuteTaskType.TEST_PLAN_GROUP, ExecuteTaskType.TEST_PLAN].includes(record.taskType)) {
openNewPage(TestPlanRouteEnum.TEST_PLAN_REPORT, { openNewPage(TestPlanRouteEnum.TEST_PLAN_REPORT, {
id: record.reportId, id: record.reportId,
type: record.taskType === ExecuteTaskType.TEST_PLAN_GROUP ? 'GROUP' : '',
}); });
} }
} }

View File

@ -164,6 +164,19 @@
slotName: 'status', slotName: 'status',
width: 50, width: 50,
showDrag: true, showDrag: true,
filterConfig: {
options: [
{
label: t('common.open'),
value: 'enable',
},
{
label: t('common.close'),
value: 'disable',
},
],
filterSlotName: FilterSlotNameEnum.GLOBAL_TASK_CENTER_SYSTEM_TASK_STATUS,
},
}, },
{ {
title: 'ms.taskCenter.type', title: 'ms.taskCenter.type',
@ -246,6 +259,13 @@
showTooltip: true, showTooltip: true,
width: 200, width: 200,
showDrag: true, showDrag: true,
filterConfig: {
options: appStore.projectList.map((item) => ({
label: item.name,
value: item.id,
})),
filterSlotName: FilterSlotNameEnum.GLOBAL_TASK_CENTER_BELONG_PROJECT,
},
}, },
{ {
title: 'common.belongOrg', title: 'common.belongOrg',
@ -253,6 +273,13 @@
showTooltip: true, showTooltip: true,
width: 200, width: 200,
showDrag: true, showDrag: true,
filterConfig: {
options: appStore.orgList.map((item) => ({
label: item.name,
value: item.id,
})),
filterSlotName: FilterSlotNameEnum.GLOBAL_TASK_CENTER_BELONG_PROJECT,
},
} }
); );
} else if (props.type === 'org') { } else if (props.type === 'org') {
@ -262,6 +289,13 @@
showTooltip: true, showTooltip: true,
width: 200, width: 200,
showDrag: true, showDrag: true,
filterConfig: {
options: appStore.projectList.map((item) => ({
label: item.name,
value: item.id,
})),
filterSlotName: FilterSlotNameEnum.GLOBAL_TASK_CENTER_BELONG_PROJECT,
},
}); });
} }