|
|
@@ -129,12 +129,13 @@ module.exports = app => {
|
|
|
const validLedgerStages = await this.ctx.service.costStage.getAllCheckedStages(ctx.tender.id, 'ledger', 'DESC');
|
|
|
for (const vls of validLedgerStages) {
|
|
|
vls.beenRela = stages.findIndex(x => { return x.rela_stage.sid === vls.id; }) >= 0;
|
|
|
+ vls.canRela = vls.stage_order === stages.length + 1;
|
|
|
}
|
|
|
const renderData = {
|
|
|
stage_type,
|
|
|
auditType: audit.auditType,
|
|
|
stages,
|
|
|
- validLedgerStages: validLedgerStages.filter(x => { return !x.beenRela; }),
|
|
|
+ validLedgerStages: validLedgerStages.filter(x => { return x.canRela; }), //validLedgerStages.filter(x => { return !x.beenRela; }),
|
|
|
auditConst: audit.common,
|
|
|
jsFiles: this.app.jsFiles.common.concat(this.app.jsFiles.cost.cost_stage)
|
|
|
};
|
|
|
@@ -149,13 +150,15 @@ module.exports = app => {
|
|
|
const stage_type = this.ctx.service.costStage.stageType.analysis.key;
|
|
|
const stages = await this.getTypeStages(ctx, stage_type);
|
|
|
// todo 兼容以ledger做关联的情况,届时只需在标段或者项目上设置这个类型即可。
|
|
|
- const analysisType = 'book';
|
|
|
+ const analysisType = this.ctx.subProject.fun_rela.costAnalysisType;
|
|
|
let validRelaStages = await this.ctx.service.costStage.getAllCheckedStages(ctx.tender.id, analysisType, 'DESC');
|
|
|
if (stages.length > 0) {
|
|
|
const checkedStage = stages.find(x => { return x.audit_status === audit.common.status.checked; });
|
|
|
if (checkedStage) validRelaStages = validRelaStages.filter( x => { return x.stage_order > checkedStage.rela_stage.sorder; });
|
|
|
}
|
|
|
const renderData = {
|
|
|
+ analysisType,
|
|
|
+ analysisTypeStr: this.ctx.service.costStage.stageType[analysisType].name,
|
|
|
stage_type,
|
|
|
auditType: audit.auditType,
|
|
|
stages,
|
|
|
@@ -191,10 +194,10 @@ module.exports = app => {
|
|
|
if (!ledgerStage) throw '选择的关联成本不存在';
|
|
|
newStage = await ctx.service.costStage.add(ctx.tender.id, stage_type, ledgerStage.stage_date, { sid: ledgerStage.id, sorder: ledgerStage.stage_order });
|
|
|
} else if (stage_type === 'analysis') {
|
|
|
+ const analysisType = this.ctx.subProject.fun_rela.costAnalysisType;
|
|
|
+ if (analysisType !== ctx.request.body.analysis_type) throw '成本分析应关联的成本类型发生改变,请在界面刷新后再试';
|
|
|
const stage_order = ctx.request.body.stage;
|
|
|
if (!stage_order) throw '请选择关联期';
|
|
|
- // todo 兼容以ledger做关联的情况,届时只需在标段或者项目上设置这个类型即可。
|
|
|
- const analysisType = 'book';
|
|
|
const relaStage = await ctx.service.costStage.getStageByOrder(ctx.tender.id, analysisType, stage_order);
|
|
|
if (!relaStage) throw '选择的关联期不存在';
|
|
|
newStage = await ctx.service.costStage.add(ctx.tender.id, stage_type, relaStage.stage_date, { sid: relaStage.id, sorder: relaStage.stage_order });
|