flameresttable 1.0.40 → 1.0.42
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/package.json
CHANGED
package/src/Table/FlameTable.ts
CHANGED
|
@@ -119,6 +119,8 @@ export default class FlameTable<T> {
|
|
|
119
119
|
*/
|
|
120
120
|
public load(rows: Rows<T>) {
|
|
121
121
|
|
|
122
|
+
rows.pages = rows.pages ?? { count: 0, page: 1, perPage: 1, total: 0 };
|
|
123
|
+
|
|
122
124
|
if (rows.data) {
|
|
123
125
|
this.Rows.rows = (rows.data ?? []) as any;
|
|
124
126
|
Object.keys(this.Pager).forEach((key) => (this.Pager as any)[key] = (rows.pages as any)[key])
|
|
@@ -132,10 +134,13 @@ export default class FlameTable<T> {
|
|
|
132
134
|
delete this.RowsParams[key];
|
|
133
135
|
|
|
134
136
|
// Заполняем параметры каждой строки
|
|
135
|
-
this.
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
137
|
+
const pk = (this.model as any).constructor.primaryKeys[0];
|
|
138
|
+
this.Rows.rows.forEach((row: any) => {
|
|
139
|
+
if (typeof this.RowsParams[row[pk]] === 'undefined') {
|
|
140
|
+
const newParam = new TableRowParams;
|
|
141
|
+
newParam.item = row;
|
|
142
|
+
this.RowsParams[row[pk]] = newParam;
|
|
143
|
+
}
|
|
139
144
|
})
|
|
140
145
|
}
|
|
141
146
|
|
|
@@ -201,14 +206,29 @@ export default class FlameTable<T> {
|
|
|
201
206
|
* Обновить результаты от RESTа
|
|
202
207
|
* @param CustomLoadParams Применить кастомные параметры загрузки
|
|
203
208
|
*/
|
|
204
|
-
public async update(CustomLoadParams: ITableLoadParams = {}) {
|
|
209
|
+
public async update(CustomLoadParams: ITableLoadParams = {}, isFile = false) {
|
|
205
210
|
|
|
206
211
|
// Дополняем загрузочные параметры фильтрами
|
|
207
212
|
const filters = merge(this.applyFiltersParams(), CustomLoadParams);
|
|
208
213
|
|
|
209
214
|
const rows: Rows<T> = await (this.model as any).constructor.all(merge({}, this.opts.LoadParams, filters, { page: this.Pager.page, perPage: this.Pager.perPage }));
|
|
210
215
|
|
|
211
|
-
|
|
216
|
+
if (!isFile)
|
|
217
|
+
|
|
218
|
+
// Строки: загружаем
|
|
219
|
+
this.load(rows);
|
|
220
|
+
|
|
221
|
+
else {
|
|
222
|
+
// Файл: скачиваем
|
|
223
|
+
const url = window.URL.createObjectURL((rows as any).data);
|
|
224
|
+
const a = document.createElement('a');
|
|
225
|
+
a.href = url;
|
|
226
|
+
a.download = 'file.xlsx';
|
|
227
|
+
document.body.appendChild(a);
|
|
228
|
+
a.click();
|
|
229
|
+
window.URL.revokeObjectURL(url);
|
|
230
|
+
document.body.removeChild(a);
|
|
231
|
+
}
|
|
212
232
|
|
|
213
233
|
}
|
|
214
234
|
|
|
@@ -470,7 +490,7 @@ export default class FlameTable<T> {
|
|
|
470
490
|
}
|
|
471
491
|
|
|
472
492
|
// Делаем запрос на отдачу
|
|
473
|
-
this.update(customFilter);
|
|
493
|
+
this.update(customFilter, true);
|
|
474
494
|
|
|
475
495
|
}
|
|
476
496
|
|
|
@@ -112,15 +112,17 @@ const selectAction = () => {
|
|
|
112
112
|
|
|
113
113
|
switch (state.selectModel) {
|
|
114
114
|
case 0:
|
|
115
|
-
|
|
115
|
+
break;
|
|
116
116
|
case 1:
|
|
117
117
|
|
|
118
|
-
|
|
118
|
+
break;
|
|
119
119
|
case 2:
|
|
120
120
|
state.Table.exportToXLS();
|
|
121
|
-
|
|
121
|
+
break;
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
+
state.selectModel = 0;
|
|
125
|
+
|
|
124
126
|
}
|
|
125
127
|
|
|
126
128
|
</script>
|