zydx-plus 1.1.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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zydx-plus",
3
- "version": "1.1.12",
3
+ "version": "1.1.13",
4
4
  "description": "Vue.js",
5
5
  "main": "src/index.js",
6
6
  "files": [
@@ -0,0 +1,6 @@
1
+ import main from './src/pagination';
2
+
3
+ main.install = function(Vue) {
4
+ Vue.component(main.name, main);
5
+ };
6
+ export default main;
@@ -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>
@@ -1,102 +0,0 @@
1
-
2
- <template>
3
- <div class="padding20">
4
- <div>
5
- <div>
6
- <div class="fontSize20 height30 lineHeight30">代码示例:</div>
7
- <div style="border: 1px solid #cccccc">
8
- <div class="menu-layout-container">
9
- <paginaton :pageCount="15"
10
- :total="2000"
11
- @page:change="handleUpdatePage"></paginaton>
12
- </div>
13
- </div>
14
- </div>
15
- </div>
16
- <el-divider content-position="right">zydx-ui</el-divider>
17
- <div>
18
- <div class="fontSize20 height30 lineHeight30">树形数据类型:</div>
19
- <pre class="language-xml"
20
- v-html="content"></pre>
21
- </div>
22
- <div class="margin30_0">
23
- <div>
24
- <div class="fontSize20 height30 lineHeight30">参数说明:</div>
25
- <div>
26
- <el-table :data="paramTableData"
27
- style="width: 100%">
28
- <el-table-column prop="field_key"
29
- label="参数字段"
30
- width="180">
31
- </el-table-column>
32
- <el-table-column prop="field_title"
33
- label="参数名称"
34
- width="180">
35
- </el-table-column>
36
- <el-table-column prop="field_value"
37
- label="示例值">
38
- </el-table-column>
39
- <el-table-column prop="field_default"
40
- label="默认值"
41
- width="180">
42
- </el-table-column>
43
- <el-table-column prop="field_remarks"
44
- label="备注">
45
- </el-table-column>
46
- </el-table>
47
- </div>
48
- </div>
49
- </div>
50
- </div>
51
- </template>
52
-
53
- <script>
54
- import paginaton from '@/components/pagination/src/pagination.vue'
55
- export default {
56
- name: "TreeDemo",
57
- components: { paginaton },
58
- data() {
59
- return {
60
-
61
- content: ``,
62
- // 参数说明
63
- paramTableData: [
64
- {
65
- field_key: "pageCount",
66
- field_title: "一页有多少条数据",
67
- field_value: "Number",
68
- field_default: "1",
69
- field_remarks: ``,
70
- },
71
- {
72
- field_key: "total",
73
- field_title: "一共有多少页",
74
- field_value: "Number",
75
- field_default: "",
76
- field_remarks: ``,
77
- },
78
- {
79
- field_key: "page:change",
80
- field_title: "回调:页码改变时触发",
81
- field_value: "Function",
82
- field_default: "''",
83
- field_remarks: ``,
84
- },
85
- ],
86
- };
87
- },
88
- methods: {
89
- handleUpdatePage: function (v) {
90
- console.log("回调函数", v);
91
- },
92
- },
93
- };
94
- </script>
95
-
96
- <style scoped>
97
- .menu-layout-container {
98
- width: 320px;
99
- height: 600px;
100
- margin: 0 auto;
101
- }
102
- </style>