Sfoglia il codice sorgente

引用文件相关

MaiXinRong 3 settimane fa
parent
commit
57c7093b32
2 ha cambiato i file con 23 aggiunte e 3 eliminazioni
  1. 22 2
      app/controller/file_controller.js
  2. 1 1
      app/public/js/file_detail.js

+ 22 - 2
app/controller/file_controller.js

@@ -338,9 +338,9 @@ module.exports = app => {
             const stage = await this.ctx.service.stage.getDataById(data.stage);
             switch (data.sub_type) {
                 case 'att':
-                    return await this.ctx.service.stageAtt.getAllDataByCondition({ where: { tid: data.tender_id, sid: stage.order }, order: [['id', 'desc']]});
+                    return await this.ctx.service.stageAtt.getAllDataByCondition({ where: { tid: data.tender_id, sid: stage.order }, orders: [['id', 'desc']]});
                 case 'dealPay':
-                    const payAtt = await this.ctx.service.payAtt.getStageData({ sid: stage.id });
+                    const payAtt = await this.ctx.service.payAtt.getAllDataByCondition({ where: { sid: stage.id}, orders: [['id', 'desc']] });
                     return payAtt;
                 case 'stageIm':
                     const imFiles = [];
@@ -370,17 +370,35 @@ module.exports = app => {
         }
         async _loadChangePlanAtt(data) {
             if (!data.selectId) throw '参数错误';
+            const self = this;
             const result = await this.ctx.service.changePlanAtt.getAllDataByCondition({ where: { cpid: data.selectId }, order: [['id', 'desc']]});
+            result.forEach(x => {
+                const info = path.parse(x.filename);
+                x.filename = info.name;
+                x.filesize = self.ctx.helper.sizeToBytes(x.filesize);
+            });
             return result;
         }
         async _loadChangeProjectAtt(data) {
             if (!data.selectId) throw '参数错误';
+            const self = this;
             const result = await this.ctx.service.changeProjectAtt.getAllDataByCondition({ where: { cpid: data.selectId }, order: [['id', 'desc']]});
+            result.forEach(x => {
+                const info = path.parse(x.filename);
+                x.filename = info.name;
+                x.filesize = self.ctx.helper.sizeToBytes(x.filesize);
+            });
             return result;
         }
         async _loadChangeApplyAtt(data) {
             if (!data.selectId) throw '参数错误';
+            const self = this;
             const result = await this.ctx.service.changeApplyAtt.getAllDataByCondition({ where: { caid: data.selectId }, order: [['id', 'desc']]});
+            result.forEach(x => {
+                const info = path.parse(x.filename);
+                x.filename = info.name;
+                x.filesize = self.ctx.helper.sizeToBytes(x.filesize);
+            });
             return result;
         }
         async loadRelaFiles(ctx) {
@@ -389,6 +407,7 @@ module.exports = app => {
                 if (!data.type) throw '参数错误';
 
                 let files;
+                console.log(data);
                 switch(data.type) {
                     case 'ledger':
                         files = await this._loadLedgerAtt(data);
@@ -413,6 +432,7 @@ module.exports = app => {
                         break;
                     default: throw '未知文件类型';
                 }
+                console.log(files);
                 ctx.body = {err: 0, msg: '', data: files };
             } catch (error) {
                 ctx.helper.log(error);

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

@@ -1229,7 +1229,7 @@ $(document).ready(function() {
             });
         }
         async _loadRelaFiles(rfType) {
-            return await postDataAsync('file/rela/files', { tender_id: this.curTender.id, ...rfType });
+            return await postDataAsync('file/rela/files', { tender_id: this.curTender.source_node.tid, ...rfType });
         }
         async _loadLedgerFile() {
             if (!this.curTender.source_node.att) this.curTender.source_node.att = await this._loadRelaFiles(this.rfType);