Browse Source

奖罚金,附件相关

MaiXinRong 5 years ago
parent
commit
eba7f6ac8a
2 changed files with 8 additions and 2 deletions
  1. 7 1
      app/controller/stage_extra_controller.js
  2. 1 1
      app/service/stage_bonus.js

+ 7 - 1
app/controller/stage_extra_controller.js

@@ -114,6 +114,12 @@ module.exports = app => {
                     }
                 }
                 const preData = await ctx.service.stageBonus.getPreStageData(ctx.stage.order);
+                for (const d of preData) {
+                    for (const pf of d.proof_file) {
+                        delete pf.filepath;
+                        pf.username = (await ctx.service.projectAccount.getAccountInfoById(pf.uid)).name;
+                    }
+                }
                 ctx.body = {err: 0, msg: '', data: data.concat(preData)};
             } catch (error) {
                 ctx.helper.log(error);
@@ -203,7 +209,7 @@ module.exports = app => {
                         throw '未发现上传文件!';
                     }
                     if (!bonus) bonus = await ctx.service.stageBonus.getStageDataById(parts.field.bonus_id);
-                    if (!bonus) throw '该奖罚金,当前不允许上传附件';
+                    if (!bonus || bonus.sid !== ctx.stage.id) throw '该奖罚金,当前不允许上传附件';
 
                     const fileInfo = path.parse(stream.filename);
                     const dirName = 'app/public/upload/extra/' + moment().format('YYYYMMDD');

+ 1 - 1
app/service/stage_bonus.js

@@ -66,7 +66,7 @@ module.exports = app => {
         }
 
         async getStageDataById(bonusId) {
-            const data = await this.getAllDataByCondition({ where: { sid: this.ctx.stage.id, id: bonusId } });
+            const data = await this.getAllDataByCondition({ where: { id: bonusId } });
             this._parseData(data);
             return data[0];
         }