tnx-shared 5.3.215 → 5.3.217
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/bundles/tnx-shared.umd.js +267 -72
- package/bundles/tnx-shared.umd.js.map +1 -1
- package/bundles/tnx-shared.umd.min.js +1 -1
- package/bundles/tnx-shared.umd.min.js.map +1 -1
- package/classes/base/list-component-base.d.ts +6 -0
- package/classes/base/list-component-base.d.ts.map +1 -1
- package/classes/base/validators.d.ts.map +1 -1
- package/esm2015/classes/base/list-component-base.js +184 -20
- package/esm2015/classes/base/validators.js +4 -1
- package/esm2015/services/export.service.js +3 -3
- package/fesm2015/tnx-shared.js +188 -21
- package/fesm2015/tnx-shared.js.map +1 -1
- package/package.json +2 -2
- package/services/export.service.d.ts +1 -1
- package/services/export.service.d.ts.map +1 -1
- package/tnx-shared.metadata.json +1 -1
package/fesm2015/tnx-shared.js
CHANGED
|
@@ -11544,6 +11544,9 @@ class RequiredValidator {
|
|
|
11544
11544
|
validate(event) {
|
|
11545
11545
|
var _a;
|
|
11546
11546
|
this._label = (_a = event.control.errorLabel) !== null && _a !== void 0 ? _a : event.control.label;
|
|
11547
|
+
if (event.control.isHtmlLabel) {
|
|
11548
|
+
this._label = event.control.fullLabel;
|
|
11549
|
+
}
|
|
11547
11550
|
return isNotEmpty(event.value, event.control);
|
|
11548
11551
|
}
|
|
11549
11552
|
getError() {
|
|
@@ -16409,9 +16412,9 @@ class ExportService {
|
|
|
16409
16412
|
this.environment = this._moduleConfig.environment;
|
|
16410
16413
|
this.serviceUri = `${this._moduleConfig.environment.apiDomain.templateEndpoint}/Export`;
|
|
16411
16414
|
}
|
|
16412
|
-
objectToExcel(data, fileName) {
|
|
16415
|
+
objectToExcel(data, fileName, numOfHeaderRow) {
|
|
16413
16416
|
return this._http
|
|
16414
|
-
.post(`${this.serviceUri}/ObjectToExcel`, data, { responseType: 'blob' })
|
|
16417
|
+
.post(`${this.serviceUri}/ObjectToExcel?numOfHeaderRow=${numOfHeaderRow}`, data, { responseType: 'blob' })
|
|
16415
16418
|
.pipe(catchError((err) => this._commonService.handleError(err, this._injector)))
|
|
16416
16419
|
.subscribe(res => {
|
|
16417
16420
|
this.saveAsExcelFile(res, fileName);
|
|
@@ -19489,9 +19492,12 @@ class ListComponentBase extends ComponentBase {
|
|
|
19489
19492
|
const tableEle = element.querySelector('table');
|
|
19490
19493
|
const headEle = tableEle.querySelector('thead');
|
|
19491
19494
|
const bodyEle = tableEle.querySelector('tbody');
|
|
19492
|
-
const arrHeadEle = this.getArrHeadByHtml(headEle);
|
|
19493
|
-
const
|
|
19494
|
-
const
|
|
19495
|
+
// const arrHeadEle = this.getArrHeadByHtml(headEle);
|
|
19496
|
+
const arrHeadEle = this.getArrHeadByHtmlForPrint(headEle);
|
|
19497
|
+
const firstHead = arrHeadEle.allCol;
|
|
19498
|
+
const arrRowData = this.getArrRowDataByHtml(bodyEle, firstHead);
|
|
19499
|
+
// const strHeadEle = this.headHtmlToString(arrHeadEle);
|
|
19500
|
+
const strHeadEle = this.headHtmlToStringNew(arrHeadEle.header);
|
|
19495
19501
|
const strBodyEle = this.rowDataHtmlToString(arrRowData);
|
|
19496
19502
|
const css = '<style type="text/css">table th, table td {border:1px solid #000;} table th {text-align: center;} table {width: 100%;border-collapse: collapse;} table td:first-child {text-align: center;}</style>';
|
|
19497
19503
|
const table = `${css}<table>${strHeadEle}${strBodyEle}</table>`;
|
|
@@ -19504,9 +19510,12 @@ class ListComponentBase extends ComponentBase {
|
|
|
19504
19510
|
const tableEle = element.querySelector('table');
|
|
19505
19511
|
const headEle = tableEle.querySelector('thead');
|
|
19506
19512
|
const bodyEle = tableEle.querySelector('tbody');
|
|
19507
|
-
const arrHeadEle = this.getArrHeadByHtml(headEle);
|
|
19508
|
-
const
|
|
19509
|
-
const
|
|
19513
|
+
// const arrHeadEle = this.getArrHeadByHtml(headEle);
|
|
19514
|
+
const arrHeadEle = this.getArrHeadByHtmlForPrint(headEle);
|
|
19515
|
+
const firstHead = arrHeadEle.allCol;
|
|
19516
|
+
const arrRowData = this.getArrRowDataHasRowSpanByHtml(bodyEle, firstHead);
|
|
19517
|
+
// const strHeadEle = this.headHtmlToString(arrHeadEle);
|
|
19518
|
+
const strHeadEle = this.headHtmlToStringNew(arrHeadEle);
|
|
19510
19519
|
const strBodyEle = this.rowDataHtmlHasRowSpanToString(arrRowData);
|
|
19511
19520
|
const css = '<style type="text/css">table th, table td {border:1px solid #000;} table th {text-align: center;} table {width: 100%;border-collapse: collapse;} table td:first-child {text-align: center;}</style>';
|
|
19512
19521
|
const table = `${css}<table>${strHeadEle}${strBodyEle}</table>`;
|
|
@@ -19516,6 +19525,7 @@ class ListComponentBase extends ComponentBase {
|
|
|
19516
19525
|
this.exportByReadingHtml(true, isTree);
|
|
19517
19526
|
}
|
|
19518
19527
|
exportByReadingHtml(exportAll = false, isTree = false) {
|
|
19528
|
+
var _a;
|
|
19519
19529
|
if (this._groupField) {
|
|
19520
19530
|
this._notifierService.showWarning('Chưa hỗ trợ xuất có nhóm dữ liệu!');
|
|
19521
19531
|
return;
|
|
@@ -19525,16 +19535,21 @@ class ListComponentBase extends ComponentBase {
|
|
|
19525
19535
|
const headEle = tableEle.querySelector('thead');
|
|
19526
19536
|
const bodyEle = tableEle.querySelector('tbody');
|
|
19527
19537
|
// header.
|
|
19528
|
-
const arrHead = this.getArrHeadByHtml(headEle);
|
|
19529
|
-
|
|
19538
|
+
// const arrHead = this.getArrHeadByHtml(headEle);
|
|
19539
|
+
let arrHead = this.getArrHeadByHtmlNew(headEle);
|
|
19540
|
+
if (!(arrHead === null || arrHead === void 0 ? void 0 : arrHead.length)) {
|
|
19530
19541
|
return;
|
|
19531
19542
|
}
|
|
19532
19543
|
// body.
|
|
19533
|
-
const
|
|
19544
|
+
const firstHead = arrHead[0];
|
|
19545
|
+
// const arrRowData = this.getArrRowDataByHtml(bodyEle, arrHead, exportAll);
|
|
19546
|
+
const arrRowData = this.getArrRowDataByHtml(bodyEle, firstHead, exportAll);
|
|
19534
19547
|
// export.
|
|
19535
|
-
|
|
19548
|
+
arrHead = arrHead.map(x => x.map(z => z.value));
|
|
19549
|
+
// const dataExport = [arrHead.map(i => i.value), ...arrRowData];
|
|
19550
|
+
const dataExport = [...arrHead, ...arrRowData];
|
|
19536
19551
|
const fileName = `Danh sách ${this.setting.objectName}`;
|
|
19537
|
-
this._exportService.objectToExcel(dataExport, fileName);
|
|
19552
|
+
this._exportService.objectToExcel(dataExport, fileName, (_a = arrHead === null || arrHead === void 0 ? void 0 : arrHead.length) !== null && _a !== void 0 ? _a : 1);
|
|
19538
19553
|
}
|
|
19539
19554
|
headHtmlToString(arrHeadEle) {
|
|
19540
19555
|
let result = '';
|
|
@@ -19543,12 +19558,28 @@ class ListComponentBase extends ComponentBase {
|
|
|
19543
19558
|
});
|
|
19544
19559
|
return result;
|
|
19545
19560
|
}
|
|
19561
|
+
headHtmlToStringNew(arrHeadEle) {
|
|
19562
|
+
let result = '';
|
|
19563
|
+
for (const itemHeader of arrHeadEle) {
|
|
19564
|
+
result += '<tr>';
|
|
19565
|
+
for (const itemTh of itemHeader) {
|
|
19566
|
+
result += `<th colSpan="${itemTh.colSpan}" rowSpan="${itemTh.rowSpan}">${itemTh.value}</th>`;
|
|
19567
|
+
}
|
|
19568
|
+
result += '</tr>';
|
|
19569
|
+
}
|
|
19570
|
+
return result;
|
|
19571
|
+
}
|
|
19546
19572
|
rowDataHtmlToString(rowDatas) {
|
|
19547
19573
|
const arrRowData = [];
|
|
19548
|
-
rowDatas.forEach(arrRowDataChild => {
|
|
19574
|
+
rowDatas.forEach((arrRowDataChild, indexChild) => {
|
|
19549
19575
|
let rowData = '<tr>';
|
|
19550
|
-
arrRowDataChild.forEach(element => {
|
|
19551
|
-
|
|
19576
|
+
arrRowDataChild.forEach((element, index) => {
|
|
19577
|
+
if (index == 0 && !this.setting.hiddenOrderColumn) {
|
|
19578
|
+
rowData += `<td>${indexChild + 1}</td>`;
|
|
19579
|
+
}
|
|
19580
|
+
else {
|
|
19581
|
+
rowData += `<td>${element}</td>`;
|
|
19582
|
+
}
|
|
19552
19583
|
});
|
|
19553
19584
|
rowData += '</tr>';
|
|
19554
19585
|
arrRowData.push(rowData);
|
|
@@ -19577,6 +19608,136 @@ class ListComponentBase extends ComponentBase {
|
|
|
19577
19608
|
}
|
|
19578
19609
|
return arrHeader;
|
|
19579
19610
|
}
|
|
19611
|
+
getArrHeadByHtmlNew(header) {
|
|
19612
|
+
var _a, _b, _c;
|
|
19613
|
+
const filter = Array.prototype.filter;
|
|
19614
|
+
const allRow = header.querySelectorAll('tr');
|
|
19615
|
+
const lstRow = filter.call(allRow, function (node) {
|
|
19616
|
+
return !node.className.includes('filter-row');
|
|
19617
|
+
});
|
|
19618
|
+
const result = [];
|
|
19619
|
+
const allTh = [];
|
|
19620
|
+
for (const item of lstRow) {
|
|
19621
|
+
allTh.push(item.querySelectorAll('th'));
|
|
19622
|
+
}
|
|
19623
|
+
const maxColSize = allTh.reduce((a, b) => {
|
|
19624
|
+
const newArr = [...b];
|
|
19625
|
+
const result = newArr.reduce((x, y) => y.colSpan + x, 0);
|
|
19626
|
+
return result > a ? result : a;
|
|
19627
|
+
}, 0);
|
|
19628
|
+
const startIndex = this.setting.hiddenCheckbox ? 0 : 1;
|
|
19629
|
+
const endIndex = maxColSize - (this.setting.hiddenFunctionColumn ? 1 : 2);
|
|
19630
|
+
for (let ind = 0; ind < lstRow.length; ind++) {
|
|
19631
|
+
const arrTh = [...allTh[ind]];
|
|
19632
|
+
if (startIndex > endIndex) {
|
|
19633
|
+
return null;
|
|
19634
|
+
}
|
|
19635
|
+
result[ind] = (_a = result[ind]) !== null && _a !== void 0 ? _a : [];
|
|
19636
|
+
let colIndex = 0;
|
|
19637
|
+
const numOfColSpan = arrTh.reduce((x, y) => x + y.colSpan - 1, 0);
|
|
19638
|
+
for (let i = startIndex; i <= endIndex - numOfColSpan; i++) {
|
|
19639
|
+
if (arrTh[i]) {
|
|
19640
|
+
if (arrTh[i].rowSpan && arrTh[i].rowSpan > 1) {
|
|
19641
|
+
for (let j = 1; j < arrTh[i].rowSpan; j++) {
|
|
19642
|
+
result[ind + j] = (_b = result[ind + j]) !== null && _b !== void 0 ? _b : [];
|
|
19643
|
+
if (result[ind + j][colIndex] == null || result[ind + j][colIndex] == undefined) {
|
|
19644
|
+
result[ind + j][colIndex] = {
|
|
19645
|
+
index: i,
|
|
19646
|
+
value: ''
|
|
19647
|
+
};
|
|
19648
|
+
}
|
|
19649
|
+
}
|
|
19650
|
+
}
|
|
19651
|
+
if (arrTh[i].colSpan && arrTh[i].colSpan > 1) {
|
|
19652
|
+
for (let j = 0; j < arrTh[i].colSpan; j++) {
|
|
19653
|
+
if (result[ind][colIndex] == null || result[ind][colIndex] == undefined) {
|
|
19654
|
+
result[ind][colIndex] = {
|
|
19655
|
+
index: colIndex + startIndex,
|
|
19656
|
+
value: j == 0 ? arrTh[i].innerText : ''
|
|
19657
|
+
};
|
|
19658
|
+
}
|
|
19659
|
+
for (let k = ind + 1; k < lstRow.length; k++) {
|
|
19660
|
+
const otherRow = [...allTh[k]];
|
|
19661
|
+
result[ind + k] = (_c = result[ind + k]) !== null && _c !== void 0 ? _c : [];
|
|
19662
|
+
if (!result[ind + k][colIndex]) {
|
|
19663
|
+
result[ind + k][colIndex] = {
|
|
19664
|
+
index: colIndex + startIndex,
|
|
19665
|
+
value: otherRow[j].innerText
|
|
19666
|
+
};
|
|
19667
|
+
}
|
|
19668
|
+
}
|
|
19669
|
+
colIndex++;
|
|
19670
|
+
}
|
|
19671
|
+
}
|
|
19672
|
+
else {
|
|
19673
|
+
if (result[ind][colIndex] == null || result[ind][colIndex] == undefined) {
|
|
19674
|
+
result[ind][colIndex] = {
|
|
19675
|
+
index: colIndex + startIndex,
|
|
19676
|
+
value: arrTh[i].innerText
|
|
19677
|
+
};
|
|
19678
|
+
}
|
|
19679
|
+
colIndex++;
|
|
19680
|
+
}
|
|
19681
|
+
}
|
|
19682
|
+
else {
|
|
19683
|
+
if (result[ind][colIndex] == null || result[ind][colIndex] == undefined) {
|
|
19684
|
+
result[ind][colIndex] = {
|
|
19685
|
+
index: colIndex + startIndex,
|
|
19686
|
+
value: ''
|
|
19687
|
+
};
|
|
19688
|
+
}
|
|
19689
|
+
colIndex++;
|
|
19690
|
+
}
|
|
19691
|
+
}
|
|
19692
|
+
}
|
|
19693
|
+
return result;
|
|
19694
|
+
}
|
|
19695
|
+
getArrHeadByHtmlForPrint(header) {
|
|
19696
|
+
const filter = Array.prototype.filter;
|
|
19697
|
+
const allRow = header.querySelectorAll('tr');
|
|
19698
|
+
const lstRow = [...filter.call(allRow, function (node) {
|
|
19699
|
+
return !node.className.includes('filter-row');
|
|
19700
|
+
})];
|
|
19701
|
+
const result = {
|
|
19702
|
+
allCol: [],
|
|
19703
|
+
header: []
|
|
19704
|
+
};
|
|
19705
|
+
for (let ind = 0; ind < lstRow.length; ind++) {
|
|
19706
|
+
const lstCell = [...lstRow[ind].querySelectorAll('th')];
|
|
19707
|
+
const startIndex = this.setting.hiddenCheckbox || ind != 0 ? 0 : 1;
|
|
19708
|
+
let colIndex = startIndex;
|
|
19709
|
+
const itemHeader = [];
|
|
19710
|
+
const endIndex = lstCell.length - (this.setting.hiddenFunctionColumn || ind != 0 ? 1 : 2);
|
|
19711
|
+
for (let i = startIndex; i <= endIndex; i++) {
|
|
19712
|
+
if (ind == 0) {
|
|
19713
|
+
if (lstCell[i].colSpan && lstCell[i].colSpan > 1) {
|
|
19714
|
+
for (let j = 0; j < lstCell[i].colSpan; j++) {
|
|
19715
|
+
result.allCol.push({
|
|
19716
|
+
index: colIndex,
|
|
19717
|
+
value: ''
|
|
19718
|
+
});
|
|
19719
|
+
colIndex++;
|
|
19720
|
+
}
|
|
19721
|
+
}
|
|
19722
|
+
else {
|
|
19723
|
+
result.allCol.push({
|
|
19724
|
+
index: colIndex,
|
|
19725
|
+
value: ''
|
|
19726
|
+
});
|
|
19727
|
+
colIndex++;
|
|
19728
|
+
}
|
|
19729
|
+
}
|
|
19730
|
+
itemHeader.push({
|
|
19731
|
+
index: i,
|
|
19732
|
+
value: lstCell[i].innerText,
|
|
19733
|
+
colSpan: lstCell[i].colSpan,
|
|
19734
|
+
rowSpan: lstCell[i].rowSpan
|
|
19735
|
+
});
|
|
19736
|
+
}
|
|
19737
|
+
result.header.push(itemHeader);
|
|
19738
|
+
}
|
|
19739
|
+
return result;
|
|
19740
|
+
}
|
|
19580
19741
|
getArrRowDataHasRowSpanByHtml(bodyEle, arrHead, exportAll = false) {
|
|
19581
19742
|
const arrRow = exportAll ? bodyEle.querySelectorAll('tr') : bodyEle.querySelectorAll('tr.ui-state-highlight');
|
|
19582
19743
|
if (!arrRow.length) {
|
|
@@ -19608,22 +19769,28 @@ class ListComponentBase extends ComponentBase {
|
|
|
19608
19769
|
return [];
|
|
19609
19770
|
}
|
|
19610
19771
|
const arrRowData = [];
|
|
19611
|
-
for (
|
|
19612
|
-
|
|
19772
|
+
// for (const element of arrRow) {
|
|
19773
|
+
arrRow.forEach((rowElement, indexRow) => {
|
|
19774
|
+
const row = rowElement;
|
|
19613
19775
|
const arrTd = row.querySelectorAll('td');
|
|
19614
19776
|
let currentTd;
|
|
19615
19777
|
const rowData = [];
|
|
19616
|
-
arrHead.forEach(head => {
|
|
19778
|
+
arrHead.forEach((head, index) => {
|
|
19617
19779
|
currentTd = arrTd[head.index];
|
|
19618
19780
|
if (currentTd.innerText === '') {
|
|
19619
19781
|
rowData.push(this.getValueCheckboxFormat(currentTd));
|
|
19620
19782
|
}
|
|
19621
19783
|
else {
|
|
19622
|
-
|
|
19784
|
+
if (index == 0 && !this.setting.hiddenOrderColumn) {
|
|
19785
|
+
rowData.push(indexRow + 1);
|
|
19786
|
+
}
|
|
19787
|
+
else {
|
|
19788
|
+
rowData.push(currentTd.innerText);
|
|
19789
|
+
}
|
|
19623
19790
|
}
|
|
19624
19791
|
});
|
|
19625
19792
|
arrRowData.push(rowData);
|
|
19626
|
-
}
|
|
19793
|
+
});
|
|
19627
19794
|
return arrRowData;
|
|
19628
19795
|
}
|
|
19629
19796
|
getValueCheckboxFormat(data) {
|