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