@amaoaaaaa/search-table 0.1.2 → 0.2.0

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.
package/README.md CHANGED
@@ -103,19 +103,20 @@ const columns = [{ label: '姓名', prop: 'name' }];
103
103
 
104
104
  ### SearchTable Props
105
105
 
106
- | 属性 | 类型 | 默认值 | 说明 |
107
- | ------------------------ | ------------------------------------ | ------------------ | -------------------- |
108
- | `columns` | `ProTableColumn[]` | - | 表格列配置 |
109
- | `fetchFn` | `SearchTableFetchFn` | **必填** | 数据请求函数 |
110
- | `showSearch` | `boolean` | `true` | 是否显示搜索区域 |
111
- | `searchInputPlaceholder` | `string` | `"输入搜索关键词"` | 搜索框占位文本 |
112
- | `showAddButton` | `boolean` | `false` | 是否显示新增按钮 |
113
- | `showBatchDeleteButton` | `boolean` | `false` | 是否显示批量删除按钮 |
114
- | `pageSize` | `number` | 自动计算 | 每页条数 |
115
- | `elPaginationProps` | `Partial<PaginationProps>` | - | 分页组件属性 |
116
- | `defaultSort` | `SortState` | - | 默认排序 |
117
- | `selectable` | `boolean \| (row, index) => boolean` | - | 是否可勾选 |
118
- | `searchParamsHandler` | `(params) => params` | - | 搜索参数处理函数 |
106
+ | 属性 | 类型 | 默认值 | 说明 |
107
+ | ------------------------ | ------------------------------------ | ------------------ | ---------------------------- |
108
+ | `columns` | `ProTableColumn[]` | - | 表格列配置 |
109
+ | `fetchFn` | `SearchTableFetchFn` | **必填** | 数据请求函数 |
110
+ | `showSearch` | `boolean` | `true` | 是否显示搜索区域 |
111
+ | `searchInputPlaceholder` | `string` | `"输入搜索关键词"` | 搜索框占位文本 |
112
+ | `searchField` | `string` | `"search"` | 搜索框绑定到查询参数的字段名 |
113
+ | `showAddButton` | `boolean` | `false` | 是否显示新增按钮 |
114
+ | `showBatchDeleteButton` | `boolean` | `false` | 是否显示批量删除按钮 |
115
+ | `pageSize` | `number` | 自动计算 | 每页条数 |
116
+ | `elPaginationProps` | `Partial<PaginationProps>` | - | 分页组件属性 |
117
+ | `defaultSort` | `SortState` | - | 默认排序 |
118
+ | `selectable` | `boolean \| (row, index) => boolean` | - | 是否可勾选 |
119
+ | `searchParamsHandler` | `(params) => params` | - | 搜索参数处理函数 |
119
120
 
120
121
  ### SearchTable Events
121
122
 
@@ -0,0 +1,2 @@
1
+ import { default as SearchTable } from './index.vue';
2
+ export type SearchTableInstance = InstanceType<typeof SearchTable>;
@@ -9,10 +9,7 @@ declare function __VLS_template(): {
9
9
  attrs: Partial<{}>;
10
10
  slots: {
11
11
  'search-form'?(_: {
12
- query: {
13
- [x: string]: any;
14
- search: string;
15
- };
12
+ query: Record<string, any>;
16
13
  search: typeof resetToFirstPage;
17
14
  }): any;
18
15
  'top-center'?(_: {}): any;
@@ -2007,6 +2004,7 @@ declare const __VLS_component: import('vue').DefineComponent<__VLS_Props, {
2007
2004
  indexWidth: string | number;
2008
2005
  showSearch: boolean;
2009
2006
  searchInputPlaceholder: string;
2007
+ searchField: string;
2010
2008
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
2011
2009
  proTableRef: import('vue').CreateComponentPublicInstanceWithMixins<Readonly<{
2012
2010
  filterData?: Record<string, any>;
@@ -11,6 +11,12 @@ export type SearchTableProps<T extends TableRow = any> = Omit<ProTableProps<T>,
11
11
  * 搜索输入框的提示语
12
12
  */
13
13
  searchInputPlaceholder?: string;
14
+ /**
15
+ * 搜索框绑定到查询参数的字段名
16
+ *
17
+ * @default 'search'
18
+ */
19
+ searchField?: string;
14
20
  /**
15
21
  * 是否显示新增按钮
16
22
  *
package/dist/index.d.ts CHANGED
@@ -2,9 +2,5 @@ export { default as SearchTable } from './SearchTable/index.vue';
2
2
  export { default as ProTable } from './ProTable/index.vue';
3
3
  export type { ProTableInstance } from './ProTable';
4
4
  export type { SearchTableProps, SearchTableFetchFn, PageParams, PageResp, } from './SearchTable/types';
5
- export type { ProTableProps, ProTableColumn, ProTableAction, TableRow, FilterOption, FilterType, ActionButtonVisibility, ApplyFilterPayload, CellEditPayload, } from './ProTable/types';
6
- export { SelectionStore } from './SearchTable/SelectionStore';
7
- export { useTableSort } from './SearchTable/useTableSort';
8
- export type { SortState, UseTableSortOption } from './SearchTable/useTableSort';
9
- export { useDelayedRef } from './hooks/useDelayedRef';
10
- export { parseErrorReason } from './utils/parseErrorReason';
5
+ export type { SearchTableInstance } from './SearchTable';
6
+ export type { ProTableProps, ProTableColumn, ProTableAction, TableRow, FilterOption, FilterType, ActionButtonVisibility, ApplyFilterPayload, CellEditPayload, ProTableColumn as SearchTableColumn, ProTableAction as SearchTableAction, } from './ProTable/types';
@@ -1,12 +1,12 @@
1
- var Ve = Object.defineProperty;
2
- var $e = (l, t, f) => t in l ? Ve(l, t, { enumerable: !0, configurable: !0, writable: !0, value: f }) : l[t] = f;
3
- var re = (l, t, f) => $e(l, typeof t != "symbol" ? t + "" : t, f);
4
- import { defineComponent as me, computed as te, isVNode as Be, openBlock as s, createBlock as C, resolveDynamicComponent as ze, createElementBlock as w, markRaw as G, createElementVNode as R, useModel as Pe, useTemplateRef as ke, ref as z, withDirectives as Z, createVNode as E, unref as n, withCtx as x, createCommentVNode as H, createTextVNode as $, toDisplayString as O, Fragment as U, renderList as ee, mergeProps as fe, createSlots as He, isRef as Se, normalizeClass as De, toValue as ye, withModifiers as oe, withKeys as ve, normalizeStyle as ge, mergeModels as be, reactive as he, nextTick as le, toRef as Fe, watch as Ce, onMounted as Me, onUnmounted as Ke, renderSlot as ue } from "vue";
5
- import { ElLoading as _e, ElTable as Le, ElTableColumn as de, ElPopover as Ae, ElScrollbar as xe, ElRadioGroup as Oe, ElRadio as Ue, ElCheckboxGroup as Ne, ElCheckbox as je, ElDatePicker as We, ElButton as F, ElInput as Ee, ElPopconfirm as Ge, ElText as Ie, ElTooltip as qe, ElPagination as Ye, ElMessage as Je } from "element-plus";
6
- import { isFunction as A, isBoolean as we, cloneDeep as I, isString as Qe, keys as pe, merge as Xe, isEqual as Ze, sortBy as et, uniq as tt, pickBy as lt, countBy as nt } from "lodash-es";
1
+ var Be = Object.defineProperty;
2
+ var ze = (l, t, f) => t in l ? Be(l, t, { enumerable: !0, configurable: !0, writable: !0, value: f }) : l[t] = f;
3
+ var re = (l, t, f) => ze(l, typeof t != "symbol" ? t + "" : t, f);
4
+ import { defineComponent as me, computed as I, isVNode as Pe, openBlock as s, createBlock as C, resolveDynamicComponent as He, createElementBlock as x, markRaw as q, createElementVNode as V, useModel as Fe, useTemplateRef as Se, ref as z, withDirectives as ee, createVNode as E, unref as n, withCtx as b, createCommentVNode as F, createTextVNode as $, toDisplayString as O, Fragment as U, renderList as te, mergeProps as fe, createSlots as De, isRef as Ce, normalizeClass as Me, toValue as ge, withModifiers as oe, withKeys as ve, normalizeStyle as be, mergeModels as xe, reactive as he, nextTick as le, toRef as Ke, watch as Ee, onMounted as _e, onUnmounted as Le, renderSlot as ue } from "vue";
5
+ import { ElLoading as Ae, ElTable as Oe, ElTableColumn as de, ElPopover as Ue, ElScrollbar as we, ElRadioGroup as Ne, ElRadio as je, ElCheckboxGroup as We, ElCheckbox as Ge, ElDatePicker as Ie, ElButton as M, ElInput as Te, ElPopconfirm as qe, ElText as Ye, ElTooltip as Qe, ElPagination as Je, ElMessage as Xe } from "element-plus";
6
+ import { isFunction as A, isBoolean as ke, cloneDeep as Q, isString as Ze, keys as pe, merge as et, isEqual as tt, sortBy as lt, uniq as nt, pickBy as at, countBy as it } from "lodash-es";
7
7
  import { vTextEllipsis as ce } from "@amaoaaaaa/v-text-ellipsis";
8
- import { isCancel as Te } from "axios";
9
- const at = ["innerHTML"], it = /* @__PURE__ */ me({
8
+ import { isCancel as Re } from "axios";
9
+ const st = ["innerHTML"], rt = /* @__PURE__ */ me({
10
10
  __name: "RenderFormatterResult",
11
11
  props: {
12
12
  col: {},
@@ -15,24 +15,24 @@ const at = ["innerHTML"], it = /* @__PURE__ */ me({
15
15
  index: {}
16
16
  },
17
17
  setup(l) {
18
- const t = l, f = te(() => {
18
+ const t = l, f = I(() => {
19
19
  var r, p;
20
- const d = t.col.prop ? t.row[t.col.prop] : void 0;
21
- return (p = (r = t.col).formatter) == null ? void 0 : p.call(r, t.row, t.column, d, t.index);
20
+ const o = t.col.prop ? t.row[t.col.prop] : void 0;
21
+ return (p = (r = t.col).formatter) == null ? void 0 : p.call(r, t.row, t.column, o, t.index);
22
22
  });
23
- return (d, r) => Be(f.value) ? (s(), C(ze(f.value), { key: 0 })) : (s(), w("span", {
23
+ return (o, r) => Pe(f.value) ? (s(), C(He(f.value), { key: 0 })) : (s(), x("span", {
24
24
  key: 1,
25
25
  innerHTML: f.value
26
- }, null, 8, at));
26
+ }, null, 8, st));
27
27
  }
28
- }), st = {
28
+ }), ot = {
29
29
  viewBox: "0 0 24 24",
30
30
  width: "1.2em",
31
31
  height: "1.2em"
32
32
  };
33
- function rt(l, t) {
34
- return s(), w("svg", st, [...t[0] || (t[0] = [
35
- R("path", {
33
+ function ut(l, t) {
34
+ return s(), x("svg", ot, [...t[0] || (t[0] = [
35
+ V("path", {
36
36
  fill: "none",
37
37
  stroke: "currentColor",
38
38
  "stroke-linecap": "round",
@@ -42,14 +42,14 @@ function rt(l, t) {
42
42
  }, null, -1)
43
43
  ])]);
44
44
  }
45
- const ot = G({ name: "tabler-filter", render: rt }), ut = {
45
+ const dt = q({ name: "tabler-filter", render: ut }), ct = {
46
46
  viewBox: "0 0 24 24",
47
47
  width: "1.2em",
48
48
  height: "1.2em"
49
49
  };
50
- function dt(l, t) {
51
- return s(), w("svg", ut, [...t[0] || (t[0] = [
52
- R("path", {
50
+ function ft(l, t) {
51
+ return s(), x("svg", ct, [...t[0] || (t[0] = [
52
+ V("path", {
53
53
  fill: "none",
54
54
  stroke: "currentColor",
55
55
  "stroke-linecap": "round",
@@ -59,12 +59,12 @@ function dt(l, t) {
59
59
  }, null, -1)
60
60
  ])]);
61
61
  }
62
- const ct = G({ name: "tabler-filter-check", render: dt }), ft = { "element-loading-text": "加载中..." }, vt = { class: "flex justify-center" }, pt = { class: "-mx-3 flex w-[150px] items-center justify-evenly" }, mt = {
62
+ const vt = q({ name: "tabler-filter-check", render: ft }), pt = { "element-loading-text": "加载中..." }, mt = { class: "flex justify-center" }, ht = { class: "-mx-3 flex w-[150px] items-center justify-evenly" }, yt = {
63
63
  key: 0,
64
64
  class: "h-[23px]"
65
- }, ht = ["onDblclick"], yt = { key: 1 }, gt = /* @__PURE__ */ me({
65
+ }, gt = ["onDblclick"], bt = { key: 1 }, xt = /* @__PURE__ */ me({
66
66
  __name: "index",
67
- props: /* @__PURE__ */ be({
67
+ props: /* @__PURE__ */ xe({
68
68
  data: {},
69
69
  columns: {},
70
70
  rowKey: { default: "id" },
@@ -79,46 +79,46 @@ const ct = G({ name: "tabler-filter-check", render: dt }), ft = { "element-loadi
79
79
  },
80
80
  filterDataModifiers: {}
81
81
  }),
82
- emits: /* @__PURE__ */ be(["applyFilter", "selectionChange", "cell-edit"], ["update:filterData"]),
82
+ emits: /* @__PURE__ */ xe(["applyFilter", "selectionChange", "cell-edit"], ["update:filterData"]),
83
83
  setup(l, { expose: t, emit: f }) {
84
- const d = _e.directive, r = l, p = Pe(l, "filterData"), S = f, B = ke("elTableRef"), g = z({}), k = z({});
84
+ const o = Ae.directive, r = l, p = Fe(l, "filterData"), k = f, B = Se("elTableRef"), g = z({}), w = z({});
85
85
  function ne(a) {
86
- g.value[a] = I(p.value[a]);
86
+ g.value[a] = Q(p.value[a]);
87
87
  }
88
88
  function ae(a) {
89
- g.value[a] = I(p.value[a]);
89
+ g.value[a] = Q(p.value[a]);
90
90
  }
91
- function q(a, o, e) {
92
- g.value[a] = void 0, p.value[a] = void 0, M(a, o, e);
91
+ function J(a, v, e) {
92
+ g.value[a] = void 0, p.value[a] = void 0, N(a, v, e);
93
93
  }
94
- function M(a, o, e) {
95
- p.value[a] = g.value[a], k.value[a] = !1, S("applyFilter", {
94
+ function N(a, v, e) {
95
+ p.value[a] = g.value[a], w.value[a] = !1, k("applyFilter", {
96
96
  col: e,
97
97
  prop: a,
98
- type: o,
98
+ type: v,
99
99
  value: p.value[a],
100
100
  filterData: p.value
101
101
  });
102
102
  }
103
- function N(a, o) {
104
- const e = A(a.actions) ? a.actions(o) : a.actions;
105
- return e == null ? void 0 : e.map((v) => {
106
- const m = A(v.visibility) ? v.visibility(o) : v.visibility ?? !0;
107
- return { ...v, visibility: m };
108
- }).filter((v) => v.visibility !== !1);
103
+ function j(a, v) {
104
+ const e = A(a.actions) ? a.actions(v) : a.actions;
105
+ return e == null ? void 0 : e.map((c) => {
106
+ const h = A(c.visibility) ? c.visibility(v) : c.visibility ?? !0;
107
+ return { ...c, visibility: h };
108
+ }).filter((c) => c.visibility !== !1);
109
109
  }
110
- function b(a) {
110
+ function S(a) {
111
111
  return a.filterFieldName ?? a.prop;
112
112
  }
113
- function K(a, o) {
113
+ function K(a, v) {
114
114
  return {
115
115
  color: a.text.includes("删除") ? "var(--el-color-danger)" : "",
116
- visibility: we(o) ? void 0 : o
116
+ visibility: ke(v) ? void 0 : v
117
117
  };
118
118
  }
119
- const V = z([]);
120
- function P() {
121
- V.value = Array.from(
119
+ const T = z([]);
120
+ function W() {
121
+ T.value = Array.from(
122
122
  { length: r.data.length },
123
123
  () => Array.from({ length: r.columns.length }, () => ({
124
124
  editing: !1,
@@ -127,47 +127,47 @@ const ct = G({ name: "tabler-filter-check", render: dt }), ft = { "element-loadi
127
127
  }))
128
128
  );
129
129
  }
130
- function D(a, o) {
131
- return A(a.editable) ? a.editable(o) : a.editable ?? !1;
130
+ function ie(a, v) {
131
+ return A(a.editable) ? a.editable(v) : a.editable ?? !1;
132
132
  }
133
- function _(a, o, e) {
134
- const v = V.value[a][o];
135
- v && (v.value = e, v.editing = !0, le(() => {
136
- var m;
137
- (m = v.inputRef) == null || m.focus();
133
+ function P(a, v, e) {
134
+ const c = T.value[a][v];
135
+ c && (c.value = e, c.editing = !0, le(() => {
136
+ var h;
137
+ (h = c.inputRef) == null || h.focus();
138
138
  }));
139
139
  }
140
- function Y(a) {
141
- const o = V.value[a.rowIndex][a.colIndex];
142
- if (!o) return;
143
- o.editing = !1;
144
- const e = a.newValue, v = a.row[a.prop];
145
- e !== v && (a.row[a.prop] = e, S("cell-edit", a));
140
+ function H(a) {
141
+ const v = T.value[a.rowIndex][a.colIndex];
142
+ if (!v) return;
143
+ v.editing = !1;
144
+ const e = a.newValue, c = a.row[a.prop];
145
+ e !== c && (a.row[a.prop] = e, k("cell-edit", a));
146
146
  }
147
- function ie(a, o) {
148
- const e = V.value[a][o];
147
+ function _(a, v) {
148
+ const e = T.value[a][v];
149
149
  e && (e.editing = !1);
150
150
  }
151
151
  return t({
152
152
  tableInstance: B,
153
- resetCells: P
154
- }), (a, o) => Z((s(), w("section", ft, [
155
- E(n(Le), {
153
+ resetCells: W
154
+ }), (a, v) => ee((s(), x("section", pt, [
155
+ E(n(Oe), {
156
156
  ref: "elTableRef",
157
157
  data: l.data,
158
158
  border: "",
159
159
  class: "pro-table",
160
160
  height: "100%",
161
161
  "row-key": l.rowKey,
162
- onSelectionChange: o[1] || (o[1] = (e) => S("selectionChange", e))
162
+ onSelectionChange: v[1] || (v[1] = (e) => k("selectionChange", e))
163
163
  }, {
164
- default: x(() => [
164
+ default: b(() => [
165
165
  l.selectable ? (s(), C(n(de), {
166
166
  key: 0,
167
167
  type: "selection",
168
168
  width: "55",
169
169
  selectable: n(A)(l.selectable) ? l.selectable : void 0
170
- }, null, 8, ["selectable"])) : H("", !0),
170
+ }, null, 8, ["selectable"])) : F("", !0),
171
171
  l.showIndex ? (s(), C(n(de), {
172
172
  key: 1,
173
173
  class: "index-cell",
@@ -175,62 +175,62 @@ const ct = G({ name: "tabler-filter-check", render: dt }), ft = { "element-loadi
175
175
  width: l.indexWidth,
176
176
  label: "序号"
177
177
  }, {
178
- default: x(({ $index: e }) => [
178
+ default: b(({ $index: e }) => [
179
179
  $(O(e + 1 + (l.indexOffset || 0)), 1)
180
180
  ]),
181
181
  _: 1
182
- }, 8, ["width"])) : H("", !0),
183
- (s(!0), w(U, null, ee(l.columns, (e, v) => (s(), C(n(de), fe({ key: v }, { ref_for: !0 }, e, {
182
+ }, 8, ["width"])) : F("", !0),
183
+ (s(!0), x(U, null, te(l.columns, (e, c) => (s(), C(n(de), fe({ key: c }, { ref_for: !0 }, e, {
184
184
  align: e.align ?? "center",
185
185
  fixed: e.label === "操作" ? "right" : !1
186
- }), He({ _: 2 }, [
187
- e.filterable ?? (e.filterType || e.filterOptions || Se(e.filterOptions)) ? {
186
+ }), De({ _: 2 }, [
187
+ e.filterable ?? (e.filterType || e.filterOptions || Ce(e.filterOptions)) ? {
188
188
  name: "header",
189
- fn: x(({ column: m }) => [
190
- R("span", {
191
- class: De(["inline-flex items-center", {
192
- "text-[--el-color-primary]": b(e) && p.value[b(e)] !== void 0
189
+ fn: b(({ column: h }) => [
190
+ V("span", {
191
+ class: Me(["inline-flex items-center", {
192
+ "text-[--el-color-primary]": S(e) && p.value[S(e)] !== void 0
193
193
  }])
194
194
  }, [
195
- b(e) ? (s(), C(n(Ae), {
195
+ S(e) ? (s(), C(n(Ue), {
196
196
  key: 0,
197
- visible: k.value[b(e)],
198
- "onUpdate:visible": (c) => k.value[b(e)] = c,
197
+ visible: w.value[S(e)],
198
+ "onUpdate:visible": (u) => w.value[S(e)] = u,
199
199
  placement: "bottom",
200
200
  trigger: "click",
201
201
  "hide-after": 0,
202
202
  "show-after": 0,
203
203
  width: e.filterPopoverWidth ?? (e.filterType === "datetimerange" ? 424 : void 0),
204
204
  "popper-class": "reset",
205
- onShow: (c) => ne(b(e)),
206
- onHide: (c) => ae(b(e))
205
+ onShow: (u) => ne(S(e)),
206
+ onHide: (u) => ae(S(e))
207
207
  }, {
208
- reference: x(() => [
209
- R("div", {
208
+ reference: b(() => [
209
+ V("div", {
210
210
  class: "inline-flex cursor-pointer items-center gap-x-0.5 duration-100 hover:text-[--el-color-primary]",
211
- onClick: o[0] || (o[0] = oe(() => {
211
+ onClick: v[0] || (v[0] = oe(() => {
212
212
  }, ["stop"]))
213
213
  }, [
214
- $(O(m.label) + " ", 1),
215
- p.value[b(e)] !== void 0 ? (s(), C(n(ct), { key: 0 })) : (s(), C(n(ot), { key: 1 }))
214
+ $(O(h.label) + " ", 1),
215
+ p.value[S(e)] !== void 0 ? (s(), C(n(vt), { key: 0 })) : (s(), C(n(dt), { key: 1 }))
216
216
  ])
217
217
  ]),
218
- default: x(() => [
219
- !e.filterType || e.filterType === "radio" ? (s(), C(n(xe), {
218
+ default: b(() => [
219
+ !e.filterType || e.filterType === "radio" ? (s(), C(n(we), {
220
220
  key: 0,
221
221
  always: "",
222
222
  "max-height": "34vh"
223
223
  }, {
224
- default: x(() => [
225
- E(n(Oe), {
226
- modelValue: g.value[b(e)],
227
- "onUpdate:modelValue": (c) => g.value[b(e)] = c
224
+ default: b(() => [
225
+ E(n(Ne), {
226
+ modelValue: g.value[S(e)],
227
+ "onUpdate:modelValue": (u) => g.value[S(e)] = u
228
228
  }, {
229
- default: x(() => [
230
- (s(!0), w(U, null, ee(ye(e.filterOptions), (c) => (s(), C(n(Ue), {
231
- key: c.value.toString(),
232
- value: c.value,
233
- label: c.label,
229
+ default: b(() => [
230
+ (s(!0), x(U, null, te(ge(e.filterOptions), (u) => (s(), C(n(je), {
231
+ key: u.value.toString(),
232
+ value: u.value,
233
+ label: u.label,
234
234
  class: "!m-0 w-full"
235
235
  }, null, 8, ["value", "label"]))), 128))
236
236
  ]),
@@ -238,21 +238,21 @@ const ct = G({ name: "tabler-filter-check", render: dt }), ft = { "element-loadi
238
238
  }, 1032, ["modelValue", "onUpdate:modelValue"])
239
239
  ]),
240
240
  _: 2
241
- }, 1024)) : e.filterType === "checkbox" ? (s(), C(n(xe), {
241
+ }, 1024)) : e.filterType === "checkbox" ? (s(), C(n(we), {
242
242
  key: 1,
243
243
  always: "",
244
244
  "max-height": "34vh"
245
245
  }, {
246
- default: x(() => [
247
- E(n(Ne), {
248
- modelValue: g.value[b(e)],
249
- "onUpdate:modelValue": (c) => g.value[b(e)] = c
246
+ default: b(() => [
247
+ E(n(We), {
248
+ modelValue: g.value[S(e)],
249
+ "onUpdate:modelValue": (u) => g.value[S(e)] = u
250
250
  }, {
251
- default: x(() => [
252
- (s(!0), w(U, null, ee(ye(e.filterOptions), (c) => (s(), C(n(je), {
253
- key: c.value.toString(),
254
- value: c.value,
255
- label: c.label,
251
+ default: b(() => [
252
+ (s(!0), x(U, null, te(ge(e.filterOptions), (u) => (s(), C(n(Ge), {
253
+ key: u.value.toString(),
254
+ value: u.value,
255
+ label: u.label,
256
256
  class: "!m-0 w-full"
257
257
  }, null, 8, ["value", "label"]))), 128))
258
258
  ]),
@@ -260,46 +260,46 @@ const ct = G({ name: "tabler-filter-check", render: dt }), ft = { "element-loadi
260
260
  }, 1032, ["modelValue", "onUpdate:modelValue"])
261
261
  ]),
262
262
  _: 2
263
- }, 1024)) : e.filterType === "datetimerange" ? (s(), C(n(We), {
263
+ }, 1024)) : e.filterType === "datetimerange" ? (s(), C(n(Ie), {
264
264
  key: 2,
265
- modelValue: g.value[b(e)],
266
- "onUpdate:modelValue": (c) => g.value[b(e)] = c,
265
+ modelValue: g.value[S(e)],
266
+ "onUpdate:modelValue": (u) => g.value[S(e)] = u,
267
267
  type: "datetimerange",
268
268
  "start-placeholder": "开始时间",
269
269
  "end-placeholder": "结束时间",
270
270
  "range-separator": "至",
271
271
  "value-format": "YYYY-MM-DD HH:mm:ss",
272
272
  teleported: !1
273
- }, null, 8, ["modelValue", "onUpdate:modelValue"])) : H("", !0),
274
- o[4] || (o[4] = R("div", { class: "-mx-3 my-3 border-t" }, null, -1)),
275
- R("div", vt, [
276
- R("div", pt, [
277
- E(n(F), {
273
+ }, null, 8, ["modelValue", "onUpdate:modelValue"])) : F("", !0),
274
+ v[4] || (v[4] = V("div", { class: "-mx-3 my-3 border-t" }, null, -1)),
275
+ V("div", mt, [
276
+ V("div", ht, [
277
+ E(n(M), {
278
278
  type: "primary",
279
279
  plain: "",
280
280
  size: "small",
281
- onClick: (c) => q(
282
- b(e),
281
+ onClick: (u) => J(
282
+ S(e),
283
283
  e.filterType || "radio",
284
284
  e
285
285
  )
286
286
  }, {
287
- default: x(() => [...o[2] || (o[2] = [
287
+ default: b(() => [...v[2] || (v[2] = [
288
288
  $("重置", -1)
289
289
  ])]),
290
290
  _: 1
291
291
  }, 8, ["onClick"]),
292
- E(n(F), {
292
+ E(n(M), {
293
293
  type: "primary",
294
294
  size: "small",
295
295
  class: "!m-0",
296
- onClick: (c) => M(
297
- b(e),
296
+ onClick: (u) => N(
297
+ S(e),
298
298
  e.filterType || "radio",
299
299
  e
300
300
  )
301
301
  }, {
302
- default: x(() => [...o[3] || (o[3] = [
302
+ default: b(() => [...v[3] || (v[3] = [
303
303
  $("确定", -1)
304
304
  ])]),
305
305
  _: 1
@@ -308,20 +308,20 @@ const ct = G({ name: "tabler-filter-check", render: dt }), ft = { "element-loadi
308
308
  ])
309
309
  ]),
310
310
  _: 2
311
- }, 1032, ["visible", "onUpdate:visible", "width", "onShow", "onHide"])) : H("", !0)
311
+ }, 1032, ["visible", "onUpdate:visible", "width", "onShow", "onHide"])) : F("", !0)
312
312
  ], 2)
313
313
  ]),
314
314
  key: "0"
315
315
  } : void 0,
316
316
  e.formatter ? {
317
317
  name: "default",
318
- fn: x(({ row: m, column: c, $index: j }) => [
319
- Z((s(), w("div", null, [
320
- E(it, {
318
+ fn: b(({ row: h, column: u, $index: D }) => [
319
+ ee((s(), x("div", null, [
320
+ E(rt, {
321
321
  col: e,
322
- row: m,
323
- column: c,
324
- index: j
322
+ row: h,
323
+ column: u,
324
+ index: D
325
325
  }, null, 8, ["col", "row", "column", "index"])
326
326
  ])), [
327
327
  [n(ce), e.truncate ?? !0]
@@ -330,90 +330,90 @@ const ct = G({ name: "tabler-filter-check", render: dt }), ft = { "element-loadi
330
330
  key: "1"
331
331
  } : {
332
332
  name: "default",
333
- fn: x(({ row: m, $index: c }) => {
334
- var j, J;
333
+ fn: b(({ row: h, $index: u }) => {
334
+ var D, Y;
335
335
  return [
336
- e.prop ? (s(), w("div", mt, [
337
- D(e, m) ? (s(), w(U, { key: 0 }, [
338
- (J = (j = V.value[c]) == null ? void 0 : j[v]) != null && J.editing ? (s(), C(n(Ee), {
336
+ e.prop ? (s(), x("div", yt, [
337
+ ie(e, h) ? (s(), x(U, { key: 0 }, [
338
+ (Y = (D = T.value[u]) == null ? void 0 : D[c]) != null && Y.editing ? (s(), C(n(Te), {
339
339
  key: 0,
340
340
  ref_for: !0,
341
- ref: (u) => V.value[c][v].inputRef = u,
342
- modelValue: V.value[c][v].value,
343
- "onUpdate:modelValue": (u) => V.value[c][v].value = u,
341
+ ref: (d) => T.value[u][c].inputRef = d,
342
+ modelValue: T.value[u][c].value,
343
+ "onUpdate:modelValue": (d) => T.value[u][c].value = d,
344
344
  style: { "--el-input-height": "23px" },
345
345
  clearable: "",
346
346
  size: "small",
347
347
  "input-style": "--el-input-inner-height: 20px",
348
- onBlur: (u) => Y({
349
- rowIndex: c,
350
- colIndex: v,
351
- row: m,
348
+ onBlur: (d) => H({
349
+ rowIndex: u,
350
+ colIndex: c,
351
+ row: h,
352
352
  prop: e.prop,
353
- oldValue: m[e.prop],
354
- newValue: V.value[c][v].value
353
+ oldValue: h[e.prop],
354
+ newValue: T.value[u][c].value
355
355
  }),
356
356
  onKeydown: [
357
- ve(oe((u) => Y({
358
- rowIndex: c,
359
- colIndex: v,
360
- row: m,
357
+ ve(oe((d) => H({
358
+ rowIndex: u,
359
+ colIndex: c,
360
+ row: h,
361
361
  prop: e.prop,
362
- oldValue: m[e.prop],
363
- newValue: V.value[c][v].value
362
+ oldValue: h[e.prop],
363
+ newValue: T.value[u][c].value
364
364
  }), ["stop", "prevent"]), ["enter"]),
365
- ve(oe((u) => ie(c, v), ["stop", "prevent"]), ["esc"])
365
+ ve(oe((d) => _(u, c), ["stop", "prevent"]), ["esc"])
366
366
  ]
367
- }, null, 8, ["modelValue", "onUpdate:modelValue", "onBlur", "onKeydown"])) : Z((s(), w("div", {
367
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "onBlur", "onKeydown"])) : ee((s(), x("div", {
368
368
  key: 1,
369
369
  class: "h-[23px] cursor-pointer",
370
- onDblclick: (u) => _(c, v, m[e.prop])
370
+ onDblclick: (d) => P(u, c, h[e.prop])
371
371
  }, [
372
- $(O(m[e.prop]), 1)
373
- ], 40, ht)), [
372
+ $(O(h[e.prop]), 1)
373
+ ], 40, gt)), [
374
374
  [n(ce), e.truncate ?? !0]
375
375
  ])
376
- ], 64)) : Z((s(), w("div", yt, [
377
- $(O(m[e.prop]), 1)
376
+ ], 64)) : ee((s(), x("div", bt, [
377
+ $(O(h[e.prop]), 1)
378
378
  ])), [
379
379
  [n(ce), e.truncate ?? !0]
380
380
  ])
381
- ])) : H("", !0),
382
- (s(!0), w(U, null, ee(N(e, m), (u) => (s(), w(U, {
383
- key: u.text
381
+ ])) : F("", !0),
382
+ (s(!0), x(U, null, te(j(e, h), (d) => (s(), x(U, {
383
+ key: d.text
384
384
  }, [
385
- u.text === "删除" || u.confirmText ? (s(), C(n(Ge), {
385
+ d.text === "删除" || d.confirmText ? (s(), C(n(qe), {
386
386
  key: 0,
387
387
  placement: "top",
388
388
  "hide-after": 0,
389
389
  "popper-style": "width: unset; min-width: 150px;",
390
- title: n(we)(u.confirmText) ? `是否确认${u.text}?` : n(A)(u.confirmText) ? u.confirmText(m) : u.confirmText ?? `是否确认${u.text}?`,
391
- onConfirm: (se) => u.visibility === "hidden" ? void 0 : u.handler(m)
390
+ title: n(ke)(d.confirmText) ? `是否确认${d.text}?` : n(A)(d.confirmText) ? d.confirmText(h) : d.confirmText ?? `是否确认${d.text}?`,
391
+ onConfirm: (se) => d.visibility === "hidden" ? void 0 : d.handler(h)
392
392
  }, {
393
- reference: x(() => [
394
- E(n(F), {
393
+ reference: b(() => [
394
+ E(n(M), {
395
395
  link: "",
396
- type: u.type ?? "primary",
397
- style: ge(K(u, u.visibility)),
398
- disabled: n(A)(u.disabled) ? u.disabled(m) : u.disabled
396
+ type: d.type ?? "primary",
397
+ style: be(K(d, d.visibility)),
398
+ disabled: n(A)(d.disabled) ? d.disabled(h) : d.disabled
399
399
  }, {
400
- default: x(() => [
401
- $(O(u.text), 1)
400
+ default: b(() => [
401
+ $(O(d.text), 1)
402
402
  ]),
403
403
  _: 2
404
404
  }, 1032, ["type", "style", "disabled"])
405
405
  ]),
406
406
  _: 2
407
- }, 1032, ["title", "onConfirm"])) : (s(), C(n(F), {
407
+ }, 1032, ["title", "onConfirm"])) : (s(), C(n(M), {
408
408
  key: 1,
409
409
  link: "",
410
- type: u.type ?? "primary",
411
- style: ge(K(u, u.visibility)),
412
- disabled: n(A)(u.disabled) ? u.disabled(m) : u.disabled,
413
- onClick: (se) => u.visibility === "hidden" ? void 0 : u.handler(m)
410
+ type: d.type ?? "primary",
411
+ style: be(K(d, d.visibility)),
412
+ disabled: n(A)(d.disabled) ? d.disabled(h) : d.disabled,
413
+ onClick: (se) => d.visibility === "hidden" ? void 0 : d.handler(h)
414
414
  }, {
415
- default: x(() => [
416
- $(O(u.text), 1)
415
+ default: b(() => [
416
+ $(O(d.text), 1)
417
417
  ]),
418
418
  _: 2
419
419
  }, 1032, ["type", "style", "disabled", "onClick"]))
@@ -427,27 +427,27 @@ const ct = G({ name: "tabler-filter-check", render: dt }), ft = { "element-loadi
427
427
  _: 1
428
428
  }, 8, ["data", "row-key"])
429
429
  ])), [
430
- [n(d), l.loading]
430
+ [n(o), l.loading]
431
431
  ]);
432
432
  }
433
- }), Re = (l, t) => {
433
+ }), Ve = (l, t) => {
434
434
  const f = l.__vccOpts || l;
435
- for (const [d, r] of t)
436
- f[d] = r;
435
+ for (const [o, r] of t)
436
+ f[o] = r;
437
437
  return f;
438
- }, bt = /* @__PURE__ */ Re(gt, [["__scopeId", "data-v-476baef5"]]);
439
- function xt(l) {
440
- var t, f, d, r, p, S, B;
441
- if (Qe(l))
438
+ }, wt = /* @__PURE__ */ Ve(xt, [["__scopeId", "data-v-476baef5"]]);
439
+ function kt(l) {
440
+ var t, f, o, r, p, k, B;
441
+ if (Ze(l))
442
442
  return l.includes("database") || l.includes("java.sql.") ? "接口异常" : l;
443
- if (Te(l)) return "请求已取消";
443
+ if (Re(l)) return "请求已取消";
444
444
  if (l.code === "ECONNABORTED" || (t = l.message) != null && t.includes("timeout"))
445
445
  return "请求超时,请稍后重试";
446
446
  if (!window.navigator.onLine || l.message === "Network Error")
447
447
  return "网络连接断开,请检查网络设置";
448
448
  if (l.response) {
449
- const g = l.response.status, k = l.response.data;
450
- if (k && k.message) return k.message;
449
+ const g = l.response.status, w = l.response.data;
450
+ if (w && w.message) return w.message;
451
451
  switch (g) {
452
452
  case 400:
453
453
  return "请求参数错误 (400)";
@@ -467,9 +467,9 @@ function xt(l) {
467
467
  return `网络异常 (${g})`;
468
468
  }
469
469
  }
470
- return l instanceof SyntaxError ? "数据解析异常" : l instanceof TypeError ? "程序运行异常" : l instanceof Object && ((r = (d = l[(f = pe(l)) == null ? void 0 : f[0]]) == null ? void 0 : d[0]) != null && r.message) ? (B = (S = l[(p = pe(l)) == null ? void 0 : p[0]]) == null ? void 0 : S[0]) == null ? void 0 : B.message : l.message || "未知错误";
470
+ return l instanceof SyntaxError ? "数据解析异常" : l instanceof TypeError ? "程序运行异常" : l instanceof Object && ((r = (o = l[(f = pe(l)) == null ? void 0 : f[0]]) == null ? void 0 : o[0]) != null && r.message) ? (B = (k = l[(p = pe(l)) == null ? void 0 : p[0]]) == null ? void 0 : k[0]) == null ? void 0 : B.message : l.message || "未知错误";
471
471
  }
472
- class wt {
472
+ class St {
473
473
  /**
474
474
  * 实例化 SelectionStore
475
475
  *
@@ -520,9 +520,9 @@ class wt {
520
520
  * @param selected 当前页勾选行
521
521
  */
522
522
  syncPage(t, f) {
523
- const d = new Set(f.map((r) => r[this.rowKey]));
523
+ const o = new Set(f.map((r) => r[this.rowKey]));
524
524
  t.forEach((r) => {
525
- d.has(r[this.rowKey]) || this.map.delete(r[this.rowKey]);
525
+ o.has(r[this.rowKey]) || this.map.delete(r[this.rowKey]);
526
526
  }), f.forEach((r) => this.map.set(r[this.rowKey], r));
527
527
  }
528
528
  /**
@@ -531,108 +531,108 @@ class wt {
531
531
  * @param toggleFn el-table toggleRowSelection
532
532
  */
533
533
  restorePageSelection(t, f) {
534
- t.forEach((d) => {
535
- Object.hasOwn(d, this.rowKey) || console.error(
534
+ t.forEach((o) => {
535
+ Object.hasOwn(o, this.rowKey) || console.error(
536
536
  "[SelectionStore]",
537
537
  `表格数据缺少配置的 rowKey 属性:'${this.rowKey}'`
538
- ), this.map.has(d[this.rowKey]) && f(d, !0);
538
+ ), this.map.has(o[this.rowKey]) && f(o, !0);
539
539
  });
540
540
  }
541
541
  }
542
- function kt(l, t, f) {
543
- let d, r;
544
- Se(l) ? (d = l, r = t ?? 300) : (d = Fe(l, t), r = f ?? 300);
545
- const p = z(d.value);
546
- let S = null;
542
+ function Ct(l, t, f) {
543
+ let o, r;
544
+ Ce(l) ? (o = l, r = t) : (o = Ke(l, t), r = 300);
545
+ const p = z(o.value);
546
+ let k = null;
547
547
  const B = () => {
548
- S !== null && (clearTimeout(S), S = null);
548
+ k !== null && (clearTimeout(k), k = null);
549
549
  };
550
- return Ce(
551
- d,
550
+ return Ee(
551
+ o,
552
552
  (g) => {
553
- g ? (B(), S = setTimeout(() => {
553
+ g ? (B(), k = setTimeout(() => {
554
554
  p.value = !0;
555
555
  }, r)) : (B(), p.value = !1);
556
556
  },
557
557
  { immediate: !1 }
558
558
  ), p;
559
559
  }
560
- function St({ defaultSort: l, fetchFn: t, onReset: f }) {
561
- const d = Xe(
560
+ function Et({ defaultSort: l, fetchFn: t, onReset: f }) {
561
+ const o = et(
562
562
  {
563
563
  order: "",
564
564
  sort: ""
565
565
  },
566
566
  l
567
- ), r = he(I(d));
568
- let p = I(r);
569
- function S({
567
+ ), r = he(Q(o));
568
+ let p = Q(r);
569
+ function k({
570
570
  prop: B,
571
571
  order: g
572
572
  }) {
573
- g ? (r.sort = B || "", r.order = g === "ascending" ? "asc" : "desc", t()) : (r.sort = d.sort, r.order = d.order, Ze(r, p) && (r.order = r.order === "asc" ? "desc" : "asc"), f ? f() : t()), p = I(r);
573
+ g ? (r.sort = B || "", r.order = g === "ascending" ? "asc" : "desc", t()) : (r.sort = o.sort, r.order = o.order, tt(r, p) && (r.order = r.order === "asc" ? "desc" : "asc"), f ? f() : t()), p = Q(r);
574
574
  }
575
575
  return {
576
576
  sortState: r,
577
- onSortChange: S
577
+ onSortChange: k
578
578
  };
579
579
  }
580
- const Ct = {
580
+ const Tt = {
581
581
  viewBox: "0 0 24 24",
582
582
  width: "1.2em",
583
583
  height: "1.2em"
584
584
  };
585
- function Et(l, t) {
586
- return s(), w("svg", Ct, [...t[0] || (t[0] = [
587
- R("path", {
585
+ function Rt(l, t) {
586
+ return s(), x("svg", Tt, [...t[0] || (t[0] = [
587
+ V("path", {
588
588
  fill: "currentColor",
589
589
  d: "m18.031 16.617l4.283 4.282l-1.415 1.415l-4.282-4.283A8.96 8.96 0 0 1 11 20c-4.968 0-9-4.032-9-9s4.032-9 9-9s9 4.032 9 9a8.96 8.96 0 0 1-1.969 5.617m-2.006-.742A6.98 6.98 0 0 0 18 11c0-3.867-3.133-7-7-7s-7 3.133-7 7s3.133 7 7 7a6.98 6.98 0 0 0 4.875-1.975z"
590
590
  }, null, -1)
591
591
  ])]);
592
592
  }
593
- const Tt = G({ name: "ri-search-line", render: Et }), Rt = {
593
+ const Vt = q({ name: "ri-search-line", render: Rt }), $t = {
594
594
  viewBox: "0 0 24 24",
595
595
  width: "1.2em",
596
596
  height: "1.2em"
597
597
  };
598
- function Vt(l, t) {
599
- return s(), w("svg", Rt, [...t[0] || (t[0] = [
600
- R("path", {
598
+ function Bt(l, t) {
599
+ return s(), x("svg", $t, [...t[0] || (t[0] = [
600
+ V("path", {
601
601
  fill: "currentColor",
602
602
  d: "M11 11V5h2v6h6v2h-6v6h-2v-6H5v-2z"
603
603
  }, null, -1)
604
604
  ])]);
605
605
  }
606
- const $t = G({ name: "ri-add-line", render: Vt }), Bt = {
606
+ const zt = q({ name: "ri-add-line", render: Bt }), Pt = {
607
607
  viewBox: "0 0 24 24",
608
608
  width: "1.2em",
609
609
  height: "1.2em"
610
610
  };
611
- function zt(l, t) {
612
- return s(), w("svg", Bt, [...t[0] || (t[0] = [
613
- R("path", {
611
+ function Ht(l, t) {
612
+ return s(), x("svg", Pt, [...t[0] || (t[0] = [
613
+ V("path", {
614
614
  fill: "currentColor",
615
615
  d: "M17 6h5v2h-2v13a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V8H2V6h5V3a1 1 0 0 1 1-1h8a1 1 0 0 1 1 1zm1 2H6v12h12zm-9 3h2v6H9zm4 0h2v6h-2zM9 4v2h6V4z"
616
616
  }, null, -1)
617
617
  ])]);
618
618
  }
619
- const Pt = G({ name: "ri-delete-bin-line", render: zt }), Ht = {
619
+ const Ft = q({ name: "ri-delete-bin-line", render: Ht }), Dt = {
620
620
  viewBox: "0 0 24 24",
621
621
  width: "1.2em",
622
622
  height: "1.2em"
623
623
  };
624
- function Dt(l, t) {
625
- return s(), w("svg", Ht, [...t[0] || (t[0] = [
626
- R("path", {
624
+ function Mt(l, t) {
625
+ return s(), x("svg", Dt, [...t[0] || (t[0] = [
626
+ V("path", {
627
627
  fill: "currentColor",
628
628
  d: "M6.535 3h14.464a1 1 0 0 1 1 1v16a1 1 0 0 1-1 1H6.535a1 1 0 0 1-.833-.445l-5.333-8a1 1 0 0 1 0-1.11l5.333-8A1 1 0 0 1 6.535 3m.535 2l-4.667 7l4.667 7H20V5zM13 10.586l2.828-2.829l1.414 1.415L14.414 12l2.828 2.828l-1.414 1.415l-2.829-2.829l-2.828 2.829l-1.414-1.415L11.585 12L8.757 9.172l1.414-1.415z"
629
629
  }, null, -1)
630
630
  ])]);
631
631
  }
632
- const Ft = G({ name: "ri-delete-back2-line", render: Dt }), Mt = { class: "flex h-full flex-col" }, Kt = {
632
+ const Kt = q({ name: "ri-delete-back2-line", render: Mt }), _t = { class: "flex h-full flex-col" }, Lt = {
633
633
  key: 0,
634
634
  class: "mb-6 flex flex-shrink-0 items-center justify-between"
635
- }, _t = { class: "flex items-center gap-x-3" }, Lt = { class: "mt-5 flex flex-shrink-0 items-center justify-between" }, At = { class: "flex w-[164px] items-center" }, Ot = /* @__PURE__ */ me({
635
+ }, At = { class: "flex items-center gap-x-3" }, Ot = { class: "mt-5 flex flex-shrink-0 items-center justify-between" }, Ut = { class: "flex w-[164px] items-center" }, Nt = /* @__PURE__ */ me({
636
636
  __name: "index",
637
637
  props: {
638
638
  columns: {},
@@ -644,6 +644,7 @@ const Ft = G({ name: "ri-delete-back2-line", render: Dt }), Mt = { class: "flex
644
644
  loading: { type: Boolean },
645
645
  showSearch: { type: Boolean, default: !0 },
646
646
  searchInputPlaceholder: { default: "输入搜索关键词" },
647
+ searchField: { default: "search" },
647
648
  showAddButton: { type: Boolean },
648
649
  showBatchDeleteButton: { type: Boolean },
649
650
  pageSize: {},
@@ -654,118 +655,123 @@ const Ft = G({ name: "ri-delete-back2-line", render: Dt }), Mt = { class: "flex
654
655
  },
655
656
  emits: ["add", "batch-delete", "cell-edit"],
656
657
  setup(l, { expose: t, emit: f }) {
657
- const d = l, r = f, p = ke("proTableRef"), { sortState: S, onSortChange: B } = St({
658
- defaultSort: d.defaultSort,
659
- fetchFn: D,
658
+ const o = l, r = f, p = Se("proTableRef"), { sortState: k, onSortChange: B } = Et({
659
+ defaultSort: o.defaultSort,
660
+ fetchFn: H,
660
661
  onReset() {
661
- var y, T;
662
- const h = S.sort, i = S.order === "asc" ? "ascending" : "descending";
663
- d.columns.some((W) => W.prop === h) ? (T = (y = p.value) == null ? void 0 : y.tableInstance) == null || T.sort(h, i) : D();
662
+ var y, R;
663
+ const m = k.sort, i = k.order === "asc" ? "ascending" : "descending";
664
+ o.columns.some((G) => G.prop === m) ? (R = (y = p.value) == null ? void 0 : y.tableInstance) == null || R.sort(m, i) : H();
664
665
  }
665
- }), g = z(d.pageSize ?? 0), k = z({
666
+ }), g = z(o.pageSize ?? 0), w = z({
666
667
  pageSize: g.value,
667
668
  currPage: 1,
668
669
  total: 0
669
- }), ne = te(() => et(tt([g.value, 10, 20, 30, 40, 50, 100]))), ae = te(() => (k.value.currPage - 1) * k.value.pageSize), q = z(0), M = z({
670
- search: ""
671
- }), N = he({}), b = z([]), K = z(!1), V = kt(K, 100);
670
+ }), ne = I(() => lt(nt([g.value, 10, 20, 30, 40, 50, 100]))), ae = I(() => (w.value.currPage - 1) * w.value.pageSize), J = z(0), N = I(() => o.searchField ?? "search"), j = z({
671
+ [N.value]: ""
672
+ }), S = I({
673
+ get: () => j.value[N.value] ?? "",
674
+ set: (m) => {
675
+ j.value[N.value] = m;
676
+ }
677
+ }), K = he({}), T = z([]), W = z(!1), ie = Ct(W, 100);
672
678
  let P = null;
673
- async function D() {
674
- P == null || P.abort(), P = new AbortController(), K.value = !0;
675
- const h = ae.value;
679
+ async function H() {
680
+ P == null || P.abort(), P = new AbortController(), W.value = !0;
681
+ const m = ae.value;
676
682
  try {
677
683
  const i = {
678
- ...M.value,
679
- ...N,
680
- ...S,
681
- limit: k.value.pageSize,
682
- offset: h
683
- }, y = d.searchParamsHandler ? d.searchParamsHandler(i) : i, { data: T = [], totalCount: W } = await d.fetchFn(y, {
684
+ ...j.value,
685
+ ...K,
686
+ ...k,
687
+ limit: w.value.pageSize,
688
+ offset: m
689
+ }, y = o.searchParamsHandler ? o.searchParamsHandler(i) : i, { data: R = [], totalCount: G } = await o.fetchFn(y, {
684
690
  signal: P.signal
685
691
  });
686
- b.value = T, q.value = h, k.value.total = W, await le(() => {
687
- var L, Q, X;
688
- (Q = (L = p.value) == null ? void 0 : L.tableInstance) == null || Q.setScrollTop(0), (X = p.value) == null || X.resetCells();
689
- }), d.selectable && se(T);
692
+ T.value = R, J.value = m, w.value.total = G, await le(() => {
693
+ var L, X, Z;
694
+ (X = (L = p.value) == null ? void 0 : L.tableInstance) == null || X.setScrollTop(0), (Z = p.value) == null || Z.resetCells();
695
+ }), o.selectable && $e(R);
690
696
  } catch (i) {
691
- if (Te(i)) return;
692
- console.error("[SearchTable] 获取数据失败", i), Je.error("表格数据加载失败:" + xt(i));
697
+ if (Re(i)) return;
698
+ console.error("[SearchTable] 获取数据失败", i), Xe.error("表格数据加载失败:" + kt(i));
693
699
  }
694
- K.value = !1;
700
+ W.value = !1;
695
701
  }
696
702
  function _() {
697
- k.value.currPage = 1, D();
703
+ w.value.currPage = 1, H();
698
704
  }
699
- function Y({ type: h, value: i, prop: y, col: T }) {
700
- if (h === "datetimerange") {
701
- const [W = `${y}Start`, L = `${y}End`] = T.datetimerangeFilterFieldNames || [], [Q, X] = i || [];
702
- N[W] = Q, N[L] = X;
705
+ function a({ type: m, value: i, prop: y, col: R }) {
706
+ if (m === "datetimerange") {
707
+ const [G = `${y}Start`, L = `${y}End`] = R.datetimerangeFilterFieldNames || [], [X, Z] = i || [];
708
+ K[G] = X, K[L] = Z;
703
709
  } else
704
- N[y] = i;
710
+ K[y] = i;
705
711
  _();
706
712
  }
707
- const ie = async () => {
708
- K.value || (u(), await D());
713
+ const v = async () => {
714
+ W.value || (ye(), await H());
709
715
  };
710
- function a() {
716
+ function e() {
711
717
  var L;
712
- const T = ((L = p.value) == null ? void 0 : L.$el).offsetHeight - 40;
713
- return Math.floor(T / 40);
718
+ const R = ((L = p.value) == null ? void 0 : L.$el).offsetHeight - 40;
719
+ return Math.floor(R / 40);
714
720
  }
715
- const o = z([]), e = te(() => o.value), v = new wt(d.rowKey);
716
- let m = !1;
717
- const c = (h) => {
718
- m || (v.syncPage(b.value, h), o.value = v.values);
719
- }, j = () => o.value, J = (h) => {
720
- c(h);
721
- }, u = () => {
722
- var h, i;
723
- (i = (h = p.value) == null ? void 0 : h.tableInstance) == null || i.clearSelection(), o.value = [], v.clear();
721
+ const c = z([]), h = I(() => c.value), u = new St(o.rowKey);
722
+ let D = !1;
723
+ const Y = (m) => {
724
+ D || (u.syncPage(T.value, m), c.value = u.values);
725
+ }, d = () => c.value, se = (m) => {
726
+ Y(m);
727
+ }, ye = () => {
728
+ var m, i;
729
+ (i = (m = p.value) == null ? void 0 : m.tableInstance) == null || i.clearSelection(), c.value = [], u.clear();
724
730
  };
725
- d.selectable && Ce(b, async () => {
726
- m = !0, await le(), v.restorePageSelection(b.value, (h, i) => {
727
- var y, T;
728
- (T = (y = p.value) == null ? void 0 : y.tableInstance) == null || T.toggleRowSelection(h, i);
729
- }), await le(), m = !1;
731
+ o.selectable && Ee(T, async () => {
732
+ D = !0, await le(), u.restorePageSelection(T.value, (m, i) => {
733
+ var y, R;
734
+ (R = (y = p.value) == null ? void 0 : y.tableInstance) == null || R.toggleRowSelection(m, i);
735
+ }), await le(), D = !1;
730
736
  });
731
- function se(h) {
732
- const i = h.map((T) => T[d.rowKey]), y = pe(lt(nt(i), (T) => T > 1));
737
+ function $e(m) {
738
+ const i = m.map((R) => R[o.rowKey]), y = pe(at(it(i), (R) => R > 1));
733
739
  y.length && console.error(
734
740
  "[SearchTable] 表格数据存在重复的 rowKey,将会导致勾选功能异常!",
735
741
  y
736
742
  );
737
743
  }
738
- return Me(() => {
739
- if (!k.value.pageSize) {
740
- const h = a();
741
- g.value = h, k.value.pageSize = h;
744
+ return _e(() => {
745
+ if (!w.value.pageSize) {
746
+ const m = e();
747
+ g.value = m, w.value.pageSize = m;
742
748
  }
743
- D();
744
- }), Ke(() => {
749
+ H();
750
+ }), Le(() => {
745
751
  P == null || P.abort();
746
752
  }), t({
747
753
  /**
748
754
  * 刷新当前页
749
755
  */
750
- refresh: ie,
756
+ refresh: v,
751
757
  /**
752
758
  * 已勾选的行
753
759
  */
754
- selectedRows: e,
760
+ selectedRows: h,
755
761
  /**
756
762
  * 获取已勾选的行
757
763
  */
758
- getSelectionRows: j,
764
+ getSelectionRows: d,
759
765
  /**
760
766
  * 勾选指定行
761
767
  */
762
- selectRows: J
763
- }), (h, i) => (s(), w("div", Mt, [
764
- l.showSearch ? (s(), w("section", Kt, [
765
- R("div", _t, [
766
- E(n(Ee), {
767
- modelValue: M.value.search,
768
- "onUpdate:modelValue": i[0] || (i[0] = (y) => M.value.search = y),
768
+ selectRows: se
769
+ }), (m, i) => (s(), x("div", _t, [
770
+ l.showSearch ? (s(), x("section", Lt, [
771
+ V("div", At, [
772
+ E(n(Te), {
773
+ modelValue: S.value,
774
+ "onUpdate:modelValue": i[0] || (i[0] = (y) => S.value = y),
769
775
  modelModifiers: { trim: !0 },
770
776
  class: "!w-[260px] flex-shrink-0",
771
777
  placeholder: l.searchInputPlaceholder,
@@ -773,119 +779,115 @@ const Ft = G({ name: "ri-delete-back2-line", render: Dt }), Mt = { class: "flex
773
779
  onKeyup: ve(_, ["enter"]),
774
780
  onClear: _
775
781
  }, null, 8, ["modelValue", "placeholder"]),
776
- ue(h.$slots, "search-form", {
777
- query: M.value,
782
+ ue(m.$slots, "search-form", {
783
+ query: j.value,
778
784
  search: _
779
785
  }, void 0, !0),
780
- E(n(F), {
786
+ E(n(M), {
781
787
  type: "primary",
782
788
  onClick: _
783
789
  }, {
784
- default: x(() => [
785
- E(n(Tt)),
790
+ default: b(() => [
791
+ E(n(Vt)),
786
792
  i[6] || (i[6] = $(" 搜索 ", -1))
787
793
  ]),
788
794
  _: 1
789
795
  })
790
796
  ]),
791
- ue(h.$slots, "top-center", {}, void 0, !0),
792
- R("div", null, [
793
- l.showAddButton ? (s(), C(n(F), {
797
+ ue(m.$slots, "top-center", {}, void 0, !0),
798
+ V("div", null, [
799
+ l.showAddButton ? (s(), C(n(M), {
794
800
  key: 0,
795
801
  type: "primary",
796
802
  onClick: i[1] || (i[1] = (y) => r("add"))
797
803
  }, {
798
- default: x(() => [
799
- E(n($t)),
804
+ default: b(() => [
805
+ E(n(zt)),
800
806
  i[7] || (i[7] = $("新增 ", -1))
801
807
  ]),
802
808
  _: 1
803
- })) : H("", !0),
804
- l.showBatchDeleteButton ? (s(), C(n(F), {
809
+ })) : F("", !0),
810
+ l.showBatchDeleteButton ? (s(), C(n(M), {
805
811
  key: 1,
806
- disabled: !o.value.length,
812
+ disabled: !c.value.length,
807
813
  type: "danger",
808
- onClick: i[2] || (i[2] = (y) => r("batch-delete", o.value))
814
+ onClick: i[2] || (i[2] = (y) => r("batch-delete", c.value))
809
815
  }, {
810
- default: x(() => [
811
- E(n(Pt)),
816
+ default: b(() => [
817
+ E(n(Ft)),
812
818
  i[8] || (i[8] = $("批量删除 ", -1))
813
819
  ]),
814
820
  _: 1
815
- }, 8, ["disabled"])) : H("", !0),
816
- ue(h.$slots, "btns", {}, void 0, !0)
821
+ }, 8, ["disabled"])) : F("", !0),
822
+ ue(m.$slots, "btns", {}, void 0, !0)
817
823
  ])
818
- ])) : H("", !0),
819
- E(bt, fe({ ref: "proTableRef" }, d, {
824
+ ])) : F("", !0),
825
+ E(wt, fe({ ref: "proTableRef" }, o, {
820
826
  class: "flex-1 overflow-hidden",
821
- "index-offset": q.value,
822
- data: b.value,
823
- loading: n(V),
827
+ "index-offset": J.value,
828
+ data: T.value,
829
+ loading: n(ie),
824
830
  "default-sort": {
825
- prop: n(S).sort,
826
- order: n(S).order === "asc" ? "ascending" : "descending"
831
+ prop: n(k).sort,
832
+ order: n(k).order === "asc" ? "ascending" : "descending"
827
833
  },
828
- onApplyFilter: Y,
829
- onSelectionChange: c,
834
+ onApplyFilter: a,
835
+ onSelectionChange: Y,
830
836
  onCellEdit: i[3] || (i[3] = (...y) => r("cell-edit", ...y)),
831
837
  onSortChange: n(B)
832
838
  }), null, 16, ["index-offset", "data", "loading", "default-sort", "onSortChange"]),
833
- R("section", Lt, [
834
- R("div", At, [
835
- l.selectable ? (s(), w(U, { key: 0 }, [
836
- E(n(Ie), { type: "info" }, {
837
- default: x(() => [
838
- $("已选 " + O(o.value.length) + " 条", 1)
839
+ V("section", Ot, [
840
+ V("div", Ut, [
841
+ l.selectable ? (s(), x(U, { key: 0 }, [
842
+ E(n(Ye), { type: "info" }, {
843
+ default: b(() => [
844
+ $("已选 " + O(c.value.length) + " 条", 1)
839
845
  ]),
840
846
  _: 1
841
847
  }),
842
- o.value.length ? (s(), C(n(qe), {
848
+ c.value.length ? (s(), C(n(Qe), {
843
849
  key: 0,
844
850
  content: "清空勾选",
845
851
  placement: "top",
846
852
  effect: "dark",
847
853
  "hide-after": 0
848
854
  }, {
849
- default: x(() => [
850
- E(n(F), {
855
+ default: b(() => [
856
+ E(n(M), {
851
857
  type: "danger",
852
858
  text: "",
853
859
  class: "ml-1 !px-2",
854
- onClick: u
860
+ onClick: ye
855
861
  }, {
856
- default: x(() => [
857
- E(n(Ft))
862
+ default: b(() => [
863
+ E(n(Kt))
858
864
  ]),
859
865
  _: 1
860
866
  })
861
867
  ]),
862
868
  _: 1
863
- })) : H("", !0)
864
- ], 64)) : H("", !0)
869
+ })) : F("", !0)
870
+ ], 64)) : F("", !0)
865
871
  ]),
866
- E(n(Ye), fe(l.elPaginationProps, {
867
- "page-size": k.value.pageSize,
868
- "onUpdate:pageSize": i[4] || (i[4] = (y) => k.value.pageSize = y),
869
- "current-page": k.value.currPage,
870
- "onUpdate:currentPage": i[5] || (i[5] = (y) => k.value.currPage = y),
871
- total: k.value.total,
872
+ E(n(Je), fe(l.elPaginationProps, {
873
+ "page-size": w.value.pageSize,
874
+ "onUpdate:pageSize": i[4] || (i[4] = (y) => w.value.pageSize = y),
875
+ "current-page": w.value.currPage,
876
+ "onUpdate:currentPage": i[5] || (i[5] = (y) => w.value.currPage = y),
877
+ total: w.value.total,
872
878
  background: "",
873
879
  "page-sizes": ne.value,
874
880
  layout: "total, sizes, prev, pager, next, jumper",
875
881
  class: "flex-shrink-0",
876
- onSizeChange: D,
877
- onCurrentChange: D
882
+ onSizeChange: H,
883
+ onCurrentChange: H
878
884
  }), null, 16, ["page-size", "current-page", "total", "page-sizes"]),
879
- i[9] || (i[9] = R("div", { class: "w-[164px]" }, null, -1))
885
+ i[9] || (i[9] = V("div", { class: "w-[164px]" }, null, -1))
880
886
  ])
881
887
  ]));
882
888
  }
883
- }), qt = /* @__PURE__ */ Re(Ot, [["__scopeId", "data-v-c11b5043"]]);
889
+ }), Qt = /* @__PURE__ */ Ve(Nt, [["__scopeId", "data-v-4c5c7ea3"]]);
884
890
  export {
885
- bt as ProTable,
886
- qt as SearchTable,
887
- wt as SelectionStore,
888
- xt as parseErrorReason,
889
- kt as useDelayedRef,
890
- St as useTableSort
891
+ wt as ProTable,
892
+ Qt as SearchTable
891
893
  };
package/dist/style.css CHANGED
@@ -1 +1 @@
1
- .fixed{position:fixed}.\!m-0{margin:0!important}.-mx-3{margin-left:-.75rem;margin-right:-.75rem}.my-3{margin-top:.75rem;margin-bottom:.75rem}.mb-6{margin-bottom:1.5rem}.ml-1{margin-left:.25rem}.mt-5{margin-top:1.25rem}.flex{display:flex}.inline-flex{display:inline-flex}.hidden{display:none}.h-\[23px\]{height:23px}.h-full{height:100%}.\!w-\[260px\]{width:260px!important}.w-\[150px\]{width:150px}.w-\[164px\]{width:164px}.w-full{width:100%}.flex-1{flex:1 1 0%}.flex-shrink-0{flex-shrink:0}.cursor-pointer{cursor:pointer}.flex-col{flex-direction:column}.items-center{align-items:center}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.justify-evenly{justify-content:space-evenly}.gap-x-0{-moz-column-gap:0px;column-gap:0px}.gap-x-0\.5{-moz-column-gap:.125rem;column-gap:.125rem}.gap-x-3{-moz-column-gap:.75rem;column-gap:.75rem}.overflow-hidden{overflow:hidden}.truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.border{border-width:1px}.border-t{border-top-width:1px}.\!px-2{padding-left:.5rem!important;padding-right:.5rem!important}.text-\[--el-color-primary\]{color:var(--el-color-primary)}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.duration-100{transition-duration:.1s}.hover\:text-\[--el-color-primary\]:hover{color:var(--el-color-primary)}[data-v-476baef5] .pro-table{--el-table-header-bg-color: #f7f8fa;--el-table-header-text-color: var(--el-text-color-regular);--el-table-text-color: var(--el-text-color-primary)}[data-v-476baef5] .pro-table thead th{font-weight:400}[data-v-c11b5043] .el-table .el-table-column--selection.el-table__cell{display:flex;align-items:center;justify-content:center}[data-v-c11b5043] .el-button>span{gap:0 4px}.el-pagination[data-v-c11b5043] .el-pagination__sizes .el-select{width:110px}
1
+ .fixed{position:fixed}.\!m-0{margin:0!important}.-mx-3{margin-left:-.75rem;margin-right:-.75rem}.my-3{margin-top:.75rem;margin-bottom:.75rem}.mb-6{margin-bottom:1.5rem}.ml-1{margin-left:.25rem}.mt-5{margin-top:1.25rem}.flex{display:flex}.inline-flex{display:inline-flex}.hidden{display:none}.h-\[23px\]{height:23px}.h-full{height:100%}.\!w-\[260px\]{width:260px!important}.w-\[150px\]{width:150px}.w-\[164px\]{width:164px}.w-full{width:100%}.flex-1{flex:1 1 0%}.flex-shrink-0{flex-shrink:0}.cursor-pointer{cursor:pointer}.flex-col{flex-direction:column}.items-center{align-items:center}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.justify-evenly{justify-content:space-evenly}.gap-x-0{-moz-column-gap:0px;column-gap:0px}.gap-x-0\.5{-moz-column-gap:.125rem;column-gap:.125rem}.gap-x-3{-moz-column-gap:.75rem;column-gap:.75rem}.overflow-hidden{overflow:hidden}.truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.border{border-width:1px}.border-t{border-top-width:1px}.\!px-2{padding-left:.5rem!important;padding-right:.5rem!important}.text-\[--el-color-primary\]{color:var(--el-color-primary)}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.duration-100{transition-duration:.1s}.hover\:text-\[--el-color-primary\]:hover{color:var(--el-color-primary)}[data-v-476baef5] .pro-table{--el-table-header-bg-color: #f7f8fa;--el-table-header-text-color: var(--el-text-color-regular);--el-table-text-color: var(--el-text-color-primary)}[data-v-476baef5] .pro-table thead th{font-weight:400}[data-v-4c5c7ea3] .el-table .el-table-column--selection.el-table__cell{display:flex;align-items:center;justify-content:center}[data-v-4c5c7ea3] .el-button>span{gap:0 4px}.el-pagination[data-v-4c5c7ea3] .el-pagination__sizes .el-select{width:110px}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amaoaaaaa/search-table",
3
- "version": "0.1.2",
3
+ "version": "0.2.0",
4
4
  "type": "module",
5
5
  "description": "基于 Element Plus 的搜索表格组件,支持分页、排序、筛选、跨页勾选等功能",
6
6
  "license": "MIT",