Просмотр исходного кода

计量台账,附件改版&上传大文件

MaiXinRong 3 дней назад
Родитель
Сommit
3c6bc11a62

+ 41 - 0
app/controller/stage_controller.js

@@ -2529,6 +2529,47 @@ module.exports = app => {
             }
         }
 
+
+        async uploadBigFile(ctx) {
+            try {
+                const data = JSON.parse(ctx.request.body.data);
+                if (!data.type || !data.lid || !data.fileInfo) throw '缺少参数';
+
+                let result;
+                const fileInfo = path.parse(data.fileInfo.filename);
+                switch(data.type) {
+                    case 'begin':
+                        const create_time = Date.parse(new Date()) / 1000;
+                        result = {
+                            filename: `app/public/upload/${this.ctx.tender.id}/stage/fujian_${create_time + fileInfo.ext}`,
+                        };
+                        result.filepath = ctx.app.config.fujianOssFolder + result.filename;
+                        result.oss = await ctx.helper.getOssToken(ctx.app.fujianOss);
+                        break;
+                    case 'end':
+                        const user = await ctx.service.projectAccount.getDataById(ctx.session.sessionUser.accountId);
+                        const extra_upload = ctx.stage.status === auditConst.status.checked;
+                        const fileData = {
+                            tid: ctx.params.id, sid: ctx.params.order,
+                            in_time: Date.parse(new Date()) / 1000,
+                            filepath: data.filepath,
+                            filename: fileInfo.name, fileext: fileInfo.ext, filesize: data.fileInfo.filesize,
+                            extra_upload,
+                        };
+                        result = await ctx.service.stageAtt.save({ lid: data.lid}, fileData, ctx.session.sessionUser.accountId);
+                        if (!result) {
+                            throw '导入数据库保存失败';
+                        }
+                        result = await ctx.service.stageAtt.getDataByFid(result.insertId);
+                        result = [result];
+                        break;
+                }
+                ctx.body = {err: 0, msg: '', data: result };
+            } catch (error) {
+                ctx.log(error);
+                ctx.body = this.ajaxErrorBody(error, '上传附件失败,请重试');
+            }
+        }
     }
 
     return StageController;

+ 37 - 355
app/public/js/stage.js

@@ -107,66 +107,6 @@ function initTreeColSettingEvents(setting) {
     }
 }
 
-// 生成所有附件列表
-function getAllList(currPageNum = 1) {
-    // 每页最多几个附件
-    const pageCount = 20;
-    // 附件总数
-    const total = attData.length;
-    // 总页数
-    const pageNum = Math.ceil(total/pageCount);
-    $('#totalPage').text(pageNum);
-    $('#currentPage').text(total === 0 ? 0 : currPageNum);
-    // 当前页附件内容
-    const currPageAttData = attData.slice((currPageNum-1)*pageCount, currPageNum*pageCount);
-    currPageFileData = currPageAttData;
-    let html = '';
-    // '/tender/' + tender.id + '/measure/stage/' + stage.order + '/download/file/' + att.id
-    for(const att of currPageAttData) {
-        const delHtml = deleteFilePermission && parseInt(cur_uid) === att.uid
-            ? `<a class="ml-1 text-danger" href="javascript:void(0)" name="att-delete" file-id="${att.id}"><i class="fa fa-close" title="删除"></i></a>`
-            : '';
-        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-10 att-file-name" file-id=${att.id}>${att.filename}${att.fileext}</a>
-            <div class="att-file-btn col-2"><a href="/tender/${tender.id}/measure/stage/${stage.order}/download/file/${att.id}" class="pl-0"><i class="fa fa-download"></i></a>${delHtml}</div>
-        </div>
-        </td><td>${att.username}</td></tr>`
-    }
-    $('#alllist-table').html(html);
-    $('#alllist-table').on('click', 'tr', function() {
-        $('#alllist-table tr').removeClass('bg-light')
-        $(this).addClass('bg-light')
-    });
-}
-// 生成当前节点列表
-function getNodeList(node) {
-    let html = '';
-    for(const att of attData) {
-        if (node === att.lid) {
-            const delHtml = deleteFilePermission && parseInt(cur_uid) === att.uid
-                ? `<a class="ml-1 text-danger" href="javascript:void(0)" name="att-delete" file-id="${att.id}"><i class="fa fa-close" title="删除"></i></a>`
-                : '';
-            // 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>
-            <div class="d-flex">
-                <a href="javascript:void(0)" class="pl-0 col-10 att-file-name" file-id=${att.id}>${att.filename}${att.fileext}</a>
-                <div class="att-file-btn col-2"><a href="/tender/${tender.id}/measure/stage/${stage.order}/download/file/${att.id}" class="pl-0"><i class="fa fa-download"></i></a>${delHtml}</div>
-            </div>
-            </td><td>${att.username}</td></tr>`
-        }
-    }
-    $('#nodelist-table').html(html);
-    $('#nodelist-table').on('click', 'tr', function() {
-        $('#nodelist-table tr').removeClass('bg-light');
-        $(this).addClass('bg-light');
-    })
-}
-
 function getGxbyText(data) {
     const def = thirdParty.gxby.find(function (x) {
         return x.value === data.gxby_status;
@@ -857,9 +797,6 @@ $(document).ready(() => {
     };
     SpreadJsObj.initSheet(slSpread.getActiveSheet(), ledgerSpreadSetting);
 
-    //初始化所有附件列表
-    getAllList();
-
     // 初始化 计量单元 Spread
     const spSpread = SpreadJsObj.createNewSpread($('#stage-pos')[0]);
     const spSheet = spSpread.getActiveSheet();
@@ -1122,6 +1059,7 @@ $(document).ready(() => {
             SpreadJsObj.resetTopAndSelect(posSheet);
             stagePosSpreadObj.loadCurPosData();
             if (posSearch) posSearch.search();
+            stageFile.getCurAttHtml(SpreadJsObj.getSelectObject(billsSheet));
         },
         selectionChanged: function (e, info) {
             if (!info.oldSelections || !info.oldSelections[0] || info.newSelections[0].row !== info.oldSelections[0].row) {
@@ -2251,7 +2189,6 @@ $(document).ready(() => {
                     }
                 });
                 SpreadJsObj.loadSheetData(spSpread.getActiveSheet(), 'data', posData, posReadOnly);
-                getNodeList(node.id);
             } else {
                 spSpread.getActiveSheet().zh_setting.readOnly = true;
                 SpreadJsObj.loadSheetData(spSpread.getActiveSheet(), 'data', [], true);
@@ -2783,6 +2720,12 @@ $(document).ready(() => {
         ledgerData = result.ledgerData;
         posData = result.posData;
         makeShouFang();
+
+        for (const r of attData) {
+            r.node = stageTree.datas.find(x => {return x.id === r.lid});
+        }
+        stageFile.loadDatas(attData);
+        stageFile.getCurAttHtml(SpreadJsObj.getSelectObject(slSheet));
     }, null, true);
     spSpread.bind(spreadNS.Events.EditEnded, stagePosSpreadObj.editEnded);
     spSpread.bind(spreadNS.Events.ClipboardPasting, stagePosSpreadObj.clipboardPasting);
@@ -3971,7 +3914,7 @@ $(document).ready(() => {
                 const select = SpreadJsObj.getSelectObject(self.spread.getActiveSheet());
                 if (select && select.source) {
                     SpreadJsObj.locateTreeNode(slSpread.getActiveSheet(), select.source[curIndex-1].id, true);
-                    stagePosSpreadObj.loadCurPosData();
+                    stageTreeSpreadObj.loadRelaData();
                     if (select.source[curIndex-1].pos_id) {
                         SpreadJsObj.locateDataBy(spSpread.getActiveSheet(), function(data){ return data.id === select.source[curIndex-1].pos_id});
                     }
@@ -3983,7 +3926,7 @@ $(document).ready(() => {
                 if (select && select.source) {
                     const targetIndex = Math.max(curIndex-1, 1);
                     SpreadJsObj.locateTreeNode(slSpread.getActiveSheet(), select.source[targetIndex-1].id, true);
-                    stagePosSpreadObj.loadCurPosData();
+                    stageTreeSpreadObj.loadRelaData();
                     $('#im-locate-info')[0].innerText = targetIndex + '/' + select.source.length;
                 }
             });
@@ -3993,7 +3936,7 @@ $(document).ready(() => {
                 if (select && select.source) {
                     const targetIndex = Math.min(curIndex+1, select.source.length);
                     SpreadJsObj.locateTreeNode(slSpread.getActiveSheet(), select.source[targetIndex-1].id, true);
-                    stagePosSpreadObj.loadCurPosData();
+                    stageTreeSpreadObj.loadRelaData();
                     $('#im-locate-info')[0].innerText = targetIndex + '/' + select.source.length;
                 }
 
@@ -4581,7 +4524,7 @@ $(document).ready(() => {
 
                                     SpreadJsObj.locateTreeNode(slSpread.getActiveSheet(), changeBills.pos[0].ledger_id, true);
                                     SpreadJsObj.resetTopAndSelect(spSpread.getActiveSheet());
-                                    stagePosSpreadObj.loadCurPosData();
+                                    stageTreeSpreadObj.loadRelaData();
                                 }
                             } else if (changeBills.gcl_id) {
                                 const node = stageTree.nodes.find(x => {return x.id === changeBills.gcl_id});
@@ -4589,7 +4532,7 @@ $(document).ready(() => {
 
                                 SpreadJsObj.locateTreeNode(slSpread.getActiveSheet(), node.ledger_id, true);
                                 SpreadJsObj.resetTopAndSelect(spSpread.getActiveSheet());
-                                stagePosSpreadObj.loadCurPosData();
+                                stageTreeSpreadObj.loadRelaData();
                                 const posData = spSpread.getActiveSheet().zh_data;
                                 if (!posData || posData.length === 0) return;
 
@@ -4615,7 +4558,7 @@ $(document).ready(() => {
                                     if (_.isMatch(cb, b)) {
                                         SpreadJsObj.locateTreeNode(slSpread.getActiveSheet(), node.ledger_id);
                                         SpreadJsObj.resetTopAndSelect(spSpread.getActiveSheet());
-                                        stagePosSpreadObj.loadCurPosData();
+                                        stageTreeSpreadObj.loadRelaData();
                                         return;
                                     }
                                 }
@@ -4877,6 +4820,29 @@ $(document).ready(() => {
         }
     }
     // 展开收起附件
+    const stageFile = $.ledger_att({
+        selector: '#fujian',
+        key: 'id',
+        masterKey: 'lid',
+        uploadUrl: window.location.pathname + '/upload/file',
+        deleteUrl: window.location.pathname + '/delete/file',
+        uploadBigUrl: window.location.pathname + '/file/upload/big',
+        checked: stageComplete,
+        zipName: `${tender.name}-附件.zip`,
+        readOnly: false,
+        bigValid: true,
+        // fileInfo: {
+        //     user_name: 'user_name',
+        //     user_id: 'uid',
+        //     create_time: 'in_time',
+        // },
+        getCurHint: function(node) { return ''; },
+        locate: function (att) {
+            if (!att) return;
+            SpreadJsObj.locateDataBy(slSheet, function(x) { return x.id === att.node.id; });
+            stageFile.getCurAttHtml(att.node);
+        }
+    });
     $('a', '.right-nav').bind('click', function () {
         //const main = $('#main-view'), tool = $('#tools-view');
         const tab = $(this), tabPanel = $(tab.attr('content'));
@@ -4965,10 +4931,6 @@ $(document).ready(() => {
                 });
                 searchLedger.spread.refresh();
             }
-            if (tab.attr('content') === '#fujian') {
-                const node = SpreadJsObj.getSelectObject(slSpread.getActiveSheet());
-                node && getNodeList(node.id);
-            }
             if (tab.attr('content') === '#zhongjian') {
                 if (!detail) {
                     detail = new Detail($('#detail-spread'));
@@ -5021,43 +4983,6 @@ $(document).ready(() => {
         }
         $('#showAttachment').hide();
     });
-    // 上传附件
-    $('#upload-file-btn').click(function () {
-        const node = SpreadJsObj.getSelectObject(slSpread.getActiveSheet());
-        if (!node) return
-        const files = $('#upload-file')[0].files;
-        const formData = new FormData();
-        formData.append('lid', node.id);
-        for (const file of files) {
-            if (file === undefined) {
-                toastr.error('未选择上传文件!');
-                return false;
-            }
-            const filesize = file.size;
-            if (filesize > 50 * 1024 * 1024) {
-                toastr.error('存在上传文件大小过大!');
-                return false;
-            }
-            const fileext = '.' + file.name.toLowerCase().split('.').splice(-1)[0];
-            if (whiteList.indexOf(fileext) === -1) {
-                toastr.error('只能上传指定格式的附件!');
-                return false;
-            }
-            formData.append('size', filesize);
-            formData.append('file[]', file);
-        }
-        postDataWithFile('/tender/' + tender.id + '/measure/stage/' + stage.order + '/upload/file', formData, function (data) {
-            $('#upload').modal('hide');
-            // 插入到attData中
-            attData = data.concat(attData);
-            // 重新生成List
-            getAllList();
-            getNodeList(node.id);
-        }, function () {
-            toastr.error('附件上传失败');
-        });
-        $('#upload-file').val('');
-    });
 
     // 获取附件信息
     $('.list-table').on('click', '.att-file-name', function () {
@@ -5105,221 +5030,6 @@ $(document).ready(() => {
             toastr.error('附件信息获取失败');
         }
     });
-    // $('body').on('click', '.alllist-table a', handleFileList);
-    $('body').on('click', '#btn-att a', function () {
-        const content = $(this).attr('content');
-        const fid = $('#showAttachment').attr('file-id');
-        const node = SpreadJsObj.getSelectObject(slSpread.getActiveSheet());
-        if (content === 'edit') {
-            $('#btn-att a').eq(3).hide();
-            $('#btn-att a').eq(2).show();
-            $('#btn-att a').eq(4).show();
-            $('#btn-att a').eq(5).show();
-            $('#show-att').hide();
-            $('#edit-att').show();
-            const att = attData.find(function (item) {
-                return item.id === parseInt(fid);
-            });
-            $('#edit-att .form-group').eq(0).find('input').val(att.filename);
-            $('#edit-att .form-group').eq(0).find('span').eq(1).text(att.fileext);
-            const name = att.code !== null && att.code !== '' ? att.code : (att.b_code !== null ? att.b_code : '');
-            $('#edit-att .form-group').eq(1).find('input').val($.trim(name + ' ' + att.lname));
-            $('#edit-att .form-group').eq(2).find('input').val(att.in_time);
-            $('#edit-att .form-group').eq(3).find('input').val(att.remark);
-        } else if (content === 'cancel') {
-            $('#show-att').show();
-            $('#edit-att').hide();
-            $('#btn-att a').eq(3).show();
-            $('#btn-att a').eq(2).hide();
-            $('#btn-att a').eq(4).hide();
-            $('#btn-att a').eq(5).hide();
-        } else if (content === 'save') {
-            const formData = new FormData();
-            formData.append('id', fid);
-            formData.append('filename', $('#edit-att .form-group').eq(0).find('input').val());
-            formData.append('fileext', $('#edit-att .form-group').eq(0).find('span').eq(1).text());
-            formData.append('remark', $('#edit-att .form-group').eq(3).find('input').val());
-            const file = $('#change-att-btn')[0];
-            if (file.files[0] !== undefined) {
-                const filesize = file.files[0].size;
-                formData.append('size', filesize);
-                formData.append('file', file.files[0]);
-            }
-            postDataWithFile('/tender/' + tender.id + '/measure/stage/' + stage.order + '/save/file', formData, function (data) {
-                // 替换到attData中
-                const att_index = attData.findIndex(function (item) {
-                    return item.id === parseInt(fid);
-                });
-                attData.splice(att_index, 1, data);
-                // 重新生成List
-                getAllList(parseInt($('#currentPage').text()));
-                getNodeList(node.id);
-                $('#show-att').show();
-                $('#edit-att').hide();
-                $('#show-att tr').eq(0).children('td').text(data.filename + data.fileext);
-                const name = data.code !== null && data.code !== '' ? data.code : (data.b_code !== null ? data.b_code : '');
-                $('#show-att tr').eq(1).children('td').text($.trim(name + ' ' + data.lname));
-                // $('#show-att tr').eq(2).find('a').attr('href', '/tender/' + tender.id + '/measure/stage/' + stage.order + '/download/file/' + data.id);
-                $('#show-att tr').eq(3).children('td').eq(0).text(data.username);
-                $('#show-att tr').eq(3).children('td').eq(1).text(data.in_time);
-                $('#show-att tr').eq(4).children('td').text(data.remark);
-                $('#btn-att a').eq(3).show();
-                $('#btn-att a').eq(2).hide();
-                $('#btn-att a').eq(4).hide();
-                $('#btn-att a').eq(5).hide();
-            }, function () {
-                toastr.error('附件上传失败');
-            });
-            $('#change-att-btn').val('');
-        } else if (content === 'del') {
-            const att = attData.find(function (item) { return item.id === parseInt(fid); });
-            deleteAfterHint(function () {
-                const data = {id: fid};
-                postData('/tender/' + tender.id + '/measure/stage/' + stage.order + '/delete/file', data, function (result) {
-                    // 删除到attData中
-                    const att_index = attData.findIndex(function (item) {
-                        return item.id === parseInt(fid);
-                    });
-                    attData.splice(att_index, 1);
-                    // 重新生成List
-
-                    if ($('#alllist-table tr').length === 1) {
-                        getAllList(parseInt($('#currentPage').text()) - 1);
-
-                    } else {
-                        getAllList(parseInt($('#currentPage').text()));
-                    }
-                    getNodeList(node.id);
-                    $('#showAttachment').hide();
-                    $('#showAttachment').attr('file-id', '');
-                });
-            }, `确认删除附件「${att.filename}」?`);
-
-        } else if (content === 'view') {
-            const att = attData.find(item => item.id === parseInt(fid));
-            window.open(att.viewpath || att.orginpath);
-        } else if (content === 'location') {
-            const att = attData.find(item => item.id === parseInt(fid));
-            if (Object.keys(att).length) {
-                SpreadJsObj.locateTreeNode(slSpread.getActiveSheet(), att.ledger_id, true);
-                stagePosSpreadObj.loadCurPosData();
-            }
-        }
-    });
-
-    // 替换附件
-    $('#change-att-btn').on('change', function () {
-        const file = $('#change-att-btn')[0].files[0];
-        const name = file.name;
-        const filename = name.substring(0, name.lastIndexOf("."));
-        const fileext = name.substr(name.indexOf("."));
-        const filesize = file.size;
-        if (filesize > 50 * 1024 * 1024) {
-            toastr.error('文件大小过大!');
-            $('#change-att-btn').val('');
-            return false;
-        }
-        if (whiteList.indexOf(fileext) === -1) {
-            toastr.error('只能上传指定格式的附件!');
-            $('#change-att-btn').val('');
-            return false;
-        }
-        $('#edit-att .form-group').eq(0).find('input').val(filename);
-        $('#edit-att .form-group').eq(0).find('span').eq(1).text(fileext);
-    });
-
-    // 切换页数
-    $('.page-select').on('click', function () {
-        const totalPageNum = parseInt($('#totalPage').text());
-        const lastPageNum = parseInt($('#currentPage').text());
-        const status = $(this).attr('content');
-        if (status === 'pre' && lastPageNum > 1) {
-            getAllList(lastPageNum-1);
-            $('#showAttachment').hide();
-            $('#syfujian .check-all-file').prop('checked', false)
-        } else if (status === 'next' && lastPageNum < totalPageNum) {
-            getAllList(lastPageNum+1);
-            $('#showAttachment').hide();
-            $('#syfujian .check-all-file').prop('checked', false)
-        }
-    });
-
-    // 批量下载
-    $('#bach-download').click(function() {
-        const fileIds = [];
-        const type = $(this).attr('type');
-        let node = ''
-        if (type === 'curr') {
-            node = '#nodelist-table .check-file:checked'
-        } else {
-            node = '#alllist-table .check-file:checked'
-        }
-        $(node).each(function() {
-            const fileId = $(this).attr('file-id');
-            fileId && fileIds.push(fileId);
-        });
-
-        if (fileIds.length) {
-            if (fileIds.length > 20) {
-              return toastr.warning(`最大允许20个文件(当前${fileIds.length}个)`)
-            }
-            toastr.success('正在进行压缩文件...', '', { timeOut: 0, extendedTimeOut: 0})
-            $(this).attr('disabled', "true")
-            const btn = $(this);
-
-            const fileArr = [];
-            for (const id of fileIds) {
-                const fileInfo = _.find(currPageFileData, { id: parseInt(id) });
-                fileArr.push({
-                    url: fileInfo.orginpath, //文件的oss存储路径 (必填)
-                    name: fileInfo.filename, // 文件名 (可选, 不需要填扩展名)
-                    foldPath: '' // (可选, 文件在压缩包中的存储路径)
-                });
-            }
-            const packageName = `${tender.name}-计量台账-第${stage.order}期-附件.zip`;
-            try {
-                zipOss.downloadFromAliOss(fileArr, packageName, btn);
-            } catch (e) {
-                btn.removeAttr('disabled');
-                toastr.clear();
-                toastr.error('批量下载失败');
-            }
-            // postCompressFile(`/tender/${tender.id}/measure/stage/${stage.order}/download/compresse-file`, {fileIds}, function(result) {
-            //   toastr.clear()
-            //   toastr.success('压缩文件成功')
-            //   btn.removeAttr('disabled')
-            //   const href = window.URL.createObjectURL(result)
-            //   $('#zipDown').attr('href', href);
-            //   $('#zipDown').attr('download', `${tender.name}-计量台账-第${stage.order}期-附件.zip`);
-            //   $("#zipDown")[0].click();
-            // }, () => {
-            //   btn.removeAttr('disabled')
-            //   toastr.clear()
-            //   toastr.error('批量下载失败')
-            // });
-            // const url = `/tender/${tender.id}/measure/stage/${stage.order}/download/compresse-file?fileIds=${JSON.stringify(fileIds)}`;
-            // $('#zipDown').attr('href', url);
-            // $("#zipDown")[0].click();
-        }
-    });
-
-    // 监听附件check是否选中
-    $('.list-table').on('click', '.check-file', function() {
-        const checkedList = $(this).parents('.list-table').children().find('input:checked');
-        const childs = $(this).parents('.list-table').children().length;
-        const checkBox = $(this).parents('.list-table').parent().find('.check-all-file');
-        if (checkedList.length === childs) {
-            checkBox.prop("checked", true);
-        } else {
-            checkBox.prop("checked", false);
-        }
-    });
-    $('.check-all-file').click(function() {
-        const isCheck = $(this).is(':checked');
-        $(this).parents('table').find('.list-table').each(function() {
-            $(this).find('input:checkbox').prop("checked", isCheck);
-        })
-    });
 
     // 显示层次
     (function (select, sheet) {
@@ -5665,7 +5375,7 @@ $(document).ready(() => {
         if (sfInfo) {
             const lData = _.find(ledgerData, { id: sfInfo.lid });
             SpreadJsObj.locateTreeNode(slSpread.getActiveSheet(), lData.ledger_id, true);
-            stagePosSpreadObj.loadCurPosData();
+            stageTreeSpreadObj.loadRelaData();
             if (sfInfo.pid) {
                 const posData = _.find(spSpread.getActiveSheet().zh_data, { id: sfInfo.pid });
                 SpreadJsObj.locateData(spSpread.getActiveSheet(), posData);
@@ -5763,34 +5473,6 @@ $(document).ready(() => {
             stageAssistRela.refreshAssistTable();
         });
     });
-    $('body').on('click', 'a[name=att-delete]', function() {
-        const fid = this.getAttribute('file-id');
-        if (!fid) return;
-
-        const att = attData.find(function (item) { return item.id === parseInt(fid); });
-        deleteAfterHint(function() {
-            const node = SpreadJsObj.getSelectObject(slSpread.getActiveSheet());
-            const data = {id: fid};
-            postData('/tender/' + tender.id + '/measure/stage/' + stage.order + '/delete/file', data, function (result) {
-                // 删除到attData中
-                const att_index = attData.findIndex(function (item) {
-                    return item.id === parseInt(fid);
-                });
-                attData.splice(att_index, 1);
-                // 重新生成List
-
-                if ($('#alllist-table tr').length === 1) {
-                    getAllList(parseInt($('#currentPage').text()) - 1);
-
-                } else {
-                    getAllList(parseInt($('#currentPage').text()));
-                }
-                getNodeList(node.id);
-                $('#showAttachment').hide();
-                $('#showAttachment').attr('file-id', '');
-            });
-        }, `确认删除附件「${att.filename}」?`);
-    });
 });
 function makeOneShouFang(sf) {
     const lData = _.find(ledgerData, { id: sf.lid });

+ 1 - 0
app/router.js

@@ -820,6 +820,7 @@ module.exports = app => {
     app.get('/tender/:id/measure/stage/:order/im-file/download', sessionAuth, tenderCheck, subProjectCheck, uncheckTenderCheck, stageCheck, 'stageController.downloadImFile');
     app.get('/tender/:id/measure/stage/:order/cpd', sessionAuth, tenderCheck, subProjectCheck, uncheckTenderCheck, stageCheck, 'stageController.exportStageData');
     app.post('/tender/:id/measure/stage/:order/cpd/load', sessionAuth, tenderCheck, subProjectCheck, uncheckTenderCheck, stageCheck, 'stageController.importStageData');
+    app.post('/tender/:id/measure/stage/:order/file/upload/big', sessionAuth, tenderCheck, subProjectCheck, uncheckTenderCheck, stageCheck, 'stageController.uploadBigFile');
     app.post('/tender/:id/measure/stage/:order/audit/spgroup', sessionAuth, tenderCheck, subProjectCheck, uncheckTenderCheck, stageCheck, 'stageController.changeSpGroup');
 
     // 暂存计量

+ 19 - 20
app/service/stage_att.js

@@ -58,6 +58,22 @@ module.exports = app => {
             return result.affectedRows === 1;
         }
 
+        analysisAttData(data) {
+            const datas = data instanceof Array ? data : [data];
+            datas.forEach(item => {
+                item.orginpath = this.ctx.app.config.fujianOssPath + item.filepath;
+                item.filepath = this.ctx.app.config.fujianOssPath + item.filepath;
+                item.viewpath = this.ctx.helper.getPreviewPath(item.fileext, item.filepath);
+                delete item.filepath;
+                // if (!this.ctx.helper.canPreview(item.fileext)) {
+                //     item.filepath = `/tender/${this.ctx.tender.id}/measure/stage/${this.ctx.params.order}/download/file/${item.id}`;
+                // } else {
+                //     item.filepath = this.ctx.app.config.fujianOssPath + item.filepath;
+                // }
+                item.in_time = this.ctx.moment(item.in_time * 1000).format('YYYY-MM-DD');
+            });
+        }
+
         /**
          * 获取所有附件
          * @param {int} tid - 标段id
@@ -72,18 +88,8 @@ module.exports = app => {
             const sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, this.ctx.service.ledger.departTableName(tid), tid, sid];
             // return await this.db.query(sql, sqlParam);
             const result = await this.db.query(sql, sqlParam);
-            return result.map(item => {
-                item.orginpath = this.ctx.app.config.fujianOssPath + item.filepath;
-                item.filepath = this.ctx.app.config.fujianOssPath + item.filepath;
-                item.viewpath = this.ctx.helper.getPreviewPath(item.fileext, item.filepath);
-                delete item.filepath;
-                // if (!this.ctx.helper.canPreview(item.fileext)) {
-                //     item.filepath = `/tender/${this.ctx.tender.id}/measure/stage/${this.ctx.params.order}/download/file/${item.id}`;
-                // } else {
-                //     item.filepath = this.ctx.app.config.fujianOssPath + item.filepath;
-                // }
-                return item;
-            });
+            this.analysisAttData(result);
+            return result;
         }
 
         /**
@@ -93,20 +99,13 @@ module.exports = app => {
          * @return {void}
          */
         async getDataByFid(id) {
-            const { ctx } = this;
             const sql = 'SELECT att.id, att.lid, att.uid, att.filepath, att.filename, att.extra_upload, att.fileext, att.filesize, att.remark, att.in_time,' +
                 ' pa.name as `username`, leg.name as `lname`, leg.code as `code`, leg.ledger_id as `ledger_id`,leg.b_code as `b_code`' +
                 ' FROM ?? AS att,?? AS pa,?? AS leg' +
                 ' WHERE leg.id = att.lid AND pa.id = att.uid AND att.id = ? ORDER BY att.in_time DESC';
             const sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, this.ctx.service.ledger.tableName, id];
             const result = await this.db.queryOne(sql, sqlParam);
-            result.orginpath = this.ctx.app.config.fujianOssPath + result.filepath;
-            if (!ctx.helper.canPreview(result.fileext)) {
-                result.filepath = `/tender/${ctx.tender.id}/measure/stage/${ctx.params.order}/download/file/${result.id}`;
-            } else {
-                // result.filepath = result.filepath.replace(/^app|\/app/, '');
-                result.filepath = this.ctx.app.config.fujianOssPath + result.filepath;
-            }
+            this.analysisAttData(result);
             return result;
         }
 

+ 26 - 0
app/view/shares/upload_att.ejs

@@ -18,6 +18,32 @@
         </div>
     </div>
 </div>
+<div class="modal fade" id="add-big-file" data-backdrop="static">
+    <div class="modal-dialog" role="document">
+        <div class="modal-content">
+            <div class="modal-header">
+                <h5 class="modal-title">上传附件</h5>
+            </div>
+            <div class="modal-body">
+                <div class="form-group text-danger" style="display: none" id="upload-big-file-hint">
+                </div>
+                <div class="form-group">
+                    <label for="formGroupExampleInput">文件大小限制:500MB,支持<span data-toggle="tooltip" data-placement="bottom" title="" data-original-title="doc,docx,xls,xlsx,ppt,pptx,pdf">office等文档格式</span>、<span data-toggle="tooltip" data-placement="bottom" title="" data-original-title="jpg,png,bmp">图片格式</span>、<span data-toggle="tooltip" data-placement="bottom" title="" data-original-title="rar,zip">压缩包格式</span></label>
+                    <input type="file" class="" id="upload-big-file">
+                </div>
+                <div class="form-group progress">
+                    <div id="upload-big-file-progress" class="progress-bar" role="progressbar" aria-valuenow="20" aria-valuemin="0" aria-valuemax="100"></div>
+                </div>
+            </div>
+            <div class="modal-footer">
+                <button type="button" class="btn btn-primary btn-sm" id="add-big-file-stop" style="display: none">暂停</button>
+                <button type="button" class="btn btn-primary btn-sm" id="add-big-file-resume" style="display: none">重新上传</button>
+                <button type="button" class="btn btn-secondary btn-sm" data-dismiss="modal">关闭</button>
+                <button type="button" class="btn btn-primary btn-sm" id="add-big-file-ok">确认</button>
+            </div>
+        </div>
+    </div>
+</div>
 <script>
     const whiteList = JSON.parse('<%- JSON.stringify(ctx.app.config.multipart.whitelist) %>');
 </script>

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

@@ -571,7 +571,6 @@
     const measureType = JSON.parse('<%- JSON.stringify(measureType) %>');
     const stage = JSON.parse(unescape('<%- escape(JSON.stringify(ctx.stage)) %>'));
     const imType = JSON.parse('<%- JSON.stringify(imType) %>');
-    const whiteList = JSON.parse('<%- JSON.stringify(whiteList) %>');
     let attData = JSON.parse(unescape('<%- escape(JSON.stringify(attData)) %>'));
     const ckColSetting = 'stage-col-visible-1.0.3-<%- tender.id %>';
     const auditConst = JSON.parse('<%- JSON.stringify(auditConst) %>');
@@ -586,6 +585,7 @@
     const deleteFilePermission = <%- deleteFilePermission %>;
     const limits = JSON.parse('<%- JSON.stringify(limits) %>');
     const correctCalcContractTp = <%- !!ctx.subProject.page_show.correctCalcContractTp %>;
+    const stageComplete = <%- ctx.stage.status === auditConst.status.checked ? 1 : 0 %>;
 </script>
 <style>
 

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

@@ -197,26 +197,6 @@
         </div>
     </div>
 </div>
-<!--上传附件-->
-<div class="modal fade" id="upload" data-backdrop="static">
-    <div class="modal-dialog" role="document">
-        <div class="modal-content">
-            <div class="modal-header">
-                <h5 class="modal-title">上传附件</h5>
-            </div>
-            <div class="modal-body">
-                <div class="form-group">
-                    <label for="formGroupExampleInput">单个文件大小限制:50MB,支持<span data-toggle="tooltip" data-placement="bottom" title="" data-original-title="doc,docx,xls,xlsx,ppt,pptx,pdf">office等文档格式</span>、<span data-toggle="tooltip" data-placement="bottom" title="" data-original-title="jpg,png,bmp">图片格式</span>、<span data-toggle="tooltip" data-placement="bottom" title="" data-original-title="rar,zip">压缩包格式</span></label>
-                    <input type="file" class="" id="upload-file" multiple>
-                </div>
-            </div>
-            <div class="modal-footer">
-                <button type="button" class="btn btn-secondary btn-sm" data-dismiss="modal">关闭</button>
-                <button type="button" class="btn btn-primary btn-sm" id="upload-file-btn">确认</button>
-            </div>
-        </div>
-    </div>
-</div>
 
 <% if (stage.revising) { %>
 <!--正在修订提示-->
@@ -738,4 +718,5 @@
 <% include ../shares/batch_import_modal.ejs%>
 <% include ../shares/import_file_modal.ejs%>
 <% include ../spss/spss_select_modal.ejs %>
-<% include ../shares/check_modal.ejs %>
+<% include ../shares/check_modal.ejs %>
+<% include ../shares/upload_att.ejs %>

+ 0 - 26
app/view/sub_proj/progress_modal.ejs

@@ -1,31 +1,5 @@
 <% include ../shares/delete_hint_modal.ejs %>
 <% include ../shares/upload_att.ejs %>
-<div class="modal fade" id="add-big-file" data-backdrop="static">
-    <div class="modal-dialog" role="document">
-        <div class="modal-content">
-            <div class="modal-header">
-                <h5 class="modal-title">上传附件</h5>
-            </div>
-            <div class="modal-body">
-                <div class="form-group text-danger" style="display: none" id="upload-big-file-hint">
-                </div>
-                <div class="form-group">
-                    <label for="formGroupExampleInput">文件大小限制:500MB,支持<span data-toggle="tooltip" data-placement="bottom" title="" data-original-title="doc,docx,xls,xlsx,ppt,pptx,pdf">office等文档格式</span>、<span data-toggle="tooltip" data-placement="bottom" title="" data-original-title="jpg,png,bmp">图片格式</span>、<span data-toggle="tooltip" data-placement="bottom" title="" data-original-title="rar,zip">压缩包格式</span></label>
-                    <input type="file" class="" id="upload-big-file">
-                </div>
-                <div class="form-group progress">
-                    <div id="upload-big-file-progress" class="progress-bar" role="progressbar" aria-valuenow="20" aria-valuemin="0" aria-valuemax="100"></div>
-                </div>
-            </div>
-            <div class="modal-footer">
-                <button type="button" class="btn btn-primary btn-sm" id="add-big-file-stop" style="display: none">暂停</button>
-                <button type="button" class="btn btn-primary btn-sm" id="add-big-file-resume" style="display: none">重新上传</button>
-                <button type="button" class="btn btn-secondary btn-sm" data-dismiss="modal">关闭</button>
-                <button type="button" class="btn btn-primary btn-sm" id="add-big-file-ok">确认</button>
-            </div>
-        </div>
-    </div>
-</div>
 <div class="modal fade" id="spp-col-set" data-backdrop="static">
     <div class="modal-dialog" role="document">
         <div class="modal-content">

+ 1 - 27
app/view/sub_proj/push_modal.ejs

@@ -1,27 +1 @@
-<% include ../shares/upload_att.ejs %>
-<div class="modal fade" id="add-big-file" data-backdrop="static">
-    <div class="modal-dialog" role="document">
-        <div class="modal-content">
-            <div class="modal-header">
-                <h5 class="modal-title">上传附件</h5>
-            </div>
-            <div class="modal-body">
-                <div class="form-group text-danger" style="display: none" id="upload-big-file-hint">
-                </div>
-                <div class="form-group">
-                    <label for="formGroupExampleInput">文件大小限制:500MB,支持<span data-toggle="tooltip" data-placement="bottom" title="" data-original-title="doc,docx,xls,xlsx,ppt,pptx,pdf">office等文档格式</span>、<span data-toggle="tooltip" data-placement="bottom" title="" data-original-title="jpg,png,bmp">图片格式</span>、<span data-toggle="tooltip" data-placement="bottom" title="" data-original-title="rar,zip">压缩包格式</span></label>
-                    <input type="file" class="" id="upload-big-file">
-                </div>
-                <div class="form-group progress">
-                    <div id="upload-big-file-progress" class="progress-bar" role="progressbar" aria-valuenow="20" aria-valuemin="0" aria-valuemax="100"></div>
-                </div>
-            </div>
-            <div class="modal-footer">
-                <button type="button" class="btn btn-primary btn-sm" id="add-big-file-stop" style="display: none">暂停</button>
-                <button type="button" class="btn btn-primary btn-sm" id="add-big-file-resume" style="display: none">重新上传</button>
-                <button type="button" class="btn btn-secondary btn-sm" data-dismiss="modal">关闭</button>
-                <button type="button" class="btn btn-primary btn-sm" id="add-big-file-ok">确认</button>
-            </div>
-        </div>
-    </div>
-</div>
+<% include ../shares/upload_att.ejs %>

+ 2 - 1
config/web.js

@@ -396,9 +396,9 @@ const JsFiles = {
                     '/public/js/spreadjs/sheets/v11/interop/gc.spread.excelio.11.2.2.min.js',
                     '/public/js/decimal.min.js',
                     '/public/js/math.min.js',
-                    // '/public/js/file-saver/FileSaver.js',
                     '/public/js/axios/axios.min.js', '/public/js/js-xlsx/jszip.min.js', '/public/js/file-saver/FileSaver.min.js',
                     '/public/js/datepicker/datepicker.min.js', '/public/js/datepicker/datepicker.zh.js',
+                    '/public/js/shares/aliyun-oss-sdk.min.js',
                 ],
                 mergeFiles: [
                     '/public/js/sub_menu.js',
@@ -421,6 +421,7 @@ const JsFiles = {
                     '/public/js/shares/batch_import.js',
                     '/public/js/shares/tender_select_multi.js',
                     // '/public/js/shares/stage_excel.js',
+                    '/public/js/shares/tools_att.js',
                     '/public/js/ledger_check.js',
                     '/public/js/stage.js',
                     '/public/js/stage_audit.js',