mirror of
https://gitee.com/fit2cloud-feizhiyun/MeterSphere.git
synced 2024-12-02 20:19:16 +08:00
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') }}
|
||||
</el-radio>
|
||||
</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"
|
||||
:parameters="body.kvs"
|
||||
:isShowEnable="isShowEnable"
|
||||
@ -55,12 +59,14 @@
|
||||
type="body"
|
||||
v-if="body.type == 'BINARY'"/>
|
||||
|
||||
<batch-add-parameter @batchSave="batchSave" ref="batchAddParameter"/>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
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 MsJsonCodeEdit from "../../../../common/components/MsJsonCodeEdit";
|
||||
|
||||
@ -68,6 +74,7 @@
|
||||
import MsApiVariable from "../ApiVariable";
|
||||
import MsApiBinaryVariable from "./ApiBinaryVariable";
|
||||
import MsApiFromUrlVariable from "./ApiFromUrlVariable";
|
||||
import BatchAddParameter from "../basis/BatchAddParameter";
|
||||
|
||||
export default {
|
||||
name: "MsApiBody",
|
||||
@ -78,7 +85,8 @@
|
||||
MsApiKeyValue,
|
||||
MsApiBinaryVariable,
|
||||
MsApiFromUrlVariable,
|
||||
MsJsonCodeEdit
|
||||
MsJsonCodeEdit,
|
||||
BatchAddParameter
|
||||
},
|
||||
props: {
|
||||
body: {},
|
||||
@ -147,9 +155,29 @@
|
||||
},
|
||||
jsonError(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() {
|
||||
if (!this.body.type) {
|
||||
this.body.type = BODY_TYPE.FORM_DATA;
|
||||
@ -187,4 +215,8 @@
|
||||
margin-top: 15px;
|
||||
}
|
||||
|
||||
.ms-el-link {
|
||||
float: right;
|
||||
margin-right: 45px;
|
||||
}
|
||||
</style>
|
||||
|
@ -13,7 +13,6 @@
|
||||
</div>
|
||||
</span>
|
||||
</el-tooltip>
|
||||
|
||||
<ms-api-key-value :is-read-only="isReadOnly" :isShowEnable="isShowEnable" :suggestions="headerSuggestions" :items="headers"/>
|
||||
</el-tab-pane>
|
||||
|
||||
@ -25,7 +24,9 @@
|
||||
<div class="el-step__icon-inner">{{request.arguments.length-1}}</div>
|
||||
</div></span>
|
||||
</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"/>
|
||||
</el-tab-pane>
|
||||
|
||||
@ -39,6 +40,9 @@
|
||||
</div>
|
||||
</span>
|
||||
</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"/>
|
||||
</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"/>
|
||||
</div>
|
||||
|
||||
<batch-add-parameter @batchSave="batchSave" ref="batchAddParameter"/>
|
||||
|
||||
</div>
|
||||
</el-col>
|
||||
<!--操作按钮-->
|
||||
@ -98,15 +105,24 @@
|
||||
import {createComponent} from "../../jmeter/components";
|
||||
import MsApiAssertions from "../../assertion/ApiAssertions";
|
||||
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 BatchAddParameter from "../../basis/BatchAddParameter";
|
||||
|
||||
|
||||
export default {
|
||||
name: "MsApiHttpRequestForm",
|
||||
components: {
|
||||
MsJsr233Processor,
|
||||
MsApiAdvancedConfig,
|
||||
MsApiVariable, ApiRequestMethodSelect, MsApiExtract, MsApiAuthConfig, MsApiBody, MsApiKeyValue, MsApiAssertions
|
||||
BatchAddParameter,
|
||||
MsApiVariable,
|
||||
ApiRequestMethodSelect,
|
||||
MsApiExtract,
|
||||
MsApiAuthConfig,
|
||||
MsApiBody,
|
||||
MsApiKeyValue,
|
||||
MsApiAssertions
|
||||
},
|
||||
props: {
|
||||
request: {},
|
||||
@ -149,7 +165,7 @@
|
||||
},
|
||||
headerSuggestions: REQUEST_HEADERS,
|
||||
isReloadData: false,
|
||||
isBodyShow: true
|
||||
isBodyShow: true,
|
||||
}
|
||||
},
|
||||
|
||||
@ -216,6 +232,35 @@
|
||||
this.$nextTick(() => {
|
||||
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;
|
||||
}
|
||||
|
||||
.ms-el-link {
|
||||
float: right;
|
||||
margin-right: 45px;
|
||||
}
|
||||
</style>
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit a22a3005d9bd254793fcf634d72539cbdf31be3a
|
||||
Subproject commit 29a8fc09602fde5708af06582ac972d98eb69836
|
@ -124,6 +124,7 @@ export default {
|
||||
already_exists: 'The name already exists',
|
||||
modifier: 'Modifier',
|
||||
validate: "Validate",
|
||||
batch_add: "Batch add",
|
||||
date: {
|
||||
select_date: 'Select date',
|
||||
start_date: 'Start date',
|
||||
|
@ -124,6 +124,7 @@ export default {
|
||||
already_exists: '名称不能重复',
|
||||
modifier: '修改人',
|
||||
validate: "校验",
|
||||
batch_add: "批量添加",
|
||||
date: {
|
||||
select_date: '选择日期',
|
||||
start_date: '开始日期',
|
||||
@ -589,7 +590,7 @@ export default {
|
||||
select_table: "选择可见数据",
|
||||
select_all: "选择全部数据"
|
||||
},
|
||||
report_name_info: '请输入报名名称',
|
||||
report_name_info: '请输入报告名称',
|
||||
save_case_info: '请先保存用例',
|
||||
reference_deleted: '引用已删除',
|
||||
},
|
||||
|
@ -124,6 +124,7 @@ export default {
|
||||
already_exists: '名稱不能重復',
|
||||
modifier: '修改人',
|
||||
validate: "校驗",
|
||||
batch_add: "批量添加",
|
||||
date: {
|
||||
select_date: '選擇日期',
|
||||
start_date: '開始日期',
|
||||
@ -166,7 +167,7 @@ export default {
|
||||
current_user: "是當前用戶"
|
||||
}
|
||||
},
|
||||
monitor:"監控",
|
||||
monitor: "監控",
|
||||
all_label: {
|
||||
case: "全部用例",
|
||||
review: "全部評審"
|
||||
@ -589,7 +590,7 @@ export default {
|
||||
select_table: "選擇可見數據",
|
||||
select_all: "選擇全部數據"
|
||||
},
|
||||
report_name_info: '請輸入報名名稱',
|
||||
report_name_info: '請輸入報告名稱',
|
||||
save_case_info: '請先保存用例',
|
||||
reference_deleted: '引用已删除',
|
||||
},
|
||||
@ -829,14 +830,14 @@ export default {
|
||||
not_exist: "測試報告不存在",
|
||||
},
|
||||
api_monitor: {
|
||||
to:"到",
|
||||
start_time:"開始時間",
|
||||
end_time:"結束時間",
|
||||
today:"今天",
|
||||
this_week:"本週",
|
||||
this_mouth:"本月",
|
||||
please_search:"請搜索",
|
||||
date:"日期"
|
||||
to: "到",
|
||||
start_time: "開始時間",
|
||||
end_time: "結束時間",
|
||||
today: "今天",
|
||||
this_week: "本週",
|
||||
this_mouth: "本月",
|
||||
please_search: "請搜索",
|
||||
date: "日期"
|
||||
},
|
||||
test_track: {
|
||||
test_track: "測試跟蹤",
|
||||
|
Loading…
Reference in New Issue
Block a user