react-table-edit 1.5.40 → 1.5.41
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 +13 -1
- package/dist/component/modal-import-excel/tab-select-file.d.ts +9 -0
- package/dist/index.d.ts +13 -1
- package/dist/index.js +21 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +21 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -48,9 +48,21 @@ type IFProps = {
|
|
|
48
48
|
* @param params - Tham số cập nhật
|
|
49
49
|
*/
|
|
50
50
|
updateGeneralSettingApi?: (params: IFDataMapExcel[]) => void;
|
|
51
|
+
/**
|
|
52
|
+
* API lấy mẫu Excel
|
|
53
|
+
*/
|
|
54
|
+
getExcelTemplate?: (params: string) => Promise<any>;
|
|
55
|
+
/**
|
|
56
|
+
* Mã code chức năng để lấy mẫu nhập excel
|
|
57
|
+
*/
|
|
58
|
+
templateCode?: string;
|
|
59
|
+
/**
|
|
60
|
+
* Tên chức năng đang import Excel
|
|
61
|
+
*/
|
|
62
|
+
resourceName?: string;
|
|
51
63
|
/**
|
|
52
64
|
* API lấy cấu hình in
|
|
53
|
-
* @returns Promise trả về
|
|
65
|
+
* @returns Promise trả về cấu hình map cột
|
|
54
66
|
*/
|
|
55
67
|
getGeneralSettingApi?: () => Promise<any>;
|
|
56
68
|
};
|
|
@@ -7,6 +7,15 @@ export interface IFPropsDetail {
|
|
|
7
7
|
setValue: UseFormSetValue<IFDataExcel>;
|
|
8
8
|
getValues: UseFormGetValues<IFDataExcel>;
|
|
9
9
|
templateUrl?: string;
|
|
10
|
+
resourceName?: string;
|
|
11
|
+
/**
|
|
12
|
+
* API lấy mẫu Excel
|
|
13
|
+
*/
|
|
14
|
+
getExcelTemplate?: (params: string) => Promise<any>;
|
|
15
|
+
/**
|
|
16
|
+
* Mã code chức năng để lấy mẫu nhập excel
|
|
17
|
+
*/
|
|
18
|
+
templateCode?: string;
|
|
10
19
|
}
|
|
11
20
|
declare const TabSelectFileImportExcel: (props: IFPropsDetail) => import("react/jsx-runtime").JSX.Element;
|
|
12
21
|
export default TabSelectFileImportExcel;
|
package/dist/index.d.ts
CHANGED
|
@@ -586,9 +586,21 @@ type IFProps$1 = {
|
|
|
586
586
|
* @param params - Tham số cập nhật
|
|
587
587
|
*/
|
|
588
588
|
updateGeneralSettingApi?: (params: IFDataMapExcel[]) => void;
|
|
589
|
+
/**
|
|
590
|
+
* API lấy mẫu Excel
|
|
591
|
+
*/
|
|
592
|
+
getExcelTemplate?: (params: string) => Promise<any>;
|
|
593
|
+
/**
|
|
594
|
+
* Mã code chức năng để lấy mẫu nhập excel
|
|
595
|
+
*/
|
|
596
|
+
templateCode?: string;
|
|
597
|
+
/**
|
|
598
|
+
* Tên chức năng đang import Excel
|
|
599
|
+
*/
|
|
600
|
+
resourceName?: string;
|
|
589
601
|
/**
|
|
590
602
|
* API lấy cấu hình in
|
|
591
|
-
* @returns Promise trả về
|
|
603
|
+
* @returns Promise trả về cấu hình map cột
|
|
592
604
|
*/
|
|
593
605
|
getGeneralSettingApi?: () => Promise<any>;
|
|
594
606
|
};
|
package/dist/index.js
CHANGED
|
@@ -68331,38 +68331,48 @@ const connectString = (t, props) => {
|
|
|
68331
68331
|
};
|
|
68332
68332
|
|
|
68333
68333
|
const TabSelectFileImportExcel = (props) => {
|
|
68334
|
-
const { templateUrl, setValue, getValues, control, errors } = props;
|
|
68334
|
+
const { templateUrl, getExcelTemplate, templateCode, resourceName, setValue, getValues, control, errors, } = props;
|
|
68335
68335
|
const [isDragging, setIsDragging] = React$5.useState(false);
|
|
68336
68336
|
const [optionSheetName, setOptionSheetName] = React$5.useState([]);
|
|
68337
68337
|
const { t } = reactI18next.useTranslation();
|
|
68338
68338
|
const hanldDrag = (e) => {
|
|
68339
68339
|
e.preventDefault();
|
|
68340
68340
|
e.stopPropagation();
|
|
68341
|
-
if (e.type ===
|
|
68341
|
+
if (e.type === 'dragenter' || e.type === 'dragover') {
|
|
68342
68342
|
setIsDragging(true);
|
|
68343
68343
|
}
|
|
68344
|
-
else if (e.type ===
|
|
68344
|
+
else if (e.type === 'dragleave') {
|
|
68345
68345
|
setIsDragging(false);
|
|
68346
68346
|
}
|
|
68347
68347
|
};
|
|
68348
|
-
return (jsxRuntime.jsxs("div", { className:
|
|
68349
|
-
const link = document.createElement(
|
|
68348
|
+
return (jsxRuntime.jsxs("div", { className: "box form-box__border", children: [templateUrl && (!templateCode || !getExcelTemplate) && (jsxRuntime.jsxs(Button$1$1, { color: "link", onClick: () => {
|
|
68349
|
+
const link = document.createElement('a');
|
|
68350
68350
|
link.href = `${templateUrl}`; // URL file
|
|
68351
68351
|
document.body.appendChild(link);
|
|
68352
68352
|
link.click();
|
|
68353
68353
|
document.body.removeChild(link);
|
|
68354
|
-
}, children: [jsxRuntime.jsx(SvgDownload, { fontSize: 14, className:
|
|
68354
|
+
}, children: [jsxRuntime.jsx(SvgDownload, { fontSize: 14, className: "me-50" }), t('Download the sample file')] })), templateCode && getExcelTemplate && (jsxRuntime.jsxs(Button$1$1, { color: "link", onClick: () => {
|
|
68355
|
+
getExcelTemplate(templateCode).then((rs) => {
|
|
68356
|
+
const url = window.URL.createObjectURL(new Blob([rs]));
|
|
68357
|
+
const link = document.createElement('a');
|
|
68358
|
+
link.href = url;
|
|
68359
|
+
link.download = `${resourceName ? `${resourceName}_` : ''}${t('Sample File')}.xlsx`;
|
|
68360
|
+
document.body.appendChild(link);
|
|
68361
|
+
link.click();
|
|
68362
|
+
document.body.removeChild(link);
|
|
68363
|
+
});
|
|
68364
|
+
}, children: [jsxRuntime.jsx(SvgDownload, { fontSize: 14, className: "me-50" }), t('Download the sample file')] })), jsxRuntime.jsx("h5", { className: "m-0 form-box__border--title", children: t('Upload file') }), jsxRuntime.jsx("div", { className: `m-1 rounded d-flex flex-column align-items-center justify-content-center ${isDragging ? 'dragging-file' : 'no-dragging-file'}`, style: { minHeight: '220px' }, draggable: true, onDragEnter: hanldDrag, onDragLeave: hanldDrag, onDragOver: hanldDrag, onDrop: (e) => {
|
|
68355
68365
|
e.preventDefault();
|
|
68356
68366
|
e.stopPropagation();
|
|
68357
68367
|
setIsDragging(false);
|
|
68358
68368
|
if (e.dataTransfer.files && e.dataTransfer.files[0]) {
|
|
68359
68369
|
getSheetsExcel(e.dataTransfer.files[0], setValue, setOptionSheetName);
|
|
68360
68370
|
}
|
|
68361
|
-
}, children: getValues('file') ? jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { className:
|
|
68371
|
+
}, children: getValues('file') ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { className: "mb-1 fs-5", children: getValues('file')?.name }), jsxRuntime.jsxs(Button$1$1, { tag: Label$1, outline: true, className: "me-75", size: "md", color: "primary", children: [jsxRuntime.jsx(SvgArrowLeftCircle, { fontSize: 18, className: "me-50" }), t('Select other file'), jsxRuntime.jsx(Input$1, { type: "file", onChange: (e) => {
|
|
68362
68372
|
getSheetsExcel(e.target.files[0], setValue, setOptionSheetName);
|
|
68363
|
-
}, hidden: true, accept:
|
|
68373
|
+
}, hidden: true, accept: ".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel" })] })] })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { className: "fs-4 bolder", children: t('Drag and drop files here') }), jsxRuntime.jsx("div", { className: "my-50", children: t('or') }), jsxRuntime.jsxs(Button$1$1, { tag: Label$1, outline: true, className: "me-75", size: "md", color: "primary", children: [jsxRuntime.jsx(SvgArrowLeftCircle, { fontSize: 18, className: "me-50" }), t('Select file'), jsxRuntime.jsx(Input$1, { type: "file", onChange: (e) => {
|
|
68364
68374
|
getSheetsExcel(e.target.files[0], setValue, setOptionSheetName);
|
|
68365
|
-
}, hidden: true, accept:
|
|
68375
|
+
}, hidden: true, accept: ".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel" })] }), jsxRuntime.jsx("div", { className: "mt-1", children: t('Accepts .xls, .xlsx, .csv files') })] })) }), jsxRuntime.jsxs(Row$1, { className: `${getValues('file') ? '' : 'd-none'} m-0 gy-1`, children: [jsxRuntime.jsx(Col$1, { lg: 6, md: 12, xs: 12, children: jsxRuntime.jsx(SelectTableBox$1, { labelSize: "d-flex form-row-inline label-medium", control: control, name: "sheetId", label: t('Sheet name'), required: true, errors: errors.sheetId, placeholder: t('Select'), options: optionSheetName }) }), jsxRuntime.jsx(Col$1, { lg: 6, md: 12, xs: 12, children: jsxRuntime.jsx(NumberInput, { control: control, name: "headerRow", labelSize: "d-flex form-row-inline label-medium", label: t('Header row'), errors: errors.headerRow }) })] })] }));
|
|
68366
68376
|
};
|
|
68367
68377
|
|
|
68368
68378
|
const TabValidateImportExcel = (props) => {
|
|
@@ -68391,7 +68401,7 @@ const TabValidateImportExcel = (props) => {
|
|
|
68391
68401
|
|
|
68392
68402
|
const ModalImportComponent = (props) => {
|
|
68393
68403
|
const { t } = reactI18next.useTranslation();
|
|
68394
|
-
const { windowSize, openModal, handleModal, handleValidate, importExcelApi, validateExcelApi, getGeneralSettingApi, updateGeneralSettingApi, headerErrorExcelColumns, templateUrl, defaultHeaderRow, formatNumber, mapColumn, headerValidateExcelColumns, zIndex, } = props;
|
|
68404
|
+
const { windowSize, openModal, handleModal, handleValidate, importExcelApi, validateExcelApi, getGeneralSettingApi, updateGeneralSettingApi, headerErrorExcelColumns, templateUrl, defaultHeaderRow, formatNumber, mapColumn, headerValidateExcelColumns, getExcelTemplate, templateCode, resourceName, zIndex, } = props;
|
|
68395
68405
|
const [optionField, setOptionField] = React$5.useState([]);
|
|
68396
68406
|
const [dataMerge, setDataMerge] = React$5.useState([]);
|
|
68397
68407
|
const [dataValidate, setDataValidate] = React$5.useState([]);
|
|
@@ -68593,7 +68603,7 @@ const ModalImportComponent = (props) => {
|
|
|
68593
68603
|
{
|
|
68594
68604
|
id: 'upload-file',
|
|
68595
68605
|
title: t('Upload file'),
|
|
68596
|
-
content: (jsxRuntime.jsx(TabSelectFileImportExcel, { control: control, errors: errors, getValues: getValues, setValue: setValue, watch: watch, templateUrl: templateUrl })),
|
|
68606
|
+
content: (jsxRuntime.jsx(TabSelectFileImportExcel, { control: control, errors: errors, getValues: getValues, setValue: setValue, watch: watch, templateUrl: templateUrl, resourceName: resourceName, templateCode: templateCode, getExcelTemplate: getExcelTemplate })),
|
|
68597
68607
|
},
|
|
68598
68608
|
{
|
|
68599
68609
|
id: 'merge-data',
|