react-table-edit 1.4.36 → 1.4.37
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 +7 -0
- package/dist/component/type/index.d.ts +12 -14
- package/dist/index.d.ts +19 -14
- package/dist/index.js +329 -281
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +329 -281
- 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++) {
|
|
@@ -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
|
}
|
|
@@ -17691,7 +17694,7 @@ const calculateTableStructure = (columns) => {
|
|
|
17691
17694
|
};
|
|
17692
17695
|
levels[level].push(cell);
|
|
17693
17696
|
const headerKey = `${level}-${indexCol}`;
|
|
17694
|
-
if (col.fixedType ===
|
|
17697
|
+
if (col.fixedType === "left" && col.visible !== false) {
|
|
17695
17698
|
objHeaderWidthFixLeft[headerKey] = leftTotal;
|
|
17696
17699
|
}
|
|
17697
17700
|
if (!hasChildren) {
|
|
@@ -17699,16 +17702,16 @@ const calculateTableStructure = (columns) => {
|
|
|
17699
17702
|
const width = col.width ?? 40;
|
|
17700
17703
|
cell.index = index;
|
|
17701
17704
|
flat.push(cell);
|
|
17702
|
-
if (col.fixedType ===
|
|
17705
|
+
if (col.fixedType === "left" && col.visible !== false) {
|
|
17703
17706
|
objWidthFixLeft[index] = leftTotal;
|
|
17704
17707
|
leftTotal += width;
|
|
17705
17708
|
}
|
|
17706
|
-
if (col.fixedType ===
|
|
17709
|
+
if (col.fixedType === "right" && col.in !== false) {
|
|
17707
17710
|
rightTotal -= width;
|
|
17708
17711
|
objWidthFixRight[index] = rightTotal;
|
|
17709
17712
|
}
|
|
17710
17713
|
}
|
|
17711
|
-
if (col.fixedType ===
|
|
17714
|
+
if (col.fixedType === "right" && col.visible !== false) {
|
|
17712
17715
|
objHeaderWidthFixRight[headerKey] = rightTotal;
|
|
17713
17716
|
}
|
|
17714
17717
|
return colspanSum + colspan;
|
|
@@ -40355,7 +40358,7 @@ const SidebarSetColumn = (props) => {
|
|
|
40355
40358
|
};
|
|
40356
40359
|
}, []);
|
|
40357
40360
|
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(
|
|
40361
|
+
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
40362
|
};
|
|
40360
40363
|
const visibleTemplate = (item, index) => {
|
|
40361
40364
|
return (jsx(Input$1, { defaultChecked: item.visible ?? true, disabled: item.invisibleDisable, type: "checkbox", style: { height: 18 }, className: " cursor-pointer", onChange: (e) => {
|
|
@@ -40366,14 +40369,14 @@ const SidebarSetColumn = (props) => {
|
|
|
40366
40369
|
} }));
|
|
40367
40370
|
};
|
|
40368
40371
|
const fixColumnTemplate = (item, index) => {
|
|
40369
|
-
return (jsx(Input$1, { defaultChecked: item.fixedType ===
|
|
40372
|
+
return (jsx(Input$1, { defaultChecked: item.fixedType === "left" || item.fixedType === "right", type: "checkbox", style: { height: 18 }, className: " cursor-pointer", onChange: (e) => {
|
|
40370
40373
|
if (dataSource) {
|
|
40371
40374
|
if (e.target.checked) {
|
|
40372
|
-
if (
|
|
40373
|
-
dataSource[index].fixedType =
|
|
40375
|
+
if (index * 2 <= dataSource.length) {
|
|
40376
|
+
dataSource[index].fixedType = "left";
|
|
40374
40377
|
}
|
|
40375
40378
|
else {
|
|
40376
|
-
dataSource[index].fixedType =
|
|
40379
|
+
dataSource[index].fixedType = "right";
|
|
40377
40380
|
}
|
|
40378
40381
|
}
|
|
40379
40382
|
else {
|
|
@@ -40385,7 +40388,7 @@ const SidebarSetColumn = (props) => {
|
|
|
40385
40388
|
};
|
|
40386
40389
|
const columns = [
|
|
40387
40390
|
{
|
|
40388
|
-
field:
|
|
40391
|
+
field: "headerText",
|
|
40389
40392
|
headerText: "Column name",
|
|
40390
40393
|
template: (e) => {
|
|
40391
40394
|
return jsx(Fragment$1, { children: t(e.headerText) });
|
|
@@ -40396,29 +40399,29 @@ const SidebarSetColumn = (props) => {
|
|
|
40396
40399
|
minWidth: 150
|
|
40397
40400
|
},
|
|
40398
40401
|
{
|
|
40399
|
-
field:
|
|
40402
|
+
field: "",
|
|
40400
40403
|
template: visibleTemplate,
|
|
40401
40404
|
headerText: "Display",
|
|
40402
|
-
textAlign:
|
|
40405
|
+
textAlign: "center",
|
|
40403
40406
|
visible: true,
|
|
40404
40407
|
width: 100,
|
|
40405
40408
|
maxWidth: 120,
|
|
40406
40409
|
minWidth: 80
|
|
40407
40410
|
},
|
|
40408
40411
|
{
|
|
40409
|
-
field:
|
|
40412
|
+
field: "",
|
|
40410
40413
|
template: fixColumnTemplate,
|
|
40411
40414
|
headerText: "Fix the column",
|
|
40412
|
-
textAlign:
|
|
40415
|
+
textAlign: "center",
|
|
40413
40416
|
visible: true,
|
|
40414
40417
|
width: 100,
|
|
40415
40418
|
maxWidth: 120,
|
|
40416
40419
|
minWidth: 80
|
|
40417
40420
|
},
|
|
40418
40421
|
{
|
|
40419
|
-
field:
|
|
40422
|
+
field: "width",
|
|
40420
40423
|
headerText: "Column width",
|
|
40421
|
-
textAlign:
|
|
40424
|
+
textAlign: "right",
|
|
40422
40425
|
visible: true,
|
|
40423
40426
|
width: 100,
|
|
40424
40427
|
maxWidth: 120,
|
|
@@ -40426,44 +40429,42 @@ const SidebarSetColumn = (props) => {
|
|
|
40426
40429
|
}
|
|
40427
40430
|
];
|
|
40428
40431
|
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 :
|
|
40432
|
+
return (jsx(Fragment, { children: col.visible !== false && (jsx("th", { className: classNames$2(`r-headercell fix-${col.fixedType}`, { "cell-fixed": col.fixedType }), style: {
|
|
40433
|
+
width: col.fixedType ? Number(col.maxWidth ? col.maxWidth : col.width ? col.width : col.minWidth ?? "auto") : col.width,
|
|
40434
|
+
minWidth: col.fixedType ? Number(col.maxWidth ? col.maxWidth : col.width ? col.width : col.minWidth ?? "auto") : col.minWidth,
|
|
40432
40435
|
top: `${0 * 42}px`,
|
|
40433
40436
|
maxWidth: col.maxWidth
|
|
40434
|
-
}, children: jsx("div", { role: "textbox", title: t(col.headerText ??
|
|
40437
|
+
}, children: jsx("div", { role: "textbox", title: t(col.headerText ?? ""), style: {
|
|
40435
40438
|
height: `${1 * 42}px`,
|
|
40436
|
-
justifyContent: col.textAlign ??
|
|
40437
|
-
}, className: "r-headercell-div", children: t(col.headerText ??
|
|
40439
|
+
justifyContent: col.textAlign ?? "left"
|
|
40440
|
+
}, className: "r-headercell-div", children: t(col.headerText ?? "") }) })) }, `header-${indexCol}`));
|
|
40438
40441
|
};
|
|
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(
|
|
40442
|
+
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) => {
|
|
40443
|
+
return renderHeaderCol(col, index);
|
|
40444
|
+
}) }) }), jsx("tbody", { className: "r-gridcontent", children: dataSource?.map((row, indexRow) => {
|
|
40445
|
+
return (jsx("tr", { className: classNames$2("r-row", { "last-row": indexRow === dataSource.length - 1 }, { "fisrt-row": indexRow === 0 }), children: columns.map((col, indexCol) => {
|
|
40443
40446
|
let value = row[col.field];
|
|
40444
|
-
if (col.type ===
|
|
40445
|
-
value = formartNumberic(row[col.field],
|
|
40447
|
+
if (col.type === "numeric" || (col.typeCondition && col.typeCondition(row) === "numeric")) {
|
|
40448
|
+
value = formartNumberic(row[col.field], ",", ".", col.numericSettings?.fraction, true) ?? 0;
|
|
40446
40449
|
}
|
|
40447
|
-
return (jsx(Fragment, { children: col.visible !== false && jsx("td", { className: classNames$2(`r-rowcell fix-${col.fixedType}`, {
|
|
40450
|
+
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
40451
|
padding: 0,
|
|
40449
|
-
textAlign: col.textAlign ? col.textAlign :
|
|
40452
|
+
textAlign: col.textAlign ? col.textAlign : "left"
|
|
40450
40453
|
}, onFocus: (e) => {
|
|
40451
40454
|
if (indexRow !== indexFocus) {
|
|
40452
40455
|
setIndexFocus(indexRow);
|
|
40453
40456
|
}
|
|
40454
40457
|
e.stopPropagation();
|
|
40455
40458
|
}, onClick: (e) => {
|
|
40456
|
-
if (e.target.nodeName ===
|
|
40459
|
+
if (e.target.nodeName === "DIV" || e.target.nodeName === "TD") {
|
|
40457
40460
|
if (indexRow !== indexFocus) {
|
|
40458
40461
|
setIndexFocus(indexRow);
|
|
40459
40462
|
}
|
|
40460
40463
|
e.stopPropagation();
|
|
40461
40464
|
}
|
|
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));
|
|
40465
|
+
}, children: jsx("div", { className: classNames$2("r-rowcell-div"), style: {
|
|
40466
|
+
width: col.fixedType ? Number(col.maxWidth ? col.maxWidth : col.width ? col.width : col.minWidth ?? "auto") : "auto"
|
|
40467
|
+
}, 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
40468
|
}) }, `row-${indexRow}`));
|
|
40468
40469
|
}) })] }) }) }) }), jsx("div", { className: "d-flex justify-content-end p-1 ", style: { boxShadow: "0 4px 24px 0 rgb(34 41 47 / 10%)" }, children: renderFooterButtons() })] }));
|
|
40469
40470
|
};
|
|
@@ -42795,7 +42796,7 @@ const ToolbarBottom = ({ handleAdd, handleDuplicate, handleInsertBefore, handleI
|
|
|
42795
42796
|
|
|
42796
42797
|
const TableEdit = forwardRef((props, ref) => {
|
|
42797
42798
|
const { t } = useTranslation();
|
|
42798
|
-
const { idTable, dataSource, columns,
|
|
42799
|
+
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, optionsFilter } = props;
|
|
42799
42800
|
useImperativeHandle(ref, () => {
|
|
42800
42801
|
return {
|
|
42801
42802
|
refeshFocusRow: handleRefeshRow
|
|
@@ -42804,28 +42805,26 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
42804
42805
|
const [refreshRow, setRefreshRow] = useState(false);
|
|
42805
42806
|
const [indexFocus, setIndexFocus] = useState(-1);
|
|
42806
42807
|
const [selectedRows, setSelectedRows] = useState([]);
|
|
42807
|
-
const [contentColumns, setContentColumns] = useState([]);
|
|
42808
42808
|
const [openPopupSetupColumn, setOpenPopupSetupColumn] = useState(false);
|
|
42809
|
-
const [searchTerm, setSearchTerm] = useState(
|
|
42809
|
+
const [searchTerm, setSearchTerm] = useState("");
|
|
42810
42810
|
const [orderBy, setOrderBy] = useState([]);
|
|
42811
42811
|
const [filterBy, setFilterBy] = useState([]);
|
|
42812
|
+
const [refreshColumns, setRefreshColumns] = useState(false);
|
|
42812
42813
|
const tableElement = useRef(null);
|
|
42813
42814
|
const gridRef = useRef(null);
|
|
42814
42815
|
const totalCount = dataSource.length;
|
|
42815
42816
|
const pagingClient = pagingSetting?.allowPaging && (pagingSetting?.pagingClient || !(editDisable || addDisable));
|
|
42816
42817
|
const searchClient = searchSetting?.searchEnable && (searchSetting?.searchClient || !(editDisable || addDisable));
|
|
42817
|
-
const fieldKey = columns.find((item) => item.isPrimarykey === true)?.field ??
|
|
42818
|
+
const fieldKey = columns.find((item) => item.isPrimarykey === true)?.field ?? "id";
|
|
42818
42819
|
const fieldUniKey = columns.filter((item) => item.isUnikey === true)?.map((item) => item.field);
|
|
42819
42820
|
useEffect(() => {
|
|
42820
42821
|
if (pagingClient && pagingSetting.setCurrentPage && Math.ceil(totalCount / (pagingSetting?.pageSize ?? 1)) < (pagingSetting.currentPage ?? 1)) {
|
|
42821
42822
|
pagingSetting.setCurrentPage(1);
|
|
42822
42823
|
}
|
|
42823
42824
|
}, [dataSource]);
|
|
42824
|
-
const { levels: headerColumns, flatVisble, objWidthFixLeft, objWidthFixRight, lastObjWidthFixLeft, fisrtObjWidthFixRight, objHeaderWidthFixLeft, objHeaderWidthFixRight, indexFirstEdit: indexFirstEdit, indexLastEdit: indexLastEdit } = useMemo(() => {
|
|
42825
|
-
|
|
42826
|
-
|
|
42827
|
-
return obj;
|
|
42828
|
-
}, [columns]);
|
|
42825
|
+
const { levels: headerColumns, flat: contentColumns, flatVisble, objWidthFixLeft, objWidthFixRight, lastObjWidthFixLeft, fisrtObjWidthFixRight, objHeaderWidthFixLeft, objHeaderWidthFixRight, indexFirstEdit: indexFirstEdit, indexLastEdit: indexLastEdit } = useMemo(() => {
|
|
42826
|
+
return calculateTableStructure(columns);
|
|
42827
|
+
}, [columns, refreshColumns]);
|
|
42829
42828
|
const handleRefeshRow = () => {
|
|
42830
42829
|
setRefreshRow(true);
|
|
42831
42830
|
setTimeout(() => {
|
|
@@ -42845,7 +42844,7 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
42845
42844
|
}
|
|
42846
42845
|
};
|
|
42847
42846
|
const handleKeyPress = (e) => {
|
|
42848
|
-
if (
|
|
42847
|
+
if (e.code === "Enter" || e.code === "NumpadEnter") {
|
|
42849
42848
|
if (searchSetting?.setSearchTerm) {
|
|
42850
42849
|
searchSetting?.setSearchTerm(e.target.value);
|
|
42851
42850
|
}
|
|
@@ -42857,9 +42856,9 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
42857
42856
|
}
|
|
42858
42857
|
};
|
|
42859
42858
|
const searchTemplate = () => {
|
|
42860
|
-
return (jsx(Fragment, { children: jsx("div", { className: "me-50 r-search", children: jsx(ReactInput, { style: { width:
|
|
42859
|
+
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
42860
|
};
|
|
42862
|
-
const defaultToolbarOption = searchSetting?.searchEnable ? [{ template: searchTemplate, align:
|
|
42861
|
+
const defaultToolbarOption = searchSetting?.searchEnable ? [{ template: searchTemplate, align: "left" }] : [];
|
|
42863
42862
|
let toolbarTopOption = [];
|
|
42864
42863
|
if (toolbarSetting?.toolbarOptions) {
|
|
42865
42864
|
toolbarTopOption = [...defaultToolbarOption, ...toolbarSetting?.toolbarOptions];
|
|
@@ -42870,8 +42869,8 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
42870
42869
|
const RenderEditCell = (row, col, indexCol, indexRow) => {
|
|
42871
42870
|
/*eslint-disable */
|
|
42872
42871
|
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(
|
|
42872
|
+
case "date":
|
|
42873
|
+
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
42874
|
row[col.field] = date ? new Date(date.getTime() + 7 * 60 * 60 * 1000) : undefined;
|
|
42876
42875
|
if (col.callback) {
|
|
42877
42876
|
col.callback(row[col.field], indexRow, row);
|
|
@@ -42887,8 +42886,8 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
42887
42886
|
e.preventDefault();
|
|
42888
42887
|
}
|
|
42889
42888
|
} }));
|
|
42890
|
-
case
|
|
42891
|
-
return (jsx(DateInput, { id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`, className: classNames$2(
|
|
42889
|
+
case "datetime":
|
|
42890
|
+
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
42891
|
row[col.field] = date;
|
|
42893
42892
|
if (col.callback) {
|
|
42894
42893
|
col.callback(row[col.field], indexRow, row);
|
|
@@ -42902,41 +42901,49 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
42902
42901
|
e.preventDefault();
|
|
42903
42902
|
}
|
|
42904
42903
|
} }));
|
|
42905
|
-
case
|
|
42904
|
+
case "select":
|
|
42906
42905
|
let valueSelect;
|
|
42907
42906
|
let optionsSelect = [];
|
|
42908
42907
|
if (col.selectSettings?.optionsField) {
|
|
42909
42908
|
optionsSelect = row[col.selectSettings?.optionsField] ? row[col.selectSettings?.optionsField] : [];
|
|
42910
42909
|
}
|
|
42911
42910
|
else {
|
|
42912
|
-
optionsSelect = col.selectSettings?.options
|
|
42911
|
+
optionsSelect = col.selectSettings?.options
|
|
42912
|
+
? col.selectSettings?.validateOption
|
|
42913
|
+
? col.selectSettings?.options.filter((item) => col.selectSettings?.validateOption(item, row))
|
|
42914
|
+
: col.selectSettings?.options
|
|
42915
|
+
: [];
|
|
42913
42916
|
}
|
|
42914
42917
|
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 ??
|
|
42918
|
+
valueSelect = optionsSelect.filter((x) => row[col.field].some((y) => (col.selectSettings?.compareFunction ? col.selectSettings.compareFunction(x, row) : x[col.selectSettings?.fieldValue ?? "value"] === y)));
|
|
42916
42919
|
}
|
|
42917
42920
|
else {
|
|
42918
|
-
valueSelect =
|
|
42921
|
+
valueSelect =
|
|
42922
|
+
!isNullOrUndefined(row[col.field]) && row[col.field] !== ""
|
|
42923
|
+
? optionsSelect?.find((val) => col.selectSettings?.compareFunction ? col.selectSettings.compareFunction(val, row) : val[col.selectSettings?.fieldValue ?? "value"] === row[col.field])
|
|
42924
|
+
: "";
|
|
42919
42925
|
if (!valueSelect && col.selectSettings?.defaultValue) {
|
|
42920
42926
|
valueSelect = col.selectSettings?.defaultValue(row);
|
|
42921
42927
|
}
|
|
42922
42928
|
}
|
|
42923
42929
|
return (jsx(SelectTable, { id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`, value: valueSelect, options: optionsSelect, onChange: (val) => {
|
|
42924
42930
|
if (col.selectSettings?.isMulti) {
|
|
42925
|
-
row[col.field] = (val?.length ?? 0) > 0 ? val.map((item) => item[col.selectSettings?.fieldValue ??
|
|
42931
|
+
row[col.field] = (val?.length ?? 0) > 0 ? val.map((item) => item[col.selectSettings?.fieldValue ?? "value"]) : [];
|
|
42926
42932
|
}
|
|
42927
42933
|
else {
|
|
42928
|
-
row[col.field] = !isNullOrUndefined(val) ? val[col.selectSettings?.fieldValue ??
|
|
42934
|
+
row[col.field] = !isNullOrUndefined(val) ? val[col.selectSettings?.fieldValue ?? "value"] : undefined;
|
|
42929
42935
|
}
|
|
42930
42936
|
if (val && col.selectSettings?.loadOptions && isMulti) {
|
|
42931
|
-
if (isMulti) {
|
|
42937
|
+
if (isMulti) {
|
|
42938
|
+
//push giá trị vào option khi loadoption
|
|
42932
42939
|
val.forEach((e) => {
|
|
42933
|
-
if (!optionsSelect.some((a) => a[col.selectSettings?.fieldValue ??
|
|
42940
|
+
if (!optionsSelect.some((a) => a[col.selectSettings?.fieldValue ?? "value"] === e[col.selectSettings?.fieldValue ?? "value"])) {
|
|
42934
42941
|
optionsSelect.unshift(e);
|
|
42935
42942
|
}
|
|
42936
42943
|
});
|
|
42937
42944
|
}
|
|
42938
42945
|
else if (!col.selectSettings?.defaultValue) {
|
|
42939
|
-
if (!optionsSelect.some((a) => a[col.selectSettings?.fieldValue ??
|
|
42946
|
+
if (!optionsSelect.some((a) => a[col.selectSettings?.fieldValue ?? "value"] === val[col.selectSettings?.fieldValue ?? "value"])) {
|
|
42940
42947
|
optionsSelect.unshift(val);
|
|
42941
42948
|
}
|
|
42942
42949
|
}
|
|
@@ -42945,27 +42952,21 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
42945
42952
|
col.callback(val, indexRow, row);
|
|
42946
42953
|
}
|
|
42947
42954
|
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) => {
|
|
42955
|
+
}, 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
42956
|
if (toolbarSetting?.showBottomToolbar && !editDisable && !addDisable && !col.disablePaste) {
|
|
42956
42957
|
pasteDataFromExcel(indexRow, indexCol, e);
|
|
42957
42958
|
e.preventDefault();
|
|
42958
42959
|
}
|
|
42959
42960
|
} }));
|
|
42960
|
-
case
|
|
42961
|
+
case "selectTree":
|
|
42961
42962
|
const findItemInTree = (items, value) => {
|
|
42962
42963
|
for (let index = 0; index < items.length; index++) {
|
|
42963
42964
|
const item = items[index];
|
|
42964
|
-
if (item[col.selectSettings?.fieldValue ? col.selectSettings?.fieldValue :
|
|
42965
|
+
if (item[col.selectSettings?.fieldValue ? col.selectSettings?.fieldValue : "value"] === value) {
|
|
42965
42966
|
return { ...item };
|
|
42966
42967
|
}
|
|
42967
|
-
else if (item[col.selectSettings?.fieldChild ??
|
|
42968
|
-
const itemFilter = findItemInTree(item[col.selectSettings?.fieldChild ??
|
|
42968
|
+
else if (item[col.selectSettings?.fieldChild ?? "children"]?.length > 0) {
|
|
42969
|
+
const itemFilter = findItemInTree(item[col.selectSettings?.fieldChild ?? "children"], value);
|
|
42969
42970
|
if (itemFilter) {
|
|
42970
42971
|
return itemFilter;
|
|
42971
42972
|
}
|
|
@@ -42978,39 +42979,37 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
42978
42979
|
optionsSelectTree = row[col.selectSettings?.optionsField] ? row[col.selectSettings?.optionsField] : [];
|
|
42979
42980
|
}
|
|
42980
42981
|
else {
|
|
42981
|
-
optionsSelectTree = col.selectSettings?.options
|
|
42982
|
+
optionsSelectTree = col.selectSettings?.options
|
|
42983
|
+
? col.selectSettings?.validateOption
|
|
42984
|
+
? col.selectSettings?.options.filter((item) => col.selectSettings?.validateOption(item, row))
|
|
42985
|
+
: col.selectSettings?.options
|
|
42986
|
+
: [];
|
|
42982
42987
|
}
|
|
42983
42988
|
if (col.selectSettings?.isMulti) {
|
|
42984
42989
|
valueSelectTree = row[col.field];
|
|
42985
42990
|
}
|
|
42986
42991
|
else {
|
|
42987
|
-
valueSelectTree =
|
|
42992
|
+
valueSelectTree = !isNullOrUndefined(row[col.field]) && row[col.field] !== "" ? findItemInTree(optionsSelectTree, row[col.field]) : "";
|
|
42988
42993
|
}
|
|
42989
42994
|
return (jsx(SelectTableTree, { id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`, value: valueSelectTree, options: optionsSelectTree, onChange: (val) => {
|
|
42990
42995
|
if (col.selectSettings?.isMulti) {
|
|
42991
42996
|
row[col.field] = !isNullOrUndefined(val) ? val : [];
|
|
42992
42997
|
}
|
|
42993
42998
|
else {
|
|
42994
|
-
row[col.field] = !isNullOrUndefined(val) ? val[col.selectSettings?.fieldValue ??
|
|
42999
|
+
row[col.field] = !isNullOrUndefined(val) ? val[col.selectSettings?.fieldValue ?? "value"] : undefined;
|
|
42995
43000
|
}
|
|
42996
43001
|
if (col.callback) {
|
|
42997
43002
|
col.callback(val, indexRow, row);
|
|
42998
43003
|
}
|
|
42999
43004
|
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) => {
|
|
43005
|
+
}, 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
43006
|
if (toolbarSetting?.showBottomToolbar && !editDisable && !addDisable && !col.disablePaste) {
|
|
43008
43007
|
pasteDataFromExcel(indexRow, indexCol, e);
|
|
43009
43008
|
e.preventDefault();
|
|
43010
43009
|
}
|
|
43011
43010
|
} }));
|
|
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 ??
|
|
43011
|
+
case "checkbox":
|
|
43012
|
+
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
43013
|
row[col.field] = val.currentTarget.checked;
|
|
43015
43014
|
if (col.callback) {
|
|
43016
43015
|
col.callback(val.target.value, indexRow, row);
|
|
@@ -43019,16 +43018,16 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
43019
43018
|
}, onKeyDown: (e) => {
|
|
43020
43019
|
checkKeyDown(e, row, col, indexRow + 1, indexCol + 1);
|
|
43021
43020
|
} }));
|
|
43022
|
-
case
|
|
43021
|
+
case "numeric":
|
|
43023
43022
|
const numericFormatProps = {
|
|
43024
|
-
value: !isNullOrUndefined(row[col.field]) ? row[col.field].toString() :
|
|
43023
|
+
value: !isNullOrUndefined(row[col.field]) ? row[col.field].toString() : "",
|
|
43025
43024
|
thousandSeparator: checkThousandSeparator(formatSetting?.thousandSeparator, formatSetting?.decimalSeparator),
|
|
43026
43025
|
decimalSeparator: checkDecimalSeparator(formatSetting?.thousandSeparator, formatSetting?.decimalSeparator),
|
|
43027
43026
|
allowNegative: col.numericSettings?.allowNegative ?? false,
|
|
43028
43027
|
decimalScale: col.numericSettings?.fraction ?? 0
|
|
43029
43028
|
};
|
|
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 ??
|
|
43029
|
+
let floatValue = parseFloat(row[col.field] ?? "0");
|
|
43030
|
+
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
43031
|
floatValue = values?.floatValue;
|
|
43033
43032
|
}, onFocus: (e) => {
|
|
43034
43033
|
e.target.setSelectionRange(0, e.target.innerText.length - 1);
|
|
@@ -43041,7 +43040,7 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
43041
43040
|
handleDataChange(row, col, indexRow);
|
|
43042
43041
|
}
|
|
43043
43042
|
}, onKeyDown: (e) => {
|
|
43044
|
-
if (e.key ===
|
|
43043
|
+
if (e.key === "ArrowDown" || e.key === "NumpadEnter" || e.key === "ArrowUp" || e.key === "Enter" || e.key === "Tab") {
|
|
43045
43044
|
if (floatValue !== row[col.field]) {
|
|
43046
43045
|
row[col.field] = !isNaN(floatValue) ? floatValue : 0;
|
|
43047
43046
|
if (col.callback) {
|
|
@@ -43057,8 +43056,8 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
43057
43056
|
e.preventDefault();
|
|
43058
43057
|
}
|
|
43059
43058
|
} }));
|
|
43060
|
-
case
|
|
43061
|
-
return (jsx("div", { style: { padding:
|
|
43059
|
+
case "color":
|
|
43060
|
+
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
43061
|
if (row[col.field] != val.target?.value) {
|
|
43063
43062
|
row[col.field] = val.target?.value;
|
|
43064
43063
|
if (col.callback) {
|
|
@@ -43069,8 +43068,8 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
43069
43068
|
}, onKeyDown: (val) => {
|
|
43070
43069
|
checkKeyDown(val, row, col, indexRow + 1, indexCol + 1);
|
|
43071
43070
|
} }, `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) :
|
|
43071
|
+
case "form":
|
|
43072
|
+
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
43073
|
Object.assign(row, val);
|
|
43075
43074
|
handleDataChange(row, col, indexRow);
|
|
43076
43075
|
}, invalid: col.validate && col.validate(row[col.field], row), textAlign: col.textAlign, template: col.template, onKeyDown: (e) => {
|
|
@@ -43081,8 +43080,8 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
43081
43080
|
e.preventDefault();
|
|
43082
43081
|
}
|
|
43083
43082
|
} }));
|
|
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) :
|
|
43083
|
+
case "formInline":
|
|
43084
|
+
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
43085
|
Object.assign(row, val);
|
|
43087
43086
|
handleDataChange(row, col, indexRow);
|
|
43088
43087
|
}, invalid: col.validate && col.validate(row[col.field], row), textAlign: col.textAlign, template: col.template, onKeyDown: (e) => {
|
|
@@ -43094,7 +43093,7 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
43094
43093
|
}
|
|
43095
43094
|
} }));
|
|
43096
43095
|
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]) ?
|
|
43096
|
+
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
43097
|
if (row[col.field] != val.target?.value) {
|
|
43099
43098
|
row[col.field] = val.target?.value;
|
|
43100
43099
|
if (col.callback) {
|
|
@@ -43122,8 +43121,8 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
43122
43121
|
setTimeout(() => {
|
|
43123
43122
|
const element = document.getElementById(`${idTable}-col${col}-row${row}`);
|
|
43124
43123
|
if (element) {
|
|
43125
|
-
if (element.className.includes(
|
|
43126
|
-
element.getElementsByTagName(
|
|
43124
|
+
if (element.className.includes("react-select") || element.className.includes("form-edit")) {
|
|
43125
|
+
element.getElementsByTagName("input")[0]?.focus();
|
|
43127
43126
|
}
|
|
43128
43127
|
else {
|
|
43129
43128
|
element.focus();
|
|
@@ -43132,16 +43131,17 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
43132
43131
|
if (tableElement.current) {
|
|
43133
43132
|
const parentRect = tableElement.current.getBoundingClientRect();
|
|
43134
43133
|
const childRect = element.getBoundingClientRect();
|
|
43135
|
-
const offset = childRect.left - parentRect.left + tableElement.current.scrollLeft -
|
|
43136
|
-
tableElement.current.scrollTo({ left: offset, behavior:
|
|
43134
|
+
const offset = childRect.left - parentRect.left + tableElement.current.scrollLeft - parentRect.width / 2 + childRect.width / 2;
|
|
43135
|
+
tableElement.current.scrollTo({ left: offset, behavior: "smooth" });
|
|
43137
43136
|
}
|
|
43138
43137
|
}
|
|
43139
43138
|
if ((tableElement.current?.scrollHeight ?? 0) > 0) {
|
|
43140
43139
|
if ((tableElement.current?.scrollTop ?? 0) > ((row - 1) % (pagingSetting?.pageSize ?? 10000)) * 34) {
|
|
43141
|
-
tableElement.current?.scrollTo({ behavior:
|
|
43140
|
+
tableElement.current?.scrollTo({ behavior: "smooth", top: ((row - 1) % (pagingSetting?.pageSize ?? 10000)) * 34 });
|
|
43142
43141
|
}
|
|
43143
|
-
else if ((
|
|
43144
|
-
|
|
43142
|
+
else if ((tableElement.current?.clientHeight ?? 0) - (haveSum ? 30 : 0) - headerColumns.length * 42 <
|
|
43143
|
+
(row % (pagingSetting?.pageSize ?? 10000)) * 34 - (tableElement.current?.scrollTop ?? 0)) {
|
|
43144
|
+
tableElement.current?.scrollTo({ behavior: "smooth", top: (tableElement.current?.scrollTop ?? 0) + 34 });
|
|
43145
43145
|
}
|
|
43146
43146
|
}
|
|
43147
43147
|
}
|
|
@@ -43150,7 +43150,7 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
43150
43150
|
//Thêm dòng mới
|
|
43151
43151
|
const moveIndexRowToNewPage = () => {
|
|
43152
43152
|
changeDataSource(dataSource, 1);
|
|
43153
|
-
if (pagingClient && pagingSetting?.setCurrentPage &&
|
|
43153
|
+
if (pagingClient && pagingSetting?.setCurrentPage && totalCount % (pagingSetting?.pageSize ?? 0) === 0) {
|
|
43154
43154
|
pagingSetting?.setCurrentPage((pagingSetting?.currentPage ?? 0) + 1);
|
|
43155
43155
|
}
|
|
43156
43156
|
if (tableElement) {
|
|
@@ -43225,25 +43225,25 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
43225
43225
|
return undefined;
|
|
43226
43226
|
};
|
|
43227
43227
|
const pasteDataFromExcel = async (currenRowIndex, indexCol, e) => {
|
|
43228
|
-
const clipboard = (e.clipboardData || window.Clipboard).getData(
|
|
43229
|
-
const rowsClipboard = clipboard.trimEnd().split(
|
|
43228
|
+
const clipboard = (e.clipboardData || window.Clipboard).getData("text");
|
|
43229
|
+
const rowsClipboard = clipboard.trimEnd().split("\n");
|
|
43230
43230
|
setIndexFocus(-1);
|
|
43231
43231
|
if (rowsClipboard.length > 200) {
|
|
43232
|
-
messageBoxError(t,
|
|
43232
|
+
messageBoxError(t, "You can only paste up to 200 rows.");
|
|
43233
43233
|
}
|
|
43234
43234
|
if (rowsClipboard.length > 0) {
|
|
43235
43235
|
const columnsDataChange = [];
|
|
43236
|
-
for (let index = 0; index < rowsClipboard[0].trimEnd().split(
|
|
43236
|
+
for (let index = 0; index < rowsClipboard[0].trimEnd().split("\t").length; index++) {
|
|
43237
43237
|
const stringData = [];
|
|
43238
43238
|
rowsClipboard.forEach((element) => {
|
|
43239
|
-
if (element.trimEnd().split(
|
|
43240
|
-
stringData.push(element.trimEnd().split(
|
|
43239
|
+
if (element.trimEnd().split("\t")[index] && !stringData.includes(element.trimEnd().split("\t")[index].toString().trim())) {
|
|
43240
|
+
stringData.push(element.trimEnd().split("\t")[index].toString().trim());
|
|
43241
43241
|
}
|
|
43242
43242
|
});
|
|
43243
43243
|
const column = getColumn(indexCol, index);
|
|
43244
43244
|
if (column) {
|
|
43245
43245
|
if ((!column.disabledCondition || !column.disabledCondition(dataSource[currenRowIndex + 0])) && column.editEnable && column.onPasteValidate) {
|
|
43246
|
-
const rs = await column.onPasteValidate(stringData.join(
|
|
43246
|
+
const rs = await column.onPasteValidate(stringData.join(","), currenRowIndex + 0, dataSource[currenRowIndex + 0]);
|
|
43247
43247
|
if (rs) {
|
|
43248
43248
|
column.resultValidate = rs;
|
|
43249
43249
|
}
|
|
@@ -43253,7 +43253,7 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
43253
43253
|
}
|
|
43254
43254
|
for (let indexRow = 0; indexRow < rowsClipboard.length; indexRow++) {
|
|
43255
43255
|
const item = rowsClipboard[indexRow];
|
|
43256
|
-
const colsClipboard = item.trimEnd().split(
|
|
43256
|
+
const colsClipboard = item.trimEnd().split("\t");
|
|
43257
43257
|
let dataRow = dataSource[currenRowIndex + indexRow];
|
|
43258
43258
|
if (!dataRow) {
|
|
43259
43259
|
dataRow = { ...defaultValue };
|
|
@@ -43265,7 +43265,7 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
43265
43265
|
if (column) {
|
|
43266
43266
|
if (((!column.disabledCondition || !column.disabledCondition(dataSource[currenRowIndex + indexRow])) && column.editEnable) || column.onPaste) {
|
|
43267
43267
|
if (column.onPasteValidate && column.resultValidate) {
|
|
43268
|
-
const rs = column.resultValidate.find((item) => item[column.selectSettings?.fieldValue ??
|
|
43268
|
+
const rs = column.resultValidate.find((item) => item[column.selectSettings?.fieldValue ?? "value"] === stringData);
|
|
43269
43269
|
if (rs) {
|
|
43270
43270
|
if (column.onPaste) {
|
|
43271
43271
|
dataRow[column.field] = column.onPaste(dataRow, stringData);
|
|
@@ -43278,12 +43278,12 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
43278
43278
|
}
|
|
43279
43279
|
}
|
|
43280
43280
|
else {
|
|
43281
|
-
notificationError(t(
|
|
43281
|
+
notificationError(t("PasteExcelNotExist", { index: currenRowIndex + indexRow + 1, field: t(column.headerText ?? ""), value: stringData }));
|
|
43282
43282
|
}
|
|
43283
43283
|
}
|
|
43284
43284
|
else {
|
|
43285
|
-
if (column.type ===
|
|
43286
|
-
const [day, month, year] = stringData.split(
|
|
43285
|
+
if (column.type === "date") {
|
|
43286
|
+
const [day, month, year] = stringData.split("/");
|
|
43287
43287
|
const date = new Date(`${year}-${month}-${day}`);
|
|
43288
43288
|
if (!isNaN(date.getTime())) {
|
|
43289
43289
|
if (column.onPaste) {
|
|
@@ -43297,13 +43297,13 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
43297
43297
|
}
|
|
43298
43298
|
}
|
|
43299
43299
|
else {
|
|
43300
|
-
notificationError(t(
|
|
43300
|
+
notificationError(t("PasteExcelIncorrectFormat", { index: currenRowIndex + indexRow + 1, field: t(column.headerText ?? ""), value: stringData }));
|
|
43301
43301
|
}
|
|
43302
43302
|
}
|
|
43303
|
-
else if (column.type ===
|
|
43304
|
-
const [datePart, timePart] = stringData.split(
|
|
43305
|
-
const [day, month, year] = datePart.split(
|
|
43306
|
-
const [hour, minute] = timePart.split(
|
|
43303
|
+
else if (column.type === "datetime") {
|
|
43304
|
+
const [datePart, timePart] = stringData.split(" ");
|
|
43305
|
+
const [day, month, year] = datePart.split("/");
|
|
43306
|
+
const [hour, minute] = timePart.split(":");
|
|
43307
43307
|
const date = new Date(Number(year), Number(month) - 1, Number(day), Number(hour), Number(minute));
|
|
43308
43308
|
if (!isNaN(date.getTime())) {
|
|
43309
43309
|
if (column.onPaste) {
|
|
@@ -43317,11 +43317,11 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
43317
43317
|
}
|
|
43318
43318
|
}
|
|
43319
43319
|
else {
|
|
43320
|
-
notificationError(t(
|
|
43320
|
+
notificationError(t("PasteExcelIncorrectFormat", { index: currenRowIndex + indexRow + 1, field: t(column.headerText ?? ""), value: stringData }));
|
|
43321
43321
|
}
|
|
43322
43322
|
}
|
|
43323
|
-
else if (column.type ===
|
|
43324
|
-
const number = Number(stringData.replaceAll(formatSetting?.thousandSeparator ??
|
|
43323
|
+
else if (column.type === "numeric") {
|
|
43324
|
+
const number = Number(stringData.replaceAll(formatSetting?.thousandSeparator ?? ".", "").replaceAll(formatSetting?.decimalSeparator ?? ",", "."));
|
|
43325
43325
|
if (!isNaN(number)) {
|
|
43326
43326
|
if (column.onPaste) {
|
|
43327
43327
|
dataRow[column.field] = column.onPaste(dataRow, number);
|
|
@@ -43334,10 +43334,10 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
43334
43334
|
}
|
|
43335
43335
|
}
|
|
43336
43336
|
else {
|
|
43337
|
-
notificationError(t(
|
|
43337
|
+
notificationError(t("PasteExcelIncorrectFormat", { index: currenRowIndex + indexRow + 1, field: t(column.headerText ?? ""), value: stringData }));
|
|
43338
43338
|
}
|
|
43339
43339
|
}
|
|
43340
|
-
else if (column.type ===
|
|
43340
|
+
else if (column.type === "select") {
|
|
43341
43341
|
if (column.selectSettings?.allowCreate) {
|
|
43342
43342
|
if (column.onPaste) {
|
|
43343
43343
|
dataRow[column.field] = column.onPaste(dataRow, stringData);
|
|
@@ -43350,7 +43350,7 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
43350
43350
|
}
|
|
43351
43351
|
}
|
|
43352
43352
|
else {
|
|
43353
|
-
const rs = ((column.selectSettings?.optionsField ? item[column.selectSettings?.optionsField] : column.selectSettings?.options) ?? []).find((item) => item[column.selectSettings?.fieldValue ??
|
|
43353
|
+
const rs = ((column.selectSettings?.optionsField ? item[column.selectSettings?.optionsField] : column.selectSettings?.options) ?? []).find((item) => item[column.selectSettings?.fieldValue ?? "value"] === stringData);
|
|
43354
43354
|
if (rs) {
|
|
43355
43355
|
if (column.onPaste) {
|
|
43356
43356
|
dataRow[column.field] = column.onPaste(dataRow, stringData);
|
|
@@ -43363,7 +43363,7 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
43363
43363
|
}
|
|
43364
43364
|
}
|
|
43365
43365
|
else {
|
|
43366
|
-
notificationError(t(
|
|
43366
|
+
notificationError(t("PasteExcelNotExist", { index: currenRowIndex + indexRow + 1, field: t(column.headerText ?? ""), value: stringData }));
|
|
43367
43367
|
}
|
|
43368
43368
|
}
|
|
43369
43369
|
}
|
|
@@ -43383,7 +43383,7 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
43383
43383
|
}
|
|
43384
43384
|
}
|
|
43385
43385
|
if (rowChange) {
|
|
43386
|
-
rowChange(dataRow, currenRowIndex + indexRow,
|
|
43386
|
+
rowChange(dataRow, currenRowIndex + indexRow, "");
|
|
43387
43387
|
}
|
|
43388
43388
|
}
|
|
43389
43389
|
}
|
|
@@ -43415,7 +43415,7 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
43415
43415
|
}
|
|
43416
43416
|
else {
|
|
43417
43417
|
if (dataSource && selectedRows?.length > 0) {
|
|
43418
|
-
if (
|
|
43418
|
+
if (!selectedItem || selectedItem[fieldKey] !== selectedRows[0][fieldKey]) {
|
|
43419
43419
|
setSelectedItem({ ...selectedRows[0] });
|
|
43420
43420
|
if (handleSelect) {
|
|
43421
43421
|
handleSelect({ ...selectedRows[0] });
|
|
@@ -43449,56 +43449,61 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
43449
43449
|
}
|
|
43450
43450
|
}, [selectedItem]);
|
|
43451
43451
|
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}`));
|
|
43452
|
+
if (col.field === "command") {
|
|
43453
|
+
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: {
|
|
43454
|
+
left: col.fixedType === "left" ? objWidthFixLeft[indexCol] : undefined,
|
|
43455
|
+
right: col.fixedType === "right" ? objWidthFixRight[indexCol] : undefined,
|
|
43456
|
+
textAlign: col.textAlign ? col.textAlign : "left"
|
|
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}`)));
|
|
43458
43458
|
}
|
|
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:
|
|
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}`, { "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: {
|
|
43461
|
+
left: col.fixedType === "left" ? objWidthFixLeft[indexCol] : undefined,
|
|
43462
|
+
right: col.fixedType === "right" ? objWidthFixRight[indexCol] : undefined,
|
|
43463
|
+
textAlign: "center"
|
|
43464
43464
|
}, onCopy: (e) => {
|
|
43465
|
-
if (!editDisable && (e.target.nodeName ===
|
|
43465
|
+
if (!editDisable && (e.target.nodeName === "DIV" || e.target.nodeName === "TD")) {
|
|
43466
43466
|
navigator.clipboard.writeText(JSON.stringify(row));
|
|
43467
|
-
notificationSuccess(t(
|
|
43467
|
+
notificationSuccess(t("CopySuccessful"));
|
|
43468
43468
|
e.stopPropagation();
|
|
43469
43469
|
}
|
|
43470
43470
|
}, onPaste: (e) => {
|
|
43471
|
-
if (!editDisable && (e.target.nodeName ===
|
|
43472
|
-
navigator.clipboard
|
|
43471
|
+
if (!editDisable && (e.target.nodeName === "DIV" || e.target.nodeName === "TD")) {
|
|
43472
|
+
navigator.clipboard
|
|
43473
|
+
.readText()
|
|
43474
|
+
.then((rs) => {
|
|
43473
43475
|
dataSource[indexRow] = JSON.parse(rs);
|
|
43474
43476
|
if (fieldKey) {
|
|
43475
43477
|
dataSource[indexRow][fieldKey] = defaultValue[fieldKey];
|
|
43476
43478
|
}
|
|
43477
43479
|
changeDataSource(dataSource);
|
|
43478
|
-
notificationSuccess(t(
|
|
43479
|
-
})
|
|
43480
|
+
notificationSuccess(t("PasteSuccessful"));
|
|
43481
|
+
})
|
|
43482
|
+
.catch((ex) => {
|
|
43483
|
+
alert(ex);
|
|
43484
|
+
});
|
|
43480
43485
|
e.stopPropagation();
|
|
43481
43486
|
}
|
|
43482
43487
|
}, onClick: (e) => {
|
|
43483
|
-
if (e.target.nodeName ===
|
|
43488
|
+
if (e.target.nodeName === "DIV" || e.target.nodeName === "TD") {
|
|
43484
43489
|
if (!editDisable && indexRow != indexFocus) {
|
|
43485
43490
|
setIndexFocus(indexRow);
|
|
43486
43491
|
}
|
|
43487
43492
|
e.stopPropagation();
|
|
43488
43493
|
}
|
|
43489
43494
|
}, onKeyDown: (e) => {
|
|
43490
|
-
if (e.code ===
|
|
43495
|
+
if (e.code === "KeyD" && e.ctrlKey == true && !editDisable && !addDisable && (e.target.nodeName === "DIV" || e.target.nodeName === "TD")) {
|
|
43491
43496
|
handleDuplicate(dataSource, indexFocus, fieldKey, defaultValue, fieldUniKey, changeDataSource, tableElement, totalCount, toolbarSetting, buttonSetting, editDisable, addDisable, onDuplicate);
|
|
43492
43497
|
e.preventDefault();
|
|
43493
43498
|
e.stopPropagation();
|
|
43494
43499
|
}
|
|
43495
|
-
}, children: jsx("div", { className: "r-rowcell-div", children: indexRow + 1 }) }, `col-${indexRow}-${indexCol}`));
|
|
43500
|
+
}, children: jsx("div", { className: "r-rowcell-div", children: indexRow + 1 }) }, `col-${indexRow}-${indexCol}`)));
|
|
43496
43501
|
}
|
|
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:
|
|
43502
|
+
else if (col.field === "checkbox") {
|
|
43503
|
+
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: {
|
|
43504
|
+
left: col.fixedType === "left" ? objWidthFixLeft[indexCol] : undefined,
|
|
43505
|
+
right: col.fixedType === "right" ? objWidthFixRight[indexCol] : undefined
|
|
43506
|
+
}, children: jsx("div", { className: "r-rowcell-div cursor-pointer", style: { alignItems: "center" }, onClick: (e) => {
|
|
43502
43507
|
if (selectEnable) {
|
|
43503
43508
|
const index = selectedRows?.findIndex((x) => x[fieldKey] === row[fieldKey]);
|
|
43504
43509
|
if (index > -1) {
|
|
@@ -43520,26 +43525,34 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
43520
43525
|
}
|
|
43521
43526
|
e.stopPropagation();
|
|
43522
43527
|
}
|
|
43523
|
-
}, children: jsx(Input$1, { checked: isSelected, type: "checkbox", className: "cursor-pointer", style: { textAlign: col.textAlign ??
|
|
43528
|
+
}, children: jsx(Input$1, { checked: isSelected, type: "checkbox", className: "cursor-pointer", style: { textAlign: col.textAlign ?? "center" } }) }) }, `col-${indexRow}-${indexCol}`));
|
|
43524
43529
|
}
|
|
43525
43530
|
else {
|
|
43526
43531
|
let value = row[col.field];
|
|
43527
|
-
if (col.type ===
|
|
43528
|
-
value = formartNumberic(row[col.field], formatSetting?.decimalSeparator ??
|
|
43532
|
+
if (col.type === "numeric" || (col.typeCondition && col.typeCondition(row) === "numeric")) {
|
|
43533
|
+
value = formartNumberic(row[col.field], formatSetting?.decimalSeparator ?? ",", formatSetting?.thousandSeparator ?? ".", col.numericSettings?.fraction, true, false) ?? 0;
|
|
43529
43534
|
}
|
|
43530
|
-
else if (col.type ===
|
|
43531
|
-
value = value ? formatDateTime(value, formatSetting?.dateFormat) :
|
|
43535
|
+
else if (col.type === "date") {
|
|
43536
|
+
value = value ? formatDateTime(value, formatSetting?.dateFormat) : "";
|
|
43532
43537
|
}
|
|
43533
|
-
else if (col.type ===
|
|
43534
|
-
value = value ? formatDateTime(value, formatSetting?.dateFormat ??
|
|
43538
|
+
else if (col.type === "datetime") {
|
|
43539
|
+
value = value ? formatDateTime(value, formatSetting?.dateFormat ?? "DD/MM/yyyy HH:mm") : "";
|
|
43535
43540
|
}
|
|
43536
|
-
const typeDis = !editDisable && (indexFocus === indexRow || col.type ===
|
|
43537
|
-
|
|
43538
|
-
|
|
43539
|
-
|
|
43540
|
-
|
|
43541
|
+
const typeDis = !editDisable && (indexFocus === indexRow || col.type === "checkbox") && (!col.disabledCondition || !col.disabledCondition(row))
|
|
43542
|
+
? col.editEnable
|
|
43543
|
+
? 1
|
|
43544
|
+
: col.template
|
|
43545
|
+
? 2
|
|
43546
|
+
: 3
|
|
43547
|
+
: col.template
|
|
43548
|
+
? 2
|
|
43549
|
+
: 3;
|
|
43550
|
+
const errorMessage = typeDis === 1 || col.field === "" || !col.validate ? "" : col.validate(row[col.field], row);
|
|
43551
|
+
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: {
|
|
43552
|
+
left: col.fixedType === "left" ? objWidthFixLeft[indexCol] : undefined,
|
|
43553
|
+
right: col.fixedType === "right" ? objWidthFixRight[indexCol] : undefined
|
|
43541
43554
|
}, onClick: (e) => {
|
|
43542
|
-
if (e.target.nodeName ===
|
|
43555
|
+
if (e.target.nodeName === "DIV" || e.target.nodeName === "TD") {
|
|
43543
43556
|
if (!editDisable && indexRow != indexFocus) {
|
|
43544
43557
|
setIndexFocus(indexRow);
|
|
43545
43558
|
focusNewElement(indexCol + 1, indexRow + 1, true);
|
|
@@ -43566,30 +43579,34 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
43566
43579
|
}
|
|
43567
43580
|
e.stopPropagation();
|
|
43568
43581
|
}
|
|
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(
|
|
43582
|
+
}, 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: {
|
|
43583
|
+
textAlign: col.textAlign ? col.textAlign : "left"
|
|
43584
|
+
}, 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
43585
|
}
|
|
43573
43586
|
};
|
|
43574
43587
|
const RenderContentCell = (row, col, indexCol, indexRow, typeDis, value) => {
|
|
43575
43588
|
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 }),
|
|
43589
|
+
const value = col.template?.(row, indexRow) ?? "";
|
|
43590
|
+
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
|
43591
|
+
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
43592
|
}
|
|
43580
43593
|
else {
|
|
43581
43594
|
return value;
|
|
43582
43595
|
}
|
|
43583
43596
|
}
|
|
43584
|
-
return (jsxs(Fragment$1, { children: [jsx("div", { id: `content-${idTable}-row${indexRow}col-${indexCol}`, className: "r-cell-text", children:
|
|
43597
|
+
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
43598
|
};
|
|
43586
43599
|
const renderFooterCol = (col, indexCol) => {
|
|
43587
|
-
const sumValue =
|
|
43588
|
-
|
|
43589
|
-
|
|
43590
|
-
|
|
43591
|
-
|
|
43592
|
-
|
|
43600
|
+
const sumValue = col.haveSum === true && col.type === "numeric"
|
|
43601
|
+
? dataSource.reduce(function (accumulator, currentValue) {
|
|
43602
|
+
return Number(accumulator ?? 0) + Number(currentValue[col.field] ?? 0);
|
|
43603
|
+
}, 0)
|
|
43604
|
+
: 0;
|
|
43605
|
+
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: {
|
|
43606
|
+
left: col.fixedType === "left" ? objWidthFixLeft[indexCol] : undefined,
|
|
43607
|
+
right: col.fixedType === "right" ? objWidthFixRight[indexCol] : undefined,
|
|
43608
|
+
textAlign: col.textAlign ? col.textAlign : "left"
|
|
43609
|
+
}, 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
43610
|
};
|
|
43594
43611
|
/**
|
|
43595
43612
|
* 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 +43614,7 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
43597
43614
|
function checkRowMatch(row, filters, keyword, searchKeys) {
|
|
43598
43615
|
if ((!filters || filters.length === 0) && (!keyword || !searchClient))
|
|
43599
43616
|
return true; // Không có filter thì mặc định là match
|
|
43600
|
-
const isFilterMatch = filters.every(filter => {
|
|
43617
|
+
const isFilterMatch = filters.every((filter) => {
|
|
43601
43618
|
const { key, value, ope } = filter;
|
|
43602
43619
|
const rowValue = row[key];
|
|
43603
43620
|
if (rowValue === undefined || rowValue === null || value === undefined || value === null)
|
|
@@ -43605,32 +43622,33 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
43605
43622
|
const valStr = String(rowValue).toLowerCase();
|
|
43606
43623
|
const filterStr = String(value).toLowerCase();
|
|
43607
43624
|
switch (ope) {
|
|
43608
|
-
case
|
|
43625
|
+
case "startswith":
|
|
43609
43626
|
return valStr.startsWith(filterStr);
|
|
43610
|
-
case
|
|
43627
|
+
case "endswith":
|
|
43611
43628
|
return valStr.endsWith(filterStr);
|
|
43612
|
-
case
|
|
43629
|
+
case "contains":
|
|
43613
43630
|
return valStr.includes(filterStr);
|
|
43614
|
-
case
|
|
43631
|
+
case "equal":
|
|
43615
43632
|
return rowValue == value;
|
|
43616
|
-
case
|
|
43633
|
+
case "notequal":
|
|
43617
43634
|
return rowValue != value;
|
|
43618
|
-
case
|
|
43635
|
+
case "greaterthan":
|
|
43619
43636
|
return rowValue > value;
|
|
43620
|
-
case
|
|
43637
|
+
case "greaterthanorequal":
|
|
43621
43638
|
return rowValue >= value;
|
|
43622
|
-
case
|
|
43639
|
+
case "lessthan":
|
|
43623
43640
|
return rowValue < value;
|
|
43624
|
-
case
|
|
43641
|
+
case "lessthanorequal":
|
|
43625
43642
|
return rowValue <= value;
|
|
43626
43643
|
default:
|
|
43627
43644
|
return false;
|
|
43628
43645
|
}
|
|
43629
43646
|
});
|
|
43630
|
-
const isSearchMatch = !keyword ||
|
|
43631
|
-
|
|
43632
|
-
|
|
43633
|
-
|
|
43647
|
+
const isSearchMatch = !keyword ||
|
|
43648
|
+
searchKeys.some((key) => {
|
|
43649
|
+
const val = row[key];
|
|
43650
|
+
return val?.toString().toLowerCase().includes(keyword.trim().toLowerCase());
|
|
43651
|
+
});
|
|
43634
43652
|
return isFilterMatch && isSearchMatch;
|
|
43635
43653
|
}
|
|
43636
43654
|
useEffect(() => {
|
|
@@ -43638,24 +43656,35 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
43638
43656
|
pagingSetting?.setCurrentPage(1);
|
|
43639
43657
|
}
|
|
43640
43658
|
}, [searchTerm, searchSetting?.searchTerm]);
|
|
43641
|
-
return (jsxs(Fragment, { children: [jsxs("div", { className: "r-table-edit", children: [jsxs("div", { className:
|
|
43659
|
+
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
43660
|
return (jsx("tr", { className: "r-row", role: "row", children: element?.map((col, index) => {
|
|
43643
|
-
return (jsx(HeaderTableCol$1, { col: col, idTable: idTable ??
|
|
43661
|
+
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
43662
|
setFilterBy([...val]);
|
|
43645
43663
|
}, changeOrder: (val) => {
|
|
43646
43664
|
setOrderBy([...val]);
|
|
43647
|
-
}, columns: contentColumns, setColumns:
|
|
43665
|
+
}, columns: contentColumns, setColumns: (newColumns) => {
|
|
43666
|
+
newColumns.forEach((x) => {
|
|
43667
|
+
const column = columns.find((y) => y.field === x.field);
|
|
43668
|
+
if (column) {
|
|
43669
|
+
column.visible = x.visible;
|
|
43670
|
+
column.fixedType = x.fixedType;
|
|
43671
|
+
column.width = x.width;
|
|
43672
|
+
}
|
|
43673
|
+
});
|
|
43674
|
+
setRefreshColumns(!refreshColumns);
|
|
43675
|
+
}, fisrtObjWidthFixRight: fisrtObjWidthFixRight, lastObjWidthFixLeft: lastObjWidthFixLeft, totalCount: totalCount }, `header-${indexParent}-${index}`));
|
|
43648
43676
|
}) }, `header-${-indexParent}`));
|
|
43649
|
-
}) }), jsx("tbody", { className:
|
|
43677
|
+
}) }), jsx("tbody", { className: "r-gridcontent", role: "rowgroup", children: dataSource.map((row, indexRow) => {
|
|
43650
43678
|
const isSelected = selectedRows?.some((x) => x[fieldKey] === row[fieldKey]);
|
|
43651
43679
|
const flagSearch = checkRowMatch(row, filterBy, searchSetting?.searchTerm !== undefined ? searchSetting?.searchTerm : searchTerm, searchSetting?.keyField ?? []);
|
|
43652
43680
|
if (flagSearch) {
|
|
43653
|
-
const flagDisplay = !pagingClient ||
|
|
43654
|
-
|
|
43681
|
+
const flagDisplay = !pagingClient ||
|
|
43682
|
+
(indexRow + 1 > (pagingSetting.pageSize ?? 0) * ((pagingSetting.currentPage ?? 0) - 1) && indexRow + 1 <= (pagingSetting.pageSize ?? 0) * (pagingSetting.currentPage ?? 0));
|
|
43683
|
+
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
43684
|
}
|
|
43656
|
-
}) }), jsx("tfoot", { className: "r-gridfoot", children: haveSum == true ? jsx("tr", { className:
|
|
43657
|
-
return
|
|
43658
|
-
}) }) : jsx(Fragment$1, {}) })] }) }), toolbarSetting?.showBottomToolbar && jsx(ToolbarBottom, { handleAdd: (numberOfRows) => {
|
|
43685
|
+
}) }), jsx("tfoot", { className: "r-gridfoot", children: haveSum == true ? (jsx("tr", { className: "r-row", children: contentColumns.map((col, index) => {
|
|
43686
|
+
return renderFooterCol(col, index);
|
|
43687
|
+
}) })) : (jsx(Fragment$1, {})) })] }) }), toolbarSetting?.showBottomToolbar && (jsx(ToolbarBottom, { handleAdd: (numberOfRows) => {
|
|
43659
43688
|
handleAdd(dataSource, tableElement.current, indexFirstEdit, changeDataSource, pagingSetting, setIndexFocus, focusNewElement, numberOfRows);
|
|
43660
43689
|
}, handleDuplicate: () => {
|
|
43661
43690
|
handleDuplicate(dataSource, indexFocus, fieldKey, defaultValue, fieldUniKey, changeDataSource, tableElement, totalCount, toolbarSetting, buttonSetting, editDisable, addDisable, onDuplicate);
|
|
@@ -43665,7 +43694,23 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
43665
43694
|
handleInsertBefore(dataSource, indexFocus, defaultValue, changeDataSource, pagingClient, pagingSetting, toolbarSetting, buttonSetting, editDisable, addDisable);
|
|
43666
43695
|
}, handleDeleteAll: () => {
|
|
43667
43696
|
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 :
|
|
43697
|
+
}, 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: () => {
|
|
43698
|
+
setOpenPopupSetupColumn(!openPopupSetupColumn);
|
|
43699
|
+
}, openSidebar: openPopupSetupColumn, column: [...contentColumns], setColumn: (newColumns) => {
|
|
43700
|
+
if (saveSettingColumn) {
|
|
43701
|
+
console.log(newColumns);
|
|
43702
|
+
saveSettingColumn(newColumns.map((x) => ({ field: x.field, headerText: x.headerText, visible: x.visible, fixedType: x.fixedType, width: x.width })));
|
|
43703
|
+
}
|
|
43704
|
+
newColumns.forEach((x) => {
|
|
43705
|
+
const column = columns.find((y) => y.field === x.field);
|
|
43706
|
+
if (column) {
|
|
43707
|
+
column.visible = x.visible;
|
|
43708
|
+
column.fixedType = x.fixedType;
|
|
43709
|
+
column.width = x.width;
|
|
43710
|
+
}
|
|
43711
|
+
});
|
|
43712
|
+
setRefreshColumns(!refreshColumns);
|
|
43713
|
+
} })] }));
|
|
43669
43714
|
});
|
|
43670
43715
|
|
|
43671
43716
|
const TabsMenuComponent = ({ buttonWidth, tabParent, tabChild, resourceCodeParent, resources, resourceCode, windowSize, renderModal }) => {
|
|
@@ -46140,6 +46185,20 @@ const CheckboxInput = (props) => {
|
|
|
46140
46185
|
}), children: [renderLabel({ isLabel, name, label: label ?? '' }), jsxs("div", { className: classNames$2('form-input-content', { 'hidden-label': isLabel === false }), children: [renderInput(), renderText()] })] }) }));
|
|
46141
46186
|
};
|
|
46142
46187
|
|
|
46188
|
+
const StyleInput = (props) => {
|
|
46189
|
+
const { control, name, label, labelSize, required, errors, height, disabled, isLabel, inLine, classes, disabledBackgroundColor, disabledFontFamily, disabledFontSize, disabledBold, disabledItalic, disabledUnderline } = props;
|
|
46190
|
+
const renderInput = () => {
|
|
46191
|
+
return (jsxs(Fragment, { children: [jsx(Controller, { name: name, control: control, render: ({ field: { value, onChange } }) => {
|
|
46192
|
+
return (jsx(InputStyleComponent, { disabledBackgroundColor: disabledBackgroundColor, disabledFontFamily: disabledFontFamily, disabledFontSize: disabledFontSize, disabledBold: disabledBold, disabledItalic: disabledItalic, disabledUnderline: disabledUnderline, disabled: disabled, value: value, onChange: onChange }));
|
|
46193
|
+
} }), errors && jsx(FormFeedback$1, { children: errors?.message })] }));
|
|
46194
|
+
};
|
|
46195
|
+
return (jsx(Fragment, { children: jsxs("div", { className: classNames$2(' align', {
|
|
46196
|
+
[labelSize ? labelSize : '']: labelSize,
|
|
46197
|
+
[classes ? classes : '']: classes,
|
|
46198
|
+
'form-row-inline-error': errors
|
|
46199
|
+
}, 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() })] }) }));
|
|
46200
|
+
};
|
|
46201
|
+
|
|
46143
46202
|
const defaultStyleExportSetting = {
|
|
46144
46203
|
title: {
|
|
46145
46204
|
color: '$black',
|
|
@@ -46218,38 +46277,24 @@ const defaultStyleExportSetting = {
|
|
|
46218
46277
|
}
|
|
46219
46278
|
};
|
|
46220
46279
|
|
|
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
46280
|
const ExportExcelComponent = ({ openModal, typeModal, handleModal, windowSize, dataItem, columns, columnGroups }) => {
|
|
46236
46281
|
const { t } = useTranslation();
|
|
46237
46282
|
const [dataSelected, setDataSelected] = useState([]);
|
|
46238
46283
|
const [selectedGroups, setSelectedGroups] = useState([]);
|
|
46239
46284
|
const { control, reset, handleSubmit, clearErrors, getValues, setValue } = useForm({
|
|
46240
|
-
mode:
|
|
46285
|
+
mode: "onChange",
|
|
46241
46286
|
defaultValues: defaultStyleExportSetting
|
|
46242
46287
|
});
|
|
46243
46288
|
const handleCancel = () => {
|
|
46244
|
-
handleModal(
|
|
46289
|
+
handleModal("ExportExcelComponent");
|
|
46245
46290
|
clearErrors();
|
|
46246
46291
|
setDataSelected([]);
|
|
46247
46292
|
reset();
|
|
46248
46293
|
setSelectedGroups([]);
|
|
46249
46294
|
};
|
|
46250
46295
|
useEffect(() => {
|
|
46251
|
-
if (openModal && typeModal ===
|
|
46252
|
-
setValue(
|
|
46296
|
+
if (openModal && typeModal === "ExportExcel") {
|
|
46297
|
+
setValue("textTitle", dataItem.title);
|
|
46253
46298
|
}
|
|
46254
46299
|
}, [openModal]);
|
|
46255
46300
|
const handleToggleGroup = (groupName) => {
|
|
@@ -46274,9 +46319,10 @@ const ExportExcelComponent = ({ openModal, typeModal, handleModal, windowSize, d
|
|
|
46274
46319
|
submit(data);
|
|
46275
46320
|
};
|
|
46276
46321
|
const submit = (data) => {
|
|
46277
|
-
dataItem
|
|
46322
|
+
dataItem
|
|
46323
|
+
.ExportExcelApi({
|
|
46278
46324
|
id: dataItem.id,
|
|
46279
|
-
columns: dataSelected.map(item => ({ ...item, headerText: t(item.headerText) })),
|
|
46325
|
+
columns: dataSelected.map((item) => ({ ...item, headerText: t(item.headerText) })),
|
|
46280
46326
|
countRowHeader: dataItem.countRowHeader,
|
|
46281
46327
|
groupby: dataItem.groupby,
|
|
46282
46328
|
fieldSums: dataItem.fieldSums,
|
|
@@ -46284,55 +46330,57 @@ const ExportExcelComponent = ({ openModal, typeModal, handleModal, windowSize, d
|
|
|
46284
46330
|
order: dataItem.order,
|
|
46285
46331
|
organizationId: dataItem.organizationId,
|
|
46286
46332
|
style: data,
|
|
46287
|
-
title: getValues(
|
|
46288
|
-
subtitle: getValues(
|
|
46289
|
-
})
|
|
46333
|
+
title: getValues("textTitle"),
|
|
46334
|
+
subtitle: getValues("textSubtitle")
|
|
46335
|
+
})
|
|
46336
|
+
.unwrap()
|
|
46290
46337
|
.then((rs) => {
|
|
46291
46338
|
const url = window.URL.createObjectURL(new Blob([rs]));
|
|
46292
|
-
const link = document.createElement(
|
|
46339
|
+
const link = document.createElement("a");
|
|
46293
46340
|
link.href = url;
|
|
46294
|
-
link.setAttribute(
|
|
46341
|
+
link.setAttribute("download", `${dataItem.title}.xlsx`);
|
|
46295
46342
|
document.body.appendChild(link);
|
|
46296
46343
|
link.click();
|
|
46297
46344
|
handleModal();
|
|
46298
|
-
})
|
|
46345
|
+
})
|
|
46346
|
+
.catch(() => notificationError("Fail"));
|
|
46299
46347
|
};
|
|
46300
46348
|
const renderFooterButtons = () => {
|
|
46301
|
-
return (jsxs(Fragment, { children: [jsx(Button$1, { color: "primary", className: "me-1", onClick: handleSubmit(onSubmit), children: t(
|
|
46349
|
+
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
46350
|
};
|
|
46303
46351
|
const rightToolbarTemplate = () => {
|
|
46304
|
-
return (jsx("div", { className:
|
|
46352
|
+
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
46353
|
};
|
|
46306
46354
|
const toolbarTopOptions = [
|
|
46307
46355
|
{
|
|
46308
46356
|
template: rightToolbarTemplate,
|
|
46309
|
-
align:
|
|
46357
|
+
align: "left"
|
|
46310
46358
|
}
|
|
46311
46359
|
];
|
|
46312
|
-
return (jsxs(Sidebar, { open: openModal && typeModal ===
|
|
46360
|
+
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
46361
|
showTopToolbar: true,
|
|
46314
46362
|
showBottomToolbar: true,
|
|
46315
46363
|
toolbarBottomOptions: toolbarTopOptions
|
|
46316
46364
|
}, maxHeight: windowSize.innerHeight - 525, minHeight: 150, columns: [
|
|
46317
46365
|
{
|
|
46318
|
-
field:
|
|
46319
|
-
headerText:
|
|
46320
|
-
textAlign:
|
|
46321
|
-
invisibleDisable: true,
|
|
46366
|
+
field: "checkbox",
|
|
46367
|
+
headerText: "",
|
|
46368
|
+
textAlign: "center",
|
|
46322
46369
|
width: 20
|
|
46323
46370
|
},
|
|
46324
46371
|
{
|
|
46325
|
-
field:
|
|
46326
|
-
|
|
46327
|
-
headerText: '',
|
|
46372
|
+
field: "field",
|
|
46373
|
+
headerText: "",
|
|
46328
46374
|
visible: false,
|
|
46329
46375
|
isPrimarykey: true
|
|
46330
46376
|
},
|
|
46331
46377
|
{
|
|
46332
|
-
type:
|
|
46378
|
+
type: "text",
|
|
46333
46379
|
field: "headerText",
|
|
46334
|
-
headerText:
|
|
46335
|
-
template: (value) => {
|
|
46380
|
+
headerText: "Column name",
|
|
46381
|
+
template: (value) => {
|
|
46382
|
+
return t(value.headerText);
|
|
46383
|
+
},
|
|
46336
46384
|
width: 360,
|
|
46337
46385
|
minWidth: 320,
|
|
46338
46386
|
maxWidth: 400
|
|
@@ -46340,7 +46388,7 @@ const ExportExcelComponent = ({ openModal, typeModal, handleModal, windowSize, d
|
|
|
46340
46388
|
], isMulti: true, searchSetting: {
|
|
46341
46389
|
searchEnable: true,
|
|
46342
46390
|
searchClient: true
|
|
46343
|
-
}, selectedItem: dataSelected, setSelectedItem: setDataSelected, selectEnable: true, addDisable: true, editDisable: true },
|
|
46391
|
+
}, 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
46392
|
};
|
|
46345
46393
|
|
|
46346
46394
|
const TabValidateImportExcel = (props) => {
|