evui 3.3.36 → 3.3.39
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/LICENSE +21 -21
- package/README.md +40 -40
- package/dist/evui.common.js +1907 -1832
- package/dist/evui.common.js.map +1 -1
- package/dist/evui.umd.js +1907 -1832
- package/dist/evui.umd.js.map +1 -1
- package/dist/evui.umd.min.js +1 -1
- package/dist/evui.umd.min.js.map +1 -1
- package/dist/img/{EVUI.7f3588fb.svg → EVUI.b82ee81a.svg} +292 -292
- package/dist/img/{icon_mysql.7ea26d5d.svg → icon_mysql.1085fdc9.svg} +78 -78
- package/dist/img/{icon_oracle.9009b108.svg → icon_oracle.0572d3ee.svg} +13 -13
- package/dist/img/{icon_postgresql.f8fffba9.svg → icon_postgresql.ee12bde8.svg} +58 -58
- package/package.json +61 -61
- package/src/common/emitter.js +20 -20
- package/src/common/utils.debounce.js +223 -223
- package/src/common/utils.js +134 -134
- package/src/common/utils.table.js +78 -78
- package/src/common/utils.throttle.js +83 -83
- package/src/common/utils.tree.js +18 -18
- package/src/components/button/Button.vue +198 -198
- package/src/components/button/index.js +7 -7
- package/src/components/buttonGroup/ButtonGroup.vue +11 -11
- package/src/components/buttonGroup/index.js +7 -7
- package/src/components/calendar/Calendar.vue +661 -661
- package/src/components/calendar/index.js +7 -7
- package/src/components/calendar/uses.js +1272 -1272
- package/src/components/chart/Chart.vue +189 -192
- package/src/components/chart/chart.core.js +870 -870
- package/src/components/chart/element/element.bar.js +524 -524
- package/src/components/chart/element/element.bar.time.js +156 -156
- package/src/components/chart/element/element.heatmap.js +533 -533
- package/src/components/chart/element/element.line.js +339 -339
- package/src/components/chart/element/element.pie.js +197 -197
- package/src/components/chart/element/element.scatter.js +184 -184
- package/src/components/chart/element/element.tip.js +550 -542
- package/src/components/chart/helpers/helpers.canvas.js +265 -265
- package/src/components/chart/helpers/helpers.constant.js +206 -206
- package/src/components/chart/helpers/helpers.util.js +346 -338
- package/src/components/chart/index.js +9 -9
- package/src/components/chart/model/index.js +4 -4
- package/src/components/chart/model/model.series.js +93 -93
- package/src/components/chart/model/model.store.js +977 -967
- package/src/components/chart/plugins/plugins.interaction.js +769 -769
- package/src/components/chart/plugins/plugins.legend.gradient.js +602 -602
- package/src/components/chart/plugins/plugins.legend.js +1155 -1151
- package/src/components/chart/plugins/plugins.pie.js +254 -254
- package/src/components/chart/plugins/plugins.title.js +56 -56
- package/src/components/chart/plugins/plugins.tooltip.js +692 -692
- package/src/components/chart/scale/scale.js +848 -848
- package/src/components/chart/scale/scale.linear.js +38 -38
- package/src/components/chart/scale/scale.logarithmic.js +128 -128
- package/src/components/chart/scale/scale.step.js +336 -336
- package/src/components/chart/scale/scale.time.category.js +277 -277
- package/src/components/chart/scale/scale.time.js +48 -48
- package/src/components/chart/style/chart.scss +312 -312
- package/src/components/chart/uses.js +264 -252
- package/src/components/checkbox/Checkbox.vue +200 -200
- package/src/components/checkbox/index.js +7 -7
- package/src/components/checkboxGroup/CheckboxGroup.vue +44 -44
- package/src/components/checkboxGroup/index.js +7 -7
- package/src/components/contextMenu/ContextMenu.vue +80 -80
- package/src/components/contextMenu/MenuList.vue +149 -149
- package/src/components/contextMenu/index.js +7 -7
- package/src/components/contextMenu/uses.js +203 -203
- package/src/components/datePicker/DatePicker.vue +437 -437
- package/src/components/datePicker/index.js +7 -7
- package/src/components/datePicker/uses.js +419 -419
- package/src/components/grid/Grid.vue +827 -827
- package/src/components/grid/grid.filter.window.vue +493 -493
- package/src/components/grid/grid.pagination.vue +75 -75
- package/src/components/grid/grid.summary.vue +265 -265
- package/src/components/grid/grid.toolbar.vue +26 -26
- package/src/components/grid/index.js +11 -11
- package/src/components/grid/style/grid.scss +263 -263
- package/src/components/grid/uses.js +1002 -1007
- package/src/components/icon/Icon.vue +49 -49
- package/src/components/icon/index.js +8 -8
- package/src/components/inputNumber/InputNumber.vue +212 -212
- package/src/components/inputNumber/index.js +7 -7
- package/src/components/inputNumber/uses.js +217 -217
- package/src/components/loading/Loading.vue +125 -125
- package/src/components/loading/index.js +7 -7
- package/src/components/menu/Menu.vue +68 -68
- package/src/components/menu/MenuItem.vue +187 -187
- package/src/components/menu/index.js +7 -7
- package/src/components/message/Message.vue +223 -223
- package/src/components/message/index.js +31 -31
- package/src/components/messageBox/MessageBox.vue +358 -358
- package/src/components/messageBox/index.js +22 -22
- package/src/components/notification/Notification.vue +316 -316
- package/src/components/notification/index.js +49 -49
- package/src/components/pagination/Pagination.vue +271 -271
- package/src/components/pagination/index.js +7 -7
- package/src/components/pagination/pageButton.vue +30 -30
- package/src/components/progress/Progress.vue +139 -139
- package/src/components/progress/index.js +7 -7
- package/src/components/radio/Radio.vue +159 -159
- package/src/components/radio/index.js +7 -7
- package/src/components/radioGroup/RadioGroup.vue +41 -41
- package/src/components/radioGroup/index.js +7 -7
- package/src/components/scheduler/Scheduler.vue +149 -149
- package/src/components/scheduler/index.js +7 -7
- package/src/components/scheduler/uses.js +183 -183
- package/src/components/select/Select.vue +440 -440
- package/src/components/select/index.js +7 -7
- package/src/components/select/uses.js +270 -270
- package/src/components/slider/Slider.vue +505 -505
- package/src/components/slider/index.js +7 -7
- package/src/components/slider/uses.js +390 -390
- package/src/components/tabPanel/TabPanel.vue +74 -74
- package/src/components/tabPanel/index.js +7 -7
- package/src/components/tabs/Tabs.vue +517 -517
- package/src/components/tabs/index.js +7 -7
- package/src/components/textField/TextField.vue +375 -375
- package/src/components/textField/index.js +7 -7
- package/src/components/timePicker/TimePicker.vue +352 -352
- package/src/components/timePicker/index.js +7 -7
- package/src/components/toggle/Toggle.vue +115 -115
- package/src/components/toggle/index.js +7 -7
- package/src/components/tree/Tree.vue +313 -313
- package/src/components/tree/TreeNode.vue +293 -293
- package/src/components/tree/index.js +7 -7
- package/src/components/treeGrid/TreeGrid.vue +758 -758
- package/src/components/treeGrid/TreeGridNode.vue +275 -275
- package/src/components/treeGrid/index.js +9 -9
- package/src/components/treeGrid/style/treeGrid.scss +261 -261
- package/src/components/treeGrid/treeGrid.toolbar.vue +26 -26
- package/src/components/treeGrid/uses.js +867 -867
- package/src/components/window/Window.vue +329 -329
- package/src/components/window/index.js +7 -7
- package/src/components/window/uses.js +899 -899
- package/src/directives/clickoutside.js +90 -90
- package/src/main.js +116 -116
- package/src/style/components/input.scss +108 -108
- package/src/style/functions.scss +3 -3
- package/src/style/index.scss +6 -6
- package/src/style/lib/fonts/EVUI.svg +292 -292
- package/src/style/lib/icon.css +888 -888
- package/src/style/mixins.scss +94 -94
- package/src/style/themes.scss +67 -67
- package/src/style/variables.scss +22 -22
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
import { defineComponent, h, render } from 'vue';
|
|
2
|
-
import Component from './Notification.vue';
|
|
3
|
-
|
|
4
|
-
const componentObj = defineComponent(Component);
|
|
5
|
-
|
|
6
|
-
const rootId = 'ev-notification-modal';
|
|
7
|
-
const root = document.createElement('div');
|
|
8
|
-
root.id = rootId;
|
|
9
|
-
|
|
10
|
-
const positionList = ['top-left', 'top-right', 'bottom-left', 'bottom-right'];
|
|
11
|
-
|
|
12
|
-
const notification = (options = {}) => {
|
|
13
|
-
const position = options.position || 'top-right';
|
|
14
|
-
if (!positionList.includes(position)) {
|
|
15
|
-
console.warn('[EVUI][Notification] The position value is incorrectly entered.');
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const hasRoot = document.getElementById(rootId);
|
|
20
|
-
if (!hasRoot) {
|
|
21
|
-
document.body.appendChild(root);
|
|
22
|
-
}
|
|
23
|
-
let wrapper = root.getElementsByClassName(`modal-${position}`);
|
|
24
|
-
const hasElem = wrapper.length;
|
|
25
|
-
if (hasElem) {
|
|
26
|
-
wrapper = wrapper[0];
|
|
27
|
-
} else {
|
|
28
|
-
wrapper = document.createElement('div');
|
|
29
|
-
wrapper.classList.add(`modal-${position}`);
|
|
30
|
-
root.appendChild(wrapper);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const container = document.createElement('div');
|
|
34
|
-
const unmount = () => render(null, container);
|
|
35
|
-
const msgOption = (typeof options === 'string') ? { message: options, unmount } : { ...options, unmount };
|
|
36
|
-
const instance = h(
|
|
37
|
-
componentObj,
|
|
38
|
-
msgOption,
|
|
39
|
-
);
|
|
40
|
-
render(instance, container);
|
|
41
|
-
wrapper.appendChild(instance.el);
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
notification.install = (app) => {
|
|
45
|
-
const global = app.config.globalProperties;
|
|
46
|
-
global.$notify = notification;
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
export default notification;
|
|
1
|
+
import { defineComponent, h, render } from 'vue';
|
|
2
|
+
import Component from './Notification.vue';
|
|
3
|
+
|
|
4
|
+
const componentObj = defineComponent(Component);
|
|
5
|
+
|
|
6
|
+
const rootId = 'ev-notification-modal';
|
|
7
|
+
const root = document.createElement('div');
|
|
8
|
+
root.id = rootId;
|
|
9
|
+
|
|
10
|
+
const positionList = ['top-left', 'top-right', 'bottom-left', 'bottom-right'];
|
|
11
|
+
|
|
12
|
+
const notification = (options = {}) => {
|
|
13
|
+
const position = options.position || 'top-right';
|
|
14
|
+
if (!positionList.includes(position)) {
|
|
15
|
+
console.warn('[EVUI][Notification] The position value is incorrectly entered.');
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const hasRoot = document.getElementById(rootId);
|
|
20
|
+
if (!hasRoot) {
|
|
21
|
+
document.body.appendChild(root);
|
|
22
|
+
}
|
|
23
|
+
let wrapper = root.getElementsByClassName(`modal-${position}`);
|
|
24
|
+
const hasElem = wrapper.length;
|
|
25
|
+
if (hasElem) {
|
|
26
|
+
wrapper = wrapper[0];
|
|
27
|
+
} else {
|
|
28
|
+
wrapper = document.createElement('div');
|
|
29
|
+
wrapper.classList.add(`modal-${position}`);
|
|
30
|
+
root.appendChild(wrapper);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const container = document.createElement('div');
|
|
34
|
+
const unmount = () => render(null, container);
|
|
35
|
+
const msgOption = (typeof options === 'string') ? { message: options, unmount } : { ...options, unmount };
|
|
36
|
+
const instance = h(
|
|
37
|
+
componentObj,
|
|
38
|
+
msgOption,
|
|
39
|
+
);
|
|
40
|
+
render(instance, container);
|
|
41
|
+
wrapper.appendChild(instance.el);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
notification.install = (app) => {
|
|
45
|
+
const global = app.config.globalProperties;
|
|
46
|
+
global.$notify = notification;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export default notification;
|
|
@@ -1,271 +1,271 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<nav class="pagination">
|
|
3
|
-
<!-- Page Info -->
|
|
4
|
-
<small v-if="showPageInfo" class="pagination-info">
|
|
5
|
-
<template v-if="perPage === 1">
|
|
6
|
-
{{ firstData }} / {{ total }}
|
|
7
|
-
</template>
|
|
8
|
-
<template v-else>
|
|
9
|
-
{{ firstData }} - {{ Math.min(current * perPage, total) }}
|
|
10
|
-
/ {{ total }}
|
|
11
|
-
</template>
|
|
12
|
-
</small>
|
|
13
|
-
<ul class="pagination-list" :style="listClasses">
|
|
14
|
-
<!-- Previous -->
|
|
15
|
-
<li :class="{'is-disabled': !hasPrev}">
|
|
16
|
-
<page-button
|
|
17
|
-
class="pagination-previous"
|
|
18
|
-
:disabled="!hasPrev"
|
|
19
|
-
:page="getPage(current - 1)"
|
|
20
|
-
>
|
|
21
|
-
<ev-icon icon="ev-icon-s-arrow-left"/>
|
|
22
|
-
</page-button>
|
|
23
|
-
</li>
|
|
24
|
-
|
|
25
|
-
<!--Pages-->
|
|
26
|
-
<template v-for="(page, i) in pagesInRange" :key="i">
|
|
27
|
-
<li v-if="page.number === -1" class="pagination-ellipsis">
|
|
28
|
-
<span>…</span>
|
|
29
|
-
</li>
|
|
30
|
-
<li v-else :class="{ 'is-current': page.isCurrent, 'is-page': true }" @click="page.click">
|
|
31
|
-
<page-button :page="page"/>
|
|
32
|
-
</li>
|
|
33
|
-
</template>
|
|
34
|
-
|
|
35
|
-
<!-- Next -->
|
|
36
|
-
<li :class="{'is-disabled': !hasNext}">
|
|
37
|
-
<page-button
|
|
38
|
-
class="pagination-next"
|
|
39
|
-
:disabled="!hasNext"
|
|
40
|
-
:page="getPage(current + 1)"
|
|
41
|
-
>
|
|
42
|
-
<ev-icon icon="ev-icon-s-arrow-right"/>
|
|
43
|
-
</page-button>
|
|
44
|
-
</li>
|
|
45
|
-
</ul>
|
|
46
|
-
</nav>
|
|
47
|
-
</template>
|
|
48
|
-
|
|
49
|
-
<script>
|
|
50
|
-
import { computed, nextTick, watch } from 'vue';
|
|
51
|
-
import EvIcon from '@/components/icon/Icon';
|
|
52
|
-
import pageButton from './pageButton';
|
|
53
|
-
|
|
54
|
-
export default {
|
|
55
|
-
name: 'EvPagination',
|
|
56
|
-
components: {
|
|
57
|
-
EvIcon,
|
|
58
|
-
pageButton,
|
|
59
|
-
},
|
|
60
|
-
props: {
|
|
61
|
-
total: {
|
|
62
|
-
type: [Number, String],
|
|
63
|
-
default: 0,
|
|
64
|
-
},
|
|
65
|
-
visiblePage: {
|
|
66
|
-
type: [Number, String],
|
|
67
|
-
default: 8,
|
|
68
|
-
},
|
|
69
|
-
perPage: {
|
|
70
|
-
type: [Number, String],
|
|
71
|
-
default: 20,
|
|
72
|
-
},
|
|
73
|
-
modelValue: {
|
|
74
|
-
type: [Number, String],
|
|
75
|
-
default: 1,
|
|
76
|
-
},
|
|
77
|
-
showPageInfo: {
|
|
78
|
-
type: Boolean,
|
|
79
|
-
default: false,
|
|
80
|
-
},
|
|
81
|
-
order: {
|
|
82
|
-
type: String,
|
|
83
|
-
default: 'left',
|
|
84
|
-
validator: val => ['left', 'right', 'center'].includes(val),
|
|
85
|
-
},
|
|
86
|
-
},
|
|
87
|
-
emits: {
|
|
88
|
-
'update:modelValue': null,
|
|
89
|
-
change: null,
|
|
90
|
-
},
|
|
91
|
-
setup(props, { emit }) {
|
|
92
|
-
const visiblePage = computed(() => (props.visiblePage > 7 ? props.visiblePage : 7));
|
|
93
|
-
const current = computed(() => props.modelValue);
|
|
94
|
-
const pageCount = computed(() => (props.total === 0
|
|
95
|
-
? 1 : Math.ceil(props.total / props.perPage)));
|
|
96
|
-
const hasPrev = computed(() => current.value > 1);
|
|
97
|
-
const hasNext = computed(() => current.value < pageCount.value);
|
|
98
|
-
const firstData = computed(() => {
|
|
99
|
-
const item = current.value * props.perPage - props.perPage + 1;
|
|
100
|
-
return item >= 0 ? item : 0;
|
|
101
|
-
});
|
|
102
|
-
const changePage = (num, event) => {
|
|
103
|
-
if (current.value === num || num < 1 || num > pageCount.value) return;
|
|
104
|
-
emit('update:modelValue', num);
|
|
105
|
-
emit('change', num);
|
|
106
|
-
if (event && event.target) {
|
|
107
|
-
nextTick(() => event.target.focus());
|
|
108
|
-
}
|
|
109
|
-
};
|
|
110
|
-
const getPage = (num, options = {}) => ({
|
|
111
|
-
number: num,
|
|
112
|
-
isCurrent: current.value === num,
|
|
113
|
-
click: event => changePage(num, event),
|
|
114
|
-
input: (event, inputNum) => changePage(+inputNum, event),
|
|
115
|
-
disabled: options.disabled || false,
|
|
116
|
-
class: options.class || '',
|
|
117
|
-
});
|
|
118
|
-
const onRange = (from, to) => {
|
|
119
|
-
const range = [];
|
|
120
|
-
const f = from > 0 ? from : 1;
|
|
121
|
-
|
|
122
|
-
for (let i = f; i <= to; i++) {
|
|
123
|
-
range.push(getPage(i));
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
return range;
|
|
127
|
-
};
|
|
128
|
-
const pagesInRange = computed(() => {
|
|
129
|
-
const totalVisible = parseInt(visiblePage.value, 10);
|
|
130
|
-
|
|
131
|
-
if (totalVisible === 0) {
|
|
132
|
-
return [];
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
const maxLength = Math.min(
|
|
136
|
-
Math.max(0, totalVisible) || pageCount.value,
|
|
137
|
-
pageCount.value,
|
|
138
|
-
);
|
|
139
|
-
if (pageCount.value <= maxLength) {
|
|
140
|
-
return onRange(1, pageCount.value);
|
|
141
|
-
}
|
|
142
|
-
const even = maxLength % 2 === 0 ? 1 : 0;
|
|
143
|
-
const left = Math.floor(maxLength / 2);
|
|
144
|
-
const right = pageCount.value - left + 1 + even;
|
|
145
|
-
|
|
146
|
-
if (current.value > left && current.value < right) {
|
|
147
|
-
const firstItem = 1;
|
|
148
|
-
const lastItem = pageCount.value;
|
|
149
|
-
const start = current.value - left + 2;
|
|
150
|
-
const end = current.value + left - 2 - even;
|
|
151
|
-
const secondItem = start - 1 === firstItem + 1 ? 2 : -1;
|
|
152
|
-
const beforeLastItem = end + 1 === lastItem - 1 ? end + 1 : -1;
|
|
153
|
-
return [
|
|
154
|
-
getPage(1),
|
|
155
|
-
getPage(secondItem),
|
|
156
|
-
...onRange(start, end),
|
|
157
|
-
getPage(beforeLastItem),
|
|
158
|
-
getPage(pageCount.value),
|
|
159
|
-
];
|
|
160
|
-
} else if (current.value === left) {
|
|
161
|
-
const end = current.value + left - 1 - even;
|
|
162
|
-
return [...onRange(1, end), getPage(-1), getPage(pageCount.value)];
|
|
163
|
-
} else if (current.value === right) {
|
|
164
|
-
const start = current.value - left + 1;
|
|
165
|
-
return [getPage(1), getPage(-1), ...onRange(start, pageCount.value)];
|
|
166
|
-
}
|
|
167
|
-
return [
|
|
168
|
-
...onRange(1, left),
|
|
169
|
-
getPage(-1),
|
|
170
|
-
...onRange(right, pageCount.value),
|
|
171
|
-
];
|
|
172
|
-
});
|
|
173
|
-
const listClasses = computed(() => ({ 'justify-content': props.order, flex: '3 1 0%' }));
|
|
174
|
-
|
|
175
|
-
watch(
|
|
176
|
-
() => pageCount.value,
|
|
177
|
-
(value) => {
|
|
178
|
-
if (current.value > value) {
|
|
179
|
-
changePage(value);
|
|
180
|
-
}
|
|
181
|
-
},
|
|
182
|
-
);
|
|
183
|
-
watch(
|
|
184
|
-
() => current.value,
|
|
185
|
-
(after, before) => {
|
|
186
|
-
if (pageCount.value < after) {
|
|
187
|
-
changePage(before);
|
|
188
|
-
}
|
|
189
|
-
},
|
|
190
|
-
);
|
|
191
|
-
return {
|
|
192
|
-
pageCount,
|
|
193
|
-
pagesInRange,
|
|
194
|
-
hasPrev,
|
|
195
|
-
hasNext,
|
|
196
|
-
listClasses,
|
|
197
|
-
firstData,
|
|
198
|
-
current,
|
|
199
|
-
changePage,
|
|
200
|
-
getPage,
|
|
201
|
-
};
|
|
202
|
-
},
|
|
203
|
-
};
|
|
204
|
-
</script>
|
|
205
|
-
|
|
206
|
-
<style lang="scss">
|
|
207
|
-
.pagination {
|
|
208
|
-
display: flex;
|
|
209
|
-
.pagination-next,
|
|
210
|
-
.pagination-previous {
|
|
211
|
-
margin: 0;
|
|
212
|
-
padding-left: 10px;
|
|
213
|
-
padding-right: 10px;
|
|
214
|
-
background: center center no-repeat;
|
|
215
|
-
background-size: 16px;
|
|
216
|
-
cursor: pointer;
|
|
217
|
-
&:hover {
|
|
218
|
-
color: #1A6AFE;
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
&-info {
|
|
222
|
-
order: 2;
|
|
223
|
-
line-height: 32px;
|
|
224
|
-
}
|
|
225
|
-
.is-current {
|
|
226
|
-
pointer-events: none;
|
|
227
|
-
cursor: not-allowed;
|
|
228
|
-
background-color: #1A6AFE;
|
|
229
|
-
color: #FFFFFF;
|
|
230
|
-
border-radius: 4px;
|
|
231
|
-
}
|
|
232
|
-
.is-page {
|
|
233
|
-
&:hover {
|
|
234
|
-
color: #1A6AFE;
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
.pagination-ellipsis {
|
|
238
|
-
pointer-events: none;
|
|
239
|
-
cursor: not-allowed;
|
|
240
|
-
}
|
|
241
|
-
.is-disabled {
|
|
242
|
-
pointer-events: none;
|
|
243
|
-
cursor: not-allowed;
|
|
244
|
-
opacity: 0.5;
|
|
245
|
-
color: #C0C4CC;
|
|
246
|
-
}
|
|
247
|
-
&-list {
|
|
248
|
-
display: flex;
|
|
249
|
-
user-select: none;
|
|
250
|
-
list-style: none;
|
|
251
|
-
font-size: 0;
|
|
252
|
-
padding: 0;
|
|
253
|
-
margin: 0;
|
|
254
|
-
align-items: center;
|
|
255
|
-
flex-wrap: wrap;
|
|
256
|
-
li {
|
|
257
|
-
display: flex;
|
|
258
|
-
height: 32px;
|
|
259
|
-
padding: 0 4px;
|
|
260
|
-
justify-content: center;
|
|
261
|
-
align-items: center;
|
|
262
|
-
font-size: 14px;
|
|
263
|
-
min-width: 32px;
|
|
264
|
-
line-height: 32px;
|
|
265
|
-
cursor: pointer;
|
|
266
|
-
box-sizing: border-box;
|
|
267
|
-
text-align: center;
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<nav class="pagination">
|
|
3
|
+
<!-- Page Info -->
|
|
4
|
+
<small v-if="showPageInfo" class="pagination-info">
|
|
5
|
+
<template v-if="perPage === 1">
|
|
6
|
+
{{ firstData }} / {{ total }}
|
|
7
|
+
</template>
|
|
8
|
+
<template v-else>
|
|
9
|
+
{{ firstData }} - {{ Math.min(current * perPage, total) }}
|
|
10
|
+
/ {{ total }}
|
|
11
|
+
</template>
|
|
12
|
+
</small>
|
|
13
|
+
<ul class="pagination-list" :style="listClasses">
|
|
14
|
+
<!-- Previous -->
|
|
15
|
+
<li :class="{'is-disabled': !hasPrev}">
|
|
16
|
+
<page-button
|
|
17
|
+
class="pagination-previous"
|
|
18
|
+
:disabled="!hasPrev"
|
|
19
|
+
:page="getPage(current - 1)"
|
|
20
|
+
>
|
|
21
|
+
<ev-icon icon="ev-icon-s-arrow-left"/>
|
|
22
|
+
</page-button>
|
|
23
|
+
</li>
|
|
24
|
+
|
|
25
|
+
<!--Pages-->
|
|
26
|
+
<template v-for="(page, i) in pagesInRange" :key="i">
|
|
27
|
+
<li v-if="page.number === -1" class="pagination-ellipsis">
|
|
28
|
+
<span>…</span>
|
|
29
|
+
</li>
|
|
30
|
+
<li v-else :class="{ 'is-current': page.isCurrent, 'is-page': true }" @click="page.click">
|
|
31
|
+
<page-button :page="page"/>
|
|
32
|
+
</li>
|
|
33
|
+
</template>
|
|
34
|
+
|
|
35
|
+
<!-- Next -->
|
|
36
|
+
<li :class="{'is-disabled': !hasNext}">
|
|
37
|
+
<page-button
|
|
38
|
+
class="pagination-next"
|
|
39
|
+
:disabled="!hasNext"
|
|
40
|
+
:page="getPage(current + 1)"
|
|
41
|
+
>
|
|
42
|
+
<ev-icon icon="ev-icon-s-arrow-right"/>
|
|
43
|
+
</page-button>
|
|
44
|
+
</li>
|
|
45
|
+
</ul>
|
|
46
|
+
</nav>
|
|
47
|
+
</template>
|
|
48
|
+
|
|
49
|
+
<script>
|
|
50
|
+
import { computed, nextTick, watch } from 'vue';
|
|
51
|
+
import EvIcon from '@/components/icon/Icon';
|
|
52
|
+
import pageButton from './pageButton';
|
|
53
|
+
|
|
54
|
+
export default {
|
|
55
|
+
name: 'EvPagination',
|
|
56
|
+
components: {
|
|
57
|
+
EvIcon,
|
|
58
|
+
pageButton,
|
|
59
|
+
},
|
|
60
|
+
props: {
|
|
61
|
+
total: {
|
|
62
|
+
type: [Number, String],
|
|
63
|
+
default: 0,
|
|
64
|
+
},
|
|
65
|
+
visiblePage: {
|
|
66
|
+
type: [Number, String],
|
|
67
|
+
default: 8,
|
|
68
|
+
},
|
|
69
|
+
perPage: {
|
|
70
|
+
type: [Number, String],
|
|
71
|
+
default: 20,
|
|
72
|
+
},
|
|
73
|
+
modelValue: {
|
|
74
|
+
type: [Number, String],
|
|
75
|
+
default: 1,
|
|
76
|
+
},
|
|
77
|
+
showPageInfo: {
|
|
78
|
+
type: Boolean,
|
|
79
|
+
default: false,
|
|
80
|
+
},
|
|
81
|
+
order: {
|
|
82
|
+
type: String,
|
|
83
|
+
default: 'left',
|
|
84
|
+
validator: val => ['left', 'right', 'center'].includes(val),
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
emits: {
|
|
88
|
+
'update:modelValue': null,
|
|
89
|
+
change: null,
|
|
90
|
+
},
|
|
91
|
+
setup(props, { emit }) {
|
|
92
|
+
const visiblePage = computed(() => (props.visiblePage > 7 ? props.visiblePage : 7));
|
|
93
|
+
const current = computed(() => props.modelValue);
|
|
94
|
+
const pageCount = computed(() => (props.total === 0
|
|
95
|
+
? 1 : Math.ceil(props.total / props.perPage)));
|
|
96
|
+
const hasPrev = computed(() => current.value > 1);
|
|
97
|
+
const hasNext = computed(() => current.value < pageCount.value);
|
|
98
|
+
const firstData = computed(() => {
|
|
99
|
+
const item = current.value * props.perPage - props.perPage + 1;
|
|
100
|
+
return item >= 0 ? item : 0;
|
|
101
|
+
});
|
|
102
|
+
const changePage = (num, event) => {
|
|
103
|
+
if (current.value === num || num < 1 || num > pageCount.value) return;
|
|
104
|
+
emit('update:modelValue', num);
|
|
105
|
+
emit('change', num);
|
|
106
|
+
if (event && event.target) {
|
|
107
|
+
nextTick(() => event.target.focus());
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
const getPage = (num, options = {}) => ({
|
|
111
|
+
number: num,
|
|
112
|
+
isCurrent: current.value === num,
|
|
113
|
+
click: event => changePage(num, event),
|
|
114
|
+
input: (event, inputNum) => changePage(+inputNum, event),
|
|
115
|
+
disabled: options.disabled || false,
|
|
116
|
+
class: options.class || '',
|
|
117
|
+
});
|
|
118
|
+
const onRange = (from, to) => {
|
|
119
|
+
const range = [];
|
|
120
|
+
const f = from > 0 ? from : 1;
|
|
121
|
+
|
|
122
|
+
for (let i = f; i <= to; i++) {
|
|
123
|
+
range.push(getPage(i));
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return range;
|
|
127
|
+
};
|
|
128
|
+
const pagesInRange = computed(() => {
|
|
129
|
+
const totalVisible = parseInt(visiblePage.value, 10);
|
|
130
|
+
|
|
131
|
+
if (totalVisible === 0) {
|
|
132
|
+
return [];
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const maxLength = Math.min(
|
|
136
|
+
Math.max(0, totalVisible) || pageCount.value,
|
|
137
|
+
pageCount.value,
|
|
138
|
+
);
|
|
139
|
+
if (pageCount.value <= maxLength) {
|
|
140
|
+
return onRange(1, pageCount.value);
|
|
141
|
+
}
|
|
142
|
+
const even = maxLength % 2 === 0 ? 1 : 0;
|
|
143
|
+
const left = Math.floor(maxLength / 2);
|
|
144
|
+
const right = pageCount.value - left + 1 + even;
|
|
145
|
+
|
|
146
|
+
if (current.value > left && current.value < right) {
|
|
147
|
+
const firstItem = 1;
|
|
148
|
+
const lastItem = pageCount.value;
|
|
149
|
+
const start = current.value - left + 2;
|
|
150
|
+
const end = current.value + left - 2 - even;
|
|
151
|
+
const secondItem = start - 1 === firstItem + 1 ? 2 : -1;
|
|
152
|
+
const beforeLastItem = end + 1 === lastItem - 1 ? end + 1 : -1;
|
|
153
|
+
return [
|
|
154
|
+
getPage(1),
|
|
155
|
+
getPage(secondItem),
|
|
156
|
+
...onRange(start, end),
|
|
157
|
+
getPage(beforeLastItem),
|
|
158
|
+
getPage(pageCount.value),
|
|
159
|
+
];
|
|
160
|
+
} else if (current.value === left) {
|
|
161
|
+
const end = current.value + left - 1 - even;
|
|
162
|
+
return [...onRange(1, end), getPage(-1), getPage(pageCount.value)];
|
|
163
|
+
} else if (current.value === right) {
|
|
164
|
+
const start = current.value - left + 1;
|
|
165
|
+
return [getPage(1), getPage(-1), ...onRange(start, pageCount.value)];
|
|
166
|
+
}
|
|
167
|
+
return [
|
|
168
|
+
...onRange(1, left),
|
|
169
|
+
getPage(-1),
|
|
170
|
+
...onRange(right, pageCount.value),
|
|
171
|
+
];
|
|
172
|
+
});
|
|
173
|
+
const listClasses = computed(() => ({ 'justify-content': props.order, flex: '3 1 0%' }));
|
|
174
|
+
|
|
175
|
+
watch(
|
|
176
|
+
() => pageCount.value,
|
|
177
|
+
(value) => {
|
|
178
|
+
if (current.value > value) {
|
|
179
|
+
changePage(value);
|
|
180
|
+
}
|
|
181
|
+
},
|
|
182
|
+
);
|
|
183
|
+
watch(
|
|
184
|
+
() => current.value,
|
|
185
|
+
(after, before) => {
|
|
186
|
+
if (pageCount.value < after) {
|
|
187
|
+
changePage(before);
|
|
188
|
+
}
|
|
189
|
+
},
|
|
190
|
+
);
|
|
191
|
+
return {
|
|
192
|
+
pageCount,
|
|
193
|
+
pagesInRange,
|
|
194
|
+
hasPrev,
|
|
195
|
+
hasNext,
|
|
196
|
+
listClasses,
|
|
197
|
+
firstData,
|
|
198
|
+
current,
|
|
199
|
+
changePage,
|
|
200
|
+
getPage,
|
|
201
|
+
};
|
|
202
|
+
},
|
|
203
|
+
};
|
|
204
|
+
</script>
|
|
205
|
+
|
|
206
|
+
<style lang="scss">
|
|
207
|
+
.pagination {
|
|
208
|
+
display: flex;
|
|
209
|
+
.pagination-next,
|
|
210
|
+
.pagination-previous {
|
|
211
|
+
margin: 0;
|
|
212
|
+
padding-left: 10px;
|
|
213
|
+
padding-right: 10px;
|
|
214
|
+
background: center center no-repeat;
|
|
215
|
+
background-size: 16px;
|
|
216
|
+
cursor: pointer;
|
|
217
|
+
&:hover {
|
|
218
|
+
color: #1A6AFE;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
&-info {
|
|
222
|
+
order: 2;
|
|
223
|
+
line-height: 32px;
|
|
224
|
+
}
|
|
225
|
+
.is-current {
|
|
226
|
+
pointer-events: none;
|
|
227
|
+
cursor: not-allowed;
|
|
228
|
+
background-color: #1A6AFE;
|
|
229
|
+
color: #FFFFFF;
|
|
230
|
+
border-radius: 4px;
|
|
231
|
+
}
|
|
232
|
+
.is-page {
|
|
233
|
+
&:hover {
|
|
234
|
+
color: #1A6AFE;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
.pagination-ellipsis {
|
|
238
|
+
pointer-events: none;
|
|
239
|
+
cursor: not-allowed;
|
|
240
|
+
}
|
|
241
|
+
.is-disabled {
|
|
242
|
+
pointer-events: none;
|
|
243
|
+
cursor: not-allowed;
|
|
244
|
+
opacity: 0.5;
|
|
245
|
+
color: #C0C4CC;
|
|
246
|
+
}
|
|
247
|
+
&-list {
|
|
248
|
+
display: flex;
|
|
249
|
+
user-select: none;
|
|
250
|
+
list-style: none;
|
|
251
|
+
font-size: 0;
|
|
252
|
+
padding: 0;
|
|
253
|
+
margin: 0;
|
|
254
|
+
align-items: center;
|
|
255
|
+
flex-wrap: wrap;
|
|
256
|
+
li {
|
|
257
|
+
display: flex;
|
|
258
|
+
height: 32px;
|
|
259
|
+
padding: 0 4px;
|
|
260
|
+
justify-content: center;
|
|
261
|
+
align-items: center;
|
|
262
|
+
font-size: 14px;
|
|
263
|
+
min-width: 32px;
|
|
264
|
+
line-height: 32px;
|
|
265
|
+
cursor: pointer;
|
|
266
|
+
box-sizing: border-box;
|
|
267
|
+
text-align: center;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
</style>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import EvPagination from './Pagination';
|
|
2
|
-
|
|
3
|
-
EvPagination.install = (app) => {
|
|
4
|
-
app.component(EvPagination.name, EvPagination);
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
export default EvPagination;
|
|
1
|
+
import EvPagination from './Pagination';
|
|
2
|
+
|
|
3
|
+
EvPagination.install = (app) => {
|
|
4
|
+
app.component(EvPagination.name, EvPagination);
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
export default EvPagination;
|