lu-lowcode-package-form 0.9.31 → 0.9.33

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.
@@ -0,0 +1,268 @@
1
+ import React, { useEffect, useState, useRef, useCallback } from "react";
2
+ import { Button } from "antd";
3
+ import { DeleteOutlined } from "@ant-design/icons";
4
+ import { isEqual, debounce } from 'lodash';
5
+ import { evalFormula } from "../../../utils/formula";
6
+
7
+ const TableCol = ({ children, width, ...props }) => {
8
+ const [sWidth, setSWidth] = useState(0);
9
+ useEffect(() => {
10
+ setSWidth(width);
11
+ }, [width]);
12
+ return <div className="fflex-1" style={{ minWidth: `${sWidth}px` }} {...props}>
13
+ {children}
14
+ </div>
15
+ }
16
+
17
+ const TableAction = ({ label, subTableIndex, children, ...props }) => {
18
+ return <div className="">
19
+ <div className="frelative fw-full fh-full fflex fflex-col foverflow-hidden">
20
+ {label && subTableIndex === 0 && <div className='fh-12 ffont-semibold fbg-gray-100 ftext-sm fflex fflex-nowrap ftext-nowrap fjustify-between fitems-center fpx-2 fborder-b'>{label}</div>}
21
+ <div className="fw-full fflex-1 fflex fitems-center fjustify-center fp-2 fbox-border ">
22
+ {children}
23
+ </div>
24
+ </div>
25
+ </div>
26
+ }
27
+
28
+ const Table = ({ children, value, onChange, ...props }) => {
29
+ const [rows, setRows] = useState([{}]);
30
+ const prevRowsRef = useRef(rows);
31
+ const dependencyMap = useRef(new Map());
32
+ const [updateField, setUpdateField] = useState({});
33
+ const tableId = props.componentId || props.__id;
34
+ const setPrevRows = (newValue) => {
35
+ setRows(newValue);
36
+ prevRowsRef.current = newValue;
37
+ }
38
+
39
+ useEffect(() => {
40
+ console.log("value useEffect ", JSON.stringify(value));
41
+ if (value && typeof value === "string") {
42
+ try {
43
+ value = JSON.parse(value);
44
+ onChange(value);
45
+ } catch (error) { }
46
+ }
47
+ if (value && Array.isArray(value) && !isEqual(prevRowsRef.current, value)) {
48
+ console.log("useEffect setRows");
49
+ setPrevRows(value);
50
+ }
51
+ }, [value]);
52
+
53
+ useEffect(() => {
54
+ console.log("children useEffect ",children);
55
+ initializeDependencyMap();
56
+ }, [children]);
57
+
58
+ const initializeDependencyMap = useCallback(() => {
59
+ dependencyMap.current.clear();
60
+ const childrenArray = React.Children.toArray(children);
61
+ childrenArray.forEach(child => {
62
+ const { componentId, __id, ...props } = child.props;
63
+ const identifier = `${tableId}.${(componentId || __id)}`;
64
+
65
+ dependencyMap.current.set(identifier, {
66
+ children: childrenArray.filter(item => item.props.withId === identifier || item.props.withIds?.includes(identifier)),
67
+ show: true,
68
+ });
69
+ });
70
+ initializeFieldVisibility();
71
+ }, [children, tableId]);
72
+
73
+ const handleRowValues = useCallback((rowValues) => {
74
+ const result = {};
75
+ for (let key in rowValues) {
76
+ result[`${tableId}.${key}`] = rowValues[key] || '';
77
+ }
78
+ return result;
79
+ }, [tableId]);
80
+
81
+ const initializeFieldVisibility = useCallback(() => {
82
+ rows.forEach((row, rowIndex) => {
83
+ const fieldValues = handleRowValues(row);
84
+ for (let key of dependencyMap.current.keys()) {
85
+ handleFieldsWith(key, fieldValues, rowIndex);
86
+ }
87
+ });
88
+ }, [rows, handleRowValues]);
89
+
90
+ const handleFieldsWith = useCallback((identifier, fieldValues, rowIndex) => {
91
+ let needRefresh = false;
92
+ const fullIdentifier = `${tableId}.${identifier}`;
93
+ if (dependencyMap.current.has(fullIdentifier)) {
94
+ const dependentChildren = dependencyMap.current.get(fullIdentifier).children;
95
+ dependentChildren.forEach(child => {
96
+ if (child.props.withFunc && typeof child.props.withFunc === 'function') {
97
+ needRefresh = handleFieldsVisible(fieldValues, child);
98
+ }
99
+
100
+ if (child.props.withFill) {
101
+ handleFieldsWithFill(fieldValues, child, rowIndex);
102
+ }
103
+ });
104
+ }
105
+ return needRefresh;
106
+ }, [tableId, rows]);
107
+
108
+ const handleFieldsVisible = useCallback((fieldValues, child) => {
109
+ let needRefresh = false;
110
+ const childShouldBeVisible = child.props.withFunc(fieldValues);
111
+ const childIdentifier = child.props.componentId || child.props.__id;
112
+ if (dependencyMap.current.has(childIdentifier)) {
113
+ const childData = dependencyMap.current.get(childIdentifier);
114
+ if (childData.show !== childShouldBeVisible) {
115
+ childData.show = childShouldBeVisible;
116
+ dependencyMap.current.set(childIdentifier, childData);
117
+ needRefresh = true;
118
+ }
119
+ }
120
+ return needRefresh;
121
+ }, []);
122
+
123
+ const handleFieldsWithFill = useCallback(async (fieldValues, child, rowIndex) => {
124
+ const withFill = child.props.withFill;
125
+ const withDataFetch = child.props.withDataFetch;
126
+
127
+ let withDatas = [];
128
+ if (withFill?.withData && withFill?.withData.length > 0 && withDataFetch && typeof withDataFetch === 'function') {
129
+ for (let index = 0; index < withFill?.withData.length; index++) {
130
+ const element = withFill?.withData[index];
131
+ let params = {}
132
+ params.tableName = element.withTable.table_name;
133
+ params.filter = {};
134
+ for (let index = 0; index < element.withCondition.length; index++) {
135
+ const { value: condition_value, column: condition_column } = element.withCondition[index];
136
+ params.filter[condition_column.column_name] = getParamValue(condition_value.group_key, condition_value.field_key, fieldValues, withDatas);
137
+ }
138
+
139
+ const response = await withDataFetch(params);
140
+ if (response.code === 0 && response.data.list) {
141
+ withDatas.push({
142
+ id: element.id,
143
+ data: response.data.list
144
+ });
145
+ }
146
+ }
147
+ }
148
+
149
+ let formula;
150
+ if (withFill.value && withFill.value.length > 0) {
151
+ formula = withFill.value.map(item => {
152
+ let result = "";
153
+ const { insert, attributes } = item;
154
+ if (typeof insert !== "string") {
155
+ if (insert?.span && attributes && attributes.tagKey && attributes.id) {
156
+ result = getParamValue(attributes.tagKey, attributes.id, fieldValues, withDatas);
157
+ if(result) result = `"${result}"`
158
+ }
159
+ } else {
160
+ result = insert;
161
+ }
162
+ return result;
163
+ });
164
+ }
165
+ console.log("formula", formula);
166
+ if (formula && formula.length > 0) {
167
+ const childIdentifier = child.props.componentId || child.props.__id;
168
+ const formulaResult = evalFormula(formula);
169
+ console.log("formulaResult", formulaResult);
170
+ console.log("handleFieldsWithFill setRows");
171
+ const newRows = [...rows]
172
+ newRows[rowIndex][childIdentifier] = formulaResult;
173
+ setPrevRows(newRows)
174
+ }
175
+ }, [rows])
176
+
177
+ const getParamValue = useCallback((tagKey, id, fieldValues, withDatas) => {
178
+ let result = "";
179
+ if (tagKey === "fieldsValue") result = fieldValues?.[id] || "";
180
+ else {
181
+ let withData = withDatas.find(item => item.id === tagKey);
182
+ if (withData && withData.data && withData.data.length > 0) {
183
+ result = withData.data[0]?.[id] || "";
184
+ }
185
+ }
186
+ return result;
187
+ }, []);
188
+
189
+
190
+
191
+ const handleInputChange = useCallback((rowIndex, childIndex, e) => {
192
+ console.log(e)
193
+ const newRows = [...rows];
194
+ newRows[rowIndex] = {
195
+ ...newRows[rowIndex],
196
+ [childIndex]: e?.target?.value || e || '',
197
+ };
198
+ console.log("handleInputChange setRows")
199
+ setPrevRows(newRows);
200
+
201
+ setUpdateField({
202
+ rowIndex: rowIndex,
203
+ identifier: childIndex,
204
+ value: handleRowValues(newRows[rowIndex]),
205
+ });
206
+
207
+ }, [rows, handleFieldsWith, handleRowValues, onChange]);
208
+
209
+
210
+ const handleDeleteRow = (rowIndex) => {
211
+ const newRows = [...rows];
212
+ newRows.splice(rowIndex, 1);
213
+ console.log("handleDeleteRow setRows")
214
+ setPrevRows(newRows);
215
+ }
216
+
217
+ const addRow = () => {
218
+ console.log("addRow setRows")
219
+ setPrevRows([...rows, {}]);
220
+ }
221
+
222
+ useEffect(() => {
223
+ console.log("rows changed rows", JSON.stringify(prevRowsRef.current));
224
+ console.log("rows changed value", JSON.stringify(value));
225
+ if (isEqual(prevRowsRef.current, value)) return;
226
+ console.log("noreq")
227
+ typeof onChange === "function" && onChange(prevRowsRef.current);
228
+ }, [rows]);
229
+
230
+ useEffect(() => {
231
+ if (updateField && updateField.identifier) {
232
+ handleFieldsWith(updateField.identifier, updateField.value, updateField.rowIndex);
233
+ }
234
+ }, [updateField])
235
+
236
+
237
+ return (
238
+ <>
239
+ <div className="fw-full frelative fmin-h-20 foverflow-x-auto">
240
+
241
+ {rows.map((row, rowIndex) => (
242
+ <div className="fborder-b fflex flex-nowrap fmin-w-full" key={rowIndex}>
243
+ {React.Children.map(children, (child, childIndex) => {
244
+ const col_id = child?.props?.__id || childIndex;
245
+ if (row?.[col_id] === undefined) row[col_id] = "";
246
+ return <TableCol width={150} key={`row_${rowIndex}_col_${childIndex}`}>
247
+ {React.cloneElement(child, {
248
+ key: `row_${rowIndex}_child_${childIndex}`,
249
+ subTable: true,
250
+ subTableIndex: rowIndex,
251
+ value: row[col_id] || '',
252
+ onChange: (e) => handleInputChange(rowIndex, col_id, e),
253
+ })}
254
+ </TableCol>
255
+ })}
256
+ <TableAction key={`row_${rowIndex}_action`} subTable={true} subTableIndex={rowIndex} label={"操作"}>
257
+ <DeleteOutlined className="fcursor-pointer" onClick={() => handleDeleteRow(rowIndex)} />
258
+ </TableAction>
259
+ </div>
260
+ ))}
261
+ </div>
262
+ <Button onClick={addRow} className="fmy-2">新增一行</Button>
263
+ </>
264
+ );
265
+ };
266
+
267
+ export default Table;
268
+ export { TableCol, TableAction };
@@ -1,268 +1,111 @@
1
- import React, { useEffect, useState, useRef, useCallback } from "react";
2
- import { Button } from "antd";
1
+ import React, { useEffect, useState } from "react";
2
+ import { Button, Form, Input } from "antd";
3
3
  import { DeleteOutlined } from "@ant-design/icons";
4
- import { isEqual, debounce } from 'lodash';
5
- import { evalFormula } from "../../../utils/formula";
4
+ import { BaseWrapper } from "../base.jsx"
6
5
 
7
- const TableCol = ({ children, width, ...props }) => {
8
- const [sWidth, setSWidth] = useState(0);
9
- useEffect(() => {
10
- setSWidth(width);
11
- }, [width]);
12
- return <div className="fflex-1" style={{ minWidth: `${sWidth}px` }} {...props}>
13
- {children}
14
- </div>
15
- }
16
-
17
- const TableAction = ({ label, subTableIndex, children, ...props }) => {
18
- return <div className="">
6
+ const TableAction = ({ label, subTableIndex, children, subTableHead = false, ...props }) => {
7
+ //fsticky fright-0
8
+ return <div className="fw-12 ">
19
9
  <div className="frelative fw-full fh-full fflex fflex-col foverflow-hidden">
20
- {label && subTableIndex === 0 && <div className='fh-12 ffont-semibold fbg-gray-100 ftext-sm fflex fflex-nowrap ftext-nowrap fjustify-between fitems-center fpx-2 fborder-b'>{label}</div>}
21
- <div className="fw-full fflex-1 fflex fitems-center fjustify-center fp-2 fbox-border ">
10
+ {label && subTableHead && <div className='fh-12 ffont-semibold fbg-[#fafafa] ftext-sm fflex fflex-nowrap ftext-nowrap fjustify-between fitems-center fpx-2 fborder-b'>{label}</div>}
11
+ {!subTableHead && <div className="fw-full fflex-1 fflex fitems-center fjustify-center fp-2 fbox-border ">
22
12
  {children}
23
13
  </div>
14
+ }
24
15
  </div>
25
16
  </div>
26
17
  }
27
18
 
28
- const Table = ({ children, value, onChange, ...props }) => {
29
- const [rows, setRows] = useState([{}]);
30
- const prevRowsRef = useRef(rows);
31
- const dependencyMap = useRef(new Map());
32
- const [updateField, setUpdateField] = useState({});
33
- const tableId = props.componentId || props.__id;
34
- const setPrevRows = (newValue) => {
35
- setRows(newValue);
36
- prevRowsRef.current = newValue;
37
- }
38
-
39
- useEffect(() => {
40
- console.log("value useEffect ", JSON.stringify(value));
41
- if (value && typeof value === "string") {
42
- try {
43
- value = JSON.parse(value);
44
- onChange(value);
45
- } catch (error) { }
46
- }
47
- if (value && Array.isArray(value) && !isEqual(prevRowsRef.current, value)) {
48
- console.log("useEffect setRows");
49
- setPrevRows(value);
50
- }
51
- }, [value]);
52
19
 
20
+ const TableCol = ({ children, width, ...props }) => {
21
+ const [sWidth, setSWidth] = useState(0);
53
22
  useEffect(() => {
54
- console.log("children useEffect ",children);
55
- initializeDependencyMap();
56
- }, [children]);
57
-
58
- const initializeDependencyMap = useCallback(() => {
59
- dependencyMap.current.clear();
60
- const childrenArray = React.Children.toArray(children);
61
- childrenArray.forEach(child => {
62
- const { componentId, __id, ...props } = child.props;
63
- const identifier = `${tableId}.${(componentId || __id)}`;
64
-
65
- dependencyMap.current.set(identifier, {
66
- children: childrenArray.filter(item => item.props.withId === identifier || item.props.withIds?.includes(identifier)),
67
- show: true,
68
- });
69
- });
70
- initializeFieldVisibility();
71
- }, [children, tableId]);
72
-
73
- const handleRowValues = useCallback((rowValues) => {
74
- const result = {};
75
- for (let key in rowValues) {
76
- result[`${tableId}.${key}`] = rowValues[key] || '';
77
- }
78
- return result;
79
- }, [tableId]);
80
-
81
- const initializeFieldVisibility = useCallback(() => {
82
- rows.forEach((row, rowIndex) => {
83
- const fieldValues = handleRowValues(row);
84
- for (let key of dependencyMap.current.keys()) {
85
- handleFieldsWith(key, fieldValues, rowIndex);
86
- }
87
- });
88
- }, [rows, handleRowValues]);
89
-
90
- const handleFieldsWith = useCallback((identifier, fieldValues, rowIndex) => {
91
- let needRefresh = false;
92
- const fullIdentifier = `${tableId}.${identifier}`;
93
- if (dependencyMap.current.has(fullIdentifier)) {
94
- const dependentChildren = dependencyMap.current.get(fullIdentifier).children;
95
- dependentChildren.forEach(child => {
96
- if (child.props.withFunc && typeof child.props.withFunc === 'function') {
97
- needRefresh = handleFieldsVisible(fieldValues, child);
98
- }
99
-
100
- if (child.props.withFill) {
101
- handleFieldsWithFill(fieldValues, child, rowIndex);
102
- }
103
- });
104
- }
105
- return needRefresh;
106
- }, [tableId, rows]);
107
-
108
- const handleFieldsVisible = useCallback((fieldValues, child) => {
109
- let needRefresh = false;
110
- const childShouldBeVisible = child.props.withFunc(fieldValues);
111
- const childIdentifier = child.props.componentId || child.props.__id;
112
- if (dependencyMap.current.has(childIdentifier)) {
113
- const childData = dependencyMap.current.get(childIdentifier);
114
- if (childData.show !== childShouldBeVisible) {
115
- childData.show = childShouldBeVisible;
116
- dependencyMap.current.set(childIdentifier, childData);
117
- needRefresh = true;
118
- }
119
- }
120
- return needRefresh;
121
- }, []);
122
-
123
- const handleFieldsWithFill = useCallback(async (fieldValues, child, rowIndex) => {
124
- const withFill = child.props.withFill;
125
- const withDataFetch = child.props.withDataFetch;
126
-
127
- let withDatas = [];
128
- if (withFill?.withData && withFill?.withData.length > 0 && withDataFetch && typeof withDataFetch === 'function') {
129
- for (let index = 0; index < withFill?.withData.length; index++) {
130
- const element = withFill?.withData[index];
131
- let params = {}
132
- params.tableName = element.withTable.table_name;
133
- params.filter = {};
134
- for (let index = 0; index < element.withCondition.length; index++) {
135
- const { value: condition_value, column: condition_column } = element.withCondition[index];
136
- params.filter[condition_column.column_name] = getParamValue(condition_value.group_key, condition_value.field_key, fieldValues, withDatas);
137
- }
138
-
139
- const response = await withDataFetch(params);
140
- if (response.code === 0 && response.data.list) {
141
- withDatas.push({
142
- id: element.id,
143
- data: response.data.list
144
- });
145
- }
146
- }
147
- }
148
-
149
- let formula;
150
- if (withFill.value && withFill.value.length > 0) {
151
- formula = withFill.value.map(item => {
152
- let result = "";
153
- const { insert, attributes } = item;
154
- if (typeof insert !== "string") {
155
- if (insert?.span && attributes && attributes.tagKey && attributes.id) {
156
- result = getParamValue(attributes.tagKey, attributes.id, fieldValues, withDatas);
157
- if(result) result = `"${result}"`
158
- }
159
- } else {
160
- result = insert;
161
- }
162
- return result;
163
- });
164
- }
165
- console.log("formula", formula);
166
- if (formula && formula.length > 0) {
167
- const childIdentifier = child.props.componentId || child.props.__id;
168
- const formulaResult = evalFormula(formula);
169
- console.log("formulaResult", formulaResult);
170
- console.log("handleFieldsWithFill setRows");
171
- const newRows = [...rows]
172
- newRows[rowIndex][childIdentifier] = formulaResult;
173
- setPrevRows(newRows)
174
- }
175
- }, [rows])
176
-
177
- const getParamValue = useCallback((tagKey, id, fieldValues, withDatas) => {
178
- let result = "";
179
- if (tagKey === "fieldsValue") result = fieldValues?.[id] || "";
180
- else {
181
- let withData = withDatas.find(item => item.id === tagKey);
182
- if (withData && withData.data && withData.data.length > 0) {
183
- result = withData.data[0]?.[id] || "";
184
- }
185
- }
186
- return result;
187
- }, []);
188
-
189
-
190
-
191
- const handleInputChange = useCallback((rowIndex, childIndex, e) => {
192
- console.log(e)
193
- const newRows = [...rows];
194
- newRows[rowIndex] = {
195
- ...newRows[rowIndex],
196
- [childIndex]: e?.target?.value || e || '',
197
- };
198
- console.log("handleInputChange setRows")
199
- setPrevRows(newRows);
200
-
201
- setUpdateField({
202
- rowIndex: rowIndex,
203
- identifier: childIndex,
204
- value: handleRowValues(newRows[rowIndex]),
205
- });
206
-
207
- }, [rows, handleFieldsWith, handleRowValues, onChange]);
208
-
209
-
210
- const handleDeleteRow = (rowIndex) => {
211
- const newRows = [...rows];
212
- newRows.splice(rowIndex, 1);
213
- console.log("handleDeleteRow setRows")
214
- setPrevRows(newRows);
215
- }
23
+ setSWidth(width);
24
+ }, [width]);
25
+ return <div className="fflex-1 fpx-1" style={{ minWidth: `${sWidth}px` }} {...props}>
26
+ {children}
27
+ </div>
28
+ }
216
29
 
217
- const addRow = () => {
218
- console.log("addRow setRows")
219
- setPrevRows([...rows, {}]);
30
+ const Table = ({ children, ...props }) => {
31
+ const [init, setInit] = useState(false);
32
+ const name = props.componentId || props.__id
33
+ const rules = []
34
+ const handleAdd = (add)=>{
35
+ if (!init) setInit(true);
36
+ typeof add === "function" && add();
220
37
  }
221
-
222
- useEffect(() => {
223
- console.log("rows changed rows", JSON.stringify(prevRowsRef.current));
224
- console.log("rows changed value", JSON.stringify(value));
225
- if (isEqual(prevRowsRef.current, value)) return;
226
- console.log("noreq")
227
- typeof onChange === "function" && onChange(prevRowsRef.current);
228
- }, [rows]);
229
-
230
- useEffect(() => {
231
- if (updateField && updateField.identifier) {
232
- handleFieldsWith(updateField.identifier, updateField.value, updateField.rowIndex);
233
- }
234
- }, [updateField])
235
-
236
-
237
- return (
238
- <>
239
- <div className="fw-full frelative fmin-h-20 foverflow-x-auto">
240
-
241
- {rows.map((row, rowIndex) => (
242
- <div className="fborder-b fflex flex-nowrap fmin-w-full" key={rowIndex}>
38
+ if (props.isRequired)
39
+ rules.push({ required: true, message: `子表[${props.label}]必须填写` });
40
+ return <Form.List name={name} rules={rules}>
41
+ {(fields, { add, remove }) => {
42
+ if (fields.length === 0 && !init) handleAdd(add);
43
+ return <div className="fw-full ">
44
+ <div className="fw-full frelative fmin-h-20 foverflow-x-auto">
45
+ <div key={`tableHead`} className="fborder-b fflex flex-nowrap fmin-w-full ">
243
46
  {React.Children.map(children, (child, childIndex) => {
244
- const col_id = child?.props?.__id || childIndex;
245
- if (row?.[col_id] === undefined) row[col_id] = "";
246
- return <TableCol width={150} key={`row_${rowIndex}_col_${childIndex}`}>
47
+ return <TableCol width={100} key={`row_${0}_col_${childIndex}`}>
247
48
  {React.cloneElement(child, {
248
- key: `row_${rowIndex}_child_${childIndex}`,
49
+ key: `row_${0}_child_${childIndex}`,
249
50
  subTable: true,
250
- subTableIndex: rowIndex,
251
- value: row[col_id] || '',
252
- onChange: (e) => handleInputChange(rowIndex, col_id, e),
51
+ subTableHead: true
253
52
  })}
254
53
  </TableCol>
255
54
  })}
256
- <TableAction key={`row_${rowIndex}_action`} subTable={true} subTableIndex={rowIndex} label={"操作"}>
257
- <DeleteOutlined className="fcursor-pointer" onClick={() => handleDeleteRow(rowIndex)} />
55
+ <TableAction subTableHead={true} key={`row_${0}_action`} subTable={true} subTableIndex={0} label={"操作"}>
258
56
  </TableAction>
259
57
  </div>
260
- ))}
58
+ {fields.map((field, index) => (
59
+ <div key={field.key} className="fborder-b fflex flex-nowrap fmin-w-full ">
60
+
61
+ {React.Children.map(children, (child, childIndex) => {
62
+ let { props } = child;
63
+ const col_id = child?.props?.componentId || child?.props?.__id || childIndex;
64
+ if (field?.[col_id] === undefined) field[col_id] = "";
65
+ const rules = []
66
+ if (props.isRequired)
67
+ rules.push({ required: true, message: `${props.label}必须填写` });
68
+ if (props.rules)
69
+ if (Array.isArray(props.rules)) {
70
+ const pattern = props.rules.join("|")
71
+ rules.push({ pattern: new RegExp(pattern), message: props.rulesFailMessage ? props.rulesFailMessage : `${props.label}格式错误` })
72
+ }
73
+ else {
74
+ rules.push({ pattern: new RegExp(props.rules), message: props.rulesFailMessage ? props.rulesFailMessage : `${props.label}格式错误` })
75
+ }
76
+
77
+ return <TableCol width={100} key={`row_${index}_col_${childIndex}`}>
78
+ <Form.Item
79
+ style={{ marginBottom: 0 }}
80
+ label=""
81
+ name={[field.name, col_id]}
82
+ rules={rules}
83
+ >
84
+ {React.cloneElement(child, {
85
+ key: `row_${index}_child_${childIndex}`,
86
+ subTable: true,
87
+ subTableIndex: index,
88
+ })}
89
+ </Form.Item>
90
+ </TableCol>
91
+ })}
92
+ <TableAction key={`row_${index}_action`} subTable={true} subTableIndex={index} label={"操作"}>
93
+ <DeleteOutlined className="fcursor-pointer" onClick={() => remove(index)} />
94
+ </TableAction>
95
+ </div>
96
+ ))}
97
+ </div>
98
+ <Button onClick={() => add()} className="fmy-2">新增一行</Button>
261
99
  </div>
262
- <Button onClick={addRow} className="fmy-2">新增一行</Button>
263
- </>
100
+ }}
101
+ </Form.List>
102
+ }
103
+ const TableWrapper = (props) => {
104
+ return (
105
+ <BaseWrapper {...props} higLabel={true} >
106
+ <Table {...props} />
107
+ </BaseWrapper>
264
108
  );
265
- };
266
-
267
- export default Table;
268
- export { TableCol, TableAction };
109
+ }
110
+ export default TableWrapper;
111
+ export { TableCol, TableAction };