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

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