|
|
@@ -590,6 +590,54 @@ module.exports = app => {
|
|
|
return checkData.checkResult.error;
|
|
|
}
|
|
|
|
|
|
+ async _checkChangeDetail(ctx) {
|
|
|
+ const errors = [];
|
|
|
+ const checkBills = await this.ctx.service.stageChange.getUsedId(ctx.stage.id);
|
|
|
+ const curBillsData = ctx.stage.readOnly
|
|
|
+ ? await ctx.service.stageBills.getAuditorStageData2(ctx.tender.id, ctx.stage.id, ctx.stage.curTimes, ctx.stage.curOrder)
|
|
|
+ : await ctx.service.stageBills.getLastestStageData2(ctx.tender.id, ctx.stage.id);
|
|
|
+ this.ctx.helper.assignRelaData(checkBills, [
|
|
|
+ { data: curBillsData, fields: ['qc_qty', 'qc_minus_qty'], prefix: '', relaId: 'lid' },
|
|
|
+ ], 'lid');
|
|
|
+ const checkPos = await this.ctx.service.stageChange.getUsedId(ctx.stage.id, false);
|
|
|
+ const curPosData = ctx.stage.readOnly
|
|
|
+ ? await ctx.service.stagePos.getAuditorStageData2(ctx.tender.id, ctx.stage.id, ctx.stage.curTimes, ctx.stage.curOrder)
|
|
|
+ : await ctx.service.stagePos.getLastestStageData2(ctx.tender.id, ctx.stage.id);
|
|
|
+ this.ctx.helper.assignRelaData(checkPos, [
|
|
|
+ { data: curPosData, fields: ['qc_qty', 'qc_minus_qty'], prefix: '', relaId: 'pid' },
|
|
|
+ ], 'pid');
|
|
|
+ const stageChange = ctx.stage.readOnly
|
|
|
+ ? await ctx.service.stageChange.getAuditorAllStageData(ctx.tender.id, ctx.stage.id, ctx.stage.curTimes, ctx.stage.curOrder)
|
|
|
+ : await ctx.service.stageChange.getLastestAllStageData(ctx.tender.id, ctx.stage.id);
|
|
|
+ for (const cb of checkBills) {
|
|
|
+ const useChanges = stageChange.filter(sc => { return sc.lid === cb.lid && sc.pid === '-1'});
|
|
|
+ const checkQcQty = cb.qc_qty || 0, checkQcMinusQty = cb.qc_minus_qty || 0;
|
|
|
+ let qc_qty = 0, qc_minus_qty = 0;
|
|
|
+ for (const uc of useChanges) {
|
|
|
+ if (uc.no_value) {
|
|
|
+ qc_minus_qty = this.ctx.helper.add(qc_minus_qty, uc.qty);
|
|
|
+ } else {
|
|
|
+ qc_qty = this.ctx.helper.add(qc_qty, uc.qty);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (qc_qty !== checkQcQty || qc_minus_qty !== checkQcMinusQty) errors.push({ lid: cb.lid });
|
|
|
+ }
|
|
|
+ for (const cb of checkPos) {
|
|
|
+ const useChanges = stageChange.filter(sc => { return sc.lid === cb.lid && sc.pid === cb.pid; });
|
|
|
+ const checkQcQty = cb.qc_qty || 0, checkQcMinusQty = cb.qc_minus_qty || 0;
|
|
|
+ let qc_qty = 0, qc_minus_qty = 0;
|
|
|
+ for (const uc of useChanges) {
|
|
|
+ if (uc.no_value) {
|
|
|
+ qc_minus_qty = this.ctx.helper.add(qc_minus_qty, uc.qty);
|
|
|
+ } else {
|
|
|
+ qc_qty = this.ctx.helper.add(qc_qty, uc.qty);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (qc_qty !== checkQcQty || qc_minus_qty !== checkQcMinusQty) errors.push({ lid: cb.lid, pid: cb.pid });
|
|
|
+ }
|
|
|
+ return errors;
|
|
|
+ }
|
|
|
+
|
|
|
async stageCheck(ctx) {
|
|
|
try {
|
|
|
if (!ctx.query.type) throw '参数错误';
|
|
|
@@ -603,6 +651,9 @@ module.exports = app => {
|
|
|
case 'change_over':
|
|
|
result.change_over = await this._checkChangeBillsOver(ctx);
|
|
|
break;
|
|
|
+ case 'change_detail':
|
|
|
+ result.change_detail = ctx.session.sessionUser.loginStatus ? await this._checkChangeDetail(ctx) : [];
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
ctx.body = { err: 0, msg: '', data: result };
|