Jelajahi Sumber

多人协作,签名相关

MaiXinRong 4 tahun lalu
induk
melakukan
e0a01f786e

+ 18 - 12
app/lib/rpt_data_analysis.js

@@ -1421,10 +1421,21 @@ const loadCooperationData = {
     hint: '须使用台账、计量审批流程、协作数据作为基础',
     defaultSetting: {
         table: 'mem_stage_im_zl',
+        co_sign: [0,1,2,3],
+    },
+    _findSign: function (relaId, stageCooperation, auditor) {
+        if (relaId.length > 0) {
+            for (const id of relaId) {
+                const c = stageCooperation.find(x => {return x.ledger_id == id});
+                if (c) return c.sign_path;
+            }
+            return auditor.sign_path;
+        } else {
+            return auditor.sign_path;
+        }
     },
     _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}));
         }
@@ -1433,17 +1444,12 @@ const loadCooperationData = {
             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);
+            for (const [i, sa] of data.stage_audit.entries()) {
+                d.cooperation.push(this._findSign(relaId, stageCooperation[i], sa));
+            }
+            if (options.co_sign) {
+                for (const [i, cs] of options.co_sign.entries()) {
+                    d['co_sign' + (i+1)] = d.cooperation[cs] || '';
                 }
             }
         }

+ 10 - 0
app/service/report.js

@@ -181,6 +181,16 @@ module.exports = app => {
             }
             for (const filter of filters) {
                 switch (filter) {
+                    // test模式下,上方Promise.all的方式,取不到以下3个数据
+                    // case 'ledger_cooperation':
+                    //     rst[filter] = await service.ledgerCooperation.getValidData(params.tender_id);
+                    //     break;
+                    // case 'stage_audit':
+                    //     rst[filter] = await service.reportMemory.getStageAuditors(params.tender_id, params.stage_id), memFieldKeys[filter];
+                    //     break;
+                    // case 'mem_stage_im_zl':
+                    //     rst[filter] = await service.reportMemory.getStageImZlData(params.tender_id, params.stage_id, memFieldKeys[filter]);
+                    //     break;
                     case 'mem_stage_im_tz':
                         rst[filter] = await service.reportMemory.getStageImTzData(params.tender_id, params.stage_id, memFieldKeys[filter]);
                         break;

+ 13 - 1
app/service/report_memory.js

@@ -979,7 +979,19 @@ module.exports = app => {
         async getStageAuditors(tid, sid) {
             await this.ctx.service.tender.checkTender(tid);
             await this.ctx.service.stage.checkStage(sid);
-            return [...this.ctx.stage.auditors];
+            const user = await this.ctx.service.projectAccount.getDataById(this.ctx.stage.user_id);
+            const auditors = this.ctx.stage.auditors;
+            return [{
+                aid: user.id,
+                name: user.name,
+                company: user.company,
+                role: user.role,
+                mobile: user.mobile,
+                telephone: user.telephone,
+                sign_path: user.sign_path,
+                end_time: auditors && auditors.length > 0 ? auditors[0].begin_time : null,
+                sort: 0,
+            }, ...this.ctx.stage.auditors];
         }
     }
 

+ 1 - 1
app/service/stage_audit.js

@@ -82,7 +82,7 @@ module.exports = app => {
          */
         async getAuditors(stageId, times = 1, order_sort = 'asc') {
             const sql =
-                'SELECT la.`aid`, pa.`name`, pa.`company`, pa.`role`, pa.`mobile`, pa.`telephone`, la.`times`, la.`order`, la.`status`, la.`opinion`, la.`begin_time`, la.`end_time`, g.`sort` ' +
+                'SELECT la.`aid`, pa.`name`, pa.`company`, pa.`role`, pa.`mobile`, pa.`telephone`, pa.sign_path, la.`times`, la.`order`, la.`status`, la.`opinion`, la.`begin_time`, la.`end_time`, g.`sort` ' +
                 'FROM ?? AS la, ?? AS pa, (SELECT `aid`,(@i:=@i+1) as `sort` FROM ??, (select @i:=0) as it WHERE `sid` = ? AND `times` = ? GROUP BY `aid`) as g ' +
                 'WHERE la.`sid` = ? and la.`times` = ? and la.`aid` = pa.`id` and g.`aid` = la.`aid` order by la.`order` ' +
                 order_sort;

+ 10 - 2
builder_report_index_define.js

@@ -680,6 +680,10 @@ const stage_im_zl = {
         { name: '计量单元', field: 'jldy', type: dataType.str },
         { name: '草图备注', field: 'calc_memo_remark', type: dataType.str },
         { name: '签名列表', field: 'cooperation', type: dataType.arr },
+        { name: '签名1', field: 'co_sign1', type: dataType.str, isPic: true },
+        { name: '签名2', field: 'co_sign2', type: dataType.str, isPic: true },
+        { name: '签名3', field: 'co_sign3', type: dataType.str, isPic: true },
+        { name: '签名4', field: 'co_sign4', type: dataType.str, isPic: true },
     ],
 };
 const stage_im_tz = {
@@ -717,6 +721,11 @@ const stage_im_tz = {
         { name: '计量单元', field: 'jldy', type: dataType.str },
         { name: '草图备注', field: 'calc_img_remark', type: dataType.str },
         { name: '签名列表', field: 'cooperation', type: dataType.arr },
+        { name: '签名1', field: 'co_sign1', type: dataType.str, isPic: true },
+        { name: '签名2', field: 'co_sign2', type: dataType.str, isPic: true },
+        { name: '签名3', field: 'co_sign3', type: dataType.str, isPic: true },
+        { name: '签名4', field: 'co_sign4', type: dataType.str, isPic: true },
+
     ],
 };
 const stage_im_tz_bills = {
@@ -1176,9 +1185,8 @@ const stage_audit = {
         { 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)) {

+ 1 - 2
test/app/lib/rpt_data_analysis.test.js

@@ -201,8 +201,7 @@ describe('test/app/service/report_memory.test.js', () => {
             ],
             mem_stage_im_zl: ['lid', 'code'],
         });
-        reportDataAnalysis.analysisObj.loadCooperationData.fun(ctx, data, [], {table: 'mem_stage_im_zl'}, null);
-        console.log(data.stage_audit);
+        reportDataAnalysis.analysisObj.loadCooperationData.fun(ctx, data, [], {table: 'mem_stage_im_zl', co_sign: [0, 1, 2, 3]}, null);
     });
     it('test join', function* () {
         const ctx = app.mockContext(mockData);