明树Git Lab

Commit 3bb0ae93 authored by zfp1's avatar zfp1

update

parent 0d859b9a
Pipeline #111384 passed with stage
in 5 seconds
const itclfiMap = {
"655d4e5247323defddafcf1b": {
isPromise: 1,
promiseType: 2,
approvalType: 2
},
"6218b527cebadc014222e863": {
isPromise: 1,
promiseType: 2,
approvalType: 2
},
"622c56d3672bb1f158cf6d25": {
isPromise: 1,
promiseType: 1,
promiseDay: 20,
approvalType: 2
},
"622c56dd672bb1f158cf6d26": {
isPromise: 1,
promiseType: 1,
promiseDay: 20,
approvalType: 2
},
"6218b500cebadc014222e6ea": {
isPromise: 1,
promiseType: 1,
promiseDay: 7,
approvalType: 2
}
}
let b = {
// key : "6218b500cebadc014222e6ea"
}
let a = {
a: 1,
...(itclfiMap[b.key] || {})
}
console.log(a);
\ No newline at end of file
let parentIds = [1,86,10]
console.log(parentIds.slice(0, 3))
let index = parentIds.indexOf(86);
console.log(index)
// const result = index !== -1
// ? parentIds.slice(0, index + 1)
// : parentIds;
// pidStr = result.join(",");
// console.log("pidStr", pidStr) //项目公司部门id字符串
\ No newline at end of file
......@@ -1287,6 +1287,9 @@ async function listProject(req, res, next) {
if (xmCompanyUser.type == 2) {
search.where.projectCreator = { [Op.in]: xmCompanyUser.userIds };
}
if (xmCompanyUser.type == 0) {
search.where.projectCreator = req.user.id;
}
console.log(search)
search.raw = true
let ret = await DB.Project.findAndCountAll(search);
......@@ -1301,35 +1304,40 @@ async function listProject(req, res, next) {
async function getXmCompanyUser(req, res, next) {
let userDepart = await DB.UserDepart.findOne({ where: { userId: req.user.id }, raw: true });
if (!(userDepart && userDepart.departId)) {
return res.sendError(errorMessage.noUserDepart);
return { type: 0 }
}
let curentDepart = await DB.Depart.findOne({ where: { id: userDepart.departId }, raw: true });
if (!(curentDepart && curentDepart.id)) {
return res.sendError(errorMessage.noUserDepart);
return { type: 0 }
}
let parentIds = curentDepart.parentIds ? curentDepart.parentIds.split(",") : [];
if (parentIds.includes(86) || parentIds.includes('86') || curentDepart.id == 86) {
let pidStr = "";
if (curentDepart.id == 86) {
pidStr = curentDepart.parentIds + curentDepart.id;
pidStr = curentDepart.parentIds + "," + curentDepart.id;
} else
if (curentDepart.parentId == 86) { //项目公司
pidStr = curentDepart.parentIds + curentDepart.id;// 为了查询currentDepart.id所有部门
pidStr = curentDepart.parentIds + "," + curentDepart.id;// 为了查询currentDepart.id所有部门
} else {
// 项目公司下属部门
const index = parentIds.indexOf(86);
const index = parentIds.indexOf('86');
const result = index !== -1
? parentIds.slice(0, index + 1)
? parentIds.slice(0, index + 2)
: parentIds;
pidStr = result.join(",");
}
console.log("pidStr", pidStr) //项目公司部门id字符串
let departs = await DB.Depart.findAll({
where: {
parentIds: { [Op.like]: `%${pidStr}%` }
}, raw: true
[Op.or]: [
{ parentIds: pidStr },
{ parentIds: { [Op.startsWith]: `${pidStr},` } }
]
},
raw: true
});
departs.push(curentDepart); //加上当前部门
console.log("departs", departs) //项目公司下属部门信息
let departIds = departs.map(o => { return o.id });
......
......@@ -149,24 +149,31 @@ async function getCompanyProjectApprover(userId, roleCode) {
console.log("parentIds", parentIds) //部门父级信息
if (departId == 41 || parentIds.includes(41) || parentIds.includes('41')) { //写死 投管部
users = await getTouGuanZfzProjectApprover(userId);
return {users, type: 1};
return { users, type: 1 };
} else if (parentIds.includes(86) || parentIds.includes('86')) { //项目公司
let pidStr = "";
if (curentDepart.parentId == 86) { //项目公司
pidStr = curentDepart.parentIds + curentDepart.id;// 为了查询currentDepart.id所有部门
pidStr = curentDepart.parentIds + "," + curentDepart.id;// 为了查询currentDepart.id所有部门
} else {
// 项目公司下属部门
const index = parentIds.indexOf(86);
const index = parentIds.indexOf('86');
const result = index !== -1
? parentIds.slice(0, index + 1)
? parentIds.slice(0, index + 2)
: parentIds;
pidStr = result.join(",");
}
console.log("pidStr", pidStr) //项目公司部门id字符串
let departs = await DB.Depart.findAll({
where: { parentIds: { [Op.like]: `%${pidStr}%` }
}, raw: true });
let departs = await DB.Depart.findAll({
where: {
[Op.or]: [
{ parentIds: pidStr },
{ parentIds: { [Op.startsWith]: `${pidStr},` } }
]
},
raw: true
});
departs.push(curentDepart); //加上当前部门
console.log("departs", departs) //项目公司下属部门信息
let departIds = departs.map(o => { return o.id });
......@@ -180,13 +187,13 @@ async function getCompanyProjectApprover(userId, roleCode) {
include: [{
model: DB.Role,
as: 'roles',
where: { del: 0 ,key: roleCode},
where: { del: 0, key: roleCode },
attributes: ["id", "name"],
},],
raw: true
});
console.log("users", users) //部门用户项目信息
return {users, type: 2};
return { users, type: 2 };
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment