refactor: 优化表格全选时的响应速度

This commit is contained in:
CaptainB 2022-04-04 15:06:11 +08:00 committed by 刘瑞斌
parent a0439bf844
commit c0e9effe15
2 changed files with 70 additions and 68 deletions

View File

@ -307,7 +307,9 @@ export default {
initData(){
//
if(this.data && this.data.length > 0){
this.data[0].showBatchTip = true;
this.$nextTick(() => {
this.data[0].showBatchTip = true;
});
}
},
// , ,

View File

@ -1,18 +1,20 @@
<template>
<div v-if="isShow">
<!-- <div :style="isShow? {} : {display: 'none'}">-->
<div>
<el-dropdown placement="bottom" trigger="click" size="medium">
<div @click.stop class="show-more-btn">
<el-tooltip popper-class="batch-popper" :value="true && !hasShowed" effect="dark" :content="$t('test_track.case.batch_operate')"
<el-tooltip v-if="isShow"
:value="!hasShowed"
effect="dark"
:content="$t('test_track.case.batch_operate')"
placement="top-start">
<i class="el-icon-more ms-icon-more table-more-icon"/>
</el-tooltip>
</div>
<el-dropdown-menu slot="dropdown" class="dropdown-menu-class">
<div class="show-more-btn-title">{{$t('test_track.case.batch_handle', [size])}}</div>
<span v-for="(btn,index) in buttons" :key="index">
<el-dropdown-item :disabled="isDisable(btn)" v-if="isXPack(btn)" @click.native.stop="click(btn)">
{{btn.name}}
<div class="show-more-btn-title">{{ $t('test_track.case.batch_handle', [size]) }}</div>
<span v-for="(btn,index) in buttons" :key="index">
<el-dropdown-item :disabled="isDisable(btn)" v-if="isXPack(btn)" @click.native.stop="click(btn)">
{{ btn.name }}
</el-dropdown-item>
</span>
</el-dropdown-menu>
@ -23,80 +25,78 @@
<script>
import {hasLicense, hasPermissions} from "@/common/js/utils";
export default {
name: "ShowMoreBtn",
data() {
return {
disabled: false,
};
export default {
name: "ShowMoreBtn",
data() {
return {
disabled: false,
};
},
props: {
isShow: {
type: Boolean,
default: false
},
props: {
isShow: {
type: Boolean,
default: false
},
buttons: Array,
row: Object,
size: Number,
hasShowed: Boolean
},
created() {
if (this.trashEnable) {
this.buttons.splice(1, 1);
buttons: Array,
row: Object,
size: Number,
hasShowed: Boolean
},
created() {
if (this.trashEnable) {
this.buttons.splice(1, 1);
}
},
methods: {
click(btn) {
if (btn.handleClick instanceof Function) {
btn.handleClick();
}
},
methods: {
click(btn) {
if (btn.handleClick instanceof Function) {
btn.handleClick();
}
},
isDisable(item) {
if (item.isDisable) {
if (item.isDisable instanceof Function) {
console.log(item.isDisable());
return item.isDisable();
} else {
return item.isDisable;
}
}
if (item.permissions && item.permissions.length > 0) {
return !hasPermissions(...item.permissions);
}
return false;
},
isXPack(item) {
if (item.isXPack) {
return hasLicense();
isDisable(item) {
if (item.isDisable) {
if (item.isDisable instanceof Function) {
console.log(item.isDisable());
return item.isDisable();
} else {
return true;
return item.isDisable;
}
}
if (item.permissions && item.permissions.length > 0) {
return !hasPermissions(...item.permissions);
}
return false;
},
isXPack(item) {
if (item.isXPack) {
return hasLicense();
} else {
return true;
}
}
}
};
</script>
<style scoped>
.ms-icon-more {
transform: rotate(90deg);
}
.ms-icon-more {
transform: rotate(90deg);
}
.show-more-btn {
width: 20px;
height: 25px;
line-height: 25px;
}
.show-more-btn {
width: 20px;
}
.show-more-btn-title {
color: #696969;
background-color: #e2e2e2;
padding: 5px;
}
.show-more-btn-title {
color: #696969;
background-color: #e2e2e2;
padding: 5px;
}
.dropdown-menu-class {
padding: 1px 0;
text-align: center;
}
.dropdown-menu-class {
padding: 1px 0;
text-align: center;
}
</style>
<style>
.batch-popper {