|
|
@@ -141,6 +141,9 @@ module.exports = app => {
|
|
|
safeStage.userIds = safeStage.audit_status === audit.status.uncheck // 当前流程下全部参与人id
|
|
|
? [safeStage.user_id]
|
|
|
: safeStage.auditorIds;
|
|
|
+ if (safeStage.audit_status === audit.status.checkNo) {
|
|
|
+ safeStage.checkNoAuditors = await this.ctx.service.safeStageAudit.getAuditorsByStatus(safeStage.id, audit.status.checkNo, safeStage.audit_times-1);
|
|
|
+ }
|
|
|
}
|
|
|
async loadAuditViewData(safeStage) {
|
|
|
if (!safeStage.user) safeStage.user = await this.ctx.service.projectAccount.getAccountInfoById(safeStage.user_id);
|
|
|
@@ -296,7 +299,7 @@ module.exports = app => {
|
|
|
return user;
|
|
|
}
|
|
|
async copyPaySafeData(payTenderId) {
|
|
|
- const details = await this.ctx.service.paymentDetail.getAllDataByCondition({ where: { tender_id: payTenderId, type: 1 } });
|
|
|
+ const details = await this.ctx.service.paymentDetail.getAllDataByCondition({ where: { tender_id: payTenderId, type: 1 }, orders: [['order', 'asc']] });
|
|
|
const tid = this.ctx.tender.id;
|
|
|
const conn = await this.db.beginTransaction();
|
|
|
try {
|
|
|
@@ -311,6 +314,12 @@ module.exports = app => {
|
|
|
};
|
|
|
insertStage.push(stage);
|
|
|
const safeBills = await this.ctx.service.paymentSafeBills.getAllDataByCondition({ where: { detail_id: detail.id } });
|
|
|
+ const exist = safeBills.length > 0 ? await this.ctx.service.safeStageBills.getDataById(safeBills[0].id) : null;
|
|
|
+ if (exist) {
|
|
|
+ const existTender = await this.ctx.service.tender.getDataById(exist.tender_id);
|
|
|
+ throw '该标段安全生产费数据已迁移' + (existTender ? `至标段【${existTender.name}】下,请勿重复迁移` : '');
|
|
|
+ }
|
|
|
+ let tp = 0, pre_tp = 0;
|
|
|
for (const sb of safeBills) {
|
|
|
sb.tender_id = tid;
|
|
|
delete sb.detail_id;
|
|
|
@@ -323,8 +332,14 @@ module.exports = app => {
|
|
|
delete h.order;
|
|
|
}
|
|
|
sb.cur_his = JSON.stringify(his);
|
|
|
+ if (sb.tree_is_leaf) {
|
|
|
+ pre_tp = this.ctx.helper.add(pre_tp, sb.pre_tp);
|
|
|
+ tp = this.ctx.helper.add(tp, sb.cur_tp);
|
|
|
+ }
|
|
|
insertBills.push(sb);
|
|
|
}
|
|
|
+ stage.pre_bills_tp = pre_tp;
|
|
|
+ stage.bills_tp = tp;
|
|
|
const user = await this._getUserInfo(detail.uid);
|
|
|
const audits = await this.ctx.service.paymentDetailAudit.getAllDataByCondition({ where: { td_id: detail.id }, orders: [['times', 'asc'], ['order', 'asc']]});
|
|
|
if (detail.status === audit.status.checked) {
|
|
|
@@ -335,7 +350,7 @@ module.exports = app => {
|
|
|
insertAudit.push({
|
|
|
tid, stage_id: stage.id, audit_id: user.id,
|
|
|
name: user.name, company: user.company, role: user.role, mobile: user.mobile,
|
|
|
- audit_times: a.times, audit_order: 0, active_order: 0, audit_type: auditType.key.common,
|
|
|
+ audit_times: 1, audit_order: 0, active_order: 0, audit_type: auditType.key.common,
|
|
|
});
|
|
|
}
|
|
|
for (const a of audits) {
|
|
|
@@ -369,8 +384,8 @@ module.exports = app => {
|
|
|
}
|
|
|
}
|
|
|
await conn.insert(this.tableName, insertStage);
|
|
|
- await conn.insert(this.ctx.service.safeStageBills.tableName, insertBills);
|
|
|
- await conn.insert(this.ctx.service.safeStageAudit.tableName, insertAudit);
|
|
|
+ if (insertBills.length > 0) await conn.insert(this.ctx.service.safeStageBills.tableName, insertBills);
|
|
|
+ if (insertAudit.length > 0) await conn.insert(this.ctx.service.safeStageAudit.tableName, insertAudit);
|
|
|
if (insertFile.length > 0) await conn.insert(this.ctx.service.safeStageFile.tableName, insertFile);
|
|
|
await conn.commit();
|
|
|
} catch (err) {
|