From 3c3188e7eb0cb3ff317a0b34bc81fcbc978f7b72 Mon Sep 17 00:00:00 2001 From: baiqi Date: Fri, 17 May 2024 11:52:54 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=20csv&=E5=9C=BA=E6=99=AF=E6=AD=A5=E9=AA=A4=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/models/apiTest/scenario.ts | 7 +++++ .../views/api-test/components/paramTable.vue | 9 +++++-- .../components/common/csvParamsTable.vue | 13 ++++++++++ .../components/common/customApiDrawer.vue | 26 +++++++++++++------ .../components/common/customCaseDrawer.vue | 19 +++++++++----- .../api-test/scenario/components/config.ts | 4 +++ .../components/step/useStepExecute.ts | 11 +++++--- .../components/step/useStepOperation.ts | 17 +++++++----- .../api-test/scenario/components/utils.ts | 22 +++++++++++++++- .../src/views/api-test/scenario/index.vue | 8 +++++- 10 files changed, 108 insertions(+), 28 deletions(-) diff --git a/frontend/src/models/apiTest/scenario.ts b/frontend/src/models/apiTest/scenario.ts index 3c63712a9c..13a99a577d 100644 --- a/frontend/src/models/apiTest/scenario.ts +++ b/frontend/src/models/apiTest/scenario.ts @@ -386,6 +386,11 @@ export interface ScenarioStepFileParams { deleteFileIds?: string[]; unLinkFileIds?: string[]; } +// 场景文件参数 +export interface ScenarioFileParams { + uploadFileIds: string[]; + linkFileIds: string[]; +} // 场景步骤详情 export type ScenarioStepDetails = Partial; // 场景 @@ -405,6 +410,7 @@ export interface Scenario { steps: ScenarioStepItem[]; stepDetails: Record; // case、api、脚本操作抽屉的详情结构 stepFileParam: Record; + fileParam: ScenarioFileParams; follow?: boolean; uploadFileIds: string[]; linkFileIds: string[]; @@ -455,6 +461,7 @@ export interface ApiScenarioDebugRequest { steps: ScenarioStepItem[]; projectId: string; stepFileParam: Record; + fileParam: ScenarioFileParams; frontendDebug?: boolean; } diff --git a/frontend/src/views/api-test/components/paramTable.vue b/frontend/src/views/api-test/components/paramTable.vue index 815c36ea10..cae4df6abd 100644 --- a/frontend/src/views/api-test/components/paramTable.vue +++ b/frontend/src/views/api-test/components/paramTable.vue @@ -916,7 +916,7 @@ (arr) => { if (arr.length > 0) { let hasNoIdItem = false; - paramsData.value = arr.map((item, i) => { + paramsData.value = arr.map((item) => { if (!item) { // 批量添加过来的数据最后一行会是 undefined hasNoIdItem = true; @@ -935,7 +935,12 @@ } return item; }); - if (hasNoIdItem && !filterKeyValParams(arr, props.defaultParamItem).lastDataIsDefault && !props.isTreeTable) { + if ( + (!props.disabledExceptParam || !props.disabledParamValue) && + hasNoIdItem && + !filterKeyValParams(arr, props.defaultParamItem).lastDataIsDefault && + !props.isTreeTable + ) { addTableLine(arr.length - 1, false, true); } } else { diff --git a/frontend/src/views/api-test/scenario/components/common/csvParamsTable.vue b/frontend/src/views/api-test/scenario/components/common/csvParamsTable.vue index 122030b3ed..68705876ab 100644 --- a/frontend/src/views/api-test/scenario/components/common/csvParamsTable.vue +++ b/frontend/src/views/api-test/scenario/components/common/csvParamsTable.vue @@ -124,6 +124,7 @@ import { CsvVariable } from '@/models/apiTest/scenario'; import { defaultCsvParamItem } from '@/views/api-test/components/config'; + import { filterKeyValParams } from '@/views/api-test/components/utils'; const props = defineProps<{ scenarioId?: string | number; @@ -310,6 +311,18 @@ } return true; } + + onBeforeMount(() => { + if ( + csvVariables.value.length > 0 && + !filterKeyValParams(csvVariables.value, defaultCsvParamItem).lastDataIsDefault + ) { + csvVariables.value.push({ + ...cloneDeep(defaultCsvParamItem), + id: getGenerateId(), + }); + } + });