@qin-ui/antd-vue-pro 1.1.25 → 2.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/README.md +73 -322
- package/es/antd-vue-pro.css +52 -0
- package/es/component-provider/index-DtsWFG3s.js +154 -0
- package/es/component-provider/index.js +3 -85
- package/es/form/index.js +637 -18
- package/es/index.d.ts +778 -7488
- package/es/index.js +19 -24
- package/es/table/index.js +538 -498
- package/es/vendor/utils/lodash-es-Bu1KKNMo.js +985 -0
- package/package.json +13 -8
- package/es/form/index-1cdda7ac.js +0 -16336
- package/es/style.css +0 -43
package/es/table/index.js
CHANGED
|
@@ -1,149 +1,79 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createElementBlock, openBlock, createElementVNode, defineComponent, ref, computed, watch, watchEffect, createBlock, unref, mergeProps, withCtx, createVNode, createCommentVNode, createTextVNode, toDisplayString, normalizeStyle, toValue, renderSlot, useAttrs, Fragment, renderList, withModifiers, inject, useSlots, onMounted, normalizeClass, isRef, createSlots, normalizeProps, guardReactiveProps, nextTick, reactive } from "vue";
|
|
2
|
+
import { I as INJECT_CONFIG, g as getObject } from "../component-provider/index-DtsWFG3s.js";
|
|
3
|
+
import _sfc_main$9, { ContainerFragment as _sfc_main$a, useForm } from "../form/index.js";
|
|
2
4
|
import { Space, Button, Dropdown, Menu, MenuItem, Checkbox, MenuDivider, Table } from "ant-design-vue";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var source = arguments[i] != null ? Object(arguments[i]) : {};
|
|
10
|
-
var ownKeys = Object.keys(source);
|
|
11
|
-
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
12
|
-
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
13
|
-
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
14
|
-
}));
|
|
15
|
-
}
|
|
16
|
-
ownKeys.forEach(function(key) {
|
|
17
|
-
_defineProperty$2(target, key, source[key]);
|
|
18
|
-
});
|
|
5
|
+
import { p as pick, c as cloneDeep } from "../vendor/utils/lodash-es-Bu1KKNMo.js";
|
|
6
|
+
import { tableProps } from "ant-design-vue/es/table";
|
|
7
|
+
const _export_sfc = (sfc, props) => {
|
|
8
|
+
const target = sfc.__vccOpts || sfc;
|
|
9
|
+
for (const [key, val] of props) {
|
|
10
|
+
target[key] = val;
|
|
19
11
|
}
|
|
20
12
|
return target;
|
|
21
|
-
}
|
|
22
|
-
function _defineProperty$2(obj, key, value) {
|
|
23
|
-
if (key in obj) {
|
|
24
|
-
Object.defineProperty(obj, key, { value, enumerable: true, configurable: true, writable: true });
|
|
25
|
-
} else {
|
|
26
|
-
obj[key] = value;
|
|
27
|
-
}
|
|
28
|
-
return obj;
|
|
29
|
-
}
|
|
30
|
-
var ColumnHeightOutlined = function ColumnHeightOutlined2(props, context) {
|
|
31
|
-
var p = _objectSpread$2({}, props, context.attrs);
|
|
32
|
-
return createVNode(AntdIcon, _objectSpread$2({}, p, {
|
|
33
|
-
"icon": ColumnHeightOutlinedSvg
|
|
34
|
-
}), null);
|
|
35
13
|
};
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
46
|
-
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
47
|
-
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
48
|
-
}));
|
|
49
|
-
}
|
|
50
|
-
ownKeys.forEach(function(key) {
|
|
51
|
-
_defineProperty$1(target, key, source[key]);
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
return target;
|
|
55
|
-
}
|
|
56
|
-
function _defineProperty$1(obj, key, value) {
|
|
57
|
-
if (key in obj) {
|
|
58
|
-
Object.defineProperty(obj, key, { value, enumerable: true, configurable: true, writable: true });
|
|
59
|
-
} else {
|
|
60
|
-
obj[key] = value;
|
|
61
|
-
}
|
|
62
|
-
return obj;
|
|
63
|
-
}
|
|
64
|
-
var DownOutlined = function DownOutlined2(props, context) {
|
|
65
|
-
var p = _objectSpread$1({}, props, context.attrs);
|
|
66
|
-
return createVNode(AntdIcon, _objectSpread$1({}, p, {
|
|
67
|
-
"icon": DownOutlinedSvg
|
|
68
|
-
}), null);
|
|
14
|
+
const _sfc_main$8 = {};
|
|
15
|
+
const _hoisted_1$7 = {
|
|
16
|
+
focusable: "false",
|
|
17
|
+
"data-icon": "down",
|
|
18
|
+
width: "1em",
|
|
19
|
+
height: "1em",
|
|
20
|
+
fill: "currentColor",
|
|
21
|
+
"aria-hidden": "true",
|
|
22
|
+
viewBox: "64 64 896 896"
|
|
69
23
|
};
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
const FilterOutlinedSvg = FilterOutlined$2;
|
|
75
|
-
function _objectSpread(target) {
|
|
76
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
77
|
-
var source = arguments[i] != null ? Object(arguments[i]) : {};
|
|
78
|
-
var ownKeys = Object.keys(source);
|
|
79
|
-
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
80
|
-
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
81
|
-
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
82
|
-
}));
|
|
83
|
-
}
|
|
84
|
-
ownKeys.forEach(function(key) {
|
|
85
|
-
_defineProperty(target, key, source[key]);
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
return target;
|
|
89
|
-
}
|
|
90
|
-
function _defineProperty(obj, key, value) {
|
|
91
|
-
if (key in obj) {
|
|
92
|
-
Object.defineProperty(obj, key, { value, enumerable: true, configurable: true, writable: true });
|
|
93
|
-
} else {
|
|
94
|
-
obj[key] = value;
|
|
95
|
-
}
|
|
96
|
-
return obj;
|
|
24
|
+
function _sfc_render$4(_ctx, _cache) {
|
|
25
|
+
return openBlock(), createElementBlock("svg", _hoisted_1$7, _cache[0] || (_cache[0] = [
|
|
26
|
+
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)
|
|
27
|
+
]));
|
|
97
28
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
"icon": FilterOutlinedSvg
|
|
102
|
-
}), null);
|
|
103
|
-
};
|
|
104
|
-
FilterOutlined.displayName = "FilterOutlined";
|
|
105
|
-
FilterOutlined.inheritAttrs = false;
|
|
106
|
-
const FilterOutlined$1 = FilterOutlined;
|
|
107
|
-
const rowGap = 16;
|
|
108
|
-
const columnGap = 24;
|
|
109
|
-
const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
110
|
-
...{
|
|
111
|
-
name: "SearchForm",
|
|
112
|
-
inheritAttrs: false
|
|
113
|
-
},
|
|
29
|
+
const DownOutlined = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["render", _sfc_render$4]]);
|
|
30
|
+
const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
31
|
+
...{ name: "SearchForm" },
|
|
114
32
|
__name: "SearchForm",
|
|
115
33
|
props: {
|
|
116
34
|
form: {},
|
|
117
35
|
layout: { default: "grid" },
|
|
118
|
-
|
|
119
|
-
|
|
36
|
+
expand: { type: [Boolean, Object], default: true },
|
|
37
|
+
class: {},
|
|
38
|
+
style: {}
|
|
120
39
|
},
|
|
121
40
|
emits: ["search", "reset"],
|
|
122
41
|
setup(__props, { emit: __emit }) {
|
|
123
42
|
const props = __props;
|
|
124
43
|
const emit = __emit;
|
|
125
|
-
|
|
126
|
-
|
|
44
|
+
const proFormHeight = ref("unset");
|
|
45
|
+
const collapseHeight = ref(0);
|
|
46
|
+
let rowHeight = 32;
|
|
47
|
+
const rowGap = 16;
|
|
48
|
+
const columnGap = 24;
|
|
49
|
+
const computedExpand = computed(() => {
|
|
50
|
+
if (!props.expand) return false;
|
|
51
|
+
if (props.expand === true) return { minExpandRows: 2, expandStatus: false };
|
|
52
|
+
return {
|
|
53
|
+
minExpandRows: Math.max(Math.floor(props.expand.minExpandRows ?? 2), 1),
|
|
54
|
+
expandStatus: props.expand.expandStatus ?? false
|
|
55
|
+
};
|
|
56
|
+
});
|
|
127
57
|
const showExpandToggle = ref(false);
|
|
128
|
-
const proFormRef = ref();
|
|
129
58
|
const expandStatus = ref(true);
|
|
130
|
-
const
|
|
59
|
+
const changeExpandStatus = () => {
|
|
131
60
|
expandStatus.value = !expandStatus.value;
|
|
132
61
|
};
|
|
62
|
+
const { formRef, getFormData } = props.form;
|
|
133
63
|
const setInitExpandStatus = () => {
|
|
134
64
|
expandStatus.value = false;
|
|
135
|
-
if (
|
|
136
|
-
const formEl =
|
|
65
|
+
if (formRef.value && props.expand) {
|
|
66
|
+
const formEl = formRef.value.$el;
|
|
137
67
|
const formItemsEl = formEl.querySelectorAll(".ant-form-item>[path]");
|
|
138
68
|
const observer = new IntersectionObserver(
|
|
139
69
|
(entries) => {
|
|
140
70
|
expandStatus.value = entries.some((e) => {
|
|
141
71
|
if (e.intersectionRatio === 0) {
|
|
142
72
|
const path = e.target.getAttribute("path");
|
|
143
|
-
const searchFieldValue = path ?
|
|
73
|
+
const searchFieldValue = path ? getFormData == null ? void 0 : getFormData(path) : void 0;
|
|
144
74
|
return ![null, void 0].includes(searchFieldValue);
|
|
145
75
|
}
|
|
146
|
-
return props.
|
|
76
|
+
return props.expand.expandStatus;
|
|
147
77
|
});
|
|
148
78
|
observer.disconnect();
|
|
149
79
|
},
|
|
@@ -154,20 +84,43 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
|
154
84
|
});
|
|
155
85
|
}
|
|
156
86
|
};
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
87
|
+
watch(
|
|
88
|
+
[
|
|
89
|
+
() => {
|
|
90
|
+
var _a, _b, _c;
|
|
91
|
+
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;
|
|
92
|
+
},
|
|
93
|
+
() => formRef.value
|
|
94
|
+
],
|
|
95
|
+
() => {
|
|
96
|
+
var _a, _b, _c, _d, _e;
|
|
97
|
+
if (!expandStatus.value || !formRef.value) return;
|
|
98
|
+
const proFormEl = (_a = formRef.value) == null ? void 0 : _a.$el;
|
|
161
99
|
const { height = 0 } = ((_b = proFormEl == null ? void 0 : proFormEl.getBoundingClientRect) == null ? void 0 : _b.call(proFormEl)) || {};
|
|
162
|
-
proFormHeight = height;
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
100
|
+
proFormHeight.value = height;
|
|
101
|
+
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;
|
|
102
|
+
},
|
|
103
|
+
{ flush: "post", immediate: true }
|
|
104
|
+
);
|
|
105
|
+
watchEffect(
|
|
106
|
+
() => {
|
|
107
|
+
if (typeof proFormHeight.value !== "number") return;
|
|
108
|
+
if (props.layout === "grid" && computedExpand.value) {
|
|
109
|
+
const { minExpandRows } = computedExpand.value;
|
|
110
|
+
collapseHeight.value = Math.min(
|
|
111
|
+
minExpandRows * rowHeight + (minExpandRows - 1) * rowGap,
|
|
112
|
+
+proFormHeight.value
|
|
113
|
+
);
|
|
114
|
+
showExpandToggle.value = +proFormHeight.value > collapseHeight.value;
|
|
115
|
+
if (showExpandToggle.value) {
|
|
116
|
+
setInitExpandStatus();
|
|
117
|
+
}
|
|
118
|
+
} else {
|
|
119
|
+
showExpandToggle.value = false;
|
|
168
120
|
}
|
|
169
|
-
}
|
|
170
|
-
|
|
121
|
+
},
|
|
122
|
+
{ flush: "post" }
|
|
123
|
+
);
|
|
171
124
|
const layoutProps = computed(
|
|
172
125
|
() => props.layout === "grid" ? {
|
|
173
126
|
grid: {
|
|
@@ -177,19 +130,19 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
|
177
130
|
style: {
|
|
178
131
|
display: "flex",
|
|
179
132
|
overflow: "hidden",
|
|
180
|
-
height: `${expandStatus.value ? proFormHeight : collapseHeight}px`
|
|
133
|
+
height: `${expandStatus.value ? proFormHeight.value : collapseHeight.value}px`
|
|
181
134
|
}
|
|
182
135
|
} : {
|
|
183
136
|
layout: "inline",
|
|
184
|
-
style: { gap: `${rowGap}px ${columnGap}px` }
|
|
137
|
+
style: { gap: `${rowGap}px ${columnGap}px` },
|
|
138
|
+
grid: false
|
|
185
139
|
}
|
|
186
140
|
);
|
|
187
141
|
return (_ctx, _cache) => {
|
|
188
|
-
return openBlock(), createBlock(unref(_sfc_main$
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
}, layoutProps.value, { class: "pro-form expand-transition" }), {
|
|
142
|
+
return openBlock(), createBlock(unref(_sfc_main$9), mergeProps(layoutProps.value, {
|
|
143
|
+
form: _ctx.form,
|
|
144
|
+
class: "search-form transition"
|
|
145
|
+
}), {
|
|
193
146
|
default: withCtx(() => [
|
|
194
147
|
createVNode(unref(Space), { align: "start" }, {
|
|
195
148
|
default: withCtx(() => [
|
|
@@ -197,9 +150,10 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
|
197
150
|
onClick: _cache[0] || (_cache[0] = ($event) => emit("reset"))
|
|
198
151
|
}, {
|
|
199
152
|
default: withCtx(() => _cache[2] || (_cache[2] = [
|
|
200
|
-
createTextVNode("重置")
|
|
153
|
+
createTextVNode("重置", -1)
|
|
201
154
|
])),
|
|
202
|
-
_: 1
|
|
155
|
+
_: 1,
|
|
156
|
+
__: [2]
|
|
203
157
|
}),
|
|
204
158
|
createVNode(unref(Button), {
|
|
205
159
|
type: "primary",
|
|
@@ -207,20 +161,22 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
|
207
161
|
onClick: _cache[1] || (_cache[1] = ($event) => emit("search"))
|
|
208
162
|
}, {
|
|
209
163
|
default: withCtx(() => _cache[3] || (_cache[3] = [
|
|
210
|
-
createTextVNode(" 查询 ")
|
|
164
|
+
createTextVNode(" 查询 ", -1)
|
|
211
165
|
])),
|
|
212
|
-
_: 1
|
|
166
|
+
_: 1,
|
|
167
|
+
__: [3]
|
|
213
168
|
}),
|
|
214
169
|
showExpandToggle.value ? (openBlock(), createBlock(unref(Button), {
|
|
215
170
|
key: 0,
|
|
216
171
|
type: "link",
|
|
217
|
-
|
|
172
|
+
class: "expand-toggle-button",
|
|
173
|
+
onClick: changeExpandStatus
|
|
218
174
|
}, {
|
|
219
175
|
default: withCtx(() => [
|
|
220
176
|
createTextVNode(toDisplayString(expandStatus.value ? "收起" : "展开") + " ", 1),
|
|
221
|
-
createVNode(
|
|
222
|
-
class: "
|
|
223
|
-
style: normalizeStyle({ transform: `rotate(${expandStatus.value ? -180 : 0}deg)` })
|
|
177
|
+
createVNode(DownOutlined, {
|
|
178
|
+
class: "transition",
|
|
179
|
+
style: normalizeStyle([{ "margin-left": "4px" }, { transform: `rotate(${expandStatus.value ? -180 : 0}deg)` }])
|
|
224
180
|
}, null, 8, ["style"])
|
|
225
181
|
]),
|
|
226
182
|
_: 1
|
|
@@ -234,64 +190,157 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
|
234
190
|
};
|
|
235
191
|
}
|
|
236
192
|
});
|
|
237
|
-
const
|
|
238
|
-
|
|
239
|
-
const
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
193
|
+
const SearchForm = /* @__PURE__ */ _export_sfc(_sfc_main$7, [["__scopeId", "data-v-107a0198"]]);
|
|
194
|
+
function useModel(props, name, options) {
|
|
195
|
+
const eventName = `onUpdate:${name}`;
|
|
196
|
+
const emitUpdate = props[eventName];
|
|
197
|
+
const _modelValue = ref(toValue(options == null ? void 0 : options.default));
|
|
198
|
+
const modelValue = computed({
|
|
199
|
+
get: () => props[name] === void 0 ? _modelValue.value : props[name],
|
|
200
|
+
set: (val) => {
|
|
201
|
+
_modelValue.value = val;
|
|
202
|
+
emitUpdate == null ? void 0 : emitUpdate(val);
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
return modelValue;
|
|
206
|
+
}
|
|
207
|
+
const _sfc_main$6 = {};
|
|
208
|
+
const _hoisted_1$6 = { class: "search-form-container" };
|
|
209
|
+
function _sfc_render$3(_ctx, _cache) {
|
|
210
|
+
return openBlock(), createElementBlock("div", _hoisted_1$6, [
|
|
211
|
+
renderSlot(_ctx.$slots, "default", {}, void 0, true)
|
|
212
|
+
]);
|
|
213
|
+
}
|
|
214
|
+
const DefaultSearchFormContainer = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["render", _sfc_render$3], ["__scopeId", "data-v-5904d9f4"]]);
|
|
215
|
+
const _sfc_main$5 = {};
|
|
216
|
+
const _hoisted_1$5 = { class: "table-container" };
|
|
217
|
+
function _sfc_render$2(_ctx, _cache) {
|
|
218
|
+
return openBlock(), createElementBlock("div", _hoisted_1$5, [
|
|
219
|
+
renderSlot(_ctx.$slots, "default", {}, void 0, true)
|
|
220
|
+
]);
|
|
221
|
+
}
|
|
222
|
+
const DefaultTableContainer = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["render", _sfc_render$2], ["__scopeId", "data-v-f089d734"]]);
|
|
223
|
+
const _sfc_main$4 = {};
|
|
224
|
+
const _hoisted_1$4 = {
|
|
225
|
+
focusable: "false",
|
|
226
|
+
"data-icon": "column-height",
|
|
227
|
+
width: "1em",
|
|
228
|
+
height: "1em",
|
|
229
|
+
fill: "currentColor",
|
|
230
|
+
"aria-hidden": "true",
|
|
231
|
+
viewBox: "64 64 896 896"
|
|
232
|
+
};
|
|
233
|
+
function _sfc_render$1(_ctx, _cache) {
|
|
234
|
+
return openBlock(), createElementBlock("svg", _hoisted_1$4, _cache[0] || (_cache[0] = [
|
|
235
|
+
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)
|
|
236
|
+
]));
|
|
237
|
+
}
|
|
238
|
+
const ColumnHeightOutlined = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["render", _sfc_render$1]]);
|
|
239
|
+
const _hoisted_1$3 = { class: "control-icon" };
|
|
240
|
+
const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
241
|
+
__name: "SizeControl",
|
|
249
242
|
setup(__props) {
|
|
250
|
-
const
|
|
251
|
-
const size = useModel(
|
|
243
|
+
const attrs = useAttrs();
|
|
244
|
+
const size = useModel(attrs, "size", { default: "large" });
|
|
252
245
|
const onSizeChange = (val) => {
|
|
253
246
|
size.value = val.key;
|
|
254
247
|
};
|
|
255
|
-
const checkAll = ref(false);
|
|
256
|
-
const indeterminate = ref(false);
|
|
257
248
|
const sizeOptions = [
|
|
258
249
|
{ label: "默认", key: "large" },
|
|
259
250
|
{ label: "中等", key: "middle" },
|
|
260
251
|
{ label: "紧凑", key: "small" }
|
|
261
252
|
];
|
|
253
|
+
return (_ctx, _cache) => {
|
|
254
|
+
return openBlock(), createBlock(unref(Dropdown), {
|
|
255
|
+
arrow: "",
|
|
256
|
+
placement: "bottomRight"
|
|
257
|
+
}, {
|
|
258
|
+
overlay: withCtx(() => [
|
|
259
|
+
createVNode(unref(Menu), {
|
|
260
|
+
style: { "width": "100px", "text-align": "center" },
|
|
261
|
+
"selected-keys": unref(size) ? [unref(size)] : [],
|
|
262
|
+
items: sizeOptions,
|
|
263
|
+
onClick: onSizeChange
|
|
264
|
+
}, null, 8, ["selected-keys", "items"])
|
|
265
|
+
]),
|
|
266
|
+
default: withCtx(() => [
|
|
267
|
+
createElementVNode("div", _hoisted_1$3, [
|
|
268
|
+
createVNode(ColumnHeightOutlined, { style: { "font-size": "16px" } })
|
|
269
|
+
])
|
|
270
|
+
]),
|
|
271
|
+
_: 1
|
|
272
|
+
});
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
});
|
|
276
|
+
const SizeControl = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-d8e78b5b"]]);
|
|
277
|
+
const _sfc_main$2 = {};
|
|
278
|
+
const _hoisted_1$2 = {
|
|
279
|
+
focusable: "false",
|
|
280
|
+
"data-icon": "filter",
|
|
281
|
+
width: "1em",
|
|
282
|
+
height: "1em",
|
|
283
|
+
fill: "currentColor",
|
|
284
|
+
"aria-hidden": "true",
|
|
285
|
+
viewBox: "64 64 896 896"
|
|
286
|
+
};
|
|
287
|
+
function _sfc_render(_ctx, _cache) {
|
|
288
|
+
return openBlock(), createElementBlock("svg", _hoisted_1$2, _cache[0] || (_cache[0] = [
|
|
289
|
+
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)
|
|
290
|
+
]));
|
|
291
|
+
}
|
|
292
|
+
const FilterOutlined = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["render", _sfc_render]]);
|
|
293
|
+
const _hoisted_1$1 = { class: "control-icon" };
|
|
294
|
+
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
295
|
+
__name: "ColumnControl",
|
|
296
|
+
props: {
|
|
297
|
+
columns: {},
|
|
298
|
+
table: { default: void 0 }
|
|
299
|
+
},
|
|
300
|
+
setup(__props) {
|
|
301
|
+
const props = __props;
|
|
302
|
+
const checkAll = ref(false);
|
|
303
|
+
const indeterminate = ref(false);
|
|
262
304
|
const checkedColumnsOptions = computed(
|
|
263
|
-
() =>
|
|
264
|
-
|
|
265
|
-
return (_a = props.columns) == null ? void 0 : _a.filter((item) => item.key && item.title).map((item) => ({
|
|
305
|
+
() => props.columns.flatMap(
|
|
306
|
+
(item) => item.key && item.title ? {
|
|
266
307
|
label: item.title,
|
|
267
|
-
value: item.key
|
|
268
|
-
|
|
269
|
-
|
|
308
|
+
value: item.key,
|
|
309
|
+
checked: !item.hidden
|
|
310
|
+
} : []
|
|
311
|
+
)
|
|
270
312
|
);
|
|
271
|
-
const
|
|
272
|
-
const checkedColumns = computed({
|
|
313
|
+
const checkedColumnKeys = computed({
|
|
273
314
|
get() {
|
|
274
|
-
|
|
275
|
-
|
|
315
|
+
return checkedColumnsOptions.value.flatMap(
|
|
316
|
+
(item) => item.checked ? item.value : []
|
|
317
|
+
) || [];
|
|
276
318
|
},
|
|
277
319
|
set(val) {
|
|
278
320
|
var _a;
|
|
279
|
-
(_a =
|
|
321
|
+
(_a = checkedColumnsOptions.value) == null ? void 0 : _a.forEach((item) => {
|
|
322
|
+
var _a2, _b;
|
|
323
|
+
(_b = (_a2 = props.table) == null ? void 0 : _a2.setColumn) == null ? void 0 : _b.call(_a2, item.value, {
|
|
324
|
+
hidden: !val.includes(item.value)
|
|
325
|
+
});
|
|
326
|
+
});
|
|
280
327
|
}
|
|
281
328
|
});
|
|
282
329
|
const onCheckAllChange = (e) => {
|
|
283
|
-
|
|
330
|
+
checkedColumnKeys.value = e.target.checked ? checkedColumnsOptions.value.map((item) => item.value) : [];
|
|
284
331
|
indeterminate.value = false;
|
|
285
332
|
};
|
|
286
333
|
const checkColumnsMenuItemClick = (val) => {
|
|
287
|
-
if (
|
|
288
|
-
|
|
334
|
+
if (checkedColumnKeys.value.includes(val)) {
|
|
335
|
+
checkedColumnKeys.value = checkedColumnKeys.value.filter(
|
|
336
|
+
(item) => item !== val
|
|
337
|
+
);
|
|
289
338
|
} else {
|
|
290
|
-
|
|
339
|
+
checkedColumnKeys.value = [...checkedColumnKeys.value, val];
|
|
291
340
|
}
|
|
292
341
|
};
|
|
293
342
|
watch(
|
|
294
|
-
|
|
343
|
+
checkedColumnKeys,
|
|
295
344
|
(val) => {
|
|
296
345
|
indeterminate.value = !!val.length && val.length < checkedColumnsOptions.value.length;
|
|
297
346
|
checkAll.value = val.length === checkedColumnsOptions.value.length;
|
|
@@ -299,324 +348,259 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
|
299
348
|
{ immediate: true }
|
|
300
349
|
);
|
|
301
350
|
return (_ctx, _cache) => {
|
|
302
|
-
return openBlock(), createBlock(unref(
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
}, null, 8, ["selected-keys", "items"])
|
|
315
|
-
]),
|
|
316
|
-
default: withCtx(() => [
|
|
317
|
-
createVNode(unref(ColumnHeightOutlined$1), {
|
|
318
|
-
style: { fontSize: "16px" },
|
|
319
|
-
class: "control-icon"
|
|
320
|
-
})
|
|
321
|
-
]),
|
|
322
|
-
_: 1
|
|
323
|
-
}),
|
|
324
|
-
createVNode(unref(Dropdown), {
|
|
325
|
-
open: checkColumnsVisible.value,
|
|
326
|
-
"onUpdate:open": _cache[1] || (_cache[1] = ($event) => checkColumnsVisible.value = $event),
|
|
327
|
-
arrow: "",
|
|
328
|
-
placement: "bottomRight"
|
|
329
|
-
}, {
|
|
330
|
-
overlay: withCtx(() => [
|
|
331
|
-
createElementVNode("div", null, [
|
|
332
|
-
createVNode(unref(Menu), {
|
|
333
|
-
style: { "min-width": "100px", "max-height": "500px", "overflow-y": "scroll" },
|
|
334
|
-
selectable: false
|
|
335
|
-
}, {
|
|
351
|
+
return openBlock(), createBlock(unref(Dropdown), {
|
|
352
|
+
arrow: "",
|
|
353
|
+
placement: "bottomRight"
|
|
354
|
+
}, {
|
|
355
|
+
overlay: withCtx(() => [
|
|
356
|
+
createElementVNode("div", null, [
|
|
357
|
+
createVNode(unref(Menu), {
|
|
358
|
+
style: { "min-width": "100px", "max-height": "500px", "overflow-y": "scroll" },
|
|
359
|
+
selectable: false
|
|
360
|
+
}, {
|
|
361
|
+
default: withCtx(() => [
|
|
362
|
+
(openBlock(), createBlock(unref(MenuItem), { key: 0 }, {
|
|
336
363
|
default: withCtx(() => [
|
|
337
|
-
(
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
364
|
+
createElementVNode("div", null, [
|
|
365
|
+
createVNode(unref(Checkbox), {
|
|
366
|
+
checked: checkAll.value,
|
|
367
|
+
indeterminate: indeterminate.value,
|
|
368
|
+
onChange: onCheckAllChange
|
|
369
|
+
}, {
|
|
370
|
+
default: withCtx(() => _cache[1] || (_cache[1] = [
|
|
371
|
+
createTextVNode(" 全选 ", -1)
|
|
372
|
+
])),
|
|
373
|
+
_: 1,
|
|
374
|
+
__: [1]
|
|
375
|
+
}, 8, ["checked", "indeterminate"])
|
|
376
|
+
])
|
|
377
|
+
]),
|
|
378
|
+
_: 1
|
|
379
|
+
})),
|
|
380
|
+
createVNode(unref(MenuDivider)),
|
|
381
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(checkedColumnsOptions.value, (item) => {
|
|
382
|
+
return openBlock(), createBlock(unref(MenuItem), {
|
|
383
|
+
key: item.value,
|
|
384
|
+
onClick: ($event) => checkColumnsMenuItemClick(item.value)
|
|
385
|
+
}, {
|
|
386
|
+
default: withCtx(() => [
|
|
387
|
+
createVNode(unref(Checkbox), {
|
|
388
|
+
checked: checkedColumnKeys.value.includes(item.value)
|
|
359
389
|
}, {
|
|
360
390
|
default: withCtx(() => [
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
createElementVNode("div", {
|
|
366
|
-
onClick: _cache[0] || (_cache[0] = withModifiers(() => {
|
|
367
|
-
}, ["stop"]))
|
|
368
|
-
}, toDisplayString(item.label), 1)
|
|
369
|
-
]),
|
|
370
|
-
_: 2
|
|
371
|
-
}, 1032, ["checked"])
|
|
391
|
+
createElementVNode("div", {
|
|
392
|
+
onClick: _cache[0] || (_cache[0] = withModifiers(() => {
|
|
393
|
+
}, ["stop"]))
|
|
394
|
+
}, toDisplayString(item.label), 1)
|
|
372
395
|
]),
|
|
373
396
|
_: 2
|
|
374
|
-
}, 1032, ["
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
})
|
|
379
|
-
])
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
}, 8, ["open"])
|
|
397
|
+
}, 1032, ["checked"])
|
|
398
|
+
]),
|
|
399
|
+
_: 2
|
|
400
|
+
}, 1032, ["onClick"]);
|
|
401
|
+
}), 128))
|
|
402
|
+
]),
|
|
403
|
+
_: 1
|
|
404
|
+
})
|
|
405
|
+
])
|
|
406
|
+
]),
|
|
407
|
+
default: withCtx(() => [
|
|
408
|
+
createElementVNode("div", _hoisted_1$1, [
|
|
409
|
+
createVNode(FilterOutlined, { style: { "font-size": "17px" } })
|
|
410
|
+
])
|
|
389
411
|
]),
|
|
390
412
|
_: 1
|
|
391
413
|
});
|
|
392
414
|
};
|
|
393
415
|
}
|
|
394
416
|
});
|
|
395
|
-
const
|
|
396
|
-
const
|
|
397
|
-
const
|
|
398
|
-
const _sfc_main$3 = {};
|
|
399
|
-
const _hoisted_1$3 = { class: "search-container" };
|
|
400
|
-
function _sfc_render$2(_ctx, _cache) {
|
|
401
|
-
return openBlock(), createElementBlock("div", _hoisted_1$3, [
|
|
402
|
-
renderSlot(_ctx.$slots, "default", {}, void 0, true)
|
|
403
|
-
]);
|
|
404
|
-
}
|
|
405
|
-
const DefaultSearchContainer = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["render", _sfc_render$2], ["__scopeId", "data-v-c00ace37"]]);
|
|
406
|
-
const DefaultTableContainer_vue_vue_type_style_index_0_scoped_db2f53ee_lang = "";
|
|
407
|
-
const _sfc_main$2 = {};
|
|
408
|
-
const _hoisted_1$2 = { class: "table-container" };
|
|
409
|
-
function _sfc_render$1(_ctx, _cache) {
|
|
410
|
-
return openBlock(), createElementBlock("div", _hoisted_1$2, [
|
|
411
|
-
renderSlot(_ctx.$slots, "default", {}, void 0, true)
|
|
412
|
-
]);
|
|
413
|
-
}
|
|
414
|
-
const DefaultTableContainer = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["render", _sfc_render$1], ["__scopeId", "data-v-db2f53ee"]]);
|
|
415
|
-
const DefaultControlContainer_vue_vue_type_style_index_0_scoped_1d26ef2f_lang = "";
|
|
416
|
-
const _sfc_main$1 = {};
|
|
417
|
-
const _hoisted_1$1 = { class: "control-container" };
|
|
418
|
-
function _sfc_render(_ctx, _cache) {
|
|
419
|
-
return openBlock(), createElementBlock("div", _hoisted_1$1, [
|
|
420
|
-
renderSlot(_ctx.$slots, "default", {}, void 0, true)
|
|
421
|
-
]);
|
|
422
|
-
}
|
|
423
|
-
const DefaultControlContainer = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render], ["__scopeId", "data-v-1d26ef2f"]]);
|
|
424
|
-
const _hoisted_1 = {
|
|
417
|
+
const ColumnControl = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-88c80679"]]);
|
|
418
|
+
const _hoisted_1 = { class: "pro-table-header" };
|
|
419
|
+
const _hoisted_2 = {
|
|
425
420
|
key: 0,
|
|
426
421
|
style: { "flex": "1" }
|
|
427
422
|
};
|
|
423
|
+
const _hoisted_3 = {
|
|
424
|
+
key: 1,
|
|
425
|
+
style: { "margin-left": "12px" }
|
|
426
|
+
};
|
|
427
|
+
const _hoisted_4 = {
|
|
428
|
+
key: 2,
|
|
429
|
+
style: { "margin-left": "12px" }
|
|
430
|
+
};
|
|
431
|
+
const _hoisted_5 = {
|
|
432
|
+
key: 3,
|
|
433
|
+
style: { "margin-left": "12px" }
|
|
434
|
+
};
|
|
428
435
|
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
429
|
-
...{
|
|
430
|
-
|
|
431
|
-
inheritAttrs: false
|
|
432
|
-
},
|
|
433
|
-
__name: "Table",
|
|
436
|
+
...{ name: "ProTable", inheritAttrs: false },
|
|
437
|
+
__name: "BaseTable",
|
|
434
438
|
props: {
|
|
435
439
|
table: { default: void 0 },
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
immediateSearch: { type: Boolean, default: false },
|
|
443
|
-
searchFormConfig: { default: void 0 }
|
|
440
|
+
search: { type: Function, default: void 0 },
|
|
441
|
+
addIndexColumn: { type: Boolean, default: void 0 },
|
|
442
|
+
immediateSearch: { type: Boolean, default: void 0 },
|
|
443
|
+
control: { type: [Boolean, Object], default: void 0 },
|
|
444
|
+
searchFormConfig: { default: void 0 },
|
|
445
|
+
tableContainer: { default: DefaultTableContainer }
|
|
444
446
|
},
|
|
445
|
-
|
|
446
|
-
setup(__props, { emit: __emit }) {
|
|
447
|
-
var _a, _b, _c, _d, _e, _f;
|
|
447
|
+
setup(__props) {
|
|
448
448
|
const props = __props;
|
|
449
|
-
const
|
|
450
|
-
const
|
|
451
|
-
const
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
pageSize
|
|
477
|
-
});
|
|
478
|
-
cache == null ? void 0 : cache.set(
|
|
479
|
-
(pre = {}) => cloneDeep({
|
|
480
|
-
...pre,
|
|
481
|
-
pagination: unref(pagination),
|
|
482
|
-
searchParam: unref(searchParam)
|
|
483
|
-
})
|
|
484
|
-
);
|
|
449
|
+
const config = INJECT_CONFIG["pro-table"];
|
|
450
|
+
const injectProps = inject(config.injectionKey, config.default);
|
|
451
|
+
const injectAttrs = pick(
|
|
452
|
+
injectProps,
|
|
453
|
+
Object.keys(tableProps())
|
|
454
|
+
);
|
|
455
|
+
const computedSearchFormConfig = computed(() => {
|
|
456
|
+
return {
|
|
457
|
+
container: DefaultSearchFormContainer,
|
|
458
|
+
...injectProps.searchFormConfig,
|
|
459
|
+
...getObject(props.searchFormConfig)
|
|
460
|
+
};
|
|
461
|
+
});
|
|
462
|
+
const attrs = pick(useAttrs(), Object.keys(tableProps()));
|
|
463
|
+
const { columns, dataSource, searchForm, pageParam, setPageParam } = props.table || {};
|
|
464
|
+
const size = useModel(attrs, "size");
|
|
465
|
+
const loading = useModel(attrs, "loading");
|
|
466
|
+
const _search = async () => {
|
|
467
|
+
var _a;
|
|
468
|
+
const { current = 0, pageSize = 0 } = pageParam || {};
|
|
469
|
+
const param = { ...searchForm == null ? void 0 : searchForm.formData, current, pageSize };
|
|
470
|
+
try {
|
|
471
|
+
loading.value = true;
|
|
472
|
+
await ((_a = props.search) == null ? void 0 : _a.call(props, param));
|
|
473
|
+
} finally {
|
|
474
|
+
loading.value = false;
|
|
475
|
+
}
|
|
485
476
|
};
|
|
486
477
|
const reset = () => {
|
|
487
|
-
var
|
|
488
|
-
(
|
|
478
|
+
var _a;
|
|
479
|
+
(_a = props.table) == null ? void 0 : _a.resetQueryParams();
|
|
489
480
|
nextTick(() => {
|
|
490
|
-
|
|
481
|
+
_search();
|
|
491
482
|
});
|
|
492
483
|
};
|
|
493
484
|
const slots = useSlots();
|
|
494
|
-
const
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
setPagination({
|
|
503
|
-
...unref(pagination),
|
|
504
|
-
...unref(((_e = cache.get()) == null ? void 0 : _e.pagination) ?? {})
|
|
505
|
-
});
|
|
506
|
-
setSearchParam({
|
|
507
|
-
...unref(searchParam),
|
|
508
|
-
...unref(((_f = cache.get()) == null ? void 0 : _f.searchParam) ?? {})
|
|
509
|
-
});
|
|
510
|
-
}
|
|
485
|
+
const {
|
|
486
|
+
"search-form": searchFormSlot,
|
|
487
|
+
"button-bar": buttonBarSlot,
|
|
488
|
+
toolbar: toolbarSlot,
|
|
489
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
490
|
+
table: tableSlot,
|
|
491
|
+
...tableSlots
|
|
492
|
+
} = slots;
|
|
511
493
|
const searchPage1st = () => {
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
(_a2 = props.table) == null ? void 0 : _a2.setPagination({ ...props.table.pagination.value, current: 1 });
|
|
515
|
-
search();
|
|
516
|
-
}
|
|
494
|
+
setPageParam == null ? void 0 : setPageParam({ current: 1 });
|
|
495
|
+
_search();
|
|
517
496
|
};
|
|
518
|
-
const
|
|
519
|
-
return {
|
|
520
|
-
...injectAttrs,
|
|
521
|
-
...attrs,
|
|
522
|
-
columns: (attrs.columns ?? (columns == null ? void 0 : columns.value) ?? []).map(
|
|
523
|
-
(item, index) => ({
|
|
524
|
-
...item,
|
|
525
|
-
key: item.key ?? item.dataIndex.toString() ?? index
|
|
526
|
-
})
|
|
527
|
-
),
|
|
528
|
-
dataSource: attrs.dataSource ?? (dataSource == null ? void 0 : dataSource.value),
|
|
529
|
-
pagination: attrs.pagination ?? {
|
|
530
|
-
showTotal: (total) => `共 ${total} 条`,
|
|
531
|
-
showSizeChanger: true,
|
|
532
|
-
pageSizeOptions: ["10", "20", "30", "40", "50", "100"],
|
|
533
|
-
showQuickJumper: true,
|
|
534
|
-
...pagination == null ? void 0 : pagination.value
|
|
535
|
-
},
|
|
536
|
-
onChange: table ? (...args) => {
|
|
537
|
-
var _a2;
|
|
538
|
-
setPagination(args[0]);
|
|
539
|
-
(_a2 = attrs.onChange) == null ? void 0 : _a2.call(attrs, ...args);
|
|
540
|
-
search();
|
|
541
|
-
} : attrs.onChange
|
|
542
|
-
};
|
|
497
|
+
const computedTableProps = computed(() => {
|
|
498
|
+
return { ...injectAttrs, ...attrs, onChange: void 0 };
|
|
543
499
|
});
|
|
544
500
|
const indexColumn = {
|
|
545
501
|
title: "序号",
|
|
546
|
-
dataIndex: "
|
|
502
|
+
dataIndex: "_index",
|
|
547
503
|
width: 80,
|
|
548
504
|
customRender: ({ index }) => index + 1
|
|
549
505
|
};
|
|
550
|
-
const
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
506
|
+
const computedColumns = computed(() => [
|
|
507
|
+
...props.addIndexColumn ?? injectProps.addIndexColumn ? [indexColumn] : [],
|
|
508
|
+
...(attrs.columns ?? (columns == null ? void 0 : columns.value) ?? []).flatMap(
|
|
509
|
+
(item, index) => {
|
|
510
|
+
if (item.key) return [{ ...item, key: item.key }];
|
|
511
|
+
if (item.dataIndex) {
|
|
512
|
+
const dataIndexKey = Array.isArray(item.dataIndex) ? item.dataIndex.join(".") : item.dataIndex;
|
|
513
|
+
return [{ ...item, key: dataIndexKey }];
|
|
514
|
+
}
|
|
515
|
+
return [{ ...item, key: index }];
|
|
516
|
+
}
|
|
517
|
+
)
|
|
518
|
+
]);
|
|
519
|
+
const visibleComputedColumns = computed(() => {
|
|
520
|
+
return computedColumns.value.filter((item) => !item.hidden);
|
|
521
|
+
});
|
|
522
|
+
const computedDataSource = computed(() => {
|
|
523
|
+
return attrs.dataSource ?? (dataSource == null ? void 0 : dataSource.value);
|
|
524
|
+
});
|
|
525
|
+
const computedPagination = computed(() => {
|
|
526
|
+
if (attrs.pagination === false) return false;
|
|
527
|
+
return { ...injectAttrs.pagination, ...pageParam, ...attrs.pagination };
|
|
528
|
+
});
|
|
529
|
+
const onTableChange = (...args) => {
|
|
530
|
+
var _a;
|
|
531
|
+
setPageParam == null ? void 0 : setPageParam(args[0]);
|
|
532
|
+
(_a = attrs.onChange) == null ? void 0 : _a.call(attrs, ...args);
|
|
533
|
+
_search();
|
|
534
|
+
};
|
|
535
|
+
const showSearch = computed(() => {
|
|
536
|
+
var _a, _b;
|
|
537
|
+
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);
|
|
538
|
+
});
|
|
539
|
+
const computedControl = computed(() => {
|
|
540
|
+
const control = props.control ?? injectProps.control;
|
|
541
|
+
const sizeControl = (control == null ? void 0 : control.sizeControl) ?? control;
|
|
542
|
+
const columnControl = (control == null ? void 0 : control.columnControl) ?? control;
|
|
543
|
+
return { sizeControl, columnControl };
|
|
564
544
|
});
|
|
565
|
-
const showSearch = computed(() => toValue(form.fields).length > 0);
|
|
566
545
|
onMounted(() => {
|
|
567
546
|
if (props.immediateSearch ?? injectProps.immediateSearch) {
|
|
568
|
-
|
|
547
|
+
_search();
|
|
569
548
|
}
|
|
570
549
|
});
|
|
571
550
|
return (_ctx, _cache) => {
|
|
572
551
|
return openBlock(), createElementBlock("div", {
|
|
573
|
-
class: "pro-table",
|
|
552
|
+
class: normalizeClass(["pro-table", _ctx.$attrs.class]),
|
|
574
553
|
style: normalizeStyle(_ctx.$attrs.style)
|
|
575
554
|
}, [
|
|
576
|
-
showSearch.value ? (openBlock(), createBlock(unref(_sfc_main$
|
|
555
|
+
showSearch.value ? (openBlock(), createBlock(unref(_sfc_main$a), {
|
|
577
556
|
key: 0,
|
|
578
|
-
component:
|
|
557
|
+
component: computedSearchFormConfig.value.container
|
|
579
558
|
}, {
|
|
580
559
|
default: withCtx(() => [
|
|
581
|
-
renderSlot(_ctx.$slots, "search", {}, () => [
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
},
|
|
560
|
+
renderSlot(_ctx.$slots, "search-form", {}, () => [
|
|
561
|
+
unref(searchForm) ? (openBlock(), createBlock(SearchForm, mergeProps({
|
|
562
|
+
key: 0,
|
|
563
|
+
form: unref(searchForm)
|
|
564
|
+
}, computedSearchFormConfig.value, {
|
|
586
565
|
onSearch: searchPage1st,
|
|
587
566
|
onReset: reset
|
|
588
|
-
}), null, 16, ["form"
|
|
567
|
+
}), null, 16, ["form"])) : createCommentVNode("", true)
|
|
589
568
|
], true)
|
|
590
569
|
]),
|
|
591
570
|
_: 3
|
|
592
571
|
}, 8, ["component"])) : createCommentVNode("", true),
|
|
593
|
-
unref(
|
|
594
|
-
key: 1,
|
|
595
|
-
component: _ctx.controlContainer
|
|
596
|
-
}, {
|
|
597
|
-
default: withCtx(() => [
|
|
598
|
-
Object.hasOwn(_ctx.$slots, "buttons") ? (openBlock(), createElementBlock("div", _hoisted_1, [
|
|
599
|
-
renderSlot(_ctx.$slots, "buttons", {}, void 0, true)
|
|
600
|
-
])) : createCommentVNode("", true),
|
|
601
|
-
unref(showControl) ? (openBlock(), createBlock(unref(Control), {
|
|
602
|
-
key: 1,
|
|
603
|
-
size: size.value,
|
|
604
|
-
"onUpdate:size": _cache[0] || (_cache[0] = ($event) => size.value = $event),
|
|
605
|
-
columns: mergeTableProps.value.columns,
|
|
606
|
-
table: unref(table)
|
|
607
|
-
}, null, 8, ["size", "columns", "table"])) : createCommentVNode("", true)
|
|
608
|
-
]),
|
|
609
|
-
_: 3
|
|
610
|
-
}, 8, ["component"])) : createCommentVNode("", true),
|
|
611
|
-
createVNode(unref(_sfc_main$7), { component: _ctx.tableContainer }, {
|
|
572
|
+
createVNode(unref(_sfc_main$a), { component: _ctx.tableContainer }, {
|
|
612
573
|
default: withCtx(() => [
|
|
574
|
+
createElementVNode("div", _hoisted_1, [
|
|
575
|
+
unref(buttonBarSlot) ? (openBlock(), createElementBlock("div", _hoisted_2, [
|
|
576
|
+
renderSlot(_ctx.$slots, "button-bar", {}, void 0, true)
|
|
577
|
+
])) : createCommentVNode("", true),
|
|
578
|
+
unref(toolbarSlot) ? (openBlock(), createElementBlock("div", _hoisted_3, [
|
|
579
|
+
renderSlot(_ctx.$slots, "toolbar", {}, void 0, true)
|
|
580
|
+
])) : createCommentVNode("", true),
|
|
581
|
+
computedControl.value.sizeControl ? (openBlock(), createElementBlock("div", _hoisted_4, [
|
|
582
|
+
createVNode(unref(SizeControl), {
|
|
583
|
+
size: unref(size),
|
|
584
|
+
"onUpdate:size": _cache[0] || (_cache[0] = ($event) => isRef(size) ? size.value = $event : null)
|
|
585
|
+
}, null, 8, ["size"])
|
|
586
|
+
])) : createCommentVNode("", true),
|
|
587
|
+
computedControl.value.columnControl ? (openBlock(), createElementBlock("div", _hoisted_5, [
|
|
588
|
+
createVNode(unref(ColumnControl), {
|
|
589
|
+
columns: computedColumns.value,
|
|
590
|
+
table: props.table
|
|
591
|
+
}, null, 8, ["columns", "table"])
|
|
592
|
+
])) : createCommentVNode("", true)
|
|
593
|
+
]),
|
|
613
594
|
renderSlot(_ctx.$slots, "table", {}, () => [
|
|
614
|
-
createVNode(unref(Table), mergeProps(
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
595
|
+
createVNode(unref(Table), mergeProps({ class: "pro-table-content" }, computedTableProps.value, {
|
|
596
|
+
size: unref(size),
|
|
597
|
+
loading: unref(loading),
|
|
598
|
+
columns: visibleComputedColumns.value,
|
|
599
|
+
"data-source": computedDataSource.value,
|
|
600
|
+
pagination: computedPagination.value,
|
|
601
|
+
onChange: onTableChange
|
|
618
602
|
}), createSlots({ _: 2 }, [
|
|
619
|
-
renderList(
|
|
603
|
+
renderList(tableSlots, (_, name) => {
|
|
620
604
|
return {
|
|
621
605
|
name,
|
|
622
606
|
fn: withCtx((scoped) => [
|
|
@@ -624,82 +608,138 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
624
608
|
])
|
|
625
609
|
};
|
|
626
610
|
})
|
|
627
|
-
]), 1040, ["columns", "
|
|
611
|
+
]), 1040, ["size", "loading", "columns", "data-source", "pagination"])
|
|
628
612
|
], true)
|
|
629
613
|
]),
|
|
630
614
|
_: 3
|
|
631
615
|
}, 8, ["component"])
|
|
632
|
-
],
|
|
616
|
+
], 6);
|
|
633
617
|
};
|
|
634
618
|
}
|
|
635
619
|
});
|
|
636
|
-
const
|
|
637
|
-
const
|
|
638
|
-
const
|
|
639
|
-
const useTable = ({
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
}
|
|
647
|
-
const _initSearchParam = cloneDeep(
|
|
648
|
-
const columns = ref(
|
|
620
|
+
const BaseTable = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-6701f35a"]]);
|
|
621
|
+
const getDefaultPageParam = () => ({ current: 1, pageSize: 10, total: 0 });
|
|
622
|
+
const pageParamProperty = ["current", "pageSize", "total"];
|
|
623
|
+
const useTable = (params) => {
|
|
624
|
+
const {
|
|
625
|
+
columns: initColumns = [],
|
|
626
|
+
dataSource: initDataSource = [],
|
|
627
|
+
pageParam: initPageParam = getDefaultPageParam(),
|
|
628
|
+
searchParam: initSearchParam = {},
|
|
629
|
+
searchFields: initSearchFields = []
|
|
630
|
+
} = params;
|
|
631
|
+
const _initSearchParam = cloneDeep(toValue(initSearchParam));
|
|
632
|
+
const columns = ref([]);
|
|
633
|
+
columns.value = initColumns;
|
|
649
634
|
const dataSource = ref(initDataSource);
|
|
650
|
-
const
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
635
|
+
const pageParam = reactive(initPageParam);
|
|
636
|
+
const setPageParam = (pa) => {
|
|
637
|
+
let newPageParam = pa;
|
|
638
|
+
if (typeof pa === "function") {
|
|
639
|
+
newPageParam = pa(pageParam);
|
|
640
|
+
}
|
|
641
|
+
Object.assign(pageParam, pick(newPageParam, pageParamProperty));
|
|
642
|
+
};
|
|
643
|
+
const searchForm = useForm(initSearchParam, initSearchFields, true);
|
|
644
|
+
const resetQueryParams = () => {
|
|
645
|
+
Object.assign(pageParam, getDefaultPageParam());
|
|
646
|
+
searchForm.setFormData(cloneDeep(_initSearchParam));
|
|
647
|
+
};
|
|
648
|
+
const updaterMatch = (key, updater, options = {}) => {
|
|
649
|
+
if (!key) return;
|
|
650
|
+
const { all = typeof key === "function" } = options;
|
|
651
|
+
for (let i = 0; i < columns.value.length; i++) {
|
|
652
|
+
const columnItem = columns.value[i];
|
|
653
|
+
let matched = false;
|
|
654
|
+
if (typeof key === "function") {
|
|
655
|
+
matched = key(columnItem);
|
|
656
|
+
} else if (columnItem.key) {
|
|
657
|
+
matched = columnItem.key === key;
|
|
658
|
+
} else if (columnItem.dataIndex) {
|
|
659
|
+
const dataIndexKey = Array.isArray(columnItem.dataIndex) ? columnItem.dataIndex.join(".") : columnItem.dataIndex;
|
|
660
|
+
matched = dataIndexKey === key;
|
|
661
|
+
} else {
|
|
662
|
+
matched = key === i;
|
|
655
663
|
}
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
664
|
+
if (matched) {
|
|
665
|
+
updater({
|
|
666
|
+
column: columnItem,
|
|
667
|
+
columnIndex: i,
|
|
668
|
+
group: columns.value
|
|
669
|
+
});
|
|
670
|
+
if (!all) return;
|
|
663
671
|
}
|
|
664
|
-
|
|
665
|
-
});
|
|
666
|
-
const setShowColumnKeys = (val) => {
|
|
667
|
-
showColumnKeys.value = val;
|
|
668
|
-
};
|
|
669
|
-
const pagination = ref(initPagination);
|
|
670
|
-
const setPagination = (val) => {
|
|
671
|
-
pagination.value = val;
|
|
672
|
+
}
|
|
672
673
|
};
|
|
673
|
-
const
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
674
|
+
const setColumn = (key, column, options) => {
|
|
675
|
+
if (!key || !column) return;
|
|
676
|
+
const { updateType = "merge", ...rest } = options || {};
|
|
677
|
+
updaterMatch(
|
|
678
|
+
key,
|
|
679
|
+
({ column: preColumn, columnIndex, group }) => {
|
|
680
|
+
let value = column;
|
|
681
|
+
if (typeof column === "function") {
|
|
682
|
+
value = column(preColumn);
|
|
683
|
+
}
|
|
684
|
+
if (!value) return;
|
|
685
|
+
if (updateType === "rewrite") {
|
|
686
|
+
group[columnIndex] = value;
|
|
687
|
+
} else {
|
|
688
|
+
Object.assign(preColumn, value);
|
|
689
|
+
}
|
|
690
|
+
},
|
|
691
|
+
rest
|
|
692
|
+
);
|
|
685
693
|
};
|
|
694
|
+
function deleteColumn(path, options) {
|
|
695
|
+
if (!path) return;
|
|
696
|
+
updaterMatch(
|
|
697
|
+
path,
|
|
698
|
+
({ columnIndex, group }) => {
|
|
699
|
+
group.splice(columnIndex, 1);
|
|
700
|
+
},
|
|
701
|
+
options
|
|
702
|
+
);
|
|
703
|
+
}
|
|
704
|
+
function addColumns(path, newColumns, options, placement) {
|
|
705
|
+
if (newColumns.length === 0) return;
|
|
706
|
+
if (path) {
|
|
707
|
+
updaterMatch(
|
|
708
|
+
path,
|
|
709
|
+
({ columnIndex, group }) => {
|
|
710
|
+
const index = placement === "after" ? columnIndex + 1 : columnIndex;
|
|
711
|
+
group.splice(index, 0, ...newColumns);
|
|
712
|
+
},
|
|
713
|
+
options
|
|
714
|
+
);
|
|
715
|
+
} else if (placement === "after") {
|
|
716
|
+
columns.value.push(...newColumns);
|
|
717
|
+
} else {
|
|
718
|
+
columns.value.unshift(...newColumns);
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
function appendColumn(path, column, options) {
|
|
722
|
+
const newColumns = Array.isArray(column) ? column : [column];
|
|
723
|
+
addColumns(path, newColumns, options, "after");
|
|
724
|
+
}
|
|
725
|
+
function prependColumn(path, column, options) {
|
|
726
|
+
const newColumns = Array.isArray(column) ? column : [column];
|
|
727
|
+
addColumns(path, newColumns, options, "before");
|
|
728
|
+
}
|
|
686
729
|
return {
|
|
687
730
|
columns,
|
|
688
731
|
dataSource,
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
setShowColumnKeys,
|
|
697
|
-
setPagination,
|
|
732
|
+
pageParam,
|
|
733
|
+
searchForm,
|
|
734
|
+
setColumn,
|
|
735
|
+
deleteColumn,
|
|
736
|
+
appendColumn,
|
|
737
|
+
prependColumn,
|
|
738
|
+
setPageParam,
|
|
698
739
|
resetQueryParams
|
|
699
740
|
};
|
|
700
741
|
};
|
|
701
|
-
const useTable$1 = useTable;
|
|
702
742
|
export {
|
|
703
743
|
BaseTable as default,
|
|
704
|
-
useTable
|
|
744
|
+
useTable
|
|
705
745
|
};
|