@neatui/nuxt 0.1.0

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.
Files changed (102) hide show
  1. package/README.md +3 -0
  2. package/package.json +43 -0
  3. package/rollup.config.js +35 -0
  4. package/src/components/basic/IDraggable.vue +84 -0
  5. package/src/components/basic/IDraggable@b.vue +80 -0
  6. package/src/components/basic/IFollowView.vue +211 -0
  7. package/src/components/basic/IPickerView.vue +351 -0
  8. package/src/components/basic/IRouterView.vue +360 -0
  9. package/src/components/basic/IScrollView.vue +127 -0
  10. package/src/components/basic/Icon.vue +54 -0
  11. package/src/components/basic/LayerView/Layer.vue +339 -0
  12. package/src/components/basic/LayerView/index.ts +5 -0
  13. package/src/components/basic/index.ts +7 -0
  14. package/src/components/display/Avatar.vue +1 -0
  15. package/src/components/display/Badge.vue +1 -0
  16. package/src/components/display/Calendar.vue +245 -0
  17. package/src/components/display/CalendarReg.vue +245 -0
  18. package/src/components/display/Card.vue +1 -0
  19. package/src/components/display/Carousel.vue +1 -0
  20. package/src/components/display/ChartView.vue +123 -0
  21. package/src/components/display/Collapse.vue +1 -0
  22. package/src/components/display/Desriptions.vue +1 -0
  23. package/src/components/display/Empty.vue +1 -0
  24. package/src/components/display/Image.vue +112 -0
  25. package/src/components/display/List.vue +1 -0
  26. package/src/components/display/PhotoEditor.vue +181 -0
  27. package/src/components/display/PhotoViewer.vue +50 -0
  28. package/src/components/display/Popover.vue +1 -0
  29. package/src/components/display/QRCode.vue +1 -0
  30. package/src/components/display/Segmented.vue +1 -0
  31. package/src/components/display/Statistic.vue +1 -0
  32. package/src/components/display/Table.vue +1 -0
  33. package/src/components/display/Tabs.vue +1 -0
  34. package/src/components/display/Tag.vue +1 -0
  35. package/src/components/display/Timeline.vue +1 -0
  36. package/src/components/display/Tooltip.vue +1 -0
  37. package/src/components/display/Tour.vue +1 -0
  38. package/src/components/display/Tree.vue +431 -0
  39. package/src/components/display/TreeView.vue +225 -0
  40. package/src/components/display/index.ts +8 -0
  41. package/src/components/form/Cascader.vue +435 -0
  42. package/src/components/form/DatePicker.vue +124 -0
  43. package/src/components/form/DateRangePicker@v2.vue.backup +224 -0
  44. package/src/components/form/DateRangePicker@v3.vue +116 -0
  45. package/src/components/form/DateRangeView@v3.vue +386 -0
  46. package/src/components/form/DateView.vue +229 -0
  47. package/src/components/form/DateView@v2.vue +386 -0
  48. package/src/components/form/DateView@v3.vue +471 -0
  49. package/src/components/form/EditUpload.vue +4 -0
  50. package/src/components/form/ImgUpload.vue +174 -0
  51. package/src/components/form/Input.vue.backup +230 -0
  52. package/src/components/form/Input@v3.vue +267 -0
  53. package/src/components/form/InputNumber.vue +200 -0
  54. package/src/components/form/InputRange.vue +235 -0
  55. package/src/components/form/MoreSelect.vue.backup +144 -0
  56. package/src/components/form/MoreSelect@v3.vue +195 -0
  57. package/src/components/form/MoreSelectList.vue +125 -0
  58. package/src/components/form/MoreSelectPanel@v3.vue +190 -0
  59. package/src/components/form/MoreSelectPicker.vue +124 -0
  60. package/src/components/form/MoreSelectTags.vue +124 -0
  61. package/src/components/form/PageMoreSelect.vue +187 -0
  62. package/src/components/form/PageSelect.vue +189 -0
  63. package/src/components/form/SearchMoreSelect.vue +173 -0
  64. package/src/components/form/SearchSelect.vue.backup +194 -0
  65. package/src/components/form/SearchSelect@v3.vue +202 -0
  66. package/src/components/form/Select@v3.vue +201 -0
  67. package/src/components/form/SelectList.vue +58 -0
  68. package/src/components/form/SelectPicker.vue +97 -0
  69. package/src/components/form/SelectTags.vue +52 -0
  70. package/src/components/form/SelectTree/SelectTree@v1.vue +227 -0
  71. package/src/components/form/Switch.vue +135 -0
  72. package/src/components/form/TextArea.vue +193 -0
  73. package/src/components/form/TimePicker.vue +11 -0
  74. package/src/components/form/TimeView.vue +244 -0
  75. package/src/components/form/Upload.vue +346 -0
  76. package/src/components/form/index.ts +82 -0
  77. package/src/components/loader/FormLoader/FormLoader@v2.vue +422 -0
  78. package/src/components/loader/FormLoader/FormLoader@v3.vue.backup +318 -0
  79. package/src/components/loader/FormLoader/index.ts +2 -0
  80. package/src/components/loader/FormLoader@v1/FormLoader.vue +506 -0
  81. package/src/components/loader/FormLoader@v1/FormRender.vue +277 -0
  82. package/src/components/loader/LimitLoader/LimitLoader.vue.backup +131 -0
  83. package/src/components/loader/LimitLoader/LimitLoader@v2.vue.backup +174 -0
  84. package/src/components/loader/LimitLoader/LimitLoader@v3.vue +183 -0
  85. package/src/components/loader/LimitLoader/index.ts +2 -0
  86. package/src/components/loader/TableLoader/TableColView.vue +115 -0
  87. package/src/components/loader/TableLoader/TableLoader.vue +360 -0
  88. package/src/components/loader/TableLoader/index.ts +2 -0
  89. package/src/components/loader/ViewLoader/ViewLoader@v1.vue +256 -0
  90. package/src/components/loader/ViewLoader/index.ts +2 -0
  91. package/src/components/loader/index.ts +5 -0
  92. package/src/components/tools/FormDraftsView.vue +330 -0
  93. package/src/components/tools/FormVerifyView.vue +206 -0
  94. package/src/components/tools/MoreTools.vue +74 -0
  95. package/src/components/tools/MoreTools@v2.vue +74 -0
  96. package/src/components/tools/Pagination@a.vue +222 -0
  97. package/src/components/tools/Pagination@b.vue +221 -0
  98. package/src/components/tools/index.ts +5 -0
  99. package/src/index.ts +9 -0
  100. package/src/shims-vue.d.ts +5 -0
  101. package/src/store/myui.ts +50 -0
  102. package/tsconfig.json +24 -0
@@ -0,0 +1,206 @@
1
+ <template>
2
+ <div ui-tips="@a co:well">
3
+ <button :ui-btn="`@a s none ${verify?.length ? '' : ':square'}`" :class="`${verify?.length ? 'co-risk' : 'co-well'}`" @click="state.show = state.show ? 0 : 1">
4
+ <i v-if="verify?.length" class="icon icon-verify-no co-risk"></i>
5
+ <i v-else class="icon icon-verify-ok co-well"></i>
6
+ <span v-if="verify?.length">{{ verify?.length }}</span>
7
+ </button>
8
+ <div ui-tips-box="tl" :ux-view="state.show" class="w-xl mob:w-ll n-ms">
9
+ <div class="fekit-layer-close" ui-flex="row cm" @click="state.show = 0"><i class="icon icon-close fs-xs"></i></div>
10
+ <h4>温馨提示</h4>
11
+ <p v-if="verify?.length" class="ny-sm">本条记录疑似有{{ verify?.length }}个错误,您再检查一遍吧~</p>
12
+ <p v-else class="nb-sm">好棒哦,没有发现任何错误!</p>
13
+ <p v-if="verify.length">
14
+ <span v-if="state.detail" class="ux-click co-link" @click="state.detail = 0">隐藏详情<i class="icon icon-dropdown r180"></i></span>
15
+ <span v-else class="ux-click co-link" @click="state.detail = 1">显示详情<i class="icon icon-dropdown"></i></span>
16
+ </p>
17
+ <ul v-if="state.detail" class="co-read" ui-scroll=":y s" style="max-height: 8em">
18
+ <li v-for="(err, idx) in verify" :key="idx">
19
+ <i v-if="err.type === 'warn'" class="icon icon-warn co-warn"></i>
20
+ <i v-else class="icon icon-error co-risk"></i>
21
+ <span class="nl-ss">
22
+ <span class="ux-hover ny-xs nx-ss r-sm" @click="fScrollToField(err.path)">[{{ err.label }}]</span>
23
+ <span class="ml-sm">{{ err.msg || '有一个错误' }}</span>
24
+ </span>
25
+ </li>
26
+ </ul>
27
+ </div>
28
+ </div>
29
+ </template>
30
+ <script setup lang="ts">
31
+ import { computed, reactive, toRefs, watch, onMounted, ref, onUnmounted } from 'vue';
32
+ import { useRoute } from 'vue-router';
33
+ import scrollTo from '@fekit/scrollto';
34
+ import { deepcopy, isArray, isObject, isFunction } from '@fekit/utils';
35
+
36
+ const route: any = useRoute();
37
+
38
+ const props: any = defineProps({
39
+ area: {
40
+ type: HTMLElement,
41
+ default: document.body
42
+ },
43
+ data: {
44
+ type: Object,
45
+ required: true,
46
+ default: () => ({})
47
+ },
48
+ form: {
49
+ type: Object,
50
+ default: () => ({})
51
+ }
52
+ });
53
+
54
+ const state: any = reactive({
55
+ __update: true,
56
+ mode: route.query.mode,
57
+ show: 0,
58
+ detail: 1,
59
+ // 数据校验
60
+ verify: computed(() => {
61
+ const error: any = [{ __update: state.__update }];
62
+ const edit = props.data || {};
63
+ const form = props.form || {};
64
+ // 核心
65
+ const core = (data: any = {}, form: any = {}, path: any = '') => {
66
+ Object.keys(data).forEach((item: any) => {
67
+ // 是否有表单结构
68
+ if (form[item]) {
69
+ // 是否末端
70
+ if (form[item]?.child && (isArray(data[item]) || isObject(data[item]))) {
71
+ if (isArray(data[item])) {
72
+ data[item].forEach((sub: any, idx: number) => {
73
+ core(sub, form[item].child, path + '-' + form[item].field + '-' + idx);
74
+ });
75
+ } else {
76
+ (Object.values(data[item]) || []).forEach((sub: any, idx: number) => {
77
+ core(sub, form[item].child, path + '-' + form[item].field + '-' + idx);
78
+ });
79
+ }
80
+ } else {
81
+ const value = data[item];
82
+ const { label = '', field = '', rules = [], clear = false } = form[item] || {};
83
+ if (isFunction(clear) ? !clear(data) : !clear) {
84
+ const _path = path + '-' + field;
85
+ rules?.forEach((rule: any = {}) => {
86
+ const { type = '', msg = '', required = null, validator = null } = rule;
87
+ if (required) {
88
+ if (isArray(value)) {
89
+ if (!value.length) {
90
+ error.push({ field, label, type, msg, path: _path });
91
+ }
92
+ } else {
93
+ if (!value) {
94
+ error.push({ field, label, type, msg, path: _path });
95
+ }
96
+ }
97
+ }
98
+ const _validator = isFunction(validator) ? validator(deepcopy(props.data)) : null;
99
+ if (value && _validator && !_validator(value)) {
100
+ error.push({ field, label, type, msg, path: _path });
101
+ }
102
+ });
103
+ }
104
+ }
105
+ }
106
+ });
107
+ };
108
+ core(edit, form, '#form-field');
109
+ error.shift();
110
+ return error;
111
+ })
112
+ });
113
+ const { verify = [] }: any = toRefs(state);
114
+
115
+ // 为了在退出编辑的时候平滑过滤
116
+ watch(
117
+ () => route.query.mode,
118
+ (mode) => {
119
+ if (mode) {
120
+ state.mode = mode;
121
+ } else {
122
+ setTimeout(() => {
123
+ state.mode = '';
124
+ state.show = 0;
125
+ }, 300);
126
+ }
127
+ }
128
+ );
129
+
130
+ const fScrollToField = (path: any) => {
131
+ const dom = document.querySelector(path);
132
+ if (dom) {
133
+ scrollTo({
134
+ el: props.area,
135
+ to: {
136
+ y: dom
137
+ },
138
+ offset: { y: -36 },
139
+ then() {
140
+ const input = dom.querySelector('input');
141
+ if (input) {
142
+ input?.focus();
143
+ }
144
+ }
145
+ });
146
+ }
147
+ };
148
+
149
+ // 初始化时进入页面时自动弹出
150
+ const timer1: any = ref(null);
151
+ onMounted(() => {
152
+ timer1.value = setTimeout(() => {
153
+ if (state.verify.length) {
154
+ state.show = 1;
155
+ }
156
+ }, 1000);
157
+ });
158
+ onUnmounted(() => {
159
+ clearTimeout(timer1.value);
160
+ });
161
+
162
+ const timer2: any = ref(null);
163
+ watch(
164
+ () => state.verify,
165
+ () => {
166
+ clearTimeout(timer2.value);
167
+ if (state.show && !state.verify.length) {
168
+ timer2.value = setTimeout(() => {
169
+ state.show = 0;
170
+ }, 1000);
171
+ }
172
+ }
173
+ );
174
+
175
+ // 初始化后进入页面时自动弹出
176
+ const timer3: any = ref(null);
177
+ watch(
178
+ () => route.query.mode,
179
+ (mode: any) => {
180
+ clearTimeout(timer3.value);
181
+ if (mode === 'edit') {
182
+ timer3.value = setTimeout(() => {
183
+ if (state.verify.length) {
184
+ state.show = 1;
185
+ }
186
+ }, 1000);
187
+ } else {
188
+ if (state.show) {
189
+ setTimeout(() => {
190
+ state.show = 0;
191
+ }, 300);
192
+ }
193
+ }
194
+ }
195
+ );
196
+
197
+ watch(
198
+ () => props.data,
199
+ () => {
200
+ state.__update = !state.__update;
201
+ },
202
+ {
203
+ deep: true
204
+ }
205
+ );
206
+ </script>
@@ -0,0 +1,74 @@
1
+ <template>
2
+ <div ui-tips="@a ux:hover">
3
+ <button :ui-btn="`@a none s :square`"><i class="icon icon-more"></i></button>
4
+ <div ui-tips-box="bl" class="n-sl">
5
+ <slot name="prefix"></slot>
6
+ <slot>
7
+ <div>
8
+ <h6 class="fs-xs o-mm nowrap">每页显示数量</h6>
9
+ <div ui-btns="@a line s :group :border">
10
+ <button @click="setLinkMode(0)"><code :class="`${state.tools.confs.linkMode === 0 ? 'co-main' : ''}`">跳转</code></button>
11
+ <button @click="setLinkMode(1)"><code :class="`${state.tools.confs.linkMode === 1 ? 'co-main' : ''}`">预览</code></button>
12
+ <button @click="setLinkMode(2)"><code :class="`${state.tools.confs.linkMode === 2 ? 'co-main' : ''}`">新窗口</code></button>
13
+ </div>
14
+ </div>
15
+ <div ui-line="@a" class="mt-sm mb-ss"></div>
16
+ <div>
17
+ <h6 class="fs-xs o-mm nowrap">每页显示数量</h6>
18
+ <div ui-btns="@a line s :group :border">
19
+ <button @click="setPageSize(10)"><code :class="`${state.tools.param.pageSize === 10 ? 'co-main' : ''}`">10</code></button>
20
+ <button @click="setPageSize(20)"><code :class="`${state.tools.param.pageSize === 20 ? 'co-main' : ''}`">20</code></button>
21
+ <button @click="setPageSize(50)"><code :class="`${state.tools.param.pageSize === 50 ? 'co-main' : ''}`">50</code></button>
22
+ <button @click="setPageSize(100)"><code :class="`${state.tools.param.pageSize === 100 ? 'co-main' : ''}`">100</code></button>
23
+ </div>
24
+ </div>
25
+ </slot>
26
+ <slot name="prefix"></slot>
27
+ </div>
28
+ </div>
29
+ </template>
30
+ <script setup lang="ts">
31
+ import { reactive, computed } from 'vue';
32
+ import { useRoute } from 'vue-router';
33
+ const emits = defineEmits(['update:confs', 'update:param']);
34
+ const props = defineProps({
35
+ confs: {
36
+ type: Object,
37
+ default: () => ({})
38
+ },
39
+ param: {
40
+ type: Object,
41
+ default: () => ({})
42
+ }
43
+ });
44
+
45
+ const route = useRoute();
46
+ const state: any = reactive({
47
+ name: computed(() => 'confs' + route.path?.replace(/\//g, '_')),
48
+ tools: {
49
+ confs: {},
50
+ param: {}
51
+ }
52
+ });
53
+
54
+ const init = () => {
55
+ const _cache = JSON.parse(localStorage.getItem(`${state.name}`) || '{}');
56
+ state.tools.confs = _cache.confs || JSON.parse(JSON.stringify(props.confs));
57
+ state.tools.param = _cache.param || JSON.parse(JSON.stringify(props.param));
58
+ emits('update:confs', state.tools.confs);
59
+ emits('update:param', state.tools.param);
60
+ };
61
+ init();
62
+
63
+ const setLinkMode = (linkMode: any) => {
64
+ state.tools.confs.linkMode = linkMode;
65
+ emits('update:confs', state.tools.confs);
66
+ localStorage.setItem(state.name, JSON.stringify(state.tools));
67
+ };
68
+
69
+ const setPageSize = (pageSize: any) => {
70
+ state.tools.param.pageSize = pageSize;
71
+ emits('update:param', state.tools.param);
72
+ localStorage.setItem(state.name, JSON.stringify(state.tools));
73
+ };
74
+ </script>
@@ -0,0 +1,74 @@
1
+ <template>
2
+ <div ui-tips="@a ux:hover">
3
+ <button :ui-btn="`@a none s :square`"><i class="icon icon-more"></i></button>
4
+ <div ui-tips-box="bl" class="n-sl">
5
+ <slot name="prefix"></slot>
6
+ <slot>
7
+ <div>
8
+ <h6 class="fs-xs o-mm nowrap">每页显示数量</h6>
9
+ <div ui-btns="@a line s :group :border">
10
+ <button @click="setLinkMode('default')"><code :class="`${state.tools.confs.linkMode === 'default' ? 'co-main' : ''}`">跳转</code></button>
11
+ <button @click="setLinkMode('preview')"><code :class="`${state.tools.confs.linkMode === 'preview' ? 'co-main' : ''}`">预览</code></button>
12
+ <button @click="setLinkMode('windows')"><code :class="`${state.tools.confs.linkMode === 'windows' ? 'co-main' : ''}`">新窗口</code></button>
13
+ </div>
14
+ </div>
15
+ <div ui-line="@a" class="mt-sm mb-ss"></div>
16
+ <div>
17
+ <h6 class="fs-xs o-mm nowrap">每页显示数量</h6>
18
+ <div ui-btns="@a line s :group :border">
19
+ <button @click="setPageSize(10)"><code :class="`${state.tools.param.pageSize === 10 ? 'co-main' : ''}`">10</code></button>
20
+ <button @click="setPageSize(20)"><code :class="`${state.tools.param.pageSize === 20 ? 'co-main' : ''}`">20</code></button>
21
+ <button @click="setPageSize(50)"><code :class="`${state.tools.param.pageSize === 50 ? 'co-main' : ''}`">50</code></button>
22
+ <button @click="setPageSize(100)"><code :class="`${state.tools.param.pageSize === 100 ? 'co-main' : ''}`">100</code></button>
23
+ </div>
24
+ </div>
25
+ </slot>
26
+ <slot name="prefix"></slot>
27
+ </div>
28
+ </div>
29
+ </template>
30
+ <script setup lang="ts">
31
+ import { reactive, computed } from 'vue';
32
+ import { useRoute } from 'vue-router';
33
+ const emits = defineEmits(['update:confs', 'update:param']);
34
+ const props = defineProps({
35
+ confs: {
36
+ type: Object,
37
+ default: () => ({})
38
+ },
39
+ param: {
40
+ type: Object,
41
+ default: () => ({})
42
+ }
43
+ });
44
+
45
+ const route = useRoute();
46
+ const state: any = reactive({
47
+ name: computed(() => 'confs' + route.path?.replace(/\//g, '_')),
48
+ tools: {
49
+ confs: {},
50
+ param: {}
51
+ }
52
+ });
53
+
54
+ const init = () => {
55
+ const _cache = JSON.parse(localStorage.getItem(`${state.name}`) || '{}');
56
+ state.tools.confs = _cache.confs || JSON.parse(JSON.stringify(props.confs));
57
+ state.tools.param = _cache.param || JSON.parse(JSON.stringify(props.param));
58
+ emits('update:confs', state.tools.confs);
59
+ emits('update:param', state.tools.param);
60
+ };
61
+ init();
62
+
63
+ const setLinkMode = (linkMode: any) => {
64
+ state.tools.confs.linkMode = linkMode;
65
+ emits('update:confs', state.tools.confs);
66
+ localStorage.setItem(state.name, JSON.stringify(state.tools));
67
+ };
68
+
69
+ const setPageSize = (pageSize: any) => {
70
+ state.tools.param.pageSize = pageSize;
71
+ emits('update:param', state.tools.param);
72
+ localStorage.setItem(state.name, JSON.stringify(state.tools));
73
+ };
74
+ </script>
@@ -0,0 +1,222 @@
1
+ <template>
2
+ <div ui-pagination="@a" class="full-x pading" ui-flex="row rm">
3
+ <div class="ml-sl ar mob-ac" ui-flex="row rm">
4
+ <div class="mx-ss-sub" ui-flex="row">
5
+ <div v-if="state.showTotal" ui-flex="row cm" ui-hide="<pad">共 {{ data[defined.total || 'total'] || 0 }} 条</div>
6
+ <button :ui-btn="`@a s read :border :square ${data[defined.current || 'current'] > 1 ? '' : ':disabled'}`" @click="prev">
7
+ <svg
8
+ style="width: 1em; height: 1em"
9
+ t="1701228540398"
10
+ class="icon co-read"
11
+ viewBox="0 0 1024 1024"
12
+ version="1.1"
13
+ xmlns="http://www.w3.org/2000/svg"
14
+ p-id="2426"
15
+ width="64"
16
+ height="64"
17
+ >
18
+ <path
19
+ d="M683.36932763 159.41593598c-21.03260057-21.03260057-55.13210605-21.03260057-76.16470661 0L340.63067237 425.99156763c-21.03260057 21.03260057-21.03260057 55.13210605 0 76.16470662l266.57479015 266.57563164c21.03260057 21.03260057 55.13210605 21.03260057 76.16470661 1e-8s21.03260057-55.13210605 0-76.16470662L454.8768908 464.07392093l228.49243683-228.49327832C704.40276971 214.54804203 704.40276971 180.44853655 683.36932763 159.41593598z"
20
+ p-id="2427"
21
+ ></path>
22
+ </svg>
23
+ </button>
24
+ <div ui-tips="@a co:well ux:hover">
25
+ <div ui-btn="@a s read :border">
26
+ <code>{{ data[defined.current || 'current'] || 0 }}/{{ data[defined.totalPages || 'totalPages'] || 0 }}</code>
27
+ <svg
28
+ style="width: 1em; height: 1em"
29
+ t="1701229420486"
30
+ class="icon"
31
+ viewBox="0 0 1024 1024"
32
+ version="1.1"
33
+ xmlns="http://www.w3.org/2000/svg"
34
+ p-id="2426"
35
+ width="64"
36
+ height="64"
37
+ >
38
+ <path
39
+ d="M210.99383545 420.72863834a55.61828615 55.61828615 0 1 1 78.60717773-78.60717774l222.91809082 222.84393313 222.84393312-222.84393313a55.61828615 55.61828615 0 1 1 78.60717772 78.60717774l-263.18572998 263.2598877a55.61828615 55.61828615 0 0 1-86.61621093-10.08544921L210.99383545 420.72863834z"
40
+ p-id="2427"
41
+ ></path>
42
+ </svg>
43
+ </div>
44
+ <div v-if="state.lists.length" ui-tips-box="tc" class="ny-sl al">
45
+ <div class="w-mm max-h-ls" ui-scroll=":y s">
46
+ <ul class="n-sl n-ss-sub dib-sub">
47
+ <li v-for="item in state.lists" :key="item">
48
+ <button :ui-btn="`@a s ${item === data[defined.current || 'current'] ? 'main' : 'read :border'}`" @click="page(item)">
49
+ <code>{{ item }}</code>
50
+ </button>
51
+ </li>
52
+ </ul>
53
+ </div>
54
+ </div>
55
+ </div>
56
+ <button :ui-btn="`@a s read :border :square ${data[defined.current || 'current'] < data[defined.totalPages || 'totalPages'] ? '' : ':disabled'}`" @click="next">
57
+ <svg style="width: 1em; height: 1em" class="icon co-read" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2426" width="64" height="64">
58
+ <path
59
+ d="M341.63640988 781.41564784c20.63742578 21.22981847 54.12571728 21.22981847 74.81456101 0l265.95100164-273.75421824c20.62728703-21.26747667 20.62728703-55.75008988 0-76.97556317l-265.95100164-273.74407946c-20.68449855-21.26747667-54.17423844-21.26747667-74.81456101 0-20.67291141 21.23706043-20.67291142 55.71170748 0 76.98497771l228.55639458 235.24869384-228.55567038 235.22117436c-20.67218722 21.26747667-20.67146302 55.74357212 0 77.02263594l0 0z"
60
+ p-id="2427"
61
+ ></path>
62
+ </svg>
63
+ </button>
64
+ </div>
65
+ <div ui-hide="<pad" ui-tips="@a co:well ux:hover">
66
+ <button ui-btn="@a s none :square">
67
+ <svg
68
+ style="width: 1em; height: 1em"
69
+ t="1701229474205"
70
+ class="icon"
71
+ viewBox="0 0 1024 1024"
72
+ version="1.1"
73
+ xmlns="http://www.w3.org/2000/svg"
74
+ p-id="2426"
75
+ width="64"
76
+ height="64"
77
+ >
78
+ <path
79
+ d="M512 604.16c-53.248 0-96.768-43.52-96.768-96.768 0-53.248 43.52-96.768 96.768-96.768 53.248 0 96.768 43.52 96.768 96.768 0 53.248-43.52 96.768-96.768 96.768zM512 274.432c-53.248 0-96.768-43.52-96.768-96.768s43.52-96.768 96.768-96.768c53.248 0 96.768 43.52 96.768 96.768s-43.52 96.768-96.768 96.768zM512 933.888c-53.248 0-96.768-43.52-96.768-96.768s43.52-96.768 96.768-96.768c53.248 0 96.768 43.52 96.768 96.768s-43.52 96.768-96.768 96.768z"
80
+ p-id="2427"
81
+ ></path>
82
+ </svg>
83
+ </button>
84
+ <div ui-tips-box="tl" class="al min-w-ms">
85
+ <slot name="setting">
86
+ <ul class="n-ms mb-sm-sub">
87
+ <li>
88
+ <h6 class="fs-xs o-mm nowrap">显示总条数</h6>
89
+ <label ui-form="@a type:switch">
90
+ <input type="checkbox" name="form2" v-model="state.showTotal" />
91
+ <span>{{ state.showTotal ? '' : '' }}</span>
92
+ </label>
93
+ </li>
94
+ <li>
95
+ <h6 class="fs-xs o-mm nowrap">每页显示数量</h6>
96
+ <ul>
97
+ <li @click="size(10)" class="ux-hover r-sm"><code :class="`${modelValue.pageSize === 10 ? 'co-main' : ''}`">10条/页</code></li>
98
+ <li @click="size(20)" class="ux-hover r-sm"><code :class="`${modelValue.pageSize === 20 ? 'co-main' : ''}`">20条/页</code></li>
99
+ <li @click="size(50)" class="ux-hover r-sm"><code :class="`${modelValue.pageSize === 50 ? 'co-main' : ''}`">50条/页</code></li>
100
+ <li @click="size(100)" class="ux-hover r-sm"><code :class="`${modelValue.pageSize === 100 ? 'co-main' : ''}`">100条/页</code></li>
101
+ </ul>
102
+ </li>
103
+ </ul>
104
+ </slot>
105
+ </div>
106
+ </div>
107
+ </div>
108
+ </div>
109
+ </template>
110
+
111
+ <script setup lang="ts">
112
+ import { reactive, computed, watch } from 'vue';
113
+ import { useRoute } from 'vue-router';
114
+ import { isObject } from '@fekit/utils';
115
+
116
+ interface ModelValueProps {
117
+ pageSize?: number;
118
+ current?: number;
119
+ [key: string]: any;
120
+ }
121
+
122
+ interface DataProps {
123
+ total?: number;
124
+ totalPages?: number;
125
+ current?: number;
126
+ [key: string]: any;
127
+ }
128
+ interface DefinedProps {
129
+ // 当前页
130
+ current?: string;
131
+ // 总页数
132
+ totalPages?: string;
133
+ // 总条数
134
+ total?: string;
135
+ // 每页条数
136
+ pageSize?: string;
137
+ }
138
+
139
+ // 类型
140
+ interface Props {
141
+ id?: string;
142
+ modelValue: ModelValueProps;
143
+ data: DataProps;
144
+ defined?: DefinedProps;
145
+ }
146
+
147
+ const route: any = useRoute();
148
+ const props: any = withDefaults(defineProps<Props>(), {
149
+ id: '',
150
+ modelValue: () => ({}),
151
+ data: () => ({}),
152
+ defined: () => ({})
153
+ });
154
+
155
+ const emits = defineEmits(['update:modelValue', 'page', 'size']);
156
+ const state: any = reactive({
157
+ id: computed(() => (props.id || 'PAGINATION' + route.path?.replace(/\//g, '_')).toUpperCase()),
158
+ showTotal: true,
159
+ list: computed(() => {
160
+ const _page = Number(props.data[props.defined.current || 'current'] || 1);
161
+ const list = [_page];
162
+ if (_page > 1) {
163
+ list.unshift(_page - 1);
164
+ }
165
+ if (_page > 2) {
166
+ list.unshift(_page - 2);
167
+ }
168
+ const _max = 5 - list.length;
169
+ for (let i = 1; i <= _max; i++) {
170
+ if (_page + i <= props.data[props.defined.totalPages || 'totalPages']) {
171
+ list.push(_page + i);
172
+ }
173
+ }
174
+ const _min = 5 - list.length;
175
+ for (let i = 1; i <= _min; i++) {
176
+ if (list[0] - 1 > 0) {
177
+ list.unshift(list[0] - 1);
178
+ }
179
+ }
180
+ return list;
181
+ }),
182
+ lists: computed(() => {
183
+ const _lists: any = [];
184
+ for (let i = 1; i <= props.data[props.defined.totalPages || 'totalPages']; i++) {
185
+ _lists.push(i);
186
+ }
187
+ return _lists;
188
+ })
189
+ });
190
+
191
+ const prev = () => {
192
+ const _page = Number(props.data[props.defined.current || 'current']) - 1 < 1 ? 1 : Number(props.data[props.defined.current || 'current']) - 1;
193
+ emits('update:modelValue', { ...props.modelValue, ...{ [props.defined.current || 'current']: _page } });
194
+ emits('page', _page);
195
+ };
196
+
197
+ const next = () => {
198
+ const _page =
199
+ Number(props.data[props.defined.current || 'current']) + 1 > props.data[props.defined.totalPages || 'totalPages']
200
+ ? props.data[props.defined.totalPages || 'totalPages']
201
+ : Number(props.data[props.defined.current || 'current']) + 1;
202
+ emits('update:modelValue', { ...props.modelValue, ...{ [props.defined.current || 'current']: _page } });
203
+ emits('page', _page);
204
+ };
205
+
206
+ const page = (idx: any) => {
207
+ emits('update:modelValue', { ...props.modelValue, ...{ [props.defined.current || 'current']: idx } });
208
+ emits('page', idx);
209
+ };
210
+
211
+ const size = (size: any) => {
212
+ emits('update:modelValue', { ...props.modelValue, ...{ [props.defined.pageSize || 'pageSize']: size } });
213
+ emits('size', size);
214
+ window.localStorage.setItem(state.id, `${size}`);
215
+ };
216
+
217
+ // 缓存
218
+ const cache = window.localStorage.getItem(state.id);
219
+ if (cache) {
220
+ size(Number(cache));
221
+ }
222
+ </script>