|
@@ -43,9 +43,25 @@ module.exports = app => {
|
|
|
try {
|
|
|
const schedule = await ctx.service.schedule.getDataByCondition({ tid: ctx.tender.id });
|
|
|
const scheduleMonth = await ctx.service.scheduleMonth.getAllDataByCondition({ where: { tid: ctx.tender.id }, orders: [['yearmonth', 'asc']] });
|
|
|
+ const scheduleStage = await ctx.service.scheduleStage.getAllDataByCondition({ where: { tid: ctx.tender.id }, orders: [['yearmonth', 'asc']] });
|
|
|
+ // 汇总并统计前几个计划月总计划额
|
|
|
+ for (const i in scheduleStage) {
|
|
|
+ let nowIndex = 0;
|
|
|
+ let lastIndex = 0;
|
|
|
+ if (i > 0) {
|
|
|
+ nowIndex = _.findIndex(scheduleMonth, { yearmonth: scheduleStage[i].yearmonth }) + 1;
|
|
|
+ lastIndex = _.findIndex(scheduleMonth, { yearmonth: scheduleStage[i - 1].yearmonth }) + 1;
|
|
|
+ } else {
|
|
|
+ nowIndex = _.findIndex(scheduleMonth, { yearmonth: scheduleStage[i].yearmonth }) + 1;
|
|
|
+ }
|
|
|
+ // 获取新计划月数组
|
|
|
+ const newSm = scheduleMonth.slice(lastIndex, nowIndex);
|
|
|
+ scheduleStage[i].plan_tp = _.sumBy(newSm, 'plan_tp');
|
|
|
+ }
|
|
|
const renderData = {
|
|
|
schedule,
|
|
|
scheduleMonth,
|
|
|
+ scheduleStage,
|
|
|
tender: ctx.tender.data,
|
|
|
tenderMenu: this.menu.tenderMenu,
|
|
|
planMonth: await this._getLastPlanMonth(ctx),
|
|
@@ -358,6 +374,9 @@ module.exports = app => {
|
|
|
case 'reload_stage':
|
|
|
responseData.data = await ctx.service.scheduleStage.changeOrder(data.postData);
|
|
|
break;
|
|
|
+ case 'update_tp':
|
|
|
+ responseData.data = await ctx.service.scheduleStage.updateOneTp(data.postData);
|
|
|
+ break;
|
|
|
default: throw '参数有误';
|
|
|
}
|
|
|
ctx.body = responseData;
|