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

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