From 8265d5f21b0dc271b355671c6c366c34209c8185 Mon Sep 17 00:00:00 2001 From: RubyLiu Date: Fri, 1 Mar 2024 15:15:00 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E9=A1=B9=E7=9B=AE=E7=AE=A1=E7=90=86):?= =?UTF-8?q?=20=E7=8E=AF=E5=A2=83=E7=AE=A1=E7=90=86=E6=96=AD=E8=A8=80?= =?UTF-8?q?=E5=AF=B9=E6=8E=A5&=E6=A0=B7=E5=BC=8F=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../project-management/envManagement.ts | 2 +- .../ms-assertion/comp/ResponseBodyTab.vue | 37 ++- .../ms-assertion/comp/ResponseHeaderTab.vue | 4 +- .../ms-assertion/comp/ResponseTimeTab.vue | 20 +- .../business/ms-assertion/comp/ScriptTab.vue | 255 ++---------------- .../ms-assertion/comp/StatusCodeTab.vue | 42 ++- .../ms-assertion/comp/VariableTab.vue | 26 +- .../business/ms-assertion/index.vue | 58 +++- .../components/business/ms-assertion/type.ts | 5 + .../models/projectManagement/environmental.ts | 5 +- .../modules/setting/useProjectEnvStore.ts | 2 +- .../api-test/components/condition/content.vue | 17 +- .../environmental/components/EnvParamBox.vue | 24 +- .../components/envParams/AssertTab.vue | 7 +- .../environmental/index.vue | 18 +- 15 files changed, 215 insertions(+), 307 deletions(-) diff --git a/frontend/src/api/modules/project-management/envManagement.ts b/frontend/src/api/modules/project-management/envManagement.ts index 4e8fcc12c6..8c91b6b17f 100644 --- a/frontend/src/api/modules/project-management/envManagement.ts +++ b/frontend/src/api/modules/project-management/envManagement.ts @@ -37,7 +37,7 @@ export function exportEnv(selectIds: string[]) { { isTransformResponse: false } ); } -export function editPosEnv(data: EnvListItem) { +export function editPosEnv(data: DragParam) { return MSR.post({ url: envURL.editPosEnvUrl, data }); } diff --git a/frontend/src/components/business/ms-assertion/comp/ResponseBodyTab.vue b/frontend/src/components/business/ms-assertion/comp/ResponseBodyTab.vue index b0935fb457..7c92e595ed 100644 --- a/frontend/src/components/business/ms-assertion/comp/ResponseBodyTab.vue +++ b/frontend/src/components/business/ms-assertion/comp/ResponseBodyTab.vue @@ -303,13 +303,7 @@
- +
@@ -362,25 +356,16 @@ (e: 'update:data', data: ExecuteConditionProcessor): void; (e: 'copy'): void; (e: 'delete', id: number): void; - (e: 'change'): void; + (e: 'change', param: Param): void; }>(); const { t } = useI18n(); const rootId = 0; // 1970-01-01 00:00:00 UTC - // const innerParams = defineModel('modelValue', { - // default: { - // jsonPath: [], - // xPath: { responseFormat: 'XML', data: [] }, - // script: { - // id: new Date().getTime(), - // processorType: RequestConditionProcessor.SCRIPT, - // scriptName: '断言脚本名称', - // enableCommonScript: false, - // params: [], - // }, - // }, - // }); - const innerParams = ref({ + const props = defineProps<{ + value: Param; + }>(); + + const defaultParamItem = { jsonPath: [], xPath: { responseFormat: 'XML', data: [] }, document: { @@ -408,6 +393,11 @@ scriptLanguage: RequestConditionScriptLanguage.JAVASCRIPT, script: new Date().getTime().toString(), }, + }; + + const innerParams = ref(props.value || defaultParamItem); + watchEffect(() => { + emit('change', innerParams.value); }); const activeTab = ref('document'); const extractParamsTableRef = ref>(); @@ -764,4 +754,7 @@ } } }; + const handleScriptChange = (data: ExecuteConditionProcessor) => { + innerParams.value.script = data; + }; diff --git a/frontend/src/components/business/ms-assertion/comp/ResponseHeaderTab.vue b/frontend/src/components/business/ms-assertion/comp/ResponseHeaderTab.vue index e8cf598796..ac883c229c 100644 --- a/frontend/src/components/business/ms-assertion/comp/ResponseHeaderTab.vue +++ b/frontend/src/components/business/ms-assertion/comp/ResponseHeaderTab.vue @@ -24,7 +24,7 @@ const innerParams = defineModel('modelValue', { default: [] }); const emit = defineEmits<{ - (e: 'change'): void; // 数据发生变化 + (e: 'change', val: any[]): void; // 数据发生变化 }>(); const defaultParamItem = { @@ -85,7 +85,7 @@ function handleParamTableChange(resultArr: any[], isInit?: boolean) { innerParams.value = [...resultArr]; if (!isInit) { - emit('change'); + emit('change', resultArr); } } diff --git a/frontend/src/components/business/ms-assertion/comp/ResponseTimeTab.vue b/frontend/src/components/business/ms-assertion/comp/ResponseTimeTab.vue index e694abfec2..d086b08541 100644 --- a/frontend/src/components/business/ms-assertion/comp/ResponseTimeTab.vue +++ b/frontend/src/components/business/ms-assertion/comp/ResponseTimeTab.vue @@ -4,18 +4,28 @@ {{ t('ms.assertion.responseTime') }} (ms) - + - diff --git a/frontend/src/components/business/ms-assertion/comp/ScriptTab.vue b/frontend/src/components/business/ms-assertion/comp/ScriptTab.vue index a3c8927675..43c7d1b488 100644 --- a/frontend/src/components/business/ms-assertion/comp/ScriptTab.vue +++ b/frontend/src/components/business/ms-assertion/comp/ScriptTab.vue @@ -1,246 +1,41 @@ diff --git a/frontend/src/components/business/ms-assertion/comp/StatusCodeTab.vue b/frontend/src/components/business/ms-assertion/comp/StatusCodeTab.vue index 9358a26a6d..f3e857afb2 100644 --- a/frontend/src/components/business/ms-assertion/comp/StatusCodeTab.vue +++ b/frontend/src/components/business/ms-assertion/comp/StatusCodeTab.vue @@ -2,28 +2,60 @@
{{ t('ms.assertion.statusCode') }}
- + {{ t(item.label) }}
- +
diff --git a/frontend/src/components/business/ms-assertion/comp/VariableTab.vue b/frontend/src/components/business/ms-assertion/comp/VariableTab.vue index d03b1d68c2..bb0a710c5e 100644 --- a/frontend/src/components/business/ms-assertion/comp/VariableTab.vue +++ b/frontend/src/components/business/ms-assertion/comp/VariableTab.vue @@ -1,19 +1,15 @@ diff --git a/frontend/src/views/project-management/environmental/components/envParams/AssertTab.vue b/frontend/src/views/project-management/environmental/components/envParams/AssertTab.vue index 6cce79493c..8bd6324d1a 100644 --- a/frontend/src/views/project-management/environmental/components/envParams/AssertTab.vue +++ b/frontend/src/views/project-management/environmental/components/envParams/AssertTab.vue @@ -4,16 +4,17 @@ diff --git a/frontend/src/views/project-management/environmental/index.vue b/frontend/src/views/project-management/environmental/index.vue index ac2c3246b6..d0a853a8ee 100644 --- a/frontend/src/views/project-management/environmental/index.vue +++ b/frontend/src/views/project-management/environmental/index.vue @@ -55,7 +55,12 @@
- +
{ + const handleEnvGroupPosChange = async (event: SortableEvent, type: EnvAuthTypeEnum) => { try { const { oldIndex, newIndex } = event; if (oldIndex === newIndex) { @@ -394,7 +400,11 @@ moveId: evnGroupList.value[_newIndex].id, moveMode: _oldIndex > _newIndex ? 'BEFORE' : 'AFTER', }; - await groupEditPosEnv(params); + if (type === EnvAuthTypeEnum.ENVIRONMENT) { + await editPosEnv(params); + } else if (type === EnvAuthTypeEnum.ENVIRONMENT_GROUP) { + await groupEditPosEnv(params); + } } catch (e) { // eslint-disable-next-line no-console console.error(e);