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

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,59 @@
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, keyBy as R, isNumber as D, isBoolean as q, isEmpty as k, chain as B, sum as O, isPlainObject as E } from "lodash-unified";
2
+ import { defineComponent as S, ref as u, shallowRef as N, reactive as I, computed as C } from "vue";
3
+ const Le = (r) => ({
4
+ model: {
5
+ value: F(r, "value"),
6
+ callback: (e) => {
7
+ P(r, "value", e);
8
+ }
9
+ }
10
+ }), V = S({
11
+ name: "SearchTags"
12
+ }), K = /* @__PURE__ */ S({
13
+ ...V,
8
14
  props: {
9
- tags: {}
15
+ tags: null
10
16
  },
11
- setup(s) {
12
- const e = y(), t = () => {
13
- e.value.scrollBy({ left: -200, behavior: "smooth" });
14
- }, r = () => {
15
- e.value.scrollBy({
17
+ setup(r) {
18
+ const e = r, t = u();
19
+ return { __sfc: !0, props: e, scrollContainer: t, scrollLeft: () => {
20
+ t.value.scrollBy({ left: -200, behavior: "smooth" });
21
+ }, scrollRight: () => {
22
+ t.value.scrollBy({
16
23
  left: 200,
17
24
  behavior: "smooth"
18
25
  });
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;
26
+ } };
27
+ }
28
+ });
29
+ function w(r, e, t, s, i, a, h, o) {
30
+ var l = typeof r == "function" ? r.options : r;
31
+ return e && (l.render = e, l.staticRenderFns = t, l._compiled = !0), a && (l._scopeId = "data-v-" + a), {
32
+ exports: r,
33
+ options: l
34
+ };
35
+ }
36
+ var H = function() {
37
+ var e = this, t = e._self._c, s = e._self._setupProxy;
38
+ 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) {
39
+ 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) } })]);
40
+ }), 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);
41
+ }, j = [], z = /* @__PURE__ */ w(
42
+ K,
43
+ H,
44
+ j,
45
+ !1,
46
+ null,
47
+ null
48
+ );
49
+ const M = z.exports;
50
+ var W = Object.defineProperty, G = (r, e, t) => e in r ? W(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, n = (r, e, t) => G(r, typeof e != "symbol" ? e + "" : e, t);
51
+ const A = 6;
52
+ class U {
92
53
  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;
54
+ n(this, "field"), n(this, "label"), n(this, "value"), n(this, "required"), n(this, "index"), n(this, "visible"), n(this, "span"), n(this, "initValue"), n(this, "tagFilter"), n(this, "render"), n(this, "transform");
55
+ var s, i;
56
+ 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 : A, this.render = e.render, this.tagFilter = e.tagFilter, this.transform = e.transform;
94
57
  }
95
58
  clean() {
96
59
  Array.isArray(this.value) ? this.value = [] : this.value = void 0;
@@ -99,16 +62,13 @@ class ae {
99
62
  this.value = this.initValue;
100
63
  }
101
64
  }
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;
65
+ var X = Object.defineProperty, J = (r, e, t) => e in r ? X(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, p = (r, e, t) => J(r, typeof e != "symbol" ? e + "" : e, t);
66
+ class _ {
67
+ constructor(e, t, s, i) {
68
+ p(this, "field"), p(this, "span"), p(this, "index"), p(this, "visible"), this.field = e, this.span = t, this.index = s, this.visible = i;
109
69
  }
110
70
  static fromSearchItem(e, t) {
111
- return new w(
71
+ return new _(
112
72
  e.field,
113
73
  e.span,
114
74
  t ?? e.index,
@@ -116,16 +76,18 @@ class w {
116
76
  );
117
77
  }
118
78
  static formSearchConfig(e, t) {
119
- return new w(
79
+ var s, i;
80
+ return new _(
120
81
  e.field,
121
- e.span ?? H,
82
+ (s = e.span) != null ? s : A,
122
83
  t ?? e,
123
- e.visible ?? !0
84
+ (i = e.visible) != null ? i : !0
124
85
  );
125
86
  }
126
87
  static fromString(e) {
127
- const [t, r, i, n] = e.split("_");
128
- return new w(r, Number(i), Number(t), !!n);
88
+ var t;
89
+ const [s, i, a, h] = e.split("_");
90
+ return new _(i, Number(a), Number(s), (t = !!h) != null ? t : !0);
129
91
  }
130
92
  toString() {
131
93
  return `${this.index}_${this.field}_${this.span}_${this.visible}`;
@@ -134,37 +96,33 @@ class w {
134
96
  this.span = e.span, this.index = e.index, this.visible = e.visible;
135
97
  }
136
98
  }
137
- const V = (s) => `searches_layouts_${s}`;
138
- class ce {
139
- id;
140
- state;
141
- itemLayouts;
142
- initialLayouts;
99
+ const L = (r) => `searches_layouts_${r}`;
100
+ class Q {
143
101
  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();
102
+ p(this, "id"), p(this, "state"), p(this, "itemLayouts"), p(this, "initialLayouts"), this.id = e.id, this.initialLayouts = t, this.state = e, this.itemLayouts = R(e.items.map(_.fromSearchItem), (s) => s.field), this.restoreCachedLayouts();
145
103
  }
146
104
  /**
147
105
  * 恢复自缓存中的布局信息
148
106
  * @private
149
107
  */
150
108
  restoreCachedLayouts() {
151
- const e = localStorage.getItem(V(this.id));
109
+ const e = localStorage.getItem(L(this.id));
152
110
  e && e.split(",").forEach((t) => {
153
- const r = w.fromString(t), i = this.itemLayouts[r.field];
154
- i && i.merge(r);
111
+ const s = _.fromString(t), i = this.itemLayouts[s.field];
112
+ i && i.merge(s);
155
113
  });
156
114
  }
157
115
  sync(e, t) {
158
116
  if (e.length !== Object.keys(this.itemLayouts).length)
159
117
  throw new Error("同步布局字段数量不一致");
160
- e.forEach((r, i) => {
161
- const n = this.itemLayouts[r];
162
- n.index = i, n.visible = t.has(r);
118
+ e.forEach((s, i) => {
119
+ const a = this.itemLayouts[s];
120
+ a.index = i, a.visible = t.has(s);
163
121
  });
164
122
  }
165
123
  persistent() {
166
124
  localStorage.setItem(
167
- V(this.id),
125
+ L(this.id),
168
126
  Object.values(this.itemLayouts).map((e) => e.toString()).join(",")
169
127
  ), this.state.updateTags();
170
128
  }
@@ -175,130 +133,125 @@ class ce {
175
133
  });
176
134
  }
177
135
  }
178
- const ue = [
136
+ var Y = Object.defineProperty, Z = (r, e, t) => e in r ? Y(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, f = (r, e, t) => Z(r, typeof e != "symbol" ? e + "" : e, t);
137
+ const ee = [
179
138
  {
180
- isApply(s) {
181
- return s.contains("el-radio-group");
139
+ isApply(r) {
140
+ return r.contains("el-radio-group");
182
141
  },
183
- getText(s) {
184
- return s.querySelector(".is-active")?.querySelector("input")?.value;
142
+ getText(r) {
143
+ var e, t;
144
+ return (t = (e = r.querySelector(".is-active")) == null ? void 0 : e.querySelector("input")) == null ? void 0 : t.value;
185
145
  }
186
146
  },
187
147
  {
188
- isApply(s) {
189
- return s.contains("el-checkbox-group");
148
+ isApply(r) {
149
+ return r.contains("el-checkbox-group");
190
150
  },
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}条`;
151
+ getText(r) {
152
+ var e;
153
+ const t = Array.from((e = r.querySelectorAll(".el-checkbox__input.is-checked")) != null ? e : []).map((s) => {
154
+ var i;
155
+ return (i = s.querySelector("input")) == null ? void 0 : i.value;
156
+ }).filter((s) => s);
157
+ return t.length === 1 ? t[0] : `${t[0]} 等${t.length}条`;
194
158
  }
195
159
  },
196
160
  {
197
- isApply(s) {
198
- return s.contains("el-input");
161
+ isApply(r) {
162
+ return r.contains("el-input");
199
163
  },
200
- getText(s, e) {
164
+ getText(r, e) {
201
165
  return e.value;
202
166
  }
203
167
  },
204
168
  {
205
- isApply(s) {
206
- return s.contains("el-input-number");
169
+ isApply(r) {
170
+ return r.contains("el-input-number");
207
171
  },
208
- getText(s, e) {
172
+ getText(r, e) {
209
173
  return e.value;
210
174
  }
211
175
  },
212
176
  {
213
- isApply(s) {
214
- return s.contains("el-select");
177
+ isApply(r) {
178
+ return r.contains("el-select");
215
179
  },
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;
180
+ getText(r, e) {
181
+ var t;
182
+ const s = r.querySelectorAll(".el-select__tags-text");
183
+ 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;
219
184
  }
220
185
  },
221
186
  {
222
- isApply(s) {
223
- return s.contains("el-cascader");
187
+ isApply(r) {
188
+ return r.contains("el-cascader");
224
189
  },
225
- getText(s) {
226
- return s.querySelector("input")?.value;
190
+ getText(r) {
191
+ var e;
192
+ return (e = r.querySelector("input")) == null ? void 0 : e.value;
227
193
  }
228
194
  },
229
195
  {
230
- isApply(s) {
231
- return s.contains("el-switch");
196
+ isApply(r) {
197
+ return r.contains("el-switch");
232
198
  },
233
- getText(s) {
234
- return s.querySelector(".is-active").innerHTML;
199
+ getText(r) {
200
+ return r.querySelector(".is-active").innerHTML;
235
201
  }
236
202
  },
237
203
  {
238
- isApply(s) {
239
- return s.contains("el-slider");
204
+ isApply(r) {
205
+ return r.contains("el-slider");
240
206
  },
241
- getText(s, e) {
207
+ getText(r, e) {
242
208
  return e.value;
243
209
  }
244
210
  },
245
211
  {
246
- isApply(s) {
247
- return s.contains("el-date-editor");
212
+ isApply(r) {
213
+ return r.contains("el-date-editor");
248
214
  },
249
- getText(s, e) {
215
+ getText(r, e) {
250
216
  return e.value ? e.value.join(" ~ ") : e.value;
251
217
  }
252
218
  }
253
219
  ];
254
- class R {
255
- id;
256
- field;
257
- value;
258
- label;
259
- valueText;
260
- required;
261
- item;
262
- state;
220
+ class T {
263
221
  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();
222
+ f(this, "id"), f(this, "field"), f(this, "value"), f(this, "label"), f(this, "valueText"), f(this, "required"), f(this, "item"), f(this, "state");
223
+ var s;
224
+ 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
225
  }
266
226
  static hasValue(e) {
267
- return I(e.value) || M(e.value) ? !0 : !z(e.value);
227
+ return D(e.value) || q(e.value) ? !0 : !k(e.value);
268
228
  }
269
229
  updateValueText() {
270
230
  const e = document.querySelector(this.id);
271
231
  if (e.children.length !== 1)
272
232
  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));
233
+ const t = e.children[0], s = ee.find((i) => i.isApply(t.classList));
234
+ s && (this.valueText = s.getText(t, this));
275
235
  }
276
236
  async clean() {
277
237
  this.item.clean(), await this.state.doSearch();
278
238
  }
279
239
  }
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;
240
+ var te = Object.defineProperty, se = (r, e, t) => e in r ? te(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, m = (r, e, t) => se(r, typeof e != "symbol" ? e + "" : e, t);
241
+ class re {
242
+ constructor(e, t, s) {
243
+ this.id = e, m(this, "items"), m(this, "config"), m(this, "searching"), m(this, "tags"), m(this, "searchCallback"), m(this, "sourceSearchable"), this.id = e, this.items = t.map((i, a) => new U(i, a)), this.config = new Q(
244
+ this,
245
+ t.map((i, a) => _.formSearchConfig(i, a))
246
+ ), this.sourceSearchable = t, this.searching = !1, this.searchCallback = s, this.tags = [];
247
+ }
295
248
  updateTags() {
296
- this.tags = this.items.filter((e) => e.tagFilter ? e.tagFilter(e.value) : R.hasValue(e)).map((e) => new R(this, e)).sort(
249
+ this.tags = this.items.filter((e) => e.tagFilter ? e.tagFilter(e.value) : T.hasValue(e)).map((e) => new T(this, e)).sort(
297
250
  (e, t) => this.config.itemLayouts[e.field].index - this.config.itemLayouts[t.field].index
298
251
  );
299
252
  }
300
253
  getSearchObject(e) {
301
- return q.from(this.items).toCondition(e);
254
+ return $.from(this.items).toCondition(e);
302
255
  }
303
256
  async doSearch() {
304
257
  if (!this.searching)
@@ -312,259 +265,174 @@ class de {
312
265
  this.items.forEach((t) => t.reset()), e && await this.doSearch();
313
266
  }
314
267
  }
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 = [
268
+ const ie = {
269
+ functional: !0,
270
+ props: {
271
+ search: {
272
+ type: Object,
273
+ required: !0
274
+ }
275
+ },
276
+ render(r, e) {
277
+ const { props: t } = e;
278
+ return t.search.render(t.search);
279
+ }
280
+ }, ae = () => {
281
+ const r = N(), e = u(), t = u([]), s = u(!1), i = u(), a = u([]), h = u(300), o = (c) => {
282
+ r.value = c, t.value = [
318
283
  {
319
284
  label: "全部",
320
285
  id: "all",
321
- children: s.value.items.sort(
322
- (f, d) => o.config.itemLayouts[f.field].index - o.config.itemLayouts[d.field].index
323
- ).map((f) => ({
324
- label: f.label,
325
- id: f.field
286
+ children: r.value.items.sort(
287
+ (v, x) => c.config.itemLayouts[v.field].index - c.config.itemLayouts[x.field].index
288
+ ).map((v) => ({
289
+ label: v.label,
290
+ id: v.field
326
291
  }))
327
292
  }
328
- ], i.value = P(o.config.itemLayouts).pickBy((f) => f.visible).keys().value();
293
+ ], i.value = B(c.config.itemLayouts).pickBy((v) => v.visible).keys().value();
329
294
  };
330
295
  return {
331
296
  treeRef: e,
332
- visible: r,
297
+ visible: s,
333
298
  snapshot: t,
334
299
  defaultCheckedKeys: i,
335
- drawerWidth: v,
336
- updateSnapshot: h,
337
- show: (o) => {
338
- h(o), r.value = !0;
300
+ drawerWidth: h,
301
+ updateSnapshot: o,
302
+ show: (c) => {
303
+ o(c), s.value = !0;
339
304
  },
340
305
  save: () => {
341
- s.value.config.sync(
342
- t.value[0].children.map((o) => o.id),
306
+ r.value.config.sync(
307
+ t.value[0].children.map((c) => c.id),
343
308
  new Set(e.value.getCheckedKeys())
344
- ), s.value.config.persistent();
309
+ ), r.value.config.persistent();
345
310
  },
346
311
  reset: () => {
347
- s.value.config.reset(), h(s.value);
312
+ r.value.config.reset(), o(r.value);
348
313
  },
349
314
  keepSelection: () => {
350
- n.value = e.value.getCheckedKeys();
315
+ a.value = e.value.getCheckedKeys();
351
316
  },
352
317
  restoreSelection: () => {
353
- e.value.setCheckedKeys(n.value), n.value = [];
318
+ e.value.setCheckedKeys(a.value), a.value = [];
354
319
  },
355
- allowDrop: (o, f, d) => d !== "inner"
320
+ allowDrop: (c, v, x) => x !== "inner"
356
321
  };
357
- }, pe = /* @__PURE__ */ L({
322
+ }, ne = /* @__PURE__ */ S({
358
323
  __name: "SearchSettingsDrawer",
359
- setup(s, { expose: e }) {
324
+ setup(r, { expose: e }) {
360
325
  const {
361
326
  treeRef: t,
362
- visible: r,
327
+ visible: s,
363
328
  snapshot: i,
364
- drawerWidth: n,
365
- defaultCheckedKeys: v,
366
- show: h,
367
- allowDrop: p,
368
- keepSelection: T,
369
- restoreSelection: b,
370
- save: l,
371
- reset: x
372
- } = fe();
329
+ drawerWidth: a,
330
+ defaultCheckedKeys: h,
331
+ show: o,
332
+ allowDrop: l,
333
+ keepSelection: y,
334
+ restoreSelection: g,
335
+ save: d,
336
+ reset: b
337
+ } = ae();
373
338
  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({
339
+ show: o
340
+ }), { __sfc: !0, treeRef: t, visible: s, snapshot: i, drawerWidth: a, defaultCheckedKeys: h, show: o, allowDrop: l, keepSelection: y, restoreSelection: g, save: d, reset: b };
341
+ }
342
+ });
343
+ var le = function() {
344
+ var e = this, t = e._self._c, s = e._self._setupProxy;
345
+ return t("el-drawer", { attrs: { size: s.drawerWidth, title: "搜索项配置", visible: s.visible }, on: { "update:visible": function(i) {
346
+ s.visible = i;
347
+ } } }, [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 }, 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)]);
348
+ }, oe = [], ce = /* @__PURE__ */ w(
349
+ ne,
350
+ le,
351
+ oe,
352
+ !1,
353
+ null,
354
+ null
355
+ );
356
+ const ue = ce.exports, he = /* @__PURE__ */ S({
422
357
  __name: "SettingButton",
423
358
  props: {
424
- state: {}
359
+ state: null
425
360
  },
426
- setup(s) {
427
- const e = s, t = y(), r = () => {
361
+ setup(r) {
362
+ const e = r, t = u();
363
+ return { __sfc: !0, props: e, searchSettingDialogRef: t, showSearchLayoutDialog: () => {
428
364
  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
- };
365
+ }, SearchSettingsDrawer: ue };
451
366
  }
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({
367
+ });
368
+ var de = function() {
369
+ var e = this, t = e._self._c, s = e._self._setupProxy;
370
+ 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);
371
+ }, fe = [], pe = /* @__PURE__ */ w(
372
+ he,
373
+ de,
374
+ fe,
375
+ !1,
376
+ null,
377
+ "61aa7563"
378
+ );
379
+ const ve = pe.exports, _e = /* @__PURE__ */ S({
453
380
  __name: "SearchBar",
454
381
  props: {
455
- searches: {},
456
- id: {},
457
- onSearch: {},
382
+ searches: null,
383
+ id: null,
384
+ onSearch: { type: Function },
458
385
  defaultSpan: { default: 6 },
459
386
  maxRows: { default: 2 },
460
387
  itemHeight: { default: 67 },
461
388
  resetAutoSearch: { type: Boolean, default: !0 }
462
389
  },
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 = $(() => ({
390
+ setup(r, { expose: e }) {
391
+ const t = r, s = I(new re(t.id, t.searches, t.onSearch)), i = u(!1), a = C(() => O(Array.from(Object.values(s.config.itemLayouts)).map((d) => d.span)) / 24 > t.maxRows), h = C(() => [...s.items].sort((d, b) => s.config.itemLayouts[d.field].index - s.config.itemLayouts[b.field].index).filter((d) => s.config.itemLayouts[d.field].visible)), o = C(() => ({
465
392
  height: `${t.itemHeight * t.maxRows}px`,
466
393
  overflow: "hidden"
467
- })), p = (b) => r.config.itemLayouts[b.field];
394
+ })), l = (g) => s.config.itemLayouts[g.field], y = () => s.items;
468
395
  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
- };
396
+ getSearchItems: y
397
+ }), { __sfc: !0, props: t, state: s, expanded: i, isShowSpanIcon: a, sortedItems: h, itemHeightStyle: o, getLayout: l, getSearchItems: y, SearchTagsRender: M, SearchItemRender: ie, SettingButton: ve };
546
398
  }
547
399
  });
548
- class q {
549
- record;
400
+ var ge = function() {
401
+ var e = this, t = e._self._c, s = e._self._setupProxy;
402
+ 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) {
403
+ 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 } })], 1)])]);
404
+ }), 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) {
405
+ s.expanded = !s.expanded;
406
+ } } }, [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);
407
+ }, me = [], ye = /* @__PURE__ */ w(
408
+ _e,
409
+ ge,
410
+ me,
411
+ !1,
412
+ null,
413
+ null
414
+ );
415
+ const Te = ye.exports;
416
+ var Se = Object.defineProperty, be = (r, e, t) => e in r ? Se(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, we = (r, e, t) => be(r, e + "", t);
417
+ class $ {
550
418
  constructor(e) {
551
- this.record = e;
419
+ we(this, "record"), this.record = e;
552
420
  }
553
421
  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;
422
+ const t = e.filter((s) => s.value === void 0 ? !1 : Array.isArray(s.value) ? s.value.length > 0 : !0).reduce(
423
+ (s, i) => {
424
+ const a = i.transform ? i.transform(i.value) : i.value;
557
425
  return {
558
- ...r,
559
- ...G(n) ? n : { [i.field]: n }
426
+ ...s,
427
+ ...E(a) ? a : { [i.field]: a }
560
428
  };
561
429
  },
562
430
  {}
563
431
  );
564
- return new q(t);
432
+ return new $(t);
565
433
  }
566
434
  transform(e, t) {
567
- const r = this.record[e], i = t(r);
435
+ const s = this.record[e], i = t(s);
568
436
  return delete this.record[e], this.record = { ...this.record, ...i }, this;
569
437
  }
570
438
  toCondition(e) {
@@ -572,6 +440,7 @@ class q {
572
440
  }
573
441
  }
574
442
  export {
575
- Le as SearchBar,
576
- q as Searches
443
+ Te as SearchBar,
444
+ $ as Searches,
445
+ Le as vModel
577
446
  };