فهرست منبع

Merge branch 'dev' of http://192.168.1.41:3000/maixinrong/Calculation into dev

MaiXinRong 4 سال پیش
والد
کامیت
119714b24f
3فایلهای تغییر یافته به همراه58 افزوده شده و 44 حذف شده
  1. 18 4
      app/public/js/stage.js
  2. 37 37
      app/service/stage_att.js
  3. 3 3
      app/view/stage/index.ejs

+ 18 - 4
app/public/js/stage.js

@@ -103,7 +103,7 @@ function initTreeColSettingEvents(setting) {
 // 生成所有附件列表
 function getAllList(currPageNum = 1) {
     // 每页最多几个附件
-    const pageCount = 11;
+    const pageCount = 15;
     // 附件总数
     const total = attData.length;
     // 总页数
@@ -115,7 +115,14 @@ function getAllList(currPageNum = 1) {
     let html = '';
     // '/tender/' + tender.id + '/measure/stage/' + stage.order + '/download/file/' + att.id
     for(const att of currPageAttData) {
-        html += `<tr><td width="25"><input type="checkbox" class="check-file" file-id=${att.id}></td><td><a href="javascript:void(0)" file-id=${att.id}>${att.filename}${att.fileext}</a></td><td width="50"><a href="/tender/${tender.id}/measure/stage/${stage.order}/download/file/${att.id}" class="att-file-btn">下载</a></td><td>${att.username}</td></td>`
+        html += `<tr>
+        <td width="25"><input type="checkbox" class="check-file" file-id=${att.id}></td>
+        <td>
+        <div class="d-flex">
+            <a href="javascript:void(0)" class="pl-0 col-11 att-file-name" file-id=${att.id}>${att.filename}${att.fileext}</a>
+            <a href="/tender/${tender.id}/measure/stage/${stage.order}/download/file/${att.id}" class="col-1 pl-0 att-file-btn"><i class="fa fa-download"></i></a>
+        </div>
+        </td><td>${att.username}</td></tr>`
     }
     $('#alllist-table').html(html);
     $('#alllist-table').on('click', 'tr', function() {
@@ -129,7 +136,14 @@ function getNodeList(node) {
     for(const att of attData) {
         if (node === att.lid) {
             // html += '<tr><td><a href="javascript:void(0)" file-id="'+ att.id +'">'+ att.filename + att.fileext +'</a></td><td>'+ att.username +'</td></tr>';
-            html += `<tr><td width="25"><input type="checkbox" class="check-file" file-id=${att.id}></td><td><a href="javascript:void(0)" file-id=${att.id}>${att.filename}${att.fileext}</a></td><td width="50"><a href="/tender/${tender.id}/measure/stage/${stage.order}/download/file/${att.id}" class="att-file-btn">下载</a></td><td>${att.username}</td></td>`
+            html += `<tr>
+            <td width="25"><input type="checkbox" class="check-file" file-id=${att.id}></td>
+            <td>
+            <div class="d-flex">
+                <a href="javascript:void(0)" class="pl-0 col-11 att-file-name" file-id=${att.id}>${att.filename}${att.fileext}</a>
+                <a href="/tender/${tender.id}/measure/stage/${stage.order}/download/file/${att.id}" class="col-1 pl-0 att-file-btn"><i class="fa fa-download"></i></a>
+            </div>
+            </td><td>${att.username}</td></tr>`
         }
     }
     $('#nodelist-table').html(html);
@@ -3147,7 +3161,7 @@ $(document).ready(() => {
     });
 
     // 获取附件信息
-    $('body').on('click', '.list-table a', function () {
+    $('body').on('click', '.list-table a.att-file-name', function () {
         console.log($(this))
         const fid = $(this).attr('file-id');
         if ($('#showAttachment').attr('file-id') === fid && !$('#showAttachment').is(":hidden")) {

+ 37 - 37
app/service/stage_att.js

@@ -8,7 +8,7 @@
  * @version
  */
 
-// const archiver = require('archiver');
+const archiver = require('archiver');
 const path = require('path');
 const fs = require('fs');
 module.exports = app => {
@@ -100,44 +100,44 @@ module.exports = app => {
          * @return {string} 压缩后的zip文件路径
          */
         async compressedFile(fileIds, zipPath) {
-            // this.initSqlBuilder();
-            // this.sqlBuilder.setAndWhere('id', {
-            //     value: fileIds,
-            //     operate: 'in',
-            // });
-            // const [sql, sqlParam] = this.sqlBuilder.build(this.tableName);
-            // const files = await this.db.query(sql, sqlParam);
-            // // const paths = files.map(item => {
-            // //     return { name: item.filename + item.fileext, path: item.filepath }
-            // // })
-            // return new Promise(resolve => {
-            //     // 每次开一个新的archiver
-            //     const ziparchiver = archiver('zip');
-            //     const outputPath = fs.createWriteStream(path.resolve(this.app.baseDir, zipPath));
-            //     ziparchiver.pipe(outputPath);
-            //     files.forEach(item => {
-            //         ziparchiver.file(item.filepath, { name: item.filename + item.fileext });
-            //     });
+            this.initSqlBuilder();
+            this.sqlBuilder.setAndWhere('id', {
+                value: fileIds,
+                operate: 'in',
+            });
+            const [sql, sqlParam] = this.sqlBuilder.build(this.tableName);
+            const files = await this.db.query(sql, sqlParam);
+            // const paths = files.map(item => {
+            //     return { name: item.filename + item.fileext, path: item.filepath }
+            // })
+            return new Promise(resolve => {
+                // 每次开一个新的archiver
+                const ziparchiver = archiver('zip');
+                const outputPath = fs.createWriteStream(path.resolve(this.app.baseDir, zipPath));
+                ziparchiver.pipe(outputPath);
+                files.forEach(item => {
+                    ziparchiver.file(item.filepath, { name: item.filename + item.fileext });
+                });
 
-            //     // 存档警告
-            //     ziparchiver.on('warning', function(err) {
-            //         if (err.code === 'ENOENT') {
-            //             console.warn('stat故障和其他非阻塞错误');
-            //         } else {
-            //             throw err;
-            //         }
-            //     });
+                // 存档警告
+                ziparchiver.on('warning', function(err) {
+                    if (err.code === 'ENOENT') {
+                        console.warn('stat故障和其他非阻塞错误');
+                    } else {
+                        throw err;
+                    }
+                });
 
-            //     // 存档出错
-            //     ziparchiver.on('error', function(err) {
-            //         console.log(err);
-            //         throw err;
-            //     });
-            //     ziparchiver.finalize();
-            //     outputPath.on('close', () => {
-            //         resolve(ziparchiver.pointer());
-            //     });
-            // });
+                // 存档出错
+                ziparchiver.on('error', function(err) {
+                    console.log(err);
+                    throw err;
+                });
+                ziparchiver.finalize();
+                outputPath.on('close', () => {
+                    resolve(ziparchiver.pointer());
+                });
+            });
         }
     }
     return StageAtt;

+ 3 - 3
app/view/stage/index.ejs

@@ -265,7 +265,7 @@
                                 <li class="nav-item">
                                     <a class="nav-link" data-toggle="tab" href="#syfujian" role="tab" fujian-content="syfujian">所有附件</a>
                                 </li>
-                                <li class="nav-item ml-auto">
+                                <li class="nav-item ml-auto pt-1">
                                     <a href="javascript:void(0);" id="bach-download" class="btn btn-sm btn-primary mr-3">批量下载</a>
                                     <!--所有附件 翻页-->
                                     <span id="showPage" style="display: none"><a href="javascript:void(0);" class="page-select" content="pre"><i class="fa fa-chevron-left"></i></a> <span id="currentPage">1</span>/<span id="totalPage">10</span> <a href="javascript:void(0);" class="page-select" content="next"><i class="fa fa-chevron-right"></i></a></span>
@@ -278,7 +278,7 @@
                             <div class="tab-pane active" id="dqjiedian">
                                 <div class="sjs-height-3" style="overflow:auto; overflow-x:hidden;">
                                     <table class="table table-sm table-bordered table-hover" style="word-break:break-all; table-layout: fixed">
-                                        <tr><th width="25"><input type="checkbox" class="check-all-file"><th>文件名</th><th width="50">下载</th><th width="80">上传</th></tr>
+                                        <tr><th width="25"><input type="checkbox" class="check-all-file"><th>文件名</th><th width="80">上传</th></tr>
                                         <tbody id="nodelist-table" class="list-table">
                                         </tbody>
                                     </table>
@@ -287,7 +287,7 @@
                             <div class="tab-pane" id="syfujian">
                                 <div class="sjs-height-3" style="overflow:auto; overflow-x:hidden;">
                                     <table class="table table-sm table-bordered table-hover" style="word-break:break-all; table-layout: fixed">
-                                        <tr><th width="25"><input type="checkbox" class="check-all-file"></th><th>文件名</th><th width="50">下载</th><th width="80">上传</th></tr>
+                                        <tr><th width="25"><input type="checkbox" class="check-all-file"></th><th>文件名</th><th width="80">上传</th></tr>
                                         <tbody id="alllist-table" class="list-table">
                                         </tbody>
                                     </table>