react-table-edit 1.4.36 → 1.4.38
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/component/sidebar-setting-column/index.d.ts +1 -1
- package/dist/component/table/index.d.ts +14 -2
- package/dist/component/type/index.d.ts +12 -14
- package/dist/component/utils.d.ts +7 -1
- package/dist/index.d.ts +33 -17
- package/dist/index.js +341 -282
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +341 -282
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -17477,11 +17477,11 @@ const useOnClickOutside = (ref, handler) => {
|
|
|
17477
17477
|
// ** Call passed function on click outside
|
|
17478
17478
|
handler(event);
|
|
17479
17479
|
};
|
|
17480
|
-
document.addEventListener(
|
|
17481
|
-
document.addEventListener(
|
|
17480
|
+
document.addEventListener("mousedown", listener);
|
|
17481
|
+
document.addEventListener("touchstart", listener);
|
|
17482
17482
|
return () => {
|
|
17483
|
-
document.removeEventListener(
|
|
17484
|
-
document.removeEventListener(
|
|
17483
|
+
document.removeEventListener("mousedown", listener);
|
|
17484
|
+
document.removeEventListener("touchstart", listener);
|
|
17485
17485
|
};
|
|
17486
17486
|
},
|
|
17487
17487
|
// ** Add ref and handler to effect dependencies
|
|
@@ -17496,7 +17496,7 @@ const checkThousandSeparator = (thousandSeparator, decimalSeparator) => {
|
|
|
17496
17496
|
if (thousandSeparator) {
|
|
17497
17497
|
if (decimalSeparator) {
|
|
17498
17498
|
if (thousandSeparator === decimalSeparator) {
|
|
17499
|
-
return
|
|
17499
|
+
return ",";
|
|
17500
17500
|
}
|
|
17501
17501
|
else {
|
|
17502
17502
|
return thousandSeparator;
|
|
@@ -17507,14 +17507,14 @@ const checkThousandSeparator = (thousandSeparator, decimalSeparator) => {
|
|
|
17507
17507
|
}
|
|
17508
17508
|
}
|
|
17509
17509
|
else {
|
|
17510
|
-
return
|
|
17510
|
+
return ",";
|
|
17511
17511
|
}
|
|
17512
17512
|
};
|
|
17513
17513
|
const checkDecimalSeparator = (thousandSeparator, decimalSeparator) => {
|
|
17514
17514
|
if (decimalSeparator) {
|
|
17515
17515
|
if (thousandSeparator) {
|
|
17516
17516
|
if (thousandSeparator === decimalSeparator) {
|
|
17517
|
-
return
|
|
17517
|
+
return ".";
|
|
17518
17518
|
}
|
|
17519
17519
|
else {
|
|
17520
17520
|
return decimalSeparator;
|
|
@@ -17525,29 +17525,32 @@ const checkDecimalSeparator = (thousandSeparator, decimalSeparator) => {
|
|
|
17525
17525
|
}
|
|
17526
17526
|
}
|
|
17527
17527
|
else {
|
|
17528
|
-
return
|
|
17528
|
+
return ".";
|
|
17529
17529
|
}
|
|
17530
17530
|
};
|
|
17531
17531
|
const isNullOrUndefined = (d) => {
|
|
17532
|
-
if (d === null || d === undefined || d ===
|
|
17532
|
+
if (d === null || d === undefined || d === "") {
|
|
17533
17533
|
return true;
|
|
17534
17534
|
}
|
|
17535
17535
|
return false;
|
|
17536
17536
|
};
|
|
17537
17537
|
const generateUUID = () => {
|
|
17538
|
+
// Public Domain/MIT
|
|
17538
17539
|
let d = new Date().getTime(); //Timestamp
|
|
17539
|
-
let d2 = (
|
|
17540
|
-
return
|
|
17540
|
+
let d2 = (typeof performance !== "undefined" && performance.now && performance.now() * 1000) || 0; //Time in microseconds since page-load or 0 if unsupported
|
|
17541
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (c) {
|
|
17541
17542
|
let r = Math.random() * 16; //random number between 0 and 16
|
|
17542
|
-
if (d > 0) {
|
|
17543
|
+
if (d > 0) {
|
|
17544
|
+
//Use timestamp until depleted
|
|
17543
17545
|
r = (d + r) % 16 | 0;
|
|
17544
17546
|
d = Math.floor(d / 16);
|
|
17545
17547
|
}
|
|
17546
|
-
else {
|
|
17548
|
+
else {
|
|
17549
|
+
//Use microseconds since page-load if supported
|
|
17547
17550
|
r = (d2 + r) % 16 | 0;
|
|
17548
17551
|
d2 = Math.floor(d2 / 16);
|
|
17549
17552
|
}
|
|
17550
|
-
return (c ===
|
|
17553
|
+
return (c === "x" ? r : 0x3).toString(16);
|
|
17551
17554
|
});
|
|
17552
17555
|
};
|
|
17553
17556
|
/**
|
|
@@ -17564,17 +17567,17 @@ const formartNumberic = (str, decimalSeparator, thousandSeparator, fraction = 10
|
|
|
17564
17567
|
str = roundNumber(Number(str), fraction);
|
|
17565
17568
|
}
|
|
17566
17569
|
// eslint-disable-next-line
|
|
17567
|
-
if (str || str ==
|
|
17570
|
+
if (str || str == "0") {
|
|
17568
17571
|
str = str.toString();
|
|
17569
|
-
const value = decimalSeparator !==
|
|
17570
|
-
const arr = value.toString().split(decimalSeparator ??
|
|
17571
|
-
let flag = value.toString().includes(decimalSeparator ??
|
|
17572
|
+
const value = decimalSeparator !== "." ? str.toString().replaceAll(".", decimalSeparator ?? "") : str;
|
|
17573
|
+
const arr = value.toString().split(decimalSeparator ?? "", 2);
|
|
17574
|
+
let flag = value.toString().includes(decimalSeparator ?? "");
|
|
17572
17575
|
if (arr[0].length < 3) {
|
|
17573
|
-
return flag ? `${arr[0]}${decimalSeparator}${arr[1]?.substring(0, fraction) ??
|
|
17576
|
+
return flag ? `${arr[0]}${decimalSeparator}${arr[1]?.substring(0, fraction) ?? ""}` : arr[0];
|
|
17574
17577
|
}
|
|
17575
17578
|
else {
|
|
17576
17579
|
let flagNegative = false;
|
|
17577
|
-
if (arr[0][0] ===
|
|
17580
|
+
if (arr[0][0] === "-") {
|
|
17578
17581
|
flagNegative = true;
|
|
17579
17582
|
arr[0] = arr[0].substring(1, arr[0].length);
|
|
17580
17583
|
}
|
|
@@ -17585,20 +17588,20 @@ const formartNumberic = (str, decimalSeparator, thousandSeparator, fraction = 10
|
|
|
17585
17588
|
count++;
|
|
17586
17589
|
}
|
|
17587
17590
|
}
|
|
17588
|
-
if (arr[0].lastIndexOf(thousandSeparator ??
|
|
17591
|
+
if (arr[0].lastIndexOf(thousandSeparator ?? "") === arr[0].length - 1) {
|
|
17589
17592
|
arr[0] = arr[0].slice(0, arr[0].length - 1);
|
|
17590
17593
|
}
|
|
17591
17594
|
if (isDone) {
|
|
17592
|
-
flag = (arr[1]?.substring(0, fraction) ??
|
|
17595
|
+
flag = (arr[1]?.substring(0, fraction) ?? "") !== "";
|
|
17593
17596
|
}
|
|
17594
17597
|
if (flagNegative && haveNegative) {
|
|
17595
|
-
arr[0] =
|
|
17598
|
+
arr[0] = "-".concat(arr[0]);
|
|
17596
17599
|
}
|
|
17597
|
-
return flag ? `${arr[0]}${decimalSeparator}${arr[1]?.substring(0, fraction) ??
|
|
17600
|
+
return flag ? `${arr[0]}${decimalSeparator}${arr[1]?.substring(0, fraction) ?? ""}` : arr[0];
|
|
17598
17601
|
}
|
|
17599
17602
|
}
|
|
17600
17603
|
else {
|
|
17601
|
-
return
|
|
17604
|
+
return "";
|
|
17602
17605
|
}
|
|
17603
17606
|
};
|
|
17604
17607
|
const roundNumber = (num, fraction) => {
|
|
@@ -17606,23 +17609,23 @@ const roundNumber = (num, fraction) => {
|
|
|
17606
17609
|
const result = Math.round(num * base) / base;
|
|
17607
17610
|
return result;
|
|
17608
17611
|
};
|
|
17609
|
-
const formatDateTime = (data, format =
|
|
17612
|
+
const formatDateTime = (data, format = "dd/MM/yyyy") => {
|
|
17610
17613
|
if (!data) {
|
|
17611
|
-
return
|
|
17614
|
+
return "";
|
|
17612
17615
|
}
|
|
17613
17616
|
const date = new Date(data);
|
|
17614
17617
|
const map = {
|
|
17615
|
-
dd: String(date.getDate()).padStart(2,
|
|
17616
|
-
MM: String(date.getMonth() + 1).padStart(2,
|
|
17618
|
+
dd: String(date.getDate()).padStart(2, "0"),
|
|
17619
|
+
MM: String(date.getMonth() + 1).padStart(2, "0"),
|
|
17617
17620
|
yyyy: date.getFullYear(),
|
|
17618
|
-
HH: String(date.getHours()).padStart(2,
|
|
17619
|
-
mm: String(date.getMinutes()).padStart(2,
|
|
17621
|
+
HH: String(date.getHours()).padStart(2, "0"),
|
|
17622
|
+
mm: String(date.getMinutes()).padStart(2, "0")
|
|
17620
17623
|
};
|
|
17621
17624
|
return format.replace(/dd|MM|yyyy|HH|mm/g, (match) => map[match]);
|
|
17622
17625
|
};
|
|
17623
17626
|
// Hàm tìm vị trí theo chuỗi index
|
|
17624
17627
|
const FindNodeByPath = (tree, path) => {
|
|
17625
|
-
const levels = path.split(
|
|
17628
|
+
const levels = path.split("-").map((num) => parseInt(num, 10));
|
|
17626
17629
|
let current = tree;
|
|
17627
17630
|
let node = null;
|
|
17628
17631
|
for (let index = 0; index < levels.length - 1; index++) {
|
|
@@ -17651,7 +17654,7 @@ const FindNodeByPath = (tree, path) => {
|
|
|
17651
17654
|
* fisrtObjWidthFixRight: number // Chỉ số cột đầu tiên fixed right
|
|
17652
17655
|
* }
|
|
17653
17656
|
*/
|
|
17654
|
-
const calculateTableStructure = (columns) => {
|
|
17657
|
+
const calculateTableStructure = (columns, settingColumns) => {
|
|
17655
17658
|
const levels = [];
|
|
17656
17659
|
const flat = [];
|
|
17657
17660
|
const objWidthFixLeft = {};
|
|
@@ -17660,18 +17663,18 @@ const calculateTableStructure = (columns) => {
|
|
|
17660
17663
|
const objHeaderWidthFixLeft = {};
|
|
17661
17664
|
let maxDepth = 0;
|
|
17662
17665
|
// Tính depth tối đa
|
|
17663
|
-
const calculateDepth = (cols, depth = 1) =>
|
|
17666
|
+
const calculateDepth = (cols, depth = 1) => Math.max(...cols.map((col) => (col.columns?.length ? calculateDepth(col.columns, depth + 1) : depth)));
|
|
17664
17667
|
maxDepth = calculateDepth(columns);
|
|
17665
17668
|
let leftTotal = 0;
|
|
17666
17669
|
let rightTotal = 0;
|
|
17667
17670
|
// Tính tổng width của các cột cố định phải
|
|
17668
17671
|
const calcTotalRightWidth = (cols) => {
|
|
17669
|
-
cols.forEach(col => {
|
|
17672
|
+
cols.forEach((col) => {
|
|
17670
17673
|
if (col.columns?.length) {
|
|
17671
17674
|
calcTotalRightWidth(col.columns);
|
|
17672
17675
|
}
|
|
17673
17676
|
else {
|
|
17674
|
-
if (col.fixedType ===
|
|
17677
|
+
if (col.fixedType === "right" && col.visible !== false) {
|
|
17675
17678
|
rightTotal += col.width ?? 40;
|
|
17676
17679
|
}
|
|
17677
17680
|
}
|
|
@@ -17689,9 +17692,20 @@ const calculateTableStructure = (columns) => {
|
|
|
17689
17692
|
colspan,
|
|
17690
17693
|
rowspan: hasChildren ? 1 : maxDepth - level
|
|
17691
17694
|
};
|
|
17695
|
+
if (settingColumns && settingColumns.length > 0) {
|
|
17696
|
+
const column = settingColumns.find((y) => y.field === cell.field);
|
|
17697
|
+
if (column) {
|
|
17698
|
+
cell.visible = column.visible;
|
|
17699
|
+
cell.fixedType = column.fixedType;
|
|
17700
|
+
cell.width = column.width;
|
|
17701
|
+
}
|
|
17702
|
+
else {
|
|
17703
|
+
cell.visible = false;
|
|
17704
|
+
}
|
|
17705
|
+
}
|
|
17692
17706
|
levels[level].push(cell);
|
|
17693
17707
|
const headerKey = `${level}-${indexCol}`;
|
|
17694
|
-
if (col.fixedType ===
|
|
17708
|
+
if (col.fixedType === "left" && col.visible !== false) {
|
|
17695
17709
|
objHeaderWidthFixLeft[headerKey] = leftTotal;
|
|
17696
17710
|
}
|
|
17697
17711
|
if (!hasChildren) {
|
|
@@ -17699,16 +17713,16 @@ const calculateTableStructure = (columns) => {
|
|
|
17699
17713
|
const width = col.width ?? 40;
|
|
17700
17714
|
cell.index = index;
|
|
17701
17715
|
flat.push(cell);
|
|
17702
|
-
if (col.fixedType ===
|
|
17716
|
+
if (col.fixedType === "left" && col.visible !== false) {
|
|
17703
17717
|
objWidthFixLeft[index] = leftTotal;
|
|
17704
17718
|
leftTotal += width;
|
|
17705
17719
|
}
|
|
17706
|
-
if (col.fixedType ===
|
|
17720
|
+
if (col.fixedType === "right" && col.in !== false) {
|
|
17707
17721
|
rightTotal -= width;
|
|
17708
17722
|
objWidthFixRight[index] = rightTotal;
|
|
17709
17723
|
}
|
|
17710
17724
|
}
|
|
17711
|
-
if (col.fixedType ===
|
|
17725
|
+
if (col.fixedType === "right" && col.visible !== false) {
|
|
17712
17726
|
objHeaderWidthFixRight[headerKey] = rightTotal;
|
|
17713
17727
|
}
|
|
17714
17728
|
return colspanSum + colspan;
|
|
@@ -40355,7 +40369,7 @@ const SidebarSetColumn = (props) => {
|
|
|
40355
40369
|
};
|
|
40356
40370
|
}, []);
|
|
40357
40371
|
const renderFooterButtons = () => {
|
|
40358
|
-
return (jsxs(Fragment, { children: [jsx(Button$1, { color: "primary", onClick: handleSubmit, className: "me-1", children: t("Confirm") }), jsx(Button$1, { color: "secondary", onClick: handleCancel, outline: true, children: t(
|
|
40372
|
+
return (jsxs(Fragment, { children: [jsx(Button$1, { color: "primary", onClick: handleSubmit, className: "me-1", children: t("Confirm") }), jsx(Button$1, { color: "secondary", onClick: handleCancel, outline: true, children: t("Close") })] }));
|
|
40359
40373
|
};
|
|
40360
40374
|
const visibleTemplate = (item, index) => {
|
|
40361
40375
|
return (jsx(Input$1, { defaultChecked: item.visible ?? true, disabled: item.invisibleDisable, type: "checkbox", style: { height: 18 }, className: " cursor-pointer", onChange: (e) => {
|
|
@@ -40366,14 +40380,14 @@ const SidebarSetColumn = (props) => {
|
|
|
40366
40380
|
} }));
|
|
40367
40381
|
};
|
|
40368
40382
|
const fixColumnTemplate = (item, index) => {
|
|
40369
|
-
return (jsx(Input$1, { defaultChecked: item.fixedType ===
|
|
40383
|
+
return (jsx(Input$1, { defaultChecked: item.fixedType === "left" || item.fixedType === "right", type: "checkbox", style: { height: 18 }, className: " cursor-pointer", onChange: (e) => {
|
|
40370
40384
|
if (dataSource) {
|
|
40371
40385
|
if (e.target.checked) {
|
|
40372
|
-
if (
|
|
40373
|
-
dataSource[index].fixedType =
|
|
40386
|
+
if (index * 2 <= dataSource.length) {
|
|
40387
|
+
dataSource[index].fixedType = "left";
|
|
40374
40388
|
}
|
|
40375
40389
|
else {
|
|
40376
|
-
dataSource[index].fixedType =
|
|
40390
|
+
dataSource[index].fixedType = "right";
|
|
40377
40391
|
}
|
|
40378
40392
|
}
|
|
40379
40393
|
else {
|
|
@@ -40385,7 +40399,7 @@ const SidebarSetColumn = (props) => {
|
|
|
40385
40399
|
};
|
|
40386
40400
|
const columns = [
|
|
40387
40401
|
{
|
|
40388
|
-
field:
|
|
40402
|
+
field: "headerText",
|
|
40389
40403
|
headerText: "Column name",
|
|
40390
40404
|
template: (e) => {
|
|
40391
40405
|
return jsx(Fragment$1, { children: t(e.headerText) });
|
|
@@ -40396,29 +40410,29 @@ const SidebarSetColumn = (props) => {
|
|
|
40396
40410
|
minWidth: 150
|
|
40397
40411
|
},
|
|
40398
40412
|
{
|
|
40399
|
-
field:
|
|
40413
|
+
field: "",
|
|
40400
40414
|
template: visibleTemplate,
|
|
40401
40415
|
headerText: "Display",
|
|
40402
|
-
textAlign:
|
|
40416
|
+
textAlign: "center",
|
|
40403
40417
|
visible: true,
|
|
40404
40418
|
width: 100,
|
|
40405
40419
|
maxWidth: 120,
|
|
40406
40420
|
minWidth: 80
|
|
40407
40421
|
},
|
|
40408
40422
|
{
|
|
40409
|
-
field:
|
|
40423
|
+
field: "",
|
|
40410
40424
|
template: fixColumnTemplate,
|
|
40411
40425
|
headerText: "Fix the column",
|
|
40412
|
-
textAlign:
|
|
40426
|
+
textAlign: "center",
|
|
40413
40427
|
visible: true,
|
|
40414
40428
|
width: 100,
|
|
40415
40429
|
maxWidth: 120,
|
|
40416
40430
|
minWidth: 80
|
|
40417
40431
|
},
|
|
40418
40432
|
{
|
|
40419
|
-
field:
|
|
40433
|
+
field: "width",
|
|
40420
40434
|
headerText: "Column width",
|
|
40421
|
-
textAlign:
|
|
40435
|
+
textAlign: "right",
|
|
40422
40436
|
visible: true,
|
|
40423
40437
|
width: 100,
|
|
40424
40438
|
maxWidth: 120,
|
|
@@ -40426,44 +40440,42 @@ const SidebarSetColumn = (props) => {
|
|
|
40426
40440
|
}
|
|
40427
40441
|
];
|
|
40428
40442
|
const renderHeaderCol = (col, indexCol) => {
|
|
40429
|
-
return (jsx(Fragment, { children: col.visible !== false && jsx("th", { className: classNames$2(`r-headercell fix-${col.fixedType}`, {
|
|
40430
|
-
width: col.fixedType ? Number(col.maxWidth ? col.maxWidth :
|
|
40431
|
-
minWidth: col.fixedType ? Number(col.maxWidth ? col.maxWidth :
|
|
40443
|
+
return (jsx(Fragment, { children: col.visible !== false && (jsx("th", { className: classNames$2(`r-headercell fix-${col.fixedType}`, { "cell-fixed": col.fixedType }), style: {
|
|
40444
|
+
width: col.fixedType ? Number(col.maxWidth ? col.maxWidth : col.width ? col.width : col.minWidth ?? "auto") : col.width,
|
|
40445
|
+
minWidth: col.fixedType ? Number(col.maxWidth ? col.maxWidth : col.width ? col.width : col.minWidth ?? "auto") : col.minWidth,
|
|
40432
40446
|
top: `${0 * 42}px`,
|
|
40433
40447
|
maxWidth: col.maxWidth
|
|
40434
|
-
}, children: jsx("div", { role: "textbox", title: t(col.headerText ??
|
|
40448
|
+
}, children: jsx("div", { role: "textbox", title: t(col.headerText ?? ""), style: {
|
|
40435
40449
|
height: `${1 * 42}px`,
|
|
40436
|
-
justifyContent: col.textAlign ??
|
|
40437
|
-
}, className: "r-headercell-div", children: t(col.headerText ??
|
|
40450
|
+
justifyContent: col.textAlign ?? "left"
|
|
40451
|
+
}, className: "r-headercell-div", children: t(col.headerText ?? "") }) })) }, `header-${indexCol}`));
|
|
40438
40452
|
};
|
|
40439
|
-
return (jsxs(Sidebar, { open: openSidebar, toggleSidebar: handleCancel, width: 700, children: [jsx(ModalHeader, { typeModal:
|
|
40440
|
-
return
|
|
40441
|
-
}) }) }), jsx("tbody", { className:
|
|
40442
|
-
return (jsx("tr", { className: classNames$2(
|
|
40453
|
+
return (jsxs(Sidebar, { open: openSidebar, toggleSidebar: handleCancel, width: 700, children: [jsx(ModalHeader, { typeModal: "Edit", handleModal: handleCancel, title: "Column setup" }), jsx("div", { className: "ms-2 r-table-edit", children: jsx("div", { className: "r-grid", children: jsx("div", { className: "r-gridtable", style: { height: windowSize.innerHeight - 120 }, children: jsxs("table", { style: { width: "100%" }, children: [jsx("thead", { className: "r-gridheader", children: jsx("tr", { className: "r-row", role: "row", children: columns.map((col, index) => {
|
|
40454
|
+
return renderHeaderCol(col, index);
|
|
40455
|
+
}) }) }), jsx("tbody", { className: "r-gridcontent", children: dataSource?.map((row, indexRow) => {
|
|
40456
|
+
return (jsx("tr", { className: classNames$2("r-row", { "last-row": indexRow === dataSource.length - 1 }, { "fisrt-row": indexRow === 0 }), children: columns.map((col, indexCol) => {
|
|
40443
40457
|
let value = row[col.field];
|
|
40444
|
-
if (col.type ===
|
|
40445
|
-
value = formartNumberic(row[col.field],
|
|
40458
|
+
if (col.type === "numeric" || (col.typeCondition && col.typeCondition(row) === "numeric")) {
|
|
40459
|
+
value = formartNumberic(row[col.field], ",", ".", col.numericSettings?.fraction, true) ?? 0;
|
|
40446
40460
|
}
|
|
40447
|
-
return (jsx(Fragment, { children: col.visible !== false && jsx("td", { className: classNames$2(`r-rowcell fix-${col.fixedType}`, {
|
|
40461
|
+
return (jsx(Fragment, { children: col.visible !== false && (jsx("td", { className: classNames$2(`r-rowcell fix-${col.fixedType}`, { "cell-fixed": col.fixedType }, { "r-active": indexFocus === indexRow }), style: {
|
|
40448
40462
|
padding: 0,
|
|
40449
|
-
textAlign: col.textAlign ? col.textAlign :
|
|
40463
|
+
textAlign: col.textAlign ? col.textAlign : "left"
|
|
40450
40464
|
}, onFocus: (e) => {
|
|
40451
40465
|
if (indexRow !== indexFocus) {
|
|
40452
40466
|
setIndexFocus(indexRow);
|
|
40453
40467
|
}
|
|
40454
40468
|
e.stopPropagation();
|
|
40455
40469
|
}, onClick: (e) => {
|
|
40456
|
-
if (e.target.nodeName ===
|
|
40470
|
+
if (e.target.nodeName === "DIV" || e.target.nodeName === "TD") {
|
|
40457
40471
|
if (indexRow !== indexFocus) {
|
|
40458
40472
|
setIndexFocus(indexRow);
|
|
40459
40473
|
}
|
|
40460
40474
|
e.stopPropagation();
|
|
40461
40475
|
}
|
|
40462
|
-
}, children: jsx("div", { className: classNames$2(
|
|
40463
|
-
width: col.fixedType ? Number(col.maxWidth ? col.maxWidth :
|
|
40464
|
-
}, children: jsx("div", { className: classNames$2(
|
|
40465
|
-
margin: '7px 9px'
|
|
40466
|
-
}, children: jsx("div", { className: "r-cell-text", children: col.template ? col.template(row, indexRow) : value }) }) }) }, `col-${indexRow}-${indexCol}`) }, indexCol));
|
|
40476
|
+
}, children: jsx("div", { className: classNames$2("r-rowcell-div"), style: {
|
|
40477
|
+
width: col.fixedType ? Number(col.maxWidth ? col.maxWidth : col.width ? col.width : col.minWidth ?? "auto") : "auto"
|
|
40478
|
+
}, children: jsx("div", { className: classNames$2("r-rowcell-content"), children: jsx("div", { className: "r-cell-text", children: col.template ? col.template(row, indexRow) : value }) }) }) }, `col-${indexRow}-${indexCol}`)) }, indexCol));
|
|
40467
40479
|
}) }, `row-${indexRow}`));
|
|
40468
40480
|
}) })] }) }) }) }), jsx("div", { className: "d-flex justify-content-end p-1 ", style: { boxShadow: "0 4px 24px 0 rgb(34 41 47 / 10%)" }, children: renderFooterButtons() })] }));
|
|
40469
40481
|
};
|
|
@@ -42795,7 +42807,7 @@ const ToolbarBottom = ({ handleAdd, handleDuplicate, handleInsertBefore, handleI
|
|
|
42795
42807
|
|
|
42796
42808
|
const TableEdit = forwardRef((props, ref) => {
|
|
42797
42809
|
const { t } = useTranslation();
|
|
42798
|
-
const { idTable, dataSource, columns,
|
|
42810
|
+
const { idTable, dataSource, columns, pagingSetting, setDataSource, height, maxHeight, minHeight, defaultValue, toolbarSetting, searchSetting, selectedItem, selectEnable, editDisable, addDisable, buttonSetting, formatSetting, haveSum, isMulti, disableAutoKey, commandClick, dataSourceChange, rowChange, setSelectedItem, handleSelect, onDuplicate, saveSettingColumn, allowFilter = true, allowOrder, settingColumns, optionsFilter } = props;
|
|
42799
42811
|
useImperativeHandle(ref, () => {
|
|
42800
42812
|
return {
|
|
42801
42813
|
refeshFocusRow: handleRefeshRow
|
|
@@ -42804,28 +42816,26 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
42804
42816
|
const [refreshRow, setRefreshRow] = useState(false);
|
|
42805
42817
|
const [indexFocus, setIndexFocus] = useState(-1);
|
|
42806
42818
|
const [selectedRows, setSelectedRows] = useState([]);
|
|
42807
|
-
const [contentColumns, setContentColumns] = useState([]);
|
|
42808
42819
|
const [openPopupSetupColumn, setOpenPopupSetupColumn] = useState(false);
|
|
42809
|
-
const [searchTerm, setSearchTerm] = useState(
|
|
42820
|
+
const [searchTerm, setSearchTerm] = useState("");
|
|
42810
42821
|
const [orderBy, setOrderBy] = useState([]);
|
|
42811
42822
|
const [filterBy, setFilterBy] = useState([]);
|
|
42823
|
+
const [refreshColumns, setRefreshColumns] = useState(false);
|
|
42812
42824
|
const tableElement = useRef(null);
|
|
42813
42825
|
const gridRef = useRef(null);
|
|
42814
42826
|
const totalCount = dataSource.length;
|
|
42815
42827
|
const pagingClient = pagingSetting?.allowPaging && (pagingSetting?.pagingClient || !(editDisable || addDisable));
|
|
42816
42828
|
const searchClient = searchSetting?.searchEnable && (searchSetting?.searchClient || !(editDisable || addDisable));
|
|
42817
|
-
const fieldKey = columns.find((item) => item.isPrimarykey === true)?.field ??
|
|
42829
|
+
const fieldKey = columns.find((item) => item.isPrimarykey === true)?.field ?? "id";
|
|
42818
42830
|
const fieldUniKey = columns.filter((item) => item.isUnikey === true)?.map((item) => item.field);
|
|
42819
42831
|
useEffect(() => {
|
|
42820
42832
|
if (pagingClient && pagingSetting.setCurrentPage && Math.ceil(totalCount / (pagingSetting?.pageSize ?? 1)) < (pagingSetting.currentPage ?? 1)) {
|
|
42821
42833
|
pagingSetting.setCurrentPage(1);
|
|
42822
42834
|
}
|
|
42823
42835
|
}, [dataSource]);
|
|
42824
|
-
const { levels: headerColumns, flatVisble, objWidthFixLeft, objWidthFixRight, lastObjWidthFixLeft, fisrtObjWidthFixRight, objHeaderWidthFixLeft, objHeaderWidthFixRight, indexFirstEdit: indexFirstEdit, indexLastEdit: indexLastEdit } = useMemo(() => {
|
|
42825
|
-
|
|
42826
|
-
|
|
42827
|
-
return obj;
|
|
42828
|
-
}, [columns]);
|
|
42836
|
+
const { levels: headerColumns, flat: contentColumns, flatVisble, objWidthFixLeft, objWidthFixRight, lastObjWidthFixLeft, fisrtObjWidthFixRight, objHeaderWidthFixLeft, objHeaderWidthFixRight, indexFirstEdit: indexFirstEdit, indexLastEdit: indexLastEdit } = useMemo(() => {
|
|
42837
|
+
return calculateTableStructure(columns, settingColumns);
|
|
42838
|
+
}, [columns, settingColumns, refreshColumns]);
|
|
42829
42839
|
const handleRefeshRow = () => {
|
|
42830
42840
|
setRefreshRow(true);
|
|
42831
42841
|
setTimeout(() => {
|
|
@@ -42845,7 +42855,7 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
42845
42855
|
}
|
|
42846
42856
|
};
|
|
42847
42857
|
const handleKeyPress = (e) => {
|
|
42848
|
-
if (
|
|
42858
|
+
if (e.code === "Enter" || e.code === "NumpadEnter") {
|
|
42849
42859
|
if (searchSetting?.setSearchTerm) {
|
|
42850
42860
|
searchSetting?.setSearchTerm(e.target.value);
|
|
42851
42861
|
}
|
|
@@ -42857,9 +42867,9 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
42857
42867
|
}
|
|
42858
42868
|
};
|
|
42859
42869
|
const searchTemplate = () => {
|
|
42860
|
-
return (jsx(Fragment, { children: jsx("div", { className: "me-50 r-search", children: jsx(ReactInput, { style: { width:
|
|
42870
|
+
return (jsx(Fragment, { children: jsx("div", { className: "me-50 r-search", children: jsx(ReactInput, { style: { width: "230px" }, value: searchSetting?.searchTerm !== undefined ? searchSetting?.searchTerm : searchTerm, setSearchTerm: searchSetting?.setSearchTerm ? searchSetting?.setSearchTerm : setSearchTerm, placeholder: t("Search"), onKeyPress: handleKeyPress }) }) }));
|
|
42861
42871
|
};
|
|
42862
|
-
const defaultToolbarOption = searchSetting?.searchEnable ? [{ template: searchTemplate, align:
|
|
42872
|
+
const defaultToolbarOption = searchSetting?.searchEnable ? [{ template: searchTemplate, align: "left" }] : [];
|
|
42863
42873
|
let toolbarTopOption = [];
|
|
42864
42874
|
if (toolbarSetting?.toolbarOptions) {
|
|
42865
42875
|
toolbarTopOption = [...defaultToolbarOption, ...toolbarSetting?.toolbarOptions];
|
|
@@ -42870,8 +42880,8 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
42870
42880
|
const RenderEditCell = (row, col, indexCol, indexRow) => {
|
|
42871
42881
|
/*eslint-disable */
|
|
42872
42882
|
switch (col?.typeCondition ? col?.typeCondition(row) : col.type) {
|
|
42873
|
-
case
|
|
42874
|
-
return (jsx(DateInput, { id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`, className: classNames$2(
|
|
42883
|
+
case "date":
|
|
42884
|
+
return (jsx(DateInput, { id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`, className: classNames$2("form-control border-0 rounded-0 input-numeric", { "is-invalid": col.validate && col.validate(row[col.field], row) }), value: row[col.field], onChange: (date) => {
|
|
42875
42885
|
row[col.field] = date ? new Date(date.getTime() + 7 * 60 * 60 * 1000) : undefined;
|
|
42876
42886
|
if (col.callback) {
|
|
42877
42887
|
col.callback(row[col.field], indexRow, row);
|
|
@@ -42887,8 +42897,8 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
42887
42897
|
e.preventDefault();
|
|
42888
42898
|
}
|
|
42889
42899
|
} }));
|
|
42890
|
-
case
|
|
42891
|
-
return (jsx(DateInput, { id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`, className: classNames$2(
|
|
42900
|
+
case "datetime":
|
|
42901
|
+
return (jsx(DateInput, { id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`, className: classNames$2("form-control border-0 rounded-0 input-numeric", { "is-invalid": col.validate && col.validate(row[col.field], row) }), value: row[col.field], onChange: (date) => {
|
|
42892
42902
|
row[col.field] = date;
|
|
42893
42903
|
if (col.callback) {
|
|
42894
42904
|
col.callback(row[col.field], indexRow, row);
|
|
@@ -42902,41 +42912,49 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
42902
42912
|
e.preventDefault();
|
|
42903
42913
|
}
|
|
42904
42914
|
} }));
|
|
42905
|
-
case
|
|
42915
|
+
case "select":
|
|
42906
42916
|
let valueSelect;
|
|
42907
42917
|
let optionsSelect = [];
|
|
42908
42918
|
if (col.selectSettings?.optionsField) {
|
|
42909
42919
|
optionsSelect = row[col.selectSettings?.optionsField] ? row[col.selectSettings?.optionsField] : [];
|
|
42910
42920
|
}
|
|
42911
42921
|
else {
|
|
42912
|
-
optionsSelect = col.selectSettings?.options
|
|
42922
|
+
optionsSelect = col.selectSettings?.options
|
|
42923
|
+
? col.selectSettings?.validateOption
|
|
42924
|
+
? col.selectSettings?.options.filter((item) => col.selectSettings?.validateOption(item, row))
|
|
42925
|
+
: col.selectSettings?.options
|
|
42926
|
+
: [];
|
|
42913
42927
|
}
|
|
42914
42928
|
if (col.selectSettings?.isMulti) {
|
|
42915
|
-
valueSelect = optionsSelect.filter((x) => row[col.field].some((y) => col.selectSettings?.compareFunction ? col.selectSettings.compareFunction(x, row) : x[col.selectSettings?.fieldValue ??
|
|
42929
|
+
valueSelect = optionsSelect.filter((x) => row[col.field].some((y) => (col.selectSettings?.compareFunction ? col.selectSettings.compareFunction(x, row) : x[col.selectSettings?.fieldValue ?? "value"] === y)));
|
|
42916
42930
|
}
|
|
42917
42931
|
else {
|
|
42918
|
-
valueSelect =
|
|
42932
|
+
valueSelect =
|
|
42933
|
+
!isNullOrUndefined(row[col.field]) && row[col.field] !== ""
|
|
42934
|
+
? optionsSelect?.find((val) => col.selectSettings?.compareFunction ? col.selectSettings.compareFunction(val, row) : val[col.selectSettings?.fieldValue ?? "value"] === row[col.field])
|
|
42935
|
+
: "";
|
|
42919
42936
|
if (!valueSelect && col.selectSettings?.defaultValue) {
|
|
42920
42937
|
valueSelect = col.selectSettings?.defaultValue(row);
|
|
42921
42938
|
}
|
|
42922
42939
|
}
|
|
42923
42940
|
return (jsx(SelectTable, { id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`, value: valueSelect, options: optionsSelect, onChange: (val) => {
|
|
42924
42941
|
if (col.selectSettings?.isMulti) {
|
|
42925
|
-
row[col.field] = (val?.length ?? 0) > 0 ? val.map((item) => item[col.selectSettings?.fieldValue ??
|
|
42942
|
+
row[col.field] = (val?.length ?? 0) > 0 ? val.map((item) => item[col.selectSettings?.fieldValue ?? "value"]) : [];
|
|
42926
42943
|
}
|
|
42927
42944
|
else {
|
|
42928
|
-
row[col.field] = !isNullOrUndefined(val) ? val[col.selectSettings?.fieldValue ??
|
|
42945
|
+
row[col.field] = !isNullOrUndefined(val) ? val[col.selectSettings?.fieldValue ?? "value"] : undefined;
|
|
42929
42946
|
}
|
|
42930
42947
|
if (val && col.selectSettings?.loadOptions && isMulti) {
|
|
42931
|
-
if (isMulti) {
|
|
42948
|
+
if (isMulti) {
|
|
42949
|
+
//push giá trị vào option khi loadoption
|
|
42932
42950
|
val.forEach((e) => {
|
|
42933
|
-
if (!optionsSelect.some((a) => a[col.selectSettings?.fieldValue ??
|
|
42951
|
+
if (!optionsSelect.some((a) => a[col.selectSettings?.fieldValue ?? "value"] === e[col.selectSettings?.fieldValue ?? "value"])) {
|
|
42934
42952
|
optionsSelect.unshift(e);
|
|
42935
42953
|
}
|
|
42936
42954
|
});
|
|
42937
42955
|
}
|
|
42938
42956
|
else if (!col.selectSettings?.defaultValue) {
|
|
42939
|
-
if (!optionsSelect.some((a) => a[col.selectSettings?.fieldValue ??
|
|
42957
|
+
if (!optionsSelect.some((a) => a[col.selectSettings?.fieldValue ?? "value"] === val[col.selectSettings?.fieldValue ?? "value"])) {
|
|
42940
42958
|
optionsSelect.unshift(val);
|
|
42941
42959
|
}
|
|
42942
42960
|
}
|
|
@@ -42945,27 +42963,21 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
42945
42963
|
col.callback(val, indexRow, row);
|
|
42946
42964
|
}
|
|
42947
42965
|
handleDataChange(row, col, indexRow);
|
|
42948
|
-
}, fieldValue: col.selectSettings?.fieldValue, fieldLabel: col.selectSettings?.fieldLabel, component: gridRef, columns: col.selectSettings?.columns, isClearable: col.selectSettings?.isClearable ?? false, formatSetting: formatSetting, placeholder: t(
|
|
42949
|
-
return checkKeyDown(e, row, col, indexRow + 1, indexCol + 1);
|
|
42950
|
-
}, onOpenMenu: () => {
|
|
42951
|
-
if (col.selectSettings?.onOpenMenu) {
|
|
42952
|
-
col.selectSettings?.onOpenMenu(row, col, indexRow);
|
|
42953
|
-
}
|
|
42954
|
-
}, onPaste: (e) => {
|
|
42966
|
+
}, fieldValue: col.selectSettings?.fieldValue, fieldLabel: col.selectSettings?.fieldLabel, component: gridRef, columns: col.selectSettings?.columns, isClearable: col.selectSettings?.isClearable ?? false, formatSetting: formatSetting, placeholder: t("Select"), loadOptions: col.selectSettings?.loadOptions, handleAdd: col.selectSettings?.handAddNew ? (e) => col.selectSettings?.handAddNew(e, indexRow, row) : undefined, isMulti: col.selectSettings?.isMulti, noHeader: col.selectSettings?.noHeader, showFooter: col.selectSettings?.showFooter, formatOptionLabel: col.selectSettings?.formatOptionLabel, footerComponent: col.selectSettings?.footerComponent, invalid: col.validate && !isNullOrUndefined(col.validate(row[col.field], row)), maxHeight: col.selectSettings?.heightPopup ? Number(col.selectSettings?.heightPopup) : undefined, menuWidth: col.selectSettings?.widthPopup ? Number(col.selectSettings?.widthPopup) : undefined, textAlign: col.textAlign ?? "left", allowCreate: col.selectSettings?.allowCreate, compareFunction: col.selectSettings?.compareFunction ? (e) => col.selectSettings?.compareFunction?.(e, row) : undefined, onKeyDown: (e) => checkKeyDown(e, row, col, indexRow + 1, indexCol + 1), onOpenMenu: col.selectSettings?.onOpenMenu ? () => col.selectSettings?.onOpenMenu?.(row, col, indexRow) : undefined, onPaste: (e) => {
|
|
42955
42967
|
if (toolbarSetting?.showBottomToolbar && !editDisable && !addDisable && !col.disablePaste) {
|
|
42956
42968
|
pasteDataFromExcel(indexRow, indexCol, e);
|
|
42957
42969
|
e.preventDefault();
|
|
42958
42970
|
}
|
|
42959
42971
|
} }));
|
|
42960
|
-
case
|
|
42972
|
+
case "selectTree":
|
|
42961
42973
|
const findItemInTree = (items, value) => {
|
|
42962
42974
|
for (let index = 0; index < items.length; index++) {
|
|
42963
42975
|
const item = items[index];
|
|
42964
|
-
if (item[col.selectSettings?.fieldValue ? col.selectSettings?.fieldValue :
|
|
42976
|
+
if (item[col.selectSettings?.fieldValue ? col.selectSettings?.fieldValue : "value"] === value) {
|
|
42965
42977
|
return { ...item };
|
|
42966
42978
|
}
|
|
42967
|
-
else if (item[col.selectSettings?.fieldChild ??
|
|
42968
|
-
const itemFilter = findItemInTree(item[col.selectSettings?.fieldChild ??
|
|
42979
|
+
else if (item[col.selectSettings?.fieldChild ?? "children"]?.length > 0) {
|
|
42980
|
+
const itemFilter = findItemInTree(item[col.selectSettings?.fieldChild ?? "children"], value);
|
|
42969
42981
|
if (itemFilter) {
|
|
42970
42982
|
return itemFilter;
|
|
42971
42983
|
}
|
|
@@ -42978,39 +42990,37 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
42978
42990
|
optionsSelectTree = row[col.selectSettings?.optionsField] ? row[col.selectSettings?.optionsField] : [];
|
|
42979
42991
|
}
|
|
42980
42992
|
else {
|
|
42981
|
-
optionsSelectTree = col.selectSettings?.options
|
|
42993
|
+
optionsSelectTree = col.selectSettings?.options
|
|
42994
|
+
? col.selectSettings?.validateOption
|
|
42995
|
+
? col.selectSettings?.options.filter((item) => col.selectSettings?.validateOption(item, row))
|
|
42996
|
+
: col.selectSettings?.options
|
|
42997
|
+
: [];
|
|
42982
42998
|
}
|
|
42983
42999
|
if (col.selectSettings?.isMulti) {
|
|
42984
43000
|
valueSelectTree = row[col.field];
|
|
42985
43001
|
}
|
|
42986
43002
|
else {
|
|
42987
|
-
valueSelectTree =
|
|
43003
|
+
valueSelectTree = !isNullOrUndefined(row[col.field]) && row[col.field] !== "" ? findItemInTree(optionsSelectTree, row[col.field]) : "";
|
|
42988
43004
|
}
|
|
42989
43005
|
return (jsx(SelectTableTree, { id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`, value: valueSelectTree, options: optionsSelectTree, onChange: (val) => {
|
|
42990
43006
|
if (col.selectSettings?.isMulti) {
|
|
42991
43007
|
row[col.field] = !isNullOrUndefined(val) ? val : [];
|
|
42992
43008
|
}
|
|
42993
43009
|
else {
|
|
42994
|
-
row[col.field] = !isNullOrUndefined(val) ? val[col.selectSettings?.fieldValue ??
|
|
43010
|
+
row[col.field] = !isNullOrUndefined(val) ? val[col.selectSettings?.fieldValue ?? "value"] : undefined;
|
|
42995
43011
|
}
|
|
42996
43012
|
if (col.callback) {
|
|
42997
43013
|
col.callback(val, indexRow, row);
|
|
42998
43014
|
}
|
|
42999
43015
|
handleDataChange(row, col, indexRow);
|
|
43000
|
-
}, fieldValue: col.selectSettings?.fieldValue, fieldLabel: col.selectSettings?.fieldLabel, component: gridRef, columns: col.selectSettings?.columns, isClearable: col.selectSettings?.isClearable ?? false, formatSetting: formatSetting, placeholder: t(
|
|
43001
|
-
if (col.selectSettings?.onOpenMenu) {
|
|
43002
|
-
col.selectSettings?.onOpenMenu(row, col, indexRow);
|
|
43003
|
-
}
|
|
43004
|
-
}, loadOptions: col.selectSettings?.loadOptions, handleAdd: col.selectSettings?.handAddNew ? (e) => col.selectSettings?.handAddNew(e, indexRow, row) : undefined, fieldChildren: col.selectSettings?.fieldChild ?? 'children', selectChilds: col.selectSettings?.selectChilds, showFooter: col.selectSettings?.showFooter, formatOptionLabel: col.selectSettings?.formatOptionLabel, footerComponent: col.selectSettings?.footerComponent, width: col.selectSettings?.widthPopup ? Number(col.selectSettings?.widthPopup) : undefined, isMulti: col.selectSettings?.isMulti, noHeader: col.selectSettings?.noHeader, invalid: col.validate && col.validate(row[col.field], row), maxHeight: col.selectSettings?.heightPopup ? Number(col.selectSettings?.heightPopup) : undefined, menuWidth: col.selectSettings?.widthPopup ? Number(col.selectSettings?.widthPopup) : undefined, textAlign: col.textAlign ?? 'left', onKeyDown: (e) => {
|
|
43005
|
-
checkKeyDown(e, row, col, indexRow + 1, indexCol + 1);
|
|
43006
|
-
}, onPaste: (e) => {
|
|
43016
|
+
}, fieldValue: col.selectSettings?.fieldValue, fieldLabel: col.selectSettings?.fieldLabel, component: gridRef, columns: col.selectSettings?.columns, isClearable: col.selectSettings?.isClearable ?? false, formatSetting: formatSetting, placeholder: t("Select"), loadOptions: col.selectSettings?.loadOptions, handleAdd: col.selectSettings?.handAddNew ? (e) => col.selectSettings?.handAddNew(e, indexRow, row) : undefined, fieldChildren: col.selectSettings?.fieldChild ?? "children", selectChilds: col.selectSettings?.selectChilds, showFooter: col.selectSettings?.showFooter, formatOptionLabel: col.selectSettings?.formatOptionLabel, footerComponent: col.selectSettings?.footerComponent, width: col.selectSettings?.widthPopup ? Number(col.selectSettings?.widthPopup) : undefined, isMulti: col.selectSettings?.isMulti, noHeader: col.selectSettings?.noHeader, invalid: col.validate && col.validate(row[col.field], row), maxHeight: col.selectSettings?.heightPopup ? Number(col.selectSettings?.heightPopup) : undefined, menuWidth: col.selectSettings?.widthPopup ? Number(col.selectSettings?.widthPopup) : undefined, textAlign: col.textAlign ?? "left", onKeyDown: (e) => checkKeyDown(e, row, col, indexRow + 1, indexCol + 1), onOpenMenu: col.selectSettings?.onOpenMenu ? () => col.selectSettings?.onOpenMenu?.(row, col, indexRow) : undefined, onPaste: (e) => {
|
|
43007
43017
|
if (toolbarSetting?.showBottomToolbar && !editDisable && !addDisable && !col.disablePaste) {
|
|
43008
43018
|
pasteDataFromExcel(indexRow, indexCol, e);
|
|
43009
43019
|
e.preventDefault();
|
|
43010
43020
|
}
|
|
43011
43021
|
} }));
|
|
43012
|
-
case
|
|
43013
|
-
return (jsx(Input$1, { checked: !!row[col.field], id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`, type: "checkbox", className: "input-checkbox cursor-pointer", style: { textAlign: col.textAlign ??
|
|
43022
|
+
case "checkbox":
|
|
43023
|
+
return (jsx(Input$1, { checked: !!row[col.field], id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`, type: "checkbox", className: "input-checkbox cursor-pointer", style: { textAlign: col.textAlign ?? "left", marginTop: 6 }, onChange: (val) => {
|
|
43014
43024
|
row[col.field] = val.currentTarget.checked;
|
|
43015
43025
|
if (col.callback) {
|
|
43016
43026
|
col.callback(val.target.value, indexRow, row);
|
|
@@ -43019,16 +43029,16 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
43019
43029
|
}, onKeyDown: (e) => {
|
|
43020
43030
|
checkKeyDown(e, row, col, indexRow + 1, indexCol + 1);
|
|
43021
43031
|
} }));
|
|
43022
|
-
case
|
|
43032
|
+
case "numeric":
|
|
43023
43033
|
const numericFormatProps = {
|
|
43024
|
-
value: !isNullOrUndefined(row[col.field]) ? row[col.field].toString() :
|
|
43034
|
+
value: !isNullOrUndefined(row[col.field]) ? row[col.field].toString() : "",
|
|
43025
43035
|
thousandSeparator: checkThousandSeparator(formatSetting?.thousandSeparator, formatSetting?.decimalSeparator),
|
|
43026
43036
|
decimalSeparator: checkDecimalSeparator(formatSetting?.thousandSeparator, formatSetting?.decimalSeparator),
|
|
43027
43037
|
allowNegative: col.numericSettings?.allowNegative ?? false,
|
|
43028
43038
|
decimalScale: col.numericSettings?.fraction ?? 0
|
|
43029
43039
|
};
|
|
43030
|
-
let floatValue = parseFloat(row[col.field] ??
|
|
43031
|
-
return (jsx(NumericFormat, { id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`, style: { textAlign: col.textAlign, height: 29 }, ...numericFormatProps, defaultValue: formartNumberic(row[col.field], formatSetting?.decimalSeparator ??
|
|
43040
|
+
let floatValue = parseFloat(row[col.field] ?? "0");
|
|
43041
|
+
return (jsx(NumericFormat, { id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`, style: { textAlign: col.textAlign, height: 29 }, ...numericFormatProps, defaultValue: formartNumberic(row[col.field], formatSetting?.decimalSeparator ?? ",", formatSetting?.thousandSeparator ?? ".", col.numericSettings?.fraction), className: classNames$2("form-control border-0 rounded-0 input-numeric", { "is-invalid": col.validate && col.validate(row[col.field], row) }), onValueChange: (values) => {
|
|
43032
43042
|
floatValue = values?.floatValue;
|
|
43033
43043
|
}, onFocus: (e) => {
|
|
43034
43044
|
e.target.setSelectionRange(0, e.target.innerText.length - 1);
|
|
@@ -43041,7 +43051,7 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
43041
43051
|
handleDataChange(row, col, indexRow);
|
|
43042
43052
|
}
|
|
43043
43053
|
}, onKeyDown: (e) => {
|
|
43044
|
-
if (e.key ===
|
|
43054
|
+
if (e.key === "ArrowDown" || e.key === "NumpadEnter" || e.key === "ArrowUp" || e.key === "Enter" || e.key === "Tab") {
|
|
43045
43055
|
if (floatValue !== row[col.field]) {
|
|
43046
43056
|
row[col.field] = !isNaN(floatValue) ? floatValue : 0;
|
|
43047
43057
|
if (col.callback) {
|
|
@@ -43057,8 +43067,8 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
43057
43067
|
e.preventDefault();
|
|
43058
43068
|
}
|
|
43059
43069
|
} }));
|
|
43060
|
-
case
|
|
43061
|
-
return (jsx("div", { style: { padding:
|
|
43070
|
+
case "color":
|
|
43071
|
+
return (jsx("div", { style: { padding: "4px 8px" }, children: jsx(Input$1, { type: "color", value: row[col.field], style: { textAlign: col.textAlign ?? "center", padding: 0, height: 23, border: "none" }, disabled: editDisable, onChange: (val) => {
|
|
43062
43072
|
if (row[col.field] != val.target?.value) {
|
|
43063
43073
|
row[col.field] = val.target?.value;
|
|
43064
43074
|
if (col.callback) {
|
|
@@ -43069,8 +43079,8 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
43069
43079
|
}, onKeyDown: (val) => {
|
|
43070
43080
|
checkKeyDown(val, row, col, indexRow + 1, indexCol + 1);
|
|
43071
43081
|
} }, `col-${indexRow}-${indexCol}`) }));
|
|
43072
|
-
case
|
|
43073
|
-
return (jsx(EditForm, { id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`, ...col.formSettings, field: col.field, displayValue: col.formSettings?.displayValue ? col.formSettings?.displayValue(row) :
|
|
43082
|
+
case "form":
|
|
43083
|
+
return (jsx(EditForm, { id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`, ...col.formSettings, field: col.field, displayValue: col.formSettings?.displayValue ? col.formSettings?.displayValue(row) : "", placeholder: col.placeholder ? t(col.placeholder) : "", rowData: row, indexRow: indexRow, onChange: (val) => {
|
|
43074
43084
|
Object.assign(row, val);
|
|
43075
43085
|
handleDataChange(row, col, indexRow);
|
|
43076
43086
|
}, invalid: col.validate && col.validate(row[col.field], row), textAlign: col.textAlign, template: col.template, onKeyDown: (e) => {
|
|
@@ -43081,8 +43091,8 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
43081
43091
|
e.preventDefault();
|
|
43082
43092
|
}
|
|
43083
43093
|
} }));
|
|
43084
|
-
case
|
|
43085
|
-
return (jsx(EditFormInline, { id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`, ...col.formSettings, field: col.field, displayValue: col.formSettings?.displayValue ? col.formSettings?.displayValue(row) :
|
|
43094
|
+
case "formInline":
|
|
43095
|
+
return (jsx(EditFormInline, { id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`, ...col.formSettings, field: col.field, displayValue: col.formSettings?.displayValue ? col.formSettings?.displayValue(row) : "", placeholder: col.placeholder ? t(col.placeholder) : "", rowData: row, indexRow: indexRow, onChange: (val) => {
|
|
43086
43096
|
Object.assign(row, val);
|
|
43087
43097
|
handleDataChange(row, col, indexRow);
|
|
43088
43098
|
}, invalid: col.validate && col.validate(row[col.field], row), textAlign: col.textAlign, template: col.template, onKeyDown: (e) => {
|
|
@@ -43094,7 +43104,7 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
43094
43104
|
}
|
|
43095
43105
|
} }));
|
|
43096
43106
|
default:
|
|
43097
|
-
return (jsx(Input$1, { id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`, style: { textAlign: col.textAlign, height: 29 }, value: isNullOrUndefined(row[col.field]) ?
|
|
43107
|
+
return (jsx(Input$1, { id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`, style: { textAlign: col.textAlign, height: 29 }, value: isNullOrUndefined(row[col.field]) ? "" : row[col.field], className: classNames$2("border-0 rounded-0 input-element", { "is-invalid": col.validate && col.validate(row[col.field], row) }), onChange: (val) => {
|
|
43098
43108
|
if (row[col.field] != val.target?.value) {
|
|
43099
43109
|
row[col.field] = val.target?.value;
|
|
43100
43110
|
if (col.callback) {
|
|
@@ -43122,8 +43132,8 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
43122
43132
|
setTimeout(() => {
|
|
43123
43133
|
const element = document.getElementById(`${idTable}-col${col}-row${row}`);
|
|
43124
43134
|
if (element) {
|
|
43125
|
-
if (element.className.includes(
|
|
43126
|
-
element.getElementsByTagName(
|
|
43135
|
+
if (element.className.includes("react-select") || element.className.includes("form-edit")) {
|
|
43136
|
+
element.getElementsByTagName("input")[0]?.focus();
|
|
43127
43137
|
}
|
|
43128
43138
|
else {
|
|
43129
43139
|
element.focus();
|
|
@@ -43132,16 +43142,17 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
43132
43142
|
if (tableElement.current) {
|
|
43133
43143
|
const parentRect = tableElement.current.getBoundingClientRect();
|
|
43134
43144
|
const childRect = element.getBoundingClientRect();
|
|
43135
|
-
const offset = childRect.left - parentRect.left + tableElement.current.scrollLeft -
|
|
43136
|
-
tableElement.current.scrollTo({ left: offset, behavior:
|
|
43145
|
+
const offset = childRect.left - parentRect.left + tableElement.current.scrollLeft - parentRect.width / 2 + childRect.width / 2;
|
|
43146
|
+
tableElement.current.scrollTo({ left: offset, behavior: "smooth" });
|
|
43137
43147
|
}
|
|
43138
43148
|
}
|
|
43139
43149
|
if ((tableElement.current?.scrollHeight ?? 0) > 0) {
|
|
43140
43150
|
if ((tableElement.current?.scrollTop ?? 0) > ((row - 1) % (pagingSetting?.pageSize ?? 10000)) * 34) {
|
|
43141
|
-
tableElement.current?.scrollTo({ behavior:
|
|
43151
|
+
tableElement.current?.scrollTo({ behavior: "smooth", top: ((row - 1) % (pagingSetting?.pageSize ?? 10000)) * 34 });
|
|
43142
43152
|
}
|
|
43143
|
-
else if ((
|
|
43144
|
-
|
|
43153
|
+
else if ((tableElement.current?.clientHeight ?? 0) - (haveSum ? 30 : 0) - headerColumns.length * 42 <
|
|
43154
|
+
(row % (pagingSetting?.pageSize ?? 10000)) * 34 - (tableElement.current?.scrollTop ?? 0)) {
|
|
43155
|
+
tableElement.current?.scrollTo({ behavior: "smooth", top: (tableElement.current?.scrollTop ?? 0) + 34 });
|
|
43145
43156
|
}
|
|
43146
43157
|
}
|
|
43147
43158
|
}
|
|
@@ -43150,7 +43161,7 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
43150
43161
|
//Thêm dòng mới
|
|
43151
43162
|
const moveIndexRowToNewPage = () => {
|
|
43152
43163
|
changeDataSource(dataSource, 1);
|
|
43153
|
-
if (pagingClient && pagingSetting?.setCurrentPage &&
|
|
43164
|
+
if (pagingClient && pagingSetting?.setCurrentPage && totalCount % (pagingSetting?.pageSize ?? 0) === 0) {
|
|
43154
43165
|
pagingSetting?.setCurrentPage((pagingSetting?.currentPage ?? 0) + 1);
|
|
43155
43166
|
}
|
|
43156
43167
|
if (tableElement) {
|
|
@@ -43225,25 +43236,25 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
43225
43236
|
return undefined;
|
|
43226
43237
|
};
|
|
43227
43238
|
const pasteDataFromExcel = async (currenRowIndex, indexCol, e) => {
|
|
43228
|
-
const clipboard = (e.clipboardData || window.Clipboard).getData(
|
|
43229
|
-
const rowsClipboard = clipboard.trimEnd().split(
|
|
43239
|
+
const clipboard = (e.clipboardData || window.Clipboard).getData("text");
|
|
43240
|
+
const rowsClipboard = clipboard.trimEnd().split("\n");
|
|
43230
43241
|
setIndexFocus(-1);
|
|
43231
43242
|
if (rowsClipboard.length > 200) {
|
|
43232
|
-
messageBoxError(t,
|
|
43243
|
+
messageBoxError(t, "You can only paste up to 200 rows.");
|
|
43233
43244
|
}
|
|
43234
43245
|
if (rowsClipboard.length > 0) {
|
|
43235
43246
|
const columnsDataChange = [];
|
|
43236
|
-
for (let index = 0; index < rowsClipboard[0].trimEnd().split(
|
|
43247
|
+
for (let index = 0; index < rowsClipboard[0].trimEnd().split("\t").length; index++) {
|
|
43237
43248
|
const stringData = [];
|
|
43238
43249
|
rowsClipboard.forEach((element) => {
|
|
43239
|
-
if (element.trimEnd().split(
|
|
43240
|
-
stringData.push(element.trimEnd().split(
|
|
43250
|
+
if (element.trimEnd().split("\t")[index] && !stringData.includes(element.trimEnd().split("\t")[index].toString().trim())) {
|
|
43251
|
+
stringData.push(element.trimEnd().split("\t")[index].toString().trim());
|
|
43241
43252
|
}
|
|
43242
43253
|
});
|
|
43243
43254
|
const column = getColumn(indexCol, index);
|
|
43244
43255
|
if (column) {
|
|
43245
43256
|
if ((!column.disabledCondition || !column.disabledCondition(dataSource[currenRowIndex + 0])) && column.editEnable && column.onPasteValidate) {
|
|
43246
|
-
const rs = await column.onPasteValidate(stringData.join(
|
|
43257
|
+
const rs = await column.onPasteValidate(stringData.join(","), currenRowIndex + 0, dataSource[currenRowIndex + 0]);
|
|
43247
43258
|
if (rs) {
|
|
43248
43259
|
column.resultValidate = rs;
|
|
43249
43260
|
}
|
|
@@ -43253,7 +43264,7 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
43253
43264
|
}
|
|
43254
43265
|
for (let indexRow = 0; indexRow < rowsClipboard.length; indexRow++) {
|
|
43255
43266
|
const item = rowsClipboard[indexRow];
|
|
43256
|
-
const colsClipboard = item.trimEnd().split(
|
|
43267
|
+
const colsClipboard = item.trimEnd().split("\t");
|
|
43257
43268
|
let dataRow = dataSource[currenRowIndex + indexRow];
|
|
43258
43269
|
if (!dataRow) {
|
|
43259
43270
|
dataRow = { ...defaultValue };
|
|
@@ -43265,7 +43276,7 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
43265
43276
|
if (column) {
|
|
43266
43277
|
if (((!column.disabledCondition || !column.disabledCondition(dataSource[currenRowIndex + indexRow])) && column.editEnable) || column.onPaste) {
|
|
43267
43278
|
if (column.onPasteValidate && column.resultValidate) {
|
|
43268
|
-
const rs = column.resultValidate.find((item) => item[column.selectSettings?.fieldValue ??
|
|
43279
|
+
const rs = column.resultValidate.find((item) => item[column.selectSettings?.fieldValue ?? "value"] === stringData);
|
|
43269
43280
|
if (rs) {
|
|
43270
43281
|
if (column.onPaste) {
|
|
43271
43282
|
dataRow[column.field] = column.onPaste(dataRow, stringData);
|
|
@@ -43278,12 +43289,12 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
43278
43289
|
}
|
|
43279
43290
|
}
|
|
43280
43291
|
else {
|
|
43281
|
-
notificationError(t(
|
|
43292
|
+
notificationError(t("PasteExcelNotExist", { index: currenRowIndex + indexRow + 1, field: t(column.headerText ?? ""), value: stringData }));
|
|
43282
43293
|
}
|
|
43283
43294
|
}
|
|
43284
43295
|
else {
|
|
43285
|
-
if (column.type ===
|
|
43286
|
-
const [day, month, year] = stringData.split(
|
|
43296
|
+
if (column.type === "date") {
|
|
43297
|
+
const [day, month, year] = stringData.split("/");
|
|
43287
43298
|
const date = new Date(`${year}-${month}-${day}`);
|
|
43288
43299
|
if (!isNaN(date.getTime())) {
|
|
43289
43300
|
if (column.onPaste) {
|
|
@@ -43297,13 +43308,13 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
43297
43308
|
}
|
|
43298
43309
|
}
|
|
43299
43310
|
else {
|
|
43300
|
-
notificationError(t(
|
|
43311
|
+
notificationError(t("PasteExcelIncorrectFormat", { index: currenRowIndex + indexRow + 1, field: t(column.headerText ?? ""), value: stringData }));
|
|
43301
43312
|
}
|
|
43302
43313
|
}
|
|
43303
|
-
else if (column.type ===
|
|
43304
|
-
const [datePart, timePart] = stringData.split(
|
|
43305
|
-
const [day, month, year] = datePart.split(
|
|
43306
|
-
const [hour, minute] = timePart.split(
|
|
43314
|
+
else if (column.type === "datetime") {
|
|
43315
|
+
const [datePart, timePart] = stringData.split(" ");
|
|
43316
|
+
const [day, month, year] = datePart.split("/");
|
|
43317
|
+
const [hour, minute] = timePart.split(":");
|
|
43307
43318
|
const date = new Date(Number(year), Number(month) - 1, Number(day), Number(hour), Number(minute));
|
|
43308
43319
|
if (!isNaN(date.getTime())) {
|
|
43309
43320
|
if (column.onPaste) {
|
|
@@ -43317,11 +43328,11 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
43317
43328
|
}
|
|
43318
43329
|
}
|
|
43319
43330
|
else {
|
|
43320
|
-
notificationError(t(
|
|
43331
|
+
notificationError(t("PasteExcelIncorrectFormat", { index: currenRowIndex + indexRow + 1, field: t(column.headerText ?? ""), value: stringData }));
|
|
43321
43332
|
}
|
|
43322
43333
|
}
|
|
43323
|
-
else if (column.type ===
|
|
43324
|
-
const number = Number(stringData.replaceAll(formatSetting?.thousandSeparator ??
|
|
43334
|
+
else if (column.type === "numeric") {
|
|
43335
|
+
const number = Number(stringData.replaceAll(formatSetting?.thousandSeparator ?? ".", "").replaceAll(formatSetting?.decimalSeparator ?? ",", "."));
|
|
43325
43336
|
if (!isNaN(number)) {
|
|
43326
43337
|
if (column.onPaste) {
|
|
43327
43338
|
dataRow[column.field] = column.onPaste(dataRow, number);
|
|
@@ -43334,10 +43345,10 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
43334
43345
|
}
|
|
43335
43346
|
}
|
|
43336
43347
|
else {
|
|
43337
|
-
notificationError(t(
|
|
43348
|
+
notificationError(t("PasteExcelIncorrectFormat", { index: currenRowIndex + indexRow + 1, field: t(column.headerText ?? ""), value: stringData }));
|
|
43338
43349
|
}
|
|
43339
43350
|
}
|
|
43340
|
-
else if (column.type ===
|
|
43351
|
+
else if (column.type === "select") {
|
|
43341
43352
|
if (column.selectSettings?.allowCreate) {
|
|
43342
43353
|
if (column.onPaste) {
|
|
43343
43354
|
dataRow[column.field] = column.onPaste(dataRow, stringData);
|
|
@@ -43350,7 +43361,7 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
43350
43361
|
}
|
|
43351
43362
|
}
|
|
43352
43363
|
else {
|
|
43353
|
-
const rs = ((column.selectSettings?.optionsField ? item[column.selectSettings?.optionsField] : column.selectSettings?.options) ?? []).find((item) => item[column.selectSettings?.fieldValue ??
|
|
43364
|
+
const rs = ((column.selectSettings?.optionsField ? item[column.selectSettings?.optionsField] : column.selectSettings?.options) ?? []).find((item) => item[column.selectSettings?.fieldValue ?? "value"] === stringData);
|
|
43354
43365
|
if (rs) {
|
|
43355
43366
|
if (column.onPaste) {
|
|
43356
43367
|
dataRow[column.field] = column.onPaste(dataRow, stringData);
|
|
@@ -43363,7 +43374,7 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
43363
43374
|
}
|
|
43364
43375
|
}
|
|
43365
43376
|
else {
|
|
43366
|
-
notificationError(t(
|
|
43377
|
+
notificationError(t("PasteExcelNotExist", { index: currenRowIndex + indexRow + 1, field: t(column.headerText ?? ""), value: stringData }));
|
|
43367
43378
|
}
|
|
43368
43379
|
}
|
|
43369
43380
|
}
|
|
@@ -43383,7 +43394,7 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
43383
43394
|
}
|
|
43384
43395
|
}
|
|
43385
43396
|
if (rowChange) {
|
|
43386
|
-
rowChange(dataRow, currenRowIndex + indexRow,
|
|
43397
|
+
rowChange(dataRow, currenRowIndex + indexRow, "");
|
|
43387
43398
|
}
|
|
43388
43399
|
}
|
|
43389
43400
|
}
|
|
@@ -43415,7 +43426,7 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
43415
43426
|
}
|
|
43416
43427
|
else {
|
|
43417
43428
|
if (dataSource && selectedRows?.length > 0) {
|
|
43418
|
-
if (
|
|
43429
|
+
if (!selectedItem || selectedItem[fieldKey] !== selectedRows[0][fieldKey]) {
|
|
43419
43430
|
setSelectedItem({ ...selectedRows[0] });
|
|
43420
43431
|
if (handleSelect) {
|
|
43421
43432
|
handleSelect({ ...selectedRows[0] });
|
|
@@ -43449,56 +43460,61 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
43449
43460
|
}
|
|
43450
43461
|
}, [selectedItem]);
|
|
43451
43462
|
const renderContentCol = (col, row, indexRow, indexCol, isSelected) => {
|
|
43452
|
-
if (col.field ===
|
|
43453
|
-
return (col.visible !== false && jsx("td", { role: "gridcell", "aria-colindex": indexCol, className: classNames$2(`r-rowcell p-0 fix-${col.fixedType}`, {
|
|
43454
|
-
left: col.fixedType ===
|
|
43455
|
-
right: col.fixedType ===
|
|
43456
|
-
textAlign: col.textAlign ? col.textAlign :
|
|
43457
|
-
}, children: jsx("div", { className: "r-rowcell-div command", children: jsx(CommandElement, { commandItems: col.commandItems ?? [], handleCommandClick: handleCommandClick, indexRow: indexRow, rowData: row, setIndexFocus: setIndexFocus, indexFocus: indexFocus }) }) }, `col-${indexRow}-${indexCol}`));
|
|
43463
|
+
if (col.field === "command") {
|
|
43464
|
+
return (col.visible !== false && (jsx("td", { role: "gridcell", "aria-colindex": indexCol, className: classNames$2(`r-rowcell p-0 fix-${col.fixedType}`, { "cell-fixed": col.fixedType }, { "fixed-last": (col.fixedType === "left" && indexCol === lastObjWidthFixLeft) || (col.fixedType === "right" && indexCol === fisrtObjWidthFixRight) }, { "r-active": (isSelected && editDisable) || indexFocus === indexRow }), style: {
|
|
43465
|
+
left: col.fixedType === "left" ? objWidthFixLeft[indexCol] : undefined,
|
|
43466
|
+
right: col.fixedType === "right" ? objWidthFixRight[indexCol] : undefined,
|
|
43467
|
+
textAlign: col.textAlign ? col.textAlign : "left"
|
|
43468
|
+
}, children: jsx("div", { className: "r-rowcell-div command", children: jsx(CommandElement, { commandItems: col.commandItems ?? [], handleCommandClick: handleCommandClick, indexRow: indexRow, rowData: row, setIndexFocus: setIndexFocus, indexFocus: indexFocus }) }) }, `col-${indexRow}-${indexCol}`)));
|
|
43458
43469
|
}
|
|
43459
|
-
else if (col.field ===
|
|
43460
|
-
return (col.visible !== false && jsx("td", { role: "gridcell", "aria-colindex": indexCol, className: classNames$2(`r-rowcell p-0 cursor-pointer fix-${col.fixedType}`, {
|
|
43461
|
-
left: col.fixedType ===
|
|
43462
|
-
right: col.fixedType ===
|
|
43463
|
-
textAlign:
|
|
43470
|
+
else if (col.field === "#") {
|
|
43471
|
+
return (col.visible !== false && (jsx("td", { role: "gridcell", "aria-colindex": indexCol, className: classNames$2(`r-rowcell p-0 cursor-pointer fix-${col.fixedType}`, { "cell-fixed": col.fixedType }, { "fixed-last": (col.fixedType === "left" && indexCol === lastObjWidthFixLeft) || (col.fixedType === "right" && indexCol === fisrtObjWidthFixRight) }, { "r-active": (isSelected && editDisable) || indexFocus === indexRow }), tabIndex: Number(`${indexRow}${indexCol}`), style: {
|
|
43472
|
+
left: col.fixedType === "left" ? objWidthFixLeft[indexCol] : undefined,
|
|
43473
|
+
right: col.fixedType === "right" ? objWidthFixRight[indexCol] : undefined,
|
|
43474
|
+
textAlign: "center"
|
|
43464
43475
|
}, onCopy: (e) => {
|
|
43465
|
-
if (!editDisable && (e.target.nodeName ===
|
|
43476
|
+
if (!editDisable && (e.target.nodeName === "DIV" || e.target.nodeName === "TD")) {
|
|
43466
43477
|
navigator.clipboard.writeText(JSON.stringify(row));
|
|
43467
|
-
notificationSuccess(t(
|
|
43478
|
+
notificationSuccess(t("CopySuccessful"));
|
|
43468
43479
|
e.stopPropagation();
|
|
43469
43480
|
}
|
|
43470
43481
|
}, onPaste: (e) => {
|
|
43471
|
-
if (!editDisable && (e.target.nodeName ===
|
|
43472
|
-
navigator.clipboard
|
|
43482
|
+
if (!editDisable && (e.target.nodeName === "DIV" || e.target.nodeName === "TD")) {
|
|
43483
|
+
navigator.clipboard
|
|
43484
|
+
.readText()
|
|
43485
|
+
.then((rs) => {
|
|
43473
43486
|
dataSource[indexRow] = JSON.parse(rs);
|
|
43474
43487
|
if (fieldKey) {
|
|
43475
43488
|
dataSource[indexRow][fieldKey] = defaultValue[fieldKey];
|
|
43476
43489
|
}
|
|
43477
43490
|
changeDataSource(dataSource);
|
|
43478
|
-
notificationSuccess(t(
|
|
43479
|
-
})
|
|
43491
|
+
notificationSuccess(t("PasteSuccessful"));
|
|
43492
|
+
})
|
|
43493
|
+
.catch((ex) => {
|
|
43494
|
+
alert(ex);
|
|
43495
|
+
});
|
|
43480
43496
|
e.stopPropagation();
|
|
43481
43497
|
}
|
|
43482
43498
|
}, onClick: (e) => {
|
|
43483
|
-
if (e.target.nodeName ===
|
|
43499
|
+
if (e.target.nodeName === "DIV" || e.target.nodeName === "TD") {
|
|
43484
43500
|
if (!editDisable && indexRow != indexFocus) {
|
|
43485
43501
|
setIndexFocus(indexRow);
|
|
43486
43502
|
}
|
|
43487
43503
|
e.stopPropagation();
|
|
43488
43504
|
}
|
|
43489
43505
|
}, onKeyDown: (e) => {
|
|
43490
|
-
if (e.code ===
|
|
43506
|
+
if (e.code === "KeyD" && e.ctrlKey == true && !editDisable && !addDisable && (e.target.nodeName === "DIV" || e.target.nodeName === "TD")) {
|
|
43491
43507
|
handleDuplicate(dataSource, indexFocus, fieldKey, defaultValue, fieldUniKey, changeDataSource, tableElement, totalCount, toolbarSetting, buttonSetting, editDisable, addDisable, onDuplicate);
|
|
43492
43508
|
e.preventDefault();
|
|
43493
43509
|
e.stopPropagation();
|
|
43494
43510
|
}
|
|
43495
|
-
}, children: jsx("div", { className: "r-rowcell-div", children: indexRow + 1 }) }, `col-${indexRow}-${indexCol}`));
|
|
43511
|
+
}, children: jsx("div", { className: "r-rowcell-div", children: indexRow + 1 }) }, `col-${indexRow}-${indexCol}`)));
|
|
43496
43512
|
}
|
|
43497
|
-
else if (col.field ===
|
|
43498
|
-
return (jsx("td", { role: "gridcell", "aria-colindex": indexCol, className: classNames$2(`r-rowcell p-0 fix-${col.fixedType}`, {
|
|
43499
|
-
left: col.fixedType ===
|
|
43500
|
-
right: col.fixedType ===
|
|
43501
|
-
}, children: jsx("div", { className: "r-rowcell-div cursor-pointer", style: { alignItems:
|
|
43513
|
+
else if (col.field === "checkbox") {
|
|
43514
|
+
return (jsx("td", { role: "gridcell", "aria-colindex": indexCol, className: classNames$2(`r-rowcell p-0 fix-${col.fixedType}`, { "cell-fixed": col.fixedType }, { "fixed-last": (col.fixedType === "left" && indexCol === lastObjWidthFixLeft) || (col.fixedType === "right" && indexCol === fisrtObjWidthFixRight) }, { "r-active": (isSelected && editDisable) || indexFocus === indexRow }), style: {
|
|
43515
|
+
left: col.fixedType === "left" ? objWidthFixLeft[indexCol] : undefined,
|
|
43516
|
+
right: col.fixedType === "right" ? objWidthFixRight[indexCol] : undefined
|
|
43517
|
+
}, children: jsx("div", { className: "r-rowcell-div cursor-pointer", style: { alignItems: "center" }, onClick: (e) => {
|
|
43502
43518
|
if (selectEnable) {
|
|
43503
43519
|
const index = selectedRows?.findIndex((x) => x[fieldKey] === row[fieldKey]);
|
|
43504
43520
|
if (index > -1) {
|
|
@@ -43520,26 +43536,34 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
43520
43536
|
}
|
|
43521
43537
|
e.stopPropagation();
|
|
43522
43538
|
}
|
|
43523
|
-
}, children: jsx(Input$1, { checked: isSelected, type: "checkbox", className: "cursor-pointer", style: { textAlign: col.textAlign ??
|
|
43539
|
+
}, children: jsx(Input$1, { checked: isSelected, type: "checkbox", className: "cursor-pointer", style: { textAlign: col.textAlign ?? "center" } }) }) }, `col-${indexRow}-${indexCol}`));
|
|
43524
43540
|
}
|
|
43525
43541
|
else {
|
|
43526
43542
|
let value = row[col.field];
|
|
43527
|
-
if (col.type ===
|
|
43528
|
-
value = formartNumberic(row[col.field], formatSetting?.decimalSeparator ??
|
|
43543
|
+
if (col.type === "numeric" || (col.typeCondition && col.typeCondition(row) === "numeric")) {
|
|
43544
|
+
value = formartNumberic(row[col.field], formatSetting?.decimalSeparator ?? ",", formatSetting?.thousandSeparator ?? ".", col.numericSettings?.fraction, true, false) ?? 0;
|
|
43529
43545
|
}
|
|
43530
|
-
else if (col.type ===
|
|
43531
|
-
value = value ? formatDateTime(value, formatSetting?.dateFormat) :
|
|
43546
|
+
else if (col.type === "date") {
|
|
43547
|
+
value = value ? formatDateTime(value, formatSetting?.dateFormat) : "";
|
|
43532
43548
|
}
|
|
43533
|
-
else if (col.type ===
|
|
43534
|
-
value = value ? formatDateTime(value, formatSetting?.dateFormat ??
|
|
43549
|
+
else if (col.type === "datetime") {
|
|
43550
|
+
value = value ? formatDateTime(value, formatSetting?.dateFormat ?? "DD/MM/yyyy HH:mm") : "";
|
|
43535
43551
|
}
|
|
43536
|
-
const typeDis = !editDisable && (indexFocus === indexRow || col.type ===
|
|
43537
|
-
|
|
43538
|
-
|
|
43539
|
-
|
|
43540
|
-
|
|
43552
|
+
const typeDis = !editDisable && (indexFocus === indexRow || col.type === "checkbox") && (!col.disabledCondition || !col.disabledCondition(row))
|
|
43553
|
+
? col.editEnable
|
|
43554
|
+
? 1
|
|
43555
|
+
: col.template
|
|
43556
|
+
? 2
|
|
43557
|
+
: 3
|
|
43558
|
+
: col.template
|
|
43559
|
+
? 2
|
|
43560
|
+
: 3;
|
|
43561
|
+
const errorMessage = typeDis === 1 || col.field === "" || !col.validate ? "" : col.validate(row[col.field], row);
|
|
43562
|
+
return (jsx(Fragment, { children: col.visible !== false && (jsx("td", { role: "gridcell", "aria-colindex": indexCol, className: classNames$2(`r-rowcell fix-${col.fixedType}`, { "cell-fixed": col.fixedType }, { "fixed-last": (col.fixedType === "left" && indexCol === lastObjWidthFixLeft) || (col.fixedType === "right" && indexCol === fisrtObjWidthFixRight) }, { "r-active": (isSelected && editDisable) || indexFocus === indexRow }), style: {
|
|
43563
|
+
left: col.fixedType === "left" ? objWidthFixLeft[indexCol] : undefined,
|
|
43564
|
+
right: col.fixedType === "right" ? objWidthFixRight[indexCol] : undefined
|
|
43541
43565
|
}, onClick: (e) => {
|
|
43542
|
-
if (e.target.nodeName ===
|
|
43566
|
+
if (e.target.nodeName === "DIV" || e.target.nodeName === "TD") {
|
|
43543
43567
|
if (!editDisable && indexRow != indexFocus) {
|
|
43544
43568
|
setIndexFocus(indexRow);
|
|
43545
43569
|
focusNewElement(indexCol + 1, indexRow + 1, true);
|
|
@@ -43566,30 +43590,34 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
43566
43590
|
}
|
|
43567
43591
|
e.stopPropagation();
|
|
43568
43592
|
}
|
|
43569
|
-
}, children: jsx("div", { className: classNames$2(
|
|
43570
|
-
textAlign: col.textAlign ? col.textAlign :
|
|
43571
|
-
}, children: [typeDis === 1 && !refreshRow && jsx(Fragment$1, { children: RenderEditCell(row, col, indexCol, indexRow) }), (typeDis !== 1 || refreshRow) && RenderContentCell(row, col, indexCol, indexRow, typeDis, value), jsx("span", { id: `error-${indexRow}-${indexCol}`, className: classNames$2(
|
|
43593
|
+
}, children: jsx("div", { className: classNames$2("r-rowcell-div"), children: jsxs("div", { id: indexFocus === indexRow && typeDis !== 1 ? `${idTable}-col${indexCol + 1}-row${indexRow + 1}` : "", className: classNames$2("r-rowcell-content", { "r-is-invalid": errorMessage }), style: {
|
|
43594
|
+
textAlign: col.textAlign ? col.textAlign : "left"
|
|
43595
|
+
}, children: [typeDis === 1 && !refreshRow && (jsx(Fragment$1, { children: RenderEditCell(row, col, indexCol, indexRow) })), (typeDis !== 1 || refreshRow) && RenderContentCell(row, col, indexCol, indexRow, typeDis, value), jsx("span", { id: `error-${indexRow}-${indexCol}`, className: classNames$2("cursor-pointer text-primary icon-table", { "d-none": !errorMessage }), children: jsx(SvgAlertCircle, { fontSize: 15.5 }) }), jsx(UncontrolledTooltip, { target: `error-${indexRow}-${indexCol}`, className: "r-tooltip tooltip-error", children: errorMessage?.toString() ?? "" })] }) }) }, `col-${indexRow}-${indexCol}`)) }, indexCol));
|
|
43572
43596
|
}
|
|
43573
43597
|
};
|
|
43574
43598
|
const RenderContentCell = (row, col, indexCol, indexRow, typeDis, value) => {
|
|
43575
43599
|
if (typeDis === 2) {
|
|
43576
|
-
const value = col.template?.(row, indexRow) ??
|
|
43577
|
-
if (typeof value ===
|
|
43578
|
-
return (jsxs(Fragment$1, { children: [jsx("div", { id: `content-${idTable}-row${indexRow}col-${indexCol}`, className: "r-cell-text", children: value }),
|
|
43600
|
+
const value = col.template?.(row, indexRow) ?? "";
|
|
43601
|
+
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
|
43602
|
+
return (jsxs(Fragment$1, { children: [jsx("div", { id: `content-${idTable}-row${indexRow}col-${indexCol}`, className: "r-cell-text", children: value }), !refreshRow && typeDis !== 2 && (jsx(UncontrolledTooltip, { className: "r-tooltip", autohide: false, target: `content-${idTable}-row${indexRow}col-${indexCol}`, children: col.type === "numeric" && Number(row[col.field]) < 0 ? (jsxs("div", { style: { color: formatSetting?.colorNegative ?? "red" }, children: [" ", `${formatSetting?.prefixNegative ?? "-"}${value}${formatSetting?.suffixNegative ?? ""}`] })) : (value) }))] }));
|
|
43579
43603
|
}
|
|
43580
43604
|
else {
|
|
43581
43605
|
return value;
|
|
43582
43606
|
}
|
|
43583
43607
|
}
|
|
43584
|
-
return (jsxs(Fragment$1, { children: [jsx("div", { id: `content-${idTable}-row${indexRow}col-${indexCol}`, className: "r-cell-text", children:
|
|
43608
|
+
return (jsxs(Fragment$1, { children: [jsx("div", { id: `content-${idTable}-row${indexRow}col-${indexCol}`, className: "r-cell-text", children: col.type === "numeric" && Number(row[col.field]) < 0 ? (jsxs("div", { style: { color: formatSetting?.colorNegative ?? "red" }, children: [" ", `${formatSetting?.prefixNegative ?? "-"}${value}${formatSetting?.suffixNegative ?? ""}`] })) : (value) }), !(typeDis === 1 && !refreshRow) && typeDis !== 2 && (jsx(UncontrolledTooltip, { className: "r-tooltip", autohide: false, target: `content-${idTable}-row${indexRow}col-${indexCol}`, children: col.type === "numeric" && Number(row[col.field]) < 0 ? (jsxs("div", { style: { color: formatSetting?.colorNegative ?? "red" }, children: [" ", `${formatSetting?.prefixNegative ?? "-"}${value}${formatSetting?.suffixNegative ?? ""}`] })) : (value) }))] }));
|
|
43585
43609
|
};
|
|
43586
43610
|
const renderFooterCol = (col, indexCol) => {
|
|
43587
|
-
const sumValue =
|
|
43588
|
-
|
|
43589
|
-
|
|
43590
|
-
|
|
43591
|
-
|
|
43592
|
-
|
|
43611
|
+
const sumValue = col.haveSum === true && col.type === "numeric"
|
|
43612
|
+
? dataSource.reduce(function (accumulator, currentValue) {
|
|
43613
|
+
return Number(accumulator ?? 0) + Number(currentValue[col.field] ?? 0);
|
|
43614
|
+
}, 0)
|
|
43615
|
+
: 0;
|
|
43616
|
+
return (jsx(Fragment, { children: col.visible !== false && (jsx("td", { className: classNames$2(`p-0 px-50 r-footer fix-${col.fixedType}`, { "cell-fixed": col.fixedType }), style: {
|
|
43617
|
+
left: col.fixedType === "left" ? objWidthFixLeft[indexCol] : undefined,
|
|
43618
|
+
right: col.fixedType === "right" ? objWidthFixRight[indexCol] : undefined,
|
|
43619
|
+
textAlign: col.textAlign ? col.textAlign : "left"
|
|
43620
|
+
}, children: jsxs("div", { className: "r-footer-div", children: [col.haveSum === true && col.type === "numeric" && Number(sumValue) >= 0 && (jsx(Fragment$1, { children: formartNumberic(sumValue, formatSetting?.decimalSeparator ?? ",", formatSetting?.thousandSeparator ?? ".", col.numericSettings?.fraction, true, false) })), col.haveSum === true && col.type === "numeric" && Number(sumValue) < 0 && (jsxs("div", { style: { color: formatSetting?.colorNegative ?? "red" }, children: [" ", `${formatSetting?.prefixNegative ?? "-"}${formartNumberic(sumValue, formatSetting?.decimalSeparator ?? ",", formatSetting?.thousandSeparator ?? ".", col.numericSettings?.fraction, true, false)}${formatSetting?.suffixNegative ?? ""}`] }))] }) })) }, `summarycell-${indexCol}`));
|
|
43593
43621
|
};
|
|
43594
43622
|
/**
|
|
43595
43623
|
* Kiểm tra row có thỏa mãn tất cả filter và chứa từ khóa tìm kiếm hay không
|
|
@@ -43597,7 +43625,7 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
43597
43625
|
function checkRowMatch(row, filters, keyword, searchKeys) {
|
|
43598
43626
|
if ((!filters || filters.length === 0) && (!keyword || !searchClient))
|
|
43599
43627
|
return true; // Không có filter thì mặc định là match
|
|
43600
|
-
const isFilterMatch = filters.every(filter => {
|
|
43628
|
+
const isFilterMatch = filters.every((filter) => {
|
|
43601
43629
|
const { key, value, ope } = filter;
|
|
43602
43630
|
const rowValue = row[key];
|
|
43603
43631
|
if (rowValue === undefined || rowValue === null || value === undefined || value === null)
|
|
@@ -43605,32 +43633,33 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
43605
43633
|
const valStr = String(rowValue).toLowerCase();
|
|
43606
43634
|
const filterStr = String(value).toLowerCase();
|
|
43607
43635
|
switch (ope) {
|
|
43608
|
-
case
|
|
43636
|
+
case "startswith":
|
|
43609
43637
|
return valStr.startsWith(filterStr);
|
|
43610
|
-
case
|
|
43638
|
+
case "endswith":
|
|
43611
43639
|
return valStr.endsWith(filterStr);
|
|
43612
|
-
case
|
|
43640
|
+
case "contains":
|
|
43613
43641
|
return valStr.includes(filterStr);
|
|
43614
|
-
case
|
|
43642
|
+
case "equal":
|
|
43615
43643
|
return rowValue == value;
|
|
43616
|
-
case
|
|
43644
|
+
case "notequal":
|
|
43617
43645
|
return rowValue != value;
|
|
43618
|
-
case
|
|
43646
|
+
case "greaterthan":
|
|
43619
43647
|
return rowValue > value;
|
|
43620
|
-
case
|
|
43648
|
+
case "greaterthanorequal":
|
|
43621
43649
|
return rowValue >= value;
|
|
43622
|
-
case
|
|
43650
|
+
case "lessthan":
|
|
43623
43651
|
return rowValue < value;
|
|
43624
|
-
case
|
|
43652
|
+
case "lessthanorequal":
|
|
43625
43653
|
return rowValue <= value;
|
|
43626
43654
|
default:
|
|
43627
43655
|
return false;
|
|
43628
43656
|
}
|
|
43629
43657
|
});
|
|
43630
|
-
const isSearchMatch = !keyword ||
|
|
43631
|
-
|
|
43632
|
-
|
|
43633
|
-
|
|
43658
|
+
const isSearchMatch = !keyword ||
|
|
43659
|
+
searchKeys.some((key) => {
|
|
43660
|
+
const val = row[key];
|
|
43661
|
+
return val?.toString().toLowerCase().includes(keyword.trim().toLowerCase());
|
|
43662
|
+
});
|
|
43634
43663
|
return isFilterMatch && isSearchMatch;
|
|
43635
43664
|
}
|
|
43636
43665
|
useEffect(() => {
|
|
@@ -43638,24 +43667,35 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
43638
43667
|
pagingSetting?.setCurrentPage(1);
|
|
43639
43668
|
}
|
|
43640
43669
|
}, [searchTerm, searchSetting?.searchTerm]);
|
|
43641
|
-
return (jsxs(Fragment, { children: [jsxs("div", { className: "r-table-edit", children: [jsxs("div", { className:
|
|
43670
|
+
return (jsxs(Fragment, { children: [jsxs("div", { className: "r-table-edit", children: [jsxs("div", { className: "r-grid", ref: gridRef, children: [toolbarSetting?.showTopToolbar && jsx(RenderToolbarTop, { toolbarTopOption: toolbarTopOption }), jsx("div", { ref: tableElement, className: "r-gridtable", style: { height: `${height ? `${height}px` : "auto"}`, minHeight: `${minHeight ? `${minHeight}px` : ""}`, maxHeight: `${maxHeight ? `${maxHeight}px` : "400px"}` }, children: jsxs("table", { style: { width: "100%" }, role: "presentation", children: [jsx(RenderColGroup, { contentColumns: flatVisble }), jsx("thead", { className: "r-gridheader", role: "rowgroup", children: headerColumns.map((element, indexParent) => {
|
|
43642
43671
|
return (jsx("tr", { className: "r-row", role: "row", children: element?.map((col, index) => {
|
|
43643
|
-
return (jsx(HeaderTableCol$1, { col: col, idTable: idTable ??
|
|
43672
|
+
return (jsx(HeaderTableCol$1, { col: col, idTable: idTable ?? "", dataSource: dataSource, indexCol: index, indexParent: indexParent, isMulti: isMulti ?? false, objHeaderWidthFixLeft: objHeaderWidthFixLeft, objHeaderWidthFixRight: objHeaderWidthFixRight, selectEnable: selectEnable ?? false, selectedRows: selectedRows, setSelectedRows: setSelectedRows, container: tableElement, filterBy: filterBy, orderBy: orderBy, optionsFilter: optionsFilter, allowFilter: allowFilter, allowOrder: allowOrder, formatSetting: formatSetting, changeFilter: (val) => {
|
|
43644
43673
|
setFilterBy([...val]);
|
|
43645
43674
|
}, changeOrder: (val) => {
|
|
43646
43675
|
setOrderBy([...val]);
|
|
43647
|
-
}, columns: contentColumns, setColumns:
|
|
43676
|
+
}, columns: contentColumns, setColumns: (newColumns) => {
|
|
43677
|
+
newColumns.forEach((x) => {
|
|
43678
|
+
const column = columns.find((y) => y.field === x.field);
|
|
43679
|
+
if (column) {
|
|
43680
|
+
column.visible = x.visible;
|
|
43681
|
+
column.fixedType = x.fixedType;
|
|
43682
|
+
column.width = x.width;
|
|
43683
|
+
}
|
|
43684
|
+
});
|
|
43685
|
+
setRefreshColumns(!refreshColumns);
|
|
43686
|
+
}, fisrtObjWidthFixRight: fisrtObjWidthFixRight, lastObjWidthFixLeft: lastObjWidthFixLeft, totalCount: totalCount }, `header-${indexParent}-${index}`));
|
|
43648
43687
|
}) }, `header-${-indexParent}`));
|
|
43649
|
-
}) }), jsx("tbody", { className:
|
|
43688
|
+
}) }), jsx("tbody", { className: "r-gridcontent", role: "rowgroup", children: dataSource.map((row, indexRow) => {
|
|
43650
43689
|
const isSelected = selectedRows?.some((x) => x[fieldKey] === row[fieldKey]);
|
|
43651
43690
|
const flagSearch = checkRowMatch(row, filterBy, searchSetting?.searchTerm !== undefined ? searchSetting?.searchTerm : searchTerm, searchSetting?.keyField ?? []);
|
|
43652
43691
|
if (flagSearch) {
|
|
43653
|
-
const flagDisplay = !pagingClient ||
|
|
43654
|
-
|
|
43692
|
+
const flagDisplay = !pagingClient ||
|
|
43693
|
+
(indexRow + 1 > (pagingSetting.pageSize ?? 0) * ((pagingSetting.currentPage ?? 0) - 1) && indexRow + 1 <= (pagingSetting.pageSize ?? 0) * (pagingSetting.currentPage ?? 0));
|
|
43694
|
+
return (flagDisplay && (jsx(Fragment$1, { children: jsx("tr", { "aria-rowindex": indexRow + 1, role: "row", className: classNames$2("r-row"), children: contentColumns.map((col, indexCol) => renderContentCol(col, row, indexRow, indexCol, isSelected)) }, `row-${indexRow}`) })));
|
|
43655
43695
|
}
|
|
43656
|
-
}) }), jsx("tfoot", { className: "r-gridfoot", children: haveSum == true ? jsx("tr", { className:
|
|
43657
|
-
return
|
|
43658
|
-
}) }) : jsx(Fragment$1, {}) })] }) }), toolbarSetting?.showBottomToolbar && jsx(ToolbarBottom, { handleAdd: (numberOfRows) => {
|
|
43696
|
+
}) }), jsx("tfoot", { className: "r-gridfoot", children: haveSum == true ? (jsx("tr", { className: "r-row", children: contentColumns.map((col, index) => {
|
|
43697
|
+
return renderFooterCol(col, index);
|
|
43698
|
+
}) })) : (jsx(Fragment$1, {})) })] }) }), toolbarSetting?.showBottomToolbar && (jsx(ToolbarBottom, { handleAdd: (numberOfRows) => {
|
|
43659
43699
|
handleAdd(dataSource, tableElement.current, indexFirstEdit, changeDataSource, pagingSetting, setIndexFocus, focusNewElement, numberOfRows);
|
|
43660
43700
|
}, handleDuplicate: () => {
|
|
43661
43701
|
handleDuplicate(dataSource, indexFocus, fieldKey, defaultValue, fieldUniKey, changeDataSource, tableElement, totalCount, toolbarSetting, buttonSetting, editDisable, addDisable, onDuplicate);
|
|
@@ -43665,7 +43705,23 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
43665
43705
|
handleInsertBefore(dataSource, indexFocus, defaultValue, changeDataSource, pagingClient, pagingSetting, toolbarSetting, buttonSetting, editDisable, addDisable);
|
|
43666
43706
|
}, handleDeleteAll: () => {
|
|
43667
43707
|
handleDeleteAll(t, messageBoxConfirmDelete, setIndexFocus, changeDataSource, editDisable, addDisable, toolbarSetting, buttonSetting);
|
|
43668
|
-
}, setOpenPopupSetupColumn: setOpenPopupSetupColumn, indexFocus: indexFocus, editDisable: editDisable, addDisable: addDisable, buttonSetting: buttonSetting, toolbarSetting: toolbarSetting, headerColumns: headerColumns, t: t })] }), pagingSetting?.allowPaging ? jsx(PagingComponent, { onChangePage: onChangePage, pageSize: pagingSetting?.pageSize ?? 0, currentPage: pagingSetting?.currentPage ?? 0, pageOptions: pagingSetting?.pageOptions ?? [20, 30, 50, 100], totalItem: pagingClient ? totalCount :
|
|
43708
|
+
}, setOpenPopupSetupColumn: setOpenPopupSetupColumn, indexFocus: indexFocus, editDisable: editDisable, addDisable: addDisable, buttonSetting: buttonSetting, toolbarSetting: toolbarSetting, headerColumns: headerColumns, t: t }))] }), pagingSetting?.allowPaging ? (jsx(PagingComponent, { onChangePage: onChangePage, pageSize: pagingSetting?.pageSize ?? 0, currentPage: pagingSetting?.currentPage ?? 0, pageOptions: pagingSetting?.pageOptions ?? [20, 30, 50, 100], totalItem: pagingClient ? totalCount : pagingSetting?.totalItem ?? 0, onChangePageSize: onChangePageSize })) : (jsx(Fragment$1, {}))] }), jsx(SidebarSetColumn, { handleSidebar: () => {
|
|
43709
|
+
setOpenPopupSetupColumn(!openPopupSetupColumn);
|
|
43710
|
+
}, openSidebar: openPopupSetupColumn, column: [...contentColumns], setColumn: (newColumns) => {
|
|
43711
|
+
if (saveSettingColumn) {
|
|
43712
|
+
console.log(newColumns);
|
|
43713
|
+
saveSettingColumn(newColumns.map((x) => ({ field: x.field, headerText: x.headerText, visible: x.visible, fixedType: x.fixedType, width: x.width })));
|
|
43714
|
+
}
|
|
43715
|
+
newColumns.forEach((x) => {
|
|
43716
|
+
const column = columns.find((y) => y.field === x.field);
|
|
43717
|
+
if (column) {
|
|
43718
|
+
column.visible = x.visible;
|
|
43719
|
+
column.fixedType = x.fixedType;
|
|
43720
|
+
column.width = x.width;
|
|
43721
|
+
}
|
|
43722
|
+
});
|
|
43723
|
+
setRefreshColumns(!refreshColumns);
|
|
43724
|
+
} })] }));
|
|
43669
43725
|
});
|
|
43670
43726
|
|
|
43671
43727
|
const TabsMenuComponent = ({ buttonWidth, tabParent, tabChild, resourceCodeParent, resources, resourceCode, windowSize, renderModal }) => {
|
|
@@ -46140,6 +46196,20 @@ const CheckboxInput = (props) => {
|
|
|
46140
46196
|
}), children: [renderLabel({ isLabel, name, label: label ?? '' }), jsxs("div", { className: classNames$2('form-input-content', { 'hidden-label': isLabel === false }), children: [renderInput(), renderText()] })] }) }));
|
|
46141
46197
|
};
|
|
46142
46198
|
|
|
46199
|
+
const StyleInput = (props) => {
|
|
46200
|
+
const { control, name, label, labelSize, required, errors, height, disabled, isLabel, inLine, classes, disabledBackgroundColor, disabledFontFamily, disabledFontSize, disabledBold, disabledItalic, disabledUnderline } = props;
|
|
46201
|
+
const renderInput = () => {
|
|
46202
|
+
return (jsxs(Fragment, { children: [jsx(Controller, { name: name, control: control, render: ({ field: { value, onChange } }) => {
|
|
46203
|
+
return (jsx(InputStyleComponent, { disabledBackgroundColor: disabledBackgroundColor, disabledFontFamily: disabledFontFamily, disabledFontSize: disabledFontSize, disabledBold: disabledBold, disabledItalic: disabledItalic, disabledUnderline: disabledUnderline, disabled: disabled, value: value, onChange: onChange }));
|
|
46204
|
+
} }), errors && jsx(FormFeedback$1, { children: errors?.message })] }));
|
|
46205
|
+
};
|
|
46206
|
+
return (jsx(Fragment, { children: jsxs("div", { className: classNames$2(' align', {
|
|
46207
|
+
[labelSize ? labelSize : '']: labelSize,
|
|
46208
|
+
[classes ? classes : '']: classes,
|
|
46209
|
+
'form-row-inline-error': errors
|
|
46210
|
+
}, inLine === false ? 'form-group ' : 'form-row-inline d-flex'), children: [renderLabel({ isLabel, name, label, required }), jsx("div", { style: { height: `${height}px` }, className: classNames$2('form-input-content', { 'hidden-label': isLabel === false }), children: renderInput() })] }) }));
|
|
46211
|
+
};
|
|
46212
|
+
|
|
46143
46213
|
const defaultStyleExportSetting = {
|
|
46144
46214
|
title: {
|
|
46145
46215
|
color: '$black',
|
|
@@ -46218,38 +46288,24 @@ const defaultStyleExportSetting = {
|
|
|
46218
46288
|
}
|
|
46219
46289
|
};
|
|
46220
46290
|
|
|
46221
|
-
const StyleInput = (props) => {
|
|
46222
|
-
const { control, name, label, labelSize, required, errors, height, disabled, isLabel, inLine, classes, disabledBackgroundColor, disabledFontFamily, disabledFontSize, disabledBold, disabledItalic, disabledUnderline } = props;
|
|
46223
|
-
const renderInput = () => {
|
|
46224
|
-
return (jsxs(Fragment, { children: [jsx(Controller, { name: name, control: control, render: ({ field: { value, onChange } }) => {
|
|
46225
|
-
return (jsx(InputStyleComponent, { disabledBackgroundColor: disabledBackgroundColor, disabledFontFamily: disabledFontFamily, disabledFontSize: disabledFontSize, disabledBold: disabledBold, disabledItalic: disabledItalic, disabledUnderline: disabledUnderline, disabled: disabled, value: value, onChange: onChange }));
|
|
46226
|
-
} }), errors && jsx(FormFeedback$1, { children: errors?.message })] }));
|
|
46227
|
-
};
|
|
46228
|
-
return (jsx(Fragment, { children: jsxs("div", { className: classNames$2(' align', {
|
|
46229
|
-
[labelSize ? labelSize : '']: labelSize,
|
|
46230
|
-
[classes ? classes : '']: classes,
|
|
46231
|
-
'form-row-inline-error': errors
|
|
46232
|
-
}, inLine === false ? 'form-group ' : 'form-row-inline d-flex'), children: [renderLabel({ isLabel, name, label, required }), jsx("div", { style: { height: `${height}px` }, className: classNames$2('form-input-content', { 'hidden-label': isLabel === false }), children: renderInput() })] }) }));
|
|
46233
|
-
};
|
|
46234
|
-
|
|
46235
46291
|
const ExportExcelComponent = ({ openModal, typeModal, handleModal, windowSize, dataItem, columns, columnGroups }) => {
|
|
46236
46292
|
const { t } = useTranslation();
|
|
46237
46293
|
const [dataSelected, setDataSelected] = useState([]);
|
|
46238
46294
|
const [selectedGroups, setSelectedGroups] = useState([]);
|
|
46239
46295
|
const { control, reset, handleSubmit, clearErrors, getValues, setValue } = useForm({
|
|
46240
|
-
mode:
|
|
46296
|
+
mode: "onChange",
|
|
46241
46297
|
defaultValues: defaultStyleExportSetting
|
|
46242
46298
|
});
|
|
46243
46299
|
const handleCancel = () => {
|
|
46244
|
-
handleModal(
|
|
46300
|
+
handleModal("ExportExcelComponent");
|
|
46245
46301
|
clearErrors();
|
|
46246
46302
|
setDataSelected([]);
|
|
46247
46303
|
reset();
|
|
46248
46304
|
setSelectedGroups([]);
|
|
46249
46305
|
};
|
|
46250
46306
|
useEffect(() => {
|
|
46251
|
-
if (openModal && typeModal ===
|
|
46252
|
-
setValue(
|
|
46307
|
+
if (openModal && typeModal === "ExportExcel") {
|
|
46308
|
+
setValue("textTitle", dataItem.title);
|
|
46253
46309
|
}
|
|
46254
46310
|
}, [openModal]);
|
|
46255
46311
|
const handleToggleGroup = (groupName) => {
|
|
@@ -46274,9 +46330,10 @@ const ExportExcelComponent = ({ openModal, typeModal, handleModal, windowSize, d
|
|
|
46274
46330
|
submit(data);
|
|
46275
46331
|
};
|
|
46276
46332
|
const submit = (data) => {
|
|
46277
|
-
dataItem
|
|
46333
|
+
dataItem
|
|
46334
|
+
.ExportExcelApi({
|
|
46278
46335
|
id: dataItem.id,
|
|
46279
|
-
columns: dataSelected.map(item => ({ ...item, headerText: t(item.headerText) })),
|
|
46336
|
+
columns: dataSelected.map((item) => ({ ...item, headerText: t(item.headerText) })),
|
|
46280
46337
|
countRowHeader: dataItem.countRowHeader,
|
|
46281
46338
|
groupby: dataItem.groupby,
|
|
46282
46339
|
fieldSums: dataItem.fieldSums,
|
|
@@ -46284,55 +46341,57 @@ const ExportExcelComponent = ({ openModal, typeModal, handleModal, windowSize, d
|
|
|
46284
46341
|
order: dataItem.order,
|
|
46285
46342
|
organizationId: dataItem.organizationId,
|
|
46286
46343
|
style: data,
|
|
46287
|
-
title: getValues(
|
|
46288
|
-
subtitle: getValues(
|
|
46289
|
-
})
|
|
46344
|
+
title: getValues("textTitle"),
|
|
46345
|
+
subtitle: getValues("textSubtitle")
|
|
46346
|
+
})
|
|
46347
|
+
.unwrap()
|
|
46290
46348
|
.then((rs) => {
|
|
46291
46349
|
const url = window.URL.createObjectURL(new Blob([rs]));
|
|
46292
|
-
const link = document.createElement(
|
|
46350
|
+
const link = document.createElement("a");
|
|
46293
46351
|
link.href = url;
|
|
46294
|
-
link.setAttribute(
|
|
46352
|
+
link.setAttribute("download", `${dataItem.title}.xlsx`);
|
|
46295
46353
|
document.body.appendChild(link);
|
|
46296
46354
|
link.click();
|
|
46297
46355
|
handleModal();
|
|
46298
|
-
})
|
|
46356
|
+
})
|
|
46357
|
+
.catch(() => notificationError("Fail"));
|
|
46299
46358
|
};
|
|
46300
46359
|
const renderFooterButtons = () => {
|
|
46301
|
-
return (jsxs(Fragment, { children: [jsx(Button$1, { color: "primary", className: "me-1", onClick: handleSubmit(onSubmit), children: t(
|
|
46360
|
+
return (jsxs(Fragment, { children: [jsx(Button$1, { color: "primary", className: "me-1", onClick: handleSubmit(onSubmit), children: t("Export") }), jsx(Button$1, { color: "secondary", onClick: handleCancel, outline: true, className: "me-1", children: t("Close") })] }));
|
|
46302
46361
|
};
|
|
46303
46362
|
const rightToolbarTemplate = () => {
|
|
46304
|
-
return (jsx("div", { className:
|
|
46363
|
+
return (jsx("div", { className: "d-flex", children: columnGroups?.map((ele, idx) => (jsx("div", { style: { width: ele.width ?? 150 }, children: jsx(CheckboxInput, { control: control, name: `group_${ele.label}`, label: t(ele.label), reverse: true, labelSize: "align-items-center", checked: selectedGroups.includes(ele.label), callback: () => handleToggleGroup(ele.label) }) }, idx))) }));
|
|
46305
46364
|
};
|
|
46306
46365
|
const toolbarTopOptions = [
|
|
46307
46366
|
{
|
|
46308
46367
|
template: rightToolbarTemplate,
|
|
46309
|
-
align:
|
|
46368
|
+
align: "left"
|
|
46310
46369
|
}
|
|
46311
46370
|
];
|
|
46312
|
-
return (jsxs(Sidebar, { open: openModal && typeModal ===
|
|
46371
|
+
return (jsxs(Sidebar, { open: openModal && typeModal === "ExportExcel", toggleSidebar: handleCancel, width: 900, children: [jsx(ModalHeader, { typeModal: typeModal, handleModal: () => handleCancel(), title: t("Export Excel Setting") }), jsx(lib.Scrollbars, { autoHeight: true, autoHeightMax: windowSize.innerHeight - 120, autoHeightMin: windowSize.innerHeight - 120, children: jsxs(ModalBody$1, { children: [jsxs("div", { className: "box form-box__border mb-2", children: [jsx("h5", { className: "m-0 form-box__border--title", children: t("Tùy chỉnh cột") }), jsx(Row$1, { className: "gy-1", children: jsx(Col$1, { lg: 12, md: 12, xs: 12, children: jsx(TableEdit, { dataSource: getCombinedColumns(), toolbarSetting: {
|
|
46313
46372
|
showTopToolbar: true,
|
|
46314
46373
|
showBottomToolbar: true,
|
|
46315
46374
|
toolbarBottomOptions: toolbarTopOptions
|
|
46316
46375
|
}, maxHeight: windowSize.innerHeight - 525, minHeight: 150, columns: [
|
|
46317
46376
|
{
|
|
46318
|
-
field:
|
|
46319
|
-
headerText:
|
|
46320
|
-
textAlign:
|
|
46321
|
-
invisibleDisable: true,
|
|
46377
|
+
field: "checkbox",
|
|
46378
|
+
headerText: "",
|
|
46379
|
+
textAlign: "center",
|
|
46322
46380
|
width: 20
|
|
46323
46381
|
},
|
|
46324
46382
|
{
|
|
46325
|
-
field:
|
|
46326
|
-
|
|
46327
|
-
headerText: '',
|
|
46383
|
+
field: "field",
|
|
46384
|
+
headerText: "",
|
|
46328
46385
|
visible: false,
|
|
46329
46386
|
isPrimarykey: true
|
|
46330
46387
|
},
|
|
46331
46388
|
{
|
|
46332
|
-
type:
|
|
46389
|
+
type: "text",
|
|
46333
46390
|
field: "headerText",
|
|
46334
|
-
headerText:
|
|
46335
|
-
template: (value) => {
|
|
46391
|
+
headerText: "Column name",
|
|
46392
|
+
template: (value) => {
|
|
46393
|
+
return t(value.headerText);
|
|
46394
|
+
},
|
|
46336
46395
|
width: 360,
|
|
46337
46396
|
minWidth: 320,
|
|
46338
46397
|
maxWidth: 400
|
|
@@ -46340,7 +46399,7 @@ const ExportExcelComponent = ({ openModal, typeModal, handleModal, windowSize, d
|
|
|
46340
46399
|
], isMulti: true, searchSetting: {
|
|
46341
46400
|
searchEnable: true,
|
|
46342
46401
|
searchClient: true
|
|
46343
|
-
}, selectedItem: dataSelected, setSelectedItem: setDataSelected, selectEnable: true, addDisable: true, editDisable: true },
|
|
46402
|
+
}, selectedItem: dataSelected, setSelectedItem: setDataSelected, selectEnable: true, addDisable: true, editDisable: true }, "TableFile") }) })] }), jsxs("div", { className: "box form-box__border", children: [jsx("h5", { className: "m-0 form-box__border--title", children: t("Title report") }), jsxs(Row$1, { className: "gy-1", children: [jsx(Col$1, { lg: 8, md: 12, xs: 12, children: jsx(TextInput, { control: control, name: "textTitle", label: t("Title report"), labelSize: "label-small", placeholder: t("Đặt tên cho tiêu đề báo cáo"), inLine: true }) }), jsx(Col$1, { lg: 8, md: 12, xs: 12, children: jsx(TextInput, { control: control, name: "textSubtitle", label: t("Subtitle"), labelSize: "label-small", placeholder: t("Đặt tên cho tiêu đề phụ"), inLine: true }) }), jsx(Col$1, { lg: 8, md: 12, xs: 12, children: jsx(StyleInput, { control: control, name: "title", disabledBackgroundColor: true, label: "Title report", labelSize: "label-small" }) }), jsx(Col$1, { lg: 4, md: 6, xs: 6, children: jsx(NumberInput, { control: control, name: "title.row", label: "Row", labelSize: "label-small", min: 0 }) }), jsx(Col$1, { lg: 8, md: 12, xs: 12, children: jsx(StyleInput, { control: control, name: "subtitle", disabledBackgroundColor: true, label: "Subtitle", labelSize: "label-small" }) }), jsx(Col$1, { lg: 4, md: 6, xs: 6, children: jsx(NumberInput, { control: control, name: "subtitle.row", label: "Row", labelSize: "label-small", min: 0 }) }), jsx(Col$1, { lg: 8, md: 12, xs: 12, children: jsx(StyleInput, { control: control, name: "header", label: "Title table", labelSize: "label-small" }) }), jsx(Col$1, { lg: 4, md: 6, xs: 6, children: jsx(NumberInput, { control: control, name: "header.row", label: "Row", labelSize: "label-small", min: 0 }) }), jsx(Col$1, { lg: 8, md: 12, xs: 12, children: jsx(StyleInput, { control: control, name: "content", label: "Content table", labelSize: "label-small" }) })] })] })] }) }), jsx("div", { className: "d-flex justify-content-end p-1", style: { boxShadow: "0 4px 24px 0 rgb(34 41 47 / 10%)" }, children: renderFooterButtons() })] }));
|
|
46344
46403
|
};
|
|
46345
46404
|
|
|
46346
46405
|
const TabValidateImportExcel = (props) => {
|