feat(接口自动化): 统一添加复制功能

This commit is contained in:
fit2-zhao 2020-12-10 18:16:30 +08:00
parent 541a823339
commit 90a9877178
13 changed files with 110 additions and 42 deletions

View File

@ -26,7 +26,8 @@
<i class="icon el-icon-arrow-right" :class="{'is-active': request.active}" <i class="icon el-icon-arrow-right" :class="{'is-active': request.active}"
@click="active(request)" v-if="request.referenced!=undefined && request.referenced!='Deleted' && request.referenced!='REF'"/> @click="active(request)" v-if="request.referenced!=undefined && request.referenced!='Deleted' && request.referenced!='REF'"/>
<el-switch v-model="request.enable" style="margin-left: 10px"/> <el-switch v-model="request.enable" style="margin-left: 10px"/>
<el-button size="mini" icon="el-icon-delete" circle @click="remove" style="margin-left: 10px"/> <el-button size="mini" icon="el-icon-copy-document" circle @click="copyRow" style="margin-left: 10px"/>
<el-button size="mini" icon="el-icon-delete" type="danger" circle @click="remove" style="margin-left: 10px"/>
</div> </div>
</el-row> </el-row>
<!-- 请求参数--> <!-- 请求参数-->
@ -101,6 +102,9 @@
remove() { remove() {
this.$emit('remove', this.request, this.node); this.$emit('remove', this.request, this.node);
}, },
copyRow() {
this.$emit('copyRow', this.request, this.node);
},
active(item) { active(item) {
item.active = !item.active; item.active = !item.active;
this.reload(); this.reload();

View File

@ -11,7 +11,8 @@
<el-tag size="mini" style="margin-left: 20px" v-if="scenario.referenced==='REF'">{{ $t('api_test.scenario.reference') }}</el-tag> <el-tag size="mini" style="margin-left: 20px" v-if="scenario.referenced==='REF'">{{ $t('api_test.scenario.reference') }}</el-tag>
<div style="margin-right: 20px; float: right"> <div style="margin-right: 20px; float: right">
<el-switch v-model="scenario.enable" style="margin-left: 10px"/> <el-switch v-model="scenario.enable" style="margin-left: 10px"/>
<el-button size="mini" icon="el-icon-delete" circle @click="remove" style="margin-left: 10px"/> <el-button size="mini" icon="el-icon-copy-document" circle @click="copyRow" style="margin-left: 10px"/>
<el-button size="mini" icon="el-icon-delete" type="danger" circle @click="remove" style="margin-left: 10px"/>
</div> </div>
</el-row> </el-row>
</el-card> </el-card>
@ -55,6 +56,9 @@
item.active = !item.active; item.active = !item.active;
this.reload(); this.reload();
}, },
copyRow() {
this.$emit('copyRow', this.scenario, this.node);
},
reload() { reload() {
this.loading = true this.loading = true
this.$nextTick(() => { this.$nextTick(() => {

View File

@ -10,7 +10,8 @@
ms ms
<div style="margin-right: 20px; float: right"> <div style="margin-right: 20px; float: right">
<el-switch v-model="timer.enable" style="margin-left: 10px"/> <el-switch v-model="timer.enable" style="margin-left: 10px"/>
<el-button size="mini" icon="el-icon-delete" circle @click="remove" style="margin-left: 10px;"/> <el-button size="mini" icon="el-icon-copy-document" circle @click="copyRow" style="margin-left: 10px"/>
<el-button size="mini" icon="el-icon-delete" type="danger" circle @click="remove" style="margin-left: 10px"/>
</div> </div>
</el-row> </el-row>
</el-card> </el-card>
@ -30,7 +31,10 @@
methods: { methods: {
remove() { remove() {
this.$emit('remove', this.timer, this.node); this.$emit('remove', this.timer, this.node);
} },
copyRow() {
this.$emit('copyRow', this.timer, this.node);
},
} }
} }
</script> </script>

View File

@ -79,8 +79,7 @@
<el-row> <el-row>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="Tag" prop="tagId"> <el-form-item label="Tag" prop="tagId">
<el-select v-model="currentScenario.tagId" size="small" class="ms-scenario-input" placeholder="Tag" <el-select v-model="currentScenario.tagId" size="small" class="ms-scenario-input" placeholder="Tag" :multiple="true">
@change="tagChange" :multiple="true">
<el-option <el-option
v-for="item in tags" v-for="item in tags"
:key="item.id" :key="item.id"
@ -168,26 +167,26 @@
<span class="custom-tree-node father" slot-scope="{ node, data}" style="width: 96%"> <span class="custom-tree-node father" slot-scope="{ node, data}" style="width: 96%">
<template> <template>
<!-- 场景 --> <!-- 场景 -->
<ms-api-scenario-component v-if="data.type==='scenario'" :scenario="data" :node="node" @remove="remove"/> <ms-api-scenario-component v-if="data.type==='scenario'" :scenario="data" :node="node" @remove="remove" @copyRow="copyRow"/>
<!--条件控制器--> <!--条件控制器-->
<ms-if-controller :controller="data" :node="node" v-if="data.type==='IfController'" @remove="remove"/> <ms-if-controller :controller="data" :node="node" v-if="data.type==='IfController'" @remove="remove" @copyRow="copyRow"/>
<!--等待控制器--> <!--等待控制器-->
<ms-constant-timer :timer="data" :node="node" v-if="data.type==='ConstantTimer'" @remove="remove"/> <ms-constant-timer :timer="data" :node="node" v-if="data.type==='ConstantTimer'" @remove="remove" @copyRow="copyRow"/>
<!--自定义脚本--> <!--自定义脚本-->
<ms-jsr233-processor v-if="data.type==='JSR223Processor'" @remove="remove" :title="$t('api_test.automation.customize_script')" <ms-jsr233-processor v-if="data.type==='JSR223Processor'" @remove="remove" @copyRow="copyRow" :title="$t('api_test.automation.customize_script')"
style-type="color: #7B4D12;background-color: #F1EEE9" :jsr223-processor="data" :node="node"/> style-type="color: #7B4D12;background-color: #F1EEE9" :jsr223-processor="data" :node="node"/>
<!--前置脚本--> <!--前置脚本-->
<ms-jsr233-processor v-if="data.type==='JSR223PreProcessor'" @remove="remove" :title="$t('api_test.definition.request.pre_script')" <ms-jsr233-processor v-if="data.type==='JSR223PreProcessor'" @remove="remove" @copyRow="copyRow" :title="$t('api_test.definition.request.pre_script')"
style-type="color: #B8741A;background-color: #F9F1EA" :jsr223-processor="data" :node="node"/> style-type="color: #B8741A;background-color: #F9F1EA" :jsr223-processor="data" :node="node"/>
<!--后置脚本--> <!--后置脚本-->
<ms-jsr233-processor v-if="data.type==='JSR223PostProcessor'" @remove="remove" :title="$t('api_test.definition.request.post_script')" <ms-jsr233-processor v-if="data.type==='JSR223PostProcessor'" @remove="remove" @copyRow="copyRow" :title="$t('api_test.definition.request.post_script')"
style-type="color: #783887;background-color: #F2ECF3" :jsr223-processor="data" :node="node"/> style-type="color: #783887;background-color: #F2ECF3" :jsr223-processor="data" :node="node"/>
<!--断言规则--> <!--断言规则-->
<ms-api-assertions v-if="data.type==='Assertions'" @remove="remove" customizeStyle="margin-top: 0px" :assertions="data" :node="node"/> <ms-api-assertions v-if="data.type==='Assertions'" @remove="remove" @copyRow="copyRow" customizeStyle="margin-top: 0px" :assertions="data" :node="node"/>
<!--提取规则--> <!--提取规则-->
<ms-api-extract @remove="remove" v-if="data.type==='Extract'" customizeStyle="margin-top: 0px" :extract="data" :node="node"/> <ms-api-extract @remove="remove" @copyRow="copyRow" v-if="data.type==='Extract'" customizeStyle="margin-top: 0px" :extract="data" :node="node"/>
<!--API 导入 --> <!--API 导入 -->
<ms-api-component :request="data" @remove="remove" v-if="data.type==='HTTPSamplerProxy'||data.type==='DubboSampler'||data.type==='JDBCSampler'||data.type==='TCPSampler'" :node="node"/> <ms-api-component :request="data" @remove="remove" @copyRow="copyRow" v-if="data.type==='HTTPSamplerProxy'||data.type==='DubboSampler'||data.type==='JDBCSampler'||data.type==='TCPSampler'" :node="node"/>
</template> </template>
</span> </span>
</el-tree> </el-tree>
@ -513,9 +512,6 @@
this.$post('/user/ws/member/tester/list', {workspaceId: workspaceId}, response => { this.$post('/user/ws/member/tester/list', {workspaceId: workspaceId}, response => {
this.maintainerOptions = response.data; this.maintainerOptions = response.data;
}); });
},
tagChange() {
}, },
openTagConfig() { openTagConfig() {
if (!this.projectId) { if (!this.projectId) {
@ -546,6 +542,16 @@
this.sort(); this.sort();
this.reload(); this.reload();
}, },
copyRow(row, node) {
const parent = node.parent
const hashTree = parent.data.hashTree || parent.data;
let obj = {};
Object.assign(obj, row);
obj.resourceId = getUUID();
hashTree.push(obj);
this.sort();
this.reload();
},
reload() { reload() {
this.isReloadData = true this.isReloadData = true
this.$nextTick(() => { this.$nextTick(() => {

View File

@ -16,7 +16,8 @@
<el-input size="small" v-model="controller.value" :placeholder="$t('api_test.value')" v-if="!hasEmptyOperator" style="width: 20%;margin-left: 20px"/> <el-input size="small" v-model="controller.value" :placeholder="$t('api_test.value')" v-if="!hasEmptyOperator" style="width: 20%;margin-left: 20px"/>
<div style="margin-right: 20px; float: right"> <div style="margin-right: 20px; float: right">
<el-switch v-model="controller.enable" style="margin-left: 10px"/> <el-switch v-model="controller.enable" style="margin-left: 10px"/>
<el-button size="mini" icon="el-icon-delete" circle @click="remove" style="margin-left: 10px;"/> <el-button size="mini" icon="el-icon-copy-document" circle @click="copyRow" style="margin-left: 10px"/>
<el-button size="mini" icon="el-icon-delete" type="danger" circle @click="remove" style="margin-left: 10px"/>
</div> </div>
</el-row> </el-row>
</el-card> </el-card>
@ -72,6 +73,9 @@
remove() { remove() {
this.$emit('remove', this.controller, this.node); this.$emit('remove', this.controller, this.node);
}, },
copyRow() {
this.$emit('copyRow', this.controller, this.node);
},
change(value) { change(value) {
if (value.indexOf("empty") > 0 && !!this.controller.value) { if (value.indexOf("empty") > 0 && !!this.controller.value) {
this.controller.value = ""; this.controller.value = "";

View File

@ -10,7 +10,8 @@
<div style="margin-right: 20px; float: right"> <div style="margin-right: 20px; float: right">
<i class="icon el-icon-arrow-right" :class="{'is-active': this.jsr223ProcessorData.active}" @click="changeActive" style="margin-left: 20px"/> <i class="icon el-icon-arrow-right" :class="{'is-active': this.jsr223ProcessorData.active}" @click="changeActive" style="margin-left: 20px"/>
<el-switch v-model="jsr223ProcessorData.enable" style="margin-left: 10px"/> <el-switch v-model="jsr223ProcessorData.enable" style="margin-left: 10px"/>
<el-button size="mini" icon="el-icon-delete" circle @click="remove" style="margin-left: 10px;"/> <el-button size="mini" icon="el-icon-copy-document" circle @click="copyRow" style="margin-left: 10px"/>
<el-button size="mini" icon="el-icon-delete" type="danger" circle @click="remove" style="margin-left: 10px"/>
</div> </div>
</div> </div>
</el-row> </el-row>
@ -142,6 +143,9 @@
remove() { remove() {
this.$emit('remove', this.jsr223ProcessorData, this.node); this.$emit('remove', this.jsr223ProcessorData, this.node);
}, },
copyRow() {
this.$emit('copyRow', this.jsr223ProcessorData, this.node);
},
reload() { reload() {
this.isCodeEditAlive = false; this.isCodeEditAlive = false;
this.$nextTick(() => (this.isCodeEditAlive = true)); this.$nextTick(() => (this.isCodeEditAlive = true));

View File

@ -11,7 +11,8 @@
<div style="margin-right: 20px; float: right"> <div style="margin-right: 20px; float: right">
<i class="icon el-icon-arrow-right" :class="{'is-active': assertions.active}" @click="active(assertions)" style="margin-left: 20px"/> <i class="icon el-icon-arrow-right" :class="{'is-active': assertions.active}" @click="active(assertions)" style="margin-left: 20px"/>
<el-switch v-model="assertions.enable" style="margin-left: 10px"/> <el-switch v-model="assertions.enable" style="margin-left: 10px"/>
<el-button size="mini" icon="el-icon-delete" circle @click="remove" style="margin-left: 10px;"/> <el-button size="mini" icon="el-icon-copy-document" circle @click="copyRow" style="margin-left: 10px"/>
<el-button size="mini" icon="el-icon-delete" type="danger" circle @click="remove" style="margin-left: 10px"/>
</div> </div>
</div> </div>
<!-- 请求参数--> <!-- 请求参数-->
@ -109,6 +110,9 @@
this.reloadData = getUUID().substring(0, 8); this.reloadData = getUUID().substring(0, 8);
this.reload(); this.reload();
}, },
copyRow() {
this.$emit('copyRow', this.assertions, this.node);
},
suggestJsonOpen() { suggestJsonOpen() {
if (!this.request.debugRequestResult) { if (!this.request.debugRequestResult) {
this.$message(this.$t('api_test.request.assertions.debug_first')); this.$message(this.$t('api_test.request.assertions.debug_first'));

View File

@ -9,7 +9,8 @@
<div style="margin-right: 20px; float: right"> <div style="margin-right: 20px; float: right">
<i class="icon el-icon-arrow-right" :class="{'is-active': extract.active}" @click="active(extract)" style="margin-left: 20px"/> <i class="icon el-icon-arrow-right" :class="{'is-active': extract.active}" @click="active(extract)" style="margin-left: 20px"/>
<el-switch v-model="extract.enable" style="margin-left: 10px"/> <el-switch v-model="extract.enable" style="margin-left: 10px"/>
<el-button size="mini" icon="el-icon-delete" circle @click="remove" style="margin-left: 10px;"/> <el-button size="mini" icon="el-icon-copy-document" circle @click="copyRow" style="margin-left: 10px"/>
<el-button size="mini" icon="el-icon-delete" type="danger" circle @click="remove" style="margin-left: 10px"/>
</div> </div>
<!-- 请求参数--> <!-- 请求参数-->
<el-collapse-transition> <el-collapse-transition>
@ -87,6 +88,9 @@
remove() { remove() {
this.$emit('remove', this.extract, this.node); this.$emit('remove', this.extract, this.node);
}, },
copyRow() {
this.$emit('copyRow', this.extract, this.node);
},
reload() { reload() {
this.loading = true this.loading = true
this.$nextTick(() => { this.$nextTick(() => {

View File

@ -9,7 +9,8 @@
<div style="margin-right: 20px; float: right"> <div style="margin-right: 20px; float: right">
<i class="icon el-icon-arrow-right" :class="{'is-active': active}" @click="changeActive"/> <i class="icon el-icon-arrow-right" :class="{'is-active': active}" @click="changeActive"/>
<el-switch v-model="jsr223ProcessorData.enable" style="margin-left: 10px"/> <el-switch v-model="jsr223ProcessorData.enable" style="margin-left: 10px"/>
<el-button size="mini" icon="el-icon-delete" circle @click="remove" style="margin-left: 10px;"/> <el-button size="mini" icon="el-icon-copy-document" circle @click="copyRow" style="margin-left: 10px"/>
<el-button size="mini" icon="el-icon-delete" type="danger" circle @click="remove" style="margin-left: 10px"/>
</div> </div>
</div> </div>
</el-row> </el-row>
@ -147,6 +148,9 @@
remove() { remove() {
this.$emit('remove', this.jsr223ProcessorData); this.$emit('remove', this.jsr223ProcessorData);
}, },
copyRow() {
this.$emit('copyRow', this.jsr223ProcessorData);
},
reload() { reload() {
this.isCodeEditAlive = false; this.isCodeEditAlive = false;
this.$nextTick(() => (this.isCodeEditAlive = true)); this.$nextTick(() => (this.isCodeEditAlive = true));

View File

@ -65,15 +65,15 @@
</div> </div>
<div v-for="row in request.hashTree" :key="row.id" v-loading="isReloadData" style="margin-left: 20px;width: 100%"> <div v-for="row in request.hashTree" :key="row.id" v-loading="isReloadData" style="margin-left: 20px;width: 100%">
<!-- 前置脚本 --> <!-- 前置脚本 -->
<ms-jsr233-processor v-if="row.label ==='JSR223 PreProcessor'" @remove="remove" :is-read-only="false" :title="$t('api_test.definition.request.pre_script')" style-type="color: #B8741A;background-color: #F9F1EA" <ms-jsr233-processor v-if="row.label ==='JSR223 PreProcessor'" @copyRow="copyRow" @remove="remove" :is-read-only="false" :title="$t('api_test.definition.request.pre_script')" style-type="color: #B8741A;background-color: #F9F1EA"
:jsr223-processor="row"/> :jsr223-processor="row"/>
<!--后置脚本--> <!--后置脚本-->
<ms-jsr233-processor v-if="row.label ==='JSR223 PostProcessor'" @remove="remove" :is-read-only="false" :title="$t('api_test.definition.request.post_script')" style-type="color: #783887;background-color: #F2ECF3" <ms-jsr233-processor v-if="row.label ==='JSR223 PostProcessor'" @copyRow="copyRow" @remove="remove" :is-read-only="false" :title="$t('api_test.definition.request.post_script')" style-type="color: #783887;background-color: #F2ECF3"
:jsr223-processor="row"/> :jsr223-processor="row"/>
<!--断言规则--> <!--断言规则-->
<ms-api-assertions v-if="row.type==='Assertions'" @remove="remove" :is-read-only="isReadOnly" :assertions="row"/> <ms-api-assertions v-if="row.type==='Assertions'" @copyRow="copyRow" @remove="remove" :is-read-only="isReadOnly" :assertions="row"/>
<!--提取规则--> <!--提取规则-->
<ms-api-extract :is-read-only="isReadOnly" @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>
</el-col> </el-col>
@ -107,6 +107,7 @@
import {parseEnvironment} from "../../../model/EnvironmentModel"; import {parseEnvironment} from "../../../model/EnvironmentModel";
import ApiEnvironmentConfig from "../../environment/ApiEnvironmentConfig"; import ApiEnvironmentConfig from "../../environment/ApiEnvironmentConfig";
import {getCurrentProjectID} from "@/common/js/utils"; import {getCurrentProjectID} from "@/common/js/utils";
import {getUUID} from "@/common/js/utils";
export default { export default {
name: "MsDatabaseConfig", name: "MsDatabaseConfig",
@ -165,6 +166,13 @@
this.request.hashTree.splice(index, 1); this.request.hashTree.splice(index, 1);
this.reload(); this.reload();
}, },
copyRow(row) {
let obj = {};
Object.assign(obj, row);
obj.id = getUUID();
this.request.hashTree.push(obj);
this.reload();
},
reload() { reload() {
this.isReloadData = true this.isReloadData = true
this.$nextTick(() => { this.$nextTick(() => {

View File

@ -44,15 +44,15 @@
<div v-for="row in request.hashTree" :key="row.id" v-loading="isReloadData" style="margin-left: 20px;width: 100%"> <div v-for="row in request.hashTree" :key="row.id" v-loading="isReloadData" style="margin-left: 20px;width: 100%">
<!-- 前置脚本 --> <!-- 前置脚本 -->
<ms-jsr233-processor v-if="row.label ==='JSR223 PreProcessor'" @remove="remove" :is-read-only="false" :title="$t('api_test.definition.request.pre_script')" style-type="color: #B8741A;background-color: #F9F1EA" <ms-jsr233-processor v-if="row.label ==='JSR223 PreProcessor'" @copyRow="copyRow" @remove="remove" :is-read-only="false" :title="$t('api_test.definition.request.pre_script')" style-type="color: #B8741A;background-color: #F9F1EA"
:jsr223-processor="row"/> :jsr223-processor="row"/>
<!--后置脚本--> <!--后置脚本-->
<ms-jsr233-processor v-if="row.label ==='JSR223 PostProcessor'" @remove="remove" :is-read-only="false" :title="$t('api_test.definition.request.post_script')" style-type="color: #783887;background-color: #F2ECF3" <ms-jsr233-processor v-if="row.label ==='JSR223 PostProcessor'" @copyRow="copyRow" @remove="remove" :is-read-only="false" :title="$t('api_test.definition.request.post_script')" style-type="color: #783887;background-color: #F2ECF3"
:jsr223-processor="row"/> :jsr223-processor="row"/>
<!--断言规则--> <!--断言规则-->
<ms-api-assertions v-if="row.type==='Assertions'" @remove="remove" :is-read-only="isReadOnly" :assertions="row"/> <ms-api-assertions v-if="row.type==='Assertions'" @copyRow="copyRow" @remove="remove" :is-read-only="isReadOnly" :assertions="row"/>
<!--提取规则--> <!--提取规则-->
<ms-api-extract :is-read-only="isReadOnly" @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>
</el-col> </el-col>
@ -81,11 +81,11 @@
import MsApiScenarioVariables from "../../ApiScenarioVariables"; import MsApiScenarioVariables from "../../ApiScenarioVariables";
import {createComponent} from "../../jmeter/components"; import {createComponent} from "../../jmeter/components";
import {Assertions, Extract, DubboRequest} from "../../../model/ApiTestModel"; import {Assertions, Extract, DubboRequest} from "../../../model/ApiTestModel";
import {parseEnvironment} from "../../../model/EnvironmentModel";
import MsDubboInterface from "../../request/dubbo/Interface"; import MsDubboInterface from "../../request/dubbo/Interface";
import MsDubboRegistryCenter from "../../request/dubbo/RegistryCenter"; import MsDubboRegistryCenter from "../../request/dubbo/RegistryCenter";
import MsDubboConfigCenter from "../../request/dubbo/ConfigCenter"; import MsDubboConfigCenter from "../../request/dubbo/ConfigCenter";
import MsDubboConsumerService from "../../request/dubbo/ConsumerAndService"; import MsDubboConsumerService from "../../request/dubbo/ConsumerAndService";
import {getUUID} from "@/common/js/utils";
export default { export default {
name: "MsDatabaseConfig", name: "MsDatabaseConfig",
@ -140,6 +140,13 @@
this.request.hashTree.splice(index, 1); this.request.hashTree.splice(index, 1);
this.reload(); this.reload();
}, },
copyRow(row) {
let obj = {};
Object.assign(obj, row);
obj.id = getUUID();
this.request.hashTree.push(obj);
this.reload();
},
reload() { reload() {
this.isReloadData = true this.isReloadData = true
this.$nextTick(() => { this.$nextTick(() => {

View File

@ -30,7 +30,7 @@
</el-tab-pane> </el-tab-pane>
<!--REST 参数--> <!--REST 参数-->
<el-tab-pane :label="$t('api_test.definition.request.rest_param')" name="rest" > <el-tab-pane :label="$t('api_test.definition.request.rest_param')" name="rest">
<el-tooltip class="item-tabs" effect="dark" :content="$t('api_test.definition.request.rest_info')" placement="top-start" slot="label"> <el-tooltip class="item-tabs" effect="dark" :content="$t('api_test.definition.request.rest_info')" placement="top-start" slot="label">
<span> <span>
{{$t('api_test.definition.request.rest_param')}} {{$t('api_test.definition.request.rest_param')}}
@ -61,15 +61,15 @@
<div v-for="row in request.hashTree" :key="row.id" v-loading="isReloadData"> <div v-for="row in request.hashTree" :key="row.id" v-loading="isReloadData">
<!-- 前置脚本 --> <!-- 前置脚本 -->
<ms-jsr233-processor v-if="row.label ==='JSR223 PreProcessor'" @remove="remove" :is-read-only="false" :title="$t('api_test.definition.request.pre_script')" style-type="color: #B8741A;background-color: #F9F1EA" <ms-jsr233-processor v-if="row.label ==='JSR223 PreProcessor'" @copyRow="copyRow" @remove="remove" :is-read-only="false" :title="$t('api_test.definition.request.pre_script')" style-type="color: #B8741A;background-color: #F9F1EA"
:jsr223-processor="row"/> :jsr223-processor="row"/>
<!--后置脚本--> <!--后置脚本-->
<ms-jsr233-processor v-if="row.label ==='JSR223 PostProcessor'" @remove="remove" :is-read-only="false" :title="$t('api_test.definition.request.post_script')" style-type="color: #783887;background-color: #F2ECF3" <ms-jsr233-processor v-if="row.label ==='JSR223 PostProcessor'" @copyRow="copyRow" @remove="remove" :is-read-only="false" :title="$t('api_test.definition.request.post_script')" style-type="color: #783887;background-color: #F2ECF3"
:jsr223-processor="row"/> :jsr223-processor="row"/>
<!--断言规则--> <!--断言规则-->
<ms-api-assertions v-if="row.type==='Assertions'" @remove="remove" :is-read-only="isReadOnly" :assertions="row"/> <ms-api-assertions v-if="row.type==='Assertions'" @copyRow="copyRow" @remove="remove" :is-read-only="isReadOnly" :assertions="row"/>
<!--提取规则--> <!--提取规则-->
<ms-api-extract :is-read-only="isReadOnly" @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>
</el-col> </el-col>
@ -99,6 +99,7 @@
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} from "../../../model/ApiTestModel";
import {getUUID} from "@/common/js/utils";
export default { export default {
name: "MsApiHttpRequestForm", name: "MsApiHttpRequestForm",
@ -180,6 +181,13 @@
this.request.hashTree.splice(index, 1); this.request.hashTree.splice(index, 1);
this.reload(); this.reload();
}, },
copyRow(row) {
let obj = {};
Object.assign(obj, row);
row.id = getUUID();
this.request.hashTree.push(obj);
this.reload();
},
reload() { reload() {
this.isReloadData = true this.isReloadData = true
this.$nextTick(() => { this.$nextTick(() => {

View File

@ -92,15 +92,15 @@
</div> </div>
<div v-for="row in request.hashTree" :key="row.id" v-loading="isReloadData" style="margin-left: 20px;width: 100%"> <div v-for="row in request.hashTree" :key="row.id" v-loading="isReloadData" style="margin-left: 20px;width: 100%">
<!-- 前置脚本 --> <!-- 前置脚本 -->
<ms-jsr233-processor v-if="row.label ==='JSR223 PreProcessor'" @remove="remove" :is-read-only="false" :title="$t('api_test.definition.request.pre_script')" style-type="color: #B8741A;background-color: #F9F1EA" <ms-jsr233-processor v-if="row.label ==='JSR223 PreProcessor'" @copyRow="copyRow" @remove="remove" :is-read-only="false" :title="$t('api_test.definition.request.pre_script')" style-type="color: #B8741A;background-color: #F9F1EA"
:jsr223-processor="row"/> :jsr223-processor="row"/>
<!--后置脚本--> <!--后置脚本-->
<ms-jsr233-processor v-if="row.label ==='JSR223 PostProcessor'" @remove="remove" :is-read-only="false" :title="$t('api_test.definition.request.post_script')" style-type="color: #783887;background-color: #F2ECF3" <ms-jsr233-processor v-if="row.label ==='JSR223 PostProcessor'" @copyRow="copyRow" @remove="remove" :is-read-only="false" :title="$t('api_test.definition.request.post_script')" style-type="color: #783887;background-color: #F2ECF3"
:jsr223-processor="row"/> :jsr223-processor="row"/>
<!--断言规则--> <!--断言规则-->
<ms-api-assertions v-if="row.type==='Assertions'" @remove="remove" :is-read-only="isReadOnly" :assertions="row"/> <ms-api-assertions v-if="row.type==='Assertions'" @copyRow="copyRow" @remove="remove" :is-read-only="isReadOnly" :assertions="row"/>
<!--提取规则--> <!--提取规则-->
<ms-api-extract :is-read-only="isReadOnly" @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>
</el-col> </el-col>
@ -132,7 +132,7 @@
import ApiEnvironmentConfig from "../../environment/ApiEnvironmentConfig"; import ApiEnvironmentConfig from "../../environment/ApiEnvironmentConfig";
import {API_STATUS} from "../../../model/JsonData"; import {API_STATUS} from "../../../model/JsonData";
import TCPSampler from "../../jmeter/components/sampler/tcp-sampler"; import TCPSampler from "../../jmeter/components/sampler/tcp-sampler";
import {getCurrentProjectID} from "@/common/js/utils"; import {getCurrentProjectID, getUUID} from "@/common/js/utils";
export default { export default {
name: "MsDatabaseConfig", name: "MsDatabaseConfig",
@ -194,6 +194,13 @@
this.request.hashTree.splice(index, 1); this.request.hashTree.splice(index, 1);
this.reload(); this.reload();
}, },
copyRow(row) {
let obj = {};
Object.assign(obj, row);
obj.id = getUUID();
this.request.hashTree.push(obj);
this.reload();
},
reload() { reload() {
this.isReloadData = true this.isReloadData = true
this.$nextTick(() => { this.$nextTick(() => {