|
@@ -406,6 +406,41 @@ module.exports = app => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ async _checkNoPre(materialId, checkData, times) {
|
|
|
+ const time = new Date();
|
|
|
+ // 整理当前流程审核人状态更新
|
|
|
+ const audit = await this.getDataByCondition({ mid: materialId, times, status: auditConst.status.checking });
|
|
|
+ console.log('audit', audit);
|
|
|
+ if (!audit || audit.order <= 1) {
|
|
|
+ throw '审核数据错误';
|
|
|
+ }
|
|
|
+ // 添加重新审批后,不能用order-1,取groupby值里的上一个才对
|
|
|
+ const auditors2 = await this.getAuditGroupByList(materialId, times);
|
|
|
+ const auditorIndex = await auditors2.findIndex(function(item) {
|
|
|
+ return item.aid === audit.aid;
|
|
|
+ });
|
|
|
+ const preAuditor = auditors2[auditorIndex - 1];
|
|
|
+ const transaction = await this.db.beginTransaction();
|
|
|
+ try {
|
|
|
+ await transaction.update(this.tableName, { id: audit.id, status: checkData.checkType, opinion: checkData.opinion, end_time: time });
|
|
|
+ const newAuditors = [];
|
|
|
+ newAuditors.push({
|
|
|
+ tid: audit.tid, mid: audit.mid, aid: preAuditor.aid,
|
|
|
+ times: audit.times, order: audit.order + 1, status: auditConst.status.checking,
|
|
|
+ begin_time: time,
|
|
|
+ });
|
|
|
+ newAuditors.push({
|
|
|
+ tid: audit.tid, mid: audit.mid, aid: audit.aid,
|
|
|
+ times: audit.times, order: audit.order + 2, status: auditConst.status.uncheck,
|
|
|
+ });
|
|
|
+ await transaction.insert(this.tableName, newAuditors);
|
|
|
+ await transaction.commit();
|
|
|
+ } catch (error) {
|
|
|
+ await transaction.rollback();
|
|
|
+ throw error;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 审批
|
|
|
* @param {Number} materialId - 材料调差期id
|
|
@@ -417,6 +452,8 @@ module.exports = app => {
|
|
|
if (checkData.checkType !== auditConst.status.checked && checkData.checkType !== auditConst.status.checkNo && checkData.checkType !== auditConst.status.checkNoPre) {
|
|
|
throw '提交数据错误';
|
|
|
}
|
|
|
+ console.log('checkData:', checkData);
|
|
|
+ console.log('times', times);
|
|
|
switch (checkData.checkType) {
|
|
|
case auditConst.status.checked:
|
|
|
await this._checked(materialId, checkData, times);
|