@scvzerng/element-plus-search-vue2 0.0.16 → 0.0.17
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 +131 -131
- package/dist/ElementPlusSearch.umd.js +1 -1
- package/package.json +1 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { get as V, set as Y, sum as U, isFunction as E, keyBy as q, isNumber as Q, isBoolean as M, isEmpty as $, isPlainObject as X } from "lodash-unified";
|
|
2
2
|
import { defineComponent as S, ref as h, shallowRef as H, inject as P, reactive as K, computed as T, provide as F } from "vue";
|
|
3
3
|
import { useMutationObserver as j, useDebounceFn as z, watchDebounced as W } from "@vueuse/core";
|
|
4
|
-
const Me = (
|
|
4
|
+
const Me = (r) => ({
|
|
5
5
|
model: {
|
|
6
|
-
value: V(
|
|
6
|
+
value: V(r, "value"),
|
|
7
7
|
callback: (e) => {
|
|
8
|
-
Y(
|
|
8
|
+
Y(r, "value", e);
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
11
|
}), G = S({
|
|
@@ -15,10 +15,10 @@ const Me = (i) => ({
|
|
|
15
15
|
props: {
|
|
16
16
|
tags: null
|
|
17
17
|
},
|
|
18
|
-
setup(
|
|
19
|
-
const e =
|
|
18
|
+
setup(r) {
|
|
19
|
+
const e = r, t = h(), s = () => {
|
|
20
20
|
t.value.scrollBy({ left: -200, behavior: "smooth" });
|
|
21
|
-
},
|
|
21
|
+
}, i = () => {
|
|
22
22
|
t.value.scrollBy({
|
|
23
23
|
left: 200,
|
|
24
24
|
behavior: "smooth"
|
|
@@ -35,20 +35,20 @@ const Me = (i) => ({
|
|
|
35
35
|
a.value = l() > u();
|
|
36
36
|
},
|
|
37
37
|
{ subtree: !0, childList: !0, attributes: !0 }
|
|
38
|
-
), { __sfc: !0, props: e, scrollContainer: t, scrollLeft: s, scrollRight:
|
|
38
|
+
), { __sfc: !0, props: e, scrollContainer: t, scrollLeft: s, scrollRight: i, showScrollBar: a, getTagsWidth: l, getContainerWidth: u };
|
|
39
39
|
}
|
|
40
40
|
});
|
|
41
|
-
function x(
|
|
42
|
-
var c = typeof
|
|
41
|
+
function x(r, e, t, s, i, a, l, u) {
|
|
42
|
+
var c = typeof r == "function" ? r.options : r;
|
|
43
43
|
return e && (c.render = e, c.staticRenderFns = t, c._compiled = !0), a && (c._scopeId = "data-v-" + a), {
|
|
44
|
-
exports:
|
|
44
|
+
exports: r,
|
|
45
45
|
options: c
|
|
46
46
|
};
|
|
47
47
|
}
|
|
48
48
|
var Z = function() {
|
|
49
49
|
var e = this, t = e._self._c, s = e._self._setupProxy;
|
|
50
|
-
return t("div", { staticClass: "tags-scroll-container" }, [t("el-tag", { directives: [{ name: "show", rawName: "v-show", value: s.showScrollBar, expression: "showScrollBar" }], staticClass: "scroll-left-bar", attrs: { "disable-transitions": "", 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(
|
|
51
|
-
return t("el-tag", { key:
|
|
50
|
+
return t("div", { staticClass: "tags-scroll-container" }, [t("el-tag", { directives: [{ name: "show", rawName: "v-show", value: s.showScrollBar, expression: "showScrollBar" }], staticClass: "scroll-left-bar", attrs: { "disable-transitions": "", 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) {
|
|
51
|
+
return t("el-tag", { key: i.field, staticClass: "search-tag", attrs: { "disable-transitions": "", 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) } })]);
|
|
52
52
|
}), 1), t("el-tag", { directives: [{ name: "show", rawName: "v-show", value: s.showScrollBar, expression: "showScrollBar" }], staticClass: "scroll-right-bar", attrs: { "disable-transitions": "", size: "medium", type: "info" }, on: { click: s.scrollRight } }, [t("i", { staticClass: "el-icon-arrow-right" })])], 1);
|
|
53
53
|
}, ee = [], te = /* @__PURE__ */ x(
|
|
54
54
|
J,
|
|
@@ -59,13 +59,13 @@ var Z = function() {
|
|
|
59
59
|
null
|
|
60
60
|
);
|
|
61
61
|
const se = te.exports;
|
|
62
|
-
var
|
|
62
|
+
var ie = Object.defineProperty, re = (r, e, t) => e in r ? ie(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, d = (r, e, t) => re(r, typeof e != "symbol" ? e + "" : e, t);
|
|
63
63
|
const N = 6;
|
|
64
64
|
class ae {
|
|
65
65
|
constructor(e, t) {
|
|
66
66
|
d(this, "field"), d(this, "label"), d(this, "value"), d(this, "required"), d(this, "index"), d(this, "visible"), d(this, "disabled"), d(this, "span"), d(this, "initValue"), d(this, "enable"), d(this, "pinned"), d(this, "tagFilter"), d(this, "render"), d(this, "transform"), d(this, "onChange");
|
|
67
|
-
var s,
|
|
68
|
-
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 = (
|
|
67
|
+
var s, i, a, l, u;
|
|
68
|
+
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 : N, this.render = e.render, this.tagFilter = e.tagFilter, this.transform = e.transform, this.enable = (a = e.enable) != null ? a : !0, this.disabled = (l = e.disabled) != null ? l : !1, this.pinned = (u = e.pinned) != null ? u : !1, e.onChange && (this.onChange = z((c, f) => e.onChange(c, f), 50));
|
|
69
69
|
}
|
|
70
70
|
clean() {
|
|
71
71
|
Array.isArray(this.value) ? this.value = [] : this.value = void 0;
|
|
@@ -80,10 +80,10 @@ class ae {
|
|
|
80
80
|
return E(this.disabled) ? this.disabled(e.getSearchObject()) : this.disabled;
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
|
-
var ne = Object.defineProperty, le = (
|
|
83
|
+
var ne = Object.defineProperty, le = (r, e, t) => e in r ? ne(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, p = (r, e, t) => le(r, typeof e != "symbol" ? e + "" : e, t);
|
|
84
84
|
class b {
|
|
85
|
-
constructor(e, t, s,
|
|
86
|
-
p(this, "field"), p(this, "span"), p(this, "index"), p(this, "visible"), p(this, "pinned"), this.field = e, this.span = t, this.index = s, this.visible =
|
|
85
|
+
constructor(e, t, s, i, a) {
|
|
86
|
+
p(this, "field"), p(this, "span"), p(this, "index"), p(this, "visible"), p(this, "pinned"), this.field = e, this.span = t, this.index = s, this.visible = i, this.pinned = a;
|
|
87
87
|
}
|
|
88
88
|
static fromSearchItem(e, t) {
|
|
89
89
|
return new b(
|
|
@@ -95,18 +95,18 @@ class b {
|
|
|
95
95
|
);
|
|
96
96
|
}
|
|
97
97
|
static formSearchConfig(e, t) {
|
|
98
|
-
var s,
|
|
98
|
+
var s, i, a;
|
|
99
99
|
return new b(
|
|
100
100
|
e.field,
|
|
101
101
|
(s = e.span) != null ? s : N,
|
|
102
102
|
t ?? e,
|
|
103
|
-
(
|
|
103
|
+
(i = e.visible) != null ? i : !0,
|
|
104
104
|
(a = e.pinned) != null ? a : !1
|
|
105
105
|
);
|
|
106
106
|
}
|
|
107
107
|
static fromString(e) {
|
|
108
|
-
const [t, s,
|
|
109
|
-
return new b(s, Number(
|
|
108
|
+
const [t, s, i, a, l] = e.split("_");
|
|
109
|
+
return new b(s, Number(i), Number(t), a === "true", l === "true");
|
|
110
110
|
}
|
|
111
111
|
toString() {
|
|
112
112
|
return `${this.index}_${this.field}_${this.span}_${this.visible}_${this.pinned}`;
|
|
@@ -115,7 +115,7 @@ class b {
|
|
|
115
115
|
this.span = e.span, this.index = e.index, this.visible = e.visible, this.pinned = e.pinned;
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
|
-
const B = (
|
|
118
|
+
const B = (r) => `searches_layouts_${r}`;
|
|
119
119
|
class oe {
|
|
120
120
|
constructor(e, t) {
|
|
121
121
|
p(this, "id"), p(this, "state"), p(this, "itemLayouts"), p(this, "initialLayouts"), this.id = e.id, this.initialLayouts = t, this.state = e, this.itemLayouts = q(e.items.map(b.fromSearchItem), (s) => s.field), this.restoreCachedLayouts();
|
|
@@ -127,16 +127,16 @@ class oe {
|
|
|
127
127
|
restoreCachedLayouts() {
|
|
128
128
|
const e = localStorage.getItem(B(this.id));
|
|
129
129
|
e && e.split(",").forEach((t) => {
|
|
130
|
-
const s = b.fromString(t),
|
|
131
|
-
|
|
130
|
+
const s = b.fromString(t), i = this.itemLayouts[s.field];
|
|
131
|
+
i && i.merge(s);
|
|
132
132
|
});
|
|
133
133
|
}
|
|
134
134
|
sync(e, t, s) {
|
|
135
135
|
if (e.length !== Object.keys(this.itemLayouts).length)
|
|
136
136
|
throw new Error("同步布局字段数量不一致");
|
|
137
|
-
e.forEach((
|
|
138
|
-
const l = this.itemLayouts[
|
|
139
|
-
l.index = a, l.visible = t.has(
|
|
137
|
+
e.forEach((i, a) => {
|
|
138
|
+
const l = this.itemLayouts[i];
|
|
139
|
+
l.index = a, l.visible = t.has(i), l.pinned = s.has(i);
|
|
140
140
|
});
|
|
141
141
|
}
|
|
142
142
|
persistent() {
|
|
@@ -152,86 +152,86 @@ class oe {
|
|
|
152
152
|
});
|
|
153
153
|
}
|
|
154
154
|
}
|
|
155
|
-
var ce = Object.defineProperty, ue = (
|
|
155
|
+
var ce = Object.defineProperty, ue = (r, e, t) => e in r ? ce(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, g = (r, e, t) => ue(r, typeof e != "symbol" ? e + "" : e, t);
|
|
156
156
|
const de = [
|
|
157
157
|
{
|
|
158
|
-
isApply(
|
|
159
|
-
return
|
|
158
|
+
isApply(r) {
|
|
159
|
+
return r.contains("el-radio-group");
|
|
160
160
|
},
|
|
161
|
-
getText(
|
|
161
|
+
getText(r) {
|
|
162
162
|
var e, t;
|
|
163
|
-
return (t = (e =
|
|
163
|
+
return (t = (e = r.querySelector(".is-active")) == null ? void 0 : e.querySelector("input")) == null ? void 0 : t.value;
|
|
164
164
|
}
|
|
165
165
|
},
|
|
166
166
|
{
|
|
167
|
-
isApply(
|
|
168
|
-
return
|
|
167
|
+
isApply(r) {
|
|
168
|
+
return r.contains("el-checkbox-group");
|
|
169
169
|
},
|
|
170
|
-
getText(
|
|
170
|
+
getText(r) {
|
|
171
171
|
var e;
|
|
172
|
-
const t = Array.from((e =
|
|
173
|
-
var
|
|
174
|
-
return (
|
|
172
|
+
const t = Array.from((e = r.querySelectorAll(".el-checkbox__input.is-checked")) != null ? e : []).map((s) => {
|
|
173
|
+
var i;
|
|
174
|
+
return (i = s.querySelector("input")) == null ? void 0 : i.value;
|
|
175
175
|
}).filter((s) => s);
|
|
176
176
|
return t.length === 1 ? t[0] : `${t[0]} 等${t.length}条`;
|
|
177
177
|
}
|
|
178
178
|
},
|
|
179
179
|
{
|
|
180
|
-
isApply(
|
|
181
|
-
return
|
|
180
|
+
isApply(r) {
|
|
181
|
+
return r.contains("el-input");
|
|
182
182
|
},
|
|
183
|
-
getText(
|
|
183
|
+
getText(r, e) {
|
|
184
184
|
return e.value;
|
|
185
185
|
}
|
|
186
186
|
},
|
|
187
187
|
{
|
|
188
|
-
isApply(
|
|
189
|
-
return
|
|
188
|
+
isApply(r) {
|
|
189
|
+
return r.contains("el-input-number");
|
|
190
190
|
},
|
|
191
|
-
getText(
|
|
191
|
+
getText(r, e) {
|
|
192
192
|
return e.value;
|
|
193
193
|
}
|
|
194
194
|
},
|
|
195
195
|
{
|
|
196
|
-
isApply(
|
|
197
|
-
return
|
|
196
|
+
isApply(r) {
|
|
197
|
+
return r.contains("el-select");
|
|
198
198
|
},
|
|
199
|
-
getText(
|
|
199
|
+
getText(r, e) {
|
|
200
200
|
var t;
|
|
201
|
-
const s =
|
|
202
|
-
return s.length > 0 ? e.value.length > 1 ? `${s[0].textContent} 等${e.value.length}条` : s[0].textContent : (t =
|
|
201
|
+
const s = r.querySelectorAll(".el-select__tags-text");
|
|
202
|
+
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;
|
|
203
203
|
}
|
|
204
204
|
},
|
|
205
205
|
{
|
|
206
|
-
isApply(
|
|
207
|
-
return
|
|
206
|
+
isApply(r) {
|
|
207
|
+
return r.contains("el-cascader");
|
|
208
208
|
},
|
|
209
|
-
getText(
|
|
209
|
+
getText(r) {
|
|
210
210
|
var e;
|
|
211
|
-
return (e =
|
|
211
|
+
return (e = r.querySelector("input")) == null ? void 0 : e.value;
|
|
212
212
|
}
|
|
213
213
|
},
|
|
214
214
|
{
|
|
215
|
-
isApply(
|
|
216
|
-
return
|
|
215
|
+
isApply(r) {
|
|
216
|
+
return r.contains("el-switch");
|
|
217
217
|
},
|
|
218
|
-
getText(
|
|
219
|
-
return
|
|
218
|
+
getText(r) {
|
|
219
|
+
return r.querySelector(".is-active").innerHTML;
|
|
220
220
|
}
|
|
221
221
|
},
|
|
222
222
|
{
|
|
223
|
-
isApply(
|
|
224
|
-
return
|
|
223
|
+
isApply(r) {
|
|
224
|
+
return r.contains("el-slider");
|
|
225
225
|
},
|
|
226
|
-
getText(
|
|
226
|
+
getText(r, e) {
|
|
227
227
|
return e.value;
|
|
228
228
|
}
|
|
229
229
|
},
|
|
230
230
|
{
|
|
231
|
-
isApply(
|
|
232
|
-
return
|
|
231
|
+
isApply(r) {
|
|
232
|
+
return r.contains("el-date-editor");
|
|
233
233
|
},
|
|
234
|
-
getText(
|
|
234
|
+
getText(r, e) {
|
|
235
235
|
return e.value ? e.value.join(" ~ ") : e.value;
|
|
236
236
|
}
|
|
237
237
|
}
|
|
@@ -251,19 +251,19 @@ class R {
|
|
|
251
251
|
return;
|
|
252
252
|
if (e.children.length !== 1)
|
|
253
253
|
throw new Error("holder children length is not 1");
|
|
254
|
-
const t = e.children[0], s = de.find((
|
|
254
|
+
const t = e.children[0], s = de.find((i) => i.isApply(t.classList));
|
|
255
255
|
s && (this.valueText = s.getText(t, this));
|
|
256
256
|
}
|
|
257
257
|
async clean() {
|
|
258
258
|
this.item.clean(), await this.state.doSearch();
|
|
259
259
|
}
|
|
260
260
|
}
|
|
261
|
-
var he = Object.defineProperty, pe = (
|
|
261
|
+
var he = Object.defineProperty, pe = (r, e, t) => e in r ? he(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, m = (r, e, t) => pe(r, typeof e != "symbol" ? e + "" : e, t);
|
|
262
262
|
class fe {
|
|
263
263
|
constructor(e, t, s) {
|
|
264
|
-
this.id = e, m(this, "items"), m(this, "config"), m(this, "searching"), m(this, "tags"), m(this, "searchCallback"), m(this, "sourceSearchable"), m(this, "_lastSearchObject", { time: 0, data: null }), this.id = e, this.items = t.map((
|
|
264
|
+
this.id = e, m(this, "items"), m(this, "config"), m(this, "searching"), m(this, "tags"), m(this, "searchCallback"), m(this, "sourceSearchable"), m(this, "_lastSearchObject", { time: 0, data: null }), this.id = e, this.items = t.map((i, a) => new ae(i, a)), this.config = new oe(
|
|
265
265
|
this,
|
|
266
|
-
t.map((
|
|
266
|
+
t.map((i, a) => b.formSearchConfig(i, a))
|
|
267
267
|
), this.sourceSearchable = t, this.searching = !1, this.searchCallback = s, this.tags = [];
|
|
268
268
|
}
|
|
269
269
|
updateSearchTag(e) {
|
|
@@ -290,18 +290,18 @@ class fe {
|
|
|
290
290
|
async reset(e) {
|
|
291
291
|
this.items.forEach((t) => t.reset()), e && await this.doSearch();
|
|
292
292
|
}
|
|
293
|
-
setSearchValue(e, t, s = (
|
|
294
|
-
const
|
|
295
|
-
|
|
293
|
+
setSearchValue(e, t, s = (i) => !0) {
|
|
294
|
+
const i = this.items.find((a) => a.field === e);
|
|
295
|
+
i && s && s(i.value) && (i.value = t);
|
|
296
296
|
}
|
|
297
297
|
}
|
|
298
298
|
const ve = () => {
|
|
299
|
-
const
|
|
300
|
-
|
|
299
|
+
const r = H(), e = h(), t = h([]), s = h(!1), i = h(), a = h([]), l = h(300), u = (n) => {
|
|
300
|
+
r.value = n, t.value = [
|
|
301
301
|
{
|
|
302
302
|
label: "全部",
|
|
303
303
|
id: "all",
|
|
304
|
-
children:
|
|
304
|
+
children: r.value.items.sort(
|
|
305
305
|
(o, v) => n.config.itemLayouts[o.field].index - n.config.itemLayouts[v.field].index
|
|
306
306
|
).map((o) => ({
|
|
307
307
|
label: o.label,
|
|
@@ -310,7 +310,7 @@ const ve = () => {
|
|
|
310
310
|
pinned: n.config.itemLayouts[o.field].pinned
|
|
311
311
|
}))
|
|
312
312
|
}
|
|
313
|
-
],
|
|
313
|
+
], i.value = Object.keys(n.config.itemLayouts).filter(
|
|
314
314
|
(o) => {
|
|
315
315
|
var v;
|
|
316
316
|
return (v = n.config.itemLayouts[o]) == null ? void 0 : v.visible;
|
|
@@ -321,21 +321,21 @@ const ve = () => {
|
|
|
321
321
|
treeRef: e,
|
|
322
322
|
visible: s,
|
|
323
323
|
snapshot: t,
|
|
324
|
-
defaultCheckedKeys:
|
|
324
|
+
defaultCheckedKeys: i,
|
|
325
325
|
drawerWidth: l,
|
|
326
326
|
updateSnapshot: u,
|
|
327
327
|
show: (n) => {
|
|
328
328
|
u(n), s.value = !0;
|
|
329
329
|
},
|
|
330
330
|
save: () => {
|
|
331
|
-
|
|
331
|
+
r.value.config.sync(
|
|
332
332
|
t.value[0].children.map((n) => n.id),
|
|
333
333
|
new Set(e.value.getCheckedKeys()),
|
|
334
334
|
new Set(t.value[0].children.filter((n) => n.pinned).map((n) => n.id))
|
|
335
|
-
),
|
|
335
|
+
), r.value.config.persistent(), s.value = !1;
|
|
336
336
|
},
|
|
337
337
|
reset: () => {
|
|
338
|
-
|
|
338
|
+
r.value.config.reset(), u(r.value);
|
|
339
339
|
},
|
|
340
340
|
keepSelection: () => {
|
|
341
341
|
a.value = e.value.getCheckedKeys();
|
|
@@ -359,11 +359,11 @@ const ve = () => {
|
|
|
359
359
|
};
|
|
360
360
|
}, ge = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAdlJREFUWEftlT9rFEEYxp/nJCii2NhYWNiLnV9CSGFtYGdGd4IkRUQMXhA9RSX+AYXTFLPH7mwO0ohW/vkAfgALsbSxuM7CRtDovrIQNcTkdmc9CchuuzPP83t/O8sQu/xwl/vRArQG/h8Dyti7KOSj98mdkD9rYgYiHT8jeRqFXA6BmByAOXeW6Aw2pu/61C3XMTEJACpjbwJY2lwoIpfyLLlfBfFXANba/V/X5QnIU9sV1YFoDKC1Plpw6iWB4+OmrIIIAShVd0XkEDqdFxB5SuDwtpMD31hwGhQlxOs8dY93ggwCiEw8JHim6ruikDnvk5XKdUDwZUSl4wFIs2O4YM1nrhpyIyDEwK9OZewDAAt/QAjeHjyw92S/3/9SZ/pyTSOASMfXSV7dUvLp+zpODIfuQ93yRgCRjrskbwNyUQTHSM6XQYXI9GqWPA8pDwZQxpbaS/0XfOoelgHKxA5gDGDRp+7ePwOItD1PYkVEruVZcmNTEZWJcxR4F3IH/Nxf6wz8Li9u5dngytYpe71eZzQa7XPOfZ64gUjPalJSAMs+dd3Qgqr1Yw3MzNgje6bwnsQjn7rFqrAm78cCKGOXCsib1TR51SS8zp5aZ6BOUNM1LUBroDXwAyP2oSHYDQ3tAAAAAElFTkSuQmCC", _e = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAc1JREFUWEftlT1oFUEUhb+zKEgQbGxSWNiLTUip82ohhbWFvl1EgiFExJAn4h8q8QdioYFIdoIEbEJSqWl3EUuxCJY29haCCBLx6kteBKPv7c7mSUB225l7znfPzN0Ru/xpl/2pAeoE/p8EXGr3FPExa+puyGT1LQHnbUVwEjEVAtE3gEZqCWJ+o3ujlSWaLpPEzgHM5Dy3JC5vM7yUxXpQBLEjgKE5G9i/lyXBiS5GhRCVAY57OxQZLxFHCrrsCVEeYDPqFuKAfedFJJYRB/9qbnwjYgTjDMarLNHjbpBBAA3PIuJU0bmaOJ83NVu0r71eHmDjdpvcAvOCuJu4wbM8ViHkVn0YQKeqkdoMYmI7hMHawGeGV8f1tUz34Ql0VJ23G4Krv5kYn9b3cPT1aX0oa14JwHlrCe6YcVHiMDDWMRzJYj0PMQ8GaKQ28XMKZjAuZIketgVcak8kzpoxmSe6/88AnLdRwazBtTzWzV9Gm+P5VBHvQt6AoEu4ZQ7czmJd+aPL6xYNDbLvzTl96XsCzltT4DGms0StUIOi/T3H8NiiDUbrvMd4lCeaLBKrst4TwKXWfuHe5olWq4iXqan0IyojXHZPDVAnUCfwAyFMiSGfgbcLAAAAAElFTkSuQmCC", me = /* @__PURE__ */ S({
|
|
361
361
|
__name: "SearchSettingsDrawer",
|
|
362
|
-
setup(
|
|
362
|
+
setup(r, { expose: e }) {
|
|
363
363
|
const {
|
|
364
364
|
treeRef: t,
|
|
365
365
|
visible: s,
|
|
366
|
-
snapshot:
|
|
366
|
+
snapshot: i,
|
|
367
367
|
drawerWidth: a,
|
|
368
368
|
defaultCheckedKeys: l,
|
|
369
369
|
show: u,
|
|
@@ -377,17 +377,17 @@ const ve = () => {
|
|
|
377
377
|
} = ve();
|
|
378
378
|
return e({
|
|
379
379
|
show: u
|
|
380
|
-
}), { __sfc: !0, treeRef: t, visible: s, snapshot:
|
|
380
|
+
}), { __sfc: !0, treeRef: t, visible: s, snapshot: i, drawerWidth: a, defaultCheckedKeys: l, show: u, allowDrop: c, allowDrag: f, keepSelection: A, restoreSelection: _, save: y, reset: w, onPinnedChange: C, pin: ge, activePin: _e };
|
|
381
381
|
}
|
|
382
382
|
});
|
|
383
383
|
var be = function() {
|
|
384
384
|
var e = this, t = e._self._c, s = e._self._setupProxy;
|
|
385
|
-
return t("el-drawer", { attrs: { size: s.drawerWidth, title: "搜索项配置", visible: s.visible, "modal-append-to-body": !0, "append-to-body": !0 }, on: { "update:visible": function(
|
|
386
|
-
s.visible =
|
|
387
|
-
} } }, [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, "expand-on-click-node": !1 }, on: { "node-drag-start": s.keepSelection, "node-drag-end": s.restoreSelection }, scopedSlots: e._u([{ key: "default", fn: function({ node:
|
|
388
|
-
return [t("span", { staticClass: "custom-tree-node" }, [t("span", [e._v(e._s(
|
|
389
|
-
return s.onPinnedChange(
|
|
390
|
-
} } }, [t("img", { attrs: { src:
|
|
385
|
+
return t("el-drawer", { attrs: { size: s.drawerWidth, title: "搜索项配置", visible: s.visible, "modal-append-to-body": !0, "append-to-body": !0 }, on: { "update:visible": function(i) {
|
|
386
|
+
s.visible = i;
|
|
387
|
+
} } }, [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, "expand-on-click-node": !1 }, on: { "node-drag-start": s.keepSelection, "node-drag-end": s.restoreSelection }, scopedSlots: e._u([{ key: "default", fn: function({ node: i }) {
|
|
388
|
+
return [t("span", { staticClass: "custom-tree-node" }, [t("span", [e._v(e._s(i.label))]), i.data.id !== "all" ? t("span", { on: { click: function(a) {
|
|
389
|
+
return s.onPinnedChange(i);
|
|
390
|
+
} } }, [t("img", { attrs: { src: i.data.pinned ? s.activePin : s.pin, alt: "固定" } })]) : e._e()])];
|
|
391
391
|
} }]) }), 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)]);
|
|
392
392
|
}, Se = [], Ae = /* @__PURE__ */ x(
|
|
393
393
|
me,
|
|
@@ -402,8 +402,8 @@ const ye = Ae.exports, we = /* @__PURE__ */ S({
|
|
|
402
402
|
props: {
|
|
403
403
|
state: null
|
|
404
404
|
},
|
|
405
|
-
setup(
|
|
406
|
-
const e =
|
|
405
|
+
setup(r) {
|
|
406
|
+
const e = r, t = h();
|
|
407
407
|
return { __sfc: !0, props: e, searchSettingDialogRef: t, showSearchLayoutDialog: () => {
|
|
408
408
|
t.value.show(e.state);
|
|
409
409
|
}, SearchSettingsDrawer: ye };
|
|
@@ -431,26 +431,26 @@ const Oe = Le.exports, Te = {
|
|
|
431
431
|
type: Object
|
|
432
432
|
}
|
|
433
433
|
},
|
|
434
|
-
render(
|
|
434
|
+
render(r, e) {
|
|
435
435
|
var t;
|
|
436
|
-
const { props: s } = e,
|
|
437
|
-
if (
|
|
436
|
+
const { props: s } = e, i = s.search.render(s.search);
|
|
437
|
+
if (i.componentOptions.propsData || (i.componentOptions.propsData = {}), i.componentOptions.listeners || (i.componentOptions.listeners = {}), i.componentOptions.listeners || (i.componentOptions.listeners = {}), (t = i.data) != null && t.attrs || (i.data.attrs = {}), i.data.attrs.labelChange = () => {
|
|
438
438
|
s.api.updateSearchTag(s.search.field);
|
|
439
|
-
},
|
|
440
|
-
const a =
|
|
441
|
-
|
|
439
|
+
}, i.componentOptions.listeners.input) {
|
|
440
|
+
const a = i.componentOptions.listeners.input;
|
|
441
|
+
i.componentOptions.listeners.input = (l) => {
|
|
442
442
|
s.search.onChange && s.search.onChange(l, s.api), a(l);
|
|
443
443
|
};
|
|
444
444
|
}
|
|
445
|
-
return
|
|
445
|
+
return i.componentOptions.propsData.disabled = s.search.isDisabled(s.api), i;
|
|
446
446
|
}
|
|
447
447
|
}, De = /* @__PURE__ */ S({
|
|
448
448
|
__name: "SearchBarItem",
|
|
449
449
|
props: {
|
|
450
450
|
item: null
|
|
451
451
|
},
|
|
452
|
-
setup(
|
|
453
|
-
const e =
|
|
452
|
+
setup(r) {
|
|
453
|
+
const e = r, t = P("search-bar-state"), s = P("search-bar-id");
|
|
454
454
|
return { __sfc: !0, props: e, state: t, id: s, SearchItemRender: Te };
|
|
455
455
|
}
|
|
456
456
|
});
|
|
@@ -477,12 +477,12 @@ const Be = Fe.exports, Re = /* @__PURE__ */ S({
|
|
|
477
477
|
resetAutoSearch: { type: Boolean, default: !0 }
|
|
478
478
|
},
|
|
479
479
|
emits: ["change"],
|
|
480
|
-
setup(
|
|
481
|
-
const s =
|
|
480
|
+
setup(r, { expose: e, emit: t }) {
|
|
481
|
+
const s = r, i = K(new fe(s.id, s.searches, s.onSearch)), a = h(!1), l = h();
|
|
482
482
|
j(
|
|
483
483
|
l,
|
|
484
484
|
() => {
|
|
485
|
-
|
|
485
|
+
i.updateTags();
|
|
486
486
|
},
|
|
487
487
|
{ childList: !0 }
|
|
488
488
|
);
|
|
@@ -492,34 +492,34 @@ const Be = Fe.exports, Re = /* @__PURE__ */ S({
|
|
|
492
492
|
() => c.value.filter((n) => !_(n).pinned)
|
|
493
493
|
);
|
|
494
494
|
W(
|
|
495
|
-
() => [
|
|
495
|
+
() => [i.items, i.config.itemLayouts],
|
|
496
496
|
() => {
|
|
497
497
|
const n = [
|
|
498
|
-
...
|
|
499
|
-
...
|
|
498
|
+
...i.items.filter((o) => o.pinned),
|
|
499
|
+
...i.items.filter((o) => !o.pinned)
|
|
500
500
|
];
|
|
501
|
-
c.value = n.sort((o, v) =>
|
|
501
|
+
c.value = n.sort((o, v) => i.config.itemLayouts[o.field].index - i.config.itemLayouts[v.field].index).filter((o) => o.isEnable(i)), t("change", i.getSearchObject(), i);
|
|
502
502
|
},
|
|
503
503
|
{ debounce: 100, immediate: !0, deep: !0 }
|
|
504
504
|
);
|
|
505
|
-
const _ = (n) =>
|
|
506
|
-
|
|
507
|
-
}, O = () =>
|
|
508
|
-
return F("search-bar-state",
|
|
505
|
+
const _ = (n) => i.config.itemLayouts[n.field], y = () => i.items, w = () => i.getSearchObject(), C = (n) => {
|
|
506
|
+
i.searching = n;
|
|
507
|
+
}, O = () => i.updateTags();
|
|
508
|
+
return F("search-bar-state", i), F("search-bar-id", s.id), e({
|
|
509
509
|
getSearchItems: y,
|
|
510
510
|
getSearchObject: w,
|
|
511
511
|
updateSearching: C,
|
|
512
512
|
updateTags: O
|
|
513
|
-
}), { __sfc: !0, props: s, state:
|
|
513
|
+
}), { __sfc: !0, props: s, state: i, expanded: a, itemContainerRef: l, isShowSpanIcon: u, sortedItems: c, sortedPinnedItems: f, sortedNormalItems: A, emits: t, getLayout: _, getSearchItems: y, getSearchObject: w, updateSearching: C, updateTags: O, SearchTagsRender: se, SettingButton: Oe, SearchBarItem: Be };
|
|
514
514
|
}
|
|
515
515
|
});
|
|
516
516
|
var $e = function() {
|
|
517
517
|
var e = this, t = e._self._c, s = e._self._setupProxy;
|
|
518
|
-
return t("div", { staticClass: "search-bar-container" }, [t("el-row", { ref: "itemContainerRef", class: "search", staticStyle: { "flex-wrap": "wrap" }, attrs: { type: "flex", gutter: 16 } }, [e._l(s.sortedPinnedItems, function(
|
|
519
|
-
return t("el-col", { directives: [{ name: "show", rawName: "v-show", value: s.getLayout(
|
|
520
|
-
}), t("el-collapse-transition", [t("div", { directives: [{ name: "show", rawName: "v-show", value: s.expanded, expression: "expanded" }] }, e._l(s.sortedNormalItems, function(
|
|
521
|
-
return t("el-col", { directives: [{ name: "show", rawName: "v-show", value: s.getLayout(
|
|
522
|
-
}), 1)])], 2), t("div", { staticClass: "search-bottom" }, [s.state.tags.length > 0 ? t(s.SearchTagsRender, { attrs: { tags: s.state.tags } }) : e._e(), t("div", { staticClass: "actions" }, [t("el-tooltip", { attrs: { content: s.expanded ? "收起" : "更多搜索条件" } }, [t("el-button", { directives: [{ name: "show", rawName: "v-show", value: s.isShowSpanIcon, expression: "isShowSpanIcon" }], staticClass: "icon-button", staticStyle: { "margin-right": "10px" }, on: { click: function(
|
|
518
|
+
return t("div", { staticClass: "search-bar-container" }, [t("el-row", { ref: "itemContainerRef", class: "search", staticStyle: { "flex-wrap": "wrap" }, attrs: { type: "flex", gutter: 16 } }, [e._l(s.sortedPinnedItems, function(i) {
|
|
519
|
+
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(s.SearchBarItem, { attrs: { item: i } })], 1);
|
|
520
|
+
}), t("el-collapse-transition", [t("div", { directives: [{ name: "show", rawName: "v-show", value: s.expanded, expression: "expanded" }], staticStyle: { width: "100%" } }, e._l(s.sortedNormalItems, function(i) {
|
|
521
|
+
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(s.SearchBarItem, { attrs: { item: i } })], 1);
|
|
522
|
+
}), 1)])], 2), t("div", { staticClass: "search-bottom" }, [s.state.tags.length > 0 ? t(s.SearchTagsRender, { attrs: { tags: s.state.tags } }) : e._e(), t("div", { staticClass: "actions" }, [t("el-tooltip", { attrs: { content: s.expanded ? "收起" : "更多搜索条件" } }, [t("el-button", { directives: [{ name: "show", rawName: "v-show", value: s.isShowSpanIcon, expression: "isShowSpanIcon" }], staticClass: "icon-button", staticStyle: { "margin-right": "10px" }, on: { click: function(i) {
|
|
523
523
|
s.expanded = !s.expanded;
|
|
524
524
|
} } }, [t("i", { class: [s.expanded ? "el-icon-arrow-up" : "el-icon-arrow-down"] })])], 1), 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);
|
|
525
525
|
}, je = [], Ne = /* @__PURE__ */ x(
|
|
@@ -531,16 +531,16 @@ var $e = function() {
|
|
|
531
531
|
null
|
|
532
532
|
);
|
|
533
533
|
const Xe = Ne.exports;
|
|
534
|
-
var ke = Object.defineProperty, Ie = (
|
|
535
|
-
const He = (
|
|
536
|
-
const t =
|
|
534
|
+
var ke = Object.defineProperty, Ie = (r, e, t) => e in r ? ke(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, Ve = (r, e, t) => Ie(r, e + "", t);
|
|
535
|
+
const He = (r) => $(r), Ke = () => !0, ze = (r, e) => {
|
|
536
|
+
const t = r.getSearchObject();
|
|
537
537
|
let s = !0;
|
|
538
|
-
for (const [
|
|
539
|
-
const l = t[
|
|
538
|
+
for (const [i, a] of Object.entries(e)) {
|
|
539
|
+
const l = t[i];
|
|
540
540
|
s = a(l), s || (s = !1);
|
|
541
541
|
}
|
|
542
542
|
return () => s;
|
|
543
|
-
}, We = (
|
|
543
|
+
}, We = (r, e, t) => ({
|
|
544
544
|
/**
|
|
545
545
|
* 数据刷新回调代理
|
|
546
546
|
*
|
|
@@ -548,9 +548,9 @@ const He = (i) => $(i), Ke = () => !0, ze = (i, e) => {
|
|
|
548
548
|
* @param param
|
|
549
549
|
*/
|
|
550
550
|
refreshCallback: async (s) => {
|
|
551
|
-
const
|
|
551
|
+
const i = e.value.getSearchObject();
|
|
552
552
|
try {
|
|
553
|
-
return e.value.updateSearching(!0), await i
|
|
553
|
+
return e.value.updateSearching(!0), await r(i, s);
|
|
554
554
|
} finally {
|
|
555
555
|
e.value.updateSearching(!1), e.value.updateTags();
|
|
556
556
|
}
|
|
@@ -562,8 +562,8 @@ const He = (i) => $(i), Ke = () => !0, ze = (i, e) => {
|
|
|
562
562
|
*/
|
|
563
563
|
searchCallback: async () => {
|
|
564
564
|
var s;
|
|
565
|
-
for (const
|
|
566
|
-
await ((s =
|
|
565
|
+
for (const i of t)
|
|
566
|
+
await ((s = i.value) == null ? void 0 : s.refresh());
|
|
567
567
|
}
|
|
568
568
|
});
|
|
569
569
|
class D {
|
|
@@ -572,11 +572,11 @@ class D {
|
|
|
572
572
|
}
|
|
573
573
|
static from(e) {
|
|
574
574
|
const t = e.filter((s) => s.value === void 0 ? !1 : Array.isArray(s.value) ? s.value.length > 0 : !0).reduce(
|
|
575
|
-
(s,
|
|
576
|
-
const a =
|
|
575
|
+
(s, i) => {
|
|
576
|
+
const a = i.transform ? i.transform(i.value) : i.value;
|
|
577
577
|
return {
|
|
578
578
|
...s,
|
|
579
|
-
...X(a) ? a : { [
|
|
579
|
+
...X(a) ? a : { [i.field]: a }
|
|
580
580
|
};
|
|
581
581
|
},
|
|
582
582
|
{}
|
|
@@ -584,8 +584,8 @@ class D {
|
|
|
584
584
|
return new D(t);
|
|
585
585
|
}
|
|
586
586
|
transform(e, t) {
|
|
587
|
-
const s = this.record[e],
|
|
588
|
-
return delete this.record[e], this.record = { ...this.record, ...
|
|
587
|
+
const s = this.record[e], i = t(s);
|
|
588
|
+
return delete this.record[e], this.record = { ...this.record, ...i }, this;
|
|
589
589
|
}
|
|
590
590
|
toCondition(e) {
|
|
591
591
|
return { ...this.record, ...e };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(d,h){typeof exports=="object"&&typeof module<"u"?h(exports,require("lodash-unified"),require("vue"),require("@vueuse/core")):typeof define=="function"&&define.amd?define(["exports","lodash-unified","vue","@vueuse/core"],h):(d=typeof globalThis<"u"?globalThis:d||self,h(d.ElementPlusSearch={},d.lodashUnified,d.vue,d.core))})(this,function(d,h,l,P){"use strict";const R=i=>({model:{value:h.get(i,"value"),callback:e=>{h.set(i,"value",e)}}}),j=l.defineComponent({name:"SearchTags"}),$=l.defineComponent({...j,props:{tags:null},setup(i){const e=i,t=l.ref(),s=()=>{t.value.scrollBy({left:-200,behavior:"smooth"})},r=()=>{t.value.scrollBy({left:200,behavior:"smooth"})},n=l.ref(!1),o=()=>{const u=Array.from(t.value.children);return h.sum(u.map(m=>m.getBoundingClientRect().width))},f=()=>t.value.getBoundingClientRect().width;return P.useMutationObserver(t,()=>{n.value=o()>f()},{subtree:!0,childList:!0,attributes:!0}),{__sfc:!0,props:e,scrollContainer:t,scrollLeft:s,scrollRight:r,showScrollBar:n,getTagsWidth:o,getContainerWidth:f}}});function y(i,e,t,s,r,n,o,f){var u=typeof i=="function"?i.options:i;return e&&(u.render=e,u.staticRenderFns=t,u._compiled=!0),n&&(u._scopeId="data-v-"+n),{exports:i,options:u}}var N=function(){var e=this,t=e._self._c,s=e._self._setupProxy;return t("div",{staticClass:"tags-scroll-container"},[t("el-tag",{directives:[{name:"show",rawName:"v-show",value:s.showScrollBar,expression:"showScrollBar"}],staticClass:"scroll-left-bar",attrs:{"disable-transitions":"",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(r){return t("el-tag",{key:r.field,staticClass:"search-tag",attrs:{"disable-transitions":"",closable:!r.required,type:r.required?"primary":"info"},on:{close:()=>r.clean()}},[t("span",[e._v(" "+e._s(r.label)+" ")]),e._v(": "),t("span",{domProps:{innerHTML:e._s(r.valueText)}})])}),1),t("el-tag",{directives:[{name:"show",rawName:"v-show",value:s.showScrollBar,expression:"showScrollBar"}],staticClass:"scroll-right-bar",attrs:{"disable-transitions":"",size:"medium",type:"info"},on:{click:s.scrollRight}},[t("i",{staticClass:"el-icon-arrow-right"})])],1)},I=[],k=y($,N,I,!1,null,null);const V=k.exports;var Y=Object.defineProperty,q=(i,e,t)=>e in i?Y(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,p=(i,e,t)=>q(i,typeof e!="symbol"?e+"":e,t);const D=6;class M{constructor(e,t){p(this,"field"),p(this,"label"),p(this,"value"),p(this,"required"),p(this,"index"),p(this,"visible"),p(this,"disabled"),p(this,"span"),p(this,"initValue"),p(this,"enable"),p(this,"pinned"),p(this,"tagFilter"),p(this,"render"),p(this,"transform"),p(this,"onChange");var s,r,n,o,f;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:D,this.render=e.render,this.tagFilter=e.tagFilter,this.transform=e.transform,this.enable=(n=e.enable)!=null?n:!0,this.disabled=(o=e.disabled)!=null?o:!1,this.pinned=(f=e.pinned)!=null?f:!1,e.onChange&&(this.onChange=P.useDebounceFn((u,m)=>e.onChange(u,m),50))}clean(){Array.isArray(this.value)?this.value=[]:this.value=void 0}reset(){this.value=this.initValue}isEnable(e){return h.isFunction(this.enable)?this.enable(e.getSearchObject()):this.enable}isDisabled(e){return h.isFunction(this.disabled)?this.disabled(e.getSearchObject()):this.disabled}}var Q=Object.defineProperty,H=(i,e,t)=>e in i?Q(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,v=(i,e,t)=>H(i,typeof e!="symbol"?e+"":e,t);class b{constructor(e,t,s,r,n){v(this,"field"),v(this,"span"),v(this,"index"),v(this,"visible"),v(this,"pinned"),this.field=e,this.span=t,this.index=s,this.visible=r,this.pinned=n}static fromSearchItem(e,t){return new b(e.field,e.span,t??e.index,e.visible,e.pinned)}static formSearchConfig(e,t){var s,r,n;return new b(e.field,(s=e.span)!=null?s:D,t??e,(r=e.visible)!=null?r:!0,(n=e.pinned)!=null?n:!1)}static fromString(e){const[t,s,r,n,o]=e.split("_");return new b(s,Number(r),Number(t),n==="true",o==="true")}toString(){return`${this.index}_${this.field}_${this.span}_${this.visible}_${this.pinned}`}merge(e){this.span=e.span,this.index=e.index,this.visible=e.visible,this.pinned=e.pinned}}const F=i=>`searches_layouts_${i}`;class X{constructor(e,t){v(this,"id"),v(this,"state"),v(this,"itemLayouts"),v(this,"initialLayouts"),this.id=e.id,this.initialLayouts=t,this.state=e,this.itemLayouts=h.keyBy(e.items.map(b.fromSearchItem),s=>s.field),this.restoreCachedLayouts()}restoreCachedLayouts(){const e=localStorage.getItem(F(this.id));e&&e.split(",").forEach(t=>{const s=b.fromString(t),r=this.itemLayouts[s.field];r&&r.merge(s)})}sync(e,t,s){if(e.length!==Object.keys(this.itemLayouts).length)throw new Error("同步布局字段数量不一致");e.forEach((r,n)=>{const o=this.itemLayouts[r];o.index=n,o.visible=t.has(r),o.pinned=s.has(r)})}persistent(){localStorage.setItem(F(this.id),Object.values(this.itemLayouts).map(e=>e.toString()).join(",")),this.state.updateTags()}reset(){this.initialLayouts.forEach(e=>{const t=this.itemLayouts[e.field];t&&t.merge(e)})}}var W=Object.defineProperty,K=(i,e,t)=>e in i?W(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,_=(i,e,t)=>K(i,typeof e!="symbol"?e+"":e,t);const U=[{isApply(i){return i.contains("el-radio-group")},getText(i){var e,t;return(t=(e=i.querySelector(".is-active"))==null?void 0:e.querySelector("input"))==null?void 0:t.value}},{isApply(i){return i.contains("el-checkbox-group")},getText(i){var e;const t=Array.from((e=i.querySelectorAll(".el-checkbox__input.is-checked"))!=null?e:[]).map(s=>{var r;return(r=s.querySelector("input"))==null?void 0:r.value}).filter(s=>s);return t.length===1?t[0]:`${t[0]} 等${t.length}条`}},{isApply(i){return i.contains("el-input")},getText(i,e){return e.value}},{isApply(i){return i.contains("el-input-number")},getText(i,e){return e.value}},{isApply(i){return i.contains("el-select")},getText(i,e){var t;const s=i.querySelectorAll(".el-select__tags-text");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}},{isApply(i){return i.contains("el-cascader")},getText(i){var e;return(e=i.querySelector("input"))==null?void 0:e.value}},{isApply(i){return i.contains("el-switch")},getText(i){return i.querySelector(".is-active").innerHTML}},{isApply(i){return i.contains("el-slider")},getText(i,e){return e.value}},{isApply(i){return i.contains("el-date-editor")},getText(i,e){return e.value?e.value.join(" ~ "):e.value}}];class B{constructor(e,t){_(this,"id"),_(this,"field"),_(this,"value"),_(this,"label"),_(this,"valueText"),_(this,"required"),_(this,"item"),_(this,"state");var s;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()}static hasValue(e){return h.isNumber(e.value)||h.isBoolean(e.value)?!0:!h.isEmpty(e.value)}updateValueText(){const e=document.querySelector(this.id);if(!e)return;if(e.children.length!==1)throw new Error("holder children length is not 1");const t=e.children[0],s=U.find(r=>r.isApply(t.classList));s&&(this.valueText=s.getText(t,this))}async clean(){this.item.clean(),await this.state.doSearch()}}var z=Object.defineProperty,G=(i,e,t)=>e in i?z(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,S=(i,e,t)=>G(i,typeof e!="symbol"?e+"":e,t);class J{constructor(e,t,s){this.id=e,S(this,"items"),S(this,"config"),S(this,"searching"),S(this,"tags"),S(this,"searchCallback"),S(this,"sourceSearchable"),S(this,"_lastSearchObject",{time:0,data:null}),this.id=e,this.items=t.map((r,n)=>new M(r,n)),this.config=new X(this,t.map((r,n)=>b.formSearchConfig(r,n))),this.sourceSearchable=t,this.searching=!1,this.searchCallback=s,this.tags=[]}updateSearchTag(e){var t;(t=this.tags.find(s=>s.field===e))==null||t.updateValueText()}updateTags(){this.tags=this.items.filter(e=>e.tagFilter?e.tagFilter(e.value):B.hasValue(e)).map(e=>new B(this,e)).sort((e,t)=>this.config.itemLayouts[e.field].index-this.config.itemLayouts[t.field].index)}getSearchObject(e){const t=Date.now();return this._lastSearchObject.data&&t-this._lastSearchObject.time<50?this._lastSearchObject.data:(this._lastSearchObject={time:t,data:T.from(this.items).toCondition(e)},this._lastSearchObject.data)}async doSearch(){if(!this.searching)try{this.searching=!0,await this.searchCallback(this.getSearchObject()),this.updateTags()}finally{this.searching=!1}}async reset(e){this.items.forEach(t=>t.reset()),e&&await this.doSearch()}setSearchValue(e,t,s=r=>!0){const r=this.items.find(n=>n.field===e);r&&s&&s(r.value)&&(r.value=t)}}const Z=()=>{const i=l.shallowRef(),e=l.ref(),t=l.ref([]),s=l.ref(!1),r=l.ref(),n=l.ref([]),o=l.ref(300),f=a=>{i.value=a,t.value=[{label:"全部",id:"all",children:i.value.items.sort((c,g)=>a.config.itemLayouts[c.field].index-a.config.itemLayouts[g.field].index).map(c=>({label:c.label,id:c.field,disabled:!c.isEnable(a),pinned:a.config.itemLayouts[c.field].pinned}))}],r.value=Object.keys(a.config.itemLayouts).filter(c=>{var g;return(g=a.config.itemLayouts[c])==null?void 0:g.visible})};return{treeRef:e,visible:s,snapshot:t,defaultCheckedKeys:r,drawerWidth:o,updateSnapshot:f,show:a=>{f(a),s.value=!0},save:()=>{i.value.config.sync(t.value[0].children.map(a=>a.id),new Set(e.value.getCheckedKeys()),new Set(t.value[0].children.filter(a=>a.pinned).map(a=>a.id))),i.value.config.persistent(),s.value=!1},reset:()=>{i.value.config.reset(),f(i.value)},keepSelection:()=>{n.value=e.value.getCheckedKeys()},restoreSelection:()=>{e.value.setCheckedKeys(n.value),n.value=[]},allowDrop:(a,c,g)=>g==="inner"?!1:!((Oe,De)=>{let E=Oe.parent;for(;E;){if(E===De)return!0;E=E.parent}return!1})(a,c),allowDrag:a=>!a.disabled,onPinnedChange:a=>{a.data.pinned=!a.data.pinned}}},ee="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAdlJREFUWEftlT9rFEEYxp/nJCii2NhYWNiLnV9CSGFtYGdGd4IkRUQMXhA9RSX+AYXTFLPH7mwO0ohW/vkAfgALsbSxuM7CRtDovrIQNcTkdmc9CchuuzPP83t/O8sQu/xwl/vRArQG/h8Dyti7KOSj98mdkD9rYgYiHT8jeRqFXA6BmByAOXeW6Aw2pu/61C3XMTEJACpjbwJY2lwoIpfyLLlfBfFXANba/V/X5QnIU9sV1YFoDKC1Plpw6iWB4+OmrIIIAShVd0XkEDqdFxB5SuDwtpMD31hwGhQlxOs8dY93ggwCiEw8JHim6ruikDnvk5XKdUDwZUSl4wFIs2O4YM1nrhpyIyDEwK9OZewDAAt/QAjeHjyw92S/3/9SZ/pyTSOASMfXSV7dUvLp+zpODIfuQ93yRgCRjrskbwNyUQTHSM6XQYXI9GqWPA8pDwZQxpbaS/0XfOoelgHKxA5gDGDRp+7ePwOItD1PYkVEruVZcmNTEZWJcxR4F3IH/Nxf6wz8Li9u5dngytYpe71eZzQa7XPOfZ64gUjPalJSAMs+dd3Qgqr1Yw3MzNgje6bwnsQjn7rFqrAm78cCKGOXCsib1TR51SS8zp5aZ6BOUNM1LUBroDXwAyP2oSHYDQ3tAAAAAElFTkSuQmCC",te="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAc1JREFUWEftlT1oFUEUhb+zKEgQbGxSWNiLTUip82ohhbWFvl1EgiFExJAn4h8q8QdioYFIdoIEbEJSqWl3EUuxCJY29haCCBLx6kteBKPv7c7mSUB225l7znfPzN0Ru/xpl/2pAeoE/p8EXGr3FPExa+puyGT1LQHnbUVwEjEVAtE3gEZqCWJ+o3ujlSWaLpPEzgHM5Dy3JC5vM7yUxXpQBLEjgKE5G9i/lyXBiS5GhRCVAY57OxQZLxFHCrrsCVEeYDPqFuKAfedFJJYRB/9qbnwjYgTjDMarLNHjbpBBAA3PIuJU0bmaOJ83NVu0r71eHmDjdpvcAvOCuJu4wbM8ViHkVn0YQKeqkdoMYmI7hMHawGeGV8f1tUz34Ql0VJ23G4Krv5kYn9b3cPT1aX0oa14JwHlrCe6YcVHiMDDWMRzJYj0PMQ8GaKQ28XMKZjAuZIketgVcak8kzpoxmSe6/88AnLdRwazBtTzWzV9Gm+P5VBHvQt6AoEu4ZQ7czmJd+aPL6xYNDbLvzTl96XsCzltT4DGms0StUIOi/T3H8NiiDUbrvMd4lCeaLBKrst4TwKXWfuHe5olWq4iXqan0IyojXHZPDVAnUCfwAyFMiSGfgbcLAAAAAElFTkSuQmCC",se=l.defineComponent({__name:"SearchSettingsDrawer",setup(i,{expose:e}){const{treeRef:t,visible:s,snapshot:r,drawerWidth:n,defaultCheckedKeys:o,show:f,allowDrop:u,allowDrag:m,keepSelection:w,restoreSelection:A,save:C,reset:x,onPinnedChange:L}=Z();return e({show:f}),{__sfc:!0,treeRef:t,visible:s,snapshot:r,drawerWidth:n,defaultCheckedKeys:o,show:f,allowDrop:u,allowDrag:m,keepSelection:w,restoreSelection:A,save:C,reset:x,onPinnedChange:L,pin:ee,activePin:te}}});var re=function(){var e=this,t=e._self._c,s=e._self._setupProxy;return t("el-drawer",{attrs:{size:s.drawerWidth,title:"搜索项配置",visible:s.visible,"modal-append-to-body":!0,"append-to-body":!0},on:{"update:visible":function(r){s.visible=r}}},[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,"expand-on-click-node":!1},on:{"node-drag-start":s.keepSelection,"node-drag-end":s.restoreSelection},scopedSlots:e._u([{key:"default",fn:function({node:r}){return[t("span",{staticClass:"custom-tree-node"},[t("span",[e._v(e._s(r.label))]),r.data.id!=="all"?t("span",{on:{click:function(n){return s.onPinnedChange(r)}}},[t("img",{attrs:{src:r.data.pinned?s.activePin:s.pin,alt:"固定"}})]):e._e()])]}}])}),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)])},ie=[],ne=y(se,re,ie,!1,null,null);const ae=ne.exports,le=l.defineComponent({__name:"SettingButton",props:{state:null},setup(i){const e=i,t=l.ref();return{__sfc:!0,props:e,searchSettingDialogRef:t,showSearchLayoutDialog:()=>{t.value.show(e.state)},SearchSettingsDrawer:ae}}});var oe=function(){var e=this,t=e._self._c,s=e._self._setupProxy;return t("div",{staticStyle:{"margin-right":"10px"}},[t("el-tooltip",{attrs:{content:"搜索项设置"}},[t("el-button",{staticClass:"icon-button",staticStyle:{height:"100%"},on:{click:s.showSearchLayoutDialog}},[t("i",{staticClass:"el-icon-s-tools"})])],1),t(s.SearchSettingsDrawer,{ref:"searchSettingDialogRef"})],1)},ce=[],ue=y(le,oe,ce,!1,null,"b401b1ee");const de=ue.exports,he={functional:!0,props:{search:{type:Object,required:!0},api:{type:Object}},render(i,e){var t;const{props:s}=e,r=s.search.render(s.search);if(r.componentOptions.propsData||(r.componentOptions.propsData={}),r.componentOptions.listeners||(r.componentOptions.listeners={}),r.componentOptions.listeners||(r.componentOptions.listeners={}),(t=r.data)!=null&&t.attrs||(r.data.attrs={}),r.data.attrs.labelChange=()=>{s.api.updateSearchTag(s.search.field)},r.componentOptions.listeners.input){const n=r.componentOptions.listeners.input;r.componentOptions.listeners.input=o=>{s.search.onChange&&s.search.onChange(o,s.api),n(o)}}return r.componentOptions.propsData.disabled=s.search.isDisabled(s.api),r}},pe=l.defineComponent({__name:"SearchBarItem",props:{item:null},setup(i){const e=i,t=l.inject("search-bar-state"),s=l.inject("search-bar-id");return{__sfc:!0,props:e,state:t,id:s,SearchItemRender:he}}});var fe=function(){var e=this,t=e._self._c,s=e._self._setupProxy;return t("div",{staticClass:"search-item"},[t("div",{staticClass:"search-item-title"},[e._v(e._s(e.item.label))]),t("div",{staticClass:"search-item-content",attrs:{id:`${s.id}-${e.item.field}`}},[t(s.SearchItemRender,{attrs:{search:e.item,api:s.state}})],1)])},ve=[],_e=y(pe,fe,ve,!1,null,"9e3df4b4");const me=_e.exports,ge=l.defineComponent({__name:"SearchBar",props:{searches:null,id:null,onSearch:{type:Function},defaultSpan:{default:6},maxRows:{default:2},itemHeight:{default:67},resetAutoSearch:{type:Boolean,default:!0}},emits:["change"],setup(i,{expose:e,emit:t}){const s=i,r=l.reactive(new J(s.id,s.searches,s.onSearch)),n=l.ref(!1),o=l.ref();P.useMutationObserver(o,()=>{r.updateTags()},{childList:!0});const f=l.computed(()=>w.value.filter(a=>A(a).visible).length>0),u=l.ref([]),m=l.computed(()=>u.value.filter(a=>A(a).pinned)),w=l.computed(()=>u.value.filter(a=>!A(a).pinned));P.watchDebounced(()=>[r.items,r.config.itemLayouts],()=>{const a=[...r.items.filter(c=>c.pinned),...r.items.filter(c=>!c.pinned)];u.value=a.sort((c,g)=>r.config.itemLayouts[c.field].index-r.config.itemLayouts[g.field].index).filter(c=>c.isEnable(r)),t("change",r.getSearchObject(),r)},{debounce:100,immediate:!0,deep:!0});const A=a=>r.config.itemLayouts[a.field],C=()=>r.items,x=()=>r.getSearchObject(),L=a=>{r.searching=a},O=()=>r.updateTags();return l.provide("search-bar-state",r),l.provide("search-bar-id",s.id),e({getSearchItems:C,getSearchObject:x,updateSearching:L,updateTags:O}),{__sfc:!0,props:s,state:r,expanded:n,itemContainerRef:o,isShowSpanIcon:f,sortedItems:u,sortedPinnedItems:m,sortedNormalItems:w,emits:t,getLayout:A,getSearchItems:C,getSearchObject:x,updateSearching:L,updateTags:O,SearchTagsRender:V,SettingButton:de,SearchBarItem:me}}});var be=function(){var e=this,t=e._self._c,s=e._self._setupProxy;return t("div",{staticClass:"search-bar-container"},[t("el-row",{ref:"itemContainerRef",class:"search",staticStyle:{"flex-wrap":"wrap"},attrs:{type:"flex",gutter:16}},[e._l(s.sortedPinnedItems,function(r){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(s.SearchBarItem,{attrs:{item:r}})],1)}),t("el-collapse-transition",[t("div",{directives:[{name:"show",rawName:"v-show",value:s.expanded,expression:"expanded"}]},e._l(s.sortedNormalItems,function(r){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(s.SearchBarItem,{attrs:{item:r}})],1)}),1)])],2),t("div",{staticClass:"search-bottom"},[s.state.tags.length>0?t(s.SearchTagsRender,{attrs:{tags:s.state.tags}}):e._e(),t("div",{staticClass:"actions"},[t("el-tooltip",{attrs:{content:s.expanded?"收起":"更多搜索条件"}},[t("el-button",{directives:[{name:"show",rawName:"v-show",value:s.isShowSpanIcon,expression:"isShowSpanIcon"}],staticClass:"icon-button",staticStyle:{"margin-right":"10px"},on:{click:function(r){s.expanded=!s.expanded}}},[t("i",{class:[s.expanded?"el-icon-arrow-up":"el-icon-arrow-down"]})])],1),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)},Se=[],Ae=y(ge,be,Se,!1,null,null);const ye=Ae.exports;var we=Object.defineProperty,Ce=(i,e,t)=>e in i?we(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,xe=(i,e,t)=>Ce(i,e+"",t);const Le=i=>h.isEmpty(i),Pe=()=>!0,Te=(i,e)=>{const t=i.getSearchObject();let s=!0;for(const[r,n]of Object.entries(e)){const o=t[r];s=n(o),s||(s=!1)}return()=>s},Ee=(i,e,t)=>({refreshCallback:async s=>{const r=e.value.getSearchObject();try{return e.value.updateSearching(!0),await i(r,s)}finally{e.value.updateSearching(!1),e.value.updateTags()}},searchCallback:async()=>{var s;for(const r of t)await((s=r.value)==null?void 0:s.refresh())}});class T{constructor(e){xe(this,"record"),this.record=e}static from(e){const t=e.filter(s=>s.value===void 0?!1:Array.isArray(s.value)?s.value.length>0:!0).reduce((s,r)=>{const n=r.transform?r.transform(r.value):r.value;return{...s,...h.isPlainObject(n)?n:{[r.field]:n}}},{});return new T(t)}transform(e,t){const s=this.record[e],r=t(s);return delete this.record[e],this.record={...this.record,...r},this}toCondition(e){return{...this.record,...e}}}d.APPLY_ALWAYS=Pe,d.APPLY_WHEN_NOT_VALUE=Le,d.APPLY_WITH_MULTIPLE_VALUE=Te,d.SearchBar=ye,d.Searches=T,d.useSearchProxy=Ee,d.vModel=R,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(d,h){typeof exports=="object"&&typeof module<"u"?h(exports,require("lodash-unified"),require("vue"),require("@vueuse/core")):typeof define=="function"&&define.amd?define(["exports","lodash-unified","vue","@vueuse/core"],h):(d=typeof globalThis<"u"?globalThis:d||self,h(d.ElementPlusSearch={},d.lodashUnified,d.vue,d.core))})(this,function(d,h,l,P){"use strict";const R=i=>({model:{value:h.get(i,"value"),callback:e=>{h.set(i,"value",e)}}}),j=l.defineComponent({name:"SearchTags"}),$=l.defineComponent({...j,props:{tags:null},setup(i){const e=i,t=l.ref(),s=()=>{t.value.scrollBy({left:-200,behavior:"smooth"})},r=()=>{t.value.scrollBy({left:200,behavior:"smooth"})},n=l.ref(!1),o=()=>{const u=Array.from(t.value.children);return h.sum(u.map(m=>m.getBoundingClientRect().width))},f=()=>t.value.getBoundingClientRect().width;return P.useMutationObserver(t,()=>{n.value=o()>f()},{subtree:!0,childList:!0,attributes:!0}),{__sfc:!0,props:e,scrollContainer:t,scrollLeft:s,scrollRight:r,showScrollBar:n,getTagsWidth:o,getContainerWidth:f}}});function y(i,e,t,s,r,n,o,f){var u=typeof i=="function"?i.options:i;return e&&(u.render=e,u.staticRenderFns=t,u._compiled=!0),n&&(u._scopeId="data-v-"+n),{exports:i,options:u}}var N=function(){var e=this,t=e._self._c,s=e._self._setupProxy;return t("div",{staticClass:"tags-scroll-container"},[t("el-tag",{directives:[{name:"show",rawName:"v-show",value:s.showScrollBar,expression:"showScrollBar"}],staticClass:"scroll-left-bar",attrs:{"disable-transitions":"",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(r){return t("el-tag",{key:r.field,staticClass:"search-tag",attrs:{"disable-transitions":"",closable:!r.required,type:r.required?"primary":"info"},on:{close:()=>r.clean()}},[t("span",[e._v(" "+e._s(r.label)+" ")]),e._v(": "),t("span",{domProps:{innerHTML:e._s(r.valueText)}})])}),1),t("el-tag",{directives:[{name:"show",rawName:"v-show",value:s.showScrollBar,expression:"showScrollBar"}],staticClass:"scroll-right-bar",attrs:{"disable-transitions":"",size:"medium",type:"info"},on:{click:s.scrollRight}},[t("i",{staticClass:"el-icon-arrow-right"})])],1)},I=[],k=y($,N,I,!1,null,null);const V=k.exports;var Y=Object.defineProperty,q=(i,e,t)=>e in i?Y(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,p=(i,e,t)=>q(i,typeof e!="symbol"?e+"":e,t);const D=6;class M{constructor(e,t){p(this,"field"),p(this,"label"),p(this,"value"),p(this,"required"),p(this,"index"),p(this,"visible"),p(this,"disabled"),p(this,"span"),p(this,"initValue"),p(this,"enable"),p(this,"pinned"),p(this,"tagFilter"),p(this,"render"),p(this,"transform"),p(this,"onChange");var s,r,n,o,f;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:D,this.render=e.render,this.tagFilter=e.tagFilter,this.transform=e.transform,this.enable=(n=e.enable)!=null?n:!0,this.disabled=(o=e.disabled)!=null?o:!1,this.pinned=(f=e.pinned)!=null?f:!1,e.onChange&&(this.onChange=P.useDebounceFn((u,m)=>e.onChange(u,m),50))}clean(){Array.isArray(this.value)?this.value=[]:this.value=void 0}reset(){this.value=this.initValue}isEnable(e){return h.isFunction(this.enable)?this.enable(e.getSearchObject()):this.enable}isDisabled(e){return h.isFunction(this.disabled)?this.disabled(e.getSearchObject()):this.disabled}}var Q=Object.defineProperty,H=(i,e,t)=>e in i?Q(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,v=(i,e,t)=>H(i,typeof e!="symbol"?e+"":e,t);class b{constructor(e,t,s,r,n){v(this,"field"),v(this,"span"),v(this,"index"),v(this,"visible"),v(this,"pinned"),this.field=e,this.span=t,this.index=s,this.visible=r,this.pinned=n}static fromSearchItem(e,t){return new b(e.field,e.span,t??e.index,e.visible,e.pinned)}static formSearchConfig(e,t){var s,r,n;return new b(e.field,(s=e.span)!=null?s:D,t??e,(r=e.visible)!=null?r:!0,(n=e.pinned)!=null?n:!1)}static fromString(e){const[t,s,r,n,o]=e.split("_");return new b(s,Number(r),Number(t),n==="true",o==="true")}toString(){return`${this.index}_${this.field}_${this.span}_${this.visible}_${this.pinned}`}merge(e){this.span=e.span,this.index=e.index,this.visible=e.visible,this.pinned=e.pinned}}const F=i=>`searches_layouts_${i}`;class X{constructor(e,t){v(this,"id"),v(this,"state"),v(this,"itemLayouts"),v(this,"initialLayouts"),this.id=e.id,this.initialLayouts=t,this.state=e,this.itemLayouts=h.keyBy(e.items.map(b.fromSearchItem),s=>s.field),this.restoreCachedLayouts()}restoreCachedLayouts(){const e=localStorage.getItem(F(this.id));e&&e.split(",").forEach(t=>{const s=b.fromString(t),r=this.itemLayouts[s.field];r&&r.merge(s)})}sync(e,t,s){if(e.length!==Object.keys(this.itemLayouts).length)throw new Error("同步布局字段数量不一致");e.forEach((r,n)=>{const o=this.itemLayouts[r];o.index=n,o.visible=t.has(r),o.pinned=s.has(r)})}persistent(){localStorage.setItem(F(this.id),Object.values(this.itemLayouts).map(e=>e.toString()).join(",")),this.state.updateTags()}reset(){this.initialLayouts.forEach(e=>{const t=this.itemLayouts[e.field];t&&t.merge(e)})}}var W=Object.defineProperty,K=(i,e,t)=>e in i?W(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,_=(i,e,t)=>K(i,typeof e!="symbol"?e+"":e,t);const U=[{isApply(i){return i.contains("el-radio-group")},getText(i){var e,t;return(t=(e=i.querySelector(".is-active"))==null?void 0:e.querySelector("input"))==null?void 0:t.value}},{isApply(i){return i.contains("el-checkbox-group")},getText(i){var e;const t=Array.from((e=i.querySelectorAll(".el-checkbox__input.is-checked"))!=null?e:[]).map(s=>{var r;return(r=s.querySelector("input"))==null?void 0:r.value}).filter(s=>s);return t.length===1?t[0]:`${t[0]} 等${t.length}条`}},{isApply(i){return i.contains("el-input")},getText(i,e){return e.value}},{isApply(i){return i.contains("el-input-number")},getText(i,e){return e.value}},{isApply(i){return i.contains("el-select")},getText(i,e){var t;const s=i.querySelectorAll(".el-select__tags-text");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}},{isApply(i){return i.contains("el-cascader")},getText(i){var e;return(e=i.querySelector("input"))==null?void 0:e.value}},{isApply(i){return i.contains("el-switch")},getText(i){return i.querySelector(".is-active").innerHTML}},{isApply(i){return i.contains("el-slider")},getText(i,e){return e.value}},{isApply(i){return i.contains("el-date-editor")},getText(i,e){return e.value?e.value.join(" ~ "):e.value}}];class B{constructor(e,t){_(this,"id"),_(this,"field"),_(this,"value"),_(this,"label"),_(this,"valueText"),_(this,"required"),_(this,"item"),_(this,"state");var s;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()}static hasValue(e){return h.isNumber(e.value)||h.isBoolean(e.value)?!0:!h.isEmpty(e.value)}updateValueText(){const e=document.querySelector(this.id);if(!e)return;if(e.children.length!==1)throw new Error("holder children length is not 1");const t=e.children[0],s=U.find(r=>r.isApply(t.classList));s&&(this.valueText=s.getText(t,this))}async clean(){this.item.clean(),await this.state.doSearch()}}var z=Object.defineProperty,G=(i,e,t)=>e in i?z(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,S=(i,e,t)=>G(i,typeof e!="symbol"?e+"":e,t);class J{constructor(e,t,s){this.id=e,S(this,"items"),S(this,"config"),S(this,"searching"),S(this,"tags"),S(this,"searchCallback"),S(this,"sourceSearchable"),S(this,"_lastSearchObject",{time:0,data:null}),this.id=e,this.items=t.map((r,n)=>new M(r,n)),this.config=new X(this,t.map((r,n)=>b.formSearchConfig(r,n))),this.sourceSearchable=t,this.searching=!1,this.searchCallback=s,this.tags=[]}updateSearchTag(e){var t;(t=this.tags.find(s=>s.field===e))==null||t.updateValueText()}updateTags(){this.tags=this.items.filter(e=>e.tagFilter?e.tagFilter(e.value):B.hasValue(e)).map(e=>new B(this,e)).sort((e,t)=>this.config.itemLayouts[e.field].index-this.config.itemLayouts[t.field].index)}getSearchObject(e){const t=Date.now();return this._lastSearchObject.data&&t-this._lastSearchObject.time<50?this._lastSearchObject.data:(this._lastSearchObject={time:t,data:T.from(this.items).toCondition(e)},this._lastSearchObject.data)}async doSearch(){if(!this.searching)try{this.searching=!0,await this.searchCallback(this.getSearchObject()),this.updateTags()}finally{this.searching=!1}}async reset(e){this.items.forEach(t=>t.reset()),e&&await this.doSearch()}setSearchValue(e,t,s=r=>!0){const r=this.items.find(n=>n.field===e);r&&s&&s(r.value)&&(r.value=t)}}const Z=()=>{const i=l.shallowRef(),e=l.ref(),t=l.ref([]),s=l.ref(!1),r=l.ref(),n=l.ref([]),o=l.ref(300),f=a=>{i.value=a,t.value=[{label:"全部",id:"all",children:i.value.items.sort((c,g)=>a.config.itemLayouts[c.field].index-a.config.itemLayouts[g.field].index).map(c=>({label:c.label,id:c.field,disabled:!c.isEnable(a),pinned:a.config.itemLayouts[c.field].pinned}))}],r.value=Object.keys(a.config.itemLayouts).filter(c=>{var g;return(g=a.config.itemLayouts[c])==null?void 0:g.visible})};return{treeRef:e,visible:s,snapshot:t,defaultCheckedKeys:r,drawerWidth:o,updateSnapshot:f,show:a=>{f(a),s.value=!0},save:()=>{i.value.config.sync(t.value[0].children.map(a=>a.id),new Set(e.value.getCheckedKeys()),new Set(t.value[0].children.filter(a=>a.pinned).map(a=>a.id))),i.value.config.persistent(),s.value=!1},reset:()=>{i.value.config.reset(),f(i.value)},keepSelection:()=>{n.value=e.value.getCheckedKeys()},restoreSelection:()=>{e.value.setCheckedKeys(n.value),n.value=[]},allowDrop:(a,c,g)=>g==="inner"?!1:!((Oe,De)=>{let E=Oe.parent;for(;E;){if(E===De)return!0;E=E.parent}return!1})(a,c),allowDrag:a=>!a.disabled,onPinnedChange:a=>{a.data.pinned=!a.data.pinned}}},ee="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAdlJREFUWEftlT9rFEEYxp/nJCii2NhYWNiLnV9CSGFtYGdGd4IkRUQMXhA9RSX+AYXTFLPH7mwO0ohW/vkAfgALsbSxuM7CRtDovrIQNcTkdmc9CchuuzPP83t/O8sQu/xwl/vRArQG/h8Dyti7KOSj98mdkD9rYgYiHT8jeRqFXA6BmByAOXeW6Aw2pu/61C3XMTEJACpjbwJY2lwoIpfyLLlfBfFXANba/V/X5QnIU9sV1YFoDKC1Plpw6iWB4+OmrIIIAShVd0XkEDqdFxB5SuDwtpMD31hwGhQlxOs8dY93ggwCiEw8JHim6ruikDnvk5XKdUDwZUSl4wFIs2O4YM1nrhpyIyDEwK9OZewDAAt/QAjeHjyw92S/3/9SZ/pyTSOASMfXSV7dUvLp+zpODIfuQ93yRgCRjrskbwNyUQTHSM6XQYXI9GqWPA8pDwZQxpbaS/0XfOoelgHKxA5gDGDRp+7ePwOItD1PYkVEruVZcmNTEZWJcxR4F3IH/Nxf6wz8Li9u5dngytYpe71eZzQa7XPOfZ64gUjPalJSAMs+dd3Qgqr1Yw3MzNgje6bwnsQjn7rFqrAm78cCKGOXCsib1TR51SS8zp5aZ6BOUNM1LUBroDXwAyP2oSHYDQ3tAAAAAElFTkSuQmCC",te="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAc1JREFUWEftlT1oFUEUhb+zKEgQbGxSWNiLTUip82ohhbWFvl1EgiFExJAn4h8q8QdioYFIdoIEbEJSqWl3EUuxCJY29haCCBLx6kteBKPv7c7mSUB225l7znfPzN0Ru/xpl/2pAeoE/p8EXGr3FPExa+puyGT1LQHnbUVwEjEVAtE3gEZqCWJ+o3ujlSWaLpPEzgHM5Dy3JC5vM7yUxXpQBLEjgKE5G9i/lyXBiS5GhRCVAY57OxQZLxFHCrrsCVEeYDPqFuKAfedFJJYRB/9qbnwjYgTjDMarLNHjbpBBAA3PIuJU0bmaOJ83NVu0r71eHmDjdpvcAvOCuJu4wbM8ViHkVn0YQKeqkdoMYmI7hMHawGeGV8f1tUz34Ql0VJ23G4Krv5kYn9b3cPT1aX0oa14JwHlrCe6YcVHiMDDWMRzJYj0PMQ8GaKQ28XMKZjAuZIketgVcak8kzpoxmSe6/88AnLdRwazBtTzWzV9Gm+P5VBHvQt6AoEu4ZQ7czmJd+aPL6xYNDbLvzTl96XsCzltT4DGms0StUIOi/T3H8NiiDUbrvMd4lCeaLBKrst4TwKXWfuHe5olWq4iXqan0IyojXHZPDVAnUCfwAyFMiSGfgbcLAAAAAElFTkSuQmCC",se=l.defineComponent({__name:"SearchSettingsDrawer",setup(i,{expose:e}){const{treeRef:t,visible:s,snapshot:r,drawerWidth:n,defaultCheckedKeys:o,show:f,allowDrop:u,allowDrag:m,keepSelection:w,restoreSelection:A,save:C,reset:x,onPinnedChange:L}=Z();return e({show:f}),{__sfc:!0,treeRef:t,visible:s,snapshot:r,drawerWidth:n,defaultCheckedKeys:o,show:f,allowDrop:u,allowDrag:m,keepSelection:w,restoreSelection:A,save:C,reset:x,onPinnedChange:L,pin:ee,activePin:te}}});var re=function(){var e=this,t=e._self._c,s=e._self._setupProxy;return t("el-drawer",{attrs:{size:s.drawerWidth,title:"搜索项配置",visible:s.visible,"modal-append-to-body":!0,"append-to-body":!0},on:{"update:visible":function(r){s.visible=r}}},[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,"expand-on-click-node":!1},on:{"node-drag-start":s.keepSelection,"node-drag-end":s.restoreSelection},scopedSlots:e._u([{key:"default",fn:function({node:r}){return[t("span",{staticClass:"custom-tree-node"},[t("span",[e._v(e._s(r.label))]),r.data.id!=="all"?t("span",{on:{click:function(n){return s.onPinnedChange(r)}}},[t("img",{attrs:{src:r.data.pinned?s.activePin:s.pin,alt:"固定"}})]):e._e()])]}}])}),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)])},ie=[],ne=y(se,re,ie,!1,null,null);const ae=ne.exports,le=l.defineComponent({__name:"SettingButton",props:{state:null},setup(i){const e=i,t=l.ref();return{__sfc:!0,props:e,searchSettingDialogRef:t,showSearchLayoutDialog:()=>{t.value.show(e.state)},SearchSettingsDrawer:ae}}});var oe=function(){var e=this,t=e._self._c,s=e._self._setupProxy;return t("div",{staticStyle:{"margin-right":"10px"}},[t("el-tooltip",{attrs:{content:"搜索项设置"}},[t("el-button",{staticClass:"icon-button",staticStyle:{height:"100%"},on:{click:s.showSearchLayoutDialog}},[t("i",{staticClass:"el-icon-s-tools"})])],1),t(s.SearchSettingsDrawer,{ref:"searchSettingDialogRef"})],1)},ce=[],ue=y(le,oe,ce,!1,null,"b401b1ee");const de=ue.exports,he={functional:!0,props:{search:{type:Object,required:!0},api:{type:Object}},render(i,e){var t;const{props:s}=e,r=s.search.render(s.search);if(r.componentOptions.propsData||(r.componentOptions.propsData={}),r.componentOptions.listeners||(r.componentOptions.listeners={}),r.componentOptions.listeners||(r.componentOptions.listeners={}),(t=r.data)!=null&&t.attrs||(r.data.attrs={}),r.data.attrs.labelChange=()=>{s.api.updateSearchTag(s.search.field)},r.componentOptions.listeners.input){const n=r.componentOptions.listeners.input;r.componentOptions.listeners.input=o=>{s.search.onChange&&s.search.onChange(o,s.api),n(o)}}return r.componentOptions.propsData.disabled=s.search.isDisabled(s.api),r}},pe=l.defineComponent({__name:"SearchBarItem",props:{item:null},setup(i){const e=i,t=l.inject("search-bar-state"),s=l.inject("search-bar-id");return{__sfc:!0,props:e,state:t,id:s,SearchItemRender:he}}});var fe=function(){var e=this,t=e._self._c,s=e._self._setupProxy;return t("div",{staticClass:"search-item"},[t("div",{staticClass:"search-item-title"},[e._v(e._s(e.item.label))]),t("div",{staticClass:"search-item-content",attrs:{id:`${s.id}-${e.item.field}`}},[t(s.SearchItemRender,{attrs:{search:e.item,api:s.state}})],1)])},ve=[],_e=y(pe,fe,ve,!1,null,"9e3df4b4");const me=_e.exports,ge=l.defineComponent({__name:"SearchBar",props:{searches:null,id:null,onSearch:{type:Function},defaultSpan:{default:6},maxRows:{default:2},itemHeight:{default:67},resetAutoSearch:{type:Boolean,default:!0}},emits:["change"],setup(i,{expose:e,emit:t}){const s=i,r=l.reactive(new J(s.id,s.searches,s.onSearch)),n=l.ref(!1),o=l.ref();P.useMutationObserver(o,()=>{r.updateTags()},{childList:!0});const f=l.computed(()=>w.value.filter(a=>A(a).visible).length>0),u=l.ref([]),m=l.computed(()=>u.value.filter(a=>A(a).pinned)),w=l.computed(()=>u.value.filter(a=>!A(a).pinned));P.watchDebounced(()=>[r.items,r.config.itemLayouts],()=>{const a=[...r.items.filter(c=>c.pinned),...r.items.filter(c=>!c.pinned)];u.value=a.sort((c,g)=>r.config.itemLayouts[c.field].index-r.config.itemLayouts[g.field].index).filter(c=>c.isEnable(r)),t("change",r.getSearchObject(),r)},{debounce:100,immediate:!0,deep:!0});const A=a=>r.config.itemLayouts[a.field],C=()=>r.items,x=()=>r.getSearchObject(),L=a=>{r.searching=a},O=()=>r.updateTags();return l.provide("search-bar-state",r),l.provide("search-bar-id",s.id),e({getSearchItems:C,getSearchObject:x,updateSearching:L,updateTags:O}),{__sfc:!0,props:s,state:r,expanded:n,itemContainerRef:o,isShowSpanIcon:f,sortedItems:u,sortedPinnedItems:m,sortedNormalItems:w,emits:t,getLayout:A,getSearchItems:C,getSearchObject:x,updateSearching:L,updateTags:O,SearchTagsRender:V,SettingButton:de,SearchBarItem:me}}});var be=function(){var e=this,t=e._self._c,s=e._self._setupProxy;return t("div",{staticClass:"search-bar-container"},[t("el-row",{ref:"itemContainerRef",class:"search",staticStyle:{"flex-wrap":"wrap"},attrs:{type:"flex",gutter:16}},[e._l(s.sortedPinnedItems,function(r){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(s.SearchBarItem,{attrs:{item:r}})],1)}),t("el-collapse-transition",[t("div",{directives:[{name:"show",rawName:"v-show",value:s.expanded,expression:"expanded"}],staticStyle:{width:"100%"}},e._l(s.sortedNormalItems,function(r){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(s.SearchBarItem,{attrs:{item:r}})],1)}),1)])],2),t("div",{staticClass:"search-bottom"},[s.state.tags.length>0?t(s.SearchTagsRender,{attrs:{tags:s.state.tags}}):e._e(),t("div",{staticClass:"actions"},[t("el-tooltip",{attrs:{content:s.expanded?"收起":"更多搜索条件"}},[t("el-button",{directives:[{name:"show",rawName:"v-show",value:s.isShowSpanIcon,expression:"isShowSpanIcon"}],staticClass:"icon-button",staticStyle:{"margin-right":"10px"},on:{click:function(r){s.expanded=!s.expanded}}},[t("i",{class:[s.expanded?"el-icon-arrow-up":"el-icon-arrow-down"]})])],1),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)},Se=[],Ae=y(ge,be,Se,!1,null,null);const ye=Ae.exports;var we=Object.defineProperty,Ce=(i,e,t)=>e in i?we(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,xe=(i,e,t)=>Ce(i,e+"",t);const Le=i=>h.isEmpty(i),Pe=()=>!0,Te=(i,e)=>{const t=i.getSearchObject();let s=!0;for(const[r,n]of Object.entries(e)){const o=t[r];s=n(o),s||(s=!1)}return()=>s},Ee=(i,e,t)=>({refreshCallback:async s=>{const r=e.value.getSearchObject();try{return e.value.updateSearching(!0),await i(r,s)}finally{e.value.updateSearching(!1),e.value.updateTags()}},searchCallback:async()=>{var s;for(const r of t)await((s=r.value)==null?void 0:s.refresh())}});class T{constructor(e){xe(this,"record"),this.record=e}static from(e){const t=e.filter(s=>s.value===void 0?!1:Array.isArray(s.value)?s.value.length>0:!0).reduce((s,r)=>{const n=r.transform?r.transform(r.value):r.value;return{...s,...h.isPlainObject(n)?n:{[r.field]:n}}},{});return new T(t)}transform(e,t){const s=this.record[e],r=t(s);return delete this.record[e],this.record={...this.record,...r},this}toCondition(e){return{...this.record,...e}}}d.APPLY_ALWAYS=Pe,d.APPLY_WHEN_NOT_VALUE=Le,d.APPLY_WITH_MULTIPLE_VALUE=Te,d.SearchBar=ye,d.Searches=T,d.useSearchProxy=Ee,d.vModel=R,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
|