|
@@ -12,6 +12,7 @@ import {BizContractInfo} from "@core-models/BizContractInfo";
|
|
|
import {PrjPhaseDefine} from "@core-models/PrjPhaseDefine";
|
|
|
import {BpmnWork} from "@core-models/BpmnWork";
|
|
|
import {BpmnCase} from "@core-models/BpmnCase";
|
|
|
+import {PrjMembers} from "@core-models/PrjMembers";
|
|
|
|
|
|
interface IData {
|
|
|
/**
|
|
@@ -68,7 +69,6 @@ interface IData {
|
|
|
type_id?: number;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
function get_list(json: IRequest, params: IMethodParams, cached_data: ICachedData): Promise<WhereOptions> {
|
|
|
return new Promise<WhereOptions>(async (resolve, reject) => {
|
|
|
try {
|
|
@@ -117,9 +117,57 @@ function get_list(json: IRequest, params: IMethodParams, cached_data: ICachedDat
|
|
|
work.assigned_to = '${cached_data.user_id}' and
|
|
|
work.status <> 2 and work.process_type = 1 and
|
|
|
flow.model_id = 'prj'
|
|
|
- where 1=1
|
|
|
+ where (
|
|
|
+ -- 项目负责人可以取到自己的项目
|
|
|
+ prj.leader_id = :user_id or
|
|
|
+
|
|
|
+ -- 项目商务负责人可以取到自己的项目
|
|
|
+ prj.bizman_id = :user_id or
|
|
|
+
|
|
|
+ -- 项目组成员可以取到自己的项目
|
|
|
+ EXISTS (
|
|
|
+ select 1 from ${PrjMembers.table_name} member where member.member_id = :user_id and member.prj_id = prj.id
|
|
|
+ ) or
|
|
|
+
|
|
|
+ -- 有全部项目查看权限的人(特权人员)可以取到全部项目
|
|
|
+ EXISTS (
|
|
|
+ select 1 from tb_acs_user
|
|
|
+ where ext_info->>'full_range' = 'true'
|
|
|
+ and id = :user_id
|
|
|
+ ) or
|
|
|
+
|
|
|
+ -- 项目审核人可以取到相关项目
|
|
|
+ EXISTS (
|
|
|
+ select 1 from tb_prj_info prj_info, jsonb_array_elements(prj.checkers) AS checker_obj
|
|
|
+ where checker_obj->>'id' = :user_id and prj_info.id = prj.id
|
|
|
+ ) or
|
|
|
+ --prj.id in (
|
|
|
+ -- select prj_id from (
|
|
|
+ -- select * from (SELECT distinct jsonb_array_elements_text((value ->> 'handlers')::jsonb) AS handler, prj_id
|
|
|
+ -- FROM tb_prj_plan_task_draft,
|
|
|
+ -- jsonb_array_elements(checkers) AS checker_obj) a
|
|
|
+ -- ) b) or
|
|
|
+
|
|
|
+
|
|
|
+ -- 任务审核人可以取到相关项目
|
|
|
+ EXISTS (
|
|
|
+ SELECT 1
|
|
|
+ FROM tb_prj_plan_task prj_task,
|
|
|
+ jsonb_array_elements(prj_task.checkers) AS checker_obj
|
|
|
+ WHERE (checker_obj->>'handlers')::jsonb ? :user_id
|
|
|
+ and prj_task.prj_id = prj.id
|
|
|
+
|
|
|
+ )
|
|
|
+ --prj.id in (select prj_id from (
|
|
|
+ -- select * from (SELECT distinct jsonb_array_elements_text((value ->> 'handlers')::jsonb) AS handler, prj_id
|
|
|
+ -- FROM tb_prj_plan_task_draft,
|
|
|
+ -- jsonb_array_elements(checkers) AS checker_obj) a where a.handler = :user_id
|
|
|
+ --) b)
|
|
|
+
|
|
|
+ )
|
|
|
+
|
|
|
`;
|
|
|
- let replacements: ISQLReplacements = {};
|
|
|
+ let replacements: ISQLReplacements = {user_id: cached_data.user_id};
|
|
|
if (data.name !== undefined) {
|
|
|
condition += ` and prj.name like :name `;
|
|
|
replacements.name = `%${data.name}%`;
|
|
@@ -137,13 +185,6 @@ function get_list(json: IRequest, params: IMethodParams, cached_data: ICachedDat
|
|
|
replacements.leader_id = data.leader_id;
|
|
|
}
|
|
|
if (data.region_id !== undefined) {
|
|
|
- // condition += `
|
|
|
- // and prj.id in (
|
|
|
- // select customer.id as id from ${AcsDomain.table_name} domain, ${BizCustomer.table_name} customer
|
|
|
- // where domain.id = customer.region_id and
|
|
|
- // domain.path <@(select path from ${AcsDomain.table_name} where id = :region_id)
|
|
|
- // )
|
|
|
- // `;
|
|
|
condition += `
|
|
|
and prj.id in (
|
|
|
select prj.id as id from ${AcsDomain.table_name} domain, ${PrjInfo.table_name} prj
|