Browse Source

奖罚金,附件删除调整

MaiXinRong 1 year ago
parent
commit
0cfde01e57

+ 5 - 2
app/controller/stage_extra_controller.js

@@ -12,6 +12,7 @@ const sendToWormhole = require('stream-wormhole');
 const path = require('path');
 const path = require('path');
 const moment = require('moment');
 const moment = require('moment');
 const fs = require('fs');
 const fs = require('fs');
+const PermissionCheck = require('../const/account_permission').PermissionCheck;
 
 
 module.exports = app => {
 module.exports = app => {
 
 
@@ -94,6 +95,7 @@ module.exports = app => {
                     jsFiles: this.app.jsFiles.common.concat(this.app.jsFiles.stageExtra.bonus),
                     jsFiles: this.app.jsFiles.common.concat(this.app.jsFiles.stageExtra.bonus),
                     auditConst,
                     auditConst,
                     stage: ctx.stage,
                     stage: ctx.stage,
+                    deleteFilePermission: PermissionCheck.delFile(this.ctx.session.sessionUser.permission),
                 };
                 };
                 await this.layout('stage_extra/bonus.ejs', renderData, 'stage_extra/bonus_modal.ejs');
                 await this.layout('stage_extra/bonus.ejs', renderData, 'stage_extra/bonus_modal.ejs');
             } catch (err) {
             } catch (err) {
@@ -417,7 +419,8 @@ module.exports = app => {
                 const fileInfo = bonus.proof_file[data.index];
                 const fileInfo = bonus.proof_file[data.index];
                 if (fileInfo.uid !== ctx.session.sessionUser.accountId) throw '您无权删除该文件';
                 if (fileInfo.uid !== ctx.session.sessionUser.accountId) throw '您无权删除该文件';
 
 
-                if (ctx.stage.status === auditConst.status.checked && !fileInfo.renew) throw '不可删除该文件';
+                const deleteFilePermission = PermissionCheck.delFile(this.ctx.session.sessionUser.permission);
+                if (ctx.stage.status === auditConst.status.checked && !fileInfo.renew && !deleteFilePermission) throw '不可删除该文件';
 
 
                 // 先删除文件
                 // 先删除文件
                 await fs.unlinkSync(path.join(this.app.baseDir, fileInfo.filepath));
                 await fs.unlinkSync(path.join(this.app.baseDir, fileInfo.filepath));
@@ -435,7 +438,7 @@ module.exports = app => {
                 ctx.body = {err: 0, msg: '', data: bonus.proof_file};
                 ctx.body = {err: 0, msg: '', data: bonus.proof_file};
             } catch (err) {
             } catch (err) {
                 this.log(err);
                 this.log(err);
-                this.postError(err, '删除文件失败');
+                this.ctx.ajaxErrorBody(err, '删除文件失败');
             }
             }
         }
         }
     }
     }

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

@@ -160,7 +160,7 @@ $(document).ready(() => {
                     // 下载
                     // 下载
                     html.push('<a href="download/file?b_id=' + id + '&index=' + i + '" title="下载"><i class="fa fa-download "></i></a>');
                     html.push('<a href="download/file?b_id=' + id + '&index=' + i + '" title="下载"><i class="fa fa-download "></i></a>');
                     // 删除
                     // 删除
-                    if (f.uid === userID && ((!isPre(data) && !stageChecked) || f.renew)) {
+                    if (f.uid === userID && ((!isPre(data) && !stageChecked) || f.renew || deleteFilePermission)) {
                         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('<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>');
                     html.push('</td>');

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

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