From 61417032b79f99ecb462f7f7f2263c2d98d1b558 Mon Sep 17 00:00:00 2001
From: 疯狂的狮子li <15040126243@163.com>
Date: 星期四, 20 四月 2023 18:45:29 +0800
Subject: [PATCH] fix 修复 代码生成菜单选项回显问题
---
src/components/Pagination/index.vue | 171 ++++++++++++++++++++++++++++++--------------------------
1 files changed, 92 insertions(+), 79 deletions(-)
diff --git a/src/components/Pagination/index.vue b/src/components/Pagination/index.vue
index 38de953..de7b02c 100644
--- a/src/components/Pagination/index.vue
+++ b/src/components/Pagination/index.vue
@@ -14,92 +14,105 @@
</div>
</template>
-<script setup>
-import { scrollTo } from '@/utils/scroll-to'
-
-const props = defineProps({
- total: {
- required: true,
- type: Number
- },
- page: {
- type: Number,
- default: 1
- },
- limit: {
- type: Number,
- default: 20
- },
- pageSizes: {
- type: Array,
- default() {
- return [10, 20, 30, 50]
- }
- },
- // 绉诲姩绔〉鐮佹寜閽殑鏁伴噺绔粯璁ゅ��5
- pagerCount: {
- type: Number,
- default: document.body.clientWidth < 992 ? 5 : 7
- },
- layout: {
- type: String,
- default: 'total, sizes, prev, pager, next, jumper'
- },
- background: {
- type: Boolean,
- default: true
- },
- autoScroll: {
- type: Boolean,
- default: true
- },
- hidden: {
- type: Boolean,
- default: false
- }
-})
-
-const emit = defineEmits();
-const currentPage = computed({
- get() {
- return props.page
- },
- set(val) {
- emit('update:page', val)
- }
-})
-const pageSize = computed({
- get() {
- return props.limit
- },
- set(val){
- emit('update:limit', val)
- }
-})
-function handleSizeChange(val) {
- if (currentPage.value * val > props.total) {
- currentPage.value = 1
- }
- emit('pagination', { page: currentPage.value, limit: val })
- if (props.autoScroll) {
- scrollTo(0, 800)
- }
+<script lang="ts">
+export default {
+ name: 'Pagination'
}
-function handleCurrentChange(val) {
- emit('pagination', { page: val, limit: pageSize.value })
- if (props.autoScroll) {
- scrollTo(0, 800)
- }
-}
-
</script>
-<style scoped>
+<script setup lang="ts">
+import { scrollTo } from '@/utils/scroll-to'
+import { PropType } from "vue";
+
+const props = defineProps({
+ total: {
+ required: true,
+ type: Number
+ },
+ page: {
+ type: Number,
+ default: 1
+ },
+ limit: {
+ type: Number,
+ default: 20
+ },
+ pageSizes: {
+ type: Array as PropType<number[]>,
+ default() {
+ return [10, 20, 30, 50]
+ }
+ },
+ // 绉诲姩绔〉鐮佹寜閽殑鏁伴噺绔粯璁ゅ��5
+ pagerCount: {
+ type: Number,
+ default: document.body.clientWidth < 992 ? 5 : 7
+ },
+ layout: {
+ type: String,
+ default: 'total, sizes, prev, pager, next, jumper'
+ },
+ background: {
+ type: Boolean,
+ default: true
+ },
+ autoScroll: {
+ type: Boolean,
+ default: true
+ },
+ hidden: {
+ type: Boolean,
+ default: false
+ },
+ float: {
+ type: String,
+ default: 'right'
+ }
+})
+
+const emit = defineEmits(['update:page', 'update:limit', 'pagination']);
+const currentPage = computed({
+ get() {
+ return props.page
+ },
+ set(val) {
+ emit('update:page', val)
+ }
+})
+const pageSize = computed({
+ get() {
+ return props.limit
+ },
+ set(val){
+ emit('update:limit', val)
+ }
+})
+function handleSizeChange(val: number) {
+ if (currentPage.value * val > props.total) {
+ currentPage.value = 1
+ }
+ emit('pagination', { page: currentPage.value, limit: val })
+ if (props.autoScroll) {
+ scrollTo(0, 800)
+ }
+}
+function handleCurrentChange(val: number) {
+ emit('pagination', { page: val, limit: pageSize.value })
+ if (props.autoScroll) {
+ scrollTo(0, 800)
+ }
+}
+</script>
+
+<style lang="scss" scoped>
.pagination-container {
background: #fff;
padding: 32px 16px;
+ .el-pagination{
+ float: v-bind(float);
+ }
}
.pagination-container.hidden {
display: none;
}
-</style>
\ No newline at end of file
+</style>
--
Gitblit v1.9.3