# Conflicts:
#	frontend/src/business/components/api/definition/components/processor/Jsr233Processor.vue
This commit is contained in:
fit2-zhao 2021-01-12 18:00:26 +08:00
commit 14a54cabcc
18 changed files with 76 additions and 369 deletions

View File

@ -13,11 +13,11 @@
<slot name="headerLeft"> <slot name="headerLeft">
<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)"/> @click="active(request)"/>
<el-input draggable v-if="isShowInput || !request.name" size="small" v-model="request.name" class="name-input" <el-input v-if="(isShowInput || !request.name) && !isDeletedOrRef" size="small" v-model="request.name" class="name-input"
@blur="isShowInput = false" :placeholder="$t('commons.input_name')"/> @blur="isShowInput = false" :placeholder="$t('commons.input_name')"/>
<span v-else> <span v-else>
{{request.name}} {{request.name}}
<i :class="{'edit-disable' : isDeletedOrRef}" class="el-icon-edit" style="cursor:pointer" @click="editName" v-tester/> <i v-if="!isDeletedOrRef" class="el-icon-edit" style="cursor:pointer" @click="isShowInput = true" v-tester/>
</span> </span>
</slot> </slot>
@ -60,84 +60,6 @@
@runRefresh="runRefresh" ref="runTest"/> @runRefresh="runRefresh" ref="runTest"/>
</api-base-component> </api-base-component>
<!--<div v-loading="loading" @click="active(request)">-->
<!--<el-card>-->
<!--<el-row>-->
<!--&lt;!&ndash;<div class="el-step__icon is-text ms-api-col" v-if="request.referenced!=undefined && request.referenced==='Deleted' || request.referenced=='REF' || request.referenced==='Copy'">&ndash;&gt;-->
<!--&lt;!&ndash;<div class="el-step__icon-inner">{{request.index}}</div>&ndash;&gt;-->
<!--&lt;!&ndash;</div>&ndash;&gt;-->
<!--&lt;!&ndash;<div class="el-step__icon is-text ms-api-col-ot-import" v-else-if="request.referenced!=undefined && request.referenced==='OT_IMPORT'">&ndash;&gt;-->
<!--&lt;!&ndash;<div class="el-step__icon-inner">{{request.index}}</div>&ndash;&gt;-->
<!--&lt;!&ndash;</div>&ndash;&gt;-->
<!--&lt;!&ndash;<div class="el-step__icon is-text ms-api-col-create" v-else>&ndash;&gt;-->
<!--&lt;!&ndash;<div class="el-step__icon-inner">{{request.index}}</div>&ndash;&gt;-->
<!--&lt;!&ndash;</div>&ndash;&gt;-->
<!--&lt;!&ndash;<el-button v-if="request.referenced!=undefined && request.referenced==='Deleted' || request.referenced=='REF' || request.referenced==='Copy'" class="ms-left-button" size="small">&ndash;&gt;-->
<!--&lt;!&ndash;{{$t('api_test.automation.api_list_import')}}&ndash;&gt;-->
<!--&lt;!&ndash;</el-button>&ndash;&gt;-->
<!--&lt;!&ndash;<el-button v-if="request.referenced!=undefined && request.referenced==='OT_IMPORT'" class="ms-api-col-ot-import-button" size="small">&ndash;&gt;-->
<!--&lt;!&ndash;{{$t('api_test.automation.external_import')}}&ndash;&gt;-->
<!--&lt;!&ndash;</el-button>&ndash;&gt;-->
<!--&lt;!&ndash;<el-button v-if="request.referenced==undefined || request.referenced==='Created' " class="ms-create-button" size="small">&ndash;&gt;-->
<!--&lt;!&ndash;{{$t('api_test.automation.customize_req')}}&ndash;&gt;-->
<!--&lt;!&ndash;</el-button>&ndash;&gt;-->
<!--<span v-if="request.referenced!=undefined && request.referenced==='Deleted' || request.referenced=='REF'">{{request.name}} </span>-->
<!--<el-input size="small" v-model="request.name" style="width: 40%;" :placeholder="$t('commons.input_name')" v-else/>-->
<!--<el-tag size="mini" style="margin-left: 20px" v-if="request.referenced==='Deleted'" type="danger">{{$t('api_test.automation.reference_deleted')}}</el-tag>-->
<!--<el-tag size="mini" style="margin-left: 20px" v-if="request.referenced==='Copy'">{{ $t('commons.copy') }}</el-tag>-->
<!--<el-tag size="mini" style="margin-left: 20px" v-if="request.referenced ==='REF'">{{ $t('api_test.scenario.reference') }}</el-tag>-->
<!--<div style="margin-right: 20px; float: right">-->
<!--<i class="icon el-icon-arrow-right" :class="{'is-active': request.active}"-->
<!--@click="active(request)"/>-->
<!--<el-switch v-model="request.enable" style="margin-left: 10px"/>-->
<!--<el-button @click="run" :tip="$t('api_test.run')" icon="el-icon-video-play"-->
<!--style="background-color: #409EFF;color: white;margin-left: 10px" size="mini" circle/>-->
<!--<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>-->
<!--</el-row>-->
<!--&lt;!&ndash;&lt;!&ndash; 请求参数&ndash;&gt;&ndash;&gt;-->
<!--&lt;!&ndash;<el-collapse-transition>&ndash;&gt;-->
<!--&lt;!&ndash;<div v-if="request.active">&ndash;&gt;-->
<!--&lt;!&ndash;<div v-if="request.protocol === 'HTTP'">&ndash;&gt;-->
<!--&lt;!&ndash;<el-input :placeholder="$t('api_test.definition.request.path_all_info')" v-if="request.url" v-model="request.url" style="width: 85%;margin-top: 10px" size="small">&ndash;&gt;-->
<!--&lt;!&ndash;<el-select v-model="request.method" slot="prepend" style="width: 100px" size="small">&ndash;&gt;-->
<!--&lt;!&ndash;<el-option v-for="item in reqOptions" :key="item.id" :label="item.label" :value="item.id"/>&ndash;&gt;-->
<!--&lt;!&ndash;</el-select>&ndash;&gt;-->
<!--&lt;!&ndash;</el-input>&ndash;&gt;-->
<!--&lt;!&ndash;<el-input :placeholder="$t('api_test.definition.request.path_all_info')" v-else v-model="request.path" style="width: 85%;margin-top: 10px" size="small">&ndash;&gt;-->
<!--&lt;!&ndash;<el-select v-model="request.method" slot="prepend" style="width: 100px" size="small">&ndash;&gt;-->
<!--&lt;!&ndash;<el-option v-for="item in reqOptions" :key="item.id" :label="item.label" :value="item.id"/>&ndash;&gt;-->
<!--&lt;!&ndash;</el-select>&ndash;&gt;-->
<!--&lt;!&ndash;</el-input>&ndash;&gt;-->
<!--&lt;!&ndash;</div>&ndash;&gt;-->
<!--&lt;!&ndash;<p class="tip">{{$t('api_test.definition.request.req_param')}} </p>&ndash;&gt;-->
<!--&lt;!&ndash;<ms-api-request-form :referenced="true" :headers="request.headers " :request="request" v-if="request.protocol==='HTTP' || request.type==='HTTPSamplerProxy'"/>&ndash;&gt;-->
<!--&lt;!&ndash;<ms-tcp-basis-parameters :request="request" v-if="request.protocol==='TCP'|| request.type==='TCPSampler'"/>&ndash;&gt;-->
<!--&lt;!&ndash;<ms-sql-basis-parameters :request="request" v-if="request.protocol==='SQL'|| request.type==='JDBCSampler'" :showScript="false"/>&ndash;&gt;-->
<!--&lt;!&ndash;<ms-dubbo-basis-parameters :request="request" v-if="request.protocol==='DUBBO' || request.protocol==='dubbo://'|| request.type==='DubboSampler'" :showScript="false"/>&ndash;&gt;-->
<!--&lt;!&ndash;<p class="tip">{{$t('api_test.definition.request.res_param')}} </p>&ndash;&gt;-->
<!--&lt;!&ndash;<ms-request-result-tail :currentProtocol="request.protocol" :response="request.requestResult" ref="runResult"/>&ndash;&gt;-->
<!--&lt;!&ndash;&lt;!&ndash; 保存操作 &ndash;&gt;&ndash;&gt;-->
<!--&lt;!&ndash;<el-button type="primary" size="small" style="margin: 20px; float: right" @click="saveTestCase(item)" v-if="!request.referenced">&ndash;&gt;-->
<!--&lt;!&ndash;{{$t('commons.save')}}&ndash;&gt;-->
<!--&lt;!&ndash;</el-button>&ndash;&gt;-->
<!--&lt;!&ndash;</div>&ndash;&gt;-->
<!--&lt;!&ndash;</el-collapse-transition>&ndash;&gt;-->
<!--</el-card>-->
<!--&lt;!&ndash; 执行组件 &ndash;&gt;-->
<!--&lt;!&ndash;<ms-run :debug="false" :reportId="reportId" :run-data="runData"&ndash;&gt;-->
<!--&lt;!&ndash;@runRefresh="runRefresh" ref="runTest"/>&ndash;&gt;-->
<!--</div>-->
</template> </template>
<script> <script>
@ -250,12 +172,6 @@
copyRow() { copyRow() {
this.$emit('copyRow', this.request, this.node); this.$emit('copyRow', this.request, this.node);
}, },
editName() {
if (this.isDeletedOrRef) {
return;
}
this.isShowInput = true;
},
getApiInfo() { getApiInfo() {
if (this.request.id && this.request.referenced === 'REF') { if (this.request.id && this.request.referenced === 'REF') {
let requestResult = this.request.requestResult; let requestResult = this.request.requestResult;
@ -359,7 +275,4 @@
.icon.is-active { .icon.is-active {
transform: rotate(90deg); transform: rotate(90deg);
} }
.edit-disable {
color: #808080;
}
</style> </style>

View File

@ -1,23 +1,30 @@
<template> <template>
<div v-loading="loading"> <api-base-component
<el-card> v-loading="loading"
<el-row> @copy="copyRow"
<div class="el-step__icon is-text ms-api-col"> @remove="remove"
<div class="el-step__icon-inner">{{scenario.index}}</div> :data="scenario"
</div> :show-collapse="false"
<el-button class="ms-title-buttion" size="small">{{$t('api_test.automation.scenario_import')}}</el-button> color="#606266"
{{scenario.name}} background-color="#F4F4F5"
<el-tag size="mini" style="margin-left: 20px" v-if="scenario.referenced==='Deleted'" type="danger">{{$t('api_test.automation.reference_deleted')}}</el-tag> :title="$t('api_test.automation.scenario_import')">
<el-tag size="mini" style="margin-left: 20px" v-if="scenario.referenced==='Copy'">{{ $t('commons.copy') }}</el-tag>
<el-tag size="mini" style="margin-left: 20px" v-if="scenario.referenced==='REF'">{{ $t('api_test.scenario.reference') }}</el-tag> <template v-slot:headerLeft>
<div style="margin-right: 20px; float: right"> <slot name="headerLeft">
<el-switch v-model="scenario.enable" style="margin-left: 10px"/> <el-input v-if="(isShowInput || !scenario.name) && !isDeletedOrRef" size="small" v-model="scenario.name" class="name-input"
<el-button size="mini" icon="el-icon-copy-document" circle @click="copyRow" style="margin-left: 10px"/> @blur="isShowInput = false" :placeholder="$t('commons.input_name')"/>
<el-button size="mini" icon="el-icon-delete" type="danger" circle @click="remove" style="margin-left: 10px"/> <span v-else>
</div> {{scenario.name}}
</el-row> <i v-if="!isDeletedOrRef" class="el-icon-edit" style="cursor:pointer" @click="isShowInput = true" v-tester/>
</el-card> </span>
</div> </slot>
<el-tag size="mini" style="margin-left: 20px" v-if="scenario.referenced==='Deleted'" type="danger">{{$t('api_test.automation.reference_deleted')}}</el-tag>
<el-tag size="mini" style="margin-left: 20px" v-if="scenario.referenced==='Copy'">{{ $t('commons.copy') }}</el-tag>
<el-tag size="mini" style="margin-left: 20px" v-if="scenario.referenced==='REF'">{{ $t('api_test.scenario.reference') }}</el-tag>
</template>
</api-base-component>
</template> </template>
<script> <script>
@ -25,6 +32,7 @@
import MsTcpBasisParameters from "../../definition/components/request/tcp/TcpBasisParameters"; import MsTcpBasisParameters from "../../definition/components/request/tcp/TcpBasisParameters";
import MsDubboBasisParameters from "../../definition/components/request/dubbo/BasisParameters"; import MsDubboBasisParameters from "../../definition/components/request/dubbo/BasisParameters";
import MsApiRequestForm from "../../definition/components/request/http/ApiRequestForm"; import MsApiRequestForm from "../../definition/components/request/http/ApiRequestForm";
import ApiBaseComponent from "./common/ApiBaseComponent";
export default { export default {
name: "ApiScenarioComponent", name: "ApiScenarioComponent",
@ -45,9 +53,20 @@
}) })
} }
}, },
components: {MsSqlBasisParameters, MsTcpBasisParameters, MsDubboBasisParameters, MsApiRequestForm}, components: {ApiBaseComponent, MsSqlBasisParameters, MsTcpBasisParameters, MsDubboBasisParameters, MsApiRequestForm},
data() { data() {
return {loading: false} return {
loading: false,
isShowInput: false
}
},
computed: {
isDeletedOrRef() {
if (this.scenario.referenced!= undefined && this.scenario.referenced === 'Deleted' || this.scenario.referenced === 'REF') {
return true
}
return false;
}
}, },
methods: { methods: {
remove() { remove() {
@ -71,23 +90,11 @@
</script> </script>
<style scoped> <style scoped>
.ms-api-col {
background-color: #F4F4F5;
border-color: #606266;
margin-right: 10px;
color: #606266;
}
/deep/ .el-card__body { /deep/ .el-card__body {
padding: 15px; padding: 15px;
} }
.ms-title-buttion {
background-color: #F4F4F5;
margin-right: 20px;
color: #606266;
}
.icon.is-active { .icon.is-active {
transform: rotate(90deg); transform: rotate(90deg);
} }

View File

@ -155,18 +155,15 @@
<!--等待控制器--> <!--等待控制器-->
<ms-constant-timer :timer="data" :node="node" v-if="data.type==='ConstantTimer'" @remove="remove" @copyRow="copyRow"/> <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" @copyRow="copyRow" :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')" :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" @copyRow="copyRow" :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')" :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" @copyRow="copyRow" :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')" :jsr223-processor="data" :node="node"/>
style-type="color: #783887;background-color: #F2ECF3" :jsr223-processor="data" :node="node"/>
<!--断言规则--> <!--断言规则-->
<ms-api-assertions :draggable="true" @suggestClick="suggestClick(node)" :response="response" v-if="data.type==='Assertions'" @remove="remove" @copyRow="copyRow" customizeStyle="margin-top: 0px" :assertions="data" :node="node"/> <ms-api-assertions :draggable="true" @suggestClick="suggestClick(node)" :response="response" v-if="data.type==='Assertions'" @remove="remove" @copyRow="copyRow" :assertions="data" :node="node"/>
<!--提取规则--> <!--提取规则-->
<ms-api-extract :draggable="true" @suggestClick="suggestClick(node)" :response="response" @remove="remove" @copyRow="copyRow" v-if="data.type==='Extract'" customizeStyle="margin-top: 0px" :extract="data" :node="node"/> <ms-api-extract :draggable="true" @suggestClick="suggestClick(node)" :response="response" @remove="remove" @copyRow="copyRow" v-if="data.type==='Extract'" :extract="data" :node="node"/>
<!--API 导入 --> <!--API 导入 -->
<ms-api-component :request="data" :currentScenario="currentScenario" :currentEnvironmentId="currentEnvironmentId" @remove="remove" @copyRow="copyRow" <ms-api-component :request="data" :currentScenario="currentScenario" :currentEnvironmentId="currentEnvironmentId" @remove="remove" @copyRow="copyRow"
v-if="data.type==='HTTPSamplerProxy'||data.type==='DubboSampler'||data.type==='JDBCSampler'||data.type==='TCPSampler'" :node="node"/> v-if="data.type==='HTTPSamplerProxy'||data.type==='DubboSampler'||data.type==='JDBCSampler'||data.type==='TCPSampler'" :node="node"/>

View File

@ -139,9 +139,6 @@
languageChange(language) { languageChange(language) {
this.jsr223ProcessorData.scriptLanguage = language; this.jsr223ProcessorData.scriptLanguage = language;
}, },
changeActive() {
this.jsr223ProcessorData.active = !this.jsr223ProcessorData.active;
},
} }
} }
</script> </script>

View File

@ -1,5 +1,5 @@
<template> <template>
<el-card> <el-card class="api-component">
<div class="header" @click="active(data)"> <div class="header" @click="active(data)">
<div v-if="data.index" class="el-step__icon is-text" style="margin-right: 10px;" :style="{'color': color, 'background-color': backgroundColor}"> <div v-if="data.index" class="el-step__icon is-text" style="margin-right: 10px;" :style="{'color': color, 'background-color': backgroundColor}">
@ -75,7 +75,7 @@
}, },
methods: { methods: {
active() { active() {
this.data.active = !this.data.active; this.$set(this.data, 'active', !this.data.active);
this.$emit('active'); this.$emit('active');
}, },
copyRow() { copyRow() {

View File

@ -403,4 +403,8 @@ export default {
border-top: none; border-top: none;
} }
/deep/ .api-component {
margin-top: 10px;
}
</style> </style>

View File

@ -56,12 +56,12 @@
<script> <script>
import {AssertionJSR223} from "../../model/ApiTestModel"; import {AssertionJSR223} from "../../model/ApiTestModel";
import MsJsr233Processor from "@/business/components/api/test/components/processor/Jsr233Processor";
import MsDialogFooter from "@/business/components/common/components/MsDialogFooter"; import MsDialogFooter from "@/business/components/common/components/MsDialogFooter";
import MsJsr233Processor from "../../../automation/scenario/Jsr233Processor";
export default { export default {
name: "MsApiAssertionJsr223", name: "MsApiAssertionJsr223",
components: {MsDialogFooter, MsJsr233Processor}, components: {MsJsr233Processor, MsDialogFooter},
props: { props: {
assertion: { assertion: {
default: () => { default: () => {

View File

@ -112,13 +112,13 @@ import MsApiRequestForm from "../request/http/ApiRequestForm";
import MsResponseText from "../response/ResponseText"; import MsResponseText from "../response/ResponseText";
import {WORKSPACE_ID} from '../../../../../../common/js/constants'; import {WORKSPACE_ID} from '../../../../../../common/js/constants';
import {API_STATUS, REQ_METHOD} from "../../model/JsonData"; import {API_STATUS, REQ_METHOD} from "../../model/JsonData";
import MsJsr233Processor from "../processor/Jsr233Processor";
import {KeyValue} from "../../model/ApiTestModel"; import {KeyValue} from "../../model/ApiTestModel";
import MsInputTag from "@/business/components/api/automation/scenario/MsInputTag"; import MsInputTag from "@/business/components/api/automation/scenario/MsInputTag";
import MsJsr233Processor from "../../../automation/scenario/Jsr233Processor";
export default { export default {
name: "MsAddCompleteHttpApi", name: "MsAddCompleteHttpApi",
components: {MsResponseText, MsApiRequestForm, MsJsr233Processor, MsInputTag}, components: {MsJsr233Processor, MsResponseText, MsApiRequestForm, MsInputTag},
data() { data() {
let validateURL = (rule, value, callback) => { let validateURL = (rule, value, callback) => {
if (!this.httpForm.path.startsWith("/") || this.httpForm.path.match(/\s/) != null) { if (!this.httpForm.path.startsWith("/") || this.httpForm.path.match(/\s/) != null) {

View File

@ -1,212 +0,0 @@
<template>
<div style="margin-top: 10px">
<el-card>
<el-row>
<div @click="changeActive">
<el-button class="ms-left-buttion" size="small" :style="styleType" style="color: #B8741A;background-color: #F9F1EA">{{title}}</el-button>
<i class="icon el-icon-arrow-right" :class="{'is-active': active}" style="margin-left:15px" @click="changeActive"/>
<el-input size="small" v-model="jsr223ProcessorData.name" class="ms-api-header-select" style="width: 380px"/>
<div style="margin-right: 20px; float: right">
<el-switch v-model="jsr223ProcessorData.enable" 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-collapse-transition>
<div v-if="active">
<el-row style="margin:0px 10px 10px">
<el-col>
<div class="document-url">
<el-link href="https://jmeter.apache.org/usermanual/component_reference.html#BeanShell_PostProcessor"
type="primary">{{$t('commons.reference_documentation')}}
</el-link>
<ms-instructions-icon :content="$t('api_test.request.processor.bean_shell_processor_tip')"/>
</div>
</el-col>
</el-row>
<el-row>
<el-col :span="20" class="script-content">
<ms-code-edit v-if="isCodeEditAlive" :mode="jsr223ProcessorData.scriptLanguage"
:read-only="isReadOnly"
:data.sync="jsr223ProcessorData.script" theme="eclipse" :modes="[]"
ref="codeEdit"/>
</el-col>
<el-col :span="4" class="script-index">
<ms-dropdown :default-command="jsr223ProcessorData.scriptLanguage" :commands="languages" @command="languageChange"/>
<div class="template-title">{{$t('api_test.request.processor.code_template')}}</div>
<div v-for="(template, index) in codeTemplates" :key="index" class="code-template">
<el-link :disabled="template.disabled" @click="addTemplate(template)">{{template.title}}</el-link>
</div>
</el-col>
</el-row>
</div>
</el-collapse-transition>
</el-card>
</div>
</template>
<script>
import MsCodeEdit from "../../../../common/components/MsCodeEdit";
import MsInstructionsIcon from "../../../../common/components/MsInstructionsIcon";
import MsDropdown from "../../../../common/components/MsDropdown";
export default {
name: "MsJsr233Processor",
components: {MsDropdown, MsInstructionsIcon, MsCodeEdit},
data() {
return {
active: false,
jsr223ProcessorData: {},
codeTemplates: [
{
title: this.$t('api_test.request.processor.code_template_get_variable'),
value: 'vars.get("variable_name")',
},
{
title: this.$t('api_test.request.processor.code_template_set_variable'),
value: 'vars.put("variable_name", "variable_value")',
},
{
title: this.$t('api_test.request.processor.code_template_get_global_variable'),
value: 'props.get("variable_name")',
},
{
title: this.$t('api_test.request.processor.code_template_set_global_variable'),
value: 'props.put("variable_name", "variable_value")',
},
{
title: this.$t('api_test.request.processor.code_template_get_response_header'),
value: 'prev.getResponseHeaders()',
disabled: this.isPreProcessor
},
{
title: this.$t('api_test.request.processor.code_template_get_response_code'),
value: 'prev.getResponseCode()',
disabled: this.isPreProcessor
},
{
title: this.$t('api_test.request.processor.code_template_get_response_result'),
value: 'prev.getResponseDataAsString()',
disabled: this.isPreProcessor
}
],
isCodeEditAlive: true,
languages: [
'beanshell', "python"
],
codeEditModeMap: {
beanshell: 'beanshell',
python: 'python'
}
}
},
created() {
this.jsr223ProcessorData = this.jsr223Processor;
},
props: {
isReadOnly: {
type: Boolean,
default:
false
}
,
jsr223Processor: {
type: Object,
}
,
isPreProcessor: {
type: Boolean,
default:
false
}
,
title: String,
styleType:
String,
}
,
watch: {
jsr223Processor() {
this.reload();
}
}
,
methods: {
addTemplate(template) {
if (!this.jsr223ProcessorData.script) {
this.jsr223ProcessorData.script = "";
}
this.jsr223ProcessorData.script += template.value;
if (this.jsr223ProcessorData.scriptLanguage === 'beanshell') {
this.jsr223ProcessorData.script += ';';
}
this.reload();
},
remove() {
this.$emit('remove', this.jsr223ProcessorData);
},
copyRow() {
this.$emit('copyRow', this.jsr223ProcessorData);
},
reload() {
this.isCodeEditAlive = false;
this.$nextTick(() => (this.isCodeEditAlive = true));
},
languageChange(language) {
this.jsr223ProcessorData.scriptLanguage = language;
},
changeActive() {
this.active = !this.active;
},
}
}
</script>
<style scoped>
.ace_editor {
border-radius: 5px;
}
.script-content {
height: calc(100vh - 570px);
}
.script-index {
padding: 0 20px;
}
.template-title {
margin-bottom: 5px;
font-weight: bold;
font-size: 15px;
}
.document-url {
margin-top: 10px;
}
.instructions-icon {
margin-left: 5px;
}
.ms-dropdown {
margin-bottom: 20px;
}
.ms-api-header-select {
margin-left: 5px;
min-width: 300px;
}
.icon.is-active {
transform: rotate(90deg);
}
/deep/ .el-card__body {
padding: 15px;
}
</style>

View File

@ -104,7 +104,6 @@
import MsApiAssertions from "../../assertion/ApiAssertions"; import MsApiAssertions from "../../assertion/ApiAssertions";
import MsApiExtract from "../../extract/ApiExtract"; import MsApiExtract from "../../extract/ApiExtract";
import ApiRequestMethodSelect from "../../collapse/ApiRequestMethodSelect"; import ApiRequestMethodSelect from "../../collapse/ApiRequestMethodSelect";
import MsJsr233Processor from "../../processor/Jsr233Processor";
import MsCodeEdit from "../../../../../common/components/MsCodeEdit"; import MsCodeEdit from "../../../../../common/components/MsCodeEdit";
import MsApiScenarioVariables from "../../ApiScenarioVariables"; import MsApiScenarioVariables from "../../ApiScenarioVariables";
import {createComponent} from "../../jmeter/components"; import {createComponent} from "../../jmeter/components";
@ -113,13 +112,15 @@
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"; import {getUUID} from "@/common/js/utils";
import MsJsr233Processor from "../../../../automation/scenario/Jsr233Processor";
export default { export default {
name: "MsDatabaseConfig", name: "MsDatabaseConfig",
components: { components: {
MsJsr233Processor,
MsApiScenarioVariables, MsApiScenarioVariables,
MsCodeEdit, MsCodeEdit,
MsJsr233Processor, ApiRequestMethodSelect, MsApiExtract, MsApiAssertions, MsApiKeyValue, ApiEnvironmentConfig ApiRequestMethodSelect, MsApiExtract, MsApiAssertions, MsApiKeyValue, ApiEnvironmentConfig
}, },
props: { props: {
request: {}, request: {},

View File

@ -80,7 +80,6 @@
import MsApiAssertions from "../../assertion/ApiAssertions"; import MsApiAssertions from "../../assertion/ApiAssertions";
import MsApiExtract from "../../extract/ApiExtract"; import MsApiExtract from "../../extract/ApiExtract";
import ApiRequestMethodSelect from "../../collapse/ApiRequestMethodSelect"; import ApiRequestMethodSelect from "../../collapse/ApiRequestMethodSelect";
import MsJsr233Processor from "../../processor/Jsr233Processor";
import MsCodeEdit from "../../../../../common/components/MsCodeEdit"; import MsCodeEdit from "../../../../../common/components/MsCodeEdit";
import MsApiScenarioVariables from "../../ApiScenarioVariables"; import MsApiScenarioVariables from "../../ApiScenarioVariables";
import {createComponent} from "../../jmeter/components"; import {createComponent} from "../../jmeter/components";
@ -90,13 +89,15 @@
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"; import {getUUID} from "@/common/js/utils";
import MsJsr233Processor from "../../../../automation/scenario/Jsr233Processor";
export default { export default {
name: "MsDatabaseConfig", name: "MsDatabaseConfig",
components: { components: {
MsJsr233Processor,
MsApiScenarioVariables, MsApiScenarioVariables,
MsCodeEdit, MsCodeEdit,
MsJsr233Processor, ApiRequestMethodSelect, MsApiExtract, MsApiAssertions, MsApiKeyValue, MsDubboConsumerService, ApiRequestMethodSelect, MsApiExtract, MsApiAssertions, MsApiKeyValue, MsDubboConsumerService,
MsDubboConfigCenter, MsDubboConfigCenter,
MsDubboRegistryCenter, MsDubboRegistryCenter,
MsDubboInterface, MsDubboInterface,

View File

@ -69,11 +69,11 @@
</div> </div>
<div v-if="!referenced"> <div v-if="!referenced">
<div v-for="row in request.hashTree" :key="row.id"> <div v-for="row in request.hashTree" :key="row.id">
<!-- 前置脚本 --> <!--前置脚本-->
<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" <ms-jsr233-processor v-if="row.type==='JSR223PreProcessor'" @remove="remove" @copyRow="copyRow" :title="$t('api_test.definition.request.pre_script')"
:jsr223-processor="row"/> :jsr223-processor="row"/>
<!--后置脚本--> <!--后置脚本-->
<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" <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')"
:jsr223-processor="row"/> :jsr223-processor="row"/>
<!--断言规则--> <!--断言规则-->
<div style="margin-top: 10px"> <div style="margin-top: 10px">
@ -108,7 +108,6 @@
import ApiRequestMethodSelect from "../../collapse/ApiRequestMethodSelect"; import ApiRequestMethodSelect from "../../collapse/ApiRequestMethodSelect";
import {REQUEST_HEADERS} from "@/common/js/constants"; import {REQUEST_HEADERS} from "@/common/js/constants";
import MsApiVariable from "../../ApiVariable"; import MsApiVariable from "../../ApiVariable";
import MsJsr233Processor from "../../processor/Jsr233Processor";
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";
@ -116,6 +115,7 @@
import {getUUID} from "@/common/js/utils"; import {getUUID} from "@/common/js/utils";
import BatchAddParameter from "../../basis/BatchAddParameter"; import BatchAddParameter from "../../basis/BatchAddParameter";
import MsApiAdvancedConfig from "./ApiAdvancedConfig"; import MsApiAdvancedConfig from "./ApiAdvancedConfig";
import MsJsr233Processor from "../../../../automation/scenario/Jsr233Processor";
export default { export default {
name: "MsApiHttpRequestForm", name: "MsApiHttpRequestForm",

View File

@ -127,7 +127,6 @@
import MsApiAssertions from "../../assertion/ApiAssertions"; import MsApiAssertions from "../../assertion/ApiAssertions";
import MsApiExtract from "../../extract/ApiExtract"; import MsApiExtract from "../../extract/ApiExtract";
import ApiRequestMethodSelect from "../../collapse/ApiRequestMethodSelect"; import ApiRequestMethodSelect from "../../collapse/ApiRequestMethodSelect";
import MsJsr233Processor from "../../processor/Jsr233Processor";
import MsCodeEdit from "../../../../../common/components/MsCodeEdit"; import MsCodeEdit from "../../../../../common/components/MsCodeEdit";
import MsApiScenarioVariables from "../../ApiScenarioVariables"; import MsApiScenarioVariables from "../../ApiScenarioVariables";
import {createComponent} from "../../jmeter/components"; import {createComponent} from "../../jmeter/components";
@ -148,7 +147,7 @@
MsApiVariable, MsApiVariable,
MsApiScenarioVariables, MsApiScenarioVariables,
MsCodeEdit, MsCodeEdit,
MsJsr233Processor, ApiRequestMethodSelect, MsApiExtract, MsApiAssertions, MsApiKeyValue, ApiEnvironmentConfig ApiRequestMethodSelect, MsApiExtract, MsApiAssertions, MsApiKeyValue, ApiEnvironmentConfig
}, },
props: { props: {
request: {}, request: {},

View File

@ -56,12 +56,12 @@
<script> <script>
import {AssertionJSR223} from "../../model/ScenarioModel"; import {AssertionJSR223} from "../../model/ScenarioModel";
import MsJsr233Processor from "@/business/components/api/test/components/processor/Jsr233Processor";
import MsDialogFooter from "@/business/components/common/components/MsDialogFooter"; import MsDialogFooter from "@/business/components/common/components/MsDialogFooter";
import MsJsr233Processor from "../../../automation/scenario/Jsr233Processor";
export default { export default {
name: "MsApiAssertionJsr223", name: "MsApiAssertionJsr223",
components: {MsDialogFooter, MsJsr233Processor}, components: {MsJsr233Processor, MsDialogFooter},
props: { props: {
assertion: { assertion: {
type: AssertionJSR223, type: AssertionJSR223,

View File

@ -65,7 +65,7 @@
import MsDubboRegistryCenter from "@/business/components/api/test/components/request/dubbo/RegistryCenter"; import MsDubboRegistryCenter from "@/business/components/api/test/components/request/dubbo/RegistryCenter";
import MsDubboConfigCenter from "@/business/components/api/test/components/request/dubbo/ConfigCenter"; import MsDubboConfigCenter from "@/business/components/api/test/components/request/dubbo/ConfigCenter";
import MsDubboConsumerService from "@/business/components/api/test/components/request/dubbo/ConsumerAndService"; import MsDubboConsumerService from "@/business/components/api/test/components/request/dubbo/ConsumerAndService";
import MsJsr233Processor from "../processor/Jsr233Processor"; import MsJsr233Processor from "../../../automation/scenario/Jsr233Processor";
export default { export default {
name: "MsApiDubboRequestForm", name: "MsApiDubboRequestForm",

View File

@ -93,8 +93,8 @@ import MsApiExtract from "../extract/ApiExtract";
import ApiRequestMethodSelect from "../collapse/ApiRequestMethodSelect"; import ApiRequestMethodSelect from "../collapse/ApiRequestMethodSelect";
import {REQUEST_HEADERS} from "@/common/js/constants"; import {REQUEST_HEADERS} from "@/common/js/constants";
import MsApiVariable from "@/business/components/api/test/components/ApiVariable"; import MsApiVariable from "@/business/components/api/test/components/ApiVariable";
import MsJsr233Processor from "../processor/Jsr233Processor";
import MsApiAdvancedConfig from "../ApiAdvancedConfig"; import MsApiAdvancedConfig from "../ApiAdvancedConfig";
import MsJsr233Processor from "../../../automation/scenario/Jsr233Processor";
export default { export default {
name: "MsApiHttpRequestForm", name: "MsApiHttpRequestForm",

View File

@ -76,16 +76,16 @@
import MsDubboRegistryCenter from "@/business/components/api/test/components/request/dubbo/RegistryCenter"; import MsDubboRegistryCenter from "@/business/components/api/test/components/request/dubbo/RegistryCenter";
import MsDubboConfigCenter from "@/business/components/api/test/components/request/dubbo/ConfigCenter"; import MsDubboConfigCenter from "@/business/components/api/test/components/request/dubbo/ConfigCenter";
import MsDubboConsumerService from "@/business/components/api/test/components/request/dubbo/ConsumerAndService"; import MsDubboConsumerService from "@/business/components/api/test/components/request/dubbo/ConsumerAndService";
import MsJsr233Processor from "../processor/Jsr233Processor";
import MsCodeEdit from "../../../../common/components/MsCodeEdit"; import MsCodeEdit from "../../../../common/components/MsCodeEdit";
import MsApiScenarioVariables from "../ApiScenarioVariables"; import MsApiScenarioVariables from "../ApiScenarioVariables";
import MsJsr233Processor from "../../../automation/scenario/Jsr233Processor";
export default { export default {
name: "MsApiSqlRequestForm", name: "MsApiSqlRequestForm",
components: { components: {
MsJsr233Processor,
MsApiScenarioVariables, MsApiScenarioVariables,
MsCodeEdit, MsCodeEdit,
MsJsr233Processor,
MsDubboConsumerService, MsDubboConsumerService,
MsDubboConfigCenter, MsDubboConfigCenter,
MsDubboRegistryCenter, MsDubboRegistryCenter,

View File

@ -119,12 +119,12 @@
import {Scenario, TCPConfig, TCPRequest} from "@/business/components/api/test/model/ScenarioModel"; import {Scenario, TCPConfig, TCPRequest} from "@/business/components/api/test/model/ScenarioModel";
import MsApiAssertions from "@/business/components/api/test/components/assertion/ApiAssertions"; import MsApiAssertions from "@/business/components/api/test/components/assertion/ApiAssertions";
import MsApiExtract from "@/business/components/api/test/components/extract/ApiExtract"; import MsApiExtract from "@/business/components/api/test/components/extract/ApiExtract";
import MsJsr233Processor from "@/business/components/api/test/components/processor/Jsr233Processor";
import MsCodeEdit from "@/business/components/common/components/MsCodeEdit"; import MsCodeEdit from "@/business/components/common/components/MsCodeEdit";
import MsJsr233Processor from "../../../automation/scenario/Jsr233Processor";
export default { export default {
name: "MsApiTcpRequestForm", name: "MsApiTcpRequestForm",
components: {MsCodeEdit, MsJsr233Processor, MsApiExtract, MsApiAssertions}, components: {MsJsr233Processor, MsCodeEdit, MsApiExtract, MsApiAssertions},
props: { props: {
request: TCPRequest, request: TCPRequest,
scenario: Scenario, scenario: Scenario,