Bläddra i källkod

奖罚金,附件上传删除调整

MaiXinRong 4 år sedan
förälder
incheckning
87c9b2b846

+ 9 - 3
app/controller/stage_extra_controller.js

@@ -91,7 +91,8 @@ module.exports = app => {
         async bonus (ctx) {
             try {
                 const renderData = {
-                    jsFiles: this.app.jsFiles.common.concat(this.app.jsFiles.stageExtra.bonus)
+                    jsFiles: this.app.jsFiles.common.concat(this.app.jsFiles.stageExtra.bonus),
+                    auditConst: auditConst,
                 };
                 await this.layout('stage_extra/bonus.ejs', renderData, 'stage_extra/bonus_modal.ejs');
             } catch (err) {
@@ -151,7 +152,7 @@ module.exports = app => {
             try {
                 const renderData = {
                     jsFiles: this.app.jsFiles.common.concat(this.app.jsFiles.stageExtra.other)
-                }
+                };
                 await this.layout('stage_extra/other.ejs', renderData);
             } catch (err) {
                 ctx.helper.log(err);
@@ -227,6 +228,7 @@ module.exports = app => {
                         filepath: path.join(dirName, fileName),
                         uid: ctx.session.sessionUser.accountId,
                         in_time: moment(create_time * 1000).format('YYYY-MM-DD'),
+                        renew: ctx.stage.status === auditConst.status.checked,
                     });
                     ++index;
                     if (Array.isArray(parts.field.size) && index < parts.field.size.length) {
@@ -295,9 +297,13 @@ module.exports = app => {
                 const data = JSON.parse(ctx.request.body.data);
 
                 const bonus = await ctx.service.stageBonus.getStageDataById(data.b_id);
-                if (!bonus || !bonus.proof_file || !bonus.proof_file[data.index]) throw '删除的文件不存在'
+                if (!bonus || !bonus.proof_file || !bonus.proof_file[data.index]) throw '删除的文件不存在';
 
                 const fileInfo = bonus.proof_file[data.index];
+                if (fileInfo.uid !== ctx.session.sessionUser.accountId) throw '您无权删除该文件';
+
+                if (ctx.stage.status === auditConst.status.checked && !fileInfo.renew) throw '不可删除该文件';
+
                 // 先删除文件
                 await fs.unlinkSync(path.join(this.app.baseDir, fileInfo.filepath));
                 // 再删除数据库

+ 1 - 1
app/public/js/se_bonus.js

@@ -155,7 +155,7 @@ $(document).ready(() => {
                     // 下载
                     html.push('<a href="download/file?b_id=' + id + '&index=' + i + '" title="下载"><i class="fa fa-download "></i></a>');
                     // 删除
-                    if (!readOnly && !isPre(data)) {
+                    if (f.uid === userID && (!stageChecked || f.renew)) {
                         html.push('<a class="delete-att text-danger ml-1" href="javascript:void(0);" data-id ="' + id + '"file-index="' + i + '" title="删除"><i class="fa fa-remove "></i></a>');
                     }
                     html.push('</td>');

+ 1 - 0
app/view/stage_extra/bonus.ejs

@@ -45,4 +45,5 @@
     const readOnly = <%- ctx.stage.readOnly %>;
     const whiteList = JSON.parse('<%- JSON.stringify(ctx.app.config.multipart.whitelist) %>');
     const thousandth = <%- ctx.tender.info.display.thousandth %>;
+    const stageChecked = <%- ctx.stage.status === auditConst.status.checked %>;
 </script>

+ 0 - 2
app/view/stage_extra/bonus_modal.ejs

@@ -6,12 +6,10 @@
                 <h5 class="modal-title">附件</h5>
             </div>
             <div class="modal-body">
-                <% if (!ctx.stage.readOnly) { %>
                 <div class="form-group" id="upload-file-panel">
                     <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-file" multiple>
                 </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>