diff --git a/api-test/backend/src/main/java/io/metersphere/service/MsHashTreeService.java b/api-test/backend/src/main/java/io/metersphere/service/MsHashTreeService.java index 5e4aaf609e..2e55bd5e5f 100644 --- a/api-test/backend/src/main/java/io/metersphere/service/MsHashTreeService.java +++ b/api-test/backend/src/main/java/io/metersphere/service/MsHashTreeService.java @@ -1,21 +1,22 @@ package io.metersphere.service; import io.metersphere.api.dto.automation.ApiScenarioDTO; -import io.metersphere.api.dto.definition.ApiDefinitionResult; import io.metersphere.api.dto.definition.ApiTestCaseInfo; import io.metersphere.api.dto.definition.request.ElementUtil; -import io.metersphere.base.domain.Project; -import io.metersphere.base.mapper.ProjectMapper; -import io.metersphere.service.definition.ApiDefinitionService; -import io.metersphere.service.definition.ApiTestCaseService; +import io.metersphere.base.domain.ApiDefinition; import io.metersphere.base.domain.ApiScenarioWithBLOBs; import io.metersphere.base.domain.ApiTestCaseWithBLOBs; +import io.metersphere.base.domain.Project; +import io.metersphere.base.mapper.ApiDefinitionMapper; import io.metersphere.base.mapper.ApiScenarioMapper; +import io.metersphere.base.mapper.ProjectMapper; import io.metersphere.base.mapper.ext.ExtApiScenarioMapper; import io.metersphere.commons.constants.ElementConstants; import io.metersphere.commons.constants.PropertyConstant; import io.metersphere.commons.utils.JSON; import io.metersphere.commons.utils.JSONUtil; +import io.metersphere.service.definition.ApiDefinitionService; +import io.metersphere.service.definition.ApiTestCaseService; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.json.JSONArray; @@ -36,6 +37,8 @@ public class MsHashTreeService { @Resource private ApiDefinitionService apiDefinitionService; @Resource + private ApiDefinitionMapper apiDefinitionMapper; + @Resource private ExtApiScenarioMapper extApiScenarioMapper; @Resource @@ -44,7 +47,7 @@ public class MsHashTreeService { public static final String CASE = "CASE"; public static final String REFERENCED = "referenced"; public static final String REF = "REF"; - public static final String CREATED = "Created"; + public static final String COPY = "Copy"; public static final String REF_TYPE = "refType"; public static final String ID = "id"; public static final String NAME = "name"; @@ -165,17 +168,13 @@ public class MsHashTreeService { isExist = true; this.setElement(element, apiTestCase.getNum(), enable, apiTestCase.getVersionName(), apiTestCase.getVersionEnable()); } - } else { - if (StringUtils.equalsIgnoreCase(element.optString(REFERENCED), "Copy")) { - ApiDefinitionResult definitionWithBLOBs = apiDefinitionService.getById(element.optString(ID)); - if (definitionWithBLOBs != null) { - Project project = projectMapper.selectByPrimaryKey(definitionWithBLOBs.getProjectId()); - definitionWithBLOBs.setProjectName(project.getName()); - definitionWithBLOBs.setVersionEnable(project.getVersionEnable()); - element.put(ID, definitionWithBLOBs.getId()); - this.setElement(element, definitionWithBLOBs.getNum(), enable, definitionWithBLOBs.getVersionName(), definitionWithBLOBs.getVersionEnable()); - isExist = true; - } + } else if (StringUtils.equalsIgnoreCase(element.optString(REFERENCED), COPY)) { + ApiDefinition definition = apiDefinitionMapper.selectByPrimaryKey(element.optString(ID)); + if (definition != null) { + Project project = projectMapper.selectByPrimaryKey(definition.getProjectId()); + element.put(ID, definition.getId()); + this.setElement(element, definition.getNum(), enable, project.getName(), project.getVersionEnable()); + isExist = true; } } if (!isExist) { diff --git a/api-test/frontend/src/business/automation/scenario/EditApiScenario.vue b/api-test/frontend/src/business/automation/scenario/EditApiScenario.vue index 89a730ec1b..6c9540fcd3 100644 --- a/api-test/frontend/src/business/automation/scenario/EditApiScenario.vue +++ b/api-test/frontend/src/business/automation/scenario/EditApiScenario.vue @@ -183,11 +183,13 @@ + @node-drag-end="nodeDragEnd" @node-click="nodeClick" draggable ref="stepTree" + :key="reloadTree"> @@ -1562,6 +1564,12 @@ export default { environmentConfigClose() { this.getEnvironments(); }, + allowDrag(node) { + if (node.data && node.data.disabled && node.parent.data && node.parent.data.disabled) { + return false; + } + return true; + }, allowDrop(draggingNode, dropNode, dropType) { if (draggingNode.data.type === 'Assertions' || dropNode.data.type === 'Assertions') { return false; @@ -1576,12 +1584,13 @@ export default { } return false; } else if (dropType === "inner" && dropNode.data.referenced !== 'REF' && dropNode.data.referenced !== 'Deleted' + && !dropNode.data.disabled && (this.stepFilter.get(dropNode.data.type) && this.stepFilter.get(dropNode.data.type).indexOf(draggingNode.data.type) != -1)) { return true; } return false; }, - allowDrag(draggingNode, dropNode, dropType) { + nodeDragEnd(draggingNode, dropNode, dropType) { if (dropNode && draggingNode && dropType) { this.sort(); this.forceRerender(); diff --git a/api-test/frontend/src/business/automation/scenario/component/ApiScenarioComponent.vue b/api-test/frontend/src/business/automation/scenario/component/ApiScenarioComponent.vue index 16408ffc85..d002a352d3 100644 --- a/api-test/frontend/src/business/automation/scenario/component/ApiScenarioComponent.vue +++ b/api-test/frontend/src/business/automation/scenario/component/ApiScenarioComponent.vue @@ -136,6 +136,7 @@ export default { this.isShowNum = this.scenario.num ? true : false; if (this.scenario.id && this.scenario.referenced === 'REF' && !this.scenario.loaded && this.scenario.hashTree) { this.scenario.root = this.node.parent.parent ? false : true; + this.scenario.disabled = true; this.recursive(this.scenario.hashTree, this.scenario.projectId, true); } }, @@ -233,6 +234,7 @@ export default { } } if (this.scenario && this.scenario.hashTree && this.node.expanded) { + this.scenario.disabled = true; this.recursive(this.scenario.hashTree, this.scenario.projectId, (this.scenario.id && this.scenario.referenced === 'REF')); } this.reload(); diff --git a/api-test/frontend/src/business/automation/scenario/component/LoopController.vue b/api-test/frontend/src/business/automation/scenario/component/LoopController.vue index faceaddb3c..cc7e22c3d3 100644 --- a/api-test/frontend/src/business/automation/scenario/component/LoopController.vue +++ b/api-test/frontend/src/business/automation/scenario/component/LoopController.vue @@ -1,23 +1,58 @@ @@ -412,4 +488,10 @@ export default { white-space: nowrap; width: 60px; } + +.ms-conn { + background-color: #409EFF; + color: white; + padding: 5px +}