|
@@ -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
|
|
* @param auditorId
|