index.vue
2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<template>
<div class="top-right-btn" :style="style">
<el-row>
<!-- 搜索框控制 -->
<el-tooltip
class="item"
effect="dark"
:content="showSearch ? $t('queryTree.hideSearch') : $t('queryTree.displayTheSearch')"
placement="top"
v-if="search"
>
<el-button circle icon="Search" @click="toggleSearch()" />
</el-tooltip>
<!-- 导出 -->
<el-tooltip class="item" effect="dark" :content="$t('common.exportBtn')" placement="top" v-if="isExport()">
<el-button circle icon="Download" @click="handleExport()" />
</el-tooltip>
<!-- 刷新功能 -->
<el-tooltip class="item" effect="dark" :content="$t('queryTree.refresh')" placement="top">
<el-button circle icon="Refresh" @click="handleRefresh()" />
</el-tooltip>
</el-row>
</div>
</template>
<script setup name="right-toolbar">
import { auth } from '/@/utils/authFunction';
/**
* 通过 defineProps 函数定义组件 props
*/
const props = defineProps({
/**
* 是否显示搜索框
*/
showSearch: {
type: Boolean,
default: true,
},
/**
* 是否导出
*/
export: {
type: [String, Boolean],
default: null,
},
/**
* 是否显示搜索框
*/
search: {
type: Boolean,
default: true,
},
/**
* 列表项之间的间距
*/
gutter: {
type: Number,
default: 10,
},
});
const emits = defineEmits(['update:showSearch', 'queryTable', 'exportExcel']);
const style = computed(() => {
const ret = {};
// 如果props中有传入gutter属性,则计算出marginRight
if (props.gutter) {
ret.marginRight = `${props.gutter / 2}px`;
}
return ret; // 返回计算后的样式对象
});
// 搜索
const toggleSearch = () => {
emits('update:showSearch', !props.showSearch);
};
// 刷新
const handleRefresh = () => {
emits('queryTable');
};
// 导出excel
const handleExport = () => {
emits('exportExcel');
};
// 是否导出
const isExport = () => {
if (props.export === true) {
return true;
}
// 字符串鉴权
return props.export && auth(props.export);
};
</script>
<style lang="scss" scoped>
:deep(.el-transfer__button) {
border-radius: 50%;
display: block;
margin-left: 0px;
}
:deep(.el-transfer__button:first-child) {
margin-bottom: 10px;
}
.my-el-transfer {
text-align: center;
}
</style>