Browse Source

中间计量,附件bug

MaiXinRong 3 years ago
parent
commit
6582aa2af0
2 changed files with 5 additions and 5 deletions
  1. 1 0
      app/service/project_account.js
  2. 4 5
      app/service/stage_detail_att.js

+ 1 - 0
app/service/project_account.js

@@ -355,6 +355,7 @@ module.exports = app => {
         }
 
         async getAccountInfoById(id) {
+            if (!id) throw new Error('id未定义');
             this.initSqlBuilder();
             this.sqlBuilder.columns = ['id', 'name', 'company', 'role'];
             this.sqlBuilder.setAndWhere('id', {

+ 4 - 5
app/service/stage_detail_att.js

@@ -59,9 +59,6 @@ module.exports = app => {
             const datas = data instanceof Array ? data : [data];
             for (const a of datas) {
                 a.attachment = a.attachment ? JSON.parse(a.attachment) : [];
-                for (const aa of a.attachment) {
-                    if (this.ctx.helper.canPreview(aa.fileext)) aa.viewpath = aa.filepath.replace(/^app|\/app/, '');
-                }
             }
         }
 
@@ -75,6 +72,7 @@ module.exports = app => {
             const datas = data instanceof Array ? data : [data];
             for (const d of datas) {
                 for (const a of d.attachment) {
+                    if (this.ctx.helper.canPreview(a.fileext)) a.viewpath = a.filepath.replace(/^app|\/app/, '');
                     delete a.filepath;
                     a.username = (await this.getUserTemp(a.uid)).name;
                 }
@@ -122,8 +120,8 @@ module.exports = app => {
 
             const index = detailAtt.attachment.findIndex(x => { return x.file_id === fileId });
             if (index < 0) throw '不存在改文件';
-            const att = detailAtt[index];
-            if (detailAtt.attachment[index].uid !== this.ctx.session.sessionUser.accountId) throw '您无权删除该文件';
+            const att = detailAtt.attachment[index];
+            if (att.uid !== this.ctx.session.sessionUser.accountId) throw '您无权删除该文件';
 
             detailAtt.attachment.splice(index, 1);
             await this.db.update(this.tableName, { id: detailAtt.id, attachment: JSON.stringify(detailAtt.attachment) });
@@ -131,6 +129,7 @@ module.exports = app => {
             if (fs.existsSync(path.join(this.ctx.app.baseDir, att.filepath))) {
                 await fs.unlinkSync(path.join(this.ctx.app.baseDir, att.filepath));
             }
+
             await this._complete4Output(detailAtt);
             return detailAtt;
         }