Преглед изворни кода

变更令数据源,新增指标&数据

MaiXinRong пре 3 месеци
родитељ
комит
a58438f33f
2 измењених фајлова са 80 додато и 0 уклоњено
  1. 42 0
      app/lib/rm/change.js
  2. 38 0
      app/service/report_memory.js

+ 42 - 0
app/lib/rm/change.js

@@ -84,6 +84,42 @@ class rptMemChange extends RptMemBase {
         return changeBills;
     }
 
+    async getChangeLedgerBillsData(showLevel) {
+        try {
+            await this.ctx.service.tender.checkTender(tid);
+
+            const billsData = await this.ctx.service.ledger.getData(this.ctx.tender.id);
+            const changeBillsData = await this.ctx.service.changeLedger.getAllDataByCondition({ where: { ccid: this.ctx.change.id } });
+            billsData.push(...changeBillsData);
+
+            const billsTree = this._getNewBillsTree();
+            billsTree.loadDatas(billsData);
+            billsTree.calculateAll();
+
+            if (this._checkFieldsExist(fields, [''])) {
+                this._calcLeafXmjRela(billsTree);
+            }
+
+            return showLevel ? billsTree.getDefaultDatasByLevel(this.ctx.tender.rpt_show_level) : billsTree.getDefaultDatas();
+        } catch(err) {
+            this.ctx.log(err);
+            return [];
+        }
+    }
+    async getChangeLedgerPosData() {
+        try {
+            const posData = await this.ctx.service.pos.getAllDataByCondition({ where: {tid: this.ctx.tender.id }});
+            const changePosData = await this.ctx.service.changePos.getAllDataByCondition({ where: { ccid: this.ctx.change.id } });
+            posData.push(...changePosData);
+            this.pos.loadDatas(posData);
+            this.pos.calculateAll();
+
+            return this.pos.getDatas();
+        } catch (err) {
+            return [];
+        }
+    }
+
     getCommonData(params, tableName, fields, customDefine, customSelect) {
         switch (tableName) {
             case 'mem_change':
@@ -100,6 +136,12 @@ class rptMemChange extends RptMemBase {
                 return [this.ctx.tender.data];
             case 'mem_tender_info':
                 return [this.ctx.tender.info];
+            case 'mem_change_ledger_bills':
+                return this.getChangeLedgerBillsData();
+            case 'mem_change_ledger_bills_filter':
+                return this.getChangeLedgerBillsData(true);
+            case 'mem_change_ledger_pos':
+                return this.getChangeLedgerPosData();
             default:
                 return [];
         }

+ 38 - 0
app/service/report_memory.js

@@ -1044,6 +1044,44 @@ module.exports = app => {
             }
         }
 
+        async getChangeLedgerBillsData(tid, showLevel) {
+            try {
+                await this.ctx.service.tender.checkTender(tid);
+
+                const billsData = await this.ctx.service.ledger.getData(this.ctx.tender.id);
+                const changeBillsData = await this.ctx.service.changeLedger.getAllDataByCondition({ where: { tender_id: tid } });
+                billsData.push(...changeBillsData);
+
+                const billsTree = this._getNewBillsTree();
+                billsTree.loadDatas(billsData);
+                billsTree.calculateAll();
+
+                if (this._checkFieldsExist(fields, billsFields.leafXmj)) {
+                    this._calcLeafXmjRela(billsTree);
+                }
+
+                return showLevel ? billsTree.getDefaultDatasByLevel(this.ctx.tender.rpt_show_level) : billsTree.getDefaultDatas();
+            } catch(err) {
+                this.ctx.log(err);
+                return [];
+            }
+        }
+
+        async getChangeLedgerPosData(tid) {
+
+            try {
+                await this.ctx.service.tender.checkTender(tid);
+
+                const posData = await this.ctx.service.pos.getAllDataByCondition({ where: {tid: this.ctx.tender.id }});
+                this.pos.loadDatas(posData);
+                this.pos.calculateAll();
+
+                return this.pos.getDatas();
+            } catch (err) {
+                return [];
+            }
+        }
+
         async _generateImportChange(sid) {
             if (this.importChange !== undefined) return;
             const self = this;