2021-04-28 14:54:55 +08:00
|
|
|
|
|
2021-03-03 15:06:52 +08:00
|
|
|
|
<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">
|
2021-04-28 14:54:55 +08:00
|
|
|
|
<div>
|
|
|
|
|
<slot name="toolbar" />
|
|
|
|
|
</div>
|
|
|
|
|
<fu-search-bar v-bind="searchConfig" @exec="search">
|
|
|
|
|
<template #complex>
|
|
|
|
|
<slot name="complex" />
|
|
|
|
|
</template>
|
|
|
|
|
<slot name="buttons" />
|
|
|
|
|
<fu-table-column-select :columns="columns" />
|
|
|
|
|
</fu-search-bar>
|
2021-03-03 15:06:52 +08:00
|
|
|
|
</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: () => []
|
|
|
|
|
},
|
2021-04-29 12:46:51 +08:00
|
|
|
|
// eslint-disable-next-line vue/require-default-prop
|
2021-03-03 15:06:52 +08:00
|
|
|
|
localKey: String, // 如果需要记住选择的列,则这里添加一个唯一的Key
|
2021-04-29 12:46:51 +08:00
|
|
|
|
// eslint-disable-next-line vue/require-default-prop
|
2021-03-03 15:06:52 +08:00
|
|
|
|
header: String,
|
2021-04-29 12:46:51 +08:00
|
|
|
|
// eslint-disable-next-line vue/require-default-prop
|
2021-03-03 15:06:52 +08:00
|
|
|
|
searchConfig: Object,
|
2021-04-29 12:46:51 +08:00
|
|
|
|
// eslint-disable-next-line vue/require-default-prop
|
2021-03-03 15:06:52 +08:00
|
|
|
|
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";
|
2021-03-07 21:29:41 +08:00
|
|
|
|
@import "~@/styles/variables.scss";
|
2021-03-03 15:06:52 +08:00
|
|
|
|
.complex-table {
|
|
|
|
|
.complex-table__header {
|
|
|
|
|
@include flex-row(flex-start, center);
|
2021-04-28 14:54:55 +08:00
|
|
|
|
line-height: 60px;
|
|
|
|
|
font-size: 18px;
|
2021-03-03 15:06:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.complex-table__toolbar {
|
2021-04-28 14:54:55 +08:00
|
|
|
|
@include flex-row(space-between, center);
|
|
|
|
|
|
|
|
|
|
.fu-search-bar {
|
|
|
|
|
width: auto;
|
|
|
|
|
}
|
2021-03-03 15:06:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.complex-table__pagination {
|
|
|
|
|
margin-top: 20px;
|
|
|
|
|
@include flex-row(flex-end);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
</style>
|