style(接口测试): 修复接口测试首页swagger跳转的问题

--bug=1015399 --user=宋天阳 【接口测试】首页-运行中的定时任务,swagger定时任务跳转后没有显示定时任务tab
https://www.tapd.cn/55049933/s/1215835
This commit is contained in:
song-tianyang 2022-07-29 19:02:32 +08:00 committed by 建国
parent 294dbdb82a
commit 134e781f7c
3 changed files with 309 additions and 262 deletions

View File

@ -220,30 +220,32 @@ export default {
if (!params) {
return;
}
let paramArr = params.split("edit:");
if (paramArr.length !== 2) {
return;
}
let scenarioId = paramArr[1];
//
this.$post("/api/automation/list/1/1", {id: scenarioId}, response => {
let data = response.data;
if (data && data.listObject && data.listObject.length > 0) {
let row = data.listObject[0];
let checks = ["array", "object"];
if (row && row.tags && (checks.indexOf(Object.prototype.toString.call(row.tags)
.match(/\[object (\w+)\]/)[1].toLowerCase()) !== -1)) {
row.tags = JSON.parse(row.tags);
}
//
if (this.moduleOptions && this.moduleOptions.length === 0) {
let projectId = data.projectId ? data.projectId : this.projectId;
this.initModules(row, projectId);
} else {
this.editScenario(row);
}
if (params instanceof String) {
let paramArr = params.split("edit:");
if (paramArr.length !== 2) {
return;
}
});
let scenarioId = paramArr[1];
//
this.$post("/api/automation/list/1/1", {id: scenarioId}, response => {
let data = response.data;
if (data && data.listObject && data.listObject.length > 0) {
let row = data.listObject[0];
let checks = ["array", "object"];
if (row && row.tags && (checks.indexOf(Object.prototype.toString.call(row.tags)
.match(/\[object (\w+)\]/)[1].toLowerCase()) !== -1)) {
row.tags = JSON.parse(row.tags);
}
//
if (this.moduleOptions && this.moduleOptions.length === 0) {
let projectId = data.projectId ? data.projectId : this.projectId;
this.initModules(row, projectId);
} else {
this.editScenario(row);
}
}
});
}
},
initModules(row, projectId) {
this.$get("/api/automation/module/list/" + projectId, response => {

View File

@ -354,51 +354,52 @@ export default {
};
},
activated() {
this.selectNodeIds = [];
let routeParamObj = this.$route.params.paramObj;
if (routeParamObj) {
let dataRange = routeParamObj.dataSelectRange;
if (dataRange && dataRange.length > 0) {
this.activeDom = 'middle';
}
let dataType = routeParamObj.dataType;
if (dataType) {
if (dataType === "api") {
this.activeDom = 'left';
} else {
this.$nextTick(() => {
let routeParamObj = this.$route.params.paramObj;
if (routeParamObj) {
let dataRange = routeParamObj.dataSelectRange;
if (dataRange && dataRange.length > 0) {
this.activeDom = 'middle';
}
}
if (routeParamObj.dataSelectRange) {
let item = JSON.parse(JSON.stringify(routeParamObj.dataSelectRange)).param;
if (item !== undefined) {
let type = item.taskGroup.toString();
if (type === "SWAGGER_IMPORT") {
this.handleTabsEdit(this.$t('api_test.api_import.timing_synchronization'), 'SCHEDULE');
this.param = item;
let dataType = routeParamObj.dataType;
if (dataType) {
if (dataType === "api") {
this.activeDom = 'left';
} else {
this.activeDom = 'middle';
}
}
if (routeParamObj.dataSelectRange) {
let item = JSON.parse(JSON.stringify(routeParamObj.dataSelectRange)).param;
if (item !== undefined) {
let type = item.taskGroup.toString();
if (type === "SWAGGER_IMPORT") {
this.openSwaggerScheduleTab();
this.param = item;
}
}
}
} else {
let dataType = this.$route.params.dataType;
if (dataType) {
if (dataType === "api") {
this.activeDom = 'left';
} else {
this.activeDom = 'middle';
}
}
if (this.$route.params.dataSelectRange) {
let item = JSON.parse(JSON.stringify(this.$route.params.dataSelectRange)).param;
if (item !== undefined) {
let type = item.taskGroup.toString();
if (type === "SWAGGER_IMPORT") {
this.openSwaggerScheduleTab();
this.param = item;
}
}
}
}
} else {
let dataType = this.$route.params.dataType;
if (dataType) {
if (dataType === "api") {
this.activeDom = 'left';
} else {
this.activeDom = 'middle';
}
}
if (this.$route.params.dataSelectRange) {
let item = JSON.parse(JSON.stringify(this.$route.params.dataSelectRange)).param;
if (item !== undefined) {
let type = item.taskGroup.toString();
if (type === "SWAGGER_IMPORT") {
this.handleTabsEdit(this.$t('api_test.api_import.timing_synchronization'), 'SCHEDULE');
this.param = item;
}
}
}
}
});
},
watch: {
currentProtocol() {
@ -463,6 +464,22 @@ export default {
}
},
methods: {
openSwaggerScheduleTab() {
//
let scheduleTabName = "";
if (this.apiTabs) {
this.apiTabs.forEach(tab => {
if (tab.type === 'SCHEDULE') {
scheduleTabName = tab.name;
}
});
}
if (scheduleTabName === "") {
this.handleTabsEdit(this.$t('api_test.api_import.timing_synchronization'), 'SCHEDULE');
} else {
this.apiDefaultTab = scheduleTabName;
}
},
setEnvironment(data) {
if (data) {
this.useEnvironment = data.id;
@ -733,7 +750,7 @@ export default {
if (routeParamObj) {
let dataRange = routeParamObj.dataSelectRange;
let dataType = routeParamObj.dataType;
if (dataRange) {
if (dataRange && dataRange instanceof String) {
let selectParamArr = dataRange.split("edit:");
if (selectParamArr.length === 2) {
let scenarioId = selectParamArr[1];
@ -747,7 +764,7 @@ export default {
} else {
let dataRange = this.$route.params.dataSelectRange;
let dataType = this.$route.params.dataType;
if (dataRange) {
if (dataRange && dataRange instanceof String) {
let selectParamArr = dataRange.split("edit:");
if (selectParamArr.length === 2) {
let scenarioId = selectParamArr[1];

View File

@ -4,23 +4,23 @@
<slot name="header"></slot>
<ms-node-tree
v-loading="result.loading"
:tree-nodes="data"
:type="isReadOnly ? 'view' : 'edit'"
:allLabel="$t('api_test.definition.api_all')"
:default-label="$t('api_test.definition.unplanned_api')"
local-suffix="api_definition"
@add="add"
@edit="edit"
@drag="drag"
@remove="remove"
@refresh="list"
@filter="filter"
:show-case-num="showCaseNum"
:delete-permission="['PROJECT_API_DEFINITION:READ+DELETE_API']"
:add-permission="['PROJECT_API_DEFINITION:READ+CREATE_API']"
:update-permission="['PROJECT_API_DEFINITION:READ+EDIT_API']"
@nodeSelectEvent="nodeChange"
v-loading="result.loading"
:tree-nodes="data"
:type="isReadOnly ? 'view' : 'edit'"
:allLabel="$t('api_test.definition.api_all')"
:default-label="$t('api_test.definition.unplanned_api')"
local-suffix="api_definition"
@add="add"
@edit="edit"
@drag="drag"
@remove="remove"
@refresh="list"
@filter="filter"
:show-case-num="showCaseNum"
:delete-permission="['PROJECT_API_DEFINITION:READ+DELETE_API']"
:add-permission="['PROJECT_API_DEFINITION:READ+CREATE_API']"
:update-permission="['PROJECT_API_DEFINITION:READ+EDIT_API']"
@nodeSelectEvent="nodeChange"
ref="nodeTree">
<template v-slot:header>
@ -67,208 +67,236 @@ export default {
},
data() {
return {
result: {},
condition: {
protocol: OPTIONS[0].value,
filterText: "",
trashEnable: false
},
data: [],
currentModule: {},
result: {},
condition: {
protocol: OPTIONS[0].value,
filterText: "",
trashEnable: false
},
data: [],
currentModule: {},
}
},
props: {
isReadOnly: {
type: Boolean,
default() {
return false;
}
},
props: {
isReadOnly: {
type: Boolean,
default() {
return false;
}
},
showCaseNum: {
type: Boolean,
default() {
return true;
}
},
showOperator: Boolean,
planId: String,
currentVersion: String,
relevanceProjectId: String,
reviewId: String,
pageSource: String,
total: Number,
isRelevance: Boolean,
options: {
type: Array,
default() {
return OPTIONS;
}
showCaseNum: {
type: Boolean,
default() {
return true;
}
},
computed: {
isPlanModel() {
return this.planId ? true : false;
},
isRelevanceModel() {
return this.relevanceProjectId ? true : false;
},
isReviewModel() {
return this.reviewId ? true : false;
},
projectId() {
return getCurrentProjectID();
showOperator: Boolean,
planId: String,
currentVersion: String,
relevanceProjectId: String,
reviewId: String,
pageSource: String,
total: Number,
isRelevance: Boolean,
options: {
type: Array,
default() {
return OPTIONS;
}
}
},
computed: {
isPlanModel() {
return this.planId ? true : false;
},
mounted() {
this.initProtocol();
isRelevanceModel() {
return this.relevanceProjectId ? true : false;
},
isReviewModel() {
return this.reviewId ? true : false;
},
projectId() {
return getCurrentProjectID();
}
},
mounted() {
this.initProtocol();
},
watch: {
'condition.filterText'() {
this.filter();
},
'condition.protocol'() {
watch: {
'condition.filterText'() {
this.filter();
},
'condition.protocol'() {
this.$emit('protocolChange', this.condition.protocol);
this.list();
},
'condition.trashEnable'() {
this.$emit('enableTrash', this.condition.trashEnable);
},
planId() {
this.list();
},
relevanceProjectId() {
this.list();
},
reviewId() {
this.list();
}
},
methods: {
initProtocol() {
//
let isRedirectPage = this.isRedirect();
if (this.$route.params.type) {
this.condition.protocol = this.$route.params.type;
this.$emit('protocolChange', this.condition.protocol);
this.list();
},
'condition.trashEnable'() {
this.$emit('enableTrash', this.condition.trashEnable);
},
planId() {
this.list();
},
relevanceProjectId() {
this.list();
},
reviewId() {
} else if (!this.isRelevance && !isRedirectPage) {
//
this.$get('/api/module/getUserDefaultApiType/', response => {
this.condition.protocol = response.data;
this.$emit('protocolChange', this.condition.protocol);
this.list();
});
} else {
this.$emit('protocolChange', this.condition.protocol);
this.list();
}
},
methods: {
initProtocol() {
if(this.$route.params.type){
this.condition.protocol = this.$route.params.type;
this.$emit('protocolChange', this.condition.protocol);
this.list();
}else if (!this.isRelevance) {
//
this.$get('/api/module/getUserDefaultApiType/', response => {
this.condition.protocol = response.data;
this.$emit('protocolChange', this.condition.protocol);
this.list();
});
} else {
this.$emit('protocolChange', this.condition.protocol);
this.list();
}
},
filter() {
this.$refs.nodeTree.filter(this.condition.filterText);
},
list(projectId) {
let url = undefined;
if (this.isPlanModel) {
url = '/api/module/list/plan/' + this.planId + '/' + this.condition.protocol;
} else if (this.isRelevanceModel) {
url = "/api/module/list/" + this.relevanceProjectId + "/" + this.condition.protocol +
(this.currentVersion ? '/' + this.currentVersion : '');
} else {
url = "/api/module/list/" + (projectId ? projectId : this.projectId) + "/" + this.condition.protocol +
(this.currentVersion ? '/' + this.currentVersion : '');
if (!this.projectId) {
return;
}
}
this.result = this.$get(url, response => {
if (response.data != undefined && response.data != null) {
this.data = response.data;
this.data.forEach(node => {
node.name = node.name === '未规划接口' ? this.$t('api_test.definition.unplanned_api') : node.name
buildTree(node, {path: ''});
});
this.$emit('setModuleOptions', this.data);
this.$emit('setNodeTree', this.data);
if (this.$refs.nodeTree) {
this.$refs.nodeTree.filter(this.condition.filterText);
isRedirect() {
let isRedirectPage = false;
let routeParamObj = this.$route.params.paramObj;
if (routeParamObj) {
if (routeParamObj.dataSelectRange) {
let item = JSON.parse(JSON.stringify(routeParamObj.dataSelectRange)).param;
if (item !== undefined) {
let type = item.taskGroup.toString();
if (type === "SWAGGER_IMPORT") {
isRedirectPage = true;
}
}
});
},
edit(param) {
param.projectId = this.projectId;
param.protocol = this.condition.protocol;
this.$post("/api/module/edit", param, () => {
}
} else {
if (this.$route.params.dataSelectRange) {
let item = JSON.parse(JSON.stringify(this.$route.params.dataSelectRange)).param;
if (item !== undefined) {
let type = item.taskGroup.toString();
if (type === "SWAGGER_IMPORT") {
isRedirectPage = true;
}
}
}
}
return isRedirectPage;
},
filter() {
this.$refs.nodeTree.filter(this.condition.filterText);
},
list(projectId) {
let url = undefined;
if (this.isPlanModel) {
url = '/api/module/list/plan/' + this.planId + '/' + this.condition.protocol;
} else if (this.isRelevanceModel) {
url = "/api/module/list/" + this.relevanceProjectId + "/" + this.condition.protocol +
(this.currentVersion ? '/' + this.currentVersion : '');
} else {
url = "/api/module/list/" + (projectId ? projectId : this.projectId) + "/" + this.condition.protocol +
(this.currentVersion ? '/' + this.currentVersion : '');
if (!this.projectId) {
return;
}
}
this.result = this.$get(url, response => {
if (response.data != undefined && response.data != null) {
this.data = response.data;
this.data.forEach(node => {
node.name = node.name === '未规划接口' ? this.$t('api_test.definition.unplanned_api') : node.name
buildTree(node, {path: ''});
});
this.$emit('setModuleOptions', this.data);
this.$emit('setNodeTree', this.data);
if (this.$refs.nodeTree) {
this.$refs.nodeTree.filter(this.condition.filterText);
}
}
});
},
edit(param) {
param.projectId = this.projectId;
param.protocol = this.condition.protocol;
this.$post("/api/module/edit", param, () => {
this.$success(this.$t('commons.save_success'));
this.list();
this.refresh();
}, (error) => {
this.list();
});
},
add(param) {
param.projectId = this.projectId;
param.protocol = this.condition.protocol;
if (param && param.level >= 9) {
this.list();
this.$error(this.$t('commons.warning_module_add'));
return;
} else {
this.$post("/api/module/add", param, () => {
this.$success(this.$t('commons.save_success'));
this.list();
this.refresh();
}, (error) => {
this.list();
});
},
add(param) {
param.projectId = this.projectId;
param.protocol = this.condition.protocol;
if (param && param.level >= 9) {
this.list();
this.$error(this.$t('commons.warning_module_add'));
return;
} else {
this.$post("/api/module/add", param, () => {
this.$success(this.$t('commons.save_success'));
this.list();
}, (error) => {
this.list();
});
}
},
remove(nodeIds) {
this.$post("/api/module/delete", nodeIds, () => {
this.list();
this.refresh();
}, (error) => {
this.list();
});
},
drag(param, list) {
this.$post("/api/module/drag", param, () => {
this.$post("/api/module/pos", list, () => {
this.list();
});
}, (error) => {
this.list();
});
},
nodeChange(node, nodeIds, pNodes) {
this.currentModule = node.data;
this.condition.trashEnable = false;
if (node.data.id === 'root') {
this.$emit("nodeSelectEvent", node, [], pNodes);
} else {
this.$emit("nodeSelectEvent", node, nodeIds, pNodes);
}
},
//---使
createRootModel() {
let dataArr = this.$refs.nodeTree.extendTreeNodes;
if (dataArr.length > 0) {
this.$refs.nodeTree.append({}, dataArr[0]);
}
},
exportAPI(type) {
this.$emit('exportAPI', type, this.data);
},
debug() {
this.$emit('debug');
},
saveAsEdit(data) {
this.$emit('saveAsEdit', data);
},
refresh() {
}
},
remove(nodeIds) {
this.$post("/api/module/delete", nodeIds, () => {
this.list();
this.$emit('refreshTable');
},
}
this.refresh();
}, (error) => {
this.list();
});
},
drag(param, list) {
this.$post("/api/module/drag", param, () => {
this.$post("/api/module/pos", list, () => {
this.list();
});
}, (error) => {
this.list();
});
},
nodeChange(node, nodeIds, pNodes) {
this.currentModule = node.data;
this.condition.trashEnable = false;
if (node.data.id === 'root') {
this.$emit("nodeSelectEvent", node, [], pNodes);
} else {
this.$emit("nodeSelectEvent", node, nodeIds, pNodes);
}
},
//---使
createRootModel() {
let dataArr = this.$refs.nodeTree.extendTreeNodes;
if (dataArr.length > 0) {
this.$refs.nodeTree.append({}, dataArr[0]);
}
},
exportAPI(type) {
this.$emit('exportAPI', type, this.data);
},
debug() {
this.$emit('debug');
},
saveAsEdit(data) {
this.$emit('saveAsEdit', data);
},
refresh() {
this.list();
this.$emit('refreshTable');
},
}
}
</script>
<style scoped>