Browse Source

工作台、待办事项,显示安全计量待重新上报的期信息

MaiXinRong 1 day ago
parent
commit
08fafface1
1 changed files with 10 additions and 4 deletions
  1. 10 4
      app/service/safe_stage_audit.js

+ 10 - 4
app/service/safe_stage_audit.js

@@ -126,6 +126,7 @@ module.exports = app => {
             return this.db.query(sql, sqlParam);
         }
         async getAuditStage(auditorId, spid = '') {
+            // 查询待审批的期
             const spSql = spid ? ' and t.`spid` = "' + spid + '"' : '';
             const sql =
                 'SELECT sa.`audit_id`, sa.`audit_times`, sa.`audit_order`, sa.active_order, sa.`tid`, sa.`stage_id`,' +
@@ -134,13 +135,18 @@ module.exports = app => {
                 `  FROM ${this.tableName} AS sa ` +
                 `    Left Join ${this.ctx.service.safeStage.tableName} AS s On sa.stage_id = s.id ` +
                 `    Left Join ${this.ctx.service.tender.tableName} As t ON sa.tid = t.id `+
-                '  WHERE sa.`audit_id` = ? and sa.`audit_status` = ?' + spSql +
+                '  WHERE sa.`audit_id` = ? and (sa.`audit_status` = ? or (sa.audit_times > 1 and sa.audit_status = ? and sa.audit_order = 0))' + spSql +
                 '  ORDER BY sa.`create_time` DESC';
-            const sqlParam = [auditorId, auditConst.common.status.checking];
+            const sqlParam = [auditorId, auditConst.common.status.checking, auditConst.common.status.uncheck];
             const result = await this.db.query(sql, sqlParam);
             for (const r of result) {
-                const preAuditTime = await this.db.queryOne(`SELECT Max(audit_time) as audit_time FROM ${this.tableName} where stage_id = ? and audit_times = ? and active_order = ?`, [r.stage_id, r.audit_times, r.active_order]);
-                r.begin_time = preAuditTime.audit_time;
+                if (r.audit_order > 0) {
+                    const preAuditTime = await this.db.queryOne(`SELECT Max(audit_time) as audit_time FROM ${this.tableName} where stage_id = ? and audit_times = ? and active_order = ?`, [r.stage_id, r.audit_times, r.active_order]);
+                    r.begin_time = preAuditTime.audit_time;
+                } else {
+                    const checkNoTime = await this.db.queryOne(`SELECT Max(audit_time) as audit_time FROM ${this.tableName} where stage_id = ? and audit_times = ? and audit_status = ?`, [r.stage_id, r.audit_times - 1, auditConst.common.status.checkNo]);
+                    r.begin_time = checkNoTime.audit_time;
+                }
             }
             return result;
         }