Ver código fonte

中间计量,附件,批量下载

MaiXinRong 2 anos atrás
pai
commit
0f5e537d12

+ 29 - 2
app/public/js/stage.js

@@ -2846,7 +2846,7 @@ $(document).ready(() => {
                         : '';
                     const viewHtml = att.viewpath ? `<a class="ml-1" href="${att.viewpath}" target="_blank" title="预览"><i class="fa fa-eye"></i></a>` : '';
                     const downloadHtml = '<a href="'+ window.location.pathname + '/im-file/download?im_id='+ data.att_uuid +'&file_id='+ att.file_id +'" title="下载"><i class="fa fa-download "></i></a>';
-                    html.push('<tr><td style="width: 200px">' + att.filename + att.fileext + '</td><td>' + att.username + '</td><td>' + att.in_time + '</td>',
+                    html.push(`<tr><td><input type="checkbox" name="sia-check" fid="${att.file_id}"></td><td style="width: 200px">` + att.filename + att.fileext + '</td><td>' + att.username + '</td><td>' + att.in_time + '</td>',
                         '<td>', downloadHtml, viewHtml, delHtml, '</td></tr>');
                 }
             }
@@ -2932,7 +2932,34 @@ $(document).ready(() => {
                     $('#load-file').attr('href', filepath);
                     $('#load-file')[0].click();
                 });
-            })
+            });
+            $('#batch-download-im-file').click(function() {
+                const select = $('[name=sia-check]:checked');
+                if (select.length === 0) {
+                    toastr.warning('请选择需要批量下载的文件');
+                    return;
+                }
+
+                const files = [];
+                const curIm = SpreadJsObj.getSelectObject(self.sheet);
+                for (const s of select) {
+                    const att = curIm.attachment.find(x => { return x.file_id === s.getAttribute('fid')});
+                    if (att) files.push(att);
+                }
+                if (files.length === 0) return;
+
+                AliOss.zipFiles(files, `中间计量[${curIm.code}].zip`, (fails) => {
+                    $(self).removeAttr('disabled');
+                    if (fails.length === 0) {
+                        toastr.success('下载成功');
+                    } else {
+                        toastr.warning(`下载成功(${fails.length}个文件下载失败)`);
+                    }
+                }, () => {
+                    $(self).removeAttr('disabled');
+                    toastr.error('批量下载失败');
+                });
+            });
         }
         _initImTypeSetRela() {
             const self = this;

+ 1 - 1
app/service/stage_detail_att.js

@@ -76,7 +76,7 @@ module.exports = app => {
                         // a.viewpath = a.filepath.replace(/^app|\/app/, '');
                         a.viewpath = this.ctx.app.config.fujianOssPath + a.filepath;
                     }
-                    delete a.filepath;
+                    a.filepath = this.ctx.app.config.fujianOssPath + a.filepath;
                     a.username = (await this.getUserTemp(a.uid)).name;
                 }
             }

+ 7 - 2
app/view/stage/modal.ejs

@@ -626,13 +626,18 @@
                 <div class="form-group">
                     <% if (!ctx.tender.isTourist || (ctx.tender.isTourist && ctx.tender.touristPermission.file) || stage.filePermission) { %>
                     <label for="formGroupExampleInput">单个文件大小限制:30MB,支持<span data-toggle="tooltip" data-placement="bottom" title="doc,docx,xls,xlsx,ppt,pptx,pdf">office等文档格式</span>、<span data-toggle="tooltip" data-placement="bottom" title="jpg,png,bmp">图片格式</span>、<span data-toggle="tooltip" data-placement="bottom" title="rar,zip">压缩包格式</span></label>
-                    <input type="file" class="" id="upload-im-file" multiple>
                     <% } %>
+                    <div class="d-flex">
+                        <% if (!ctx.tender.isTourist || (ctx.tender.isTourist && ctx.tender.touristPermission.file) || stage.filePermission) { %>
+                        <input type="file" class="" id="upload-im-file" multiple>
+                        <% } %>
+                        <div class="ml-auto"><button class="btn btn-sm btn-primary" id="batch-download-im-file">批量下载</button></div>
+                    </div>
                 </div>
                 <div class="modal-height-500" style="overflow:auto;">
                     <table class="table table-sm table-bordered" style="word-break:break-all; table-layout: fixed">
                         <thead>
-                        <tr><th width="240">文件名</th><th>上传人</th><th>上传时间</th><th width="52">操作</th></tr>
+                        <tr><th width="40px">选择</th><th width="200">文件名</th><th>上传人</th><th>上传时间</th><th width="52">操作</th></tr>
                         </thead>
                         <tbody id="im-attList">
                         </tbody>

+ 2 - 2
config/menu.js

@@ -31,7 +31,7 @@ const menu = {
         display: true,
         url: '/list',
         children: null,
-        caption: '项目',
+        caption: '标段管理',
     },
     sub_project: {
         name: '项目管理',
@@ -43,7 +43,7 @@ const menu = {
     },
     file: {
         name: '资料归集',
-        icon: 'fa-credit-card',
+        icon: 'fa-file-zip-o',
         display: true,
         url: '/file',
         children: null,

+ 1 - 0
config/web.js

@@ -356,6 +356,7 @@ const JsFiles = {
                     '/public/js/zh_calc.js',
                     '/public/js/path_tree.js',
                     '/public/js/zip_oss.js',
+                    '/public/js/shares/ali_oss.js',
                     '/public/js/stage_im.js',
                     '/public/js/shares/tenders2tree.js',
                     '/public/js/shares/tender_select.js',