refactor(项目设置): 创建环境 不需要选择项目,环境名称一行显示

--story=1003804 --user=lyh 12.项目设置下 创建环境 不需要选择项目,环境名称一行显示
https://www.tapd.cn/55049933/s/1063853
This commit is contained in:
shiziyuan9527 2021-11-03 18:38:24 +08:00 committed by 刘瑞斌
parent 52e4c2ffa8
commit 265de173b8
2 changed files with 279 additions and 300 deletions

View File

@ -1,9 +1,8 @@
<template> <template>
<el-main v-loading="result.loading" class="environment-edit" style="margin-left: 0px"> <el-main v-loading="result.loading" class="environment-edit" style="margin-left: 0px">
<el-form :model="environment" :rules="rules" ref="environment"> <el-form :model="environment" :rules="rules" ref="environment" label-width="80px">
<span>{{$t('api_test.environment.name')}}</span> <el-form-item prop="name" :label="$t('api_test.environment.name')">
<el-form-item prop="name">
<el-input v-model="environment.name" :disabled="isReadOnly" :placeholder="this.$t('commons.input_name')" clearable/> <el-input v-model="environment.name" :disabled="isReadOnly" :placeholder="this.$t('commons.input_name')" clearable/>
</el-form-item> </el-form-item>

View File

@ -42,7 +42,8 @@
:delete-permission="['PROJECT_ENVIRONMENT:READ+DELETE']" :delete-permission="['PROJECT_ENVIRONMENT:READ+DELETE']"
@editClick="editEnv(scope.row)" @deleteClick="deleteEnv(scope.row)"> @editClick="editEnv(scope.row)" @deleteClick="deleteEnv(scope.row)">
<template v-slot:middle> <template v-slot:middle>
<ms-table-operator-button v-permission="['PROJECT_ENVIRONMENT:READ+COPY']" :tip="$t('commons.copy')" <ms-table-operator-button v-permission="['PROJECT_ENVIRONMENT:READ+COPY']"
:tip="$t('commons.copy')"
@exec="copyEnv(scope.row)" @exec="copyEnv(scope.row)"
icon="el-icon-document-copy" type="info"/> icon="el-icon-document-copy" type="info"/>
</template> </template>
@ -57,14 +58,6 @@
<!-- 创建编辑复制环境时的对话框 --> <!-- 创建编辑复制环境时的对话框 -->
<el-dialog :visible.sync="dialogVisible" :close-on-click-modal="false" :title="dialogTitle" width="66%"> <el-dialog :visible.sync="dialogVisible" :close-on-click-modal="false" :title="dialogTitle" width="66%">
<div class="project-item">
<span>
{{$t('project.select')}}
</span>
<el-select style="width: 50%" @change="handleProjectChange" v-model="currentProjectId" filterable clearable>
<el-option v-for="item in projectList" :key="item.id" :label="item.name" :value="item.id"></el-option>
</el-select>
</div>
<environment-edit :environment="currentEnvironment" ref="environmentEdit" @close="close" <environment-edit :environment="currentEnvironment" ref="environmentEdit" @close="close"
:project-id="currentProjectId" @refreshAfterSave="refresh"> :project-id="currentProjectId" @refreshAfterSave="refresh">
</environment-edit> </environment-edit>
@ -75,28 +68,30 @@
<el-table :data="conditions"> <el-table :data="conditions">
<el-table-column prop="socket" :label="$t('load_test.domain')" show-overflow-tooltip width="180"> <el-table-column prop="socket" :label="$t('load_test.domain')" show-overflow-tooltip width="180">
<template v-slot:default="{row}"> <template v-slot:default="{row}">
{{getUrl(row)}} {{ getUrl(row) }}
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="type" :label="$t('api_test.environment.condition_enable')" show-overflow-tooltip min-width="100px"> <el-table-column prop="type" :label="$t('api_test.environment.condition_enable')" show-overflow-tooltip
min-width="100px">
<template v-slot:default="{row}"> <template v-slot:default="{row}">
{{getName(row)}} {{ getName(row) }}
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="details" show-overflow-tooltip min-width="120px" :label="$t('api_test.value')"> <el-table-column prop="details" show-overflow-tooltip min-width="120px" :label="$t('api_test.value')">
<template v-slot:default="{row}"> <template v-slot:default="{row}">
{{getDetails(row)}} {{ getDetails(row) }}
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="createTime" show-overflow-tooltip min-width="120px" :label="$t('commons.create_time')"> <el-table-column prop="createTime" show-overflow-tooltip min-width="120px"
:label="$t('commons.create_time')">
<template v-slot:default="{row}"> <template v-slot:default="{row}">
<span>{{ row.time | timestampFormatDate }}</span> <span>{{ row.time | timestampFormatDate }}</span>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<span slot="footer" class="dialog-footer"> <span slot="footer" class="dialog-footer">
<el-button @click="domainVisible = false" size="mini">{{$t('commons.cancel')}}</el-button> <el-button @click="domainVisible = false" size="mini">{{ $t('commons.cancel') }}</el-button>
<el-button type="primary" @click="domainVisible = false" size="mini">{{$t('commons.confirm')}}</el-button> <el-button type="primary" @click="domainVisible = false" size="mini">{{ $t('commons.confirm') }}</el-button>
</span> </span>
</el-dialog> </el-dialog>
</div> </div>
@ -105,24 +100,24 @@
</template> </template>
<script> <script>
import MsTableHeader from "@/business/components/common/components/MsTableHeader"; import MsTableHeader from "@/business/components/common/components/MsTableHeader";
import MsTableButton from "@/business/components/common/components/MsTableButton"; import MsTableButton from "@/business/components/common/components/MsTableButton";
import MsTableOperator from "@/business/components/common/components/MsTableOperator"; import MsTableOperator from "@/business/components/common/components/MsTableOperator";
import MsTableOperatorButton from "@/business/components/common/components/MsTableOperatorButton"; import MsTableOperatorButton from "@/business/components/common/components/MsTableOperatorButton";
import MsTablePagination from "@/business/components/common/pagination/TablePagination"; import MsTablePagination from "@/business/components/common/pagination/TablePagination";
import ApiEnvironmentConfig from "@/business/components/api/test/components/ApiEnvironmentConfig"; import ApiEnvironmentConfig from "@/business/components/api/test/components/ApiEnvironmentConfig";
import {Environment, parseEnvironment} from "@/business/components/api/test/model/EnvironmentModel"; import {Environment, parseEnvironment} from "@/business/components/api/test/model/EnvironmentModel";
import EnvironmentEdit from "@/business/components/api/test/components/environment/EnvironmentEdit"; import EnvironmentEdit from "@/business/components/api/test/components/environment/EnvironmentEdit";
import MsAsideItem from "@/business/components/common/components/MsAsideItem"; import MsAsideItem from "@/business/components/common/components/MsAsideItem";
import MsAsideContainer from "@/business/components/common/components/MsAsideContainer"; import MsAsideContainer from "@/business/components/common/components/MsAsideContainer";
import ProjectSwitch from "@/business/components/common/head/ProjectSwitch"; import ProjectSwitch from "@/business/components/common/head/ProjectSwitch";
import SearchList from "@/business/components/common/head/SearchList"; import SearchList from "@/business/components/common/head/SearchList";
import {downloadFile, getCurrentProjectID} from "@/common/js/utils"; import {downloadFile, getCurrentProjectID} from "@/common/js/utils";
import EnvironmentImport from "@/business/components/project/menu/EnvironmentImport"; import EnvironmentImport from "@/business/components/project/menu/EnvironmentImport";
import MsMainContainer from "@/business/components/common/components/MsMainContainer"; import MsMainContainer from "@/business/components/common/components/MsMainContainer";
import MsContainer from "@/business/components/common/components/MsContainer"; import MsContainer from "@/business/components/common/components/MsContainer";
export default { export default {
name: "EnvironmentList", name: "EnvironmentList",
components: { components: {
MsContainer, MsContainer,
@ -147,7 +142,7 @@
dialogVisible: false, dialogVisible: false,
idNameMap: new Map(), idNameMap: new Map(),
dialogTitle: '', dialogTitle: '',
currentProjectId: '', //id currentProjectId: getCurrentProjectID(), //id
selectRows: [], selectRows: [],
isTesterPermission: false, isTesterPermission: false,
domainVisible: false, domainVisible: false,
@ -167,19 +162,6 @@
this.list(); this.list();
}, },
watch: {
//projectId
currentProjectId() {
// el-select''''projectId使
if (this.currentProjectId === '') {
this.currentEnvironment.projectId = null;
} else {
this.currentEnvironment.projectId = this.currentProjectId;
}
}
},
methods: { methods: {
showInfo(row) { showInfo(row) {
const config = JSON.parse(row.config); const config = JSON.parse(row.config);
@ -236,7 +218,7 @@
this.getEnvironments() this.getEnvironments()
} }
}, },
getEnvironments(projectIds){ getEnvironments(projectIds) {
this.environments = []; this.environments = [];
if (projectIds && projectIds.length > 0) { if (projectIds && projectIds.length > 0) {
this.condition.projectIds = projectIds; this.condition.projectIds = projectIds;
@ -250,10 +232,10 @@
}) })
}, },
createEnv() { createEnv() {
this.currentProjectId = '';
this.dialogTitle = this.$t('api_test.environment.create'); this.dialogTitle = this.$t('api_test.environment.create');
this.dialogVisible = true; this.dialogVisible = true;
this.currentEnvironment = new Environment(); this.currentEnvironment = new Environment();
this.currentEnvironment.projectId = this.currentProjectId;
}, },
search() { search() {
this.list() this.list()
@ -333,7 +315,7 @@
//idprojectId //idprojectId
const envs = JSON.parse(JSON.stringify(this.selectRows)); const envs = JSON.parse(JSON.stringify(this.selectRows));
envs.map(env => { //idprojectId envs.map(env => { //idprojectId
if (env.config){ //config if (env.config) { //config
let tempConfig = JSON.parse(env.config); let tempConfig = JSON.parse(env.config);
if (tempConfig.httpConfig.conditions && tempConfig.httpConfig.conditions.length > 0) { if (tempConfig.httpConfig.conditions && tempConfig.httpConfig.conditions.length > 0) {
tempConfig.httpConfig.conditions = tempConfig.httpConfig.conditions.filter(condition => { // tempConfig.httpConfig.conditions = tempConfig.httpConfig.conditions.filter(condition => { //
@ -367,8 +349,7 @@
} }
} else if (config.httpConfig.conditions.length > 1) { } else if (config.httpConfig.conditions.length > 1) {
return "SHOW_INFO"; return "SHOW_INFO";
} } else {
else {
return ""; return "";
} }
} }
@ -380,40 +361,39 @@
}, },
}
}
</script> </script>
<style scoped> <style scoped>
.item-bar { .item-bar {
width: 100%; width: 100%;
background: #F9F9F9; background: #F9F9F9;
padding: 5px 10px; padding: 5px 10px;
box-sizing: border-box; box-sizing: border-box;
border: solid 1px #e6e6e6; border: solid 1px #e6e6e6;
} }
.item-selected { .item-selected {
background: #ECF5FF; background: #ECF5FF;
border-left: solid #409EFF 5px; border-left: solid #409EFF 5px;
} }
.item-selected .item-right { .item-selected .item-right {
visibility: visible; visibility: visible;
} }
.environment-edit { .environment-edit {
margin-left: 0; margin-left: 0;
width: 100%; width: 100%;
border: 0; border: 0;
} }
.project-item { .project-item {
padding-left: 10px; padding-left: 10px;
padding-right: 20px; padding-right: 20px;
} }
.project-item .el-select { .project-item .el-select {
margin-top: 15px; margin-top: 15px;
} }
</style> </style>