Explorar o código

报表,协作签名相关

MaiXinRong %!s(int64=4) %!d(string=hai) anos
pai
achega
2afe404b65

+ 45 - 0
app/lib/rpt_data_analysis.js

@@ -1416,6 +1416,50 @@ const stageSelectConverse = {
         }
     }
 };
+const loadCooperationData = {
+    name: '加载协作数据',
+    hint: '须使用台账、计量审批流程、协作数据作为基础',
+    defaultSetting: {
+        table: 'mem_stage_im_zl',
+    },
+    _loadImCooperationData: function (ctx, data, options) {
+        const stageCooperation = [];
+        stageCooperation.push(data.ledger_cooperation.filter(x => {return x.user_id === data.stage[0].user_id}));
+        for (const sa of data.stage_audit) {
+            stageCooperation.push(data.ledger_cooperation.filter(x => {return x.user_id === sa.aid}));
+        }
+        for (const d of data[options.table]) {
+            const bills = data.mem_stage_bills.find(x => {return x.id === d.lid});
+            const relaId = bills ? bills.full_path.split('-').reverse() : [];
+
+            d.cooperation = [];
+            for (const sc of stageCooperation) {
+                if (relaId.length > 0) {
+                    for (const id of relaId) {
+                        const c = sc.find(x => {return x.ledger_id == id});
+                        if (c) {
+                            d.cooperation.push(c.sign_path);
+                            break;
+                        }
+                    }
+                } else {
+                    d.cooperation.push(null);
+                }
+            }
+        }
+    },
+    fun: function (ctx, data, fieldsKey, options, csRela) {
+        if (!options || !options.table) return;
+        if (!data[options.table]) return;
+        if (!data.mem_stage_bills) return;
+        if (!data.stage) return;
+        if (!data.stage_audit) return;
+        if (!data.ledger_cooperation) return;
+
+        if (['mem_stage_im_zl', 'mem_stage_im_tz'].indexOf(options.table) >= 0)
+            this._loadImCooperationData(ctx, data, options);
+    }
+};
 
 const analysisObj = {
     changeSort,
@@ -1435,6 +1479,7 @@ const analysisObj = {
     sortPos,
     unionPos,
     splitXmjCode,
+    loadCooperationData,
 };
 const analysisDefine = (function (obj) {
     const result = [];

+ 4 - 0
app/service/report.js

@@ -84,6 +84,10 @@ module.exports = app => {
                             runnableRst.push(service.reportMemory.getMonthProgress(params.tender_id, memFieldKeys[filter]));
                             runnableKey.push(filter);
                             break;
+                        case 'stage_audit':
+                            runnableRst.push(service.reportMemory.getStageAuditors(params.tender_id, params.stage_id), memFieldKeys[filter]);
+                            runnableKey.push(filter);
+                            break;
                         case 'mem_stage_bills':
                             runnableRst.push(service.reportMemory.getStageBillsData(params.tender_id, params.stage_id, memFieldKeys[filter]));
                             runnableKey.push(filter);

+ 6 - 0
app/service/report_memory.js

@@ -975,6 +975,12 @@ module.exports = app => {
                 return [];
             }
         }
+
+        async getStageAuditors(tid, sid) {
+            await this.ctx.service.tender.checkTender(tid);
+            await this.ctx.service.stage.checkStage(sid);
+            return [...this.ctx.stage.auditors];
+        }
     }
 
     return ReportMemory;

+ 24 - 2
builder_report_index_define.js

@@ -17,6 +17,7 @@ const dataType = {
     double: 'double',
     currency: 'currency',
     time: 'string',
+    arr: 'array',
 };
 const tag = {
     tp: { type: 'tp' },
@@ -60,7 +61,7 @@ const ledger_cooperation = {
         { name: '密码', field: 'pwd', type: dataType.str },
         { name: '电子签名地址', field: 'sign_path', type: dataType.str },
     ]
-}
+};
 // 其他台账
 const stage_jgcl = {
     name: '期-甲供材料(mem_stage_jgcl)',
@@ -678,6 +679,7 @@ const stage_im_zl = {
         { name: '位置', field: 'position', type: dataType.str },
         { name: '计量单元', field: 'jldy', type: dataType.str },
         { name: '草图备注', field: 'calc_memo_remark', type: dataType.str },
+        { name: '签名列表', field: 'cooperation', type: dataType.arr },
     ],
 };
 const stage_im_tz = {
@@ -714,6 +716,7 @@ const stage_im_tz = {
         { name: '位置', field: 'position', type: dataType.str },
         { name: '计量单元', field: 'jldy', type: dataType.str },
         { name: '草图备注', field: 'calc_img_remark', type: dataType.str },
+        { name: '签名列表', field: 'cooperation', type: dataType.arr },
     ],
 };
 const stage_im_tz_bills = {
@@ -1157,6 +1160,25 @@ const stage_sum_pay = {
     ],
 };
 
+const stage_audit = {
+    name: '期-审批人 列表(stage_audit)',
+    remark: '',
+    id: 46,
+    key: 'stage_audit',
+    prefix: '期-审批人',
+    cols: [
+        { name: '审批人id', field: 'aid', type: dataType.int },
+        { name: '姓名', field: 'name', type: dataType.str },
+        { name: '公司', field: 'company', type: dataType.str },
+        { name: '角色', field: 'role', type: dataType.str },
+        { name: '手机', field: 'mobile', type: dataType.str },
+        { name: '电话', field: 'telephone', type: dataType.str },
+        { name: '审批意见', field: 'opinion', type: dataType.str },
+        { name: '审批时间', field: 'end_time', type: dataType.str },
+        { name: '审批顺序', field: 'sort', type: dataType.str },
+
+    ],
+}
 
 const recursiveMkdirSync = async function(pathName) {
     if (!fs.existsSync(pathName)) {
@@ -1261,7 +1283,7 @@ const defines = [
     stage_im_zl, stage_im_tz, stage_im_tz_bills,
     gather_stage_bills, gather_tender_info, gather_stage_pay, gather_deal_bills,
     material, materialGl,
-    stage_sum_bills, stage_sum_pay
+    stage_sum_bills, stage_sum_pay, stage_audit,
 ];
 for (const d of defines) {
     exportTableDefine(d);

+ 16 - 0
test/app/lib/rpt_data_analysis.test.js

@@ -188,6 +188,22 @@ describe('test/app/service/report_memory.test.js', () => {
         const chapter400 = ctx.helper._.find(data.mem_stage_bills, {code: '400'});
         assert(chapter400.total_price.toFixed(0) == 1231018);
     });
+    it('test loadCooperationData', function* () {
+        const ctx = app.mockContext(mockData);
+        const stage = yield ctx.service.stage.getDataByCondition({tid: 3301, order: 1});
+        const params = {
+            tender_id: stage.tid,
+            stage_id: stage.id,
+        };
+        const data = yield ctx.service.report.getReportData(params, ['mem_stage_bills', 'stage', 'stage_audit', 'ledger_cooperation', 'mem_stage_im_zl'], {
+            mem_stage_bills: [
+                'id', 'tender_id', 'ledger_id', 'ledger_pid', 'level', 'order', 'full_path', 'is_leaf'
+            ],
+            mem_stage_im_zl: ['lid', 'code'],
+        });
+        reportDataAnalysis.analysisObj.loadCooperationData.fun(ctx, data, [], {table: 'mem_stage_im_zl'}, null);
+        console.log(data.stage_audit);
+    });
     it('test join', function* () {
         const ctx = app.mockContext(mockData);