Browse Source

1. 报表,添加审批人选择,报表预处理
2. 其他台账,其他,金额只读设置

MaiXinRong 5 years ago
parent
commit
09cd12b735

+ 7 - 6
app/controller/report_controller.js

@@ -165,7 +165,8 @@ module.exports = app => {
             }
             rptTpl = JSON.parse(rptTpl[0].rpt_content);
             // console.log('get the template!');
-            const pageRst = await getAllPagesCommon(ctx, rptTpl, params, JV.PAGING_OPTION_NORMAL, JV.OUTPUT_TYPE_NORMAL, this.app.baseDir);
+            const customSelect = await ctx.service.rptCustomDefine.getCustomDefine(params.tender_id, params.stage_id, params.rpt_tpl_id);
+            const pageRst = await getAllPagesCommon(ctx, rptTpl, params, JV.PAGING_OPTION_NORMAL, JV.OUTPUT_TYPE_NORMAL, this.app.baseDir, customSelect);
             // console.log(pageRst);
             // const roleRel = (params.stage_status === 3) ? (await ctx.service.roleRptRel.getRoleRptRelByDetailIds(params.tender_id, params.rpt_tpl_id)) : [];
             const roleRel = await ctx.service.roleRptRel.getRoleRptRelByDetailIds(params.tender_id, params.rpt_tpl_id); // 新需求中,允许在非审核状态下设置签名
@@ -175,7 +176,6 @@ module.exports = app => {
             await encodeSignatureDataUri(roleRel, this.app.baseDir);
             await encodeDummySignatureDataUri(pageRst, this.app.baseDir);
             const stageFlow = await ctx.service.stageAudit.getAuditGroupByListWithOwner(params.stage_id, params.stage_times);
-            const customSelect = await ctx.service.rptCustomDefine.getCustomDefine(params.tender_id, params.stage_id, params.rpt_tpl_id);
 
             // console.log('encodeSignatureDataUri!');
             return {
@@ -527,12 +527,12 @@ async function checkStg(ctx, params) {
     return rst;
 }*/
 
-async function getAllPagesCommon(ctx, rptTpl, params, option, outputType, baseDir) {
+async function getAllPagesCommon(ctx, rptTpl, params, option, outputType, baseDir, customSelect) {
     const rptDataUtil = new rptDataExtractor();
     rptDataUtil.initialize(rptTpl);
     const filter = rptDataUtil.getDataRequestFilter();
     // console.log(filter.tables);
-    const rawDataObj = await ctx.service.report.getReportData(params, filter.tables, filter.memFieldKeys, rptTpl);
+    const rawDataObj = await ctx.service.report.getReportData(params, filter.tables, filter.memFieldKeys);
     // console.log(rawDataObj);
     try {
         const printCom = JpcEx.createNew();
@@ -546,7 +546,7 @@ async function getAllPagesCommon(ctx, rptTpl, params, option, outputType, baseDi
         // console.log(defProperties);
 
         // console.log('before assemble');
-        const tplData = rptDataUtil.assembleData(ctx, rawDataObj, baseDir, printCom);
+        const tplData = rptDataUtil.assembleData(ctx, rawDataObj, baseDir, printCom, customSelect);
         // console.log(tplData);
 
         if (params.custCfg) {
@@ -639,7 +639,8 @@ async function getMultiRptsCommon(ctx, params, outputType, baseDir) {
         for (let tplIdx = 0; tplIdx < rptTpls.length; tplIdx++) {
             const rptTpl = (rptTpls[tplIdx]._doc) ? rptTpls[tplIdx]._doc : rptTpls[tplIdx];
             rptDataUtil.initialize(rptTpl);
-            const tplData = rptDataUtil.assembleData(ctx, rawDataObj, baseDir);
+            const customSelect = await ctx.service.rptCustomDefine.getCustomDefine(params.tender_id, params.stage_id, rptTpls[tplIdx].id);
+            const tplData = rptDataUtil.assembleData(ctx, rawDataObj, baseDir, null, customSelect);
             const printCom = JpcEx.createNew();
             rptTpl[JV.NODE_MAIN_INFO][JV.NODE_PAGE_INFO][JV.PROP_PAGE_SIZE] = params.pageSize;
 

+ 53 - 0
app/lib/rpt_data_analysis.js

@@ -830,6 +830,58 @@ const addSumChapter = {
         });
     }
 };
+const auditSelect = {
+    name: '审批人选择',
+    hint: '需搭配用户交互--审批人选择一起使用',
+    defaultSetting: {
+        table: ['mem_stage_bills_compare'],
+    },
+    _stageBillsCompare(data, order) {
+        const fields = [];
+        for (const [i, o] of order.entries()) {
+            const sPrefix = 'r' + o + '_';
+            const tPrefix = 'as' + i + '_';
+            fields.push({source: sPrefix + 'contract_qty', target: tPrefix + 'contract_qty'});
+            fields.push({source: sPrefix + 'contract_tp', target: tPrefix + 'contract_tp'});
+            fields.push({source: sPrefix + 'qc_qty', target: tPrefix + 'qc_qty'});
+            fields.push({source: sPrefix + 'qc_tp', target: tPrefix + 'qc_tp'});
+            fields.push({source: sPrefix + 'gather_qty', target: tPrefix + 'gather_qty'});
+            fields.push({source: sPrefix + 'gather_tp', target: tPrefix + 'gather_tp'});
+        }
+        for (const d of data) {
+            for (const f of fields) {
+                d[f.target] = d[f.source];
+            }
+        }
+    },
+    fun: function (ctx, data, fieldsKey, options, csRela) {
+        if (!ctx.tender || !ctx.stage) return;
+        if (!csRela.tplDefine) return;
+        const asDefine = csRela.tplDefine.audit_select;
+        if (!asDefine || !asDefine.enable || !asDefine.setting || asDefine.setting === '') return;
+        const asCustom = csRela.cDefine ? csRela.cDefine.audit_select : null;
+
+        const order = [];
+        if (asCustom) {
+            for (const asc of asCustom) {
+                order.push(asc.order);
+            }
+        } else {
+            const setting = JSON.stringify(asDefine.setting);
+            for (const [i, s] of setting.select.entries) {
+                order.push(i);
+            }
+        }
+
+        for (const t of options.table) {
+            switch (t) {
+                case 'mem_stage_bills_compare':
+                    this._stageBillsCompare(data[t], order);
+                    break;
+            }
+        }
+    }
+};
 
 const analysisObj = {
     changeSort,
@@ -842,6 +894,7 @@ const analysisObj = {
     union,
     gatherStagePay,
     addSumChapter,
+    auditSelect,
 };
 const analysisDefine = (function (obj) {
     const result = [];

+ 1 - 0
app/public/js/se_other.js

@@ -292,6 +292,7 @@ $(document).ready(() => {
 
                 switch (col.field) {
                     case 'name':
+                    case 'total_price':
                         info.cancel = readOnly || node.pre_used;
                         break;
                 }

+ 6 - 4
app/reports/util/rpt_calculation_data_util.js

@@ -190,7 +190,7 @@ class Rpt_Data_Extractor {
     }
 
     // 装配数据(把收集到的数据,依据报表模板的指示,预处理(如:排序、过滤、合计)及装配到相关指标)
-    assembleData(ctx, rawDataObj, baseDir, $CURRENT_RPT) {
+    assembleData(ctx, rawDataObj, baseDir, $CURRENT_RPT, customSelect) {
         const $PROJECT = { REPORT: {} };
         const tpl = this.rptTpl;
         this.COMMON.initialize(tpl, rawDataObj);
@@ -210,7 +210,7 @@ class Rpt_Data_Extractor {
                         // filterData(srcData, preHandle, rawDataObj.prjData);
                         break;
                     case JV.PROP_HANDLE_TYPE_PRE_DEFINED:
-                        preDefineProcess(ctx, tpl, preHandle, rawDataObj, $CURRENT_RPT);
+                        preDefineProcess(ctx, tpl, preHandle, rawDataObj, $CURRENT_RPT, customSelect);
                         break;
                     default:
                         break;
@@ -514,7 +514,7 @@ function getOrgFieldDefine(fieldId, tpl) {
     return rst;
 }
 
-function preDefineProcess(ctx, tpl, preDefineCfg, rawDataObj, $CURRENT_RPT) {
+function preDefineProcess(ctx, tpl, preDefineCfg, rawDataObj, $CURRENT_RPT, customSelect) {
     // 依据约定,需要提供如右所示格式的数据:[{field: 'b_code', table: 'mem_stage_bills'}, {field: 'id', table: 'mem_stage_bills'}]
     // 指标对象的mapExpression 格式类似于: "$PROJECT.REPORT.getProperty('mem_stage_im_zl', 'calc_memo')"
     const fields = [];
@@ -558,7 +558,9 @@ function preDefineProcess(ctx, tpl, preDefineCfg, rawDataObj, $CURRENT_RPT) {
                     console.log(analysisKey);
                     ctx.helper.log(ex);
                 }
-                data_analyze_util[analysisKey].fun(ctx, rawDataObj, fields, preSetup);
+                data_analyze_util[analysisKey].fun(ctx, rawDataObj, fields, preSetup, {
+                    tplDefine: tpl[JV.NODE_CUS_AUDIT_SELECT], cDefine: customSelect
+                });
             } catch (err) {
                 ctx.helper.log(err);
                 throw '报表预处理数据出错';