feat(接口定义): 增加批量方法
This commit is contained in:
parent
884fc213dd
commit
0ff2be302d
|
@ -1 +1 @@
|
||||||
Subproject commit bb494fc68a2367359c9048fa7250c7618de4afb6
|
Subproject commit 1fe20ba15a7ca3fe9f77ddf866021e7c7dfe5969
|
|
@ -0,0 +1,63 @@
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<el-dialog
|
||||||
|
:title="$t('commons.batch_add')"
|
||||||
|
:visible.sync="dialogVisible"
|
||||||
|
width="60%"
|
||||||
|
class="batch-edit-dialog"
|
||||||
|
:destroy-on-close="true"
|
||||||
|
@close="handleClose">
|
||||||
|
<div>
|
||||||
|
<div>格式:参数名,必填,参数值,备注 如:Accept-Encoding,必填,utf-8,编码</div>
|
||||||
|
<div style="height: 200px">
|
||||||
|
<ms-code-edit :enable-format="false" mode="text" :data.sync="parameters" theme="eclipse" :modes="['text']"
|
||||||
|
ref="codeEdit"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<template v-slot:footer>
|
||||||
|
<ms-dialog-footer
|
||||||
|
@cancel="dialogVisible = false"
|
||||||
|
@confirm="confirm()"/>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import MsDialogFooter from "../../../../common/components/MsDialogFooter";
|
||||||
|
import {listenGoBack, removeGoBackListener} from "@/common/js/utils";
|
||||||
|
import MsCodeEdit from "../../../../common/components/MsCodeEdit";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: "BatchAddParameter",
|
||||||
|
components: {
|
||||||
|
MsDialogFooter,
|
||||||
|
MsCodeEdit
|
||||||
|
},
|
||||||
|
props: {},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
dialogVisible: false,
|
||||||
|
parameters: "",
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
open() {
|
||||||
|
this.dialogVisible = true;
|
||||||
|
listenGoBack(this.handleClose);
|
||||||
|
},
|
||||||
|
handleClose() {
|
||||||
|
this.parameters = "";
|
||||||
|
removeGoBackListener(this.handleClose);
|
||||||
|
},
|
||||||
|
confirm() {
|
||||||
|
this.dialogVisible = false;
|
||||||
|
this.$emit("batchSave", this.parameters);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
|
||||||
|
</style>
|
|
@ -25,6 +25,10 @@
|
||||||
{{ $t('api_test.definition.request.body_binary') }}
|
{{ $t('api_test.definition.request.body_binary') }}
|
||||||
</el-radio>
|
</el-radio>
|
||||||
</el-radio-group>
|
</el-radio-group>
|
||||||
|
<el-row v-if="body.type == 'Form Data' || body.type == 'WWW_FORM'">
|
||||||
|
<el-link class="ms-el-link" @click="batchAdd"> {{$t("commons.batch_add")}}</el-link>
|
||||||
|
</el-row>
|
||||||
|
|
||||||
<ms-api-variable :is-read-only="isReadOnly"
|
<ms-api-variable :is-read-only="isReadOnly"
|
||||||
:parameters="body.kvs"
|
:parameters="body.kvs"
|
||||||
:isShowEnable="isShowEnable"
|
:isShowEnable="isShowEnable"
|
||||||
|
@ -55,12 +59,14 @@
|
||||||
type="body"
|
type="body"
|
||||||
v-if="body.type == 'BINARY'"/>
|
v-if="body.type == 'BINARY'"/>
|
||||||
|
|
||||||
|
<batch-add-parameter @batchSave="batchSave" ref="batchAddParameter"/>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import MsApiKeyValue from "../ApiKeyValue";
|
import MsApiKeyValue from "../ApiKeyValue";
|
||||||
import {BODY_FORMAT, BODY_TYPE, KeyValue} from "../../model/ApiTestModel";
|
import {BODY_TYPE, KeyValue} from "../../model/ApiTestModel";
|
||||||
import MsCodeEdit from "../../../../common/components/MsCodeEdit";
|
import MsCodeEdit from "../../../../common/components/MsCodeEdit";
|
||||||
import MsJsonCodeEdit from "../../../../common/components/MsJsonCodeEdit";
|
import MsJsonCodeEdit from "../../../../common/components/MsJsonCodeEdit";
|
||||||
|
|
||||||
|
@ -68,6 +74,7 @@
|
||||||
import MsApiVariable from "../ApiVariable";
|
import MsApiVariable from "../ApiVariable";
|
||||||
import MsApiBinaryVariable from "./ApiBinaryVariable";
|
import MsApiBinaryVariable from "./ApiBinaryVariable";
|
||||||
import MsApiFromUrlVariable from "./ApiFromUrlVariable";
|
import MsApiFromUrlVariable from "./ApiFromUrlVariable";
|
||||||
|
import BatchAddParameter from "../basis/BatchAddParameter";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "MsApiBody",
|
name: "MsApiBody",
|
||||||
|
@ -78,7 +85,8 @@
|
||||||
MsApiKeyValue,
|
MsApiKeyValue,
|
||||||
MsApiBinaryVariable,
|
MsApiBinaryVariable,
|
||||||
MsApiFromUrlVariable,
|
MsApiFromUrlVariable,
|
||||||
MsJsonCodeEdit
|
MsJsonCodeEdit,
|
||||||
|
BatchAddParameter
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
body: {},
|
body: {},
|
||||||
|
@ -147,9 +155,29 @@
|
||||||
},
|
},
|
||||||
jsonError(e) {
|
jsonError(e) {
|
||||||
this.$error(e);
|
this.$error(e);
|
||||||
|
},
|
||||||
|
batchAdd() {
|
||||||
|
this.$refs.batchAddParameter.open();
|
||||||
|
},
|
||||||
|
batchSave(data) {
|
||||||
|
if (data) {
|
||||||
|
let params = data.split("\n");
|
||||||
|
let keyValues = [];
|
||||||
|
params.forEach(item => {
|
||||||
|
let line = item.split(/,|,/);
|
||||||
|
let required = false;
|
||||||
|
if (line[1] === '必填' || line[1] === 'true') {
|
||||||
|
required = true;
|
||||||
|
}
|
||||||
|
keyValues.push(new KeyValue({name: line[0], required: required, value: line[2], description: line[3], type: "text", valid: false, file: false, encode: true, enable: true, contentType: "text/plain"}));
|
||||||
|
})
|
||||||
|
keyValues.forEach(item => {
|
||||||
|
this.body.kvs.unshift(item);
|
||||||
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
},
|
||||||
created() {
|
created() {
|
||||||
if (!this.body.type) {
|
if (!this.body.type) {
|
||||||
this.body.type = BODY_TYPE.FORM_DATA;
|
this.body.type = BODY_TYPE.FORM_DATA;
|
||||||
|
@ -187,4 +215,8 @@
|
||||||
margin-top: 15px;
|
margin-top: 15px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.ms-el-link {
|
||||||
|
float: right;
|
||||||
|
margin-right: 45px;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
</div>
|
</div>
|
||||||
</span>
|
</span>
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
|
|
||||||
<ms-api-key-value :is-read-only="isReadOnly" :isShowEnable="isShowEnable" :suggestions="headerSuggestions" :items="headers"/>
|
<ms-api-key-value :is-read-only="isReadOnly" :isShowEnable="isShowEnable" :suggestions="headerSuggestions" :items="headers"/>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
|
|
||||||
|
@ -25,7 +24,9 @@
|
||||||
<div class="el-step__icon-inner">{{request.arguments.length-1}}</div>
|
<div class="el-step__icon-inner">{{request.arguments.length-1}}</div>
|
||||||
</div></span>
|
</div></span>
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
|
<el-row>
|
||||||
|
<el-link class="ms-el-link" @click="batchAdd"> {{$t("commons.batch_add")}}</el-link>
|
||||||
|
</el-row>
|
||||||
<ms-api-variable :is-read-only="isReadOnly" :isShowEnable="isShowEnable" :parameters="request.arguments"/>
|
<ms-api-variable :is-read-only="isReadOnly" :isShowEnable="isShowEnable" :parameters="request.arguments"/>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
|
|
||||||
|
@ -39,6 +40,9 @@
|
||||||
</div>
|
</div>
|
||||||
</span>
|
</span>
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
|
<el-row>
|
||||||
|
<el-link class="ms-el-link" @click="batchAdd"> {{$t("commons.batch_add")}}</el-link>
|
||||||
|
</el-row>
|
||||||
<ms-api-variable :is-read-only="isReadOnly" :isShowEnable="isShowEnable" :parameters="request.rest"/>
|
<ms-api-variable :is-read-only="isReadOnly" :isShowEnable="isShowEnable" :parameters="request.rest"/>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
|
|
||||||
|
@ -71,6 +75,9 @@
|
||||||
<!--提取规则-->
|
<!--提取规则-->
|
||||||
<ms-api-extract :is-read-only="isReadOnly" @copyRow="copyRow" @remove="remove" v-if="row.type==='Extract'" :extract="row"/>
|
<ms-api-extract :is-read-only="isReadOnly" @copyRow="copyRow" @remove="remove" v-if="row.type==='Extract'" :extract="row"/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<batch-add-parameter @batchSave="batchSave" ref="batchAddParameter"/>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</el-col>
|
</el-col>
|
||||||
<!--操作按钮-->
|
<!--操作按钮-->
|
||||||
|
@ -98,15 +105,24 @@
|
||||||
import {createComponent} from "../../jmeter/components";
|
import {createComponent} from "../../jmeter/components";
|
||||||
import MsApiAssertions from "../../assertion/ApiAssertions";
|
import MsApiAssertions from "../../assertion/ApiAssertions";
|
||||||
import MsApiExtract from "../../extract/ApiExtract";
|
import MsApiExtract from "../../extract/ApiExtract";
|
||||||
import {Assertions, Body, Extract} from "../../../model/ApiTestModel";
|
import {Assertions, Body, Extract, KeyValue} from "../../../model/ApiTestModel";
|
||||||
import {getUUID} from "@/common/js/utils";
|
import {getUUID} from "@/common/js/utils";
|
||||||
|
import BatchAddParameter from "../../basis/BatchAddParameter";
|
||||||
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "MsApiHttpRequestForm",
|
name: "MsApiHttpRequestForm",
|
||||||
components: {
|
components: {
|
||||||
MsJsr233Processor,
|
MsJsr233Processor,
|
||||||
MsApiAdvancedConfig,
|
MsApiAdvancedConfig,
|
||||||
MsApiVariable, ApiRequestMethodSelect, MsApiExtract, MsApiAuthConfig, MsApiBody, MsApiKeyValue, MsApiAssertions
|
BatchAddParameter,
|
||||||
|
MsApiVariable,
|
||||||
|
ApiRequestMethodSelect,
|
||||||
|
MsApiExtract,
|
||||||
|
MsApiAuthConfig,
|
||||||
|
MsApiBody,
|
||||||
|
MsApiKeyValue,
|
||||||
|
MsApiAssertions
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
request: {},
|
request: {},
|
||||||
|
@ -149,7 +165,7 @@
|
||||||
},
|
},
|
||||||
headerSuggestions: REQUEST_HEADERS,
|
headerSuggestions: REQUEST_HEADERS,
|
||||||
isReloadData: false,
|
isReloadData: false,
|
||||||
isBodyShow: true
|
isBodyShow: true,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -216,6 +232,35 @@
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.isBodyShow = true;
|
this.isBodyShow = true;
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
batchAdd() {
|
||||||
|
this.$refs.batchAddParameter.open();
|
||||||
|
},
|
||||||
|
batchSave(data) {
|
||||||
|
if (data) {
|
||||||
|
let params = data.split("\n");
|
||||||
|
let keyValues = [];
|
||||||
|
params.forEach(item => {
|
||||||
|
let line = item.split(/,|,/);
|
||||||
|
let required = false;
|
||||||
|
if (line[1] === '必填' || line[1] === 'true') {
|
||||||
|
required = true;
|
||||||
|
}
|
||||||
|
keyValues.push(new KeyValue({name: line[0], required: required, value: line[2], description: line[3], type: "text", valid: false, file: false, encode: true, enable: true, contentType: "text/plain"}));
|
||||||
|
})
|
||||||
|
keyValues.forEach(item => {
|
||||||
|
switch (this.activeName) {
|
||||||
|
case "parameters":
|
||||||
|
this.request.arguments.unshift(item);
|
||||||
|
break;
|
||||||
|
case "rest":
|
||||||
|
this.request.rest.unshift(item);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -273,4 +318,8 @@
|
||||||
border: #E6EEF2;
|
border: #E6EEF2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.ms-el-link {
|
||||||
|
float: right;
|
||||||
|
margin-right: 45px;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit a22a3005d9bd254793fcf634d72539cbdf31be3a
|
Subproject commit 29a8fc09602fde5708af06582ac972d98eb69836
|
|
@ -124,6 +124,7 @@ export default {
|
||||||
already_exists: 'The name already exists',
|
already_exists: 'The name already exists',
|
||||||
modifier: 'Modifier',
|
modifier: 'Modifier',
|
||||||
validate: "Validate",
|
validate: "Validate",
|
||||||
|
batch_add: "Batch add",
|
||||||
date: {
|
date: {
|
||||||
select_date: 'Select date',
|
select_date: 'Select date',
|
||||||
start_date: 'Start date',
|
start_date: 'Start date',
|
||||||
|
|
|
@ -124,6 +124,7 @@ export default {
|
||||||
already_exists: '名称不能重复',
|
already_exists: '名称不能重复',
|
||||||
modifier: '修改人',
|
modifier: '修改人',
|
||||||
validate: "校验",
|
validate: "校验",
|
||||||
|
batch_add: "批量添加",
|
||||||
date: {
|
date: {
|
||||||
select_date: '选择日期',
|
select_date: '选择日期',
|
||||||
start_date: '开始日期',
|
start_date: '开始日期',
|
||||||
|
@ -589,7 +590,7 @@ export default {
|
||||||
select_table: "选择可见数据",
|
select_table: "选择可见数据",
|
||||||
select_all: "选择全部数据"
|
select_all: "选择全部数据"
|
||||||
},
|
},
|
||||||
report_name_info: '请输入报名名称',
|
report_name_info: '请输入报告名称',
|
||||||
save_case_info: '请先保存用例',
|
save_case_info: '请先保存用例',
|
||||||
reference_deleted: '引用已删除',
|
reference_deleted: '引用已删除',
|
||||||
},
|
},
|
||||||
|
|
|
@ -124,6 +124,7 @@ export default {
|
||||||
already_exists: '名稱不能重復',
|
already_exists: '名稱不能重復',
|
||||||
modifier: '修改人',
|
modifier: '修改人',
|
||||||
validate: "校驗",
|
validate: "校驗",
|
||||||
|
batch_add: "批量添加",
|
||||||
date: {
|
date: {
|
||||||
select_date: '選擇日期',
|
select_date: '選擇日期',
|
||||||
start_date: '開始日期',
|
start_date: '開始日期',
|
||||||
|
@ -589,7 +590,7 @@ export default {
|
||||||
select_table: "選擇可見數據",
|
select_table: "選擇可見數據",
|
||||||
select_all: "選擇全部數據"
|
select_all: "選擇全部數據"
|
||||||
},
|
},
|
||||||
report_name_info: '請輸入報名名稱',
|
report_name_info: '請輸入報告名稱',
|
||||||
save_case_info: '請先保存用例',
|
save_case_info: '請先保存用例',
|
||||||
reference_deleted: '引用已删除',
|
reference_deleted: '引用已删除',
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue