zydx-plus 1.0.12 → 1.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<useOffsetPagination :pageCount="pageCount"
|
|
3
|
+
:total="total"
|
|
4
|
+
:page="page"
|
|
5
|
+
@page:change="pageChange"
|
|
6
|
+
v-slot="{
|
|
7
|
+
next,
|
|
8
|
+
prev,
|
|
9
|
+
isFirstPage,
|
|
10
|
+
isLastPage
|
|
11
|
+
}">
|
|
12
|
+
|
|
13
|
+
<div class="paginator">
|
|
14
|
+
<button :disabled="isFirstPage"
|
|
15
|
+
class="defaultButton"
|
|
16
|
+
@click="prev">
|
|
17
|
+
上一页
|
|
18
|
+
</button>
|
|
19
|
+
<div class="paginator_info">
|
|
20
|
+
<input type="input"
|
|
21
|
+
class="paginator_input"
|
|
22
|
+
v-model.number="page" />
|
|
23
|
+
<span>/</span>
|
|
24
|
+
<span>{{ pages }}</span>
|
|
25
|
+
</div>
|
|
26
|
+
<button :disabled="isLastPage"
|
|
27
|
+
class="defaultButton"
|
|
28
|
+
@click="next">
|
|
29
|
+
下一页
|
|
30
|
+
</button>
|
|
31
|
+
</div>
|
|
32
|
+
</useOffsetPagination>
|
|
33
|
+
</template>
|
|
34
|
+
|
|
35
|
+
<script>
|
|
36
|
+
import { defineComponent } from 'vue'
|
|
37
|
+
import useOffsetPagination from './useOffsetPagination.vue';
|
|
38
|
+
export default defineComponent({
|
|
39
|
+
name: 'zydx-pagination',
|
|
40
|
+
components: {
|
|
41
|
+
useOffsetPagination
|
|
42
|
+
},
|
|
43
|
+
inheritAttrs: false,
|
|
44
|
+
props: {
|
|
45
|
+
total: {
|
|
46
|
+
type: Number,
|
|
47
|
+
default: 0
|
|
48
|
+
},
|
|
49
|
+
pageCount: {
|
|
50
|
+
type: Number,
|
|
51
|
+
default: 10
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
data() {
|
|
55
|
+
return {
|
|
56
|
+
page: 1,
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
methods: {
|
|
60
|
+
pageChange: function (v) {
|
|
61
|
+
this.$emit('page:change', v)
|
|
62
|
+
this.page = v
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
computed: {
|
|
66
|
+
pages: function () {
|
|
67
|
+
return this.total / this.pageCount
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
},
|
|
71
|
+
watch: {
|
|
72
|
+
page: {
|
|
73
|
+
handler: function (v) {
|
|
74
|
+
if (v >= this.pages) {
|
|
75
|
+
this.page = this.pages
|
|
76
|
+
}
|
|
77
|
+
if (v <= 1) {
|
|
78
|
+
this.page = 1
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
})
|
|
84
|
+
</script>
|
|
85
|
+
|
|
86
|
+
<style scoped>
|
|
87
|
+
.paginator_info {
|
|
88
|
+
display: flex;
|
|
89
|
+
align-items: center;
|
|
90
|
+
gap: 5px;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.paginator_input {
|
|
94
|
+
width: 40px;
|
|
95
|
+
height: 20px;
|
|
96
|
+
line-height: 18px;
|
|
97
|
+
border: 1px solid #ccc;
|
|
98
|
+
text-align: center;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.defaultButton {
|
|
102
|
+
margin: 1px;
|
|
103
|
+
width: auto;
|
|
104
|
+
min-width: 60px;
|
|
105
|
+
height: 20px;
|
|
106
|
+
background-color: #ffffff;
|
|
107
|
+
color: #000000;
|
|
108
|
+
border: #000000 1px solid;
|
|
109
|
+
line-height: 18px;
|
|
110
|
+
border-radius: 3px;
|
|
111
|
+
font-size: 12px !important;
|
|
112
|
+
text-align: center;
|
|
113
|
+
cursor: pointer;
|
|
114
|
+
padding: 0 5px;
|
|
115
|
+
font-weight: normal;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.defaultButton:disabled {
|
|
119
|
+
background-color: #ffffff;
|
|
120
|
+
color: #717171;
|
|
121
|
+
border: #717171 1px solid;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.paginator {
|
|
125
|
+
width: 100%;
|
|
126
|
+
display: flex;
|
|
127
|
+
align-items: center;
|
|
128
|
+
justify-content: center;
|
|
129
|
+
gap: 15px
|
|
130
|
+
}
|
|
131
|
+
</style>
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
|
|
2
|
+
<script>
|
|
3
|
+
export const debounceTimer = 500
|
|
4
|
+
export function debounce(fn, delay = debounceTimer) {
|
|
5
|
+
var timeoutID = null
|
|
6
|
+
return function () {
|
|
7
|
+
clearTimeout(timeoutID)
|
|
8
|
+
var args = arguments
|
|
9
|
+
var that = this
|
|
10
|
+
timeoutID = setTimeout(function () {
|
|
11
|
+
fn.apply(that, args)
|
|
12
|
+
}, delay)
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
import { defineComponent } from 'vue';
|
|
16
|
+
export default defineComponent({
|
|
17
|
+
props: {
|
|
18
|
+
page: {
|
|
19
|
+
type: Number,
|
|
20
|
+
default: 1
|
|
21
|
+
},
|
|
22
|
+
total: {
|
|
23
|
+
type: Number,
|
|
24
|
+
default: 0
|
|
25
|
+
},
|
|
26
|
+
pageCount: {
|
|
27
|
+
type: Number,
|
|
28
|
+
default: 10
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
inheritAttrs: false,
|
|
32
|
+
data() {
|
|
33
|
+
return {
|
|
34
|
+
currentPage: 1
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
methods: {
|
|
38
|
+
clamp: (num, min, max) => Math.min(Math.max(num, min), max),
|
|
39
|
+
prev: function () {
|
|
40
|
+
this.currentPage = this.clamp(this.currentPage - 1, 1, this.pages)
|
|
41
|
+
},
|
|
42
|
+
next: function () {
|
|
43
|
+
this.currentPage = this.clamp(this.currentPage + 1, 1, this.pages)
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
computed: {
|
|
47
|
+
isFirstPage: function () {
|
|
48
|
+
return this.currentPage === 1
|
|
49
|
+
},
|
|
50
|
+
isLastPage: function () {
|
|
51
|
+
return this.currentPage === this.pages
|
|
52
|
+
},
|
|
53
|
+
pages: function () {
|
|
54
|
+
return this.total / this.pageCount
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
watch: {
|
|
58
|
+
page: {
|
|
59
|
+
handler: function (v) {
|
|
60
|
+
this.currentPage = this.clamp(v, 1, this.pages)
|
|
61
|
+
},
|
|
62
|
+
immediate: true
|
|
63
|
+
},
|
|
64
|
+
currentPage: {
|
|
65
|
+
handler: debounce(function (v) {
|
|
66
|
+
this.$emit('page:change', v)
|
|
67
|
+
}),
|
|
68
|
+
immediate: true
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
render() {
|
|
72
|
+
return this.$slots.default({
|
|
73
|
+
currentPage: this.currentPage,
|
|
74
|
+
next: this.next,
|
|
75
|
+
prev: this.prev,
|
|
76
|
+
isFirstPage: this.isFirstPage,
|
|
77
|
+
isLastPage: this.isLastPage
|
|
78
|
+
})
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
})
|
|
82
|
+
</script>
|
package/src/index.js
CHANGED
|
@@ -4,13 +4,15 @@ import Switch from './components/switch/index';
|
|
|
4
4
|
import menuTree from './components/menuTree/index';
|
|
5
5
|
import coloring from './components/coloring/index';
|
|
6
6
|
import tree from './components/tree/index';
|
|
7
|
+
import Pagination from './components/pagination/index';
|
|
7
8
|
|
|
8
9
|
const components = [
|
|
9
10
|
Calendar,
|
|
10
11
|
Switch,
|
|
11
12
|
menuTree,
|
|
12
13
|
coloring,
|
|
13
|
-
tree
|
|
14
|
+
tree,
|
|
15
|
+
Pagination
|
|
14
16
|
];
|
|
15
17
|
|
|
16
18
|
function install(app) {
|
|
@@ -21,13 +23,14 @@ function install(app) {
|
|
|
21
23
|
}
|
|
22
24
|
|
|
23
25
|
export default {
|
|
24
|
-
version: '1.
|
|
26
|
+
version: '1.1.12',
|
|
25
27
|
install,
|
|
26
28
|
Calendar,
|
|
27
29
|
Message,
|
|
28
30
|
Switch,
|
|
29
31
|
menuTree,
|
|
30
32
|
coloring,
|
|
31
|
-
tree
|
|
33
|
+
tree,
|
|
34
|
+
Pagination
|
|
32
35
|
};
|
|
33
36
|
|