|
@@ -389,6 +389,32 @@ module.exports = app => {
|
|
|
// const sqlParam = [this.tableName, stageId, times];
|
|
|
// return await this.db.query(sql, sqlParam);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 复制上一期的审批人列表给最新一期
|
|
|
+ *
|
|
|
+ * @param transaction - 新增一期的事务
|
|
|
+ * @param {Object} preStage - 上一期
|
|
|
+ * @param {Object} newStage - 最新一期
|
|
|
+ * @returns {Promise<*>}
|
|
|
+ */
|
|
|
+ async copyPreStageAuditors(transaction, preStage, newStage) {
|
|
|
+ const auditors = await this.getAuditGroupByList(preStage.id, preStage.times);
|
|
|
+ const newAuditors = [];
|
|
|
+ for (const a of auditors) {
|
|
|
+ const na = {
|
|
|
+ tid: preStage.tid,
|
|
|
+ sid: newStage.id,
|
|
|
+ aid: a.aid,
|
|
|
+ times: newStage.times,
|
|
|
+ order: newAuditors.length + 1,
|
|
|
+ status: auditConst.status.uncheck
|
|
|
+ };
|
|
|
+ newAuditors.push(na);
|
|
|
+ }
|
|
|
+ const result = await transaction.insert(this.tableName, newAuditors);
|
|
|
+ return result.effectRows = auditors.length;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
return StageAudit;
|