|
@@ -81,6 +81,41 @@ module.exports = app => {
|
|
|
return showLevel ? billsTree.getDefaultDatasByLevel(this.ctx.tender.rpt_show_level) : billsTree.getDefaultDatas();
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ async getStageSumBills(tid, memFieldKeys, gsDefine, gsCustom) {
|
|
|
+ const self = this;
|
|
|
+ if (!gsDefine || !gsDefine.enable) return [];
|
|
|
+ if (!gsCustom || !gsCustom.stages || gsCustom.stages.length === 0) return [];
|
|
|
+
|
|
|
+ await this.ctx.service.tender.checkTender(tid);
|
|
|
+ const posData = await this.ctx.service.pos.getAllDataByCondition({ where: { tid: tender.id} });
|
|
|
+ const calcPrefix = [];
|
|
|
+ for (const s of gsCustom.stages) {
|
|
|
+ const stage = await this.db.get(this.ctx.service.stage.tableName, { tid: this.ctx.tender.id, order: s });
|
|
|
+ if (!stage) continue;
|
|
|
+ await this.ctx.service.stage.doCheckStage(stage);
|
|
|
+
|
|
|
+ const prefix = 's_' + stage.order + '_';
|
|
|
+ calcPrefix.push(prefix);
|
|
|
+ const defaultData = {};
|
|
|
+ defaultData[prefix + 'order'] = stage.order;
|
|
|
+
|
|
|
+ const curStage = stage.readOnly
|
|
|
+ ? await this.ctx.service.stagePos.getAuditorStageData2(this.ctx.tender.id, stage.id, stage.curTimes, stage.curOrder)
|
|
|
+ : await this.ctx.service.stagePos.getLastestStageData2(this.ctx.tender.id, stage.id);
|
|
|
+ this.ctx.helper.assignRelaData(posData, [
|
|
|
+ {data: curStage, fields: ['contract_qty', 'qc_qty'], prefix: prefix, relaId: 'lid', defaultData},
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+ posData.forEach(x => {
|
|
|
+ for (const cp of calcPrefix) {
|
|
|
+ x[cp + 'gather_qty'] = self.helper.add(x[cp + 'contract_qty'], x[cp + 'qc_qty']);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ return posData;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 合同支付
|
|
|
*/
|