feat(接口测试): 接口测试参数名称和参数值交互调整

This commit is contained in:
xinxin.wu 2024-08-05 15:21:41 +08:00 committed by 刘瑞斌
parent 8bb5567c5f
commit 4033ffea7a
14 changed files with 54 additions and 7 deletions

View File

@ -231,6 +231,11 @@
class="ms-params-input-suffix-icon" class="ms-params-input-suffix-icon"
@click.stop="openParamSetting" @click.stop="openParamSetting"
/> />
<MsIcon
type="icon-icon_full_screen_one"
class="ms-params-input-suffix-icon ml-[8px]"
@click.stop="emit('setParams')"
/>
</template> </template>
<template #option="{ data }"> <template #option="{ data }">
<div class="w-[350px]"> <div class="w-[350px]">
@ -281,6 +286,7 @@
(e: 'change', val: string): void; (e: 'change', val: string): void;
(e: 'dblclick'): void; (e: 'dblclick'): void;
(e: 'apply', val: string): void; (e: 'apply', val: string): void;
(e: 'setParams'): void;
}>(); }>();
const { t } = useI18n(); const { t } = useI18n();

View File

@ -85,7 +85,7 @@
v-model:value="record.example" v-model:value="record.example"
size="medium" size="medium"
:disabled="props.disabled" :disabled="props.disabled"
@dblclick="() => quickInputParams(record)" @set-params="() => quickInputParams(record)"
@change="emitChange('exampleInput')" @change="emitChange('exampleInput')"
/> />
</template> </template>

View File

@ -202,4 +202,5 @@ export default {
'common.gotIt': 'Got it', 'common.gotIt': 'Got it',
'common.inputPleaseEnterTags': 'Please enter the update tag enter add, not more than 64 characters', 'common.inputPleaseEnterTags': 'Please enter the update tag enter add, not more than 64 characters',
'common.cutSuccess': 'Cut successfully', 'common.cutSuccess': 'Cut successfully',
'common.copySuccessToClipboard': 'Copied to clipboard',
}; };

View File

@ -201,4 +201,5 @@ export default {
'common.gotIt': '知道了', 'common.gotIt': '知道了',
'common.inputPleaseEnterTags': '请输入更新标签回车添加不得超过64字符', 'common.inputPleaseEnterTags': '请输入更新标签回车添加不得超过64字符',
'common.cutSuccess': '剪切成功', 'common.cutSuccess': '剪切成功',
'common.copySuccessToClipboard': '已复制到剪切板',
}; };

View File

@ -237,6 +237,7 @@
required: false, required: false,
}" }"
:selectable="false" :selectable="false"
:show-quick-copy="props.showQuickCopy"
@change="() => emit('change')" @change="() => emit('change')"
/> />
<MsCodeEditor <MsCodeEditor
@ -323,6 +324,7 @@
:columns="sqlSourceColumns" :columns="sqlSourceColumns"
:selectable="false" :selectable="false"
:default-param-item="defaultKeyValueParamItem" :default-param-item="defaultKeyValueParamItem"
:show-quick-copy="props.showQuickCopy"
@change="handleSqlSourceParamTableChange" @change="handleSqlSourceParamTableChange"
/> />
</div> </div>
@ -378,6 +380,7 @@
:selectable="false" :selectable="false"
:scroll="{ x: '700px' }" :scroll="{ x: '700px' }"
:response="props.response" :response="props.response"
:show-quick-copy="props.showQuickCopy"
@change="handleExtractParamTableChange" @change="handleExtractParamTableChange"
@more-action-select="(e,r)=> handleExtractParamMoreActionSelect(e,r as ExpressionConfig)" @more-action-select="(e,r)=> handleExtractParamMoreActionSelect(e,r as ExpressionConfig)"
> >
@ -537,6 +540,7 @@
totalList?: ExecuteConditionProcessor[]; // totalList?: ExecuteConditionProcessor[]; //
sqlCodeEditorHeight?: string; // sql sqlCodeEditorHeight?: string; // sql
scriptCodeEditorHeight?: string; // scriptCodeEditorHeight?: string; //
showQuickCopy?: boolean; // icon
}>(), }>(),
{ {
showAssociatedScene: false, showAssociatedScene: false,

View File

@ -43,6 +43,7 @@
:show-pre-post-request="props.showPrePostRequest" :show-pre-post-request="props.showPrePostRequest"
:request-radio-text-props="props.requestRadioTextProps" :request-radio-text-props="props.requestRadioTextProps"
:sql-code-editor-height="props.sqlCodeEditorHeight" :sql-code-editor-height="props.sqlCodeEditorHeight"
:show-quick-copy="props.showQuickCopy"
@copy="copyListItem" @copy="copyListItem"
@delete="deleteListItem" @delete="deleteListItem"
@change="changeHandler" @change="changeHandler"
@ -73,6 +74,7 @@
showAssociatedScene?: boolean; showAssociatedScene?: boolean;
showPrePostRequest?: boolean; // showPrePostRequest?: boolean; //
sqlCodeEditorHeight?: string; sqlCodeEditorHeight?: string;
showQuickCopy?: boolean; // icon
}>(), }>(),
{ {
showAssociatedScene: false, showAssociatedScene: false,

View File

@ -124,9 +124,17 @@
v-model:model-value="record[columnConfig.dataIndex as string]" v-model:model-value="record[columnConfig.dataIndex as string]"
:disabled="props.disabledExceptParam || columnConfig.disabledColumn" :disabled="props.disabledExceptParam || columnConfig.disabledColumn"
:placeholder="t('apiTestDebug.commonPlaceholder')" :placeholder="t('apiTestDebug.commonPlaceholder')"
class="ms-form-table-input ms-form-table-input--hasPlaceholder" class="ms-form-table-input ms-params-input ms-form-table-input--hasPlaceholder"
@input="() => addTableLine(rowIndex, columnConfig.addLineDisabled)" @input="() => addTableLine(rowIndex, columnConfig.addLineDisabled)"
>
<template v-if="props.showQuickCopy" #suffix>
<MsIcon
type="icon-icon_copy_outlined"
class="ms-params-input-suffix-icon"
@click="copyParamsName(record[columnConfig.dataIndex as string])"
/> />
</template>
</a-input>
</a-popover> </a-popover>
</template> </template>
<template #name="{ record, columnConfig, rowIndex }"> <template #name="{ record, columnConfig, rowIndex }">
@ -149,7 +157,15 @@
:placeholder="t('apiTestDebug.commonPlaceholder')" :placeholder="t('apiTestDebug.commonPlaceholder')"
class="ms-form-table-input ms-form-table-input--hasPlaceholder" class="ms-form-table-input ms-form-table-input--hasPlaceholder"
@input="() => addTableLine(rowIndex, columnConfig.addLineDisabled)" @input="() => addTableLine(rowIndex, columnConfig.addLineDisabled)"
>
<template v-if="props.showQuickCopy" #suffix>
<MsIcon
type="icon-icon_copy_outlined"
class="ms-params-input-suffix-icon"
@click="copyParamsName(record[columnConfig.dataIndex as string])"
/> />
</template>
</a-input>
</a-popover> </a-popover>
</template> </template>
<!-- 参数类型 --> <!-- 参数类型 -->
@ -268,8 +284,8 @@
v-model:value="record.value" v-model:value="record.value"
:disabled="props.disabledParamValue" :disabled="props.disabledParamValue"
@change="() => addTableLine(rowIndex, columnConfig.addLineDisabled)" @change="() => addTableLine(rowIndex, columnConfig.addLineDisabled)"
@dblclick="() => quickInputParams(record)"
@apply="() => addTableLine(rowIndex, columnConfig.addLineDisabled)" @apply="() => addTableLine(rowIndex, columnConfig.addLineDisabled)"
@set-params="() => quickInputParams(record)"
/> />
</template> </template>
<!-- 文件 --> <!-- 文件 -->
@ -588,7 +604,8 @@
</template> </template>
<script async setup lang="ts"> <script async setup lang="ts">
import { TableColumnData, TableData } from '@arco-design/web-vue'; import { useClipboard } from '@vueuse/core';
import { Message, TableColumnData, TableData } from '@arco-design/web-vue';
import { cloneDeep } from 'lodash-es'; import { cloneDeep } from 'lodash-es';
import { NO_CHECK } from '@/components/pure/ms-advance-filter/index'; import { NO_CHECK } from '@/components/pure/ms-advance-filter/index';
@ -624,6 +641,7 @@
// //
const MsAddAttachment = defineAsyncComponent(() => import('@/components/business/ms-add-attachment/index.vue')); const MsAddAttachment = defineAsyncComponent(() => import('@/components/business/ms-add-attachment/index.vue'));
const MsParamsInput = defineAsyncComponent(() => import('@/components/business/ms-params-input/index.vue')); const MsParamsInput = defineAsyncComponent(() => import('@/components/business/ms-params-input/index.vue'));
const { copy, isSupported } = useClipboard({ legacy: true });
export interface ParamTableColumn extends FormTableColumn { export interface ParamTableColumn extends FormTableColumn {
isAutoComplete?: boolean; // key / isAutoComplete?: boolean; // key /
@ -674,6 +692,7 @@
deleteIntercept?: (record: any, deleteCall: () => void) => void; // deleteIntercept?: (record: any, deleteCall: () => void) => void; //
typeChangeIntercept?: (record: any, doChange: () => void) => void; // type typeChangeIntercept?: (record: any, doChange: () => void) => void; // type
enableChangeIntercept?: (record: any, val: string | number | boolean) => boolean | Promise<boolean>; // enable enableChangeIntercept?: (record: any, val: string | number | boolean) => boolean | Promise<boolean>; // enable
showQuickCopy?: boolean; // icon
}>(), }>(),
{ {
params: () => [], params: () => [],
@ -1206,6 +1225,14 @@
record[item.dataIndex as string] = val; record[item.dataIndex as string] = val;
} }
function copyParamsName(value: string) {
const copyValue = `\${${value}}`;
if (isSupported) {
copy(copyValue);
Message.info(t('common.copySuccessToClipboard'));
}
}
const isDisabledCondition = ref([NO_CHECK.value]); const isDisabledCondition = ref([NO_CHECK.value]);
defineExpose({ defineExpose({

View File

@ -7,6 +7,7 @@
:response="props.response" :response="props.response"
:disabled="props.disabled" :disabled="props.disabled"
:sql-code-editor-height="props.sqlCodeEditorHeight" :sql-code-editor-height="props.sqlCodeEditorHeight"
show-quick-copy
@change="emit('change')" @change="emit('change')"
> >
<template v-if="$slots.dropdownAppend" #dropdownAppend> <template v-if="$slots.dropdownAppend" #dropdownAppend>

View File

@ -6,6 +6,7 @@
:condition-types="conditionTypes" :condition-types="conditionTypes"
:sql-code-editor-height="props.sqlCodeEditorHeight" :sql-code-editor-height="props.sqlCodeEditorHeight"
add-text="apiTestDebug.precondition" add-text="apiTestDebug.precondition"
show-quick-copy
@change="emit('change')" @change="emit('change')"
> >
<template v-if="$slots.dropdownAppend" #dropdownAppend> <template v-if="$slots.dropdownAppend" #dropdownAppend>

View File

@ -74,7 +74,7 @@
set-default-class set-default-class
:disabled="props.disabled" :disabled="props.disabled"
@change="() => addMatchRule(idx)" @change="() => addMatchRule(idx)"
@dblclick="quickInputParams(item)" @set-params="quickInputParams(item)"
@apply="() => addMatchRule(idx)" @apply="() => addMatchRule(idx)"
/> />
</a-form-item> </a-form-item>

View File

@ -27,6 +27,7 @@
:default-param-item="defaultNormalParamItem" :default-param-item="defaultNormalParamItem"
:draggable="false" :draggable="false"
:selectable="false" :selectable="false"
show-quick-copy
@change="handleCommonVariablesChange" @change="handleCommonVariablesChange"
@batch-add="() => (batchAddKeyValVisible = true)" @batch-add="() => (batchAddKeyValVisible = true)"
/> />

View File

@ -19,6 +19,7 @@
show-setting show-setting
:selectable="true" :selectable="true"
:default-param-item="defaultParamItem" :default-param-item="defaultParamItem"
show-quick-copy
@change="handleParamTableChange" @change="handleParamTableChange"
@batch-add="batchAddKeyValVisible = true" @batch-add="batchAddKeyValVisible = true"
/> />

View File

@ -7,6 +7,7 @@
:show-associated-scene="props.showAssociatedScene" :show-associated-scene="props.showAssociatedScene"
:show-pre-post-request="props.showPrePostRequest" :show-pre-post-request="props.showPrePostRequest"
:request-radio-text-props="props.requestRadioTextProps" :request-radio-text-props="props.requestRadioTextProps"
show-quick-copy
> >
</condition> </condition>
</template> </template>

View File

@ -7,6 +7,7 @@
:show-associated-scene="props.showAssociatedScene" :show-associated-scene="props.showAssociatedScene"
:show-pre-post-request="props.showPrePostRequest" :show-pre-post-request="props.showPrePostRequest"
:request-radio-text-props="props.requestRadioTextProps" :request-radio-text-props="props.requestRadioTextProps"
show-quick-copy
> >
</condition> </condition>
</template> </template>