dataease/frontend/src/components/business/complex-table/index.vue
fit2cloud-chenyw f04809c638 feat: 新前端
2021-03-03 15:06:52 +08:00

86 lines
1.9 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<div class="complex-table">
<div v-if="$slots.header || header" class="complex-table__header">
<slot name="header">{{ header }}</slot>
</div>
<div v-if="$slots.toolbar || searchConfig" class="complex-table__toolbar">
<slot name="toolbar">
<fu-search-bar v-bind="searchConfig" @exec="search">
<slot name="buttons" />
<fu-table-column-select :columns="columns" />
</fu-search-bar>
</slot>
</div>
<div class="complex-table__body">
<fu-table v-bind="$attrs" :columns="columns" :local-key="localKey" v-on="$listeners">
<slot />
</fu-table>
</div>
<div v-if="$slots.pagination || paginationConfig" class="complex-table__pagination">
<slot name="pagination">
<fu-table-pagination
:current-page.sync="paginationConfig.currentPage"
:page-size.sync="paginationConfig.pageSize"
v-bind="paginationConfig"
@change="search"
/>
</slot>
</div>
</div>
</template>
<script>
export default {
name: 'ComplexTable',
props: {
columns: {
type: Array,
default: () => []
},
localKey: String, // 如果需要记住选择的列则这里添加一个唯一的Key
header: String,
searchConfig: Object,
paginationConfig: Object
},
data() {
return {
condition: {}
}
},
methods: {
search(condition, e) {
if (condition) {
this.condition = condition
}
this.$emit('search', this.condition, e)
}
}
}
</script>
<style lang="scss">
@import "~@/styles/mixin.scss";
@import "~@/styles/element-variables.scss";
.complex-table {
.complex-table__header {
@include flex-row(flex-start, center);
height: 60px;
font-size: 20px;
}
.complex-table__toolbar {
@include flex-row(flex-end, center);
}
.complex-table__pagination {
margin-top: 20px;
@include flex-row(flex-end);
}
}
</style>