diff --git a/frontend/src/business/components/api/automation/ApiAutomation.vue b/frontend/src/business/components/api/automation/ApiAutomation.vue
index e48d936f7b..54095f6859 100644
--- a/frontend/src/business/components/api/automation/ApiAutomation.vue
+++ b/frontend/src/business/components/api/automation/ApiAutomation.vue
@@ -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 => {
diff --git a/frontend/src/business/components/api/definition/ApiDefinition.vue b/frontend/src/business/components/api/definition/ApiDefinition.vue
index d5eba137b7..d8336e7a2f 100644
--- a/frontend/src/business/components/api/definition/ApiDefinition.vue
+++ b/frontend/src/business/components/api/definition/ApiDefinition.vue
@@ -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];
diff --git a/frontend/src/business/components/api/definition/components/module/ApiModule.vue b/frontend/src/business/components/api/definition/components/module/ApiModule.vue
index 4173b1ae43..b65d78261f 100644
--- a/frontend/src/business/components/api/definition/components/module/ApiModule.vue
+++ b/frontend/src/business/components/api/definition/components/module/ApiModule.vue
@@ -4,23 +4,23 @@
@@ -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');
+ },
}
+}