|
@@ -1,10 +1,8 @@
|
|
|
import BaseController from "../../common/base/base_controller";
|
|
|
-import CompilationModel from '../../users/models/compilation_model';
|
|
|
-const multiparty = require('multiparty');
|
|
|
-const excel = require('node-xlsx');
|
|
|
-const fs = require('fs');
|
|
|
const facade = require('../facade/index');
|
|
|
const config = require("../../../config/config.js");
|
|
|
+const excel = require('node-xlsx');
|
|
|
+const fs = require('fs');
|
|
|
|
|
|
class PriceInfoSummaryController extends BaseController {
|
|
|
async main(req, res) {
|
|
@@ -52,6 +50,26 @@ class PriceInfoSummaryController extends BaseController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ async exportSummaryData(request, response) {
|
|
|
+ try {
|
|
|
+ const excelData = await facade.exportExcelData();
|
|
|
+ const buffer = excel.build([{ name: "材料信息价总表", data: excelData }]);
|
|
|
+ const filePath = './public/exportPriceSummary.xlsx';
|
|
|
+ fs.writeFileSync(filePath, buffer, 'binary');
|
|
|
+ const stats = fs.statSync(filePath);
|
|
|
+ // 下载相关header
|
|
|
+ response.set({
|
|
|
+ 'Content-Type': 'application/octet-stream',
|
|
|
+ 'Content-Disposition': 'attachment; filename=infoPriceSummary.xlsx',
|
|
|
+ 'Content-Length': stats.size
|
|
|
+ });
|
|
|
+ fs.createReadStream(filePath).pipe(response);
|
|
|
+ fs.unlink(filePath);
|
|
|
+ } catch (error) {
|
|
|
+ response.end(error);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
module.exports = {
|