fix:全选自动提示

This commit is contained in:
wenyann 2021-06-29 18:35:22 +08:00 committed by 刘瑞斌
parent 2804488979
commit b325f42598
3 changed files with 32 additions and 5 deletions

View File

@ -29,7 +29,8 @@
:resizable="false" align="center"> :resizable="false" align="center">
<template v-slot:default="scope"> <template v-slot:default="scope">
<!-- 选中记录后浮现的按钮提供对记录的批量操作 --> <!-- 选中记录后浮现的按钮提供对记录的批量操作 -->
<show-more-btn :is-show="scope.row.showMore" :buttons="batchOperators" :size="selectDataCounts"/> <show-more-btn :is-show-tool="scope.row.showTool" :is-show="scope.row.showMore" :buttons="batchOperators"
:size="selectDataCounts"/>
</template> </template>
</el-table-column> </el-table-column>

View File

@ -2,7 +2,8 @@
<div v-if="isShow"> <div v-if="isShow">
<el-dropdown placement="bottom" trigger="click" size="medium"> <el-dropdown placement="bottom" trigger="click" size="medium">
<div @click.stop class="show-more-btn"> <div @click.stop class="show-more-btn">
<el-tooltip class="item" effect="dark" :content="$t('test_track.case.batch_operate')" placement="top-start"> <el-tooltip :value="showTool" class="item" effect="dark" :content="$t('test_track.case.batch_operate')"
placement="top-start">
<i class="el-icon-more ms-icon-more"/> <i class="el-icon-more ms-icon-more"/>
</el-tooltip> </el-tooltip>
@ -24,7 +25,8 @@
name: "ShowMoreBtn", name: "ShowMoreBtn",
data() { data() {
return { return {
disabled: false disabled: false,
showTool: false
}; };
}, },
props: { props: {
@ -32,10 +34,24 @@
type: Boolean, type: Boolean,
default: false default: false
}, },
isShowTool: {
type: Boolean,
default: false
},
buttons: Array, buttons: Array,
row: Object, row: Object,
size: Number size: Number
}, },
watch: {
isShowTool(val) {
if (val) {
this.showTool = val;
setTimeout(() => {
this.showTool = false;
}, 1000);
}
}
},
created() { created() {
if (this.trashEnable) { if (this.trashEnable) {
this.buttons.splice(1, 1); this.buttons.splice(1, 1);

View File

@ -7,13 +7,19 @@ export function _handleSelectAll(component, selection, tableData, selectRows, co
if (selection.length > 0) { if (selection.length > 0) {
if (selection.length === 1) { if (selection.length === 1) {
selection.hashTree = []; selection.hashTree = [];
tableData.forEach(item => { tableData.forEach((item, index) => {
if (index === 0) {
component.$set(item, "showTool", true);
}
component.$set(item, "showMore", true); component.$set(item, "showMore", true);
selectRows.add(item); selectRows.add(item);
}); });
} else { } else {
tableData.forEach(item => { tableData.forEach((item, index) => {
item.hashTree = []; item.hashTree = [];
if (index === 0) {
component.$set(item, "showTool", true);
}
component.$set(item, "showMore", true); component.$set(item, "showMore", true);
selectRows.add(item); selectRows.add(item);
}); });
@ -21,6 +27,7 @@ export function _handleSelectAll(component, selection, tableData, selectRows, co
} else { } else {
selectRows.clear(); selectRows.clear();
tableData.forEach(item => { tableData.forEach(item => {
component.$set(item, "showTool", false);
component.$set(item, "showMore", false); component.$set(item, "showMore", false);
}); });
if (condition) { if (condition) {
@ -32,14 +39,17 @@ export function _handleSelectAll(component, selection, tableData, selectRows, co
export function _handleSelect(component, selection, row, selectRows) { export function _handleSelect(component, selection, row, selectRows) {
row.hashTree = []; row.hashTree = [];
if (selectRows.has(row)) { if (selectRows.has(row)) {
component.$set(row, "showTool", false);
component.$set(row, "showMore", false); component.$set(row, "showMore", false);
selectRows.delete(row); selectRows.delete(row);
} else { } else {
component.$set(row, "showTool", true);
component.$set(row, "showMore", true); component.$set(row, "showMore", true);
selectRows.add(row); selectRows.add(row);
} }
let arr = Array.from(selectRows); let arr = Array.from(selectRows);
arr.forEach(row => { arr.forEach(row => {
component.$set(row, "showTool", true);
component.$set(row, "showMore", true); component.$set(row, "showMore", true);
}); });
} }