react-table-edit 1.4.35 → 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/select-table/index.d.ts +1 -0
- 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 +15 -15
- package/dist/index.d.ts +22 -14
- package/dist/index.js +338 -290
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +338 -290
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -17505,11 +17505,11 @@ const useOnClickOutside = (ref, handler) => {
|
|
|
17505
17505
|
// ** Call passed function on click outside
|
|
17506
17506
|
handler(event);
|
|
17507
17507
|
};
|
|
17508
|
-
document.addEventListener(
|
|
17509
|
-
document.addEventListener(
|
|
17508
|
+
document.addEventListener("mousedown", listener);
|
|
17509
|
+
document.addEventListener("touchstart", listener);
|
|
17510
17510
|
return () => {
|
|
17511
|
-
document.removeEventListener(
|
|
17512
|
-
document.removeEventListener(
|
|
17511
|
+
document.removeEventListener("mousedown", listener);
|
|
17512
|
+
document.removeEventListener("touchstart", listener);
|
|
17513
17513
|
};
|
|
17514
17514
|
},
|
|
17515
17515
|
// ** Add ref and handler to effect dependencies
|
|
@@ -17524,7 +17524,7 @@ const checkThousandSeparator = (thousandSeparator, decimalSeparator) => {
|
|
|
17524
17524
|
if (thousandSeparator) {
|
|
17525
17525
|
if (decimalSeparator) {
|
|
17526
17526
|
if (thousandSeparator === decimalSeparator) {
|
|
17527
|
-
return
|
|
17527
|
+
return ",";
|
|
17528
17528
|
}
|
|
17529
17529
|
else {
|
|
17530
17530
|
return thousandSeparator;
|
|
@@ -17535,14 +17535,14 @@ const checkThousandSeparator = (thousandSeparator, decimalSeparator) => {
|
|
|
17535
17535
|
}
|
|
17536
17536
|
}
|
|
17537
17537
|
else {
|
|
17538
|
-
return
|
|
17538
|
+
return ",";
|
|
17539
17539
|
}
|
|
17540
17540
|
};
|
|
17541
17541
|
const checkDecimalSeparator = (thousandSeparator, decimalSeparator) => {
|
|
17542
17542
|
if (decimalSeparator) {
|
|
17543
17543
|
if (thousandSeparator) {
|
|
17544
17544
|
if (thousandSeparator === decimalSeparator) {
|
|
17545
|
-
return
|
|
17545
|
+
return ".";
|
|
17546
17546
|
}
|
|
17547
17547
|
else {
|
|
17548
17548
|
return decimalSeparator;
|
|
@@ -17553,29 +17553,32 @@ const checkDecimalSeparator = (thousandSeparator, decimalSeparator) => {
|
|
|
17553
17553
|
}
|
|
17554
17554
|
}
|
|
17555
17555
|
else {
|
|
17556
|
-
return
|
|
17556
|
+
return ".";
|
|
17557
17557
|
}
|
|
17558
17558
|
};
|
|
17559
17559
|
const isNullOrUndefined = (d) => {
|
|
17560
|
-
if (d === null || d === undefined || d ===
|
|
17560
|
+
if (d === null || d === undefined || d === "") {
|
|
17561
17561
|
return true;
|
|
17562
17562
|
}
|
|
17563
17563
|
return false;
|
|
17564
17564
|
};
|
|
17565
17565
|
const generateUUID = () => {
|
|
17566
|
+
// Public Domain/MIT
|
|
17566
17567
|
let d = new Date().getTime(); //Timestamp
|
|
17567
|
-
let d2 = (
|
|
17568
|
-
return
|
|
17568
|
+
let d2 = (typeof performance !== "undefined" && performance.now && performance.now() * 1000) || 0; //Time in microseconds since page-load or 0 if unsupported
|
|
17569
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (c) {
|
|
17569
17570
|
let r = Math.random() * 16; //random number between 0 and 16
|
|
17570
|
-
if (d > 0) {
|
|
17571
|
+
if (d > 0) {
|
|
17572
|
+
//Use timestamp until depleted
|
|
17571
17573
|
r = (d + r) % 16 | 0;
|
|
17572
17574
|
d = Math.floor(d / 16);
|
|
17573
17575
|
}
|
|
17574
|
-
else {
|
|
17576
|
+
else {
|
|
17577
|
+
//Use microseconds since page-load if supported
|
|
17575
17578
|
r = (d2 + r) % 16 | 0;
|
|
17576
17579
|
d2 = Math.floor(d2 / 16);
|
|
17577
17580
|
}
|
|
17578
|
-
return (c ===
|
|
17581
|
+
return (c === "x" ? r : 0x3).toString(16);
|
|
17579
17582
|
});
|
|
17580
17583
|
};
|
|
17581
17584
|
/**
|
|
@@ -17592,17 +17595,17 @@ const formartNumberic = (str, decimalSeparator, thousandSeparator, fraction = 10
|
|
|
17592
17595
|
str = roundNumber(Number(str), fraction);
|
|
17593
17596
|
}
|
|
17594
17597
|
// eslint-disable-next-line
|
|
17595
|
-
if (str || str ==
|
|
17598
|
+
if (str || str == "0") {
|
|
17596
17599
|
str = str.toString();
|
|
17597
|
-
const value = decimalSeparator !==
|
|
17598
|
-
const arr = value.toString().split(decimalSeparator ??
|
|
17599
|
-
let flag = value.toString().includes(decimalSeparator ??
|
|
17600
|
+
const value = decimalSeparator !== "." ? str.toString().replaceAll(".", decimalSeparator ?? "") : str;
|
|
17601
|
+
const arr = value.toString().split(decimalSeparator ?? "", 2);
|
|
17602
|
+
let flag = value.toString().includes(decimalSeparator ?? "");
|
|
17600
17603
|
if (arr[0].length < 3) {
|
|
17601
|
-
return flag ? `${arr[0]}${decimalSeparator}${arr[1]?.substring(0, fraction) ??
|
|
17604
|
+
return flag ? `${arr[0]}${decimalSeparator}${arr[1]?.substring(0, fraction) ?? ""}` : arr[0];
|
|
17602
17605
|
}
|
|
17603
17606
|
else {
|
|
17604
17607
|
let flagNegative = false;
|
|
17605
|
-
if (arr[0][0] ===
|
|
17608
|
+
if (arr[0][0] === "-") {
|
|
17606
17609
|
flagNegative = true;
|
|
17607
17610
|
arr[0] = arr[0].substring(1, arr[0].length);
|
|
17608
17611
|
}
|
|
@@ -17613,20 +17616,20 @@ const formartNumberic = (str, decimalSeparator, thousandSeparator, fraction = 10
|
|
|
17613
17616
|
count++;
|
|
17614
17617
|
}
|
|
17615
17618
|
}
|
|
17616
|
-
if (arr[0].lastIndexOf(thousandSeparator ??
|
|
17619
|
+
if (arr[0].lastIndexOf(thousandSeparator ?? "") === arr[0].length - 1) {
|
|
17617
17620
|
arr[0] = arr[0].slice(0, arr[0].length - 1);
|
|
17618
17621
|
}
|
|
17619
17622
|
if (isDone) {
|
|
17620
|
-
flag = (arr[1]?.substring(0, fraction) ??
|
|
17623
|
+
flag = (arr[1]?.substring(0, fraction) ?? "") !== "";
|
|
17621
17624
|
}
|
|
17622
17625
|
if (flagNegative && haveNegative) {
|
|
17623
|
-
arr[0] =
|
|
17626
|
+
arr[0] = "-".concat(arr[0]);
|
|
17624
17627
|
}
|
|
17625
|
-
return flag ? `${arr[0]}${decimalSeparator}${arr[1]?.substring(0, fraction) ??
|
|
17628
|
+
return flag ? `${arr[0]}${decimalSeparator}${arr[1]?.substring(0, fraction) ?? ""}` : arr[0];
|
|
17626
17629
|
}
|
|
17627
17630
|
}
|
|
17628
17631
|
else {
|
|
17629
|
-
return
|
|
17632
|
+
return "";
|
|
17630
17633
|
}
|
|
17631
17634
|
};
|
|
17632
17635
|
const roundNumber = (num, fraction) => {
|
|
@@ -17634,23 +17637,23 @@ const roundNumber = (num, fraction) => {
|
|
|
17634
17637
|
const result = Math.round(num * base) / base;
|
|
17635
17638
|
return result;
|
|
17636
17639
|
};
|
|
17637
|
-
const formatDateTime = (data, format =
|
|
17640
|
+
const formatDateTime = (data, format = "dd/MM/yyyy") => {
|
|
17638
17641
|
if (!data) {
|
|
17639
|
-
return
|
|
17642
|
+
return "";
|
|
17640
17643
|
}
|
|
17641
17644
|
const date = new Date(data);
|
|
17642
17645
|
const map = {
|
|
17643
|
-
dd: String(date.getDate()).padStart(2,
|
|
17644
|
-
MM: String(date.getMonth() + 1).padStart(2,
|
|
17646
|
+
dd: String(date.getDate()).padStart(2, "0"),
|
|
17647
|
+
MM: String(date.getMonth() + 1).padStart(2, "0"),
|
|
17645
17648
|
yyyy: date.getFullYear(),
|
|
17646
|
-
HH: String(date.getHours()).padStart(2,
|
|
17647
|
-
mm: String(date.getMinutes()).padStart(2,
|
|
17649
|
+
HH: String(date.getHours()).padStart(2, "0"),
|
|
17650
|
+
mm: String(date.getMinutes()).padStart(2, "0")
|
|
17648
17651
|
};
|
|
17649
17652
|
return format.replace(/dd|MM|yyyy|HH|mm/g, (match) => map[match]);
|
|
17650
17653
|
};
|
|
17651
17654
|
// Hàm tìm vị trí theo chuỗi index
|
|
17652
17655
|
const FindNodeByPath = (tree, path) => {
|
|
17653
|
-
const levels = path.split(
|
|
17656
|
+
const levels = path.split("-").map((num) => parseInt(num, 10));
|
|
17654
17657
|
let current = tree;
|
|
17655
17658
|
let node = null;
|
|
17656
17659
|
for (let index = 0; index < levels.length - 1; index++) {
|
|
@@ -17688,18 +17691,18 @@ const calculateTableStructure = (columns) => {
|
|
|
17688
17691
|
const objHeaderWidthFixLeft = {};
|
|
17689
17692
|
let maxDepth = 0;
|
|
17690
17693
|
// Tính depth tối đa
|
|
17691
|
-
const calculateDepth = (cols, depth = 1) =>
|
|
17694
|
+
const calculateDepth = (cols, depth = 1) => Math.max(...cols.map((col) => (col.columns?.length ? calculateDepth(col.columns, depth + 1) : depth)));
|
|
17692
17695
|
maxDepth = calculateDepth(columns);
|
|
17693
17696
|
let leftTotal = 0;
|
|
17694
17697
|
let rightTotal = 0;
|
|
17695
17698
|
// Tính tổng width của các cột cố định phải
|
|
17696
17699
|
const calcTotalRightWidth = (cols) => {
|
|
17697
|
-
cols.forEach(col => {
|
|
17700
|
+
cols.forEach((col) => {
|
|
17698
17701
|
if (col.columns?.length) {
|
|
17699
17702
|
calcTotalRightWidth(col.columns);
|
|
17700
17703
|
}
|
|
17701
17704
|
else {
|
|
17702
|
-
if (col.fixedType ===
|
|
17705
|
+
if (col.fixedType === "right" && col.visible !== false) {
|
|
17703
17706
|
rightTotal += col.width ?? 40;
|
|
17704
17707
|
}
|
|
17705
17708
|
}
|
|
@@ -17719,7 +17722,7 @@ const calculateTableStructure = (columns) => {
|
|
|
17719
17722
|
};
|
|
17720
17723
|
levels[level].push(cell);
|
|
17721
17724
|
const headerKey = `${level}-${indexCol}`;
|
|
17722
|
-
if (col.fixedType ===
|
|
17725
|
+
if (col.fixedType === "left" && col.visible !== false) {
|
|
17723
17726
|
objHeaderWidthFixLeft[headerKey] = leftTotal;
|
|
17724
17727
|
}
|
|
17725
17728
|
if (!hasChildren) {
|
|
@@ -17727,16 +17730,16 @@ const calculateTableStructure = (columns) => {
|
|
|
17727
17730
|
const width = col.width ?? 40;
|
|
17728
17731
|
cell.index = index;
|
|
17729
17732
|
flat.push(cell);
|
|
17730
|
-
if (col.fixedType ===
|
|
17733
|
+
if (col.fixedType === "left" && col.visible !== false) {
|
|
17731
17734
|
objWidthFixLeft[index] = leftTotal;
|
|
17732
17735
|
leftTotal += width;
|
|
17733
17736
|
}
|
|
17734
|
-
if (col.fixedType ===
|
|
17737
|
+
if (col.fixedType === "right" && col.in !== false) {
|
|
17735
17738
|
rightTotal -= width;
|
|
17736
17739
|
objWidthFixRight[index] = rightTotal;
|
|
17737
17740
|
}
|
|
17738
17741
|
}
|
|
17739
|
-
if (col.fixedType ===
|
|
17742
|
+
if (col.fixedType === "right" && col.visible !== false) {
|
|
17740
17743
|
objHeaderWidthFixRight[headerKey] = rightTotal;
|
|
17741
17744
|
}
|
|
17742
17745
|
return colspanSum + colspan;
|
|
@@ -17849,7 +17852,7 @@ const TextInput = (props) => {
|
|
|
17849
17852
|
|
|
17850
17853
|
const defaultMaxHeight$1 = 250;
|
|
17851
17854
|
const SelectTable = React$5.forwardRef((props, ref) => {
|
|
17852
|
-
const { id, menuWidth, width, invalid, placeholder, textAlign, options, columns, value, fieldValue, fieldLabel, maxHeight, isClearable, component, isMulti, noHeader, isDisabled, showFooter, formatSetting, allowCreate, onPaste, onChange, handleAdd, onKeyDown, onOpenMenu, loadOptions, onCloseMenu, footerComponent, formatOptionLabel } = props;
|
|
17855
|
+
const { id, menuWidth, width, invalid, placeholder, textAlign, options, columns, value, fieldValue, fieldLabel, maxHeight, isClearable, component, isMulti, noHeader, isDisabled, showFooter, formatSetting, allowCreate, onPaste, onChange, handleAdd, onKeyDown, onOpenMenu, loadOptions, onCloseMenu, footerComponent, formatOptionLabel, compareFunction } = props;
|
|
17853
17856
|
const selectTableRef = React$5.useRef(null);
|
|
17854
17857
|
const selectMenuTableRef = React$5.useRef(null);
|
|
17855
17858
|
const inputRef = React$5.useRef(null);
|
|
@@ -17888,7 +17891,7 @@ const SelectTable = React$5.forwardRef((props, ref) => {
|
|
|
17888
17891
|
};
|
|
17889
17892
|
React$5.useEffect(() => {
|
|
17890
17893
|
if (dropdownOpen && value && !isMulti && selectMenuTableRef) {
|
|
17891
|
-
const index = (optionsLoad ? optionsLoad : options)?.findIndex((
|
|
17894
|
+
const index = (optionsLoad ? optionsLoad : options)?.findIndex((row) => (compareFunction ? compareFunction(row) : row[fieldValue ?? 'value'] === value[fieldValue ?? 'value']));
|
|
17892
17895
|
if (index >= 0) {
|
|
17893
17896
|
selectMenuTableRef.current.scrollTo({ top: (index - 1) * 30 });
|
|
17894
17897
|
}
|
|
@@ -17995,7 +17998,7 @@ const SelectTable = React$5.forwardRef((props, ref) => {
|
|
|
17995
17998
|
newIndex = indexFocus + 1;
|
|
17996
17999
|
}
|
|
17997
18000
|
else if (value) {
|
|
17998
|
-
newIndex = (optionsLoad ? optionsLoad : options)?.findIndex((
|
|
18001
|
+
newIndex = (optionsLoad ? optionsLoad : options)?.findIndex((row) => (compareFunction ? compareFunction(row) : row[fieldValue ?? 'value'] === value[fieldValue ?? 'value'])) + 1;
|
|
17999
18002
|
}
|
|
18000
18003
|
if (newIndex < (optionsLoad ? optionsLoad : options).length) {
|
|
18001
18004
|
setIndexFocus(newIndex);
|
|
@@ -18019,7 +18022,7 @@ const SelectTable = React$5.forwardRef((props, ref) => {
|
|
|
18019
18022
|
newIndex = indexFocus - 1;
|
|
18020
18023
|
}
|
|
18021
18024
|
else if (value) {
|
|
18022
|
-
newIndex = (optionsLoad ? optionsLoad : options)?.findIndex((
|
|
18025
|
+
newIndex = (optionsLoad ? optionsLoad : options)?.findIndex((row) => (compareFunction ? compareFunction(row) : row[fieldValue ?? 'value'] === value[fieldValue ?? 'value'])) - 1;
|
|
18023
18026
|
}
|
|
18024
18027
|
if (newIndex >= 0) {
|
|
18025
18028
|
setIndexFocus(newIndex);
|
|
@@ -18115,9 +18118,9 @@ const SelectTable = React$5.forwardRef((props, ref) => {
|
|
|
18115
18118
|
};
|
|
18116
18119
|
const RenderElement = React__default["default"].memo((props) => {
|
|
18117
18120
|
const { indexRow, row, isSelected, level = 0 } = props;
|
|
18118
|
-
return (jsxRuntime.jsxs("tr", { id: `row-select-table-${indexRow}`, style: { paddingLeft: 10 * level }, className: classNames$2('r-select-row', { 'last-row': indexRow === (optionsLoad ? optionsLoad : options).length - 1 }, { 'fisrt-row': indexRow === 0 }), children: [isMulti && jsxRuntime.jsx("td", { className: classNames$2(`r-select-rowcell`, { 'r-select-move': indexFocus === indexRow, 'r-select-active': !isMulti && value && value[fieldValue ?? 'value'] === row[fieldValue ?? 'value'] }), style: { width: 40, textAlign: 'center', padding: 0, paddingBottom: 6 }, onClick: (e) => {
|
|
18121
|
+
return (jsxRuntime.jsxs("tr", { id: `row-select-table-${indexRow}`, style: { paddingLeft: 10 * level }, className: classNames$2('r-select-row', { 'last-row': indexRow === (optionsLoad ? optionsLoad : options).length - 1 }, { 'fisrt-row': indexRow === 0 }), children: [isMulti && jsxRuntime.jsx("td", { className: classNames$2(`r-select-rowcell`, { 'r-select-move': indexFocus === indexRow, 'r-select-active': !isMulti && value && (compareFunction ? compareFunction(row) : value[fieldValue ?? 'value'] === row[fieldValue ?? 'value']) }), style: { width: 40, textAlign: 'center', padding: 0, paddingBottom: 6 }, onClick: (e) => {
|
|
18119
18122
|
if (isMulti) {
|
|
18120
|
-
const index = value?.findIndex((x) => x[fieldValue ?? 'value'] === row[fieldValue ?? 'value']);
|
|
18123
|
+
const index = value?.findIndex((x) => (compareFunction ? compareFunction(row) : x[fieldValue ?? 'value'] === row[fieldValue ?? 'value']));
|
|
18121
18124
|
if (index > -1) {
|
|
18122
18125
|
value?.splice(index, 1);
|
|
18123
18126
|
handChange([...value]);
|
|
@@ -18146,14 +18149,14 @@ const SelectTable = React$5.forwardRef((props, ref) => {
|
|
|
18146
18149
|
}
|
|
18147
18150
|
return (jsxRuntime.jsxs(React$5.Fragment, { children: [col.visible !== false && jsxRuntime.jsx("td", { id: `select-${id}-${indexRow}-${indexCol}`,
|
|
18148
18151
|
// ref={refRow}
|
|
18149
|
-
className: classNames$2(`r-select-rowcell`, { 'r-select-move': indexFocus === indexRow, 'r-select-active': !isMulti && value && value[fieldValue ?? 'value'] === row[fieldValue ?? 'value'] }), style: {
|
|
18152
|
+
className: classNames$2(`r-select-rowcell`, { 'r-select-move': indexFocus === indexRow, 'r-select-active': !isMulti && value && (compareFunction ? compareFunction(row) : value[fieldValue ?? 'value'] === row[fieldValue ?? 'value']) }), style: {
|
|
18150
18153
|
minWidth: col.minWidth,
|
|
18151
18154
|
width: col.width,
|
|
18152
18155
|
maxWidth: col.maxWidth,
|
|
18153
18156
|
textAlign: col.textAlign ? col.textAlign : 'left'
|
|
18154
18157
|
}, onClick: (e) => {
|
|
18155
18158
|
if (isMulti) {
|
|
18156
|
-
const index = value?.findIndex((x) => x[fieldValue ?? 'value'] === row[fieldValue ?? 'value']);
|
|
18159
|
+
const index = value?.findIndex((x) => (compareFunction ? compareFunction(row) : x[fieldValue ?? 'value'] === row[fieldValue ?? 'value']));
|
|
18157
18160
|
if (index > -1) {
|
|
18158
18161
|
value?.splice(index, 1);
|
|
18159
18162
|
handChange([...value]);
|
|
@@ -18198,7 +18201,7 @@ const SelectTable = React$5.forwardRef((props, ref) => {
|
|
|
18198
18201
|
}, readOnly: true, className: classNames$2('cursor-pointer', { 'd-none': !isMulti }), style: { textAlign: 'center', marginTop: 6 } }) }) }), (columns ? columns : defaultColumns).map((col, index) => {
|
|
18199
18202
|
return (renderHeaderCol(col, index));
|
|
18200
18203
|
})] }) }), ((optionsLoad ? optionsLoad : options) && !isLoading) && jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsxs("tbody", { className: 'r-select-gridcontent', children: [haveCreateNew && jsxRuntime.jsx(RenderElement, { isSelected: false, indexRow: 0, row: { valueCreate: searchTerm, [fieldValue ?? "value"]: searchTerm, [fieldLabel ?? "label"]: `${t('Create')} '${searchTerm}'`, isCreated: true } }), (optionsLoad ? optionsLoad : options)?.map((row, indexRow) => {
|
|
18201
|
-
const isSelected = isMulti && value?.some((x) => x[fieldValue ?? 'value'] === row[fieldValue ?? 'value']);
|
|
18204
|
+
const isSelected = isMulti && value?.some((x) => (compareFunction ? compareFunction(row) : x[fieldValue ?? 'value'] === row[fieldValue ?? 'value']));
|
|
18202
18205
|
return (jsxRuntime.jsx(RenderElement, { isSelected: isSelected ?? false, indexRow: indexRow + (haveCreateNew ? 1 : 0), row: row }, `select-table-${indexRow}`));
|
|
18203
18206
|
})] }) })] }), ((((optionsLoad ? optionsLoad : options)?.length ?? 0) === 0) && !haveCreateNew && !isLoading) && jsxRuntime.jsxs("div", { className: "r-no-data", children: [jsxRuntime.jsx("svg", { width: "64", height: "41", viewBox: "0 0 64 41", xmlns: "http://www.w3.org/2000/svg", children: jsxRuntime.jsxs("g", { transform: "translate(0 1)", fill: "none", fillRule: "evenodd", children: [jsxRuntime.jsx("ellipse", { fill: "#f5f5f5", cx: "32", cy: "33", rx: "32", ry: "7" }), jsxRuntime.jsxs("g", { fillRule: "nonzero", stroke: "#d9d9d9", children: [jsxRuntime.jsx("path", { d: "M55 12.76L44.854 1.258C44.367.474 43.656 0 42.907 0H21.093c-.749 0-1.46.474-1.947 1.257L9 12.761V22h46v-9.24z" }), jsxRuntime.jsx("path", { d: "M41.613 15.931c0-1.605.994-2.93 2.227-2.931H55v18.137C55 33.26 53.68 35 52.05 35h-40.1C10.32 35 9 33.259 9 31.137V13h11.16c1.233 0 2.227 1.323 2.227 2.928v.022c0 1.605 1.005 2.901 2.237 2.901h14.752c1.232 0 2.237-1.308 2.237-2.913v-.007z", fill: "#fafafa" })] })] }) }), t('No data available.')] }), isLoading && jsxRuntime.jsxs("div", { className: "r-no-data", children: [jsxRuntime.jsx(Spinner$1, { className: "me-1", children: " " }), t('Loading...')] })] }));
|
|
18204
18207
|
};
|
|
@@ -40383,7 +40386,7 @@ const SidebarSetColumn = (props) => {
|
|
|
40383
40386
|
};
|
|
40384
40387
|
}, []);
|
|
40385
40388
|
const renderFooterButtons = () => {
|
|
40386
|
-
return (jsxRuntime.jsxs(React$5.Fragment, { children: [jsxRuntime.jsx(Button$1, { color: "primary", onClick: handleSubmit, className: "me-1", children: t("Confirm") }), jsxRuntime.jsx(Button$1, { color: "secondary", onClick: handleCancel, outline: true, children: t(
|
|
40389
|
+
return (jsxRuntime.jsxs(React$5.Fragment, { children: [jsxRuntime.jsx(Button$1, { color: "primary", onClick: handleSubmit, className: "me-1", children: t("Confirm") }), jsxRuntime.jsx(Button$1, { color: "secondary", onClick: handleCancel, outline: true, children: t("Close") })] }));
|
|
40387
40390
|
};
|
|
40388
40391
|
const visibleTemplate = (item, index) => {
|
|
40389
40392
|
return (jsxRuntime.jsx(Input$1, { defaultChecked: item.visible ?? true, disabled: item.invisibleDisable, type: "checkbox", style: { height: 18 }, className: " cursor-pointer", onChange: (e) => {
|
|
@@ -40394,14 +40397,14 @@ const SidebarSetColumn = (props) => {
|
|
|
40394
40397
|
} }));
|
|
40395
40398
|
};
|
|
40396
40399
|
const fixColumnTemplate = (item, index) => {
|
|
40397
|
-
return (jsxRuntime.jsx(Input$1, { defaultChecked: item.fixedType ===
|
|
40400
|
+
return (jsxRuntime.jsx(Input$1, { defaultChecked: item.fixedType === "left" || item.fixedType === "right", type: "checkbox", style: { height: 18 }, className: " cursor-pointer", onChange: (e) => {
|
|
40398
40401
|
if (dataSource) {
|
|
40399
40402
|
if (e.target.checked) {
|
|
40400
|
-
if (
|
|
40401
|
-
dataSource[index].fixedType =
|
|
40403
|
+
if (index * 2 <= dataSource.length) {
|
|
40404
|
+
dataSource[index].fixedType = "left";
|
|
40402
40405
|
}
|
|
40403
40406
|
else {
|
|
40404
|
-
dataSource[index].fixedType =
|
|
40407
|
+
dataSource[index].fixedType = "right";
|
|
40405
40408
|
}
|
|
40406
40409
|
}
|
|
40407
40410
|
else {
|
|
@@ -40413,7 +40416,7 @@ const SidebarSetColumn = (props) => {
|
|
|
40413
40416
|
};
|
|
40414
40417
|
const columns = [
|
|
40415
40418
|
{
|
|
40416
|
-
field:
|
|
40419
|
+
field: "headerText",
|
|
40417
40420
|
headerText: "Column name",
|
|
40418
40421
|
template: (e) => {
|
|
40419
40422
|
return jsxRuntime.jsx(jsxRuntime.Fragment, { children: t(e.headerText) });
|
|
@@ -40424,29 +40427,29 @@ const SidebarSetColumn = (props) => {
|
|
|
40424
40427
|
minWidth: 150
|
|
40425
40428
|
},
|
|
40426
40429
|
{
|
|
40427
|
-
field:
|
|
40430
|
+
field: "",
|
|
40428
40431
|
template: visibleTemplate,
|
|
40429
40432
|
headerText: "Display",
|
|
40430
|
-
textAlign:
|
|
40433
|
+
textAlign: "center",
|
|
40431
40434
|
visible: true,
|
|
40432
40435
|
width: 100,
|
|
40433
40436
|
maxWidth: 120,
|
|
40434
40437
|
minWidth: 80
|
|
40435
40438
|
},
|
|
40436
40439
|
{
|
|
40437
|
-
field:
|
|
40440
|
+
field: "",
|
|
40438
40441
|
template: fixColumnTemplate,
|
|
40439
40442
|
headerText: "Fix the column",
|
|
40440
|
-
textAlign:
|
|
40443
|
+
textAlign: "center",
|
|
40441
40444
|
visible: true,
|
|
40442
40445
|
width: 100,
|
|
40443
40446
|
maxWidth: 120,
|
|
40444
40447
|
minWidth: 80
|
|
40445
40448
|
},
|
|
40446
40449
|
{
|
|
40447
|
-
field:
|
|
40450
|
+
field: "width",
|
|
40448
40451
|
headerText: "Column width",
|
|
40449
|
-
textAlign:
|
|
40452
|
+
textAlign: "right",
|
|
40450
40453
|
visible: true,
|
|
40451
40454
|
width: 100,
|
|
40452
40455
|
maxWidth: 120,
|
|
@@ -40454,44 +40457,42 @@ const SidebarSetColumn = (props) => {
|
|
|
40454
40457
|
}
|
|
40455
40458
|
];
|
|
40456
40459
|
const renderHeaderCol = (col, indexCol) => {
|
|
40457
|
-
return (jsxRuntime.jsx(React$5.Fragment, { children: col.visible !== false && jsxRuntime.jsx("th", { className: classNames$2(`r-headercell fix-${col.fixedType}`, {
|
|
40458
|
-
width: col.fixedType ? Number(col.maxWidth ? col.maxWidth :
|
|
40459
|
-
minWidth: col.fixedType ? Number(col.maxWidth ? col.maxWidth :
|
|
40460
|
+
return (jsxRuntime.jsx(React$5.Fragment, { children: col.visible !== false && (jsxRuntime.jsx("th", { className: classNames$2(`r-headercell fix-${col.fixedType}`, { "cell-fixed": col.fixedType }), style: {
|
|
40461
|
+
width: col.fixedType ? Number(col.maxWidth ? col.maxWidth : col.width ? col.width : col.minWidth ?? "auto") : col.width,
|
|
40462
|
+
minWidth: col.fixedType ? Number(col.maxWidth ? col.maxWidth : col.width ? col.width : col.minWidth ?? "auto") : col.minWidth,
|
|
40460
40463
|
top: `${0 * 42}px`,
|
|
40461
40464
|
maxWidth: col.maxWidth
|
|
40462
|
-
}, children: jsxRuntime.jsx("div", { role: "textbox", title: t(col.headerText ??
|
|
40465
|
+
}, children: jsxRuntime.jsx("div", { role: "textbox", title: t(col.headerText ?? ""), style: {
|
|
40463
40466
|
height: `${1 * 42}px`,
|
|
40464
|
-
justifyContent: col.textAlign ??
|
|
40465
|
-
}, className: "r-headercell-div", children: t(col.headerText ??
|
|
40467
|
+
justifyContent: col.textAlign ?? "left"
|
|
40468
|
+
}, className: "r-headercell-div", children: t(col.headerText ?? "") }) })) }, `header-${indexCol}`));
|
|
40466
40469
|
};
|
|
40467
|
-
return (jsxRuntime.jsxs(Sidebar, { open: openSidebar, toggleSidebar: handleCancel, width: 700, children: [jsxRuntime.jsx(ModalHeader, { typeModal:
|
|
40468
|
-
return
|
|
40469
|
-
}) }) }), jsxRuntime.jsx("tbody", { className:
|
|
40470
|
-
return (jsxRuntime.jsx("tr", { className: classNames$2(
|
|
40470
|
+
return (jsxRuntime.jsxs(Sidebar, { open: openSidebar, toggleSidebar: handleCancel, width: 700, children: [jsxRuntime.jsx(ModalHeader, { typeModal: "Edit", handleModal: handleCancel, title: "Column setup" }), jsxRuntime.jsx("div", { className: "ms-2 r-table-edit", children: jsxRuntime.jsx("div", { className: "r-grid", children: jsxRuntime.jsx("div", { className: "r-gridtable", style: { height: windowSize.innerHeight - 120 }, children: jsxRuntime.jsxs("table", { style: { width: "100%" }, children: [jsxRuntime.jsx("thead", { className: "r-gridheader", children: jsxRuntime.jsx("tr", { className: "r-row", role: "row", children: columns.map((col, index) => {
|
|
40471
|
+
return renderHeaderCol(col, index);
|
|
40472
|
+
}) }) }), jsxRuntime.jsx("tbody", { className: "r-gridcontent", children: dataSource?.map((row, indexRow) => {
|
|
40473
|
+
return (jsxRuntime.jsx("tr", { className: classNames$2("r-row", { "last-row": indexRow === dataSource.length - 1 }, { "fisrt-row": indexRow === 0 }), children: columns.map((col, indexCol) => {
|
|
40471
40474
|
let value = row[col.field];
|
|
40472
|
-
if (col.type ===
|
|
40473
|
-
value = formartNumberic(row[col.field],
|
|
40475
|
+
if (col.type === "numeric" || (col.typeCondition && col.typeCondition(row) === "numeric")) {
|
|
40476
|
+
value = formartNumberic(row[col.field], ",", ".", col.numericSettings?.fraction, true) ?? 0;
|
|
40474
40477
|
}
|
|
40475
|
-
return (jsxRuntime.jsx(React$5.Fragment, { children: col.visible !== false && jsxRuntime.jsx("td", { className: classNames$2(`r-rowcell fix-${col.fixedType}`, {
|
|
40478
|
+
return (jsxRuntime.jsx(React$5.Fragment, { children: col.visible !== false && (jsxRuntime.jsx("td", { className: classNames$2(`r-rowcell fix-${col.fixedType}`, { "cell-fixed": col.fixedType }, { "r-active": indexFocus === indexRow }), style: {
|
|
40476
40479
|
padding: 0,
|
|
40477
|
-
textAlign: col.textAlign ? col.textAlign :
|
|
40480
|
+
textAlign: col.textAlign ? col.textAlign : "left"
|
|
40478
40481
|
}, onFocus: (e) => {
|
|
40479
40482
|
if (indexRow !== indexFocus) {
|
|
40480
40483
|
setIndexFocus(indexRow);
|
|
40481
40484
|
}
|
|
40482
40485
|
e.stopPropagation();
|
|
40483
40486
|
}, onClick: (e) => {
|
|
40484
|
-
if (e.target.nodeName ===
|
|
40487
|
+
if (e.target.nodeName === "DIV" || e.target.nodeName === "TD") {
|
|
40485
40488
|
if (indexRow !== indexFocus) {
|
|
40486
40489
|
setIndexFocus(indexRow);
|
|
40487
40490
|
}
|
|
40488
40491
|
e.stopPropagation();
|
|
40489
40492
|
}
|
|
40490
|
-
}, children: jsxRuntime.jsx("div", { className: classNames$2(
|
|
40491
|
-
width: col.fixedType ? Number(col.maxWidth ? col.maxWidth :
|
|
40492
|
-
}, children: jsxRuntime.jsx("div", { className: classNames$2(
|
|
40493
|
-
margin: '7px 9px'
|
|
40494
|
-
}, children: jsxRuntime.jsx("div", { className: "r-cell-text", children: col.template ? col.template(row, indexRow) : value }) }) }) }, `col-${indexRow}-${indexCol}`) }, indexCol));
|
|
40493
|
+
}, children: jsxRuntime.jsx("div", { className: classNames$2("r-rowcell-div"), style: {
|
|
40494
|
+
width: col.fixedType ? Number(col.maxWidth ? col.maxWidth : col.width ? col.width : col.minWidth ?? "auto") : "auto"
|
|
40495
|
+
}, children: jsxRuntime.jsx("div", { className: classNames$2("r-rowcell-content"), children: jsxRuntime.jsx("div", { className: "r-cell-text", children: col.template ? col.template(row, indexRow) : value }) }) }) }, `col-${indexRow}-${indexCol}`)) }, indexCol));
|
|
40495
40496
|
}) }, `row-${indexRow}`));
|
|
40496
40497
|
}) })] }) }) }) }), jsxRuntime.jsx("div", { className: "d-flex justify-content-end p-1 ", style: { boxShadow: "0 4px 24px 0 rgb(34 41 47 / 10%)" }, children: renderFooterButtons() })] }));
|
|
40497
40498
|
};
|
|
@@ -42823,7 +42824,7 @@ const ToolbarBottom = ({ handleAdd, handleDuplicate, handleInsertBefore, handleI
|
|
|
42823
42824
|
|
|
42824
42825
|
const TableEdit = React$5.forwardRef((props, ref) => {
|
|
42825
42826
|
const { t } = reactI18next.useTranslation();
|
|
42826
|
-
const { idTable, dataSource, columns,
|
|
42827
|
+
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;
|
|
42827
42828
|
React$5.useImperativeHandle(ref, () => {
|
|
42828
42829
|
return {
|
|
42829
42830
|
refeshFocusRow: handleRefeshRow
|
|
@@ -42832,28 +42833,26 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
42832
42833
|
const [refreshRow, setRefreshRow] = React$5.useState(false);
|
|
42833
42834
|
const [indexFocus, setIndexFocus] = React$5.useState(-1);
|
|
42834
42835
|
const [selectedRows, setSelectedRows] = React$5.useState([]);
|
|
42835
|
-
const [contentColumns, setContentColumns] = React$5.useState([]);
|
|
42836
42836
|
const [openPopupSetupColumn, setOpenPopupSetupColumn] = React$5.useState(false);
|
|
42837
|
-
const [searchTerm, setSearchTerm] = React$5.useState(
|
|
42837
|
+
const [searchTerm, setSearchTerm] = React$5.useState("");
|
|
42838
42838
|
const [orderBy, setOrderBy] = React$5.useState([]);
|
|
42839
42839
|
const [filterBy, setFilterBy] = React$5.useState([]);
|
|
42840
|
+
const [refreshColumns, setRefreshColumns] = React$5.useState(false);
|
|
42840
42841
|
const tableElement = React$5.useRef(null);
|
|
42841
42842
|
const gridRef = React$5.useRef(null);
|
|
42842
42843
|
const totalCount = dataSource.length;
|
|
42843
42844
|
const pagingClient = pagingSetting?.allowPaging && (pagingSetting?.pagingClient || !(editDisable || addDisable));
|
|
42844
42845
|
const searchClient = searchSetting?.searchEnable && (searchSetting?.searchClient || !(editDisable || addDisable));
|
|
42845
|
-
const fieldKey = columns.find((item) => item.isPrimarykey === true)?.field ??
|
|
42846
|
+
const fieldKey = columns.find((item) => item.isPrimarykey === true)?.field ?? "id";
|
|
42846
42847
|
const fieldUniKey = columns.filter((item) => item.isUnikey === true)?.map((item) => item.field);
|
|
42847
42848
|
React$5.useEffect(() => {
|
|
42848
42849
|
if (pagingClient && pagingSetting.setCurrentPage && Math.ceil(totalCount / (pagingSetting?.pageSize ?? 1)) < (pagingSetting.currentPage ?? 1)) {
|
|
42849
42850
|
pagingSetting.setCurrentPage(1);
|
|
42850
42851
|
}
|
|
42851
42852
|
}, [dataSource]);
|
|
42852
|
-
const { levels: headerColumns, flatVisble, objWidthFixLeft, objWidthFixRight, lastObjWidthFixLeft, fisrtObjWidthFixRight, objHeaderWidthFixLeft, objHeaderWidthFixRight, indexFirstEdit: indexFirstEdit, indexLastEdit: indexLastEdit } = React$5.useMemo(() => {
|
|
42853
|
-
|
|
42854
|
-
|
|
42855
|
-
return obj;
|
|
42856
|
-
}, [columns]);
|
|
42853
|
+
const { levels: headerColumns, flat: contentColumns, flatVisble, objWidthFixLeft, objWidthFixRight, lastObjWidthFixLeft, fisrtObjWidthFixRight, objHeaderWidthFixLeft, objHeaderWidthFixRight, indexFirstEdit: indexFirstEdit, indexLastEdit: indexLastEdit } = React$5.useMemo(() => {
|
|
42854
|
+
return calculateTableStructure(columns);
|
|
42855
|
+
}, [columns, refreshColumns]);
|
|
42857
42856
|
const handleRefeshRow = () => {
|
|
42858
42857
|
setRefreshRow(true);
|
|
42859
42858
|
setTimeout(() => {
|
|
@@ -42873,7 +42872,7 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
42873
42872
|
}
|
|
42874
42873
|
};
|
|
42875
42874
|
const handleKeyPress = (e) => {
|
|
42876
|
-
if (
|
|
42875
|
+
if (e.code === "Enter" || e.code === "NumpadEnter") {
|
|
42877
42876
|
if (searchSetting?.setSearchTerm) {
|
|
42878
42877
|
searchSetting?.setSearchTerm(e.target.value);
|
|
42879
42878
|
}
|
|
@@ -42885,9 +42884,9 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
42885
42884
|
}
|
|
42886
42885
|
};
|
|
42887
42886
|
const searchTemplate = () => {
|
|
42888
|
-
return (jsxRuntime.jsx(React$5.Fragment, { children: jsxRuntime.jsx("div", { className: "me-50 r-search", children: jsxRuntime.jsx(ReactInput, { style: { width:
|
|
42887
|
+
return (jsxRuntime.jsx(React$5.Fragment, { children: jsxRuntime.jsx("div", { className: "me-50 r-search", children: jsxRuntime.jsx(ReactInput, { style: { width: "230px" }, value: searchSetting?.searchTerm !== undefined ? searchSetting?.searchTerm : searchTerm, setSearchTerm: searchSetting?.setSearchTerm ? searchSetting?.setSearchTerm : setSearchTerm, placeholder: t("Search"), onKeyPress: handleKeyPress }) }) }));
|
|
42889
42888
|
};
|
|
42890
|
-
const defaultToolbarOption = searchSetting?.searchEnable ? [{ template: searchTemplate, align:
|
|
42889
|
+
const defaultToolbarOption = searchSetting?.searchEnable ? [{ template: searchTemplate, align: "left" }] : [];
|
|
42891
42890
|
let toolbarTopOption = [];
|
|
42892
42891
|
if (toolbarSetting?.toolbarOptions) {
|
|
42893
42892
|
toolbarTopOption = [...defaultToolbarOption, ...toolbarSetting?.toolbarOptions];
|
|
@@ -42898,8 +42897,8 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
42898
42897
|
const RenderEditCell = (row, col, indexCol, indexRow) => {
|
|
42899
42898
|
/*eslint-disable */
|
|
42900
42899
|
switch (col?.typeCondition ? col?.typeCondition(row) : col.type) {
|
|
42901
|
-
case
|
|
42902
|
-
return (jsxRuntime.jsx(DateInput, { id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`, className: classNames$2(
|
|
42900
|
+
case "date":
|
|
42901
|
+
return (jsxRuntime.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) => {
|
|
42903
42902
|
row[col.field] = date ? new Date(date.getTime() + 7 * 60 * 60 * 1000) : undefined;
|
|
42904
42903
|
if (col.callback) {
|
|
42905
42904
|
col.callback(row[col.field], indexRow, row);
|
|
@@ -42915,8 +42914,8 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
42915
42914
|
e.preventDefault();
|
|
42916
42915
|
}
|
|
42917
42916
|
} }));
|
|
42918
|
-
case
|
|
42919
|
-
return (jsxRuntime.jsx(DateInput, { id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`, className: classNames$2(
|
|
42917
|
+
case "datetime":
|
|
42918
|
+
return (jsxRuntime.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) => {
|
|
42920
42919
|
row[col.field] = date;
|
|
42921
42920
|
if (col.callback) {
|
|
42922
42921
|
col.callback(row[col.field], indexRow, row);
|
|
@@ -42930,41 +42929,49 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
42930
42929
|
e.preventDefault();
|
|
42931
42930
|
}
|
|
42932
42931
|
} }));
|
|
42933
|
-
case
|
|
42932
|
+
case "select":
|
|
42934
42933
|
let valueSelect;
|
|
42935
42934
|
let optionsSelect = [];
|
|
42936
42935
|
if (col.selectSettings?.optionsField) {
|
|
42937
42936
|
optionsSelect = row[col.selectSettings?.optionsField] ? row[col.selectSettings?.optionsField] : [];
|
|
42938
42937
|
}
|
|
42939
42938
|
else {
|
|
42940
|
-
optionsSelect = col.selectSettings?.options
|
|
42939
|
+
optionsSelect = col.selectSettings?.options
|
|
42940
|
+
? col.selectSettings?.validateOption
|
|
42941
|
+
? col.selectSettings?.options.filter((item) => col.selectSettings?.validateOption(item, row))
|
|
42942
|
+
: col.selectSettings?.options
|
|
42943
|
+
: [];
|
|
42941
42944
|
}
|
|
42942
42945
|
if (col.selectSettings?.isMulti) {
|
|
42943
|
-
valueSelect = optionsSelect.filter((x) => row[col.field].some((y) => x[col.selectSettings?.fieldValue ??
|
|
42946
|
+
valueSelect = optionsSelect.filter((x) => row[col.field].some((y) => (col.selectSettings?.compareFunction ? col.selectSettings.compareFunction(x, row) : x[col.selectSettings?.fieldValue ?? "value"] === y)));
|
|
42944
42947
|
}
|
|
42945
42948
|
else {
|
|
42946
|
-
valueSelect =
|
|
42949
|
+
valueSelect =
|
|
42950
|
+
!isNullOrUndefined(row[col.field]) && row[col.field] !== ""
|
|
42951
|
+
? optionsSelect?.find((val) => col.selectSettings?.compareFunction ? col.selectSettings.compareFunction(val, row) : val[col.selectSettings?.fieldValue ?? "value"] === row[col.field])
|
|
42952
|
+
: "";
|
|
42947
42953
|
if (!valueSelect && col.selectSettings?.defaultValue) {
|
|
42948
42954
|
valueSelect = col.selectSettings?.defaultValue(row);
|
|
42949
42955
|
}
|
|
42950
42956
|
}
|
|
42951
42957
|
return (jsxRuntime.jsx(SelectTable, { id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`, value: valueSelect, options: optionsSelect, onChange: (val) => {
|
|
42952
42958
|
if (col.selectSettings?.isMulti) {
|
|
42953
|
-
row[col.field] = (val?.length ?? 0) > 0 ? val.map((item) => item[col.selectSettings?.fieldValue ??
|
|
42959
|
+
row[col.field] = (val?.length ?? 0) > 0 ? val.map((item) => item[col.selectSettings?.fieldValue ?? "value"]) : [];
|
|
42954
42960
|
}
|
|
42955
42961
|
else {
|
|
42956
|
-
row[col.field] = !isNullOrUndefined(val) ? val[col.selectSettings?.fieldValue ??
|
|
42962
|
+
row[col.field] = !isNullOrUndefined(val) ? val[col.selectSettings?.fieldValue ?? "value"] : undefined;
|
|
42957
42963
|
}
|
|
42958
42964
|
if (val && col.selectSettings?.loadOptions && isMulti) {
|
|
42959
|
-
if (isMulti) {
|
|
42965
|
+
if (isMulti) {
|
|
42966
|
+
//push giá trị vào option khi loadoption
|
|
42960
42967
|
val.forEach((e) => {
|
|
42961
|
-
if (!optionsSelect.some((a) => a[col.selectSettings?.fieldValue ??
|
|
42968
|
+
if (!optionsSelect.some((a) => a[col.selectSettings?.fieldValue ?? "value"] === e[col.selectSettings?.fieldValue ?? "value"])) {
|
|
42962
42969
|
optionsSelect.unshift(e);
|
|
42963
42970
|
}
|
|
42964
42971
|
});
|
|
42965
42972
|
}
|
|
42966
42973
|
else if (!col.selectSettings?.defaultValue) {
|
|
42967
|
-
if (!optionsSelect.some((a) => a[col.selectSettings?.fieldValue ??
|
|
42974
|
+
if (!optionsSelect.some((a) => a[col.selectSettings?.fieldValue ?? "value"] === val[col.selectSettings?.fieldValue ?? "value"])) {
|
|
42968
42975
|
optionsSelect.unshift(val);
|
|
42969
42976
|
}
|
|
42970
42977
|
}
|
|
@@ -42973,27 +42980,21 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
42973
42980
|
col.callback(val, indexRow, row);
|
|
42974
42981
|
}
|
|
42975
42982
|
handleDataChange(row, col, indexRow);
|
|
42976
|
-
}, fieldValue: col.selectSettings?.fieldValue, fieldLabel: col.selectSettings?.fieldLabel, component: gridRef, columns: col.selectSettings?.columns, isClearable: col.selectSettings?.isClearable ?? false, formatSetting: formatSetting, placeholder: t(
|
|
42977
|
-
return checkKeyDown(e, row, col, indexRow + 1, indexCol + 1);
|
|
42978
|
-
}, onOpenMenu: () => {
|
|
42979
|
-
if (col.selectSettings?.onOpenMenu) {
|
|
42980
|
-
col.selectSettings?.onOpenMenu(row, col, indexRow);
|
|
42981
|
-
}
|
|
42982
|
-
}, onPaste: (e) => {
|
|
42983
|
+
}, 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) => {
|
|
42983
42984
|
if (toolbarSetting?.showBottomToolbar && !editDisable && !addDisable && !col.disablePaste) {
|
|
42984
42985
|
pasteDataFromExcel(indexRow, indexCol, e);
|
|
42985
42986
|
e.preventDefault();
|
|
42986
42987
|
}
|
|
42987
42988
|
} }));
|
|
42988
|
-
case
|
|
42989
|
+
case "selectTree":
|
|
42989
42990
|
const findItemInTree = (items, value) => {
|
|
42990
42991
|
for (let index = 0; index < items.length; index++) {
|
|
42991
42992
|
const item = items[index];
|
|
42992
|
-
if (item[col.selectSettings?.fieldValue ? col.selectSettings?.fieldValue :
|
|
42993
|
+
if (item[col.selectSettings?.fieldValue ? col.selectSettings?.fieldValue : "value"] === value) {
|
|
42993
42994
|
return { ...item };
|
|
42994
42995
|
}
|
|
42995
|
-
else if (item[col.selectSettings?.fieldChild ??
|
|
42996
|
-
const itemFilter = findItemInTree(item[col.selectSettings?.fieldChild ??
|
|
42996
|
+
else if (item[col.selectSettings?.fieldChild ?? "children"]?.length > 0) {
|
|
42997
|
+
const itemFilter = findItemInTree(item[col.selectSettings?.fieldChild ?? "children"], value);
|
|
42997
42998
|
if (itemFilter) {
|
|
42998
42999
|
return itemFilter;
|
|
42999
43000
|
}
|
|
@@ -43006,39 +43007,37 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43006
43007
|
optionsSelectTree = row[col.selectSettings?.optionsField] ? row[col.selectSettings?.optionsField] : [];
|
|
43007
43008
|
}
|
|
43008
43009
|
else {
|
|
43009
|
-
optionsSelectTree = col.selectSettings?.options
|
|
43010
|
+
optionsSelectTree = col.selectSettings?.options
|
|
43011
|
+
? col.selectSettings?.validateOption
|
|
43012
|
+
? col.selectSettings?.options.filter((item) => col.selectSettings?.validateOption(item, row))
|
|
43013
|
+
: col.selectSettings?.options
|
|
43014
|
+
: [];
|
|
43010
43015
|
}
|
|
43011
43016
|
if (col.selectSettings?.isMulti) {
|
|
43012
43017
|
valueSelectTree = row[col.field];
|
|
43013
43018
|
}
|
|
43014
43019
|
else {
|
|
43015
|
-
valueSelectTree =
|
|
43020
|
+
valueSelectTree = !isNullOrUndefined(row[col.field]) && row[col.field] !== "" ? findItemInTree(optionsSelectTree, row[col.field]) : "";
|
|
43016
43021
|
}
|
|
43017
43022
|
return (jsxRuntime.jsx(SelectTableTree, { id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`, value: valueSelectTree, options: optionsSelectTree, onChange: (val) => {
|
|
43018
43023
|
if (col.selectSettings?.isMulti) {
|
|
43019
43024
|
row[col.field] = !isNullOrUndefined(val) ? val : [];
|
|
43020
43025
|
}
|
|
43021
43026
|
else {
|
|
43022
|
-
row[col.field] = !isNullOrUndefined(val) ? val[col.selectSettings?.fieldValue ??
|
|
43027
|
+
row[col.field] = !isNullOrUndefined(val) ? val[col.selectSettings?.fieldValue ?? "value"] : undefined;
|
|
43023
43028
|
}
|
|
43024
43029
|
if (col.callback) {
|
|
43025
43030
|
col.callback(val, indexRow, row);
|
|
43026
43031
|
}
|
|
43027
43032
|
handleDataChange(row, col, indexRow);
|
|
43028
|
-
}, fieldValue: col.selectSettings?.fieldValue, fieldLabel: col.selectSettings?.fieldLabel, component: gridRef, columns: col.selectSettings?.columns, isClearable: col.selectSettings?.isClearable ?? false, formatSetting: formatSetting, placeholder: t(
|
|
43029
|
-
if (col.selectSettings?.onOpenMenu) {
|
|
43030
|
-
col.selectSettings?.onOpenMenu(row, col, indexRow);
|
|
43031
|
-
}
|
|
43032
|
-
}, 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) => {
|
|
43033
|
-
checkKeyDown(e, row, col, indexRow + 1, indexCol + 1);
|
|
43034
|
-
}, onPaste: (e) => {
|
|
43033
|
+
}, 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) => {
|
|
43035
43034
|
if (toolbarSetting?.showBottomToolbar && !editDisable && !addDisable && !col.disablePaste) {
|
|
43036
43035
|
pasteDataFromExcel(indexRow, indexCol, e);
|
|
43037
43036
|
e.preventDefault();
|
|
43038
43037
|
}
|
|
43039
43038
|
} }));
|
|
43040
|
-
case
|
|
43041
|
-
return (jsxRuntime.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 ??
|
|
43039
|
+
case "checkbox":
|
|
43040
|
+
return (jsxRuntime.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) => {
|
|
43042
43041
|
row[col.field] = val.currentTarget.checked;
|
|
43043
43042
|
if (col.callback) {
|
|
43044
43043
|
col.callback(val.target.value, indexRow, row);
|
|
@@ -43047,16 +43046,16 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43047
43046
|
}, onKeyDown: (e) => {
|
|
43048
43047
|
checkKeyDown(e, row, col, indexRow + 1, indexCol + 1);
|
|
43049
43048
|
} }));
|
|
43050
|
-
case
|
|
43049
|
+
case "numeric":
|
|
43051
43050
|
const numericFormatProps = {
|
|
43052
|
-
value: !isNullOrUndefined(row[col.field]) ? row[col.field].toString() :
|
|
43051
|
+
value: !isNullOrUndefined(row[col.field]) ? row[col.field].toString() : "",
|
|
43053
43052
|
thousandSeparator: checkThousandSeparator(formatSetting?.thousandSeparator, formatSetting?.decimalSeparator),
|
|
43054
43053
|
decimalSeparator: checkDecimalSeparator(formatSetting?.thousandSeparator, formatSetting?.decimalSeparator),
|
|
43055
43054
|
allowNegative: col.numericSettings?.allowNegative ?? false,
|
|
43056
43055
|
decimalScale: col.numericSettings?.fraction ?? 0
|
|
43057
43056
|
};
|
|
43058
|
-
let floatValue = parseFloat(row[col.field] ??
|
|
43059
|
-
return (jsxRuntime.jsx(NumericFormat, { id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`, style: { textAlign: col.textAlign, height: 29 }, ...numericFormatProps, defaultValue: formartNumberic(row[col.field], formatSetting?.decimalSeparator ??
|
|
43057
|
+
let floatValue = parseFloat(row[col.field] ?? "0");
|
|
43058
|
+
return (jsxRuntime.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) => {
|
|
43060
43059
|
floatValue = values?.floatValue;
|
|
43061
43060
|
}, onFocus: (e) => {
|
|
43062
43061
|
e.target.setSelectionRange(0, e.target.innerText.length - 1);
|
|
@@ -43069,7 +43068,7 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43069
43068
|
handleDataChange(row, col, indexRow);
|
|
43070
43069
|
}
|
|
43071
43070
|
}, onKeyDown: (e) => {
|
|
43072
|
-
if (e.key ===
|
|
43071
|
+
if (e.key === "ArrowDown" || e.key === "NumpadEnter" || e.key === "ArrowUp" || e.key === "Enter" || e.key === "Tab") {
|
|
43073
43072
|
if (floatValue !== row[col.field]) {
|
|
43074
43073
|
row[col.field] = !isNaN(floatValue) ? floatValue : 0;
|
|
43075
43074
|
if (col.callback) {
|
|
@@ -43085,8 +43084,8 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43085
43084
|
e.preventDefault();
|
|
43086
43085
|
}
|
|
43087
43086
|
} }));
|
|
43088
|
-
case
|
|
43089
|
-
return (jsxRuntime.jsx("div", { style: { padding:
|
|
43087
|
+
case "color":
|
|
43088
|
+
return (jsxRuntime.jsx("div", { style: { padding: "4px 8px" }, children: jsxRuntime.jsx(Input$1, { type: "color", value: row[col.field], style: { textAlign: col.textAlign ?? "center", padding: 0, height: 23, border: "none" }, disabled: editDisable, onChange: (val) => {
|
|
43090
43089
|
if (row[col.field] != val.target?.value) {
|
|
43091
43090
|
row[col.field] = val.target?.value;
|
|
43092
43091
|
if (col.callback) {
|
|
@@ -43097,8 +43096,8 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43097
43096
|
}, onKeyDown: (val) => {
|
|
43098
43097
|
checkKeyDown(val, row, col, indexRow + 1, indexCol + 1);
|
|
43099
43098
|
} }, `col-${indexRow}-${indexCol}`) }));
|
|
43100
|
-
case
|
|
43101
|
-
return (jsxRuntime.jsx(EditForm, { id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`, ...col.formSettings, field: col.field, displayValue: col.formSettings?.displayValue ? col.formSettings?.displayValue(row) :
|
|
43099
|
+
case "form":
|
|
43100
|
+
return (jsxRuntime.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) => {
|
|
43102
43101
|
Object.assign(row, val);
|
|
43103
43102
|
handleDataChange(row, col, indexRow);
|
|
43104
43103
|
}, invalid: col.validate && col.validate(row[col.field], row), textAlign: col.textAlign, template: col.template, onKeyDown: (e) => {
|
|
@@ -43109,8 +43108,8 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43109
43108
|
e.preventDefault();
|
|
43110
43109
|
}
|
|
43111
43110
|
} }));
|
|
43112
|
-
case
|
|
43113
|
-
return (jsxRuntime.jsx(EditFormInline, { id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`, ...col.formSettings, field: col.field, displayValue: col.formSettings?.displayValue ? col.formSettings?.displayValue(row) :
|
|
43111
|
+
case "formInline":
|
|
43112
|
+
return (jsxRuntime.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) => {
|
|
43114
43113
|
Object.assign(row, val);
|
|
43115
43114
|
handleDataChange(row, col, indexRow);
|
|
43116
43115
|
}, invalid: col.validate && col.validate(row[col.field], row), textAlign: col.textAlign, template: col.template, onKeyDown: (e) => {
|
|
@@ -43122,7 +43121,7 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43122
43121
|
}
|
|
43123
43122
|
} }));
|
|
43124
43123
|
default:
|
|
43125
|
-
return (jsxRuntime.jsx(Input$1, { id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`, style: { textAlign: col.textAlign, height: 29 }, value: isNullOrUndefined(row[col.field]) ?
|
|
43124
|
+
return (jsxRuntime.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) => {
|
|
43126
43125
|
if (row[col.field] != val.target?.value) {
|
|
43127
43126
|
row[col.field] = val.target?.value;
|
|
43128
43127
|
if (col.callback) {
|
|
@@ -43150,8 +43149,8 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43150
43149
|
setTimeout(() => {
|
|
43151
43150
|
const element = document.getElementById(`${idTable}-col${col}-row${row}`);
|
|
43152
43151
|
if (element) {
|
|
43153
|
-
if (element.className.includes(
|
|
43154
|
-
element.getElementsByTagName(
|
|
43152
|
+
if (element.className.includes("react-select") || element.className.includes("form-edit")) {
|
|
43153
|
+
element.getElementsByTagName("input")[0]?.focus();
|
|
43155
43154
|
}
|
|
43156
43155
|
else {
|
|
43157
43156
|
element.focus();
|
|
@@ -43160,16 +43159,17 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43160
43159
|
if (tableElement.current) {
|
|
43161
43160
|
const parentRect = tableElement.current.getBoundingClientRect();
|
|
43162
43161
|
const childRect = element.getBoundingClientRect();
|
|
43163
|
-
const offset = childRect.left - parentRect.left + tableElement.current.scrollLeft -
|
|
43164
|
-
tableElement.current.scrollTo({ left: offset, behavior:
|
|
43162
|
+
const offset = childRect.left - parentRect.left + tableElement.current.scrollLeft - parentRect.width / 2 + childRect.width / 2;
|
|
43163
|
+
tableElement.current.scrollTo({ left: offset, behavior: "smooth" });
|
|
43165
43164
|
}
|
|
43166
43165
|
}
|
|
43167
43166
|
if ((tableElement.current?.scrollHeight ?? 0) > 0) {
|
|
43168
43167
|
if ((tableElement.current?.scrollTop ?? 0) > ((row - 1) % (pagingSetting?.pageSize ?? 10000)) * 34) {
|
|
43169
|
-
tableElement.current?.scrollTo({ behavior:
|
|
43168
|
+
tableElement.current?.scrollTo({ behavior: "smooth", top: ((row - 1) % (pagingSetting?.pageSize ?? 10000)) * 34 });
|
|
43170
43169
|
}
|
|
43171
|
-
else if ((
|
|
43172
|
-
|
|
43170
|
+
else if ((tableElement.current?.clientHeight ?? 0) - (haveSum ? 30 : 0) - headerColumns.length * 42 <
|
|
43171
|
+
(row % (pagingSetting?.pageSize ?? 10000)) * 34 - (tableElement.current?.scrollTop ?? 0)) {
|
|
43172
|
+
tableElement.current?.scrollTo({ behavior: "smooth", top: (tableElement.current?.scrollTop ?? 0) + 34 });
|
|
43173
43173
|
}
|
|
43174
43174
|
}
|
|
43175
43175
|
}
|
|
@@ -43178,7 +43178,7 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43178
43178
|
//Thêm dòng mới
|
|
43179
43179
|
const moveIndexRowToNewPage = () => {
|
|
43180
43180
|
changeDataSource(dataSource, 1);
|
|
43181
|
-
if (pagingClient && pagingSetting?.setCurrentPage &&
|
|
43181
|
+
if (pagingClient && pagingSetting?.setCurrentPage && totalCount % (pagingSetting?.pageSize ?? 0) === 0) {
|
|
43182
43182
|
pagingSetting?.setCurrentPage((pagingSetting?.currentPage ?? 0) + 1);
|
|
43183
43183
|
}
|
|
43184
43184
|
if (tableElement) {
|
|
@@ -43253,25 +43253,25 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43253
43253
|
return undefined;
|
|
43254
43254
|
};
|
|
43255
43255
|
const pasteDataFromExcel = async (currenRowIndex, indexCol, e) => {
|
|
43256
|
-
const clipboard = (e.clipboardData || window.Clipboard).getData(
|
|
43257
|
-
const rowsClipboard = clipboard.trimEnd().split(
|
|
43256
|
+
const clipboard = (e.clipboardData || window.Clipboard).getData("text");
|
|
43257
|
+
const rowsClipboard = clipboard.trimEnd().split("\n");
|
|
43258
43258
|
setIndexFocus(-1);
|
|
43259
43259
|
if (rowsClipboard.length > 200) {
|
|
43260
|
-
messageBoxError(t,
|
|
43260
|
+
messageBoxError(t, "You can only paste up to 200 rows.");
|
|
43261
43261
|
}
|
|
43262
43262
|
if (rowsClipboard.length > 0) {
|
|
43263
43263
|
const columnsDataChange = [];
|
|
43264
|
-
for (let index = 0; index < rowsClipboard[0].trimEnd().split(
|
|
43264
|
+
for (let index = 0; index < rowsClipboard[0].trimEnd().split("\t").length; index++) {
|
|
43265
43265
|
const stringData = [];
|
|
43266
43266
|
rowsClipboard.forEach((element) => {
|
|
43267
|
-
if (element.trimEnd().split(
|
|
43268
|
-
stringData.push(element.trimEnd().split(
|
|
43267
|
+
if (element.trimEnd().split("\t")[index] && !stringData.includes(element.trimEnd().split("\t")[index].toString().trim())) {
|
|
43268
|
+
stringData.push(element.trimEnd().split("\t")[index].toString().trim());
|
|
43269
43269
|
}
|
|
43270
43270
|
});
|
|
43271
43271
|
const column = getColumn(indexCol, index);
|
|
43272
43272
|
if (column) {
|
|
43273
43273
|
if ((!column.disabledCondition || !column.disabledCondition(dataSource[currenRowIndex + 0])) && column.editEnable && column.onPasteValidate) {
|
|
43274
|
-
const rs = await column.onPasteValidate(stringData.join(
|
|
43274
|
+
const rs = await column.onPasteValidate(stringData.join(","), currenRowIndex + 0, dataSource[currenRowIndex + 0]);
|
|
43275
43275
|
if (rs) {
|
|
43276
43276
|
column.resultValidate = rs;
|
|
43277
43277
|
}
|
|
@@ -43281,7 +43281,7 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43281
43281
|
}
|
|
43282
43282
|
for (let indexRow = 0; indexRow < rowsClipboard.length; indexRow++) {
|
|
43283
43283
|
const item = rowsClipboard[indexRow];
|
|
43284
|
-
const colsClipboard = item.trimEnd().split(
|
|
43284
|
+
const colsClipboard = item.trimEnd().split("\t");
|
|
43285
43285
|
let dataRow = dataSource[currenRowIndex + indexRow];
|
|
43286
43286
|
if (!dataRow) {
|
|
43287
43287
|
dataRow = { ...defaultValue };
|
|
@@ -43293,7 +43293,7 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43293
43293
|
if (column) {
|
|
43294
43294
|
if (((!column.disabledCondition || !column.disabledCondition(dataSource[currenRowIndex + indexRow])) && column.editEnable) || column.onPaste) {
|
|
43295
43295
|
if (column.onPasteValidate && column.resultValidate) {
|
|
43296
|
-
const rs = column.resultValidate.find((item) => item[column.selectSettings?.fieldValue ??
|
|
43296
|
+
const rs = column.resultValidate.find((item) => item[column.selectSettings?.fieldValue ?? "value"] === stringData);
|
|
43297
43297
|
if (rs) {
|
|
43298
43298
|
if (column.onPaste) {
|
|
43299
43299
|
dataRow[column.field] = column.onPaste(dataRow, stringData);
|
|
@@ -43306,12 +43306,12 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43306
43306
|
}
|
|
43307
43307
|
}
|
|
43308
43308
|
else {
|
|
43309
|
-
notificationError(t(
|
|
43309
|
+
notificationError(t("PasteExcelNotExist", { index: currenRowIndex + indexRow + 1, field: t(column.headerText ?? ""), value: stringData }));
|
|
43310
43310
|
}
|
|
43311
43311
|
}
|
|
43312
43312
|
else {
|
|
43313
|
-
if (column.type ===
|
|
43314
|
-
const [day, month, year] = stringData.split(
|
|
43313
|
+
if (column.type === "date") {
|
|
43314
|
+
const [day, month, year] = stringData.split("/");
|
|
43315
43315
|
const date = new Date(`${year}-${month}-${day}`);
|
|
43316
43316
|
if (!isNaN(date.getTime())) {
|
|
43317
43317
|
if (column.onPaste) {
|
|
@@ -43325,13 +43325,13 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43325
43325
|
}
|
|
43326
43326
|
}
|
|
43327
43327
|
else {
|
|
43328
|
-
notificationError(t(
|
|
43328
|
+
notificationError(t("PasteExcelIncorrectFormat", { index: currenRowIndex + indexRow + 1, field: t(column.headerText ?? ""), value: stringData }));
|
|
43329
43329
|
}
|
|
43330
43330
|
}
|
|
43331
|
-
else if (column.type ===
|
|
43332
|
-
const [datePart, timePart] = stringData.split(
|
|
43333
|
-
const [day, month, year] = datePart.split(
|
|
43334
|
-
const [hour, minute] = timePart.split(
|
|
43331
|
+
else if (column.type === "datetime") {
|
|
43332
|
+
const [datePart, timePart] = stringData.split(" ");
|
|
43333
|
+
const [day, month, year] = datePart.split("/");
|
|
43334
|
+
const [hour, minute] = timePart.split(":");
|
|
43335
43335
|
const date = new Date(Number(year), Number(month) - 1, Number(day), Number(hour), Number(minute));
|
|
43336
43336
|
if (!isNaN(date.getTime())) {
|
|
43337
43337
|
if (column.onPaste) {
|
|
@@ -43345,11 +43345,11 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43345
43345
|
}
|
|
43346
43346
|
}
|
|
43347
43347
|
else {
|
|
43348
|
-
notificationError(t(
|
|
43348
|
+
notificationError(t("PasteExcelIncorrectFormat", { index: currenRowIndex + indexRow + 1, field: t(column.headerText ?? ""), value: stringData }));
|
|
43349
43349
|
}
|
|
43350
43350
|
}
|
|
43351
|
-
else if (column.type ===
|
|
43352
|
-
const number = Number(stringData.replaceAll(formatSetting?.thousandSeparator ??
|
|
43351
|
+
else if (column.type === "numeric") {
|
|
43352
|
+
const number = Number(stringData.replaceAll(formatSetting?.thousandSeparator ?? ".", "").replaceAll(formatSetting?.decimalSeparator ?? ",", "."));
|
|
43353
43353
|
if (!isNaN(number)) {
|
|
43354
43354
|
if (column.onPaste) {
|
|
43355
43355
|
dataRow[column.field] = column.onPaste(dataRow, number);
|
|
@@ -43362,10 +43362,10 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43362
43362
|
}
|
|
43363
43363
|
}
|
|
43364
43364
|
else {
|
|
43365
|
-
notificationError(t(
|
|
43365
|
+
notificationError(t("PasteExcelIncorrectFormat", { index: currenRowIndex + indexRow + 1, field: t(column.headerText ?? ""), value: stringData }));
|
|
43366
43366
|
}
|
|
43367
43367
|
}
|
|
43368
|
-
else if (column.type ===
|
|
43368
|
+
else if (column.type === "select") {
|
|
43369
43369
|
if (column.selectSettings?.allowCreate) {
|
|
43370
43370
|
if (column.onPaste) {
|
|
43371
43371
|
dataRow[column.field] = column.onPaste(dataRow, stringData);
|
|
@@ -43378,7 +43378,7 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43378
43378
|
}
|
|
43379
43379
|
}
|
|
43380
43380
|
else {
|
|
43381
|
-
const rs = ((column.selectSettings?.optionsField ? item[column.selectSettings?.optionsField] : column.selectSettings?.options) ?? []).find((item) => item[column.selectSettings?.fieldValue ??
|
|
43381
|
+
const rs = ((column.selectSettings?.optionsField ? item[column.selectSettings?.optionsField] : column.selectSettings?.options) ?? []).find((item) => item[column.selectSettings?.fieldValue ?? "value"] === stringData);
|
|
43382
43382
|
if (rs) {
|
|
43383
43383
|
if (column.onPaste) {
|
|
43384
43384
|
dataRow[column.field] = column.onPaste(dataRow, stringData);
|
|
@@ -43391,7 +43391,7 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43391
43391
|
}
|
|
43392
43392
|
}
|
|
43393
43393
|
else {
|
|
43394
|
-
notificationError(t(
|
|
43394
|
+
notificationError(t("PasteExcelNotExist", { index: currenRowIndex + indexRow + 1, field: t(column.headerText ?? ""), value: stringData }));
|
|
43395
43395
|
}
|
|
43396
43396
|
}
|
|
43397
43397
|
}
|
|
@@ -43411,7 +43411,7 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43411
43411
|
}
|
|
43412
43412
|
}
|
|
43413
43413
|
if (rowChange) {
|
|
43414
|
-
rowChange(dataRow, currenRowIndex + indexRow,
|
|
43414
|
+
rowChange(dataRow, currenRowIndex + indexRow, "");
|
|
43415
43415
|
}
|
|
43416
43416
|
}
|
|
43417
43417
|
}
|
|
@@ -43443,7 +43443,7 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43443
43443
|
}
|
|
43444
43444
|
else {
|
|
43445
43445
|
if (dataSource && selectedRows?.length > 0) {
|
|
43446
|
-
if (
|
|
43446
|
+
if (!selectedItem || selectedItem[fieldKey] !== selectedRows[0][fieldKey]) {
|
|
43447
43447
|
setSelectedItem({ ...selectedRows[0] });
|
|
43448
43448
|
if (handleSelect) {
|
|
43449
43449
|
handleSelect({ ...selectedRows[0] });
|
|
@@ -43477,56 +43477,61 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43477
43477
|
}
|
|
43478
43478
|
}, [selectedItem]);
|
|
43479
43479
|
const renderContentCol = (col, row, indexRow, indexCol, isSelected) => {
|
|
43480
|
-
if (col.field ===
|
|
43481
|
-
return (col.visible !== false && jsxRuntime.jsx("td", { role: "gridcell", "aria-colindex": indexCol, className: classNames$2(`r-rowcell p-0 fix-${col.fixedType}`, {
|
|
43482
|
-
left: col.fixedType ===
|
|
43483
|
-
right: col.fixedType ===
|
|
43484
|
-
textAlign: col.textAlign ? col.textAlign :
|
|
43485
|
-
}, children: jsxRuntime.jsx("div", { className: "r-rowcell-div command", children: jsxRuntime.jsx(CommandElement, { commandItems: col.commandItems ?? [], handleCommandClick: handleCommandClick, indexRow: indexRow, rowData: row, setIndexFocus: setIndexFocus, indexFocus: indexFocus }) }) }, `col-${indexRow}-${indexCol}`));
|
|
43480
|
+
if (col.field === "command") {
|
|
43481
|
+
return (col.visible !== false && (jsxRuntime.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: {
|
|
43482
|
+
left: col.fixedType === "left" ? objWidthFixLeft[indexCol] : undefined,
|
|
43483
|
+
right: col.fixedType === "right" ? objWidthFixRight[indexCol] : undefined,
|
|
43484
|
+
textAlign: col.textAlign ? col.textAlign : "left"
|
|
43485
|
+
}, children: jsxRuntime.jsx("div", { className: "r-rowcell-div command", children: jsxRuntime.jsx(CommandElement, { commandItems: col.commandItems ?? [], handleCommandClick: handleCommandClick, indexRow: indexRow, rowData: row, setIndexFocus: setIndexFocus, indexFocus: indexFocus }) }) }, `col-${indexRow}-${indexCol}`)));
|
|
43486
43486
|
}
|
|
43487
|
-
else if (col.field ===
|
|
43488
|
-
return (col.visible !== false && jsxRuntime.jsx("td", { role: "gridcell", "aria-colindex": indexCol, className: classNames$2(`r-rowcell p-0 cursor-pointer fix-${col.fixedType}`, {
|
|
43489
|
-
left: col.fixedType ===
|
|
43490
|
-
right: col.fixedType ===
|
|
43491
|
-
textAlign:
|
|
43487
|
+
else if (col.field === "#") {
|
|
43488
|
+
return (col.visible !== false && (jsxRuntime.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: {
|
|
43489
|
+
left: col.fixedType === "left" ? objWidthFixLeft[indexCol] : undefined,
|
|
43490
|
+
right: col.fixedType === "right" ? objWidthFixRight[indexCol] : undefined,
|
|
43491
|
+
textAlign: "center"
|
|
43492
43492
|
}, onCopy: (e) => {
|
|
43493
|
-
if (!editDisable && (e.target.nodeName ===
|
|
43493
|
+
if (!editDisable && (e.target.nodeName === "DIV" || e.target.nodeName === "TD")) {
|
|
43494
43494
|
navigator.clipboard.writeText(JSON.stringify(row));
|
|
43495
|
-
notificationSuccess(t(
|
|
43495
|
+
notificationSuccess(t("CopySuccessful"));
|
|
43496
43496
|
e.stopPropagation();
|
|
43497
43497
|
}
|
|
43498
43498
|
}, onPaste: (e) => {
|
|
43499
|
-
if (!editDisable && (e.target.nodeName ===
|
|
43500
|
-
navigator.clipboard
|
|
43499
|
+
if (!editDisable && (e.target.nodeName === "DIV" || e.target.nodeName === "TD")) {
|
|
43500
|
+
navigator.clipboard
|
|
43501
|
+
.readText()
|
|
43502
|
+
.then((rs) => {
|
|
43501
43503
|
dataSource[indexRow] = JSON.parse(rs);
|
|
43502
43504
|
if (fieldKey) {
|
|
43503
43505
|
dataSource[indexRow][fieldKey] = defaultValue[fieldKey];
|
|
43504
43506
|
}
|
|
43505
43507
|
changeDataSource(dataSource);
|
|
43506
|
-
notificationSuccess(t(
|
|
43507
|
-
})
|
|
43508
|
+
notificationSuccess(t("PasteSuccessful"));
|
|
43509
|
+
})
|
|
43510
|
+
.catch((ex) => {
|
|
43511
|
+
alert(ex);
|
|
43512
|
+
});
|
|
43508
43513
|
e.stopPropagation();
|
|
43509
43514
|
}
|
|
43510
43515
|
}, onClick: (e) => {
|
|
43511
|
-
if (e.target.nodeName ===
|
|
43516
|
+
if (e.target.nodeName === "DIV" || e.target.nodeName === "TD") {
|
|
43512
43517
|
if (!editDisable && indexRow != indexFocus) {
|
|
43513
43518
|
setIndexFocus(indexRow);
|
|
43514
43519
|
}
|
|
43515
43520
|
e.stopPropagation();
|
|
43516
43521
|
}
|
|
43517
43522
|
}, onKeyDown: (e) => {
|
|
43518
|
-
if (e.code ===
|
|
43523
|
+
if (e.code === "KeyD" && e.ctrlKey == true && !editDisable && !addDisable && (e.target.nodeName === "DIV" || e.target.nodeName === "TD")) {
|
|
43519
43524
|
handleDuplicate(dataSource, indexFocus, fieldKey, defaultValue, fieldUniKey, changeDataSource, tableElement, totalCount, toolbarSetting, buttonSetting, editDisable, addDisable, onDuplicate);
|
|
43520
43525
|
e.preventDefault();
|
|
43521
43526
|
e.stopPropagation();
|
|
43522
43527
|
}
|
|
43523
|
-
}, children: jsxRuntime.jsx("div", { className: "r-rowcell-div", children: indexRow + 1 }) }, `col-${indexRow}-${indexCol}`));
|
|
43528
|
+
}, children: jsxRuntime.jsx("div", { className: "r-rowcell-div", children: indexRow + 1 }) }, `col-${indexRow}-${indexCol}`)));
|
|
43524
43529
|
}
|
|
43525
|
-
else if (col.field ===
|
|
43526
|
-
return (jsxRuntime.jsx("td", { role: "gridcell", "aria-colindex": indexCol, className: classNames$2(`r-rowcell p-0 fix-${col.fixedType}`, {
|
|
43527
|
-
left: col.fixedType ===
|
|
43528
|
-
right: col.fixedType ===
|
|
43529
|
-
}, children: jsxRuntime.jsx("div", { className: "r-rowcell-div cursor-pointer", style: { alignItems:
|
|
43530
|
+
else if (col.field === "checkbox") {
|
|
43531
|
+
return (jsxRuntime.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: {
|
|
43532
|
+
left: col.fixedType === "left" ? objWidthFixLeft[indexCol] : undefined,
|
|
43533
|
+
right: col.fixedType === "right" ? objWidthFixRight[indexCol] : undefined
|
|
43534
|
+
}, children: jsxRuntime.jsx("div", { className: "r-rowcell-div cursor-pointer", style: { alignItems: "center" }, onClick: (e) => {
|
|
43530
43535
|
if (selectEnable) {
|
|
43531
43536
|
const index = selectedRows?.findIndex((x) => x[fieldKey] === row[fieldKey]);
|
|
43532
43537
|
if (index > -1) {
|
|
@@ -43548,26 +43553,34 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43548
43553
|
}
|
|
43549
43554
|
e.stopPropagation();
|
|
43550
43555
|
}
|
|
43551
|
-
}, children: jsxRuntime.jsx(Input$1, { checked: isSelected, type: "checkbox", className: "cursor-pointer", style: { textAlign: col.textAlign ??
|
|
43556
|
+
}, children: jsxRuntime.jsx(Input$1, { checked: isSelected, type: "checkbox", className: "cursor-pointer", style: { textAlign: col.textAlign ?? "center" } }) }) }, `col-${indexRow}-${indexCol}`));
|
|
43552
43557
|
}
|
|
43553
43558
|
else {
|
|
43554
43559
|
let value = row[col.field];
|
|
43555
|
-
if (col.type ===
|
|
43556
|
-
value = formartNumberic(row[col.field], formatSetting?.decimalSeparator ??
|
|
43560
|
+
if (col.type === "numeric" || (col.typeCondition && col.typeCondition(row) === "numeric")) {
|
|
43561
|
+
value = formartNumberic(row[col.field], formatSetting?.decimalSeparator ?? ",", formatSetting?.thousandSeparator ?? ".", col.numericSettings?.fraction, true, false) ?? 0;
|
|
43557
43562
|
}
|
|
43558
|
-
else if (col.type ===
|
|
43559
|
-
value = value ? formatDateTime(value, formatSetting?.dateFormat) :
|
|
43563
|
+
else if (col.type === "date") {
|
|
43564
|
+
value = value ? formatDateTime(value, formatSetting?.dateFormat) : "";
|
|
43560
43565
|
}
|
|
43561
|
-
else if (col.type ===
|
|
43562
|
-
value = value ? formatDateTime(value, formatSetting?.dateFormat ??
|
|
43566
|
+
else if (col.type === "datetime") {
|
|
43567
|
+
value = value ? formatDateTime(value, formatSetting?.dateFormat ?? "DD/MM/yyyy HH:mm") : "";
|
|
43563
43568
|
}
|
|
43564
|
-
const typeDis = !editDisable && (indexFocus === indexRow || col.type ===
|
|
43565
|
-
|
|
43566
|
-
|
|
43567
|
-
|
|
43568
|
-
|
|
43569
|
+
const typeDis = !editDisable && (indexFocus === indexRow || col.type === "checkbox") && (!col.disabledCondition || !col.disabledCondition(row))
|
|
43570
|
+
? col.editEnable
|
|
43571
|
+
? 1
|
|
43572
|
+
: col.template
|
|
43573
|
+
? 2
|
|
43574
|
+
: 3
|
|
43575
|
+
: col.template
|
|
43576
|
+
? 2
|
|
43577
|
+
: 3;
|
|
43578
|
+
const errorMessage = typeDis === 1 || col.field === "" || !col.validate ? "" : col.validate(row[col.field], row);
|
|
43579
|
+
return (jsxRuntime.jsx(React$5.Fragment, { children: col.visible !== false && (jsxRuntime.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: {
|
|
43580
|
+
left: col.fixedType === "left" ? objWidthFixLeft[indexCol] : undefined,
|
|
43581
|
+
right: col.fixedType === "right" ? objWidthFixRight[indexCol] : undefined
|
|
43569
43582
|
}, onClick: (e) => {
|
|
43570
|
-
if (e.target.nodeName ===
|
|
43583
|
+
if (e.target.nodeName === "DIV" || e.target.nodeName === "TD") {
|
|
43571
43584
|
if (!editDisable && indexRow != indexFocus) {
|
|
43572
43585
|
setIndexFocus(indexRow);
|
|
43573
43586
|
focusNewElement(indexCol + 1, indexRow + 1, true);
|
|
@@ -43594,30 +43607,34 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43594
43607
|
}
|
|
43595
43608
|
e.stopPropagation();
|
|
43596
43609
|
}
|
|
43597
|
-
}, children: jsxRuntime.jsx("div", { className: classNames$2(
|
|
43598
|
-
textAlign: col.textAlign ? col.textAlign :
|
|
43599
|
-
}, children: [typeDis === 1 && !refreshRow && jsxRuntime.jsx(jsxRuntime.Fragment, { children: RenderEditCell(row, col, indexCol, indexRow) }), (typeDis !== 1 || refreshRow) && RenderContentCell(row, col, indexCol, indexRow, typeDis, value), jsxRuntime.jsx("span", { id: `error-${indexRow}-${indexCol}`, className: classNames$2(
|
|
43610
|
+
}, children: jsxRuntime.jsx("div", { className: classNames$2("r-rowcell-div"), children: jsxRuntime.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: {
|
|
43611
|
+
textAlign: col.textAlign ? col.textAlign : "left"
|
|
43612
|
+
}, children: [typeDis === 1 && !refreshRow && (jsxRuntime.jsx(jsxRuntime.Fragment, { children: RenderEditCell(row, col, indexCol, indexRow) })), (typeDis !== 1 || refreshRow) && RenderContentCell(row, col, indexCol, indexRow, typeDis, value), jsxRuntime.jsx("span", { id: `error-${indexRow}-${indexCol}`, className: classNames$2("cursor-pointer text-primary icon-table", { "d-none": !errorMessage }), children: jsxRuntime.jsx(SvgAlertCircle, { fontSize: 15.5 }) }), jsxRuntime.jsx(UncontrolledTooltip, { target: `error-${indexRow}-${indexCol}`, className: "r-tooltip tooltip-error", children: errorMessage?.toString() ?? "" })] }) }) }, `col-${indexRow}-${indexCol}`)) }, indexCol));
|
|
43600
43613
|
}
|
|
43601
43614
|
};
|
|
43602
43615
|
const RenderContentCell = (row, col, indexCol, indexRow, typeDis, value) => {
|
|
43603
43616
|
if (typeDis === 2) {
|
|
43604
|
-
const value = col.template?.(row, indexRow) ??
|
|
43605
|
-
if (typeof value ===
|
|
43606
|
-
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { id: `content-${idTable}-row${indexRow}col-${indexCol}`, className: "r-cell-text", children: value }),
|
|
43617
|
+
const value = col.template?.(row, indexRow) ?? "";
|
|
43618
|
+
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
|
43619
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { id: `content-${idTable}-row${indexRow}col-${indexCol}`, className: "r-cell-text", children: value }), !refreshRow && typeDis !== 2 && (jsxRuntime.jsx(UncontrolledTooltip, { className: "r-tooltip", autohide: false, target: `content-${idTable}-row${indexRow}col-${indexCol}`, children: col.type === "numeric" && Number(row[col.field]) < 0 ? (jsxRuntime.jsxs("div", { style: { color: formatSetting?.colorNegative ?? "red" }, children: [" ", `${formatSetting?.prefixNegative ?? "-"}${value}${formatSetting?.suffixNegative ?? ""}`] })) : (value) }))] }));
|
|
43607
43620
|
}
|
|
43608
43621
|
else {
|
|
43609
43622
|
return value;
|
|
43610
43623
|
}
|
|
43611
43624
|
}
|
|
43612
|
-
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { id: `content-${idTable}-row${indexRow}col-${indexCol}`, className: "r-cell-text", children:
|
|
43625
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { id: `content-${idTable}-row${indexRow}col-${indexCol}`, className: "r-cell-text", children: col.type === "numeric" && Number(row[col.field]) < 0 ? (jsxRuntime.jsxs("div", { style: { color: formatSetting?.colorNegative ?? "red" }, children: [" ", `${formatSetting?.prefixNegative ?? "-"}${value}${formatSetting?.suffixNegative ?? ""}`] })) : (value) }), !(typeDis === 1 && !refreshRow) && typeDis !== 2 && (jsxRuntime.jsx(UncontrolledTooltip, { className: "r-tooltip", autohide: false, target: `content-${idTable}-row${indexRow}col-${indexCol}`, children: col.type === "numeric" && Number(row[col.field]) < 0 ? (jsxRuntime.jsxs("div", { style: { color: formatSetting?.colorNegative ?? "red" }, children: [" ", `${formatSetting?.prefixNegative ?? "-"}${value}${formatSetting?.suffixNegative ?? ""}`] })) : (value) }))] }));
|
|
43613
43626
|
};
|
|
43614
43627
|
const renderFooterCol = (col, indexCol) => {
|
|
43615
|
-
const sumValue =
|
|
43616
|
-
|
|
43617
|
-
|
|
43618
|
-
|
|
43619
|
-
|
|
43620
|
-
|
|
43628
|
+
const sumValue = col.haveSum === true && col.type === "numeric"
|
|
43629
|
+
? dataSource.reduce(function (accumulator, currentValue) {
|
|
43630
|
+
return Number(accumulator ?? 0) + Number(currentValue[col.field] ?? 0);
|
|
43631
|
+
}, 0)
|
|
43632
|
+
: 0;
|
|
43633
|
+
return (jsxRuntime.jsx(React$5.Fragment, { children: col.visible !== false && (jsxRuntime.jsx("td", { className: classNames$2(`p-0 px-50 r-footer fix-${col.fixedType}`, { "cell-fixed": col.fixedType }), style: {
|
|
43634
|
+
left: col.fixedType === "left" ? objWidthFixLeft[indexCol] : undefined,
|
|
43635
|
+
right: col.fixedType === "right" ? objWidthFixRight[indexCol] : undefined,
|
|
43636
|
+
textAlign: col.textAlign ? col.textAlign : "left"
|
|
43637
|
+
}, children: jsxRuntime.jsxs("div", { className: "r-footer-div", children: [col.haveSum === true && col.type === "numeric" && Number(sumValue) >= 0 && (jsxRuntime.jsx(jsxRuntime.Fragment, { children: formartNumberic(sumValue, formatSetting?.decimalSeparator ?? ",", formatSetting?.thousandSeparator ?? ".", col.numericSettings?.fraction, true, false) })), col.haveSum === true && col.type === "numeric" && Number(sumValue) < 0 && (jsxRuntime.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}`));
|
|
43621
43638
|
};
|
|
43622
43639
|
/**
|
|
43623
43640
|
* 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
|
|
@@ -43625,7 +43642,7 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43625
43642
|
function checkRowMatch(row, filters, keyword, searchKeys) {
|
|
43626
43643
|
if ((!filters || filters.length === 0) && (!keyword || !searchClient))
|
|
43627
43644
|
return true; // Không có filter thì mặc định là match
|
|
43628
|
-
const isFilterMatch = filters.every(filter => {
|
|
43645
|
+
const isFilterMatch = filters.every((filter) => {
|
|
43629
43646
|
const { key, value, ope } = filter;
|
|
43630
43647
|
const rowValue = row[key];
|
|
43631
43648
|
if (rowValue === undefined || rowValue === null || value === undefined || value === null)
|
|
@@ -43633,32 +43650,33 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43633
43650
|
const valStr = String(rowValue).toLowerCase();
|
|
43634
43651
|
const filterStr = String(value).toLowerCase();
|
|
43635
43652
|
switch (ope) {
|
|
43636
|
-
case
|
|
43653
|
+
case "startswith":
|
|
43637
43654
|
return valStr.startsWith(filterStr);
|
|
43638
|
-
case
|
|
43655
|
+
case "endswith":
|
|
43639
43656
|
return valStr.endsWith(filterStr);
|
|
43640
|
-
case
|
|
43657
|
+
case "contains":
|
|
43641
43658
|
return valStr.includes(filterStr);
|
|
43642
|
-
case
|
|
43659
|
+
case "equal":
|
|
43643
43660
|
return rowValue == value;
|
|
43644
|
-
case
|
|
43661
|
+
case "notequal":
|
|
43645
43662
|
return rowValue != value;
|
|
43646
|
-
case
|
|
43663
|
+
case "greaterthan":
|
|
43647
43664
|
return rowValue > value;
|
|
43648
|
-
case
|
|
43665
|
+
case "greaterthanorequal":
|
|
43649
43666
|
return rowValue >= value;
|
|
43650
|
-
case
|
|
43667
|
+
case "lessthan":
|
|
43651
43668
|
return rowValue < value;
|
|
43652
|
-
case
|
|
43669
|
+
case "lessthanorequal":
|
|
43653
43670
|
return rowValue <= value;
|
|
43654
43671
|
default:
|
|
43655
43672
|
return false;
|
|
43656
43673
|
}
|
|
43657
43674
|
});
|
|
43658
|
-
const isSearchMatch = !keyword ||
|
|
43659
|
-
|
|
43660
|
-
|
|
43661
|
-
|
|
43675
|
+
const isSearchMatch = !keyword ||
|
|
43676
|
+
searchKeys.some((key) => {
|
|
43677
|
+
const val = row[key];
|
|
43678
|
+
return val?.toString().toLowerCase().includes(keyword.trim().toLowerCase());
|
|
43679
|
+
});
|
|
43662
43680
|
return isFilterMatch && isSearchMatch;
|
|
43663
43681
|
}
|
|
43664
43682
|
React$5.useEffect(() => {
|
|
@@ -43666,24 +43684,35 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43666
43684
|
pagingSetting?.setCurrentPage(1);
|
|
43667
43685
|
}
|
|
43668
43686
|
}, [searchTerm, searchSetting?.searchTerm]);
|
|
43669
|
-
return (jsxRuntime.jsxs(React$5.Fragment, { children: [jsxRuntime.jsxs("div", { className: "r-table-edit", children: [jsxRuntime.jsxs("div", { className:
|
|
43687
|
+
return (jsxRuntime.jsxs(React$5.Fragment, { children: [jsxRuntime.jsxs("div", { className: "r-table-edit", children: [jsxRuntime.jsxs("div", { className: "r-grid", ref: gridRef, children: [toolbarSetting?.showTopToolbar && jsxRuntime.jsx(RenderToolbarTop, { toolbarTopOption: toolbarTopOption }), jsxRuntime.jsx("div", { ref: tableElement, className: "r-gridtable", style: { height: `${height ? `${height}px` : "auto"}`, minHeight: `${minHeight ? `${minHeight}px` : ""}`, maxHeight: `${maxHeight ? `${maxHeight}px` : "400px"}` }, children: jsxRuntime.jsxs("table", { style: { width: "100%" }, role: "presentation", children: [jsxRuntime.jsx(RenderColGroup, { contentColumns: flatVisble }), jsxRuntime.jsx("thead", { className: "r-gridheader", role: "rowgroup", children: headerColumns.map((element, indexParent) => {
|
|
43670
43688
|
return (jsxRuntime.jsx("tr", { className: "r-row", role: "row", children: element?.map((col, index) => {
|
|
43671
|
-
return (jsxRuntime.jsx(HeaderTableCol$1, { col: col, idTable: idTable ??
|
|
43689
|
+
return (jsxRuntime.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) => {
|
|
43672
43690
|
setFilterBy([...val]);
|
|
43673
43691
|
}, changeOrder: (val) => {
|
|
43674
43692
|
setOrderBy([...val]);
|
|
43675
|
-
}, columns: contentColumns, setColumns:
|
|
43693
|
+
}, columns: contentColumns, setColumns: (newColumns) => {
|
|
43694
|
+
newColumns.forEach((x) => {
|
|
43695
|
+
const column = columns.find((y) => y.field === x.field);
|
|
43696
|
+
if (column) {
|
|
43697
|
+
column.visible = x.visible;
|
|
43698
|
+
column.fixedType = x.fixedType;
|
|
43699
|
+
column.width = x.width;
|
|
43700
|
+
}
|
|
43701
|
+
});
|
|
43702
|
+
setRefreshColumns(!refreshColumns);
|
|
43703
|
+
}, fisrtObjWidthFixRight: fisrtObjWidthFixRight, lastObjWidthFixLeft: lastObjWidthFixLeft, totalCount: totalCount }, `header-${indexParent}-${index}`));
|
|
43676
43704
|
}) }, `header-${-indexParent}`));
|
|
43677
|
-
}) }), jsxRuntime.jsx("tbody", { className:
|
|
43705
|
+
}) }), jsxRuntime.jsx("tbody", { className: "r-gridcontent", role: "rowgroup", children: dataSource.map((row, indexRow) => {
|
|
43678
43706
|
const isSelected = selectedRows?.some((x) => x[fieldKey] === row[fieldKey]);
|
|
43679
43707
|
const flagSearch = checkRowMatch(row, filterBy, searchSetting?.searchTerm !== undefined ? searchSetting?.searchTerm : searchTerm, searchSetting?.keyField ?? []);
|
|
43680
43708
|
if (flagSearch) {
|
|
43681
|
-
const flagDisplay = !pagingClient ||
|
|
43682
|
-
|
|
43709
|
+
const flagDisplay = !pagingClient ||
|
|
43710
|
+
(indexRow + 1 > (pagingSetting.pageSize ?? 0) * ((pagingSetting.currentPage ?? 0) - 1) && indexRow + 1 <= (pagingSetting.pageSize ?? 0) * (pagingSetting.currentPage ?? 0));
|
|
43711
|
+
return (flagDisplay && (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.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}`) })));
|
|
43683
43712
|
}
|
|
43684
|
-
}) }), jsxRuntime.jsx("tfoot", { className: "r-gridfoot", children: haveSum == true ? jsxRuntime.jsx("tr", { className:
|
|
43685
|
-
return
|
|
43686
|
-
}) }) : jsxRuntime.jsx(jsxRuntime.Fragment, {}) })] }) }), toolbarSetting?.showBottomToolbar && jsxRuntime.jsx(ToolbarBottom, { handleAdd: (numberOfRows) => {
|
|
43713
|
+
}) }), jsxRuntime.jsx("tfoot", { className: "r-gridfoot", children: haveSum == true ? (jsxRuntime.jsx("tr", { className: "r-row", children: contentColumns.map((col, index) => {
|
|
43714
|
+
return renderFooterCol(col, index);
|
|
43715
|
+
}) })) : (jsxRuntime.jsx(jsxRuntime.Fragment, {})) })] }) }), toolbarSetting?.showBottomToolbar && (jsxRuntime.jsx(ToolbarBottom, { handleAdd: (numberOfRows) => {
|
|
43687
43716
|
handleAdd(dataSource, tableElement.current, indexFirstEdit, changeDataSource, pagingSetting, setIndexFocus, focusNewElement, numberOfRows);
|
|
43688
43717
|
}, handleDuplicate: () => {
|
|
43689
43718
|
handleDuplicate(dataSource, indexFocus, fieldKey, defaultValue, fieldUniKey, changeDataSource, tableElement, totalCount, toolbarSetting, buttonSetting, editDisable, addDisable, onDuplicate);
|
|
@@ -43693,7 +43722,23 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43693
43722
|
handleInsertBefore(dataSource, indexFocus, defaultValue, changeDataSource, pagingClient, pagingSetting, toolbarSetting, buttonSetting, editDisable, addDisable);
|
|
43694
43723
|
}, handleDeleteAll: () => {
|
|
43695
43724
|
handleDeleteAll(t, messageBoxConfirmDelete, setIndexFocus, changeDataSource, editDisable, addDisable, toolbarSetting, buttonSetting);
|
|
43696
|
-
}, setOpenPopupSetupColumn: setOpenPopupSetupColumn, indexFocus: indexFocus, editDisable: editDisable, addDisable: addDisable, buttonSetting: buttonSetting, toolbarSetting: toolbarSetting, headerColumns: headerColumns, t: t })] }), pagingSetting?.allowPaging ? jsxRuntime.jsx(PagingComponent, { onChangePage: onChangePage, pageSize: pagingSetting?.pageSize ?? 0, currentPage: pagingSetting?.currentPage ?? 0, pageOptions: pagingSetting?.pageOptions ?? [20, 30, 50, 100], totalItem: pagingClient ? totalCount :
|
|
43725
|
+
}, setOpenPopupSetupColumn: setOpenPopupSetupColumn, indexFocus: indexFocus, editDisable: editDisable, addDisable: addDisable, buttonSetting: buttonSetting, toolbarSetting: toolbarSetting, headerColumns: headerColumns, t: t }))] }), pagingSetting?.allowPaging ? (jsxRuntime.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 })) : (jsxRuntime.jsx(jsxRuntime.Fragment, {}))] }), jsxRuntime.jsx(SidebarSetColumn, { handleSidebar: () => {
|
|
43726
|
+
setOpenPopupSetupColumn(!openPopupSetupColumn);
|
|
43727
|
+
}, openSidebar: openPopupSetupColumn, column: [...contentColumns], setColumn: (newColumns) => {
|
|
43728
|
+
if (saveSettingColumn) {
|
|
43729
|
+
console.log(newColumns);
|
|
43730
|
+
saveSettingColumn(newColumns.map((x) => ({ field: x.field, headerText: x.headerText, visible: x.visible, fixedType: x.fixedType, width: x.width })));
|
|
43731
|
+
}
|
|
43732
|
+
newColumns.forEach((x) => {
|
|
43733
|
+
const column = columns.find((y) => y.field === x.field);
|
|
43734
|
+
if (column) {
|
|
43735
|
+
column.visible = x.visible;
|
|
43736
|
+
column.fixedType = x.fixedType;
|
|
43737
|
+
column.width = x.width;
|
|
43738
|
+
}
|
|
43739
|
+
});
|
|
43740
|
+
setRefreshColumns(!refreshColumns);
|
|
43741
|
+
} })] }));
|
|
43697
43742
|
});
|
|
43698
43743
|
|
|
43699
43744
|
const TabsMenuComponent = ({ buttonWidth, tabParent, tabChild, resourceCodeParent, resources, resourceCode, windowSize, renderModal }) => {
|
|
@@ -46168,6 +46213,20 @@ const CheckboxInput = (props) => {
|
|
|
46168
46213
|
}), children: [renderLabel({ isLabel, name, label: label ?? '' }), jsxRuntime.jsxs("div", { className: classNames$2('form-input-content', { 'hidden-label': isLabel === false }), children: [renderInput(), renderText()] })] }) }));
|
|
46169
46214
|
};
|
|
46170
46215
|
|
|
46216
|
+
const StyleInput = (props) => {
|
|
46217
|
+
const { control, name, label, labelSize, required, errors, height, disabled, isLabel, inLine, classes, disabledBackgroundColor, disabledFontFamily, disabledFontSize, disabledBold, disabledItalic, disabledUnderline } = props;
|
|
46218
|
+
const renderInput = () => {
|
|
46219
|
+
return (jsxRuntime.jsxs(React$5.Fragment, { children: [jsxRuntime.jsx(Controller, { name: name, control: control, render: ({ field: { value, onChange } }) => {
|
|
46220
|
+
return (jsxRuntime.jsx(InputStyleComponent, { disabledBackgroundColor: disabledBackgroundColor, disabledFontFamily: disabledFontFamily, disabledFontSize: disabledFontSize, disabledBold: disabledBold, disabledItalic: disabledItalic, disabledUnderline: disabledUnderline, disabled: disabled, value: value, onChange: onChange }));
|
|
46221
|
+
} }), errors && jsxRuntime.jsx(FormFeedback$1, { children: errors?.message })] }));
|
|
46222
|
+
};
|
|
46223
|
+
return (jsxRuntime.jsx(React$5.Fragment, { children: jsxRuntime.jsxs("div", { className: classNames$2(' align', {
|
|
46224
|
+
[labelSize ? labelSize : '']: labelSize,
|
|
46225
|
+
[classes ? classes : '']: classes,
|
|
46226
|
+
'form-row-inline-error': errors
|
|
46227
|
+
}, inLine === false ? 'form-group ' : 'form-row-inline d-flex'), children: [renderLabel({ isLabel, name, label, required }), jsxRuntime.jsx("div", { style: { height: `${height}px` }, className: classNames$2('form-input-content', { 'hidden-label': isLabel === false }), children: renderInput() })] }) }));
|
|
46228
|
+
};
|
|
46229
|
+
|
|
46171
46230
|
const defaultStyleExportSetting = {
|
|
46172
46231
|
title: {
|
|
46173
46232
|
color: '$black',
|
|
@@ -46246,38 +46305,24 @@ const defaultStyleExportSetting = {
|
|
|
46246
46305
|
}
|
|
46247
46306
|
};
|
|
46248
46307
|
|
|
46249
|
-
const StyleInput = (props) => {
|
|
46250
|
-
const { control, name, label, labelSize, required, errors, height, disabled, isLabel, inLine, classes, disabledBackgroundColor, disabledFontFamily, disabledFontSize, disabledBold, disabledItalic, disabledUnderline } = props;
|
|
46251
|
-
const renderInput = () => {
|
|
46252
|
-
return (jsxRuntime.jsxs(React$5.Fragment, { children: [jsxRuntime.jsx(Controller, { name: name, control: control, render: ({ field: { value, onChange } }) => {
|
|
46253
|
-
return (jsxRuntime.jsx(InputStyleComponent, { disabledBackgroundColor: disabledBackgroundColor, disabledFontFamily: disabledFontFamily, disabledFontSize: disabledFontSize, disabledBold: disabledBold, disabledItalic: disabledItalic, disabledUnderline: disabledUnderline, disabled: disabled, value: value, onChange: onChange }));
|
|
46254
|
-
} }), errors && jsxRuntime.jsx(FormFeedback$1, { children: errors?.message })] }));
|
|
46255
|
-
};
|
|
46256
|
-
return (jsxRuntime.jsx(React$5.Fragment, { children: jsxRuntime.jsxs("div", { className: classNames$2(' align', {
|
|
46257
|
-
[labelSize ? labelSize : '']: labelSize,
|
|
46258
|
-
[classes ? classes : '']: classes,
|
|
46259
|
-
'form-row-inline-error': errors
|
|
46260
|
-
}, inLine === false ? 'form-group ' : 'form-row-inline d-flex'), children: [renderLabel({ isLabel, name, label, required }), jsxRuntime.jsx("div", { style: { height: `${height}px` }, className: classNames$2('form-input-content', { 'hidden-label': isLabel === false }), children: renderInput() })] }) }));
|
|
46261
|
-
};
|
|
46262
|
-
|
|
46263
46308
|
const ExportExcelComponent = ({ openModal, typeModal, handleModal, windowSize, dataItem, columns, columnGroups }) => {
|
|
46264
46309
|
const { t } = reactI18next.useTranslation();
|
|
46265
46310
|
const [dataSelected, setDataSelected] = React$5.useState([]);
|
|
46266
46311
|
const [selectedGroups, setSelectedGroups] = React$5.useState([]);
|
|
46267
46312
|
const { control, reset, handleSubmit, clearErrors, getValues, setValue } = useForm({
|
|
46268
|
-
mode:
|
|
46313
|
+
mode: "onChange",
|
|
46269
46314
|
defaultValues: defaultStyleExportSetting
|
|
46270
46315
|
});
|
|
46271
46316
|
const handleCancel = () => {
|
|
46272
|
-
handleModal(
|
|
46317
|
+
handleModal("ExportExcelComponent");
|
|
46273
46318
|
clearErrors();
|
|
46274
46319
|
setDataSelected([]);
|
|
46275
46320
|
reset();
|
|
46276
46321
|
setSelectedGroups([]);
|
|
46277
46322
|
};
|
|
46278
46323
|
React$5.useEffect(() => {
|
|
46279
|
-
if (openModal && typeModal ===
|
|
46280
|
-
setValue(
|
|
46324
|
+
if (openModal && typeModal === "ExportExcel") {
|
|
46325
|
+
setValue("textTitle", dataItem.title);
|
|
46281
46326
|
}
|
|
46282
46327
|
}, [openModal]);
|
|
46283
46328
|
const handleToggleGroup = (groupName) => {
|
|
@@ -46302,9 +46347,10 @@ const ExportExcelComponent = ({ openModal, typeModal, handleModal, windowSize, d
|
|
|
46302
46347
|
submit(data);
|
|
46303
46348
|
};
|
|
46304
46349
|
const submit = (data) => {
|
|
46305
|
-
dataItem
|
|
46350
|
+
dataItem
|
|
46351
|
+
.ExportExcelApi({
|
|
46306
46352
|
id: dataItem.id,
|
|
46307
|
-
columns: dataSelected.map(item => ({ ...item, headerText: t(item.headerText) })),
|
|
46353
|
+
columns: dataSelected.map((item) => ({ ...item, headerText: t(item.headerText) })),
|
|
46308
46354
|
countRowHeader: dataItem.countRowHeader,
|
|
46309
46355
|
groupby: dataItem.groupby,
|
|
46310
46356
|
fieldSums: dataItem.fieldSums,
|
|
@@ -46312,55 +46358,57 @@ const ExportExcelComponent = ({ openModal, typeModal, handleModal, windowSize, d
|
|
|
46312
46358
|
order: dataItem.order,
|
|
46313
46359
|
organizationId: dataItem.organizationId,
|
|
46314
46360
|
style: data,
|
|
46315
|
-
title: getValues(
|
|
46316
|
-
subtitle: getValues(
|
|
46317
|
-
})
|
|
46361
|
+
title: getValues("textTitle"),
|
|
46362
|
+
subtitle: getValues("textSubtitle")
|
|
46363
|
+
})
|
|
46364
|
+
.unwrap()
|
|
46318
46365
|
.then((rs) => {
|
|
46319
46366
|
const url = window.URL.createObjectURL(new Blob([rs]));
|
|
46320
|
-
const link = document.createElement(
|
|
46367
|
+
const link = document.createElement("a");
|
|
46321
46368
|
link.href = url;
|
|
46322
|
-
link.setAttribute(
|
|
46369
|
+
link.setAttribute("download", `${dataItem.title}.xlsx`);
|
|
46323
46370
|
document.body.appendChild(link);
|
|
46324
46371
|
link.click();
|
|
46325
46372
|
handleModal();
|
|
46326
|
-
})
|
|
46373
|
+
})
|
|
46374
|
+
.catch(() => notificationError("Fail"));
|
|
46327
46375
|
};
|
|
46328
46376
|
const renderFooterButtons = () => {
|
|
46329
|
-
return (jsxRuntime.jsxs(React$5.Fragment, { children: [jsxRuntime.jsx(Button$1, { color: "primary", className: "me-1", onClick: handleSubmit(onSubmit), children: t(
|
|
46377
|
+
return (jsxRuntime.jsxs(React$5.Fragment, { children: [jsxRuntime.jsx(Button$1, { color: "primary", className: "me-1", onClick: handleSubmit(onSubmit), children: t("Export") }), jsxRuntime.jsx(Button$1, { color: "secondary", onClick: handleCancel, outline: true, className: "me-1", children: t("Close") })] }));
|
|
46330
46378
|
};
|
|
46331
46379
|
const rightToolbarTemplate = () => {
|
|
46332
|
-
return (jsxRuntime.jsx("div", { className:
|
|
46380
|
+
return (jsxRuntime.jsx("div", { className: "d-flex", children: columnGroups?.map((ele, idx) => (jsxRuntime.jsx("div", { style: { width: ele.width ?? 150 }, children: jsxRuntime.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))) }));
|
|
46333
46381
|
};
|
|
46334
46382
|
const toolbarTopOptions = [
|
|
46335
46383
|
{
|
|
46336
46384
|
template: rightToolbarTemplate,
|
|
46337
|
-
align:
|
|
46385
|
+
align: "left"
|
|
46338
46386
|
}
|
|
46339
46387
|
];
|
|
46340
|
-
return (jsxRuntime.jsxs(Sidebar, { open: openModal && typeModal ===
|
|
46388
|
+
return (jsxRuntime.jsxs(Sidebar, { open: openModal && typeModal === "ExportExcel", toggleSidebar: handleCancel, width: 900, children: [jsxRuntime.jsx(ModalHeader, { typeModal: typeModal, handleModal: () => handleCancel(), title: t("Export Excel Setting") }), jsxRuntime.jsx(lib.Scrollbars, { autoHeight: true, autoHeightMax: windowSize.innerHeight - 120, autoHeightMin: windowSize.innerHeight - 120, children: jsxRuntime.jsxs(ModalBody$1, { children: [jsxRuntime.jsxs("div", { className: "box form-box__border mb-2", children: [jsxRuntime.jsx("h5", { className: "m-0 form-box__border--title", children: t("Tùy chỉnh cột") }), jsxRuntime.jsx(Row$1, { className: "gy-1", children: jsxRuntime.jsx(Col$1, { lg: 12, md: 12, xs: 12, children: jsxRuntime.jsx(TableEdit, { dataSource: getCombinedColumns(), toolbarSetting: {
|
|
46341
46389
|
showTopToolbar: true,
|
|
46342
46390
|
showBottomToolbar: true,
|
|
46343
46391
|
toolbarBottomOptions: toolbarTopOptions
|
|
46344
46392
|
}, maxHeight: windowSize.innerHeight - 525, minHeight: 150, columns: [
|
|
46345
46393
|
{
|
|
46346
|
-
field:
|
|
46347
|
-
headerText:
|
|
46348
|
-
textAlign:
|
|
46349
|
-
invisibleDisable: true,
|
|
46394
|
+
field: "checkbox",
|
|
46395
|
+
headerText: "",
|
|
46396
|
+
textAlign: "center",
|
|
46350
46397
|
width: 20
|
|
46351
46398
|
},
|
|
46352
46399
|
{
|
|
46353
|
-
field:
|
|
46354
|
-
|
|
46355
|
-
headerText: '',
|
|
46400
|
+
field: "field",
|
|
46401
|
+
headerText: "",
|
|
46356
46402
|
visible: false,
|
|
46357
46403
|
isPrimarykey: true
|
|
46358
46404
|
},
|
|
46359
46405
|
{
|
|
46360
|
-
type:
|
|
46406
|
+
type: "text",
|
|
46361
46407
|
field: "headerText",
|
|
46362
|
-
headerText:
|
|
46363
|
-
template: (value) => {
|
|
46408
|
+
headerText: "Column name",
|
|
46409
|
+
template: (value) => {
|
|
46410
|
+
return t(value.headerText);
|
|
46411
|
+
},
|
|
46364
46412
|
width: 360,
|
|
46365
46413
|
minWidth: 320,
|
|
46366
46414
|
maxWidth: 400
|
|
@@ -46368,7 +46416,7 @@ const ExportExcelComponent = ({ openModal, typeModal, handleModal, windowSize, d
|
|
|
46368
46416
|
], isMulti: true, searchSetting: {
|
|
46369
46417
|
searchEnable: true,
|
|
46370
46418
|
searchClient: true
|
|
46371
|
-
}, selectedItem: dataSelected, setSelectedItem: setDataSelected, selectEnable: true, addDisable: true, editDisable: true },
|
|
46419
|
+
}, selectedItem: dataSelected, setSelectedItem: setDataSelected, selectEnable: true, addDisable: true, editDisable: true }, "TableFile") }) })] }), jsxRuntime.jsxs("div", { className: "box form-box__border", children: [jsxRuntime.jsx("h5", { className: "m-0 form-box__border--title", children: t("Title report") }), jsxRuntime.jsxs(Row$1, { className: "gy-1", children: [jsxRuntime.jsx(Col$1, { lg: 8, md: 12, xs: 12, children: jsxRuntime.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 }) }), jsxRuntime.jsx(Col$1, { lg: 8, md: 12, xs: 12, children: jsxRuntime.jsx(TextInput, { control: control, name: "textSubtitle", label: t("Subtitle"), labelSize: "label-small", placeholder: t("Đặt tên cho tiêu đề phụ"), inLine: true }) }), jsxRuntime.jsx(Col$1, { lg: 8, md: 12, xs: 12, children: jsxRuntime.jsx(StyleInput, { control: control, name: "title", disabledBackgroundColor: true, label: "Title report", labelSize: "label-small" }) }), jsxRuntime.jsx(Col$1, { lg: 4, md: 6, xs: 6, children: jsxRuntime.jsx(NumberInput, { control: control, name: "title.row", label: "Row", labelSize: "label-small", min: 0 }) }), jsxRuntime.jsx(Col$1, { lg: 8, md: 12, xs: 12, children: jsxRuntime.jsx(StyleInput, { control: control, name: "subtitle", disabledBackgroundColor: true, label: "Subtitle", labelSize: "label-small" }) }), jsxRuntime.jsx(Col$1, { lg: 4, md: 6, xs: 6, children: jsxRuntime.jsx(NumberInput, { control: control, name: "subtitle.row", label: "Row", labelSize: "label-small", min: 0 }) }), jsxRuntime.jsx(Col$1, { lg: 8, md: 12, xs: 12, children: jsxRuntime.jsx(StyleInput, { control: control, name: "header", label: "Title table", labelSize: "label-small" }) }), jsxRuntime.jsx(Col$1, { lg: 4, md: 6, xs: 6, children: jsxRuntime.jsx(NumberInput, { control: control, name: "header.row", label: "Row", labelSize: "label-small", min: 0 }) }), jsxRuntime.jsx(Col$1, { lg: 8, md: 12, xs: 12, children: jsxRuntime.jsx(StyleInput, { control: control, name: "content", label: "Content table", labelSize: "label-small" }) })] })] })] }) }), jsxRuntime.jsx("div", { className: "d-flex justify-content-end p-1", style: { boxShadow: "0 4px 24px 0 rgb(34 41 47 / 10%)" }, children: renderFooterButtons() })] }));
|
|
46372
46420
|
};
|
|
46373
46421
|
|
|
46374
46422
|
const TabValidateImportExcel = (props) => {
|