refactor: 打开环境配置时默认选中当前配置
This commit is contained in:
parent
dfc24d96a4
commit
a8b54c9d74
|
@ -5,12 +5,12 @@
|
||||||
<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(pe.id)">
|
<el-button class="ms-scenario-button" size="mini" type="primary" @click="openEnvironmentConfig(pe.id, pe['selectEnv'])">
|
||||||
{{ $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(pe.id)">
|
<el-button class="ms-scenario-button" size="mini" type="primary" @click="openEnvironmentConfig(pe.id, pe['selectEnv'])">
|
||||||
{{ $t('api_test.environment.environment_config') }}
|
{{ $t('api_test.environment.environment_config') }}
|
||||||
</el-button>
|
</el-button>
|
||||||
</div>
|
</div>
|
||||||
|
@ -78,12 +78,12 @@ export default {
|
||||||
const project = this.projectList.find(p => p.id === id);
|
const project = this.projectList.find(p => p.id === id);
|
||||||
return project ? project.name : "";
|
return project ? project.name : "";
|
||||||
},
|
},
|
||||||
openEnvironmentConfig(projectId) {
|
openEnvironmentConfig(projectId, envId) {
|
||||||
if (!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(projectId);
|
this.$refs.environmentConfig.open(projectId, envId);
|
||||||
},
|
},
|
||||||
handleConfirm() {
|
handleConfirm() {
|
||||||
let map = new Map();
|
let map = new Map();
|
||||||
|
|
|
@ -77,7 +77,7 @@
|
||||||
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(this.projectId, this.environmentId);
|
||||||
},
|
},
|
||||||
environmentChange(value) {
|
environmentChange(value) {
|
||||||
for (let i in this.environments) {
|
for (let i in this.environments) {
|
||||||
|
|
|
@ -46,13 +46,15 @@
|
||||||
icon: 'el-icon-delete',
|
icon: 'el-icon-delete',
|
||||||
func: this.deleteEnvironment
|
func: this.deleteEnvironment
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
selectEnvironmentId: ''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
open: function (projectId) {
|
open: function (projectId, envId) {
|
||||||
this.visible = true;
|
this.visible = true;
|
||||||
this.projectId = projectId;
|
this.projectId = projectId;
|
||||||
|
this.selectEnvironmentId = envId;
|
||||||
this.getEnvironments();
|
this.getEnvironments();
|
||||||
listenGoBack(this.close);
|
listenGoBack(this.close);
|
||||||
},
|
},
|
||||||
|
@ -114,7 +116,16 @@
|
||||||
this.result = this.$get('/api/environment/list/' + this.projectId, response => {
|
this.result = this.$get('/api/environment/list/' + this.projectId, response => {
|
||||||
this.environments = response.data;
|
this.environments = response.data;
|
||||||
if (this.environments.length > 0) {
|
if (this.environments.length > 0) {
|
||||||
this.$refs.environmentItems.itemSelected(0, this.environments[0]);
|
if (this.selectEnvironmentId) {
|
||||||
|
const index = this.environments.findIndex(e => e.id === this.selectEnvironmentId);
|
||||||
|
if (index !== -1) {
|
||||||
|
this.$refs.environmentItems.itemSelected(index, this.environments[index]);
|
||||||
|
} else {
|
||||||
|
this.$refs.environmentItems.itemSelected(0, this.environments[0]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.$refs.environmentItems.itemSelected(0, this.environments[0]);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
let item = new Environment({
|
let item = new Environment({
|
||||||
projectId: this.projectId
|
projectId: this.projectId
|
||||||
|
|
|
@ -46,13 +46,15 @@
|
||||||
icon: 'el-icon-delete',
|
icon: 'el-icon-delete',
|
||||||
func: this.deleteEnvironment
|
func: this.deleteEnvironment
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
selectEnvironmentId: ''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
open: function (projectId) {
|
open: function (projectId, envId) {
|
||||||
this.visible = true;
|
this.visible = true;
|
||||||
this.projectId = projectId;
|
this.projectId = projectId;
|
||||||
|
this.selectEnvironmentId = envId;
|
||||||
this.getEnvironments();
|
this.getEnvironments();
|
||||||
listenGoBack(this.close);
|
listenGoBack(this.close);
|
||||||
},
|
},
|
||||||
|
@ -114,7 +116,16 @@
|
||||||
this.result = this.$get('/api/environment/list/' + this.projectId, response => {
|
this.result = this.$get('/api/environment/list/' + this.projectId, response => {
|
||||||
this.environments = response.data;
|
this.environments = response.data;
|
||||||
if (this.environments.length > 0) {
|
if (this.environments.length > 0) {
|
||||||
this.$refs.environmentItems.itemSelected(0, this.environments[0]);
|
if (this.selectEnvironmentId) {
|
||||||
|
const index = this.environments.findIndex(e => e.id === this.selectEnvironmentId);
|
||||||
|
if (index !== -1) {
|
||||||
|
this.$refs.environmentItems.itemSelected(index, this.environments[index]);
|
||||||
|
} else {
|
||||||
|
this.$refs.environmentItems.itemSelected(0, this.environments[0]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.$refs.environmentItems.itemSelected(0, this.environments[0]);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
let item = new Environment({
|
let item = new Environment({
|
||||||
projectId: this.projectId
|
projectId: this.projectId
|
||||||
|
|
Loading…
Reference in New Issue