From 0d680831f6d1a4d73bf55354b8ccf3b3f3f14ad4 Mon Sep 17 00:00:00 2001 From: wxg0103 <727495428@qq.com> Date: Fri, 3 Dec 2021 11:41:35 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E8=87=AA=E5=8A=A8=E5=8C=96=E4=B8=AD=E5=9C=BA?= =?UTF-8?q?=E6=99=AF=E5=8F=98=E9=87=8F=E6=B7=BB=E5=8A=A0=E5=B8=B8=E9=87=8F?= =?UTF-8?q?=E5=8F=8ASQL=E6=B7=BB=E5=8A=A0=E5=8F=98=E9=87=8F=EF=BC=8C?= =?UTF-8?q?=E9=87=87=E7=94=A8mock=E5=8A=A0=E5=87=BD=E6=95=B0=E4=BF=9D?= =?UTF-8?q?=E5=AD=98=E4=B8=8D=E4=BA=86=EF=BC=8C=E6=8E=A7=E5=88=B6=E5=8F=B0?= =?UTF-8?q?=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【场景变量添加常量及SQL添加变量,采用mock加函数保存不了,控制台报错】https://www.tapd.cn/33805590/bugtrace/bugs/view?bug_id=1133805590001008481 --- .../scenario/variable/EditConstant.vue | 16 +++++++++++---- .../api/test/components/ApiVariable.vue | 18 +++++++++++++++-- .../test/components/ApiVariableAdvance.vue | 20 ++++++++++++++++++- 3 files changed, 47 insertions(+), 7 deletions(-) diff --git a/frontend/src/business/components/api/automation/scenario/variable/EditConstant.vue b/frontend/src/business/components/api/automation/scenario/variable/EditConstant.vue index fd4e63b7d6..be5c780a28 100644 --- a/frontend/src/business/components/api/automation/scenario/variable/EditConstant.vue +++ b/frontend/src/business/components/api/automation/scenario/variable/EditConstant.vue @@ -24,12 +24,12 @@ value-key="name" :fetch-suggestions="funcSearch" highlight-first-item> - + - + @@ -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(() => { diff --git a/frontend/src/business/components/api/test/components/ApiVariable.vue b/frontend/src/business/components/api/test/components/ApiVariable.vue index cd36f59bf1..0016fe58fe 100644 --- a/frontend/src/business/components/api/test/components/ApiVariable.vue +++ b/frontend/src/business/components/api/test/components/ApiVariable.vue @@ -59,8 +59,10 @@ + :current-item="currentItem" + @advancedRefresh="reload"/> @@ -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) { diff --git a/frontend/src/business/components/api/test/components/ApiVariableAdvance.vue b/frontend/src/business/components/api/test/components/ApiVariableAdvance.vue index 9d02dcaea6..2621d1af93 100644 --- a/frontend/src/business/components/api/test/components/ApiVariableAdvance.vue +++ b/frontend/src/business/components/api/test/components/ApiVariableAdvance.vue @@ -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); + } } }