Commit 84d95ecf authored by Samir Sadyhov's avatar Samir Sadyhov 🤔

записи реестра - триггер выгрузки записей в excel

parent 476e20f3
...@@ -622,37 +622,47 @@ compContainer.off() ...@@ -622,37 +622,47 @@ compContainer.off()
registryTable.filterSearchUrl = filterSearchUrl; registryTable.filterSearchUrl = filterSearchUrl;
Paginator.currentPage = 1; Paginator.currentPage = 1;
registryTable.createBody(); registryTable.createBody();
}); }).on('getXLS', e => {
if($('#button-print-report').length) { Cons.showLoader();
$('#button-print-report').off().on('click', e => {
e.preventDefault(); let url = registryTable.getUrl(true);
e.target.blur(); url += `&pageNumber=1&countInPart=1&loadData=false`;
if(registryTable.searchString || registryTable.filterSearchUrl || registryTable.searchField) {
Cons.showLoader(); rest.synergyGet(url, part => {
rest.synergyGet(registryTable.getUrl(true), data => { Cons.hideLoader();
let excelData = [];
data.result.forEach(res => { UIkit.modal.confirm(`Вы собираетесь выгрузить ${part.count} записей. Продолжить?`,
let tmpValues = {}; {labels: {ok: i18n.tr('Да'), cancel: i18n.tr('Отмена')}})
registryTable.heads.forEach(col => tmpValues[col.label] = res.fieldValue[col.columnID] || ""); .then(() => {
excelData.push(tmpValues);
if(registryTable.searchString || registryTable.filterSearchUrl || registryTable.searchField) {
Cons.showLoader();
rest.synergyGet(registryTable.getUrl(true), data => {
let excelData = [];
data.result.forEach(res => {
let tmpValues = {};
registryTable.heads.forEach(col => tmpValues[col.label] = res.fieldValue[col.columnID] || "");
excelData.push(tmpValues);
});
try {
let opts = {headers: true, column: {style:{Font:{Bold:"1"}}}};
let result = alasql(`SELECT * INTO XLS("${registryTable.registryName}_${formatDate()}.xls",?) FROM ?`, [opts, excelData]);
Cons.hideLoader();
} catch (e) {
console.log(e.message);
Cons.hideLoader();
showMessage(i18n.tr('Произошла ошибка при выгрузке записей реестра'), 'error');
}
}); });
} else {
getSystemReport();
}
try { }, () => null);
let opts = {headers: true, column: {style:{Font:{Bold:"1"}}}};
let result = alasql(`SELECT * INTO XLS("${registryTable.registryName}_${formatDate()}.xls",?) FROM ?`, [opts, excelData]); //XLSXML ломается, скорее всего где-то косяк в данных
Cons.hideLoader();
} catch (e) {
console.log(e.message);
Cons.hideLoader();
showMessage(i18n.tr('Произошла ошибка при выгрузке отчета'), 'error');
}
});
} else {
getSystemReport();
}
}); });
} });
$(document).off() $(document).off()
.on('contextmenu', () => $('.exp-context-menu').remove()) .on('contextmenu', () => $('.exp-context-menu').remove())
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment