MaiXinRong 2 年 前
コミット
2c0fde292a

+ 59 - 3
app/lib/rpt_data_analysis.js

@@ -1528,7 +1528,6 @@ const loadCooperationData = {
         return auditor.sign_path ? 'public/upload/sign/' + auditor.sign_path : '';
     },
     _loadImCooperationData(ctx, data, options, csRela) {
-
         let coSignOrder = [];
         if (csRela && csRela.tplDefine && csRela.tplDefine.audit_select && csRela.cDefine && csRela.cDefine.audit_select) {
             if (csRela.cDefine.audit_select) {
@@ -1569,14 +1568,71 @@ const loadCooperationData = {
             }
         }
     },
+    _findStageAuditAss(relaId, stageAuditAss, auditor) {
+        if (!stageAuditAss || stageAuditAss.length === 0) return null;
+        if (relaId.length > 0) {
+            for (const id of relaId) {
+                const c = stageCooperation.find(x => { return x.ass_ledger_id.indexOf(id) >= 0; });
+                if (c) return c;
+            }
+            return null;
+        }
+        return null;
+
+    },
+    _loadImAssistData(ctx, data, options, csRela) {
+        let coSignOrder = [];
+        if (csRela && csRela.tplDefine && csRela.tplDefine.audit_select && csRela.cDefine && csRela.cDefine.audit_select) {
+            if (csRela.cDefine.audit_select) {
+                for (const asc of csRela.cDefine.audit_select) {
+                    coSignOrder.push(asc.order);
+                }
+            }
+        } else {
+            coSignOrder = options.co_sign || [];
+        }
+
+        const stageAuditAss = [];
+        let finish = true;
+        for (const sa of data.stage_audit) {
+            if (sa.end_time) stageAuditAss.push(data.mem_stage_audit_ass.filter(x => { return x.user_id === sa.aid; }));
+            if (finish && !sa.end_time) finish = false;
+        }
+        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.ass = [];
+            for (const [i, sa] of data.stage_audit.entries()) {
+                const co = this._findStageAuditAss(relaId, stageAuditAss[i], sa);
+                d.ass.push(co);
+            }
+
+            for (const [i, cs] of coSignOrder.entries()) {
+                if (data.stage_audit[cs] && data.stage_audit[cs].end_time) {
+                    d['co_sign' + (i + 1)] = this._completeSign(d.ass[cs] || data.stage_audit[cs]);
+                    d['co_opinion' + (i + 1)] = data.stage_audit[cs].opinion || '';
+                    d['co_time' + (i + 1)] = data.stage_audit[cs].end_time;
+                    d['co_name' + (i + 1)] = d.ass[cs] ? d.ass[cs].name : data.stage_audit[cs].name;
+                    d['co_company' + (i + 1)] = d.ass[cs] ? d.ass[cs].company : data.stage_audit[cs].company;
+                }
+            }
+        }
+    },
     fun(ctx, data, fieldsKey, options, csRela) {
         if (!options || !options.table) return;
         if (!data[options.table]) return;
         if (!data.mem_stage_bills) return;
         if (!data.stage_audit) return;
-        if (!data.ledger_cooperation) return;
+        if (!data.ledger_cooperation && !data.mem_stage_audit_ass) return;
 
-        if (['mem_stage_im_zl', 'mem_stage_im_tz'].indexOf(options.table) >= 0) { this._loadImCooperationData(ctx, data, options, csRela); }
+        if (['mem_stage_im_zl', 'mem_stage_im_tz'].indexOf(options.table) >= 0) {
+            if (data.mem_stage_audit_ass) {
+                this._loadImAssistData(ctx, data, options, csRela);
+            } else {
+                this._loadImCooperationData(ctx, data, options, csRela);
+            }
+        }
     },
 };
 const signSelect = {

+ 4 - 0
app/service/report.js

@@ -122,6 +122,10 @@ module.exports = app => {
                             runnableRst.push(service.reportMemory.getStageAuditors(params.tender_id, params.stage_id));
                             runnableKey.push(filter);
                             break;
+                        case 'mem_stage_audit_ass':
+                            runnableRst.push(service.reportMemory.getStageAuditAss(params.tender_id, params.stage_id));
+                            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

@@ -1418,6 +1418,12 @@ module.exports = app => {
             return result;
         }
 
+        async getStageAuditAss(tid, sid) {
+            await this.ctx.service.tender.checkTender(tid);
+            await this.ctx.service.stage.checkStage(sid);
+            return await this.ctx.service.stageAuditAss.getReportData(this.ctx.stage.id, this.ctx.stage.times);
+        }
+
         async getChangeInfo(tid, sid) {
             await this.ctx.service.tender.checkTender(tid);
             await this.ctx.service.stage.checkStage(sid);

+ 7 - 0
app/service/stage_audit_ass.js

@@ -169,6 +169,13 @@ module.exports = app => {
         async getLockedId(stage) {
             return await this.getAllDataByCondition({ where: { sid: stage.id, times: stage.times, locked: 1 } });
         }
+
+        async getReportData(sid, stimes) {
+            const sql = 'SELECT saa.tid, saa.sid, saa.times, saa.user_id, saa.ass_ledger_id, saa.ass_user_id, saa.name, saa.company, saa.role, pa.sign_path, pa.stamp_path' +
+                `   FROM ${this.tableName} saa LEFT JOIN ${this.ctx.service.projectAccount.tableName} pa ON saa.ass_user_id = pa.id` +
+                `   WHERE saa.sid = ? AND saa.stimes = ?`;
+            return this.db.query(sql, [sid, stimes]);
+        }
     }
 
     return StageAuditAss;

ファイルの差分が大きいため隠しています
+ 0 - 2839
builder_report_index_define.js