|
@@ -1213,7 +1213,7 @@ module.exports = app => {
|
|
|
if (!gsDefine || !gsDefine.enable) return [];
|
|
|
if (!gsCustom || !gsCustom.tenders || gsCustom.tenders.length === 0) return [];
|
|
|
|
|
|
- this.resultTenderInfo = [];
|
|
|
+ this.resultDealBills = [];
|
|
|
const gsSetting = JSON.parse(gsDefine.setting);
|
|
|
let commonIndex = 0;
|
|
|
const completeDatas = [];
|
|
@@ -1343,6 +1343,88 @@ module.exports = app => {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ async _gatherStageChange(completeData, tender, stage, hasPre, gatherType = 'flow'){
|
|
|
+ if (!stage) return [];
|
|
|
+ const helper = this.ctx.helper;
|
|
|
+ await this.ctx.service.stage.doCheckStage(stage);
|
|
|
+
|
|
|
+ const curStageChange = await this.ctx.service.stageChange.getCurStageData(stage.tid, stage.id, stage.curTimes, stage.curOrder);
|
|
|
+ const preStageChange = hasPre && stage.preCheckedStage ? await this.ctx.service.stageChangeFinal.getEndStageData(stage.tid, stage.preCheckedStage.order) : [];
|
|
|
+ if (gatherType === 'flow') return [...curStageChange, ...preStageChange];
|
|
|
+
|
|
|
+ const result = [];
|
|
|
+ const findR = function(source) {
|
|
|
+ let r = result.find(x => { return x.cbid === source.cbid});
|
|
|
+ if (!r) {
|
|
|
+ r = { cid: source.cid, cbid: source.cbid, qty: 0, pre_qty: 0 };
|
|
|
+ result.push(r);
|
|
|
+ }
|
|
|
+ return r;
|
|
|
+ };
|
|
|
+ curStageChange.forEach(sc => {
|
|
|
+ const r = findR(sc);
|
|
|
+ r.qty = helper.add(r.qty, sc.qty);
|
|
|
+ });
|
|
|
+ preStageChange.forEach(sc => {
|
|
|
+ const r = findR(sc);
|
|
|
+ r.pre_qty = helper.add(r.pre_qty, sc.qty);
|
|
|
+ });
|
|
|
+ result.forEach(r => { r.end_qty = helper.add(r.pre_qty, r.qty); });
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ async _gatherMonthStageChange(sTender, completeData, month, hasPre, gatherType) {
|
|
|
+ const tender = await this.ctx.service.tender.getCheckTender(sTender.tid);
|
|
|
+ const stages = await this._getValidStages(tender.id);
|
|
|
+ const stage = this.ctx.helper._.find(stages, {s_time: month});
|
|
|
+ await this._gatherStageChange(completeData, tender, stage, hasPre, gatherType);
|
|
|
+ }
|
|
|
+ async _gatherOrderStageChange(sTender, completeData, order, hasPre, gatherType) {
|
|
|
+ const tender = await this.ctx.service.tender.getCheckTender(sTender.tid);
|
|
|
+ const stages = await this._getValidStages(tender.id);
|
|
|
+ const stage = this.ctx.helper._.find(stages, {order: order});
|
|
|
+ await this._gatherStageChange(completeData, tender, stage, hasPre, gatherType);
|
|
|
+ }
|
|
|
+ async _gatherFinalStageChange(sTender, completeData, hasPre, gatherType) {
|
|
|
+ const tender = await this.ctx.service.tender.getCheckTender(sTender.tid);
|
|
|
+ const stages = await this._getValidStages(tender.id);
|
|
|
+ await this._gatherStageChange(completeData, tender, stages[0], hasPre, gatherType);
|
|
|
+ }
|
|
|
+ async _gatherCheckedFinalStageChange(sTender, completeData, hasPre, gatherType) {
|
|
|
+ const tender = await this.ctx.service.tender.getCheckTender(sTender.tid);
|
|
|
+ const stages = await this._getCheckedStages(tender.id);
|
|
|
+ await this._gatherStageChange(completeData, tender, stages[0], hasPre, gatherType);
|
|
|
+ }
|
|
|
+ async getGatherStageChange(memFieldKeys, gsDefine, gsCustom) {
|
|
|
+ if (!gsDefine || !gsDefine.enable) return [];
|
|
|
+ if (!gsCustom || !gsCustom.tenders || gsCustom.tenders.length === 0) return [];
|
|
|
+ const gsSetting = JSON.parse(gsDefine.setting);
|
|
|
+ if (gsSetting.type !== 'stage') return [];
|
|
|
+
|
|
|
+ this.resultStageChange = [];
|
|
|
+ let commonIndex = 0;
|
|
|
+ const completeDatas = [];
|
|
|
+ for (const tender of gsCustom.tenders) {
|
|
|
+ const completeData = { prefix: 't_' + commonIndex + '_' };
|
|
|
+ completeDatas.push(completeData);
|
|
|
+ switch (gsSetting.type) {
|
|
|
+ case 'month':
|
|
|
+ await this._gatherMonthStageChange(tender, completeData, gsCustom.month, gsSetting.hasPre, gsSetting.gather);
|
|
|
+ break;
|
|
|
+ case 'final':
|
|
|
+ await this._gatherFinalStageChange(tender, completeData, gsSetting.hasPre, gsSetting.gather);
|
|
|
+ break;
|
|
|
+ case 'checked-final':
|
|
|
+ await this._gatherCheckedFinalStageChange(tender, completeData, gsSetting.hasPre, gsSetting.gather);
|
|
|
+ break;
|
|
|
+ case 'stage':
|
|
|
+ await this._gatherOrderStageChange(tender, completeData, gsCustom.stage, gsSetting.hasPre, gsSetting.gather);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ commonIndex++;
|
|
|
+ }
|
|
|
+ return this.resultStageChange;
|
|
|
+ }
|
|
|
+
|
|
|
async getGatherAdvancePay(memFieldKeys, gsDefine, gsCustom) {
|
|
|
if (!gsDefine || !gsDefine.enable) return [];
|
|
|
if (!gsCustom || !gsCustom.tenders || gsCustom.tenders.length === 0) return [];
|