|
@@ -1,7 +1,6 @@
|
|
import {IApiProcessor, ICachedData, IMethodParams, IRequest} from "@core/Defined";
|
|
import {IApiProcessor, ICachedData, IMethodParams, IRequest} from "@core/Defined";
|
|
import {PrjInfo} from "@core-models/PrjInfo";
|
|
import {PrjInfo} from "@core-models/PrjInfo";
|
|
import {Resp} from "@util/Resp";
|
|
import {Resp} from "@util/Resp";
|
|
-import {PrjPhaseDefine} from "@core-models/PrjPhaseDefine";
|
|
|
|
import {PrjTaskOutcome} from "@core-models/PrjTaskOutcome";
|
|
import {PrjTaskOutcome} from "@core-models/PrjTaskOutcome";
|
|
import {PrjTaskOutcomeDraft} from "@core-models/PrjTaskOutcomeDraft";
|
|
import {PrjTaskOutcomeDraft} from "@core-models/PrjTaskOutcomeDraft";
|
|
import {PrjPlanTaskDraft} from "@core-models/PrjPlanTaskDraft";
|
|
import {PrjPlanTaskDraft} from "@core-models/PrjPlanTaskDraft";
|
|
@@ -11,6 +10,7 @@ import {ChangeMarker, TaskStatus} from "@src/utils/define";
|
|
import {PrjPlanTask} from "@core-models/PrjPlanTask";
|
|
import {PrjPlanTask} from "@core-models/PrjPlanTask";
|
|
import {Transaction} from "sequelize";
|
|
import {Transaction} from "sequelize";
|
|
import {
|
|
import {
|
|
|
|
+ if_project_task_manageable_in_current_phase,
|
|
is_project_task_outcome_modifiable
|
|
is_project_task_outcome_modifiable
|
|
} from "@src/utils/prj_premission_helper";
|
|
} from "@src/utils/prj_premission_helper";
|
|
|
|
|
|
@@ -98,32 +98,34 @@ function statusGuard(json: IRequest, cached_data: ICachedData): Promise<void> {
|
|
|
|
|
|
let prj_info = await PrjInfo.findOne({where: {id: task.prj_id}, raw: true});
|
|
let prj_info = await PrjInfo.findOne({where: {id: task.prj_id}, raw: true});
|
|
if (!prj_info) return reject(Resp.gen_err(Resp.ResourceNotFound, '项目不存在。'));
|
|
if (!prj_info) return reject(Resp.gen_err(Resp.ResourceNotFound, '项目不存在。'));
|
|
-
|
|
|
|
- let phase = await PrjPhaseDefine.findOne({where: {id: prj_info.phase_id}, raw: true});
|
|
|
|
- if (!phase) return reject(Resp.gen_err(Resp.ResourceNotFound, '项目状态信息出错,id: ' + prj_info.id));
|
|
|
|
-
|
|
|
|
- if (phase.order_index < 20) return reject(Resp.gen_err(Resp.InvalidFlow, '需要先对项目进行立项,立项后才可制订计划。'));
|
|
|
|
- // if (phase.order_index >= 80) return reject(Resp.gen_err(Resp.InvalidFlow, '当前项目阶段不允许删除交付物。'));
|
|
|
|
- if (phase.order_index === 80) {
|
|
|
|
- return reject(Resp.gen_err(Resp.InvalidFlow, '项目验收中,不允许删除交付物。'));
|
|
|
|
- }
|
|
|
|
- if (phase.order_index === 90) {
|
|
|
|
- return reject(Resp.gen_err(Resp.InvalidFlow, '项目已作废,不允许删除交付物。'));
|
|
|
|
- }
|
|
|
|
- if (phase.order_index === 100) {
|
|
|
|
- return reject(Resp.gen_err(Resp.InvalidFlow, '项目已完成,不允许删除交付物。'));
|
|
|
|
- }
|
|
|
|
- // if (data.draft == true) {
|
|
|
|
- if (phase.order_index >= 60 && phase.order_index <= 65) {
|
|
|
|
- return reject(Resp.gen_err(Resp.InvalidFlow, '计划变更审核中,现阶段不允许删除交付物。'));
|
|
|
|
- }
|
|
|
|
- // } else {
|
|
|
|
- if (!data.draft) {
|
|
|
|
- if (phase.order_index >=30 && phase.order_index <= 40)
|
|
|
|
- return reject(Resp.gen_err(Resp.InvalidFlow, '项目计划审核中,当前阶段不允许删除。'));
|
|
|
|
- // if (phase.order_index === 70)
|
|
|
|
- // return reject(Resp.gen_err(Resp.InvalidFlow, '当前项目阶段不允许直接删除交付物,应在草稿中修改后重新提交计划变更审核。'));
|
|
|
|
- }
|
|
|
|
|
|
+ let result = await if_project_task_manageable_in_current_phase(data.draft, prj_info.id, prj_info.phase_id, '删除交付物信息');
|
|
|
|
+ if (!result.manageable)
|
|
|
|
+ return reject(result.error);
|
|
|
|
+ // let phase = await PrjPhaseDefine.findOne({where: {id: prj_info.phase_id}, raw: true});
|
|
|
|
+ // if (!phase) return reject(Resp.gen_err(Resp.ResourceNotFound, '项目状态信息出错,id: ' + prj_info.id));
|
|
|
|
+ //
|
|
|
|
+ // if (phase.order_index < 20) return reject(Resp.gen_err(Resp.InvalidFlow, '需要先对项目进行立项,立项后才可制订计划。'));
|
|
|
|
+ // // if (phase.order_index >= 80) return reject(Resp.gen_err(Resp.InvalidFlow, '当前项目阶段不允许删除交付物。'));
|
|
|
|
+ // if (phase.order_index === 80) {
|
|
|
|
+ // return reject(Resp.gen_err(Resp.InvalidFlow, '项目验收中,不允许删除交付物。'));
|
|
|
|
+ // }
|
|
|
|
+ // if (phase.order_index === 90) {
|
|
|
|
+ // return reject(Resp.gen_err(Resp.InvalidFlow, '项目已作废,不允许删除交付物。'));
|
|
|
|
+ // }
|
|
|
|
+ // if (phase.order_index === 100) {
|
|
|
|
+ // return reject(Resp.gen_err(Resp.InvalidFlow, '项目已完成,不允许删除交付物。'));
|
|
|
|
+ // }
|
|
|
|
+ // // if (data.draft == true) {
|
|
|
|
+ // if (phase.order_index >= 60 && phase.order_index <= 65) {
|
|
|
|
+ // return reject(Resp.gen_err(Resp.InvalidFlow, '计划变更审核中,现阶段不允许删除交付物。'));
|
|
|
|
+ // }
|
|
|
|
+ // // } else {
|
|
|
|
+ // if (!data.draft) {
|
|
|
|
+ // if (phase.order_index >=30 && phase.order_index <= 40)
|
|
|
|
+ // return reject(Resp.gen_err(Resp.InvalidFlow, '项目计划审核中,当前阶段不允许删除。'));
|
|
|
|
+ // // if (phase.order_index === 70)
|
|
|
|
+ // // return reject(Resp.gen_err(Resp.InvalidFlow, '当前项目阶段不允许直接删除交付物,应在草稿中修改后重新提交计划变更审核。'));
|
|
|
|
+ // }
|
|
if (task.status >= TaskStatus.apply_for_review) {
|
|
if (task.status >= TaskStatus.apply_for_review) {
|
|
return reject(Resp.gen_err(Resp.InvalidFlow, '当前任务阶段不允许删除交付物。'));
|
|
return reject(Resp.gen_err(Resp.InvalidFlow, '当前任务阶段不允许删除交付物。'));
|
|
}
|
|
}
|