@aplus-frontend/ui 6.31.1 → 6.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/index.mjs +39 -37
- package/es/src/ag-grid/components/body-cell/index.vue2.mjs +14 -12
- package/es/src/ag-grid/editable/index.vue.d.ts +18 -0
- package/es/src/ag-grid/editable/index.vue.mjs +233 -0
- package/es/src/ag-grid/editable/index.vue2.mjs +4 -0
- package/es/src/ag-grid/editable/interface.d.ts +96 -0
- package/es/src/ag-grid/editable/interface.mjs +1 -0
- package/es/src/ag-grid/editable/style/css.d.ts +0 -0
- package/es/src/ag-grid/editable/style/css.js +1 -0
- package/es/src/ag-grid/editable/style/index.d.ts +0 -0
- package/es/src/ag-grid/editable/style/index.js +1 -0
- package/es/src/ag-grid/editable/utils.d.ts +5 -0
- package/es/src/ag-grid/editable/utils.mjs +23 -0
- package/es/src/ag-grid/hooks/use-editable-api.d.ts +15 -0
- package/es/src/ag-grid/hooks/use-editable-api.mjs +150 -0
- package/es/src/ag-grid/hooks/use-editable-columns.d.ts +6 -0
- package/es/src/ag-grid/hooks/use-editable-columns.mjs +96 -0
- package/es/src/ag-grid/hooks/use-editable-form-item-api.d.ts +14 -0
- package/es/src/ag-grid/index.d.ts +3 -1
- package/es/src/ag-grid/index.mjs +2 -0
- package/es/src/ag-grid/index.vue.mjs +70 -66
- package/es/src/ag-grid/interface.d.ts +20 -1
- package/es/src/ag-grid/utils.d.ts +2 -0
- package/es/src/ag-grid/utils.mjs +12 -7
- package/es/src/ap-field/date/index.vue.mjs +29 -28
- package/es/src/ap-field/radio/index.vue.d.ts +4 -0
- package/es/src/ap-field/radio/index.vue.mjs +9 -8
- package/es/src/ap-field/radio/read.vue2.mjs +5 -4
- package/es/src/ap-field/rate/index.vue.d.ts +20 -0
- package/es/src/ap-field/rate/index.vue.mjs +12 -11
- package/es/src/ap-form/interface.d.ts +4 -0
- package/es/src/ap-form/item/index.vue.mjs +41 -39
- package/es/src/ap-form/items/checkbox/index.vue.mjs +5 -5
- package/es/src/ap-form/items/date/index.vue.mjs +9 -9
- package/es/src/ap-form/items/date-range/index.vue.mjs +8 -8
- package/es/src/ap-form/items/number/index.vue.mjs +11 -11
- package/es/src/ap-form/items/radio/index.vue.d.ts +8 -0
- package/es/src/ap-form/items/radio/index.vue.mjs +6 -6
- package/es/src/ap-form/items/select/index.vue.mjs +3 -3
- package/es/src/ap-form/items/switch/index.vue.mjs +2 -2
- package/es/src/ap-form/items/text/index.vue2.mjs +12 -12
- package/es/src/ap-form/items/text/password.vue.mjs +2 -2
- package/es/src/ap-form/items/text-area/index.vue.d.ts +4 -4
- package/es/src/ap-form/items/text-area/index.vue.mjs +3 -3
- package/es/src/ap-form/items/tree-select/index.vue.mjs +6 -6
- package/es/src/ap-form/render/item.vue.mjs +6 -5
- package/es/src/ap-grid/utils/editable.d.ts +2 -1
- package/es/src/ap-table/constants.d.ts +4 -0
- package/es/src/ap-table/interface.d.ts +5 -0
- package/es/src/ap-table/utils.mjs +76 -71
- package/es/src/ap-upload/components/MultipleFile.vue.d.ts +10 -0
- package/es/src/business/ap-appendix/ap-appendix.vue2.mjs +67 -68
- package/es/src/business/batch-input-group/form-item.vue.mjs +1 -1
- package/es/src/editable-table/utils.d.ts +3 -2
- package/es/src/index.mjs +42 -40
- package/es/src/version.d.ts +1 -1
- package/es/src/version.mjs +1 -1
- package/lib/index.js +1 -1
- package/lib/src/ag-grid/components/body-cell/index.vue2.js +1 -1
- package/lib/src/ag-grid/editable/index.vue.d.ts +18 -0
- package/lib/src/ag-grid/editable/index.vue.js +1 -0
- package/lib/src/ag-grid/editable/index.vue2.js +1 -0
- package/lib/src/ag-grid/editable/interface.d.ts +96 -0
- package/lib/src/ag-grid/editable/interface.js +1 -0
- package/lib/src/ag-grid/editable/style/css.cjs +1 -0
- package/lib/src/ag-grid/editable/style/css.d.ts +0 -0
- package/lib/src/ag-grid/editable/style/index.cjs +1 -0
- package/lib/src/ag-grid/editable/style/index.d.ts +0 -0
- package/lib/src/ag-grid/editable/utils.d.ts +5 -0
- package/lib/src/ag-grid/editable/utils.js +1 -0
- package/lib/src/ag-grid/hooks/use-editable-api.d.ts +15 -0
- package/lib/src/ag-grid/hooks/use-editable-api.js +1 -0
- package/lib/src/ag-grid/hooks/use-editable-columns.d.ts +6 -0
- package/lib/src/ag-grid/hooks/use-editable-columns.js +1 -0
- package/lib/src/ag-grid/hooks/use-editable-form-item-api.d.ts +14 -0
- package/lib/src/ag-grid/index.d.ts +3 -1
- package/lib/src/ag-grid/index.js +1 -1
- package/lib/src/ag-grid/index.vue.js +1 -1
- package/lib/src/ag-grid/interface.d.ts +20 -1
- package/lib/src/ag-grid/utils.d.ts +2 -0
- package/lib/src/ag-grid/utils.js +1 -1
- package/lib/src/ap-field/date/index.vue.js +1 -1
- package/lib/src/ap-field/radio/index.vue.d.ts +4 -0
- package/lib/src/ap-field/radio/index.vue.js +1 -1
- package/lib/src/ap-field/radio/read.vue2.js +1 -1
- package/lib/src/ap-field/rate/index.vue.d.ts +20 -0
- package/lib/src/ap-field/rate/index.vue.js +1 -1
- package/lib/src/ap-form/interface.d.ts +4 -0
- package/lib/src/ap-form/item/index.vue.js +1 -1
- package/lib/src/ap-form/items/checkbox/index.vue.js +1 -1
- package/lib/src/ap-form/items/date/index.vue.js +1 -1
- package/lib/src/ap-form/items/date-range/index.vue.js +1 -1
- package/lib/src/ap-form/items/number/index.vue.js +1 -1
- package/lib/src/ap-form/items/radio/index.vue.d.ts +8 -0
- package/lib/src/ap-form/items/radio/index.vue.js +1 -1
- package/lib/src/ap-form/items/select/index.vue.js +1 -1
- package/lib/src/ap-form/items/switch/index.vue.js +1 -1
- package/lib/src/ap-form/items/text/index.vue2.js +1 -1
- package/lib/src/ap-form/items/text/password.vue.js +1 -1
- package/lib/src/ap-form/items/text-area/index.vue.d.ts +4 -4
- package/lib/src/ap-form/items/text-area/index.vue.js +1 -1
- package/lib/src/ap-form/items/tree-select/index.vue.js +1 -1
- package/lib/src/ap-form/render/item.vue.js +1 -1
- package/lib/src/ap-grid/utils/editable.d.ts +2 -1
- package/lib/src/ap-table/constants.d.ts +4 -0
- package/lib/src/ap-table/interface.d.ts +5 -0
- package/lib/src/ap-table/utils.js +1 -1
- package/lib/src/ap-upload/components/MultipleFile.vue.d.ts +10 -0
- package/lib/src/business/ap-appendix/ap-appendix.vue2.js +1 -1
- package/lib/src/business/batch-input-group/form-item.vue.js +1 -1
- package/lib/src/editable-table/utils.d.ts +3 -2
- package/lib/src/index.js +1 -1
- package/lib/src/version.d.ts +1 -1
- package/lib/src/version.js +1 -1
- package/package.json +3 -3
- package/theme/ag-grid/editable.css +52 -0
- package/theme/ag-grid/editable.less +11 -0
- package/theme/ag-grid/index.css +18 -0
- package/theme/ag-grid/index.less +1 -0
- package/theme/ap-appendix/ap-appendix.css +4 -13
- package/theme/ap-appendix/ap-appendix.less +5 -12
- package/theme/ap-form/ap-form-item.css +12 -0
- package/theme/ap-form/ap-form-item.less +12 -0
- package/theme/ap-form/index.css +12 -0
- package/theme/ap-form/search-form.css +12 -0
- package/theme/ap-grid/editable.css +1 -0
- package/theme/ap-grid/editable.less +1 -0
- package/theme/ap-grid/index.css +13 -0
- package/theme/ap-grid/index.less +1 -0
- package/theme/ap-table/ap-table.css +12 -0
- package/theme/ap-table-modal/index.css +12 -0
- package/theme/editable-table/index.css +13 -0
- package/theme/editable-table/index.less +1 -0
- package/theme/index.css +25 -13
- package/es/src/business/ap-appendix/icons/empty-admin-icon.vue.d.ts +0 -3
- package/es/src/business/ap-appendix/icons/empty-admin-icon.vue.mjs +0 -20
- package/es/src/business/ap-appendix/icons/empty-aplus-icon.vue.d.ts +0 -3
- package/es/src/business/ap-appendix/icons/empty-aplus-icon.vue.mjs +0 -20
- package/lib/src/business/ap-appendix/icons/empty-admin-icon.vue.d.ts +0 -3
- package/lib/src/business/ap-appendix/icons/empty-admin-icon.vue.js +0 -1
- package/lib/src/business/ap-appendix/icons/empty-aplus-icon.vue.d.ts +0 -3
- package/lib/src/business/ap-appendix/icons/empty-aplus-icon.vue.js +0 -1
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { shallowRef as _, computed as S, unref as d, isRef as z } from "vue";
|
|
2
|
+
import { isDef as K } from "../../utils/index.mjs";
|
|
3
|
+
import { isFunction as x, isUndefined as A, isNumber as h, cloneDeep as E, isArray as I, isString as N } from "lodash-unified";
|
|
4
|
+
import { arrayToObject as U } from "../editable/utils.mjs";
|
|
5
|
+
let $ = 0;
|
|
6
|
+
function R() {
|
|
7
|
+
return `_ag_grid${$++}`;
|
|
8
|
+
}
|
|
9
|
+
const J = (n, g, i, m) => {
|
|
10
|
+
const w = _([]), y = S(() => z(g) ? d(g) : g);
|
|
11
|
+
function F(u, l) {
|
|
12
|
+
const r = d(i)?.length || 0;
|
|
13
|
+
if (K(n.maxLength) && r >= n.maxLength || !u && x(n.rowKey))
|
|
14
|
+
return;
|
|
15
|
+
const f = {
|
|
16
|
+
...u || { [n.rowKey]: R() }
|
|
17
|
+
};
|
|
18
|
+
y.value?.setFieldValue?.(
|
|
19
|
+
n.name,
|
|
20
|
+
f,
|
|
21
|
+
!0,
|
|
22
|
+
(o, s) => {
|
|
23
|
+
const e = c(f, void 0, n.rowKey);
|
|
24
|
+
if (o[s] ? o[s][e] = f : o[s] = { [e]: f }, !i.value?.length) {
|
|
25
|
+
i.value = [f];
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
A(l) ? i.value.push(f) : (w.value = i.value.map(
|
|
29
|
+
(t, v) => v < l ? null : c(t, v, n.rowKey)
|
|
30
|
+
).filter(Boolean), i.value.splice(l, 0, f));
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
function j(u, l = "suffix") {
|
|
35
|
+
const r = d(i)?.length || 0, f = h(u) ? u : u.length;
|
|
36
|
+
if (K(n.maxLength) && r + f > n.maxLength || h(u) && x(n.rowKey))
|
|
37
|
+
return;
|
|
38
|
+
const o = h(u) ? new Array(u).fill(0).map(() => ({ [n.rowKey]: R() })) : E(u), s = U(o, n.rowKey);
|
|
39
|
+
y.value?.setFieldValue?.(
|
|
40
|
+
n.name,
|
|
41
|
+
o,
|
|
42
|
+
!0,
|
|
43
|
+
(e, t) => {
|
|
44
|
+
if (e[t] ? Object.assign(e[t], s) : e[t] = s, !i.value?.length) {
|
|
45
|
+
i.value = [...o];
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
l === "suffix" ? i.value.push(...o) : (w.value = i.value.map(
|
|
49
|
+
(v, T) => c(v, T, n.rowKey)
|
|
50
|
+
), i.value.unshift(...o));
|
|
51
|
+
}
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
function k(u) {
|
|
55
|
+
const l = I(u) ? u : [u];
|
|
56
|
+
y.value?.setFieldValue?.(
|
|
57
|
+
n.name,
|
|
58
|
+
void 0,
|
|
59
|
+
!0,
|
|
60
|
+
(r, f) => {
|
|
61
|
+
for (const e of l) {
|
|
62
|
+
const t = c(e, void 0, n.rowKey);
|
|
63
|
+
delete r[f][t];
|
|
64
|
+
}
|
|
65
|
+
const o = i.value.filter(
|
|
66
|
+
(e) => !l.includes(e)
|
|
67
|
+
), s = i.value.findIndex(
|
|
68
|
+
(e) => l.includes(e)
|
|
69
|
+
);
|
|
70
|
+
w.value = i.value.map(
|
|
71
|
+
(e, t) => t <= s ? null : c(e, t, n.rowKey)
|
|
72
|
+
).filter(Boolean), m?.(o);
|
|
73
|
+
}
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
function c(u, l, r) {
|
|
77
|
+
if (r)
|
|
78
|
+
return N(r) ? u[r] : r(u, l);
|
|
79
|
+
}
|
|
80
|
+
function L(u) {
|
|
81
|
+
const l = new Set(I(u) ? u : [u]);
|
|
82
|
+
l.size !== 0 && y.value?.setFieldValue?.(
|
|
83
|
+
n.name,
|
|
84
|
+
void 0,
|
|
85
|
+
!0,
|
|
86
|
+
(r, f) => {
|
|
87
|
+
for (const e of l)
|
|
88
|
+
delete r[f][e];
|
|
89
|
+
const o = i.value.filter(
|
|
90
|
+
(e, t) => !l.has(c(e, t, n.rowKey))
|
|
91
|
+
), s = i.value.findIndex(
|
|
92
|
+
(e, t) => l.has(c(e, t, n.rowKey))
|
|
93
|
+
);
|
|
94
|
+
w.value = i.value.map(
|
|
95
|
+
(e, t) => t <= s ? null : c(e, t, n.rowKey)
|
|
96
|
+
).filter(Boolean), m?.(o);
|
|
97
|
+
}
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
function O(u) {
|
|
101
|
+
return d(i)?.[u];
|
|
102
|
+
}
|
|
103
|
+
function V() {
|
|
104
|
+
return d(i);
|
|
105
|
+
}
|
|
106
|
+
function B(u, l, r = !0) {
|
|
107
|
+
y.value?.setFieldValue?.(
|
|
108
|
+
n.name,
|
|
109
|
+
void 0,
|
|
110
|
+
!0,
|
|
111
|
+
(f, o) => {
|
|
112
|
+
const s = i.value.findIndex(
|
|
113
|
+
(t, v) => u === v
|
|
114
|
+
);
|
|
115
|
+
if (!~s)
|
|
116
|
+
return;
|
|
117
|
+
const e = c(
|
|
118
|
+
i.value[s],
|
|
119
|
+
s,
|
|
120
|
+
n.rowKey
|
|
121
|
+
);
|
|
122
|
+
if (e && !(!f[o] || !f[o][e])) {
|
|
123
|
+
if (!r) {
|
|
124
|
+
const t = Object.keys(f[o][e]);
|
|
125
|
+
for (const v of t)
|
|
126
|
+
v !== n.rowKey && delete f[o][e][v];
|
|
127
|
+
}
|
|
128
|
+
Object.assign(f[o][e], { ...l });
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
function a() {
|
|
134
|
+
y.value?.setFieldValue?.(n.name, {}), m?.([]);
|
|
135
|
+
}
|
|
136
|
+
return {
|
|
137
|
+
add: F,
|
|
138
|
+
addMultiple: j,
|
|
139
|
+
remove: k,
|
|
140
|
+
removeByKey: L,
|
|
141
|
+
getRowData: O,
|
|
142
|
+
getRowsData: V,
|
|
143
|
+
setRowData: B,
|
|
144
|
+
clear: a,
|
|
145
|
+
refreshRowIds: w
|
|
146
|
+
};
|
|
147
|
+
};
|
|
148
|
+
export {
|
|
149
|
+
J as useEditableApi
|
|
150
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ComputedRef, Ref } from 'vue';
|
|
2
|
+
import { EditableAgGridProps } from '../editable/interface';
|
|
3
|
+
import { ValueTypeRenderConfig } from '../../config-provider';
|
|
4
|
+
import { AgGridColumnType } from '../interface';
|
|
5
|
+
export declare const useGetEditableColumns: (props: EditableAgGridProps, extraValueTypes: Ref<Record<string, ValueTypeRenderConfig> | undefined>, shadowName?: string) => ComputedRef<AgGridColumnType[]>;
|
|
6
|
+
export default useGetEditableColumns;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { unref as w, computed as E } from "vue";
|
|
2
|
+
import { isFunction as F, isArray as g } from "lodash-unified";
|
|
3
|
+
import { mergeClass as p, getColumnIsRequired as v } from "../../editable-table/utils.mjs";
|
|
4
|
+
import { updateFormProps as y, getFieldProps as q } from "../../ap-table/utils.mjs";
|
|
5
|
+
import { getFinalEditableNode as A } from "../../ap-grid/utils/editable.mjs";
|
|
6
|
+
import { isDef as K } from "../../utils/index.mjs";
|
|
7
|
+
import { getRowKey as M } from "../editable/utils.mjs";
|
|
8
|
+
function m(t, r, n) {
|
|
9
|
+
t.__skipNextRefresh ? t.__skipNextRefresh[r] = n : t.__skipNextRefresh = { [r]: n };
|
|
10
|
+
}
|
|
11
|
+
function D(t, r, n) {
|
|
12
|
+
t.__prevEditable ? t.__prevEditable[r] = n : t.__prevEditable = { [r]: n };
|
|
13
|
+
}
|
|
14
|
+
const J = (t, r, n) => {
|
|
15
|
+
function h(e) {
|
|
16
|
+
return !e.editable || e.children?.length ? {} : {
|
|
17
|
+
customRender({ value: f, originalNode: d, params: o, ...i }) {
|
|
18
|
+
const s = F(e.editable) ? e.editable(
|
|
19
|
+
i.text,
|
|
20
|
+
i.record,
|
|
21
|
+
i.rowIndex
|
|
22
|
+
) : !!e.editable;
|
|
23
|
+
let c = d;
|
|
24
|
+
if (s) {
|
|
25
|
+
const u = y(
|
|
26
|
+
e,
|
|
27
|
+
q(e.fieldProps, {
|
|
28
|
+
value: f,
|
|
29
|
+
...i
|
|
30
|
+
})
|
|
31
|
+
), b = {};
|
|
32
|
+
t.onFieldChange && (b[`onUpdate:${u.valuePropName || "value"}`] = (k) => t.onFieldChange?.(
|
|
33
|
+
i.rowIndex,
|
|
34
|
+
e.dataIndex,
|
|
35
|
+
k
|
|
36
|
+
));
|
|
37
|
+
const I = g(e.dataIndex) ? e.dataIndex : [e.dataIndex], C = n ? [n] : g(t.name) ? t.name : [t.name], R = M(
|
|
38
|
+
i.record,
|
|
39
|
+
i.rowIndex,
|
|
40
|
+
t.rowKey
|
|
41
|
+
), N = {
|
|
42
|
+
name: [...C, String(R), ...I],
|
|
43
|
+
...u || {},
|
|
44
|
+
field: {
|
|
45
|
+
style: "width: 100%",
|
|
46
|
+
...u?.field || {},
|
|
47
|
+
...b,
|
|
48
|
+
class: p("is-editable", u.class)
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
c = A(
|
|
52
|
+
e,
|
|
53
|
+
N,
|
|
54
|
+
i.record,
|
|
55
|
+
w(r)
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
e.customRender && (c = e.customRender({
|
|
59
|
+
value: f,
|
|
60
|
+
...i,
|
|
61
|
+
editable: s,
|
|
62
|
+
originalNode: c,
|
|
63
|
+
index: i.rowIndex,
|
|
64
|
+
renderIndex: i.rowIndex
|
|
65
|
+
}));
|
|
66
|
+
const a = o.node, l = o.column.getColId(), _ = a.__prevEditable?.[l];
|
|
67
|
+
return !a.__skipNextRefresh?.[l] && K(_) && _ !== s && (m(a, l, !0), setTimeout(() => {
|
|
68
|
+
o?.api.refreshCells({
|
|
69
|
+
rowNodes: [o.node],
|
|
70
|
+
columns: [o.column.getColId()],
|
|
71
|
+
force: !0
|
|
72
|
+
}), m(a, l, !1);
|
|
73
|
+
}, 0)), D(a, l, s), c;
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
return E(() => {
|
|
78
|
+
const e = t.columns;
|
|
79
|
+
if (!e)
|
|
80
|
+
return [];
|
|
81
|
+
function x(f) {
|
|
82
|
+
return f.map((d) => ({
|
|
83
|
+
...d,
|
|
84
|
+
_requireMark: v(d),
|
|
85
|
+
children: x(d.children || []),
|
|
86
|
+
// 处理可编辑/不可编辑下的单元格渲染
|
|
87
|
+
...h(d)
|
|
88
|
+
}));
|
|
89
|
+
}
|
|
90
|
+
return x(e);
|
|
91
|
+
});
|
|
92
|
+
};
|
|
93
|
+
export {
|
|
94
|
+
J as default,
|
|
95
|
+
J as useGetEditableColumns
|
|
96
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Ref } from 'vue';
|
|
2
|
+
import { ApFormInternalInstance } from '../../ap-form';
|
|
3
|
+
import { EditableAgGridProps } from '../editable/interface';
|
|
4
|
+
import { Key } from '@aplus-frontend/antdv/es/_util/type';
|
|
5
|
+
export declare const useEditableFormItemApi: <RecordType>(props: EditableAgGridProps<RecordType>, formApi: ApFormInternalInstance | undefined, tableData: Ref<RecordType[]>, shadowName: string) => {
|
|
6
|
+
add: (defaultValue?: Partial<RecordType>, insertIndex?: number) => void;
|
|
7
|
+
addMultiple: (list: number | Partial<RecordType>[], insetIn?: "prefix" | "suffix") => void;
|
|
8
|
+
remove: (data: RecordType | RecordType[]) => void;
|
|
9
|
+
removeByKey: (key: Key | Key[]) => void;
|
|
10
|
+
getRowData: (index: number) => RecordType;
|
|
11
|
+
getRowsData: () => RecordType[];
|
|
12
|
+
setRowData: (index: number, payload: any, merge?: boolean) => void;
|
|
13
|
+
clear: () => void;
|
|
14
|
+
};
|
package/es/src/ag-grid/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineComponent as eo, useSlots as oo, ref as I, toRef as T, unref as t, computed as l, nextTick as to, watch as z, createElementBlock as A, openBlock as b, normalizeStyle as V, normalizeClass as m, createCommentVNode as re, createElementVNode as B, createVNode as M, mergeProps as O, createSlots as ro, withCtx as ae, Fragment as ao, renderList as no, createBlock as ne, resolveDynamicComponent as lo, renderSlot as le, withDirectives as so, vShow as io } from "vue";
|
|
2
|
-
import { AgGridVue as
|
|
3
|
-
import { ModuleRegistry as
|
|
2
|
+
import { AgGridVue as uo } from "ag-grid-vue3";
|
|
3
|
+
import { ModuleRegistry as co, AllCommunityModule as mo } from "ag-grid-community";
|
|
4
4
|
import { mergeProps as po } from "./utils.mjs";
|
|
5
5
|
import { Spin as fo, Pagination as go } from "@aplus-frontend/antdv";
|
|
6
6
|
import { isUndefined as F, isFunction as se } from "lodash-unified";
|
|
@@ -26,7 +26,7 @@ import Ko from "./hooks/use-selection-col-def.mjs";
|
|
|
26
26
|
import { useNamespace as Po } from "../config-provider/hooks/use-namespace.mjs";
|
|
27
27
|
import { useGlobalConfig as zo } from "../config-provider/hooks/use-global-config.mjs";
|
|
28
28
|
import Ao from "./components/empty/index.vue2.mjs";
|
|
29
|
-
const
|
|
29
|
+
const ct = /* @__PURE__ */ eo({
|
|
30
30
|
name: "AgGrid",
|
|
31
31
|
__name: "index",
|
|
32
32
|
props: {
|
|
@@ -95,16 +95,18 @@ const ut = /* @__PURE__ */ eo({
|
|
|
95
95
|
onRowClicked: {},
|
|
96
96
|
onScrollEnd: {},
|
|
97
97
|
rowClassName: {},
|
|
98
|
-
rowClassRules: {}
|
|
98
|
+
rowClassRules: {},
|
|
99
|
+
autoHeight: { type: Boolean },
|
|
100
|
+
onUpdate: {}
|
|
99
101
|
},
|
|
100
|
-
setup(de, { expose:
|
|
101
|
-
|
|
102
|
-
const o = de, G = oo(), { e: k, b:
|
|
102
|
+
setup(de, { expose: ue }) {
|
|
103
|
+
co.registerModules([mo]);
|
|
104
|
+
const o = de, G = oo(), { e: k, b: u, be: ce } = Po("ag-grid"), y = I(o.size), me = Fo(y, T(o, "rowHeight")), pe = Do(T(o, "virtual")), { rowPinnedGridConfig: H, getRowPinnedCellClass: fe } = Eo(
|
|
103
105
|
T(o, "summary")
|
|
104
|
-
), ge = zo("apGrid"),
|
|
106
|
+
), ge = zo("apGrid"), s = I(), [, we] = Bo();
|
|
105
107
|
let p = !!o.dataSource;
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
+
const L = No(o), { shownColumns: f, columns: U, columnKeys: Se, getTargetColumnByKey: ye } = ko(o), { defaultColDef: Ce, columnDefs: he } = xo(
|
|
109
|
+
U,
|
|
108
110
|
o,
|
|
109
111
|
fe
|
|
110
112
|
), x = I({});
|
|
@@ -119,19 +121,19 @@ const ut = /* @__PURE__ */ eo({
|
|
|
119
121
|
desc: "descend"
|
|
120
122
|
};
|
|
121
123
|
function Re() {
|
|
122
|
-
const e =
|
|
124
|
+
const e = s.value.getColumns()?.filter((c) => c.getSort() !== void 0), r = t(x) || {};
|
|
123
125
|
let a = e?.[0];
|
|
124
126
|
const d = Object.keys(r);
|
|
125
|
-
if (d.length && d.every((
|
|
126
|
-
const
|
|
127
|
-
|
|
127
|
+
if (d.length && d.every((c) => r[c] === null)) {
|
|
128
|
+
const c = Object.keys(r)[0];
|
|
129
|
+
c && (a = s.value?.getColumn(c));
|
|
128
130
|
}
|
|
129
131
|
if (!a)
|
|
130
132
|
return;
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
column:
|
|
134
|
-
field: v?.field ??
|
|
133
|
+
const i = a.getColDef(), S = a.getSort(), v = ye(i.colId);
|
|
134
|
+
j(void 0, void 0, {
|
|
135
|
+
column: i,
|
|
136
|
+
field: v?.field ?? i.field ?? i.colId,
|
|
135
137
|
order: S ? ve[S] : null
|
|
136
138
|
});
|
|
137
139
|
}
|
|
@@ -140,7 +142,7 @@ const ut = /* @__PURE__ */ eo({
|
|
|
140
142
|
return e.field ?? e.dataIndex ?? e.key;
|
|
141
143
|
}).filter(Boolean)), Be = () => {
|
|
142
144
|
x.value = {};
|
|
143
|
-
const e =
|
|
145
|
+
const e = s.value;
|
|
144
146
|
if (!e)
|
|
145
147
|
return;
|
|
146
148
|
const r = e.getColumnState()?.map((a) => ({ ...a, sort: null }));
|
|
@@ -150,8 +152,8 @@ const ut = /* @__PURE__ */ eo({
|
|
|
150
152
|
submit: N,
|
|
151
153
|
reset: D,
|
|
152
154
|
data: w,
|
|
153
|
-
tableProps:
|
|
154
|
-
handleTableChangeOptional:
|
|
155
|
+
tableProps: W,
|
|
156
|
+
handleTableChangeOptional: j,
|
|
155
157
|
submitWith: $,
|
|
156
158
|
refresh: q,
|
|
157
159
|
getPaging: ke,
|
|
@@ -218,9 +220,9 @@ const ut = /* @__PURE__ */ eo({
|
|
|
218
220
|
return se(o.rowKey) ? o.rowKey(e) : e[o.rowKey];
|
|
219
221
|
}
|
|
220
222
|
const J = ({
|
|
221
|
-
api: e =
|
|
223
|
+
api: e = s.value
|
|
222
224
|
}) => {
|
|
223
|
-
if (!C.value)
|
|
225
|
+
if (o.onUpdate?.(), !C.value)
|
|
224
226
|
return;
|
|
225
227
|
const r = E.value;
|
|
226
228
|
if (!r.length) {
|
|
@@ -232,8 +234,8 @@ const ut = /* @__PURE__ */ eo({
|
|
|
232
234
|
p = !1;
|
|
233
235
|
const a = [];
|
|
234
236
|
e.forEachNode((d) => {
|
|
235
|
-
const h = d.data,
|
|
236
|
-
r.find((S) => K(S) ===
|
|
237
|
+
const h = d.data, i = K(h);
|
|
238
|
+
r.find((S) => K(S) === i) && a.push(d);
|
|
237
239
|
}), e.setNodesSelected({ nodes: a, newValue: !0 }), setTimeout(() => {
|
|
238
240
|
p = !0;
|
|
239
241
|
}, 0);
|
|
@@ -242,7 +244,7 @@ const ut = /* @__PURE__ */ eo({
|
|
|
242
244
|
}, Oe = () => {
|
|
243
245
|
p = !0;
|
|
244
246
|
}, P = () => {
|
|
245
|
-
Pe(),
|
|
247
|
+
Pe(), s.value?.deselectAll();
|
|
246
248
|
};
|
|
247
249
|
function Ge(e) {
|
|
248
250
|
ze(e), to(() => {
|
|
@@ -268,8 +270,8 @@ const ut = /* @__PURE__ */ eo({
|
|
|
268
270
|
function ee(e) {
|
|
269
271
|
return e && String(e);
|
|
270
272
|
}
|
|
271
|
-
function
|
|
272
|
-
const r =
|
|
273
|
+
function He(e) {
|
|
274
|
+
const r = s.value;
|
|
273
275
|
if (!r)
|
|
274
276
|
return;
|
|
275
277
|
const a = r.getColumnState() || [], d = e.map((n) => n.key ? String(n.key) : n.key).filter(Boolean), h = a.map((n) => {
|
|
@@ -282,14 +284,14 @@ const ut = /* @__PURE__ */ eo({
|
|
|
282
284
|
(_e) => ee(_e.key) === n.colId
|
|
283
285
|
);
|
|
284
286
|
return te && (oe.pinned = te.fixed || null), oe;
|
|
285
|
-
}),
|
|
287
|
+
}), i = new Map(
|
|
286
288
|
e.map((n, R) => [ee(n.key), R])
|
|
287
|
-
), S = h.filter((n) =>
|
|
288
|
-
(n, R) =>
|
|
289
|
+
), S = h.filter((n) => i.has(n.colId)).sort(
|
|
290
|
+
(n, R) => i.get(n.colId) - i.get(R.colId)
|
|
289
291
|
), v = [];
|
|
290
|
-
let
|
|
292
|
+
let c = 0;
|
|
291
293
|
for (const n of h)
|
|
292
|
-
|
|
294
|
+
i.has(n.colId) ? v.push(S[c++]) : v.push(n);
|
|
293
295
|
r.applyColumnState({
|
|
294
296
|
state: v,
|
|
295
297
|
applyOrder: !0
|
|
@@ -297,16 +299,16 @@ const ut = /* @__PURE__ */ eo({
|
|
|
297
299
|
}
|
|
298
300
|
vo({
|
|
299
301
|
columns: l(() => f.value),
|
|
300
|
-
columnsBackup: l(() =>
|
|
302
|
+
columnsBackup: l(() => U.value),
|
|
301
303
|
size: l(() => bo[y.value]),
|
|
302
304
|
updateColumns(e) {
|
|
303
|
-
f.value = e, o.onShownColumnsChange?.(e),
|
|
305
|
+
f.value = e, o.onShownColumnsChange?.(e), He(e);
|
|
304
306
|
},
|
|
305
307
|
updateSize(e) {
|
|
306
308
|
y.value = Ro[e];
|
|
307
309
|
},
|
|
308
310
|
renderConfig: l(() => ({
|
|
309
|
-
className:
|
|
311
|
+
className: ce("table-header", "title"),
|
|
310
312
|
color: we.value.colorTextTertiary
|
|
311
313
|
})),
|
|
312
314
|
dataSource: l(() => t(w).records),
|
|
@@ -320,25 +322,25 @@ const ut = /* @__PURE__ */ eo({
|
|
|
320
322
|
setSearchFormSorterItems: Z,
|
|
321
323
|
resetSearchFormSorterItems: _
|
|
322
324
|
});
|
|
323
|
-
const
|
|
325
|
+
const Le = l(
|
|
324
326
|
() => F(o.loading) ? w.loading : o.loading
|
|
325
|
-
),
|
|
326
|
-
|
|
327
|
-
o.card ? null :
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
].filter(Boolean)),
|
|
327
|
+
), Ue = l(() => [
|
|
328
|
+
u(),
|
|
329
|
+
o.card ? null : u("wrapper"),
|
|
330
|
+
u("adaptive"),
|
|
331
|
+
u(`size-${y.value}`)
|
|
332
|
+
].filter(Boolean)), We = l(() => ({
|
|
331
333
|
height: "100%",
|
|
332
334
|
...o.tableStyle || {}
|
|
333
|
-
})),
|
|
334
|
-
|
|
335
|
+
})), je = (e, r) => {
|
|
336
|
+
j({ current: e, pageSize: r });
|
|
335
337
|
};
|
|
336
338
|
function $e(e) {
|
|
337
339
|
const r = e.data;
|
|
338
340
|
return K(r);
|
|
339
341
|
}
|
|
340
342
|
function qe(e, r) {
|
|
341
|
-
|
|
343
|
+
s.value?.ensureIndexVisible(e, r);
|
|
342
344
|
}
|
|
343
345
|
function Je(e) {
|
|
344
346
|
o.onRowClicked?.(e.data, e.event);
|
|
@@ -347,14 +349,14 @@ const ut = /* @__PURE__ */ eo({
|
|
|
347
349
|
o.onScrollEnd?.(e.direction);
|
|
348
350
|
}
|
|
349
351
|
function Xe(e) {
|
|
350
|
-
return
|
|
352
|
+
return s.value?.refreshCells(e);
|
|
351
353
|
}
|
|
352
354
|
function Ye(e) {
|
|
353
|
-
return
|
|
355
|
+
return s.value?.redrawRows(e);
|
|
354
356
|
}
|
|
355
357
|
const Ze = (e) => {
|
|
356
358
|
const r = [
|
|
357
|
-
|
|
359
|
+
H.value.getRowClass?.(e)
|
|
358
360
|
];
|
|
359
361
|
if (!e.node.rowPinned) {
|
|
360
362
|
const a = se(o.rowClassName) ? o.rowClassName(e.data, e.rowIndex) : o.rowClassName;
|
|
@@ -378,7 +380,7 @@ const ut = /* @__PURE__ */ eo({
|
|
|
378
380
|
(e) => {
|
|
379
381
|
o.onLoadingChange?.(e);
|
|
380
382
|
}
|
|
381
|
-
),
|
|
383
|
+
), ue({
|
|
382
384
|
submit: N,
|
|
383
385
|
reset: D,
|
|
384
386
|
refresh: q,
|
|
@@ -399,12 +401,13 @@ const ut = /* @__PURE__ */ eo({
|
|
|
399
401
|
setSearchFormSorterItems: Z,
|
|
400
402
|
resetSearchFormSorterItems: _,
|
|
401
403
|
refreshCells: Xe,
|
|
402
|
-
redrawRows: Ye
|
|
404
|
+
redrawRows: Ye,
|
|
405
|
+
_internalGridApi: l(() => s.value)
|
|
403
406
|
}), (e, r) => (b(), A("div", {
|
|
404
|
-
class: m(
|
|
407
|
+
class: m(Ue.value),
|
|
405
408
|
style: V(e.wrapperStyle)
|
|
406
409
|
}, [
|
|
407
|
-
t(F)(e.dataSource) && e.searchForm !== !1 && t(
|
|
410
|
+
t(F)(e.dataSource) && e.searchForm !== !1 && t(L).length > 0 ? (b(), A("div", {
|
|
408
411
|
key: 0,
|
|
409
412
|
class: m(e.card ? t(k)("search-wrapper") : null),
|
|
410
413
|
style: V(e.searchFormWrapperStyle)
|
|
@@ -413,12 +416,12 @@ const ut = /* @__PURE__ */ eo({
|
|
|
413
416
|
ref_key: "formRef",
|
|
414
417
|
ref: g,
|
|
415
418
|
"custom-reset": "",
|
|
416
|
-
"submit-loading": t(
|
|
419
|
+
"submit-loading": t(W).loading,
|
|
417
420
|
onSubmit: t(N),
|
|
418
421
|
onReset: t(D)
|
|
419
422
|
}), ro({
|
|
420
423
|
default: ae(() => [
|
|
421
|
-
(b(!0), A(ao, null, no(t(
|
|
424
|
+
(b(!0), A(ao, null, no(t(L), (a) => (b(), ne(lo(a.renderNode), {
|
|
422
425
|
key: a.dataIndex
|
|
423
426
|
}))), 128))
|
|
424
427
|
]),
|
|
@@ -438,7 +441,7 @@ const ut = /* @__PURE__ */ eo({
|
|
|
438
441
|
style: V(e.tableWrapperStyle)
|
|
439
442
|
}, [
|
|
440
443
|
B("div", {
|
|
441
|
-
class: m(t(
|
|
444
|
+
class: m(t(u)("header-wrapper"))
|
|
442
445
|
}, [
|
|
443
446
|
le(e.$slots, "title", {
|
|
444
447
|
selectedRows: t(E),
|
|
@@ -448,11 +451,11 @@ const ut = /* @__PURE__ */ eo({
|
|
|
448
451
|
})
|
|
449
452
|
], 2),
|
|
450
453
|
B("div", {
|
|
451
|
-
class: m(t(
|
|
454
|
+
class: m(t(u)("grid-wrapper"))
|
|
452
455
|
}, [
|
|
453
|
-
M(t(
|
|
456
|
+
M(t(uo), O(t(po)(t(pe), t(H)), {
|
|
454
457
|
"get-row-class": Ze,
|
|
455
|
-
style:
|
|
458
|
+
style: We.value,
|
|
456
459
|
"row-data": t(w).records,
|
|
457
460
|
"column-defs": t(he),
|
|
458
461
|
"default-col-def": t(Ce),
|
|
@@ -467,34 +470,35 @@ const ut = /* @__PURE__ */ eo({
|
|
|
467
470
|
"row-class-rules": e.rowClassRules,
|
|
468
471
|
"no-rows-overlay-component": Ao,
|
|
469
472
|
"suppress-cell-focus": "",
|
|
473
|
+
"dom-layout": e.autoHeight ? "autoHeight" : "normal",
|
|
470
474
|
onSortChanged: Re,
|
|
471
|
-
onGridReady: r[0] || (r[0] = (a) =>
|
|
475
|
+
onGridReady: r[0] || (r[0] = (a) => s.value = a.api),
|
|
472
476
|
onRowDataUpdated: J,
|
|
473
477
|
onRowSelected: Me,
|
|
474
478
|
onFirstDataRendered: Oe,
|
|
475
479
|
onRowClicked: Je,
|
|
476
480
|
onBodyScrollEnd: Qe
|
|
477
|
-
}), null, 16, ["style", "row-data", "column-defs", "default-col-def", "row-selection", "selection-column-def", "theme", "enable-browser-tooltips", "row-class-rules"]),
|
|
481
|
+
}), null, 16, ["style", "row-data", "column-defs", "default-col-def", "row-selection", "selection-column-def", "theme", "enable-browser-tooltips", "row-class-rules", "dom-layout"]),
|
|
478
482
|
so(B("div", {
|
|
479
483
|
class: m(t(k)("table-loading-wrapper"))
|
|
480
484
|
}, [
|
|
481
485
|
M(t(fo), { delay: 300 })
|
|
482
486
|
], 2), [
|
|
483
|
-
[io,
|
|
487
|
+
[io, Le.value]
|
|
484
488
|
])
|
|
485
489
|
], 2),
|
|
486
490
|
B("div", {
|
|
487
|
-
class: m(t(
|
|
491
|
+
class: m(t(u)("pagination-wrapper"))
|
|
488
492
|
}, [
|
|
489
493
|
e.pagination !== !1 ? (b(), ne(t(go), O({
|
|
490
494
|
key: 0,
|
|
491
|
-
class: t(
|
|
492
|
-
}, t(
|
|
495
|
+
class: t(u)("pagination")
|
|
496
|
+
}, t(W).pagination, { onChange: je }), null, 16, ["class"])) : re("", !0)
|
|
493
497
|
], 2)
|
|
494
498
|
], 6)
|
|
495
499
|
], 6));
|
|
496
500
|
}
|
|
497
501
|
});
|
|
498
502
|
export {
|
|
499
|
-
|
|
503
|
+
ct as default
|
|
500
504
|
};
|
|
@@ -4,7 +4,7 @@ import { TableProps } from '@aplus-frontend/antdv';
|
|
|
4
4
|
import { ApFormSearchFormPopoverSorterItem, ApFormSearchFormProps } from '../ap-form/interface';
|
|
5
5
|
import { Recordable } from '../type';
|
|
6
6
|
import { SortOrder, TableRowSelection } from '@aplus-frontend/antdv/es/table/interface';
|
|
7
|
-
import { ColDef, IRowNode, RedrawRowsParams, RefreshCellsParams, RowClassRules, RowPinnedType, ScrollDirection } from 'ag-grid-community';
|
|
7
|
+
import { ColDef, GridApi, ICellRendererParams, IRowNode, RedrawRowsParams, RefreshCellsParams, RowClassRules, RowPinnedType, ScrollDirection } from 'ag-grid-community';
|
|
8
8
|
import { InternalPagingType } from '../ap-table/hooks/use-table-paging-ng';
|
|
9
9
|
export type AgGridColumnType<RecordType = any, ExtraValueType = 'text', ValueType extends ApTableValueTypes = ApTableValueTypes, MergedValueType extends ExtraValueType | ValueType = ExtraValueType | ValueType> = MergedValueType extends ExtraValueType | ValueType ? Omit<ExtraProColumnType<RecordType>, 'sorter' | 'rowSpan' | 'customCell' | 'customHeaderCell' | 'minWidth' | 'width' | 'maxWidth' | 'className' | 'class' | 'colSpan'> & {
|
|
10
10
|
children?: AgGridColumnType<RecordType, ExtraValueType, ValueType>[];
|
|
@@ -83,6 +83,7 @@ export type AgGridColumnType<RecordType = any, ExtraValueType = 'text', ValueTyp
|
|
|
83
83
|
originalText?: any;
|
|
84
84
|
pinned?: boolean;
|
|
85
85
|
rowIndex?: number;
|
|
86
|
+
params?: ICellRendererParams;
|
|
86
87
|
}) => any;
|
|
87
88
|
width?: number;
|
|
88
89
|
minWidth?: number;
|
|
@@ -97,6 +98,11 @@ export type AgGridColumnType<RecordType = any, ExtraValueType = 'text', ValueTyp
|
|
|
97
98
|
* 仅用于和接口交互的字段,如果不设置将会尝试使用`dataIndex`和`key`
|
|
98
99
|
*/
|
|
99
100
|
field?: string;
|
|
101
|
+
/**
|
|
102
|
+
* 是否在表头渲染必填标记
|
|
103
|
+
* @description 仅限内部使用
|
|
104
|
+
*/
|
|
105
|
+
_requireMark?: boolean;
|
|
100
106
|
} : null;
|
|
101
107
|
export type AgGridRowSelection<RecordType> = Pick<TableRowSelection<RecordType>, 'type' | 'fixed' | 'columnWidth' | 'defaultSelectedRowKeys'> & {
|
|
102
108
|
/**
|
|
@@ -259,6 +265,15 @@ export type AgGridProps<RecordType = any, ParamsType = any> = Omit<TableProps<Re
|
|
|
259
265
|
* 表格行自定义样式规则集
|
|
260
266
|
*/
|
|
261
267
|
rowClassRules?: RowClassRules<RecordType>;
|
|
268
|
+
/**
|
|
269
|
+
* 使用由内容撑起的高度来布局
|
|
270
|
+
*/
|
|
271
|
+
autoHeight?: boolean;
|
|
272
|
+
/**
|
|
273
|
+
* 当表格数据更新被应用后的回调
|
|
274
|
+
* @returns
|
|
275
|
+
*/
|
|
276
|
+
onUpdate?: () => void;
|
|
262
277
|
};
|
|
263
278
|
export type AgGridExpose<SearchParamsType = Recordable, RecordType = any> = {
|
|
264
279
|
/**
|
|
@@ -364,4 +379,8 @@ export type AgGridExpose<SearchParamsType = Recordable, RecordType = any> = {
|
|
|
364
379
|
* @returns
|
|
365
380
|
*/
|
|
366
381
|
redrawRows: (params?: RedrawRowsParams<RecordType>) => void;
|
|
382
|
+
/**
|
|
383
|
+
* AgGrid 暴露的Api实例(仅限内部使用)
|
|
384
|
+
*/
|
|
385
|
+
_internalGridApi?: GridApi | undefined;
|
|
367
386
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { GridOptions } from 'ag-grid-community';
|
|
2
|
+
import { EditableAgGridFormItemProps } from './editable/interface';
|
|
2
3
|
export declare function mergeProps(...options: GridOptions[]): GridOptions<any>;
|
|
3
4
|
/**
|
|
4
5
|
* 将尺寸单位px去掉
|
|
@@ -13,3 +14,4 @@ export declare function pxToNumber(value?: string | number, defaultValue?: numbe
|
|
|
13
14
|
* @returns
|
|
14
15
|
*/
|
|
15
16
|
export declare function getStringKey(key?: string | number): string | undefined;
|
|
17
|
+
export declare function getShadowName(name: EditableAgGridFormItemProps['name']): string;
|