Browse Source

合同管理数据源,新增标段合同指标&数据

MaiXinRong 3 months ago
parent
commit
b388b962b4
4 changed files with 107 additions and 6 deletions
  1. 2 1
      app/const/source_type.js
  2. 25 0
      app/lib/rm/contract.js
  3. 67 0
      app/lib/rm/phase_pay.js
  4. 13 5
      app/service/report.js

+ 2 - 1
app/const/source_type.js

@@ -2,6 +2,7 @@
 
 
 const sourceTypeData = [
 const sourceTypeData = [
     { id: 1, name: '标段&期', key: 'tender', params: { tender_id: 1, stage_id: 1 } },
     { id: 1, name: '标段&期', key: 'tender', params: { tender_id: 1, stage_id: 1 } },
+    { id: 2, name: '合同支付', key: 'phase_pay', params: { phase_pay_id: 'uuid'} },
     { id: 10, name: '预付款', key: 'advance', params: { advance_id: 1 } },
     { id: 10, name: '预付款', key: 'advance', params: { advance_id: 1 } },
     { id: 20, name: '变更令', key: 'change', params: { change_id: 'uuid' } },
     { id: 20, name: '变更令', key: 'change', params: { change_id: 'uuid' } },
     { id: 21, name: '变更方案', key: 'change_plan', params: { change_plan_id: 1 } },
     { id: 21, name: '变更方案', key: 'change_plan', params: { change_plan_id: 1 } },
@@ -12,7 +13,7 @@ const sourceTypeData = [
     { id: 100, name: '支付审批', key: 'payment', params: { tender_id: 1, detail_id: 1 } },
     { id: 100, name: '支付审批', key: 'payment', params: { tender_id: 1, detail_id: 1 } },
     { id: 101, name: '安全生产费', key: 'payment_safe', params: { tender_id: 1, detail_id: 1 } },
     { id: 101, name: '安全生产费', key: 'payment_safe', params: { tender_id: 1, detail_id: 1 } },
     { id: 200, name: '项目进度', key: 'budget', params: { sp_id: 'uuid', budget_id: 1 } },
     { id: 200, name: '项目进度', key: 'budget', params: { sp_id: 'uuid', budget_id: 1 } },
-    { id: 300, name: '合同管理', key: 'contract_management', params: {} },
+    { id: 300, name: '合同管理', key: 'contract', params: {} },
     // { id: 301, name: '标段合同', key: 'tender_contract' },
     // { id: 301, name: '标段合同', key: 'tender_contract' },
 ];
 ];
 
 

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

@@ -54,6 +54,19 @@ class rptMemContract extends RptMemBase {
         return await this._getContractPay({ spid: this.ctx.subProject.id, contract_type });
         return await this._getContractPay({ spid: this.ctx.subProject.id, contract_type });
     }
     }
 
 
+    async getContractTree(tid, contract_type) {
+        if (!this.ctx.subProject) return [];
+        return await this._getContractTree({ tid, contract_type });
+    }
+    async getContract(tid, contract_type) {
+        if (!this.ctx.subProject) return [];
+        return await this._getContract({ tid, contract_type });
+    }
+    async getContractPay(tid, contract_type) {
+        if (!this.ctx.subProject) return [];
+        return await this._getContractPay({ tid, contract_type });
+    }
+
     getCommonData(params, tableName, fields, customDefine, customSelect) {
     getCommonData(params, tableName, fields, customDefine, customSelect) {
         switch (tableName) {
         switch (tableName) {
             case 'sp_contract_tree_1':
             case 'sp_contract_tree_1':
@@ -68,6 +81,18 @@ class rptMemContract extends RptMemBase {
                 return this.getSpContract(2);
                 return this.getSpContract(2);
             case 'sp_contract_pay_2':
             case 'sp_contract_pay_2':
                 return this.getSpContractPay(2);
                 return this.getSpContractPay(2);
+            case 'contract_tree_1':
+                return this.getContractTree(params.tender_id, 1);
+            case 'contract_1':
+                return this.getContract(params.tender_id, 1);
+            case 'contract_pay_1':
+                return this.getContractPay(params.tender_id, 1);
+            case 'contract_tree_2':
+                return this.getContractTree(params.tender_id, 2);
+            case 'contract_2':
+                return this.getContract(params.tender_id, 2);
+            case 'contract_pay_2':
+                return this.getContractPay(params.tender_id, 2);
             default:
             default:
                 return [];
                 return [];
         }
         }

+ 67 - 0
app/lib/rm/phase_pay.js

@@ -0,0 +1,67 @@
+'use strict';
+
+/**
+ *
+ *
+ * @author Mai
+ * @date
+ * @version
+ */
+
+const RptMemBase = require('./base');
+const bindData = {};
+const Ledger = require('../ledger');
+
+class rptMemChange extends RptMemBase {
+    constructor(ctx) {
+        super(ctx, bindData);
+    }
+
+    async doCheckPhasePay(phase_pay_id) {
+        if (this.ctx.phasePay) return;
+        this.ctx.phasePay = await this.ctx.service.safeStage.getPhasePay(phase_pay_id);
+        await this.service.phasePay.doCheckPhase(this.ctx.phasePay);
+    }
+
+    async doCheckTender(tenderId) {
+        if (this.ctx.tender) return;
+        this.ctx.tender = { id: tenderId };
+        this.ctx.tender.data = await this.ctx.service.tender.getTender(tenderId);
+        this.ctx.tender.info = await this.ctx.service.tenderInfo.getTenderInfo(tenderId);
+    }
+
+    async doBeforeLoadReport(params) {
+        await this.doCheckPhasePay(params.phase_pay_id);
+        await this.doCheckTender(this.ctx.phasePay.tid);
+    }
+
+    async getPhasePayDetail() {
+        const data = await this.ctx.service.phasePayDetail.getDetailData(this.ctx.phasePay);
+        const payTree = new Ledger.baseTree(this.ctx, {
+            id: 'tree_id', pid: 'tree_pid', order: 'tree_order',
+            level: 'tree_level', isLeaf: 'tree_is_leaf', fullPath: 'tree_full_path',
+            rootId: -1, calcField: [],
+        });
+        payTree.loadDatas(data);
+        return payTree.getDefaultDatas();
+    }
+
+    getCommonData(params, tableName, fields, customDefine, customSelect) {
+        switch (tableName) {
+            case 'mem_project':
+                return this.ctx.service.project.getDataByCondition({ id: this.ctx.session.sessionProject.id });
+            case 'mem_tender':
+                return [this.ctx.tender.data];
+            case 'mem_tender_info':
+                return [this.ctx.tender.info];
+            case 'mem_phase_pay':
+                return [this.ctx.phasePay];
+            case 'mem_phase_pay_detail':
+                return this.getPhasePayDetail();
+            default:
+                return [];
+        }
+    }
+}
+
+module.exports = rptMemChange;

+ 13 - 5
app/service/report.js

@@ -788,12 +788,12 @@ module.exports = app => {
             return rptAdvance.getReportData(params, sourceFilters, memFieldKeys, customDefine, customSelect);
             return rptAdvance.getReportData(params, sourceFilters, memFieldKeys, customDefine, customSelect);
         }
         }
 
 
-        // params = { }
-        async contract_management(params, sourceFilters, memFieldKeys, customDefine, customSelect) {
-            const RptAdvance = require('../lib/rm/contract');
-            const rptAdvance = new RptAdvance(this.ctx);
+        // params = { tender_id: int }
+        async contract(params, sourceFilters, memFieldKeys, customDefine, customSelect) {
+            const RptContract = require('../lib/rm/contract');
+            const rptContract= new RptContract(this.ctx);
 
 
-            return rptAdvance.getReportData(params, sourceFilters, memFieldKeys, customDefine, customSelect);
+            return rptContract.getReportData(params, sourceFilters, memFieldKeys, customDefine, customSelect);
         }
         }
 
 
         // params = { safe_stage_id: uuid }
         // params = { safe_stage_id: uuid }
@@ -804,6 +804,14 @@ module.exports = app => {
             return rptSafeStage.getReportData(params, sourceFilters, memFieldKeys, customDefine, customSelect);
             return rptSafeStage.getReportData(params, sourceFilters, memFieldKeys, customDefine, customSelect);
         }
         }
 
 
+        // params = { phase_pay_id: uuid }
+        async safe_stage(params, sourceFilters, memFieldKeys, customDefine, customSelect) {
+            const RptPhasePay = require('../lib/rm/phase_pay');
+            const rptPhasePay = new RptPhasePay(this.ctx);
+
+            return rptPhasePay.getReportData(params, sourceFilters, memFieldKeys, customDefine, customSelect);
+        }
+
         async getReportData(source_type, params, sourceFilters, memFieldKeys, customDefine, customSelect) {
         async getReportData(source_type, params, sourceFilters, memFieldKeys, customDefine, customSelect) {
             this.clearReportCache();
             this.clearReportCache();
             const sourceType = sourceTypeConst.sourceTypeData.find(x => { return x.id === source_type; });
             const sourceType = sourceTypeConst.sourceTypeData.find(x => { return x.id === source_type; });