@scvzerng/element-plus-search-vue2 0.0.3 → 0.0.4

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