|
@@ -1,12 +1,11 @@
|
|
|
import {IApiProcessor, ICachedData, IMethodParams, IRequest} from "@core/Defined";
|
|
|
import {Resp} from "@util/Resp";
|
|
|
-import {Op, QueryTypes, WhereOptions} from "sequelize";
|
|
|
+import {WhereOptions} from "sequelize";
|
|
|
import DataCURD, {ISQLReplacements} from "@core/DataCURD";
|
|
|
-import {BizCustomer} from "@core-models/BizCustomer";
|
|
|
import {AcsUserInfo} from "@core-models/AcsUserInfo";
|
|
|
-import {BizContractInfo} from "@core-models/BizContractInfo";
|
|
|
import {PrjInfo} from "@core-models/PrjInfo";
|
|
|
import {PrjWeekReport} from "@core-models/PrjWeekReport";
|
|
|
+import {is_project_leader, is_project_privileged_account} from "@src/utils/prj_premission_helper";
|
|
|
|
|
|
|
|
|
interface IData {
|
|
@@ -29,7 +28,7 @@ interface IData {
|
|
|
/**
|
|
|
* 精确通过项目查找合同
|
|
|
*/
|
|
|
- prj_id?: string;
|
|
|
+ prj_id: string;
|
|
|
/**
|
|
|
* 根据项目名称过滤(模糊匹配)
|
|
|
*/
|
|
@@ -70,18 +69,22 @@ function get_list(json: IRequest, params: IMethodParams, cached_data: ICachedDat
|
|
|
from ${PrjWeekReport.table_name} report
|
|
|
left join ${PrjInfo.table_name} prj on prj.id = report.prj_id
|
|
|
left join ${AcsUserInfo.table_name} reporter on reporter.id = report.reporter_id
|
|
|
- where 1=1
|
|
|
+ where prj.id = :prj_id
|
|
|
`;
|
|
|
- let replacements: ISQLReplacements = {};
|
|
|
+ let replacements: ISQLReplacements = {prj_id: data.prj_id};
|
|
|
+
|
|
|
+ // 如果是项目经理或特权人员,可以看到全部周报,否则只能看到自己的周报
|
|
|
+ if (!await is_project_privileged_account(cached_data.user_id)&&
|
|
|
+ !await is_project_leader(cached_data.user_id, data.prj_id)) {
|
|
|
+ condition += ` and reporter.id = :reporter_id `;
|
|
|
+ replacements.reporter_id = cached_data.user_id;
|
|
|
+ }
|
|
|
|
|
|
if (data.prj_name !== undefined) {
|
|
|
condition += ` and prj.name like :keyword `;
|
|
|
replacements.keyword = `%${data.prj_name}%`;
|
|
|
}
|
|
|
- if (data.prj_id !== undefined) {
|
|
|
- condition += ` and prj.id = :prj_id `;
|
|
|
- replacements.prj_id = data.prj_id;
|
|
|
- }
|
|
|
+
|
|
|
if (data.reporter_id !== undefined) {
|
|
|
condition += ` and reporter.id = :reporter_id `;
|
|
|
replacements.reporter_id = data.reporter_id;
|
|
@@ -188,7 +191,8 @@ const v1_0: IApiProcessor = {
|
|
|
"title": "请求参数内容",
|
|
|
"required": [
|
|
|
"page_no",
|
|
|
- "page_size"
|
|
|
+ "page_size",
|
|
|
+ "prj_id"
|
|
|
]
|
|
|
},
|
|
|
"ver": {
|