Browse Source

报表数据源,添加通用方法

MaiXinRong 11 months ago
parent
commit
0d7ac853cb
2 changed files with 23 additions and 4 deletions
  1. 4 4
      app/lib/rm/advance.js
  2. 19 0
      app/lib/rm/base.js

+ 4 - 4
app/lib/rm/advance.js

@@ -11,14 +11,14 @@
 const RptMemBase = require('./base');
 const bindData = {};
 
-class rptMemChange extends RptMemBase {
+class rptMemAdvance extends RptMemBase {
     constructor(ctx) {
         super(ctx, bindData);
     }
 
     async doCheckAdvance(advanceId) {
         if (this.ctx.advance) return;
-        this.ctx.advance = await this.ctx.service.advance.getDataByCondition({ cid: advanceId });
+        this.ctx.advance = await this.ctx.service.advance.getDataByCondition({ id: advanceId });
     }
 
     async doCheckTender(tenderId) {
@@ -30,7 +30,7 @@ class rptMemChange extends RptMemBase {
 
     async doBeforeLoadReport(params) {
         await this.doCheckAdvance(params.advance_id);
-        await this.doCheckTender(this.ctx.change.tid);
+        await this.doCheckTender(this.ctx.advance.tid);
     }
 
     async _getAdvanceAudit() {
@@ -58,4 +58,4 @@ class rptMemChange extends RptMemBase {
     }
 }
 
-module.exports = rptMemChange;
+module.exports = rptMemAdvance;

+ 19 - 0
app/lib/rm/base.js

@@ -23,6 +23,25 @@ class rptMemBase {
         this.bindData = bindData;
     }
 
+    _checkFieldsExistReg(source, regStr) {
+        const reg = new RegExp(regStr, 'igm');
+        for (const s of source) {
+            if (reg.test(s)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    _checkFieldsExist(source, check) {
+        for (const s of source) {
+            if (check.indexOf(s) >= 0) {
+                return true;
+            }
+        }
+        return false;
+    }
+
     /**
      * 数据表分类(普通表,绑定表)
      * @param sourceFilters