fix(接口测试): 修复请求头删除报错

This commit is contained in:
chenjianxing 2020-09-27 15:09:07 +08:00
parent 5927f0fc2b
commit 85e320910e
5 changed files with 9 additions and 46 deletions

@ -1 +1 @@
Subproject commit c2dacf960cdb1ed35664bdd3432120b1203b73d8
Subproject commit cf6b06526324326a563d933e07118fac014a63b4

View File

@ -5,7 +5,7 @@
</span>
<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 v-if="isShowEnable" class="kv-checkbox">
<el-col class="kv-checkbox">
<input type="checkbox" v-if="!isDisable(index)" v-model="item.enable"
:disabled="isReadOnly"/>
</el-col>
@ -19,6 +19,7 @@
show-word-limit/>
</el-col>
<el-col>
<el-input :disabled="isReadOnly" v-model="item.value" size="small" @change="change"
:placeholder="valueText" show-word-limit/>
@ -42,7 +43,6 @@
keyPlaceholder: String,
valuePlaceholder: String,
description: String,
isShowEnable: Boolean,
items: Array,
isReadOnly: {
type: Boolean,
@ -52,7 +52,6 @@
},
data() {
return {
// checkedValues: []
}
},
computed: {
@ -66,11 +65,6 @@
methods: {
remove: function (index) {
if (this.isShowEnable) {
//
let checkIndex = this.checkedValues.indexOf(this.items[index].uuid);
checkIndex != -1 ? this.checkedValues.splice(checkIndex, 1) : this.checkedValues;
}
//
this.items.splice(index, 1);
this.$emit('change', this.items);

View File

@ -29,7 +29,7 @@
<el-tabs v-model="activeName" :disabled="isReadOnly">
<el-tab-pane :label="$t('api_test.scenario.variables')" name="parameters">
<ms-api-scenario-variables :isShowEnable="true" :is-read-only="isReadOnly" :items="scenario.variables"
<ms-api-scenario-variables :is-read-only="isReadOnly" :items="scenario.variables"
:description="$t('api_test.scenario.kv_description')"/>
</el-tab-pane>
<el-tab-pane :label="$t('api_test.scenario.headers')" name="headers">

View File

@ -5,8 +5,8 @@
</span>
<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 v-if="isShowEnable" class="kv-checkbox">
<input type="checkbox" v-if="!isDisable(index)" @change="change" :value="item.uuid" v-model="checkedValues"
<el-col class="kv-checkbox">
<input type="checkbox" v-if="!isDisable(index)" @change="change" :value="item.uuid" v-model="item.enable"
:disabled="isDisable(index) || isReadOnly"/>
</el-col>
@ -41,10 +41,6 @@
type: Boolean,
default: false
},
isShowEnable: {
type: Boolean,
default: false
},
showVariable: {
type: Boolean,
default: true
@ -52,16 +48,10 @@
},
data() {
return {
checkedValues: []
}
},
methods: {
remove: function (index) {
if (this.isShowEnable) {
//
let checkIndex = this.checkedValues.indexOf(this.items[index].uuid);
checkIndex != -1 ? this.checkedValues.splice(checkIndex, 1) : this.checkedValues;
}
this.items.splice(index, 1);
this.$emit('change', this.items);
},
@ -69,10 +59,6 @@
let isNeedCreate = true;
let removeIndex = -1;
this.items.forEach((item, index) => {
//
if (this.isShowEnable) {
item.enable = this.checkedValues.indexOf(item.uuid) != -1 ? true : false;
}
if (!item.name && !item.value) {
//
if (index !== this.items.length - 1) {
@ -83,20 +69,11 @@
}
});
if (isNeedCreate) {
//
if (this.isShowEnable) {
this.items[this.items.length - 1].enable = true;
// v-model
this.checkedValues.push(this.items[this.items.length - 1].uuid);
}
this.items.push(new KeyValue());
this.items.push(new KeyValue({enable: true}));
}
this.$emit('change', this.items);
// TODO key
},
uuid: function () {
return (((1 + Math.random()) * 0x100000) | 0).toString(16).substring(1);
},
isDisable: function (index) {
return this.items.length - 1 === index;
}
@ -104,15 +81,7 @@
created() {
if (this.items.length === 0) {
this.items.push(new KeyValue());
}else if (this.isShowEnable) {
this.items.forEach((item, index) => {
let uuid = this.uuid();
item.uuid = uuid;
if (item.enable) {
this.checkedValues.push(uuid);
}
})
this.items.push(new KeyValue({enable: true}));
}
}
}

@ -1 +1 @@
Subproject commit cc38137a69a0f20fadece9c0f9f50a9468c4ace9
Subproject commit 06d935cd1d22ab36f09763745c2aff8ad3fb08c1