@aplus-frontend/ui 0.1.45 → 0.1.46
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-table/hooks/use-table-column-state.mjs +55 -54
- package/es/src/ap-table/utils.d.ts +2 -1
- package/es/src/editable-table/form-item.vue.d.ts +1 -0
- package/es/src/editable-table/form-item.vue.mjs +60 -55
- package/es/src/editable-table/interface.d.ts +1 -1
- package/es/src/editable-table/utils.mjs +69 -69
- package/es/src/pro-table/pro-table.vue.d.ts +1 -0
- package/lib/src/ap-table/hooks/use-table-column-state.js +1 -1
- package/lib/src/ap-table/utils.d.ts +2 -1
- package/lib/src/editable-table/form-item.vue.d.ts +1 -0
- package/lib/src/editable-table/form-item.vue.js +1 -1
- package/lib/src/editable-table/interface.d.ts +1 -1
- package/lib/src/editable-table/utils.js +1 -1
- package/lib/src/pro-table/pro-table.vue.d.ts +1 -0
- package/package.json +3 -3
|
@@ -1,110 +1,111 @@
|
|
|
1
|
-
import { ref as R, shallowRef as _, unref as
|
|
1
|
+
import { ref as R, shallowRef as _, unref as a, computed as j, watchEffect as z } from "vue";
|
|
2
2
|
import { isDef as D } from "../../utils/index.mjs";
|
|
3
3
|
import G, { customCloneColumnStates as A, getColumnStateString as W } from "../components/setting/utils.mjs";
|
|
4
4
|
import { useInjectApTable as X } from "../context.mjs";
|
|
5
5
|
import { isObject as k, mergeWith as E, isBoolean as q, omit as H, isNumber as N } from "lodash-unified";
|
|
6
|
-
function
|
|
7
|
-
|
|
8
|
-
var
|
|
9
|
-
n(
|
|
6
|
+
function l(t, n) {
|
|
7
|
+
t.forEach((o) => {
|
|
8
|
+
var i;
|
|
9
|
+
n(o), (i = o.children) != null && i.length && l(o.children, n);
|
|
10
10
|
});
|
|
11
11
|
}
|
|
12
|
-
function L(
|
|
12
|
+
function L(t, n) {
|
|
13
13
|
if (!n)
|
|
14
14
|
return {};
|
|
15
|
-
const
|
|
16
|
-
return
|
|
15
|
+
const o = t.getItem(n);
|
|
16
|
+
return o ? JSON.parse(o) : {};
|
|
17
17
|
}
|
|
18
|
-
function I(
|
|
19
|
-
if (k(
|
|
20
|
-
return E({},
|
|
18
|
+
function I(t, n) {
|
|
19
|
+
if (k(t) && k(n))
|
|
20
|
+
return E({}, t, n, I);
|
|
21
21
|
}
|
|
22
|
-
const B = Number.MAX_SAFE_INTEGER, $ = (
|
|
23
|
-
const
|
|
22
|
+
const B = Number.MAX_SAFE_INTEGER, $ = (t, n) => {
|
|
23
|
+
const o = R(n), i = _(
|
|
24
24
|
A(n)
|
|
25
|
-
), { columnsBackup:
|
|
25
|
+
), { columnsBackup: m, updateColumns: u } = X(), T = t.persistenceType || "localStorage", p = window[T];
|
|
26
26
|
function F() {
|
|
27
27
|
const e = L(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
),
|
|
28
|
+
p,
|
|
29
|
+
t.persistenceKey
|
|
30
|
+
), r = E(
|
|
31
31
|
{},
|
|
32
|
-
|
|
32
|
+
t.defaultValue || {},
|
|
33
33
|
e,
|
|
34
34
|
I
|
|
35
|
-
),
|
|
35
|
+
), c = a(m);
|
|
36
36
|
function v(M, d, b) {
|
|
37
37
|
return M.map((s) => {
|
|
38
38
|
var x;
|
|
39
|
-
const
|
|
39
|
+
const f = (d == null ? void 0 : d[s.key]) || {}, h = {
|
|
40
40
|
key: s.key,
|
|
41
41
|
label: s.title,
|
|
42
42
|
show: !0,
|
|
43
43
|
fixed: b ? b.fixed : q(s.fixed) ? s.fixed ? "left" : void 0 : s.fixed,
|
|
44
44
|
disabled: !1,
|
|
45
|
-
...H(
|
|
45
|
+
...H(f, "children")
|
|
46
46
|
};
|
|
47
|
-
return
|
|
47
|
+
return h.children = (x = s.children) != null && x.length ? v(
|
|
48
48
|
s.children,
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
) : void 0,
|
|
49
|
+
f.children,
|
|
50
|
+
h
|
|
51
|
+
) : void 0, h;
|
|
52
52
|
}).sort(
|
|
53
|
-
(s,
|
|
53
|
+
(s, f) => (N(s.order) ? s.order : B) - (N(f.order) ? f.order : B)
|
|
54
54
|
);
|
|
55
55
|
}
|
|
56
|
-
return v(
|
|
56
|
+
return v(c || [], r);
|
|
57
57
|
}
|
|
58
|
-
const
|
|
59
|
-
function
|
|
60
|
-
const e =
|
|
61
|
-
|
|
62
|
-
!
|
|
58
|
+
const C = j(() => a(o).every((e) => e.show));
|
|
59
|
+
function S() {
|
|
60
|
+
const e = a(o);
|
|
61
|
+
l(e, (r) => {
|
|
62
|
+
!r.disabled && (r.show = !0);
|
|
63
63
|
});
|
|
64
64
|
}
|
|
65
|
-
function
|
|
66
|
-
const e =
|
|
67
|
-
|
|
68
|
-
!
|
|
65
|
+
function g() {
|
|
66
|
+
const e = a(o);
|
|
67
|
+
l(e, (r) => {
|
|
68
|
+
!r.disabled && (r.show = !1);
|
|
69
69
|
});
|
|
70
70
|
}
|
|
71
71
|
function O() {
|
|
72
|
-
|
|
72
|
+
a(C) ? g() : S();
|
|
73
73
|
}
|
|
74
|
-
function K(e,
|
|
75
|
-
|
|
76
|
-
|
|
74
|
+
function K(e, r) {
|
|
75
|
+
l(a(o), (c) => {
|
|
76
|
+
c.key === e && (c.show = D(r) ? r : !c.show);
|
|
77
77
|
});
|
|
78
78
|
}
|
|
79
79
|
function w(e) {
|
|
80
|
-
|
|
80
|
+
o.value = e;
|
|
81
81
|
}
|
|
82
82
|
function J(e) {
|
|
83
|
-
|
|
83
|
+
i.value = e;
|
|
84
84
|
}
|
|
85
85
|
function y(e) {
|
|
86
|
-
if (
|
|
87
|
-
const
|
|
88
|
-
|
|
86
|
+
if (t.persistenceKey) {
|
|
87
|
+
const r = W(e);
|
|
88
|
+
p.setItem(t.persistenceKey, JSON.stringify(r));
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
return z(() => {
|
|
92
|
+
var r;
|
|
92
93
|
const e = F();
|
|
93
|
-
w(e),
|
|
94
|
+
w(e), (r = t.onChange) == null || r.call(t, e), u == null || u(
|
|
94
95
|
G(
|
|
95
|
-
|
|
96
|
-
|
|
96
|
+
a(m),
|
|
97
|
+
a(e)
|
|
97
98
|
)
|
|
98
|
-
),
|
|
99
|
+
), i.value = A(e), y(e);
|
|
99
100
|
}), {
|
|
100
|
-
columnState:
|
|
101
|
-
selectAll:
|
|
102
|
-
unSelectAll:
|
|
101
|
+
columnState: o,
|
|
102
|
+
selectAll: S,
|
|
103
|
+
unSelectAll: g,
|
|
103
104
|
toggleSelect: K,
|
|
104
105
|
setColumnState: w,
|
|
105
|
-
isAllSelected:
|
|
106
|
+
isAllSelected: C,
|
|
106
107
|
toggleSelectAll: O,
|
|
107
|
-
columnStateBackup:
|
|
108
|
+
columnStateBackup: i,
|
|
108
109
|
setColumnStateBackup: J,
|
|
109
110
|
cacheColumnStateIfNeeded: y
|
|
110
111
|
};
|
|
@@ -2,6 +2,7 @@ import { ApColumnType, ValueEnum, ValueEnumType } from './interface';
|
|
|
2
2
|
import { ValueTypeRenderConfig } from '../config-provider';
|
|
3
3
|
import { apTableRenderItemMap } from './constants';
|
|
4
4
|
import { VNode, CreateComponentPublicInstance, ExtractPropTypes, PropType, HTMLAttributes, ComponentOptionsMixin, VNodeProps, AllowedComponentProps, ComponentCustomProps, ComponentOptionsBase, VNodeArrayChildren } from 'vue';
|
|
5
|
+
import { EditableColumnType } from '../editable-table/interface';
|
|
5
6
|
import { ApFormItemTransformType, ApFieldTextPasswordProps, ApFormItemSlots, ApFieldTextProps, ApFormItemTextPassword, ApFieldTextAreaProps, ApFieldNumberProps, ApFieldDateProps, ApFieldDateRangeProps, ApFieldRadioProps, ApFieldSelectProps, ApFieldSwitchProps, ApFieldCheckboxProps } from '..';
|
|
6
7
|
import { ColSize } from '@aplus-frontend/antdv/es/grid';
|
|
7
8
|
import { RuleObject } from '@aplus-frontend/antdv/es/form';
|
|
@@ -63,7 +64,7 @@ export declare function getFieldProps<RecordType = any>(fieldProps: ApColumnType
|
|
|
63
64
|
* @param item
|
|
64
65
|
* @returns
|
|
65
66
|
*/
|
|
66
|
-
export declare function getTableRenderType(item: ApColumnType
|
|
67
|
+
export declare function getTableRenderType(item: ApColumnType | EditableColumnType): "number" | "select" | "date" | "checkbox" | "radio" | "text" | "index" | "switch" | "status" | "password" | "action" | "dateRange" | "textArea";
|
|
67
68
|
export declare function getTableCellRenderNode(renderType: keyof typeof apTableRenderItemMap, renderProps: any, record: any, extraRenderMap?: Record<string, ValueTypeRenderConfig>): any;
|
|
68
69
|
/**
|
|
69
70
|
* 获取查询表单最终渲染的节点
|
|
@@ -13,6 +13,7 @@ declare const _default: <RecordType = any>(__VLS_props: NonNullable<Awaited<type
|
|
|
13
13
|
addMultiple: (list: number | Partial<RecordType>[], insetIn?: "prefix" | "suffix") => void;
|
|
14
14
|
scrollTo: (index: number | "end", options?: StandardBehaviorOptions) => void;
|
|
15
15
|
setTableData: (nextTableData: RecordType[]) => void;
|
|
16
|
+
clear: () => void;
|
|
16
17
|
}>): void;
|
|
17
18
|
attrs: any;
|
|
18
19
|
slots: Readonly<{
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { Table as
|
|
1
|
+
import { defineComponent as z, ref as h, unref as n, useSlots as O, watch as K, openBlock as M, createBlock as G, mergeProps as x, withCtx as g, createVNode as H, createSlots as W, renderList as $, renderSlot as U, normalizeProps as q, guardReactiveProps as J } from "vue";
|
|
2
|
+
import { Table as Q } from "@aplus-frontend/antdv";
|
|
3
3
|
import { ApForm as b } from "../ap-form/index.mjs";
|
|
4
|
-
import { isArray as
|
|
4
|
+
import { isArray as X, isNumber as d, cloneDeep as f, omit as w } from "lodash-unified";
|
|
5
5
|
import "../config-provider/index.mjs";
|
|
6
|
-
import { useInjectForm as
|
|
6
|
+
import { useInjectForm as Y } from "../ap-form/context.mjs";
|
|
7
7
|
import "./style/index.css";
|
|
8
8
|
import { isDef as m } from "../utils/index.mjs";
|
|
9
|
-
import
|
|
10
|
-
import { scrollToRowIndex as
|
|
11
|
-
import { useNamespace as
|
|
12
|
-
import { useGlobalConfig as
|
|
13
|
-
const
|
|
9
|
+
import Z from "./hooks/use-get-columns.mjs";
|
|
10
|
+
import { scrollToRowIndex as I } from "./utils.mjs";
|
|
11
|
+
import { useNamespace as ee } from "../config-provider/hooks/use-namespace.mjs";
|
|
12
|
+
import { useGlobalConfig as oe } from "../config-provider/hooks/use-global-config.mjs";
|
|
13
|
+
const pe = /* @__PURE__ */ z({
|
|
14
14
|
name: "EditableTableInner",
|
|
15
15
|
__name: "form-item",
|
|
16
16
|
props: {
|
|
@@ -113,99 +113,104 @@ const ce = /* @__PURE__ */ P({
|
|
|
113
113
|
setup(C, {
|
|
114
114
|
expose: y
|
|
115
115
|
}) {
|
|
116
|
-
const
|
|
116
|
+
const l = C;
|
|
117
117
|
function R(e, o) {
|
|
118
|
-
return
|
|
118
|
+
return X(o) ? o.reduce((r, a) => r == null ? void 0 : r[a], e) : e == null ? void 0 : e[o];
|
|
119
119
|
}
|
|
120
120
|
const {
|
|
121
|
-
internalInstance:
|
|
121
|
+
internalInstance: t,
|
|
122
122
|
model: B
|
|
123
|
-
} =
|
|
124
|
-
|
|
123
|
+
} = Y(), u = h(R(n(B), l.name) || []), D = O(), F = b.useWatch(l.name);
|
|
124
|
+
K(() => F.value, (e) => {
|
|
125
125
|
var o;
|
|
126
|
-
u.value = e, (o =
|
|
126
|
+
u.value = e, (o = l.onChange) == null || o.call(l, e);
|
|
127
127
|
}, {
|
|
128
128
|
deep: !0
|
|
129
129
|
});
|
|
130
130
|
const {
|
|
131
131
|
b: L
|
|
132
|
-
} =
|
|
133
|
-
function
|
|
132
|
+
} = ee("editable-table"), i = h(), T = oe("valueTypeMap"), V = Z(l, T);
|
|
133
|
+
function v(e, o) {
|
|
134
134
|
var s;
|
|
135
|
-
const r = ((s =
|
|
136
|
-
if (m(
|
|
135
|
+
const r = ((s = n(u)) == null ? void 0 : s.length) || 0;
|
|
136
|
+
if (m(l.maxLength) && r >= l.maxLength)
|
|
137
137
|
return;
|
|
138
|
-
const
|
|
139
|
-
m(o) ?
|
|
138
|
+
const a = [...n(u) || []];
|
|
139
|
+
m(o) ? a.splice(o, 0, {
|
|
140
140
|
...e || {}
|
|
141
|
-
}) :
|
|
141
|
+
}) : a.push({
|
|
142
142
|
...e || {}
|
|
143
|
-
}),
|
|
143
|
+
}), t == null || t.setFieldValue(l.name, a);
|
|
144
144
|
}
|
|
145
|
-
function
|
|
145
|
+
function E(e, o = "suffix") {
|
|
146
146
|
var p;
|
|
147
|
-
const r = ((p =
|
|
148
|
-
if (m(
|
|
147
|
+
const r = ((p = n(u)) == null ? void 0 : p.length) || 0, a = d(e) ? e : e.length;
|
|
148
|
+
if (m(l.maxLength) && r + a > l.maxLength)
|
|
149
149
|
return;
|
|
150
|
-
const s = [...
|
|
151
|
-
o === "suffix" ? s.push(...c) : s.unshift(...c),
|
|
150
|
+
const s = [...n(u) || []], c = d(e) ? new Array(e).fill({}) : f(e);
|
|
151
|
+
o === "suffix" ? s.push(...c) : s.unshift(...c), t == null || t.setFieldValue(l.name, s);
|
|
152
152
|
}
|
|
153
|
-
function
|
|
154
|
-
let o = f(
|
|
153
|
+
function N(e) {
|
|
154
|
+
let o = f(n(u) || []);
|
|
155
155
|
const r = d(e) ? [e] : e;
|
|
156
|
-
o = o.filter((
|
|
156
|
+
o = o.filter((a, s) => !r.includes(s)), t == null || t.setFieldValue(l.name, o);
|
|
157
157
|
}
|
|
158
|
-
function
|
|
159
|
-
return
|
|
158
|
+
function S() {
|
|
159
|
+
return n(u);
|
|
160
160
|
}
|
|
161
161
|
function _(e) {
|
|
162
162
|
var o;
|
|
163
|
-
return (o =
|
|
163
|
+
return (o = n(u)) == null ? void 0 : o[e];
|
|
164
164
|
}
|
|
165
165
|
function k(e, o, r = !0) {
|
|
166
|
-
const
|
|
167
|
-
|
|
168
|
-
...r ?
|
|
166
|
+
const a = f(n(u));
|
|
167
|
+
a[e] && (a[e] = {
|
|
168
|
+
...r ? a[e] : {},
|
|
169
169
|
...o
|
|
170
|
-
},
|
|
170
|
+
}, t == null || t.setFieldValue(l.name, [...a]));
|
|
171
171
|
}
|
|
172
172
|
function j(e) {
|
|
173
|
-
|
|
173
|
+
t == null || t.setFieldValue(l.name, e);
|
|
174
174
|
}
|
|
175
175
|
function A(e, o) {
|
|
176
|
-
var
|
|
176
|
+
var a;
|
|
177
177
|
const r = e === "end" ? u.value.length - 1 : e;
|
|
178
|
-
|
|
178
|
+
I(r, (a = i.value) == null ? void 0 : a.$el, o);
|
|
179
|
+
}
|
|
180
|
+
function P() {
|
|
181
|
+
var e;
|
|
182
|
+
(e = t == null ? void 0 : t.setFieldValue) == null || e.call(t, l.name, []);
|
|
179
183
|
}
|
|
180
184
|
return y({
|
|
181
|
-
add:
|
|
182
|
-
remove:
|
|
185
|
+
add: v,
|
|
186
|
+
remove: N,
|
|
183
187
|
getRowData: _,
|
|
184
|
-
getRowsData:
|
|
188
|
+
getRowsData: S,
|
|
185
189
|
setRowData: k,
|
|
186
|
-
addMultiple:
|
|
190
|
+
addMultiple: E,
|
|
187
191
|
scrollTo: A,
|
|
188
|
-
setTableData: j
|
|
189
|
-
|
|
192
|
+
setTableData: j,
|
|
193
|
+
clear: P
|
|
194
|
+
}), (e, o) => (M(), G(n(b).FormItem, x(e.formItem, {
|
|
190
195
|
name: e.name,
|
|
191
196
|
label: e.label
|
|
192
197
|
}), {
|
|
193
|
-
default: g(() => [
|
|
194
|
-
class:
|
|
195
|
-
columns:
|
|
198
|
+
default: g(() => [H(n(Q), x(n(w)(l, ["name", "maxLength", "onChange"]), {
|
|
199
|
+
class: n(L)(),
|
|
200
|
+
columns: n(V),
|
|
196
201
|
"data-source": u.value,
|
|
197
202
|
ref_key: "tableRef",
|
|
198
203
|
ref: i
|
|
199
|
-
}),
|
|
204
|
+
}), W({
|
|
200
205
|
_: 2
|
|
201
|
-
}, [
|
|
202
|
-
name:
|
|
203
|
-
fn: g((s) => [
|
|
206
|
+
}, [$(n(w)(D, ["headerCell"]), (r, a) => ({
|
|
207
|
+
name: a,
|
|
208
|
+
fn: g((s) => [U(e.$slots, a, q(J(s || {})))])
|
|
204
209
|
}))]), 1040, ["class", "columns", "data-source"])]),
|
|
205
210
|
_: 3
|
|
206
211
|
}, 16, ["name", "label"]));
|
|
207
212
|
}
|
|
208
213
|
});
|
|
209
214
|
export {
|
|
210
|
-
|
|
215
|
+
pe as default
|
|
211
216
|
};
|
|
@@ -175,4 +175,4 @@ export type EditableTableExpose<ModelType = any, RecordType = any> = {
|
|
|
175
175
|
* 可编辑表格作为表单项暴露的实例
|
|
176
176
|
* @description 作为Form表单使用时不再暴露表单相关的API
|
|
177
177
|
*/
|
|
178
|
-
export type EditableTableFormItemExpose<ModelType = any, RecordType = any> = Omit<EditableTableExpose<ModelType, RecordType>, 'resetFields' | 'validateFields'
|
|
178
|
+
export type EditableTableFormItemExpose<ModelType = any, RecordType = any> = Omit<EditableTableExpose<ModelType, RecordType>, 'resetFields' | 'validateFields'>;
|
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
import { isVNode as I, createVNode as
|
|
2
|
-
import { isFunction as
|
|
3
|
-
import { apTableFormItemMap as
|
|
4
|
-
import { isDef as
|
|
1
|
+
import { isVNode as I, createVNode as s, mergeProps as S, createTextVNode as F, Fragment as w } from "vue";
|
|
2
|
+
import { isFunction as T, isArray as h, isBoolean as P, omit as V, isString as q } from "lodash-unified";
|
|
3
|
+
import { apTableFormItemMap as C, noRenderAsFormItemValueList as N, apTableRenderItemMap as j } from "../ap-table/constants.mjs";
|
|
4
|
+
import { isDef as v } from "../utils/index.mjs";
|
|
5
5
|
import { getValueStr as A } from "../ap-field/number/helper.mjs";
|
|
6
6
|
import O from "scroll-into-view-if-needed";
|
|
7
|
-
import { Typography as
|
|
7
|
+
import { Typography as R, Tooltip as W } from "@aplus-frontend/antdv";
|
|
8
8
|
import "../ap-form/index.mjs";
|
|
9
|
-
import { objectToString as D } from "../ap-table/utils.mjs";
|
|
9
|
+
import { objectToString as _, getTableRenderType as D } from "../ap-table/utils.mjs";
|
|
10
10
|
import { QuestionCircleOutlined as E } from "@ant-design/icons-vue";
|
|
11
|
-
import
|
|
12
|
-
function
|
|
11
|
+
import b from "../ap-form/ap-form-item.vue.mjs";
|
|
12
|
+
function g(t) {
|
|
13
13
|
return typeof t == "function" || Object.prototype.toString.call(t) === "[object Object]" && !I(t);
|
|
14
14
|
}
|
|
15
|
-
function R(t) {
|
|
16
|
-
return v[t];
|
|
17
|
-
}
|
|
18
15
|
function k(t) {
|
|
16
|
+
return C[t];
|
|
17
|
+
}
|
|
18
|
+
function B(t) {
|
|
19
19
|
if (!t.fieldProps)
|
|
20
20
|
return !1;
|
|
21
|
-
const e =
|
|
22
|
-
return
|
|
21
|
+
const e = T(t.fieldProps) ? t.fieldProps({}) : t.fieldProps;
|
|
22
|
+
return v(e.required) ? e.required : (h(e.rules) ? e.rules : e.rules ? [e.rules] : []).some((i) => i.required);
|
|
23
23
|
}
|
|
24
|
-
function
|
|
24
|
+
function L(t, e) {
|
|
25
25
|
if (t.valueType === "text" || t.valueType === "textArea")
|
|
26
26
|
return e || "--";
|
|
27
27
|
if (t.valueType === "number") {
|
|
28
|
-
const
|
|
29
|
-
return A(e,
|
|
28
|
+
const o = t.fieldProps ? T(t.fieldProps) ? t.fieldProps({}) : t.fieldProps : {};
|
|
29
|
+
return A(e, o) || "--";
|
|
30
30
|
}
|
|
31
|
-
return
|
|
31
|
+
return _(e);
|
|
32
32
|
}
|
|
33
|
-
function
|
|
34
|
-
const
|
|
33
|
+
function M(t, e) {
|
|
34
|
+
const o = [t];
|
|
35
35
|
if (e) {
|
|
36
|
-
const
|
|
37
|
-
|
|
36
|
+
const i = h(e) ? e : [e];
|
|
37
|
+
o.unshift(...i);
|
|
38
38
|
}
|
|
39
|
-
return
|
|
39
|
+
return o.join(" ");
|
|
40
40
|
}
|
|
41
|
-
function
|
|
42
|
-
const
|
|
43
|
-
|
|
41
|
+
function tt(t, e = document.body, o = {}) {
|
|
42
|
+
const i = e.querySelectorAll("tr.ant-table-row")[t];
|
|
43
|
+
i && O(i, {
|
|
44
44
|
scrollMode: "if-needed",
|
|
45
45
|
block: "nearest",
|
|
46
46
|
behavior: "smooth",
|
|
47
|
-
...
|
|
47
|
+
...o
|
|
48
48
|
});
|
|
49
49
|
}
|
|
50
|
-
function
|
|
51
|
-
return
|
|
50
|
+
function Q(t, e, o) {
|
|
51
|
+
return N.includes(t.valueType) ? o : t.copyable || t.ellipsis ? s(R.Paragraph, {
|
|
52
52
|
copyable: t.copyable ? {
|
|
53
53
|
text: e,
|
|
54
54
|
tooltip: !1
|
|
@@ -59,76 +59,76 @@ function L(t, e, i) {
|
|
|
59
59
|
...t.ellipsis,
|
|
60
60
|
tooltip: e
|
|
61
61
|
} : !1,
|
|
62
|
-
content: t.ellipsis ?
|
|
63
|
-
}, null) :
|
|
62
|
+
content: t.ellipsis ? L(t, e) : o
|
|
63
|
+
}, null) : o;
|
|
64
64
|
}
|
|
65
|
-
function
|
|
66
|
-
var
|
|
65
|
+
function et(t, e, o, i, u, l) {
|
|
66
|
+
var m, c;
|
|
67
67
|
if (e) {
|
|
68
68
|
if (t.customRenderFormItem) {
|
|
69
|
-
const
|
|
70
|
-
return
|
|
71
|
-
default: () => [
|
|
69
|
+
const d = t.customRenderFormItem(t, o.field, e, u);
|
|
70
|
+
return s(b, V(o, ["field"]), g(d) ? d : {
|
|
71
|
+
default: () => [d]
|
|
72
72
|
});
|
|
73
73
|
}
|
|
74
|
-
const
|
|
75
|
-
if (
|
|
76
|
-
return r
|
|
77
|
-
const n = l == null ? void 0 : l[t.valueType],
|
|
78
|
-
return
|
|
79
|
-
default: () => [
|
|
74
|
+
const r = k(t.valueType);
|
|
75
|
+
if (r)
|
|
76
|
+
return s(r, o, null);
|
|
77
|
+
const n = l == null ? void 0 : l[t.valueType], f = (m = n == null ? void 0 : n.renderFormItem) == null ? void 0 : m.call(n, o.field);
|
|
78
|
+
return f ? s(b, o, g(f) ? f : {
|
|
79
|
+
default: () => [f]
|
|
80
80
|
}) : null;
|
|
81
81
|
}
|
|
82
|
-
let
|
|
83
|
-
const
|
|
84
|
-
if (
|
|
85
|
-
|
|
82
|
+
let p;
|
|
83
|
+
const y = D(t), a = j[y];
|
|
84
|
+
if (a)
|
|
85
|
+
p = s(a, S(o.field, {
|
|
86
86
|
mode: "read"
|
|
87
87
|
}), null);
|
|
88
88
|
else {
|
|
89
|
-
const
|
|
90
|
-
|
|
89
|
+
const r = l == null ? void 0 : l[y];
|
|
90
|
+
p = (c = r == null ? void 0 : r.render) == null ? void 0 : c.call(r, i, u, o.field);
|
|
91
91
|
}
|
|
92
|
-
return
|
|
92
|
+
return p ? Q(t, i, p) : null;
|
|
93
93
|
}
|
|
94
|
-
function
|
|
95
|
-
const l =
|
|
94
|
+
function ot(t, e, o, i, u) {
|
|
95
|
+
const l = i == null ? void 0 : i({
|
|
96
96
|
title: t.title,
|
|
97
97
|
column: t
|
|
98
|
-
}),
|
|
99
|
-
if (l &&
|
|
98
|
+
}), p = (l == null ? void 0 : l.filter((d) => d.type !== Symbol.for("v-cmt"))) || [];
|
|
99
|
+
if (l && p.length > 0)
|
|
100
100
|
return l;
|
|
101
|
-
const
|
|
101
|
+
const a = B(t), c = q(t.title) ? {
|
|
102
102
|
class: e,
|
|
103
103
|
title: t.title
|
|
104
|
-
} : {},
|
|
105
|
-
class:
|
|
106
|
-
}, [F("*")]) : null, t.title]),
|
|
107
|
-
return
|
|
104
|
+
} : {}, r = s("div", c, [a ? s("span", {
|
|
105
|
+
class: o
|
|
106
|
+
}, [F("*")]) : null, t.title]), n = t.tooltip ? T(t.tooltip) ? t.tooltip(t) : s(w, null, [t.tooltip]) : null;
|
|
107
|
+
return n ? s("span", {
|
|
108
108
|
style: {
|
|
109
109
|
display: "inline-flex",
|
|
110
110
|
alignItems: "center",
|
|
111
111
|
maxWidth: "100%"
|
|
112
112
|
}
|
|
113
|
-
}, [
|
|
114
|
-
title:
|
|
113
|
+
}, [r, s(W, {
|
|
114
|
+
title: n,
|
|
115
115
|
placement: "bottom"
|
|
116
116
|
}, {
|
|
117
|
-
default: () => [
|
|
117
|
+
default: () => [s(E, {
|
|
118
118
|
style: {
|
|
119
119
|
padding: "4px",
|
|
120
|
-
color:
|
|
120
|
+
color: u,
|
|
121
121
|
verticalAlign: "middle"
|
|
122
122
|
}
|
|
123
123
|
}, null)]
|
|
124
|
-
})]) :
|
|
124
|
+
})]) : r;
|
|
125
125
|
}
|
|
126
126
|
export {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
127
|
+
B as getColumnIsRequired,
|
|
128
|
+
k as getEditableComponent,
|
|
129
|
+
ot as getEditableTableTitle,
|
|
130
|
+
et as getFinalNode,
|
|
131
|
+
L as getRawDisplayValue,
|
|
132
|
+
M as mergeClass,
|
|
133
|
+
tt as scrollToRowIndex
|
|
134
134
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("vue"),j=require("../../utils/index.js"),f=require("../components/setting/utils.js"),K=require("../context.js"),i=require("lodash-unified");function d(t,o){t.forEach(n=>{var c;o(n),(c=n.children)!=null&&c.length&&d(n.children,o)})}function M(t,o){if(!o)return{};const n=t.getItem(o);return n?JSON.parse(n):{}}function k(t,o){if(i.isObject(t)&&i.isObject(o))return i.mergeWith({},t,o,k)}const T=Number.MAX_SAFE_INTEGER,J=(t,o)=>{const n=s.ref(o),c=s.shallowRef(f.customCloneColumnStates(o)),{columnsBackup:g,updateColumns:h}=K.useInjectApTable(),O=t.persistenceType||"localStorage",b=window[O];function q(){const e=M(b,t.persistenceKey),r=i.mergeWith({},t.defaultValue||{},e,k),a=s.unref(g);function x(F,C,A){return F.map(u=>{var N;const l=(C==null?void 0:C[u.key])||{},S={key:u.key,label:u.title,show:!0,fixed:A?A.fixed:i.isBoolean(u.fixed)?u.fixed?"left":void 0:u.fixed,disabled:!1,...i.omit(l,"children")};return S.children=(N=u.children)!=null&&N.length?x(u.children,l.children,S):void 0,S}).sort((u,l)=>(i.isNumber(u.order)?u.order:T)-(i.isNumber(l.order)?l.order:T))}return x(a||[],r)}const p=s.computed(()=>s.unref(n).every(e=>e.show));function w(){const e=s.unref(n);d(e,r=>{!r.disabled&&(r.show=!0)})}function y(){const e=s.unref(n);d(e,r=>{!r.disabled&&(r.show=!1)})}function E(){s.unref(p)?y():w()}function I(e,r){d(s.unref(n),a=>{a.key===e&&(a.show=j.isDef(r)?r:!a.show)})}function m(e){n.value=e}function B(e){c.value=e}function v(e){if(t.persistenceKey){const r=f.getColumnStateString(e);b.setItem(t.persistenceKey,JSON.stringify(r))}}return s.watchEffect(()=>{var r;const e=q();m(e),(r=t.onChange)==null||r.call(t,e),h==null||h(f.default(s.unref(g),s.unref(e))),c.value=f.customCloneColumnStates(e),v(e)}),{columnState:n,selectAll:w,unSelectAll:y,toggleSelect:I,setColumnState:m,isAllSelected:p,toggleSelectAll:E,columnStateBackup:c,setColumnStateBackup:B,cacheColumnStateIfNeeded:v}};exports.useTableColumnState=J;
|
|
@@ -2,6 +2,7 @@ import { ApColumnType, ValueEnum, ValueEnumType } from './interface';
|
|
|
2
2
|
import { ValueTypeRenderConfig } from '../config-provider';
|
|
3
3
|
import { apTableRenderItemMap } from './constants';
|
|
4
4
|
import { VNode, CreateComponentPublicInstance, ExtractPropTypes, PropType, HTMLAttributes, ComponentOptionsMixin, VNodeProps, AllowedComponentProps, ComponentCustomProps, ComponentOptionsBase, VNodeArrayChildren } from 'vue';
|
|
5
|
+
import { EditableColumnType } from '../editable-table/interface';
|
|
5
6
|
import { ApFormItemTransformType, ApFieldTextPasswordProps, ApFormItemSlots, ApFieldTextProps, ApFormItemTextPassword, ApFieldTextAreaProps, ApFieldNumberProps, ApFieldDateProps, ApFieldDateRangeProps, ApFieldRadioProps, ApFieldSelectProps, ApFieldSwitchProps, ApFieldCheckboxProps } from '..';
|
|
6
7
|
import { ColSize } from '@aplus-frontend/antdv/es/grid';
|
|
7
8
|
import { RuleObject } from '@aplus-frontend/antdv/es/form';
|
|
@@ -63,7 +64,7 @@ export declare function getFieldProps<RecordType = any>(fieldProps: ApColumnType
|
|
|
63
64
|
* @param item
|
|
64
65
|
* @returns
|
|
65
66
|
*/
|
|
66
|
-
export declare function getTableRenderType(item: ApColumnType
|
|
67
|
+
export declare function getTableRenderType(item: ApColumnType | EditableColumnType): "number" | "select" | "date" | "checkbox" | "radio" | "text" | "index" | "switch" | "status" | "password" | "action" | "dateRange" | "textArea";
|
|
67
68
|
export declare function getTableCellRenderNode(renderType: keyof typeof apTableRenderItemMap, renderProps: any, record: any, extraRenderMap?: Record<string, ValueTypeRenderConfig>): any;
|
|
68
69
|
/**
|
|
69
70
|
* 获取查询表单最终渲染的节点
|
|
@@ -13,6 +13,7 @@ declare const _default: <RecordType = any>(__VLS_props: NonNullable<Awaited<type
|
|
|
13
13
|
addMultiple: (list: number | Partial<RecordType>[], insetIn?: "prefix" | "suffix") => void;
|
|
14
14
|
scrollTo: (index: number | "end", options?: StandardBehaviorOptions) => void;
|
|
15
15
|
setTableData: (nextTableData: RecordType[]) => void;
|
|
16
|
+
clear: () => void;
|
|
16
17
|
}>): void;
|
|
17
18
|
attrs: any;
|
|
18
19
|
slots: Readonly<{
|
|
@@ -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"),V=require("@aplus-frontend/antdv"),p=require("../ap-form/index.js"),d=require("lodash-unified");require("../config-provider/index.js");const E=require("../ap-form/context.js");require("./style/index.css");const f=require("../utils/index.js"),P=require("./hooks/use-get-columns.js"),j=require("./utils.js"),k=require("../config-provider/hooks/use-namespace.js"),A=require("../config-provider/hooks/use-global-config.js"),M=o.defineComponent({name:"EditableTableInner",__name:"form-item",props:{dropdownPrefixCls:{},pagination:{type:[Boolean,Object],default:!1},loading:{type:[Boolean,Object],default:void 0},size:{default:"middle"},bordered:{type:Boolean,default:!1},locale:{},onResizeColumn:{},rowSelection:{},getPopupContainer:{},scroll:{},sortDirections:{default:()=>["ascend","descend"]},showSorterTooltip:{type:[Boolean,Object],default:!0},prefixCls:{},rowKey:{default:"key"},tableLayout:{default:"fixed"},rowClassName:{},title:{},footer:{},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]},transformCellText:{},columns:{},value:{},defaultValue:{},"onUpdate:value":{},onChange:{},maxLength:{},onFieldChange:{},label:{},name:{},formItem:{default:()=>({})}},setup(h,{expose:x}){const u=h;function g(e,t){return d.isArray(t)?t.reduce((l,a)=>l==null?void 0:l[a],e):e==null?void 0:e[t]}const{internalInstance:n,model:b}=E.useInjectForm(),r=o.ref(g(o.unref(b),u.name)||[]),C=o.useSlots(),w=p.ApForm.useWatch(u.name);o.watch(()=>w.value,e=>{var t;r.value=e,(t=u.onChange)==null||t.call(u,e)},{deep:!0});const{b:y}=k.useNamespace("editable-table"),i=o.ref(),R=A.useGlobalConfig("valueTypeMap"),D=P.default(u,R);function B(e,t){var s;const l=((s=o.unref(r))==null?void 0:s.length)||0;if(f.isDef(u.maxLength)&&l>=u.maxLength)return;const a=[...o.unref(r)||[]];f.isDef(t)?a.splice(t,0,{...e||{}}):a.push({...e||{}}),n==null||n.setFieldValue(u.name,a)}function q(e,t="suffix"){var m;const l=((m=o.unref(r))==null?void 0:m.length)||0,a=d.isNumber(e)?e:e.length;if(f.isDef(u.maxLength)&&l+a>u.maxLength)return;const s=[...o.unref(r)||[]],c=d.isNumber(e)?new Array(e).fill({}):d.cloneDeep(e);t==="suffix"?s.push(...c):s.unshift(...c),n==null||n.setFieldValue(u.name,s)}function F(e){let t=d.cloneDeep(o.unref(r)||[]);const l=d.isNumber(e)?[e]:e;t=t.filter((a,s)=>!l.includes(s)),n==null||n.setFieldValue(u.name,t)}function v(){return o.unref(r)}function N(e){var t;return(t=o.unref(r))==null?void 0:t[e]}function T(e,t,l=!0){const a=d.cloneDeep(o.unref(r));a[e]&&(a[e]={...l?a[e]:{},...t},n==null||n.setFieldValue(u.name,[...a]))}function L(e){n==null||n.setFieldValue(u.name,e)}function S(e,t){var a;const l=e==="end"?r.value.length-1:e;j.scrollToRowIndex(l,(a=i.value)==null?void 0:a.$el,t)}function _(){var e;(e=n==null?void 0:n.setFieldValue)==null||e.call(n,u.name,[])}return x({add:B,remove:F,getRowData:N,getRowsData:v,setRowData:T,addMultiple:q,scrollTo:S,setTableData:L,clear:_}),(e,t)=>(o.openBlock(),o.createBlock(o.unref(p.ApForm).FormItem,o.mergeProps(e.formItem,{name:e.name,label:e.label}),{default:o.withCtx(()=>[o.createVNode(o.unref(V.Table),o.mergeProps(o.unref(d.omit)(u,["name","maxLength","onChange"]),{class:o.unref(y)(),columns:o.unref(D),"data-source":r.value,ref_key:"tableRef",ref:i}),o.createSlots({_:2},[o.renderList(o.unref(d.omit)(C,["headerCell"]),(l,a)=>({name:a,fn:o.withCtx(s=>[o.renderSlot(e.$slots,a,o.normalizeProps(o.guardReactiveProps(s||{})))])}))]),1040,["class","columns","data-source"])]),_:3},16,["name","label"]))}});exports.default=M;
|
|
@@ -175,4 +175,4 @@ export type EditableTableExpose<ModelType = any, RecordType = any> = {
|
|
|
175
175
|
* 可编辑表格作为表单项暴露的实例
|
|
176
176
|
* @description 作为Form表单使用时不再暴露表单相关的API
|
|
177
177
|
*/
|
|
178
|
-
export type EditableTableFormItemExpose<ModelType = any, RecordType = any> = Omit<EditableTableExpose<ModelType, RecordType>, 'resetFields' | 'validateFields'
|
|
178
|
+
export type EditableTableFormItemExpose<ModelType = any, RecordType = any> = Omit<EditableTableExpose<ModelType, RecordType>, 'resetFields' | 'validateFields'>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("vue"),u=require("lodash-unified"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("vue"),u=require("lodash-unified"),g=require("../ap-table/constants.js"),v=require("../utils/index.js"),w=require("../ap-field/number/helper.js"),C=require("scroll-into-view-if-needed"),N=require("@aplus-frontend/antdv");require("../ap-form/index.js");const I=require("../ap-table/utils.js"),P=require("@ant-design/icons-vue"),q=require("../ap-form/ap-form-item.vue.js");function V(e){return typeof e=="function"||Object.prototype.toString.call(e)==="[object Object]"&&!o.isVNode(e)}function h(e){return g.apTableFormItemMap[e]}function F(e){if(!e.fieldProps)return!1;const t=u.isFunction(e.fieldProps)?e.fieldProps({}):e.fieldProps;return v.isDef(t.required)?t.required:(u.isArray(t.rules)?t.rules:t.rules?[t.rules]:[]).some(l=>l.required)}function S(e,t){if(e.valueType==="text"||e.valueType==="textArea")return t||"--";if(e.valueType==="number"){const i=e.fieldProps?u.isFunction(e.fieldProps)?e.fieldProps({}):e.fieldProps:{};return w.getValueStr(t,i)||"--"}return I.objectToString(t)}function _(e,t){const i=[e];if(t){const l=u.isArray(t)?t:[t];i.unshift(...l)}return i.join(" ")}function j(e,t=document.body,i={}){const l=t.querySelectorAll("tr.ant-table-row")[e];l&&C(l,{scrollMode:"if-needed",block:"nearest",behavior:"smooth",...i})}function m(e,t,i){return g.noRenderAsFormItemValueList.includes(e.valueType)?i:e.copyable||e.ellipsis?o.createVNode(N.Typography.Paragraph,{copyable:e.copyable?{text:t,tooltip:!1}:!1,ellipsis:e.ellipsis?u.isBoolean(e.ellipsis)?{tooltip:t}:{...e.ellipsis,tooltip:t}:!1,content:e.ellipsis?S(e,t):i},null):i}function A(e,t,i,l,p,r){var T,y;if(t){if(e.customRenderFormItem){const c=e.customRenderFormItem(e,i.field,t,p);return o.createVNode(q.default,u.omit(i,["field"]),V(c)?c:{default:()=>[c]})}const s=h(e.valueType);if(s)return o.createVNode(s,i,null);const n=r==null?void 0:r[e.valueType],a=(T=n==null?void 0:n.renderFormItem)==null?void 0:T.call(n,i.field);return a?o.createVNode(q.default,i,V(a)?a:{default:()=>[a]}):null}let d;const b=I.getTableRenderType(e),f=g.apTableRenderItemMap[b];if(f)d=o.createVNode(f,o.mergeProps(i.field,{mode:"read"}),null);else{const s=r==null?void 0:r[b];d=(y=s==null?void 0:s.render)==null?void 0:y.call(s,l,p,i.field)}return d?m(e,l,d):null}function R(e,t,i,l,p){const r=l==null?void 0:l({title:e.title,column:e}),d=(r==null?void 0:r.filter(c=>c.type!==Symbol.for("v-cmt")))||[];if(r&&d.length>0)return r;const f=F(e),y=u.isString(e.title)?{class:t,title:e.title}:{},s=o.createVNode("div",y,[f?o.createVNode("span",{class:i},[o.createTextVNode("*")]):null,e.title]),n=e.tooltip?u.isFunction(e.tooltip)?e.tooltip(e):o.createVNode(o.Fragment,null,[e.tooltip]):null;return n?o.createVNode("span",{style:{display:"inline-flex",alignItems:"center",maxWidth:"100%"}},[s,o.createVNode(N.Tooltip,{title:n,placement:"bottom"},{default:()=>[o.createVNode(P.QuestionCircleOutlined,{style:{padding:"4px",color:p,verticalAlign:"middle"}},null)]})]):s}exports.getColumnIsRequired=F;exports.getEditableComponent=h;exports.getEditableTableTitle=R;exports.getFinalNode=A;exports.getRawDisplayValue=S;exports.mergeClass=_;exports.scrollToRowIndex=j;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aplus-frontend/ui",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.46",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"module": "es/index.mjs",
|
|
6
6
|
"files": [
|
|
@@ -68,10 +68,10 @@
|
|
|
68
68
|
"@aplus-frontend/icon": "^1.0.21",
|
|
69
69
|
"@aplus-frontend/oss": "^1.1.2",
|
|
70
70
|
"vue": "3.4.38",
|
|
71
|
-
"@aplus-frontend/antdv": "^1.0.
|
|
71
|
+
"@aplus-frontend/antdv": "^1.0.2"
|
|
72
72
|
},
|
|
73
73
|
"scripts": {
|
|
74
|
-
"pub:cb": "pnpm publish --access public",
|
|
74
|
+
"pub:cb": "CI=true pnpm publish --access public",
|
|
75
75
|
"release:major": "release-it major",
|
|
76
76
|
"release:minor": "release-it minor",
|
|
77
77
|
"release:patch": "release-it patch",
|