|
@@ -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));
|
|
|
// 再删除数据库
|