fix(系统设置):环境列表增加筛选项目功能

This commit is contained in:
黎龙鑫 2021-04-29 15:56:30 +08:00 committed by jianxing
parent 31c50cde08
commit 4cabc0f701
1 changed files with 20 additions and 6 deletions

View File

@ -1,6 +1,6 @@
<template> <template>
<div v-loading="result.loading"> <div>
<el-card class="table-card"> <el-card class="table-card" v-loading="result.loading">
<!-- 表头 --> <!-- 表头 -->
<template v-slot:header> <template v-slot:header>
<ms-table-header :title="$t('api_test.environment.environment_list')" :create-tip="btnTips" <ms-table-header :title="$t('api_test.environment.environment_list')" :create-tip="btnTips"
@ -14,10 +14,10 @@
</ms-table-header> </ms-table-header>
</template> </template>
<!-- 环境列表内容 --> <!-- 环境列表内容 -->
<el-table border :data="environments" <el-table border :data="environments" @filter-change="filter"
@selection-change="handleSelectionChange" class="adjust-table" style="width: 100%" ref="table"> @selection-change="handleSelectionChange" class="adjust-table" style="width: 100%" ref="table">
<el-table-column type="selection"></el-table-column> <el-table-column type="selection"></el-table-column>
<el-table-column :label="$t('commons.project')" width="250" show-overflow-tooltip> <el-table-column :label="$t('commons.project')" width="250" :filters="projectFilters" column-key="projectId" show-overflow-tooltip>
<template v-slot="scope"> <template v-slot="scope">
<span>{{idNameMap.get(scope.row.projectId)}}</span> <span>{{idNameMap.get(scope.row.projectId)}}</span>
</template> </template>
@ -140,6 +140,7 @@
pageSize: 10, pageSize: 10,
total: 0, total: 0,
projectIds: [], //id projectIds: [], //id
projectFilters: [],
} }
}, },
created() { created() {
@ -208,6 +209,10 @@
this.projectList.forEach(project => { this.projectList.forEach(project => {
this.idNameMap.set(project.id, project.name); this.idNameMap.set(project.id, project.name);
this.projectIds.push(project.id); this.projectIds.push(project.id);
this.projectFilters.push({
text: project.name,
value: project.id,
})
}); });
this.getEnvironments(); this.getEnvironments();
}) })
@ -215,9 +220,13 @@
this.getEnvironments() this.getEnvironments()
} }
}, },
getEnvironments(){ getEnvironments(projectIds){
this.environments = []; this.environments = [];
this.condition.projectIds = this.projectIds; if (projectIds && projectIds.length > 0) {
this.condition.projectIds = projectIds;
} else {
this.condition.projectIds = this.projectIds;
}
let url = '/api/environment/list/' + this.currentPage + '/' + this.pageSize; let url = '/api/environment/list/' + this.currentPage + '/' + this.pageSize;
this.result = this.$post(url, this.condition, response => { this.result = this.$post(url, this.condition, response => {
this.environments = response.data.listObject; this.environments = response.data.listObject;
@ -281,6 +290,11 @@
return name; return name;
}, },
//
filter(filters) {
this.getEnvironments(filters.projectId)
},
// //
close() { close() {
this.dialogVisible = false; this.dialogVisible = false;