fix(接口测试): 接口自动化中场景变量添加常量及SQL添加变量,采用mock加函数保存不了,控制台报错

【场景变量添加常量及SQL添加变量,采用mock加函数保存不了,控制台报错】https://www.tapd.cn/33805590/bugtrace/bugs/view?bug_id=1133805590001008481
This commit is contained in:
wxg0103 2021-12-03 11:41:35 +08:00 committed by 刘瑞斌
parent f4e9c82bad
commit 0d680831f6
3 changed files with 47 additions and 7 deletions

View File

@ -24,12 +24,12 @@
value-key="name"
:fetch-suggestions="funcSearch"
highlight-first-item>
<i slot="suffix" class="el-input__icon el-icon-edit pointer" @click="advanced"></i>
<i slot="suffix" class="el-input__icon el-icon-edit pointer" @click="advanced(editData.value)"></i>
</el-autocomplete>
</el-col>
</el-form-item>
</el-form>
<ms-api-variable-advance ref="variableAdvance"/>
<ms-api-variable-advance ref="variableAdvance" :current-item="editData" @advancedRefresh="reload"/>
</div>
</template>
@ -45,11 +45,12 @@
},
data() {
return {
currentItem: null,
rules: {
name: [
{required: true, message: this.$t('test_track.case.input_name'), trigger: 'blur'},
],
},
}
}
},
computed:{
@ -58,8 +59,9 @@
}
},
methods: {
advanced() {
advanced(item) {
this.$refs.variableAdvance.open();
this.editData.value = item;
},
createFilter(queryString) {
return (variable) => {
@ -77,6 +79,12 @@
// callback
cb(results);
},
reload() {
this.isActive = false;
this.$nextTick(() => {
this.isActive = true;
});
},
},
created() {
this.$nextTick(() => {

View File

@ -59,8 +59,10 @@
</el-row>
</div>
<ms-api-variable-advance ref="variableAdvance" :environment="environment" :scenario="scenario"
:append-to-body="appendDialogToBody"
:parameters="parameters"
:current-item="currentItem"/>
:current-item="currentItem"
@advancedRefresh="reload"/>
</div>
</template>
@ -84,6 +86,12 @@
type: String,
default: ''
},
appendDialogToBody: {
type: Boolean,
default() {
return false;
}
},
isReadOnly: {
type: Boolean,
default: false
@ -165,7 +173,13 @@
} else {
item.contentType = 'text/plain';
}
}
},
reload() {
this.isActive = false;
this.$nextTick(() => {
this.isActive = true;
});
},
},
created() {
if (this.parameters.length === 0 || this.parameters[this.parameters.length - 1].name) {

View File

@ -101,6 +101,12 @@ export default {
environment: Object,
scenario: Scenario,
currentItem: Object,
appendToBody: {
type: Boolean,
default() {
return false;
}
},
},
data() {
return {
@ -161,6 +167,7 @@ export default {
methods: {
open() {
this.itemValueVisible = true;
this.itemValue = this.currentItem.value;
},
prepareData() {
if (this.scenario) {
@ -245,6 +252,11 @@ export default {
this.showPreview();
},
addFunc() {
if (this.itemValue.indexOf('@') == -1) {
this.itemValue = '@' + this.itemValue;
} else {
this.itemValue = this.itemValue;
}
if (this.mockVariableFuncs.length > 4) {
this.$info(this.$t('api_test.request.parameters_advance_add_func_limit'));
return;
@ -267,9 +279,15 @@ export default {
this.mockVariableFuncs.push({name: '', params: []});
},
saveAdvanced() {
this.currentItem.value = this.itemValue;
if (this.itemValue.indexOf('@') == -1) {
this.currentItem.value = '@' + this.itemValue;
} else {
this.currentItem.value = this.itemValue;
}
this.itemValueVisible = false;
this.mockVariableFuncs = [];
this.$emit('advancedRefresh', this.currentItem.value);
}
}
}