diff --git a/frontend/src/views/api-test/scenario/components/common/customApiDrawer.vue b/frontend/src/views/api-test/scenario/components/common/customApiDrawer.vue index c9f1289e4d..0c2d0b7e3b 100644 --- a/frontend/src/views/api-test/scenario/components/common/customApiDrawer.vue +++ b/frontend/src/views/api-test/scenario/components/common/customApiDrawer.vue @@ -39,7 +39,6 @@ v-model:model-value="requestVModel.useEnv" :style="{ width: '150px', float: 'right' }" :allow-search="false" - allow-clear :options="[ { label: t('common.quote'), value: 'true' }, { label: t('common.notQuote'), value: 'false' }, @@ -48,6 +47,7 @@ value-key="value" label-key="label" :prefix="t('project.environmental.env')" + @change="handleUseEnvChange" > @@ -74,10 +74,10 @@ class="flex items-center" /> - requestVModel.label + requestVModel.label - {{ requestVModel.label }} + {{ requestVModel.label }} @@ -546,6 +546,7 @@ const protocolLoading = ref(false); const protocolOptions = ref([]); + async function initProtocolList() { try { protocolLoading.value = true; @@ -591,7 +592,11 @@ function controlPluginFormFields() { const allFields = fApi.value?.fields(); let fields: string[] = []; - fields = pluginScriptMap.value[requestVModel.value.protocol].apiDebugFields || []; + if (requestVModel.value.useEnv === 'true') { + fields = pluginScriptMap.value[requestVModel.value.protocol].apiDefinitionFields || []; + } else { + fields = pluginScriptMap.value[requestVModel.value.protocol].apiDebugFields || []; + } fApi.value?.hidden(true, allFields?.filter((e) => !fields.includes(e)) || []); return fields; } @@ -628,6 +633,20 @@ } } + // 切换是否使用环境变量 + async function handleUseEnvChange() { + const pluginId = protocolOptions.value.find((e) => e.value === requestVModel.value.protocol)?.pluginId; + const res = await getPluginScript(pluginId); + pluginScriptMap.value[requestVModel.value.protocol] = res; + fApi.value?.nextTick(() => { + controlPluginFormFields(); + }); + nextTick(() => { + // 如果是没有缓存也不是编辑,则需要重置表单,因为 form-create 只有一个实例,已经被其他有数据的 tab 污染了,需要重置 + fApi.value?.resetFields(); + }); + } + const pluginError = ref(false); async function initPluginScript() { @@ -722,9 +741,11 @@ const verticalSplitBoxRef = ref>(); const isVerticalExpanded = ref(true); + function handleVerticalExpandChange(val: boolean) { isVerticalExpanded.value = val; } + function changeVerticalExpand(val: boolean) { isVerticalExpanded.value = val; if (val) { @@ -769,6 +790,7 @@ const reportId = ref(''); const websocket = ref(); + /** * 开启websocket监听,接收执行结果 */ @@ -941,6 +963,7 @@ websocket.value?.close(); requestVModel.value.executeLoading = false; } + const step = ref(); function handleContinue() { @@ -948,6 +971,7 @@ emit('addStep', step.value); requestVModel.value = { ...defaultDebugParams }; } + function handleSave() { handleContinue(); visible.value = false; @@ -979,6 +1003,7 @@