diff --git a/frontend/src/api/modules/api-test/scenario.ts b/frontend/src/api/modules/api-test/scenario.ts index 85ab88dc5f..3a6d9e8aad 100644 --- a/frontend/src/api/modules/api-test/scenario.ts +++ b/frontend/src/api/modules/api-test/scenario.ts @@ -17,6 +17,7 @@ import { dragSortUrl, ExecuteHistoryUrl, ExecuteScenarioUrl, + ExportScenarioUrl, FollowScenarioUrl, GetModuleCountUrl, GetModuleTreeUrl, @@ -27,6 +28,7 @@ import { GetSystemRequestUrl, GetTrashModuleCountUrl, GetTrashModuleTreeUrl, + ImportScenarioUrl, MoveModuleUrl, RecoverScenarioUrl, RecycleScenarioUrl, @@ -63,7 +65,9 @@ import { ApiScenarioUpdateDTO, ExecuteHistoryItem, ExecutePageParams, + type ExportScenarioParams, GetSystemRequestParams, + type ImportScenarioParams, ImportSystemData, Scenario, ScenarioDetail, @@ -325,7 +329,18 @@ export function logScenarioReportBatchExport(data: BatchApiParams) { export function getScenarioBatchExportParams(data: BatchApiParams) { return MSR.post({ url: `${GetScenarioBatchExportParamsUrl}`, data }); } + // 场景导出报告id集合 export function scenarioAssociateExport(data: ImportSystemData) { return MSR.post({ url: `${ScenarioAssociateExportUrl}`, data }); } + +// 导入场景 +export function importScenario(params: ImportScenarioParams) { + return MSR.uploadFile({ url: ImportScenarioUrl }, { fileList: [params.file], request: params.request }, 'file'); +} + +// 导出场景 +export function exportScenario(data: ExportScenarioParams) { + return MSR.post({ url: ExportScenarioUrl, data }); +} diff --git a/frontend/src/api/requrls/api-test/scenario.ts b/frontend/src/api/requrls/api-test/scenario.ts index bb306e7da7..74a669d21d 100644 --- a/frontend/src/api/requrls/api-test/scenario.ts +++ b/frontend/src/api/requrls/api-test/scenario.ts @@ -28,6 +28,9 @@ export const BatchEditScenarioUrl = '/api/scenario/batch-operation/edit'; // 批 export const BatchRunScenarioUrl = '/api/scenario/batch-operation/run'; // 批量执行接口场景 export const UpdateScenarioPriorityUrl = '/api/scenario/update-priority'; // 场景更新等级 export const UpdateScenarioStatusUrl = '/api/scenario/update-status'; // 场景更新状态 +export const ImportScenarioUrl = '/api/scenario/import'; // 导入场景 +export const ExportScenarioUrl = '/api/scenario/export'; // 导入场景 + // 场景拖拽排序 export const dragSortUrl = '/api/scenario/edit/pos'; // 回收站相关 diff --git a/frontend/src/models/apiTest/scenario.ts b/frontend/src/models/apiTest/scenario.ts index 3f3b902b98..d111c0ba72 100644 --- a/frontend/src/models/apiTest/scenario.ts +++ b/frontend/src/models/apiTest/scenario.ts @@ -1,3 +1,4 @@ +import type { BatchActionQueryParams } from '@/components/pure/ms-table/type'; import type { saveParams } from '@/components/business/ms-associate-case/types'; import type { CaseLevel } from '@/components/business/ms-case-associate/types'; @@ -7,6 +8,7 @@ import { RequestAssertionCondition, RequestComposition, RequestDefinitionStatus, + type RequestImportFormat, RequestMethods, ScenarioExecuteStatus, ScenarioFailureStrategy, @@ -521,9 +523,30 @@ export interface ScenarioAssociateCaseParams { protocols: string[]; associateType?: string; } + // 多模块关联 export interface ImportSystemData { API: ScenarioAssociateCaseParams; // 接口 CASE: ScenarioAssociateCaseParams; // 用例 SCENARIO: ScenarioAssociateCaseParams; // 场景 } + +// 导入场景请求参数 +export interface ImportScenarioRequest { + moduleId: string; + projectId: string; + type: RequestImportFormat.MeterSphere | RequestImportFormat.Jmeter; + coverData: boolean; +} + +// 导入场景参数 +export interface ImportScenarioParams { + file: File | null; + request: ImportScenarioRequest; +} + +// 导出场景参数 +export interface ExportScenarioParams extends BatchActionQueryParams { + apiScenarioId: string; + fileId: string; +} diff --git a/frontend/src/views/api-test/scenario/components/import.vue b/frontend/src/views/api-test/scenario/components/import.vue new file mode 100644 index 0000000000..31700892dc --- /dev/null +++ b/frontend/src/views/api-test/scenario/components/import.vue @@ -0,0 +1,224 @@ + + + + + diff --git a/frontend/src/views/api-test/scenario/components/scenarioModuleTree.vue b/frontend/src/views/api-test/scenario/components/scenarioModuleTree.vue index dc8699f072..0b5406f0c9 100644 --- a/frontend/src/views/api-test/scenario/components/scenarioModuleTree.vue +++ b/frontend/src/views/api-test/scenario/components/scenarioModuleTree.vue @@ -1,24 +1,37 @@ +