feat: update pagination
parent
a760a10676
commit
2ff8ba05a4
|
@ -113,7 +113,7 @@ export default {
|
||||||
...this.getIconsProps(prefixCls),
|
...this.getIconsProps(prefixCls),
|
||||||
selectComponentClass: isSmall ? MiniSelect : VcSelect,
|
selectComponentClass: isSmall ? MiniSelect : VcSelect,
|
||||||
locale: { ...contextLocale, ...customLocale },
|
locale: { ...contextLocale, ...customLocale },
|
||||||
buildOptionText: buildOptionText || this.$slots.buildOptionText?.(),
|
buildOptionText: buildOptionText || this.$slots.buildOptionText,
|
||||||
...this.$attrs,
|
...this.$attrs,
|
||||||
class: classNames({ mini: isSmall }, this.$attrs.class),
|
class: classNames({ mini: isSmall }, this.$attrs.class),
|
||||||
};
|
};
|
||||||
|
@ -126,7 +126,7 @@ export default {
|
||||||
<LocaleReceiver
|
<LocaleReceiver
|
||||||
componentName="Pagination"
|
componentName="Pagination"
|
||||||
defaultLocale={enUS}
|
defaultLocale={enUS}
|
||||||
slots={{ default: this.renderPagination }}
|
children={this.renderPagination}
|
||||||
></LocaleReceiver>
|
></LocaleReceiver>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
import Pagination from './Pagination';
|
import Pagination from './Pagination';
|
||||||
import Base from '../base';
|
|
||||||
|
|
||||||
export { PaginationProps, PaginationConfig } from './Pagination';
|
export { PaginationProps, PaginationConfig } from './Pagination';
|
||||||
|
|
||||||
/* istanbul ignore next */
|
/* istanbul ignore next */
|
||||||
Pagination.install = function(app) {
|
Pagination.install = function(app) {
|
||||||
app.use(Base);
|
|
||||||
app.component(Pagination.name, Pagination);
|
app.component(Pagination.name, Pagination);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import PropTypes from '../_util/vue-types';
|
import PropTypes from '../_util/vue-types';
|
||||||
import BaseMixin from '../_util/BaseMixin';
|
import BaseMixin from '../_util/BaseMixin';
|
||||||
import { hasProp, getOptionProps, getComponent } from '../_util/props-util';
|
import { hasProp, getOptionProps, getComponent, splitAttrs } from '../_util/props-util';
|
||||||
import Pager from './Pager';
|
import Pager from './Pager';
|
||||||
import Options from './Options';
|
import Options from './Options';
|
||||||
import LOCALE from './locale/zh_CN';
|
import LOCALE from './locale/zh_CN';
|
||||||
|
@ -30,10 +30,6 @@ export default {
|
||||||
name: 'Pagination',
|
name: 'Pagination',
|
||||||
mixins: [BaseMixin],
|
mixins: [BaseMixin],
|
||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
model: {
|
|
||||||
prop: 'current',
|
|
||||||
event: 'change.current',
|
|
||||||
},
|
|
||||||
props: {
|
props: {
|
||||||
disabled: PropTypes.bool,
|
disabled: PropTypes.bool,
|
||||||
prefixCls: PropTypes.string.def('rc-pagination'),
|
prefixCls: PropTypes.string.def('rc-pagination'),
|
||||||
|
@ -241,7 +237,7 @@ export default {
|
||||||
this.$emit('update:pageSize', size);
|
this.$emit('update:pageSize', size);
|
||||||
this.$emit('showSizeChange', current, size);
|
this.$emit('showSizeChange', current, size);
|
||||||
if (current !== preCurrent) {
|
if (current !== preCurrent) {
|
||||||
this.$emit('change.current', current, size);
|
this.$emit('update:current', current);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
handleChange(p) {
|
handleChange(p) {
|
||||||
|
@ -262,7 +258,7 @@ export default {
|
||||||
}
|
}
|
||||||
// this.$emit('input', page)
|
// this.$emit('input', page)
|
||||||
this.$emit('change', page, this.statePageSize);
|
this.$emit('change', page, this.statePageSize);
|
||||||
this.$emit('change.current', page, this.statePageSize);
|
this.$emit('update:current', page);
|
||||||
return page;
|
return page;
|
||||||
}
|
}
|
||||||
return this.stateCurrent;
|
return this.stateCurrent;
|
||||||
|
@ -314,7 +310,7 @@ export default {
|
||||||
},
|
},
|
||||||
render() {
|
render() {
|
||||||
const { prefixCls, disabled } = this.$props;
|
const { prefixCls, disabled } = this.$props;
|
||||||
|
const { class: className, ...restAttrs } = splitAttrs(this.$attrs).extraAttrs;
|
||||||
// When hideOnSinglePage is true and there is only 1 page, hide the pager
|
// When hideOnSinglePage is true and there is only 1 page, hide the pager
|
||||||
if (this.hideOnSinglePage === true && this.total <= this.statePageSize) {
|
if (this.hideOnSinglePage === true && this.total <= this.statePageSize) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -363,7 +359,7 @@ export default {
|
||||||
const hasNext = this.hasNext();
|
const hasNext = this.hasNext();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ul class={classNames(`${prefixCls} ${prefixCls}-simple`, this.$attrs.class)}>
|
<ul class={classNames(`${prefixCls} ${prefixCls}-simple`, className)} {...restAttrs}>
|
||||||
<li
|
<li
|
||||||
title={this.showTitle ? locale.prev_page : null}
|
title={this.showTitle ? locale.prev_page : null}
|
||||||
onClick={this.prev}
|
onClick={this.prev}
|
||||||
|
@ -579,14 +575,16 @@ export default {
|
||||||
}
|
}
|
||||||
const prevDisabled = !this.hasPrev() || !allPages;
|
const prevDisabled = !this.hasPrev() || !allPages;
|
||||||
const nextDisabled = !this.hasNext() || !allPages;
|
const nextDisabled = !this.hasNext() || !allPages;
|
||||||
const buildOptionText = this.buildOptionText || this.$slots.buildOptionText?.();
|
const buildOptionText = this.buildOptionText || this.$slots.buildOptionText;
|
||||||
const { class: _cls, style } = this.$attrs;
|
|
||||||
return (
|
return (
|
||||||
<ul
|
<ul
|
||||||
unselectable="unselectable"
|
unselectable="unselectable"
|
||||||
ref="paginationNode"
|
ref="paginationNode"
|
||||||
style={style}
|
{...restAttrs}
|
||||||
class={classNames({ [`${prefixCls}`]: true, [`${prefixCls}-disabled`]: disabled }, _cls)}
|
class={classNames(
|
||||||
|
{ [`${prefixCls}`]: true, [`${prefixCls}-disabled`]: disabled },
|
||||||
|
className,
|
||||||
|
)}
|
||||||
>
|
>
|
||||||
{totalText}
|
{totalText}
|
||||||
<li
|
<li
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import demo from '../antdv-demo/docs/form-model/demo/custom-validation';
|
import demo from '../antdv-demo/docs/pagination/demo/custom-changer';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
|
|
|
@ -22,6 +22,7 @@ import {
|
||||||
Switch,
|
Switch,
|
||||||
Checkbox,
|
Checkbox,
|
||||||
Cascader,
|
Cascader,
|
||||||
|
Pagination,
|
||||||
notification,
|
notification,
|
||||||
message,
|
message,
|
||||||
} from 'ant-design-vue';
|
} from 'ant-design-vue';
|
||||||
|
@ -44,6 +45,7 @@ app
|
||||||
.component('api', { ...basic })
|
.component('api', { ...basic })
|
||||||
.component('CN', { ...basic })
|
.component('CN', { ...basic })
|
||||||
.component('US', { ...basic })
|
.component('US', { ...basic })
|
||||||
|
.use(Pagination)
|
||||||
.use(Select)
|
.use(Select)
|
||||||
.use(Spin)
|
.use(Spin)
|
||||||
.use(Upload)
|
.use(Upload)
|
||||||
|
|
Loading…
Reference in New Issue