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

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