소스 검색

合同管理数据源

MaiXinRong 3 주 전
부모
커밋
5de96b5937
2개의 변경된 파일85개의 추가작업 그리고 0개의 파일을 삭제
  1. 77 0
      app/lib/rm/contract.js
  2. 8 0
      app/service/report.js

+ 77 - 0
app/lib/rm/contract.js

@@ -0,0 +1,77 @@
+'use strict';
+
+/**
+ *
+ *
+ * @author Mai
+ * @date
+ * @version
+ */
+
+const RptMemBase = require('./base');
+const bindData = {};
+const Ledger = require('../ledger');
+
+class rptMemContract extends RptMemBase {
+    constructor(ctx) {
+        super(ctx, bindData);
+    }
+
+    async _getContractTree(condition) {
+        const data = await this.ctx.service.contractTree.getAllDataByCondition({ where: condition });
+        const contract_data = await this.ctx.service.contract.getAllDataByCondition({ where: condition });
+        const tree = new Ledger.billsTree(this.ctx, {
+            id: 'contract_id',
+            pid: 'contract_pid',
+            order: 'order',
+            level: 'level',
+            rootId: -1,
+            calcFields: [ 'total_price', 'pay_price', 'debit_price', 'yf_price', 'sf_price'],
+            calc: function (node, helper, decimal) {},
+        });
+        tree.loadDatas([...data, ...contract_data]);
+        return tree.getDefaultDatas();
+    }
+    async _getContract(condition) {
+        const data = await this.ctx.service.contract.getAllDataByCondition({ where: condition });
+        return data;
+    }
+    async _getContractPay(condition) {
+        const data = await this.ctx.service.contractPay.getAllDataByCondition({ where: condition, orders: [['cid', 'asc'], ['create_time', 'asc']] });
+        return data;
+    }
+
+    async getSpContractTree(contract_type) {
+        if (!this.ctx.subProject) return [];
+        return await this._getContractTree({ spid: this.ctx.subProject.id, contract_type });
+    }
+    async getSpContract(contract_type) {
+        if (!this.ctx.subProject) return [];
+        return await this._getContract({ spid: this.ctx.subProject.id, contract_type });
+    }
+    async getSpContractPay(contract_type) {
+        if (!this.ctx.subProject) return [];
+        return await this._getContractPay({ spid: this.ctx.subProject.id, contract_type });
+    }
+
+    getCommonData(params, tableName, fields, customDefine, customSelect) {
+        switch (tableName) {
+            case 'sp_contract_tree_1':
+                return this.getSpContractTree(1);
+            case 'sp_contract_1':
+                return this.getSpContract(1);
+            case 'sp_contract_pay_1':
+                return this.getSpContractPay(1);
+            case 'sp_contract_tree_2':
+                return this.getSpContractTree(2);
+            case 'sp_contract_2':
+                return this.getSpContract(2);
+            case 'sp_contract_pay_2':
+                return this.getSpContractPay(2);
+            default:
+                return [];
+        }
+    }
+}
+
+module.exports = rptMemContract;

+ 8 - 0
app/service/report.js

@@ -718,6 +718,14 @@ module.exports = app => {
             return rptAdvance.getReportData(params, sourceFilters, memFieldKeys, customDefine, customSelect);
         }
 
+        // params = { }
+        async contract(params, sourceFilters, memFieldKeys, customDefine, customSelect) {
+            const RptAdvance = require('../lib/rm/contract');
+            const rptAdvance = new RptAdvance(this.ctx);
+
+            return rptAdvance.getReportData(params, sourceFilters, memFieldKeys, customDefine, customSelect);
+        }
+
         async getReportData(source_type, params, sourceFilters, memFieldKeys, customDefine, customSelect) {
             this.clearReportCache();
             const sourceType = sourceTypeConst.sourceTypeData.find(x => { return x.id === source_type; });