|
@@ -64,14 +64,12 @@ module.exports = app => {
|
|
|
const date = ctx.request.body.date;
|
|
|
if (!date) throw '请选择支付年月';
|
|
|
const stage = ctx.request.body.stage;
|
|
|
- if (!stage) throw '请选择计量期';
|
|
|
const memo = ctx.request.body.memo;
|
|
|
|
|
|
const pays = await ctx.service.phasePay.getAllPhasePay(ctx.tender.id, 'DESC');
|
|
|
const unCompleteCount = pays.filter(s => { return s.status !== audit.common.status.checked; }).length;
|
|
|
if (unCompleteCount.length > 0) throw `最新一起未审批通过,请审批通过后再新增`;
|
|
|
- // 预留可以关联多期
|
|
|
- const stages = await ctx.service.stage.getAllDataByCondition({ where: { tid: ctx.tender.id, order: stage } });
|
|
|
+ const stages = stage ? await ctx.service.stage.getAllDataByCondition({ where: { tid: ctx.tender.id, order: stage } }) : [];
|
|
|
|
|
|
const newPhase = await ctx.service.phasePay.add(ctx.tender.id, stages, date, memo);
|
|
|
if (!newPhase) throw '新增期失败';
|