Ver código fonte

文件类型功能

laiguoran 3 anos atrás
pai
commit
3b7999e014

+ 7 - 0
app/const/change.js

@@ -111,4 +111,11 @@ module.exports = {
         3: '变更建议',
         4: '变更意向',
     },
+    file_type: [
+        { key: 1, value: '图纸' },
+        { key: 2, value: '勘查资料' },
+        { key: 3, value: '报告' },
+        { key: 4, value: '会议纪要' },
+        { key: 5, value: '其他资料' },
+    ],
 };

+ 9 - 8
app/controller/change_controller.js

@@ -2217,17 +2217,17 @@ module.exports = app => {
                         const userAgent = (ctx.request.header['user-agent'] || '').toLowerCase();
                         let disposition = '';
                         if (userAgent.indexOf('msie') >= 0 || userAgent.indexOf('chrome') >= 0) {
-                            disposition = 'attachment; filename=' + encodeURIComponent(fileInfo.file_name);
+                            disposition = 'attachment; filename=' + encodeURIComponent(fileInfo.filename);
                         } else if (userAgent.indexOf('firefox') >= 0) {
-                            disposition = 'attachment; filename*="utf8\'\'' + encodeURIComponent(fileInfo.file_name) + '"';
+                            disposition = 'attachment; filename*="utf8\'\'' + encodeURIComponent(fileInfo.filename) + '"';
                         } else {
                             /* safari等其他非主流浏览器只能自求多福了 */
-                            disposition = 'attachment; filename=' + new Buffer(fileInfo.file_name).toString('binary');
+                            disposition = 'attachment; filename=' + new Buffer(fileInfo.filename).toString('binary');
                         }
                         ctx.response.set({
                             'Content-Type': 'application/octet-stream',
                             'Content-Disposition': disposition,
-                            'Content-Length': fileInfo.file_size,
+                            'Content-Length': fileInfo.filesize,
                         });
                         // ctx.body = await fs.createReadStream(fileName);
                         ctx.body = await ctx.helper.ossFileGet(fileInfo.filepath);
@@ -2659,6 +2659,7 @@ module.exports = app => {
                         tid: ctx.tender.id,
                         caid: ctx.change.id,
                         uid: ctx.session.sessionUser.accountId,
+                        type: parts.field.type,
                         filename: file.name,
                         fileext: file.ext,
                         filesize: ctx.helper.bytesToSize(idx === 'isString' ? parts.field.size : parts.field.size[idx]),
@@ -2721,17 +2722,17 @@ module.exports = app => {
                         const userAgent = (ctx.request.header['user-agent'] || '').toLowerCase();
                         let disposition = '';
                         if (userAgent.indexOf('msie') >= 0 || userAgent.indexOf('chrome') >= 0) {
-                            disposition = 'attachment; filename=' + encodeURIComponent(fileInfo.file_name);
+                            disposition = 'attachment; filename=' + encodeURIComponent(fileInfo.filename);
                         } else if (userAgent.indexOf('firefox') >= 0) {
-                            disposition = 'attachment; filename*="utf8\'\'' + encodeURIComponent(fileInfo.file_name) + '"';
+                            disposition = 'attachment; filename*="utf8\'\'' + encodeURIComponent(fileInfo.filename) + '"';
                         } else {
                             /* safari等其他非主流浏览器只能自求多福了 */
-                            disposition = 'attachment; filename=' + new Buffer(fileInfo.file_name).toString('binary');
+                            disposition = 'attachment; filename=' + new Buffer(fileInfo.filename).toString('binary');
                         }
                         ctx.response.set({
                             'Content-Type': 'application/octet-stream',
                             'Content-Disposition': disposition,
-                            'Content-Length': fileInfo.file_size,
+                            'Content-Length': fileInfo.filesize,
                         });
                         // ctx.body = await fs.createReadStream(fileName);
                         ctx.body = await ctx.helper.ossFileGet(fileInfo.filepath);

Diferenças do arquivo suprimidas por serem muito extensas
+ 15 - 9
app/public/js/change_apply_information.js


+ 2 - 2
app/public/js/change_project_information.js

@@ -75,9 +75,9 @@ $(document).ready(() => {
         let html = change.filePermission ? `<tr><td colspan="5"><a href="#addfujian" data-toggle="modal" class="btn btn-primary btn-sm" data-placement="bottom" title="">上传附件</a></td></tr>` : '';
         newFiles.forEach((file, idx) => {
             if (file.showDel) {
-                html += `<tr><td>${idx + 1}</td><td><a href="${file.filepath}" target="_blank">${file.filename}</a></td><td>${file.username}</td><td>${moment(file.upload_time).format('YYYY-MM-DD HH:mm:ss')}</td><td><a href="javascript: void(0);" class="text-danger file-del" data-id="${file.id}"><i class="fa fa-remove"></i></a></td></tr>`
+                html += `<tr><td>${idx + 1}</td><td><a href="${file.filepath}" target="_blank">${file.filename}</a></td><td>${file.username}</td><td>${moment(file.upload_time).format('YYYY-MM-DD HH:mm:ss')}</td><td><a href="/tender/${file.tid}/change/project/${file.cpid}/information/file/${file.id}/download" class="mr-2"><i class="fa fa-download"></i></a><a href="javascript: void(0);" class="text-danger file-del" data-id="${file.id}"><i class="fa fa-remove"></i></a></td></tr>`
             } else {
-                html += `<tr><td width="70">${idx + 1}</td><td><a href="${file.filepath}" target="_blank">${file.filename}</a></td><td>${file.username}</td><td>${moment(file.upload_time).format('YYYY-MM-DD HH:mm:ss')}</td><td></td></tr>`
+                html += `<tr><td width="70">${idx + 1}</td><td><a href="${file.filepath}" target="_blank">${file.filename}</a></td><td>${file.username}</td><td>${moment(file.upload_time).format('YYYY-MM-DD HH:mm:ss')}</td><td><a href="/tender/${file.tid}/change/project/${file.cpid}/information/file/${file.id}/download" class="mr-2"><i class="fa fa-download"></i></a></td></tr>`
             }
         })
         $('#file-content').append(html);

+ 2 - 0
app/view/change/apply_information.ejs

@@ -105,6 +105,7 @@
                             <th></th>
                             <th>附件</th>
                             <th>上传者</th>
+                            <th>资料类型</th>
                             <th>上传时间</th>
                             <th>操作</th>
                         </tr>
@@ -139,6 +140,7 @@
 <script>
     autoFlashHeight();
     const auditConst = JSON.parse('<%- JSON.stringify(auditConst) %>');
+    const fileTypeConst = JSON.parse(unescape('<%- escape(JSON.stringify(changeConst.file_type)) %>'));
     const fileList = JSON.parse(unescape('<%- escape(JSON.stringify(fileList)) %>')) || [];
     const whiteList = JSON.parse('<%- JSON.stringify(whiteList) %>');
     const preUrl = '<%- preUrl %>';

+ 13 - 3
app/view/change/apply_information_modal.ejs

@@ -9,9 +9,19 @@
                 </button>
             </div>
             <div class="modal-body">
-                <p>大小限制:30MB,支持office等文档格式、图片格式、压缩包格式</p>
-                <!-- <p><a href="javascript: void(0);" class="btn btn-primary" id="file-modal-target">选择文件</a></p> -->
-                <input type="file" id="file-modal" multiple="multiple">
+                <div class="form-group">
+                    <label for="file-modal">大小限制:30MB,支持office等文档格式、图片格式、压缩包格式</label>
+                    <!-- <p><a href="javascript: void(0);" class="btn btn-primary" id="file-modal-target">选择文件</a></p> -->
+                    <input type="file" id="file-modal" multiple="multiple">
+                </div>
+                <div>
+                    <% for (const t of changeConst.file_type) { %>
+                    <div class="form-check form-check-inline">
+                        <input class="form-check-input" type="radio" name="type" id="file_type_<%- t.key %>" value="<%- t.key %>">
+                        <label class="form-check-label" for="file_type_<%- t.key %>"><%- t.value %></label>
+                    </div>
+                    <% } %>
+                </div>
             </div>
             <div class="modal-footer">
                 <button id="file-cancel" type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>