@scvzerng/element-plus-search-vue2 0.0.6 → 0.0.7

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 q, keyBy as P, isNumber as U, isBoolean as G, isEmpty as W, chain as X, sum as J, isPlainObject as Q } from "lodash-unified";
2
- import { defineComponent as T, ref as v, resolveComponent as g, createElementBlock as C, openBlock as h, createVNode as o, createElementVNode as y, withCtx as c, unref as u, Fragment as H, renderList as K, createBlock as b, createTextVNode as x, toDisplayString as I, reactive as M, shallowRef as Y, isRef as Z, computed as R, normalizeStyle as ee, normalizeClass as te, withDirectives as se, vShow as ie, createCommentVNode as N } from "vue";
3
- import { ArrowLeft as re, ArrowRight as ne, ArrowDown as ae, ArrowUp as le } from "@element-plus/icons-vue";
4
- import { Setting as oe } from "@scvzerng/icons";
5
- import { watchDebounced as ce } from "@vueuse/core";
6
- const ue = { class: "tags-scroll-container" }, de = ["innerHTML"], he = /* @__PURE__ */ T({
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 = v(), 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, a) => {
22
- const f = g("el-icon"), d = g("el-tag");
23
- return h(), C("div", ue, [
24
- o(d, {
25
- type: "info",
26
- class: "scroll-left-bar",
27
- onClick: t
28
- }, {
29
- default: c(() => [
30
- o(f, null, {
31
- default: c(() => [
32
- o(u(re))
33
- ]),
34
- _: 1
35
- }),
36
- a[0] || (a[0] = y("i", { class: "el-icon-arrow-left" }, null, -1))
37
- ]),
38
- _: 1
39
- }),
40
- y("div", {
41
- ref_key: "scrollContainer",
42
- ref: e,
43
- class: "search-tags"
44
- }, [
45
- (h(!0), C(H, null, K(s.tags, (p) => (h(), b(d, {
46
- class: "search-tag",
47
- onClose: () => p.clean(),
48
- closable: !p.required,
49
- type: p.required ? "primary" : "info",
50
- key: p.field
51
- }, {
52
- default: c(() => [
53
- y("span", null, I(p.label), 1),
54
- a[1] || (a[1] = x(": ", -1)),
55
- y("span", {
56
- innerHTML: p.valueText
57
- }, null, 8, de)
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(f, null, {
69
- default: c(() => [
70
- o(u(ne))
71
- ]),
72
- _: 1
73
- })
74
- ]),
75
- _: 1
76
- })
77
- ]);
78
- };
27
+ } };
79
28
  }
80
- }), z = 6;
81
- class fe {
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 ?? z, 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 fe {
102
63
  this.value = this.initValue;
103
64
  }
104
65
  isEnable(e) {
105
- return q(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 q(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 S {
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 S(
78
+ return new g(
121
79
  e.field,
122
80
  e.span,
123
81
  t ?? e.index,
@@ -125,16 +83,17 @@ class S {
125
83
  );
126
84
  }
127
85
  static formSearchConfig(e, t) {
128
- return new S(
86
+ var s, i;
87
+ return new g(
129
88
  e.field,
130
- e.span ?? z,
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, a] = e.split("_");
137
- return new S(r, Number(i), Number(t), a === "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 S {
143
102
  this.span = e.span, this.index = e.index, this.visible = e.visible;
144
103
  }
145
104
  }
146
- const B = (s) => `searches_layouts_${s}`;
147
- class pe {
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 = P(e.items.map(S.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(B(this.id));
115
+ const e = localStorage.getItem(D(this.id));
161
116
  e && e.split(",").forEach((t) => {
162
- const r = S.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 a = this.itemLayouts[r];
171
- a.index = i, a.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
- B(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 pe {
184
139
  });
185
140
  }
186
141
  }
187
- const ge = [
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 F {
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 U(e.value) || G(e.value) ? !0 : !W(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 = ge.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 me {
290
- constructor(e, t, r) {
291
- this.id = e, this.id = e, this.items = t.map((i, a) => new fe(i, a)), this.config = M(
292
- new pe(
293
- this,
294
- t.map((i, a) => S.formSearchConfig(i, a))
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) : F.hasValue(e)).map((e) => new F(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,47 +272,59 @@ class me {
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 ve = ({ 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
- }, ye = () => {
334
- const s = Y(), e = v(), t = v([]), r = v(!1), i = v(), a = v([]), f = v(300), d = (l) => {
335
- s.value = l, 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
- (n, m) => l.config.itemLayouts[n.field].index - l.config.itemLayouts[m.field].index
341
- ).map((n) => ({
342
- label: n.label,
343
- id: n.field,
344
- disabled: !n.isEnable(l)
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 = X(l.config.itemLayouts).pickBy((n) => n.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: f,
355
- updateSnapshot: d,
356
- show: (l) => {
357
- d(l), 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((l) => l.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
330
  a.value = e.value.getCheckedKeys();
@@ -371,228 +332,129 @@ const ve = ({ search: s, api: e }) => {
371
332
  restoreSelection: () => {
372
333
  e.value.setCheckedKeys(a.value), a.value = [];
373
334
  },
374
- allowDrop: (l, n, m) => m !== "inner",
375
- allowDrag: (l) => !l.disabled
335
+ allowDrop: (n, u, $) => $ !== "inner",
336
+ allowDrag: (n) => !n.disabled
376
337
  };
377
- }, be = /* @__PURE__ */ T({
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
345
  drawerWidth: a,
385
- defaultCheckedKeys: f,
386
- show: d,
387
- allowDrop: p,
388
- allowDrag: k,
389
- keepSelection: w,
390
- restoreSelection: L,
391
- save: A,
392
- reset: j
393
- } = ye();
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
- }), (V, l) => {
397
- const n = g("el-tree"), m = g("el-button"), D = g("el-drawer");
398
- return h(), b(D, {
399
- class: "search-setting",
400
- size: u(a),
401
- title: "搜索项配置",
402
- modelValue: u(r),
403
- "onUpdate:modelValue": l[0] || (l[0] = (O) => Z(r) ? r.value = O : null)
404
- }, {
405
- footer: c(() => [
406
- o(m, { onClick: u(j) }, {
407
- default: c(() => [...l[1] || (l[1] = [
408
- x("重置", -1)
409
- ])]),
410
- _: 1
411
- }, 8, ["onClick"]),
412
- o(m, {
413
- type: "primary",
414
- onClick: u(A)
415
- }, {
416
- default: c(() => [...l[2] || (l[2] = [
417
- x("保存", -1)
418
- ])]),
419
- _: 1
420
- }, 8, ["onClick"])
421
- ]),
422
- default: c(() => [
423
- o(n, {
424
- class: "tree",
425
- "default-expand-all": "",
426
- "default-checked-keys": u(f),
427
- "node-key": "id",
428
- ref_key: "treeRef",
429
- ref: t,
430
- draggable: "",
431
- "show-checkbox": "",
432
- data: u(i),
433
- onNodeDragStart: u(w),
434
- onNodeDragEnd: u(L),
435
- "allow-drop": u(p),
436
- "allow-drag": u(k)
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
- }), _e = /* @__PURE__ */ T({
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 = v(), 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, a) => {
453
- const f = g("el-icon"), d = g("el-button");
454
- return h(), b(d, {
455
- class: "icon-button",
456
- onClick: r
457
- }, {
458
- default: c(() => [
459
- o(f, null, {
460
- default: c(() => [
461
- o(u(oe))
462
- ]),
463
- _: 1
464
- }),
465
- o(be, {
466
- ref_key: "searchSettingDialogRef",
467
- ref: t
468
- }, null, 512)
469
- ]),
470
- _: 1
471
- });
472
- };
382
+ }, SearchSettingsDrawer: pe };
473
383
  }
474
- }), Se = { class: "search-bar-container" }, we = { class: "search-item" }, xe = { class: "search-item-title" }, ke = ["id"], Ce = { class: "search-bottom" }, Te = { class: "actions" }, $e = /* @__PURE__ */ T({
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 = M(new me(r.id, r.searches, r.onSearch)), a = v(!1), f = R(() => J(Array.from(Object.values(i.config.itemLayouts)).filter((n) => n.visible).map((n) => n.span)) / 24 > r.maxRows), d = v([]), p = t;
488
- ce(() => i.items, () => {
489
- const l = [...i.items];
490
- d.value = l.sort((n, m) => i.config.itemLayouts[n.field].index - i.config.itemLayouts[m.field].index).filter((n) => i.config.itemLayouts[n.field].visible).filter((n) => n.isEnable(i)), p("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 k = R(() => ({
493
- height: `${r.itemHeight * r.maxRows}px`,
414
+ const c = O(() => ({
415
+ height: `${s.itemHeight * s.maxRows}px`,
494
416
  overflow: "hidden"
495
- })), w = (l) => i.config.itemLayouts[l.field];
496
- return e({
497
- getSearchItems: () => i.items,
498
- getSearchObject: () => i.getSearchObject(),
499
- updateSearching: (l) => {
500
- i.searching = l;
501
- },
502
- updateTags: () => {
503
- i.updateTags();
504
- }
505
- }), (l, n) => {
506
- const m = g("el-col"), D = g("el-row"), O = g("el-icon"), $ = g("el-button");
507
- return h(), C("div", Se, [
508
- o(D, {
509
- class: te("search"),
510
- style: ee(f.value && !a.value ? k.value : {}),
511
- gutter: 16
512
- }, {
513
- default: c(() => [
514
- (h(!0), C(H, null, K(d.value, (_) => se((h(), b(m, {
515
- span: w(_).span,
516
- key: _.field
517
- }, {
518
- default: c(() => [
519
- y("div", we, [
520
- y("div", xe, I(_.label), 1),
521
- y("div", {
522
- id: `${s.id}-${_.field}`,
523
- class: "search-item-content"
524
- }, [
525
- o(u(ve), {
526
- search: _,
527
- api: i
528
- }, null, 8, ["search", "api"])
529
- ], 8, ke)
530
- ])
531
- ]),
532
- _: 2
533
- }, 1032, ["span"])), [
534
- [ie, w(_).visible]
535
- ])), 128))
536
- ]),
537
- _: 1
538
- }, 8, ["style"]),
539
- y("div", Ce, [
540
- i.tags.length > 0 ? (h(), b(he, {
541
- key: 0,
542
- tags: i.tags
543
- }, null, 8, ["tags"])) : N("", !0),
544
- y("div", Te, [
545
- f.value ? (h(), b($, {
546
- key: 0,
547
- class: "icon-button",
548
- onClick: n[0] || (n[0] = (_) => a.value = !a.value)
549
- }, {
550
- default: c(() => [
551
- o(O, null, {
552
- default: c(() => [
553
- a.value ? (h(), b(u(le), { key: 1 })) : (h(), b(u(ae), { key: 0 }))
554
- ]),
555
- _: 1
556
- })
557
- ]),
558
- _: 1
559
- })) : N("", !0),
560
- o(_e, { state: i }, null, 8, ["state"]),
561
- o($, {
562
- onClick: n[1] || (n[1] = () => i.reset(s.resetAutoSearch))
563
- }, {
564
- default: c(() => [...n[3] || (n[3] = [
565
- x("重 置", -1)
566
- ])]),
567
- _: 1
568
- }),
569
- o($, {
570
- type: "primary",
571
- loading: i.searching,
572
- disabled: i.searching,
573
- onClick: n[2] || (n[2] = () => i.doSearch())
574
- }, {
575
- default: c(() => [...n[4] || (n[4] = [
576
- x("搜 索", -1)
577
- ])]),
578
- _: 1
579
- }, 8, ["loading", "disabled"])
580
- ])
581
- ])
582
- ]);
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();
583
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 };
584
428
  }
585
- }), Ee = (s, e, t) => ({
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) => ({
586
448
  /**
587
449
  * 数据刷新回调代理
588
450
  *
589
451
  * 填充数据拉取接口的搜索参数
590
452
  * @param param
591
453
  */
592
- refreshCallback: async (r) => {
454
+ refreshCallback: async (s) => {
593
455
  const i = e.value.getSearchObject();
594
456
  try {
595
- return e.value.updateSearching(!0), await s(i, r);
457
+ return e.value.updateSearching(!0), await r(i, s);
596
458
  } finally {
597
459
  e.value.updateSearching(!1), e.value.updateTags();
598
460
  }
@@ -603,30 +465,30 @@ const ve = ({ search: s, api: e }) => {
603
465
  * 回调所有的可刷新组件
604
466
  */
605
467
  searchCallback: async () => {
606
- for (const r of t)
607
- await r.value?.refresh();
468
+ var s;
469
+ for (const i of t)
470
+ await ((s = i.value) == null ? void 0 : s.refresh());
608
471
  }
609
472
  });
610
- class E {
611
- record;
473
+ class L {
612
474
  constructor(e) {
613
- this.record = e;
475
+ Le(this, "record"), this.record = e;
614
476
  }
615
477
  static from(e) {
616
- const t = e.filter((r) => r.value === void 0 ? !1 : Array.isArray(r.value) ? r.value.length > 0 : !0).reduce(
617
- (r, i) => {
478
+ const t = e.filter((s) => s.value === void 0 ? !1 : Array.isArray(s.value) ? s.value.length > 0 : !0).reduce(
479
+ (s, i) => {
618
480
  const a = i.transform ? i.transform(i.value) : i.value;
619
481
  return {
620
- ...r,
621
- ...Q(a) ? a : { [i.field]: a }
482
+ ...s,
483
+ ...V(a) ? a : { [i.field]: a }
622
484
  };
623
485
  },
624
486
  {}
625
487
  );
626
- return new E(t);
488
+ return new L(t);
627
489
  }
628
490
  transform(e, t) {
629
- const r = this.record[e], i = t(r);
491
+ const s = this.record[e], i = t(s);
630
492
  return delete this.record[e], this.record = { ...this.record, ...i }, this;
631
493
  }
632
494
  toCondition(e) {
@@ -634,7 +496,8 @@ class E {
634
496
  }
635
497
  }
636
498
  export {
637
- $e as SearchBar,
638
- E as Searches,
639
- Ee as useSearchProxy
499
+ Fe as SearchBar,
500
+ L as Searches,
501
+ Pe as useSearchProxy,
502
+ Ae as vModel
640
503
  };