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