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_STATUS = 'GLOBAL_TASK_CENTER_EXEC_STATUS', // 任务中心-执行状态
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', // 任务中心-后台任务类型
} }
export enum FilterRemoteMethodsEnum { export enum FilterRemoteMethodsEnum {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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