@aplus-frontend/ui 7.19.4 → 7.19.6
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/ag-grid/editable/form-item.vue.mjs +43 -39
- package/es/src/ag-grid/editable/index.vue.mjs +14 -10
- package/es/src/ag-grid/editable/interface.d.ts +10 -1
- package/es/src/ag-grid/hooks/use-editable-api.d.ts +1 -0
- package/es/src/ag-grid/hooks/use-editable-api.mjs +93 -87
- package/es/src/ag-grid/hooks/use-editable-columns.d.ts +2 -2
- package/es/src/ag-grid/hooks/use-editable-columns.mjs +84 -76
- package/es/src/ag-grid/hooks/use-editable-form-item-api.d.ts +1 -0
- package/es/src/ag-grid/hooks/use-editable-form-item-api.mjs +100 -94
- package/es/src/business/ap-product-info/constans.mjs +1 -1
- package/es/src/version.d.ts +1 -1
- package/es/src/version.mjs +1 -1
- package/lib/src/ag-grid/editable/form-item.vue.js +1 -1
- package/lib/src/ag-grid/editable/index.vue.js +1 -1
- package/lib/src/ag-grid/editable/interface.d.ts +10 -1
- package/lib/src/ag-grid/hooks/use-editable-api.d.ts +1 -0
- package/lib/src/ag-grid/hooks/use-editable-api.js +1 -1
- package/lib/src/ag-grid/hooks/use-editable-columns.d.ts +2 -2
- package/lib/src/ag-grid/hooks/use-editable-columns.js +1 -1
- package/lib/src/ag-grid/hooks/use-editable-form-item-api.d.ts +1 -0
- package/lib/src/ag-grid/hooks/use-editable-form-item-api.js +1 -1
- package/lib/src/business/ap-product-info/constans.js +1 -1
- package/lib/src/version.d.ts +1 -1
- package/lib/src/version.js +1 -1
- package/package.json +3 -3
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { defineComponent as G, useSlots as
|
|
1
|
+
import { defineComponent as G, useSlots as U, ref as g, onMounted as W, watch as $, unref as r, createElementBlock as q, openBlock as J, Fragment as Q, createVNode as f, mergeProps as h, withCtx as C, createSlots as X, renderList as Y, renderSlot as Z, normalizeProps as ee, guardReactiveProps as oe } from "vue";
|
|
2
2
|
import { cloneDeep as u, isEqual as te, omit as ae } from "lodash-unified";
|
|
3
|
-
import { ApForm as
|
|
3
|
+
import { ApForm as R } from "../../ap-form/index.mjs";
|
|
4
4
|
import { useInjectForm as ne } from "../../ap-form/context.mjs";
|
|
5
5
|
import { useWatch as le } from "../../ap-form/hooks/use-watch.mjs";
|
|
6
6
|
import { getModelValue as re } from "../../ap-form/utils/get.mjs";
|
|
7
|
-
import { transformValues as
|
|
7
|
+
import { transformValues as se } from "../../ap-form/utils/transform.mjs";
|
|
8
8
|
import "../../config-provider/index.mjs";
|
|
9
|
-
import { useGetEditableColumns as
|
|
9
|
+
import { useGetEditableColumns as ie } from "../hooks/use-editable-columns.mjs";
|
|
10
10
|
import { useEditableFormItemApi as me } from "../hooks/use-editable-form-item-api.mjs";
|
|
11
11
|
import "../index.vue2.mjs";
|
|
12
12
|
import ue from "../style/editable.mjs";
|
|
13
13
|
import { getShadowName as de } from "../utils.mjs";
|
|
14
|
-
import { getColumnTransformOptions as pe, arrayToObject as
|
|
14
|
+
import { getColumnTransformOptions as pe, arrayToObject as b, getRowKey as fe } from "./utils.mjs";
|
|
15
15
|
import { useNamespace as ce } from "../../config-provider/hooks/use-namespace.mjs";
|
|
16
16
|
import { useGlobalConfig as we } from "../../config-provider/hooks/use-global-config.mjs";
|
|
17
|
-
import
|
|
17
|
+
import ye from "../index.vue.mjs";
|
|
18
18
|
const Ke = /* @__PURE__ */ G({
|
|
19
19
|
name: "EditableGrid",
|
|
20
20
|
__name: "form-item",
|
|
@@ -134,6 +134,10 @@ const Ke = /* @__PURE__ */ G({
|
|
|
134
134
|
onChange: {},
|
|
135
135
|
maxLength: {},
|
|
136
136
|
onFieldChange: {},
|
|
137
|
+
supressForceRowUpdate: {
|
|
138
|
+
type: Boolean,
|
|
139
|
+
default: !1
|
|
140
|
+
},
|
|
137
141
|
label: {},
|
|
138
142
|
name: {},
|
|
139
143
|
formItem: {}
|
|
@@ -141,27 +145,27 @@ const Ke = /* @__PURE__ */ G({
|
|
|
141
145
|
setup(v, {
|
|
142
146
|
expose: B
|
|
143
147
|
}) {
|
|
144
|
-
const x =
|
|
148
|
+
const x = U(), t = v, {
|
|
145
149
|
b: S
|
|
146
|
-
} = ce("editable-aggrid"), I = ue("editable-aggrid"), m =
|
|
150
|
+
} = ce("editable-aggrid"), I = ue("editable-aggrid"), m = g(), {
|
|
147
151
|
internalInstance: n
|
|
148
152
|
} = ne();
|
|
149
153
|
function F(e) {
|
|
150
|
-
const o = pe(
|
|
154
|
+
const o = pe(t.columns || []);
|
|
151
155
|
if (!Object.keys(o).length || !e?.length)
|
|
152
156
|
return e;
|
|
153
|
-
let
|
|
154
|
-
for (const
|
|
155
|
-
|
|
156
|
-
return
|
|
157
|
+
let a = [];
|
|
158
|
+
for (const i of e)
|
|
159
|
+
a.push(se(i, o));
|
|
160
|
+
return a;
|
|
157
161
|
}
|
|
158
|
-
const
|
|
162
|
+
const s = de(t.name);
|
|
159
163
|
let c = [];
|
|
160
|
-
|
|
161
|
-
const e =
|
|
162
|
-
e && (n?.updateInitialModel(
|
|
164
|
+
W(() => {
|
|
165
|
+
const e = t.formItem?.initialValue ?? re(n?.getInitialValues() ?? {}, t.name);
|
|
166
|
+
e && (n?.updateInitialModel(s, b(u(e), t.rowKey)), c = u(e), l.value || j(u(e), "suffix", !0));
|
|
163
167
|
});
|
|
164
|
-
const l =
|
|
168
|
+
const l = g([]), T = le(t.name);
|
|
165
169
|
$(() => T.value, (e) => {
|
|
166
170
|
te(e, l.value) || w(e ?? u(c));
|
|
167
171
|
}, {
|
|
@@ -169,7 +173,7 @@ const Ke = /* @__PURE__ */ G({
|
|
|
169
173
|
flush: "post",
|
|
170
174
|
immediate: !0
|
|
171
175
|
});
|
|
172
|
-
const E = we("valueTypeMap"), V =
|
|
176
|
+
const E = we("valueTypeMap"), V = ie(t, E, s), {
|
|
173
177
|
add: N,
|
|
174
178
|
addMultiple: _,
|
|
175
179
|
__addMultiple: j,
|
|
@@ -180,36 +184,36 @@ const Ke = /* @__PURE__ */ G({
|
|
|
180
184
|
setRowData: z,
|
|
181
185
|
clear: H,
|
|
182
186
|
refreshRowIds: d
|
|
183
|
-
} = me(
|
|
187
|
+
} = me(t, n, l, s);
|
|
184
188
|
function L() {
|
|
185
189
|
const e = m.value?._internalGridApi;
|
|
186
190
|
if (!d.value?.length || !e)
|
|
187
191
|
return;
|
|
188
|
-
const o = d.value.map((
|
|
189
|
-
e.refreshCells({
|
|
192
|
+
const o = d.value.map((a) => e.getRowNode(a)).filter((a) => !!a);
|
|
193
|
+
t.supressForceRowUpdate || e.refreshCells({
|
|
190
194
|
rowNodes: o,
|
|
191
195
|
force: !0
|
|
192
196
|
}), d.value = [];
|
|
193
197
|
}
|
|
194
198
|
function w(e) {
|
|
195
199
|
l.value = [...e];
|
|
196
|
-
const o =
|
|
197
|
-
n?.setFieldValue(
|
|
200
|
+
const o = b(e, t.rowKey);
|
|
201
|
+
n?.setFieldValue(t.name, [...e]), n?.setFieldValue(s, o);
|
|
198
202
|
}
|
|
199
|
-
function
|
|
200
|
-
const
|
|
201
|
-
m.value?.scrollToRow(
|
|
203
|
+
function y(e, o) {
|
|
204
|
+
const a = e === "end" ? l.value.length - 1 : e;
|
|
205
|
+
m.value?.scrollToRow(a, o);
|
|
202
206
|
}
|
|
203
207
|
function M(e, o) {
|
|
204
208
|
m.value?.scrollToColumn(e, o);
|
|
205
209
|
}
|
|
206
210
|
function P(e, o) {
|
|
207
|
-
const
|
|
208
|
-
return n?.validateFields([
|
|
211
|
+
const a = [s, String(e), o].flat();
|
|
212
|
+
return n?.validateFields([a]);
|
|
209
213
|
}
|
|
210
214
|
function A(e) {
|
|
211
|
-
const
|
|
212
|
-
return n?.validateFields(
|
|
215
|
+
const a = r(l).map((i, p) => [s, String(fe(i, p, t.rowKey)), e].flat());
|
|
216
|
+
return n?.validateFields(a);
|
|
213
217
|
}
|
|
214
218
|
return B({
|
|
215
219
|
add: N,
|
|
@@ -221,21 +225,21 @@ const Ke = /* @__PURE__ */ G({
|
|
|
221
225
|
setRowData: z,
|
|
222
226
|
clear: H,
|
|
223
227
|
setTableData: w,
|
|
224
|
-
scrollTo:
|
|
225
|
-
scrollToRow:
|
|
228
|
+
scrollTo: y,
|
|
229
|
+
scrollToRow: y,
|
|
226
230
|
scrollToColumn: M,
|
|
227
231
|
validateCell: P,
|
|
228
232
|
validateColumn: A,
|
|
229
233
|
table: m
|
|
230
|
-
}), (e, o) => (J(), q(Q, null, [f(r(
|
|
234
|
+
}), (e, o) => (J(), q(Q, null, [f(r(R).FormItem, {
|
|
231
235
|
hidden: "",
|
|
232
236
|
name: e.name,
|
|
233
237
|
"initial-value": e.formItem?.initialValue,
|
|
234
238
|
transform: F
|
|
235
|
-
}, null, 8, ["name", "initial-value"]), f(r(
|
|
239
|
+
}, null, 8, ["name", "initial-value"]), f(r(R).FormItem, h({
|
|
236
240
|
label: e.label
|
|
237
241
|
}, e.formItem), {
|
|
238
|
-
default: C(() => [f(
|
|
242
|
+
default: C(() => [f(ye, h(r(ae)(t, ["name", "maxLength", "onChange", "defaultValue", "formItem"]), {
|
|
239
243
|
ref_key: "tableRef",
|
|
240
244
|
ref: m,
|
|
241
245
|
class: [r(S)(), r(I)],
|
|
@@ -246,9 +250,9 @@ const Ke = /* @__PURE__ */ G({
|
|
|
246
250
|
onUpdate: L
|
|
247
251
|
}), X({
|
|
248
252
|
_: 2
|
|
249
|
-
}, [Y(x, (
|
|
250
|
-
name:
|
|
251
|
-
fn: C((p) => [Z(e.$slots,
|
|
253
|
+
}, [Y(x, (a, i) => ({
|
|
254
|
+
name: i,
|
|
255
|
+
fn: C((p) => [Z(e.$slots, i, ee(oe(p || {})))])
|
|
252
256
|
}))]), 1040, ["class", "columns", "data-source"])]),
|
|
253
257
|
_: 3
|
|
254
258
|
}, 16, ["label"])], 64));
|
|
@@ -135,7 +135,11 @@ const Fe = /* @__PURE__ */ M({
|
|
|
135
135
|
name: {
|
|
136
136
|
default: "ap-editable-table-inner-name"
|
|
137
137
|
},
|
|
138
|
-
onFieldChange: {}
|
|
138
|
+
onFieldChange: {},
|
|
139
|
+
supressForceRowUpdate: {
|
|
140
|
+
type: Boolean,
|
|
141
|
+
default: !1
|
|
142
|
+
}
|
|
139
143
|
},
|
|
140
144
|
emits: ["update:value"],
|
|
141
145
|
setup(C, {
|
|
@@ -170,12 +174,12 @@ const Fe = /* @__PURE__ */ M({
|
|
|
170
174
|
if (!d.value?.length || !e)
|
|
171
175
|
return;
|
|
172
176
|
const o = d.value.map((t) => e.getRowNode(t)).filter((t) => !!t);
|
|
173
|
-
e.refreshCells({
|
|
177
|
+
a.supressForceRowUpdate || e.refreshCells({
|
|
174
178
|
rowNodes: o,
|
|
175
179
|
force: !0
|
|
176
180
|
}), d.value = [];
|
|
177
181
|
}
|
|
178
|
-
function
|
|
182
|
+
function U() {
|
|
179
183
|
r.value?.resetFields();
|
|
180
184
|
}
|
|
181
185
|
function w(e) {
|
|
@@ -189,15 +193,15 @@ const Fe = /* @__PURE__ */ M({
|
|
|
189
193
|
return e;
|
|
190
194
|
}
|
|
191
195
|
}
|
|
192
|
-
async function
|
|
196
|
+
async function L(e, o) {
|
|
193
197
|
const n = (await r.value?.validateFields(w(e), o))?.[a.name];
|
|
194
198
|
return g(n);
|
|
195
199
|
}
|
|
196
|
-
async function
|
|
200
|
+
async function P(e, o) {
|
|
197
201
|
const n = (await r.value?.validateFieldsReturnTransformed(w(e), o))?.[a.name];
|
|
198
202
|
return g(n);
|
|
199
203
|
}
|
|
200
|
-
function
|
|
204
|
+
function G(e) {
|
|
201
205
|
y(e);
|
|
202
206
|
const o = f(e, a.rowKey);
|
|
203
207
|
r.value?.setFieldValue(a.name, o);
|
|
@@ -210,9 +214,9 @@ const Fe = /* @__PURE__ */ M({
|
|
|
210
214
|
i.value?.scrollToColumn(e, o);
|
|
211
215
|
}
|
|
212
216
|
return x({
|
|
213
|
-
resetFields:
|
|
214
|
-
validateFields:
|
|
215
|
-
validateFieldsReturnTransformed:
|
|
217
|
+
resetFields: U,
|
|
218
|
+
validateFields: L,
|
|
219
|
+
validateFieldsReturnTransformed: P,
|
|
216
220
|
add: A,
|
|
217
221
|
addMultiple: N,
|
|
218
222
|
remove: j,
|
|
@@ -221,7 +225,7 @@ const Fe = /* @__PURE__ */ M({
|
|
|
221
225
|
getRowsData: D,
|
|
222
226
|
setRowData: z,
|
|
223
227
|
clear: H,
|
|
224
|
-
setTableData:
|
|
228
|
+
setTableData: G,
|
|
225
229
|
scrollTo: R,
|
|
226
230
|
scrollToRow: R,
|
|
227
231
|
scrollToColumn: W,
|
|
@@ -77,7 +77,16 @@ export type EditableAgGridProps<RecordType = any> = Omit<AgGridProps<RecordType>
|
|
|
77
77
|
* 当字段值变更的时候触发(注意,向表单设置值并不会触发)
|
|
78
78
|
* @returns
|
|
79
79
|
*/
|
|
80
|
-
onFieldChange?: (rowIndex: number, fieldName: DataIndex, newValue: any) => void;
|
|
80
|
+
onFieldChange?: (rowIndex: number, fieldName: DataIndex, newValue: any, record: RecordType) => void;
|
|
81
|
+
/**
|
|
82
|
+
* 是否禁止在行操作后(添加/删除行等)避免强制更新
|
|
83
|
+
* 默认情况下,表格行会在行操作后强制更新哪些受到影响的行来保证渲染始终是正确的,但这样会导致表单校验被清空、频繁更新导致渲染性能下降等问题
|
|
84
|
+
* 设置为`true`后,在行操作后不会主动强制更新受影响的行,由于不再更新行,配置中如果`editable`/`fieldProps`/`customRender`等函数使用
|
|
85
|
+
* 到了`rowIndex`等字段可能会出现渲染异常的问题
|
|
86
|
+
* @default false
|
|
87
|
+
* @since 7.19.5
|
|
88
|
+
*/
|
|
89
|
+
supressForceRowUpdate?: boolean;
|
|
81
90
|
};
|
|
82
91
|
export type EditableAgGridExpose<RecordType = any, ModelType = RecordType[]> = Omit<EditableTableExpose<ModelType, RecordType>, 'scrollTo' | 'remove'> & {
|
|
83
92
|
scrollTo: (index: number | 'end', position?: 'top' | 'bottom' | 'middle') => void;
|
|
@@ -12,4 +12,5 @@ export declare const useEditableApi: <RecordType>(props: EditableAgGridProps<Rec
|
|
|
12
12
|
setRowData: (index: string | number, payload: any, merge?: boolean) => void;
|
|
13
13
|
clear: () => void;
|
|
14
14
|
refreshRowIds: ShallowRef<string[], string[]>;
|
|
15
|
+
getRowDataByKey: (key: Key) => RecordType | undefined;
|
|
15
16
|
};
|
|
@@ -1,151 +1,157 @@
|
|
|
1
|
-
import { isFunction as h, isUndefined as
|
|
2
|
-
import { shallowRef as
|
|
1
|
+
import { isFunction as h, isUndefined as S, isNumber as K, cloneDeep as z, isArray as x, isString as A } from "lodash-unified";
|
|
2
|
+
import { shallowRef as E, computed as N, unref as d, isRef as U } from "vue";
|
|
3
3
|
import "../../utils/index.mjs";
|
|
4
|
-
import { arrayToObject as
|
|
5
|
-
import { isDef as
|
|
6
|
-
let
|
|
7
|
-
function
|
|
8
|
-
return `_ag_grid${
|
|
4
|
+
import { arrayToObject as $ } from "../editable/utils.mjs";
|
|
5
|
+
import { isDef as R } from "../../utils/is.mjs";
|
|
6
|
+
let q = 0;
|
|
7
|
+
function I() {
|
|
8
|
+
return `_ag_grid${q++}`;
|
|
9
9
|
}
|
|
10
|
-
const
|
|
11
|
-
const w =
|
|
12
|
-
function F(
|
|
10
|
+
const Q = (u, m, i, g) => {
|
|
11
|
+
const w = E([]), y = N(() => U(m) ? d(m) : m);
|
|
12
|
+
function F(n, t) {
|
|
13
13
|
const l = d(i)?.length || 0;
|
|
14
|
-
if (
|
|
14
|
+
if (R(u.maxLength) && l >= u.maxLength || !n && h(u.rowKey))
|
|
15
15
|
return;
|
|
16
|
-
const
|
|
17
|
-
...
|
|
16
|
+
const o = {
|
|
17
|
+
...n || { [u.rowKey]: I() }
|
|
18
18
|
};
|
|
19
19
|
y.value?.setFieldValue?.(
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
u.name,
|
|
21
|
+
o,
|
|
22
22
|
!0,
|
|
23
|
-
(
|
|
24
|
-
const e =
|
|
25
|
-
if (
|
|
26
|
-
i.value = [
|
|
23
|
+
(r, c) => {
|
|
24
|
+
const e = s(o, void 0, u.rowKey);
|
|
25
|
+
if (r[c] ? r[c][e] = o : r[c] = { [e]: o }, !i.value) {
|
|
26
|
+
i.value = [o];
|
|
27
27
|
return;
|
|
28
28
|
}
|
|
29
|
-
|
|
30
|
-
(
|
|
31
|
-
).filter(Boolean), i.value.splice(
|
|
29
|
+
S(t) ? i.value.push(o) : (w.value = i.value.map(
|
|
30
|
+
(f, v) => v < t ? null : s(f, v, u.rowKey)
|
|
31
|
+
).filter(Boolean), i.value.splice(t, 0, o));
|
|
32
32
|
}
|
|
33
33
|
);
|
|
34
34
|
}
|
|
35
|
-
function j(
|
|
36
|
-
const l = d(i)?.length || 0,
|
|
37
|
-
if (
|
|
35
|
+
function j(n, t = "suffix") {
|
|
36
|
+
const l = d(i)?.length || 0, o = K(n) ? n : n.length;
|
|
37
|
+
if (R(u.maxLength) && l + o > u.maxLength || K(n) && h(u.rowKey))
|
|
38
38
|
return;
|
|
39
|
-
const
|
|
39
|
+
const r = K(n) ? new Array(n).fill(0).map(() => ({ [u.rowKey]: I() })) : z(n), c = $(r, u.rowKey);
|
|
40
40
|
y.value?.setFieldValue?.(
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
u.name,
|
|
42
|
+
r,
|
|
43
43
|
!0,
|
|
44
|
-
(e,
|
|
45
|
-
if (e[
|
|
46
|
-
i.value = [...
|
|
44
|
+
(e, f) => {
|
|
45
|
+
if (e[f] ? Object.assign(e[f], c) : e[f] = c, !i.value) {
|
|
46
|
+
i.value = [...r];
|
|
47
47
|
return;
|
|
48
48
|
}
|
|
49
|
-
|
|
50
|
-
(v,
|
|
51
|
-
), i.value.unshift(...
|
|
49
|
+
t === "suffix" ? i.value.push(...r) : (w.value = i.value.map(
|
|
50
|
+
(v, _) => s(v, _, u.rowKey)
|
|
51
|
+
), i.value.unshift(...r));
|
|
52
52
|
}
|
|
53
53
|
);
|
|
54
54
|
}
|
|
55
|
-
function k(
|
|
56
|
-
const
|
|
55
|
+
function k(n) {
|
|
56
|
+
const t = x(n) ? n : [n];
|
|
57
57
|
y.value?.setFieldValue?.(
|
|
58
|
-
|
|
58
|
+
u.name,
|
|
59
59
|
void 0,
|
|
60
60
|
!0,
|
|
61
|
-
(l,
|
|
62
|
-
for (const e of
|
|
63
|
-
const
|
|
64
|
-
delete l[
|
|
61
|
+
(l, o) => {
|
|
62
|
+
for (const e of t) {
|
|
63
|
+
const f = s(e, void 0, u.rowKey);
|
|
64
|
+
delete l[o][f];
|
|
65
65
|
}
|
|
66
|
-
const
|
|
67
|
-
(e) => !
|
|
68
|
-
),
|
|
69
|
-
(e) =>
|
|
66
|
+
const r = i.value.filter(
|
|
67
|
+
(e) => !t.includes(e)
|
|
68
|
+
), c = i.value.findIndex(
|
|
69
|
+
(e) => t.includes(e)
|
|
70
70
|
);
|
|
71
71
|
w.value = i.value.map(
|
|
72
|
-
(e,
|
|
73
|
-
).filter(Boolean), g?.(
|
|
72
|
+
(e, f) => f <= c ? null : s(e, f, u.rowKey)
|
|
73
|
+
).filter(Boolean), g?.(r);
|
|
74
74
|
}
|
|
75
75
|
);
|
|
76
76
|
}
|
|
77
|
-
function
|
|
77
|
+
function s(n, t, l) {
|
|
78
78
|
if (l)
|
|
79
|
-
return
|
|
79
|
+
return A(l) ? n[l] : l(n, t);
|
|
80
80
|
}
|
|
81
|
-
function
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
|
|
81
|
+
function B(n) {
|
|
82
|
+
const t = new Set(x(n) ? n : [n]);
|
|
83
|
+
t.size !== 0 && y.value?.setFieldValue?.(
|
|
84
|
+
u.name,
|
|
85
85
|
void 0,
|
|
86
86
|
!0,
|
|
87
|
-
(l,
|
|
88
|
-
for (const e of
|
|
89
|
-
delete l[
|
|
90
|
-
const
|
|
91
|
-
(e,
|
|
92
|
-
),
|
|
93
|
-
(e,
|
|
87
|
+
(l, o) => {
|
|
88
|
+
for (const e of t)
|
|
89
|
+
delete l[o][e];
|
|
90
|
+
const r = i.value.filter(
|
|
91
|
+
(e, f) => !t.has(s(e, f, u.rowKey))
|
|
92
|
+
), c = i.value.findIndex(
|
|
93
|
+
(e, f) => t.has(s(e, f, u.rowKey))
|
|
94
94
|
);
|
|
95
95
|
w.value = i.value.map(
|
|
96
|
-
(e,
|
|
97
|
-
).filter(Boolean), g?.(
|
|
96
|
+
(e, f) => f <= c ? null : s(e, f, u.rowKey)
|
|
97
|
+
).filter(Boolean), g?.(r);
|
|
98
98
|
}
|
|
99
99
|
);
|
|
100
100
|
}
|
|
101
|
-
function
|
|
102
|
-
return d(i)?.[
|
|
101
|
+
function L(n) {
|
|
102
|
+
return d(i)?.[n];
|
|
103
|
+
}
|
|
104
|
+
function O(n) {
|
|
105
|
+
return i.value?.find(
|
|
106
|
+
(t, l) => s(t, l, u.rowKey) === n
|
|
107
|
+
);
|
|
103
108
|
}
|
|
104
109
|
function V() {
|
|
105
110
|
return d(i);
|
|
106
111
|
}
|
|
107
|
-
function
|
|
112
|
+
function a(n, t, l = !0) {
|
|
108
113
|
y.value?.setFieldValue?.(
|
|
109
|
-
|
|
114
|
+
u.name,
|
|
110
115
|
void 0,
|
|
111
116
|
!0,
|
|
112
|
-
(
|
|
113
|
-
const
|
|
114
|
-
(
|
|
117
|
+
(o, r) => {
|
|
118
|
+
const c = i.value.findIndex(
|
|
119
|
+
(f, v) => n === v
|
|
115
120
|
);
|
|
116
|
-
if (!~
|
|
121
|
+
if (!~c)
|
|
117
122
|
return;
|
|
118
|
-
const e =
|
|
119
|
-
i.value[
|
|
120
|
-
|
|
121
|
-
|
|
123
|
+
const e = s(
|
|
124
|
+
i.value[c],
|
|
125
|
+
c,
|
|
126
|
+
u.rowKey
|
|
122
127
|
);
|
|
123
|
-
if (e && !(!
|
|
128
|
+
if (e && !(!o[r] || !o[r][e])) {
|
|
124
129
|
if (!l) {
|
|
125
|
-
const
|
|
126
|
-
for (const v of
|
|
127
|
-
v !==
|
|
130
|
+
const f = Object.keys(o[r][e]);
|
|
131
|
+
for (const v of f)
|
|
132
|
+
v !== u.rowKey && delete o[r][e][v];
|
|
128
133
|
}
|
|
129
|
-
Object.assign(
|
|
134
|
+
Object.assign(o[r][e], { ...t });
|
|
130
135
|
}
|
|
131
136
|
}
|
|
132
137
|
);
|
|
133
138
|
}
|
|
134
|
-
function
|
|
135
|
-
y.value?.setFieldValue?.(
|
|
139
|
+
function T() {
|
|
140
|
+
y.value?.setFieldValue?.(u.name, {}), g?.([]);
|
|
136
141
|
}
|
|
137
142
|
return {
|
|
138
143
|
add: F,
|
|
139
144
|
addMultiple: j,
|
|
140
145
|
remove: k,
|
|
141
|
-
removeByKey:
|
|
142
|
-
getRowData:
|
|
146
|
+
removeByKey: B,
|
|
147
|
+
getRowData: L,
|
|
143
148
|
getRowsData: V,
|
|
144
|
-
setRowData:
|
|
145
|
-
clear:
|
|
146
|
-
refreshRowIds: w
|
|
149
|
+
setRowData: a,
|
|
150
|
+
clear: T,
|
|
151
|
+
refreshRowIds: w,
|
|
152
|
+
getRowDataByKey: O
|
|
147
153
|
};
|
|
148
154
|
};
|
|
149
155
|
export {
|
|
150
|
-
|
|
156
|
+
Q as useEditableApi
|
|
151
157
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Ref } from 'vue';
|
|
2
2
|
import { ValueTypeRenderConfig } from '../../config-provider';
|
|
3
3
|
import { EditableAgGridProps } from '../editable/interface';
|
|
4
4
|
import { AgGridColumnType } from '../interface';
|
|
5
|
-
export declare const useGetEditableColumns: (props: EditableAgGridProps, extraValueTypes: Ref<Record<string, ValueTypeRenderConfig> | undefined>, shadowName?: string) =>
|
|
5
|
+
export declare const useGetEditableColumns: (props: EditableAgGridProps, extraValueTypes: Ref<Record<string, ValueTypeRenderConfig> | undefined>, shadowName?: string) => Ref<AgGridColumnType[]>;
|
|
6
6
|
export default useGetEditableColumns;
|
|
@@ -1,104 +1,112 @@
|
|
|
1
|
-
import { clsx as
|
|
2
|
-
import { isArray as g, isFunction as
|
|
3
|
-
import {
|
|
4
|
-
import { getFinalEditableNode as
|
|
5
|
-
import { updateFormProps as
|
|
6
|
-
import { getColumnIsRequired as
|
|
1
|
+
import { clsx as v } from "clsx";
|
|
2
|
+
import { isArray as g, isFunction as C } from "lodash-unified";
|
|
3
|
+
import { ref as E, watch as F, unref as y } from "vue";
|
|
4
|
+
import { getFinalEditableNode as q } from "../../ap-grid/utils/editable.mjs";
|
|
5
|
+
import { updateFormProps as A, getFieldProps as K } from "../../ap-table/utils.mjs";
|
|
6
|
+
import { getColumnIsRequired as M } from "../../editable-table/utils.mjs";
|
|
7
7
|
import "../../utils/index.mjs";
|
|
8
|
-
import { getRowKey as
|
|
9
|
-
import { isDef as
|
|
10
|
-
function
|
|
11
|
-
t.__skipNextRefresh ? t.__skipNextRefresh[
|
|
8
|
+
import { getRowKey as S } from "../editable/utils.mjs";
|
|
9
|
+
import { isDef as D } from "../../utils/is.mjs";
|
|
10
|
+
function I(t, d, r) {
|
|
11
|
+
t.__skipNextRefresh ? t.__skipNextRefresh[d] = r : t.__skipNextRefresh = { [d]: r };
|
|
12
12
|
}
|
|
13
|
-
function
|
|
14
|
-
t.__prevEditable ? t.__prevEditable[
|
|
13
|
+
function G(t, d, r) {
|
|
14
|
+
t.__prevEditable ? t.__prevEditable[d] = r : t.__prevEditable = { [d]: r };
|
|
15
15
|
}
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
const Q = (t, d, r) => {
|
|
17
|
+
const _ = E([]);
|
|
18
|
+
F(
|
|
19
|
+
() => t.columns,
|
|
20
|
+
(e) => {
|
|
21
|
+
if (!e?.length) {
|
|
22
|
+
_.value = [];
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
function c(a) {
|
|
26
|
+
return a.map((n) => ({
|
|
27
|
+
...n,
|
|
28
|
+
_requireMark: M(n),
|
|
29
|
+
children: c(n.children || []),
|
|
30
|
+
// 处理可编辑/不可编辑下的单元格渲染
|
|
31
|
+
...R(n)
|
|
32
|
+
}));
|
|
33
|
+
}
|
|
34
|
+
_.value = c(e);
|
|
35
|
+
},
|
|
36
|
+
{ immediate: !0, deep: !0 }
|
|
37
|
+
);
|
|
38
|
+
function R(e) {
|
|
39
|
+
const c = e.editable, a = r ? [r] : g(t.name) ? t.name : [t.name];
|
|
40
|
+
return !c || e.children?.length ? {
|
|
41
|
+
_path: [...a]
|
|
21
42
|
} : {
|
|
22
|
-
customRender({ value:
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
43
|
+
customRender({ value: n, originalNode: p, params: o, ...i }) {
|
|
44
|
+
const s = C(e.editable) ? e.editable(
|
|
45
|
+
i.text,
|
|
46
|
+
i.record,
|
|
47
|
+
i.rowIndex
|
|
27
48
|
) : !!e.editable;
|
|
28
|
-
let u =
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
49
|
+
let u = p;
|
|
50
|
+
const w = g(e.dataIndex) ? e.dataIndex : [e.dataIndex], x = S(
|
|
51
|
+
i.record,
|
|
52
|
+
i.rowIndex,
|
|
32
53
|
t.rowKey
|
|
33
54
|
);
|
|
34
|
-
if (
|
|
35
|
-
const
|
|
55
|
+
if (s) {
|
|
56
|
+
const h = A(
|
|
36
57
|
e,
|
|
37
|
-
|
|
38
|
-
value:
|
|
39
|
-
...
|
|
58
|
+
K(e.fieldProps, {
|
|
59
|
+
value: n,
|
|
60
|
+
...i
|
|
40
61
|
})
|
|
41
|
-
),
|
|
42
|
-
t.onFieldChange && (
|
|
43
|
-
|
|
62
|
+
), b = {};
|
|
63
|
+
t.onFieldChange && (b[`onUpdate:${h.valuePropName || "value"}`] = (k) => t.onFieldChange?.(
|
|
64
|
+
i.rowIndex,
|
|
44
65
|
e.dataIndex,
|
|
45
|
-
|
|
66
|
+
k,
|
|
67
|
+
i.record
|
|
46
68
|
));
|
|
47
|
-
const
|
|
48
|
-
name: [...
|
|
49
|
-
...
|
|
69
|
+
const N = {
|
|
70
|
+
name: [...a, String(x), ...w],
|
|
71
|
+
...h || {},
|
|
50
72
|
field: {
|
|
51
73
|
style: "width: 100%",
|
|
52
|
-
...
|
|
53
|
-
...
|
|
54
|
-
class:
|
|
74
|
+
...h?.field || {},
|
|
75
|
+
...b,
|
|
76
|
+
class: v("is-editable", h.class)
|
|
55
77
|
}
|
|
56
78
|
};
|
|
57
|
-
u =
|
|
79
|
+
u = q(
|
|
58
80
|
e,
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
81
|
+
N,
|
|
82
|
+
i.record,
|
|
83
|
+
y(d)
|
|
62
84
|
);
|
|
63
85
|
}
|
|
64
86
|
e.customRender && (u = e.customRender({
|
|
65
|
-
value:
|
|
66
|
-
...
|
|
67
|
-
editable:
|
|
87
|
+
value: n,
|
|
88
|
+
...i,
|
|
89
|
+
editable: s,
|
|
68
90
|
originalNode: u,
|
|
69
|
-
index:
|
|
70
|
-
renderIndex:
|
|
71
|
-
path: [...
|
|
91
|
+
index: i.rowIndex,
|
|
92
|
+
renderIndex: i.rowIndex,
|
|
93
|
+
path: [...a, String(x)]
|
|
72
94
|
}));
|
|
73
|
-
const l =
|
|
74
|
-
return !l.__skipNextRefresh?.[f] &&
|
|
75
|
-
|
|
76
|
-
rowNodes: [
|
|
77
|
-
columns: [
|
|
95
|
+
const l = o.node, f = o.column.getColId(), m = l.__prevEditable?.[f];
|
|
96
|
+
return !l.__skipNextRefresh?.[f] && D(m) && m !== s && (I(l, f, !0), setTimeout(() => {
|
|
97
|
+
o?.api.refreshCells({
|
|
98
|
+
rowNodes: [o.node],
|
|
99
|
+
columns: [o.column.getColId()],
|
|
78
100
|
force: !0
|
|
79
|
-
}),
|
|
80
|
-
}, 0)),
|
|
101
|
+
}), I(l, f, !1);
|
|
102
|
+
}, 0)), G(l, f, s), u;
|
|
81
103
|
},
|
|
82
|
-
_path: [...
|
|
104
|
+
_path: [...a]
|
|
83
105
|
};
|
|
84
106
|
}
|
|
85
|
-
return
|
|
86
|
-
const e = t.columns;
|
|
87
|
-
if (!e)
|
|
88
|
-
return [];
|
|
89
|
-
function s(o) {
|
|
90
|
-
return o.map((d) => ({
|
|
91
|
-
...d,
|
|
92
|
-
_requireMark: A(d),
|
|
93
|
-
children: s(d.children || []),
|
|
94
|
-
// 处理可编辑/不可编辑下的单元格渲染
|
|
95
|
-
...I(d)
|
|
96
|
-
}));
|
|
97
|
-
}
|
|
98
|
-
return s(e);
|
|
99
|
-
});
|
|
107
|
+
return _;
|
|
100
108
|
};
|
|
101
109
|
export {
|
|
102
|
-
|
|
103
|
-
|
|
110
|
+
Q as default,
|
|
111
|
+
Q as useGetEditableColumns
|
|
104
112
|
};
|
|
@@ -13,4 +13,5 @@ export declare const useEditableFormItemApi: <RecordType>(props: EditableAgGridP
|
|
|
13
13
|
setRowData: (index: number, payload: any, merge?: boolean) => void;
|
|
14
14
|
clear: () => void;
|
|
15
15
|
refreshRowIds: ShallowRef<string[], string[]>;
|
|
16
|
+
getRowDataByKey: (key: Key) => RecordType | undefined;
|
|
16
17
|
};
|
|
@@ -1,60 +1,60 @@
|
|
|
1
|
-
import { isFunction as V, isUndefined as R, isNumber as F, cloneDeep as
|
|
2
|
-
import { shallowRef as
|
|
1
|
+
import { isFunction as V, isUndefined as R, isNumber as F, cloneDeep as $, isArray as I } from "lodash-unified";
|
|
2
|
+
import { shallowRef as q, unref as h } from "vue";
|
|
3
3
|
import "../../utils/index.mjs";
|
|
4
|
-
import { getRowKey as y, arrayToObject as
|
|
4
|
+
import { getRowKey as y, arrayToObject as C } from "../editable/utils.mjs";
|
|
5
5
|
import { isDef as j } from "../../utils/is.mjs";
|
|
6
|
-
let
|
|
6
|
+
let G = 0;
|
|
7
7
|
function k() {
|
|
8
|
-
return `_ag_grid${
|
|
8
|
+
return `_ag_grid${G++}`;
|
|
9
9
|
}
|
|
10
|
-
const
|
|
11
|
-
const d =
|
|
12
|
-
function
|
|
13
|
-
const v = h(
|
|
14
|
-
if (j(
|
|
10
|
+
const X = (f, c, u, w) => {
|
|
11
|
+
const d = q([]);
|
|
12
|
+
function B(i, l) {
|
|
13
|
+
const v = h(u)?.length || 0;
|
|
14
|
+
if (j(f.maxLength) && v >= f.maxLength || !i && V(f.rowKey))
|
|
15
15
|
return;
|
|
16
|
-
const
|
|
17
|
-
...i || { [
|
|
16
|
+
const t = {
|
|
17
|
+
...i || { [f.rowKey]: k() }
|
|
18
18
|
};
|
|
19
19
|
c?.setFieldValue(
|
|
20
20
|
w,
|
|
21
|
-
|
|
21
|
+
t,
|
|
22
22
|
!1,
|
|
23
23
|
(o, s) => {
|
|
24
|
-
const e = y(
|
|
25
|
-
o[s] ? o[s][e] =
|
|
26
|
-
(
|
|
27
|
-
).filter(Boolean),
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
const e = y(t, void 0, f.rowKey);
|
|
25
|
+
o[s] ? o[s][e] = t : o[s] = { [e]: t }, u.value ? R(l) ? u.value.push(t) : (d.value = u.value.map(
|
|
26
|
+
(n, r) => r < l ? null : y(n, r, f.rowKey)
|
|
27
|
+
).filter(Boolean), u.value.splice(l, 0, t)) : u.value = [t], c?.setFieldValue(
|
|
28
|
+
f.name,
|
|
29
|
+
t,
|
|
30
30
|
!0,
|
|
31
|
-
(
|
|
32
|
-
if (!
|
|
33
|
-
|
|
31
|
+
(n, r) => {
|
|
32
|
+
if (!n[r]) {
|
|
33
|
+
n[r] = [t];
|
|
34
34
|
return;
|
|
35
35
|
}
|
|
36
|
-
R(
|
|
36
|
+
R(l) ? n[r].push(t) : n[r].splice(l, 0, t);
|
|
37
37
|
}
|
|
38
38
|
);
|
|
39
39
|
}
|
|
40
40
|
);
|
|
41
41
|
}
|
|
42
|
-
function x(i,
|
|
42
|
+
function x(i, l = "suffix", v = !1) {
|
|
43
43
|
if (!i)
|
|
44
44
|
return;
|
|
45
|
-
const
|
|
46
|
-
if (j(
|
|
45
|
+
const t = h(u)?.length || 0, o = F(i) ? i : i.length;
|
|
46
|
+
if (j(f.maxLength) && t + o > f.maxLength || F(i) && V(f.rowKey))
|
|
47
47
|
return;
|
|
48
|
-
const s = F(i) ? new Array(i).fill(0).map(() => ({ [
|
|
48
|
+
const s = F(i) ? new Array(i).fill(0).map(() => ({ [f.rowKey]: k() })) : $(i), e = C(s, f.rowKey);
|
|
49
49
|
c?.setFieldValue(
|
|
50
50
|
w,
|
|
51
51
|
e,
|
|
52
52
|
!1,
|
|
53
|
-
(
|
|
54
|
-
|
|
55
|
-
(g, K) => y(g, K,
|
|
56
|
-
),
|
|
57
|
-
|
|
53
|
+
(n, r) => {
|
|
54
|
+
n[r] ? Object.assign(n[r], e) : n[r] = e, u.value ? l === "suffix" ? u.value.push(...s) : (d.value = u.value.map(
|
|
55
|
+
(g, K) => y(g, K, f.rowKey)
|
|
56
|
+
), u.value.unshift(...s)) : u.value = [...s], c?.setFieldValue(
|
|
57
|
+
f.name,
|
|
58
58
|
s,
|
|
59
59
|
!0,
|
|
60
60
|
(g, K) => {
|
|
@@ -62,120 +62,126 @@ const W = (l, c, n, w) => {
|
|
|
62
62
|
g[K] = [...s];
|
|
63
63
|
return;
|
|
64
64
|
}
|
|
65
|
-
|
|
65
|
+
l === "suffix" ? g[K].push(...s) : g[K].unshift(...s);
|
|
66
66
|
}
|
|
67
67
|
);
|
|
68
68
|
}
|
|
69
69
|
);
|
|
70
70
|
}
|
|
71
|
-
function
|
|
72
|
-
x(i,
|
|
71
|
+
function L(i, l = "suffix") {
|
|
72
|
+
x(i, l, !1);
|
|
73
73
|
}
|
|
74
|
-
function
|
|
75
|
-
const
|
|
74
|
+
function O(i) {
|
|
75
|
+
const l = I(i) ? i : [i];
|
|
76
76
|
c?.setFieldValue(
|
|
77
77
|
w,
|
|
78
78
|
void 0,
|
|
79
79
|
!1,
|
|
80
|
-
(v,
|
|
81
|
-
for (const e of
|
|
82
|
-
const
|
|
83
|
-
delete v[
|
|
80
|
+
(v, t) => {
|
|
81
|
+
for (const e of l) {
|
|
82
|
+
const n = y(e, void 0, f.rowKey);
|
|
83
|
+
delete v[t][n];
|
|
84
84
|
}
|
|
85
|
-
const o =
|
|
86
|
-
(e) => !
|
|
87
|
-
), s =
|
|
88
|
-
(e) =>
|
|
85
|
+
const o = u.value.filter(
|
|
86
|
+
(e) => !l.includes(e)
|
|
87
|
+
), s = u.value.findIndex(
|
|
88
|
+
(e) => l.includes(e)
|
|
89
89
|
);
|
|
90
|
-
d.value =
|
|
91
|
-
(e,
|
|
92
|
-
).filter(Boolean), o.length ?
|
|
93
|
-
|
|
90
|
+
d.value = u.value.map(
|
|
91
|
+
(e, n) => n <= s ? null : y(e, n, f.rowKey)
|
|
92
|
+
).filter(Boolean), o.length ? u.value = o : u.value.splice(0, u.value.length), c.setFieldValue(
|
|
93
|
+
f.name,
|
|
94
94
|
void 0,
|
|
95
95
|
!0,
|
|
96
|
-
(e,
|
|
97
|
-
e[
|
|
96
|
+
(e, n) => {
|
|
97
|
+
e[n] = [...o];
|
|
98
98
|
}
|
|
99
99
|
);
|
|
100
100
|
}
|
|
101
101
|
);
|
|
102
102
|
}
|
|
103
|
-
function
|
|
104
|
-
const
|
|
105
|
-
|
|
103
|
+
function T(i) {
|
|
104
|
+
const l = new Set(I(i) ? i : [i]);
|
|
105
|
+
l.size !== 0 && c?.setFieldValue(
|
|
106
106
|
w,
|
|
107
107
|
void 0,
|
|
108
108
|
!1,
|
|
109
|
-
(v,
|
|
110
|
-
for (const e of
|
|
111
|
-
delete v[
|
|
112
|
-
const o =
|
|
113
|
-
(e,
|
|
114
|
-
), s =
|
|
115
|
-
(e,
|
|
109
|
+
(v, t) => {
|
|
110
|
+
for (const e of l)
|
|
111
|
+
delete v[t][e];
|
|
112
|
+
const o = u.value.filter(
|
|
113
|
+
(e, n) => !l.has(y(e, n, f.rowKey))
|
|
114
|
+
), s = u.value.findIndex(
|
|
115
|
+
(e, n) => l.has(y(e, n, f.rowKey))
|
|
116
116
|
);
|
|
117
|
-
d.value =
|
|
118
|
-
(e,
|
|
119
|
-
).filter(Boolean), o.length ?
|
|
120
|
-
|
|
117
|
+
d.value = u.value.map(
|
|
118
|
+
(e, n) => n <= s ? null : y(e, n, f.rowKey)
|
|
119
|
+
).filter(Boolean), o.length ? u.value = o : u.value.splice(0, u.value.length), c.setFieldValue(
|
|
120
|
+
f.name,
|
|
121
121
|
void 0,
|
|
122
122
|
!0,
|
|
123
|
-
(e,
|
|
124
|
-
e[
|
|
123
|
+
(e, n) => {
|
|
124
|
+
e[n] = [...o];
|
|
125
125
|
}
|
|
126
126
|
);
|
|
127
127
|
}
|
|
128
128
|
);
|
|
129
129
|
}
|
|
130
|
-
function
|
|
131
|
-
return h(
|
|
130
|
+
function _(i) {
|
|
131
|
+
return h(u)?.[i];
|
|
132
|
+
}
|
|
133
|
+
function z(i) {
|
|
134
|
+
return u.value?.find(
|
|
135
|
+
(l, v) => y(l, v, f.rowKey) === i
|
|
136
|
+
);
|
|
132
137
|
}
|
|
133
|
-
function
|
|
134
|
-
return h(
|
|
138
|
+
function E() {
|
|
139
|
+
return h(u);
|
|
135
140
|
}
|
|
136
|
-
function
|
|
141
|
+
function S(i, l, v = !0) {
|
|
137
142
|
c?.setFieldValue?.(
|
|
138
143
|
w,
|
|
139
144
|
void 0,
|
|
140
145
|
!1,
|
|
141
|
-
(
|
|
142
|
-
const s =
|
|
143
|
-
(
|
|
146
|
+
(t, o) => {
|
|
147
|
+
const s = u.value.findIndex(
|
|
148
|
+
(n, r) => i === r
|
|
144
149
|
);
|
|
145
150
|
if (!~s)
|
|
146
151
|
return;
|
|
147
152
|
const e = y(
|
|
148
|
-
|
|
153
|
+
u.value[s],
|
|
149
154
|
s,
|
|
150
|
-
|
|
155
|
+
f.rowKey
|
|
151
156
|
);
|
|
152
|
-
if (e && !(!
|
|
157
|
+
if (e && !(!t[o] || !t[o][e])) {
|
|
153
158
|
if (!v) {
|
|
154
|
-
const
|
|
155
|
-
for (const r of
|
|
156
|
-
r !==
|
|
159
|
+
const n = Object.keys(t[o][e]);
|
|
160
|
+
for (const r of n)
|
|
161
|
+
r !== f.rowKey && delete t[o][e][r];
|
|
157
162
|
}
|
|
158
|
-
Object.assign(
|
|
163
|
+
Object.assign(t[o][e], { ...l });
|
|
159
164
|
}
|
|
160
165
|
}
|
|
161
166
|
);
|
|
162
167
|
}
|
|
163
|
-
function
|
|
164
|
-
c?.setFieldValue(w, {}), c?.setFieldValue(
|
|
168
|
+
function U() {
|
|
169
|
+
c?.setFieldValue(w, {}), c?.setFieldValue(f.name, []);
|
|
165
170
|
}
|
|
166
171
|
return {
|
|
167
|
-
add:
|
|
168
|
-
addMultiple:
|
|
172
|
+
add: B,
|
|
173
|
+
addMultiple: L,
|
|
169
174
|
__addMultiple: x,
|
|
170
|
-
remove:
|
|
171
|
-
removeByKey:
|
|
172
|
-
getRowData:
|
|
173
|
-
getRowsData:
|
|
174
|
-
setRowData:
|
|
175
|
-
clear:
|
|
176
|
-
refreshRowIds: d
|
|
175
|
+
remove: O,
|
|
176
|
+
removeByKey: T,
|
|
177
|
+
getRowData: _,
|
|
178
|
+
getRowsData: E,
|
|
179
|
+
setRowData: S,
|
|
180
|
+
clear: U,
|
|
181
|
+
refreshRowIds: d,
|
|
182
|
+
getRowDataByKey: z
|
|
177
183
|
};
|
|
178
184
|
};
|
|
179
185
|
export {
|
|
180
|
-
|
|
186
|
+
X as useEditableFormItemApi
|
|
181
187
|
};
|
package/es/src/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: "7.19.
|
|
1
|
+
declare const _default: "7.19.6";
|
|
2
2
|
export default _default;
|
package/es/src/version.mjs
CHANGED
|
@@ -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"),i=require("lodash-unified"),y=require("../../ap-form/index.js"),k=require("../../ap-form/context.js"),A=require("../../ap-form/hooks/use-watch.js"),z=require("../../ap-form/utils/get.js"),H=require("../../ap-form/utils/transform.js");require("../../config-provider/index.js");const L=require("../hooks/use-editable-columns.js"),G=require("../hooks/use-editable-form-item-api.js");require("../index.vue2.js");const U=require("../style/editable.js"),W=require("../utils.js"),c=require("./utils.js"),$=require("../../config-provider/hooks/use-namespace.js"),J=require("../../config-provider/hooks/use-global-config.js"),Q=require("../index.vue.js"),X=o.defineComponent({name:"EditableGrid",__name:"form-item",props:{dropdownPrefixCls:{},bordered:{type:Boolean},locale:{},onResizeColumn:{},getPopupContainer:{},scroll:{},sortDirections:{},showSorterTooltip:{type:[Boolean,Object]},prefixCls:{},rowKey:{type:[String,Function],default:"key"},tableLayout:{},title:{},id:{},showHeader:{type:Boolean},components:{},customHeaderRow:{},direction:{},expandFixed:{type:[String,Boolean]},expandColumnWidth:{},expandedRowKeys:{},defaultExpandedRowKeys:{},expandedRowRender:{},expandRowByClick:{type:Boolean},expandIcon:{},onExpand:{},onExpandedRowsChange:{},defaultExpandAllRows:{type:Boolean},indentSize:{},expandIconColumnIndex:{},showExpandColumn:{type:Boolean},expandedRowClassName:{},childrenColumnName:{},rowExpandable:{},transformCellText:{},rowHoverable:{type:Boolean},rowSelection:{type:[Boolean,Object]},onLoadingChange:{},onShownColumnsChange:{},pagination:{type:[Boolean,Object],default:!1},searchFormWrapperStyle:{},tableWrapperStyle:{},wrapperStyle:{},tableStyle:{},adaptive:{type:Boolean},columnResizable:{type:Boolean,default:!1},loading:{type:Boolean,default:void 0},summary:{},rowHeight:{default:66},getRowHeight:{},advanceRenderer:{type:Boolean},browserTooltips:{type:Boolean},virtual:{type:[Boolean,Object],default:void 0},onRowClicked:{},onScrollEnd:{},rowClassName:{},rowClassRules:{},autoHeight:{type:Boolean},onUpdate:{},customRow:{},theme:{},emptyComponent:{},emptyText:{},onColumnResized:{},animateRows:{type:Boolean},plugins:{},columns:{},defaultValue:{},onChange:{},maxLength:{},onFieldChange:{},supressForceRowUpdate:{type:Boolean,default:!1},label:{},name:{},formItem:{}},setup(h,{expose:b}){const C=o.useSlots(),n=h,{b:R}=$.useNamespace("editable-aggrid"),v=U.default("editable-aggrid"),d=o.ref(),{internalInstance:l}=k.useInjectForm();function B(e){const t=c.getColumnTransformOptions(n.columns||[]);if(!Object.keys(t).length||!e?.length)return e;let a=[];for(const u of e)a.push(H.transformValues(u,t));return a}const s=W.getShadowName(n.name);let f=[];o.onMounted(()=>{const e=n.formItem?.initialValue??z.getModelValue(l?.getInitialValues()??{},n.name);e&&(l?.updateInitialModel(s,c.arrayToObject(i.cloneDeep(e),n.rowKey)),f=i.cloneDeep(e),r.value||_(i.cloneDeep(e),"suffix",!0))});const r=o.ref([]),x=A.useWatch(n.name);o.watch(()=>x.value,e=>{i.isEqual(e,r.value)||g(e??i.cloneDeep(f))},{deep:!0,flush:"post",immediate:!0});const S=J.useGlobalConfig("valueTypeMap"),q=L.useGetEditableColumns(n,S,s),{add:F,addMultiple:I,__addMultiple:_,remove:T,removeByKey:E,getRowData:N,getRowsData:V,setRowData:j,clear:D,refreshRowIds:m}=G.useEditableFormItemApi(n,l,r,s);function O(){const e=d.value?._internalGridApi;if(!m.value?.length||!e)return;const t=m.value.map(a=>e.getRowNode(a)).filter(a=>!!a);n.supressForceRowUpdate||e.refreshCells({rowNodes:t,force:!0}),m.value=[]}function g(e){r.value=[...e];const t=c.arrayToObject(e,n.rowKey);l?.setFieldValue(n.name,[...e]),l?.setFieldValue(s,t)}function w(e,t){const a=e==="end"?r.value.length-1:e;d.value?.scrollToRow(a,t)}function K(e,t){d.value?.scrollToColumn(e,t)}function M(e,t){const a=[s,String(e),t].flat();return l?.validateFields([a])}function P(e){const a=o.unref(r).map((u,p)=>[s,String(c.getRowKey(u,p,n.rowKey)),e].flat());return l?.validateFields(a)}return b({add:F,addMultiple:I,remove:T,removeByKey:E,getRowData:N,getRowsData:V,setRowData:j,clear:D,setTableData:g,scrollTo:w,scrollToRow:w,scrollToColumn:K,validateCell:M,validateColumn:P,table:d}),(e,t)=>(o.openBlock(),o.createElementBlock(o.Fragment,null,[o.createVNode(o.unref(y.ApForm).FormItem,{hidden:"",name:e.name,"initial-value":e.formItem?.initialValue,transform:B},null,8,["name","initial-value"]),o.createVNode(o.unref(y.ApForm).FormItem,o.mergeProps({label:e.label},e.formItem),{default:o.withCtx(()=>[o.createVNode(Q.default,o.mergeProps(o.unref(i.omit)(n,["name","maxLength","onChange","defaultValue","formItem"]),{ref_key:"tableRef",ref:d,class:[o.unref(R)(),o.unref(v)],size:"mini",columns:o.unref(q),"data-source":r.value,"search-form":!1,onUpdate:O}),o.createSlots({_:2},[o.renderList(C,(a,u)=>({name:u,fn:o.withCtx(p=>[o.renderSlot(e.$slots,u,o.normalizeProps(o.guardReactiveProps(p||{})))])}))]),1040,["class","columns","data-source"])]),_:3},16,["label"])],64))}});exports.default=X;
|
|
@@ -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 o=require("vue"),i=require("lodash-unified"),m=require("../../ap-form/index.js");require("../../config-provider/index.js");require("../../hooks/index.js");const P=require("../hooks/use-editable-api.js"),G=require("../hooks/use-editable-columns.js");require("../index.vue2.js");const L=require("../style/editable.js"),d=require("./utils.js"),M=require("../../config-provider/hooks/use-namespace.js"),W=require("../../hooks/useControllableValue.js"),$=require("../../config-provider/hooks/use-global-config.js"),J=require("../index.vue.js"),Q=o.defineComponent({name:"EditableGrid",__name:"index",props:{dropdownPrefixCls:{},bordered:{type:Boolean},locale:{},onResizeColumn:{},getPopupContainer:{},scroll:{},sortDirections:{},showSorterTooltip:{type:[Boolean,Object]},prefixCls:{},rowKey:{type:[String,Function],default:"key"},tableLayout:{},title:{},id:{},showHeader:{type:Boolean},components:{},customHeaderRow:{},direction:{},expandFixed:{type:[String,Boolean]},expandColumnWidth:{},expandedRowKeys:{},defaultExpandedRowKeys:{},expandedRowRender:{},expandRowByClick:{type:Boolean},expandIcon:{},onExpand:{},onExpandedRowsChange:{},defaultExpandAllRows:{type:Boolean},indentSize:{},expandIconColumnIndex:{},showExpandColumn:{type:Boolean},expandedRowClassName:{},childrenColumnName:{},rowExpandable:{},transformCellText:{},rowHoverable:{type:Boolean},rowSelection:{type:[Boolean,Object]},onLoadingChange:{},onShownColumnsChange:{},pagination:{type:[Boolean,Object],default:!1},searchFormWrapperStyle:{},tableWrapperStyle:{},wrapperStyle:{},tableStyle:{},adaptive:{type:Boolean},columnResizable:{type:Boolean,default:!1},loading:{type:Boolean,default:void 0},summary:{},rowHeight:{default:66},getRowHeight:{},advanceRenderer:{type:Boolean},browserTooltips:{type:Boolean},virtual:{type:[Boolean,Object],default:void 0},onRowClicked:{},onScrollEnd:{},rowClassName:{},rowClassRules:{},autoHeight:{type:Boolean},onUpdate:{},customRow:{},theme:{},emptyComponent:{},emptyText:{},onColumnResized:{},animateRows:{type:Boolean},plugins:{},columns:{},value:{},defaultValue:{},"onUpdate:value":{},onChange:{},maxLength:{},name:{default:"ap-editable-table-inner-name"},onFieldChange:{},supressForceRowUpdate:{type:Boolean,default:!1}},emits:["update:value"],setup(v,{expose:h,emit:R}){const C=o.useSlots(),t=v,{b:x}=M.useNamespace("editable-aggrid"),B=L.default("editable-aggrid"),T=R,u=o.ref(),{value:s,updateValue:y}=W.useControllableValue(t,T),l=o.ref(),_=m.ApForm.useWatch(t.name,l);o.watch(s,e=>{const a=d.arrayToObject(e,t.rowKey);i.isEqual(a,o.unref(_))||l.value?.setFieldValue(t.name,a)},{deep:!0});const F=$.useGlobalConfig("valueTypeMap"),S=G.useGetEditableColumns(t,F),{add:q,addMultiple:A,remove:E,removeByKey:j,getRowData:N,getRowsData:K,setRowData:V,clear:k,refreshRowIds:c}=P.useEditableApi(t,l,s,y);function O(){const e=u.value?._internalGridApi;if(!c.value?.length||!e)return;const a=c.value.map(n=>e.getRowNode(n)).filter(n=>!!n);t.supressForceRowUpdate||e.refreshCells({rowNodes:a,force:!0}),c.value=[]}function I(){l.value?.resetFields()}function w(e){return e?(i.isArray(e)?e:[e]).map(n=>i.isArray(n)?[t.name,...n]:[t.name,n]):void 0}function b(e){try{const a=Object.keys(e),n=s.value.map(r=>d.getRowKey(r,void 0,t.rowKey));return a.sort((r,p)=>n.findIndex(f=>String(f)===r)-n.findIndex(f=>String(f)===p)),a.map(r=>e[r])}catch{return e}}async function D(e,a){const r=(await l.value?.validateFields(w(e),a))?.[t.name];return b(r)}async function U(e,a){const r=(await l.value?.validateFieldsReturnTransformed(w(e),a))?.[t.name];return b(r)}function z(e){y(e);const a=d.arrayToObject(e,t.rowKey);l.value?.setFieldValue(t.name,a)}function g(e,a){const n=e==="end"?s.value.length-1:e;u.value?.scrollToRow(n,a)}function H(e,a){u.value?.scrollToColumn(e,a)}return h({resetFields:I,validateFields:D,validateFieldsReturnTransformed:U,add:q,addMultiple:A,remove:E,removeByKey:j,getRowData:N,getRowsData:K,setRowData:V,clear:k,setTableData:z,scrollTo:g,scrollToRow:g,scrollToColumn:H,table:u}),(e,a)=>(o.openBlock(),o.createBlock(o.unref(m.ApForm),{ref_key:"formRef",ref:l,"initial-values":{[t.name]:o.unref(d.arrayToObject)(o.unref(s),t.rowKey)},style:{height:"100%"}},{default:o.withCtx(()=>[o.createVNode(o.unref(m.ApForm).FormItem,{name:e.name,"no-style":""},{default:o.withCtx(()=>[o.createVNode(J.default,o.mergeProps(o.unref(i.omit)(t,["name","value","onUpdate:value","maxLength","onChange","defaultValue"]),{ref_key:"tableRef",ref:u,class:[o.unref(x)(),o.unref(B)],size:"mini",columns:o.unref(S),"data-source":o.unref(s),"search-form":!1,onUpdate:O}),o.createSlots({_:2},[o.renderList(C,(n,r)=>({name:r,fn:o.withCtx(p=>[o.renderSlot(e.$slots,r,o.normalizeProps(o.guardReactiveProps(p||{})))])}))]),1040,["class","columns","data-source"])]),_:3},8,["name"])]),_:3},8,["initial-values"]))}});exports.default=Q;
|
|
@@ -77,7 +77,16 @@ export type EditableAgGridProps<RecordType = any> = Omit<AgGridProps<RecordType>
|
|
|
77
77
|
* 当字段值变更的时候触发(注意,向表单设置值并不会触发)
|
|
78
78
|
* @returns
|
|
79
79
|
*/
|
|
80
|
-
onFieldChange?: (rowIndex: number, fieldName: DataIndex, newValue: any) => void;
|
|
80
|
+
onFieldChange?: (rowIndex: number, fieldName: DataIndex, newValue: any, record: RecordType) => void;
|
|
81
|
+
/**
|
|
82
|
+
* 是否禁止在行操作后(添加/删除行等)避免强制更新
|
|
83
|
+
* 默认情况下,表格行会在行操作后强制更新哪些受到影响的行来保证渲染始终是正确的,但这样会导致表单校验被清空、频繁更新导致渲染性能下降等问题
|
|
84
|
+
* 设置为`true`后,在行操作后不会主动强制更新受影响的行,由于不再更新行,配置中如果`editable`/`fieldProps`/`customRender`等函数使用
|
|
85
|
+
* 到了`rowIndex`等字段可能会出现渲染异常的问题
|
|
86
|
+
* @default false
|
|
87
|
+
* @since 7.19.5
|
|
88
|
+
*/
|
|
89
|
+
supressForceRowUpdate?: boolean;
|
|
81
90
|
};
|
|
82
91
|
export type EditableAgGridExpose<RecordType = any, ModelType = RecordType[]> = Omit<EditableTableExpose<ModelType, RecordType>, 'scrollTo' | 'remove'> & {
|
|
83
92
|
scrollTo: (index: number | 'end', position?: 'top' | 'bottom' | 'middle') => void;
|
|
@@ -12,4 +12,5 @@ export declare const useEditableApi: <RecordType>(props: EditableAgGridProps<Rec
|
|
|
12
12
|
setRowData: (index: string | number, payload: any, merge?: boolean) => void;
|
|
13
13
|
clear: () => void;
|
|
14
14
|
refreshRowIds: ShallowRef<string[], string[]>;
|
|
15
|
+
getRowDataByKey: (key: Key) => RecordType | undefined;
|
|
15
16
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("lodash-unified"),d=require("vue");require("../../utils/index.js");const V=require("../editable/utils.js"),m=require("../../utils/is.js");let S=0;function x(){return`_ag_grid${S++}`}const T=(u,K,i,h)=>{const g=d.shallowRef([]),w=d.computed(()=>d.isRef(K)?d.unref(K):K);function R(n,t){const l=d.unref(i)?.length||0;if(m.isDef(u.maxLength)&&l>=u.maxLength||!n&&v.isFunction(u.rowKey))return;const r={...n||{[u.rowKey]:x()}};w.value?.setFieldValue?.(u.name,r,!0,(o,s)=>{const e=c(r,void 0,u.rowKey);if(o[s]?o[s][e]=r:o[s]={[e]:r},!i.value){i.value=[r];return}v.isUndefined(t)?i.value.push(r):(g.value=i.value.map((f,y)=>y<t?null:c(f,y,u.rowKey)).filter(Boolean),i.value.splice(t,0,r))})}function a(n,t="suffix"){const l=d.unref(i)?.length||0,r=v.isNumber(n)?n:n.length;if(m.isDef(u.maxLength)&&l+r>u.maxLength||v.isNumber(n)&&v.isFunction(u.rowKey))return;const o=v.isNumber(n)?new Array(n).fill(0).map(()=>({[u.rowKey]:x()})):v.cloneDeep(n),s=V.arrayToObject(o,u.rowKey);w.value?.setFieldValue?.(u.name,o,!0,(e,f)=>{if(e[f]?Object.assign(e[f],s):e[f]=s,!i.value){i.value=[...o];return}t==="suffix"?i.value.push(...o):(g.value=i.value.map((y,L)=>c(y,L,u.rowKey)),i.value.unshift(...o))})}function F(n){const t=v.isArray(n)?n:[n];w.value?.setFieldValue?.(u.name,void 0,!0,(l,r)=>{for(const e of t){const f=c(e,void 0,u.rowKey);delete l[r][f]}const o=i.value.filter(e=>!t.includes(e)),s=i.value.findIndex(e=>t.includes(e));g.value=i.value.map((e,f)=>f<=s?null:c(e,f,u.rowKey)).filter(Boolean),h?.(o)})}function c(n,t,l){if(l)return v.isString(l)?n[l]:l(n,t)}function I(n){const t=new Set(v.isArray(n)?n:[n]);t.size!==0&&w.value?.setFieldValue?.(u.name,void 0,!0,(l,r)=>{for(const e of t)delete l[r][e];const o=i.value.filter((e,f)=>!t.has(c(e,f,u.rowKey))),s=i.value.findIndex((e,f)=>t.has(c(e,f,u.rowKey)));g.value=i.value.map((e,f)=>f<=s?null:c(e,f,u.rowKey)).filter(Boolean),h?.(o)})}function j(n){return d.unref(i)?.[n]}function O(n){return i.value?.find((t,l)=>c(t,l,u.rowKey)===n)}function k(){return d.unref(i)}function q(n,t,l=!0){w.value?.setFieldValue?.(u.name,void 0,!0,(r,o)=>{const s=i.value.findIndex((f,y)=>n===y);if(!~s)return;const e=c(i.value[s],s,u.rowKey);if(e&&!(!r[o]||!r[o][e])){if(!l){const f=Object.keys(r[o][e]);for(const y of f)y!==u.rowKey&&delete r[o][e][y]}Object.assign(r[o][e],{...t})}})}function B(){w.value?.setFieldValue?.(u.name,{}),h?.([])}return{add:R,addMultiple:a,remove:F,removeByKey:I,getRowData:j,getRowsData:k,setRowData:q,clear:B,refreshRowIds:g,getRowDataByKey:O}};exports.useEditableApi=T;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Ref } from 'vue';
|
|
2
2
|
import { ValueTypeRenderConfig } from '../../config-provider';
|
|
3
3
|
import { EditableAgGridProps } from '../editable/interface';
|
|
4
4
|
import { AgGridColumnType } from '../interface';
|
|
5
|
-
export declare const useGetEditableColumns: (props: EditableAgGridProps, extraValueTypes: Ref<Record<string, ValueTypeRenderConfig> | undefined>, shadowName?: string) =>
|
|
5
|
+
export declare const useGetEditableColumns: (props: EditableAgGridProps, extraValueTypes: Ref<Record<string, ValueTypeRenderConfig> | undefined>, shadowName?: string) => Ref<AgGridColumnType[]>;
|
|
6
6
|
export default useGetEditableColumns;
|
|
@@ -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 F=require("clsx"),b=require("lodash-unified"),x=require("vue"),M=require("../../ap-grid/utils/editable.js"),q=require("../../ap-table/utils.js"),S=require("../../editable-table/utils.js");require("../../utils/index.js");const $=require("../editable/utils.js"),A=require("../../utils/is.js");function v(t,n,r){t.__skipNextRefresh?t.__skipNextRefresh[n]=r:t.__skipNextRefresh={[n]:r}}function G(t,n,r){t.__prevEditable?t.__prevEditable[n]=r:t.__prevEditable={[n]:r}}const w=(t,n,r)=>{const h=x.ref([]);x.watch(()=>t.columns,e=>{if(!e?.length){h.value=[];return}function o(a){return a.map(d=>({...d,_requireMark:S.getColumnIsRequired(d),children:o(d.children||[]),...C(d)}))}h.value=o(e)},{immediate:!0,deep:!0});function C(e){const o=e.editable,a=r?[r]:b.isArray(t.name)?t.name:[t.name];return!o||e.children?.length?{_path:[...a]}:{customRender({value:d,originalNode:N,params:l,...i}){const c=b.isFunction(e.editable)?e.editable(i.text,i.record,i.rowIndex):!!e.editable;let f=N;const k=b.isArray(e.dataIndex)?e.dataIndex:[e.dataIndex],g=$.getRowKey(i.record,i.rowIndex,t.rowKey);if(c){const _=q.updateFormProps(e,q.getFieldProps(e.fieldProps,{value:d,...i})),R={};t.onFieldChange&&(R[`onUpdate:${_.valuePropName||"value"}`]=y=>t.onFieldChange?.(i.rowIndex,e.dataIndex,y,i.record));const E={name:[...a,String(g),...k],..._||{},field:{style:"width: 100%",..._?.field||{},...R,class:F.clsx("is-editable",_.class)}};f=M.getFinalEditableNode(e,E,i.record,x.unref(n))}e.customRender&&(f=e.customRender({value:d,...i,editable:c,originalNode:f,index:i.rowIndex,renderIndex:i.rowIndex,path:[...a,String(g)]}));const u=l.node,s=l.column.getColId(),I=u.__prevEditable?.[s];return!u.__skipNextRefresh?.[s]&&A.isDef(I)&&I!==c&&(v(u,s,!0),setTimeout(()=>{l?.api.refreshCells({rowNodes:[l.node],columns:[l.column.getColId()],force:!0}),v(u,s,!1)},0)),G(u,s,c),f},_path:[...a]}}return h};exports.default=w;exports.useGetEditableColumns=w;
|
|
@@ -13,4 +13,5 @@ export declare const useEditableFormItemApi: <RecordType>(props: EditableAgGridP
|
|
|
13
13
|
setRowData: (index: number, payload: any, merge?: boolean) => void;
|
|
14
14
|
clear: () => void;
|
|
15
15
|
refreshRowIds: ShallowRef<string[], string[]>;
|
|
16
|
+
getRowDataByKey: (key: Key) => RecordType | undefined;
|
|
16
17
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("lodash-unified"),R=require("vue");require("../../utils/index.js");const v=require("../editable/utils.js"),x=require("../../utils/is.js");let S=0;function V(){return`_ag_grid${S++}`}const U=(l,c,u,w)=>{const h=R.shallowRef([]);function I(i,t){const y=R.unref(u)?.length||0;if(x.isDef(l.maxLength)&&y>=l.maxLength||!i&&g.isFunction(l.rowKey))return;const f={...i||{[l.rowKey]:V()}};c?.setFieldValue(w,f,!1,(r,s)=>{const e=v.getRowKey(f,void 0,l.rowKey);r[s]?r[s][e]=f:r[s]={[e]:f},u.value?g.isUndefined(t)?u.value.push(f):(h.value=u.value.map((n,o)=>o<t?null:v.getRowKey(n,o,l.rowKey)).filter(Boolean),u.value.splice(t,0,f)):u.value=[f],c?.setFieldValue(l.name,f,!0,(n,o)=>{if(!n[o]){n[o]=[f];return}g.isUndefined(t)?n[o].push(f):n[o].splice(t,0,f)})})}function F(i,t="suffix",y=!1){if(!i)return;const f=R.unref(u)?.length||0,r=g.isNumber(i)?i:i.length;if(x.isDef(l.maxLength)&&f+r>l.maxLength||g.isNumber(i)&&g.isFunction(l.rowKey))return;const s=g.isNumber(i)?new Array(i).fill(0).map(()=>({[l.rowKey]:V()})):g.cloneDeep(i),e=v.arrayToObject(s,l.rowKey);c?.setFieldValue(w,e,!1,(n,o)=>{n[o]?Object.assign(n[o],e):n[o]=e,u.value?t==="suffix"?u.value.push(...s):(h.value=u.value.map((K,d)=>v.getRowKey(K,d,l.rowKey)),u.value.unshift(...s)):u.value=[...s],c?.setFieldValue(l.name,s,!0,(K,d)=>{if(!K[d]||y){K[d]=[...s];return}t==="suffix"?K[d].push(...s):K[d].unshift(...s)})})}function j(i,t="suffix"){F(i,t,!1)}function O(i){const t=g.isArray(i)?i:[i];c?.setFieldValue(w,void 0,!1,(y,f)=>{for(const e of t){const n=v.getRowKey(e,void 0,l.rowKey);delete y[f][n]}const r=u.value.filter(e=>!t.includes(e)),s=u.value.findIndex(e=>t.includes(e));h.value=u.value.map((e,n)=>n<=s?null:v.getRowKey(e,n,l.rowKey)).filter(Boolean),r.length?u.value=r:u.value.splice(0,u.value.length),c.setFieldValue(l.name,void 0,!0,(e,n)=>{e[n]=[...r]})})}function T(i){const t=new Set(g.isArray(i)?i:[i]);t.size!==0&&c?.setFieldValue(w,void 0,!1,(y,f)=>{for(const e of t)delete y[f][e];const r=u.value.filter((e,n)=>!t.has(v.getRowKey(e,n,l.rowKey))),s=u.value.findIndex((e,n)=>t.has(v.getRowKey(e,n,l.rowKey)));h.value=u.value.map((e,n)=>n<=s?null:v.getRowKey(e,n,l.rowKey)).filter(Boolean),r.length?u.value=r:u.value.splice(0,u.value.length),c.setFieldValue(l.name,void 0,!0,(e,n)=>{e[n]=[...r]})})}function k(i){return R.unref(u)?.[i]}function q(i){return u.value?.find((t,y)=>v.getRowKey(t,y,l.rowKey)===i)}function B(){return R.unref(u)}function L(i,t,y=!0){c?.setFieldValue?.(w,void 0,!1,(f,r)=>{const s=u.value.findIndex((n,o)=>i===o);if(!~s)return;const e=v.getRowKey(u.value[s],s,l.rowKey);if(e&&!(!f[r]||!f[r][e])){if(!y){const n=Object.keys(f[r][e]);for(const o of n)o!==l.rowKey&&delete f[r][e][o]}Object.assign(f[r][e],{...t})}})}function _(){c?.setFieldValue(w,{}),c?.setFieldValue(l.name,[])}return{add:I,addMultiple:j,__addMultiple:F,remove:O,removeByKey:T,getRowData:k,getRowsData:B,setRowData:L,clear:_,refreshRowIds:h,getRowDataByKey:q}};exports.useEditableFormItemApi=U;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=()=>({title:{type:String,default:""},imgSrc:{type:String,default:""},preview:{type:Boolean,default:!
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=()=>({title:{type:String,default:""},imgSrc:{type:String,default:""},preview:{type:Boolean,default:!0},values:{type:Array,default:()=>[]},disableCopy:{type:Boolean,default:!1},showImg:{type:Boolean,default:!0}});exports.ApProductInfoProps=e;
|
package/lib/src/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: "7.19.
|
|
1
|
+
declare const _default: "7.19.6";
|
|
2
2
|
export default _default;
|
package/lib/src/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e="7.19.
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e="7.19.6";exports.default=e;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aplus-frontend/ui",
|
|
3
|
-
"version": "7.19.
|
|
3
|
+
"version": "7.19.6",
|
|
4
4
|
"main": "./lib/index.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"typings": "./lib/index.d.ts",
|
|
@@ -41,8 +41,8 @@
|
|
|
41
41
|
"scroll-into-view-if-needed": "^3.1.0",
|
|
42
42
|
"vue-virtual-scroller": "2.0.0-beta.8",
|
|
43
43
|
"vuedraggable": "^4.1.0",
|
|
44
|
-
"@aplus-frontend/
|
|
45
|
-
"@aplus-frontend/
|
|
44
|
+
"@aplus-frontend/utils": "1.0.66",
|
|
45
|
+
"@aplus-frontend/hooks": "1.0.7"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
48
|
"@aplus-frontend/antdv": "^2.1.4",
|