|
@@ -204,6 +204,29 @@ module.exports = app => {
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+ async getTpData(materialId) {
|
|
|
+ const materialInfo = await this.ctx.material.getDataById(materialId);
|
|
|
+ const tp_data = {
|
|
|
+ m_tp: materialInfo.m_tp,
|
|
|
+ m_tax_tp: materialInfo.m_tax_tp,
|
|
|
+ }
|
|
|
+ if (materialInfo.is_stage_self) {
|
|
|
+ const materialStageList = await this.ctx.materialStage.getAllDataByCondition({ where: { mid: materialId }});
|
|
|
+ const stage_tp = [];
|
|
|
+ for (const ms of materialStageList) {
|
|
|
+ stage_tp.push({
|
|
|
+ id: ms.id,
|
|
|
+ sid: ms.sid,
|
|
|
+ order: ms.order,
|
|
|
+ m_tp: ms.m_tp,
|
|
|
+ m_tax_tp: ms.m_tax_tp,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ tp_data.stage_tp = stage_tp;
|
|
|
+ }
|
|
|
+ return tp_data;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 开始审批
|
|
|
* @param {Number} materialId - 材料调差期id
|
|
@@ -222,10 +245,11 @@ module.exports = app => {
|
|
|
}
|
|
|
|
|
|
const transaction = await this.db.beginTransaction();
|
|
|
+ const tp_data = await this.getTpData(materialId);
|
|
|
try {
|
|
|
await transaction.update(this.tableName, { id: audit.id, status: auditConst.status.checking, begin_time: new Date() });
|
|
|
await transaction.update(this.ctx.service.material.tableName, {
|
|
|
- id: materialId, status: auditConst.status.checking,
|
|
|
+ id: materialId, status: auditConst.status.checking, tp_data: JSON.stringify(tp_data),
|
|
|
});
|
|
|
// 本期一些必要数据(如应耗数量和上期调差金额)插入到material_bills_history表里
|
|
|
const materialBillsData = await this.ctx.service.materialBills.getAllDataByCondition({ where: { tid: this.ctx.tender.id } });
|
|
@@ -286,10 +310,12 @@ module.exports = app => {
|
|
|
|
|
|
const nextAudit = await this.getDataByCondition({ mid: materialId, times, order: audit.order + 1 });
|
|
|
|
|
|
+ // 获取当前总金额及独立单价期的金额,添加到tp_data中,报表使用
|
|
|
+ const tp_data = await this.getTpData(materialId);
|
|
|
|
|
|
const transaction = await this.db.beginTransaction();
|
|
|
try {
|
|
|
- await transaction.update(this.tableName, { id: audit.id, status: checkData.checkType, opinion: checkData.opinion, end_time: time });
|
|
|
+ await transaction.update(this.tableName, { id: audit.id, status: checkData.checkType, opinion: checkData.opinion, end_time: time, tp_data: JSON.stringify(tp_data) });
|
|
|
|
|
|
// 获取推送必要信息
|
|
|
const noticeContent = await this.getNoticeContent(pid, audit.tid, materialId, audit.aid, checkData.opinion);
|
|
@@ -469,8 +495,9 @@ module.exports = app => {
|
|
|
order++;
|
|
|
}
|
|
|
const transaction = await this.db.beginTransaction();
|
|
|
+ const tp_data = await this.getTpData(materialId);
|
|
|
try {
|
|
|
- await transaction.update(this.tableName, { id: audit.id, status: checkData.checkType, opinion: checkData.opinion, end_time: time });
|
|
|
+ await transaction.update(this.tableName, { id: audit.id, status: checkData.checkType, opinion: checkData.opinion, end_time: time, tp_data: JSON.stringify(tp_data), });
|
|
|
// 添加到消息推送表
|
|
|
const noticeContent = await this.getNoticeContent(pid, audit.tid, materialId, audit.aid, checkData.opinion);
|
|
|
const records = [{ pid, type: pushType.material, uid: this.ctx.material.user_id, status: auditConst.status.checkNo, content: noticeContent }];
|
|
@@ -564,6 +591,7 @@ module.exports = app => {
|
|
|
const preAuditor = auditors2[auditorIndex - 1];
|
|
|
const noticeContent = await this.getNoticeContent(pid, audit.tid, materialId, audit.aid, checkData.opinion);
|
|
|
const transaction = await this.db.beginTransaction();
|
|
|
+ const tp_data = await this.getTpData(materialId);
|
|
|
try {
|
|
|
// 添加到消息推送表
|
|
|
const records = [{ pid, type: pushType.material, uid: this.ctx.material.user_id, status: auditConst.status.checkNoPre, content: noticeContent }];
|
|
@@ -571,7 +599,7 @@ module.exports = app => {
|
|
|
records.push({ pid, type: pushType.material, uid: audit.aid, status: auditConst.status.checkNoPre, content: noticeContent });
|
|
|
});
|
|
|
await transaction.insert('zh_notice', records);
|
|
|
- await transaction.update(this.tableName, { id: audit.id, status: checkData.checkType, opinion: checkData.opinion, end_time: time });
|
|
|
+ await transaction.update(this.tableName, { id: audit.id, status: checkData.checkType, opinion: checkData.opinion, end_time: time, tp_data: JSON.stringify(tp_data) });
|
|
|
// 顺移气候审核人流程顺序
|
|
|
this.initSqlBuilder();
|
|
|
this.sqlBuilder.setAndWhere('mid', { value: materialId, operate: '=' });
|