fix(接口自动化): 跨项目添加场景
This commit is contained in:
parent
ef08532187
commit
6417a131b0
|
@ -32,7 +32,7 @@ public class ServiceUtils {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static<T> void getSelectAllIds( T batchRequest, BaseQueryRequest queryRequest, Function<BaseQueryRequest, List<String>> func) {
|
public static<T> void getSelectAllIds( T batchRequest, BaseQueryRequest queryRequest, Function<BaseQueryRequest, List<String>> func) {
|
||||||
if (queryRequest.isSelectAll()) {
|
if (queryRequest != null && queryRequest.isSelectAll()) {
|
||||||
List<String> ids = func.apply(queryRequest);
|
List<String> ids = func.apply(queryRequest);
|
||||||
if (!ids.isEmpty()) {
|
if (!ids.isEmpty()) {
|
||||||
ids = ids.stream()
|
ids = ids.stream()
|
||||||
|
|
|
@ -3,21 +3,23 @@
|
||||||
title="环境选择"
|
title="环境选择"
|
||||||
:visible.sync="dialogVisible"
|
:visible.sync="dialogVisible"
|
||||||
width="30%"
|
width="30%"
|
||||||
|
:destroy-on-close="true"
|
||||||
:before-close="handleClose">
|
:before-close="handleClose">
|
||||||
|
|
||||||
<div v-for="pe in data" :key="pe.id">
|
<div v-for="pe in data" :key="pe.id">
|
||||||
<div>
|
<div>
|
||||||
{{ getProjectName(pe.id) }}
|
{{ getProjectName(pe.id) }}
|
||||||
<el-select v-model="pe['selectEnv']" placeholder="请选择环境" style="margin-left:10px; margin-top: 10px;" size="small">
|
<el-select v-model="pe['selectEnv']" placeholder="请选择环境" style="margin-left:10px; margin-top: 10px;"
|
||||||
|
size="small">
|
||||||
<el-option v-for="(environment, index) in pe.envs" :key="index"
|
<el-option v-for="(environment, index) in pe.envs" :key="index"
|
||||||
:label="environment.name + (environment.config.httpConfig.socket ? (': ' + environment.config.httpConfig.protocol + '://' + environment.config.httpConfig.socket) : '')"
|
:label="environment.name + (environment.config.httpConfig.socket ? (': ' + environment.config.httpConfig.protocol + '://' + environment.config.httpConfig.socket) : '')"
|
||||||
:value="environment.id"/>
|
:value="environment.id"/>
|
||||||
<el-button class="ms-scenario-button" size="mini" type="primary" @click="openEnvironmentConfig">
|
<el-button class="ms-scenario-button" size="mini" type="primary" @click="openEnvironmentConfig(pe.id)">
|
||||||
{{ $t('api_test.environment.environment_config') }}
|
{{ $t('api_test.environment.environment_config') }}
|
||||||
</el-button>
|
</el-button>
|
||||||
<template v-slot:empty>
|
<template v-slot:empty>
|
||||||
<div class="empty-environment">
|
<div class="empty-environment">
|
||||||
<el-button class="ms-scenario-button" size="mini" type="primary" @click="openEnvironmentConfig">
|
<el-button class="ms-scenario-button" size="mini" type="primary" @click="openEnvironmentConfig(pe.id)">
|
||||||
{{ $t('api_test.environment.environment_config') }}
|
{{ $t('api_test.environment.environment_config') }}
|
||||||
</el-button>
|
</el-button>
|
||||||
</div>
|
</div>
|
||||||
|
@ -30,14 +32,16 @@
|
||||||
<el-button @click="dialogVisible = false" size="small">取 消</el-button>
|
<el-button @click="dialogVisible = false" size="small">取 消</el-button>
|
||||||
<el-button type="primary" @click="handleConfirm" size="small">确 定</el-button>
|
<el-button type="primary" @click="handleConfirm" size="small">确 定</el-button>
|
||||||
</span>
|
</span>
|
||||||
|
<api-environment-config ref="environmentConfig" @close="environmentConfigClose"/>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {parseEnvironment} from "@/business/components/api/test/model/EnvironmentModel";
|
import {parseEnvironment} from "@/business/components/api/test/model/EnvironmentModel";
|
||||||
|
import ApiEnvironmentConfig from "@/business/components/api/definition/components/environment/ApiEnvironmentConfig";
|
||||||
export default {
|
export default {
|
||||||
name: "ApiScenarioEnv",
|
name: "ApiScenarioEnv",
|
||||||
|
components: {ApiEnvironmentConfig},
|
||||||
props: {
|
props: {
|
||||||
projectIds: Set,
|
projectIds: Set,
|
||||||
envMap: Map
|
envMap: Map
|
||||||
|
@ -55,13 +59,8 @@ export default {
|
||||||
this.getWsProjects();
|
this.getWsProjects();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
handleClose(done) {
|
handleClose() {
|
||||||
this.$confirm('确认关闭?')
|
this.dialogVisible = false;
|
||||||
.then(_ => {
|
|
||||||
done();
|
|
||||||
})
|
|
||||||
.catch(_ => {
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
init() {
|
init() {
|
||||||
this.projectIds.forEach(id => {
|
this.projectIds.forEach(id => {
|
||||||
|
@ -92,20 +91,14 @@ export default {
|
||||||
},
|
},
|
||||||
getProjectName(id) {
|
getProjectName(id) {
|
||||||
const project = this.projects.find(p => p.id === id);
|
const project = this.projects.find(p => p.id === id);
|
||||||
if (project) {
|
return project ? project.name : "";
|
||||||
return project.name;
|
|
||||||
}
|
|
||||||
return '';
|
|
||||||
},
|
},
|
||||||
openEnvironmentConfig() {
|
openEnvironmentConfig(projectId) {
|
||||||
if (!this.projectId) {
|
if (!projectId) {
|
||||||
this.$error(this.$t('api_test.select_project'));
|
this.$error(this.$t('api_test.select_project'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.$refs.environmentConfig.open(this.projectId);
|
this.$refs.environmentConfig.open(projectId);
|
||||||
},
|
|
||||||
getProjectEnvMap() {
|
|
||||||
|
|
||||||
},
|
},
|
||||||
handleConfirm() {
|
handleConfirm() {
|
||||||
let map = new Map();
|
let map = new Map();
|
||||||
|
@ -123,6 +116,23 @@ export default {
|
||||||
}
|
}
|
||||||
this.$emit('setProjectEnvMap', map);
|
this.$emit('setProjectEnvMap', map);
|
||||||
this.dialogVisible = false;
|
this.dialogVisible = false;
|
||||||
|
},
|
||||||
|
checkEnv() {
|
||||||
|
let sign = true;
|
||||||
|
this.data.forEach(dt => {
|
||||||
|
if (!dt.selectEnv) {
|
||||||
|
sign = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
if (!sign) {
|
||||||
|
this.$warning("请为每个项目选择一个运行环境!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
environmentConfigClose(id) {
|
||||||
|
// todo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -593,7 +593,7 @@
|
||||||
scenarioIds.push(row.id);
|
scenarioIds.push(row.id);
|
||||||
run.id = getUUID();
|
run.id = getUUID();
|
||||||
run.projectId = getCurrentProjectID();
|
run.projectId = getCurrentProjectID();
|
||||||
run.scenarioIds = scenarioIds;
|
run.ids = scenarioIds;
|
||||||
this.$post(url, run, response => {
|
this.$post(url, run, response => {
|
||||||
let data = response.data;
|
let data = response.data;
|
||||||
this.runVisible = true;
|
this.runVisible = true;
|
||||||
|
|
|
@ -662,6 +662,9 @@ export default {
|
||||||
const index = hashTree.findIndex(d => d.resourceId != undefined && row.resourceId != undefined && d.resourceId === row.resourceId)
|
const index = hashTree.findIndex(d => d.resourceId != undefined && row.resourceId != undefined && d.resourceId === row.resourceId)
|
||||||
if (hashTree[index] && hashTree[index].projectId) {
|
if (hashTree[index] && hashTree[index].projectId) {
|
||||||
this.projectIds.delete(hashTree[index].projectId);
|
this.projectIds.delete(hashTree[index].projectId);
|
||||||
|
if (this.projectEnvMap.has(hashTree[index].projectId)) {
|
||||||
|
this.projectEnvMap.delete(hashTree[index].projectId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
hashTree.splice(index, 1);
|
hashTree.splice(index, 1);
|
||||||
this.sort();
|
this.sort();
|
||||||
|
@ -701,12 +704,9 @@ export default {
|
||||||
// this.$error(this.$t('api_test.environment.select_environment'));
|
// this.$error(this.$t('api_test.environment.select_environment'));
|
||||||
// return;
|
// return;
|
||||||
// }
|
// }
|
||||||
let iter = this.projectEnvMap.values();
|
let sign = this.$refs.apiScenarioEnv.checkEnv();
|
||||||
for (let i of iter) {
|
if (!sign) {
|
||||||
if (!i) {
|
return;
|
||||||
this.$warning("请为每个项目选择一个运行环境!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
this.$refs['currentScenario'].validate((valid) => {
|
this.$refs['currentScenario'].validate((valid) => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
<el-tag size="mini" style="margin-left: 20px" v-if="scenario.referenced==='Copy'">{{ $t('commons.copy') }}</el-tag>
|
<el-tag size="mini" style="margin-left: 20px" v-if="scenario.referenced==='Copy'">{{ $t('commons.copy') }}</el-tag>
|
||||||
<el-tag size="mini" style="margin-left: 20px" v-if="scenario.referenced==='REF'">{{ $t('api_test.scenario.reference') }}</el-tag>
|
<el-tag size="mini" style="margin-left: 20px" v-if="scenario.referenced==='REF'">{{ $t('api_test.scenario.reference') }}</el-tag>
|
||||||
|
|
||||||
<span style="margin-left: 20px;">{{scenario.projectName}}</span>
|
<span style="margin-left: 20px;">{{getProjectName(scenario.projectId)}}</span>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
</api-base-component>
|
</api-base-component>
|
||||||
|
@ -44,8 +44,9 @@
|
||||||
},
|
},
|
||||||
watch: {},
|
watch: {},
|
||||||
created() {
|
created() {
|
||||||
|
this.getWsProjects();
|
||||||
|
getProject.$emit('addProjectEnv', this.scenario.projectId, this.currentEnvironmentId);
|
||||||
if (this.scenario.id && this.scenario.referenced === 'REF' && !this.scenario.loaded) {
|
if (this.scenario.id && this.scenario.referenced === 'REF' && !this.scenario.loaded) {
|
||||||
this.getWsProjects();
|
|
||||||
this.result = this.$get("/api/automation/getApiScenario/" + this.scenario.id, response => {
|
this.result = this.$get("/api/automation/getApiScenario/" + this.scenario.id, response => {
|
||||||
if (response.data) {
|
if (response.data) {
|
||||||
this.scenario.loaded = true;
|
this.scenario.loaded = true;
|
||||||
|
@ -57,9 +58,6 @@
|
||||||
}
|
}
|
||||||
this.scenario.disabled = true;
|
this.scenario.disabled = true;
|
||||||
this.scenario.name = response.data.name;
|
this.scenario.name = response.data.name;
|
||||||
const project = this.projects.find(p => p.id === this.scenario.projectId);
|
|
||||||
getProject.$emit('addProjectEnv', this.scenario.projectId, this.currentEnvironmentId);
|
|
||||||
this.scenario.projectName = project ? project.name : '';
|
|
||||||
this.$emit('refReload');
|
this.$emit('refReload');
|
||||||
} else {
|
} else {
|
||||||
this.scenario.referenced = "Deleted";
|
this.scenario.referenced = "Deleted";
|
||||||
|
@ -122,6 +120,13 @@
|
||||||
this.$get("/project/listAll", res => {
|
this.$get("/project/listAll", res => {
|
||||||
this.projects = res.data;
|
this.projects = res.data;
|
||||||
})
|
})
|
||||||
|
},
|
||||||
|
getProjectName(id) {
|
||||||
|
const project = this.projects.find(p => p.id === id);
|
||||||
|
if (project) {
|
||||||
|
return project.name;
|
||||||
|
}
|
||||||
|
return '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue