@scvzerng/element-plus-search-vue2 0.0.3 → 0.0.4
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/ElementPlusSearch.es.js +407 -268
- package/dist/ElementPlusSearch.umd.js +1 -1
- package/dist/element-plus-search.css +1 -0
- package/dist/stats.html +4949 -0
- package/dist/types/SearchBar.vue.d.ts +6 -30
- package/dist/types/SearchBarState.d.ts +2 -1
- package/dist/types/SearchItemRender.d.ts +5 -20
- package/dist/types/SearchTagsRender.vue.d.ts +4 -17
- package/dist/types/index.d.ts +0 -1
- package/dist/types/setting/SearchSettingsDrawer.vue.d.ts +3 -2
- package/dist/types/setting/SettingButton.vue.d.ts +2 -10
- package/dist/types/setting/use-setting.d.ts +15 -4
- package/package.json +2 -2
- package/dist/style.css +0 -1
- package/dist/types/helper/vModel.d.ts +0 -14
@@ -1,60 +1,99 @@
|
|
1
|
-
import {
|
2
|
-
import { defineComponent as
|
3
|
-
import {
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
}
|
10
|
-
}
|
11
|
-
}), H = y({
|
12
|
-
name: "SearchTags"
|
13
|
-
}), z = /* @__PURE__ */ y({
|
14
|
-
...H,
|
1
|
+
import { isFunction as V, keyBy as M, isNumber as z, isBoolean as P, isEmpty as U, chain as G, sum as W, isPlainObject as X } from "lodash-unified";
|
2
|
+
import { defineComponent as D, ref as y, resolveComponent as g, createElementBlock as A, openBlock as f, createVNode as o, createElementVNode as b, withCtx as c, unref as u, Fragment as N, renderList as B, createBlock as w, createTextVNode as L, toDisplayString as F, reactive as H, shallowRef as J, isRef as Q, computed as j, normalizeStyle as Y, normalizeClass as Z, withDirectives as ee, vShow as te, createCommentVNode as q } from "vue";
|
3
|
+
import { ArrowLeft as se, ArrowRight as ie, ArrowDown as re, ArrowUp as ne } from "@element-plus/icons-vue";
|
4
|
+
import { Setting as le } from "@scvzerng/icons";
|
5
|
+
import { watchDebounced as ae } from "@vueuse/core";
|
6
|
+
const oe = { class: "tags-scroll-container" }, ce = ["innerHTML"], ue = /* @__PURE__ */ D({
|
7
|
+
name: "SearchTags",
|
8
|
+
__name: "SearchTagsRender",
|
15
9
|
props: {
|
16
|
-
tags:
|
10
|
+
tags: {}
|
17
11
|
},
|
18
|
-
setup(
|
19
|
-
const e =
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
t.value.scrollBy({
|
12
|
+
setup(s) {
|
13
|
+
const e = y(), t = () => {
|
14
|
+
e.value.scrollBy({ left: -200, behavior: "smooth" });
|
15
|
+
}, r = () => {
|
16
|
+
e.value.scrollBy({
|
24
17
|
left: 200,
|
25
18
|
behavior: "smooth"
|
26
19
|
});
|
27
|
-
}
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
},
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
class
|
20
|
+
};
|
21
|
+
return (i, n) => {
|
22
|
+
const p = g("el-icon"), d = g("el-tag");
|
23
|
+
return f(), A("div", oe, [
|
24
|
+
o(d, {
|
25
|
+
type: "info",
|
26
|
+
class: "scroll-left-bar",
|
27
|
+
onClick: t
|
28
|
+
}, {
|
29
|
+
default: c(() => [
|
30
|
+
o(p, null, {
|
31
|
+
default: c(() => [
|
32
|
+
o(u(se))
|
33
|
+
]),
|
34
|
+
_: 1
|
35
|
+
}),
|
36
|
+
n[0] || (n[0] = b("i", { class: "el-icon-arrow-left" }, null, -1))
|
37
|
+
]),
|
38
|
+
_: 1
|
39
|
+
}),
|
40
|
+
b("div", {
|
41
|
+
ref_key: "scrollContainer",
|
42
|
+
ref: e,
|
43
|
+
class: "search-tags"
|
44
|
+
}, [
|
45
|
+
(f(!0), A(N, null, B(s.tags, (m) => (f(), w(d, {
|
46
|
+
class: "search-tag",
|
47
|
+
onClose: () => m.clean(),
|
48
|
+
closable: !m.required,
|
49
|
+
type: m.required ? "primary" : "info",
|
50
|
+
key: m.field
|
51
|
+
}, {
|
52
|
+
default: c(() => [
|
53
|
+
b("span", null, F(m.label), 1),
|
54
|
+
n[1] || (n[1] = L(": ", -1)),
|
55
|
+
b("span", {
|
56
|
+
innerHTML: m.valueText
|
57
|
+
}, null, 8, ce)
|
58
|
+
]),
|
59
|
+
_: 2
|
60
|
+
}, 1032, ["onClose", "closable", "type"]))), 128))
|
61
|
+
], 512),
|
62
|
+
o(d, {
|
63
|
+
type: "info",
|
64
|
+
class: "scroll-right-bar",
|
65
|
+
onClick: r
|
66
|
+
}, {
|
67
|
+
default: c(() => [
|
68
|
+
o(p, null, {
|
69
|
+
default: c(() => [
|
70
|
+
o(u(ie))
|
71
|
+
]),
|
72
|
+
_: 1
|
73
|
+
})
|
74
|
+
]),
|
75
|
+
_: 1
|
76
|
+
})
|
77
|
+
]);
|
78
|
+
};
|
79
|
+
}
|
80
|
+
}), K = 6;
|
81
|
+
class de {
|
82
|
+
field;
|
83
|
+
label;
|
84
|
+
value;
|
85
|
+
required;
|
86
|
+
index;
|
87
|
+
visible;
|
88
|
+
disabled;
|
89
|
+
span;
|
90
|
+
initValue;
|
91
|
+
enable;
|
92
|
+
tagFilter;
|
93
|
+
render;
|
94
|
+
transform;
|
54
95
|
constructor(e, t) {
|
55
|
-
|
56
|
-
var s, r, a, d;
|
57
|
-
this.field = e.field, this.label = e.label, this.value = e.initValue, this.required = e.required, this.initValue = e.initValue, this.index = t, this.visible = (s = e.visible) != null ? s : !0, this.span = (r = e.span) != null ? r : A, this.render = e.render, this.tagFilter = e.tagFilter, this.transform = e.transform, this.enable = (a = e.enable) != null ? a : !0, this.disabled = (d = e.disabled) != null ? d : !1;
|
96
|
+
this.field = e.field, this.label = e.label, this.value = e.initValue, this.required = e.required, this.initValue = e.initValue, this.index = t, this.visible = e.visible ?? !0, this.span = e.span ?? K, this.render = e.render, this.tagFilter = e.tagFilter, this.transform = e.transform, this.enable = e.enable ?? !0, this.disabled = e.disabled ?? !1;
|
58
97
|
}
|
59
98
|
clean() {
|
60
99
|
Array.isArray(this.value) ? this.value = [] : this.value = void 0;
|
@@ -63,19 +102,22 @@ class Q {
|
|
63
102
|
this.value = this.initValue;
|
64
103
|
}
|
65
104
|
isEnable(e) {
|
66
|
-
return
|
105
|
+
return V(this.enable) ? this.enable(e.getSearchObject()) : this.enable;
|
67
106
|
}
|
68
107
|
isDisabled(e) {
|
69
|
-
return
|
108
|
+
return V(this.disabled) ? this.disabled(e.getSearchObject()) : this.disabled;
|
70
109
|
}
|
71
110
|
}
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
111
|
+
class x {
|
112
|
+
field;
|
113
|
+
span;
|
114
|
+
index;
|
115
|
+
visible;
|
116
|
+
constructor(e, t, r, i) {
|
117
|
+
this.field = e, this.span = t, this.index = r, this.visible = i;
|
76
118
|
}
|
77
119
|
static fromSearchItem(e, t) {
|
78
|
-
return new
|
120
|
+
return new x(
|
79
121
|
e.field,
|
80
122
|
e.span,
|
81
123
|
t ?? e.index,
|
@@ -83,17 +125,16 @@ class g {
|
|
83
125
|
);
|
84
126
|
}
|
85
127
|
static formSearchConfig(e, t) {
|
86
|
-
|
87
|
-
return new g(
|
128
|
+
return new x(
|
88
129
|
e.field,
|
89
|
-
|
130
|
+
e.span ?? K,
|
90
131
|
t ?? e,
|
91
|
-
|
132
|
+
e.visible ?? !0
|
92
133
|
);
|
93
134
|
}
|
94
135
|
static fromString(e) {
|
95
|
-
const [t,
|
96
|
-
return new
|
136
|
+
const [t, r, i, n] = e.split("_");
|
137
|
+
return new x(r, Number(i), Number(t), n === "true");
|
97
138
|
}
|
98
139
|
toString() {
|
99
140
|
return `${this.index}_${this.field}_${this.span}_${this.visible}`;
|
@@ -102,33 +143,37 @@ class g {
|
|
102
143
|
this.span = e.span, this.index = e.index, this.visible = e.visible;
|
103
144
|
}
|
104
145
|
}
|
105
|
-
const
|
106
|
-
class
|
146
|
+
const O = (s) => `searches_layouts_${s}`;
|
147
|
+
class he {
|
148
|
+
id;
|
149
|
+
state;
|
150
|
+
itemLayouts;
|
151
|
+
initialLayouts;
|
107
152
|
constructor(e, t) {
|
108
|
-
|
153
|
+
this.id = e.id, this.initialLayouts = t, this.state = e, this.itemLayouts = M(e.items.map(x.fromSearchItem), (r) => r.field), this.restoreCachedLayouts();
|
109
154
|
}
|
110
155
|
/**
|
111
156
|
* 恢复自缓存中的布局信息
|
112
157
|
* @private
|
113
158
|
*/
|
114
159
|
restoreCachedLayouts() {
|
115
|
-
const e = localStorage.getItem(
|
160
|
+
const e = localStorage.getItem(O(this.id));
|
116
161
|
e && e.split(",").forEach((t) => {
|
117
|
-
const
|
118
|
-
|
162
|
+
const r = x.fromString(t), i = this.itemLayouts[r.field];
|
163
|
+
i && i.merge(r);
|
119
164
|
});
|
120
165
|
}
|
121
166
|
sync(e, t) {
|
122
167
|
if (e.length !== Object.keys(this.itemLayouts).length)
|
123
168
|
throw new Error("同步布局字段数量不一致");
|
124
|
-
e.forEach((
|
125
|
-
const
|
126
|
-
|
169
|
+
e.forEach((r, i) => {
|
170
|
+
const n = this.itemLayouts[r];
|
171
|
+
n.index = i, n.visible = t.has(r);
|
127
172
|
});
|
128
173
|
}
|
129
174
|
persistent() {
|
130
175
|
localStorage.setItem(
|
131
|
-
|
176
|
+
O(this.id),
|
132
177
|
Object.values(this.itemLayouts).map((e) => e.toString()).join(",")
|
133
178
|
), this.state.updateTags();
|
134
179
|
}
|
@@ -139,126 +184,132 @@ class ee {
|
|
139
184
|
});
|
140
185
|
}
|
141
186
|
}
|
142
|
-
|
143
|
-
const ie = [
|
187
|
+
const fe = [
|
144
188
|
{
|
145
|
-
isApply(
|
146
|
-
return
|
189
|
+
isApply(s) {
|
190
|
+
return s.contains("el-radio-group");
|
147
191
|
},
|
148
|
-
getText(
|
149
|
-
|
150
|
-
return (t = (e = i.querySelector(".is-active")) == null ? void 0 : e.querySelector("input")) == null ? void 0 : t.value;
|
192
|
+
getText(s) {
|
193
|
+
return s.querySelector(".is-active")?.querySelector("input")?.value;
|
151
194
|
}
|
152
195
|
},
|
153
196
|
{
|
154
|
-
isApply(
|
155
|
-
return
|
197
|
+
isApply(s) {
|
198
|
+
return s.contains("el-checkbox-group");
|
156
199
|
},
|
157
|
-
getText(
|
158
|
-
|
159
|
-
|
160
|
-
var r;
|
161
|
-
return (r = s.querySelector("input")) == null ? void 0 : r.value;
|
162
|
-
}).filter((s) => s);
|
163
|
-
return t.length === 1 ? t[0] : `${t[0]} 等${t.length}条`;
|
200
|
+
getText(s) {
|
201
|
+
const e = Array.from(s.querySelectorAll(".el-checkbox__input.is-checked") ?? []).map((t) => t.querySelector("input")?.value).filter((t) => t);
|
202
|
+
return e.length === 1 ? e[0] : `${e[0]} 等${e.length}条`;
|
164
203
|
}
|
165
204
|
},
|
166
205
|
{
|
167
|
-
isApply(
|
168
|
-
return
|
206
|
+
isApply(s) {
|
207
|
+
return s.contains("el-input");
|
169
208
|
},
|
170
|
-
getText(
|
209
|
+
getText(s, e) {
|
171
210
|
return e.value;
|
172
211
|
}
|
173
212
|
},
|
174
213
|
{
|
175
|
-
isApply(
|
176
|
-
return
|
214
|
+
isApply(s) {
|
215
|
+
return s.contains("el-input-number");
|
177
216
|
},
|
178
|
-
getText(
|
217
|
+
getText(s, e) {
|
179
218
|
return e.value;
|
180
219
|
}
|
181
220
|
},
|
182
221
|
{
|
183
|
-
isApply(
|
184
|
-
return
|
222
|
+
isApply(s) {
|
223
|
+
return s.contains("el-select");
|
185
224
|
},
|
186
|
-
getText(
|
187
|
-
|
188
|
-
|
189
|
-
return s.length > 0 ? e.value.length > 1 ? `${s[0].textContent} 等${e.value.length}条` : s[0].textContent : (t = i.querySelector("input")) == null ? void 0 : t.value;
|
225
|
+
getText(s, e) {
|
226
|
+
const t = s.querySelectorAll(".el-select__tags-text");
|
227
|
+
return t.length > 0 ? e.value.length > 1 ? `${t[0].textContent} 等${e.value.length}条` : t[0].textContent : s.querySelector(".el-select__placeholder")?.innerHTML;
|
190
228
|
}
|
191
229
|
},
|
192
230
|
{
|
193
|
-
isApply(
|
194
|
-
return
|
231
|
+
isApply(s) {
|
232
|
+
return s.contains("el-cascader");
|
195
233
|
},
|
196
|
-
getText(
|
197
|
-
|
198
|
-
return (e = i.querySelector("input")) == null ? void 0 : e.value;
|
234
|
+
getText(s) {
|
235
|
+
return s.querySelector("input")?.value;
|
199
236
|
}
|
200
237
|
},
|
201
238
|
{
|
202
|
-
isApply(
|
203
|
-
return
|
239
|
+
isApply(s) {
|
240
|
+
return s.contains("el-switch");
|
204
241
|
},
|
205
|
-
getText(
|
206
|
-
return
|
242
|
+
getText(s) {
|
243
|
+
return s.querySelector(".is-active").innerHTML;
|
207
244
|
}
|
208
245
|
},
|
209
246
|
{
|
210
|
-
isApply(
|
211
|
-
return
|
247
|
+
isApply(s) {
|
248
|
+
return s.contains("el-slider");
|
212
249
|
},
|
213
|
-
getText(
|
250
|
+
getText(s, e) {
|
214
251
|
return e.value;
|
215
252
|
}
|
216
253
|
},
|
217
254
|
{
|
218
|
-
isApply(
|
219
|
-
return
|
255
|
+
isApply(s) {
|
256
|
+
return s.contains("el-date-editor");
|
220
257
|
},
|
221
|
-
getText(
|
258
|
+
getText(s, e) {
|
222
259
|
return e.value ? e.value.join(" ~ ") : e.value;
|
223
260
|
}
|
224
261
|
}
|
225
262
|
];
|
226
|
-
class
|
263
|
+
class R {
|
264
|
+
id;
|
265
|
+
field;
|
266
|
+
value;
|
267
|
+
label;
|
268
|
+
valueText;
|
269
|
+
required;
|
270
|
+
item;
|
271
|
+
state;
|
227
272
|
constructor(e, t) {
|
228
|
-
|
229
|
-
var s;
|
230
|
-
this.id = `#${e.id}-${t.field}`, this.state = e, this.field = t.field, this.value = t.value, this.label = t.label, this.item = t, this.required = (s = t.required) != null ? s : !1, this.updateValueText();
|
273
|
+
this.id = `#${e.id}-${t.field}`, this.state = e, this.field = t.field, this.value = t.value, this.label = t.label, this.item = t, this.required = t.required ?? !1, this.updateValueText();
|
231
274
|
}
|
232
275
|
static hasValue(e) {
|
233
|
-
return
|
276
|
+
return z(e.value) || P(e.value) ? !0 : !U(e.value);
|
234
277
|
}
|
235
278
|
updateValueText() {
|
236
279
|
const e = document.querySelector(this.id);
|
237
280
|
if (e.children.length !== 1)
|
238
281
|
throw new Error("holder children length is not 1");
|
239
|
-
const t = e.children[0],
|
240
|
-
|
282
|
+
const t = e.children[0], r = fe.find((i) => i.isApply(t.classList));
|
283
|
+
r && (this.valueText = r.getText(t, this));
|
241
284
|
}
|
242
285
|
async clean() {
|
243
286
|
this.item.clean(), await this.state.doSearch();
|
244
287
|
}
|
245
288
|
}
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
289
|
+
class pe {
|
290
|
+
constructor(e, t, r) {
|
291
|
+
this.id = e, this.id = e, this.items = t.map((i, n) => new de(i, n)), this.config = H(
|
292
|
+
new he(
|
293
|
+
this,
|
294
|
+
t.map((i, n) => x.formSearchConfig(i, n))
|
295
|
+
)
|
296
|
+
), this.sourceSearchable = t, this.searching = !1, this.searchCallback = r, this.tags = [];
|
297
|
+
}
|
298
|
+
items;
|
299
|
+
config;
|
300
|
+
searching;
|
301
|
+
tags;
|
302
|
+
searchCallback;
|
303
|
+
sourceSearchable;
|
304
|
+
_lastSearchObject = { time: 0, data: null };
|
254
305
|
updateTags() {
|
255
|
-
this.tags = this.items.filter((e) => e.tagFilter ? e.tagFilter(e.value) :
|
306
|
+
this.tags = this.items.filter((e) => e.tagFilter ? e.tagFilter(e.value) : R.hasValue(e)).map((e) => new R(this, e)).sort(
|
256
307
|
(e, t) => this.config.itemLayouts[e.field].index - this.config.itemLayouts[t.field].index
|
257
308
|
);
|
258
309
|
}
|
259
310
|
getSearchObject(e) {
|
260
311
|
const t = Date.now();
|
261
|
-
return this._lastSearchObject.data && t - this._lastSearchObject.time < 50 ? this._lastSearchObject.data : (this._lastSearchObject = { time: t, data:
|
312
|
+
return this._lastSearchObject.data && t - this._lastSearchObject.time < 50 ? this._lastSearchObject.data : (this._lastSearchObject = { time: t, data: E.from(this.items).toCondition(e) }, this._lastSearchObject.data);
|
262
313
|
}
|
263
314
|
async doSearch() {
|
264
315
|
if (!this.searching)
|
@@ -272,198 +323,286 @@ class ne {
|
|
272
323
|
this.items.forEach((t) => t.reset()), e && await this.doSearch();
|
273
324
|
}
|
274
325
|
setSearchValue(e, t) {
|
275
|
-
const
|
276
|
-
|
326
|
+
const r = this.items.find((i) => i.field === e);
|
327
|
+
r && (r.value = t);
|
277
328
|
}
|
278
329
|
}
|
279
|
-
const
|
280
|
-
|
281
|
-
props
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
},
|
286
|
-
api: {
|
287
|
-
type: Object
|
288
|
-
}
|
289
|
-
},
|
290
|
-
render(i, e) {
|
291
|
-
const { props: t } = e, s = t.search.render(t.search);
|
292
|
-
return s.componentOptions.propsData || (s.componentOptions.propsData = {}), s.componentOptions.propsData.disabled = t.search.isDisabled(t.api), s;
|
293
|
-
}
|
294
|
-
}, oe = () => {
|
295
|
-
const i = V(), e = h(), t = h([]), s = h(!1), r = h(), a = h([]), d = h(300), c = (o) => {
|
296
|
-
i.value = o, t.value = [
|
330
|
+
const me = ({ search: s, api: e }) => {
|
331
|
+
const t = s.render(s);
|
332
|
+
return t.props || (t.props = {}), s.isDisabled(e) && (t.props.disabled = !0), t;
|
333
|
+
}, ge = () => {
|
334
|
+
const s = J(), e = y(), t = y([]), r = y(!1), i = y(), n = y([]), p = y(300), d = (a) => {
|
335
|
+
s.value = a, t.value = [
|
297
336
|
{
|
298
337
|
label: "全部",
|
299
338
|
id: "all",
|
300
|
-
children:
|
301
|
-
(
|
302
|
-
).map((
|
303
|
-
label:
|
304
|
-
id:
|
305
|
-
disabled: !
|
339
|
+
children: s.value.items.sort(
|
340
|
+
(h, v) => a.config.itemLayouts[h.field].index - a.config.itemLayouts[v.field].index
|
341
|
+
).map((h) => ({
|
342
|
+
label: h.label,
|
343
|
+
id: h.field,
|
344
|
+
disabled: !h.isEnable(a)
|
306
345
|
}))
|
307
346
|
}
|
308
|
-
],
|
347
|
+
], i.value = G(a.config.itemLayouts).pickBy((h) => h.visible).keys().value();
|
309
348
|
};
|
310
349
|
return {
|
311
350
|
treeRef: e,
|
312
|
-
visible:
|
351
|
+
visible: r,
|
313
352
|
snapshot: t,
|
314
|
-
defaultCheckedKeys:
|
315
|
-
drawerWidth:
|
316
|
-
updateSnapshot:
|
317
|
-
show: (
|
318
|
-
|
353
|
+
defaultCheckedKeys: i,
|
354
|
+
drawerWidth: p,
|
355
|
+
updateSnapshot: d,
|
356
|
+
show: (a) => {
|
357
|
+
d(a), r.value = !0;
|
319
358
|
},
|
320
359
|
save: () => {
|
321
|
-
|
322
|
-
t.value[0].children.map((
|
360
|
+
s.value.config.sync(
|
361
|
+
t.value[0].children.map((a) => a.id),
|
323
362
|
new Set(e.value.getCheckedKeys())
|
324
|
-
),
|
363
|
+
), s.value.config.persistent();
|
325
364
|
},
|
326
365
|
reset: () => {
|
327
|
-
|
366
|
+
s.value.config.reset(), d(s.value);
|
328
367
|
},
|
329
368
|
keepSelection: () => {
|
330
|
-
|
369
|
+
n.value = e.value.getCheckedKeys();
|
331
370
|
},
|
332
371
|
restoreSelection: () => {
|
333
|
-
e.value.setCheckedKeys(
|
372
|
+
e.value.setCheckedKeys(n.value), n.value = [];
|
334
373
|
},
|
335
|
-
allowDrop: (
|
336
|
-
allowDrag: (
|
374
|
+
allowDrop: (a, h, v) => v !== "inner",
|
375
|
+
allowDrag: (a) => !a.disabled
|
337
376
|
};
|
338
|
-
},
|
377
|
+
}, ve = /* @__PURE__ */ D({
|
339
378
|
__name: "SearchSettingsDrawer",
|
340
|
-
setup(
|
379
|
+
setup(s, { expose: e }) {
|
341
380
|
const {
|
342
381
|
treeRef: t,
|
343
|
-
visible:
|
344
|
-
snapshot:
|
345
|
-
drawerWidth:
|
346
|
-
defaultCheckedKeys:
|
347
|
-
show:
|
348
|
-
allowDrop:
|
349
|
-
allowDrag:
|
350
|
-
keepSelection:
|
351
|
-
restoreSelection:
|
352
|
-
save:
|
353
|
-
reset:
|
354
|
-
} =
|
382
|
+
visible: r,
|
383
|
+
snapshot: i,
|
384
|
+
drawerWidth: n,
|
385
|
+
defaultCheckedKeys: p,
|
386
|
+
show: d,
|
387
|
+
allowDrop: m,
|
388
|
+
allowDrag: T,
|
389
|
+
keepSelection: k,
|
390
|
+
restoreSelection: $,
|
391
|
+
save: S,
|
392
|
+
reset: l
|
393
|
+
} = ge();
|
355
394
|
return e({
|
356
|
-
show:
|
357
|
-
}),
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
},
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
)
|
373
|
-
|
395
|
+
show: d
|
396
|
+
}), (C, a) => {
|
397
|
+
const h = g("el-tree"), v = g("el-button"), _ = g("el-drawer");
|
398
|
+
return f(), w(_, {
|
399
|
+
class: "search-setting",
|
400
|
+
size: u(n),
|
401
|
+
title: "搜索项配置",
|
402
|
+
modelValue: u(r),
|
403
|
+
"onUpdate:modelValue": a[0] || (a[0] = (I) => Q(r) ? r.value = I : null)
|
404
|
+
}, {
|
405
|
+
footer: c(() => [
|
406
|
+
o(v, { onClick: u(l) }, {
|
407
|
+
default: c(() => [...a[1] || (a[1] = [
|
408
|
+
L("重置", -1)
|
409
|
+
])]),
|
410
|
+
_: 1
|
411
|
+
}, 8, ["onClick"]),
|
412
|
+
o(v, {
|
413
|
+
type: "primary",
|
414
|
+
onClick: u(S)
|
415
|
+
}, {
|
416
|
+
default: c(() => [...a[2] || (a[2] = [
|
417
|
+
L("保存", -1)
|
418
|
+
])]),
|
419
|
+
_: 1
|
420
|
+
}, 8, ["onClick"])
|
421
|
+
]),
|
422
|
+
default: c(() => [
|
423
|
+
o(h, {
|
424
|
+
class: "tree",
|
425
|
+
"default-expand-all": "",
|
426
|
+
"default-checked-keys": u(p),
|
427
|
+
"node-key": "id",
|
428
|
+
ref_key: "treeRef",
|
429
|
+
ref: t,
|
430
|
+
draggable: "",
|
431
|
+
"show-checkbox": "",
|
432
|
+
data: u(i),
|
433
|
+
onNodeDragStart: u(k),
|
434
|
+
onNodeDragEnd: u($),
|
435
|
+
"allow-drop": u(m),
|
436
|
+
"allow-drag": u(T)
|
437
|
+
}, null, 8, ["default-checked-keys", "data", "onNodeDragStart", "onNodeDragEnd", "allow-drop", "allow-drag"])
|
438
|
+
]),
|
439
|
+
_: 1
|
440
|
+
}, 8, ["size", "modelValue"]);
|
441
|
+
};
|
442
|
+
}
|
443
|
+
}), ye = /* @__PURE__ */ D({
|
374
444
|
__name: "SettingButton",
|
375
445
|
props: {
|
376
|
-
state:
|
446
|
+
state: {}
|
377
447
|
},
|
378
|
-
setup(
|
379
|
-
const e =
|
380
|
-
return { __sfc: !0, props: e, searchSettingDialogRef: t, showSearchLayoutDialog: () => {
|
448
|
+
setup(s) {
|
449
|
+
const e = s, t = y(), r = () => {
|
381
450
|
t.value.show(e.state);
|
382
|
-
}
|
451
|
+
};
|
452
|
+
return (i, n) => {
|
453
|
+
const p = g("el-icon"), d = g("el-button");
|
454
|
+
return f(), w(d, {
|
455
|
+
class: "icon-button",
|
456
|
+
onClick: r
|
457
|
+
}, {
|
458
|
+
default: c(() => [
|
459
|
+
o(p, null, {
|
460
|
+
default: c(() => [
|
461
|
+
o(u(le))
|
462
|
+
]),
|
463
|
+
_: 1
|
464
|
+
}),
|
465
|
+
o(ve, {
|
466
|
+
ref_key: "searchSettingDialogRef",
|
467
|
+
ref: t
|
468
|
+
}, null, 512)
|
469
|
+
]),
|
470
|
+
_: 1
|
471
|
+
});
|
472
|
+
};
|
383
473
|
}
|
384
|
-
})
|
385
|
-
var ve = function() {
|
386
|
-
var e = this, t = e._self._c, s = e._self._setupProxy;
|
387
|
-
return t("div", { staticStyle: { "margin-right": "10px" } }, [t("el-button", { staticClass: "icon-button", staticStyle: { height: "100%" }, on: { click: s.showSearchLayoutDialog } }, [t("i", { staticClass: "el-icon-s-tools" })]), t(s.SearchSettingsDrawer, { ref: "searchSettingDialogRef" })], 1);
|
388
|
-
}, _e = [], me = /* @__PURE__ */ x(
|
389
|
-
pe,
|
390
|
-
ve,
|
391
|
-
_e,
|
392
|
-
!1,
|
393
|
-
null,
|
394
|
-
"61aa7563"
|
395
|
-
);
|
396
|
-
const ge = me.exports, be = /* @__PURE__ */ y({
|
474
|
+
}), _e = { class: "search-bar-container" }, be = { class: "search-item" }, Se = { class: "search-item-title" }, we = ["id"], xe = { class: "search-bottom" }, ke = { class: "actions" }, $e = /* @__PURE__ */ D({
|
397
475
|
__name: "SearchBar",
|
398
476
|
props: {
|
399
|
-
searches:
|
400
|
-
id:
|
401
|
-
onSearch: {
|
477
|
+
searches: {},
|
478
|
+
id: {},
|
479
|
+
onSearch: {},
|
402
480
|
defaultSpan: { default: 6 },
|
403
481
|
maxRows: { default: 2 },
|
404
482
|
itemHeight: { default: 67 },
|
405
483
|
resetAutoSearch: { type: Boolean, default: !0 }
|
406
484
|
},
|
407
485
|
emits: ["change"],
|
408
|
-
setup(
|
409
|
-
const
|
410
|
-
|
411
|
-
const
|
412
|
-
|
486
|
+
setup(s, { expose: e, emit: t }) {
|
487
|
+
const r = s, i = H(new pe(r.id, r.searches, r.onSearch)), n = y(!1), p = j(() => W(Array.from(Object.values(i.config.itemLayouts)).filter((l) => l.visible).map((l) => l.span)) / 24 > r.maxRows), d = y([]), m = t;
|
488
|
+
ae(() => i.items, () => {
|
489
|
+
const S = [...i.items];
|
490
|
+
d.value = S.sort((l, C) => i.config.itemLayouts[l.field].index - i.config.itemLayouts[C.field].index).filter((l) => i.config.itemLayouts[l.field].visible).filter((l) => l.isEnable(i)), m("change", i.getSearchObject(), i);
|
413
491
|
}, { debounce: 100, immediate: !0, deep: !0 });
|
414
|
-
const
|
415
|
-
height: `${
|
492
|
+
const T = j(() => ({
|
493
|
+
height: `${r.itemHeight * r.maxRows}px`,
|
416
494
|
overflow: "hidden"
|
417
|
-
})),
|
495
|
+
})), k = (S) => i.config.itemLayouts[S.field];
|
418
496
|
return e({
|
419
|
-
getSearchItems:
|
420
|
-
}),
|
497
|
+
getSearchItems: () => i.items
|
498
|
+
}), (S, l) => {
|
499
|
+
const C = g("el-col"), a = g("el-row"), h = g("el-icon"), v = g("el-button");
|
500
|
+
return f(), A("div", _e, [
|
501
|
+
o(a, {
|
502
|
+
class: Z("search"),
|
503
|
+
style: Y(p.value && !n.value ? T.value : {}),
|
504
|
+
gutter: 16
|
505
|
+
}, {
|
506
|
+
default: c(() => [
|
507
|
+
(f(!0), A(N, null, B(d.value, (_) => ee((f(), w(C, {
|
508
|
+
span: k(_).span,
|
509
|
+
key: _.field
|
510
|
+
}, {
|
511
|
+
default: c(() => [
|
512
|
+
b("div", be, [
|
513
|
+
b("div", Se, F(_.label), 1),
|
514
|
+
b("div", {
|
515
|
+
id: `${s.id}-${_.field}`,
|
516
|
+
class: "search-item-content"
|
517
|
+
}, [
|
518
|
+
o(u(me), {
|
519
|
+
search: _,
|
520
|
+
api: i
|
521
|
+
}, null, 8, ["search", "api"])
|
522
|
+
], 8, we)
|
523
|
+
])
|
524
|
+
]),
|
525
|
+
_: 2
|
526
|
+
}, 1032, ["span"])), [
|
527
|
+
[te, k(_).visible]
|
528
|
+
])), 128))
|
529
|
+
]),
|
530
|
+
_: 1
|
531
|
+
}, 8, ["style"]),
|
532
|
+
b("div", xe, [
|
533
|
+
i.tags.length > 0 ? (f(), w(ue, {
|
534
|
+
key: 0,
|
535
|
+
tags: i.tags
|
536
|
+
}, null, 8, ["tags"])) : q("", !0),
|
537
|
+
b("div", ke, [
|
538
|
+
p.value ? (f(), w(v, {
|
539
|
+
key: 0,
|
540
|
+
class: "icon-button",
|
541
|
+
onClick: l[0] || (l[0] = (_) => n.value = !n.value)
|
542
|
+
}, {
|
543
|
+
default: c(() => [
|
544
|
+
o(h, null, {
|
545
|
+
default: c(() => [
|
546
|
+
n.value ? (f(), w(u(ne), { key: 1 })) : (f(), w(u(re), { key: 0 }))
|
547
|
+
]),
|
548
|
+
_: 1
|
549
|
+
})
|
550
|
+
]),
|
551
|
+
_: 1
|
552
|
+
})) : q("", !0),
|
553
|
+
o(ye, { state: i }, null, 8, ["state"]),
|
554
|
+
o(v, {
|
555
|
+
onClick: l[1] || (l[1] = () => i.reset(s.resetAutoSearch))
|
556
|
+
}, {
|
557
|
+
default: c(() => [...l[3] || (l[3] = [
|
558
|
+
L("重 置", -1)
|
559
|
+
])]),
|
560
|
+
_: 1
|
561
|
+
}),
|
562
|
+
o(v, {
|
563
|
+
type: "primary",
|
564
|
+
loading: i.searching,
|
565
|
+
disabled: i.searching,
|
566
|
+
onClick: l[2] || (l[2] = () => i.doSearch())
|
567
|
+
}, {
|
568
|
+
default: c(() => [...l[4] || (l[4] = [
|
569
|
+
L("搜 索", -1)
|
570
|
+
])]),
|
571
|
+
_: 1
|
572
|
+
}, 8, ["loading", "disabled"])
|
573
|
+
])
|
574
|
+
])
|
575
|
+
]);
|
576
|
+
};
|
421
577
|
}
|
422
578
|
});
|
423
|
-
|
424
|
-
|
425
|
-
return t("div", { staticClass: "search-bar-container" }, [t("el-row", { class: "search", style: s.isShowSpanIcon && !s.expanded ? s.itemHeightStyle : {}, attrs: { gutter: 16 } }, e._l(s.sortedItems, function(r) {
|
426
|
-
return t("el-col", { directives: [{ name: "show", rawName: "v-show", value: s.getLayout(r).visible, expression: "getLayout(item).visible" }], key: r.field, attrs: { span: s.getLayout(r).span } }, [t("div", { staticClass: "search-item" }, [t("div", { staticClass: "search-item-title" }, [e._v(e._s(r.label))]), t("div", { staticClass: "search-item-content", attrs: { id: `${e.id}-${r.field}` } }, [t(s.SearchItemRender, { attrs: { search: r, api: s.state } })], 1)])]);
|
427
|
-
}), 1), t("div", { staticClass: "search-bottom" }, [s.state.tags.length > 0 ? t(s.SearchTagsRender, { attrs: { tags: s.state.tags } }) : e._e(), t("div", { staticClass: "actions" }, [s.isShowSpanIcon ? t("el-button", { staticClass: "icon-button", staticStyle: { "margin-right": "10px" }, on: { click: function(r) {
|
428
|
-
s.expanded = !s.expanded;
|
429
|
-
} } }, [t("i", { class: [s.expanded ? "el-icon-arrow-up" : "el-icon-arrow-down"] })]) : e._e(), t(s.SettingButton, { attrs: { state: s.state } }), t("el-button", { on: { click: () => s.state.reset(e.resetAutoSearch) } }, [e._v("重 置")]), t("el-button", { attrs: { type: "primary", loading: s.state.searching, disabled: s.state.searching }, on: { click: () => s.state.doSearch() } }, [e._v("搜 索")])], 1)], 1)], 1);
|
430
|
-
}, Se = [], we = /* @__PURE__ */ x(
|
431
|
-
be,
|
432
|
-
ye,
|
433
|
-
Se,
|
434
|
-
!1,
|
435
|
-
null,
|
436
|
-
null
|
437
|
-
);
|
438
|
-
const Fe = we.exports;
|
439
|
-
var xe = Object.defineProperty, Ce = (i, e, t) => e in i ? xe(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t, $e = (i, e, t) => Ce(i, e + "", t);
|
440
|
-
class $ {
|
579
|
+
class E {
|
580
|
+
record;
|
441
581
|
constructor(e) {
|
442
|
-
|
582
|
+
this.record = e;
|
443
583
|
}
|
444
584
|
static from(e) {
|
445
|
-
const t = e.filter((
|
446
|
-
(
|
447
|
-
const
|
585
|
+
const t = e.filter((r) => r.value === void 0 ? !1 : Array.isArray(r.value) ? r.value.length > 0 : !0).reduce(
|
586
|
+
(r, i) => {
|
587
|
+
const n = i.transform ? i.transform(i.value) : i.value;
|
448
588
|
return {
|
449
|
-
...
|
450
|
-
...
|
589
|
+
...r,
|
590
|
+
...X(n) ? n : { [i.field]: n }
|
451
591
|
};
|
452
592
|
},
|
453
593
|
{}
|
454
594
|
);
|
455
|
-
return new
|
595
|
+
return new E(t);
|
456
596
|
}
|
457
597
|
transform(e, t) {
|
458
|
-
const
|
459
|
-
return delete this.record[e], this.record = { ...this.record, ...
|
598
|
+
const r = this.record[e], i = t(r);
|
599
|
+
return delete this.record[e], this.record = { ...this.record, ...i }, this;
|
460
600
|
}
|
461
601
|
toCondition(e) {
|
462
602
|
return { ...this.record, ...e };
|
463
603
|
}
|
464
604
|
}
|
465
605
|
export {
|
466
|
-
|
467
|
-
|
468
|
-
Ae as vModel
|
606
|
+
$e as SearchBar,
|
607
|
+
E as Searches
|
469
608
|
};
|