Explorar el Código

协作类项目,中间计量,审批意见、时间等

MaiXinRong hace 4 años
padre
commit
d5fed026f8
Se han modificado 3 ficheros con 54 adiciones y 10 borrados
  1. 11 7
      app/lib/rpt_data_analysis.js
  2. 41 2
      app/service/report_memory.js
  3. 2 1
      app/service/stage_audit.js

+ 11 - 7
app/lib/rpt_data_analysis.js

@@ -1436,11 +1436,11 @@ const loadCooperationData = {
         }
     },
     _completeSign: function (auditor) {
-        if (!auditor) return '';
+        if (!auditor || !auditor.end_time) return '';
         return 'public/upload/sign/' + auditor.sign_path;
     },
     _loadImCooperationData: function (ctx, data, options, csRela) {
-        console.log(ctx.rpt_roleSign);
+
         let coSignOrder = [];
         if (csRela && csRela.tplDefine && csRela.tplDefine.audit_select && csRela.cDefine && csRela.cDefine.audit_select) {
             if (csRela.cDefine.audit_select) {
@@ -1453,8 +1453,10 @@ const loadCooperationData = {
         }
 
         const stageCooperation = [];
+        let finish = true;
         for (const sa of data.stage_audit) {
             if (sa.end_time) stageCooperation.push(data.ledger_cooperation.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});
@@ -1465,11 +1467,13 @@ const loadCooperationData = {
                 d.cooperation.push(this._findSign(relaId, stageCooperation[i], sa));
             }
 
-            for (const [i, cs] of coSignOrder.entries()) {
-                if (data.stage_audit[cs] && data.stage_audit[cs].end_time) {
-                    d['co_sign' + (i+1)] = d.cooperation[cs] || this._completeSign(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;
+            if (finish) {
+                for (const [i, cs] of coSignOrder.entries()) {
+                    if (data.stage_audit[cs] && data.stage_audit[cs].end_time) {
+                        d['co_sign' + (i+1)] = d.cooperation[cs] || this._completeSign(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;
+                    }
                 }
             }
         }

+ 41 - 2
app/service/report_memory.js

@@ -981,7 +981,7 @@ module.exports = app => {
             await this.ctx.service.stage.checkStage(sid);
             const user = await this.ctx.service.projectAccount.getDataById(this.ctx.stage.user_id);
             const auditors = this.ctx.stage.auditors;
-            return [{
+            const result = [{
                 aid: user.id,
                 name: user.name,
                 company: user.company,
@@ -989,9 +989,48 @@ module.exports = app => {
                 mobile: user.mobile,
                 telephone: user.telephone,
                 sign_path: user.sign_path,
+                opinion: user.opinion,
                 end_time: auditors && auditors.length > 0 ? auditors[0].begin_time : null,
                 sort: 0,
-            }, ...this.ctx.stage.auditors];
+            }];
+            for (const a of auditors) {
+                const auditor = await this.ctx.service.stageAudit.getDataByCondition({tid: a.tid, sid: a.sid, order: a.max_order});
+                result.push({
+                    aid: a.aid,
+                    name: a.name,
+                    company: a.company,
+                    role: a.role,
+                    mobile: a.mobile,
+                    telephone: a.telephone,
+                    sign_path: a.sign_path,
+                    end_time: auditor.end_time,
+                    opinion: auditor.opinion,
+                })
+            }
+            return result;
+        }
+
+        async getSignSelect(tid, sid, customSelect) {
+            await this.ctx.service.tender.checkTender(tid);
+            await this.ctx.service.stage.checkStage(sid);
+
+            const signSelect = customSelect.sign_select, result = {};
+            for (const [i, ss] of signSelect.entries()) {
+                const user = await this.ctx.service.projectAccount.getDataById(ss.id);
+                const sign = {
+                    id: ss.id, name: user.name, company: user.company, role: user.role,
+                    mobile: user.mobile, telephone: user.telephone,
+                };
+                if (ss.id !== this.ctx.stage.user_id) {
+                    const audit = this.ctx.stage.auditors.find(x => {return x.aid === ss.id});
+                    user.end_time = audit ? audit.end_time : ss.audit_time;
+                } else {
+                    user.end_time = this.ctx.stage.auditors[0].end_time;
+                }
+                if (user.end_time) sign.sign_path = user.sign_path;
+                result['sign' + (i+1)] = sign;
+            }
+            return result;
         }
     }
 

+ 2 - 1
app/service/stage_audit.js

@@ -88,11 +88,12 @@ module.exports = app => {
                 order_sort;
             const sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, this.tableName, stageId, times, stageId, times];
             const result = await this.db.query(sql, sqlParam);
-            const sql2 = 'SELECT COUNT(a.`aid`) as num FROM (SELECT `aid` FROM ?? WHERE `sid` = ? AND `times` = ? GROUP BY `aid`) as a';
+            const sql2 = 'SELECT COUNT(a.`aid`) as num, a.`max_order` FROM (SELECT `aid`, Max(`order`) as max_order FROM ?? WHERE `sid` = ? AND `times` = ? GROUP BY `aid`) as a';
             const sqlParam2 = [this.tableName, stageId, times];
             const count = await this.db.queryOne(sql2, sqlParam2);
             for (const i in result) {
                 result[i].max_sort = count.num;
+                result[i].max_order = count.max_order;
             }
             return result;
         }