react-table-edit 1.5.37 → 1.5.39
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/modal-import-excel/index.d.ts +3 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +141 -206
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +141 -206
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -68362,7 +68362,7 @@ const TabValidateImportExcel = (props) => {
|
|
|
68362
68362
|
|
|
68363
68363
|
const ModalImportComponent = (props) => {
|
|
68364
68364
|
const { t } = useTranslation();
|
|
68365
|
-
const { windowSize, openModal, handleModal, handleValidate, importExcelApi, validateExcelApi, getGeneralSettingApi, updateGeneralSettingApi, headerErrorExcelColumns, templateUrl, defaultHeaderRow, formatNumber, mapColumn, headerValidateExcelColumns } = props;
|
|
68365
|
+
const { windowSize, openModal, handleModal, handleValidate, importExcelApi, validateExcelApi, getGeneralSettingApi, updateGeneralSettingApi, headerErrorExcelColumns, templateUrl, defaultHeaderRow, formatNumber, mapColumn, headerValidateExcelColumns, style, } = props;
|
|
68366
68366
|
const [optionField, setOptionField] = useState([]);
|
|
68367
68367
|
const [dataMerge, setDataMerge] = useState([]);
|
|
68368
68368
|
const [dataValidate, setDataValidate] = useState([]);
|
|
@@ -68377,22 +68377,22 @@ const ModalImportComponent = (props) => {
|
|
|
68377
68377
|
step: create$1(),
|
|
68378
68378
|
sheetId: create$2().when('step', {
|
|
68379
68379
|
is: 1,
|
|
68380
|
-
then: create$2().required(`${t('Sheet name')} ${t('is required')}`)
|
|
68380
|
+
then: create$2().required(`${t('Sheet name')} ${t('is required')}`),
|
|
68381
68381
|
}),
|
|
68382
68382
|
headerRow: create$1().when('step', {
|
|
68383
68383
|
is: 1,
|
|
68384
|
-
then: create$1().required(`${t('Header row')} ${t('is required')}`)
|
|
68385
|
-
})
|
|
68384
|
+
then: create$1().required(`${t('Header row')} ${t('is required')}`),
|
|
68385
|
+
}),
|
|
68386
68386
|
});
|
|
68387
68387
|
const defaultValues = {
|
|
68388
68388
|
step: 1,
|
|
68389
68389
|
headerRow: defaultHeaderRow ?? 1,
|
|
68390
|
-
dataMap: []
|
|
68390
|
+
dataMap: [],
|
|
68391
68391
|
};
|
|
68392
|
-
const { control, clearErrors, reset, handleSubmit, getValues, setValue, watch, setError, formState: { errors } } = useForm({
|
|
68392
|
+
const { control, clearErrors, reset, handleSubmit, getValues, setValue, watch, setError, formState: { errors }, } = useForm({
|
|
68393
68393
|
defaultValues,
|
|
68394
68394
|
mode: 'onChange',
|
|
68395
|
-
resolver: o(formSchema)
|
|
68395
|
+
resolver: o(formSchema),
|
|
68396
68396
|
});
|
|
68397
68397
|
const handleSetColumns = (headerColumns, dataS) => {
|
|
68398
68398
|
if (headerColumns.length === 0) {
|
|
@@ -68430,7 +68430,10 @@ const ModalImportComponent = (props) => {
|
|
|
68430
68430
|
validateExcelApi(arr)
|
|
68431
68431
|
.then((rs) => {
|
|
68432
68432
|
setCheckInitValidate(false);
|
|
68433
|
-
const list = rs.map((item) => ({
|
|
68433
|
+
const list = rs.map((item) => ({
|
|
68434
|
+
...item,
|
|
68435
|
+
errors: item.errors.map((x) => connectString(t, x)),
|
|
68436
|
+
}));
|
|
68434
68437
|
setDataValidate(list);
|
|
68435
68438
|
setDataInvalid(list.filter((x) => x.errors?.length > 0));
|
|
68436
68439
|
setDataValid(list.filter((x) => x.error || x.errors?.length === 0));
|
|
@@ -68472,7 +68475,13 @@ const ModalImportComponent = (props) => {
|
|
|
68472
68475
|
});
|
|
68473
68476
|
};
|
|
68474
68477
|
const getDataType = (e) => {
|
|
68475
|
-
return e.dataType === 'numeric' ||
|
|
68478
|
+
return e.dataType === 'numeric' ||
|
|
68479
|
+
e.dataType === 'datetime' ||
|
|
68480
|
+
e.dataType === 'date'
|
|
68481
|
+
? e.dataType
|
|
68482
|
+
: e.dataType === 'boolean'
|
|
68483
|
+
? 'checkbox'
|
|
68484
|
+
: 'text';
|
|
68476
68485
|
};
|
|
68477
68486
|
const defaultValidateExcelColumns = [
|
|
68478
68487
|
{
|
|
@@ -68480,7 +68489,7 @@ const ModalImportComponent = (props) => {
|
|
|
68480
68489
|
headerText: 'Row',
|
|
68481
68490
|
fixedType: 'left',
|
|
68482
68491
|
textAlign: 'center',
|
|
68483
|
-
width: 80
|
|
68492
|
+
width: 80,
|
|
68484
68493
|
},
|
|
68485
68494
|
{
|
|
68486
68495
|
field: 'result',
|
|
@@ -68488,8 +68497,8 @@ const ModalImportComponent = (props) => {
|
|
|
68488
68497
|
fixedType: 'left',
|
|
68489
68498
|
width: 140,
|
|
68490
68499
|
template: (props) => {
|
|
68491
|
-
return props.errors?.length === 0 ? jsx("span", { className: "text-success", children: t('Valid') }) : jsx("span", { className: "text-danger", children: t('Invalid') });
|
|
68492
|
-
}
|
|
68500
|
+
return props.errors?.length === 0 ? (jsx("span", { className: "text-success", children: t('Valid') })) : (jsx("span", { className: "text-danger", children: t('Invalid') }));
|
|
68501
|
+
},
|
|
68493
68502
|
},
|
|
68494
68503
|
{
|
|
68495
68504
|
field: 'errorDetail',
|
|
@@ -68500,8 +68509,8 @@ const ModalImportComponent = (props) => {
|
|
|
68500
68509
|
return (jsx("div", { children: props.errors?.map((item, index) => {
|
|
68501
68510
|
return (jsxs("div", { className: "d-flex text-danger align-items-center", children: [jsx(SvgCircle, { fontSize: 6, className: "me-50 " }), jsx("div", { style: { fontSize: '12px' }, children: t(item) })] }, index));
|
|
68502
68511
|
}) }));
|
|
68503
|
-
}
|
|
68504
|
-
}
|
|
68512
|
+
},
|
|
68513
|
+
},
|
|
68505
68514
|
];
|
|
68506
68515
|
const handleFormOpened = () => {
|
|
68507
68516
|
if (getGeneralSettingApi) {
|
|
@@ -68534,8 +68543,8 @@ const ModalImportComponent = (props) => {
|
|
|
68534
68543
|
headerText: e.header,
|
|
68535
68544
|
width: e.width ?? 150,
|
|
68536
68545
|
type: getDataType(e),
|
|
68537
|
-
template: e.template
|
|
68538
|
-
}))
|
|
68546
|
+
template: e.template,
|
|
68547
|
+
})),
|
|
68539
68548
|
]);
|
|
68540
68549
|
}
|
|
68541
68550
|
};
|
|
@@ -68551,29 +68560,31 @@ const ModalImportComponent = (props) => {
|
|
|
68551
68560
|
setValue('step', 2);
|
|
68552
68561
|
}
|
|
68553
68562
|
};
|
|
68554
|
-
return (jsx(Modal$1, { isOpen: openModal, toggle: handleModal, backdrop: "static", className: "modal-dialog-centered modal-xl", contentClassName: "p-0", onOpened: handleFormOpened, onClosed: handleModalClosed, children: jsxs(Form$1, { id: "form-modal-globalzone", className: "todo-modal modal-form-content", children: [jsx(ModalHeader, { typeModal: 'Import', handleModal: handleModal, title: "Import Excel" }), jsx(Scrollbars, { autoHide: true, autoHeight: true, autoHeightMax: windowSize.innerHeight - 120, children: jsx(ModalBody$1, { children: jsx("div", { style: { marginTop: '-25px' }, className: "modern-horizontal-wizard", children: jsx(Wizard, { activeStep: watch('step'), type: "modern-horizontal", steps: [
|
|
68563
|
+
return (jsx(Modal$1, { isOpen: openModal, style: style, toggle: handleModal, backdrop: "static", className: "modal-dialog-centered modal-xl", contentClassName: "p-0", onOpened: handleFormOpened, onClosed: handleModalClosed, children: jsxs(Form$1, { id: "form-modal-globalzone", className: "todo-modal modal-form-content", children: [jsx(ModalHeader, { typeModal: 'Import', handleModal: handleModal, title: "Import Excel" }), jsx(Scrollbars, { autoHide: true, autoHeight: true, autoHeightMax: windowSize.innerHeight - 120, children: jsx(ModalBody$1, { children: jsx("div", { style: { marginTop: '-25px' }, className: "modern-horizontal-wizard", children: jsx(Wizard, { activeStep: watch('step'), type: "modern-horizontal", steps: [
|
|
68555
68564
|
{
|
|
68556
68565
|
id: 'upload-file',
|
|
68557
68566
|
title: t('Upload file'),
|
|
68558
|
-
content: jsx(TabSelectFileImportExcel, { control: control, errors: errors, getValues: getValues, setValue: setValue, watch: watch, templateUrl: templateUrl })
|
|
68567
|
+
content: (jsx(TabSelectFileImportExcel, { control: control, errors: errors, getValues: getValues, setValue: setValue, watch: watch, templateUrl: templateUrl })),
|
|
68559
68568
|
},
|
|
68560
68569
|
{
|
|
68561
68570
|
id: 'merge-data',
|
|
68562
68571
|
title: t('Merge data fields'),
|
|
68563
|
-
content: jsx(TabMergeImportExcel, { control: control, errors: errors, getValues: getValues, setValue: setValue, formatNumber: formatNumber, watch: watch, optionField: optionField, windowSize: windowSize })
|
|
68572
|
+
content: (jsx(TabMergeImportExcel, { control: control, errors: errors, getValues: getValues, setValue: setValue, formatNumber: formatNumber, watch: watch, optionField: optionField, windowSize: windowSize })),
|
|
68564
68573
|
},
|
|
68565
68574
|
{
|
|
68566
68575
|
id: 'validate-data',
|
|
68567
68576
|
title: t('Validate data'),
|
|
68568
|
-
content: jsx(TabValidateImportExcel, { formatNumber: formatNumber, dataInvalid: dataInvalid, dataValid: dataValid, dataValidate: dataValidate, headerValidateExcelColumns: validateExcelColumns, windowSize: windowSize })
|
|
68577
|
+
content: (jsx(TabValidateImportExcel, { formatNumber: formatNumber, dataInvalid: dataInvalid, dataValid: dataValid, dataValidate: dataValidate, headerValidateExcelColumns: validateExcelColumns, windowSize: windowSize })),
|
|
68569
68578
|
},
|
|
68570
68579
|
{
|
|
68571
68580
|
id: 'handle-error',
|
|
68572
68581
|
title: t('Error result'),
|
|
68573
68582
|
visible: !!headerErrorExcelColumns,
|
|
68574
|
-
content: jsx(TabHandleErrorImportExcel, { formatNumber: formatNumber, dataError: dataError, headerHandleErrorExcelColumns: headerErrorExcelColumns ?? [], windowSize: windowSize })
|
|
68575
|
-
}
|
|
68576
|
-
] }) }) }) }), jsxs("div", { className: "d-flex justify-content-between align-items-center p-1", style: { boxShadow: '0 4px 24px 0 rgb(34 41 47 / 10%)' }, children: [jsx("div", { className: "d-flex align-items-center", children: watch('step') === 2 &&
|
|
68583
|
+
content: (jsx(TabHandleErrorImportExcel, { formatNumber: formatNumber, dataError: dataError, headerHandleErrorExcelColumns: headerErrorExcelColumns ?? [], windowSize: windowSize })),
|
|
68584
|
+
},
|
|
68585
|
+
] }) }) }) }), jsxs("div", { className: "d-flex justify-content-between align-items-center p-1", style: { boxShadow: '0 4px 24px 0 rgb(34 41 47 / 10%)' }, children: [jsx("div", { className: "d-flex align-items-center", children: watch('step') === 2 &&
|
|
68586
|
+
getGeneralSettingApi &&
|
|
68587
|
+
updateGeneralSettingApi && (jsxs(Fragment$1, { children: [jsx(Input$1, { checked: isSaveSetting, type: "checkbox", className: "me-50", onChange: (val) => {
|
|
68577
68588
|
setIsSaveSetting(val.target.checked);
|
|
68578
68589
|
} }), jsx("span", { children: "L\u01B0u th\u00F4ng tin gh\u00E9p tr\u01B0\u1EDDng d\u1EEF li\u1EC7u" })] })) }), jsxs("div", { className: "d-flex align-items-center", children: [jsx(Button$1$1, { disabled: !getValues('file'), color: "primary", outline: true, className: `update-btn update-todo-item me-1 ${watch('step') !== 1 ? '' : 'd-none'}`, onClick: handleBackStep, children: t('Back') }), jsx(Button$1$1, { className: `update-btn update-todo-item me-1 ${watch('step') !== 3 ? '' : 'd-none'}`, disabled: !watch('file') || checkInitValidate, color: "primary", onClick: handleSubmit(onSubmit), children: t('Next') }), jsx(Button$1$1, { className: `update-btn update-todo-item me-1 ${watch('step') === 3 ? '' : 'd-none'}`, disabled: dataValid.length === 0 || !getValues('file') || checkInit, color: "primary", onClick: handleSubmit(onSubmit), children: t('Import') }), jsx(Button$1$1, { color: "secondary", onClick: handleModal, outline: true, children: t('Close') })] })] })] }) }));
|
|
68579
68590
|
};
|
|
@@ -68708,21 +68719,32 @@ const UnExpandAllIcon = ({ className, color = '#7F7F7F', size = 24, onClick, sty
|
|
|
68708
68719
|
};
|
|
68709
68720
|
|
|
68710
68721
|
const RenderContentCol = (props) => {
|
|
68711
|
-
const { col, indexCol, indexRow, isSelected, row, zeroVisiable, formatSetting, idTable, fisrtObjWidthFixRight, lastObjWidthFixLeft, objWidthFixLeft, objWidthFixRight, selectedRows, setSelectedRows, handleCloseContext, handleDoubleClick, fieldKey, isMulti
|
|
68722
|
+
const { col, indexCol, indexRow, isSelected, row, zeroVisiable, formatSetting, idTable, fisrtObjWidthFixRight, lastObjWidthFixLeft, objWidthFixLeft, objWidthFixRight, selectedRows, setSelectedRows, handleCloseContext, handleDoubleClick, fieldKey, isMulti } = props;
|
|
68712
68723
|
const cellId = `content-${idTable}-row${indexRow}col-${indexCol}`;
|
|
68713
68724
|
const checkOverflow = () => {
|
|
68714
68725
|
const element = document.getElementById(cellId);
|
|
68715
68726
|
return element && element.scrollWidth > element.clientWidth;
|
|
68716
68727
|
};
|
|
68728
|
+
const toggleSelect = () => {
|
|
68729
|
+
const idx = selectedRows?.findIndex((x) => x?.[fieldKey] === row?.[fieldKey]);
|
|
68730
|
+
if (idx > -1) {
|
|
68731
|
+
if (isMulti) {
|
|
68732
|
+
return selectedRows?.filter((_, i) => i !== idx);
|
|
68733
|
+
}
|
|
68734
|
+
return [];
|
|
68735
|
+
}
|
|
68736
|
+
if (isMulti) {
|
|
68737
|
+
return [...selectedRows, row];
|
|
68738
|
+
}
|
|
68739
|
+
return [row];
|
|
68740
|
+
};
|
|
68717
68741
|
const RenderElement = () => {
|
|
68718
68742
|
if (col.field === '#' || col.type === '#') {
|
|
68719
68743
|
return (jsx("div", { className: classNames$1('r-rowcell-div cursor-pointer text-center', {
|
|
68720
|
-
'r-active-cell': isSelected
|
|
68744
|
+
'r-active-cell': isSelected
|
|
68721
68745
|
}), style: {
|
|
68722
|
-
fontWeight: row.sortOrder < 0 || row.sortOrder > 100000 || row.haveBoldType
|
|
68723
|
-
|
|
68724
|
-
: 400,
|
|
68725
|
-
fontStyle: row.haveItalicType ? 'italic' : 'normal',
|
|
68746
|
+
fontWeight: row.sortOrder < 0 || row.sortOrder > 100000 || row.haveBoldType ? 600 : 400,
|
|
68747
|
+
fontStyle: row.haveItalicType ? 'italic' : 'normal'
|
|
68726
68748
|
}, onDoubleClick: (e) => {
|
|
68727
68749
|
e.preventDefault();
|
|
68728
68750
|
handleCloseContext();
|
|
@@ -68731,34 +68753,13 @@ const RenderContentCol = (props) => {
|
|
|
68731
68753
|
}
|
|
68732
68754
|
else if (col.type === 'checkbox' || col.field === 'checkbox') {
|
|
68733
68755
|
return (jsx("div", { className: classNames$1('r-rowcell-div cursor-pointer', {
|
|
68734
|
-
'r-active-cell': isSelected
|
|
68756
|
+
'r-active-cell': isSelected
|
|
68735
68757
|
}), style: {
|
|
68736
68758
|
display: 'flex',
|
|
68737
|
-
justifyContent: col.textAlign === 'center'
|
|
68738
|
-
|
|
68739
|
-
: col.textAlign === 'right'
|
|
68740
|
-
? 'flex-end'
|
|
68741
|
-
: 'flex-start',
|
|
68742
|
-
alignItems: 'center',
|
|
68759
|
+
justifyContent: col.textAlign === 'center' ? 'center' : col.textAlign === 'right' ? 'flex-end' : 'flex-start',
|
|
68760
|
+
alignItems: 'center'
|
|
68743
68761
|
}, onClick: (e) => {
|
|
68744
|
-
|
|
68745
|
-
if (index > -1) {
|
|
68746
|
-
if (isMulti) {
|
|
68747
|
-
selectedRows?.splice(index, 1);
|
|
68748
|
-
setSelectedRows([...selectedRows]);
|
|
68749
|
-
}
|
|
68750
|
-
else {
|
|
68751
|
-
setSelectedRows([]);
|
|
68752
|
-
}
|
|
68753
|
-
}
|
|
68754
|
-
else {
|
|
68755
|
-
if (isMulti) {
|
|
68756
|
-
setSelectedRows([...selectedRows, row]);
|
|
68757
|
-
}
|
|
68758
|
-
else {
|
|
68759
|
-
setSelectedRows([row]);
|
|
68760
|
-
}
|
|
68761
|
-
}
|
|
68762
|
+
setSelectedRows(toggleSelect());
|
|
68762
68763
|
e.stopPropagation();
|
|
68763
68764
|
}, children: jsx(Input$1, { defaultChecked: isSelected, type: "checkbox", className: "cursor-pointer", style: { textAlign: col.textAlign ?? 'center' } }) }));
|
|
68764
68765
|
}
|
|
@@ -68766,11 +68767,8 @@ const RenderContentCol = (props) => {
|
|
|
68766
68767
|
let value = row[col.field];
|
|
68767
68768
|
// ✅ Format dữ liệu theo loại cột
|
|
68768
68769
|
if (col.type === 'numeric') {
|
|
68769
|
-
value =
|
|
68770
|
-
|
|
68771
|
-
if (!zeroVisiable &&
|
|
68772
|
-
!(row?.sortOrder < 0 || row?.sortOrder > 100000) &&
|
|
68773
|
-
(value === '0' || value === 0)) {
|
|
68770
|
+
value = formartNumberic(row[col.field], formatSetting?.decimalSeparator ?? ',', formatSetting?.thousandSeparator ?? '.', col.numericSettings?.fraction, true, false) ?? 0;
|
|
68771
|
+
if (!zeroVisiable && !(row?.sortOrder < 0 || row?.sortOrder > 100000) && (value === '0' || value === 0)) {
|
|
68774
68772
|
value = '';
|
|
68775
68773
|
}
|
|
68776
68774
|
}
|
|
@@ -68778,88 +68776,75 @@ const RenderContentCol = (props) => {
|
|
|
68778
68776
|
value = value ? formatDateTime(value, formatSetting?.dateFormat) : '';
|
|
68779
68777
|
}
|
|
68780
68778
|
else if (col.type === 'datetime') {
|
|
68781
|
-
value = value
|
|
68782
|
-
? formatDateTime(value, formatSetting?.dateFormat ?? 'DD/MM/yyyy HH:mm')
|
|
68783
|
-
: '';
|
|
68779
|
+
value = value ? formatDateTime(value, formatSetting?.dateFormat ?? 'DD/MM/yyyy HH:mm') : '';
|
|
68784
68780
|
}
|
|
68785
68781
|
if (col.template) {
|
|
68786
68782
|
value = col.template(row, indexRow) ?? '';
|
|
68787
68783
|
}
|
|
68788
68784
|
const isNegative = col.type === 'numeric' && Number(row[col.field]) < 0;
|
|
68789
|
-
const textColor = isNegative
|
|
68790
|
-
|
|
68791
|
-
|
|
68792
|
-
const
|
|
68793
|
-
const suffix = isNegative ? (formatSetting?.suffixNegative ?? '') : '';
|
|
68794
|
-
const displayText = isNegative
|
|
68795
|
-
? `${prefix}${value}${suffix}`
|
|
68796
|
-
: (value ?? '');
|
|
68785
|
+
const textColor = isNegative ? formatSetting?.colorNegative ?? 'red' : undefined;
|
|
68786
|
+
const prefix = isNegative ? formatSetting?.prefixNegative ?? '-' : '';
|
|
68787
|
+
const suffix = isNegative ? formatSetting?.suffixNegative ?? '' : '';
|
|
68788
|
+
const displayText = isNegative ? `${prefix}${value}${suffix}` : value ?? '';
|
|
68797
68789
|
return (jsxs("div", { className: classNames$1('r-rowcell-div cursor-pointer', {
|
|
68798
|
-
'r-active-cell': isSelected
|
|
68790
|
+
'r-active-cell': isSelected
|
|
68799
68791
|
}), style: {
|
|
68800
|
-
fontWeight: row.sortOrder < 0 || row.sortOrder > 100000 || row.haveBoldType
|
|
68801
|
-
|
|
68802
|
-
: 400,
|
|
68803
|
-
fontStyle: row.haveItalicType ? 'italic' : 'normal',
|
|
68804
|
-
}, onDoubleClick: (e) => {
|
|
68805
|
-
e.preventDefault();
|
|
68806
|
-
handleCloseContext();
|
|
68807
|
-
handleDoubleClick?.(row, col);
|
|
68792
|
+
fontWeight: row.sortOrder < 0 || row.sortOrder > 100000 || row.haveBoldType ? 600 : 400,
|
|
68793
|
+
fontStyle: row.haveItalicType ? 'italic' : 'normal'
|
|
68808
68794
|
}, children: [jsx("div", { className: "r-cell-text", style: {
|
|
68809
68795
|
display: 'flex',
|
|
68810
|
-
justifyContent: col.textAlign === 'center'
|
|
68811
|
-
|
|
68812
|
-
: col.textAlign === 'right'
|
|
68813
|
-
? 'flex-end'
|
|
68814
|
-
: 'flex-start',
|
|
68815
|
-
alignItems: 'center',
|
|
68796
|
+
justifyContent: col.textAlign === 'center' ? 'center' : col.textAlign === 'right' ? 'flex-end' : 'flex-start',
|
|
68797
|
+
alignItems: 'center'
|
|
68816
68798
|
}, children: jsx("div", { id: cellId, style: {
|
|
68817
68799
|
color: textColor,
|
|
68818
68800
|
overflow: 'hidden',
|
|
68819
68801
|
textOverflow: 'ellipsis',
|
|
68820
68802
|
whiteSpace: 'pre',
|
|
68821
|
-
maxWidth: '100%'
|
|
68803
|
+
maxWidth: '100%'
|
|
68822
68804
|
}, children: displayText }) }), checkOverflow() && (jsx(UncontrolledTooltip, { className: "r-tooltip", autohide: false, target: cellId, placement: "top", children: jsx("div", { style: { color: textColor }, onClick: (e) => {
|
|
68823
68805
|
e.stopPropagation();
|
|
68824
68806
|
e.preventDefault();
|
|
68825
68807
|
}, children: displayText }) }))] }));
|
|
68826
68808
|
}
|
|
68827
68809
|
};
|
|
68810
|
+
const clickTimerRef = useRef(null);
|
|
68828
68811
|
return (jsx(Fragment$1, { children: col.visible !== false && col.isGroup !== true && (jsx("td", { className: classNames$1(`r-rowcell fix-${col.fixedType}`, { 'cell-fixed': col.fixedType }, {
|
|
68829
|
-
'fixed-last': (col.fixedType === 'left' &&
|
|
68830
|
-
indexCol === lastObjWidthFixLeft) ||
|
|
68831
|
-
(col.fixedType === 'right' &&
|
|
68832
|
-
indexCol === fisrtObjWidthFixRight),
|
|
68812
|
+
'fixed-last': (col.fixedType === 'left' && indexCol === lastObjWidthFixLeft) || (col.fixedType === 'right' && indexCol === fisrtObjWidthFixRight)
|
|
68833
68813
|
}, { 'r-active': isSelected }), style: {
|
|
68834
68814
|
left: col.fixedType === 'left' ? objWidthFixLeft[indexCol] : undefined,
|
|
68835
|
-
right: col.fixedType === 'right'
|
|
68836
|
-
? objWidthFixRight[indexCol]
|
|
68837
|
-
: undefined,
|
|
68815
|
+
right: col.fixedType === 'right' ? objWidthFixRight[indexCol] : undefined
|
|
68838
68816
|
}, onClick: (e) => {
|
|
68839
|
-
|
|
68840
|
-
|
|
68841
|
-
|
|
68842
|
-
|
|
68843
|
-
|
|
68844
|
-
|
|
68845
|
-
}
|
|
68846
|
-
else {
|
|
68847
|
-
setSelectedRows([]);
|
|
68848
|
-
}
|
|
68849
|
-
}
|
|
68850
|
-
else {
|
|
68851
|
-
if (isMulti) {
|
|
68852
|
-
setSelectedRows([...selectedRows, row]);
|
|
68853
|
-
}
|
|
68854
|
-
else {
|
|
68855
|
-
setSelectedRows([row]);
|
|
68856
|
-
}
|
|
68857
|
-
}
|
|
68817
|
+
const tag = e.target?.nodeName;
|
|
68818
|
+
if (tag !== 'DIV' && tag !== 'TD') {
|
|
68819
|
+
return;
|
|
68820
|
+
}
|
|
68821
|
+
if (clickTimerRef.current) {
|
|
68822
|
+
window.clearTimeout(clickTimerRef.current);
|
|
68858
68823
|
}
|
|
68824
|
+
if (handleDoubleClick) {
|
|
68825
|
+
clickTimerRef.current = window.setTimeout(() => {
|
|
68826
|
+
setSelectedRows(toggleSelect());
|
|
68827
|
+
clickTimerRef.current = null;
|
|
68828
|
+
}, 200);
|
|
68829
|
+
}
|
|
68830
|
+
else {
|
|
68831
|
+
setSelectedRows(toggleSelect());
|
|
68832
|
+
clickTimerRef.current = null;
|
|
68833
|
+
}
|
|
68834
|
+
}, onDoubleClick: (e) => {
|
|
68835
|
+
// hủy single click pending để không đổi style trước
|
|
68836
|
+
if (clickTimerRef.current) {
|
|
68837
|
+
window.clearTimeout(clickTimerRef.current);
|
|
68838
|
+
}
|
|
68839
|
+
clickTimerRef.current = null;
|
|
68840
|
+
handleCloseContext();
|
|
68841
|
+
handleDoubleClick?.(row, col);
|
|
68842
|
+
e.preventDefault();
|
|
68843
|
+
e.stopPropagation();
|
|
68859
68844
|
}, children: RenderElement() }, `col-${indexRow}-${indexCol}`)) }));
|
|
68860
68845
|
};
|
|
68861
68846
|
|
|
68862
|
-
const TableView = ({ idTable, dataSource, height = 400, haveSum, columns, isLoading, formatSetting, querySetting, pagingSetting, searchSetting, columnsAggregate, toolbarSetting, selectedItem, setSelectedItem, handleSelect, saveSettingColumn, resetDefaultColumns, settingColumns, headerComponent, groupSetting, zeroVisiable, isMulti, handleDoubleClick, contextMenuItems, handleContextMenuClick
|
|
68847
|
+
const TableView = ({ idTable, dataSource, height = 400, haveSum, columns, isLoading, formatSetting, querySetting, pagingSetting, searchSetting, columnsAggregate, toolbarSetting, selectedItem, setSelectedItem, handleSelect, saveSettingColumn, resetDefaultColumns, settingColumns, headerComponent, groupSetting, zeroVisiable, isMulti, handleDoubleClick, contextMenuItems, handleContextMenuClick }) => {
|
|
68863
68848
|
const { t } = useTranslation();
|
|
68864
68849
|
const gridRef = useRef(null);
|
|
68865
68850
|
const [openPopupSetupColumn, setOpenPopupSetupColumn] = useState(false);
|
|
@@ -68867,8 +68852,7 @@ const TableView = ({ idTable, dataSource, height = 400, haveSum, columns, isLoad
|
|
|
68867
68852
|
const [orderBy, setOrderBy] = useState([]);
|
|
68868
68853
|
const [filterBy, setFilterBy] = useState([]);
|
|
68869
68854
|
const [searchTerm, setSearchTerm] = useState('');
|
|
68870
|
-
const fieldKey = columns.find((item) => item.isPrimarykey === true)?.field ??
|
|
68871
|
-
'id';
|
|
68855
|
+
const fieldKey = columns.find((item) => item.isPrimarykey === true)?.field ?? 'id';
|
|
68872
68856
|
const [contentColumns, setContentColumns] = useState([]);
|
|
68873
68857
|
const [groupColumns, setGroupColumns] = useState([]);
|
|
68874
68858
|
const [expandsAll, setExpandsAll] = useState(true);
|
|
@@ -68887,7 +68871,7 @@ const TableView = ({ idTable, dataSource, height = 400, haveSum, columns, isLoad
|
|
|
68887
68871
|
}
|
|
68888
68872
|
setExpandsAll(true);
|
|
68889
68873
|
}, [groupSetting?.groupColumns]);
|
|
68890
|
-
const { levels: headerColumns, objHeaderWidthFixLeft, objHeaderWidthFixRight, objWidthFixLeft, objWidthFixRight, lastObjWidthFixLeft, fisrtObjWidthFixRight
|
|
68874
|
+
const { levels: headerColumns, objHeaderWidthFixLeft, objHeaderWidthFixRight, objWidthFixLeft, objWidthFixRight, lastObjWidthFixLeft, fisrtObjWidthFixRight } = useMemo(() => {
|
|
68891
68875
|
const rs = calculateTableStructure(columns, settingColumns?.value, groupSetting?.groupColumns);
|
|
68892
68876
|
setContentColumns(rs.flat);
|
|
68893
68877
|
return rs;
|
|
@@ -68916,10 +68900,7 @@ const TableView = ({ idTable, dataSource, height = 400, haveSum, columns, isLoad
|
|
|
68916
68900
|
if (searchTerm) {
|
|
68917
68901
|
datas = datas.filter((row) => {
|
|
68918
68902
|
return searchSetting?.keyField?.some((key) => {
|
|
68919
|
-
return row[key]
|
|
68920
|
-
?.toString()
|
|
68921
|
-
.toLowerCase()
|
|
68922
|
-
.includes(searchTerm.trim().toLowerCase());
|
|
68903
|
+
return row[key]?.toString().toLowerCase().includes(searchTerm.trim().toLowerCase());
|
|
68923
68904
|
});
|
|
68924
68905
|
});
|
|
68925
68906
|
}
|
|
@@ -68928,10 +68909,7 @@ const TableView = ({ idTable, dataSource, height = 400, haveSum, columns, isLoad
|
|
|
68928
68909
|
return filterBy.every((filter) => {
|
|
68929
68910
|
const { key, value, ope } = filter;
|
|
68930
68911
|
const rowValue = row[key];
|
|
68931
|
-
if (rowValue === undefined ||
|
|
68932
|
-
rowValue === null ||
|
|
68933
|
-
value === undefined ||
|
|
68934
|
-
value === null) {
|
|
68912
|
+
if (rowValue === undefined || rowValue === null || value === undefined || value === null) {
|
|
68935
68913
|
return false;
|
|
68936
68914
|
}
|
|
68937
68915
|
const valStr = String(rowValue).toLowerCase();
|
|
@@ -68994,17 +68972,12 @@ const TableView = ({ idTable, dataSource, height = 400, haveSum, columns, isLoad
|
|
|
68994
68972
|
}
|
|
68995
68973
|
};
|
|
68996
68974
|
const searchTemplate = () => {
|
|
68997
|
-
return (jsx("div", { className: "me-50 r-search", children: jsx(ReactInput, { style: { width: '230px' }, value: searchSetting?.searchTerm !== undefined
|
|
68998
|
-
? searchSetting?.searchTerm
|
|
68999
|
-
: searchTerm, setSearchTerm: searchSetting?.setSearchTerm
|
|
69000
|
-
? searchSetting?.setSearchTerm
|
|
69001
|
-
: setSearchTerm, placeholder: t('Search'), onKeyPress: handleKeyPress }) }));
|
|
68975
|
+
return (jsx("div", { className: "me-50 r-search", children: jsx(ReactInput, { style: { width: '230px' }, value: searchSetting?.searchTerm !== undefined ? searchSetting?.searchTerm : searchTerm, setSearchTerm: searchSetting?.setSearchTerm ? searchSetting?.setSearchTerm : setSearchTerm, placeholder: t('Search'), onKeyPress: handleKeyPress }) }));
|
|
69002
68976
|
};
|
|
69003
68977
|
const groupbtnTemplate = () => {
|
|
69004
68978
|
return (jsxs(UncontrolledDropdown, { children: [jsx(DropdownToggle$1, { tag: "div", id: "group-dropdown-toggle", style: { position: 'relative' }, onClick: (e) => e.preventDefault(), children: jsx(GroupIcon, { color: "#7F7F7F", size: 24 }) }), jsxs(DropdownMenu$1, { className: "formula-dropdown icon-dropdown p-1", children: [jsx("div", { className: "mb-1", style: { fontSize: 16, fontWeight: 500 }, children: "Nh\u00F3m d\u1EEF li\u1EC7u theo c\u1ED9t" }), jsxs("div", { className: 'form-group', children: [jsx(Label$1, { id: `label-group-1`, style: { fontWeight: 500, fontSize: 13 }, children: "M\u1EE9c 1" }), jsx("div", { className: "form-input", children: jsx(SelectTable, { options: contentColumns, fieldLabel: 'headerText', fieldValue: 'field', value: groupColumns[0]
|
|
69005
68979
|
? {
|
|
69006
|
-
headerText: t(contentColumns.find((x) => x.field === groupColumns[0])?.headerText ??
|
|
69007
|
-
contentColumns.find((x) => x.field === groupColumns[0])?.headerText),
|
|
68980
|
+
headerText: t(contentColumns.find((x) => x.field === groupColumns[0])?.headerText ?? contentColumns.find((x) => x.field === groupColumns[0])?.headerText)
|
|
69008
68981
|
}
|
|
69009
68982
|
: undefined, onChange: (val) => {
|
|
69010
68983
|
if (val) {
|
|
@@ -69016,8 +68989,7 @@ const TableView = ({ idTable, dataSource, height = 400, haveSum, columns, isLoad
|
|
|
69016
68989
|
setGroupColumns([...groupColumns]);
|
|
69017
68990
|
}, isClearable: groupColumns?.length === 1 }) })] }), jsxs("div", { className: 'form-group', children: [jsx(Label$1, { id: `label-group-2`, style: { fontWeight: 500, fontSize: 13 }, children: "M\u1EE9c 2" }), jsx("div", { className: "form-input", children: jsx(SelectTable, { options: contentColumns, fieldLabel: 'headerText', fieldValue: 'field', value: groupColumns[1]
|
|
69018
68991
|
? {
|
|
69019
|
-
headerText: t(contentColumns.find((x) => x.field === groupColumns[1])?.headerText ??
|
|
69020
|
-
contentColumns.find((x) => x.field === groupColumns[1])?.headerText),
|
|
68992
|
+
headerText: t(contentColumns.find((x) => x.field === groupColumns[1])?.headerText ?? contentColumns.find((x) => x.field === groupColumns[1])?.headerText)
|
|
69021
68993
|
}
|
|
69022
68994
|
: undefined, onChange: (val) => {
|
|
69023
68995
|
if (val) {
|
|
@@ -69029,8 +69001,7 @@ const TableView = ({ idTable, dataSource, height = 400, haveSum, columns, isLoad
|
|
|
69029
69001
|
setGroupColumns([...groupColumns]);
|
|
69030
69002
|
}, isClearable: groupColumns?.length === 2 }) })] }), jsxs("div", { className: 'form-group', children: [jsx(Label$1, { id: `label-group-3`, style: { fontWeight: 500, fontSize: 13 }, children: "M\u1EE9c 3" }), jsx("div", { className: "form-input", children: jsx(SelectTable, { options: contentColumns, fieldLabel: 'headerText', fieldValue: 'field', value: groupColumns[2]
|
|
69031
69003
|
? {
|
|
69032
|
-
headerText: t(contentColumns.find((x) => x.field === groupColumns[2])?.headerText ??
|
|
69033
|
-
contentColumns.find((x) => x.field === groupColumns[2])?.headerText),
|
|
69004
|
+
headerText: t(contentColumns.find((x) => x.field === groupColumns[2])?.headerText ?? contentColumns.find((x) => x.field === groupColumns[2])?.headerText)
|
|
69034
69005
|
}
|
|
69035
69006
|
: undefined, onChange: (val) => {
|
|
69036
69007
|
if (groupSetting) {
|
|
@@ -69044,7 +69015,7 @@ const TableView = ({ idTable, dataSource, height = 400, haveSum, columns, isLoad
|
|
|
69044
69015
|
}
|
|
69045
69016
|
}, isClearable: groupColumns?.length === 3 }) })] }), jsxs("div", { className: "border-top d-flex justify-content-end mt-1", children: [jsx(Button$1$1, { color: "primary", className: "mt-1 me-50 rounded", size: "sm", onClick: () => {
|
|
69046
69017
|
groupSetting?.onGroup({
|
|
69047
|
-
columnGrouped: groupColumns.filter((x) => x)
|
|
69018
|
+
columnGrouped: groupColumns.filter((x) => x)
|
|
69048
69019
|
});
|
|
69049
69020
|
document.getElementById('group-dropdown-toggle')?.click();
|
|
69050
69021
|
}, children: `${t('Apply')}` }), jsx(Button$1$1, { color: "secondary", outline: true, className: "mt-1 rounded", size: "sm", onClick: () => {
|
|
@@ -69053,16 +69024,14 @@ const TableView = ({ idTable, dataSource, height = 400, haveSum, columns, isLoad
|
|
|
69053
69024
|
}, children: `${t('Delete')}` })] })] })] }));
|
|
69054
69025
|
};
|
|
69055
69026
|
const chooseColumnsTemplate = () => {
|
|
69056
|
-
return
|
|
69027
|
+
return jsx(SvgSettings, { className: "r-toolbar-icon", fontSize: 20, color: "#7F7F7F", onClick: () => setOpenPopupSetupColumn(true) });
|
|
69057
69028
|
};
|
|
69058
69029
|
const expandTemplate = () => {
|
|
69059
69030
|
return (jsxs(Fragment$1, { children: [!expandsAll && (jsx(ExpandAllIcon, { onClick: () => {
|
|
69060
69031
|
setExpandsAll(true);
|
|
69061
|
-
}, color: "#7F7F7F", size: 24 })), expandsAll &&
|
|
69032
|
+
}, color: "#7F7F7F", size: 24 })), expandsAll && jsx(UnExpandAllIcon, { onClick: () => setExpandsAll(false), color: "#7F7F7F", size: 24 })] }));
|
|
69062
69033
|
};
|
|
69063
|
-
const defaultToolbarOption = searchSetting?.searchEnable
|
|
69064
|
-
? [{ template: searchTemplate, align: 'left' }]
|
|
69065
|
-
: [];
|
|
69034
|
+
const defaultToolbarOption = searchSetting?.searchEnable ? [{ template: searchTemplate, align: 'left' }] : [];
|
|
69066
69035
|
if (groupSetting) {
|
|
69067
69036
|
defaultToolbarOption.push({ template: groupbtnTemplate, align: 'left' });
|
|
69068
69037
|
}
|
|
@@ -69071,10 +69040,7 @@ const TableView = ({ idTable, dataSource, height = 400, haveSum, columns, isLoad
|
|
|
69071
69040
|
}
|
|
69072
69041
|
let toolbarTopOption = [];
|
|
69073
69042
|
if (toolbarSetting?.toolbarOptions) {
|
|
69074
|
-
toolbarTopOption = [
|
|
69075
|
-
...defaultToolbarOption,
|
|
69076
|
-
...toolbarSetting?.toolbarOptions,
|
|
69077
|
-
];
|
|
69043
|
+
toolbarTopOption = [...defaultToolbarOption, ...toolbarSetting?.toolbarOptions];
|
|
69078
69044
|
}
|
|
69079
69045
|
else {
|
|
69080
69046
|
toolbarTopOption = [...defaultToolbarOption];
|
|
@@ -69105,9 +69071,7 @@ const TableView = ({ idTable, dataSource, height = 400, haveSum, columns, isLoad
|
|
|
69105
69071
|
useEffect(() => {
|
|
69106
69072
|
if (setSelectedItem) {
|
|
69107
69073
|
if (isMulti) {
|
|
69108
|
-
if (dataSource &&
|
|
69109
|
-
selectedRows &&
|
|
69110
|
-
selectedRows?.length !== selectedItem?.length) {
|
|
69074
|
+
if (dataSource && selectedRows && selectedRows?.length !== selectedItem?.length) {
|
|
69111
69075
|
setSelectedItem([...selectedRows]);
|
|
69112
69076
|
if (handleSelect) {
|
|
69113
69077
|
handleSelect([...selectedRows]);
|
|
@@ -69116,8 +69080,7 @@ const TableView = ({ idTable, dataSource, height = 400, haveSum, columns, isLoad
|
|
|
69116
69080
|
}
|
|
69117
69081
|
else {
|
|
69118
69082
|
if (dataSource && selectedRows?.length > 0) {
|
|
69119
|
-
if (!selectedItem ||
|
|
69120
|
-
selectedItem[fieldKey] !== selectedRows[0][fieldKey]) {
|
|
69083
|
+
if (!selectedItem || selectedItem[fieldKey] !== selectedRows[0][fieldKey]) {
|
|
69121
69084
|
setSelectedItem({ ...selectedRows[0] });
|
|
69122
69085
|
if (handleSelect) {
|
|
69123
69086
|
handleSelect({ ...selectedRows[0] });
|
|
@@ -69136,8 +69099,7 @@ const TableView = ({ idTable, dataSource, height = 400, haveSum, columns, isLoad
|
|
|
69136
69099
|
useEffect(() => {
|
|
69137
69100
|
if (!isMulti) {
|
|
69138
69101
|
if (dataSource && selectedItem && selectedItem[fieldKey]) {
|
|
69139
|
-
if (selectedRows?.length === 0 ||
|
|
69140
|
-
selectedItem[fieldKey] !== selectedRows[0][fieldKey]) {
|
|
69102
|
+
if (selectedRows?.length === 0 || selectedItem[fieldKey] !== selectedRows[0][fieldKey]) {
|
|
69141
69103
|
setSelectedRows([selectedItem]);
|
|
69142
69104
|
}
|
|
69143
69105
|
}
|
|
@@ -69146,9 +69108,7 @@ const TableView = ({ idTable, dataSource, height = 400, haveSum, columns, isLoad
|
|
|
69146
69108
|
}
|
|
69147
69109
|
}
|
|
69148
69110
|
else {
|
|
69149
|
-
if (dataSource &&
|
|
69150
|
-
selectedItem &&
|
|
69151
|
-
selectedRows?.length !== selectedItem.length) {
|
|
69111
|
+
if (dataSource && selectedItem && selectedRows?.length !== selectedItem.length) {
|
|
69152
69112
|
setSelectedRows(selectedItem ? [...selectedItem] : []);
|
|
69153
69113
|
}
|
|
69154
69114
|
}
|
|
@@ -69166,67 +69126,52 @@ const TableView = ({ idTable, dataSource, height = 400, haveSum, columns, isLoad
|
|
|
69166
69126
|
const col = contentColumns.find((x) => x.field === row.field);
|
|
69167
69127
|
let value = row[col.field];
|
|
69168
69128
|
if (col.type === 'numeric') {
|
|
69169
|
-
value =
|
|
69170
|
-
formartNumberic(row[col.field], formatSetting?.decimalSeparator ?? ',', formatSetting?.thousandSeparator ?? '.', col.numericSettings?.fraction, true, false) ?? 0;
|
|
69129
|
+
value = formartNumberic(row[col.field], formatSetting?.decimalSeparator ?? ',', formatSetting?.thousandSeparator ?? '.', col.numericSettings?.fraction, true, false) ?? 0;
|
|
69171
69130
|
}
|
|
69172
69131
|
else if (col.type === 'date') {
|
|
69173
|
-
value = value
|
|
69174
|
-
? formatDateTime(value, formatSetting?.dateFormat)
|
|
69175
|
-
: '';
|
|
69132
|
+
value = value ? formatDateTime(value, formatSetting?.dateFormat) : '';
|
|
69176
69133
|
}
|
|
69177
69134
|
else if (col.type === 'datetime') {
|
|
69178
|
-
value = value
|
|
69179
|
-
? formatDateTime(value, formatSetting?.dateFormat ?? 'DD/MM/yyyy HH:mm')
|
|
69180
|
-
: '';
|
|
69135
|
+
value = value ? formatDateTime(value, formatSetting?.dateFormat ?? 'DD/MM/yyyy HH:mm') : '';
|
|
69181
69136
|
}
|
|
69182
69137
|
if (col.template) {
|
|
69183
69138
|
value = col.template(row, indexRow) ?? '';
|
|
69184
69139
|
}
|
|
69185
69140
|
return (jsxs(Fragment$1, { children: [jsxs("tr", { "aria-rowindex": indexRow + 1, role: "row", className: "r-row", children: [jsx("td", { className: "r-rowcell r-cell-group", colSpan: 3, children: jsxs("div", { className: "r-rowcell-div", children: [jsx(SvgChevronRight, { style: {
|
|
69186
69141
|
marginLeft: level * 20,
|
|
69187
|
-
transform: expand ? 'rotate(90deg)' : 'rotate(0deg)'
|
|
69142
|
+
transform: expand ? 'rotate(90deg)' : 'rotate(0deg)'
|
|
69188
69143
|
}, fontSize: 15, onClick: () => {
|
|
69189
69144
|
setExpand(!expand);
|
|
69190
69145
|
setExpandsAll(undefined);
|
|
69191
69146
|
row.expand = !expand;
|
|
69192
69147
|
} }), t(col.headerDisplay ?? col.headerText), ": ", value, " (", row.children.length, ")"] }) }), contentColumns.map((colSum, indexCol) => {
|
|
69193
|
-
if (indexCol <= firstColSpan ||
|
|
69194
|
-
colSum.visible === false ||
|
|
69195
|
-
colSum.isGroup === true) {
|
|
69148
|
+
if (indexCol <= firstColSpan || colSum.visible === false || colSum.isGroup === true) {
|
|
69196
69149
|
return;
|
|
69197
69150
|
}
|
|
69198
69151
|
let sumValue = row[colSum.field];
|
|
69199
|
-
const haveSum = row[colSum.field] !== undefined &&
|
|
69200
|
-
|
|
69201
|
-
if (!haveSum &&
|
|
69202
|
-
colSum.haveSum === true &&
|
|
69203
|
-
colSum.type === 'numeric') {
|
|
69152
|
+
const haveSum = row[colSum.field] !== undefined && row[colSum.field] !== null;
|
|
69153
|
+
if (!haveSum && colSum.haveSum === true && colSum.type === 'numeric') {
|
|
69204
69154
|
sumValue = row.children.reduce(function (accumulator, currentValue) {
|
|
69205
|
-
return
|
|
69206
|
-
Number(currentValue[colSum.field] ?? 0));
|
|
69155
|
+
return Number(accumulator ?? 0) + Number(currentValue[colSum.field] ?? 0);
|
|
69207
69156
|
}, 0);
|
|
69208
69157
|
}
|
|
69209
69158
|
if (colSum.type === 'numeric') {
|
|
69210
69159
|
sumValue = formartNumberic(sumValue, formatSetting?.decimalSeparator ?? ',', formatSetting?.thousandSeparator ?? '.', colSum.numericSettings?.fraction, true, false);
|
|
69211
|
-
if (!zeroVisiable &&
|
|
69212
|
-
(sumValue === '0' || sumValue === 0)) {
|
|
69160
|
+
if (!zeroVisiable && (sumValue === '0' || sumValue === 0)) {
|
|
69213
69161
|
sumValue = '';
|
|
69214
69162
|
}
|
|
69215
69163
|
}
|
|
69216
69164
|
return (jsx("td", { className: "r-rowcell r-cell-sum-group", children: jsx("div", { className: "r-rowcell-div", style: {
|
|
69217
|
-
justifyContent: colSum.textAlign
|
|
69218
|
-
|
|
69219
|
-
: '
|
|
69220
|
-
}, children: (haveSum || colSum.haveSum === true) &&
|
|
69221
|
-
Number(row[colSum.field] ?? '0') < 0 ? (jsxs("div", { style: {
|
|
69222
|
-
color: formatSetting?.colorNegative ?? 'red',
|
|
69165
|
+
justifyContent: colSum.textAlign ? colSum.textAlign : 'left'
|
|
69166
|
+
}, children: (haveSum || colSum.haveSum === true) && Number(row[colSum.field] ?? '0') < 0 ? (jsxs("div", { style: {
|
|
69167
|
+
color: formatSetting?.colorNegative ?? 'red'
|
|
69223
69168
|
}, children: [' ', `${formatSetting?.prefixNegative ?? '-'}${sumValue}${formatSetting?.suffixNegative ?? ''}`] })) : (sumValue) }) }, `group-sum-cell-${level}-${indexRow}-${indexCol}`));
|
|
69224
|
-
})] }), expand &&
|
|
69169
|
+
})] }), expand && jsx(RenderContent, { datas: row.children, level: level + 1 })] }, `row-${level}-${indexRow}`));
|
|
69225
69170
|
}
|
|
69226
69171
|
else {
|
|
69227
69172
|
const isSelected = selectedRows?.some((x) => x[fieldKey] === row[fieldKey]);
|
|
69228
69173
|
return (jsx("tr", { id: `row-content-${indexRow}`, "aria-rowindex": indexRow + 1, role: "row", className: classNames$1('r-row', {
|
|
69229
|
-
'r-last-row': level === 0 && indexRow === viewData.length - 1
|
|
69174
|
+
'r-last-row': level === 0 && indexRow === viewData.length - 1
|
|
69230
69175
|
}), onContextMenu: (e) => {
|
|
69231
69176
|
e.preventDefault();
|
|
69232
69177
|
handleContextMenu(e, row);
|
|
@@ -69242,7 +69187,7 @@ const TableView = ({ idTable, dataSource, height = 400, haveSum, columns, isLoad
|
|
|
69242
69187
|
x: e.clientX,
|
|
69243
69188
|
y: e.clientY,
|
|
69244
69189
|
row,
|
|
69245
|
-
show: true
|
|
69190
|
+
show: true
|
|
69246
69191
|
});
|
|
69247
69192
|
}, 100);
|
|
69248
69193
|
};
|
|
@@ -69257,9 +69202,9 @@ const TableView = ({ idTable, dataSource, height = 400, haveSum, columns, isLoad
|
|
|
69257
69202
|
virtualDivRef.current.style.height = '0px';
|
|
69258
69203
|
}
|
|
69259
69204
|
}, [context]);
|
|
69260
|
-
return (jsxs("div", { className: "r-table-edit r-virtualized-table", children: [jsxs("div", { className: "r-grid", children: [toolbarSetting?.showTopToolbar &&
|
|
69205
|
+
return (jsxs("div", { className: "r-table-edit r-virtualized-table", children: [jsxs("div", { className: "r-grid", children: [toolbarSetting?.showTopToolbar && jsx(RenderToolbarTop, { toolbarTopOption: toolbarTopOption }), headerComponent && headerComponent(), jsxs("div", { ref: gridRef, className: "r-gridtable", style: {
|
|
69261
69206
|
height: `${height ? `${height}px` : 'auto'}`,
|
|
69262
|
-
position: 'relative'
|
|
69207
|
+
position: 'relative'
|
|
69263
69208
|
}, children: [jsxs("table", { role: "presentation", style: { width: '100%' }, children: [jsx(RenderColGroup, { contentColumns: contentColumns }), jsx("thead", { className: "r-gridheader", role: "rowgroup", children: headerColumns.map((rowColumn, indexParent) => {
|
|
69264
69209
|
return (jsx("tr", { className: "r-row", role: "row", children: rowColumn.map((col, index) => (jsx(HeaderTableCol, { col: col, idTable: idTable ?? '', dataSource: dataSource, indexCol: index, indexParent: indexParent, isMulti: isMulti ?? false, objHeaderWidthFixLeft: objHeaderWidthFixLeft, objHeaderWidthFixRight: objHeaderWidthFixRight, selectEnable: true, selectedRows: selectedRows, setSelectedRows: setSelectedRows, container: gridRef, filterBy: filterBy, orderBy: orderBy, optionsFilter: querySetting?.optionsFilter, allowFiltering: querySetting?.allowFiltering, allowSorting: querySetting?.allowSorting, formatSetting: formatSetting, changeFilter: (val) => {
|
|
69265
69210
|
setFilterBy([...val]);
|
|
@@ -69278,32 +69223,22 @@ const TableView = ({ idTable, dataSource, height = 400, haveSum, columns, isLoad
|
|
|
69278
69223
|
}
|
|
69279
69224
|
const item = columnsAggregate?.find((x) => x.field === col.field);
|
|
69280
69225
|
let sumValue = item?.value;
|
|
69281
|
-
if (!item &&
|
|
69282
|
-
col.haveSum === true &&
|
|
69283
|
-
col.type === 'numeric') {
|
|
69226
|
+
if (!item && col.haveSum === true && col.type === 'numeric') {
|
|
69284
69227
|
sumValue = viewData.reduce(function (accumulator, currentValue) {
|
|
69285
|
-
return
|
|
69286
|
-
Number(currentValue[col.field] ?? 0));
|
|
69228
|
+
return Number(accumulator ?? 0) + Number(currentValue[col.field] ?? 0);
|
|
69287
69229
|
}, 0);
|
|
69288
69230
|
}
|
|
69289
69231
|
if (col.type === 'numeric') {
|
|
69290
69232
|
sumValue = formartNumberic(sumValue, formatSetting?.decimalSeparator ?? ',', formatSetting?.thousandSeparator ?? '.', col.numericSettings?.fraction, true, false);
|
|
69291
69233
|
}
|
|
69292
69234
|
return (jsx("td", { className: classNames$1(`p-0 px-50 r-footer fix-${col.fixedType}`, { 'cell-fixed': col.fixedType }), style: {
|
|
69293
|
-
left: col.fixedType === 'left'
|
|
69294
|
-
|
|
69295
|
-
|
|
69296
|
-
|
|
69297
|
-
|
|
69298
|
-
: undefined,
|
|
69299
|
-
textAlign: col.textAlign ? col.textAlign : 'left',
|
|
69300
|
-
}, children: jsx("div", { className: "r-footer-div", children: (item || col.haveSum === true) &&
|
|
69301
|
-
Number(item?.value ?? '0') < 0 ? (jsxs("div", { style: {
|
|
69302
|
-
color: formatSetting?.colorNegative ?? 'red',
|
|
69235
|
+
left: col.fixedType === 'left' ? objWidthFixLeft[indexCol] : undefined,
|
|
69236
|
+
right: col.fixedType === 'right' ? objWidthFixRight[indexCol] : undefined,
|
|
69237
|
+
textAlign: col.textAlign ? col.textAlign : 'left'
|
|
69238
|
+
}, children: jsx("div", { className: "r-footer-div", children: (item || col.haveSum === true) && Number(item?.value ?? '0') < 0 ? (jsxs("div", { style: {
|
|
69239
|
+
color: formatSetting?.colorNegative ?? 'red'
|
|
69303
69240
|
}, children: [' ', `${formatSetting?.prefixNegative ?? '-'}${sumValue}${formatSetting?.suffixNegative ?? ''}`] })) : (sumValue) }) }, `summarycell-${indexCol}`));
|
|
69304
|
-
}) })) })] }), jsx("div", { ref: virtualDivRef }), context &&
|
|
69305
|
-
(contextMenuItems?.length ?? 0) > 0 &&
|
|
69306
|
-
handleContextMenuClick && (jsx(Popover$1, { className: "r-context-popover", placement: "right-start", isOpen: context.show, target: virtualDivRef.current, toggle: handleCloseContext, fade: false, children: jsx(PopoverBody$1, { children: contextMenuItems?.map((item, index) => {
|
|
69241
|
+
}) })) })] }), jsx("div", { ref: virtualDivRef }), context && (contextMenuItems?.length ?? 0) > 0 && handleContextMenuClick && (jsx(Popover$1, { className: "r-context-popover", placement: "right-start", isOpen: context.show, target: virtualDivRef.current, toggle: handleCloseContext, fade: false, children: jsx(PopoverBody$1, { children: contextMenuItems?.map((item, index) => {
|
|
69307
69242
|
return (jsxs("div", { className: "r-context-item", onClick: () => {
|
|
69308
69243
|
handleCloseContext();
|
|
69309
69244
|
handleContextMenuClick?.(item, context.row);
|
|
@@ -69318,7 +69253,7 @@ const TableView = ({ idTable, dataSource, height = 400, haveSum, columns, isLoad
|
|
|
69318
69253
|
visible: x.visible,
|
|
69319
69254
|
fixedType: x.fixedType,
|
|
69320
69255
|
width: x.width,
|
|
69321
|
-
sortOrder: index + 1
|
|
69256
|
+
sortOrder: index + 1
|
|
69322
69257
|
})));
|
|
69323
69258
|
}
|
|
69324
69259
|
} })] }));
|