|
@@ -1,6 +1,6 @@
|
|
|
import {IApiProcessor, ICachedData, IMethodParams, IRequest} from "@core/Defined";
|
|
|
import DataCURD from "@core/DataCURD";
|
|
|
-import {Op, Transaction, WhereOptions} from "sequelize";
|
|
|
+import {Op, WhereOptions} from "sequelize";
|
|
|
import {PrjInfo} from "@core-models/PrjInfo";
|
|
|
import dayjs from "dayjs";
|
|
|
import {PrjLogger} from "@src/utils/prj_logger";
|
|
@@ -8,11 +8,8 @@ import {PrjPlanTaskDraft} from "@core-models/PrjPlanTaskDraft";
|
|
|
import {PrjPlanTask} from "@core-models/PrjPlanTask";
|
|
|
import {Resp} from "@util/Resp";
|
|
|
import {Logger} from "@util/Logger";
|
|
|
-import {ChangeMarker} from "@src/utils/define";
|
|
|
-import {start_plan_alt_flow, update_parent_task_info} from "@src/utils/plan_task_helper";
|
|
|
import {PrjFile} from "@core-models/PrjFile";
|
|
|
import {BizContractInfo} from "@core-models/BizContractInfo";
|
|
|
-import {IdGen} from "@util/IdGen";
|
|
|
import {is_project_modifiable, is_project_privileged_account} from "@src/utils/prj_premission_helper";
|
|
|
import {AcsUserInfo} from "@core-models/AcsUserInfo";
|
|
|
import {BpmnCase} from "@core-models/BpmnCase";
|
|
@@ -72,7 +69,7 @@ function permission_guard(content: IRequest, cached_data: ICachedData): Promise<
|
|
|
let phase = await PrjPhaseDefine.findOne({where: {id: prj.phase_id}, raw: true});
|
|
|
if (!phase) return reject(Resp.gen_err(Resp.ResourceNotFound, '项目状态信息出错,id: ' + prj.id));
|
|
|
if (phase.order_index >= 20 ) {
|
|
|
- if (data.type_id !== undefined) {
|
|
|
+ if (data.type_id !== undefined && prj.type_id !== data.type_id) {
|
|
|
return reject(Resp.gen_err(Resp.Forbidden, '项目立项后不允许修改项目类型。'))
|
|
|
}
|
|
|
if (!await is_project_privileged_account(cached_data.user_id)) {
|
|
@@ -106,7 +103,7 @@ function permission_guard(content: IRequest, cached_data: ICachedData): Promise<
|
|
|
});
|
|
|
}
|
|
|
|
|
|
-async function get_where(json: IRequest, params: IMethodParams, cached_data: ICachedData): Promise<WhereOptions> {
|
|
|
+async function get_where(json: IRequest, _params: IMethodParams, _cached_data: ICachedData): Promise<WhereOptions> {
|
|
|
let data = <IData>json.data;
|
|
|
|
|
|
return {id: data.id};
|
|
@@ -135,9 +132,7 @@ function modify(content: IRequest, params: IMethodParams, cached_data: ICachedDa
|
|
|
let t = await PrjInfo.sequelize!.transaction();
|
|
|
try {
|
|
|
let prj = await PrjInfo.findOne({where: {id: data.id}, raw: true, transaction: t});
|
|
|
- if (!prj) {
|
|
|
- throw Resp.gen_err(Resp.ResourceNotFound, '项目不存在.');
|
|
|
- }
|
|
|
+ if (!prj) throw Resp.gen_err(Resp.ResourceNotFound, '项目不存在.');
|
|
|
|
|
|
// 修改了项目负责人,这个问题就严重了,要改很多东西
|
|
|
// 要将该项目的项目流程全部移交给新负责人,
|
|
@@ -148,10 +143,10 @@ function modify(content: IRequest, params: IMethodParams, cached_data: ICachedDa
|
|
|
if (!new_leader) {
|
|
|
throw Resp.gen_err(Resp.ResourceNotFound, '新选中的项目负责人不存在.');
|
|
|
}
|
|
|
- let [count, flow_cases] = await BpmnCase.update({creator_id: data.leader_id},
|
|
|
+ let [_count, flow_cases] = await BpmnCase.update({creator_id: data.leader_id},
|
|
|
{where: {prj_id: prj.id, task_id: {[Op.is]: null}, completed_at: {[Op.is]: null}}, transaction: t, returning: true});
|
|
|
await BpmnWork.update({assigned_to: data.leader_id},
|
|
|
- {where: {prj_id: prj.id, task_id: {[Op.is]: null}, status: {[Op.ne]: 2}}, transaction: t});
|
|
|
+ {where: {prj_id: prj.id, task_id: {[Op.is]: null}, status: {[Op.ne]: 2}}, transaction: t, returning: false});
|
|
|
if (flow_cases && flow_cases.length > 0) {
|
|
|
for (let flow_case of flow_cases) {
|
|
|
let engine = FlowEngine.case_engine_map.get(flow_case.id);
|