明树Git Lab

Commit 37d30c98 authored by zfp1's avatar zfp1

update

parent 70349c89
Pipeline #111308 passed with stage
in 3 seconds
...@@ -289,8 +289,11 @@ async function startLixiang(req, res, next) { ...@@ -289,8 +289,11 @@ async function startLixiang(req, res, next) {
* 此处需要判断当前项目是从哪一个节点回来的,依次往下 * 此处需要判断当前项目是从哪一个节点回来的,依次往下
* 1. 初审退回 * 1. 初审退回
* 2. 核准退回 * 2. 核准退回
* 3. 首次提交 * 3. 终审核退回
* 4. 首次提交
*
*/ */
req.body.projectLxTjUser = req.user.id;//立项提交人
if (req.body.projectLxjbrUser) { if (req.body.projectLxjbrUser) {
//更新信息和状态 //更新信息和状态
req.body.daibanUsers = [req.body.projectLxjbrUser]; req.body.daibanUsers = [req.body.projectLxjbrUser];
...@@ -333,15 +336,47 @@ async function startLixiang(req, res, next) { ...@@ -333,15 +336,47 @@ async function startLixiang(req, res, next) {
projectCode: req.body.projectCode, projectCode: req.body.projectCode,
}); });
return res.sendData(ret); return res.sendData(ret);
} else { } else if(req.body.projectLxzsUser) {
// 如果没有走初审、核准但是又有终审用户,则是终审退回
req.body.daibanUsers = [req.body.projectLxzsUser];
let ret = await xiangmulixianggengxin(req.body, "4"); //状态 2 -- 立项核准中
// 记录流程节点操作
await DB.FlowRecord.create({
userId: req.user.id,
actionName: '发起项目立项终审',
projectId: req.body.id,
projectName: req.body.projectName,
projectCode: req.body.projectCode,
});
await DB.Message.create({
projectId: req.body.id,
creator: req.user.id,
receivers: approvers.map(o => o.id),
type: 2,
title: `项目【${req.body.projectName}】已发起立项终审,请尽快处理!`,
content: `项目【${req.body.projectName}】已发起立项终审,请尽快处理!`
});
return res.sendData(ret);
}
else {
// 项目公司所属单位员工发起,发送消息给项目单位部门长核准 // 项目公司所属单位员工发起,发送消息给项目单位部门长核准
let approvers = await userModule.getCompanyProjectApprover(req.user.id); let rett = await userModule.getCompanyProjectApprover(req.user.id);
if (!(approvers && approvers.length > 0)) { if (!(_.isEmpty(rett))) {
return res.sendError({ code: '60001', message: '项目已保存,请联系管理员为本公司添加【项目立项核准】角色人员' }); return res.sendError({ code: '60001', message: '项目已保存,请联系管理员为本公司添加【项目立项核准】角色人员' });
} }
//更新信息和状态 //更新信息和状态
req.body.daibanUsers = approvers.map(o => o.id); req.body.daibanUsers = approvers.map(o => o.id);
let ret = await xiangmulixianggengxin(req.body, "2"); //状态 2 -- 立项核准中 let ret;
if(rett.type == 1) {
//投管
ret = await xiangmulixianggengxin(req.body, "4"); //状态 2 -- 立项核准中
} else {
//部门长
ret = await xiangmulixianggengxin(req.body, "2"); //状态 2 -- 立项核准中
}
// 记录流程节点操作 // 记录流程节点操作
await DB.FlowRecord.create({ await DB.FlowRecord.create({
userId: req.user.id, userId: req.user.id,
...@@ -411,7 +446,7 @@ async function approvalLixiangByDepartHeader(req, res, next) { ...@@ -411,7 +446,7 @@ async function approvalLixiangByDepartHeader(req, res, next) {
} }
else { else {
//部门长核准不通过,更新项目信息和状态--退回到草稿 //部门长核准不通过,更新项目信息和状态--退回到草稿
req.body.daibanUsers = [body.projectCreator]; req.body.daibanUsers = [body.projectLxTjUser];
ret = await xiangmulixianggengxin(body, "1"); ret = await xiangmulixianggengxin(body, "1");
//记录操作 //记录操作
await DB.FlowRecord.create({ await DB.FlowRecord.create({
...@@ -425,7 +460,7 @@ async function approvalLixiangByDepartHeader(req, res, next) { ...@@ -425,7 +460,7 @@ async function approvalLixiangByDepartHeader(req, res, next) {
await DB.Message.create({ await DB.Message.create({
projectId: body.id, projectId: body.id,
creator: req.user.id, creator: req.user.id,
receivers: [body.projectCreator], receivers: [body.projectLxTjUser],
type: 6, type: 6,
title: `项目【${body.projectName}】未通过部门长核准,请检查后重新提交!`, title: `项目【${body.projectName}】未通过部门长核准,请检查后重新提交!`,
content: req.body.approvalMessage || `项目【${body.projectName}】未通过部门长核准,请检查后重新提交!` content: req.body.approvalMessage || `项目【${body.projectName}】未通过部门长核准,请检查后重新提交!`
...@@ -479,13 +514,13 @@ async function approvalLixiangByTouGuanJbr(req, res, next) { ...@@ -479,13 +514,13 @@ async function approvalLixiangByTouGuanJbr(req, res, next) {
} }
else { else {
//投管部经办人审批不通过,更新项目信息和状态--直接回到项目提交人 //投管部经办人审批不通过,更新项目信息和状态--直接回到项目提交人
req.body.daibanUsers = [body.projectCreator]; req.body.daibanUsers = [body.projectLxTjUser];
ret = await xiangmulixianggengxin(body, "1"); ret = await xiangmulixianggengxin(body, "1");
// 给项目提交人发消息 // 给项目提交人发消息
await DB.Message.create({ await DB.Message.create({
projectId: body.id, projectId: body.id,
creator: req.user.id, creator: req.user.id,
receivers: [body.projectCreator], receivers: [body.projectLxTjUser],
type: 8, // 初审不通过消息 type: 8, // 初审不通过消息
title: `项目【${body.projectName}】未通过投管部经办人审批,请检查后重新提交!`, title: `项目【${body.projectName}】未通过投管部经办人审批,请检查后重新提交!`,
content: req.body.approvalMessage || `项目【${body.projectName}】未通过投管部经办人审批,请检查后重新提交!` content: req.body.approvalMessage || `项目【${body.projectName}】未通过投管部经办人审批,请检查后重新提交!`
...@@ -1501,6 +1536,11 @@ async function approvalZaiJuece(req, res, next) { ...@@ -1501,6 +1536,11 @@ async function approvalZaiJuece(req, res, next) {
} }
} }
async function getCompanyProjectApprover(req, res, next) {
let ret = await userModule.getCompanyProjectApprover(46);
return res.sendData(ret);
}
module.exports = { module.exports = {
getProjectFields, getProjectFields,
createProject, createProject,
...@@ -1526,4 +1566,5 @@ module.exports = { ...@@ -1526,4 +1566,5 @@ module.exports = {
saveZaiJuece, saveZaiJuece,
startZaiJuece, startZaiJuece,
approvalZaiJuece, approvalZaiJuece,
getCompanyProjectApprover,
} }
\ No newline at end of file
...@@ -36,6 +36,10 @@ const Project = sequelize.define('Project', { ...@@ -36,6 +36,10 @@ const Project = sequelize.define('Project', {
defaultValue: 0, defaultValue: 0,
comment1: "0 正常 1 删除", comment1: "0 正常 1 删除",
}, },
projectLxTjUser: {
type: DataTypes.INTEGER,
comment: "立项提交人",
},
projectHzUser: { projectHzUser: {
type: DataTypes.INTEGER, type: DataTypes.INTEGER,
comment: "项目核准人ID", comment: "项目核准人ID",
...@@ -319,8 +323,8 @@ const Project = sequelize.define('Project', { ...@@ -319,8 +323,8 @@ const Project = sequelize.define('Project', {
sbdwhbzj: { type: DataTypes.DECIMAL(20, 8), allowNull: true, comment: "申报单位货币资金" }, sbdwhbzj: { type: DataTypes.DECIMAL(20, 8), allowNull: true, comment: "申报单位货币资金" },
dxfzgm: { type: DataTypes.STRING, allowNull: true, comment: "带息负债规模" }, dxfzgm: { type: DataTypes.STRING, allowNull: true, comment: "带息负债规模" },
jlnsflxks: { type: DataTypes.STRING, allowNull: true, comment: "近两年是否连续亏损", _mark: 'juece', zjType: 'danxuan', zjKey: 'sf' }, jlnsflxks: { type: DataTypes.STRING, allowNull: true, comment: "近两年是否连续亏损", _mark: 'juece', zjType: 'danxuan', zjKey: 'sf' },
// 项目可行性:项目投资现金流量表 项目资本金现金流量表 能建方现金流量表 利润表 投评报告及测算表 excel表 // 项目可行性:项目投资现金流量表 项目资本金现金流量表 能建方现金流量表 利润表 投评报告及测算表 excel表
tjjh: { type: DataTypes.JSON }, tjjh: { type: DataTypes.JSON },
xmtzzjll: { type: DataTypes.JSON }, xmtzzjll: { type: DataTypes.JSON },
...@@ -330,14 +334,14 @@ const Project = sequelize.define('Project', { ...@@ -330,14 +334,14 @@ const Project = sequelize.define('Project', {
//再决策 //再决策
jcspdw: {type: DataTypes.STRING, allowNull: true, comment: "决策审批单位", _mark: 'juece',zjType: 'danxuan',}, jcspdw: { type: DataTypes.STRING, allowNull: true, comment: "决策审批单位", _mark: 'juece', zjType: 'danxuan', },
yykssj: { type: DataTypes.DATE, allowNull: true, comment: "运营开始时间", _mark: "juece" }, yykssj: { type: DataTypes.DATE, allowNull: true, comment: "运营开始时间", _mark: "juece" },
yyjssj: { type: DataTypes.DATE, allowNull: true, comment: "运营结束时间", _mark: "juece" }, yyjssj: { type: DataTypes.DATE, allowNull: true, comment: "运营结束时间", _mark: "juece" },
tzwcqk: { type: DataTypes.TEXT, allowNull: true, comment: "投资完成情况", _mark: "juece" }, tzwcqk: { type: DataTypes.TEXT, allowNull: true, comment: "投资完成情况", _mark: "juece" },
tzhsqk: { type: DataTypes.TEXT, allowNull: true, comment: "投资回收情况", _mark: "juece" }, tzhsqk: { type: DataTypes.TEXT, allowNull: true, comment: "投资回收情况", _mark: "juece" },
//申请报告 //申请报告
"projectIntro": { "projectIntro": {
"name": "顶部描述信息", "name": "顶部描述信息",
"type": DataTypes.TEXT, "type": DataTypes.TEXT,
}, },
...@@ -363,7 +367,7 @@ const Project = sequelize.define('Project', { ...@@ -363,7 +367,7 @@ const Project = sequelize.define('Project', {
}, },
"dwzj": { "dwzj": {
"name": "单位造价", "name": "单位造价",
"type": DataTypes.DECIMAL(20, 8) "type": DataTypes.DECIMAL(20, 8)
}, },
"tzgc": { "tzgc": {
"name": "投资构成", "name": "投资构成",
...@@ -424,11 +428,11 @@ const Project = sequelize.define('Project', { ...@@ -424,11 +428,11 @@ const Project = sequelize.define('Project', {
}, },
"zbjbl": { "zbjbl": {
"name": "资金方案-资本金-比例", "name": "资金方案-资本金-比例",
"type": DataTypes.DECIMAL(20, 8) "type": DataTypes.DECIMAL(20, 8)
}, },
"zbjje": { "zbjje": {
"name": "资金方案-资本金-金额", "name": "资金方案-资本金-金额",
"type": DataTypes.DECIMAL(20, 8) "type": DataTypes.DECIMAL(20, 8)
}, },
"zbjly": { "zbjly": {
"name": "资金方案-资本金-来源", "name": "资金方案-资本金-来源",
...@@ -436,11 +440,11 @@ const Project = sequelize.define('Project', { ...@@ -436,11 +440,11 @@ const Project = sequelize.define('Project', {
}, },
"dkbl": { "dkbl": {
"name": "资金方案-贷款-比例", "name": "资金方案-贷款-比例",
"type": DataTypes.DECIMAL(20, 8) "type": DataTypes.DECIMAL(20, 8)
}, },
"dkbje": { "dkbje": {
"name": "资金方案-贷款-金额", "name": "资金方案-贷款-金额",
"type": DataTypes.DECIMAL(20, 8) "type": DataTypes.DECIMAL(20, 8)
}, },
"dkrzzt": { "dkrzzt": {
"name": "资金方案-贷款-融资主体", "name": "资金方案-贷款-融资主体",
...@@ -448,11 +452,11 @@ const Project = sequelize.define('Project', { ...@@ -448,11 +452,11 @@ const Project = sequelize.define('Project', {
}, },
"dkqx": { "dkqx": {
"name": "资金方案-贷款-期限", "name": "资金方案-贷款-期限",
"type": DataTypes.DECIMAL(20, 8) "type": DataTypes.DECIMAL(20, 8)
}, },
"dkll": { "dkll": {
"name": "资金方案-贷款-利率", "name": "资金方案-贷款-利率",
"type": DataTypes.DECIMAL(20, 8) "type": DataTypes.DECIMAL(20, 8)
}, },
"dkdbfa": { "dkdbfa": {
"name": "资金方案-贷款-担保方案", "name": "资金方案-贷款-担保方案",
...@@ -504,11 +508,11 @@ const Project = sequelize.define('Project', { ...@@ -504,11 +508,11 @@ const Project = sequelize.define('Project', {
}, },
"qtzcwnbsyl": { "qtzcwnbsyl": {
"name": "经济可行性-全投资财务内部收益率(税前)", "name": "经济可行性-全投资财务内部收益率(税前)",
"type": DataTypes.DECIMAL(20, 8) "type": DataTypes.DECIMAL(20, 8)
}, },
"zbjcwnbsyl": { "zbjcwnbsyl": {
"name": "经济可行性-资本金财务内部收益率(税后)", "name": "经济可行性-资本金财务内部收益率(税后)",
"type": DataTypes.DECIMAL(20, 8) "type": DataTypes.DECIMAL(20, 8)
}, },
"jxjlhznf": { "jxjlhznf": {
"name": "经济可行性-净现金流回正年份", "name": "经济可行性-净现金流回正年份",
...@@ -524,7 +528,7 @@ const Project = sequelize.define('Project', { ...@@ -524,7 +528,7 @@ const Project = sequelize.define('Project', {
}, },
"cwjxz": { "cwjxz": {
"name": "经济可行性-财务净现值(税前)", "name": "经济可行性-财务净现值(税前)",
"type": DataTypes.DECIMAL(20, 8) "type": DataTypes.DECIMAL(20, 8)
}, },
"jxjlList": { "jxjlList": {
"name": "经济可行性-净现金流table", "name": "经济可行性-净现金流table",
......
...@@ -47,7 +47,7 @@ async function setUserDepart(userId, departIds, departs) { ...@@ -47,7 +47,7 @@ async function setUserDepart(userId, departIds, departs) {
dbIds.push(element.id); dbIds.push(element.id);
if (!departIds.includes(element.id)) { if (!departIds.includes(element.id)) {
// 1. departIds里面没有 但是关系表里有的 需要删除 // 1. departIds里面没有 但是关系表里有的 需要删除
needDelIds.push(element.id); needDelIds.push(element.id);
} }
} }
for (let index = 0; index < departIds.length; index++) { for (let index = 0; index < departIds.length; index++) {
...@@ -105,7 +105,7 @@ async function setUserPosition(userId, positionIds, positions) { ...@@ -105,7 +105,7 @@ async function setUserPosition(userId, positionIds, positions) {
* @param {*} rolemenus 角色已有的菜单 * @param {*} rolemenus 角色已有的菜单
*/ */
async function setRoleMenu(roleId, menuIds, rolemenus) { async function setRoleMenu(roleId, menuIds, rolemenus) {
menuIds = menuIds.map(o => {return o && o.id || o}); menuIds = menuIds.map(o => { return o && o.id || o });
let needAddIds = [], needDelIds = [], dbMenuIds = []; let needAddIds = [], needDelIds = [], dbMenuIds = [];
for (let index = 0; index < rolemenus.length; index++) { for (let index = 0; index < rolemenus.length; index++) {
const element = rolemenus[index]; const element = rolemenus[index];
...@@ -132,44 +132,87 @@ async function setRoleMenu(roleId, menuIds, rolemenus) { ...@@ -132,44 +132,87 @@ async function setRoleMenu(roleId, menuIds, rolemenus) {
async function getCompanyProjectApprover(userId, roleCode) { async function getCompanyProjectApprover(userId, roleCode) {
roleCode = roleCode || "xmssdwbmz"; //暂时 roleCode = roleCode || "xmssdwbmz"; //暂时
let users = [];
// 获取投管部正副职tgbzfz的用户列表 // 获取投管部正副职tgbzfz的用户列表
let role = await DB.Role.findOne({where: {key: roleCode}, raw: true}); let userDepart = await DB.UserDepart.findOne({ where: { userId }, raw: true });
if(!(role && role.id)) { if (!(userDepart && userDepart.departId)) {
return []; return {};
} }
let userIds = await DB.UserRole.findAll({where: {roleId: role.id}, raw: true}); let departId = userDepart.departId;
userIds = (userIds || []).map(o => {return o.userId}); let curentDepart = await DB.Depart.findOne({ where: { id: departId }, raw: true });
console.log("curentDepart", curentDepart) //部门信息
if (!(curentDepart && curentDepart.id)) {
return {};
}
let parentIds = curentDepart.parentIds ? curentDepart.parentIds.split(",") : [];
console.log("parentIds", parentIds) //部门父级信息
if (departId == 41 || parentIds.includes(41) || parentIds.includes('41')) { //写死 投管部
users = await getTouGuanZfzProjectApprover(userId);
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所有部门
} else {
// 项目公司下属部门
const index = parentIds.indexOf(86);
let users = await DB.User.findAll({ where: { id: {[Op.in]: userIds} } }); const result = index !== -1
return users; ? parentIds.slice(0, index + 1)
: parentIds;
pidStr = result.join(",");
}
console.log("pidStr", pidStr) //项目公司部门id字符串
let departs = await DB.Depart.findAll({
where: { parentIds: { [Op.like]: `%${pidStr}%` }
}, raw: true });
departs.push(curentDepart); //加上当前部门
console.log("departs", departs) //项目公司下属部门信息
let departIds = departs.map(o => { return o.id });
let userDeparts = await DB.UserDepart.findAll({ where: { departId: { [Op.in]: departIds } }, raw: true });
let userIds = userDeparts.map(o => { return o.userId });
console.log("userIds", userIds) //部门用户信息
users = await DB.User.findAll({
where: {
id: { [Op.in]: userIds }
},
include: [{
model: DB.Role,
as: 'roles',
where: { del: 0 ,key: roleCode},
attributes: ["id", "name"],
},]
});
return {users, type: 1};
}
} }
async function getTouGuanJbrProjectApprover(userId, roleCode) { async function getTouGuanJbrProjectApprover(userId, roleCode) {
roleCode = roleCode || "tgbjbr"; roleCode = roleCode || "tgbjbr";
// 获取投管部正副职tgbzfz的用户列表 // 获取投管部正副职tgbzfz的用户列表
let role = await DB.Role.findOne({where: {key: roleCode}, raw: true}); let role = await DB.Role.findOne({ where: { key: roleCode }, raw: true });
if(!(role && role.id)) { if (!(role && role.id)) {
return []; return [];
} }
let userIds = await DB.UserRole.findAll({where: {roleId: role.id}, raw: true}); let userIds = await DB.UserRole.findAll({ where: { roleId: role.id }, raw: true });
userIds = (userIds || []).map(o => {return o.userId}); userIds = (userIds || []).map(o => { return o.userId });
let users = await DB.User.findAll({ where: { id: {[Op.in]: userIds} } }); let users = await DB.User.findAll({ where: { id: { [Op.in]: userIds } } });
return users; return users;
} }
async function getTouGuanZfzProjectApprover(userId, roleCode) { async function getTouGuanZfzProjectApprover(userId, roleCode) {
roleCode = roleCode || "tgbzfz"; roleCode = roleCode || "tgbzfz";
// 获取投管部正副职tgbzfz的用户列表 // 获取投管部正副职tgbzfz的用户列表
let role = await DB.Role.findOne({where: {key: roleCode}, raw: true}); let role = await DB.Role.findOne({ where: { key: roleCode }, raw: true });
if(!(role && role.id)) { if (!(role && role.id)) {
return []; return [];
} }
let userIds = await DB.UserRole.findAll({where: {roleId: role.id}, raw: true}); let userIds = await DB.UserRole.findAll({ where: { roleId: role.id }, raw: true });
userIds = (userIds || []).map(o => {return o.userId}); userIds = (userIds || []).map(o => { return o.userId });
let users = await DB.User.findAll({ where: { id: {[Op.in]: userIds} } }); let users = await DB.User.findAll({ where: { id: { [Op.in]: userIds } } });
return users; return users;
} }
......
...@@ -47,7 +47,7 @@ router.post('/listProject', projectController.listProject); ...@@ -47,7 +47,7 @@ router.post('/listProject', projectController.listProject);
// router.post('/preJugProject', projectController.preJugProject); //初审 // router.post('/preJugProject', projectController.preJugProject); //初审
// router.post('/finalJugProject', projectController.finalJugProject); //终审 --暂时没有 // router.post('/finalJugProject', projectController.finalJugProject); //终审 --暂时没有
// router.post('/getOwnProjects', projectController.getOwnProjects); router.post('/getCompanyProjectApprover', projectController.getCompanyProjectApprover);
router.post('/getProFlowRecord', projectController.getProFlowRecord) router.post('/getProFlowRecord', projectController.getProFlowRecord)
......
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