@cmstops/pro-compo 0.3.100 → 3.9.0-beta.1
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 +39 -4
- package/dist/index.min.css +1 -1
- package/es/config.js +1 -1
- package/es/editMetaInfo/components/metaInfoForm.js +4 -2
- package/es/hooks/useAttachement.d.ts +26 -7
- package/es/hooks/useAttachement.js +42 -2
- package/es/hooks/usePopper.d.ts +1 -1
- package/es/hooks/usePopper.js +3 -3
- package/es/index.css +39 -4
- 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 +174 -76
- package/es/selectResourceModal/components/List/ListNormal/index.js +21 -6
- package/es/selectResourceModal/hooks/useResponsiveFilter.d.ts +21 -0
- package/es/selectResourceModal/hooks/useResponsiveFilter.js +142 -0
- package/es/selectResourceModal/scripts/useCompoLf.js +1 -1
- package/es/selectResourceModal/style/index.css +39 -4
- package/es/selectResourceModal/style/index.less +5 -0
- package/es/selectResourceModal/style/list.less +39 -4
- package/es/selectThumb/component.js +57 -3
- package/lib/config.js +1 -1
- package/lib/editMetaInfo/components/metaInfoForm.js +4 -2
- package/lib/hooks/useAttachement.js +42 -0
- package/lib/hooks/usePopper.js +3 -3
- package/lib/index.css +39 -4
- package/lib/selectResourceModal/components/List/ListNormal/Filter.js +171 -73
- package/lib/selectResourceModal/components/List/ListNormal/index.js +20 -5
- package/lib/selectResourceModal/hooks/useResponsiveFilter.js +144 -0
- package/lib/selectResourceModal/scripts/useCompoLf.js +1 -1
- package/lib/selectResourceModal/style/index.css +39 -4
- package/lib/selectResourceModal/style/index.less +5 -0
- package/lib/selectResourceModal/style/list.less +39 -4
- package/lib/selectThumb/component.js +56 -2
- package/package.json +1 -1
|
@@ -1,29 +1,47 @@
|
|
|
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
|
+
import { useDirectory } from "../../../../hooks/useAttachement.js";
|
|
5
6
|
import { RESOURCE_SOURCE_OPTIONS, RESOURCE_CATALOG_OPTIONS } from "../../../../utils/typeMap.js";
|
|
6
7
|
import { getAccountList } from "../../../scripts/selectionApis.js";
|
|
7
8
|
import { keywordsSelection } from "../../../../utils/resource.js";
|
|
9
|
+
import { useResponsiveFilter } from "../../../hooks/useResponsiveFilter.js";
|
|
8
10
|
const _hoisted_1 = { class: "list-filter-wrapper" };
|
|
9
11
|
const _hoisted_2 = { class: "list-filter" };
|
|
10
|
-
const _hoisted_3 = { class: "
|
|
11
|
-
const _hoisted_4 = {
|
|
12
|
+
const _hoisted_3 = { class: "more-btn" };
|
|
13
|
+
const _hoisted_4 = { class: "right-prefix" };
|
|
12
14
|
const _hoisted_5 = {
|
|
13
15
|
class: "filter-item",
|
|
14
16
|
style: { "width": "200px" }
|
|
15
17
|
};
|
|
16
|
-
const _hoisted_6 = {
|
|
18
|
+
const _hoisted_6 = {
|
|
19
|
+
class: "filter-item",
|
|
20
|
+
style: { "width": "180px" }
|
|
21
|
+
};
|
|
17
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 = {
|
|
18
35
|
key: 0,
|
|
19
36
|
class: "filter-item"
|
|
20
37
|
};
|
|
21
|
-
const
|
|
22
|
-
const
|
|
38
|
+
const _hoisted_11 = { class: "filter-extra" };
|
|
39
|
+
const _hoisted_12 = { class: "filter-item" };
|
|
40
|
+
const _hoisted_13 = {
|
|
23
41
|
key: 0,
|
|
24
42
|
class: "list-filter-tags"
|
|
25
43
|
};
|
|
26
|
-
const
|
|
44
|
+
const _hoisted_14 = ["onClick"];
|
|
27
45
|
const _sfc_main = defineComponent({
|
|
28
46
|
__name: "Filter",
|
|
29
47
|
props: {
|
|
@@ -37,6 +55,16 @@ const _sfc_main = defineComponent({
|
|
|
37
55
|
const baseAPI = inject("baseAPI");
|
|
38
56
|
const filterOptions = inject("filterOptions");
|
|
39
57
|
const domainId = computed(() => userInfo == null ? void 0 : userInfo.value.domain_id);
|
|
58
|
+
const filterItemsRef = ref();
|
|
59
|
+
const {
|
|
60
|
+
moreBtnRef,
|
|
61
|
+
popperPanelRef,
|
|
62
|
+
hiddenElementList,
|
|
63
|
+
visible,
|
|
64
|
+
show,
|
|
65
|
+
hide,
|
|
66
|
+
refreshLayout
|
|
67
|
+
} = useResponsiveFilter(filterItemsRef);
|
|
40
68
|
const { options, loading, load, loadMore, handleSearch } = useSelection({
|
|
41
69
|
labelStr: "alias",
|
|
42
70
|
valueStr: "id",
|
|
@@ -56,6 +84,9 @@ const _sfc_main = defineComponent({
|
|
|
56
84
|
});
|
|
57
85
|
const resourceSource = RESOURCE_SOURCE_OPTIONS;
|
|
58
86
|
const resourceCatalog = RESOURCE_CATALOG_OPTIONS;
|
|
87
|
+
const { tree } = useDirectory({
|
|
88
|
+
BASE_API: baseAPI
|
|
89
|
+
});
|
|
59
90
|
const originFilter = {
|
|
60
91
|
catalog: [],
|
|
61
92
|
source: "",
|
|
@@ -64,7 +95,8 @@ const _sfc_main = defineComponent({
|
|
|
64
95
|
keyword: "",
|
|
65
96
|
precise_keyword: "",
|
|
66
97
|
upload_by: null,
|
|
67
|
-
sf: ""
|
|
98
|
+
sf: "",
|
|
99
|
+
directory_id: void 0
|
|
68
100
|
};
|
|
69
101
|
const filter = ref(JSON.parse(JSON.stringify(originFilter)));
|
|
70
102
|
const handleReset = () => {
|
|
@@ -111,82 +143,123 @@ const _sfc_main = defineComponent({
|
|
|
111
143
|
filter.value.keyword = val;
|
|
112
144
|
filter.value.precise_keyword = "";
|
|
113
145
|
}
|
|
146
|
+
filter.value.sf = "";
|
|
114
147
|
}
|
|
115
148
|
});
|
|
116
|
-
watch(
|
|
117
|
-
() => searchType.value,
|
|
118
|
-
() => {
|
|
119
|
-
searchInput.value = filter.value.keyword || filter.value.precise_keyword;
|
|
120
|
-
}
|
|
121
|
-
);
|
|
122
149
|
const isEmpty = computed(() => {
|
|
123
|
-
return Object.keys(
|
|
150
|
+
return Object.keys(originFilter).every((key) => {
|
|
151
|
+
if (key === "catalog") {
|
|
152
|
+
const currentCatalog = filter.value[key] || [];
|
|
153
|
+
const originCatalog = originFilter[key] || [];
|
|
154
|
+
return currentCatalog.length === originCatalog.length && currentCatalog.every((v) => originCatalog.includes(v));
|
|
155
|
+
}
|
|
124
156
|
return filter.value[key] === originFilter[key];
|
|
125
157
|
});
|
|
126
158
|
});
|
|
127
159
|
watch(
|
|
128
160
|
() => filter.value,
|
|
129
|
-
() => {
|
|
130
|
-
const result = { ...
|
|
161
|
+
(val) => {
|
|
162
|
+
const result = { ...val };
|
|
131
163
|
Object.keys(result).forEach((key) => {
|
|
132
164
|
if (props.disableUploadBy && key === "upload_by")
|
|
133
165
|
delete result[key];
|
|
134
|
-
if (
|
|
135
|
-
|
|
166
|
+
if (result[key] === "" || result[key] === null || result[key] === void 0) {
|
|
167
|
+
if (key !== "catalog") {
|
|
168
|
+
delete result[key];
|
|
169
|
+
}
|
|
170
|
+
}
|
|
136
171
|
});
|
|
137
|
-
if (
|
|
138
|
-
result.catalog
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
},
|
|
143
|
-
{ deep: true, immediate: true }
|
|
144
|
-
);
|
|
145
|
-
watch(
|
|
146
|
-
() => filterOptions == null ? void 0 : filterOptions.value,
|
|
147
|
-
() => {
|
|
148
|
-
var _a;
|
|
149
|
-
if ((_a = filterOptions == null ? void 0 : filterOptions.value) == null ? void 0 : _a.mediaType) {
|
|
150
|
-
filter.value.catalog = filterOptions == null ? void 0 : filterOptions.value.mediaType.split(",");
|
|
151
|
-
if (filterOptions == null ? void 0 : filterOptions.value.mediaTypeStrict) {
|
|
152
|
-
originFilter.catalog = filterOptions == null ? void 0 : filterOptions.value.mediaType.split(",");
|
|
172
|
+
if (result.catalog && Array.isArray(result.catalog)) {
|
|
173
|
+
if (result.catalog.length > 0) {
|
|
174
|
+
result.catalog = result.catalog.join(",");
|
|
175
|
+
} else {
|
|
176
|
+
delete result.catalog;
|
|
153
177
|
}
|
|
154
178
|
}
|
|
179
|
+
emits("change", result);
|
|
180
|
+
refreshLayout();
|
|
155
181
|
},
|
|
156
|
-
{
|
|
182
|
+
{ deep: true, immediate: true }
|
|
157
183
|
);
|
|
158
184
|
onMounted(() => {
|
|
185
|
+
var _a;
|
|
159
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
|
+
}
|
|
160
194
|
});
|
|
161
195
|
__expose({
|
|
162
|
-
|
|
196
|
+
filter,
|
|
197
|
+
handleReset
|
|
163
198
|
});
|
|
164
199
|
return (_ctx, _cache) => {
|
|
165
200
|
var _a;
|
|
166
201
|
return openBlock(), createElementBlock("div", _hoisted_1, [
|
|
202
|
+
createCommentVNode(" Use filterItemsRef's parentElement as the container for boundary checks "),
|
|
167
203
|
createElementVNode("div", _hoisted_2, [
|
|
168
|
-
|
|
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[10] || (_cache[10] = createTextVNode(" \u66F4\u591A\u7B5B\u9009 ")),
|
|
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
|
+
]),
|
|
169
242
|
createCommentVNode(" \u5173\u952E\u8BCD "),
|
|
170
|
-
createElementVNode("div",
|
|
243
|
+
createElementVNode("div", _hoisted_5, [
|
|
171
244
|
createVNode(unref(Input), {
|
|
172
245
|
modelValue: searchInput.value,
|
|
173
|
-
"onUpdate:modelValue": _cache[
|
|
246
|
+
"onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => searchInput.value = $event),
|
|
174
247
|
"allow-clear": "",
|
|
175
248
|
placeholder: "\u8BF7\u8F93\u5165\u5173\u952E\u8BCD"
|
|
176
249
|
}, {
|
|
177
250
|
prepend: withCtx(() => [
|
|
178
251
|
createVNode(unref(Dropdown), {
|
|
179
|
-
onSelect: _cache[
|
|
252
|
+
onSelect: _cache[2] || (_cache[2] = (e) => searchType.value = e)
|
|
180
253
|
}, {
|
|
181
254
|
content: withCtx(() => [
|
|
182
255
|
createVNode(unref(Doption), { value: 0 }, {
|
|
183
|
-
default: withCtx(() => _cache[
|
|
256
|
+
default: withCtx(() => _cache[11] || (_cache[11] = [
|
|
184
257
|
createTextVNode("\u7CBE\u51C6\u641C")
|
|
185
258
|
])),
|
|
186
259
|
_: 1
|
|
187
260
|
}),
|
|
188
261
|
createVNode(unref(Doption), { value: 1 }, {
|
|
189
|
-
default: withCtx(() => _cache[
|
|
262
|
+
default: withCtx(() => _cache[12] || (_cache[12] = [
|
|
190
263
|
createTextVNode("\u6A21\u7CCA\u641C")
|
|
191
264
|
])),
|
|
192
265
|
_: 1
|
|
@@ -206,15 +279,32 @@ const _sfc_main = defineComponent({
|
|
|
206
279
|
_: 1
|
|
207
280
|
}, 8, ["modelValue"])
|
|
208
281
|
]),
|
|
282
|
+
createCommentVNode(" \u76EE\u5F55 "),
|
|
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
|
+
]),
|
|
209
297
|
createCommentVNode(" \u7D20\u6750\u7C7B\u578B "),
|
|
210
|
-
createElementVNode("div",
|
|
298
|
+
createElementVNode("div", _hoisted_7, [
|
|
211
299
|
createVNode(unref(Select), {
|
|
212
300
|
modelValue: filter.value.catalog,
|
|
213
|
-
"onUpdate:modelValue": _cache[
|
|
301
|
+
"onUpdate:modelValue": _cache[5] || (_cache[5] = ($event) => filter.value.catalog = $event),
|
|
214
302
|
disabled: (_a = unref(filterOptions)) == null ? void 0 : _a.mediaTypeStrict,
|
|
303
|
+
"popup-container": "#resource-filter-pannel",
|
|
215
304
|
"allow-clear": "",
|
|
216
305
|
placeholder: "\u7C7B\u578B",
|
|
217
|
-
multiple: ""
|
|
306
|
+
multiple: "",
|
|
307
|
+
"max-tag-count": 1
|
|
218
308
|
}, {
|
|
219
309
|
default: withCtx(() => [
|
|
220
310
|
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(resourceCatalog), (item) => {
|
|
@@ -229,19 +319,22 @@ const _sfc_main = defineComponent({
|
|
|
229
319
|
}, 8, ["modelValue", "disabled"])
|
|
230
320
|
]),
|
|
231
321
|
createCommentVNode(" \u65F6\u95F4\u8303\u56F4 "),
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
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
|
+
]),
|
|
238
330
|
createCommentVNode(" \u7D20\u6750\u4E0A\u4F20\u6765\u6E90 "),
|
|
239
|
-
createElementVNode("div",
|
|
331
|
+
createElementVNode("div", _hoisted_9, [
|
|
240
332
|
createVNode(unref(Select), {
|
|
241
333
|
modelValue: filter.value.source,
|
|
242
|
-
"onUpdate:modelValue": _cache[
|
|
334
|
+
"onUpdate:modelValue": _cache[7] || (_cache[7] = ($event) => filter.value.source = $event),
|
|
243
335
|
"allow-clear": "",
|
|
244
|
-
placeholder: "\u6765\u6E90"
|
|
336
|
+
placeholder: "\u6765\u6E90",
|
|
337
|
+
"popup-container": "#resource-filter-pannel"
|
|
245
338
|
}, {
|
|
246
339
|
default: withCtx(() => [
|
|
247
340
|
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(resourceSource), (item) => {
|
|
@@ -256,14 +349,15 @@ const _sfc_main = defineComponent({
|
|
|
256
349
|
}, 8, ["modelValue"])
|
|
257
350
|
]),
|
|
258
351
|
createCommentVNode(" \u7D20\u6750\u4E0A\u4F20\u4EBA "),
|
|
259
|
-
!_ctx.disableUploadBy ? (openBlock(), createElementBlock("div",
|
|
352
|
+
!_ctx.disableUploadBy ? (openBlock(), createElementBlock("div", _hoisted_10, [
|
|
260
353
|
createVNode(unref(Select), {
|
|
261
354
|
modelValue: filter.value.upload_by,
|
|
262
|
-
"onUpdate:modelValue": _cache[
|
|
355
|
+
"onUpdate:modelValue": _cache[8] || (_cache[8] = ($event) => filter.value.upload_by = $event),
|
|
263
356
|
"allow-clear": "",
|
|
264
357
|
placeholder: "\u4E0A\u4F20\u4EBA",
|
|
265
358
|
loading: unref(loading),
|
|
266
359
|
"allow-search": "",
|
|
360
|
+
"popup-container": "#resource-filter-pannel",
|
|
267
361
|
onSearch: unref(handleSearch),
|
|
268
362
|
onDropdownReachBottom: unref(loadMore)
|
|
269
363
|
}, {
|
|
@@ -278,40 +372,44 @@ const _sfc_main = defineComponent({
|
|
|
278
372
|
]),
|
|
279
373
|
_: 1
|
|
280
374
|
}, 8, ["modelValue", "loading", "onSearch", "onDropdownReachBottom"])
|
|
281
|
-
])) : createCommentVNode("v-if", true)
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
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[13] || (_cache[13] = [
|
|
385
|
+
createTextVNode(" \u91CD\u7F6E ")
|
|
386
|
+
])),
|
|
387
|
+
_: 1
|
|
388
|
+
})
|
|
389
|
+
], 512), [
|
|
390
|
+
[vShow, !isEmpty.value]
|
|
391
|
+
]),
|
|
294
392
|
createVNode(unref(Button), {
|
|
295
393
|
type: "primary",
|
|
296
|
-
onClick: _cache[
|
|
394
|
+
onClick: _cache[9] || (_cache[9] = ($event) => emits("upload"))
|
|
297
395
|
}, {
|
|
298
396
|
icon: withCtx(() => [
|
|
299
397
|
createVNode(unref(IconUpload))
|
|
300
398
|
]),
|
|
301
399
|
default: withCtx(() => [
|
|
302
|
-
_cache[
|
|
400
|
+
_cache[14] || (_cache[14] = createTextVNode(" \u4E0A\u4F20 "))
|
|
303
401
|
]),
|
|
304
402
|
_: 1
|
|
305
403
|
})
|
|
306
404
|
])
|
|
307
405
|
]),
|
|
308
|
-
searchInput.value ? (openBlock(), createElementBlock("div",
|
|
406
|
+
searchInput.value ? (openBlock(), createElementBlock("div", _hoisted_13, [
|
|
309
407
|
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(keywordsSelection), (item) => {
|
|
310
408
|
return openBlock(), createElementBlock("div", {
|
|
311
409
|
key: item.value,
|
|
312
410
|
class: normalizeClass(["list-filter-tag", { active: filter.value.sf === item.value }]),
|
|
313
411
|
onClick: ($event) => filter.value.sf = item.value
|
|
314
|
-
}, toDisplayString(item.name), 11,
|
|
412
|
+
}, toDisplayString(item.name), 11, _hoisted_14);
|
|
315
413
|
}), 128))
|
|
316
414
|
])) : createCommentVNode("v-if", true)
|
|
317
415
|
]);
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { defineComponent, inject, watch, onMounted, openBlock, createBlock, unref, withCtx, renderSlot, createVNode, isRef, createElementVNode, createElementBlock, Fragment, renderList } from "vue";
|
|
1
|
+
import { defineComponent, inject, watch, ref, onMounted, openBlock, createBlock, unref, withCtx, renderSlot, createVNode, isRef, createElementVNode, createElementBlock, Fragment, renderList } from "vue";
|
|
2
2
|
import { Pagination } from "@arco-design/web-vue";
|
|
3
3
|
import _sfc_main$1 from "../ListWraper.js";
|
|
4
4
|
import useAttachement from "../../../../hooks/useAttachement.js";
|
|
5
5
|
import _sfc_main$2 from "./Filter.js";
|
|
6
|
-
const _hoisted_1 = { class: "list-item-grid" };
|
|
7
6
|
const _sfc_main = defineComponent({
|
|
8
7
|
__name: "index",
|
|
9
8
|
props: {
|
|
@@ -27,6 +26,18 @@ const _sfc_main = defineComponent({
|
|
|
27
26
|
changeKey
|
|
28
27
|
} = useAttachement({ key: props.activeKey, BASE_API });
|
|
29
28
|
watch(() => props.activeKey, changeKey);
|
|
29
|
+
const listWrapper = ref(null);
|
|
30
|
+
const showPageSize = ref(true);
|
|
31
|
+
watch(
|
|
32
|
+
() => {
|
|
33
|
+
var _a;
|
|
34
|
+
return (_a = listWrapper.value) == null ? void 0 : _a.offsetWidth;
|
|
35
|
+
},
|
|
36
|
+
(val) => {
|
|
37
|
+
showPageSize.value = !(val && val < 480);
|
|
38
|
+
},
|
|
39
|
+
{ immediate: true }
|
|
40
|
+
);
|
|
30
41
|
onMounted(() => {
|
|
31
42
|
loadData();
|
|
32
43
|
});
|
|
@@ -51,22 +62,26 @@ const _sfc_main = defineComponent({
|
|
|
51
62
|
total: unref(total),
|
|
52
63
|
"page-size": unref(limit),
|
|
53
64
|
"show-total": "",
|
|
54
|
-
"show-page-size":
|
|
65
|
+
"show-page-size": showPageSize.value,
|
|
55
66
|
"base-size": 3,
|
|
56
67
|
"buffer-size": 1,
|
|
57
68
|
onChange: _cache[2] || (_cache[2] = (e) => unref(changePage)((e - 1) * unref(limit))),
|
|
58
69
|
onPageSizeChange: unref(changeSize)
|
|
59
|
-
}, null, 8, ["current", "total", "page-size", "onPageSizeChange"])
|
|
70
|
+
}, null, 8, ["current", "total", "page-size", "show-page-size", "onPageSizeChange"])
|
|
60
71
|
]),
|
|
61
72
|
default: withCtx(() => [
|
|
62
|
-
createElementVNode("div",
|
|
73
|
+
createElementVNode("div", {
|
|
74
|
+
ref_key: "listWrapper",
|
|
75
|
+
ref: listWrapper,
|
|
76
|
+
class: "list-item-grid"
|
|
77
|
+
}, [
|
|
63
78
|
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(list), (item) => {
|
|
64
79
|
return renderSlot(_ctx.$slots, "item", {
|
|
65
80
|
key: item.id,
|
|
66
81
|
item
|
|
67
82
|
});
|
|
68
83
|
}), 128))
|
|
69
|
-
])
|
|
84
|
+
], 512)
|
|
70
85
|
]),
|
|
71
86
|
_: 3
|
|
72
87
|
}, 8, ["loading", "is-empty"]);
|
|
@@ -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 };
|