refactor(接口自动化): 修改全选

This commit is contained in:
q4speed 2020-12-02 18:23:26 +08:00
parent 02a5eb9570
commit 7ee2374b00
2 changed files with 30 additions and 15 deletions

View File

@ -6,15 +6,10 @@
</template> </template>
<el-table ref="scenarioTable" border :data="tableData" class="adjust-table" @select-all="select" @select="select"> <el-table ref="scenarioTable" border :data="tableData" class="adjust-table" @select-all="select" @select="select">
<el-table-column width="100"> <el-table-column type="selection"/>
<template v-slot:header="{row}"> <el-table-column width="40" :resizable="false" align="center">
<el-dropdown id="select" size="small" split-button @command="handleCommand"> <template v-slot:default="{row}">
<el-checkbox @change="selectAllChange"></el-checkbox> <show-more-btn :is-show="isSelect(row)" :buttons="buttons" :size="selection.length"/>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item command="table">{{ $t('api_test.automation.scenario.select_table') }}</el-dropdown-item>
<el-dropdown-item command="all">{{ $t('api_test.automation.scenario.select_all') }}</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="name" :label="$t('api_test.automation.scenario_name')" width="200" <el-table-column prop="name" :label="$t('api_test.automation.scenario_name')" width="200"
@ -56,10 +51,11 @@
<script> <script>
import MsTableHeader from "@/business/components/common/components/MsTableHeader"; import MsTableHeader from "@/business/components/common/components/MsTableHeader";
import MsTablePagination from "@/business/components/common/pagination/TablePagination"; import MsTablePagination from "@/business/components/common/pagination/TablePagination";
import ShowMoreBtn from "@/business/components/track/case/components/ShowMoreBtn";
export default { export default {
name: "MsApiScenarioList", name: "MsApiScenarioList",
components: {MsTablePagination, MsTableHeader}, components: {ShowMoreBtn, MsTablePagination, MsTableHeader},
props: { props: {
currentProject: Object, currentProject: Object,
currentModule: Object, currentModule: Object,
@ -69,13 +65,21 @@ export default {
result: {}, result: {},
condition: {}, condition: {},
selectAll: false, selectAll: false,
selection: [],
tableData: [], tableData: [],
currentPage: 1, currentPage: 1,
pageSize: 10, pageSize: 10,
total: 0, total: 0,
buttons: [
{
name: this.$t('api_test.automation.batch_add_plan'), handleClick: this.handleBatchAddCase
}, {
name: this.$t('api_test.automation.batch_execute'), handleClick: this.handleBatchExecute
}
],
} }
}, },
watch:{ watch: {
currentProject() { currentProject() {
this.search(); this.search();
}, },
@ -118,12 +122,23 @@ export default {
this.selectAll = true; this.selectAll = true;
break break
} }
},
handleBatchAddCase() {
},
handleBatchExecute() {
}, },
selectAllChange() { selectAllChange() {
this.handleCommand("table"); this.handleCommand("table");
}, },
select(selection) { select(selection) {
console.log(selection) this.selection = selection.map(s => s.id);
console.log(this.selection)
},
isSelect(row) {
console.log(this.selection.includes(row.id))
return this.selection.includes(row.id)
}, },
edit(row) { edit(row) {
@ -160,7 +175,5 @@ export default {
</script> </script>
<style scoped> <style scoped>
#select >>> .el-button-group > .el-button:first-child {
padding: 7px 15px;
}
</style> </style>

View File

@ -561,6 +561,8 @@ export default {
execute: "执行", execute: "执行",
copy: "复制", copy: "复制",
remove: "删除", remove: "删除",
batch_add_plan: "批量添加到测试计划",
batch_execute: "批量执行",
scenario: { scenario: {
principal: "责任人", principal: "责任人",
select_principal: "请选择责任人", select_principal: "请选择责任人",