refactor(系统设置): 优化环境配置相关设置

--bug=1016095 --user=王孝刚 【系统设置】工作空间 - 环境管理 - 创建环境页面,通用配置处,点击"高级设置"的相关问题
https://www.tapd.cn/55049933/s/1230602
This commit is contained in:
wxg0103 2022-08-23 13:51:03 +08:00 committed by 刘瑞斌
parent 15b640f8be
commit 5064d12d4a
6 changed files with 588 additions and 581 deletions

View File

@ -397,7 +397,7 @@ public class MsHTTPSamplerProxy extends MsTestElement {
url = url.replace(this.getPort(), "10990"); url = url.replace(this.getPort(), "10990");
} }
try { try {
if (StringUtils.startsWithAny(url, "http://", "https://")) { if (!StringUtils.startsWithAny(url, "http://", "https://")) {
url = "http://" + url; url = "http://" + url;
} }
URL urlObject = new URL(url); URL urlObject = new URL(url);

View File

@ -36,7 +36,7 @@
</el-tab-pane> </el-tab-pane>
<el-tab-pane :label="$t('api_test.variable')"> <el-tab-pane :label="$t('api_test.variable')">
<el-row> <el-row>
<el-col :span="6" class="col-height"> <el-col :span="6" class="col-height" v-if="environment || scenario || preRequestParams.length > 0">
<div v-if="environment"> <div v-if="environment">
<p>{{ $t('api_test.environment.environment') }}</p> <p>{{ $t('api_test.environment.environment') }}</p>
<el-tree :data="environmentParams" :props="treeProps" @node-click="selectVariable"></el-tree> <el-tree :data="environmentParams" :props="treeProps" @node-click="selectVariable"></el-tree>
@ -45,7 +45,7 @@
<p>{{ $t('api_test.scenario.scenario') }}</p> <p>{{ $t('api_test.scenario.scenario') }}</p>
<el-tree :data="scenarioParams" :props="treeProps" @node-click="selectVariable"></el-tree> <el-tree :data="scenarioParams" :props="treeProps" @node-click="selectVariable"></el-tree>
</div> </div>
<div v-if="preRequestParams"> <div v-if="preRequestParams && preRequestParams.length > 0">
<p>{{ $t('api_test.request.parameters_pre_request') }}</p> <p>{{ $t('api_test.request.parameters_pre_request') }}</p>
<el-tree :data="preRequestParams" :props="treeProps" @node-click="selectVariable"></el-tree> <el-tree :data="preRequestParams" :props="treeProps" @node-click="selectVariable"></el-tree>
</div> </div>
@ -53,7 +53,8 @@
<el-col :span="18" class="col-height"> <el-col :span="18" class="col-height">
<div> <div>
<h1>{{ $t('api_test.request.jmeter_func') }}</h1> <h1>{{ $t('api_test.request.jmeter_func') }}</h1>
<el-table border :data="jmeterFuncs" class="adjust-table table-content" height="400"> <el-table border :data="jmeterFuncs" class="adjust-table table-content" height="400"
@row-click="handleRowClick">
<el-table-column prop="type" label="Type" width="150"/> <el-table-column prop="type" label="Type" width="150"/>
<el-table-column prop="name" label="Functions" width="250"/> <el-table-column prop="name" label="Functions" width="250"/>
<el-table-column prop="description" label="Description"/> <el-table-column prop="description" label="Description"/>
@ -63,24 +64,27 @@
</el-row> </el-row>
</el-tab-pane> </el-tab-pane>
</el-tabs> </el-tabs>
<el-form>
<el-form-item>
<el-input :placeholder="valueText" size="small"
v-model="itemValue"/>
</el-form-item>
</el-form>
<div style="padding-top: 10px;"> <div style="padding-top: 10px;">
<el-row type="flex" align="middle"> <el-row type="flex">
<el-col :span="12"> <el-col :span="16">
<el-button size="small" type="primary" plain @click="saveAdvanced()"> <div>
{{ $t('commons.save') }} <el-form :inline="true" class="demo-form-inline">
</el-button> <el-form-item>
<el-button size="small" type="info" plain @click="addFunc()" v-if="currentTab === 0"> <el-input :placeholder="valueText" size="small" v-model="itemValue"/>
{{ $t('api_test.request.parameters_advance_add_func') }} </el-form-item>
</el-button> <el-form-item>
<el-button size="small" type="success" plain @click="showPreview()" v-if="currentTab === 0"> <el-button size="small" type="primary" plain @click="saveAdvanced()">
{{ $t('api_test.request.parameters_preview') }} {{ $t('commons.save') }}
</el-button> </el-button>
<el-button size="small" type="info" plain @click="addFunc()" v-if="currentTab === 0">
{{ $t('api_test.request.parameters_advance_add_func') }}
</el-button>
<el-button size="small" type="success" plain @click="showPreview()" v-if="currentTab === 0">
{{ $t('api_test.request.parameters_preview') }}
</el-button>
</el-form-item>
</el-form>
</div>
</el-col> </el-col>
<el-col> <el-col>
<div> {{ itemValuePreview }}</div> <div> {{ itemValuePreview }}</div>
@ -255,14 +259,14 @@ export default {
let index = this.mockVariableFuncs.indexOf(itemFunc); let index = this.mockVariableFuncs.indexOf(itemFunc);
this.mockVariableFuncs = this.mockVariableFuncs.slice(0, index); this.mockVariableFuncs = this.mockVariableFuncs.slice(0, index);
this.mockVariableFuncs.push({name: '', params: []}); this.mockVariableFuncs.push({name: '', params: []});
let valindex = this.itemValue.indexOf('|'+func.name); let valindex = this.itemValue.indexOf('|' + func.name);
this.itemValue = this.itemValue.slice(0,valindex); this.itemValue = this.itemValue.slice(0, valindex);
}else { } else {
this.methodChange(itemFunc, func); this.methodChange(itemFunc, func);
} }
}, },
addFunc() { addFunc() {
if (this.itemValue.indexOf('@') == -1) { if (this.currentTab === 0 && this.itemValue.indexOf('@') == -1) {
this.itemValue = '@' + this.itemValue; this.itemValue = '@' + this.itemValue;
} else { } else {
this.itemValue = this.itemValue; this.itemValue = this.itemValue;
@ -289,7 +293,7 @@ export default {
this.mockVariableFuncs.push({name: '', params: []}); this.mockVariableFuncs.push({name: '', params: []});
}, },
saveAdvanced() { saveAdvanced() {
if (this.itemValue.indexOf('@') == -1) { if (this.currentTab === 0 && this.itemValue.indexOf('@') == -1) {
this.currentItem.value = '@' + this.itemValue; this.currentItem.value = '@' + this.itemValue;
} else { } else {
this.currentItem.value = this.itemValue; this.currentItem.value = this.itemValue;
@ -298,7 +302,12 @@ export default {
this.mockVariableFuncs = []; this.mockVariableFuncs = [];
this.$emit('advancedRefresh', this.currentItem.value); this.$emit('advancedRefresh', this.currentItem.value);
} },
handleRowClick(row) {
if (row && row.name) {
this.itemValue = row.name;
}
},
} }
} }
</script> </script>

View File

@ -54,15 +54,15 @@
</template> </template>
</ms-table-column> </ms-table-column>
<ms-table-column prop="value" :label="$t('api_test.value')" <el-table-column prop="value" :label="$t('api_test.value')"
min-width="200px" sortable> min-width="200px" sortable show-overflow-tooltip>
<template slot-scope="scope"> <template slot-scope="scope">
<el-input v-model="scope.row.value" size="mini" v-if="scope.row.type !=='CSV'" <el-input v-model="scope.row.value" size="mini" v-if="scope.row.type !=='CSV'"
:placeholder="valueText(scope.row)" :placeholder="valueText(scope.row)"
:disabled="scope.row.type === 'COUNTER' || scope.row.type === 'RANDOM'"/> :disabled="scope.row.type === 'COUNTER' || scope.row.type === 'RANDOM'"/>
<csv-file-upload :parameter="scope.row" v-if="scope.row.type ==='CSV'"/> <csv-file-upload :parameter="scope.row" v-if="scope.row.type ==='CSV'"/>
</template> </template>
</ms-table-column> </el-table-column>
<ms-table-column prop="description" :label="$t('commons.remark')" <ms-table-column prop="description" :label="$t('commons.remark')"
min-width="160" sortable> min-width="160" sortable>
<template slot-scope="scope"> <template slot-scope="scope">

View File

@ -32,24 +32,11 @@
</el-tab-pane> </el-tab-pane>
<el-tab-pane :label="$t('api_test.variable')"> <el-tab-pane :label="$t('api_test.variable')">
<el-row> <el-row>
<el-col :span="6" class="col-height"> <el-col class="col-height">
<div v-if="environment">
<p>{{ $t('api_test.environment.environment') }}</p>
<el-tree :data="environmentParams" :props="treeProps" @node-click="selectVariable"></el-tree>
</div>
<div v-if="scenario">
<p>{{ $t('api_test.scenario.scenario') }}</p>
<el-tree :data="scenarioParams" :props="treeProps" @node-click="selectVariable"></el-tree>
</div>
<div v-if="preRequestParams">
<p>{{ $t('api_test.request.parameters_pre_request') }}</p>
<el-tree :data="preRequestParams" :props="treeProps" @node-click="selectVariable"></el-tree>
</div>
</el-col>
<el-col :span="18" class="col-height">
<div> <div>
<h1>{{ $t('api_test.request.jmeter_func') }}</h1> <h1>{{ $t('api_test.request.jmeter_func') }}</h1>
<el-table border :data="jmeterFuncs" class="adjust-table table-content" height="400"> <el-table border :data="jmeterFuncs" class="adjust-table table-content" height="400"
@row-click="handleRowClick">
<el-table-column prop="type" label="Type" width="150"/> <el-table-column prop="type" label="Type" width="150"/>
<el-table-column prop="name" label="Functions" width="250"/> <el-table-column prop="name" label="Functions" width="250"/>
<el-table-column prop="description" label="Description"/> <el-table-column prop="description" label="Description"/>
@ -59,21 +46,27 @@
</el-row> </el-row>
</el-tab-pane> </el-tab-pane>
</el-tabs> </el-tabs>
<el-form>
<el-form-item>
<el-input :placeholder="valueText" size="small"
v-model="itemValue"/>
</el-form-item>
</el-form>
<div style="padding-top: 10px;"> <div style="padding-top: 10px;">
<el-row type="flex" align="middle"> <el-row type="flex">
<el-col :span="12"> <el-col :span="16">
<el-button size="small" type="info" plain @click="addFunc()" v-if="currentTab === 0"> <div>
{{ $t('api_test.request.parameters_advance_add_func') }} <el-form :inline="true" class="demo-form-inline">
</el-button> <el-form-item>
<el-button size="small" type="success" plain @click="showPreview()" v-if="currentTab === 0"> <el-input :placeholder="valueText" size="small" v-model="itemValue"/>
{{ $t('api_test.request.parameters_preview') }} </el-form-item>
</el-button> <el-form-item>
<el-button size="small" type="primary" plain @click="saveAdvanced()">
{{ $t('commons.save') }}
</el-button>
<el-button size="small" type="info" plain @click="addFunc()" v-if="currentTab === 0">
{{ $t('api_test.request.parameters_advance_add_func') }}
</el-button>
<el-button size="small" type="success" plain @click="showPreview()" v-if="currentTab === 0">
{{ $t('api_test.request.parameters_preview') }}
</el-button>
</el-form-item>
</el-form>
</div>
</el-col> </el-col>
<el-col> <el-col>
<div> {{ itemValuePreview }}</div> <div> {{ itemValuePreview }}</div>
@ -293,7 +286,12 @@ export default {
this.mockVariableFuncs = []; this.mockVariableFuncs = [];
this.$emit('advancedRefresh', this.currentItem.value); this.$emit('advancedRefresh', this.currentItem.value);
} },
handleRowClick(row) {
if (row && row.name) {
this.itemValue = row.name;
}
},
} }
} }
</script> </script>

View File

@ -1,7 +1,7 @@
<template> <template>
<ms-edit-dialog <ms-edit-dialog
:visible.sync="visible" :visible.sync="visible"
width="700px" width="70%"
:title="$t('schema.adv_setting')" :title="$t('schema.adv_setting')"
:with-footer="false" :with-footer="false"
append-to-body append-to-body