-
Notifications
You must be signed in to change notification settings - Fork 284
/
Copy pathpager.js
376 lines (376 loc) · 13 KB
/
pager.js
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
export default {
mode: ['pc', 'mobile-first'],
apis: [
{
name: 'pager',
type: 'component',
props: [
{
name: 'align',
type: "'left' | 'center' | 'right'",
defaultValue: "'left'",
desc: {
'zh-CN': '分页对齐方式,Aurora、XDesign主题默认值为 right',
'en-US': 'Pagination alignment, the default value for Aurora and XDesign themes is right'
},
mode: ['pc'],
pcDemo: 'align'
},
{
name: 'current-page',
type: 'number',
defaultValue: '1',
desc: {
'zh-CN': '当前所在页',
'en-US': 'The current page'
},
mode: ['pc', 'mobile-first'],
pcDemo: 'current-page',
mfDemo: ''
},
{
name: 'custom-total',
type: 'boolean | string',
defaultValue: 'false',
desc: {
'zh-CN': '自定义总条数,传值为 true 时,显示10万+、100万+,传值为字符串则显示传入的字符串',
'en-US':
'Maximum number of page buttons to be displayed in the middle in number/complete mode. Number of page buttons. When the total number of pages exceeds the value, the buttons will be collapsed. The value of this attribute can be an odd number ranging from 5 to 21'
},
mode: ['pc'],
pcDemo: 'custom-total'
},
{
name: 'disabled',
type: 'boolean',
defaultValue: 'false',
desc: {
'zh-CN': '是否禁用分页',
'en-US': 'Disabled pager'
},
mode: ['pc', 'mobile-first'],
pcDemo: 'disabled-and-size',
mfDemo: ''
},
{
name: 'hide-on-single-page',
type: 'boolean',
defaultValue: 'false',
desc: {
'zh-CN': '只有一页时是否隐藏',
'en-US': 'Hide when there is only one page'
},
mode: ['pc', 'mobile-first'],
pcDemo: 'hide-on-single-page',
mfDemo: ''
},
{
name: 'is-before-page-change',
type: 'boolean',
defaultValue: 'false',
desc: {
'zh-CN': '是否开启前置处理特性,开启后,翻页或者改变页大小不会立即生效,由用户处理业务逻辑',
'en-US':
'Whether to enable the preprocessing feature. After opening, flipping or changing the page size will not take effect immediately. The user handles the business logic'
},
mode: ['pc', 'mobile-first'],
pcDemo: 'before-page-change',
mfDemo: ''
},
{
name: 'layout',
type: 'string',
defaultValue: "'total, prev, pager, next, jumper'",
desc: {
'zh-CN':
'组件布局,子组件名用英文逗号分隔,子组件类型有 sizes、 prev、 pager、 next、 jumper、 current、 total、 slot',
'en-US':
'Component layout, with sub component names separated by commas; The optional values for this attribute are sizes, preview, pager, next, jumper, current, total, slot.'
},
mode: ['pc'],
pcDemo: 'custom-layout'
},
{
name: 'mode',
type: "'number' | 'simple' | 'complete' | 'fixed' | 'simplest'",
defaultValue: '',
desc: {
'zh-CN': '设置分页组件显示模式,此属性优先级大于 layout, 3.19.0新增simplest',
'en-US': 'Set the display mode of pagination components, which takes priority over layout'
},
mode: ['pc'],
pcDemo: 'pager-mode'
},
{
name: 'next-text',
type: 'string',
defaultValue: '',
desc: {
'zh-CN': '替代图标显示的下一页文字',
'en-US': 'Replace icon display with next page text'
},
mode: ['pc', 'mobile-first'],
pcDemo: 'custom-next-prev-text',
mfDemo: ''
},
{
name: 'page-count',
type: 'number',
defaultValue: '',
desc: {
'zh-CN':
'总页数,total 和 page-count 设置任意一个就可以达到显示页码的功能,如果要支持 page-sizes 的更改,则需要使用 total 属性',
'en-US':
'Setting either the total number of pages, total, or page count can achieve the function of displaying page numbers; If you want to support changes to page sizes, you need to use the total attribute'
},
mode: ['pc'],
pcDemo: 'page-count'
},
{
name: 'page-size',
type: 'Number',
defaultValue: '',
desc: {
'zh-CN': '每页显示条目个数,支持 .sync 修饰符',
'en-US': ''
},
mode: ['mobile-first'],
mfDemo: ''
},
{
name: 'page-size/v-model:page-size',
type: 'number',
defaultValue: '10',
desc: {
'zh-CN': '每页显示条目数',
'en-US': 'Number of items displayed on each page'
},
mode: ['pc'],
pcDemo: 'page-size'
},
{
name: 'page-sizes',
type: 'number[]',
defaultValue: '[10, 20, 30, 40, 50, 100]',
desc: {
'zh-CN': '设置指定可选择的每页显示条数,每页显示个数选择器的选项设置',
'en-US':
'Set the specified number of selectable display items per page; Option settings for displaying number selectors per page'
},
mode: ['pc'],
pcDemo: 'page-size'
},
{
name: 'pager-count',
type: 'number',
defaultValue: '7',
desc: {
'zh-CN':
'设置页码按钮需要显示的最多个数,当总页数超过该值时会折叠,该属性的合法值为大于等于 5 且小于等于 21 的奇数',
'en-US':
'Set the maximum number of page number buttons to display; When the total number of pages exceeds this value, it will collapse; The optional values for this attribute are odd numbers greater than or equal to 5 and less than or equal to 21'
},
mode: ['pc'],
pcDemo: 'pager-count'
},
{
name: 'popper-append-to-body',
type: 'boolean',
defaultValue: 'true',
desc: {
'zh-CN': '是否将弹出框插入至 body 元素,可将该属性设置为 false(可参考 select 组件)',
'en-US':
'Whether to insert the pop-up box into the body element. You can set this attribute to false (refer to the select component)'
},
mode: ['pc'],
pcDemo: 'popper-append-to-body'
},
{
name: 'popper-class',
type: 'string',
defaultValue: '',
desc: {
'zh-CN': '为 popper 添加类名(可参考 popover 组件)',
'en-US':
'Indicates whether to insert a pop-up box to the body element. If an error occurs in locating a fault in the dialog box that is displayed, set this attribute to false (for details, see the select component).'
},
mode: ['pc'],
pcDemo: 'popper-class'
},
{
name: 'prev-text',
type: 'string',
defaultValue: '',
desc: {
'zh-CN': '替代图标显示的上一页文字',
'en-US': 'Replace the previous page text displayed by the icon'
},
mode: ['pc', 'mobile-first'],
pcDemo: 'custom-next-prev-text',
mfDemo: ''
},
{
name: 'show-total-loading',
type: 'boolean',
defaultValue: 'false',
desc: {
'zh-CN': '是否显示总条数加载中',
'en-US': 'Is the total number of items being loaded'
},
mode: ['pc'],
pcDemo: 'show-total-loading'
},
{
name: 'size',
type: "'mini'",
defaultValue: '',
desc: {
'zh-CN': '定义分页尺寸',
'en-US': 'Define the page size'
},
mode: ['pc'],
pcDemo: 'disabled-and-size'
},
{
name: 'total',
type: 'number',
defaultValue: '',
desc: {
'zh-CN': '总条目数',
'en-US': 'Total number of entries'
},
mode: ['pc', 'mobile-first'],
pcDemo: 'basic-usage',
mfDemo: ''
},
{
name: 'total-fixed-left',
type: 'boolean',
defaultValue: 'false',
meta: {
stable: '3.18.0'
},
desc: {
'zh-CN': '总条目数是否固定在左侧,Aurora、XDesign主题默认值为 true',
'en-US':
'Whether the total number of entries is fixed on the left, the default value for Aurora and XDesign themes is true'
},
mode: ['pc'],
pcDemo: ''
},
{
name: 'page-size-text',
type: 'string',
defaultValue: '"条/页"',
meta: {
stable: '3.19.0'
},
desc: {
'zh-CN': '自定以页码大小后置显示文本,XDesign主题默认为空',
'en-US':
'Customize the text to be displayed after the page number size. The XDesign theme is empty by default.'
},
mode: ['pc'],
pcDemo: ''
}
],
events: [
{
name: 'before-page-change',
typeAnchorName: 'IBeforeChangeEvent',
type: 'IBeforeChangeEvent',
defaultValue: '',
desc: {
'zh-CN':
'当 is-before-page-change 设置为 true 后,翻页或改变页大小前会触发此事件,用户可以在参数中获取相应事件和分页相关信息控制后续逻辑',
'en-US':
'When the is-before-page-change is set to true, this event will be triggered before flipping or changing the page size. Users can obtain the corresponding event and pagination related information in the parameters to control the subsequent logic'
},
mode: ['pc', 'mobile-first'],
pcDemo: 'before-page-change',
mfDemo: ''
},
{
name: 'current-change',
type: '(currentPage: number) => void',
defaultValue: '',
desc: {
'zh-CN': '当前所在页改变时会触发',
'en-US': 'Triggered when the currentPage changes'
},
mode: ['pc', 'mobile-first'],
pcDemo: 'pager-event',
mfDemo: ''
},
{
name: 'next-click',
type: '(currentPage: number) => void',
defaultValue: '',
desc: {
'zh-CN': '点击下一页按钮改变当前页后触发',
'en-US': 'Triggered after clicking the next page button to change the current page'
},
mode: ['pc', 'mobile-first'],
pcDemo: 'pager-event',
mfDemo: ''
},
{
name: 'prev-click',
type: '(currentPage: number) => void',
defaultValue: '',
desc: {
'zh-CN': '点击上一页按钮改变当前页后触发',
'en-US': 'Triggered after clicking the previous page button to change the current page'
},
mode: ['pc', 'mobile-first'],
pcDemo: 'pager-event',
mfDemo: ''
},
{
name: 'size-change',
type: '(pageSize: number) => void',
defaultValue: '',
desc: {
'zh-CN': '每页显示条目数改变后会触发',
'en-US':
'Set the event after pagination. This event is triggered when pageSize changes. arg1: pageSize new current value'
},
mode: ['pc'],
pcDemo: 'pager-event'
}
],
methods: [],
slots: [
{
name: 'default',
defaultValue: '',
desc: {
'zh-CN': '自定义内容,需要在 layout 中列出 slot',
'en-US': 'User-defined content. Slots must be listed in the layout'
},
mode: ['pc'],
pcDemo: 'custom-layout'
}
]
}
],
types: [
{
name: 'IBeforeChangeEvent',
type: 'interface',
code: `
// 函数接受一个参数
interface IBeforeChangeEvent {
(param: IBeforeChangeParam): void
}
interface IBeforeChangeParam {
callback: () => void // 回调函数,调用则继续本次变更
rollback: () => void // 回滚函数,调用则阻止本次变更
newPage: number // 变更后所在页
newPageSize: number // 变更后分页大小
currentPage: number // 当前所在页
currentPageSize: number // 当前分页大小
}`
}
]
}