linkmore-design 1.1.1 → 1.1.2
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/dist/LmTable/components/tableChartsModal.d.ts +2 -0
- package/dist/LmTable/util.d.ts +18 -6
- package/dist/index.umd.js +376 -255
- package/dist/index.umd.min.js +4 -4
- package/es/LmTable/Table.js +187 -135
- package/es/LmTable/components/sheelTableCell.js +10 -6
- package/es/LmTable/components/sortableItemCol.js +3 -1
- package/es/LmTable/components/tableChartsModal.d.ts +2 -0
- package/es/LmTable/components/tableChartsModal.js +31 -5
- package/es/LmTable/util.js +94 -27
- package/lib/LmTable/Table.js +187 -135
- package/lib/LmTable/components/sheelTableCell.js +10 -6
- package/lib/LmTable/components/sortableItemCol.js +3 -1
- package/lib/LmTable/components/tableChartsModal.d.ts +2 -0
- package/lib/LmTable/components/tableChartsModal.js +33 -4
- package/lib/LmTable/util.js +94 -27
- package/package.json +2 -1
- package/dist/LmTable/test/index.d.ts +0 -100
- package/es/LmTable/test/index.js +0 -254
- package/lib/LmTable/test/index.js +0 -254
package/es/LmTable/Table.js
CHANGED
|
@@ -171,12 +171,6 @@ var ResetTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
171
171
|
|
|
172
172
|
var deepDataSourceRef = (0, _react.useRef)([]);
|
|
173
173
|
var deepColumnsRef = (0, _react.useRef)([]);
|
|
174
|
-
/** 行分组表格对应数据的隐藏数列表 */
|
|
175
|
-
|
|
176
|
-
var hideListRef = (0, _react.useRef)([]);
|
|
177
|
-
/** 行分组的空行列表数据 */
|
|
178
|
-
|
|
179
|
-
var skipListRef = (0, _react.useRef)([]);
|
|
180
174
|
/** 记录最原始数据 */
|
|
181
175
|
|
|
182
176
|
(0, _react.useEffect)(function () {
|
|
@@ -210,8 +204,7 @@ var ResetTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
210
204
|
setExpandedRowKeys([]);
|
|
211
205
|
deepDataSourceRef.current = [];
|
|
212
206
|
deepColumnsRef.current = [];
|
|
213
|
-
|
|
214
|
-
}, [groupRowKeys]);
|
|
207
|
+
}, [groupRowKeys, groupColKeys]);
|
|
215
208
|
/** sheel数据的表格 */
|
|
216
209
|
|
|
217
210
|
var _useState9 = (0, _react.useState)({
|
|
@@ -295,46 +288,18 @@ var ResetTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
295
288
|
(0, _react.useEffect)(function () {
|
|
296
289
|
var source = [];
|
|
297
290
|
|
|
298
|
-
var dfs = function dfs(children) {
|
|
299
|
-
var num = 0;
|
|
300
|
-
children.forEach(function (item) {
|
|
301
|
-
if (item.children) {
|
|
302
|
-
num += dfs(item.children);
|
|
303
|
-
} else {
|
|
304
|
-
num += 1;
|
|
305
|
-
}
|
|
306
|
-
});
|
|
307
|
-
return num;
|
|
308
|
-
};
|
|
309
|
-
|
|
310
|
-
var hideList = [];
|
|
311
|
-
|
|
312
291
|
var deepChildren = function deepChildren(arr) {
|
|
313
292
|
arr.forEach(function (item) {
|
|
314
|
-
source.push((0, _lodash.omit)(item, 'children'));
|
|
315
|
-
var prev = hideList.length ? hideList[hideList.length - 1] : 0; // 展开
|
|
293
|
+
source.push((0, _lodash.omit)(item, 'children')); // 展开
|
|
316
294
|
|
|
317
295
|
if ((item === null || item === void 0 ? void 0 : item.children) && expandedRowKeys.includes(item.key)) {
|
|
318
|
-
hideList.push(prev);
|
|
319
296
|
deepChildren(item === null || item === void 0 ? void 0 : item.children);
|
|
320
|
-
} // 隐藏
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
if ((item === null || item === void 0 ? void 0 : item.children) && !expandedRowKeys.includes(item.key)) {
|
|
324
|
-
var count = dfs(item.children);
|
|
325
|
-
hideList.push(count + prev);
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
if (!(item === null || item === void 0 ? void 0 : item.children)) {
|
|
329
|
-
hideList.push(prev);
|
|
330
297
|
}
|
|
331
298
|
});
|
|
332
299
|
};
|
|
333
300
|
|
|
334
301
|
deepChildren(dataSource);
|
|
335
302
|
deepDataSourceRef.current = source;
|
|
336
|
-
hideListRef.current = hideList;
|
|
337
|
-
skipListRef.current = (0, _util.getSkipList)((groupRowKeys === null || groupRowKeys === void 0 ? void 0 : groupRowKeys.length) ? deepDataSourceRef.current : dataSource);
|
|
338
303
|
}, [dataSource, expandedRowKeys]); // 列分组数据铺平,在框选时获取数据使用
|
|
339
304
|
|
|
340
305
|
(0, _react.useEffect)(function () {
|
|
@@ -444,7 +409,11 @@ var ResetTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
444
409
|
isEditing: (editing === null || editing === void 0 ? void 0 : editing.i) === i && (editing === null || editing === void 0 ? void 0 : editing.j) === j,
|
|
445
410
|
|
|
446
411
|
/** 是否有效拉伸 */
|
|
447
|
-
isVaildCommit: isEmpty(commiting) ? false : isSelected && !(0, _util.checkIsSelectd)(i, j, commiting === null || commiting === void 0 ? void 0 : commiting.start, commiting === null || commiting === void 0 ? void 0 : commiting.end)
|
|
412
|
+
isVaildCommit: isEmpty(commiting) ? false : isSelected && !(0, _util.checkIsSelectd)(i, j, commiting === null || commiting === void 0 ? void 0 : commiting.start, commiting === null || commiting === void 0 ? void 0 : commiting.end),
|
|
413
|
+
|
|
414
|
+
/** 是否选中只读框 */
|
|
415
|
+
// TODO
|
|
416
|
+
selectedReadonly: true
|
|
448
417
|
};
|
|
449
418
|
};
|
|
450
419
|
/** 获取框选的数据 */
|
|
@@ -473,40 +442,36 @@ var ResetTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
473
442
|
|
|
474
443
|
|
|
475
444
|
var handleCopy = function handleCopy(e) {
|
|
476
|
-
var
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
e.clipboardData.setData('text/plain', text);
|
|
491
|
-
} else {
|
|
492
|
-
var _document;
|
|
445
|
+
var _e$clipboardData;
|
|
446
|
+
|
|
447
|
+
e === null || e === void 0 ? void 0 : e.preventDefault();
|
|
448
|
+
var _shellStatusRef$curre2 = shellStatusRef.current,
|
|
449
|
+
start = _shellStatusRef$curre2.start,
|
|
450
|
+
end = _shellStatusRef$curre2.end;
|
|
451
|
+
var text = getSelectDatas(start, end);
|
|
452
|
+
|
|
453
|
+
if (window.clipboardData && window.clipboardData.setData) {
|
|
454
|
+
window.clipboardData.setData('Text', text);
|
|
455
|
+
} else if ((_e$clipboardData = e.clipboardData) === null || _e$clipboardData === void 0 ? void 0 : _e$clipboardData.setData) {
|
|
456
|
+
e.clipboardData.setData('text/plain', text);
|
|
457
|
+
} else {
|
|
458
|
+
var _document;
|
|
493
459
|
|
|
494
|
-
|
|
460
|
+
(_document = document) === null || _document === void 0 ? void 0 : _document.execCommand('copy');
|
|
495
461
|
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
}
|
|
462
|
+
if (contextMenuStatus) {
|
|
463
|
+
setContextMenuStatus(false);
|
|
499
464
|
}
|
|
500
465
|
}
|
|
501
466
|
};
|
|
502
467
|
|
|
503
468
|
var onMouseOver = function onMouseOver(i, j) {
|
|
504
|
-
var _shellStatusRef$
|
|
469
|
+
var _shellStatusRef$curre3, _shellStatusRef$curre6, _checkStatus, _shellStatusRef$curre7;
|
|
505
470
|
|
|
506
|
-
if (isEmpty(shellStatusRef === null || shellStatusRef === void 0 ? void 0 : (_shellStatusRef$
|
|
507
|
-
var _shellStatusRef$
|
|
471
|
+
if (isEmpty(shellStatusRef === null || shellStatusRef === void 0 ? void 0 : (_shellStatusRef$curre3 = shellStatusRef.current) === null || _shellStatusRef$curre3 === void 0 ? void 0 : _shellStatusRef$curre3.commiting)) {
|
|
472
|
+
var _shellStatusRef$curre4, _shellStatusRef$curre5;
|
|
508
473
|
|
|
509
|
-
if ((shellStatusRef === null || shellStatusRef === void 0 ? void 0 : (_shellStatusRef$
|
|
474
|
+
if ((shellStatusRef === null || shellStatusRef === void 0 ? void 0 : (_shellStatusRef$curre4 = shellStatusRef.current) === null || _shellStatusRef$curre4 === void 0 ? void 0 : _shellStatusRef$curre4.selecting) && isEmpty(shellStatusRef === null || shellStatusRef === void 0 ? void 0 : (_shellStatusRef$curre5 = shellStatusRef.current) === null || _shellStatusRef$curre5 === void 0 ? void 0 : _shellStatusRef$curre5.editing)) {
|
|
510
475
|
shellStatusRef.current = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, shellStatusRef.current), {}, {
|
|
511
476
|
end: {
|
|
512
477
|
i: i,
|
|
@@ -520,7 +485,15 @@ var ResetTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
520
485
|
}
|
|
521
486
|
}));
|
|
522
487
|
}
|
|
523
|
-
} else if (!isEmpty((shellStatusRef === null || shellStatusRef === void 0 ? void 0 : (_shellStatusRef$
|
|
488
|
+
} else if (!isEmpty((shellStatusRef === null || shellStatusRef === void 0 ? void 0 : (_shellStatusRef$curre6 = shellStatusRef.current) === null || _shellStatusRef$curre6 === void 0 ? void 0 : _shellStatusRef$curre6.commiting) || {}) && ((_checkStatus = (0, _util.checkStatus)(i, j, shellStatusRef === null || shellStatusRef === void 0 ? void 0 : (_shellStatusRef$curre7 = shellStatusRef.current) === null || _shellStatusRef$curre7 === void 0 ? void 0 : _shellStatusRef$curre7.commiting)) === null || _checkStatus === void 0 ? void 0 : _checkStatus.isVaildCommit)) {
|
|
489
|
+
if ((0, _util.isSelectCrossRowGroup)(i, shellStatusRef, deepDataSourceRef)) {
|
|
490
|
+
return;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
if ((0, _util.isSelectCrossInvalidCol)(i, j, shellStatusRef, deepDataSourceRef, deepColumnsRef)) {
|
|
494
|
+
return;
|
|
495
|
+
}
|
|
496
|
+
|
|
524
497
|
shellStatusRef.current = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, shellStatusRef.current), {}, {
|
|
525
498
|
end: {
|
|
526
499
|
i: i,
|
|
@@ -534,6 +507,49 @@ var ResetTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
534
507
|
}
|
|
535
508
|
}));
|
|
536
509
|
}
|
|
510
|
+
}; // 通过表格的行列索引,获取对应的原始数据的item信息
|
|
511
|
+
|
|
512
|
+
|
|
513
|
+
var getSourceItemInfo = function getSourceItemInfo(trIndex, tdIndex) {
|
|
514
|
+
var innerColumns = (groupColKeys === null || groupColKeys === void 0 ? void 0 : groupColKeys.length) ? deepColumnsRef.current : columns;
|
|
515
|
+
var columnsKeysList = innerColumns.map(function (item) {
|
|
516
|
+
return item.dataIndex;
|
|
517
|
+
});
|
|
518
|
+
var key = columnsKeysList[tdIndex];
|
|
519
|
+
var index;
|
|
520
|
+
var nil = {
|
|
521
|
+
index: -1,
|
|
522
|
+
key: undefined
|
|
523
|
+
};
|
|
524
|
+
|
|
525
|
+
if (key === undefined) {
|
|
526
|
+
return nil;
|
|
527
|
+
} // 列分组的情况下
|
|
528
|
+
|
|
529
|
+
|
|
530
|
+
if (groupColKeys === null || groupColKeys === void 0 ? void 0 : groupColKeys.length) {
|
|
531
|
+
var _deepDataSourceRef$cu;
|
|
532
|
+
|
|
533
|
+
if ((groupRowKeys === null || groupRowKeys === void 0 ? void 0 : groupRowKeys.length) && (deepDataSourceRef === null || deepDataSourceRef === void 0 ? void 0 : (_deepDataSourceRef$cu = deepDataSourceRef.current) === null || _deepDataSourceRef$cu === void 0 ? void 0 : _deepDataSourceRef$cu[trIndex]._group)) {
|
|
534
|
+
return nil;
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
index = (0, _util.getDataSourceIndex)({
|
|
538
|
+
key: key,
|
|
539
|
+
dataSource: dataSource
|
|
540
|
+
});
|
|
541
|
+
var arr = key.split('_');
|
|
542
|
+
key = arr[arr.length - 2];
|
|
543
|
+
} else if (groupRowKeys.length) {
|
|
544
|
+
index = deepDataSourceRef.current[trIndex].__index;
|
|
545
|
+
} else {
|
|
546
|
+
index = trIndex;
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
return {
|
|
550
|
+
index: index,
|
|
551
|
+
key: key
|
|
552
|
+
};
|
|
537
553
|
};
|
|
538
554
|
/** sheel 表格 鼠标松开 */
|
|
539
555
|
|
|
@@ -541,28 +557,29 @@ var ResetTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
541
557
|
|
|
542
558
|
|
|
543
559
|
var sheelOnMouseUp = function sheelOnMouseUp() {
|
|
544
|
-
var _shellStatusRef$
|
|
560
|
+
var _shellStatusRef$curre8;
|
|
545
561
|
|
|
546
|
-
if (!isEmpty((_shellStatusRef$
|
|
562
|
+
if (!isEmpty((_shellStatusRef$curre8 = shellStatusRef.current) === null || _shellStatusRef$curre8 === void 0 ? void 0 : _shellStatusRef$curre8.commiting)) {
|
|
547
563
|
var _commiting$start, _commiting$end, _commiting$start2, _commiting$end2, _difference, _difference2, _obj$i;
|
|
548
564
|
|
|
549
|
-
var _shellStatusRef$
|
|
550
|
-
start = _shellStatusRef$
|
|
551
|
-
end = _shellStatusRef$
|
|
552
|
-
commiting = _shellStatusRef$
|
|
565
|
+
var _shellStatusRef$curre9 = shellStatusRef.current,
|
|
566
|
+
start = _shellStatusRef$curre9.start,
|
|
567
|
+
end = _shellStatusRef$curre9.end,
|
|
568
|
+
commiting = _shellStatusRef$curre9.commiting; //
|
|
553
569
|
|
|
554
570
|
var innerColumns = (groupColKeys === null || groupColKeys === void 0 ? void 0 : groupColKeys.length) ? deepColumnsRef.current : columns;
|
|
555
571
|
var innerDataSource = (groupRowKeys === null || groupRowKeys === void 0 ? void 0 : groupRowKeys.length) ? deepDataSourceRef.current : dataSource; //
|
|
556
572
|
|
|
557
573
|
var columnsKeysList = innerColumns.map(function (item) {
|
|
558
574
|
return item.dataIndex;
|
|
559
|
-
}); //
|
|
575
|
+
}); // 行文本
|
|
560
576
|
|
|
561
577
|
var rowtext = (0, _util.getSelectionRowText)({
|
|
562
578
|
selection: commiting,
|
|
563
579
|
columnsKeysList: columnsKeysList,
|
|
564
580
|
dataSource: innerDataSource
|
|
565
|
-
});
|
|
581
|
+
}); // 列文本
|
|
582
|
+
|
|
566
583
|
var coltext = (0, _util.getSelectionColText)({
|
|
567
584
|
selection: commiting,
|
|
568
585
|
columns: innerColumns,
|
|
@@ -609,20 +626,17 @@ var ResetTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
609
626
|
var _isSelected;
|
|
610
627
|
|
|
611
628
|
if ((_isSelected = isSelected(tri, tdj)) === null || _isSelected === void 0 ? void 0 : _isSelected.isSelected) {
|
|
612
|
-
var
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
if (
|
|
616
|
-
|
|
617
|
-
key: key,
|
|
618
|
-
dataSource: dataSource
|
|
619
|
-
});
|
|
620
|
-
var arr = key.split('_');
|
|
621
|
-
key = arr[arr.length - 2];
|
|
622
|
-
} else {
|
|
623
|
-
sourceIndex = tri - skipListRef.current[tri] + hideListRef.current[tri];
|
|
629
|
+
var _deepColumnsRef$curre, _deepColumnsRef$curre2;
|
|
630
|
+
|
|
631
|
+
// 只读列无法修改其内容
|
|
632
|
+
if (deepColumnsRef === null || deepColumnsRef === void 0 ? void 0 : (_deepColumnsRef$curre = deepColumnsRef.current) === null || _deepColumnsRef$curre === void 0 ? void 0 : (_deepColumnsRef$curre2 = _deepColumnsRef$curre[tdj]) === null || _deepColumnsRef$curre2 === void 0 ? void 0 : _deepColumnsRef$curre2.readOnly) {
|
|
633
|
+
return;
|
|
624
634
|
}
|
|
625
635
|
|
|
636
|
+
var _getSourceItemInfo = getSourceItemInfo(tri, tdj),
|
|
637
|
+
sourceIndex = _getSourceItemInfo.index,
|
|
638
|
+
key = _getSourceItemInfo.key;
|
|
639
|
+
|
|
626
640
|
if (sourceIndex < 0 || sourceIndex >= data.length) {
|
|
627
641
|
return;
|
|
628
642
|
} // 行替换
|
|
@@ -670,9 +684,9 @@ var ResetTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
670
684
|
|
|
671
685
|
|
|
672
686
|
var handleCut = function handleCut(e) {
|
|
673
|
-
var _shellStatusRef$
|
|
687
|
+
var _shellStatusRef$curre10;
|
|
674
688
|
|
|
675
|
-
if (isEmpty((_shellStatusRef$
|
|
689
|
+
if (isEmpty((_shellStatusRef$curre10 = shellStatusRef.current) === null || _shellStatusRef$curre10 === void 0 ? void 0 : _shellStatusRef$curre10.editing)) {
|
|
676
690
|
e.preventDefault();
|
|
677
691
|
handleCopy(e);
|
|
678
692
|
/** 暂时先不隐藏 */
|
|
@@ -685,42 +699,70 @@ var ResetTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
685
699
|
/** TODO: 在分组的情况,需要排除_group行的数据转换 */
|
|
686
700
|
|
|
687
701
|
|
|
688
|
-
var handlePaste = function handlePaste(e) {
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
702
|
+
var handlePaste = function handlePaste(e) {
|
|
703
|
+
var _shellStatusRef$curre11;
|
|
704
|
+
|
|
705
|
+
if (isEmpty((_shellStatusRef$curre11 = shellStatusRef.current) === null || _shellStatusRef$curre11 === void 0 ? void 0 : _shellStatusRef$curre11.editing)) {
|
|
706
|
+
var _shellStatusRef$curre12 = shellStatusRef.current,
|
|
707
|
+
start = _shellStatusRef$curre12.start,
|
|
708
|
+
end = _shellStatusRef$curre12.end;
|
|
709
|
+
start = {
|
|
710
|
+
i: Math.min(start.i, end.i),
|
|
711
|
+
j: Math.min(start.j, end.j)
|
|
712
|
+
};
|
|
713
|
+
end = {
|
|
714
|
+
i: Math.max(start.i, end.i),
|
|
715
|
+
j: Math.max(start.j, end.j)
|
|
716
|
+
};
|
|
717
|
+
var parse = defaultParsePaste;
|
|
718
|
+
var pasteData = [];
|
|
719
|
+
|
|
720
|
+
if (window.clipboardData && window.clipboardData.getData) {
|
|
721
|
+
// IE
|
|
722
|
+
pasteData = parse(window.clipboardData.getData('Text'));
|
|
723
|
+
} else if (e.clipboardData && e.clipboardData.getData) {
|
|
724
|
+
pasteData = parse(e.clipboardData.getData('text/plain'));
|
|
725
|
+
} // in order of preference
|
|
726
|
+
|
|
727
|
+
|
|
728
|
+
var resultEnd = [];
|
|
729
|
+
pasteData.forEach(function (row, i) {
|
|
730
|
+
row.forEach(function (value, j) {
|
|
731
|
+
resultEnd.push({
|
|
732
|
+
i: start.i + i,
|
|
733
|
+
j: start.j + j,
|
|
734
|
+
value: value
|
|
735
|
+
});
|
|
736
|
+
});
|
|
737
|
+
});
|
|
738
|
+
var res = (0, _immer.produce)(dataSourceRef.current, function (draft) {
|
|
739
|
+
resultEnd.forEach(function (item) {
|
|
740
|
+
var _isSelected2;
|
|
741
|
+
|
|
742
|
+
if ((_isSelected2 = isSelected(item.i, item.j)) === null || _isSelected2 === void 0 ? void 0 : _isSelected2.isSelected) {
|
|
743
|
+
var _getSourceItemInfo2 = getSourceItemInfo(item.i, item.j),
|
|
744
|
+
index = _getSourceItemInfo2.index,
|
|
745
|
+
key = _getSourceItemInfo2.key;
|
|
746
|
+
|
|
747
|
+
if (index < 0 || index >= draft.length) {
|
|
748
|
+
return;
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
draft[index][key] = item.value;
|
|
752
|
+
}
|
|
753
|
+
});
|
|
754
|
+
});
|
|
755
|
+
/** 只有开通了编辑权限之后才可以 */
|
|
756
|
+
|
|
757
|
+
if (editSheet) {
|
|
758
|
+
dataChange === null || dataChange === void 0 ? void 0 : dataChange(res);
|
|
759
|
+
}
|
|
760
|
+
} // 修复重复问题
|
|
761
|
+
|
|
762
|
+
|
|
763
|
+
document.removeEventListener('paste', handlePaste);
|
|
764
|
+
document.removeEventListener('copy', handleCopy);
|
|
765
|
+
document.removeEventListener('cut', handleCut);
|
|
724
766
|
};
|
|
725
767
|
|
|
726
768
|
var pageClick = function pageClick(e) {
|
|
@@ -764,13 +806,13 @@ var ResetTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
764
806
|
|
|
765
807
|
|
|
766
808
|
var sheelMouseDown = function sheelMouseDown(i, j, e, commitStatus) {
|
|
767
|
-
var _shellStatusRef$
|
|
809
|
+
var _shellStatusRef$curre13, _shellStatusRef$curre14, _shellStatusRef$curre15, _shellStatusRef$curre16, _shellStatusRef$curre17, _shellStatusRef$curre18, _shellStatusRef$curre19, _shellStatusRef$curre20, _shellStatusRef$curre21, _shellStatusRef$curre22;
|
|
768
810
|
|
|
769
|
-
var isNowEditingSameCell = !isEmpty((_shellStatusRef$
|
|
770
|
-
var editing = isEmpty((_shellStatusRef$
|
|
811
|
+
var isNowEditingSameCell = !isEmpty((_shellStatusRef$curre13 = shellStatusRef.current) === null || _shellStatusRef$curre13 === void 0 ? void 0 : _shellStatusRef$curre13.editing) && ((_shellStatusRef$curre14 = shellStatusRef.current) === null || _shellStatusRef$curre14 === void 0 ? void 0 : _shellStatusRef$curre14.editing.i) === i && ((_shellStatusRef$curre15 = shellStatusRef.current) === null || _shellStatusRef$curre15 === void 0 ? void 0 : _shellStatusRef$curre15.editing.j) === j;
|
|
812
|
+
var editing = isEmpty((_shellStatusRef$curre16 = shellStatusRef.current) === null || _shellStatusRef$curre16 === void 0 ? void 0 : _shellStatusRef$curre16.editing) || ((_shellStatusRef$curre17 = shellStatusRef.current) === null || _shellStatusRef$curre17 === void 0 ? void 0 : _shellStatusRef$curre17.editing.i) !== i || ((_shellStatusRef$curre18 = shellStatusRef.current) === null || _shellStatusRef$curre18 === void 0 ? void 0 : _shellStatusRef$curre18.editing.j) !== j ? {} : (_shellStatusRef$curre19 = shellStatusRef.current) === null || _shellStatusRef$curre19 === void 0 ? void 0 : _shellStatusRef$curre19.editing;
|
|
771
813
|
shellStatusRef.current = {
|
|
772
814
|
selecting: !isNowEditingSameCell,
|
|
773
|
-
start: (e === null || e === void 0 ? void 0 : e.shiftKey) || commitStatus ? (_shellStatusRef$
|
|
815
|
+
start: (e === null || e === void 0 ? void 0 : e.shiftKey) || commitStatus ? (_shellStatusRef$curre20 = shellStatusRef.current) === null || _shellStatusRef$curre20 === void 0 ? void 0 : _shellStatusRef$curre20.start : {
|
|
774
816
|
i: i,
|
|
775
817
|
j: j
|
|
776
818
|
},
|
|
@@ -781,7 +823,7 @@ var ResetTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
781
823
|
editing: editing,
|
|
782
824
|
forceEdit: !!isNowEditingSameCell,
|
|
783
825
|
commiting: commitStatus ? {
|
|
784
|
-
start: (_shellStatusRef$
|
|
826
|
+
start: (_shellStatusRef$curre21 = shellStatusRef.current) === null || _shellStatusRef$curre21 === void 0 ? void 0 : _shellStatusRef$curre21.start,
|
|
785
827
|
end: {
|
|
786
828
|
i: i,
|
|
787
829
|
j: j
|
|
@@ -794,7 +836,7 @@ var ResetTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
794
836
|
setCommitIng(true);
|
|
795
837
|
}
|
|
796
838
|
|
|
797
|
-
if (isEmpty((_shellStatusRef$
|
|
839
|
+
if (isEmpty((_shellStatusRef$curre22 = shellStatusRef.current) === null || _shellStatusRef$curre22 === void 0 ? void 0 : _shellStatusRef$curre22.editing)) {
|
|
798
840
|
setEditIng(false);
|
|
799
841
|
}
|
|
800
842
|
|
|
@@ -809,9 +851,9 @@ var ResetTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
809
851
|
|
|
810
852
|
var onContextMenu = function onContextMenu(evt, i, j) {
|
|
811
853
|
evt.preventDefault();
|
|
812
|
-
var _shellStatusRef$
|
|
813
|
-
start = _shellStatusRef$
|
|
814
|
-
end = _shellStatusRef$
|
|
854
|
+
var _shellStatusRef$curre23 = shellStatusRef.current,
|
|
855
|
+
start = _shellStatusRef$curre23.start,
|
|
856
|
+
end = _shellStatusRef$curre23.end;
|
|
815
857
|
/** 如果表格当前没有选择,则把当前的右击的td块默认选中 */
|
|
816
858
|
|
|
817
859
|
if (isEmpty(start) && isEmpty(end)) {
|
|
@@ -863,11 +905,18 @@ var ResetTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
863
905
|
}
|
|
864
906
|
};
|
|
865
907
|
|
|
866
|
-
var dataSourceChange = function dataSourceChange(i, j,
|
|
867
|
-
|
|
868
|
-
|
|
908
|
+
var dataSourceChange = function dataSourceChange(i, j, value) {
|
|
909
|
+
var _getSourceItemInfo3 = getSourceItemInfo(i, j),
|
|
910
|
+
index = _getSourceItemInfo3.index,
|
|
911
|
+
key = _getSourceItemInfo3.key;
|
|
912
|
+
|
|
913
|
+
if (index < 0 || index >= dataSourceRef.current.length) {
|
|
914
|
+
return;
|
|
915
|
+
} // 表格中的行数 转化为 对应的数据源索引
|
|
916
|
+
|
|
917
|
+
|
|
869
918
|
var res = (0, _immer.produce)(dataSourceRef.current, function (draft) {
|
|
870
|
-
draft[
|
|
919
|
+
draft[index][key] = value;
|
|
871
920
|
});
|
|
872
921
|
dataChange === null || dataChange === void 0 ? void 0 : dataChange(res);
|
|
873
922
|
shellStatusRef.current = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, shellStatusRef.current), {}, {
|
|
@@ -897,6 +946,7 @@ var ResetTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
897
946
|
|
|
898
947
|
if (col.children && col.children.length) {
|
|
899
948
|
traverseColumns(col.children);
|
|
949
|
+
return;
|
|
900
950
|
} else {
|
|
901
951
|
// $_ 开头表示私有属性
|
|
902
952
|
col.$_colIndex = colIndex;
|
|
@@ -1333,6 +1383,8 @@ var ResetTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
1333
1383
|
return setChartsModalStatus(false);
|
|
1334
1384
|
},
|
|
1335
1385
|
data: dataSource,
|
|
1386
|
+
deepDataSource: deepDataSourceRef.current,
|
|
1387
|
+
rowKey: rowKey,
|
|
1336
1388
|
columns: columns,
|
|
1337
1389
|
selectInfo: (0, _lodash.pick)(shellStatusRef.current, ['start', 'end'])
|
|
1338
1390
|
}));
|
|
@@ -42,7 +42,7 @@ var SheelTabelCell = function SheelTabelCell(props) {
|
|
|
42
42
|
|
|
43
43
|
var _ref = (isSelected === null || isSelected === void 0 ? void 0 : isSelected(rowIndex, colIndex)) || {},
|
|
44
44
|
_ref$isSelected = _ref.isSelected,
|
|
45
|
-
|
|
45
|
+
_selected = _ref$isSelected === void 0 ? false : _ref$isSelected,
|
|
46
46
|
_ref$isEnd = _ref.isEnd,
|
|
47
47
|
isEnd = _ref$isEnd === void 0 ? false : _ref$isEnd,
|
|
48
48
|
_ref$isRightEnd = _ref.isRightEnd,
|
|
@@ -50,7 +50,9 @@ var SheelTabelCell = function SheelTabelCell(props) {
|
|
|
50
50
|
_ref$isEditing = _ref.isEditing,
|
|
51
51
|
isEditing = _ref$isEditing === void 0 ? false : _ref$isEditing,
|
|
52
52
|
_ref$isVaildCommit = _ref.isVaildCommit,
|
|
53
|
-
isVaildCommit = _ref$isVaildCommit === void 0 ? false : _ref$isVaildCommit
|
|
53
|
+
isVaildCommit = _ref$isVaildCommit === void 0 ? false : _ref$isVaildCommit,
|
|
54
|
+
_ref$selectedReadonly = _ref.selectedReadonly,
|
|
55
|
+
selectedReadonly = _ref$selectedReadonly === void 0 ? false : _ref$selectedReadonly;
|
|
54
56
|
|
|
55
57
|
var _useState = useState((record === null || record === void 0 ? void 0 : record[col === null || col === void 0 ? void 0 : col.dataIndex]) || ''),
|
|
56
58
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -118,13 +120,12 @@ var SheelTabelCell = function SheelTabelCell(props) {
|
|
|
118
120
|
|
|
119
121
|
var saveRenderValue = function saveRenderValue() {
|
|
120
122
|
if (valueRef.current !== (record === null || record === void 0 ? void 0 : record[col === null || col === void 0 ? void 0 : col.dataIndex])) {
|
|
121
|
-
dataSourceChange === null || dataSourceChange === void 0 ? void 0 : dataSourceChange(rowIndex, colIndex, Object.assign(Object.assign({}, record), _defineProperty({}, col.dataIndex, valueRef.current)));
|
|
123
|
+
dataSourceChange === null || dataSourceChange === void 0 ? void 0 : dataSourceChange(rowIndex, colIndex, valueRef.current, Object.assign(Object.assign({}, record), _defineProperty({}, col.dataIndex, valueRef.current)));
|
|
122
124
|
}
|
|
123
125
|
};
|
|
124
126
|
|
|
125
127
|
var renderEditor = function renderEditor() {
|
|
126
128
|
if (isEditing) {
|
|
127
|
-
console.log(isEditing, '-----isEditing-----');
|
|
128
129
|
var Editor = (col === null || col === void 0 ? void 0 : col.dataEditor) || InputDataEdit;
|
|
129
130
|
return /*#__PURE__*/React.createElement(Editor, {
|
|
130
131
|
cell: col,
|
|
@@ -145,13 +146,16 @@ var SheelTabelCell = function SheelTabelCell(props) {
|
|
|
145
146
|
var content = renderComponent() || renderEditor() || renderViewer;
|
|
146
147
|
return /*#__PURE__*/React.createElement("td", Object.assign({}, omit(clearProps, ['commitIng', 'editIng']), {
|
|
147
148
|
// style={{ userSelect: 'none' }}
|
|
148
|
-
className: cls(colIndex === undefined && 'row_selection_td', 'unselection',
|
|
149
|
+
className: cls(colIndex === undefined && 'row_selection_td', 'unselection', _selected && selectIng && 'selected', isEnd && 'end', isRightEnd && 'right_end', isEditing && 'editing', isVaildCommit && 'commiting', selectedReadonly && 'readonly_red'),
|
|
149
150
|
onMouseDown: handleMouseDown,
|
|
150
151
|
onMouseOver: handleMouseOver,
|
|
151
152
|
onContextMenu: handleContextMenu,
|
|
152
153
|
onDoubleClick: handleDoubleClick,
|
|
153
154
|
key: "".concat(rowIndex, "_").concat(colIndex)
|
|
154
|
-
}), content
|
|
155
|
+
}), content, isRightEnd && isEnd && !isEditing && /*#__PURE__*/React.createElement("div", {
|
|
156
|
+
ref: endCellRef,
|
|
157
|
+
className: 'lmtable_cell_end_icon'
|
|
158
|
+
}));
|
|
155
159
|
};
|
|
156
160
|
|
|
157
161
|
export default SheelTabelCell;
|
|
@@ -21,11 +21,13 @@ var _utilities = require("@dnd-kit/utilities");
|
|
|
21
21
|
|
|
22
22
|
var _excluded = ["children"];
|
|
23
23
|
var Item = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
24
|
+
var _children$props;
|
|
25
|
+
|
|
24
26
|
var children = _ref.children,
|
|
25
27
|
props = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
26
28
|
return /*#__PURE__*/_react.default.createElement("th", (0, _extends2.default)({}, props, {
|
|
27
29
|
ref: ref
|
|
28
|
-
}), children);
|
|
30
|
+
}), (children === null || children === void 0 ? void 0 : (_children$props = children.props) === null || _children$props === void 0 ? void 0 : _children$props.children) || children);
|
|
29
31
|
});
|
|
30
32
|
|
|
31
33
|
function SortableItem(props) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
1
2
|
import React, { useMemo } from 'react';
|
|
2
|
-
import { pick } from 'lodash';
|
|
3
|
+
import { pick, keyBy } from 'lodash';
|
|
3
4
|
import { Modal } from 'linkmore-design';
|
|
4
5
|
import { Column, Line, Pie } from '@ant-design/plots';
|
|
5
6
|
/** i 是行 j 是列 */
|
|
@@ -9,8 +10,16 @@ var TableChartsModal = function TableChartsModal(props) {
|
|
|
9
10
|
onCancel = props.onCancel,
|
|
10
11
|
data = props.data,
|
|
11
12
|
columns = props.columns,
|
|
12
|
-
selectInfo = props.selectInfo
|
|
13
|
+
selectInfo = props.selectInfo,
|
|
14
|
+
rowKey = props.rowKey,
|
|
15
|
+
deepDataSource = props.deepDataSource;
|
|
16
|
+
console.log(data, columns, '---props---', rowKey);
|
|
17
|
+
var keyByCol = useMemo(function () {
|
|
18
|
+
return keyBy(columns, 'dataIndex');
|
|
19
|
+
}, [columns]);
|
|
13
20
|
var resultData = useMemo(function () {
|
|
21
|
+
var _a;
|
|
22
|
+
|
|
14
23
|
var start = selectInfo.start,
|
|
15
24
|
end = selectInfo.end;
|
|
16
25
|
var rCol = columns === null || columns === void 0 ? void 0 : columns.filter(function (item, index) {
|
|
@@ -27,14 +36,14 @@ var TableChartsModal = function TableChartsModal(props) {
|
|
|
27
36
|
});
|
|
28
37
|
var maxi = Math.max(start.i, end.i);
|
|
29
38
|
var mini = Math.min(start.i, end.i);
|
|
30
|
-
var rDataSource = data === null ||
|
|
39
|
+
var rDataSource = (_a = deepDataSource || data) === null || _a === void 0 ? void 0 : _a.filter(function (item, index) {
|
|
31
40
|
if (index >= mini && index <= maxi) {
|
|
32
41
|
return true;
|
|
33
42
|
}
|
|
34
43
|
|
|
35
44
|
return false;
|
|
36
45
|
}).map(function (item) {
|
|
37
|
-
return pick(item, rCol);
|
|
46
|
+
return pick(item, [].concat(_toConsumableArray(rCol), [rowKey]));
|
|
38
47
|
});
|
|
39
48
|
return {
|
|
40
49
|
rDataSource: rDataSource,
|
|
@@ -59,6 +68,7 @@ var TableChartsModal = function TableChartsModal(props) {
|
|
|
59
68
|
yField: yField
|
|
60
69
|
};
|
|
61
70
|
}, [resultData, getTypeCol]);
|
|
71
|
+
console.log(Field, '--Field--', resultData);
|
|
62
72
|
var config = useMemo(function () {
|
|
63
73
|
if (type === 'pie') {
|
|
64
74
|
return {
|
|
@@ -87,7 +97,7 @@ var TableChartsModal = function TableChartsModal(props) {
|
|
|
87
97
|
|
|
88
98
|
return {
|
|
89
99
|
data: resultData.rDataSource,
|
|
90
|
-
xField:
|
|
100
|
+
xField: rowKey,
|
|
91
101
|
yField: Field.yField,
|
|
92
102
|
label: {
|
|
93
103
|
position: 'middle',
|
|
@@ -96,8 +106,24 @@ var TableChartsModal = function TableChartsModal(props) {
|
|
|
96
106
|
opacity: 0.6
|
|
97
107
|
}
|
|
98
108
|
},
|
|
109
|
+
tooltip: {
|
|
110
|
+
title: Field.xField,
|
|
111
|
+
formatter: function formatter(datum) {
|
|
112
|
+
var _a, _b;
|
|
113
|
+
|
|
114
|
+
return {
|
|
115
|
+
name: ((_a = keyByCol[Field.yField]) === null || _a === void 0 ? void 0 : _a.title) || ((_b = keyByCol[Field.yField]) === null || _b === void 0 ? void 0 : _b.dataIndex),
|
|
116
|
+
value: datum === null || datum === void 0 ? void 0 : datum[Field.yField]
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
},
|
|
99
120
|
xAxis: {
|
|
100
121
|
label: {
|
|
122
|
+
formatter: function formatter(text, item, index) {
|
|
123
|
+
var _a, _b;
|
|
124
|
+
|
|
125
|
+
return ((_b = (_a = resultData.rDataSource) === null || _a === void 0 ? void 0 : _a[index]) === null || _b === void 0 ? void 0 : _b[Field.xField]) || text;
|
|
126
|
+
},
|
|
101
127
|
autoHide: true,
|
|
102
128
|
autoRotate: false
|
|
103
129
|
}
|