|
|
@@ -186,41 +186,43 @@ module.exports = app => {
|
|
|
async _loadDealBillsData(tender) {
|
|
|
|
|
|
}
|
|
|
- async _getValidStages(tenderId, sort = 'desc') {
|
|
|
+ async _getValidStages(tenderId, sort = 'desc', checked = false) {
|
|
|
const accountId = this.ctx.session.sessionUser.accountId;
|
|
|
- const stages = await this.ctx.service.stage.getAllDataByCondition({ where: { tid: tenderId }, orders: [['order', sort]] });
|
|
|
+ const condition = { tid: tenderId };
|
|
|
+ if (checked) condition.status = status.checked;
|
|
|
+ const stages = await this.ctx.service.stage.getAllDataByCondition({ where: condition, orders: [['order', sort]] });
|
|
|
return stages.filter(s => { return s.status !== status.uncheck || s.user_id === accountId; });
|
|
|
}
|
|
|
- async _filterOrder(tender, order) {
|
|
|
- const stages = await this._getValidStages(tender.id);
|
|
|
+ async _filterOrder(tender, order, checked) {
|
|
|
+ const stages = await this._getValidStages(tender.id, 'desc', checked);
|
|
|
const stage = this.ctx.helper._.find(stages, { order });
|
|
|
if (stage) await this.ctx.service.stage.doCheckStage(stage);
|
|
|
return { type: 'stage', stage, filter: `第${order}期` };
|
|
|
}
|
|
|
- async _filterMonth(tender, month) {
|
|
|
- const stages = await this._getValidStages(tender.id);
|
|
|
+ async _filterMonth(tender, month, checked) {
|
|
|
+ const stages = await this._getValidStages(tender.id, 'desc', checked);
|
|
|
const stage = this.ctx.helper._.find(stages, { s_time: month });
|
|
|
if (stage) await this.ctx.service.stage.doCheckStage(stage);
|
|
|
return { type: 'stage', stage, filter: month };
|
|
|
}
|
|
|
- async _filterFinal(tender) {
|
|
|
- const stages = await this._getValidStages(tender.id);
|
|
|
+ async _filterFinal(tender, checked) {
|
|
|
+ const stages = await this._getValidStages(tender.id, 'desc', checked);
|
|
|
const stage = stages[0];
|
|
|
if (stage) await this.ctx.service.stage.doCheckStage(stage);
|
|
|
return { type: 'stage', stage, filter: `第${stage.order}期` };
|
|
|
}
|
|
|
- async _filterCheckedFinal(tender) {
|
|
|
- const stages = await this._getValidStages(tender.id);
|
|
|
+ async _filterCheckedFinal(tender, checked) {
|
|
|
+ const stages = await this._getValidStages(tender.id, 'desc', checked);
|
|
|
const checkedStages = stages.filter(x => { return x.status === status.checked; });
|
|
|
const stage = checkedStages[0];
|
|
|
if (stage) await this.ctx.service.stage.doCheckStage(stage);
|
|
|
return { type: 'stage', stage, filter: `第${stage.order}期` };
|
|
|
}
|
|
|
- async _filterOrderZone(tender, zone) {
|
|
|
+ async _filterOrderZone(tender, zone, checked) {
|
|
|
let [iBegin, iEnd] = zone.split(':');
|
|
|
iBegin = this.ctx.helper._.toInteger(iBegin) || 0;
|
|
|
iEnd = this.ctx.helper._.toInteger(iEnd) || 0;
|
|
|
- const stages = await this._getValidStages(tender.id, 'asc'), validStages = [];
|
|
|
+ const stages = await this._getValidStages(tender.id, 'asc', checked), validStages = [];
|
|
|
let preStage, endStage;
|
|
|
for (const stage of stages) {
|
|
|
if (stage.order < iBegin) {
|
|
|
@@ -233,13 +235,13 @@ module.exports = app => {
|
|
|
}
|
|
|
return { type: 'stages', stages: validStages, preStage, endStage, filter: `第${iBegin}期 ~ 第${iEnd}期` };
|
|
|
}
|
|
|
- async _filterTimeZone(tender, zone) {
|
|
|
+ async _filterTimeZone(tender, zone, checked) {
|
|
|
const times = zone.split(' - ');
|
|
|
if (times.length !== 2) throw '选择的汇总周期无效';
|
|
|
const beginTime = moment(times[0], 'YYYY-MM');
|
|
|
const endTime = moment(times[1], 'YYYY-MM');
|
|
|
|
|
|
- const stages = await this._getValidStages(tender.id, 'asc'), validStages = [];
|
|
|
+ const stages = await this._getValidStages(tender.id, 'asc', checked), validStages = [];
|
|
|
let preStage, endStage;
|
|
|
for (const stage of stages) {
|
|
|
const sTime = moment(stage.s_time, 'YYYY-MM');
|
|
|
@@ -256,17 +258,17 @@ module.exports = app => {
|
|
|
async _filterStages(tender, stageInfo) {
|
|
|
switch (stageInfo.type) {
|
|
|
case 'stage':
|
|
|
- return await this._filterOrder(tender, stageInfo.stage);
|
|
|
+ return await this._filterOrder(tender, stageInfo.stage, stageInfo.checked);
|
|
|
case 'month':
|
|
|
- return await this._filterMonth(tender, stageInfo.month);
|
|
|
+ return await this._filterMonth(tender, stageInfo.month, stageInfo.checked);
|
|
|
case 'final':
|
|
|
- return await this._filterFinal(tender);
|
|
|
+ return await this._filterFinal(tender, stageInfo.checked);
|
|
|
case 'checked-final':
|
|
|
- return await this._filterCheckedFinal(tender);
|
|
|
+ return await this._filterCheckedFinal(tender, stageInfo.checked);
|
|
|
case 'zone':
|
|
|
- return await this._filterTimeZone(tender, stageInfo.zone);
|
|
|
+ return await this._filterTimeZone(tender, stageInfo.zone, stageInfo.checked);
|
|
|
case 'stage-zone':
|
|
|
- return await this._filterOrderZone(tender, stageInfo.stage_zone);
|
|
|
+ return await this._filterOrderZone(tender, stageInfo.stage_zone, stageInfo.checked);
|
|
|
default:
|
|
|
return;
|
|
|
}
|