feat(接口测试): 场景表格支持拖拽排序

This commit is contained in:
Jianguo-Genius 2024-04-17 15:39:22 +08:00 committed by 刘瑞斌
parent 69fc71c3d3
commit 6442bd7641
3 changed files with 30 additions and 2 deletions

View File

@ -14,6 +14,7 @@ import {
DebugScenarioUrl, DebugScenarioUrl,
DeleteModuleUrl, DeleteModuleUrl,
DeleteScenarioUrl, DeleteScenarioUrl,
dragSortUrl,
ExecuteHistoryUrl, ExecuteHistoryUrl,
ExecuteScenarioUrl, ExecuteScenarioUrl,
FollowScenarioUrl, FollowScenarioUrl,
@ -64,7 +65,14 @@ import {
ScenarioHistoryPageParams, ScenarioHistoryPageParams,
ScenarioStepResourceInfo, ScenarioStepResourceInfo,
} from '@/models/apiTest/scenario'; } from '@/models/apiTest/scenario';
import { AddModuleParams, CommonList, ModuleTreeNode, MoveModules, TransferFileParams } from '@/models/common'; import {
AddModuleParams,
CommonList,
DragSortParams,
ModuleTreeNode,
MoveModules,
TransferFileParams,
} from '@/models/common';
import { ApiScenarioStatus, ScenarioStepType } from '@/enums/apiEnum'; import { ApiScenarioStatus, ScenarioStepType } from '@/enums/apiEnum';
import type { RequestParam as CaseRequestParam } from '@/views/api-test/components/requestComposition/index.vue'; import type { RequestParam as CaseRequestParam } from '@/views/api-test/components/requestComposition/index.vue';
@ -278,6 +286,11 @@ export function updateScenarioStatus(id: string | number, status: ApiScenarioSta
return MSR.get({ url: `${UpdateScenarioStatusUrl}/${id}/${status}` }); return MSR.get({ url: `${UpdateScenarioStatusUrl}/${id}/${status}` });
} }
// 拖拽排序
export function dragSort(data: DragSortParams) {
return MSR.post({ url: dragSortUrl, data });
}
export function updateScenarioPro(id: string | number, priority: CaseLevel | undefined) { export function updateScenarioPro(id: string | number, priority: CaseLevel | undefined) {
return MSR.get({ url: `${UpdateScenarioPriorityUrl}/${id}/${priority}` }); return MSR.get({ url: `${UpdateScenarioPriorityUrl}/${id}/${priority}` });
} }

View File

@ -27,7 +27,8 @@ export const BatchEditScenarioUrl = '/api/scenario/batch-operation/edit'; // 批
export const BatchRunScenarioUrl = '/api/scenario/batch-operation/run'; // 批量执行接口场景 export const BatchRunScenarioUrl = '/api/scenario/batch-operation/run'; // 批量执行接口场景
export const UpdateScenarioPriorityUrl = '/api/scenario/update-priority'; // 场景更新等级 export const UpdateScenarioPriorityUrl = '/api/scenario/update-priority'; // 场景更新等级
export const UpdateScenarioStatusUrl = '/api/scenario/update-status'; // 场景更新状态 export const UpdateScenarioStatusUrl = '/api/scenario/update-status'; // 场景更新状态
// 场景拖拽排序
export const dragSortUrl = '/api/scenario/edit/pos';
// 回收站相关 // 回收站相关
export const GetTrashModuleTreeUrl = '/api/scenario/module/trash/tree'; export const GetTrashModuleTreeUrl = '/api/scenario/module/trash/tree';
export const GetTrashModuleCountUrl = '/api/scenario/module/trash/count'; export const GetTrashModuleCountUrl = '/api/scenario/module/trash/count';

View File

@ -28,6 +28,7 @@
v-on="propsEvent" v-on="propsEvent"
@selected-change="handleTableSelect" @selected-change="handleTableSelect"
@batch-action="handleTableBatch" @batch-action="handleTableBatch"
@drag-change="changeHandler"
@module-change="loadScenarioList(false)" @module-change="loadScenarioList(false)"
> >
<template #statusFilter="{ columnConfig }"> <template #statusFilter="{ columnConfig }">
@ -622,6 +623,7 @@
batchRecycleScenario, batchRecycleScenario,
batchRunScenario, batchRunScenario,
deleteScheduleConfig, deleteScheduleConfig,
dragSort,
getScenarioPage, getScenarioPage,
recycleScenario, recycleScenario,
scenarioScheduleConfig, scenarioScheduleConfig,
@ -638,6 +640,7 @@
import { Environment } from '@/models/apiTest/management'; import { Environment } from '@/models/apiTest/management';
import { ApiScenarioScheduleConfig, ApiScenarioTableItem, ApiScenarioUpdateDTO } from '@/models/apiTest/scenario'; import { ApiScenarioScheduleConfig, ApiScenarioTableItem, ApiScenarioUpdateDTO } from '@/models/apiTest/scenario';
import { DragSortParams } from '@/models/common';
import { ResourcePoolItem } from '@/models/setting/resourcePool'; import { ResourcePoolItem } from '@/models/setting/resourcePool';
import { ApiScenarioStatus } from '@/enums/apiEnum'; import { ApiScenarioStatus } from '@/enums/apiEnum';
import { ReportEnum, ReportStatus } from '@/enums/reportEnum'; import { ReportEnum, ReportStatus } from '@/enums/reportEnum';
@ -1489,6 +1492,17 @@
); );
} }
//
async function changeHandler(params: DragSortParams) {
try {
await dragSort(params);
Message.success(t('caseManagement.featureCase.sortSuccess'));
loadScenarioList();
} catch (error) {
console.log(error);
}
}
onBeforeMount(() => { onBeforeMount(() => {
loadScenarioList(); loadScenarioList();
}); });