fix(接口自动化): 场景步骤按钮控制

This commit is contained in:
fit2-zhao 2021-03-23 17:30:23 +08:00
parent c4ae15256b
commit eeedae7a4a
3 changed files with 23 additions and 8 deletions

View File

@ -164,7 +164,7 @@
</div> </div>
<!--接口列表--> <!--接口列表-->
<scenario-api-relevance @save="pushApiOrCase" ref="scenarioApiRelevance" v-if="type!=='detail'"/> <scenario-api-relevance @save="pushApiOrCase" @close="setHideBtn" ref="scenarioApiRelevance" v-if="type!=='detail'"/>
<!--自定义接口--> <!--自定义接口-->
<el-drawer v-if="type!=='detail'" :visible.sync="customizeVisible" :destroy-on-close="true" direction="ltr" <el-drawer v-if="type!=='detail'" :visible.sync="customizeVisible" :destroy-on-close="true" direction="ltr"
@ -173,7 +173,7 @@
<ms-api-customize :request="customizeRequest" @addCustomizeApi="addCustomizeApi"/> <ms-api-customize :request="customizeRequest" @addCustomizeApi="addCustomizeApi"/>
</el-drawer> </el-drawer>
<!--场景导入 --> <!--场景导入 -->
<scenario-relevance v-if="type!=='detail'" @save="addScenario" ref="scenarioRelevance"/> <scenario-relevance v-if="type!=='detail'" @save="addScenario" @close="setHideBtn" ref="scenarioRelevance"/>
<!-- 环境 --> <!-- 环境 -->
<api-environment-config v-if="type!=='detail'" ref="environmentConfig" @close="environmentConfigClose"/> <api-environment-config v-if="type!=='detail'" ref="environmentConfig" @close="environmentConfigClose"/>
@ -288,7 +288,7 @@
loading: false, loading: false,
apiListVisible: false, apiListVisible: false,
customizeVisible: false, customizeVisible: false,
scenarioVisible: false, isBtnHide: false,
debugVisible: false, debugVisible: false,
customizeRequest: {protocol: "HTTP", type: "API", hashTree: [], referenced: 'Created', active: false}, customizeRequest: {protocol: "HTTP", type: "API", hashTree: [], referenced: 'Created', active: false},
operatingElements: [], operatingElements: [],
@ -441,6 +441,9 @@
} }
}, },
methods: { methods: {
setHideBtn() {
this.isBtnHide = false;
},
// //
openScenario(data) { openScenario(data) {
this.$emit('openScenario', data); this.$emit('openScenario', data);
@ -532,6 +535,7 @@
this.scenarioDefinition.push(new LoopController()); this.scenarioDefinition.push(new LoopController());
break; break;
case ELEMENT_TYPE.scenario: case ELEMENT_TYPE.scenario:
this.isBtnHide = true;
this.$refs.scenarioRelevance.open(); this.$refs.scenarioRelevance.open();
break; break;
default: default:
@ -559,12 +563,14 @@
} }
}, },
showAll() { showAll() {
if (!this.customizeVisible) { //
if (!this.customizeVisible && !this.isBtnHide) {
this.operatingElements = ELEMENTS.get("ALL"); this.operatingElements = ELEMENTS.get("ALL");
this.selectedTreeNode = undefined; this.selectedTreeNode = undefined;
} }
}, },
apiListImport() { apiListImport() {
this.isBtnHide = true;
this.$refs.scenarioApiRelevance.open(); this.$refs.scenarioApiRelevance.open();
}, },
recursiveSorting(arr) { recursiveSorting(arr) {
@ -631,13 +637,17 @@
item.hashTree = []; item.hashTree = [];
} }
item.enable === undefined ? item.enable = true : item.enable; item.enable === undefined ? item.enable = true : item.enable;
this.scenarioDefinition.push(item); if (this.selectedTreeNode != undefined) {
this.selectedTreeNode.hashTree.push(item);
} else {
this.scenarioDefinition.push(item);
}
}) })
} }
this.isBtnHide = false;
this.sort(); this.sort();
this.reload(); this.reload();
this.initProjectIds(); this.initProjectIds();
this.scenarioVisible = false;
}, },
setApiParameter(item, refType, referenced) { setApiParameter(item, refType, referenced) {
let request = {}; let request = {};
@ -676,6 +686,7 @@
data.forEach(item => { data.forEach(item => {
this.setApiParameter(item, refType, referenced); this.setApiParameter(item, refType, referenced);
}); });
this.isBtnHide = false;
this.sort(); this.sort();
this.reload(); this.reload();
this.initProjectIds(); this.initProjectIds();

View File

@ -128,6 +128,7 @@ export default {
} }
}, },
close() { close() {
this.$emit('close');
this.refresh(); this.refresh();
this.$refs.relevanceDialog.close(); this.$refs.relevanceDialog.close();
}, },

View File

@ -90,8 +90,10 @@
response.data.forEach(item => { response.data.forEach(item => {
let scenarioDefinition = JSON.parse(item.scenarioDefinition); let scenarioDefinition = JSON.parse(item.scenarioDefinition);
if (scenarioDefinition && scenarioDefinition.hashTree) { if (scenarioDefinition && scenarioDefinition.hashTree) {
let obj = {id: item.id, name: item.name, type: "scenario", headers: scenarioDefinition.headers, variables: scenarioDefinition.variables, environmentMap: scenarioDefinition.environmentMap, let obj = {
referenced: 'Copy', resourceId: getUUID(), hashTree: scenarioDefinition.hashTree, projectId: item.projectId}; id: item.id, name: item.name, type: "scenario", headers: scenarioDefinition.headers, variables: scenarioDefinition.variables, environmentMap: scenarioDefinition.environmentMap,
referenced: 'Copy', resourceId: getUUID(), hashTree: scenarioDefinition.hashTree, projectId: item.projectId
};
scenarios.push(obj); scenarios.push(obj);
} }
}); });
@ -101,6 +103,7 @@
}) })
}, },
close() { close() {
this.$emit('close');
this.refresh(); this.refresh();
this.$refs.relevanceDialog.close(); this.$refs.relevanceDialog.close();
}, },