style(接口测试): 规范化提交内容

This commit is contained in:
fit2-zhao 2020-09-03 16:17:15 +08:00
parent 82cf5b25c4
commit 60961c0a27
5 changed files with 263 additions and 258 deletions

View File

@ -12,7 +12,8 @@ public class KeyValue {
private String type;
private List<BodyFile> files;
private String description;
private boolean checked;
private boolean enable;
public KeyValue() {
}

View File

@ -6,7 +6,8 @@
<div class="kv-row" v-for="(item, index) in items" :key="index">
<el-row type="flex" :gutter="20" justify="space-between" align="middle">
<el-col class="kv-checkbox">
<input type="checkbox" v-if="!isDisable(index)" @change="change" :value="item.uuid" v-model="checkedValues" :disabled="isDisable(index) || isReadOnly"/>
<input type="checkbox" v-if="!isDisable(index)" @change="change" :value="item.uuid" v-model="checkedValues"
:disabled="isDisable(index) || isReadOnly"/>
</el-col>
<el-col>
@ -32,9 +33,9 @@
</template>
<script>
import {KeyValue} from "../model/ScenarioModel";
import {KeyValue} from "../model/ScenarioModel";
export default {
export default {
name: "MsApiKeyValue",
props: {
@ -50,7 +51,7 @@ export default {
},
data() {
return {
checkedValues:[]
checkedValues: []
}
},
computed: {
@ -66,7 +67,7 @@ export default {
remove: function (index) {
//
let checkIndex = this.checkedValues.indexOf(this.items[index].uuid);
checkIndex != -1 ? this.checkedValues.splice(checkIndex,1): this.checkedValues;
checkIndex != -1 ? this.checkedValues.splice(checkIndex, 1) : this.checkedValues;
//
this.items.splice(index, 1);
this.$emit('change', this.items);
@ -76,7 +77,7 @@ export default {
let removeIndex = -1;
this.items.forEach((item, index) => {
//
item.checked=this.checkedValues.indexOf(item.uuid) != -1 ? true:false;
item.enable = this.checkedValues.indexOf(item.uuid) != -1 ? true : false;
if (!item.name && !item.value) {
//
@ -89,9 +90,9 @@ export default {
});
if (isNeedCreate) {
//
this.items[this.items.length-1].checked = true;
this.items[this.items.length - 1].enable = true;
// v-model
this.checkedValues.push(this.items[this.items.length-1].uuid);
this.checkedValues.push(this.items[this.items.length - 1].uuid);
this.items.push(new KeyValue());
}
this.$emit('change', this.items);
@ -106,7 +107,7 @@ export default {
cb(results);
},
uuid: function () {
return (((1+Math.random())*0x100000)|0).toString(16).substring(1);
return (((1 + Math.random()) * 0x100000) | 0).toString(16).substring(1);
},
createFilter(queryString) {
return (restaurant) => {
@ -117,37 +118,38 @@ export default {
created() {
if (this.items.length === 0) {
this.items.push(new KeyValue());
}else{
} else {
this.items.forEach((item, index) => {
let uuid = this.uuid();
item.uuid = uuid;
if(item.checked){
if (item.enable) {
this.checkedValues.push(uuid);
}
})
}
}
}
}
</script>
<style scoped>
.kv-description {
.kv-description {
font-size: 13px;
}
}
.kv-row {
.kv-row {
margin-top: 10px;
}
.kv-checkbox {
}
.kv-checkbox {
width: 20px;
margin-right: 10px;
}
}
.kv-delete {
.kv-delete {
width: 60px;
}
}
.el-autocomplete {
.el-autocomplete {
width: 100%;
}
}
</style>

View File

@ -7,7 +7,8 @@
<el-row type="flex" :gutter="20" justify="space-between" align="middle">
<el-col class="kv-checkbox">
<input type="checkbox" v-if="!isDisable(index)" @change="change" :value="item.uuid" v-model="checkedValues" :disabled="isDisable(index) || isReadOnly"/>
<input type="checkbox" v-if="!isDisable(index)" @change="change" :value="item.uuid" v-model="checkedValues"
:disabled="isDisable(index) || isReadOnly"/>
</el-col>
<el-col>
@ -56,12 +57,12 @@
</template>
<script>
import {KeyValue, Scenario} from "../model/ScenarioModel";
import {JMETER_FUNC, MOCKJS_FUNC} from "@/common/js/constants";
import MsApiVariableAdvance from "@/business/components/api/test/components/ApiVariableAdvance";
import MsApiBodyFileUpload from "./body/ApiBodyFileUpload";
import {KeyValue, Scenario} from "../model/ScenarioModel";
import {JMETER_FUNC, MOCKJS_FUNC} from "@/common/js/constants";
import MsApiVariableAdvance from "@/business/components/api/test/components/ApiVariableAdvance";
import MsApiBodyFileUpload from "./body/ApiBodyFileUpload";
export default {
export default {
name: "MsApiVariable",
components: {MsApiBodyFileUpload, MsApiVariableAdvance},
props: {
@ -84,7 +85,7 @@ export default {
data() {
return {
currentItem: null,
checkedValues:[]
checkedValues: []
}
},
computed: {
@ -99,7 +100,7 @@ export default {
remove: function (index) {
//
let checkIndex = this.checkedValues.indexOf(this.parameters[index].uuid);
checkIndex != -1 ? this.checkedValues.splice(checkIndex,1): this.checkedValues;
checkIndex != -1 ? this.checkedValues.splice(checkIndex, 1) : this.checkedValues;
//
this.parameters.splice(index, 1);
this.$emit('change', this.parameters);
@ -109,7 +110,7 @@ export default {
let removeIndex = -1;
this.parameters.forEach((item, index) => {
//
item.checked=this.checkedValues.indexOf(item.uuid) != -1 ? true:false;
item.enable = this.checkedValues.indexOf(item.uuid) != -1 ? true : false;
if (!item.name && !item.value) {
//
@ -122,10 +123,10 @@ export default {
});
if (isNeedCreate) {
//
this.parameters[this.parameters.length-1].checked = true;
this.parameters[this.parameters.length - 1].enable = true;
// v-model
this.checkedValues.push(this.parameters[this.parameters.length-1].uuid);
this.parameters.push(new KeyValue(null, null, 'text',false,this.uuid()));
this.checkedValues.push(this.parameters[this.parameters.length - 1].uuid);
this.parameters.push(new KeyValue(null, null, 'text', false, this.uuid()));
}
this.$emit('change', this.parameters);
// TODO key
@ -155,7 +156,7 @@ export default {
};
},
uuid: function () {
return (((1+Math.random())*0x100000)|0).toString(16).substring(1);
return (((1 + Math.random()) * 0x100000) | 0).toString(16).substring(1);
},
advanced(item) {
this.$refs.variableAdvance.open();
@ -167,55 +168,56 @@ export default {
},
created() {
if (this.parameters.length === 0) {
this.parameters.push(new KeyValue(null, null, 'text',false,this.uuid()));
}else{
this.parameters.push(new KeyValue(null, null, 'text', false, this.uuid()));
} else {
this.parameters.forEach((item, index) => {
let uuid = this.uuid();
item.uuid = uuid;
if(item.checked){
if (item.enable) {
this.checkedValues.push(uuid);
}
})
}
}
}
}
</script>
<style scoped>
.kv-description {
.kv-description {
font-size: 13px;
}
}
.kv-row {
.kv-row {
margin-top: 10px;
}
}
.kv-delete {
.kv-delete {
width: 60px;
}
}
.el-autocomplete {
.el-autocomplete {
width: 100%;
}
.kv-checkbox {
}
.kv-checkbox {
width: 20px;
margin-right: 10px;
}
}
.advanced-item-value >>> .el-dialog__body {
.advanced-item-value >>> .el-dialog__body {
padding: 15px 25px;
}
}
.el-row {
.el-row {
margin-bottom: 5px;
}
}
.kv-type {
.kv-type {
width: 70px;
}
}
.pointer {
.pointer {
cursor: pointer;
color: #1E90FF;
}
}
</style>

View File

@ -318,7 +318,7 @@ export class HTTPSamplerArguments extends Element {
let collectionProp = this.collectionProp('Arguments.arguments');
this.args.forEach(arg => {
if(arg.checked) { // 非禁用的条件加入执行
if (arg.enable) { // 非禁用的条件加入执行
let elementProp = collectionProp.elementProp(arg.name, 'HTTPArgument');
elementProp.boolProp('HTTPArgument.always_encode', arg.encode, true);
elementProp.boolProp('HTTPArgument.use_equals', arg.equals, true);
@ -490,7 +490,7 @@ export class HeaderManager extends DefaultTestElement {
this.headers.forEach(header => {
let elementProp = collectionProp.elementProp('', 'Header');
if(header.checked) {
if (header.enable) {
elementProp.stringProp('Header.name', header.name);
elementProp.stringProp('Header.value', header.value);
}
@ -506,7 +506,7 @@ export class Arguments extends DefaultTestElement {
let collectionProp = this.collectionProp('Arguments.arguments');
this.args.forEach(arg => {
if(arg.checked) { // 非禁用的条件加入执行
if (arg.enable) { // 非禁用的条件加入执行
let elementProp = collectionProp.elementProp(arg.name, 'Argument');
elementProp.stringProp('Argument.name', arg.name);
elementProp.stringProp('Argument.value', arg.value);
@ -531,7 +531,7 @@ export class ElementArguments extends Element {
let collectionProp = this.collectionProp('Arguments.arguments');
if (args) {
args.forEach(arg => {
if(arg.checked) { // 非禁用的条件加入执行
if (arg.enable) { // 非禁用的条件加入执行
let elementProp = collectionProp.elementProp(arg.name, 'Argument');
elementProp.stringProp('Argument.name', arg.name);
elementProp.stringProp('Argument.value', arg.value);

View File

@ -312,7 +312,7 @@ export class HttpRequest extends Request {
this.jsr223PreProcessor = undefined;
this.jsr223PostProcessor = undefined;
this.enable = true;
this.connectTimeout = 60*1000;
this.connectTimeout = 60 * 1000;
this.responseTimeout = undefined;
this.followRedirects = true;
@ -541,7 +541,7 @@ export class Body extends BaseConfig {
export class KeyValue extends BaseConfig {
constructor() {
let options, key, value, type,checked,uuid;
let options, key, value, type, enable, uuid;
if (arguments.length === 1) {
options = arguments[0];
}
@ -559,7 +559,7 @@ export class KeyValue extends BaseConfig {
key = arguments[0];
value = arguments[1];
type = arguments[2];
checked = arguments[3];
enable = arguments[3];
uuid = arguments[4];
}
super();
@ -567,7 +567,7 @@ export class KeyValue extends BaseConfig {
this.value = value;
this.type = type;
this.files = undefined;
this.checked = checked;
this.enable = enable;
this.uuid = uuid;
this.set(options);
}
@ -780,7 +780,7 @@ class JMXHttpRequest {
if (this.method.toUpperCase() !== "GET") {
let parameters = [];
request.parameters.forEach(parameter => {
if (parameter.name && parameter.value && parameter.checked) {
if (parameter.name && parameter.value && parameter.enable) {
parameters.push(parameter);
}
});