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
117
118
119
120
121
122
123
124
125
126
| <template>
| <FYSearchBar @search="search" :loading="loading">
| <template #options>
| <FYOptionText v-bind="$attrs" v-model:value="searchText" width="200px"></FYOptionText>
| </template>
| </FYSearchBar>
| <div>
| <el-scrollbar v-if="data.length > 0" :height="scrollHeight" class="item-box" :loading="loading">
| <el-space direction="vertical" alignment="start" fill style="width: 100%">
| <div v-for="(item, index) in data" :key="index">
| <slot :row="item"></slot>
| </div>
| </el-space>
| </el-scrollbar>
| <el-empty v-else description="暂无记录" />
| </div>
| <el-pagination
| v-if="pageShow && data.length > 0"
| size="small"
| ref="paginationRef"
| class="el-pagination"
| v-model:current-page="currentPage"
| v-model:page-size="pageSize"
| :page-sizes="pageSizes"
| :background="true"
| layout="total, sizes, prev, pager, next"
| :total="total"
| />
| </template>
|
| <script>
| import { usePagination } from '@/composables/pagination';
|
| /**
| * 带有分页逻辑的信息检索列表
| */
| export default {
| setup() {
| // 分页逻辑
| const { currentPage, pageSize, addPageEvent } = usePagination();
| return { currentPage, pageSize, addPageEvent };
| },
| props: {
| // label: {
| // type: String,
| // default: '检索项'
| // },
| // placeholder: {
| // type: String,
| // default: '输入关键字检索'
| // },
| // 数据列表
| data: {
| type: Array,
| default: () => {
| return [];
| }
| },
| // 查询函数
| onSearch: {
| type: Function,
| default: () => {}
| },
| // 是否显示分页
| pageShow: {
| type: Boolean,
| default: true
| },
| // 每页可选数量
| pageSizes: {
| type: Array,
| default: () => {
| return [10, 20, 50, 100];
| }
| },
| // 总数据量
| total: {
| type: Number,
| default: 0
| },
| scrollHeight: {
| type: String,
| default: '38vh'
| }
| },
| data() {
| return {
| searchText: '',
| loading: false
| };
| },
| watch: {},
| methods: {
| async search() {
| this.loading = true;
| const param = {
| text: this.searchText,
| page: this.currentPage,
| pageSize: this.pageSize
| };
| await this.onSearch(param);
| this.loading = false;
| }
| },
| mounted() {
| this.addPageEvent(this.search);
| }
| };
| </script>
| <style scoped>
| .select-box {
| border: 1px solid var(--el-border-color);
| border-radius: var(--el-border-radius-base);
| padding: 0 8px;
| }
| .item-box {
| /* border: 1px solid var(--el-border-color);
| border-radius: var(--el-border-radius-base);
| margin-top: 20px; */
| }
| .el-pagination {
| /* background-color: var(--el-color-white); */
| border-top: 1px solid rgba(0, 0, 0, 0.096);
| /* background-color: aliceblue; */
| }
| </style>
|
|