Добавлена функция сохранения истории обработки территорий
This commit is contained in:
32
api/controllers/generator.report.territories.controller.js
Normal file
32
api/controllers/generator.report.territories.controller.js
Normal file
@@ -0,0 +1,32 @@
|
||||
const getTable = require("../middleware/genReportTerritories");
|
||||
|
||||
class generatorReportTerritoriesController {
|
||||
async getTable(req, res) {
|
||||
if (req.possibilities.can_add_territory) {
|
||||
let result = await getTable();
|
||||
|
||||
if (result) {
|
||||
res.setHeader(
|
||||
'Content-Disposition',
|
||||
`attachment; filename*=UTF-8''${encodeURIComponent('Опрацювання_територій.xlsx')}`
|
||||
);
|
||||
res.setHeader(
|
||||
'Content-Type',
|
||||
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
|
||||
);
|
||||
return res.status(200).send(result);
|
||||
} else {
|
||||
return res
|
||||
.status(404)
|
||||
.send({ message: 'Table creation error.' });
|
||||
}
|
||||
} else {
|
||||
return res
|
||||
.status(403)
|
||||
.send({ message: 'The user does not have enough rights.' });
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = new generatorReportTerritoriesController();
|
||||
Reference in New Issue
Block a user