fix(接口测试): 修复swagger定时同步消息通知缓存问题

--bug=1010018 --user=宋天阳 【接口测试】github#10003,swagger定时同步,任务通知的弹窗内容有缓存
https://www.tapd.cn/55049933/s/1112953
This commit is contained in:
song-tianyang 2022-03-03 18:48:13 +08:00 committed by 刘瑞斌
parent 663d2f652c
commit 742ef2cad8
2 changed files with 38 additions and 21 deletions

View File

@ -32,24 +32,27 @@
</el-col> </el-col>
<el-col :span="12" style="margin-left: 50px"> <el-col :span="12" style="margin-left: 50px">
<el-switch v-model="authEnable" :active-text="$t('api_test.api_import.add_request_params')" @change="changeAuthEnable"></el-switch> <el-switch v-model="authEnable" :active-text="$t('api_test.api_import.add_request_params')"
@change="changeAuthEnable"></el-switch>
</el-col> </el-col>
<el-col :span="19" v-show="authEnable" style="margin-top: 10px; margin-left: 50px" class="request-tabs"> <el-col :span="19" v-show="authEnable" style="margin-top: 10px; margin-left: 50px" class="request-tabs">
<!-- 请求头 --> <!-- 请求头 -->
<div> <div>
<span>{{$t('api_test.request.headers')}}{{$t('api_test.api_import.optional')}}</span> <span>{{ $t('api_test.request.headers') }}{{ $t('api_test.api_import.optional') }}</span>
</div> </div>
<ms-api-key-value :label="$t('api_test.definition.request.auth_config')" <ms-api-key-value :label="$t('api_test.definition.request.auth_config')"
:show-desc="true" :isShowEnable="isShowEnable" :suggestions="headerSuggestions" :items="headers"/> :show-desc="true" :isShowEnable="isShowEnable" :suggestions="headerSuggestions"
:items="headers"/>
<!--query 参数--> <!--query 参数-->
<div style="margin-top: 10px"> <div style="margin-top: 10px">
<span>{{$t('api_test.definition.request.query_param')}}{{$t('api_test.api_import.optional')}}</span> <span>{{ $t('api_test.definition.request.query_param') }}{{ $t('api_test.api_import.optional') }}</span>
</div> </div>
<ms-api-variable :with-mor-setting="true" :is-read-only="isReadOnly" :isShowEnable="isShowEnable" :parameters="queryArguments"/> <ms-api-variable :with-mor-setting="true" :is-read-only="isReadOnly" :isShowEnable="isShowEnable"
:parameters="queryArguments"/>
<!--认证配置--> <!--认证配置-->
<div style="margin-top: 10px"> <div style="margin-top: 10px">
<span>{{$t('api_test.definition.request.auth_config')}}{{$t('api_test.api_import.optional')}}</span> <span>{{ $t('api_test.definition.request.auth_config') }}{{ $t('api_test.api_import.optional') }}</span>
</div> </div>
<ms-api-auth-config :is-read-only="isReadOnly" :request="authConfig" :encryptShow="false"/> <ms-api-auth-config :is-read-only="isReadOnly" :request="authConfig" :encryptShow="false"/>
</el-col> </el-col>
@ -105,7 +108,7 @@
width="60%" width="60%"
> >
<swagger-task-notification :api-test-id="formData.id" :scheduleReceiverOptions="scheduleReceiverOptions" <swagger-task-notification :api-test-id="formData.id" :scheduleReceiverOptions="scheduleReceiverOptions"
ref="schedule-task-notification"> ref="scheduleTaskNotification">
</swagger-task-notification> </swagger-task-notification>
</el-dialog> </el-dialog>
@ -133,7 +136,15 @@ import {ELEMENT_TYPE, TYPE_TO_C} from "@/business/components/api/automation/scen
export default { export default {
name: "ApiSchedule", name: "ApiSchedule",
components: { components: {
SwaggerTaskNotification, SelectTree, MsFormDivider, SwaggerTaskList, CrontabResult, Crontab, MsApiKeyValue, MsApiVariable, MsApiAuthConfig SwaggerTaskNotification,
SelectTree,
MsFormDivider,
SwaggerTaskList,
CrontabResult,
Crontab,
MsApiKeyValue,
MsApiVariable,
MsApiAuthConfig
}, },
props: { props: {
customValidate: { customValidate: {
@ -225,6 +236,11 @@ export default {
if (this.formData.id !== null && this.formData.id !== undefined) { if (this.formData.id !== null && this.formData.id !== undefined) {
this.dialogVisible = true; this.dialogVisible = true;
this.initUserList(); this.initUserList();
this.$nextTick(() => {
if (this.$refs.scheduleTaskNotification) {
this.$refs.scheduleTaskNotification.initForm();
}
})
} else { } else {
this.$warning("请先选择您要添加通知的定时任务"); this.$warning("请先选择您要添加通知的定时任务");
} }
@ -240,7 +256,7 @@ export default {
return getCurrentUser(); return getCurrentUser();
}, },
changeAuthEnable() { changeAuthEnable() {
if(!this.authEnable){ if (!this.authEnable) {
this.clearAuthInfo(); this.clearAuthInfo();
} }
}, },
@ -284,16 +300,16 @@ export default {
this.formData.projectId = getCurrentProjectID(); this.formData.projectId = getCurrentProjectID();
this.formData.workspaceId = getCurrentWorkspaceId(); this.formData.workspaceId = getCurrentWorkspaceId();
this.formData.value = this.formData.rule; this.formData.value = this.formData.rule;
if(this.authEnable){ if (this.authEnable) {
// query // query
this.formData.headers = this.headers; this.formData.headers = this.headers;
this.formData.arguments = this.queryArguments; this.formData.arguments = this.queryArguments;
// BaseAuth // BaseAuth
if(this.authConfig.authManager != undefined){ if (this.authConfig.authManager != undefined) {
this.authConfig.authManager.clazzName = TYPE_TO_C.get("AuthManager"); this.authConfig.authManager.clazzName = TYPE_TO_C.get("AuthManager");
this.formData.authManager = this.authConfig.authManager; this.formData.authManager = this.authConfig.authManager;
} }
}else { } else {
this.formData.headers = undefined; this.formData.headers = undefined;
this.formData.arguments = undefined; this.formData.arguments = undefined;
this.formData.authManager = undefined; this.formData.authManager = undefined;
@ -305,8 +321,8 @@ export default {
this.formData.enable = true; this.formData.enable = true;
url = '/api/definition/schedule/create'; url = '/api/definition/schedule/create';
} }
if(!this.formData.moduleId){ if (!this.formData.moduleId) {
if( this.$refs.selectTree.returnDataKeys.length>0){ if (this.$refs.selectTree.returnDataKeys.length > 0) {
this.formData.moduleId = this.$refs.selectTree.returnDataKeys this.formData.moduleId = this.$refs.selectTree.returnDataKeys
} }
} }
@ -337,17 +353,17 @@ export default {
}, },
handleRowClick(row) { handleRowClick(row) {
// //
if(row.config != null || row.config != undefined){ if (row.config != null || row.config != undefined) {
this.authEnable = true; this.authEnable = true;
let config = JSON.parse(row.config); let config = JSON.parse(row.config);
this.headers = config.headers; this.headers = config.headers;
this.queryArguments = config.arguments; this.queryArguments = config.arguments;
if(config.authManager != null || config.authManager != undefined){ if (config.authManager != null || config.authManager != undefined) {
this.authConfig = config; this.authConfig = config;
}else { } else {
this.authConfig = {hashTree: [], authManager: {}}; this.authConfig = {hashTree: [], authManager: {}};
} }
}else { } else {
this.clearAuthInfo(); this.clearAuthInfo();
} }
Object.assign(this.formData, row); Object.assign(this.formData, row);
@ -355,7 +371,7 @@ export default {
this.$refs.selectTree.init(); this.$refs.selectTree.init();
}); });
}, },
clearAuthInfo(){ clearAuthInfo() {
this.headers = []; this.headers = [];
this.queryArguments = []; this.queryArguments = [];
this.headers.push(new KeyValue({enable: true})); this.headers.push(new KeyValue({enable: true}));

View File

@ -60,7 +60,7 @@
</el-table-column> </el-table-column>
<el-table-column label="webhook" min-width="20%" prop="webhook"> <el-table-column label="webhook" min-width="20%" prop="webhook">
<template v-slot:default="scope"> <template v-slot:default="scope">
<el-input v-model="scope.row.webhook" size="mini" <el-input v-model="scope.row.webhook" size="mini"
:disabled="!scope.row.isSet||!scope.row.isReadOnly"></el-input> :disabled="!scope.row.isSet||!scope.row.isReadOnly"></el-input>
</template> </template>
</el-table-column> </el-table-column>
@ -185,7 +185,8 @@ export default {
}; };
}, },
mounted() { mounted() {
this.initForm(); },
created() {
}, },
methods: { methods: {
initForm() { initForm() {