Browse Source

分离导入清单的下载示例

vian 5 years ago
parent
commit
d0c1c959df

+ 7 - 3
modules/main/controllers/bills_controller.js

@@ -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);

public/static/uploadExample.xlsx → public/static/分部分项工程项目清单计价表.xlsx


BIN
public/static/算量示例-清单汇总表.xlsx


+ 1 - 1
web/building_saas/main/js/views/project_view.js

@@ -3168,7 +3168,7 @@ function doAfterImport(resData){
 }
 //下载导入清单示例文件
 $('#uploadExample').click(function () {
-    window.location.href = '/bills/downloadExamp';
+    window.location.href = `/bills/downloadExamp?type=${fileType}`;
 });
 
 $(function () {