@ecoding/components.antd 0.3.51 → 0.3.53
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.
|
@@ -1,30 +1,33 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { FormListFieldData } from 'antd';
|
|
3
3
|
interface IC {
|
|
4
|
-
|
|
4
|
+
type?: "operation";
|
|
5
|
+
title?: string;
|
|
5
6
|
tooltip?: string;
|
|
6
7
|
require?: boolean;
|
|
7
|
-
name
|
|
8
|
+
name?: string;
|
|
8
9
|
rules?: any;
|
|
9
10
|
width?: number;
|
|
10
|
-
|
|
11
|
+
hideRemove?: boolean | ((field: FormListFieldData, index: number) => boolean);
|
|
12
|
+
render?: (field: FormListFieldData, index: number, { add, remove }: {
|
|
13
|
+
add: any;
|
|
14
|
+
remove: any;
|
|
15
|
+
}) => React.ReactNode;
|
|
11
16
|
}
|
|
12
17
|
interface IProps {
|
|
13
18
|
columns: IC[];
|
|
14
19
|
name: string | string[];
|
|
15
20
|
rules?: any;
|
|
16
21
|
i18n?: any;
|
|
17
|
-
hideOperation?: boolean;
|
|
18
22
|
hideBottom?: boolean;
|
|
19
23
|
hideHeader?: boolean;
|
|
20
24
|
afterRemove?: (index: any) => void;
|
|
21
25
|
afterAdd?: (index: any) => void;
|
|
22
26
|
tStyle?: React.CSSProperties;
|
|
23
27
|
operation?: {
|
|
28
|
+
hide?: boolean;
|
|
24
29
|
width?: number;
|
|
25
|
-
render?: (field: FormListFieldData, index: number) => React.ReactNode;
|
|
26
30
|
title?: string;
|
|
27
|
-
hideRemove?: boolean;
|
|
28
31
|
};
|
|
29
32
|
}
|
|
30
33
|
declare const C: React.FC<IProps>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useMemo, useRef } from 'react';
|
|
2
2
|
import { Typography, Form, Button, Space, Tooltip } from 'antd';
|
|
3
3
|
import { PlusCircleOutlined, QuestionCircleOutlined } from '@ant-design/icons';
|
|
4
|
-
const C = ({ columns, rules, tStyle, name,
|
|
4
|
+
const C = ({ columns, rules, tStyle, name, hideHeader, hideBottom, operation, i18n, afterRemove, afterAdd }) => {
|
|
5
5
|
const tbodyRef = useRef(null);
|
|
6
6
|
const tdStyle = {
|
|
7
7
|
verticalAlign: 'top',
|
|
@@ -32,6 +32,9 @@ const C = ({ columns, rules, tStyle, name, hideOperation, hideHeader, hideBottom
|
|
|
32
32
|
}
|
|
33
33
|
return w;
|
|
34
34
|
}, []);
|
|
35
|
+
const needDefaultOperation = useMemo(() => {
|
|
36
|
+
return columns.findIndex(column => column.type == "operation") == -1;
|
|
37
|
+
}, []);
|
|
35
38
|
return (React.createElement(Form.List, { name: name, rules: rules || [] }, (fields, { add, remove }, { errors }) => {
|
|
36
39
|
return (React.createElement("div", { className: 'm-form-list' },
|
|
37
40
|
React.createElement("div", { ref: tbodyRef, className: "m-form-list-table", style: Object.assign({}, { marginBottom: '4px', paddingBottom: '12px', overflow: "auto", position: 'relative' }, tStyle) },
|
|
@@ -39,12 +42,18 @@ const C = ({ columns, rules, tStyle, name, hideOperation, hideHeader, hideBottom
|
|
|
39
42
|
React.createElement("colgroup", null,
|
|
40
43
|
React.createElement("col", { style: Object.assign({}, { width: 60 }) }),
|
|
41
44
|
columns.map((column) => {
|
|
45
|
+
if (column.type == "operation") {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
42
48
|
return (React.createElement("col", { style: Object.assign({}, { width: column.width || 200 }) }));
|
|
43
49
|
}),
|
|
44
|
-
|
|
50
|
+
(operation === null || operation === void 0 ? void 0 : operation.hide) ? null : (React.createElement("col", { style: Object.assign({}, { width: (operation === null || operation === void 0 ? void 0 : operation.width) || 150 }) }))),
|
|
45
51
|
React.createElement("thead", null, hideHeader ? null : (React.createElement("tr", null,
|
|
46
52
|
React.createElement("th", { style: thStyle }, i18n ? i18n.$t("global.num", "序号") : "序号"),
|
|
47
53
|
columns.map((column, i) => {
|
|
54
|
+
if (column.type == "operation") {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
48
57
|
if (column.require) {
|
|
49
58
|
return (React.createElement("th", { style: thStyle },
|
|
50
59
|
React.createElement("span", { style: { color: '#ff4d4f' } }, "*"),
|
|
@@ -57,25 +66,30 @@ const C = ({ columns, rules, tStyle, name, hideOperation, hideHeader, hideBottom
|
|
|
57
66
|
column.tooltip ? (React.createElement(Tooltip, { placement: "top", title: column.tooltip || undefined },
|
|
58
67
|
React.createElement(QuestionCircleOutlined, { style: { paddingLeft: 4, color: "rgba(0, 0, 0, 0.45)" } }))) : null));
|
|
59
68
|
}),
|
|
60
|
-
|
|
69
|
+
(operation === null || operation === void 0 ? void 0 : operation.hide) ? null : (React.createElement("th", { style: Object.assign({}, thStyle, { right: 0 }) }, i18n ? i18n.$t("global.operation", "操作") : "操作"))))),
|
|
61
70
|
React.createElement("tbody", null, fields.map((field, index) => {
|
|
62
71
|
return (React.createElement("tr", { style: trStyle },
|
|
63
72
|
React.createElement("td", { style: tdStyle }, index + 1),
|
|
64
73
|
columns.map((column, i) => {
|
|
65
|
-
|
|
66
|
-
React.createElement(
|
|
74
|
+
if (column.type == "operation") {
|
|
75
|
+
return (React.createElement("td", { style: Object.assign({}, tdStyle, { right: 0, position: "sticky", backgroundColor: "#fff" }) },
|
|
76
|
+
React.createElement(Space, null,
|
|
77
|
+
column.render && column.render(field, index, { add, remove }),
|
|
78
|
+
(typeof column.hideRemove == "function" && column.hideRemove(field, index)) || (typeof column.hideRemove == "boolean" && column.hideRemove) ? (React.createElement(Typography.Text, { disabled: true }, i18n ? i18n.$t("global.del", '删除') : '删除')) : (React.createElement(Typography.Text, { style: { cursor: 'pointer' }, type: "danger", onClick: () => {
|
|
79
|
+
remove(field.name);
|
|
80
|
+
afterRemove && afterRemove(field.name);
|
|
81
|
+
} }, i18n ? i18n.$t("global.del", '删除') : '删除')))));
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
return (React.createElement("td", { style: tdStyle },
|
|
85
|
+
React.createElement(Form.Item, { style: { marginBottom: 0 }, name: [field.name, column.name], rules: column.rules || [] }, column.render(field, index, { add, remove }))));
|
|
86
|
+
}
|
|
67
87
|
}),
|
|
68
|
-
|
|
69
|
-
React.createElement(Space, null,
|
|
70
|
-
operation.render && operation.render(field, index),
|
|
71
|
-
operation.hideRemove ? null : (React.createElement(Typography.Text, { style: { cursor: 'pointer' }, type: "danger", onClick: () => {
|
|
72
|
-
remove(field.name);
|
|
73
|
-
afterRemove && afterRemove(field.name);
|
|
74
|
-
} }, i18n ? i18n.$t("global.del", '删除') : '删除'))))) : (React.createElement("td", { style: Object.assign({}, tdStyle, { right: 0, position: "sticky", backgroundColor: "#fff" }) },
|
|
88
|
+
needDefaultOperation ? (React.createElement("td", { style: Object.assign({}, tdStyle, { right: 0, position: "sticky", backgroundColor: "#fff" }) },
|
|
75
89
|
React.createElement(Typography.Text, { style: { cursor: 'pointer' }, type: "danger", onClick: () => {
|
|
76
90
|
remove(field.name);
|
|
77
91
|
afterRemove && afterRemove(field.name);
|
|
78
|
-
} }, i18n ? i18n.$t("global.del", '删除') : '删除')))));
|
|
92
|
+
} }, i18n ? i18n.$t("global.del", '删除') : '删除'))) : null));
|
|
79
93
|
})))),
|
|
80
94
|
hideBottom ? null : (React.createElement("div", null,
|
|
81
95
|
React.createElement(Button, { icon: React.createElement(PlusCircleOutlined, null), type: "dashed", onClick: () => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ecoding/components.antd",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.53",
|
|
4
4
|
"author": "cxc",
|
|
5
5
|
"homepage": "",
|
|
6
6
|
"license": "MIT",
|
|
@@ -43,5 +43,5 @@
|
|
|
43
43
|
"antd": "^5.8.4",
|
|
44
44
|
"axios": "^1.1.2"
|
|
45
45
|
},
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "e7e04840b2c866bfbba71561a728ba31b25d0b81"
|
|
47
47
|
}
|