feat(接口自动化): 场景步骤增加禁用全部/启用全部

This commit is contained in:
fit2-zhao 2021-06-17 18:08:36 +08:00 committed by fit2-zhao
parent 1028f768ef
commit 03293013ad
2 changed files with 102 additions and 19 deletions

View File

@ -133,6 +133,9 @@
<el-col :span="3" class="ms-col-one ms-font"> <el-col :span="3" class="ms-col-one ms-font">
<el-checkbox v-model="enableCookieShare">共享cookie</el-checkbox> <el-checkbox v-model="enableCookieShare">共享cookie</el-checkbox>
</el-col> </el-col>
<el-col :span="3" class="ms-col-one ms-font">
<el-checkbox v-model="onSampleError">{{ $t('commons.failure_continues') }}</el-checkbox>
</el-col>
<el-col :span="4"> <el-col :span="4">
<env-popover :disabled="scenarioDefinition.length < 1" :env-map="projectEnvMap" <env-popover :disabled="scenarioDefinition.length < 1" :env-map="projectEnvMap"
:project-ids="projectIds" @setProjectEnvMap="setProjectEnvMap" :result="envResult" :project-ids="projectIds" @setProjectEnvMap="setProjectEnvMap" :result="envResult"
@ -140,9 +143,6 @@
:isReadOnly="scenarioDefinition.length < 1" @showPopover="showPopover" :isReadOnly="scenarioDefinition.length < 1" @showPopover="showPopover"
:project-list="projectList" ref="envPopover"/> :project-list="projectList" ref="envPopover"/>
</el-col> </el-col>
<el-col :span="3" class="ms-col-one ms-font">
<el-checkbox v-model="onSampleError">{{ $t('commons.failure_continues') }}</el-checkbox>
</el-col>
<el-col :span="4"> <el-col :span="4">
<el-button :disabled="scenarioDefinition.length < 1" size="mini" type="primary" v-prevent-re-click <el-button :disabled="scenarioDefinition.length < 1" size="mini" type="primary" v-prevent-re-click
@click="runDebug">{{ $t('api_test.request.debug') }} @click="runDebug">{{ $t('api_test.request.debug') }}
@ -160,12 +160,19 @@
</div> </div>
<!-- 场景步骤内容 --> <!-- 场景步骤内容 -->
<div> <div>
<el-button class="el-icon-files ms-open-btn ms-open-btn-left" size="mini" v-prevent-re-click @click="openExpansion"> <el-tooltip :content="$t('api_test.automation.open_expansion')" placement="top" effect="light">
{{ $t('api_test.automation.open_expansion') }} <i class="el-icon-remove-outline ms-open-btn ms-open-btn-left" v-prevent-re-click @click="openExpansion"/>
</el-button> </el-tooltip>
<el-button class=" el-icon-notebook-1 ms-open-btn" size="mini" @click="closeExpansion"> <el-tooltip :content="$t('api_test.automation.close_expansion')" placement="top" effect="light">
{{ $t('api_test.automation.close_expansion') }} <i class=" el-icon-circle-plus-outline ms-open-btn" size="mini" v-prevent-re-click @click="closeExpansion"/>
</el-button> </el-tooltip>
<el-tooltip :content="$t('api_test.scenario.enable')" placement="top" effect="light">
<font-awesome-icon class="ms-open-btn" :icon="['fas', 'toggle-on']" v-prevent-re-click @click="enableAll"/>
</el-tooltip>
<el-tooltip :content="$t('api_test.scenario.disable')" placement="top" effect="light">
<font-awesome-icon class="ms-open-btn" :icon="['fas', 'toggle-off']" v-prevent-re-click @click="disableAll"/>
</el-tooltip>
<el-tree node-key="resourceId" :props="props" :data="scenarioDefinition" class="ms-tree" <el-tree node-key="resourceId" :props="props" :data="scenarioDefinition" class="ms-tree"
:default-expanded-keys="expandedNode" :default-expanded-keys="expandedNode"
:expand-on-click-node="false" :expand-on-click-node="false"
@ -382,6 +389,7 @@ export default {
drawer: false, drawer: false,
isFullUrl: true, isFullUrl: true,
expandedStatus: false, expandedStatus: false,
stepEnable: false,
envResult: { envResult: {
loading: false loading: false
} }
@ -1214,6 +1222,35 @@ export default {
this.expandedNode = []; this.expandedNode = [];
this.shrinkTreeNode(); this.shrinkTreeNode();
this.reload(); this.reload();
},
stepNode() {
//
for (let i in this.scenarioDefinition) {
if (this.scenarioDefinition[i]) {
this.scenarioDefinition[i].enable = this.stepEnable;
if (this.scenarioDefinition[i].hashTree && this.scenarioDefinition[i].hashTree.length > 0) {
this.stepStatus(this.scenarioDefinition[i].hashTree);
}
}
}
},
stepStatus(nodes) {
for (let i in nodes) {
if (nodes[i]) {
nodes[i].enable = this.stepEnable;
if (nodes[i].hashTree != undefined && nodes[i].hashTree.length > 0) {
this.stepStatus(nodes[i].hashTree);
}
}
}
},
enableAll() {
this.stepEnable = true;
this.stepNode();
},
disableAll() {
this.stepEnable = false;
this.stepNode();
} }
} }
} }
@ -1377,12 +1414,17 @@ export default {
.ms-open-btn { .ms-open-btn {
margin: 5px 5px 0px; margin: 5px 5px 0px;
font-size: 10px; color: #6D317C;
font-size: 20px;
}
.ms-open-btn:hover {
background-color: #F2F9EE; background-color: #F2F9EE;
cursor: pointer;
color: #67C23A; color: #67C23A;
} }
.ms-open-btn-left { .ms-open-btn-left {
margin-left: 30px; margin-left: 35px;
} }
</style> </style>

View File

@ -5,12 +5,18 @@
<ms-aside-container style="padding-top: 0px"> <ms-aside-container style="padding-top: 0px">
<!-- 场景步骤内容 --> <!-- 场景步骤内容 -->
<div v-loading="loading"> <div v-loading="loading">
<el-button class="el-icon-files ms-open-btn ms-open-btn-left" size="mini" @click="openExpansion"> <el-tooltip :content="$t('api_test.automation.open_expansion')" placement="top" effect="light">
{{ $t('api_test.automation.open_expansion') }} <i class="el-icon-remove-outline ms-open-btn ms-open-btn-left" v-prevent-re-click @click="openExpansion"/>
</el-button> </el-tooltip>
<el-button class="el-icon-notebook-1 ms-open-btn" size="mini" @click="closeExpansion"> <el-tooltip :content="$t('api_test.automation.close_expansion')" placement="top" effect="light">
{{ $t('api_test.automation.close_expansion') }} <i class=" el-icon-circle-plus-outline ms-open-btn" size="mini" @click="closeExpansion"/>
</el-button> </el-tooltip>
<el-tooltip :content="$t('api_test.scenario.enable')" placement="top" effect="light">
<font-awesome-icon class="ms-open-btn" :icon="['fas', 'toggle-on']" @click="enableAll"/>
</el-tooltip>
<el-tooltip :content="$t('api_test.scenario.disable')" placement="top" effect="light">
<font-awesome-icon class="ms-open-btn" :icon="['fas', 'toggle-off']" @click="disableAll"/>
</el-tooltip>
<el-tree node-key="resourceId" <el-tree node-key="resourceId"
:props="props" :props="props"
:data="scenarioDefinition" :data="scenarioDefinition"
@ -234,6 +240,7 @@ export default {
projectList: [], projectList: [],
debugResult: new Map, debugResult: new Map,
expandedStatus: false, expandedStatus: false,
stepEnable: false,
} }
}, },
created() { created() {
@ -973,6 +980,35 @@ export default {
this.expandedNode = []; this.expandedNode = [];
this.shrinkTreeNode(); this.shrinkTreeNode();
this.reload(); this.reload();
},
stepNode() {
//
for (let i in this.scenarioDefinition) {
if (this.scenarioDefinition[i]) {
this.scenarioDefinition[i].enable = this.stepEnable;
if (this.scenarioDefinition[i].hashTree && this.scenarioDefinition[i].hashTree.length > 0) {
this.stepStatus(this.scenarioDefinition[i].hashTree);
}
}
}
},
stepStatus(nodes) {
for (let i in nodes) {
if (nodes[i]) {
nodes[i].enable = this.stepEnable;
if (nodes[i].hashTree != undefined && nodes[i].hashTree.length > 0) {
this.stepStatus(nodes[i].hashTree);
}
}
}
},
enableAll() {
this.stepEnable = true;
this.stepNode();
},
disableAll() {
this.stepEnable = false;
this.stepNode();
} }
} }
} }
@ -1147,8 +1183,13 @@ export default {
.ms-open-btn { .ms-open-btn {
margin: 5px 5px 0px; margin: 5px 5px 0px;
font-size: 10px; color: #6D317C;
font-size: 20px;
}
.ms-open-btn:hover {
background-color: #F2F9EE; background-color: #F2F9EE;
cursor: pointer;
color: #67C23A; color: #67C23A;
} }