@cmstops/pro-compo 3.9.2-alpha.0 → 3.9.2-alpha.2
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/dist/index.css +40 -3
- package/dist/index.min.css +1 -1
- package/es/hooks/usePopper.d.ts +1 -1
- package/es/hooks/usePopper.js +3 -3
- package/es/index.css +40 -3
- package/es/selectResourceModal/__demo__/module/DivWrapper.d.ts +268 -0
- package/es/selectResourceModal/__demo__/module/basic.d.ts +299 -0
- package/es/selectResourceModal/components/List/ListNormal/Filter.js +176 -87
- package/es/selectResourceModal/components/List/ListNormal/index.js +6 -4
- package/es/selectResourceModal/hooks/useResponsiveFilter.d.ts +21 -0
- package/es/selectResourceModal/hooks/useResponsiveFilter.js +142 -0
- package/es/selectResourceModal/style/index.css +40 -3
- package/es/selectResourceModal/style/index.less +9 -0
- package/es/selectResourceModal/style/list.less +39 -3
- package/lib/hooks/usePopper.js +3 -3
- package/lib/index.css +40 -3
- package/lib/selectResourceModal/components/List/ListNormal/Filter.js +173 -84
- package/lib/selectResourceModal/components/List/ListNormal/index.js +6 -4
- package/lib/selectResourceModal/hooks/useResponsiveFilter.js +144 -0
- package/lib/selectResourceModal/style/index.css +40 -3
- package/lib/selectResourceModal/style/index.less +9 -0
- package/lib/selectResourceModal/style/list.less +39 -3
- package/package.json +1 -1
|
@@ -1,33 +1,51 @@
|
|
|
1
|
-
import { defineComponent, inject, computed, ref, watch, onMounted, openBlock, createElementBlock, createElementVNode,
|
|
2
|
-
import { Input, Dropdown, Doption,
|
|
3
|
-
import { IconUpload } from "@arco-design/web-vue/es/icon";
|
|
1
|
+
import { defineComponent, inject, computed, ref, watch, onMounted, openBlock, createElementBlock, createCommentVNode, createElementVNode, withDirectives, createVNode, unref, withModifiers, withCtx, createTextVNode, vShow, toDisplayString, Fragment, renderList, createBlock, normalizeClass } from "vue";
|
|
2
|
+
import { Button, Input, Dropdown, Doption, TreeSelect, Select, Option, RangePicker } from "@arco-design/web-vue";
|
|
3
|
+
import { IconCaretDown, IconUpload } from "@arco-design/web-vue/es/icon";
|
|
4
4
|
import useSelection from "../../../../hooks/useSelection.js";
|
|
5
5
|
import { useDirectory } from "../../../../hooks/useAttachement.js";
|
|
6
6
|
import { RESOURCE_SOURCE_OPTIONS, RESOURCE_CATALOG_OPTIONS } from "../../../../utils/typeMap.js";
|
|
7
7
|
import { getAccountList } from "../../../scripts/selectionApis.js";
|
|
8
8
|
import { keywordsSelection } from "../../../../utils/resource.js";
|
|
9
|
+
import { useResponsiveFilter } from "../../../hooks/useResponsiveFilter.js";
|
|
9
10
|
const _hoisted_1 = { class: "list-filter-wrapper" };
|
|
10
11
|
const _hoisted_2 = { class: "list-filter" };
|
|
11
|
-
const _hoisted_3 = { class: "
|
|
12
|
-
const _hoisted_4 = {
|
|
12
|
+
const _hoisted_3 = { class: "more-btn" };
|
|
13
|
+
const _hoisted_4 = { class: "right-prefix" };
|
|
13
14
|
const _hoisted_5 = {
|
|
14
15
|
class: "filter-item",
|
|
15
|
-
style: { "width": "
|
|
16
|
+
style: { "width": "200px" }
|
|
17
|
+
};
|
|
18
|
+
const _hoisted_6 = {
|
|
19
|
+
class: "filter-item",
|
|
20
|
+
style: { "width": "180px" }
|
|
16
21
|
};
|
|
17
|
-
const _hoisted_6 = { class: "filter-item" };
|
|
18
22
|
const _hoisted_7 = {
|
|
23
|
+
class: "filter-item",
|
|
24
|
+
style: { "width": "170px" }
|
|
25
|
+
};
|
|
26
|
+
const _hoisted_8 = {
|
|
27
|
+
class: "filter-item",
|
|
28
|
+
style: { "width": "240px" }
|
|
29
|
+
};
|
|
30
|
+
const _hoisted_9 = {
|
|
31
|
+
class: "filter-item",
|
|
32
|
+
style: { "width": "240px" }
|
|
33
|
+
};
|
|
34
|
+
const _hoisted_10 = {
|
|
19
35
|
key: 0,
|
|
20
36
|
class: "filter-item"
|
|
21
37
|
};
|
|
22
|
-
const
|
|
23
|
-
const
|
|
38
|
+
const _hoisted_11 = { class: "filter-extra" };
|
|
39
|
+
const _hoisted_12 = { class: "filter-item" };
|
|
40
|
+
const _hoisted_13 = {
|
|
24
41
|
key: 0,
|
|
25
42
|
class: "list-filter-tags"
|
|
26
43
|
};
|
|
27
|
-
const
|
|
44
|
+
const _hoisted_14 = ["onClick"];
|
|
28
45
|
const _sfc_main = defineComponent({
|
|
29
46
|
__name: "Filter",
|
|
30
47
|
props: {
|
|
48
|
+
smallScreen: { type: Boolean },
|
|
31
49
|
disableUploadBy: { type: Boolean }
|
|
32
50
|
},
|
|
33
51
|
emits: ["upload", "change"],
|
|
@@ -38,6 +56,16 @@ const _sfc_main = defineComponent({
|
|
|
38
56
|
const baseAPI = inject("baseAPI");
|
|
39
57
|
const filterOptions = inject("filterOptions");
|
|
40
58
|
const domainId = computed(() => userInfo == null ? void 0 : userInfo.value.domain_id);
|
|
59
|
+
const filterItemsRef = ref();
|
|
60
|
+
const {
|
|
61
|
+
moreBtnRef,
|
|
62
|
+
popperPanelRef,
|
|
63
|
+
hiddenElementList,
|
|
64
|
+
visible,
|
|
65
|
+
show,
|
|
66
|
+
hide,
|
|
67
|
+
refreshLayout
|
|
68
|
+
} = useResponsiveFilter(filterItemsRef);
|
|
41
69
|
const { options, loading, load, loadMore, handleSearch } = useSelection({
|
|
42
70
|
labelStr: "alias",
|
|
43
71
|
valueStr: "id",
|
|
@@ -116,82 +144,122 @@ const _sfc_main = defineComponent({
|
|
|
116
144
|
filter.value.keyword = val;
|
|
117
145
|
filter.value.precise_keyword = "";
|
|
118
146
|
}
|
|
147
|
+
filter.value.sf = "";
|
|
119
148
|
}
|
|
120
149
|
});
|
|
121
|
-
watch(
|
|
122
|
-
() => searchType.value,
|
|
123
|
-
() => {
|
|
124
|
-
searchInput.value = filter.value.keyword || filter.value.precise_keyword;
|
|
125
|
-
}
|
|
126
|
-
);
|
|
127
150
|
const isEmpty = computed(() => {
|
|
128
|
-
return Object.keys(
|
|
151
|
+
return Object.keys(originFilter).every((key) => {
|
|
152
|
+
if (key === "catalog") {
|
|
153
|
+
const currentCatalog = filter.value[key] || [];
|
|
154
|
+
const originCatalog = originFilter[key] || [];
|
|
155
|
+
return currentCatalog.length === originCatalog.length && currentCatalog.every((v) => originCatalog.includes(v));
|
|
156
|
+
}
|
|
129
157
|
return filter.value[key] === originFilter[key];
|
|
130
158
|
});
|
|
131
159
|
});
|
|
132
160
|
watch(
|
|
133
161
|
() => filter.value,
|
|
134
|
-
() => {
|
|
135
|
-
const result = { ...
|
|
162
|
+
(val) => {
|
|
163
|
+
const result = { ...val };
|
|
136
164
|
Object.keys(result).forEach((key) => {
|
|
137
165
|
if (props.disableUploadBy && key === "upload_by")
|
|
138
166
|
delete result[key];
|
|
139
|
-
if (
|
|
140
|
-
|
|
167
|
+
if (result[key] === "" || result[key] === null || result[key] === void 0) {
|
|
168
|
+
if (key !== "catalog") {
|
|
169
|
+
delete result[key];
|
|
170
|
+
}
|
|
171
|
+
}
|
|
141
172
|
});
|
|
142
|
-
if (
|
|
143
|
-
result.catalog
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
},
|
|
148
|
-
{ deep: true, immediate: true }
|
|
149
|
-
);
|
|
150
|
-
watch(
|
|
151
|
-
() => filterOptions == null ? void 0 : filterOptions.value,
|
|
152
|
-
() => {
|
|
153
|
-
var _a;
|
|
154
|
-
if ((_a = filterOptions == null ? void 0 : filterOptions.value) == null ? void 0 : _a.mediaType) {
|
|
155
|
-
filter.value.catalog = filterOptions == null ? void 0 : filterOptions.value.mediaType.split(",");
|
|
156
|
-
if (filterOptions == null ? void 0 : filterOptions.value.mediaTypeStrict) {
|
|
157
|
-
originFilter.catalog = filterOptions == null ? void 0 : filterOptions.value.mediaType.split(",");
|
|
173
|
+
if (result.catalog && Array.isArray(result.catalog)) {
|
|
174
|
+
if (result.catalog.length > 0) {
|
|
175
|
+
result.catalog = result.catalog.join(",");
|
|
176
|
+
} else {
|
|
177
|
+
delete result.catalog;
|
|
158
178
|
}
|
|
159
179
|
}
|
|
180
|
+
emits("change", result);
|
|
160
181
|
},
|
|
161
|
-
{
|
|
182
|
+
{ deep: true, immediate: true }
|
|
162
183
|
);
|
|
163
184
|
onMounted(() => {
|
|
185
|
+
var _a;
|
|
164
186
|
load();
|
|
187
|
+
if ((_a = filterOptions == null ? void 0 : filterOptions.value) == null ? void 0 : _a.mediaType) {
|
|
188
|
+
const initialCatalog = filterOptions.value.mediaType.split(",");
|
|
189
|
+
filter.value.catalog = initialCatalog;
|
|
190
|
+
if (filterOptions.value.mediaTypeStrict) {
|
|
191
|
+
originFilter.catalog = initialCatalog;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
165
194
|
});
|
|
166
195
|
__expose({
|
|
167
|
-
|
|
196
|
+
filter,
|
|
197
|
+
handleReset
|
|
168
198
|
});
|
|
169
199
|
return (_ctx, _cache) => {
|
|
170
200
|
var _a;
|
|
171
201
|
return openBlock(), createElementBlock("div", _hoisted_1, [
|
|
202
|
+
createCommentVNode(" Use filterItemsRef's parentElement as the container for boundary checks "),
|
|
172
203
|
createElementVNode("div", _hoisted_2, [
|
|
173
|
-
|
|
204
|
+
createCommentVNode(" Filter Items Container "),
|
|
205
|
+
createElementVNode("div", {
|
|
206
|
+
id: "resource-filter-pannel",
|
|
207
|
+
ref_key: "filterItemsRef",
|
|
208
|
+
ref: filterItemsRef,
|
|
209
|
+
class: "filter-list"
|
|
210
|
+
}, [
|
|
211
|
+
createCommentVNode(" More Filters Button and Popper Panel "),
|
|
212
|
+
createElementVNode("div", _hoisted_3, [
|
|
213
|
+
createElementVNode("div", {
|
|
214
|
+
ref_key: "moreBtnRef",
|
|
215
|
+
ref: moreBtnRef
|
|
216
|
+
}, [
|
|
217
|
+
withDirectives(createVNode(unref(Button), {
|
|
218
|
+
style: { marginRight: "10px" },
|
|
219
|
+
onClick: _cache[0] || (_cache[0] = withModifiers(() => unref(visible) ? unref(hide)() : unref(show)(), ["stop"]))
|
|
220
|
+
}, {
|
|
221
|
+
default: withCtx(() => [
|
|
222
|
+
createElementVNode("span", _hoisted_4, [
|
|
223
|
+
_cache[11] || (_cache[11] = createTextVNode(" \u66F4\u591A ")),
|
|
224
|
+
createVNode(unref(IconCaretDown))
|
|
225
|
+
])
|
|
226
|
+
]),
|
|
227
|
+
_: 1
|
|
228
|
+
}, 512), [
|
|
229
|
+
[vShow, unref(hiddenElementList).length]
|
|
230
|
+
])
|
|
231
|
+
], 512),
|
|
232
|
+
withDirectives(createElementVNode("div", {
|
|
233
|
+
ref_key: "popperPanelRef",
|
|
234
|
+
ref: popperPanelRef,
|
|
235
|
+
class: "filter-pannel",
|
|
236
|
+
onClick: _cache[1] || (_cache[1] = withModifiers(() => {
|
|
237
|
+
}, ["stop"]))
|
|
238
|
+
}, null, 512), [
|
|
239
|
+
[vShow, unref(visible)]
|
|
240
|
+
])
|
|
241
|
+
]),
|
|
174
242
|
createCommentVNode(" \u5173\u952E\u8BCD "),
|
|
175
|
-
createElementVNode("div",
|
|
243
|
+
createElementVNode("div", _hoisted_5, [
|
|
176
244
|
createVNode(unref(Input), {
|
|
177
245
|
modelValue: searchInput.value,
|
|
178
|
-
"onUpdate:modelValue": _cache[
|
|
246
|
+
"onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => searchInput.value = $event),
|
|
179
247
|
"allow-clear": "",
|
|
180
248
|
placeholder: "\u8BF7\u8F93\u5165\u5173\u952E\u8BCD"
|
|
181
249
|
}, {
|
|
182
250
|
prepend: withCtx(() => [
|
|
183
251
|
createVNode(unref(Dropdown), {
|
|
184
|
-
onSelect: _cache[
|
|
252
|
+
onSelect: _cache[2] || (_cache[2] = (e) => searchType.value = e)
|
|
185
253
|
}, {
|
|
186
254
|
content: withCtx(() => [
|
|
187
255
|
createVNode(unref(Doption), { value: 0 }, {
|
|
188
|
-
default: withCtx(() => _cache[
|
|
256
|
+
default: withCtx(() => _cache[12] || (_cache[12] = [
|
|
189
257
|
createTextVNode("\u7CBE\u51C6\u641C")
|
|
190
258
|
])),
|
|
191
259
|
_: 1
|
|
192
260
|
}),
|
|
193
261
|
createVNode(unref(Doption), { value: 1 }, {
|
|
194
|
-
default: withCtx(() => _cache[
|
|
262
|
+
default: withCtx(() => _cache[13] || (_cache[13] = [
|
|
195
263
|
createTextVNode("\u6A21\u7CCA\u641C")
|
|
196
264
|
])),
|
|
197
265
|
_: 1
|
|
@@ -212,24 +280,27 @@ const _sfc_main = defineComponent({
|
|
|
212
280
|
}, 8, ["modelValue"])
|
|
213
281
|
]),
|
|
214
282
|
createCommentVNode(" \u76EE\u5F55 "),
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
283
|
+
createElementVNode("div", _hoisted_6, [
|
|
284
|
+
createVNode(unref(TreeSelect), {
|
|
285
|
+
modelValue: filter.value.directory_id,
|
|
286
|
+
"onUpdate:modelValue": _cache[4] || (_cache[4] = ($event) => filter.value.directory_id = $event),
|
|
287
|
+
data: unref(tree),
|
|
288
|
+
"popup-container": "#resource-filter-pannel",
|
|
289
|
+
placeholder: "\u8BF7\u9009\u62E9\u76EE\u5F55",
|
|
290
|
+
"field-names": {
|
|
291
|
+
title: "alias",
|
|
292
|
+
key: "id"
|
|
293
|
+
},
|
|
294
|
+
"allow-clear": ""
|
|
295
|
+
}, null, 8, ["modelValue", "data"])
|
|
296
|
+
]),
|
|
227
297
|
createCommentVNode(" \u7D20\u6750\u7C7B\u578B "),
|
|
228
|
-
createElementVNode("div",
|
|
298
|
+
createElementVNode("div", _hoisted_7, [
|
|
229
299
|
createVNode(unref(Select), {
|
|
230
300
|
modelValue: filter.value.catalog,
|
|
231
|
-
"onUpdate:modelValue": _cache[
|
|
301
|
+
"onUpdate:modelValue": _cache[5] || (_cache[5] = ($event) => filter.value.catalog = $event),
|
|
232
302
|
disabled: (_a = unref(filterOptions)) == null ? void 0 : _a.mediaTypeStrict,
|
|
303
|
+
"popup-container": "#resource-filter-pannel",
|
|
233
304
|
"allow-clear": "",
|
|
234
305
|
placeholder: "\u7C7B\u578B",
|
|
235
306
|
multiple: "",
|
|
@@ -248,19 +319,22 @@ const _sfc_main = defineComponent({
|
|
|
248
319
|
}, 8, ["modelValue", "disabled"])
|
|
249
320
|
]),
|
|
250
321
|
createCommentVNode(" \u65F6\u95F4\u8303\u56F4 "),
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
322
|
+
createElementVNode("div", _hoisted_8, [
|
|
323
|
+
createVNode(unref(RangePicker), {
|
|
324
|
+
modelValue: rangeTime.value,
|
|
325
|
+
"onUpdate:modelValue": _cache[6] || (_cache[6] = ($event) => rangeTime.value = $event),
|
|
326
|
+
"allow-clear": "",
|
|
327
|
+
"popup-container": "#resource-filter-pannel"
|
|
328
|
+
}, null, 8, ["modelValue"])
|
|
329
|
+
]),
|
|
257
330
|
createCommentVNode(" \u7D20\u6750\u4E0A\u4F20\u6765\u6E90 "),
|
|
258
|
-
createElementVNode("div",
|
|
331
|
+
createElementVNode("div", _hoisted_9, [
|
|
259
332
|
createVNode(unref(Select), {
|
|
260
333
|
modelValue: filter.value.source,
|
|
261
|
-
"onUpdate:modelValue": _cache[
|
|
334
|
+
"onUpdate:modelValue": _cache[7] || (_cache[7] = ($event) => filter.value.source = $event),
|
|
262
335
|
"allow-clear": "",
|
|
263
|
-
placeholder: "\u6765\u6E90"
|
|
336
|
+
placeholder: "\u6765\u6E90",
|
|
337
|
+
"popup-container": "#resource-filter-pannel"
|
|
264
338
|
}, {
|
|
265
339
|
default: withCtx(() => [
|
|
266
340
|
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(resourceSource), (item) => {
|
|
@@ -275,14 +349,15 @@ const _sfc_main = defineComponent({
|
|
|
275
349
|
}, 8, ["modelValue"])
|
|
276
350
|
]),
|
|
277
351
|
createCommentVNode(" \u7D20\u6750\u4E0A\u4F20\u4EBA "),
|
|
278
|
-
!_ctx.disableUploadBy ? (openBlock(), createElementBlock("div",
|
|
352
|
+
!_ctx.disableUploadBy ? (openBlock(), createElementBlock("div", _hoisted_10, [
|
|
279
353
|
createVNode(unref(Select), {
|
|
280
354
|
modelValue: filter.value.upload_by,
|
|
281
|
-
"onUpdate:modelValue": _cache[
|
|
355
|
+
"onUpdate:modelValue": _cache[8] || (_cache[8] = ($event) => filter.value.upload_by = $event),
|
|
282
356
|
"allow-clear": "",
|
|
283
357
|
placeholder: "\u4E0A\u4F20\u4EBA",
|
|
284
358
|
loading: unref(loading),
|
|
285
359
|
"allow-search": "",
|
|
360
|
+
"popup-container": "#resource-filter-pannel",
|
|
286
361
|
onSearch: unref(handleSearch),
|
|
287
362
|
onDropdownReachBottom: unref(loadMore)
|
|
288
363
|
}, {
|
|
@@ -297,40 +372,54 @@ const _sfc_main = defineComponent({
|
|
|
297
372
|
]),
|
|
298
373
|
_: 1
|
|
299
374
|
}, 8, ["modelValue", "loading", "onSearch", "onDropdownReachBottom"])
|
|
300
|
-
])) : createCommentVNode("v-if", true)
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
375
|
+
])) : createCommentVNode("v-if", true)
|
|
376
|
+
], 512),
|
|
377
|
+
createElementVNode("div", _hoisted_11, [
|
|
378
|
+
createCommentVNode(" \u91CD\u7F6E\u6309\u94AE - Wrap in filter-item to be managed by the hook "),
|
|
379
|
+
withDirectives(createElementVNode("div", _hoisted_12, [
|
|
380
|
+
createVNode(unref(Button), {
|
|
381
|
+
type: "text",
|
|
382
|
+
onClick: handleReset
|
|
383
|
+
}, {
|
|
384
|
+
default: withCtx(() => _cache[14] || (_cache[14] = [
|
|
385
|
+
createTextVNode(" \u91CD\u7F6E ")
|
|
386
|
+
])),
|
|
387
|
+
_: 1
|
|
388
|
+
})
|
|
389
|
+
], 512), [
|
|
390
|
+
[vShow, !isEmpty.value]
|
|
391
|
+
]),
|
|
392
|
+
_ctx.smallScreen ? (openBlock(), createBlock(unref(Button), {
|
|
393
|
+
key: 0,
|
|
394
|
+
type: "primary",
|
|
395
|
+
onClick: _cache[9] || (_cache[9] = ($event) => emits("upload"))
|
|
305
396
|
}, {
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
])
|
|
397
|
+
icon: withCtx(() => [
|
|
398
|
+
createVNode(unref(IconUpload))
|
|
399
|
+
]),
|
|
309
400
|
_: 1
|
|
310
|
-
})) :
|
|
311
|
-
|
|
312
|
-
createElementVNode("div", _hoisted_8, [
|
|
313
|
-
createVNode(unref(Button), {
|
|
401
|
+
})) : (openBlock(), createBlock(unref(Button), {
|
|
402
|
+
key: 1,
|
|
314
403
|
type: "primary",
|
|
315
|
-
onClick: _cache[
|
|
404
|
+
onClick: _cache[10] || (_cache[10] = ($event) => emits("upload"))
|
|
316
405
|
}, {
|
|
317
406
|
icon: withCtx(() => [
|
|
318
407
|
createVNode(unref(IconUpload))
|
|
319
408
|
]),
|
|
320
409
|
default: withCtx(() => [
|
|
321
|
-
_cache[
|
|
410
|
+
_cache[15] || (_cache[15] = createTextVNode(" \u4E0A\u4F20 "))
|
|
322
411
|
]),
|
|
323
412
|
_: 1
|
|
324
|
-
})
|
|
413
|
+
}))
|
|
325
414
|
])
|
|
326
415
|
]),
|
|
327
|
-
searchInput.value ? (openBlock(), createElementBlock("div",
|
|
416
|
+
searchInput.value ? (openBlock(), createElementBlock("div", _hoisted_13, [
|
|
328
417
|
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(keywordsSelection), (item) => {
|
|
329
418
|
return openBlock(), createElementBlock("div", {
|
|
330
419
|
key: item.value,
|
|
331
420
|
class: normalizeClass(["list-filter-tag", { active: filter.value.sf === item.value }]),
|
|
332
421
|
onClick: ($event) => filter.value.sf = item.value
|
|
333
|
-
}, toDisplayString(item.name), 11,
|
|
422
|
+
}, toDisplayString(item.name), 11, _hoisted_14);
|
|
334
423
|
}), 128))
|
|
335
424
|
])) : createCommentVNode("v-if", true)
|
|
336
425
|
]);
|
|
@@ -27,14 +27,15 @@ const _sfc_main = defineComponent({
|
|
|
27
27
|
} = useAttachement({ key: props.activeKey, BASE_API });
|
|
28
28
|
watch(() => props.activeKey, changeKey);
|
|
29
29
|
const listWrapper = ref(null);
|
|
30
|
-
const
|
|
30
|
+
const smallScreen = ref(false);
|
|
31
31
|
watch(
|
|
32
32
|
() => {
|
|
33
33
|
var _a;
|
|
34
34
|
return (_a = listWrapper.value) == null ? void 0 : _a.offsetWidth;
|
|
35
35
|
},
|
|
36
36
|
(val) => {
|
|
37
|
-
|
|
37
|
+
console.log(val);
|
|
38
|
+
smallScreen.value = !!(val && val < 600);
|
|
38
39
|
},
|
|
39
40
|
{ immediate: true }
|
|
40
41
|
);
|
|
@@ -51,9 +52,10 @@ const _sfc_main = defineComponent({
|
|
|
51
52
|
]),
|
|
52
53
|
header: withCtx(() => [
|
|
53
54
|
createVNode(_sfc_main$2, {
|
|
55
|
+
smallScreen: smallScreen.value,
|
|
54
56
|
onChange: unref(changeFilter),
|
|
55
57
|
onUpload: _cache[0] || (_cache[0] = ($event) => emits("change-tab", "local"))
|
|
56
|
-
}, null, 8, ["onChange"])
|
|
58
|
+
}, null, 8, ["smallScreen", "onChange"])
|
|
57
59
|
]),
|
|
58
60
|
footer: withCtx(() => [
|
|
59
61
|
createVNode(unref(Pagination), {
|
|
@@ -62,7 +64,7 @@ const _sfc_main = defineComponent({
|
|
|
62
64
|
total: unref(total),
|
|
63
65
|
"page-size": unref(limit),
|
|
64
66
|
"show-total": "",
|
|
65
|
-
"show-page-size":
|
|
67
|
+
"show-page-size": !smallScreen.value,
|
|
66
68
|
"base-size": 3,
|
|
67
69
|
"buffer-size": 1,
|
|
68
70
|
onChange: _cache[2] || (_cache[2] = (e) => unref(changePage)((e - 1) * unref(limit))),
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Ref } from 'vue';
|
|
2
|
+
declare type HideElementType = {
|
|
3
|
+
width: number;
|
|
4
|
+
el: HTMLDivElement;
|
|
5
|
+
};
|
|
6
|
+
export declare function useResponsiveFilter(filterItemsRef: Ref<HTMLElement | undefined>): {
|
|
7
|
+
moreBtnRef: Ref<HTMLElement | undefined, HTMLElement | undefined>;
|
|
8
|
+
popperPanelRef: Ref<HTMLElement | undefined, HTMLElement | undefined>;
|
|
9
|
+
hiddenElementList: Ref<{
|
|
10
|
+
width: number;
|
|
11
|
+
el: HTMLDivElement;
|
|
12
|
+
}[], HideElementType[] | {
|
|
13
|
+
width: number;
|
|
14
|
+
el: HTMLDivElement;
|
|
15
|
+
}[]>;
|
|
16
|
+
visible: Ref<boolean, boolean>;
|
|
17
|
+
show: () => void;
|
|
18
|
+
hide: () => void;
|
|
19
|
+
refreshLayout: () => Promise<void>;
|
|
20
|
+
};
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { ref, onMounted, nextTick, onUnmounted } from "vue";
|
|
2
|
+
import usePopper from "../../hooks/usePopper.js";
|
|
3
|
+
const getRect = (el) => {
|
|
4
|
+
if (!el || typeof el.getClientRects !== "function")
|
|
5
|
+
return { right: 0, width: 0 };
|
|
6
|
+
const rects = el.getClientRects();
|
|
7
|
+
if (rects.length === 0)
|
|
8
|
+
return { right: 0, width: 0 };
|
|
9
|
+
const rect = rects[0];
|
|
10
|
+
return {
|
|
11
|
+
right: rect.right,
|
|
12
|
+
width: rect.width
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
function useResponsiveFilter(filterItemsRef) {
|
|
16
|
+
const moreBtnRef = ref();
|
|
17
|
+
const popperPanelRef = ref();
|
|
18
|
+
const { initPopper, show, visible, hide } = usePopper(
|
|
19
|
+
popperPanelRef,
|
|
20
|
+
moreBtnRef
|
|
21
|
+
);
|
|
22
|
+
const windowWidth = ref(0);
|
|
23
|
+
const filterContainerRightBoundary = ref(0);
|
|
24
|
+
const hiddenElementList = ref([]);
|
|
25
|
+
const initWidths = () => {
|
|
26
|
+
var _a, _b;
|
|
27
|
+
windowWidth.value = ((_a = document.body) == null ? void 0 : _a.clientWidth) || 0;
|
|
28
|
+
const containerElement = (_b = filterItemsRef.value) == null ? void 0 : _b.parentElement;
|
|
29
|
+
if (containerElement) {
|
|
30
|
+
filterContainerRightBoundary.value = getRect(containerElement).right;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
const initResizeListener = () => {
|
|
34
|
+
window.addEventListener("resize", refreshLayout);
|
|
35
|
+
};
|
|
36
|
+
const removeResizeListener = () => {
|
|
37
|
+
window.removeEventListener("resize", refreshLayout);
|
|
38
|
+
};
|
|
39
|
+
const hideElement = (el) => {
|
|
40
|
+
var _a, _b, _c;
|
|
41
|
+
const { width } = getRect(el);
|
|
42
|
+
if (width > 0 && ((_a = filterItemsRef.value) == null ? void 0 : _a.contains(el))) {
|
|
43
|
+
hiddenElementList.value.push({ width, el });
|
|
44
|
+
(_b = filterItemsRef.value) == null ? void 0 : _b.removeChild(el);
|
|
45
|
+
(_c = popperPanelRef.value) == null ? void 0 : _c.insertBefore(el, popperPanelRef.value.firstChild);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
const showElement = () => {
|
|
49
|
+
var _a, _b;
|
|
50
|
+
if (!hiddenElementList.value.length || !filterItemsRef.value)
|
|
51
|
+
return;
|
|
52
|
+
const popEl = hiddenElementList.value.pop();
|
|
53
|
+
if (!popEl)
|
|
54
|
+
return;
|
|
55
|
+
const { el } = popEl;
|
|
56
|
+
(_a = popperPanelRef.value) == null ? void 0 : _a.removeChild(el);
|
|
57
|
+
(_b = filterItemsRef.value) == null ? void 0 : _b.appendChild(el);
|
|
58
|
+
};
|
|
59
|
+
const checkOverflow = () => {
|
|
60
|
+
if (!filterItemsRef.value)
|
|
61
|
+
return -1;
|
|
62
|
+
const containerRight = filterContainerRightBoundary.value;
|
|
63
|
+
const children = filterItemsRef.value.children;
|
|
64
|
+
let currentRightmostBoundary = getRect(filterItemsRef.value).right - getRect(filterItemsRef.value).width;
|
|
65
|
+
for (let i = children.length - 1; i >= 0; i--) {
|
|
66
|
+
const item = children[i];
|
|
67
|
+
if (!item || !item.classList || !item.classList.contains("filter-item"))
|
|
68
|
+
continue;
|
|
69
|
+
const itemRect = getRect(item);
|
|
70
|
+
if (itemRect.right > containerRight - 300) {
|
|
71
|
+
hideElement(item);
|
|
72
|
+
} else {
|
|
73
|
+
currentRightmostBoundary = Math.max(
|
|
74
|
+
currentRightmostBoundary,
|
|
75
|
+
itemRect.right
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return currentRightmostBoundary;
|
|
80
|
+
};
|
|
81
|
+
const refreshLayout = async () => {
|
|
82
|
+
await nextTick();
|
|
83
|
+
initWidths();
|
|
84
|
+
if (!filterItemsRef.value || !popperPanelRef.value)
|
|
85
|
+
return;
|
|
86
|
+
const containerRight = filterContainerRightBoundary.value;
|
|
87
|
+
let lastVisibleItemRight = checkOverflow();
|
|
88
|
+
if (lastVisibleItemRight === -1 && filterItemsRef.value.children.length > 0) {
|
|
89
|
+
lastVisibleItemRight = getRect(filterItemsRef.value).left;
|
|
90
|
+
} else if (filterItemsRef.value.children.length === 0) {
|
|
91
|
+
lastVisibleItemRight = getRect(filterItemsRef.value).left;
|
|
92
|
+
}
|
|
93
|
+
await nextTick();
|
|
94
|
+
let availableSpace = containerRight - lastVisibleItemRight;
|
|
95
|
+
while (hiddenElementList.value.length > 0) {
|
|
96
|
+
const nextHiddenItem = hiddenElementList.value[hiddenElementList.value.length - 1];
|
|
97
|
+
const nextHiddenItemWidth = nextHiddenItem.width;
|
|
98
|
+
if (availableSpace > nextHiddenItemWidth + 10) {
|
|
99
|
+
showElement();
|
|
100
|
+
await nextTick();
|
|
101
|
+
const visibleElements = Array.from(
|
|
102
|
+
filterItemsRef.value.children
|
|
103
|
+
);
|
|
104
|
+
if (visibleElements.length > 0) {
|
|
105
|
+
lastVisibleItemRight = visibleElements.reduce((maxRight, el) => {
|
|
106
|
+
var _a;
|
|
107
|
+
if ((_a = el.classList) == null ? void 0 : _a.contains("filter-item")) {
|
|
108
|
+
return Math.max(maxRight, getRect(el).right);
|
|
109
|
+
}
|
|
110
|
+
return maxRight;
|
|
111
|
+
}, getRect(filterItemsRef.value).left);
|
|
112
|
+
} else {
|
|
113
|
+
lastVisibleItemRight = getRect(filterItemsRef.value).left;
|
|
114
|
+
}
|
|
115
|
+
availableSpace = containerRight - lastVisibleItemRight;
|
|
116
|
+
} else {
|
|
117
|
+
break;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
onMounted(async () => {
|
|
122
|
+
initResizeListener();
|
|
123
|
+
initPopper("bottom-start", [0, 40]);
|
|
124
|
+
await nextTick();
|
|
125
|
+
initWidths();
|
|
126
|
+
await nextTick();
|
|
127
|
+
refreshLayout();
|
|
128
|
+
});
|
|
129
|
+
onUnmounted(() => {
|
|
130
|
+
removeResizeListener();
|
|
131
|
+
});
|
|
132
|
+
return {
|
|
133
|
+
moreBtnRef,
|
|
134
|
+
popperPanelRef,
|
|
135
|
+
hiddenElementList,
|
|
136
|
+
visible,
|
|
137
|
+
show,
|
|
138
|
+
hide,
|
|
139
|
+
refreshLayout
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
export { useResponsiveFilter };
|