@aplus-frontend/ui 0.1.28 → 0.1.29
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/src/ap-field/date-range/index.vue.mjs +154 -109
- package/es/src/ap-field/interface.d.ts +4 -0
- package/es/src/ap-field/select/index.vue.mjs +4 -2
- package/es/src/ap-form/style/ap-form-item.css +2 -0
- package/es/src/ap-table/components/setting/modal/index.vue2.mjs +72 -97
- package/es/src/ap-table/components/setting/select-group/index.vue2.mjs +37 -33
- package/es/src/ap-table/components/setting/sorter/index.vue2.mjs +91 -87
- package/es/src/ap-table/components/setting/utils.d.ts +7 -1
- package/es/src/ap-table/components/setting/utils.mjs +37 -22
- package/es/src/ap-table/constants.d.ts +12 -0
- package/es/src/ap-table/hooks/use-table-column-state.d.ts +6 -2
- package/es/src/ap-table/hooks/use-table-column-state.mjs +101 -33
- package/es/src/ap-table/interface.d.ts +8 -1
- package/es/src/editable-table/form-item.vue.d.ts +1 -0
- package/es/src/editable-table/form-item.vue.mjs +63 -59
- package/es/src/editable-table/index.vue.d.ts +1 -0
- package/es/src/editable-table/index.vue.mjs +77 -72
- package/es/src/editable-table/interface.d.ts +6 -0
- package/es/src/theme/ap-form/ap-form-item.css +2 -0
- package/lib/src/ap-field/date-range/index.vue.js +1 -1
- package/lib/src/ap-field/interface.d.ts +4 -0
- package/lib/src/ap-field/select/index.vue.js +1 -1
- package/lib/src/ap-form/style/ap-form-item.css +2 -0
- package/lib/src/ap-table/components/setting/modal/index.vue2.js +1 -1
- package/lib/src/ap-table/components/setting/select-group/index.vue2.js +1 -1
- package/lib/src/ap-table/components/setting/sorter/index.vue2.js +1 -1
- package/lib/src/ap-table/components/setting/utils.d.ts +7 -1
- package/lib/src/ap-table/components/setting/utils.js +1 -1
- package/lib/src/ap-table/constants.d.ts +12 -0
- package/lib/src/ap-table/hooks/use-table-column-state.d.ts +6 -2
- package/lib/src/ap-table/hooks/use-table-column-state.js +1 -1
- package/lib/src/ap-table/interface.d.ts +8 -1
- package/lib/src/editable-table/form-item.vue.d.ts +1 -0
- package/lib/src/editable-table/form-item.vue.js +1 -1
- package/lib/src/editable-table/index.vue.d.ts +1 -0
- package/lib/src/editable-table/index.vue.js +1 -1
- package/lib/src/editable-table/interface.d.ts +6 -0
- package/lib/src/theme/ap-form/ap-form-item.css +2 -0
- package/package.json +1 -1
|
@@ -1,46 +1,114 @@
|
|
|
1
|
-
import { ref as
|
|
2
|
-
import { isDef as
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { ref as _, unref as i, computed as j, watchEffect as z } from "vue";
|
|
2
|
+
import { isDef as D } from "../../utils/index.mjs";
|
|
3
|
+
import G, { customCloneColumnStates as k, getColumnStateString as R } from "../components/setting/utils.mjs";
|
|
4
|
+
import { useInjectApTable as W } from "../context.mjs";
|
|
5
|
+
import { isObject as v, mergeWith as E, isBoolean as X, omit as q, isNumber as N } from "lodash-unified";
|
|
6
|
+
function f(r, o) {
|
|
7
|
+
r.forEach((t) => {
|
|
8
|
+
var c;
|
|
9
|
+
o(t), (c = t.children) != null && c.length && f(t.children, o);
|
|
7
10
|
});
|
|
8
11
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
function H(r, o) {
|
|
13
|
+
if (!o)
|
|
14
|
+
return {};
|
|
15
|
+
const t = r.getItem(o);
|
|
16
|
+
return t ? JSON.parse(t) : {};
|
|
17
|
+
}
|
|
18
|
+
function I(r, o) {
|
|
19
|
+
if (v(r) && v(o))
|
|
20
|
+
return E({}, r, o, I);
|
|
21
|
+
}
|
|
22
|
+
const B = Number.MAX_SAFE_INTEGER, Z = (r, o) => {
|
|
23
|
+
const t = _(o);
|
|
24
|
+
let c = k(o);
|
|
25
|
+
const { columnsBackup: h, updateColumns: u } = W(), T = r.persistenceType || "localStorage", S = window[T];
|
|
26
|
+
function F() {
|
|
27
|
+
const e = H(
|
|
28
|
+
S,
|
|
29
|
+
r.persistenceKey
|
|
30
|
+
), n = E(
|
|
31
|
+
{},
|
|
32
|
+
r.defaultValue || {},
|
|
33
|
+
e,
|
|
34
|
+
I
|
|
35
|
+
), l = i(h);
|
|
36
|
+
function b(M, d, x) {
|
|
37
|
+
return M.map((s) => {
|
|
38
|
+
var A;
|
|
39
|
+
const a = (d == null ? void 0 : d[s.key]) || {}, m = {
|
|
40
|
+
key: s.key,
|
|
41
|
+
label: s.title,
|
|
42
|
+
show: !0,
|
|
43
|
+
fixed: x ? x.fixed : X(s.fixed) ? s.fixed ? "left" : void 0 : s.fixed,
|
|
44
|
+
disabled: !1,
|
|
45
|
+
...q(a, "children")
|
|
46
|
+
};
|
|
47
|
+
return m.children = (A = s.children) != null && A.length ? b(
|
|
48
|
+
s.children,
|
|
49
|
+
a.children,
|
|
50
|
+
m
|
|
51
|
+
) : void 0, m;
|
|
52
|
+
}).sort(
|
|
53
|
+
(s, a) => (N(s.order) ? s.order : B) - (N(a.order) ? a.order : B)
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
return b(l || [], n);
|
|
57
|
+
}
|
|
58
|
+
const g = j(() => i(t).every((e) => e.show));
|
|
59
|
+
function p() {
|
|
60
|
+
const e = i(t);
|
|
61
|
+
f(e, (n) => {
|
|
62
|
+
!n.disabled && (n.show = !0);
|
|
15
63
|
});
|
|
16
64
|
}
|
|
17
|
-
function
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
!
|
|
65
|
+
function C() {
|
|
66
|
+
const e = i(t);
|
|
67
|
+
f(e, (n) => {
|
|
68
|
+
!n.disabled && (n.show = !1);
|
|
21
69
|
});
|
|
22
70
|
}
|
|
23
|
-
function
|
|
24
|
-
|
|
71
|
+
function O() {
|
|
72
|
+
i(g) ? C() : p();
|
|
25
73
|
}
|
|
26
|
-
function
|
|
27
|
-
|
|
28
|
-
|
|
74
|
+
function K(e, n) {
|
|
75
|
+
f(i(t), (l) => {
|
|
76
|
+
l.key === e && (l.show = D(n) ? n : !l.show);
|
|
29
77
|
});
|
|
30
78
|
}
|
|
31
|
-
function
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
79
|
+
function w(e) {
|
|
80
|
+
t.value = e;
|
|
81
|
+
}
|
|
82
|
+
function J(e) {
|
|
83
|
+
c = e;
|
|
84
|
+
}
|
|
85
|
+
function y(e) {
|
|
86
|
+
if (r.persistenceKey) {
|
|
87
|
+
const n = R(e);
|
|
88
|
+
S.setItem(r.persistenceKey, JSON.stringify(n));
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return z(() => {
|
|
92
|
+
const e = F();
|
|
93
|
+
w(e), u == null || u(
|
|
94
|
+
G(
|
|
95
|
+
i(h),
|
|
96
|
+
i(e)
|
|
97
|
+
)
|
|
98
|
+
), c = k(e), y(e);
|
|
99
|
+
}), {
|
|
100
|
+
columnState: t,
|
|
101
|
+
selectAll: p,
|
|
102
|
+
unSelectAll: C,
|
|
103
|
+
toggleSelect: K,
|
|
104
|
+
setColumnState: w,
|
|
105
|
+
isAllSelected: g,
|
|
106
|
+
toggleSelectAll: O,
|
|
107
|
+
columnStateBackup: c,
|
|
108
|
+
setColumnStateBackup: J,
|
|
109
|
+
cacheColumnStateIfNeeded: y
|
|
42
110
|
};
|
|
43
111
|
};
|
|
44
112
|
export {
|
|
45
|
-
|
|
113
|
+
Z as useTableColumnState
|
|
46
114
|
};
|
|
@@ -84,7 +84,7 @@ export type ApTableSettingType = {
|
|
|
84
84
|
/**
|
|
85
85
|
* 列的默认状态
|
|
86
86
|
*/
|
|
87
|
-
defaultValue?:
|
|
87
|
+
defaultValue?: ApTableSettingDefaultValueType;
|
|
88
88
|
/**
|
|
89
89
|
* 列状态变更时的回调(注意,返回的是全量状态)
|
|
90
90
|
* @param val
|
|
@@ -92,6 +92,9 @@ export type ApTableSettingType = {
|
|
|
92
92
|
*/
|
|
93
93
|
onChange?: (val: ApColumnState[]) => void;
|
|
94
94
|
};
|
|
95
|
+
export type ApTableSettingDefaultValueType = Recordable<Omit<ApColumnState, 'label' | 'key' | 'children'> & {
|
|
96
|
+
children?: ApTableSettingDefaultValueType;
|
|
97
|
+
}>;
|
|
95
98
|
export type ApColumnState = {
|
|
96
99
|
/**
|
|
97
100
|
* 列的唯一标识
|
|
@@ -117,6 +120,10 @@ export type ApColumnState = {
|
|
|
117
120
|
* 子节点状态
|
|
118
121
|
*/
|
|
119
122
|
children?: ApColumnState[];
|
|
123
|
+
/**
|
|
124
|
+
* 字段排序(和其同级的表头排序)
|
|
125
|
+
*/
|
|
126
|
+
order?: number;
|
|
120
127
|
};
|
|
121
128
|
export type FieldPropsType<ReturnType, RecordType, ExtraValueType, ValueType extends ApTableValueTypes, MergedValueType extends ExtraValueType | ValueType> = ReturnType | ((opt: Partial<{
|
|
122
129
|
value: any;
|
|
@@ -12,6 +12,7 @@ declare const _default: <RecordType = any>(__VLS_props: NonNullable<Awaited<type
|
|
|
12
12
|
setRowData: (index: number, payload: any) => void;
|
|
13
13
|
addMultiple: (list: number | Partial<RecordType>[], insetIn?: "prefix" | "suffix") => void;
|
|
14
14
|
scrollTo: (index: number | "end", options?: StandardBehaviorOptions) => void;
|
|
15
|
+
setTableData: (nextTableData: RecordType[]) => void;
|
|
15
16
|
}>): void;
|
|
16
17
|
attrs: any;
|
|
17
18
|
slots: Readonly<{
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { Table as
|
|
1
|
+
import { defineComponent as q, ref as x, unref as a, useSlots as G, watch as H, openBlock as m, createBlock as y, mergeProps as C, withCtx as d, createVNode as b, createSlots as W, createElementBlock as $, normalizeClass as Q, createCommentVNode as w, createElementVNode as U, toDisplayString as I, normalizeStyle as J, renderList as X, renderSlot as Y, normalizeProps as Z, guardReactiveProps as ee } from "vue";
|
|
2
|
+
import { Table as te, Tooltip as oe } from "ant-design-vue";
|
|
3
3
|
import { ApForm as R } from "../ap-form/index.mjs";
|
|
4
|
-
import { isArray as
|
|
4
|
+
import { isArray as ae, isNumber as i, cloneDeep as f, omit as le } from "lodash-unified";
|
|
5
5
|
import "../config-provider/index.mjs";
|
|
6
|
-
import { useInjectForm as
|
|
6
|
+
import { useInjectForm as ne } from "../ap-form/context.mjs";
|
|
7
7
|
import "./style/index.css";
|
|
8
|
-
import { isDef as
|
|
9
|
-
import
|
|
10
|
-
import { scrollToRowIndex as
|
|
11
|
-
import { QuestionCircleOutlined as
|
|
12
|
-
import { useToken as
|
|
13
|
-
import { useNamespace as
|
|
14
|
-
import { useGlobalConfig as
|
|
15
|
-
const
|
|
8
|
+
import { isDef as p } from "../utils/index.mjs";
|
|
9
|
+
import re from "./hooks/use-get-columns.mjs";
|
|
10
|
+
import { scrollToRowIndex as ue, getColumnIsRequired as se } from "./utils.mjs";
|
|
11
|
+
import { QuestionCircleOutlined as de } from "@ant-design/icons-vue";
|
|
12
|
+
import { useToken as me } from "ant-design-vue/es/theme/internal";
|
|
13
|
+
import { useNamespace as ie } from "../config-provider/hooks/use-namespace.mjs";
|
|
14
|
+
import { useGlobalConfig as fe } from "../config-provider/hooks/use-global-config.mjs";
|
|
15
|
+
const Fe = /* @__PURE__ */ q({
|
|
16
16
|
name: "EditableTableInner",
|
|
17
17
|
__name: "form-item",
|
|
18
18
|
props: {
|
|
@@ -113,101 +113,105 @@ const Le = /* @__PURE__ */ M({
|
|
|
113
113
|
}
|
|
114
114
|
},
|
|
115
115
|
setup(B, {
|
|
116
|
-
expose:
|
|
116
|
+
expose: D
|
|
117
117
|
}) {
|
|
118
118
|
const l = B;
|
|
119
|
-
function
|
|
120
|
-
return
|
|
119
|
+
function k(e, t) {
|
|
120
|
+
return ae(t) ? t.reduce((o, r) => o == null ? void 0 : o[r], e) : e == null ? void 0 : e[t];
|
|
121
121
|
}
|
|
122
122
|
const {
|
|
123
|
-
internalInstance:
|
|
124
|
-
model:
|
|
125
|
-
} =
|
|
126
|
-
|
|
123
|
+
internalInstance: n,
|
|
124
|
+
model: T
|
|
125
|
+
} = ne(), u = x(k(a(T), l.name) || []), F = G(), L = R.useWatch(l.name);
|
|
126
|
+
H(() => L.value, (e) => {
|
|
127
127
|
var t;
|
|
128
|
-
|
|
128
|
+
u.value = e, (t = l.onChange) == null || t.call(l, e);
|
|
129
129
|
}, {
|
|
130
130
|
deep: !0
|
|
131
131
|
});
|
|
132
132
|
const {
|
|
133
|
-
b:
|
|
133
|
+
b: E,
|
|
134
134
|
em: N
|
|
135
|
-
} =
|
|
135
|
+
} = ie("editable-table"), c = x(), S = fe("valueTypeMap"), [, V] = me(), _ = re(l, S);
|
|
136
136
|
function v(e, t) {
|
|
137
|
-
var
|
|
138
|
-
const o = ((
|
|
139
|
-
if (
|
|
137
|
+
var s;
|
|
138
|
+
const o = ((s = a(u)) == null ? void 0 : s.length) || 0;
|
|
139
|
+
if (p(l.maxLength) && o >= l.maxLength)
|
|
140
140
|
return;
|
|
141
|
-
const
|
|
142
|
-
|
|
141
|
+
const r = [...a(u) || []];
|
|
142
|
+
p(t) ? r.splice(t, 0, {
|
|
143
143
|
...e || {}
|
|
144
|
-
}) :
|
|
144
|
+
}) : r.push({
|
|
145
145
|
...e || {}
|
|
146
|
-
}),
|
|
146
|
+
}), n == null || n.setFieldValue(l.name, r);
|
|
147
147
|
}
|
|
148
148
|
function z(e, t = "suffix") {
|
|
149
149
|
var g;
|
|
150
|
-
const o = ((g = a(
|
|
151
|
-
if (
|
|
150
|
+
const o = ((g = a(u)) == null ? void 0 : g.length) || 0, r = i(e) ? e : e.length;
|
|
151
|
+
if (p(l.maxLength) && o + r > l.maxLength)
|
|
152
152
|
return;
|
|
153
|
-
const
|
|
154
|
-
t === "suffix" ?
|
|
153
|
+
const s = [...a(u) || []], h = i(e) ? new Array(e).fill({}) : f(e);
|
|
154
|
+
t === "suffix" ? s.push(...h) : s.unshift(...h), n == null || n.setFieldValue(l.name, s);
|
|
155
155
|
}
|
|
156
156
|
function P(e) {
|
|
157
|
-
let t = f(a(
|
|
157
|
+
let t = f(a(u) || []);
|
|
158
158
|
const o = i(e) ? [e] : e;
|
|
159
|
-
t = t.filter((
|
|
159
|
+
t = t.filter((r, s) => !o.includes(s)), n == null || n.setFieldValue(l.name, t);
|
|
160
160
|
}
|
|
161
161
|
function j() {
|
|
162
|
-
return a(
|
|
162
|
+
return a(u);
|
|
163
163
|
}
|
|
164
164
|
function A(e) {
|
|
165
165
|
var t;
|
|
166
|
-
return (t = a(
|
|
166
|
+
return (t = a(u)) == null ? void 0 : t[e];
|
|
167
167
|
}
|
|
168
168
|
function O(e, t) {
|
|
169
|
-
const o = f(a(
|
|
169
|
+
const o = f(a(u));
|
|
170
170
|
o[e] && (o[e] = {
|
|
171
171
|
...o[e],
|
|
172
172
|
...t
|
|
173
|
-
},
|
|
173
|
+
}, n == null || n.setFieldValue(l.name, [...o]));
|
|
174
174
|
}
|
|
175
|
-
function K(e
|
|
176
|
-
|
|
177
|
-
const o = e === "end" ? s.value.length - 1 : e;
|
|
178
|
-
re(o, (n = p.value) == null ? void 0 : n.$el, t);
|
|
175
|
+
function K(e) {
|
|
176
|
+
n == null || n.setFieldValue(l.name, e);
|
|
179
177
|
}
|
|
180
|
-
|
|
178
|
+
function M(e, t) {
|
|
179
|
+
var r;
|
|
180
|
+
const o = e === "end" ? u.value.length - 1 : e;
|
|
181
|
+
ue(o, (r = c.value) == null ? void 0 : r.$el, t);
|
|
182
|
+
}
|
|
183
|
+
return D({
|
|
181
184
|
add: v,
|
|
182
185
|
remove: P,
|
|
183
186
|
getRowData: A,
|
|
184
187
|
getRowsData: j,
|
|
185
188
|
setRowData: O,
|
|
186
189
|
addMultiple: z,
|
|
187
|
-
scrollTo:
|
|
190
|
+
scrollTo: M,
|
|
191
|
+
setTableData: K
|
|
188
192
|
}), (e, t) => (m(), y(a(R).FormItem, C(e.formItem, {
|
|
189
193
|
name: e.name,
|
|
190
194
|
label: e.label
|
|
191
195
|
}), {
|
|
192
|
-
default: d(() => [b(a(
|
|
193
|
-
class: a(
|
|
196
|
+
default: d(() => [b(a(te), C(a(le)(l, ["name", "maxLength", "onChange"]), {
|
|
197
|
+
class: a(E)(),
|
|
194
198
|
columns: a(_),
|
|
195
|
-
"data-source":
|
|
199
|
+
"data-source": u.value,
|
|
196
200
|
ref_key: "tableRef",
|
|
197
|
-
ref:
|
|
198
|
-
}),
|
|
201
|
+
ref: c
|
|
202
|
+
}), W({
|
|
199
203
|
headerCell: d(({
|
|
200
204
|
column: o
|
|
201
|
-
}) => [a(se)(o) ? (m(),
|
|
205
|
+
}) => [a(se)(o) ? (m(), $("span", {
|
|
202
206
|
key: 0,
|
|
203
|
-
class:
|
|
204
|
-
}, "*", 2)) : w("", !0),
|
|
207
|
+
class: Q(a(N)("header-cell", "required"))
|
|
208
|
+
}, "*", 2)) : w("", !0), U("span", null, I(o.title), 1), o.tooltip ? (m(), y(a(oe), {
|
|
205
209
|
key: 1,
|
|
206
210
|
title: o.tooltip,
|
|
207
211
|
placement: "bottom"
|
|
208
212
|
}, {
|
|
209
|
-
default: d(() => [b(a(
|
|
210
|
-
style:
|
|
213
|
+
default: d(() => [b(a(de), {
|
|
214
|
+
style: J({
|
|
211
215
|
paddingLeft: "4px",
|
|
212
216
|
color: a(V).colorPrimary
|
|
213
217
|
})
|
|
@@ -215,14 +219,14 @@ const Le = /* @__PURE__ */ M({
|
|
|
215
219
|
_: 2
|
|
216
220
|
}, 1032, ["title"])) : w("", !0)]),
|
|
217
221
|
_: 2
|
|
218
|
-
}, [
|
|
219
|
-
name:
|
|
220
|
-
fn: d((
|
|
222
|
+
}, [X(F, (o, r) => ({
|
|
223
|
+
name: r,
|
|
224
|
+
fn: d((s) => [Y(e.$slots, r, Z(ee(s || {})))])
|
|
221
225
|
}))]), 1040, ["class", "columns", "data-source"])]),
|
|
222
226
|
_: 3
|
|
223
227
|
}, 16, ["name", "label"]));
|
|
224
228
|
}
|
|
225
229
|
});
|
|
226
230
|
export {
|
|
227
|
-
|
|
231
|
+
Fe as default
|
|
228
232
|
};
|
|
@@ -20,6 +20,7 @@ declare const _default: <RecordType extends Recordable = any>(__VLS_props: NonNu
|
|
|
20
20
|
addMultiple: (list: number | Partial<RecordType>[], insetIn?: "prefix" | "suffix") => void;
|
|
21
21
|
scrollTo: (index: number | "end", options?: StandardBehaviorOptions) => void;
|
|
22
22
|
clear: () => void;
|
|
23
|
+
setTableData: (nextTableData: RecordType[]) => void;
|
|
23
24
|
}>): void;
|
|
24
25
|
attrs: any;
|
|
25
26
|
slots: Readonly<{
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { Table as
|
|
1
|
+
import { defineComponent as J, useSlots as X, ref as b, watch as R, unref as o, openBlock as p, createBlock as F, withCtx as m, createVNode as x, mergeProps as Y, createSlots as Z, createElementBlock as ee, normalizeClass as te, createCommentVNode as B, createElementVNode as ae, toDisplayString as ne, normalizeStyle as oe, renderList as le, renderSlot as re, normalizeProps as ue, guardReactiveProps as se } from "vue";
|
|
2
|
+
import { Table as ie, Tooltip as de } from "ant-design-vue";
|
|
3
3
|
import { ApForm as y } from "../ap-form/index.mjs";
|
|
4
|
-
import { isEqual as
|
|
4
|
+
import { isEqual as me, isArray as k, isNumber as g, cloneDeep as h, omit as fe } from "lodash-unified";
|
|
5
5
|
import "../config-provider/index.mjs";
|
|
6
6
|
import "../hooks/index.mjs";
|
|
7
7
|
import { isDef as C } from "../utils/index.mjs";
|
|
8
|
-
import { scrollToRowIndex as
|
|
9
|
-
import
|
|
8
|
+
import { scrollToRowIndex as ce, getColumnIsRequired as pe } from "./utils.mjs";
|
|
9
|
+
import xe from "./hooks/use-get-columns.mjs";
|
|
10
10
|
import "./style/index.css";
|
|
11
|
-
import { useToken as
|
|
12
|
-
import { QuestionCircleOutlined as
|
|
13
|
-
import { useNamespace as
|
|
14
|
-
import { useControllableValue as
|
|
15
|
-
import { useGlobalConfig as
|
|
16
|
-
const
|
|
11
|
+
import { useToken as ye } from "ant-design-vue/es/theme/internal";
|
|
12
|
+
import { QuestionCircleOutlined as ge } from "@ant-design/icons-vue";
|
|
13
|
+
import { useNamespace as he } from "../config-provider/hooks/use-namespace.mjs";
|
|
14
|
+
import { useControllableValue as Ce } from "../hooks/useControllableValue.mjs";
|
|
15
|
+
import { useGlobalConfig as ve } from "../config-provider/hooks/use-global-config.mjs";
|
|
16
|
+
const ze = /* @__PURE__ */ J({
|
|
17
17
|
name: "EditableTable",
|
|
18
18
|
__name: "index",
|
|
19
19
|
props: {
|
|
@@ -113,141 +113,146 @@ const Ae = /* @__PURE__ */ Q({
|
|
|
113
113
|
},
|
|
114
114
|
emits: ["update:value"],
|
|
115
115
|
setup(V, {
|
|
116
|
-
expose:
|
|
117
|
-
emit:
|
|
116
|
+
expose: T,
|
|
117
|
+
emit: D
|
|
118
118
|
}) {
|
|
119
119
|
const l = V, {
|
|
120
|
-
b:
|
|
121
|
-
em:
|
|
122
|
-
} =
|
|
123
|
-
value:
|
|
120
|
+
b: E,
|
|
121
|
+
em: L
|
|
122
|
+
} = he("editable-table"), N = X(), _ = D, v = b(), {
|
|
123
|
+
value: u,
|
|
124
124
|
updateValue: S
|
|
125
|
-
} =
|
|
125
|
+
} = Ce(l, _), s = b(), [, A] = ye(), z = ve("valueTypeMap"), c = y.useWatch(l.name, s);
|
|
126
126
|
R(() => c.value, (e) => {
|
|
127
127
|
var t;
|
|
128
128
|
S(e), (t = l.onChange) == null || t.call(l, e);
|
|
129
129
|
}, {
|
|
130
130
|
deep: !0
|
|
131
|
-
}), R(
|
|
131
|
+
}), R(u, (e) => {
|
|
132
132
|
var t;
|
|
133
|
-
e !==
|
|
133
|
+
e !== o(c) && (me(e, o(c)) || (t = s.value) == null || t.setFieldValue(l.name, e));
|
|
134
134
|
}, {
|
|
135
135
|
deep: !0
|
|
136
136
|
});
|
|
137
|
-
const P =
|
|
137
|
+
const P = xe(l, z);
|
|
138
138
|
function I() {
|
|
139
139
|
var e;
|
|
140
|
-
(e =
|
|
140
|
+
(e = s.value) == null || e.resetFields();
|
|
141
141
|
}
|
|
142
142
|
function O(e) {
|
|
143
143
|
return e ? (k(e) ? e : [e]).map((a) => k(a) ? [l.name, ...a] : [l.name, a]) : void 0;
|
|
144
144
|
}
|
|
145
145
|
async function j(e, t) {
|
|
146
|
-
var
|
|
147
|
-
const a = await ((
|
|
146
|
+
var n;
|
|
147
|
+
const a = await ((n = s.value) == null ? void 0 : n.validateFields(O(e), t));
|
|
148
148
|
return a == null ? void 0 : a[l.name];
|
|
149
149
|
}
|
|
150
150
|
function q(e, t) {
|
|
151
151
|
var r, i, d;
|
|
152
|
-
const a = ((r =
|
|
152
|
+
const a = ((r = o(u)) == null ? void 0 : r.length) || 0;
|
|
153
153
|
if (C(l.maxLength) && a >= l.maxLength)
|
|
154
154
|
return;
|
|
155
|
-
const
|
|
156
|
-
C(t) ?
|
|
155
|
+
const n = [...o(u) || []];
|
|
156
|
+
C(t) ? n.splice(t, 0, {
|
|
157
157
|
...e || {}
|
|
158
|
-
}) :
|
|
158
|
+
}) : n.push({
|
|
159
159
|
...e || {}
|
|
160
|
-
}), (d = (i =
|
|
160
|
+
}), (d = (i = s.value) == null ? void 0 : i.setFieldValue) == null || d.call(i, l.name, n);
|
|
161
161
|
}
|
|
162
162
|
function K(e, t = "suffix") {
|
|
163
163
|
var d, f, w;
|
|
164
|
-
const a = ((d =
|
|
165
|
-
if (C(l.maxLength) && a +
|
|
164
|
+
const a = ((d = o(u)) == null ? void 0 : d.length) || 0, n = g(e) ? e : e.length;
|
|
165
|
+
if (C(l.maxLength) && a + n > l.maxLength)
|
|
166
166
|
return;
|
|
167
|
-
const r = [...
|
|
168
|
-
t === "suffix" ? r.push(...i) : r.unshift(...i), (w = (f =
|
|
167
|
+
const r = [...o(u) || []], i = g(e) ? new Array(e).fill({}) : h(e);
|
|
168
|
+
t === "suffix" ? r.push(...i) : r.unshift(...i), (w = (f = s.value) == null ? void 0 : f.setFieldValue) == null || w.call(f, l.name, r);
|
|
169
169
|
}
|
|
170
170
|
function M(e) {
|
|
171
|
-
var
|
|
172
|
-
let t = h(
|
|
171
|
+
var n, r;
|
|
172
|
+
let t = h(o(u) || []);
|
|
173
173
|
const a = g(e) ? [e] : e;
|
|
174
|
-
t = t.filter((i, d) => !a.includes(d)), (r = (
|
|
174
|
+
t = t.filter((i, d) => !a.includes(d)), (r = (n = s.value) == null ? void 0 : n.setFieldValue) == null || r.call(n, l.name, t);
|
|
175
175
|
}
|
|
176
176
|
function G() {
|
|
177
|
-
return
|
|
177
|
+
return o(u);
|
|
178
178
|
}
|
|
179
179
|
function H(e) {
|
|
180
180
|
var t;
|
|
181
|
-
|
|
181
|
+
(t = s.value) == null || t.setFieldValue(l.name, e);
|
|
182
182
|
}
|
|
183
|
-
function U(e
|
|
184
|
-
var
|
|
185
|
-
|
|
183
|
+
function U(e) {
|
|
184
|
+
var t;
|
|
185
|
+
return (t = o(u)) == null ? void 0 : t[e];
|
|
186
|
+
}
|
|
187
|
+
function W(e, t) {
|
|
188
|
+
var n, r;
|
|
189
|
+
const a = h(o(u));
|
|
186
190
|
a[e] && (a[e] = {
|
|
187
191
|
...a[e],
|
|
188
192
|
...t
|
|
189
|
-
}, (r = (
|
|
193
|
+
}, (r = (n = s.value) == null ? void 0 : n.setFieldValue) == null || r.call(n, l.name, [...a]));
|
|
190
194
|
}
|
|
191
|
-
function
|
|
192
|
-
var
|
|
193
|
-
const a = e === "end" ?
|
|
194
|
-
|
|
195
|
+
function $(e, t) {
|
|
196
|
+
var n;
|
|
197
|
+
const a = e === "end" ? u.value.length - 1 : e;
|
|
198
|
+
ce(a, (n = v.value) == null ? void 0 : n.$el, t);
|
|
195
199
|
}
|
|
196
|
-
function
|
|
200
|
+
function Q() {
|
|
197
201
|
var e, t;
|
|
198
|
-
(t = (e =
|
|
202
|
+
(t = (e = s.value) == null ? void 0 : e.setFieldValue) == null || t.call(e, l.name, []);
|
|
199
203
|
}
|
|
200
|
-
return
|
|
204
|
+
return T({
|
|
201
205
|
resetFields: I,
|
|
202
206
|
validateFields: j,
|
|
203
207
|
add: q,
|
|
204
208
|
remove: M,
|
|
205
|
-
getRowData:
|
|
209
|
+
getRowData: U,
|
|
206
210
|
getRowsData: G,
|
|
207
|
-
setRowData:
|
|
211
|
+
setRowData: W,
|
|
208
212
|
addMultiple: K,
|
|
209
|
-
scrollTo:
|
|
210
|
-
clear:
|
|
211
|
-
|
|
213
|
+
scrollTo: $,
|
|
214
|
+
clear: Q,
|
|
215
|
+
setTableData: H
|
|
216
|
+
}), (e, t) => (p(), F(o(y), {
|
|
212
217
|
"initial-values": {
|
|
213
|
-
[l.name]:
|
|
218
|
+
[l.name]: o(u)
|
|
214
219
|
},
|
|
215
220
|
ref_key: "formRef",
|
|
216
|
-
ref:
|
|
221
|
+
ref: s
|
|
217
222
|
}, {
|
|
218
|
-
default: m(() => [x(
|
|
223
|
+
default: m(() => [x(o(y).FormItem, {
|
|
219
224
|
name: e.name,
|
|
220
225
|
"no-style": ""
|
|
221
226
|
}, {
|
|
222
|
-
default: m(() => [x(
|
|
223
|
-
class:
|
|
224
|
-
columns:
|
|
225
|
-
"data-source":
|
|
227
|
+
default: m(() => [x(o(ie), Y(o(fe)(l, ["name", "value", "onUpdate:value", "maxLength", "onChange"]), {
|
|
228
|
+
class: o(E)(),
|
|
229
|
+
columns: o(P),
|
|
230
|
+
"data-source": o(u),
|
|
226
231
|
ref_key: "tableRef",
|
|
227
232
|
ref: v
|
|
228
|
-
}),
|
|
233
|
+
}), Z({
|
|
229
234
|
headerCell: m(({
|
|
230
235
|
column: a
|
|
231
|
-
}) => [
|
|
236
|
+
}) => [o(pe)(a) ? (p(), ee("span", {
|
|
232
237
|
key: 0,
|
|
233
|
-
class:
|
|
234
|
-
}, "*", 2)) :
|
|
238
|
+
class: te(o(L)("header-cell", "required"))
|
|
239
|
+
}, "*", 2)) : B("", !0), ae("span", null, ne(a.title), 1), a.tooltip ? (p(), F(o(de), {
|
|
235
240
|
key: 1,
|
|
236
241
|
title: a.tooltip,
|
|
237
242
|
placement: "bottom"
|
|
238
243
|
}, {
|
|
239
|
-
default: m(() => [x(
|
|
244
|
+
default: m(() => [x(o(ge), {
|
|
240
245
|
style: oe({
|
|
241
246
|
paddingLeft: "4px",
|
|
242
|
-
color:
|
|
247
|
+
color: o(A).colorPrimary
|
|
243
248
|
})
|
|
244
249
|
}, null, 8, ["style"])]),
|
|
245
250
|
_: 2
|
|
246
|
-
}, 1032, ["title"])) :
|
|
251
|
+
}, 1032, ["title"])) : B("", !0)]),
|
|
247
252
|
_: 2
|
|
248
|
-
}, [
|
|
249
|
-
name:
|
|
250
|
-
fn: m((r) => [
|
|
253
|
+
}, [le(N, (a, n) => ({
|
|
254
|
+
name: n,
|
|
255
|
+
fn: m((r) => [re(e.$slots, n, ue(se(r || {})))])
|
|
251
256
|
}))]), 1040, ["class", "columns", "data-source"])]),
|
|
252
257
|
_: 3
|
|
253
258
|
}, 8, ["name"])]),
|
|
@@ -256,5 +261,5 @@ const Ae = /* @__PURE__ */ Q({
|
|
|
256
261
|
}
|
|
257
262
|
});
|
|
258
263
|
export {
|
|
259
|
-
|
|
264
|
+
ze as default
|
|
260
265
|
};
|
|
@@ -163,6 +163,12 @@ export type EditableTableExpose<ModelType = any, RecordType = any> = {
|
|
|
163
163
|
* @returns
|
|
164
164
|
*/
|
|
165
165
|
scrollTo: (index: number | 'end', options?: StandardBehaviorOptions) => void;
|
|
166
|
+
/**
|
|
167
|
+
* 设置表格数据
|
|
168
|
+
* @param nextTableData
|
|
169
|
+
* @returns
|
|
170
|
+
*/
|
|
171
|
+
setTableData: (nextTableData: RecordType[]) => void;
|
|
166
172
|
};
|
|
167
173
|
/**
|
|
168
174
|
* 可编辑表格作为表单项暴露的实例
|