Browse Source

台账修订列表相关

MaiXinRong 10 months ago
parent
commit
82085440b8
2 changed files with 42 additions and 1 deletions
  1. 2 1
      app/controller/revise_controller.js
  2. 40 0
      app/service/revise_audit.js

+ 2 - 1
app/controller/revise_controller.js

@@ -123,7 +123,8 @@ module.exports = app => {
                 }
                 for (const lr of ledgerRevise) {
                     if (lr.valid) {
-                        lr.curAuditor = await ctx.service.reviseAudit.getAuditorByStatus(lr.id, lr.status, lr.times);
+                        lr.curAuditors = await ctx.service.reviseAudit.getAuditorsByStatus(lr.id, lr.status, lr.times);
+                        lr.curAuditorIds = lr.curAuditors.map(x => { return x.audit_id; });
                     }
                 }
                 const [addVisible, addValid, changeValid] = await this._getAddReviseValid(ctx);

+ 40 - 0
app/service/revise_audit.js

@@ -978,6 +978,46 @@ module.exports = app => {
         }
 
         /**
+         * 获取最新的审批人状态
+         *
+         * @param {Number} rid - 修订id
+         * @param {Number} status - 修订状态
+         * @param {Number} times - 修订次数
+         * @return {Promise<boolean>}
+         */
+        async getAuditorsByStatus(rid, status, times = 1) {
+            let cur;
+            let sql = '';
+            let sqlParam = '';
+            switch (status) {
+                case auditConst.status.checking:
+                case auditConst.status.checked:
+                case auditConst.status.checkNoPre:
+                    cur = await this.db.queryOne(`SELECT * From ${this.tableName} where rid = ? AND times = ? AND status = ? ORDER By times DESC, ` + '`audit_order` DESC', [rid, times, status]);
+                    if (!cur) return [];
+
+                    sql = 'SELECT la.`audit_id`, pa.`name`, pa.`company`, pa.`role`, la.`times`, la.`tender_id`, la.audit_order, la.audit_type, la.audit_ledger_id ' +
+                        '  FROM ?? AS la Left Join ?? AS pa On la.`audit_id` = pa.`id` ' +
+                        '  WHERE la.rid = ? and la.`audit_order` = ? and la.`times` = ?';
+                    sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, rid, cur.audit_order, times];
+                    return await this.db.query(sql, sqlParam);
+                case auditConst.status.checkNo:
+                    cur = await this.db.queryOne(`SELECT * From ${this.tableName} where rid = ? AND times = ? AND status = ? ORDER By times DESC, ` + '`audit_order` DESC', [rid, parseInt(times) - 1, status]);
+                    if (!cur) return [];
+
+                    sql = 'SELECT la.`audit_id`, pa.`name`, pa.`company`, pa.`role`, la.`times`, la.`tender_id`, la.audit_order, la.audit_type, la.audit_ledger_id ' +
+                        '  FROM ?? AS la Left Join ?? AS pa On la.`audit_id` = pa.`id` ' +
+                        '  WHERE la.rid = ? and la.`audit_order` = ? and la.`times` = ?';
+                    sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, rid, cur.audit_order, parseInt(times) - 1];
+                    return await this.db.query(sql, sqlParam);
+                case auditConst.status.uncheck:
+                    return [];
+                default:
+                    return [];
+            }
+        }
+
+        /**
          * 获取审核人流程列表
          *
          * @param auditorId