es-grid-template 1.4.5 → 1.4.6
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/grid-component/EditableCell.js +3 -2
- package/es/grid-component/hooks/utils.d.ts +3 -0
- package/es/grid-component/hooks/utils.js +113 -4
- package/es/grid-component/table/GridEdit.js +445 -443
- package/lib/grid-component/EditableCell.js +2 -1
- package/lib/grid-component/hooks/utils.d.ts +3 -0
- package/lib/grid-component/hooks/utils.js +119 -7
- package/lib/grid-component/table/GridEdit.js +445 -443
- package/package.json +1 -1
|
@@ -1118,211 +1118,483 @@ const GridEdit = props => {
|
|
|
1118
1118
|
}
|
|
1119
1119
|
pasteCells.current = new Set();
|
|
1120
1120
|
};
|
|
1121
|
-
const
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
const startPasteRow = (0, _hooks.getLastSelectCell)(selectedCells.current).row;
|
|
1127
|
-
const newPasteCells = new Set();
|
|
1128
|
-
for (let r = Math.min(startPasteRow, dataSource.length - 1) + 1; r <= Math.max(startPasteRow, dataSource.length - 1); r++) {
|
|
1129
|
-
for (let c = Math.min(colStart, colStart); c <= Math.max(colStart, colEnd); c++) {
|
|
1130
|
-
newPasteCells.add(`${r}-${c}`);
|
|
1131
|
-
}
|
|
1132
|
-
}
|
|
1133
|
-
(0, _hooks.hideDraggingPoint)(selectedCells.current, id);
|
|
1134
|
-
triggerDragPaste(newPasteCells);
|
|
1135
|
-
};
|
|
1136
|
-
const handleMouseDown = (record, row, col, e) => {
|
|
1137
|
-
if (e.button === 2) {
|
|
1138
|
-
e.stopPropagation();
|
|
1139
|
-
return;
|
|
1140
|
-
}
|
|
1141
|
-
if (editingKey && editingKey === record[rowKey]) {
|
|
1142
|
-
return;
|
|
1143
|
-
}
|
|
1144
|
-
if (record[rowKey] !== editingKey && editingKey !== '') {
|
|
1145
|
-
setEditingKey('');
|
|
1146
|
-
}
|
|
1121
|
+
const handlePasted = (record, indexCol, rowNumber, pasteData) => {
|
|
1122
|
+
const rows = pasteData.slice(0, onCellPaste?.maxRowsPaste ?? 200);
|
|
1123
|
+
if (!record?.parentId) {
|
|
1124
|
+
// Cập nhật data mới
|
|
1125
|
+
const newData = [...dataSource];
|
|
1147
1126
|
|
|
1148
|
-
|
|
1149
|
-
isMouseDown.current = true;
|
|
1150
|
-
if (e.ctrlKey) {
|
|
1151
|
-
isSelecting.current = true;
|
|
1152
|
-
startCell.current = {
|
|
1153
|
-
row,
|
|
1154
|
-
col
|
|
1155
|
-
};
|
|
1127
|
+
// const indexRows = newData.findIndex((it) => it[rowKey as any] === record[rowKey])
|
|
1156
1128
|
|
|
1157
|
-
//
|
|
1129
|
+
// Lấy vị trí bắt đầu
|
|
1130
|
+
// const { row: startRow, col: startCol } = selectedCell;
|
|
1131
|
+
const startRow = newData.findIndex(it => it[rowKey] === record[rowKey]);
|
|
1132
|
+
const startCol = indexCol;
|
|
1158
1133
|
|
|
1159
|
-
//
|
|
1160
|
-
} else {
|
|
1161
|
-
isSelecting.current = true;
|
|
1162
|
-
startCell.current = {
|
|
1163
|
-
row,
|
|
1164
|
-
col
|
|
1165
|
-
};
|
|
1166
|
-
const target = e.target;
|
|
1167
|
-
if (target.closest('.dragging-point')) {
|
|
1168
|
-
e.stopPropagation();
|
|
1169
|
-
e.preventDefault();
|
|
1170
|
-
return; // Không xử lý gì cả
|
|
1171
|
-
} else {
|
|
1172
|
-
// setStartSelectedCell({row, col})
|
|
1134
|
+
// const flattData = flattenArray(newData);
|
|
1173
1135
|
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1136
|
+
const pastedRows = [];
|
|
1137
|
+
const pastedColumns = new Set();
|
|
1138
|
+
rows.forEach((rowValues, rowIndex) => {
|
|
1139
|
+
const targetRow = startRow + rowIndex;
|
|
1178
1140
|
|
|
1179
|
-
//
|
|
1141
|
+
// Nếu vượt quá số dòng hiện có, thêm dòng mới
|
|
1142
|
+
if (targetRow >= newData.length) {
|
|
1143
|
+
// @ts-ignore
|
|
1144
|
+
// newData.push({ id: newGuid()});
|
|
1145
|
+
newData.push({
|
|
1146
|
+
id: undefined,
|
|
1147
|
+
rowId: (0, _hooks.newGuid)()
|
|
1148
|
+
});
|
|
1149
|
+
}
|
|
1150
|
+
rowValues.forEach((cellValue, colIndex) => {
|
|
1151
|
+
const targetCol = startCol + colIndex;
|
|
1152
|
+
if (targetCol >= visibleCols.length) {
|
|
1153
|
+
// Không vượt quá số cột
|
|
1154
|
+
return;
|
|
1155
|
+
}
|
|
1156
|
+
if (visibleCols[targetCol].editEnable) {
|
|
1157
|
+
// @ts-ignore
|
|
1158
|
+
const columnKey = visibleCols[targetCol].field;
|
|
1180
1159
|
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
(0, _hooks.onRemoveBgCellIndex)(selectedCells.current, id);
|
|
1160
|
+
// @ts-ignore
|
|
1161
|
+
newData[targetRow] = {
|
|
1162
|
+
...newData[targetRow],
|
|
1163
|
+
[columnKey]: cellValue.trim()
|
|
1164
|
+
};
|
|
1165
|
+
pastedColumns.add(columnKey);
|
|
1188
1166
|
}
|
|
1189
|
-
}
|
|
1190
|
-
if (rowsSelected.current && rowsSelected.current.size > 0) {
|
|
1191
|
-
(0, _hooks.removeClassCellIndexSelected)(rowsSelected.current, id);
|
|
1192
|
-
}
|
|
1193
|
-
if (!(0, _hooks.isEqualSet)(cells, selectedCells.current)) {
|
|
1194
|
-
(0, _hooks.onRemoveBgSelectedCell)(selectedCells.current, id);
|
|
1195
|
-
(0, _hooks.hideDraggingPoint)(selectedCells.current, id);
|
|
1196
|
-
selectedCells.current = cells;
|
|
1197
|
-
// setRangeCells(cells)
|
|
1167
|
+
});
|
|
1198
1168
|
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1169
|
+
// Lưu dòng được paste
|
|
1170
|
+
pastedRows.push(newData[targetRow]);
|
|
1171
|
+
});
|
|
1172
|
+
const pastedColumnsArray = Array.from(pastedColumns) ?? [];
|
|
1173
|
+
triggerPaste?.(pastedRows, pastedColumnsArray, newData);
|
|
1174
|
+
} else {
|
|
1175
|
+
// Cập nhật data mới
|
|
1176
|
+
const newData = [...dataSource];
|
|
1177
|
+
const parent = (0, _hooks.findItemByKey)(newData, rowKey, record.parentId);
|
|
1204
1178
|
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
}
|
|
1208
|
-
}
|
|
1209
|
-
};
|
|
1210
|
-
const handleMouseUp = e => {
|
|
1211
|
-
isSelecting.current = false;
|
|
1212
|
-
startCell.current = null;
|
|
1213
|
-
isSelectingRow.current = false;
|
|
1214
|
-
rowStart.current = null;
|
|
1215
|
-
isDragMouse.current = false;
|
|
1216
|
-
isMouseDown.current = false;
|
|
1217
|
-
setIsPasteDragging(false);
|
|
1218
|
-
if (e.ctrlKey) {
|
|
1179
|
+
// Cập nhật childData mới
|
|
1180
|
+
const childData = parent?.children ? [...parent.children] : [];
|
|
1219
1181
|
|
|
1220
|
-
//
|
|
1221
|
-
|
|
1182
|
+
// Lấy vị trí bắt đầu
|
|
1183
|
+
// const { row: startRow, col: startCol } = selectedCell;
|
|
1184
|
+
const startRow = childData.findIndex(it => it[rowKey] === record[rowKey]);
|
|
1185
|
+
const startCol = indexCol;
|
|
1186
|
+
const pastedRows = [];
|
|
1187
|
+
const pastedColumns = new Set();
|
|
1188
|
+
rows.forEach((rowValues, rowIndex) => {
|
|
1189
|
+
const targetRow = startRow + rowIndex;
|
|
1222
1190
|
|
|
1223
|
-
|
|
1191
|
+
// Nếu vượt quá số dòng hiện có, thêm dòng mới
|
|
1192
|
+
if (targetRow >= childData.length) {
|
|
1193
|
+
childData.push({
|
|
1194
|
+
id: undefined,
|
|
1195
|
+
rowId: (0, _hooks.newGuid)(),
|
|
1196
|
+
parentId: parent[rowKey ?? 'id']
|
|
1197
|
+
});
|
|
1198
|
+
}
|
|
1199
|
+
rowValues.forEach((cellValue, colIndex) => {
|
|
1200
|
+
const targetCol = startCol + colIndex;
|
|
1201
|
+
if (targetCol >= visibleCols.length) {
|
|
1202
|
+
// Không vượt quá số cột
|
|
1203
|
+
return;
|
|
1204
|
+
}
|
|
1205
|
+
if (visibleCols[targetCol].editEnable) {
|
|
1206
|
+
// @ts-ignore
|
|
1207
|
+
const columnKey = visibleCols[targetCol].field;
|
|
1224
1208
|
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
return; // Không xử lý gì cả
|
|
1234
|
-
}
|
|
1235
|
-
if (selectedCells.current && selectedCells.current.size > 1) {
|
|
1236
|
-
(0, _hooks.hideDraggingPoint)(selectedCells.current, id);
|
|
1237
|
-
(0, _hooks.onAddBorderSelectedCell)(selectedCells.current, id);
|
|
1209
|
+
// @ts-ignore
|
|
1210
|
+
childData[targetRow] = {
|
|
1211
|
+
...childData[targetRow],
|
|
1212
|
+
[columnKey]: cellValue.trim()
|
|
1213
|
+
};
|
|
1214
|
+
pastedColumns.add(columnKey);
|
|
1215
|
+
}
|
|
1216
|
+
});
|
|
1238
1217
|
|
|
1239
|
-
//
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1218
|
+
// Lưu dòng được paste
|
|
1219
|
+
pastedRows.push(childData[targetRow]);
|
|
1220
|
+
});
|
|
1221
|
+
const pastedColumnsArray = Array.from(pastedColumns) ?? [];
|
|
1222
|
+
const newRowData = {
|
|
1223
|
+
...parent,
|
|
1224
|
+
children: childData
|
|
1225
|
+
};
|
|
1226
|
+
const newDataSource = (0, _hooks.updateArrayByKey)(newData, newRowData, rowKey);
|
|
1227
|
+
triggerPaste?.(pastedRows, pastedColumnsArray, newDataSource);
|
|
1243
1228
|
}
|
|
1244
1229
|
};
|
|
1245
|
-
const
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
}
|
|
1249
|
-
const {
|
|
1250
|
-
row: startRow,
|
|
1251
|
-
col: startCol
|
|
1252
|
-
} = startCell.current;
|
|
1253
|
-
if (e.ctrlKey) {
|
|
1254
|
-
// const newCtrlCells = new Set();
|
|
1255
|
-
// for (let r = Math.min(startRow, row); r <= Math.max(startRow, row); r++) {
|
|
1256
|
-
// for (let c = Math.min(startCol, col); c <= Math.max(startCol, col); c++) {
|
|
1257
|
-
// newCtrlCells.add(`${r}-${c}`)
|
|
1258
|
-
// }
|
|
1259
|
-
// }
|
|
1230
|
+
const handlePaste = (record, indexCol, rowNumber, e) => {
|
|
1231
|
+
// const clipboard: any = (e.clipboardData || (window && window?.Clipboard)).getData("text")
|
|
1232
|
+
const pasteData = e.clipboardData.getData("text/plain");
|
|
1260
1233
|
|
|
1261
|
-
|
|
1234
|
+
// Chuyển đổi dữ liệu từ clipboard thành mảng
|
|
1235
|
+
const rowsPasted = pasteData.split("\n").map(row =>
|
|
1236
|
+
// const rows = pasteData.split("\n").map((row: any) =>
|
|
1237
|
+
row.replace(/\r/g, "").split("\t"));
|
|
1238
|
+
if (rowsPasted.length > (onCellPaste?.maxRowsPaste ?? 200)) {
|
|
1239
|
+
// bật popup thông báo
|
|
1262
1240
|
|
|
1263
|
-
|
|
1241
|
+
_antd.Modal.confirm({
|
|
1242
|
+
content: /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(Paragraph, {
|
|
1243
|
+
style: {
|
|
1244
|
+
marginBottom: '.25rem',
|
|
1245
|
+
fontSize: 14
|
|
1246
|
+
}
|
|
1247
|
+
}, "D\u1EEF li\u1EC7u sao ch\xE9p v\u01B0\u1EE3t qu\xE1 s\u1ED1 d\xF2ng cho ph\xE9p (500 d\xF2ng).Ph\u1EA7n m\u1EC1n s\u1EBD ch\u1EC9 l\u1EA5y 500 d\xF2ng \u0111\u1EA7u ti\xEAn."), /*#__PURE__*/_react.default.createElement(Title, {
|
|
1248
|
+
level: 5,
|
|
1249
|
+
style: {
|
|
1250
|
+
marginTop: '.75rem'
|
|
1251
|
+
}
|
|
1252
|
+
}, "B\u1EA1n c\xF3 mu\u1ED1n ti\u1EBFp t\u1EE5c sao ch\xE9p kh\xF4ng?")),
|
|
1253
|
+
centered: true,
|
|
1254
|
+
className: 'be-popup-container',
|
|
1255
|
+
onOk: () => {
|
|
1256
|
+
handlePasted(record, indexCol, rowNumber, rowsPasted);
|
|
1257
|
+
}
|
|
1258
|
+
// footer: (_, { OkBtn, CancelBtn }) => (
|
|
1259
|
+
// <>
|
|
1260
|
+
// <OkBtn />
|
|
1261
|
+
// <CancelBtn />
|
|
1262
|
+
// </>
|
|
1263
|
+
// ),
|
|
1264
|
+
});
|
|
1265
|
+
} else {
|
|
1266
|
+
handlePasted(record, indexCol, rowNumber, rowsPasted);
|
|
1264
1267
|
}
|
|
1265
|
-
if (!isPasteDragging) {
|
|
1266
|
-
// chọn vùng copy
|
|
1267
|
-
|
|
1268
|
-
// setSelectIsDragging(true)
|
|
1269
|
-
|
|
1270
|
-
setIsPasteDragging(false);
|
|
1271
|
-
// isPasteDragging.current = false
|
|
1272
1268
|
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1269
|
+
// const rows = rowsPasted.slice(0, (onCellPaste?.maxRowsPaste ?? 200));
|
|
1270
|
+
//
|
|
1271
|
+
//
|
|
1272
|
+
// if (!record?.parentId ) {
|
|
1273
|
+
//
|
|
1274
|
+
// // Cập nhật data mới
|
|
1275
|
+
// const newData = [...dataSource];
|
|
1276
|
+
//
|
|
1277
|
+
// // @ts-ignore
|
|
1278
|
+
// const indexRows = newData.findIndex((it) => it[rowKey] === record[rowKey])
|
|
1279
|
+
//
|
|
1280
|
+
// // Lấy vị trí bắt đầu
|
|
1281
|
+
// // const { row: startRow, col: startCol } = selectedCell;
|
|
1282
|
+
// const startRow = indexRows
|
|
1283
|
+
// const startCol = indexCol
|
|
1284
|
+
//
|
|
1285
|
+
//
|
|
1286
|
+
//
|
|
1287
|
+
// // const flattData = flattenArray(newData);
|
|
1288
|
+
//
|
|
1289
|
+
// const pastedRows: RecordType[] = [];
|
|
1290
|
+
// const pastedColumns = new Set()
|
|
1291
|
+
//
|
|
1292
|
+
//
|
|
1293
|
+
// rows.forEach((rowValues: any, rowIndex: any) => {
|
|
1294
|
+
// const targetRow = startRow + rowIndex;
|
|
1295
|
+
//
|
|
1296
|
+
// // Nếu vượt quá số dòng hiện có, thêm dòng mới
|
|
1297
|
+
// if (targetRow >= newData.length) {
|
|
1298
|
+
// // @ts-ignore
|
|
1299
|
+
// // newData.push({ id: newGuid()});
|
|
1300
|
+
// newData.push({ id: undefined, rowId: newGuid()});
|
|
1301
|
+
// }
|
|
1302
|
+
//
|
|
1303
|
+
// rowValues.forEach((cellValue: any, colIndex: any) => {
|
|
1304
|
+
// const targetCol = startCol + colIndex;
|
|
1305
|
+
// if (targetCol >= columns.length) { // Không vượt quá số cột
|
|
1306
|
+
// return
|
|
1307
|
+
// }
|
|
1308
|
+
//
|
|
1309
|
+
// if (columns[targetCol].editEnable) {
|
|
1310
|
+
// // @ts-ignore
|
|
1311
|
+
// const columnKey = columns[targetCol].field;
|
|
1312
|
+
//
|
|
1313
|
+
// // @ts-ignore
|
|
1314
|
+
// newData[targetRow] = { ...newData[targetRow], [columnKey]: cellValue.trim() };
|
|
1315
|
+
// pastedColumns.add(columnKey);
|
|
1316
|
+
// }
|
|
1317
|
+
//
|
|
1318
|
+
// });
|
|
1319
|
+
//
|
|
1320
|
+
// // Lưu dòng được paste
|
|
1321
|
+
// pastedRows.push(newData[targetRow]);
|
|
1322
|
+
//
|
|
1323
|
+
// });
|
|
1324
|
+
//
|
|
1325
|
+
// const pastedColumnsArray = Array.from(pastedColumns) ?? [];
|
|
1326
|
+
//
|
|
1327
|
+
// triggerPaste?.(pastedRows, pastedColumnsArray as string[], newData)
|
|
1328
|
+
//
|
|
1329
|
+
//
|
|
1330
|
+
// } else {
|
|
1331
|
+
//
|
|
1332
|
+
// // Cập nhật data mới
|
|
1333
|
+
// const newData = [...dataSource];
|
|
1334
|
+
//
|
|
1335
|
+
// const parent = findItemByKey(newData, rowKey as any, record.parentId)
|
|
1336
|
+
//
|
|
1337
|
+
// // Cập nhật childData mới
|
|
1338
|
+
// const childData: any[] = parent?.children ? [...parent.children] : []
|
|
1339
|
+
//
|
|
1340
|
+
//
|
|
1341
|
+
// // Lấy vị trí bắt đầu
|
|
1342
|
+
// // const { row: startRow, col: startCol } = selectedCell;
|
|
1343
|
+
// const startRow = childData.findIndex((it) => it[rowKey] === record[rowKey])
|
|
1344
|
+
// const startCol = indexCol
|
|
1345
|
+
//
|
|
1346
|
+
// const pastedRows: RecordType[] = []
|
|
1347
|
+
// const pastedColumns = new Set()
|
|
1348
|
+
//
|
|
1349
|
+
//
|
|
1350
|
+
// rows.forEach((rowValues: any, rowIndex: any) => {
|
|
1351
|
+
// const targetRow = startRow + rowIndex
|
|
1352
|
+
//
|
|
1353
|
+
// // Nếu vượt quá số dòng hiện có, thêm dòng mới
|
|
1354
|
+
// if (targetRow >= childData.length) {
|
|
1355
|
+
//
|
|
1356
|
+
// childData.push({ id: undefined, rowId: newGuid(), parentId: parent[rowKey ?? 'id']})
|
|
1357
|
+
// }
|
|
1358
|
+
//
|
|
1359
|
+
// rowValues.forEach((cellValue: any, colIndex: any) => {
|
|
1360
|
+
// const targetCol = startCol + colIndex
|
|
1361
|
+
// if (targetCol >= columns.length) { // Không vượt quá số cột
|
|
1362
|
+
// return
|
|
1363
|
+
// }
|
|
1364
|
+
//
|
|
1365
|
+
// if (columns[targetCol].editEnable) {
|
|
1366
|
+
//
|
|
1367
|
+
// // @ts-ignore
|
|
1368
|
+
// const columnKey = columns[targetCol].field
|
|
1369
|
+
//
|
|
1370
|
+
// // @ts-ignore
|
|
1371
|
+
// childData[targetRow] = { ...childData[targetRow], [columnKey]: cellValue.trim() }
|
|
1372
|
+
// pastedColumns.add(columnKey)
|
|
1373
|
+
// }
|
|
1374
|
+
//
|
|
1375
|
+
// })
|
|
1376
|
+
//
|
|
1377
|
+
// // Lưu dòng được paste
|
|
1378
|
+
// pastedRows.push(childData[targetRow])
|
|
1379
|
+
//
|
|
1380
|
+
// })
|
|
1381
|
+
//
|
|
1382
|
+
// const pastedColumnsArray = Array.from(pastedColumns) ?? []
|
|
1383
|
+
//
|
|
1384
|
+
// const newRowData = {...parent, children: childData}
|
|
1385
|
+
//
|
|
1386
|
+
// const newDataSource = updateArrayByKey(newData, newRowData, rowKey as string)
|
|
1387
|
+
//
|
|
1388
|
+
// triggerPaste?.(pastedRows, pastedColumnsArray as string[], newDataSource )
|
|
1389
|
+
// }
|
|
1390
|
+
};
|
|
1391
|
+
const handlePointDoubleClick = e => {
|
|
1392
|
+
// e.preventDefault()
|
|
1393
|
+
e.stopPropagation();
|
|
1394
|
+
const colStart = (0, _hooks.getFirstSelectCell)(selectedCells.current).col;
|
|
1395
|
+
const colEnd = (0, _hooks.getLastSelectCell)(selectedCells.current).col;
|
|
1396
|
+
const startPasteRow = (0, _hooks.getLastSelectCell)(selectedCells.current).row;
|
|
1397
|
+
const newPasteCells = new Set();
|
|
1398
|
+
for (let r = Math.min(startPasteRow, dataSource.length - 1) + 1; r <= Math.max(startPasteRow, dataSource.length - 1); r++) {
|
|
1399
|
+
for (let c = Math.min(colStart, colStart); c <= Math.max(colStart, colEnd); c++) {
|
|
1400
|
+
newPasteCells.add(`${r}-${c}`);
|
|
1278
1401
|
}
|
|
1402
|
+
}
|
|
1403
|
+
(0, _hooks.hideDraggingPoint)(selectedCells.current, id);
|
|
1404
|
+
triggerDragPaste(newPasteCells);
|
|
1405
|
+
};
|
|
1406
|
+
const handleMouseDown = (record, row, col, e) => {
|
|
1407
|
+
if (e.button === 2) {
|
|
1408
|
+
e.stopPropagation();
|
|
1409
|
+
return;
|
|
1410
|
+
}
|
|
1411
|
+
if (editingKey && editingKey === record[rowKey]) {
|
|
1412
|
+
return;
|
|
1413
|
+
}
|
|
1414
|
+
if (record[rowKey] !== editingKey && editingKey !== '') {
|
|
1415
|
+
setTimeout(() => {
|
|
1416
|
+
setEditingKey('');
|
|
1417
|
+
});
|
|
1418
|
+
}
|
|
1279
1419
|
|
|
1280
|
-
|
|
1420
|
+
// isDragMouse.current = true
|
|
1421
|
+
isMouseDown.current = true;
|
|
1422
|
+
if (e.ctrlKey) {
|
|
1423
|
+
isSelecting.current = true;
|
|
1424
|
+
startCell.current = {
|
|
1425
|
+
row,
|
|
1426
|
+
col
|
|
1427
|
+
};
|
|
1281
1428
|
|
|
1282
|
-
|
|
1283
|
-
(0, _hooks.onRemoveBgSelectedCell)(selectedCells.current, id);
|
|
1284
|
-
}
|
|
1285
|
-
selectedCells.current = newSelectedCells;
|
|
1286
|
-
(0, _hooks.onAddBgSelectedCell)(newSelectedCells, id);
|
|
1287
|
-
} else {
|
|
1288
|
-
// chọn vùng paste
|
|
1429
|
+
// const cell: any = new Set([`${row}-${col}`])
|
|
1289
1430
|
|
|
1290
|
-
//
|
|
1431
|
+
// setCurrentCtrlCells(cell)
|
|
1432
|
+
} else {
|
|
1433
|
+
isSelecting.current = true;
|
|
1434
|
+
startCell.current = {
|
|
1435
|
+
row,
|
|
1436
|
+
col
|
|
1437
|
+
};
|
|
1438
|
+
const target = e.target;
|
|
1439
|
+
if (target.closest('.dragging-point')) {
|
|
1440
|
+
e.stopPropagation();
|
|
1441
|
+
e.preventDefault();
|
|
1442
|
+
return; // Không xử lý gì cả
|
|
1443
|
+
} else {
|
|
1444
|
+
// setStartSelectedCell({row, col})
|
|
1291
1445
|
|
|
1292
|
-
|
|
1446
|
+
startSelectedCells.current = {
|
|
1447
|
+
row,
|
|
1448
|
+
col
|
|
1449
|
+
};
|
|
1293
1450
|
|
|
1294
|
-
|
|
1295
|
-
for (let r = Math.min(startRow, row); r <= Math.max(startRow, row); r++) {
|
|
1296
|
-
for (let c = Math.min(startCol, col); c <= Math.max(startCol, col); c++) {
|
|
1297
|
-
newSelectedCells.add(`${r}-${c}`);
|
|
1298
|
-
}
|
|
1299
|
-
}
|
|
1300
|
-
const colStart = (0, _hooks.getFirstSelectCell)(selectedCells.current).col;
|
|
1301
|
-
const colEnd = (0, _hooks.getLastSelectCell)(selectedCells.current).col;
|
|
1302
|
-
const rowSelectedEnd = (0, _hooks.getLastSelectCell)(selectedCells.current).row;
|
|
1303
|
-
if (row >= rowSelectedEnd) {
|
|
1304
|
-
// kéo xuống dưới
|
|
1451
|
+
// setSelectedCells(new Set([`${row}-${col}`]));
|
|
1305
1452
|
|
|
1306
|
-
const
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1453
|
+
const cells = new Set([`${row}-${col}`]);
|
|
1454
|
+
if (selectedCells.current && selectedCells.current.size > 0) {
|
|
1455
|
+
if (!(0, _hooks.isEqualSet)(cells, rangeCells)) {
|
|
1456
|
+
// onRemoveBgSelectedCell(rangeCells, id)
|
|
1457
|
+
// onRemoveBorderSelectedCell(rangeCells, id)
|
|
1458
|
+
(0, _hooks.hideDraggingPoint)(rangeCells, id);
|
|
1459
|
+
(0, _hooks.onRemoveBgCellIndex)(selectedCells.current, id);
|
|
1310
1460
|
}
|
|
1311
1461
|
}
|
|
1462
|
+
if (rowsSelected.current && rowsSelected.current.size > 0) {
|
|
1463
|
+
(0, _hooks.removeClassCellIndexSelected)(rowsSelected.current, id);
|
|
1464
|
+
}
|
|
1465
|
+
if (!(0, _hooks.isEqualSet)(cells, selectedCells.current)) {
|
|
1466
|
+
(0, _hooks.onRemoveBgSelectedCell)(selectedCells.current, id);
|
|
1467
|
+
(0, _hooks.hideDraggingPoint)(selectedCells.current, id);
|
|
1468
|
+
selectedCells.current = cells;
|
|
1469
|
+
// setRangeCells(cells)
|
|
1312
1470
|
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
(0, _hooks.
|
|
1471
|
+
(0, _hooks.onAddBgCellIndex)(cells, id);
|
|
1472
|
+
(0, _hooks.onAddBorderSelectedCell)(cells, id);
|
|
1473
|
+
(0, _hooks.onAddBgSelectedCell)(selectedCells.current, id, false);
|
|
1474
|
+
(0, _hooks.showDraggingPoint)(selectedCells.current, id);
|
|
1317
1475
|
}
|
|
1318
|
-
|
|
1319
|
-
(
|
|
1476
|
+
|
|
1477
|
+
// setRowsSelected(new Set())
|
|
1478
|
+
rowsSelected.current = new Set();
|
|
1320
1479
|
}
|
|
1321
|
-
|
|
1322
|
-
|
|
1480
|
+
}
|
|
1481
|
+
};
|
|
1482
|
+
const handleMouseUp = e => {
|
|
1483
|
+
isSelecting.current = false;
|
|
1484
|
+
startCell.current = null;
|
|
1485
|
+
isSelectingRow.current = false;
|
|
1486
|
+
rowStart.current = null;
|
|
1487
|
+
isDragMouse.current = false;
|
|
1488
|
+
isMouseDown.current = false;
|
|
1489
|
+
setIsPasteDragging(false);
|
|
1490
|
+
if (e.ctrlKey) {
|
|
1323
1491
|
|
|
1324
|
-
|
|
1325
|
-
|
|
1492
|
+
// setCtrlCells([...ctrlCells, currentCtrlCells])
|
|
1493
|
+
}
|
|
1494
|
+
|
|
1495
|
+
// nếu ctrlCell length > 0 thì set selectCells
|
|
1496
|
+
|
|
1497
|
+
if (pasteCells && pasteCells.current.size > 0) {
|
|
1498
|
+
triggerDragPaste(pasteCells.current);
|
|
1499
|
+
} else {
|
|
1500
|
+
setRangeCells(selectedCells.current);
|
|
1501
|
+
const target = e.target;
|
|
1502
|
+
if (target.closest('.dragging-point')) {
|
|
1503
|
+
e.stopPropagation();
|
|
1504
|
+
e.preventDefault();
|
|
1505
|
+
return; // Không xử lý gì cả
|
|
1506
|
+
}
|
|
1507
|
+
if (selectedCells.current && selectedCells.current.size > 1) {
|
|
1508
|
+
(0, _hooks.hideDraggingPoint)(selectedCells.current, id);
|
|
1509
|
+
(0, _hooks.onAddBorderSelectedCell)(selectedCells.current, id);
|
|
1510
|
+
|
|
1511
|
+
// showDraggingPoint(selectedCells.current, id)
|
|
1512
|
+
}
|
|
1513
|
+
(0, _hooks.showDraggingPoint)(selectedCells.current, id);
|
|
1514
|
+
// onAddBorderSelectedCell(selectedCells.current, id)
|
|
1515
|
+
}
|
|
1516
|
+
};
|
|
1517
|
+
const handleMouseEnter = (row, col, e) => {
|
|
1518
|
+
if (!isSelecting.current || !startCell.current) {
|
|
1519
|
+
return;
|
|
1520
|
+
}
|
|
1521
|
+
const {
|
|
1522
|
+
row: startRow,
|
|
1523
|
+
col: startCol
|
|
1524
|
+
} = startCell.current;
|
|
1525
|
+
if (e.ctrlKey) {
|
|
1526
|
+
// const newCtrlCells = new Set();
|
|
1527
|
+
// for (let r = Math.min(startRow, row); r <= Math.max(startRow, row); r++) {
|
|
1528
|
+
// for (let c = Math.min(startCol, col); c <= Math.max(startCol, col); c++) {
|
|
1529
|
+
// newCtrlCells.add(`${r}-${c}`)
|
|
1530
|
+
// }
|
|
1531
|
+
// }
|
|
1532
|
+
|
|
1533
|
+
// setCurrentCtrlCells(newCtrlCells)
|
|
1534
|
+
|
|
1535
|
+
return;
|
|
1536
|
+
}
|
|
1537
|
+
if (!isPasteDragging) {
|
|
1538
|
+
// chọn vùng copy
|
|
1539
|
+
|
|
1540
|
+
// setSelectIsDragging(true)
|
|
1541
|
+
|
|
1542
|
+
setIsPasteDragging(false);
|
|
1543
|
+
// isPasteDragging.current = false
|
|
1544
|
+
|
|
1545
|
+
const newSelectedCells = new Set();
|
|
1546
|
+
for (let r = Math.min(startRow, row); r <= Math.max(startRow, row); r++) {
|
|
1547
|
+
for (let c = Math.min(startCol, col); c <= Math.max(startCol, col); c++) {
|
|
1548
|
+
newSelectedCells.add(`${r}-${c}`);
|
|
1549
|
+
}
|
|
1550
|
+
}
|
|
1551
|
+
|
|
1552
|
+
// setSelectedCells(newSelectedCells)
|
|
1553
|
+
|
|
1554
|
+
if (selectedCells.current && selectedCells.current.size > 0) {
|
|
1555
|
+
(0, _hooks.onRemoveBgSelectedCell)(selectedCells.current, id);
|
|
1556
|
+
}
|
|
1557
|
+
selectedCells.current = newSelectedCells;
|
|
1558
|
+
(0, _hooks.onAddBgSelectedCell)(newSelectedCells, id);
|
|
1559
|
+
} else {
|
|
1560
|
+
// chọn vùng paste
|
|
1561
|
+
|
|
1562
|
+
// setSelectIsDragging(false)
|
|
1563
|
+
|
|
1564
|
+
// setIsPasteDragging(true) ////////
|
|
1565
|
+
|
|
1566
|
+
const newSelectedCells = new Set();
|
|
1567
|
+
for (let r = Math.min(startRow, row); r <= Math.max(startRow, row); r++) {
|
|
1568
|
+
for (let c = Math.min(startCol, col); c <= Math.max(startCol, col); c++) {
|
|
1569
|
+
newSelectedCells.add(`${r}-${c}`);
|
|
1570
|
+
}
|
|
1571
|
+
}
|
|
1572
|
+
const colStart = (0, _hooks.getFirstSelectCell)(selectedCells.current).col;
|
|
1573
|
+
const colEnd = (0, _hooks.getLastSelectCell)(selectedCells.current).col;
|
|
1574
|
+
const rowSelectedEnd = (0, _hooks.getLastSelectCell)(selectedCells.current).row;
|
|
1575
|
+
if (row >= rowSelectedEnd) {
|
|
1576
|
+
// kéo xuống dưới
|
|
1577
|
+
|
|
1578
|
+
const newPasteCells = new Set();
|
|
1579
|
+
for (let r = Math.min(startRow, row) + 1; r <= Math.max(startRow, row); r++) {
|
|
1580
|
+
for (let c = Math.min(colStart, col); c <= Math.max(colStart, colEnd); c++) {
|
|
1581
|
+
newPasteCells.add(`${r}-${c}`);
|
|
1582
|
+
}
|
|
1583
|
+
}
|
|
1584
|
+
|
|
1585
|
+
// setPasteCells(newPasteCells)
|
|
1586
|
+
|
|
1587
|
+
if (pasteCells.current && pasteCells.current.size > 0) {
|
|
1588
|
+
(0, _hooks.removeClassBorderPasteCell)(pasteCells.current, 'down', id);
|
|
1589
|
+
}
|
|
1590
|
+
pasteCells.current = newPasteCells;
|
|
1591
|
+
(0, _hooks.addClassBorderPasteCell)(newPasteCells, 'down', id);
|
|
1592
|
+
}
|
|
1593
|
+
if (row < rowSelectedEnd) {
|
|
1594
|
+
// kéo lên trên
|
|
1595
|
+
|
|
1596
|
+
const rowSelectedStart = (0, _hooks.getFirstSelectCell)(selectedCells.current).row;
|
|
1597
|
+
if (row < rowSelectedStart) {
|
|
1326
1598
|
const newPasteCells = new Set();
|
|
1327
1599
|
for (let r = Math.min(rowSelectedStart, row); r <= Math.max(rowSelectedStart, row) - 1; r++) {
|
|
1328
1600
|
for (let c = Math.min(colStart, col); c <= Math.max(colStart, colEnd); c++) {
|
|
@@ -1515,276 +1787,6 @@ const GridEdit = props => {
|
|
|
1515
1787
|
e.clipboardData.setData("text/plain", copyText);
|
|
1516
1788
|
(0, _Message.default)(t ? t('CopySuccessful') : 'Copy Successful');
|
|
1517
1789
|
};
|
|
1518
|
-
const handlePasted = (record, indexCol, rowNumber, pasteData) => {
|
|
1519
|
-
const rows = pasteData.slice(0, onCellPaste?.maxRowsPaste ?? 200);
|
|
1520
|
-
if (!record?.parentId) {
|
|
1521
|
-
// Cập nhật data mới
|
|
1522
|
-
const newData = [...dataSource];
|
|
1523
|
-
|
|
1524
|
-
// const indexRows = newData.findIndex((it) => it[rowKey as any] === record[rowKey])
|
|
1525
|
-
|
|
1526
|
-
// Lấy vị trí bắt đầu
|
|
1527
|
-
// const { row: startRow, col: startCol } = selectedCell;
|
|
1528
|
-
const startRow = newData.findIndex(it => it[rowKey] === record[rowKey]);
|
|
1529
|
-
const startCol = indexCol;
|
|
1530
|
-
|
|
1531
|
-
// const flattData = flattenArray(newData);
|
|
1532
|
-
|
|
1533
|
-
const pastedRows = [];
|
|
1534
|
-
const pastedColumns = new Set();
|
|
1535
|
-
rows.forEach((rowValues, rowIndex) => {
|
|
1536
|
-
const targetRow = startRow + rowIndex;
|
|
1537
|
-
|
|
1538
|
-
// Nếu vượt quá số dòng hiện có, thêm dòng mới
|
|
1539
|
-
if (targetRow >= newData.length) {
|
|
1540
|
-
// @ts-ignore
|
|
1541
|
-
// newData.push({ id: newGuid()});
|
|
1542
|
-
newData.push({
|
|
1543
|
-
id: undefined,
|
|
1544
|
-
rowId: (0, _hooks.newGuid)()
|
|
1545
|
-
});
|
|
1546
|
-
}
|
|
1547
|
-
rowValues.forEach((cellValue, colIndex) => {
|
|
1548
|
-
const targetCol = startCol + colIndex;
|
|
1549
|
-
if (targetCol >= visibleCols.length) {
|
|
1550
|
-
// Không vượt quá số cột
|
|
1551
|
-
return;
|
|
1552
|
-
}
|
|
1553
|
-
if (visibleCols[targetCol].editEnable) {
|
|
1554
|
-
// @ts-ignore
|
|
1555
|
-
const columnKey = visibleCols[targetCol].field;
|
|
1556
|
-
|
|
1557
|
-
// @ts-ignore
|
|
1558
|
-
newData[targetRow] = {
|
|
1559
|
-
...newData[targetRow],
|
|
1560
|
-
[columnKey]: cellValue.trim()
|
|
1561
|
-
};
|
|
1562
|
-
pastedColumns.add(columnKey);
|
|
1563
|
-
}
|
|
1564
|
-
});
|
|
1565
|
-
|
|
1566
|
-
// Lưu dòng được paste
|
|
1567
|
-
pastedRows.push(newData[targetRow]);
|
|
1568
|
-
});
|
|
1569
|
-
const pastedColumnsArray = Array.from(pastedColumns) ?? [];
|
|
1570
|
-
triggerPaste?.(pastedRows, pastedColumnsArray, newData);
|
|
1571
|
-
} else {
|
|
1572
|
-
// Cập nhật data mới
|
|
1573
|
-
const newData = [...dataSource];
|
|
1574
|
-
const parent = (0, _hooks.findItemByKey)(newData, rowKey, record.parentId);
|
|
1575
|
-
|
|
1576
|
-
// Cập nhật childData mới
|
|
1577
|
-
const childData = parent?.children ? [...parent.children] : [];
|
|
1578
|
-
|
|
1579
|
-
// Lấy vị trí bắt đầu
|
|
1580
|
-
// const { row: startRow, col: startCol } = selectedCell;
|
|
1581
|
-
const startRow = childData.findIndex(it => it[rowKey] === record[rowKey]);
|
|
1582
|
-
const startCol = indexCol;
|
|
1583
|
-
const pastedRows = [];
|
|
1584
|
-
const pastedColumns = new Set();
|
|
1585
|
-
rows.forEach((rowValues, rowIndex) => {
|
|
1586
|
-
const targetRow = startRow + rowIndex;
|
|
1587
|
-
|
|
1588
|
-
// Nếu vượt quá số dòng hiện có, thêm dòng mới
|
|
1589
|
-
if (targetRow >= childData.length) {
|
|
1590
|
-
childData.push({
|
|
1591
|
-
id: undefined,
|
|
1592
|
-
rowId: (0, _hooks.newGuid)(),
|
|
1593
|
-
parentId: parent[rowKey ?? 'id']
|
|
1594
|
-
});
|
|
1595
|
-
}
|
|
1596
|
-
rowValues.forEach((cellValue, colIndex) => {
|
|
1597
|
-
const targetCol = startCol + colIndex;
|
|
1598
|
-
if (targetCol >= visibleCols.length) {
|
|
1599
|
-
// Không vượt quá số cột
|
|
1600
|
-
return;
|
|
1601
|
-
}
|
|
1602
|
-
if (visibleCols[targetCol].editEnable) {
|
|
1603
|
-
// @ts-ignore
|
|
1604
|
-
const columnKey = visibleCols[targetCol].field;
|
|
1605
|
-
|
|
1606
|
-
// @ts-ignore
|
|
1607
|
-
childData[targetRow] = {
|
|
1608
|
-
...childData[targetRow],
|
|
1609
|
-
[columnKey]: cellValue.trim()
|
|
1610
|
-
};
|
|
1611
|
-
pastedColumns.add(columnKey);
|
|
1612
|
-
}
|
|
1613
|
-
});
|
|
1614
|
-
|
|
1615
|
-
// Lưu dòng được paste
|
|
1616
|
-
pastedRows.push(childData[targetRow]);
|
|
1617
|
-
});
|
|
1618
|
-
const pastedColumnsArray = Array.from(pastedColumns) ?? [];
|
|
1619
|
-
const newRowData = {
|
|
1620
|
-
...parent,
|
|
1621
|
-
children: childData
|
|
1622
|
-
};
|
|
1623
|
-
const newDataSource = (0, _hooks.updateArrayByKey)(newData, newRowData, rowKey);
|
|
1624
|
-
triggerPaste?.(pastedRows, pastedColumnsArray, newDataSource);
|
|
1625
|
-
}
|
|
1626
|
-
};
|
|
1627
|
-
const handlePaste = (record, indexCol, rowNumber, e) => {
|
|
1628
|
-
// const clipboard: any = (e.clipboardData || (window && window?.Clipboard)).getData("text")
|
|
1629
|
-
const pasteData = e.clipboardData.getData("text/plain");
|
|
1630
|
-
|
|
1631
|
-
// Chuyển đổi dữ liệu từ clipboard thành mảng
|
|
1632
|
-
const rowsPasted = pasteData.split("\n").map(row =>
|
|
1633
|
-
// const rows = pasteData.split("\n").map((row: any) =>
|
|
1634
|
-
row.replace(/\r/g, "").split("\t"));
|
|
1635
|
-
if (rowsPasted.length > (onCellPaste?.maxRowsPaste ?? 200)) {
|
|
1636
|
-
// bật popup thông báo
|
|
1637
|
-
|
|
1638
|
-
_antd.Modal.confirm({
|
|
1639
|
-
content: /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(Paragraph, {
|
|
1640
|
-
style: {
|
|
1641
|
-
marginBottom: '.25rem',
|
|
1642
|
-
fontSize: 14
|
|
1643
|
-
}
|
|
1644
|
-
}, "D\u1EEF li\u1EC7u sao ch\xE9p v\u01B0\u1EE3t qu\xE1 s\u1ED1 d\xF2ng cho ph\xE9p (500 d\xF2ng).Ph\u1EA7n m\u1EC1n s\u1EBD ch\u1EC9 l\u1EA5y 500 d\xF2ng \u0111\u1EA7u ti\xEAn."), /*#__PURE__*/_react.default.createElement(Title, {
|
|
1645
|
-
level: 5,
|
|
1646
|
-
style: {
|
|
1647
|
-
marginTop: '.75rem'
|
|
1648
|
-
}
|
|
1649
|
-
}, "B\u1EA1n c\xF3 mu\u1ED1n ti\u1EBFp t\u1EE5c sao ch\xE9p kh\xF4ng?")),
|
|
1650
|
-
centered: true,
|
|
1651
|
-
className: 'be-popup-container',
|
|
1652
|
-
onOk: () => {
|
|
1653
|
-
handlePasted(record, indexCol, rowNumber, rowsPasted);
|
|
1654
|
-
}
|
|
1655
|
-
// footer: (_, { OkBtn, CancelBtn }) => (
|
|
1656
|
-
// <>
|
|
1657
|
-
// <OkBtn />
|
|
1658
|
-
// <CancelBtn />
|
|
1659
|
-
// </>
|
|
1660
|
-
// ),
|
|
1661
|
-
});
|
|
1662
|
-
} else {
|
|
1663
|
-
handlePasted(record, indexCol, rowNumber, rowsPasted);
|
|
1664
|
-
}
|
|
1665
|
-
|
|
1666
|
-
// const rows = rowsPasted.slice(0, (onCellPaste?.maxRowsPaste ?? 200));
|
|
1667
|
-
//
|
|
1668
|
-
//
|
|
1669
|
-
// if (!record?.parentId ) {
|
|
1670
|
-
//
|
|
1671
|
-
// // Cập nhật data mới
|
|
1672
|
-
// const newData = [...dataSource];
|
|
1673
|
-
//
|
|
1674
|
-
// // @ts-ignore
|
|
1675
|
-
// const indexRows = newData.findIndex((it) => it[rowKey] === record[rowKey])
|
|
1676
|
-
//
|
|
1677
|
-
// // Lấy vị trí bắt đầu
|
|
1678
|
-
// // const { row: startRow, col: startCol } = selectedCell;
|
|
1679
|
-
// const startRow = indexRows
|
|
1680
|
-
// const startCol = indexCol
|
|
1681
|
-
//
|
|
1682
|
-
//
|
|
1683
|
-
//
|
|
1684
|
-
// // const flattData = flattenArray(newData);
|
|
1685
|
-
//
|
|
1686
|
-
// const pastedRows: RecordType[] = [];
|
|
1687
|
-
// const pastedColumns = new Set()
|
|
1688
|
-
//
|
|
1689
|
-
//
|
|
1690
|
-
// rows.forEach((rowValues: any, rowIndex: any) => {
|
|
1691
|
-
// const targetRow = startRow + rowIndex;
|
|
1692
|
-
//
|
|
1693
|
-
// // Nếu vượt quá số dòng hiện có, thêm dòng mới
|
|
1694
|
-
// if (targetRow >= newData.length) {
|
|
1695
|
-
// // @ts-ignore
|
|
1696
|
-
// // newData.push({ id: newGuid()});
|
|
1697
|
-
// newData.push({ id: undefined, rowId: newGuid()});
|
|
1698
|
-
// }
|
|
1699
|
-
//
|
|
1700
|
-
// rowValues.forEach((cellValue: any, colIndex: any) => {
|
|
1701
|
-
// const targetCol = startCol + colIndex;
|
|
1702
|
-
// if (targetCol >= columns.length) { // Không vượt quá số cột
|
|
1703
|
-
// return
|
|
1704
|
-
// }
|
|
1705
|
-
//
|
|
1706
|
-
// if (columns[targetCol].editEnable) {
|
|
1707
|
-
// // @ts-ignore
|
|
1708
|
-
// const columnKey = columns[targetCol].field;
|
|
1709
|
-
//
|
|
1710
|
-
// // @ts-ignore
|
|
1711
|
-
// newData[targetRow] = { ...newData[targetRow], [columnKey]: cellValue.trim() };
|
|
1712
|
-
// pastedColumns.add(columnKey);
|
|
1713
|
-
// }
|
|
1714
|
-
//
|
|
1715
|
-
// });
|
|
1716
|
-
//
|
|
1717
|
-
// // Lưu dòng được paste
|
|
1718
|
-
// pastedRows.push(newData[targetRow]);
|
|
1719
|
-
//
|
|
1720
|
-
// });
|
|
1721
|
-
//
|
|
1722
|
-
// const pastedColumnsArray = Array.from(pastedColumns) ?? [];
|
|
1723
|
-
//
|
|
1724
|
-
// triggerPaste?.(pastedRows, pastedColumnsArray as string[], newData)
|
|
1725
|
-
//
|
|
1726
|
-
//
|
|
1727
|
-
// } else {
|
|
1728
|
-
//
|
|
1729
|
-
// // Cập nhật data mới
|
|
1730
|
-
// const newData = [...dataSource];
|
|
1731
|
-
//
|
|
1732
|
-
// const parent = findItemByKey(newData, rowKey as any, record.parentId)
|
|
1733
|
-
//
|
|
1734
|
-
// // Cập nhật childData mới
|
|
1735
|
-
// const childData: any[] = parent?.children ? [...parent.children] : []
|
|
1736
|
-
//
|
|
1737
|
-
//
|
|
1738
|
-
// // Lấy vị trí bắt đầu
|
|
1739
|
-
// // const { row: startRow, col: startCol } = selectedCell;
|
|
1740
|
-
// const startRow = childData.findIndex((it) => it[rowKey] === record[rowKey])
|
|
1741
|
-
// const startCol = indexCol
|
|
1742
|
-
//
|
|
1743
|
-
// const pastedRows: RecordType[] = []
|
|
1744
|
-
// const pastedColumns = new Set()
|
|
1745
|
-
//
|
|
1746
|
-
//
|
|
1747
|
-
// rows.forEach((rowValues: any, rowIndex: any) => {
|
|
1748
|
-
// const targetRow = startRow + rowIndex
|
|
1749
|
-
//
|
|
1750
|
-
// // Nếu vượt quá số dòng hiện có, thêm dòng mới
|
|
1751
|
-
// if (targetRow >= childData.length) {
|
|
1752
|
-
//
|
|
1753
|
-
// childData.push({ id: undefined, rowId: newGuid(), parentId: parent[rowKey ?? 'id']})
|
|
1754
|
-
// }
|
|
1755
|
-
//
|
|
1756
|
-
// rowValues.forEach((cellValue: any, colIndex: any) => {
|
|
1757
|
-
// const targetCol = startCol + colIndex
|
|
1758
|
-
// if (targetCol >= columns.length) { // Không vượt quá số cột
|
|
1759
|
-
// return
|
|
1760
|
-
// }
|
|
1761
|
-
//
|
|
1762
|
-
// if (columns[targetCol].editEnable) {
|
|
1763
|
-
//
|
|
1764
|
-
// // @ts-ignore
|
|
1765
|
-
// const columnKey = columns[targetCol].field
|
|
1766
|
-
//
|
|
1767
|
-
// // @ts-ignore
|
|
1768
|
-
// childData[targetRow] = { ...childData[targetRow], [columnKey]: cellValue.trim() }
|
|
1769
|
-
// pastedColumns.add(columnKey)
|
|
1770
|
-
// }
|
|
1771
|
-
//
|
|
1772
|
-
// })
|
|
1773
|
-
//
|
|
1774
|
-
// // Lưu dòng được paste
|
|
1775
|
-
// pastedRows.push(childData[targetRow])
|
|
1776
|
-
//
|
|
1777
|
-
// })
|
|
1778
|
-
//
|
|
1779
|
-
// const pastedColumnsArray = Array.from(pastedColumns) ?? []
|
|
1780
|
-
//
|
|
1781
|
-
// const newRowData = {...parent, children: childData}
|
|
1782
|
-
//
|
|
1783
|
-
// const newDataSource = updateArrayByKey(newData, newRowData, rowKey as string)
|
|
1784
|
-
//
|
|
1785
|
-
// triggerPaste?.(pastedRows, pastedColumnsArray as string[], newDataSource )
|
|
1786
|
-
// }
|
|
1787
|
-
};
|
|
1788
1790
|
const onSubmit = formData => {
|
|
1789
1791
|
try {
|
|
1790
1792
|
// const record = (await form.validateFields()) as RecordType;
|