|
@@ -895,7 +895,7 @@ module.exports = app => {
|
|
* @param {Number} times - 第几次审批
|
|
* @param {Number} times - 第几次审批
|
|
* @return {Promise<void>}
|
|
* @return {Promise<void>}
|
|
*/
|
|
*/
|
|
- async checkAgain(stageId, times = 1) {
|
|
|
|
|
|
+ async checkAgain(stageId, times = 1, force) {
|
|
const accountId = this.ctx.session.sessionUser.accountId;
|
|
const accountId = this.ctx.session.sessionUser.accountId;
|
|
const time = new Date();
|
|
const time = new Date();
|
|
// 整理当前流程审核人状态更新
|
|
// 整理当前流程审核人状态更新
|
|
@@ -907,7 +907,8 @@ module.exports = app => {
|
|
const audits = auditors.filter(x => { return x.order === maxOrder});
|
|
const audits = auditors.filter(x => { return x.order === maxOrder});
|
|
if (!audits || audits.length === 0 || maxOrder < 1) throw '审核数据错误';
|
|
if (!audits || audits.length === 0 || maxOrder < 1) throw '审核数据错误';
|
|
const selfAudit = audits.find(x => { return x.aid === accountId; });
|
|
const selfAudit = audits.find(x => { return x.aid === accountId; });
|
|
- if (!selfAudit) throw '当前标段您无权审批';
|
|
|
|
|
|
+ if (!selfAudit && !force) throw '当前标段您无权审批';
|
|
|
|
+ const finalAudit = selfAudit || audits[0];
|
|
const stageInfo = await this.ctx.service.stage.getDataById(stageId);
|
|
const stageInfo = await this.ctx.service.stage.getDataById(stageId);
|
|
|
|
|
|
const transaction = await this.db.beginTransaction();
|
|
const transaction = await this.db.beginTransaction();
|
|
@@ -918,7 +919,7 @@ module.exports = app => {
|
|
checkAgainAuditors.push({
|
|
checkAgainAuditors.push({
|
|
tid: x.tid, sid: x.sid, aid: x.aid,
|
|
tid: x.tid, sid: x.sid, aid: x.aid,
|
|
times: x.times, order: x.order + 1,
|
|
times: x.times, order: x.order + 1,
|
|
- status: x.aid === selfAudit.aid ? auditConst.status.checkAgain : auditConst.status.checkSkip,
|
|
|
|
|
|
+ status: !selfAudit || x.aid === selfAudit.aid ? auditConst.status.checkAgain : auditConst.status.checkSkip,
|
|
begin_time: time, end_time: time, opinion: '',
|
|
begin_time: time, end_time: time, opinion: '',
|
|
audit_type: x.audit_type, audit_order: x.audit_order,
|
|
audit_type: x.audit_type, audit_order: x.audit_order,
|
|
});
|
|
});
|
|
@@ -936,8 +937,8 @@ module.exports = app => {
|
|
await transaction.insert(this.tableName, checkingAuditors);
|
|
await transaction.insert(this.tableName, checkingAuditors);
|
|
|
|
|
|
// 复制一份最新数据给下一人
|
|
// 复制一份最新数据给下一人
|
|
- await this.ctx.service.stagePay.copyAuditStagePays(this.ctx.stage, this.ctx.stage.times, selfAudit.order + 1, transaction);
|
|
|
|
- await this.ctx.service.stagePay.copyAuditStagePays(this.ctx.stage, this.ctx.stage.times, selfAudit.order + 2, transaction);
|
|
|
|
|
|
+ await this.ctx.service.stagePay.copyAuditStagePays(this.ctx.stage, this.ctx.stage.times, finalAudit.order + 1, transaction);
|
|
|
|
+ await this.ctx.service.stagePay.copyAuditStagePays(this.ctx.stage, this.ctx.stage.times, finalAudit.order + 2, transaction);
|
|
await this.ctx.service.stageJgcl.updateHistory4CheckAgain(this.ctx.stage, transaction);
|
|
await this.ctx.service.stageJgcl.updateHistory4CheckAgain(this.ctx.stage, transaction);
|
|
await this.ctx.service.stageBonus.updateHistory4CheckAgain(this.ctx.stage, transaction);
|
|
await this.ctx.service.stageBonus.updateHistory4CheckAgain(this.ctx.stage, transaction);
|
|
await this.ctx.service.stageOther.updateHistory4CheckAgain(this.ctx.stage, transaction);
|
|
await this.ctx.service.stageOther.updateHistory4CheckAgain(this.ctx.stage, transaction);
|
|
@@ -945,7 +946,7 @@ module.exports = app => {
|
|
await this.ctx.service.stageTempLand.updateHistory4CheckAgain(this.ctx.stage, transaction);
|
|
await this.ctx.service.stageTempLand.updateHistory4CheckAgain(this.ctx.stage, transaction);
|
|
|
|
|
|
// 同步 期信息
|
|
// 同步 期信息
|
|
- const his = this.ctx.stage.tp_history.find(x => { return x.times === times && x.order === selfAudit.order });
|
|
|
|
|
|
+ const his = this.ctx.stage.tp_history.find(x => { return x.times === times && x.order === finalAudit.order });
|
|
const stageTp = {
|
|
const stageTp = {
|
|
contract_tp: his.contract_tp,
|
|
contract_tp: his.contract_tp,
|
|
qc_tp: his.qc_tp,
|
|
qc_tp: his.qc_tp,
|
|
@@ -954,7 +955,7 @@ module.exports = app => {
|
|
yf_tp: his.tp,
|
|
yf_tp: his.tp,
|
|
sf_tp: his.tp,
|
|
sf_tp: his.tp,
|
|
};
|
|
};
|
|
- this.ctx.stage.tp_history.push({ times, order: selfAudit.order + 1, ...stageTp });
|
|
|
|
|
|
+ this.ctx.stage.tp_history.push({ times, order: finalAudit.order + 1, ...stageTp });
|
|
await transaction.update(this.ctx.service.stage.tableName, {
|
|
await transaction.update(this.ctx.service.stage.tableName, {
|
|
id: stageId,
|
|
id: stageId,
|
|
status: auditConst.status.checking,
|
|
status: auditConst.status.checking,
|
|
@@ -965,7 +966,7 @@ module.exports = app => {
|
|
await this.ctx.service.revisePrice.cancelPriceUsed(this.ctx.stage, transaction);
|
|
await this.ctx.service.revisePrice.cancelPriceUsed(this.ctx.stage, transaction);
|
|
// 重算所有单价变更
|
|
// 重算所有单价变更
|
|
const priceCalc = new RevisePrice(this.ctx);
|
|
const priceCalc = new RevisePrice(this.ctx);
|
|
- const pcTp = await priceCalc.stageCheckAgainPriceChange(this.ctx.stage, selfAudit.order + 2, transaction);
|
|
|
|
|
|
+ const pcTp = await priceCalc.stageCheckAgainPriceChange(this.ctx.stage, finalAudit.order + 2, transaction);
|
|
await this.ctx.service.tenderCache.updateStageCache4Flow(transaction, this.ctx.stage, auditConst.status.checking, checkingAuditors, checkAgainAuditors, null, stageTp, pcTp);
|
|
await this.ctx.service.tenderCache.updateStageCache4Flow(transaction, this.ctx.stage, auditConst.status.checking, checkingAuditors, checkAgainAuditors, null, stageTp, pcTp);
|
|
|
|
|
|
// 添加短信通知-需要审批提醒功能
|
|
// 添加短信通知-需要审批提醒功能
|
|
@@ -1996,7 +1997,7 @@ module.exports = app => {
|
|
return group;
|
|
return group;
|
|
}
|
|
}
|
|
|
|
|
|
- async getAuditorHistory(stageId, times) {
|
|
|
|
|
|
+ async getAuditorHistory(stageId, times, reverse = false) {
|
|
const history = [];
|
|
const history = [];
|
|
if (times >= 1) {
|
|
if (times >= 1) {
|
|
for (let i = 1; i <= times; i++) {
|
|
for (let i = 1; i <= times; i++) {
|
|
@@ -2041,7 +2042,11 @@ module.exports = app => {
|
|
}
|
|
}
|
|
historyGroup.push(his);
|
|
historyGroup.push(his);
|
|
}
|
|
}
|
|
- history.push(historyGroup);
|
|
|
|
|
|
+ if (reverse) {
|
|
|
|
+ history.push(historyGroup.reverse());
|
|
|
|
+ } else {
|
|
|
|
+ history.push(historyGroup);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return history;
|
|
return history;
|