fix(任务中心): bugFix

This commit is contained in:
baiqi 2024-10-24 15:08:46 +08:00 committed by Craftsman
parent 7499e0d519
commit 6d5d5217e7
11 changed files with 108 additions and 55 deletions

View File

@ -22,6 +22,7 @@ export enum FilterSlotNameEnum {
GLOBAL_TASK_CENTER_EXEC_STATUS = 'GLOBAL_TASK_CENTER_EXEC_STATUS', // 任务中心-执行状态
GLOBAL_TASK_CENTER_EXEC_RESULT = 'GLOBAL_TASK_CENTER_EXEC_RESULT', // 任务中心-执行结果
GLOBAL_TASK_CENTER_EXEC_METHOD = 'GLOBAL_TASK_CENTER_EXEC_METHOD', // 任务中心-执行方式
GLOBAL_TASK_CENTER_SYSTEM_TASK_TYPE = 'GLOBAL_TASK_CENTER_SYSTEM_TASK_TYPE', // 任务中心-后台任务类型
}
export enum FilterRemoteMethodsEnum {

View File

@ -47,6 +47,7 @@ export enum SystemTaskType {
BUG_SYNC = 'BUG_SYNC',
DEMAND_SYNC = 'DEMAND_SYNC',
TEST_PLAN = 'TEST_PLAN',
TEST_PLAN_GROUP = 'TEST_PLAN_GROUP',
}
export enum ExecuteTaskType {

View File

@ -13,6 +13,7 @@ export interface TaskCenterSystemTaskItem {
resourceId: string; // 资源ID
num: number;
resourceType: string; // 资源类型
resourceNum: number; // 资源num
value: string;
nextTime: number;
enable: boolean;

View File

@ -25,13 +25,16 @@ const Setting: AppRouteRecordRaw = {
'SYSTEM_AUTH:READ',
'SYSTEM_PLUGIN:READ',
'SYSTEM_LOG:READ',
'SYSTEM_CASE_TASK_CENTER:READ',
'SYSTEM_SCHEDULE_TASK_CENTER:READ',
'ORGANIZATION_MEMBER:READ',
'ORGANIZATION_USER_ROLE:READ',
'ORGANIZATION_PROJECT:READ',
'SYSTEM_SERVICE_INTEGRATION:READ',
'ORGANIZATION_TEMPLATE:READ',
'ORGANIZATION_LOG:READ',
'SYSTEM_TASK_CENTER:READ',
'ORGANIZATION_CASE_TASK_CENTER:READ',
'ORGANIZATION_SCHEDULE_TASK_CENTER:READ',
],
},
children: [
@ -54,7 +57,8 @@ const Setting: AppRouteRecordRaw = {
'SYSTEM_AUTH:READ',
'SYSTEM_PLUGIN:READ',
'SYSTEM_LOG:READ',
'SYSTEM_TASK_CENTER:READ',
'SYSTEM_CASE_TASK_CENTER:READ',
'SYSTEM_SCHEDULE_TASK_CENTER:READ',
],
hideChildrenInMenu: true,
},
@ -143,7 +147,7 @@ const Setting: AppRouteRecordRaw = {
component: () => import('@/views/setting/system/taskCenter/index.vue'),
meta: {
locale: 'menu.projectManagement.taskCenter',
roles: [' SYSTEM_CASE_TASK_CENTER:READ'],
roles: ['SYSTEM_CASE_TASK_CENTER:READ', 'SYSTEM_SCHEDULE_TASK_CENTER:READ'],
isTopMenu: true,
},
},
@ -193,8 +197,8 @@ const Setting: AppRouteRecordRaw = {
'SYSTEM_SERVICE_INTEGRATION:READ',
'ORGANIZATION_TEMPLATE:READ',
'ORGANIZATION_LOG:READ',
'ORGANIZATION_TASK_CENTER:READ',
'ORGANIZATION_TASK_CENTER:READ',
'ORGANIZATION_CASE_TASK_CENTER:READ',
'ORGANIZATION_SCHEDULE_TASK_CENTER:READ',
],
hideChildrenInMenu: true,
},
@ -406,7 +410,7 @@ const Setting: AppRouteRecordRaw = {
component: () => import('@/views/setting/organization/taskCenter/index.vue'),
meta: {
locale: 'menu.projectManagement.taskCenter',
roles: ['ORGANIZATION_CASE_TASK_CENTER:READ'],
roles: ['ORGANIZATION_CASE_TASK_CENTER:READ', 'ORGANIZATION_SCHEDULE_TASK_CENTER:READ'],
isTopMenu: true,
},
},

View File

@ -135,6 +135,7 @@
import useTableStore from '@/hooks/useTableStore';
import { useAppStore } from '@/store';
import { characterLimit, mapTree } from '@/utils';
import { hasAnyPermission } from '@/utils/permission';
import { TaskCenterTaskDetailItem } from '@/models/taskCenter';
import { TableKeyEnum } from '@/enums/tableEnum';
@ -307,29 +308,32 @@
];
if (props.type === 'system') {
columns.splice(2, 0, [
columns.splice(
2,
0,
{
title: 'common.belongProject',
dataIndex: 'belongProject',
dataIndex: 'projectName',
showTooltip: true,
width: 100,
width: 200,
showDrag: true,
},
{
title: 'common.belongOrg',
dataIndex: 'belongOrg',
dataIndex: 'organizationName',
showTooltip: true,
width: 100,
},
]);
width: 200,
showDrag: true,
}
);
} else if (props.type === 'org') {
columns.splice(2, 0, [
{
title: 'common.belongProject',
dataIndex: 'belongProject',
showTooltip: true,
width: 100,
},
]);
columns.splice(2, 0, {
title: 'common.belongProject',
dataIndex: 'projectName',
showTooltip: true,
width: 200,
showDrag: true,
});
}
function getCurrentPermission(action: 'STOP') {
@ -371,7 +375,7 @@
{
tableKey: TableKeyEnum.TASK_CENTER_CASE_TASK_DETAIL,
scroll: { x: '1000px' },
selectable: true,
selectable: hasAnyPermission([getCurrentPermission('STOP')]),
heightUsed: 288,
showSetting: true,
size: 'default',
@ -581,7 +585,10 @@
const queue = res[item.id];
if (queue) {
item.lineNum = queue;
} else if ([ExecuteStatusEnum.COMPLETED, ExecuteStatusEnum.STOPPED].includes(item.status)) {
} else if (
[ExecuteStatusEnum.COMPLETED, ExecuteStatusEnum.STOPPED].includes(item.status) ||
!item.resourcePoolNode
) {
item.lineNum = '-';
} else {
item.lineNum = t('ms.taskCenter.waitQueue');

View File

@ -212,6 +212,7 @@
import useTableStore from '@/hooks/useTableStore';
import useAppStore from '@/store/modules/app';
import { characterLimit } from '@/utils';
import { hasAnyPermission } from '@/utils/permission';
import { TaskCenterTaskItem } from '@/models/taskCenter';
import { ReportEnum } from '@/enums/reportEnum';
@ -376,23 +377,26 @@
0,
{
title: 'common.belongProject',
dataIndex: 'belongProject',
dataIndex: 'projectName',
showTooltip: true,
width: 100,
showDrag: true,
width: 200,
},
{
title: 'common.belongOrg',
dataIndex: 'belongOrg',
dataIndex: 'organizationName',
showTooltip: true,
width: 100,
showDrag: true,
width: 200,
}
);
} else if (props.type === 'org') {
columns.splice(2, 0, {
title: 'common.belongProject',
dataIndex: 'belongProject',
dataIndex: 'projectName',
showTooltip: true,
width: 100,
showDrag: true,
width: 200,
});
}
@ -448,7 +452,7 @@
{
tableKey: TableKeyEnum.TASK_CENTER_CASE_TASK,
scroll: { x: '1000px' },
selectable: true,
selectable: hasAnyPermission([getCurrentPermission('STOP'), getCurrentPermission('DELETE')]),
showSetting: true,
showPagination: true,
},

View File

@ -87,4 +87,5 @@ export const scheduleTaskTypeMap: Record<string, any> = {
BUG_SYNC: 'ms.taskCenter.thirdPartSync',
DEMAND_SYNC: 'ms.taskCenter.thirdPartSync',
TEST_PLAN: 'menu.testPlan',
TEST_PLAN_GROUP: 'menu.testPlanGroup',
};

View File

@ -34,11 +34,15 @@
v-model:model-value="record.enable"
size="small"
:before-change="() => handleBeforeEnableChange(record)"
:disabled="!hasAnyPermission([getCurrentPermission('EDIT')])"
></a-switch>
</template>
<template #resourceType="{ record }">
{{ t(scheduleTaskTypeMap[record.resourceType]) }}
</template>
<template #[FilterSlotNameEnum.GLOBAL_TASK_CENTER_SYSTEM_TASK_TYPE]="{ filterContent }">
{{ t(scheduleTaskTypeMap[filterContent.value]) }}
</template>
<template #runRule="{ record }">
<MsCronSelect
v-if="hasAnyPermission([getCurrentPermission('EDIT')])"
@ -117,6 +121,7 @@
import { MenuEnum } from '@/enums/commonEnum';
import { ApiTestRouteEnum, ProjectManagementRouteEnum, TestPlanRouteEnum } from '@/enums/routeEnum';
import { TableKeyEnum } from '@/enums/tableEnum';
import { FilterSlotNameEnum } from '@/enums/tableFilterEnum';
import { SystemTaskType } from '@/enums/taskCenter';
import { scheduleTaskTypeMap } from './config';
@ -132,7 +137,6 @@
const appStore = useAppStore();
const keyword = ref('');
const batchModalParams = ref();
const columns: MsTableColumn = [
{
title: 'ms.taskCenter.taskID',
@ -140,6 +144,7 @@
slotName: 'num',
width: 100,
fixed: 'left',
columnSelectorDisabled: true,
},
{
title: 'ms.taskCenter.taskName',
@ -160,6 +165,17 @@
title: 'ms.taskCenter.type',
dataIndex: 'resourceType',
slotName: 'resourceType',
sortable: {
sortDirections: ['ascend', 'descend'],
sorter: true,
},
filterConfig: {
options: Object.keys(scheduleTaskTypeMap).map((key) => ({
label: t(scheduleTaskTypeMap[key]),
value: key,
})),
filterSlotName: FilterSlotNameEnum.GLOBAL_TASK_CENTER_SYSTEM_TASK_TYPE,
},
width: 120,
showDrag: true,
},
@ -216,29 +232,32 @@
},
];
if (props.type === 'system') {
columns.splice(1, 0, [
columns.splice(
2,
0,
{
title: 'common.belongProject',
dataIndex: 'belongProject',
dataIndex: 'projectName',
showTooltip: true,
width: 100,
width: 200,
showDrag: true,
},
{
title: 'common.belongOrg',
dataIndex: 'belongOrg',
dataIndex: 'organizationName',
showTooltip: true,
width: 100,
},
]);
width: 200,
showDrag: true,
}
);
} else if (props.type === 'org') {
columns.splice(1, 0, [
{
title: 'common.belongProject',
dataIndex: 'belongProject',
showTooltip: true,
width: 100,
},
]);
columns.splice(2, 0, {
title: 'common.belongProject',
dataIndex: 'projectName',
showTooltip: true,
width: 200,
showDrag: true,
});
}
await tableStore.initColumn(TableKeyEnum.TASK_CENTER_SYSTEM_TASK, columns, 'drawer');
@ -286,7 +305,7 @@
{
tableKey: TableKeyEnum.TASK_CENTER_SYSTEM_TASK,
scroll: { x: '100%' },
selectable: true,
selectable: hasAnyPermission([getCurrentPermission('EDIT'), getCurrentPermission('DELETE')]),
heightUsed: 288,
showSetting: true,
size: 'default',
@ -350,8 +369,9 @@
}[props.type];
async function openTask(params?: BatchActionQueryParams) {
try {
propsRes.value.loading = true;
await currentBatchOpenSchedule({
selectIds: params?.selectIds || [],
selectIds: params?.selectedIds || [],
selectAll: !!params?.selectAll,
excludeIds: params?.excludeIds || [],
...getTableQueryParams(),
@ -362,6 +382,8 @@
} catch (error) {
// eslint-disable-next-line no-console
console.log(error);
} finally {
propsRes.value.loading = false;
}
}
@ -372,8 +394,9 @@
}[props.type];
async function closeTask(params?: BatchActionQueryParams) {
try {
propsRes.value.loading = true;
await currentBatchCloseSchedule({
selectIds: params?.selectIds || [],
selectIds: params?.selectedIds || [],
selectAll: !!params?.selectAll,
excludeIds: params?.excludeIds || [],
...getTableQueryParams(),
@ -384,6 +407,8 @@
} catch (error) {
// eslint-disable-next-line no-console
console.log(error);
} finally {
propsRes.value.loading = false;
}
}
@ -399,6 +424,11 @@
id: record.resourceId,
});
break;
case SystemTaskType.TEST_PLAN_GROUP:
openNewPage(TestPlanRouteEnum.TEST_PLAN_INDEX, {
groupId: record.resourceNum,
});
break;
case SystemTaskType.API_SCENARIO:
openNewPage(ApiTestRouteEnum.API_TEST_SCENARIO, {
id: record.resourceId,
@ -444,7 +474,6 @@
* @param event 批量操作事件对象
*/
function handleTableBatch(event: BatchActionParams, params: BatchActionQueryParams) {
batchModalParams.value = params;
switch (event.eventTag) {
case 'open':
openTask(params);

View File

@ -1,6 +1,6 @@
export default {
'ms.taskCenter.caseTaskList': 'Case Execution Task',
'ms.taskCenter.caseTaskDetailList': 'Case Execution Task Details',
'ms.taskCenter.caseTaskList': 'System immediate tasks',
'ms.taskCenter.caseTaskDetailList': 'Task execution details',
'ms.taskCenter.backendTaskList': 'System Backend Task',
'ms.taskCenter.search': 'Search by ID/Name',
'ms.taskCenter.rerun': 'Rerun',

View File

@ -1,6 +1,6 @@
export default {
'ms.taskCenter.caseTaskList': '用例执行任务',
'ms.taskCenter.caseTaskDetailList': '用例执行任务详情',
'ms.taskCenter.caseTaskList': '系统即时任务',
'ms.taskCenter.caseTaskDetailList': '任务执行详情',
'ms.taskCenter.backendTaskList': '系统后台任务',
'ms.taskCenter.search': '通过 ID/名称搜索',
'ms.taskCenter.rerun': '重跑',

View File

@ -361,7 +361,7 @@
<script setup lang="ts">
import { ref } from 'vue';
import { useRouter } from 'vue-router';
import { useRoute, useRouter } from 'vue-router';
import { Message } from '@arco-design/web-vue';
import { cloneDeep } from 'lodash-es';
import dayjs from 'dayjs';
@ -445,6 +445,7 @@
const tableStore = useTableStore();
const appStore = useAppStore();
const globalStore = useGlobalStore();
const route = useRoute();
const router = useRouter();
const { t } = useI18n();
const { openModal } = useModal();
@ -1673,6 +1674,10 @@
onBeforeMount(() => {
if (!isActivated.value) {
if (route.query.groupId) {
showType.value = testPlanTypeEnum.GROUP;
keyword.value = route.query.groupId as string;
}
fetchData();
}
});