@webitel/ui-sdk 24.6.40 → 24.6.43
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/ui-sdk.css +1 -1
- package/dist/ui-sdk.js +2 -2
- package/dist/ui-sdk.umd.cjs +13 -13
- package/package.json +3 -2
- package/src/api/defaults/getDefaultInstance/getDefaultInstance.js +1 -0
- package/src/components/wt-button-select/wt-button-select.vue +15 -15
- package/src/enums/TypesExportedSettings/TypesExportedSettings.enum.js +4 -0
- package/src/modules/CSVExport/CSVExport.js +5 -4
- package/src/modules/CSVExport/XLSExport.js +50 -0
- package/src/modules/CSVExport/mixins/exportXLSMixin.js +38 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webitel/ui-sdk",
|
|
3
|
-
"version": "24.6.
|
|
3
|
+
"version": "24.6.43",
|
|
4
4
|
"private": false,
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "vite",
|
|
@@ -61,7 +61,8 @@
|
|
|
61
61
|
"vue-multiselect": "^3.0.0-beta.3",
|
|
62
62
|
"vue-observe-visibility": "^2.0.0-alpha.1",
|
|
63
63
|
"vue-router": "^4.1.6",
|
|
64
|
-
"webitel-sdk": "^24.2.16"
|
|
64
|
+
"webitel-sdk": "^24.2.16",
|
|
65
|
+
"xlsx": "^0.18.5"
|
|
65
66
|
},
|
|
66
67
|
"devDependencies": {
|
|
67
68
|
"@vitejs/plugin-vue": "5.0.4",
|
|
@@ -105,25 +105,25 @@ function atClickaway() {
|
|
|
105
105
|
display: inline-flex;
|
|
106
106
|
align-items: center;
|
|
107
107
|
gap: var(--button-select-buttons-gap);
|
|
108
|
-
}
|
|
109
108
|
|
|
110
|
-
.wt-button-select__button {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}
|
|
109
|
+
.wt-button-select__button {
|
|
110
|
+
padding: var(--button-select-button-padding);
|
|
111
|
+
border-radius: var(--border-radius) 0 0 var(--border-radius);
|
|
112
|
+
}
|
|
114
113
|
|
|
115
|
-
.wt-button-select__select-btn {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
114
|
+
.wt-button-select__select-btn {
|
|
115
|
+
min-width: auto;
|
|
116
|
+
padding: var(--button-select-icon-button-padding);
|
|
117
|
+
border-radius: 0 var(--border-radius) var(--border-radius) 0;
|
|
119
118
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
119
|
+
// OPEN AND SHUT ARROW
|
|
120
|
+
.wt-button-select__select-arrow {
|
|
121
|
+
display: flex;
|
|
122
|
+
transform: rotate(0);
|
|
124
123
|
|
|
125
|
-
|
|
126
|
-
|
|
124
|
+
&--active {
|
|
125
|
+
transform: rotate(180deg);
|
|
126
|
+
}
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
129
|
}
|
|
@@ -22,16 +22,17 @@ export default class CSVExport {
|
|
|
22
22
|
|
|
23
23
|
downloadProgress = { count: 0 };
|
|
24
24
|
|
|
25
|
-
constructor(fetchMethod, { filename }) {
|
|
25
|
+
constructor(fetchMethod, { filename, delimiter }) {
|
|
26
26
|
if (!fetchMethod) throw new Error('fetch method should be specified!');
|
|
27
27
|
this.fetchMethod = fetchMethod;
|
|
28
28
|
this.filename = filename;
|
|
29
|
+
this.delimiter = delimiter || ',';
|
|
29
30
|
}
|
|
30
31
|
|
|
31
|
-
static _getStringifyOptions() {
|
|
32
|
+
static _getStringifyOptions(delimiter) {
|
|
32
33
|
const defaultOptions = {
|
|
33
34
|
header: true,
|
|
34
|
-
delimiter
|
|
35
|
+
delimiter,
|
|
35
36
|
};
|
|
36
37
|
const localStorageOptions = JSON.parse(localStorage.getItem('csv-export-options')) ||
|
|
37
38
|
{};
|
|
@@ -71,7 +72,7 @@ export default class CSVExport {
|
|
|
71
72
|
if (!columns.length && items.length) columns = Object.keys(items[0]);
|
|
72
73
|
|
|
73
74
|
const options = {
|
|
74
|
-
...CSVExport._getStringifyOptions(),
|
|
75
|
+
...CSVExport._getStringifyOptions(params.delimiter),
|
|
75
76
|
columns,
|
|
76
77
|
};
|
|
77
78
|
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import * as XLSX from 'xlsx';
|
|
2
|
+
import { saveAs } from 'file-saver-es';
|
|
3
|
+
|
|
4
|
+
export default class XLSExport {
|
|
5
|
+
filename = 'export';
|
|
6
|
+
|
|
7
|
+
fetchMethod = null;
|
|
8
|
+
|
|
9
|
+
downloadProgress = { count: 0 };
|
|
10
|
+
|
|
11
|
+
constructor(fetchMethod, { filename }) {
|
|
12
|
+
if (!fetchMethod) throw new Error('fetch method should be specified!');
|
|
13
|
+
this.fetchMethod = fetchMethod;
|
|
14
|
+
this.filename = filename;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
resetProgress() {
|
|
18
|
+
this.downloadProgress = { count: 0 };
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
save(data) {
|
|
22
|
+
const ws = XLSX.utils.json_to_sheet(data);
|
|
23
|
+
const wb = XLSX.utils.book_new();
|
|
24
|
+
XLSX.utils.book_append_sheet(wb, ws, 'Sheet1');
|
|
25
|
+
const wbout = XLSX.write(wb, { bookType: 'xlsx', type: 'array' });
|
|
26
|
+
const blob = new Blob([wbout], { type: 'application/octet-stream' });
|
|
27
|
+
saveAs(blob, `${this.filename}.xlsx`);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async export(params) {
|
|
31
|
+
let data = [];
|
|
32
|
+
let isNext = false;
|
|
33
|
+
let page = 1;
|
|
34
|
+
|
|
35
|
+
do {
|
|
36
|
+
const { items, next } = await this.fetchMethod({
|
|
37
|
+
...params,
|
|
38
|
+
page,
|
|
39
|
+
});
|
|
40
|
+
data = data.concat(items);
|
|
41
|
+
this.downloadProgress.count += items.length;
|
|
42
|
+
|
|
43
|
+
isNext = next;
|
|
44
|
+
page += 1;
|
|
45
|
+
} while (isNext);
|
|
46
|
+
|
|
47
|
+
this.save(data);
|
|
48
|
+
this.resetProgress();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import XLSExport from '../XLSExport.js';
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
data: () => ({
|
|
5
|
+
XLSExport: null,
|
|
6
|
+
}),
|
|
7
|
+
computed: {
|
|
8
|
+
isXLSLoading() {
|
|
9
|
+
return !!this.XLSDownloadProgress;
|
|
10
|
+
},
|
|
11
|
+
|
|
12
|
+
XLSDownloadProgress() {
|
|
13
|
+
return this.XLSExport ? this.XLSExport.downloadProgress.count : 0;
|
|
14
|
+
},
|
|
15
|
+
|
|
16
|
+
},
|
|
17
|
+
methods: {
|
|
18
|
+
initXLSExport(fetchMethod, options) {
|
|
19
|
+
this.XLSExport = new XLSExport(fetchMethod, options);
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
async exportXLS(exportParams) {
|
|
23
|
+
const routeQuery = this.$route?.query;
|
|
24
|
+
const params = {
|
|
25
|
+
...exportParams || routeQuery,
|
|
26
|
+
size: 5000,
|
|
27
|
+
};
|
|
28
|
+
if (this.isAnySelected) params.id = this.selectedIds;
|
|
29
|
+
|
|
30
|
+
try {
|
|
31
|
+
await this.XLSExport.export(params);
|
|
32
|
+
} catch (err) {
|
|
33
|
+
throw err;
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
|
|
37
|
+
},
|
|
38
|
+
};
|