@aplus-frontend/ui 0.6.0-beta.3 → 0.6.0-beta.4
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-grid/editable/form-item.vue.mjs +91 -83
- package/es/src/ap-grid/editable/index.vue.mjs +86 -78
- package/es/src/ap-grid/index.vue.mjs +2 -0
- package/es/src/ap-table/ap-table.vue2.mjs +2 -0
- package/es/src/business/ap-status/interface.d.ts +1 -1
- package/es/src/editable-table/form-item.vue.d.ts +2 -14
- package/es/src/editable-table/form-item.vue.mjs +84 -76
- package/es/src/editable-table/index.vue.d.ts +2 -16
- package/es/src/editable-table/index.vue.mjs +91 -83
- package/es/src/editable-table/interface.d.ts +7 -0
- package/lib/src/ap-grid/editable/form-item.vue.js +1 -1
- package/lib/src/ap-grid/editable/index.vue.js +1 -1
- package/lib/src/ap-grid/index.vue.js +1 -1
- package/lib/src/ap-table/ap-table.vue2.js +1 -1
- package/lib/src/business/ap-status/interface.d.ts +1 -1
- package/lib/src/editable-table/form-item.vue.d.ts +2 -14
- package/lib/src/editable-table/form-item.vue.js +1 -1
- package/lib/src/editable-table/index.vue.d.ts +2 -16
- package/lib/src/editable-table/index.vue.js +1 -1
- package/lib/src/editable-table/interface.d.ts +7 -0
- package/package.json +1 -1
- package/theme/ap-tag/ap-tag.css +1 -1
- package/theme/ap-tag/ap-tag.less +1 -1
- package/theme/index.css +1 -1
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { Table as
|
|
3
|
-
import { ApForm as
|
|
4
|
-
import { isArray as
|
|
1
|
+
import { defineComponent as G, ref as c, unref as s, useSlots as H, toRef as U, watch as W, nextTick as $, createBlock as q, openBlock as J, mergeProps as h, withCtx as w, createVNode as Q, createSlots as X, renderList as Y, renderSlot as Z, normalizeProps as I, guardReactiveProps as M } from "vue";
|
|
2
|
+
import { Table as ee } from "@aplus-frontend/antdv";
|
|
3
|
+
import { ApForm as x } from "../ap-form/index.mjs";
|
|
4
|
+
import { isArray as g, isUndefined as oe, isNumber as m, cloneDeep as te, omit as y } from "lodash-unified";
|
|
5
5
|
import "../config-provider/index.mjs";
|
|
6
|
-
import { useInjectForm as
|
|
6
|
+
import { useInjectForm as ae } from "../ap-form/context.mjs";
|
|
7
7
|
import { isDef as b } from "../utils/index.mjs";
|
|
8
|
-
import
|
|
9
|
-
import { scrollToRowIndex as
|
|
8
|
+
import le from "./hooks/use-get-columns.mjs";
|
|
9
|
+
import { scrollToRowIndex as ue } from "./utils.mjs";
|
|
10
10
|
import { useNamespace as ne } from "../config-provider/hooks/use-namespace.mjs";
|
|
11
|
-
import { useGlobalConfig as
|
|
12
|
-
const
|
|
11
|
+
import { useGlobalConfig as fe } from "../config-provider/hooks/use-global-config.mjs";
|
|
12
|
+
const ye = /* @__PURE__ */ G({
|
|
13
13
|
name: "EditableTableInner",
|
|
14
14
|
__name: "form-item",
|
|
15
15
|
props: {
|
|
@@ -109,119 +109,127 @@ const we = /* @__PURE__ */ O({
|
|
|
109
109
|
default: () => ({})
|
|
110
110
|
}
|
|
111
111
|
},
|
|
112
|
-
setup(
|
|
113
|
-
expose:
|
|
112
|
+
setup(C, {
|
|
113
|
+
expose: R
|
|
114
114
|
}) {
|
|
115
|
-
const l =
|
|
116
|
-
function
|
|
117
|
-
return
|
|
115
|
+
const l = C;
|
|
116
|
+
function B(e, a) {
|
|
117
|
+
return g(a) ? a.reduce((u, t) => u == null ? void 0 : u[t], e) : e == null ? void 0 : e[a];
|
|
118
118
|
}
|
|
119
119
|
const {
|
|
120
|
-
internalInstance:
|
|
121
|
-
model:
|
|
122
|
-
} =
|
|
123
|
-
|
|
124
|
-
var
|
|
125
|
-
await
|
|
120
|
+
internalInstance: o,
|
|
121
|
+
model: F
|
|
122
|
+
} = ae(), d = c(B(s(F), l.name) || []), T = H(), D = U(l, "name"), V = x.useWatch(D);
|
|
123
|
+
W(() => V.value, async (e) => {
|
|
124
|
+
var a;
|
|
125
|
+
await $(), d.value = e, (a = l.onChange) == null || a.call(l, e);
|
|
126
126
|
}, {
|
|
127
127
|
deep: !0
|
|
128
128
|
});
|
|
129
129
|
const {
|
|
130
130
|
b: L
|
|
131
|
-
} = ne("editable-table"), p = c(),
|
|
132
|
-
function
|
|
133
|
-
var
|
|
134
|
-
const
|
|
135
|
-
if (b(l.maxLength) &&
|
|
131
|
+
} = ne("editable-table"), p = c(), S = fe("valueTypeMap"), v = le(l, S);
|
|
132
|
+
function N(e, a) {
|
|
133
|
+
var n;
|
|
134
|
+
const u = ((n = s(d)) == null ? void 0 : n.length) || 0;
|
|
135
|
+
if (b(l.maxLength) && u >= l.maxLength)
|
|
136
136
|
return;
|
|
137
|
-
const
|
|
137
|
+
const t = {
|
|
138
138
|
...e || {}
|
|
139
139
|
};
|
|
140
|
-
|
|
141
|
-
if (!r
|
|
142
|
-
r
|
|
140
|
+
o == null || o.setFieldValue(l.name, t, !0, (f, r) => {
|
|
141
|
+
if (!f[r]) {
|
|
142
|
+
f[r] = [t];
|
|
143
143
|
return;
|
|
144
144
|
}
|
|
145
|
-
|
|
145
|
+
oe(a) ? f[r].push(t) : f[r].splice(a, 0, t);
|
|
146
146
|
});
|
|
147
147
|
}
|
|
148
|
-
function
|
|
149
|
-
var
|
|
150
|
-
const
|
|
151
|
-
if (b(l.maxLength) &&
|
|
148
|
+
function E(e, a = "suffix") {
|
|
149
|
+
var f;
|
|
150
|
+
const u = ((f = s(d)) == null ? void 0 : f.length) || 0, t = m(e) ? e : e.length;
|
|
151
|
+
if (b(l.maxLength) && u + t > l.maxLength)
|
|
152
152
|
return;
|
|
153
|
-
const
|
|
154
|
-
|
|
155
|
-
if (!
|
|
156
|
-
|
|
153
|
+
const n = m(e) ? new Array(e).fill(0).map(() => ({})) : te(e);
|
|
154
|
+
o == null || o.setFieldValue(l.name, n, !0, (r, i) => {
|
|
155
|
+
if (!r[i]) {
|
|
156
|
+
r[i] = [...n];
|
|
157
157
|
return;
|
|
158
158
|
}
|
|
159
|
-
|
|
159
|
+
a === "suffix" ? r[i].push(...n) : r[i].unshift(...n);
|
|
160
160
|
});
|
|
161
161
|
}
|
|
162
|
-
function
|
|
163
|
-
const
|
|
164
|
-
|
|
165
|
-
|
|
162
|
+
function _(e) {
|
|
163
|
+
const a = new Set(m(e) ? [e] : e);
|
|
164
|
+
o == null || o.setFieldValue(l.name, void 0, !0, (u, t) => {
|
|
165
|
+
u[t] = u[t].filter((n, f) => !a.has(f));
|
|
166
166
|
});
|
|
167
167
|
}
|
|
168
|
-
function
|
|
168
|
+
function k(e) {
|
|
169
|
+
var u;
|
|
170
|
+
const a = new Set(g(e) ? e : [e]);
|
|
171
|
+
a.size !== 0 && ((u = o == null ? void 0 : o.setFieldValue) == null || u.call(o, l.name, void 0, !0, (t, n) => {
|
|
172
|
+
t[n] = t[n].filter((f) => !a.has(f[l.rowKey]));
|
|
173
|
+
}));
|
|
174
|
+
}
|
|
175
|
+
function j() {
|
|
169
176
|
return s(d);
|
|
170
177
|
}
|
|
171
|
-
function
|
|
172
|
-
var
|
|
173
|
-
return (
|
|
178
|
+
function z(e) {
|
|
179
|
+
var a;
|
|
180
|
+
return (a = s(d)) == null ? void 0 : a[e];
|
|
174
181
|
}
|
|
175
|
-
function
|
|
176
|
-
|
|
177
|
-
!
|
|
178
|
-
...
|
|
179
|
-
...
|
|
182
|
+
function K(e, a, u = !0) {
|
|
183
|
+
o == null || o.setFieldValue(l.name, void 0, !0, (t, n) => {
|
|
184
|
+
!t[n] || !t[n][e] || (t[n][e] = {
|
|
185
|
+
...u ? t[n][e] : {},
|
|
186
|
+
...a
|
|
180
187
|
});
|
|
181
188
|
});
|
|
182
189
|
}
|
|
183
190
|
function P(e) {
|
|
184
|
-
|
|
191
|
+
o == null || o.setFieldValue(l.name, e);
|
|
185
192
|
}
|
|
186
|
-
function
|
|
187
|
-
var
|
|
188
|
-
const
|
|
189
|
-
|
|
193
|
+
function A(e, a) {
|
|
194
|
+
var t;
|
|
195
|
+
const u = e === "end" ? d.value.length - 1 : e;
|
|
196
|
+
ue(u, (t = p.value) == null ? void 0 : t.$el, a);
|
|
190
197
|
}
|
|
191
|
-
function
|
|
198
|
+
function O() {
|
|
192
199
|
var e;
|
|
193
|
-
(e =
|
|
200
|
+
(e = o == null ? void 0 : o.setFieldValue) == null || e.call(o, l.name, []);
|
|
194
201
|
}
|
|
195
|
-
return
|
|
196
|
-
add:
|
|
197
|
-
remove:
|
|
198
|
-
getRowData:
|
|
199
|
-
getRowsData:
|
|
200
|
-
setRowData:
|
|
201
|
-
addMultiple:
|
|
202
|
-
scrollTo:
|
|
202
|
+
return R({
|
|
203
|
+
add: N,
|
|
204
|
+
remove: _,
|
|
205
|
+
getRowData: z,
|
|
206
|
+
getRowsData: j,
|
|
207
|
+
setRowData: K,
|
|
208
|
+
addMultiple: E,
|
|
209
|
+
scrollTo: A,
|
|
203
210
|
setTableData: P,
|
|
204
|
-
clear:
|
|
205
|
-
|
|
211
|
+
clear: O,
|
|
212
|
+
removeByKey: k
|
|
213
|
+
}), (e, a) => (J(), q(s(x).FormItem, h(e.formItem, {
|
|
206
214
|
name: e.name,
|
|
207
215
|
label: e.label
|
|
208
216
|
}), {
|
|
209
|
-
default:
|
|
217
|
+
default: w(() => [Q(s(ee), h(s(y)(l, ["name", "maxLength", "onChange"]), {
|
|
210
218
|
ref_key: "tableRef",
|
|
211
219
|
ref: p,
|
|
212
220
|
class: s(L)(),
|
|
213
|
-
columns: s(
|
|
221
|
+
columns: s(v),
|
|
214
222
|
"data-source": d.value
|
|
215
|
-
}),
|
|
223
|
+
}), X({
|
|
216
224
|
_: 2
|
|
217
|
-
}, [
|
|
218
|
-
name:
|
|
219
|
-
fn:
|
|
225
|
+
}, [Y(s(y)(T, ["headerCell"]), (u, t) => ({
|
|
226
|
+
name: t,
|
|
227
|
+
fn: w((n) => [Z(e.$slots, t, I(M(n || {})))])
|
|
220
228
|
}))]), 1040, ["class", "columns", "data-source"])]),
|
|
221
229
|
_: 3
|
|
222
230
|
}, 16, ["name", "label"]));
|
|
223
231
|
}
|
|
224
232
|
});
|
|
225
233
|
export {
|
|
226
|
-
|
|
234
|
+
ye as default
|
|
227
235
|
};
|
|
@@ -1,25 +1,11 @@
|
|
|
1
|
-
import { EditableTableProps, EditableColumnType } from './interface';
|
|
2
|
-
import { NamePath, ValidateOptions } from '@aplus-frontend/antdv/es/form/interface';
|
|
1
|
+
import { EditableTableProps, EditableColumnType, EditableTableExpose } from './interface';
|
|
3
2
|
import { Recordable } from '../type';
|
|
4
|
-
import { StandardBehaviorOptions } from '../../node_modules/scroll-into-view-if-needed';
|
|
5
3
|
import { VNodeProps, AllowedComponentProps, ComponentCustomProps, PublicProps, ShallowUnwrapRef, VNode } from 'vue';
|
|
6
4
|
declare const _default: <RecordType extends Recordable = any>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
7
5
|
props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{
|
|
8
6
|
readonly "onUpdate:value"?: ((...args: any[]) => any) | undefined;
|
|
9
7
|
} & VNodeProps & AllowedComponentProps & ComponentCustomProps, never>, "onUpdate:value"> & EditableTableProps<RecordType> & Partial<{}>> & PublicProps;
|
|
10
|
-
expose(exposed: ShallowUnwrapRef<
|
|
11
|
-
resetFields: () => void;
|
|
12
|
-
validateFields: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<any>;
|
|
13
|
-
add: (defaultValue?: Partial<RecordType>, insertIndex?: number) => void;
|
|
14
|
-
remove: (index: number | number[]) => void;
|
|
15
|
-
getRowData: (index: number) => RecordType;
|
|
16
|
-
getRowsData: () => RecordType[];
|
|
17
|
-
setRowData: (index: number, payload: any, merge?: boolean) => void;
|
|
18
|
-
addMultiple: (list: number | Partial<RecordType>[], insetIn?: "prefix" | "suffix") => void;
|
|
19
|
-
scrollTo: (index: number | "end", options?: StandardBehaviorOptions) => void;
|
|
20
|
-
clear: () => void;
|
|
21
|
-
setTableData: (nextTableData: RecordType[]) => void;
|
|
22
|
-
}>): void;
|
|
8
|
+
expose(exposed: ShallowUnwrapRef<EditableTableExpose>): void;
|
|
23
9
|
attrs: any;
|
|
24
10
|
slots: Readonly<{
|
|
25
11
|
default: any;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { Table as
|
|
1
|
+
import { defineComponent as q, useSlots as J, ref as y, watch as C, unref as r, createBlock as Q, openBlock as X, withCtx as h, createVNode as b, mergeProps as Y, createSlots as Z, renderList as M, renderSlot as ee, normalizeProps as te, guardReactiveProps as ae } from "vue";
|
|
2
|
+
import { Table as ne } from "@aplus-frontend/antdv";
|
|
3
3
|
import { ApForm as x } from "../ap-form/index.mjs";
|
|
4
|
-
import { isEqual as
|
|
4
|
+
import { isEqual as oe, isArray as v, isUndefined as le, isNumber as g, cloneDeep as ue, omit as R } from "lodash-unified";
|
|
5
5
|
import "../config-provider/index.mjs";
|
|
6
6
|
import "../hooks/index.mjs";
|
|
7
7
|
import { isDef as F } from "../utils/index.mjs";
|
|
8
|
-
import { scrollToRowIndex as
|
|
9
|
-
import
|
|
10
|
-
import { useNamespace as
|
|
11
|
-
import { useControllableValue as
|
|
8
|
+
import { scrollToRowIndex as se } from "./utils.mjs";
|
|
9
|
+
import re from "./hooks/use-get-columns.mjs";
|
|
10
|
+
import { useNamespace as ie } from "../config-provider/hooks/use-namespace.mjs";
|
|
11
|
+
import { useControllableValue as fe } from "../hooks/useControllableValue.mjs";
|
|
12
12
|
import { useGlobalConfig as de } from "../config-provider/hooks/use-global-config.mjs";
|
|
13
|
-
const
|
|
13
|
+
const Fe = /* @__PURE__ */ q({
|
|
14
14
|
name: "EditableTable",
|
|
15
15
|
__name: "index",
|
|
16
16
|
props: {
|
|
@@ -113,137 +113,145 @@ const Re = /* @__PURE__ */ $({
|
|
|
113
113
|
expose: V,
|
|
114
114
|
emit: T
|
|
115
115
|
}) {
|
|
116
|
-
const
|
|
117
|
-
b:
|
|
118
|
-
} =
|
|
116
|
+
const o = B, {
|
|
117
|
+
b: D
|
|
118
|
+
} = ie("editable-table"), L = J(), S = T, w = y(), {
|
|
119
119
|
value: m,
|
|
120
|
-
updateValue:
|
|
121
|
-
} =
|
|
122
|
-
|
|
120
|
+
updateValue: _
|
|
121
|
+
} = fe(o, S), i = y(), E = de("valueTypeMap"), c = x.useWatch(o.name, i);
|
|
122
|
+
C(() => c.value, (e) => {
|
|
123
123
|
var t;
|
|
124
|
-
|
|
124
|
+
_(e), (t = o.onChange) == null || t.call(o, e);
|
|
125
125
|
}, {
|
|
126
126
|
deep: !0,
|
|
127
127
|
flush: "post"
|
|
128
|
-
}),
|
|
128
|
+
}), C(m, (e) => {
|
|
129
129
|
var t;
|
|
130
|
-
e !==
|
|
130
|
+
e !== r(c) && (oe(e, r(c)) || (t = i.value) == null || t.setFieldValue(o.name, e));
|
|
131
131
|
}, {
|
|
132
132
|
deep: !0
|
|
133
133
|
});
|
|
134
|
-
const
|
|
134
|
+
const N = re(o, E);
|
|
135
135
|
function k() {
|
|
136
136
|
var e;
|
|
137
137
|
(e = i.value) == null || e.resetFields();
|
|
138
138
|
}
|
|
139
139
|
function A(e) {
|
|
140
|
-
return e ? (
|
|
140
|
+
return e ? (v(e) ? e : [e]).map((a) => v(a) ? [o.name, ...a] : [o.name, a]) : void 0;
|
|
141
141
|
}
|
|
142
|
-
async function
|
|
143
|
-
var
|
|
144
|
-
const
|
|
145
|
-
return
|
|
142
|
+
async function z(e, t) {
|
|
143
|
+
var n;
|
|
144
|
+
const a = await ((n = i.value) == null ? void 0 : n.validateFields(A(e), t));
|
|
145
|
+
return a == null ? void 0 : a[o.name];
|
|
146
146
|
}
|
|
147
|
-
function
|
|
148
|
-
var l, u,
|
|
149
|
-
const
|
|
150
|
-
if (F(
|
|
147
|
+
function I(e, t) {
|
|
148
|
+
var l, u, s;
|
|
149
|
+
const a = ((l = r(m)) == null ? void 0 : l.length) || 0;
|
|
150
|
+
if (F(o.maxLength) && a >= o.maxLength)
|
|
151
151
|
return;
|
|
152
|
-
const
|
|
152
|
+
const n = {
|
|
153
153
|
...e || {}
|
|
154
154
|
};
|
|
155
|
-
(
|
|
156
|
-
if (!d
|
|
157
|
-
d
|
|
155
|
+
(s = (u = i.value) == null ? void 0 : u.setFieldValue) == null || s.call(u, o.name, n, !0, (f, d) => {
|
|
156
|
+
if (!f[d]) {
|
|
157
|
+
f[d] = [n];
|
|
158
158
|
return;
|
|
159
159
|
}
|
|
160
|
-
|
|
160
|
+
le(t) ? f[d].push(n) : f[d].splice(t, 0, n);
|
|
161
161
|
});
|
|
162
162
|
}
|
|
163
|
-
function
|
|
164
|
-
var u,
|
|
165
|
-
const
|
|
166
|
-
if (F(
|
|
163
|
+
function K(e, t = "suffix") {
|
|
164
|
+
var u, s, f;
|
|
165
|
+
const a = ((u = r(m)) == null ? void 0 : u.length) || 0, n = g(e) ? e : e.length;
|
|
166
|
+
if (F(o.maxLength) && a + n > o.maxLength)
|
|
167
167
|
return;
|
|
168
|
-
const l = g(e) ? new Array(e).fill(0).map(() => ({})) :
|
|
169
|
-
(
|
|
170
|
-
if (!
|
|
171
|
-
|
|
168
|
+
const l = g(e) ? new Array(e).fill(0).map(() => ({})) : ue(e);
|
|
169
|
+
(f = (s = i.value) == null ? void 0 : s.setFieldValue) == null || f.call(s, o.name, l, !0, (d, p) => {
|
|
170
|
+
if (!d[p]) {
|
|
171
|
+
d[p] = [...l];
|
|
172
172
|
return;
|
|
173
173
|
}
|
|
174
|
-
t === "suffix" ?
|
|
174
|
+
t === "suffix" ? d[p].push(...l) : d[p].unshift(...l);
|
|
175
175
|
});
|
|
176
176
|
}
|
|
177
|
-
function
|
|
178
|
-
var
|
|
177
|
+
function P(e) {
|
|
178
|
+
var a, n;
|
|
179
179
|
const t = new Set(g(e) ? [e] : e);
|
|
180
|
-
(
|
|
181
|
-
l[u] = l[u].filter((
|
|
180
|
+
(n = (a = i.value) == null ? void 0 : a.setFieldValue) == null || n.call(a, o.name, void 0, !0, (l, u) => {
|
|
181
|
+
l[u] = l[u].filter((s, f) => !t.has(f));
|
|
182
182
|
});
|
|
183
183
|
}
|
|
184
|
+
function j(e) {
|
|
185
|
+
var a, n;
|
|
186
|
+
const t = new Set(v(e) ? e : [e]);
|
|
187
|
+
t.size !== 0 && ((n = (a = i.value) == null ? void 0 : a.setFieldValue) == null || n.call(a, o.name, void 0, !0, (l, u) => {
|
|
188
|
+
l[u] = l[u].filter((s) => !t.has(s[o.rowKey]));
|
|
189
|
+
}));
|
|
190
|
+
}
|
|
184
191
|
function O() {
|
|
185
|
-
return
|
|
192
|
+
return r(m);
|
|
186
193
|
}
|
|
187
|
-
function
|
|
194
|
+
function U(e) {
|
|
188
195
|
var t;
|
|
189
|
-
(t = i.value) == null || t.setFieldValue(
|
|
196
|
+
(t = i.value) == null || t.setFieldValue(o.name, e);
|
|
190
197
|
}
|
|
191
|
-
function
|
|
198
|
+
function G(e) {
|
|
192
199
|
var t;
|
|
193
|
-
return (t =
|
|
200
|
+
return (t = r(m)) == null ? void 0 : t[e];
|
|
194
201
|
}
|
|
195
|
-
function
|
|
196
|
-
var
|
|
197
|
-
(l = (
|
|
198
|
-
!u[
|
|
199
|
-
...
|
|
202
|
+
function H(e, t, a = !0) {
|
|
203
|
+
var n, l;
|
|
204
|
+
(l = (n = i.value) == null ? void 0 : n.setFieldValue) == null || l.call(n, o.name, void 0, !0, (u, s) => {
|
|
205
|
+
!u[s] || !u[s][e] || (u[s][e] = {
|
|
206
|
+
...a ? u[s][e] : {},
|
|
200
207
|
...t
|
|
201
208
|
});
|
|
202
209
|
});
|
|
203
210
|
}
|
|
204
|
-
function
|
|
205
|
-
var
|
|
206
|
-
const
|
|
207
|
-
|
|
211
|
+
function W(e, t) {
|
|
212
|
+
var n;
|
|
213
|
+
const a = e === "end" ? m.value.length - 1 : e;
|
|
214
|
+
se(a, (n = w.value) == null ? void 0 : n.$el, t);
|
|
208
215
|
}
|
|
209
|
-
function
|
|
216
|
+
function $() {
|
|
210
217
|
var e, t;
|
|
211
|
-
(t = (e = i.value) == null ? void 0 : e.setFieldValue) == null || t.call(e,
|
|
218
|
+
(t = (e = i.value) == null ? void 0 : e.setFieldValue) == null || t.call(e, o.name, []);
|
|
212
219
|
}
|
|
213
220
|
return V({
|
|
214
221
|
resetFields: k,
|
|
215
|
-
validateFields:
|
|
216
|
-
add:
|
|
217
|
-
remove:
|
|
218
|
-
getRowData:
|
|
222
|
+
validateFields: z,
|
|
223
|
+
add: I,
|
|
224
|
+
remove: P,
|
|
225
|
+
getRowData: G,
|
|
219
226
|
getRowsData: O,
|
|
220
|
-
setRowData:
|
|
221
|
-
addMultiple:
|
|
222
|
-
scrollTo:
|
|
223
|
-
clear:
|
|
224
|
-
setTableData:
|
|
225
|
-
|
|
227
|
+
setRowData: H,
|
|
228
|
+
addMultiple: K,
|
|
229
|
+
scrollTo: W,
|
|
230
|
+
clear: $,
|
|
231
|
+
setTableData: U,
|
|
232
|
+
removeByKey: j
|
|
233
|
+
}), (e, t) => (X(), Q(r(x), {
|
|
226
234
|
ref_key: "formRef",
|
|
227
235
|
ref: i,
|
|
228
236
|
"initial-values": {
|
|
229
|
-
[
|
|
237
|
+
[o.name]: r(m)
|
|
230
238
|
}
|
|
231
239
|
}, {
|
|
232
|
-
default: h(() => [
|
|
240
|
+
default: h(() => [b(r(x).FormItem, {
|
|
233
241
|
name: e.name,
|
|
234
242
|
"no-style": ""
|
|
235
243
|
}, {
|
|
236
|
-
default: h(() => [
|
|
244
|
+
default: h(() => [b(r(ne), Y(r(R)(o, ["name", "value", "onUpdate:value", "maxLength", "onChange"]), {
|
|
237
245
|
ref_key: "tableRef",
|
|
238
|
-
ref:
|
|
239
|
-
class:
|
|
240
|
-
columns:
|
|
241
|
-
"data-source":
|
|
242
|
-
}),
|
|
246
|
+
ref: w,
|
|
247
|
+
class: r(D)(),
|
|
248
|
+
columns: r(N),
|
|
249
|
+
"data-source": r(m)
|
|
250
|
+
}), Z({
|
|
243
251
|
_: 2
|
|
244
|
-
}, [
|
|
245
|
-
name:
|
|
246
|
-
fn: h((l) => [
|
|
252
|
+
}, [M(r(R)(L, ["headerCell"]), (a, n) => ({
|
|
253
|
+
name: n,
|
|
254
|
+
fn: h((l) => [ee(e.$slots, n, te(ae(l || {})))])
|
|
247
255
|
}))]), 1040, ["class", "columns", "data-source"])]),
|
|
248
256
|
_: 3
|
|
249
257
|
}, 8, ["name"])]),
|
|
@@ -252,5 +260,5 @@ const Re = /* @__PURE__ */ $({
|
|
|
252
260
|
}
|
|
253
261
|
});
|
|
254
262
|
export {
|
|
255
|
-
|
|
263
|
+
Fe as default
|
|
256
264
|
};
|
|
@@ -7,6 +7,7 @@ import { EllipsisConfig } from '@aplus-frontend/antdv/es/typography/Base';
|
|
|
7
7
|
import { StandardBehaviorOptions } from '../../node_modules/scroll-into-view-if-needed';
|
|
8
8
|
import { Recordable } from '../type';
|
|
9
9
|
import { ApFormItemProps } from '../ap-form';
|
|
10
|
+
import { Key } from '@aplus-frontend/antdv/es/_util/type';
|
|
10
11
|
export type EditableColumnType<RecordType = any, ExtraValueType = 'text', ValueType extends ApTableValueTypes = ApTableValueTypes, MergedValueType extends ExtraValueType | ValueType = ExtraValueType | ValueType> = MergedValueType extends ExtraValueType | ValueType ? Omit<ColumnType<RecordType>, 'children' | 'customRender' | 'ellipsis'> & {
|
|
11
12
|
children?: EditableColumnType<RecordType, ExtraValueType, ValueType, MergedValueType>[];
|
|
12
13
|
/**
|
|
@@ -138,6 +139,12 @@ export type EditableTableExpose<ModelType = any, RecordType = any> = {
|
|
|
138
139
|
* @returns
|
|
139
140
|
*/
|
|
140
141
|
remove: (index: number | number[]) => void;
|
|
142
|
+
/**
|
|
143
|
+
* 通过key删除数据
|
|
144
|
+
* @param key
|
|
145
|
+
* @returns
|
|
146
|
+
*/
|
|
147
|
+
removeByKey: (key: Key | Key[]) => void;
|
|
141
148
|
/**
|
|
142
149
|
* 清空所有数据
|
|
143
150
|
* @returns
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("vue"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("vue"),y=require("../../ap-form/index.js"),i=require("lodash-unified");require("../../config-provider/index.js");const g=require("../../utils/index.js"),E=require("../hooks/use-editable-columns.js");require("../index.vue2.js");const O=require("../../ap-form/context.js"),P=require("../../config-provider/hooks/use-namespace.js"),z=require("../../config-provider/hooks/use-global-config.js"),A=require("../index.vue.js"),K=o.defineComponent({name:"EditableGrid",__name:"form-item",props:{dropdownPrefixCls:{},bordered:{type:Boolean,default:!1},locale:{},onResizeColumn:{},getPopupContainer:{},scroll:{},sortDirections:{default:()=>["ascend","descend"]},showSorterTooltip:{type:[Boolean,Object],default:!0},prefixCls:{},tableLayout:{default:"fixed"},title:{},id:{},showHeader:{type:Boolean,default:!0},components:{},customRow:{},customHeaderRow:{},direction:{},expandFixed:{type:[String,Boolean],default:!1},expandColumnWidth:{},expandedRowKeys:{},defaultExpandedRowKeys:{},expandedRowRender:{},expandRowByClick:{type:Boolean,default:!1},expandIcon:{},onExpand:{},onExpandedRowsChange:{},defaultExpandAllRows:{type:Boolean,default:!1},indentSize:{default:15},expandIconColumnIndex:{},showExpandColumn:{type:Boolean,default:!0},expandedRowClassName:{},childrenColumnName:{default:"children"},rowExpandable:{},sticky:{type:[Boolean,Object],default:!1},transformCellText:{},rowClassName:{},stripe:{type:Boolean},headerRowClassName:{},footerRowClassName:{},cellClassName:{},headerCellClassName:{},footerCellClassName:{},rowStyle:{},headerRowStyle:{},footerRowStyle:{},cellStyle:{},headerCellStyle:{},footerCellStyle:{},height:{},minHeight:{},maxHeight:{},mergeCells:{},mergeFooterItems:{},cellConfig:{},loading:{type:Boolean,default:void 0},loadingConfig:{},headerCellConfig:{},footerCellConfig:{},round:{type:Boolean},rowSelection:{type:Boolean,default:void 0},onLoadingChange:{},onShownColumnsChange:{},pagination:{type:[Boolean,Object],default:!1},searchFormWrapperStyle:{},tableWrapperStyle:{},wrapperStyle:{},size:{default:"mini"},adaptive:{type:Boolean,default:!1},columnResizable:{type:[Boolean,Object],default:!1},rowKey:{default:"key"},footer:{},virtual:{type:[Boolean,Object],default:void 0},expandable:{},value:{},columns:{},defaultValue:{},"onUpdate:value":{},onChange:{},maxLength:{},onFieldChange:{},label:{},name:{},formItem:{default:()=>({})}},setup(h,{expose:C}){const w=o.useSlots(),u=h,{b}=P.useNamespace("editable-grid");function x(e,a){return i.isArray(a)?a.reduce((n,l)=>n==null?void 0:n[l],e):e==null?void 0:e[a]}const{internalInstance:t,model:R}=O.useInjectForm(),p=o.toRef(u.name),d=o.ref(x(o.unref(R),p.value)||[]),S=y.ApForm.useWatch(p);o.watch(()=>S.value,async e=>{var a;await o.nextTick(),d.value=e,(a=u.onChange)==null||a.call(u,e)},{deep:!0});const m=o.ref(),B=z.useGlobalConfig("valueTypeMap"),v=E.useGetEditableColumns(u,B);function N(e,a){var s;const n=((s=o.unref(d))==null?void 0:s.length)||0;if(g.isDef(u.maxLength)&&n>=u.maxLength)return;const l={...e||{}};t==null||t.setFieldValue(u.name,l,!0,(r,f)=>{if(!r[f]){r[f]=[l];return}i.isUndefined(a)?r[f].push(l):r[f].splice(a,0,l)})}function _(e,a="suffix"){var r;const n=((r=o.unref(d))==null?void 0:r.length)||0,l=i.isNumber(e)?e:e.length;if(g.isDef(u.maxLength)&&n+l>u.maxLength)return;const s=i.isNumber(e)?new Array(e).fill(0).map(()=>({})):i.cloneDeep(e);t==null||t.setFieldValue(u.name,s,!0,(f,c)=>{if(!f[c]){f[c]=[...s];return}a==="suffix"?f[c].push(...s):f[c].unshift(...s)})}function F(e){const a=new Set(i.isNumber(e)?[e]:e);t==null||t.setFieldValue(u.name,void 0,!0,(n,l)=>{n[l]=n[l].filter((s,r)=>!a.has(r))})}function D(e){var n;const a=new Set(i.isArray(e)?e:[e]);a.size!==0&&((n=t==null?void 0:t.setFieldValue)==null||n.call(t,u.name,void 0,!0,(l,s)=>{l[s]=l[s].filter(r=>!a.has(r[u.rowKey]))}))}function q(){return o.unref(d)}function T(e){var a;return(a=o.unref(d))==null?void 0:a[e]}function V(e,a,n=!0){t==null||t.setFieldValue(u.name,void 0,!0,(l,s)=>{if(!(!l[s]||!l[s][e])){if(!n){const r=Object.keys(l[s][e]);for(const f of r)f!==u.rowKey&&delete l[s][e][f]}Object.assign(l[s][e],{...a})}})}function L(e){t==null||t.setFieldValue(u.name,e)}function j(e){var n;const a=e==="end"?d.value.length-1:e;(n=m.value)==null||n.scrollToRow(a)}function k(){var e;(e=t==null?void 0:t.setFieldValue)==null||e.call(t,u.name,[])}return C({add:N,remove:F,getRowData:T,getRowsData:q,setRowData:V,addMultiple:_,scrollTo:j,setTableData:L,clear:k,removeByKey:D}),(e,a)=>(o.openBlock(),o.createBlock(o.unref(y.ApForm).FormItem,o.mergeProps(e.formItem,{name:e.name,label:e.label}),{default:o.withCtx(()=>[o.createVNode(A.default,o.mergeProps(o.unref(i.omit)(u,["name","value","onUpdate:value","maxLength","onChange","defaultValue","formItem"]),{ref_key:"tableRef",ref:m,class:o.unref(b)(),columns:o.unref(v),"data-source":d.value,"search-form":!1}),o.createSlots({_:2},[o.renderList(w,(n,l)=>({name:l,fn:o.withCtx(s=>[o.renderSlot(e.$slots,l,o.normalizeProps(o.guardReactiveProps(s||{})))])}))]),1040,["class","columns","data-source"])]),_:3},16,["name","label"]))}});exports.default=K;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=require("vue"),y=require("../../ap-form/index.js"),c=require("lodash-unified");require("../../config-provider/index.js");require("../../hooks/index.js");const C=require("../../utils/index.js"),P=require("../hooks/use-editable-columns.js");require("../index.vue2.js");const I=require("../../config-provider/hooks/use-namespace.js"),G=require("../../hooks/useControllableValue.js"),H=require("../../config-provider/hooks/use-global-config.js"),U=require("../index.vue.js"),W=a.defineComponent({name:"EditableGrid",__name:"index",props:{dropdownPrefixCls:{},bordered:{type:Boolean,default:!1},locale:{},onResizeColumn:{},getPopupContainer:{},scroll:{},sortDirections:{default:()=>["ascend","descend"]},showSorterTooltip:{type:[Boolean,Object],default:!0},prefixCls:{},tableLayout:{default:"fixed"},title:{},id:{},showHeader:{type:Boolean,default:!0},components:{},customRow:{},customHeaderRow:{},direction:{},expandFixed:{type:[String,Boolean],default:!1},expandColumnWidth:{},expandedRowKeys:{},defaultExpandedRowKeys:{},expandedRowRender:{},expandRowByClick:{type:Boolean,default:!1},expandIcon:{},onExpand:{},onExpandedRowsChange:{},defaultExpandAllRows:{type:Boolean,default:!1},indentSize:{default:15},expandIconColumnIndex:{},showExpandColumn:{type:Boolean,default:!0},expandedRowClassName:{},childrenColumnName:{default:"children"},rowExpandable:{},sticky:{type:[Boolean,Object],default:!1},transformCellText:{},rowClassName:{},stripe:{type:Boolean},headerRowClassName:{},footerRowClassName:{},cellClassName:{},headerCellClassName:{},footerCellClassName:{},rowStyle:{},headerRowStyle:{},footerRowStyle:{},cellStyle:{},headerCellStyle:{},footerCellStyle:{},height:{},minHeight:{},maxHeight:{},mergeCells:{},mergeFooterItems:{},cellConfig:{},loading:{type:Boolean,default:void 0},loadingConfig:{},headerCellConfig:{},footerCellConfig:{},round:{type:Boolean},rowSelection:{type:Boolean,default:void 0},onLoadingChange:{},onShownColumnsChange:{},pagination:{type:[Boolean,Object],default:!1},searchFormWrapperStyle:{},tableWrapperStyle:{},wrapperStyle:{},size:{default:"mini"},adaptive:{type:Boolean,default:!1},columnResizable:{type:[Boolean,Object],default:!1},rowKey:{default:"key"},footer:{},virtual:{type:[Boolean,Object],default:void 0},expandable:{},value:{},columns:{},defaultValue:{},"onUpdate:value":{},onChange:{},maxLength:{},name:{default:"ap-editable-table-inner-name"},onFieldChange:{}},emits:["update:value"],setup(w,{expose:v,emit:x}){const b=a.useSlots(),l=w,{b:R}=I.useNamespace("editable-grid"),S=x,g=a.ref(),{value:p,updateValue:B}=G.useControllableValue(l,S),i=a.ref(),F=H.useGlobalConfig("valueTypeMap"),h=y.ApForm.useWatch(l.name,i);a.watch(()=>h.value,e=>{var t;B(e),(t=l.onChange)==null||t.call(l,e)},{deep:!0,flush:"post"}),a.watch(p,e=>{var t;e!==a.unref(h)&&(c.isEqual(e,a.unref(h))||(t=i.value)==null||t.setFieldValue(l.name,e))},{deep:!0});const _=P.useGetEditableColumns(l,F);function N(){var e;(e=i.value)==null||e.resetFields()}function V(e){return e?(c.isArray(e)?e:[e]).map(n=>c.isArray(n)?[l.name,...n]:[l.name,n]):void 0}async function q(e,t){var o;const n=await((o=i.value)==null?void 0:o.validateFields(V(e),t));return n==null?void 0:n[l.name]}function A(e,t){var r,u,s;const n=((r=a.unref(p))==null?void 0:r.length)||0;if(C.isDef(l.maxLength)&&n>=l.maxLength)return;const o={...e||{}};(s=(u=i.value)==null?void 0:u.setFieldValue)==null||s.call(u,l.name,o,!0,(d,f)=>{if(!d[f]){d[f]=[o];return}c.isUndefined(t)?d[f].push(o):d[f].splice(t,0,o)})}function D(e,t="suffix"){var u,s,d;const n=((u=a.unref(p))==null?void 0:u.length)||0,o=c.isNumber(e)?e:e.length;if(C.isDef(l.maxLength)&&n+o>l.maxLength)return;const r=c.isNumber(e)?new Array(e).fill(0).map(()=>({})):c.cloneDeep(e);(d=(s=i.value)==null?void 0:s.setFieldValue)==null||d.call(s,l.name,r,!0,(f,m)=>{if(!f[m]){f[m]=[...r];return}t==="suffix"?f[m].push(...r):f[m].unshift(...r)})}function E(e){var n,o;const t=new Set(c.isNumber(e)?[e]:e);(o=(n=i.value)==null?void 0:n.setFieldValue)==null||o.call(n,l.name,void 0,!0,(r,u)=>{r[u]=r[u].filter((s,d)=>!t.has(d))})}function L(e){var n,o;const t=new Set(c.isArray(e)?e:[e]);t.size!==0&&((o=(n=i.value)==null?void 0:n.setFieldValue)==null||o.call(n,l.name,void 0,!0,(r,u)=>{r[u]=r[u].filter(s=>!t.has(s[l.rowKey]))}))}function T(){return a.unref(p)}function k(e){var t;(t=i.value)==null||t.setFieldValue(l.name,e)}function j(e){var t;return(t=a.unref(p))==null?void 0:t[e]}function O(e,t,n=!0){var o,r;(r=(o=i.value)==null?void 0:o.setFieldValue)==null||r.call(o,l.name,void 0,!0,(u,s)=>{if(!(!u[s]||!u[s][e])){if(!n){const d=Object.keys(u[s][e]);for(const f of d)f!==l.rowKey&&delete u[s][e][f]}Object.assign(u[s][e],{...t})}})}function z(e){var n;const t=e==="end"?p.value.length-1:e;(n=g.value)==null||n.scrollToRow(t)}function K(){var e,t;(t=(e=i.value)==null?void 0:e.setFieldValue)==null||t.call(e,l.name,[])}return v({resetFields:N,validateFields:q,add:A,remove:E,getRowData:j,getRowsData:T,setRowData:O,addMultiple:D,scrollTo:z,clear:K,setTableData:k,removeByKey:L}),(e,t)=>(a.openBlock(),a.createBlock(a.unref(y.ApForm),{ref_key:"formRef",ref:i,"initial-values":{[l.name]:a.unref(p)},style:{height:"100%"}},{default:a.withCtx(()=>[a.createVNode(a.unref(y.ApForm).FormItem,{name:e.name,"no-style":""},{default:a.withCtx(()=>[a.createVNode(U.default,a.mergeProps(a.unref(c.omit)(l,["name","value","onUpdate:value","maxLength","onChange","defaultValue"]),{ref_key:"tableRef",ref:g,class:a.unref(R)(),columns:a.unref(_),"data-source":a.unref(p),"search-form":!1}),a.createSlots({_:2},[a.renderList(b,(n,o)=>({name:o,fn:a.withCtx(r=>[a.renderSlot(e.$slots,o,a.normalizeProps(a.guardReactiveProps(r||{})))])}))]),1040,["class","columns","data-source"])]),_:3},8,["name"])]),_:3},8,["initial-values"]))}});exports.default=W;
|