|
@@ -193,14 +193,18 @@ module.exports = {
|
|
|
res.json(result);
|
|
|
},
|
|
|
//下载导入清单示例
|
|
|
- downloadExample: async function(request, response) {
|
|
|
+ downloadExample: function(request, response) {
|
|
|
try {
|
|
|
- const filePath = './public/static/uploadExample.xlsx';
|
|
|
+ //导入类型(09表、广联达)对应的示例文件名
|
|
|
+ const uploadTypeMap = { lj: '分部分项工程项目清单计价表.xlsx', gld: '算量示例-清单汇总表.xlsx' };
|
|
|
+ const type = request.query.type;
|
|
|
+ const fileName = uploadTypeMap[type];
|
|
|
+ const filePath = `./public/static/${fileName}`;
|
|
|
const stats = fs.statSync(filePath);
|
|
|
// 下载相关header
|
|
|
response.set({
|
|
|
'Content-Type': 'application/octet-stream',
|
|
|
- 'Content-Disposition': 'attachment; filename=uploadExample.xlsx',
|
|
|
+ 'Content-Disposition': `attachment; filename=${encodeURI(fileName)}`,
|
|
|
'Content-Length': stats.size
|
|
|
});
|
|
|
fs.createReadStream(filePath).pipe(response);
|