es-grid-template 1.5.13 → 1.5.15
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/collapse/index.d.ts +4 -0
- package/es/collapse/index.js +2 -0
- package/es/date-range-picker/index.d.ts +4 -0
- package/es/date-range-picker/index.js +2 -0
- package/es/datepicker/index.d.ts +4 -0
- package/es/datepicker/index.js +2 -0
- package/es/dropdown/index.d.ts +4 -0
- package/es/dropdown/index.js +2 -0
- package/es/grid-component/InternalTable.js +12 -4
- package/es/grid-component/TableGrid.js +19 -6
- package/es/grid-component/hooks/columns/index.js +12 -2
- package/es/grid-component/hooks/content/HeaderContent.d.ts +2 -0
- package/es/grid-component/hooks/content/HeaderContent.js +16 -5
- package/es/grid-component/hooks/utils.d.ts +5 -0
- package/es/grid-component/hooks/utils.js +60 -1
- package/es/grid-component/styles.scss +27 -0
- package/es/grid-component/table/GridEdit.js +278 -239
- package/es/grid-component/type.d.ts +25 -2
- package/es/index.d.ts +12 -0
- package/es/index.js +7 -1
- package/es/select/index.d.ts +4 -0
- package/es/select/index.js +2 -0
- package/es/select-table/index.d.ts +4 -0
- package/es/select-table/index.js +2 -0
- package/es/splitter/index.d.ts +4 -0
- package/es/splitter/index.js +2 -0
- package/es/tree-select/index.d.ts +4 -0
- package/es/tree-select/index.js +2 -0
- package/lib/collapse/index.d.ts +4 -0
- package/lib/collapse/index.js +8 -0
- package/lib/date-range-picker/index.d.ts +4 -0
- package/lib/date-range-picker/index.js +9 -0
- package/lib/datepicker/index.d.ts +4 -0
- package/lib/datepicker/index.js +9 -0
- package/lib/dropdown/index.d.ts +4 -0
- package/lib/dropdown/index.js +9 -0
- package/lib/grid-component/InternalTable.js +12 -4
- package/lib/grid-component/TableGrid.js +19 -6
- package/lib/grid-component/hooks/columns/index.js +12 -2
- package/lib/grid-component/hooks/content/HeaderContent.d.ts +2 -0
- package/lib/grid-component/hooks/content/HeaderContent.js +16 -5
- package/lib/grid-component/hooks/utils.d.ts +5 -0
- package/lib/grid-component/hooks/utils.js +66 -5
- package/lib/grid-component/styles.scss +27 -0
- package/lib/grid-component/table/GridEdit.js +277 -238
- package/lib/grid-component/type.d.ts +25 -2
- package/lib/index.d.ts +12 -0
- package/lib/index.js +43 -1
- package/lib/select/index.d.ts +4 -0
- package/lib/select/index.js +8 -0
- package/lib/select-table/index.d.ts +4 -0
- package/lib/select-table/index.js +9 -0
- package/lib/splitter/index.d.ts +4 -0
- package/lib/splitter/index.js +8 -0
- package/lib/tree-select/index.d.ts +4 -0
- package/lib/tree-select/index.js +8 -0
- package/package.json +2 -2
|
@@ -19,132 +19,134 @@ import { addClassBorderPasteCell, addClassCellIndexSelected, addRows8, addRowsUp
|
|
|
19
19
|
onRemoveBgSelectedCell, removeClassBorderPasteCell, removeClassCellIndexSelected, showDraggingPoint, sortedSetASC, totalFixedWidth, updateArrayByKey, getFormat,
|
|
20
20
|
// isRangeCell,
|
|
21
21
|
// isSelectedCell,
|
|
22
|
-
onRemoveBgCellIndex, onAddBgCellIndex, onAddBorderSelectedCell, onRemoveBorderSelectedCell } from "../hooks";
|
|
22
|
+
onRemoveBgCellIndex, onAddBgCellIndex, onAddBorderSelectedCell, onRemoveBorderSelectedCell, isFormattedNumber, checkThousandSeparator, checkDecimalSeparator, detectSeparators } from "../hooks";
|
|
23
23
|
import Message from "../../Message/Message";
|
|
24
24
|
import { Toolbar, ConfigProvider, InputNumber } from "rc-master-ui";
|
|
25
25
|
import classnames from "classnames";
|
|
26
26
|
import { Plus, Trash2 } from "becoxy-icons";
|
|
27
27
|
// import {faker} from "@faker-js/faker";
|
|
28
28
|
import { SELECTION_COLUMN } from "../InternalTable";
|
|
29
|
+
import { removeNumericFormat } from "react-numeric-component";
|
|
29
30
|
const {
|
|
30
31
|
Paragraph,
|
|
31
32
|
Title
|
|
32
33
|
} = Typography;
|
|
33
34
|
dayjs.extend(customParseFormat);
|
|
34
35
|
const toast = 'top-right';
|
|
35
|
-
const defaultContext = [
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
36
|
+
// const defaultContext = [
|
|
37
|
+
// {
|
|
38
|
+
// key: 'INSERT_BEFORE',
|
|
39
|
+
// label: 'Thêm dòng bên trên',
|
|
40
|
+
// icon: <Plus fontSize={14} />,
|
|
41
|
+
// children: [
|
|
42
|
+
// {
|
|
43
|
+
// parentKey: 'INSERT_BEFORE',
|
|
44
|
+
// key: 'INSERT_BEFORE_1',
|
|
45
|
+
// label: 'Thêm 1 dòng',
|
|
46
|
+
// row: 1
|
|
47
|
+
// },
|
|
48
|
+
// {
|
|
49
|
+
// parentKey: 'INSERT_BEFORE',
|
|
50
|
+
// key: 'INSERT_BEFORE_10',
|
|
51
|
+
// label: 'Thêm 10 dòng',
|
|
52
|
+
// row: 10
|
|
53
|
+
// },
|
|
54
|
+
// {
|
|
55
|
+
// parentKey: 'INSERT_BEFORE',
|
|
56
|
+
// key: 'INSERT_BEFORE_50',
|
|
57
|
+
// label: 'Thêm 50 dòng',
|
|
58
|
+
// row: 50
|
|
59
|
+
// },
|
|
60
|
+
// {
|
|
61
|
+
// parentKey: 'INSERT_BEFORE',
|
|
62
|
+
// key: 'INSERT_BEFORE_100',
|
|
63
|
+
// label: 'Thêm 100 dòng',
|
|
64
|
+
// row: 100
|
|
65
|
+
// },
|
|
66
|
+
// {
|
|
67
|
+
// parentKey: 'INSERT_BEFORE',
|
|
68
|
+
// key: 'INSERT_BEFORE_ADV',
|
|
69
|
+
// label: 'Tùy chỉnh'
|
|
70
|
+
// }
|
|
71
|
+
// ]
|
|
72
|
+
// },
|
|
73
|
+
// {
|
|
74
|
+
// key: 'INSERT_AFTER',
|
|
75
|
+
// label: 'Thêm dòng bên dưới',
|
|
76
|
+
// icon: <Plus fontSize={14} />,
|
|
77
|
+
// children: [
|
|
78
|
+
// {
|
|
79
|
+
// parentKey: 'INSERT_AFTER',
|
|
80
|
+
// key: 'INSERT_AFTER_1',
|
|
81
|
+
// label: 'Thêm 1 dòng',
|
|
82
|
+
// row: 1
|
|
83
|
+
// },
|
|
84
|
+
// {
|
|
85
|
+
// parentKey: 'INSERT_AFTER',
|
|
86
|
+
// key: 'INSERT_AFTER_10',
|
|
87
|
+
// label: 'Thêm 10 dòng',
|
|
88
|
+
// row: 10
|
|
89
|
+
// },
|
|
90
|
+
// {
|
|
91
|
+
// parentKey: 'INSERT_AFTER',
|
|
92
|
+
// key: 'INSERT_AFTER_50',
|
|
93
|
+
// label: 'Thêm 50 dòng',
|
|
94
|
+
// row: 50
|
|
95
|
+
// },
|
|
96
|
+
// {
|
|
97
|
+
// parentKey: 'INSERT_AFTER',
|
|
98
|
+
// key: 'INSERT_AFTER_100',
|
|
99
|
+
// label: 'Thêm 100 dòng',
|
|
100
|
+
// row: 100
|
|
101
|
+
// },
|
|
102
|
+
// {
|
|
103
|
+
// parentKey: 'INSERT_AFTER',
|
|
104
|
+
// key: 'INSERT_AFTER_ADV',
|
|
105
|
+
// label: 'Tùy chỉnh'
|
|
106
|
+
// }
|
|
107
|
+
// ]
|
|
108
|
+
// },
|
|
109
|
+
// {
|
|
110
|
+
// key: 'INSERT_CHILDREN',
|
|
111
|
+
// // label: 'Insert item children',
|
|
112
|
+
// label: 'Thêm cấp con',
|
|
113
|
+
// icon: <Plus fontSize={14} />
|
|
114
|
+
// // children: [
|
|
115
|
+
// // {
|
|
116
|
+
// // parentKey: 'INSERT_AFTER',
|
|
117
|
+
// // key: 'INSERT_AFTER_1',
|
|
118
|
+
// // label: 'Thêm 1 dòng',
|
|
119
|
+
// // row: 1
|
|
120
|
+
// // },
|
|
121
|
+
// // {
|
|
122
|
+
// // parentKey: 'INSERT_AFTER',
|
|
123
|
+
// // key: 'INSERT_AFTER_10',
|
|
124
|
+
// // label: 'Thêm 10 dòng',
|
|
125
|
+
// // row: 10
|
|
126
|
+
// // },
|
|
127
|
+
// // {
|
|
128
|
+
// // parentKey: 'INSERT_AFTER',
|
|
129
|
+
// // key: 'INSERT_AFTER_50',
|
|
130
|
+
// // label: 'Thêm 50 dòng',
|
|
131
|
+
// // row: 50
|
|
132
|
+
// // },
|
|
133
|
+
// // {
|
|
134
|
+
// // parentKey: 'INSERT_AFTER',
|
|
135
|
+
// // key: 'INSERT_AFTER_100',
|
|
136
|
+
// // label: 'Thêm 100 dòng',
|
|
137
|
+
// // row: 100
|
|
138
|
+
// // },
|
|
139
|
+
// // {
|
|
140
|
+
// // parentKey: 'INSERT_AFTER',
|
|
141
|
+
// // key: 'INSERT_AFTER_ADV',
|
|
142
|
+
// // label: 'Tùy chỉnh'
|
|
143
|
+
// // }
|
|
144
|
+
// // ]
|
|
145
|
+
// },
|
|
146
|
+
// { key: 'DELETE_CONTENT', label: 'Xóa nội dung', icon: <Trash2 fontSize={14} /> },
|
|
147
|
+
// { key: 'DELETE_ROWS', label: 'Xóa dòng', icon: <Trash2 fontSize={14} /> }
|
|
148
|
+
// ]
|
|
149
|
+
|
|
148
150
|
const validateData = async (data, formSchema) => {
|
|
149
151
|
if (!formSchema) {
|
|
150
152
|
return [];
|
|
@@ -208,6 +210,7 @@ const GridEdit = props => {
|
|
|
208
210
|
validate,
|
|
209
211
|
setTooltipContent,
|
|
210
212
|
onBlur,
|
|
213
|
+
locale,
|
|
211
214
|
...rest
|
|
212
215
|
} = props;
|
|
213
216
|
const ref = useRef(null);
|
|
@@ -253,123 +256,122 @@ const GridEdit = props => {
|
|
|
253
256
|
label: `100 ${t ? t('rows') : 'rows'}`
|
|
254
257
|
}];
|
|
255
258
|
}, [t]);
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
259
|
+
const defaultContext = React.useMemo(() => {
|
|
260
|
+
return [{
|
|
261
|
+
key: 'INSERT_BEFORE',
|
|
262
|
+
// label: 'Thêm dòng bên trên',
|
|
263
|
+
label: `${t ? t(locale?.add_rows_before ?? 'Add rows before') : 'Add rows before'}`,
|
|
264
|
+
icon: /*#__PURE__*/React.createElement(Plus, {
|
|
265
|
+
fontSize: 14
|
|
266
|
+
}),
|
|
267
|
+
children: [{
|
|
268
|
+
parentKey: 'INSERT_BEFORE',
|
|
269
|
+
key: 'INSERT_BEFORE_1',
|
|
270
|
+
label: `${t ? t(locale?.add_1 ?? 'Add 1 rows') : 'Add 1 rows'}`,
|
|
271
|
+
row: 1
|
|
272
|
+
}, {
|
|
273
|
+
parentKey: 'INSERT_BEFORE',
|
|
274
|
+
key: 'INSERT_BEFORE_10',
|
|
275
|
+
label: `${t ? t(locale?.add_10 ?? 'Add 10 rows') : 'Add 10 rows'}`,
|
|
276
|
+
row: 10
|
|
277
|
+
}, {
|
|
278
|
+
parentKey: 'INSERT_BEFORE',
|
|
279
|
+
key: 'INSERT_BEFORE_50',
|
|
280
|
+
label: `${t ? t(locale?.add_50 ?? 'Add 50 rows') : 'Add 50 rows'}`,
|
|
281
|
+
row: 50
|
|
282
|
+
}, {
|
|
283
|
+
parentKey: 'INSERT_BEFORE',
|
|
284
|
+
key: 'INSERT_BEFORE_100',
|
|
285
|
+
label: `${t ? t(locale?.add_100 ?? 'Add 100 rows') : 'Add 100 rows'}`,
|
|
286
|
+
row: 100
|
|
287
|
+
}, {
|
|
288
|
+
parentKey: 'INSERT_BEFORE',
|
|
289
|
+
key: 'INSERT_BEFORE_ADV',
|
|
290
|
+
label: `${t ? t(locale?.custom ?? 'Custom') : 'Custom'}`
|
|
291
|
+
}]
|
|
292
|
+
}, {
|
|
293
|
+
key: 'INSERT_AFTER',
|
|
294
|
+
label: `${t ? t(locale?.add_rows_after ?? 'Add rows after') : 'Add rows before'}`,
|
|
295
|
+
icon: /*#__PURE__*/React.createElement(Plus, {
|
|
296
|
+
fontSize: 14
|
|
297
|
+
}),
|
|
298
|
+
children: [{
|
|
299
|
+
parentKey: 'INSERT_AFTER',
|
|
300
|
+
key: 'INSERT_AFTER_1',
|
|
301
|
+
label: `${t ? t(locale?.add_1 ?? 'Add 1 rows') : 'Add 1 rows'}`,
|
|
302
|
+
row: 1
|
|
303
|
+
}, {
|
|
304
|
+
parentKey: 'INSERT_AFTER',
|
|
305
|
+
key: 'INSERT_AFTER_10',
|
|
306
|
+
label: `${t ? t(locale?.add_10 ?? 'Add 10 rows') : 'Add 10 rows'}`,
|
|
307
|
+
row: 10
|
|
308
|
+
}, {
|
|
309
|
+
parentKey: 'INSERT_AFTER',
|
|
310
|
+
key: 'INSERT_AFTER_50',
|
|
311
|
+
label: `${t ? t(locale?.add_50 ?? 'Add 50 rows') : 'Add 50 rows'}`,
|
|
312
|
+
row: 50
|
|
313
|
+
}, {
|
|
314
|
+
parentKey: 'INSERT_AFTER',
|
|
315
|
+
key: 'INSERT_AFTER_100',
|
|
316
|
+
label: `${t ? t(locale?.add_100 ?? 'Add 100 rows') : 'Add 100 rows'}`,
|
|
317
|
+
row: 100
|
|
318
|
+
}, {
|
|
319
|
+
parentKey: 'INSERT_AFTER',
|
|
320
|
+
key: 'INSERT_AFTER_ADV',
|
|
321
|
+
label: `${t ? t(locale?.custom ?? 'Custom') : 'Custom'}`
|
|
322
|
+
}]
|
|
323
|
+
}, {
|
|
324
|
+
key: 'INSERT_CHILDREN',
|
|
325
|
+
// label: 'Insert item children',
|
|
326
|
+
label: `${t ? t(locale?.add_children ?? 'Add children') : 'Add children'}`,
|
|
327
|
+
icon: /*#__PURE__*/React.createElement(Plus, {
|
|
328
|
+
fontSize: 14
|
|
329
|
+
})
|
|
330
|
+
// children: [
|
|
331
|
+
// {
|
|
332
|
+
// parentKey: 'INSERT_AFTER',
|
|
333
|
+
// key: 'INSERT_AFTER_1',
|
|
334
|
+
// label: 'Thêm 1 dòng',
|
|
335
|
+
// row: 1
|
|
336
|
+
// },
|
|
337
|
+
// {
|
|
338
|
+
// parentKey: 'INSERT_AFTER',
|
|
339
|
+
// key: 'INSERT_AFTER_10',
|
|
340
|
+
// label: 'Thêm 10 dòng',
|
|
341
|
+
// row: 10
|
|
342
|
+
// },
|
|
343
|
+
// {
|
|
344
|
+
// parentKey: 'INSERT_AFTER',
|
|
345
|
+
// key: 'INSERT_AFTER_50',
|
|
346
|
+
// label: 'Thêm 50 dòng',
|
|
347
|
+
// row: 50
|
|
348
|
+
// },
|
|
349
|
+
// {
|
|
350
|
+
// parentKey: 'INSERT_AFTER',
|
|
351
|
+
// key: 'INSERT_AFTER_100',
|
|
352
|
+
// label: 'Thêm 100 dòng',
|
|
353
|
+
// row: 100
|
|
354
|
+
// },
|
|
355
|
+
// {
|
|
356
|
+
// parentKey: 'INSERT_AFTER',
|
|
357
|
+
// key: 'INSERT_AFTER_ADV',
|
|
358
|
+
// label: 'Tùy chỉnh'
|
|
359
|
+
// }
|
|
360
|
+
// ]
|
|
361
|
+
}, {
|
|
362
|
+
key: 'DELETE_CONTENT',
|
|
363
|
+
label: `${t ? t(locale?.delete_content ?? 'Delete content') : 'Delete content'}`,
|
|
364
|
+
icon: /*#__PURE__*/React.createElement(Trash2, {
|
|
365
|
+
fontSize: 14
|
|
366
|
+
})
|
|
367
|
+
}, {
|
|
368
|
+
key: 'DELETE_ROWS',
|
|
369
|
+
label: `${t ? t(locale?.delete_rows ?? 'Delete rows') : 'Delete rows'}`,
|
|
370
|
+
icon: /*#__PURE__*/React.createElement(Trash2, {
|
|
371
|
+
fontSize: 14
|
|
372
|
+
})
|
|
373
|
+
}];
|
|
374
|
+
}, [t, locale]);
|
|
373
375
|
const [form] = Form.useForm();
|
|
374
376
|
|
|
375
377
|
// const [editingKey, setEditingKey] = useState<string | number>('')
|
|
@@ -1143,7 +1145,11 @@ const GridEdit = props => {
|
|
|
1143
1145
|
};
|
|
1144
1146
|
const handlePasted = (record, indexCol, rowNumber, pasteData) => {
|
|
1145
1147
|
const rows = pasteData.slice(0, onCellPaste?.maxRowsPaste ?? 200);
|
|
1148
|
+
console.log('rows', rows);
|
|
1149
|
+
console.log('record', record);
|
|
1146
1150
|
if (!record?.parentId) {
|
|
1151
|
+
console.log('1');
|
|
1152
|
+
|
|
1147
1153
|
// Cập nhật data mới
|
|
1148
1154
|
const newData = [...dataSource];
|
|
1149
1155
|
|
|
@@ -1178,13 +1184,38 @@ const GridEdit = props => {
|
|
|
1178
1184
|
}
|
|
1179
1185
|
if (visibleCols[targetCol].editEnable) {
|
|
1180
1186
|
// @ts-ignore
|
|
1187
|
+
const columnTarget = visibleCols[targetCol];
|
|
1181
1188
|
const columnKey = visibleCols[targetCol].field;
|
|
1189
|
+
if (columnTarget.type === 'number' && isFormattedNumber(cellValue.trim())) {
|
|
1190
|
+
const colFormat = typeof columnTarget.format === 'function' ? columnTarget.format(record) : columnTarget.format;
|
|
1191
|
+
const valuePasteFormat = detectSeparators(cellValue.trim());
|
|
1192
|
+
const cellFormat = getFormat(colFormat, format);
|
|
1193
|
+
const thousandSeparator = valuePasteFormat?.thousandSeparator ?? cellFormat?.thousandSeparator;
|
|
1194
|
+
const decimalSeparator = valuePasteFormat?.decimalSeparator ?? cellFormat?.decimalSeparator;
|
|
1195
|
+
const dec = cellFormat?.decimalScale;
|
|
1196
|
+
const numericFormatProps = {
|
|
1197
|
+
thousandSeparator: checkThousandSeparator(thousandSeparator, decimalSeparator),
|
|
1198
|
+
decimalSeparator: checkDecimalSeparator(thousandSeparator, decimalSeparator),
|
|
1199
|
+
allowNegative: cellFormat?.allowNegative ?? true,
|
|
1200
|
+
prefix: cellFormat?.prefix,
|
|
1201
|
+
suffix: cellFormat?.suffix,
|
|
1202
|
+
decimalScale: dec,
|
|
1203
|
+
fixedDecimalScale: cellFormat?.fixedDecimalScale ?? false
|
|
1204
|
+
};
|
|
1205
|
+
const val = removeNumericFormat(cellValue.trim(), undefined, numericFormatProps);
|
|
1182
1206
|
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1207
|
+
// @ts-ignore
|
|
1208
|
+
newData[targetRow] = {
|
|
1209
|
+
...newData[targetRow],
|
|
1210
|
+
[columnKey]: Number(val)
|
|
1211
|
+
};
|
|
1212
|
+
} else {
|
|
1213
|
+
// @ts-ignore
|
|
1214
|
+
newData[targetRow] = {
|
|
1215
|
+
...newData[targetRow],
|
|
1216
|
+
[columnKey]: cellValue.trim()
|
|
1217
|
+
};
|
|
1218
|
+
}
|
|
1188
1219
|
pastedColumns.add(columnKey);
|
|
1189
1220
|
}
|
|
1190
1221
|
});
|
|
@@ -1193,8 +1224,12 @@ const GridEdit = props => {
|
|
|
1193
1224
|
pastedRows.push(newData[targetRow]);
|
|
1194
1225
|
});
|
|
1195
1226
|
const pastedColumnsArray = Array.from(pastedColumns) ?? [];
|
|
1227
|
+
console.log('pastedRows', pastedRows);
|
|
1228
|
+
console.log('pastedColumnsArray', pastedColumnsArray);
|
|
1229
|
+
console.log('newData', newData);
|
|
1196
1230
|
triggerPaste?.(pastedRows, pastedColumnsArray, newData);
|
|
1197
1231
|
} else {
|
|
1232
|
+
console.log('2');
|
|
1198
1233
|
// Cập nhật data mới
|
|
1199
1234
|
const newData = [...dataSource];
|
|
1200
1235
|
const parent = findItemByKey(newData, rowKey, record.parentId);
|
|
@@ -1253,6 +1288,7 @@ const GridEdit = props => {
|
|
|
1253
1288
|
const handlePaste = (record, indexCol, rowNumber, e) => {
|
|
1254
1289
|
// const clipboard: any = (e.clipboardData || (window && window?.Clipboard)).getData("text")
|
|
1255
1290
|
const pasteData = e.clipboardData.getData("text/plain");
|
|
1291
|
+
console.log('pasteData', pasteData);
|
|
1256
1292
|
|
|
1257
1293
|
// Chuyển đổi dữ liệu từ clipboard thành mảng
|
|
1258
1294
|
const rowsPasted = pasteData.split("\n").map(row =>
|
|
@@ -1286,6 +1322,7 @@ const GridEdit = props => {
|
|
|
1286
1322
|
// ),
|
|
1287
1323
|
});
|
|
1288
1324
|
} else {
|
|
1325
|
+
console.log('5555');
|
|
1289
1326
|
handlePasted(record, indexCol, rowNumber, rowsPasted);
|
|
1290
1327
|
}
|
|
1291
1328
|
|
|
@@ -2209,6 +2246,7 @@ const GridEdit = props => {
|
|
|
2209
2246
|
}
|
|
2210
2247
|
},
|
|
2211
2248
|
onPaste: event => {
|
|
2249
|
+
console.log('aaaaaa');
|
|
2212
2250
|
if (editingKey.current === '') {
|
|
2213
2251
|
handlePaste(record, colIndex, rowNumber, event);
|
|
2214
2252
|
event.preventDefault();
|
|
@@ -2533,6 +2571,7 @@ const GridEdit = props => {
|
|
|
2533
2571
|
id: id,
|
|
2534
2572
|
tableRef: tableRef,
|
|
2535
2573
|
dataSource: dataSource,
|
|
2574
|
+
locale: locale,
|
|
2536
2575
|
components: {
|
|
2537
2576
|
...components,
|
|
2538
2577
|
body: {
|
|
@@ -2618,12 +2657,12 @@ const GridEdit = props => {
|
|
|
2618
2657
|
className: 'react-hot-toast'
|
|
2619
2658
|
}
|
|
2620
2659
|
}), /*#__PURE__*/React.createElement(Modal, {
|
|
2621
|
-
title:
|
|
2660
|
+
title: `${t ? t(locale?.add_rows ?? 'Add rows') : 'Add rows'}`,
|
|
2622
2661
|
open: openModalAddRow.open,
|
|
2623
2662
|
onOk: onOkAddRow,
|
|
2624
2663
|
onCancel: hideModalAddRow,
|
|
2625
|
-
okText:
|
|
2626
|
-
cancelText:
|
|
2664
|
+
okText: `${t ? t(locale?.ok_btn ?? 'Ok') : 'Ok'}`,
|
|
2665
|
+
cancelText: `${t ? t(locale?.cancel_btn ?? 'Cancel') : 'Cancel'}`,
|
|
2627
2666
|
className: 'be-popup-container',
|
|
2628
2667
|
centered: true,
|
|
2629
2668
|
width: 250,
|