@qin-ui/antdv-next-pro 1.0.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/es/antdv-next-pro.css +58 -0
- package/es/component-provider/index-B-Yy-eoc.js +519 -0
- package/es/component-provider/index.js +5 -0
- package/es/form/index-DnjfDQC_.js +439 -0
- package/es/form/index.js +20 -0
- package/es/index.d.ts +840 -0
- package/es/index.js +47 -0
- package/es/table/index.js +679 -0
- package/es/vendor/utils/lodash-es-p6jau26B.js +1120 -0
- package/package.json +44 -0
|
@@ -0,0 +1,679 @@
|
|
|
1
|
+
import { createElementBlock, openBlock, createElementVNode, defineComponent, ref, computed, watch, watchEffect, createBlock, unref, mergeProps, withCtx, createVNode, renderSlot, resolveDynamicComponent, createTextVNode, createCommentVNode, Fragment, toDisplayString, normalizeStyle, useModel, h, mergeModels, inject, useAttrs, useSlots, onMounted, normalizeClass, createSlots, renderList, normalizeProps, guardReactiveProps, nextTick } from "vue";
|
|
2
|
+
import { Space, Button, theme, useConfig, Dropdown, Menu, Checkbox, Table } from "antdv-next";
|
|
3
|
+
import "antdv-next/dist/config-provider/DisabledContext";
|
|
4
|
+
import "antdv-next/dist/config-provider/SizeContext";
|
|
5
|
+
import { _ as _sfc_main$9, t as tableProps, a as _sfc_main$a } from "../form/index-DnjfDQC_.js";
|
|
6
|
+
import { a as INJECT_CONFIG, g as getObject, c as camelizeProperties, h as useTable$1 } from "../component-provider/index-B-Yy-eoc.js";
|
|
7
|
+
import { p as pick } from "../vendor/utils/lodash-es-p6jau26B.js";
|
|
8
|
+
const _export_sfc = (sfc, props) => {
|
|
9
|
+
const target = sfc.__vccOpts || sfc;
|
|
10
|
+
for (const [key, val] of props) {
|
|
11
|
+
target[key] = val;
|
|
12
|
+
}
|
|
13
|
+
return target;
|
|
14
|
+
};
|
|
15
|
+
const _sfc_main$8 = {};
|
|
16
|
+
const _hoisted_1$3 = {
|
|
17
|
+
focusable: "false",
|
|
18
|
+
"data-icon": "down",
|
|
19
|
+
width: "1em",
|
|
20
|
+
height: "1em",
|
|
21
|
+
fill: "currentColor",
|
|
22
|
+
"aria-hidden": "true",
|
|
23
|
+
viewBox: "64 64 896 896"
|
|
24
|
+
};
|
|
25
|
+
function _sfc_render$2(_ctx, _cache) {
|
|
26
|
+
return openBlock(), createElementBlock("svg", _hoisted_1$3, [..._cache[0] || (_cache[0] = [
|
|
27
|
+
createElementVNode("path", { d: "M884 256h-75c-5.1 0-9.9 2.5-12.9 6.6L512 654.2 227.9 262.6c-3-4.1-7.8-6.6-12.9-6.6h-75c-6.5 0-10.3 7.4-6.5 12.7l352.6 486.1c12.8 17.6 39 17.6 51.7 0l352.6-486.1c3.9-5.3.1-12.7-6.4-12.7z" }, null, -1)
|
|
28
|
+
])]);
|
|
29
|
+
}
|
|
30
|
+
const DownOutlined = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["render", _sfc_render$2]]);
|
|
31
|
+
const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
32
|
+
...{ name: "SearchForm" },
|
|
33
|
+
__name: "SearchForm",
|
|
34
|
+
props: {
|
|
35
|
+
form: {},
|
|
36
|
+
layout: { default: "grid" },
|
|
37
|
+
expand: { type: [Boolean, Object], default: true },
|
|
38
|
+
searchButton: { type: [Object, Function], default: void 0 },
|
|
39
|
+
resetButton: { type: [Object, Function], default: void 0 },
|
|
40
|
+
expandButton: { type: [Object, Function], default: void 0 },
|
|
41
|
+
class: {},
|
|
42
|
+
style: {}
|
|
43
|
+
},
|
|
44
|
+
emits: ["search", "reset"],
|
|
45
|
+
setup(__props, { emit: __emit }) {
|
|
46
|
+
const emit = __emit;
|
|
47
|
+
const proFormHeight = ref("unset");
|
|
48
|
+
const collapseHeight = ref(0);
|
|
49
|
+
let rowHeight = 32;
|
|
50
|
+
const rowGap = 16;
|
|
51
|
+
const columnGap = 24;
|
|
52
|
+
const computedExpand = computed(() => {
|
|
53
|
+
if (!__props.expand) return false;
|
|
54
|
+
if (__props.expand === true) return { minExpandRows: 2, expandStatus: false };
|
|
55
|
+
return {
|
|
56
|
+
minExpandRows: Math.max(Math.floor(__props.expand.minExpandRows ?? 2), 1),
|
|
57
|
+
expandStatus: __props.expand.expandStatus ?? false
|
|
58
|
+
};
|
|
59
|
+
});
|
|
60
|
+
const showExpandToggle = ref(false);
|
|
61
|
+
const expandStatus = ref(true);
|
|
62
|
+
const changeExpandStatus = () => {
|
|
63
|
+
expandStatus.value = !expandStatus.value;
|
|
64
|
+
};
|
|
65
|
+
const { formRef, getFormData } = __props.form;
|
|
66
|
+
const setInitExpandStatus = () => {
|
|
67
|
+
expandStatus.value = false;
|
|
68
|
+
if (formRef.value && __props.expand) {
|
|
69
|
+
const formEl = formRef.value.$el;
|
|
70
|
+
const formItemsEl = formEl.querySelectorAll(".ant-form-item>[path]");
|
|
71
|
+
const observer = new IntersectionObserver(
|
|
72
|
+
(entries) => {
|
|
73
|
+
expandStatus.value = entries.some((e) => {
|
|
74
|
+
if (e.intersectionRatio === 0) {
|
|
75
|
+
const path = e.target.getAttribute("path");
|
|
76
|
+
const searchFieldValue = path ? getFormData == null ? void 0 : getFormData(path) : void 0;
|
|
77
|
+
return ![null, void 0].includes(searchFieldValue);
|
|
78
|
+
}
|
|
79
|
+
return __props.expand.expandStatus;
|
|
80
|
+
});
|
|
81
|
+
observer.disconnect();
|
|
82
|
+
},
|
|
83
|
+
{ root: formEl }
|
|
84
|
+
);
|
|
85
|
+
formItemsEl.forEach((element) => {
|
|
86
|
+
observer.observe(element);
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
watch(
|
|
91
|
+
[
|
|
92
|
+
() => {
|
|
93
|
+
var _a, _b, _c;
|
|
94
|
+
return (_c = (_b = (_a = __props.form) == null ? void 0 : _a.fields.value) == null ? void 0 : _b.filter((f) => !f.hidden)) == null ? void 0 : _c.length;
|
|
95
|
+
},
|
|
96
|
+
() => formRef.value
|
|
97
|
+
],
|
|
98
|
+
() => {
|
|
99
|
+
var _a, _b, _c, _d, _e;
|
|
100
|
+
if (!expandStatus.value || !formRef.value) return;
|
|
101
|
+
const proFormEl = (_a = formRef.value) == null ? void 0 : _a.$el;
|
|
102
|
+
const { height = 0 } = ((_b = proFormEl == null ? void 0 : proFormEl.getBoundingClientRect) == null ? void 0 : _b.call(proFormEl)) || {};
|
|
103
|
+
proFormHeight.value = height;
|
|
104
|
+
rowHeight = (_e = (_d = (_c = proFormEl == null ? void 0 : proFormEl.querySelector(".ant-form-item")) == null ? void 0 : _c.getBoundingClientRect) == null ? void 0 : _d.call(_c)) == null ? void 0 : _e.height;
|
|
105
|
+
},
|
|
106
|
+
{ flush: "post", immediate: true }
|
|
107
|
+
);
|
|
108
|
+
watchEffect(
|
|
109
|
+
() => {
|
|
110
|
+
if (typeof proFormHeight.value !== "number") return;
|
|
111
|
+
if (__props.layout === "grid" && computedExpand.value) {
|
|
112
|
+
const { minExpandRows } = computedExpand.value;
|
|
113
|
+
collapseHeight.value = Math.min(
|
|
114
|
+
minExpandRows * rowHeight + (minExpandRows - 1) * rowGap,
|
|
115
|
+
+proFormHeight.value
|
|
116
|
+
);
|
|
117
|
+
showExpandToggle.value = +proFormHeight.value - collapseHeight.value > 1;
|
|
118
|
+
if (showExpandToggle.value) {
|
|
119
|
+
setInitExpandStatus();
|
|
120
|
+
}
|
|
121
|
+
} else {
|
|
122
|
+
showExpandToggle.value = false;
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
{ flush: "post" }
|
|
126
|
+
);
|
|
127
|
+
const layoutProps = computed(
|
|
128
|
+
() => __props.layout === "grid" ? {
|
|
129
|
+
grid: {
|
|
130
|
+
gutter: [columnGap, rowGap],
|
|
131
|
+
style: { flex: 1, marginRight: "12px" }
|
|
132
|
+
},
|
|
133
|
+
style: {
|
|
134
|
+
display: "flex",
|
|
135
|
+
overflow: "hidden",
|
|
136
|
+
height: `${expandStatus.value ? proFormHeight.value : collapseHeight.value}px`
|
|
137
|
+
}
|
|
138
|
+
} : {
|
|
139
|
+
layout: "inline",
|
|
140
|
+
style: { gap: `${rowGap}px ${columnGap}px` },
|
|
141
|
+
grid: false
|
|
142
|
+
}
|
|
143
|
+
);
|
|
144
|
+
const onReset = () => {
|
|
145
|
+
emit("reset");
|
|
146
|
+
};
|
|
147
|
+
const onSearch = () => {
|
|
148
|
+
emit("search");
|
|
149
|
+
};
|
|
150
|
+
return (_ctx, _cache) => {
|
|
151
|
+
return openBlock(), createBlock(unref(_sfc_main$9), mergeProps(layoutProps.value, {
|
|
152
|
+
form: __props.form,
|
|
153
|
+
class: "pro-table_search-form transition"
|
|
154
|
+
}), {
|
|
155
|
+
default: withCtx(() => [
|
|
156
|
+
createVNode(unref(Space), {
|
|
157
|
+
align: "start",
|
|
158
|
+
class: "pro-table_search-form_button-group"
|
|
159
|
+
}, {
|
|
160
|
+
default: withCtx(() => [
|
|
161
|
+
renderSlot(_ctx.$slots, "reset-button", { onClick: onReset }, () => [
|
|
162
|
+
__props.resetButton ? (openBlock(), createBlock(resolveDynamicComponent(__props.resetButton), {
|
|
163
|
+
key: 0,
|
|
164
|
+
onClick: onReset
|
|
165
|
+
})) : (openBlock(), createBlock(unref(Button), {
|
|
166
|
+
key: 1,
|
|
167
|
+
class: "pro-table_search-form_reset-button",
|
|
168
|
+
onClick: onReset
|
|
169
|
+
}, {
|
|
170
|
+
default: withCtx(() => [..._cache[0] || (_cache[0] = [
|
|
171
|
+
createTextVNode("重置", -1)
|
|
172
|
+
])]),
|
|
173
|
+
_: 1
|
|
174
|
+
}))
|
|
175
|
+
], true),
|
|
176
|
+
renderSlot(_ctx.$slots, "search-button", { onClick: onSearch }, () => [
|
|
177
|
+
__props.searchButton ? (openBlock(), createBlock(resolveDynamicComponent(__props.searchButton), {
|
|
178
|
+
key: 0,
|
|
179
|
+
onClick: onSearch
|
|
180
|
+
})) : (openBlock(), createBlock(unref(Button), {
|
|
181
|
+
key: 1,
|
|
182
|
+
class: "pro-table_search-form_search-button",
|
|
183
|
+
type: "primary",
|
|
184
|
+
"html-type": "submit",
|
|
185
|
+
onClick: onSearch
|
|
186
|
+
}, {
|
|
187
|
+
default: withCtx(() => [..._cache[1] || (_cache[1] = [
|
|
188
|
+
createTextVNode(" 查询 ", -1)
|
|
189
|
+
])]),
|
|
190
|
+
_: 1
|
|
191
|
+
}))
|
|
192
|
+
], true),
|
|
193
|
+
renderSlot(_ctx.$slots, "expand-button", { onClick: changeExpandStatus }, () => [
|
|
194
|
+
showExpandToggle.value ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
|
|
195
|
+
__props.expandButton ? (openBlock(), createBlock(resolveDynamicComponent(__props.expandButton), {
|
|
196
|
+
key: 0,
|
|
197
|
+
"expand-status": expandStatus.value,
|
|
198
|
+
onClick: changeExpandStatus
|
|
199
|
+
}, null, 8, ["expand-status"])) : (openBlock(), createBlock(unref(Button), {
|
|
200
|
+
key: 1,
|
|
201
|
+
type: "link",
|
|
202
|
+
class: "pro-table_search-form_expand-toggle-button",
|
|
203
|
+
onClick: changeExpandStatus
|
|
204
|
+
}, {
|
|
205
|
+
default: withCtx(() => [
|
|
206
|
+
createTextVNode(toDisplayString(expandStatus.value ? "收起" : "展开") + " ", 1),
|
|
207
|
+
createVNode(DownOutlined, {
|
|
208
|
+
class: "transition",
|
|
209
|
+
style: normalizeStyle([{ "margin-left": "4px" }, { transform: `rotate(${expandStatus.value ? -180 : 0}deg)` }])
|
|
210
|
+
}, null, 8, ["style"])
|
|
211
|
+
]),
|
|
212
|
+
_: 1
|
|
213
|
+
}))
|
|
214
|
+
], 64)) : createCommentVNode("", true)
|
|
215
|
+
], true)
|
|
216
|
+
]),
|
|
217
|
+
_: 3
|
|
218
|
+
})
|
|
219
|
+
]),
|
|
220
|
+
_: 3
|
|
221
|
+
}, 16, ["form"]);
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
const SearchForm = /* @__PURE__ */ _export_sfc(_sfc_main$7, [["__scopeId", "data-v-37368080"]]);
|
|
226
|
+
const _sfc_main$6 = /* @__PURE__ */ defineComponent({
|
|
227
|
+
__name: "DefaultSearchFormContainer",
|
|
228
|
+
setup(__props) {
|
|
229
|
+
const { token } = theme.useToken();
|
|
230
|
+
return (_ctx, _cache) => {
|
|
231
|
+
var _a;
|
|
232
|
+
return openBlock(), createElementBlock("div", {
|
|
233
|
+
class: "pro-table_search-form-container",
|
|
234
|
+
style: normalizeStyle({ backgroundColor: (_a = unref(token).value) == null ? void 0 : _a.colorBgContainer })
|
|
235
|
+
}, [
|
|
236
|
+
renderSlot(_ctx.$slots, "default", {}, void 0, true)
|
|
237
|
+
], 4);
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
const DefaultSearchFormContainer = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["__scopeId", "data-v-8f67830d"]]);
|
|
242
|
+
const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
243
|
+
__name: "DefaultTableContainer",
|
|
244
|
+
setup(__props) {
|
|
245
|
+
const { token } = theme.useToken();
|
|
246
|
+
return (_ctx, _cache) => {
|
|
247
|
+
var _a;
|
|
248
|
+
return openBlock(), createElementBlock("div", {
|
|
249
|
+
class: "pro-table_table-container",
|
|
250
|
+
style: normalizeStyle({ backgroundColor: (_a = unref(token).value) == null ? void 0 : _a.colorBgContainer })
|
|
251
|
+
}, [
|
|
252
|
+
renderSlot(_ctx.$slots, "default", {}, void 0, true)
|
|
253
|
+
], 4);
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
const DefaultTableContainer = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["__scopeId", "data-v-02fe26ae"]]);
|
|
258
|
+
const _sfc_main$4 = {};
|
|
259
|
+
const _hoisted_1$2 = {
|
|
260
|
+
focusable: "false",
|
|
261
|
+
"data-icon": "column-height",
|
|
262
|
+
width: "1em",
|
|
263
|
+
height: "1em",
|
|
264
|
+
fill: "currentColor",
|
|
265
|
+
"aria-hidden": "true",
|
|
266
|
+
viewBox: "64 64 896 896"
|
|
267
|
+
};
|
|
268
|
+
function _sfc_render$1(_ctx, _cache) {
|
|
269
|
+
return openBlock(), createElementBlock("svg", _hoisted_1$2, [..._cache[0] || (_cache[0] = [
|
|
270
|
+
createElementVNode("path", { d: "M840 836H184c-4.4 0-8 3.6-8 8v60c0 4.4 3.6 8 8 8h656c4.4 0 8-3.6 8-8v-60c0-4.4-3.6-8-8-8zm0-724H184c-4.4 0-8 3.6-8 8v60c0 4.4 3.6 8 8 8h656c4.4 0 8-3.6 8-8v-60c0-4.4-3.6-8-8-8zM610.8 378c6 0 9.4-7 5.7-11.7L515.7 238.7a7.14 7.14 0 00-11.3 0L403.6 366.3a7.23 7.23 0 005.7 11.7H476v268h-62.8c-6 0-9.4 7-5.7 11.7l100.8 127.5c2.9 3.7 8.5 3.7 11.3 0l100.8-127.5c3.7-4.7.4-11.7-5.7-11.7H548V378h62.8z" }, null, -1)
|
|
271
|
+
])]);
|
|
272
|
+
}
|
|
273
|
+
const ColumnHeightOutlined = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["render", _sfc_render$1]]);
|
|
274
|
+
const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
275
|
+
__name: "SizeControl",
|
|
276
|
+
props: {
|
|
277
|
+
"size": {},
|
|
278
|
+
"sizeModifiers": {}
|
|
279
|
+
},
|
|
280
|
+
emits: ["update:size"],
|
|
281
|
+
setup(__props) {
|
|
282
|
+
var _a;
|
|
283
|
+
const config = useConfig();
|
|
284
|
+
const size = useModel(__props, "size");
|
|
285
|
+
size.value = size.value ?? ((_a = config.componentSize) == null ? void 0 : _a.value) ?? "large";
|
|
286
|
+
const items = [
|
|
287
|
+
{ label: "默认", key: "large" },
|
|
288
|
+
{ label: "中等", key: "middle" },
|
|
289
|
+
{ label: "紧凑", key: "small" }
|
|
290
|
+
];
|
|
291
|
+
return (_ctx, _cache) => {
|
|
292
|
+
return openBlock(), createBlock(unref(Dropdown), {
|
|
293
|
+
arrow: "",
|
|
294
|
+
placement: "bottomRight"
|
|
295
|
+
}, {
|
|
296
|
+
popupRender: withCtx(() => [
|
|
297
|
+
createVNode(unref(Menu), {
|
|
298
|
+
"selected-keys": [size.value],
|
|
299
|
+
style: { "min-width": "80px" },
|
|
300
|
+
items,
|
|
301
|
+
onClick: _cache[0] || (_cache[0] = ({ key }) => size.value = key)
|
|
302
|
+
}, null, 8, ["selected-keys"])
|
|
303
|
+
]),
|
|
304
|
+
default: withCtx(() => [
|
|
305
|
+
createVNode(unref(Button), {
|
|
306
|
+
type: "text",
|
|
307
|
+
class: "pro-table_size-control_button"
|
|
308
|
+
}, {
|
|
309
|
+
default: withCtx(() => [
|
|
310
|
+
createVNode(ColumnHeightOutlined)
|
|
311
|
+
]),
|
|
312
|
+
_: 1
|
|
313
|
+
})
|
|
314
|
+
]),
|
|
315
|
+
_: 1
|
|
316
|
+
});
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
});
|
|
320
|
+
const SizeControl = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-832ddd0e"]]);
|
|
321
|
+
const _sfc_main$2 = {};
|
|
322
|
+
const _hoisted_1$1 = {
|
|
323
|
+
focusable: "false",
|
|
324
|
+
"data-icon": "filter",
|
|
325
|
+
width: "1em",
|
|
326
|
+
height: "1em",
|
|
327
|
+
fill: "currentColor",
|
|
328
|
+
"aria-hidden": "true",
|
|
329
|
+
viewBox: "64 64 896 896"
|
|
330
|
+
};
|
|
331
|
+
function _sfc_render(_ctx, _cache) {
|
|
332
|
+
return openBlock(), createElementBlock("svg", _hoisted_1$1, [..._cache[0] || (_cache[0] = [
|
|
333
|
+
createElementVNode("path", { d: "M880.1 154H143.9c-24.5 0-39.8 26.7-27.5 48L349 597.4V838c0 17.7 14.2 32 31.8 32h262.4c17.6 0 31.8-14.3 31.8-32V597.4L907.7 202c12.2-21.3-3.1-48-27.6-48zM603.4 798H420.6V642h182.9v156zm9.6-236.6l-9.5 16.6h-183l-9.5-16.6L212.7 226h598.6L613 561.4z" }, null, -1)
|
|
334
|
+
])]);
|
|
335
|
+
}
|
|
336
|
+
const FilterOutlined = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["render", _sfc_render]]);
|
|
337
|
+
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
338
|
+
__name: "ColumnControl",
|
|
339
|
+
props: {
|
|
340
|
+
columns: {},
|
|
341
|
+
table: { default: () => void 0 }
|
|
342
|
+
},
|
|
343
|
+
setup(__props) {
|
|
344
|
+
const open = ref(false);
|
|
345
|
+
const checkAll = ref(false);
|
|
346
|
+
const indeterminate = ref(false);
|
|
347
|
+
const checkedColumnsOptions = computed(
|
|
348
|
+
() => __props.columns.flatMap(
|
|
349
|
+
(item) => item.key && item.title ? {
|
|
350
|
+
label: item.title,
|
|
351
|
+
value: item.key,
|
|
352
|
+
checked: !item.hidden
|
|
353
|
+
} : []
|
|
354
|
+
)
|
|
355
|
+
);
|
|
356
|
+
const checkedColumnKeys = computed({
|
|
357
|
+
get() {
|
|
358
|
+
return checkedColumnsOptions.value.flatMap(
|
|
359
|
+
(item) => item.checked ? item.value : []
|
|
360
|
+
) || [];
|
|
361
|
+
},
|
|
362
|
+
set(val) {
|
|
363
|
+
var _a;
|
|
364
|
+
(_a = checkedColumnsOptions.value) == null ? void 0 : _a.forEach((item) => {
|
|
365
|
+
var _a2, _b;
|
|
366
|
+
(_b = (_a2 = __props.table) == null ? void 0 : _a2.setColumn) == null ? void 0 : _b.call(_a2, item.value, {
|
|
367
|
+
hidden: !val.includes(item.value)
|
|
368
|
+
});
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
});
|
|
372
|
+
const onCheckAllChange = (e) => {
|
|
373
|
+
checkedColumnKeys.value = e.target.checked ? checkedColumnsOptions.value.map((item) => item.value) : [];
|
|
374
|
+
indeterminate.value = false;
|
|
375
|
+
};
|
|
376
|
+
const checkColumnsMenuItemClick = (val) => {
|
|
377
|
+
if (checkedColumnKeys.value.includes(val)) {
|
|
378
|
+
checkedColumnKeys.value = checkedColumnKeys.value.filter(
|
|
379
|
+
(item) => item !== val
|
|
380
|
+
);
|
|
381
|
+
} else {
|
|
382
|
+
checkedColumnKeys.value = [...checkedColumnKeys.value, val];
|
|
383
|
+
}
|
|
384
|
+
};
|
|
385
|
+
watch(
|
|
386
|
+
checkedColumnKeys,
|
|
387
|
+
(val) => {
|
|
388
|
+
indeterminate.value = !!val.length && val.length < checkedColumnsOptions.value.length;
|
|
389
|
+
checkAll.value = val.length > 0 && val.length === checkedColumnsOptions.value.length;
|
|
390
|
+
},
|
|
391
|
+
{ immediate: true }
|
|
392
|
+
);
|
|
393
|
+
const items = computed(() => [
|
|
394
|
+
{
|
|
395
|
+
key: "all",
|
|
396
|
+
label: h(
|
|
397
|
+
Checkbox,
|
|
398
|
+
{
|
|
399
|
+
style: { width: "100%" },
|
|
400
|
+
checked: checkAll.value,
|
|
401
|
+
indeterminate: indeterminate.value,
|
|
402
|
+
onChange: onCheckAllChange
|
|
403
|
+
},
|
|
404
|
+
() => "全选"
|
|
405
|
+
)
|
|
406
|
+
},
|
|
407
|
+
{ type: "divider" },
|
|
408
|
+
...checkedColumnsOptions.value.map((item) => ({
|
|
409
|
+
key: item.value,
|
|
410
|
+
label: h(
|
|
411
|
+
Checkbox,
|
|
412
|
+
{
|
|
413
|
+
style: { width: "100%" },
|
|
414
|
+
checked: item.checked,
|
|
415
|
+
onChange: () => checkColumnsMenuItemClick(item.value)
|
|
416
|
+
},
|
|
417
|
+
() => item.label
|
|
418
|
+
)
|
|
419
|
+
}))
|
|
420
|
+
]);
|
|
421
|
+
function handleOpenChange(nextOpen, info) {
|
|
422
|
+
if (info.source === "trigger" || nextOpen) {
|
|
423
|
+
open.value = nextOpen;
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
return (_ctx, _cache) => {
|
|
427
|
+
return openBlock(), createBlock(unref(Dropdown), {
|
|
428
|
+
open: open.value,
|
|
429
|
+
arrow: "",
|
|
430
|
+
placement: "bottomRight",
|
|
431
|
+
menu: { items: items.value },
|
|
432
|
+
onOpenChange: handleOpenChange
|
|
433
|
+
}, {
|
|
434
|
+
default: withCtx(() => [
|
|
435
|
+
createVNode(unref(Button), {
|
|
436
|
+
type: "text",
|
|
437
|
+
class: "pro-table_column-control_button"
|
|
438
|
+
}, {
|
|
439
|
+
default: withCtx(() => [
|
|
440
|
+
createVNode(FilterOutlined)
|
|
441
|
+
]),
|
|
442
|
+
_: 1
|
|
443
|
+
})
|
|
444
|
+
]),
|
|
445
|
+
_: 1
|
|
446
|
+
}, 8, ["open", "menu"]);
|
|
447
|
+
};
|
|
448
|
+
}
|
|
449
|
+
});
|
|
450
|
+
const ColumnControl = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-246b0faf"]]);
|
|
451
|
+
const _hoisted_1 = { class: "pro-table_header" };
|
|
452
|
+
const _hoisted_2 = {
|
|
453
|
+
key: 0,
|
|
454
|
+
class: "pro-table_header_button-bar"
|
|
455
|
+
};
|
|
456
|
+
const _hoisted_3 = {
|
|
457
|
+
key: 1,
|
|
458
|
+
class: "pro-table_header_toolbar"
|
|
459
|
+
};
|
|
460
|
+
const _hoisted_4 = {
|
|
461
|
+
key: 2,
|
|
462
|
+
class: "pro-table_header_size-control"
|
|
463
|
+
};
|
|
464
|
+
const _hoisted_5 = {
|
|
465
|
+
key: 3,
|
|
466
|
+
class: "pro-table_header_column-control"
|
|
467
|
+
};
|
|
468
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
469
|
+
...{ name: "ProTable", inheritAttrs: false },
|
|
470
|
+
__name: "BaseTable",
|
|
471
|
+
props: /* @__PURE__ */ mergeModels({
|
|
472
|
+
table: { default: () => void 0 },
|
|
473
|
+
search: { type: Function, default: void 0 },
|
|
474
|
+
addIndexColumn: { type: Boolean, default: () => void 0 },
|
|
475
|
+
immediateSearch: { type: Boolean, default: () => void 0 },
|
|
476
|
+
control: { type: [Boolean, Object], default: () => void 0 },
|
|
477
|
+
searchFormConfig: { default: () => void 0 },
|
|
478
|
+
tableContainer: { type: [Object, Function, Boolean], default: void 0 }
|
|
479
|
+
}, {
|
|
480
|
+
"size": {},
|
|
481
|
+
"sizeModifiers": {},
|
|
482
|
+
"loading": { type: Boolean },
|
|
483
|
+
"loadingModifiers": {}
|
|
484
|
+
}),
|
|
485
|
+
emits: ["update:size", "update:loading"],
|
|
486
|
+
setup(__props) {
|
|
487
|
+
const config = INJECT_CONFIG["pro-table"];
|
|
488
|
+
const injectProps = inject(config.injectionKey, config.default);
|
|
489
|
+
const tableProperties = Object.keys(tableProps());
|
|
490
|
+
const injectAttrs = pick(injectProps, tableProperties);
|
|
491
|
+
const computedSearchFormConfig = computed(() => {
|
|
492
|
+
var _a, _b;
|
|
493
|
+
const container = ((_a = __props.searchFormConfig) == null ? void 0 : _a.container) ?? ((_b = injectProps.searchFormConfig) == null ? void 0 : _b.container) ?? DefaultSearchFormContainer;
|
|
494
|
+
return {
|
|
495
|
+
...injectProps.searchFormConfig,
|
|
496
|
+
...getObject(__props.searchFormConfig),
|
|
497
|
+
container: container ? container : void 0
|
|
498
|
+
};
|
|
499
|
+
});
|
|
500
|
+
const attrs = useAttrs();
|
|
501
|
+
const tableAttrs = computed(() => {
|
|
502
|
+
return pick(camelizeProperties(attrs), tableProperties);
|
|
503
|
+
});
|
|
504
|
+
const { columns, dataSource, searchForm, pageParam, setPageParam } = __props.table || {};
|
|
505
|
+
const size = useModel(__props, "size");
|
|
506
|
+
const loading = useModel(__props, "loading");
|
|
507
|
+
const _search = async () => {
|
|
508
|
+
var _a;
|
|
509
|
+
try {
|
|
510
|
+
loading.value = true;
|
|
511
|
+
await ((_a = __props.search) == null ? void 0 : _a.call(__props));
|
|
512
|
+
} finally {
|
|
513
|
+
loading.value = false;
|
|
514
|
+
}
|
|
515
|
+
};
|
|
516
|
+
const reset = () => {
|
|
517
|
+
var _a;
|
|
518
|
+
(_a = __props.table) == null ? void 0 : _a.resetQueryParams();
|
|
519
|
+
nextTick(() => {
|
|
520
|
+
_search();
|
|
521
|
+
});
|
|
522
|
+
};
|
|
523
|
+
const slots = useSlots();
|
|
524
|
+
const {
|
|
525
|
+
"search-form": searchFormSlot,
|
|
526
|
+
"button-bar": buttonBarSlot,
|
|
527
|
+
toolbar: toolbarSlot,
|
|
528
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
529
|
+
table: tableSlot,
|
|
530
|
+
...tableSlots
|
|
531
|
+
} = slots;
|
|
532
|
+
const searchPage1st = () => {
|
|
533
|
+
setPageParam == null ? void 0 : setPageParam({ current: 1 });
|
|
534
|
+
_search();
|
|
535
|
+
};
|
|
536
|
+
const computedTableProps = computed(() => {
|
|
537
|
+
return {
|
|
538
|
+
...injectAttrs,
|
|
539
|
+
...tableAttrs.value,
|
|
540
|
+
pagination: void 0,
|
|
541
|
+
onChange: void 0
|
|
542
|
+
};
|
|
543
|
+
});
|
|
544
|
+
const computedTableContainer = computed(() => {
|
|
545
|
+
const container = __props.tableContainer ?? injectProps.tableContainer ?? DefaultTableContainer;
|
|
546
|
+
return container ? container : void 0;
|
|
547
|
+
});
|
|
548
|
+
const indexColumn = {
|
|
549
|
+
title: "序号",
|
|
550
|
+
dataIndex: "_index",
|
|
551
|
+
width: 80,
|
|
552
|
+
render: (_, __, index) => index + 1
|
|
553
|
+
};
|
|
554
|
+
const computedColumns = computed(
|
|
555
|
+
() => [
|
|
556
|
+
...__props.addIndexColumn ?? injectProps.addIndexColumn ? [indexColumn] : [],
|
|
557
|
+
...(tableAttrs.value.columns ?? (columns == null ? void 0 : columns.value) ?? []).flatMap(
|
|
558
|
+
(item, index) => {
|
|
559
|
+
if (item.key) return [{ ...item, key: item.key }];
|
|
560
|
+
if (item.dataIndex) {
|
|
561
|
+
const dataIndexKey = Array.isArray(item.dataIndex) ? item.dataIndex.join(".") : item.dataIndex;
|
|
562
|
+
return [{ ...item, key: dataIndexKey }];
|
|
563
|
+
}
|
|
564
|
+
return [{ ...item, key: index }];
|
|
565
|
+
}
|
|
566
|
+
)
|
|
567
|
+
]
|
|
568
|
+
);
|
|
569
|
+
const visibleComputedColumns = computed(() => {
|
|
570
|
+
return computedColumns.value.filter((item) => !item.hidden);
|
|
571
|
+
});
|
|
572
|
+
const computedDataSource = computed(() => {
|
|
573
|
+
return tableAttrs.value.dataSource ?? (dataSource == null ? void 0 : dataSource.value);
|
|
574
|
+
});
|
|
575
|
+
const computedPagination = computed(() => {
|
|
576
|
+
if (tableAttrs.value.pagination === false) return false;
|
|
577
|
+
return {
|
|
578
|
+
...injectAttrs.pagination,
|
|
579
|
+
...pageParam,
|
|
580
|
+
...tableAttrs.value.pagination
|
|
581
|
+
};
|
|
582
|
+
});
|
|
583
|
+
const onTableChange = (...args) => {
|
|
584
|
+
var _a;
|
|
585
|
+
setPageParam == null ? void 0 : setPageParam(args[0]);
|
|
586
|
+
(_a = attrs.onChange) == null ? void 0 : _a.call(attrs, ...args);
|
|
587
|
+
_search();
|
|
588
|
+
};
|
|
589
|
+
const showSearch = computed(() => {
|
|
590
|
+
var _a, _b;
|
|
591
|
+
return !!(searchFormSlot || ((_a = computedSearchFormConfig.value) == null ? void 0 : _a.hidden) !== true && searchForm && ((_b = searchForm.fields.value.filter((item) => !item.hidden)) == null ? void 0 : _b.length) > 0);
|
|
592
|
+
});
|
|
593
|
+
const computedControl = computed(() => {
|
|
594
|
+
const mergedControl = __props.control ?? injectProps.control;
|
|
595
|
+
const sizeControl = (mergedControl == null ? void 0 : mergedControl.sizeControl) ?? mergedControl;
|
|
596
|
+
const columnControl = (mergedControl == null ? void 0 : mergedControl.columnControl) ?? mergedControl;
|
|
597
|
+
return { sizeControl, columnControl };
|
|
598
|
+
});
|
|
599
|
+
onMounted(() => {
|
|
600
|
+
if (__props.immediateSearch ?? injectProps.immediateSearch) {
|
|
601
|
+
_search();
|
|
602
|
+
}
|
|
603
|
+
});
|
|
604
|
+
return (_ctx, _cache) => {
|
|
605
|
+
return openBlock(), createElementBlock("div", {
|
|
606
|
+
class: normalizeClass(["pro-table", _ctx.$attrs.class]),
|
|
607
|
+
style: normalizeStyle(_ctx.$attrs.style)
|
|
608
|
+
}, [
|
|
609
|
+
showSearch.value ? (openBlock(), createBlock(unref(_sfc_main$a), {
|
|
610
|
+
key: 0,
|
|
611
|
+
component: computedSearchFormConfig.value.container
|
|
612
|
+
}, {
|
|
613
|
+
default: withCtx(() => [
|
|
614
|
+
renderSlot(_ctx.$slots, "search-form", {}, () => [
|
|
615
|
+
unref(searchForm) ? (openBlock(), createBlock(SearchForm, mergeProps({
|
|
616
|
+
key: 0,
|
|
617
|
+
form: unref(searchForm)
|
|
618
|
+
}, computedSearchFormConfig.value, {
|
|
619
|
+
onSearch: searchPage1st,
|
|
620
|
+
onReset: reset
|
|
621
|
+
}), null, 16, ["form"])) : createCommentVNode("", true)
|
|
622
|
+
], true)
|
|
623
|
+
]),
|
|
624
|
+
_: 3
|
|
625
|
+
}, 8, ["component"])) : createCommentVNode("", true),
|
|
626
|
+
createVNode(unref(_sfc_main$a), { component: computedTableContainer.value }, {
|
|
627
|
+
default: withCtx(() => [
|
|
628
|
+
createElementVNode("div", _hoisted_1, [
|
|
629
|
+
unref(buttonBarSlot) ? (openBlock(), createElementBlock("div", _hoisted_2, [
|
|
630
|
+
renderSlot(_ctx.$slots, "button-bar", {}, void 0, true)
|
|
631
|
+
])) : createCommentVNode("", true),
|
|
632
|
+
unref(toolbarSlot) ? (openBlock(), createElementBlock("div", _hoisted_3, [
|
|
633
|
+
renderSlot(_ctx.$slots, "toolbar", {}, void 0, true)
|
|
634
|
+
])) : createCommentVNode("", true),
|
|
635
|
+
computedControl.value.sizeControl ? (openBlock(), createElementBlock("div", _hoisted_4, [
|
|
636
|
+
createVNode(unref(SizeControl), {
|
|
637
|
+
size: size.value,
|
|
638
|
+
"onUpdate:size": _cache[0] || (_cache[0] = ($event) => size.value = $event)
|
|
639
|
+
}, null, 8, ["size"])
|
|
640
|
+
])) : createCommentVNode("", true),
|
|
641
|
+
computedControl.value.columnControl ? (openBlock(), createElementBlock("div", _hoisted_5, [
|
|
642
|
+
createVNode(unref(ColumnControl), {
|
|
643
|
+
columns: computedColumns.value,
|
|
644
|
+
table: __props.table
|
|
645
|
+
}, null, 8, ["columns", "table"])
|
|
646
|
+
])) : createCommentVNode("", true)
|
|
647
|
+
]),
|
|
648
|
+
renderSlot(_ctx.$slots, "table", {}, () => [
|
|
649
|
+
createVNode(unref(Table), mergeProps({ class: "pro-table_content" }, computedTableProps.value, {
|
|
650
|
+
size: size.value,
|
|
651
|
+
loading: loading.value,
|
|
652
|
+
columns: visibleComputedColumns.value,
|
|
653
|
+
"data-source": computedDataSource.value,
|
|
654
|
+
pagination: computedPagination.value,
|
|
655
|
+
onChange: onTableChange
|
|
656
|
+
}), createSlots({ _: 2 }, [
|
|
657
|
+
renderList(tableSlots, (_, name) => {
|
|
658
|
+
return {
|
|
659
|
+
name,
|
|
660
|
+
fn: withCtx((scoped) => [
|
|
661
|
+
renderSlot(_ctx.$slots, name, normalizeProps(guardReactiveProps(scoped)), void 0, true)
|
|
662
|
+
])
|
|
663
|
+
};
|
|
664
|
+
})
|
|
665
|
+
]), 1040, ["size", "loading", "columns", "data-source", "pagination"])
|
|
666
|
+
], true)
|
|
667
|
+
]),
|
|
668
|
+
_: 3
|
|
669
|
+
}, 8, ["component"])
|
|
670
|
+
], 6);
|
|
671
|
+
};
|
|
672
|
+
}
|
|
673
|
+
});
|
|
674
|
+
const BaseTable = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-270ae6c9"]]);
|
|
675
|
+
const useTable = useTable$1;
|
|
676
|
+
export {
|
|
677
|
+
BaseTable as default,
|
|
678
|
+
useTable
|
|
679
|
+
};
|