|
@@ -34,14 +34,14 @@ let consts = require('../../main/models/project_consts');
|
|
|
let rp = require('request-promise');
|
|
let rp = require('request-promise');
|
|
|
const commonUtil = require('../../../public/common_util');
|
|
const commonUtil = require('../../../public/common_util');
|
|
|
//统一回调函数
|
|
//统一回调函数
|
|
|
-let callback = function(req, res, err, message, data){
|
|
|
|
|
- res.json({error: err, message: message, data: data});
|
|
|
|
|
|
|
+let callback = function (req, res, err, message, data) {
|
|
|
|
|
+ res.json({ error: err, message: message, data: data });
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = {
|
|
module.exports = {
|
|
|
checkRight: function (req, res) {
|
|
checkRight: function (req, res) {
|
|
|
- if(typeof req.body.data === 'object'){
|
|
|
|
|
|
|
+ if (typeof req.body.data === 'object') {
|
|
|
req.body.data = JSON.stringify(req.body.data);
|
|
req.body.data = JSON.stringify(req.body.data);
|
|
|
}
|
|
}
|
|
|
let data = JSON.parse(req.body.data);
|
|
let data = JSON.parse(req.body.data);
|
|
@@ -60,7 +60,7 @@ module.exports = {
|
|
|
let shareInfo = null;
|
|
let shareInfo = null;
|
|
|
let isOpenShareProject = false;
|
|
let isOpenShareProject = false;
|
|
|
//判断是否是打开分享的项目,分享项目shareInfo不为null
|
|
//判断是否是打开分享的项目,分享项目shareInfo不为null
|
|
|
- if(userId !== result.userID){
|
|
|
|
|
|
|
+ if (userId !== result.userID) {
|
|
|
shareInfo = await pm_facade.getShareInfo(userId, result.ID);
|
|
shareInfo = await pm_facade.getShareInfo(userId, result.ID);
|
|
|
isOpenShareProject = true;
|
|
isOpenShareProject = true;
|
|
|
}
|
|
}
|
|
@@ -74,7 +74,7 @@ module.exports = {
|
|
|
callback(false);
|
|
callback(false);
|
|
|
});
|
|
});
|
|
|
},
|
|
},
|
|
|
- getProjects: async function(req, res){
|
|
|
|
|
|
|
+ getProjects: async function (req, res) {
|
|
|
await ProjectsData.getUserProjects(req.session.sessionUser.id, req.session.sessionCompilation._id, function(err, message, projects){
|
|
await ProjectsData.getUserProjects(req.session.sessionUser.id, req.session.sessionCompilation._id, function(err, message, projects){
|
|
|
if (projects) {
|
|
if (projects) {
|
|
|
callback(req, res, err, message, projects);
|
|
callback(req, res, err, message, projects);
|
|
@@ -84,8 +84,8 @@ module.exports = {
|
|
|
});
|
|
});
|
|
|
},
|
|
},
|
|
|
updateProjects: async function (req, res) {
|
|
updateProjects: async function (req, res) {
|
|
|
|
|
+ let data = JSON.parse(req.body.data);
|
|
|
try {
|
|
try {
|
|
|
- let data = JSON.parse(req.body.data);
|
|
|
|
|
await ProjectsData.updateUserProjects(req.session.sessionUser.id, req.session.sessionCompilation._id, req.session.sessionCompilation, data.updateData, function (err, message, data) {
|
|
await ProjectsData.updateUserProjects(req.session.sessionUser.id, req.session.sessionCompilation._id, req.session.sessionCompilation, data.updateData, function (err, message, data) {
|
|
|
if (err === 0) {
|
|
if (err === 0) {
|
|
|
callback(req, res, err, message, data);
|
|
callback(req, res, err, message, data);
|
|
@@ -99,7 +99,7 @@ module.exports = {
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
// CSL, 2017-12-14 该方法用于项目属性:提交保存混合型数据,这些数据来自不同的表,包括projects.property、ration、bills、labour_coes.
|
|
// CSL, 2017-12-14 该方法用于项目属性:提交保存混合型数据,这些数据来自不同的表,包括projects.property、ration、bills、labour_coes.
|
|
|
- updateMixDatas: async function(req, res){
|
|
|
|
|
|
|
+ updateMixDatas: async function (req, res) {
|
|
|
let datas = JSON.parse(req.body.data).mixDataArr;
|
|
let datas = JSON.parse(req.body.data).mixDataArr;
|
|
|
let functions = [];
|
|
let functions = [];
|
|
|
|
|
|
|
@@ -109,7 +109,7 @@ module.exports = {
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- function updateLC(){
|
|
|
|
|
|
|
+ function updateLC() {
|
|
|
return function (cb) {
|
|
return function (cb) {
|
|
|
datas.labourCoes.updateData.projectID = datas.projectID;
|
|
datas.labourCoes.updateData.projectID = datas.projectID;
|
|
|
labourCoe.save(datas.labourCoes.updateData, cb);
|
|
labourCoe.save(datas.labourCoes.updateData, cb);
|
|
@@ -117,84 +117,84 @@ module.exports = {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
// 项目属性
|
|
// 项目属性
|
|
|
- if (Object.keys(datas.properties).length > 0){
|
|
|
|
|
|
|
+ if (Object.keys(datas.properties).length > 0) {
|
|
|
//基本信息特殊处理,更新建设项目
|
|
//基本信息特殊处理,更新建设项目
|
|
|
- if(datas.properties['property.basicInformation']){
|
|
|
|
|
|
|
+ if (datas.properties['property.basicInformation']) {
|
|
|
let constructionProject = await pm_facade.getConstructionProject(datas.projectID);
|
|
let constructionProject = await pm_facade.getConstructionProject(datas.projectID);
|
|
|
- if(constructionProject){
|
|
|
|
|
- functions.push(updateFunc(projectModel, {ID: constructionProject.ID}, {'property.basicInformation': datas.properties['property.basicInformation']}));
|
|
|
|
|
|
|
+ if (constructionProject) {
|
|
|
|
|
+ functions.push(updateFunc(projectModel, { ID: constructionProject.ID }, { 'property.basicInformation': datas.properties['property.basicInformation'] }));
|
|
|
}
|
|
}
|
|
|
delete datas.properties['property.basicInformation'];
|
|
delete datas.properties['property.basicInformation'];
|
|
|
}
|
|
}
|
|
|
- functions.push(updateFunc(projectModel, {ID: datas.projectID}, datas.properties));
|
|
|
|
|
|
|
+ functions.push(updateFunc(projectModel, { ID: datas.projectID }, datas.properties));
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
//选项
|
|
//选项
|
|
|
- if(datas.options && datas.options.updateData){
|
|
|
|
|
- functions.push(updateFunc(optionModel, {user_id: req.session.sessionUser.id, compilation_id: req.session.sessionCompilation._id}, {'options.GENERALOPTS': datas.options.updateData}));
|
|
|
|
|
|
|
+ if (datas.options && datas.options.updateData) {
|
|
|
|
|
+ functions.push(updateFunc(optionModel, { user_id: req.session.sessionUser.id, compilation_id: req.session.sessionCompilation._id }, { 'options.GENERALOPTS': datas.options.updateData }));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 人工系数
|
|
// 人工系数
|
|
|
- if (datas.labourCoes&&datas.labourCoes.updateData){
|
|
|
|
|
|
|
+ if (datas.labourCoes && datas.labourCoes.updateData) {
|
|
|
functions.push(updateLC());
|
|
functions.push(updateLC());
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
// 清单:每文档doc只存储一条清单,每条清单都必须定位一次文档,无法合并处理
|
|
// 清单:每文档doc只存储一条清单,每条清单都必须定位一次文档,无法合并处理
|
|
|
- if (datas.bills.length > 0){
|
|
|
|
|
- for (let bill of datas.bills){
|
|
|
|
|
- functions.push(updateFunc(billsModel, {projectID: datas.projectID, ID: bill.ID, deleteInfo: null}, bill));
|
|
|
|
|
|
|
+ if (datas.bills && datas.bills.length > 0) {
|
|
|
|
|
+ for (let bill of datas.bills) {
|
|
|
|
|
+ functions.push(updateFunc(billsModel, { projectID: datas.projectID, ID: bill.ID, deleteInfo: null }, bill));
|
|
|
};
|
|
};
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
// 定额:每文档doc只存储一条定额,每条定额都必须定位一次文档,无法合并处理
|
|
// 定额:每文档doc只存储一条定额,每条定额都必须定位一次文档,无法合并处理
|
|
|
- if (datas.rations.length > 0){
|
|
|
|
|
- for (let ration of datas.rations){
|
|
|
|
|
- functions.push(updateFunc(rationsModel, {projectID: datas.projectID, ID: ration.ID, deleteInfo: null}, ration));
|
|
|
|
|
|
|
+ if (datas.rations && datas.rations.length > 0) {
|
|
|
|
|
+ for (let ration of datas.rations) {
|
|
|
|
|
+ functions.push(updateFunc(rationsModel, { projectID: datas.projectID, ID: ration.ID, deleteInfo: null }, ration));
|
|
|
};
|
|
};
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- asyncTool.parallel(functions, function(err, result){
|
|
|
|
|
|
|
+ asyncTool.parallel(functions, function (err, result) {
|
|
|
{
|
|
{
|
|
|
if (!err) {
|
|
if (!err) {
|
|
|
- res.json({error: 0, message: err, data: result});
|
|
|
|
|
|
|
+ res.json({ error: 0, message: err, data: result });
|
|
|
} else {
|
|
} else {
|
|
|
- res.json({error: 1, message: err, data: null});
|
|
|
|
|
|
|
+ res.json({ error: 1, message: err, data: null });
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
},
|
|
},
|
|
|
- updateFiles: async function(req, res){
|
|
|
|
|
|
|
+ updateFiles: async function (req, res) {
|
|
|
let data = JSON.parse(req.body.data);
|
|
let data = JSON.parse(req.body.data);
|
|
|
let updateDatas = data.updateDatas;
|
|
let updateDatas = data.updateDatas;
|
|
|
await ProjectsData.udpateUserFiles(req.session.sessionUser.id, updateDatas, function (err, message, data) {
|
|
await ProjectsData.udpateUserFiles(req.session.sessionUser.id, updateDatas, function (err, message, data) {
|
|
|
callback(req, res, err, message, data);
|
|
callback(req, res, err, message, data);
|
|
|
});
|
|
});
|
|
|
},
|
|
},
|
|
|
- defaultSettings: async function(req, res){
|
|
|
|
|
- try{
|
|
|
|
|
|
|
+ defaultSettings: async function (req, res) {
|
|
|
|
|
+ try {
|
|
|
let data = JSON.parse(req.body.data);
|
|
let data = JSON.parse(req.body.data);
|
|
|
let projectID = data.projectID;
|
|
let projectID = data.projectID;
|
|
|
let defaultSettingSc = await ProjectsData.defaultSettings(req.session.sessionUser.id, req.session.sessionCompilation, projectID);
|
|
let defaultSettingSc = await ProjectsData.defaultSettings(req.session.sessionUser.id, req.session.sessionCompilation, projectID);
|
|
|
- if(!defaultSettingSc){
|
|
|
|
|
|
|
+ if (!defaultSettingSc) {
|
|
|
throw '恢复失败';
|
|
throw '恢复失败';
|
|
|
}
|
|
}
|
|
|
- res.json({error: 0, message: '恢复成功', data: null});
|
|
|
|
|
|
|
+ res.json({ error: 0, message: '恢复成功', data: null });
|
|
|
}
|
|
}
|
|
|
- catch(error){
|
|
|
|
|
|
|
+ catch (error) {
|
|
|
console.log(error);
|
|
console.log(error);
|
|
|
- res.json({error: 1, message: error, data: null});
|
|
|
|
|
- }
|
|
|
|
|
- },
|
|
|
|
|
- /* copyProjects: function (req, res) {
|
|
|
|
|
- let data = JSON.parse(req.body.data);
|
|
|
|
|
- ProjectsData.copyUserProjects(req.session.sessionUser.id, req.session.sessionCompilation._id, data.updateData, function (err, message, data) {
|
|
|
|
|
- if (err === 0) {
|
|
|
|
|
- callback(req, res, err, message, data);
|
|
|
|
|
- } else {
|
|
|
|
|
- callback(req, res, err, message, null);
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
- },*/
|
|
|
|
|
|
|
+ res.json({ error: 1, message: error, data: null });
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ /* copyProjects: function (req, res) {
|
|
|
|
|
+ let data = JSON.parse(req.body.data);
|
|
|
|
|
+ ProjectsData.copyUserProjects(req.session.sessionUser.id, req.session.sessionCompilation._id, data.updateData, function (err, message, data) {
|
|
|
|
|
+ if (err === 0) {
|
|
|
|
|
+ callback(req, res, err, message, data);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ callback(req, res, err, message, null);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ },*/
|
|
|
rename: function (req, res) {
|
|
rename: function (req, res) {
|
|
|
let data = JSON.parse(req.body.data);
|
|
let data = JSON.parse(req.body.data);
|
|
|
ProjectsData.rename(req.session.sessionUser.id, req.session.sessionCompilation._id, data, function (err, message) {
|
|
ProjectsData.rename(req.session.sessionUser.id, req.session.sessionCompilation._id, data, function (err, message) {
|
|
@@ -202,8 +202,8 @@ module.exports = {
|
|
|
});
|
|
});
|
|
|
},
|
|
},
|
|
|
//project getData接口
|
|
//project getData接口
|
|
|
- getData: function(projectID, callback, userID) {
|
|
|
|
|
- projectModel.findOne({$or: [{deleteInfo: null}, {'deleteInfo.deleted': false}], ID: projectID}, '-_id').then(async function (project) {
|
|
|
|
|
|
|
+ getData: function (projectID, callback, isReport, userID) {
|
|
|
|
|
+ projectModel.findOne({ $or: [{ deleteInfo: null }, { 'deleteInfo.deleted': false }], ID: projectID }, '-_id').then(async function (project) {
|
|
|
if (!project) {
|
|
if (!project) {
|
|
|
callback('', consts.projectConst.PROJECT_INFO, {});
|
|
callback('', consts.projectConst.PROJECT_INFO, {});
|
|
|
}
|
|
}
|
|
@@ -212,10 +212,10 @@ module.exports = {
|
|
|
await engineeringLibModel.getEngineering(project.property.engineering_id) : null;
|
|
await engineeringLibModel.getEngineering(project.property.engineering_id) : null;
|
|
|
let projInfo = project._doc;
|
|
let projInfo = project._doc;
|
|
|
if (engineeringInfo !== null) {
|
|
if (engineeringInfo !== null) {
|
|
|
- if(engineeringInfo.billsGuidance_lib){
|
|
|
|
|
- for(let billsGuidanceLib of engineeringInfo.billsGuidance_lib){
|
|
|
|
|
- let stdBillsGuidanceLib = await stdBillsGuidanceLibModel.findOne({ID: billsGuidanceLib.id});
|
|
|
|
|
- if(stdBillsGuidanceLib){
|
|
|
|
|
|
|
+ if (engineeringInfo.billsGuidance_lib) {
|
|
|
|
|
+ for (let billsGuidanceLib of engineeringInfo.billsGuidance_lib) {
|
|
|
|
|
+ let stdBillsGuidanceLib = await stdBillsGuidanceLibModel.findOne({ ID: billsGuidanceLib.id });
|
|
|
|
|
+ if (stdBillsGuidanceLib) {
|
|
|
billsGuidanceLib.type = stdBillsGuidanceLib.type ? stdBillsGuidanceLib.type : 1;
|
|
billsGuidanceLib.type = stdBillsGuidanceLib.type ? stdBillsGuidanceLib.type : 1;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -244,10 +244,10 @@ module.exports = {
|
|
|
callback(err, consts.projectConst.PROJECT_INFO, {});
|
|
callback(err, consts.projectConst.PROJECT_INFO, {});
|
|
|
});
|
|
});
|
|
|
},
|
|
},
|
|
|
- getProject: function(req, res){
|
|
|
|
|
|
|
+ getProject: function (req, res) {
|
|
|
let data = JSON.parse(req.body.data);
|
|
let data = JSON.parse(req.body.data);
|
|
|
let projectID = data.proj_id;
|
|
let projectID = data.proj_id;
|
|
|
- ProjectsData.getUserProject(req.session.sessionUser.id, data.proj_id, async function(err, message, data){
|
|
|
|
|
|
|
+ ProjectsData.getUserProject(req.session.sessionUser.id, data.proj_id, async function (err, message, data) {
|
|
|
if (err === 0) {
|
|
if (err === 0) {
|
|
|
let engineeringLibModel = new EngineeringLibModel();
|
|
let engineeringLibModel = new EngineeringLibModel();
|
|
|
let engineeringInfo = data !== null && data.property.engineering_id !== undefined ?
|
|
let engineeringInfo = data !== null && data.property.engineering_id !== undefined ?
|
|
@@ -255,10 +255,10 @@ module.exports = {
|
|
|
let strData = JSON.stringify(data);
|
|
let strData = JSON.stringify(data);
|
|
|
let projInfo = JSON.parse(strData);
|
|
let projInfo = JSON.parse(strData);
|
|
|
if (engineeringInfo !== null) {
|
|
if (engineeringInfo !== null) {
|
|
|
- if(engineeringInfo.billsGuidance_lib){
|
|
|
|
|
- for(let billsGuidanceLib of engineeringInfo.billsGuidance_lib){
|
|
|
|
|
- let stdBillsGuidanceLib = await stdBillsGuidanceLibModel.findOne({ID: billsGuidanceLib.id});
|
|
|
|
|
- if(stdBillsGuidanceLib){
|
|
|
|
|
|
|
+ if (engineeringInfo.billsGuidance_lib) {
|
|
|
|
|
+ for (let billsGuidanceLib of engineeringInfo.billsGuidance_lib) {
|
|
|
|
|
+ let stdBillsGuidanceLib = await stdBillsGuidanceLibModel.findOne({ ID: billsGuidanceLib.id });
|
|
|
|
|
+ if (stdBillsGuidanceLib) {
|
|
|
billsGuidanceLib.type = stdBillsGuidanceLib.type ? stdBillsGuidanceLib.type : 1;
|
|
billsGuidanceLib.type = stdBillsGuidanceLib.type ? stdBillsGuidanceLib.type : 1;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -292,12 +292,11 @@ module.exports = {
|
|
|
});
|
|
});
|
|
|
},
|
|
},
|
|
|
// 项目管理首页
|
|
// 项目管理首页
|
|
|
- index: async function(request, response) {
|
|
|
|
|
- // 上线后删除,处理旧的分享数据
|
|
|
|
|
- // await pm_facade.prepareShareList();
|
|
|
|
|
|
|
+ index: async function (request, response) {
|
|
|
|
|
+ //await pm_facade.prepareShareList();
|
|
|
// 获取编办信息
|
|
// 获取编办信息
|
|
|
let sessionCompilation = request.session.sessionCompilation;
|
|
let sessionCompilation = request.session.sessionCompilation;
|
|
|
- if (sessionCompilation === undefined ||sessionCompilation ===null) {
|
|
|
|
|
|
|
+ if (sessionCompilation === undefined || sessionCompilation === null) {
|
|
|
return response.redirect('/logout');
|
|
return response.redirect('/logout');
|
|
|
}
|
|
}
|
|
|
let compilationModel = new CompilationModel();
|
|
let compilationModel = new CompilationModel();
|
|
@@ -306,7 +305,6 @@ module.exports = {
|
|
|
request.session.sessionCompilation = compilationData;
|
|
request.session.sessionCompilation = compilationData;
|
|
|
sessionCompilation = request.session.sessionCompilation;
|
|
sessionCompilation = request.session.sessionCompilation;
|
|
|
//更新用户的使用过的费用定额列表
|
|
//更新用户的使用过的费用定额列表
|
|
|
- //是否第一次进入该费用定额
|
|
|
|
|
let isFirst = await pm_facade.isFirst(request.session.sessionUser.id, compilationData._id.toString());
|
|
let isFirst = await pm_facade.isFirst(request.session.sessionUser.id, compilationData._id.toString());
|
|
|
// 清单计价
|
|
// 清单计价
|
|
|
let billValuation = sessionCompilation.bill_valuation !== undefined ?
|
|
let billValuation = sessionCompilation.bill_valuation !== undefined ?
|
|
@@ -321,7 +319,7 @@ module.exports = {
|
|
|
sessionCompilation.ration_valuation : [];
|
|
sessionCompilation.ration_valuation : [];
|
|
|
rationValuation = await engineeringLibModel.getLib(rationValuation);
|
|
rationValuation = await engineeringLibModel.getLib(rationValuation);
|
|
|
let absoluteUrl = compilationData.overWriteUrl ? request.app.locals.rootDir + compilationData.overWriteUrl : request.app.locals.rootDir;
|
|
let absoluteUrl = compilationData.overWriteUrl ? request.app.locals.rootDir + compilationData.overWriteUrl : request.app.locals.rootDir;
|
|
|
- let overWriteUrl = fs.existsSync(absoluteUrl) && fs.statSync(absoluteUrl).isFile()? compilationData.overWriteUrl : null;
|
|
|
|
|
|
|
+ let overWriteUrl = fs.existsSync(absoluteUrl) && fs.statSync(absoluteUrl).isFile() ? compilationData.overWriteUrl : null;
|
|
|
//欢迎页显示控制
|
|
//欢迎页显示控制
|
|
|
let [isShow,context,showTime] = await pm_facade.getWelcomeInfo(sessionCompilation._id,request.session.sessionUser,request.session.compilationVersion.includes('学习'));
|
|
let [isShow,context,showTime] = await pm_facade.getWelcomeInfo(sessionCompilation._id,request.session.sessionUser,request.session.compilationVersion.includes('学习'));
|
|
|
const unreadShareList = await pm_facade.getUnreadShareListByCompilation(request.session.sessionUser.id, sessionCompilation._id);
|
|
const unreadShareList = await pm_facade.getUnreadShareListByCompilation(request.session.sessionUser.id, sessionCompilation._id);
|
|
@@ -348,7 +346,7 @@ module.exports = {
|
|
|
response.render('building_saas/pm/html/project-management.html', renderData);
|
|
response.render('building_saas/pm/html/project-management.html', renderData);
|
|
|
},
|
|
},
|
|
|
//第一次进入该费用定额时准备的初始数据
|
|
//第一次进入该费用定额时准备的初始数据
|
|
|
- prepareInitialData: async function(request, response) {
|
|
|
|
|
|
|
+ prepareInitialData: async function (request, response) {
|
|
|
try {
|
|
try {
|
|
|
const data = {
|
|
const data = {
|
|
|
userID: request.session.sessionUser.id,
|
|
userID: request.session.sessionUser.id,
|
|
@@ -357,19 +355,19 @@ module.exports = {
|
|
|
};
|
|
};
|
|
|
await redirectToImportServer(data, 'prepareInitialData', request);
|
|
await redirectToImportServer(data, 'prepareInitialData', request);
|
|
|
callback(request, response, 0, 'success', null);
|
|
callback(request, response, 0, 'success', null);
|
|
|
- } catch(err) {
|
|
|
|
|
|
|
+ } catch (err) {
|
|
|
console.log(err);
|
|
console.log(err);
|
|
|
callback(request, response, 1, err.toString(), null);
|
|
callback(request, response, 1, err.toString(), null);
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
// 获取单价文件列表
|
|
// 获取单价文件列表
|
|
|
- getUnitFileList: async function(request, response) {
|
|
|
|
|
|
|
+ getUnitFileList: async function (request, response) {
|
|
|
let data = request.body.data;
|
|
let data = request.body.data;
|
|
|
try {
|
|
try {
|
|
|
data = JSON.parse(data);
|
|
data = JSON.parse(data);
|
|
|
let projectId = data.parentID !== undefined ? data.parentID : 0;
|
|
let projectId = data.parentID !== undefined ? data.parentID : 0;
|
|
|
if (isNaN(projectId) && projectId <= 0) {
|
|
if (isNaN(projectId) && projectId <= 0) {
|
|
|
- throw {msg: 'id数据有误!', err: 1};
|
|
|
|
|
|
|
+ throw { msg: 'id数据有误!', err: 1 };
|
|
|
}
|
|
}
|
|
|
/*// 获取对应建设项目下所有的单位工程id
|
|
/*// 获取对应建设项目下所有的单位工程id
|
|
|
let idList = await ProjectsData.getTenderByProjectId(projectId);
|
|
let idList = await ProjectsData.getTenderByProjectId(projectId);
|
|
@@ -381,7 +379,7 @@ module.exports = {
|
|
|
let unitPriceFileData = await unitPriceFileModel.getDataByRootProject(projectId);
|
|
let unitPriceFileData = await unitPriceFileModel.getDataByRootProject(projectId);
|
|
|
|
|
|
|
|
if (unitPriceFileData === null) {
|
|
if (unitPriceFileData === null) {
|
|
|
- throw {msg: '不存在对应单价文件', err: 0};
|
|
|
|
|
|
|
+ throw { msg: '不存在对应单价文件', err: 0 };
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 整理数据
|
|
// 整理数据
|
|
@@ -401,17 +399,17 @@ module.exports = {
|
|
|
callback(request, response, error.err, error.msg, responseData);
|
|
callback(request, response, error.err, error.msg, responseData);
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
- getFeeRateFileList:async function(request, response) {
|
|
|
|
|
|
|
+ getFeeRateFileList: async function (request, response) {
|
|
|
let data = request.body.data;
|
|
let data = request.body.data;
|
|
|
try {
|
|
try {
|
|
|
data = JSON.parse(data);
|
|
data = JSON.parse(data);
|
|
|
let projectId = data.parentID !== undefined ? data.parentID : 0;
|
|
let projectId = data.parentID !== undefined ? data.parentID : 0;
|
|
|
if (isNaN(projectId) && projectId <= 0) {
|
|
if (isNaN(projectId) && projectId <= 0) {
|
|
|
- throw {msg: 'id数据有误!', err: 1};
|
|
|
|
|
|
|
+ throw { msg: 'id数据有误!', err: 1 };
|
|
|
}
|
|
}
|
|
|
// 获取对应建设项目下所有的单位工程id
|
|
// 获取对应建设项目下所有的单位工程id
|
|
|
let feeRateFileList = await fee_rate_facade.getFeeRatesByProject(projectId);
|
|
let feeRateFileList = await fee_rate_facade.getFeeRatesByProject(projectId);
|
|
|
- callback(request, response, 0, '',feeRateFileList );
|
|
|
|
|
|
|
+ callback(request, response, 0, '', feeRateFileList);
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
console.log(error);
|
|
console.log(error);
|
|
|
let responseData = error.err === 1 ? null : [];
|
|
let responseData = error.err === 1 ? null : [];
|
|
@@ -452,45 +450,45 @@ module.exports = {
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
- getGCDatas: async function(request, response) {
|
|
|
|
|
|
|
+ getGCDatas: async function (request, response) {
|
|
|
let userID = request.session.sessionUser.id;
|
|
let userID = request.session.sessionUser.id;
|
|
|
let compilatoinId = request.session.sessionCompilation._id;
|
|
let compilatoinId = request.session.sessionCompilation._id;
|
|
|
let rst = [];
|
|
let rst = [];
|
|
|
let _projs = Object.create(null), _engs = Object.create(null), prefix = 'ID_';
|
|
let _projs = Object.create(null), _engs = Object.create(null), prefix = 'ID_';
|
|
|
- try{
|
|
|
|
|
|
|
+ try {
|
|
|
let gc_unitPriceFiles = await ProjectsData.getGCFiles(fileType.unitPriceFile, userID);
|
|
let gc_unitPriceFiles = await ProjectsData.getGCFiles(fileType.unitPriceFile, userID);
|
|
|
let gc_feeRateFiles = await ProjectsData.getGCFiles(fileType.feeRateFile, userID);
|
|
let gc_feeRateFiles = await ProjectsData.getGCFiles(fileType.feeRateFile, userID);
|
|
|
let gc_tenderFiles = await ProjectsData.getGCFiles(projType.tender, userID);
|
|
let gc_tenderFiles = await ProjectsData.getGCFiles(projType.tender, userID);
|
|
|
- for(let i = 0, len = gc_unitPriceFiles.length; i < len; i++){
|
|
|
|
|
|
|
+ for (let i = 0, len = gc_unitPriceFiles.length; i < len; i++) {
|
|
|
let gc_uf = gc_unitPriceFiles[i];
|
|
let gc_uf = gc_unitPriceFiles[i];
|
|
|
let theProj = _projs[prefix + gc_uf.root_project_id] || null;
|
|
let theProj = _projs[prefix + gc_uf.root_project_id] || null;
|
|
|
- if(!theProj){
|
|
|
|
|
|
|
+ if (!theProj) {
|
|
|
let tempProj = await ProjectsData.getProjectsByIds(userID, compilatoinId, [gc_uf.root_project_id]);
|
|
let tempProj = await ProjectsData.getProjectsByIds(userID, compilatoinId, [gc_uf.root_project_id]);
|
|
|
- if(tempProj.length > 0 && tempProj[0].projType !== projType.folder){
|
|
|
|
|
|
|
+ if (tempProj.length > 0 && tempProj[0].projType !== projType.folder) {
|
|
|
theProj = _projs[prefix + gc_uf.root_project_id] = tempProj[0]._doc;
|
|
theProj = _projs[prefix + gc_uf.root_project_id] = tempProj[0]._doc;
|
|
|
buildProj(theProj);
|
|
buildProj(theProj);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- if(theProj){
|
|
|
|
|
|
|
+ if (theProj) {
|
|
|
theProj.unitPriceFiles.push(gc_uf);
|
|
theProj.unitPriceFiles.push(gc_uf);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- for(let i = 0, len = gc_feeRateFiles.length; i < len; i++){
|
|
|
|
|
|
|
+ for (let i = 0, len = gc_feeRateFiles.length; i < len; i++) {
|
|
|
let gc_ff = gc_feeRateFiles[i];
|
|
let gc_ff = gc_feeRateFiles[i];
|
|
|
let theProj = _projs[prefix + gc_ff.rootProjectID] || null;
|
|
let theProj = _projs[prefix + gc_ff.rootProjectID] || null;
|
|
|
- if(!theProj){
|
|
|
|
|
|
|
+ if (!theProj) {
|
|
|
let tempProj = await ProjectsData.getProjectsByIds(userID, compilatoinId, [gc_ff.rootProjectID]);
|
|
let tempProj = await ProjectsData.getProjectsByIds(userID, compilatoinId, [gc_ff.rootProjectID]);
|
|
|
- if(tempProj.length > 0 && tempProj[0].projType !== projType.folder){
|
|
|
|
|
|
|
+ if (tempProj.length > 0 && tempProj[0].projType !== projType.folder) {
|
|
|
theProj = _projs[prefix + gc_ff.rootProjectID] = tempProj[0]._doc;
|
|
theProj = _projs[prefix + gc_ff.rootProjectID] = tempProj[0]._doc;
|
|
|
buildProj(theProj);
|
|
buildProj(theProj);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- if(theProj) {
|
|
|
|
|
|
|
+ if (theProj) {
|
|
|
theProj.feeRateFiles.push(gc_ff);
|
|
theProj.feeRateFiles.push(gc_ff);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- if(gc_tenderFiles.length > 0){
|
|
|
|
|
- for(let i = 0, len = gc_tenderFiles.length; i < len; i++){
|
|
|
|
|
|
|
+ if (gc_tenderFiles.length > 0) {
|
|
|
|
|
+ for (let i = 0, len = gc_tenderFiles.length; i < len; i++) {
|
|
|
let gc_t = gc_tenderFiles[i];
|
|
let gc_t = gc_tenderFiles[i];
|
|
|
let theProj = _projs[prefix + gc_t.ParentID] || null;
|
|
let theProj = _projs[prefix + gc_t.ParentID] || null;
|
|
|
if(!theProj){
|
|
if(!theProj){
|
|
@@ -505,22 +503,22 @@ module.exports = {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- for(let i in _projs){
|
|
|
|
|
|
|
+ for (let i in _projs) {
|
|
|
rst.push(_projs[i]);
|
|
rst.push(_projs[i]);
|
|
|
}
|
|
}
|
|
|
- function buildProj(proj){
|
|
|
|
|
|
|
+ function buildProj(proj) {
|
|
|
proj.children = [];
|
|
proj.children = [];
|
|
|
proj.unitPriceFiles = [];
|
|
proj.unitPriceFiles = [];
|
|
|
proj.feeRateFiles = [];
|
|
proj.feeRateFiles = [];
|
|
|
}
|
|
}
|
|
|
callback(request, response, 0, 'success', rst);
|
|
callback(request, response, 0, 'success', rst);
|
|
|
}
|
|
}
|
|
|
- catch (error){
|
|
|
|
|
|
|
+ catch (error) {
|
|
|
callback(request, response, true, error, null);
|
|
callback(request, response, true, error, null);
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
- recGC: function(request, response){
|
|
|
|
|
|
|
+ recGC: function (request, response) {
|
|
|
let userID = request.session.sessionUser.id,
|
|
let userID = request.session.sessionUser.id,
|
|
|
compilationId = request.session.sessionCompilation._id;
|
|
compilationId = request.session.sessionCompilation._id;
|
|
|
let data = JSON.parse(request.body.data);
|
|
let data = JSON.parse(request.body.data);
|
|
@@ -528,76 +526,76 @@ module.exports = {
|
|
|
ProjectsData.recGC(userID, compilationId, nodes, function (err, msg, data) {
|
|
ProjectsData.recGC(userID, compilationId, nodes, function (err, msg, data) {
|
|
|
callback(request, response, err, msg, data);
|
|
callback(request, response, err, msg, data);
|
|
|
});
|
|
});
|
|
|
- },
|
|
|
|
|
|
|
+ },
|
|
|
|
|
|
|
|
- delGC: async function(request, response){
|
|
|
|
|
|
|
+ delGC: async function (request, response) {
|
|
|
let data = JSON.parse(request.body.data);
|
|
let data = JSON.parse(request.body.data);
|
|
|
let delDatas = data.delDatas;
|
|
let delDatas = data.delDatas;
|
|
|
let bulkProjs = [], bulkUFs = [], bulkFFs = [];
|
|
let bulkProjs = [], bulkUFs = [], bulkFFs = [];
|
|
|
- try{
|
|
|
|
|
- for(let data of delDatas){
|
|
|
|
|
- if(data.updateType === 'Project'){
|
|
|
|
|
- bulkProjs.push({updateOne: {filter: {ID: data.ID}, update: {'deleteInfo.completeDeleted': true}}});
|
|
|
|
|
|
|
+ try {
|
|
|
|
|
+ for (let data of delDatas) {
|
|
|
|
|
+ if (data.updateType === 'Project') {
|
|
|
|
|
+ bulkProjs.push({ updateOne: { filter: { ID: data.ID }, update: { 'deleteInfo.completeDeleted': true } } });
|
|
|
}
|
|
}
|
|
|
- else if(data.updateType === fileType.unitPriceFile){
|
|
|
|
|
- bulkUFs.push({updateOne: {filter: {id: data.ID}, update: {'deleteInfo.completeDeleted': true}}});
|
|
|
|
|
|
|
+ else if (data.updateType === fileType.unitPriceFile) {
|
|
|
|
|
+ bulkUFs.push({ updateOne: { filter: { id: data.ID }, update: { 'deleteInfo.completeDeleted': true } } });
|
|
|
}
|
|
}
|
|
|
- else{
|
|
|
|
|
- bulkFFs.push({updateOne: {filter: {ID: data.ID}, update: {'deleteInfo.completeDeleted': true}}});
|
|
|
|
|
|
|
+ else {
|
|
|
|
|
+ bulkFFs.push({ updateOne: { filter: { ID: data.ID }, update: { 'deleteInfo.completeDeleted': true } } });
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- if(bulkProjs.length > 0){
|
|
|
|
|
|
|
+ if (bulkProjs.length > 0) {
|
|
|
await projectModel.bulkWrite(bulkProjs);
|
|
await projectModel.bulkWrite(bulkProjs);
|
|
|
}
|
|
}
|
|
|
- if(bulkUFs.length > 0){
|
|
|
|
|
|
|
+ if (bulkUFs.length > 0) {
|
|
|
await unitPriceFileModel.bulkWrite(bulkUFs);
|
|
await unitPriceFileModel.bulkWrite(bulkUFs);
|
|
|
}
|
|
}
|
|
|
- if(bulkFFs.length > 0){
|
|
|
|
|
|
|
+ if (bulkFFs.length > 0) {
|
|
|
await feeRateFileModel.bulkWrite(bulkFFs);
|
|
await feeRateFileModel.bulkWrite(bulkFFs);
|
|
|
}
|
|
}
|
|
|
callback(request, response, 0, 'success', null);
|
|
callback(request, response, 0, 'success', null);
|
|
|
- } catch(err){
|
|
|
|
|
|
|
+ } catch (err) {
|
|
|
callback(request, response, 1, err, null);
|
|
callback(request, response, 1, err, null);
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
- moveProject:async function(req,res){
|
|
|
|
|
- let result={
|
|
|
|
|
- error:0
|
|
|
|
|
|
|
+ moveProject: async function (req, res) {
|
|
|
|
|
+ let result = {
|
|
|
|
|
+ error: 0
|
|
|
};
|
|
};
|
|
|
try {
|
|
try {
|
|
|
let data = req.body.data;
|
|
let data = req.body.data;
|
|
|
- let rdata= await pm_facade.moveProject(data);
|
|
|
|
|
- result.data= rdata;
|
|
|
|
|
- }catch (err){
|
|
|
|
|
|
|
+ let rdata = await pm_facade.moveProject(data);
|
|
|
|
|
+ result.data = rdata;
|
|
|
|
|
+ } catch (err) {
|
|
|
console.log(err);
|
|
console.log(err);
|
|
|
- result.error=1;
|
|
|
|
|
|
|
+ result.error = 1;
|
|
|
result.message = err.message;
|
|
result.message = err.message;
|
|
|
}
|
|
}
|
|
|
res.json(result);
|
|
res.json(result);
|
|
|
},
|
|
},
|
|
|
- copyProjects:async function (req, res) {
|
|
|
|
|
- let result={
|
|
|
|
|
- error:0
|
|
|
|
|
|
|
+ copyProjects: async function (req, res) {
|
|
|
|
|
+ let result = {
|
|
|
|
|
+ error: 0
|
|
|
};
|
|
};
|
|
|
try {
|
|
try {
|
|
|
- let data = {dataString:req.body.data,userID:req.session.sessionUser.id,compilationID:req.session.sessionCompilation._id};
|
|
|
|
|
- result = await redirectToImportServer(data,"copyProject",req);
|
|
|
|
|
- }catch (err){
|
|
|
|
|
|
|
+ let data = { dataString: req.body.data, userID: req.session.sessionUser.id, compilationID: req.session.sessionCompilation._id };
|
|
|
|
|
+ result = await redirectToImportServer(data, "copyProject", req);
|
|
|
|
|
+ } catch (err) {
|
|
|
console.log(err);
|
|
console.log(err);
|
|
|
- result.error=1;
|
|
|
|
|
|
|
+ result.error = 1;
|
|
|
result.message = err.message;
|
|
result.message = err.message;
|
|
|
}
|
|
}
|
|
|
res.json(result);
|
|
res.json(result);
|
|
|
},
|
|
},
|
|
|
- projectShareInfo: async function(req, res){
|
|
|
|
|
- try{
|
|
|
|
|
|
|
+ projectShareInfo: async function (req, res) {
|
|
|
|
|
+ try {
|
|
|
const data = JSON.parse(req.body.data);
|
|
const data = JSON.parse(req.body.data);
|
|
|
- const shareList = await pm_facade.getShareList({projectID: data.projectID});
|
|
|
|
|
|
|
+ const shareList = await pm_facade.getShareList({ projectID: data.projectID });
|
|
|
const shareInfoMap = await pm_facade.getShareInfoMap(null, shareList);
|
|
const shareInfoMap = await pm_facade.getShareInfoMap(null, shareList);
|
|
|
const shareInfo = shareInfoMap[data.projectID] || [];
|
|
const shareInfo = shareInfoMap[data.projectID] || [];
|
|
|
callback(req, res, 0, 'success', shareInfo);
|
|
callback(req, res, 0, 'success', shareInfo);
|
|
|
}
|
|
}
|
|
|
- catch (err){
|
|
|
|
|
|
|
+ catch (err) {
|
|
|
callback(req, res, 1, err, null);
|
|
callback(req, res, 1, err, null);
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
@@ -704,7 +702,7 @@ module.exports = {
|
|
|
const rstTask = [
|
|
const rstTask = [
|
|
|
pm_facade.getRecentShareList(userID, count),
|
|
pm_facade.getRecentShareList(userID, count),
|
|
|
userModelObj.getContacts(userID)
|
|
userModelObj.getContacts(userID)
|
|
|
- ]
|
|
|
|
|
|
|
+ ];
|
|
|
// 获取需要广播推送的单位工程
|
|
// 获取需要广播推送的单位工程
|
|
|
// shareData数组的形式是以前需求需要,现在的需求下,shareData数组必定只有一个元素
|
|
// shareData数组的形式是以前需求需要,现在的需求下,shareData数组必定只有一个元素
|
|
|
const emitTenders = await pm_facade.getShareInfoAfterChangePermission(permissionType, shareData[0].userID, projectID);
|
|
const emitTenders = await pm_facade.getShareInfoAfterChangePermission(permissionType, shareData[0].userID, projectID);
|
|
@@ -720,20 +718,20 @@ module.exports = {
|
|
|
callback(req, res, 1, String(err), null);
|
|
callback(req, res, 1, String(err), null);
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
- receiveProjects: async function(req, res) {
|
|
|
|
|
|
|
+ receiveProjects: async function (req, res) {
|
|
|
try {
|
|
try {
|
|
|
- let rst = {grouped: [], ungrouped: [], summaryInfo: null};
|
|
|
|
|
|
|
+ let rst = { grouped: [], ungrouped: [], summaryInfo: null };
|
|
|
let userID = req.session.sessionUser.id;
|
|
let userID = req.session.sessionUser.id;
|
|
|
const shareList = await pm_facade.getShareList({ receiver: userID });
|
|
const shareList = await pm_facade.getShareList({ receiver: userID });
|
|
|
const receiveProjectIDs = shareList.map(item => item.projectID);
|
|
const receiveProjectIDs = shareList.map(item => item.projectID);
|
|
|
const compilation = req.session.sessionCompilation._id;
|
|
const compilation = req.session.sessionCompilation._id;
|
|
|
- const notDeleted = [{deleteInfo: null}, {'deleteInfo.deleted': false}];
|
|
|
|
|
- const receiveProjects = await projectModel.find({ID: {$in: receiveProjectIDs}, compilation, $or: notDeleted}, '-_id').lean();
|
|
|
|
|
|
|
+ const notDeleted = [{ deleteInfo: null }, { 'deleteInfo.deleted': false }];
|
|
|
|
|
+ const receiveProjects = await projectModel.find({ ID: { $in: receiveProjectIDs }, compilation, $or: notDeleted }, '-_id').lean();
|
|
|
//设置原项目用户信息
|
|
//设置原项目用户信息
|
|
|
const shareInfoMap = await pm_facade.getShareInfoMap(null, shareList);
|
|
const shareInfoMap = await pm_facade.getShareInfoMap(null, shareList);
|
|
|
- if(receiveProjects.length > 0){
|
|
|
|
|
|
|
+ if (receiveProjects.length > 0) {
|
|
|
let orgUserIDs = [];
|
|
let orgUserIDs = [];
|
|
|
- for(let proj of receiveProjects){
|
|
|
|
|
|
|
+ for (let proj of receiveProjects) {
|
|
|
orgUserIDs.push(proj.userID);
|
|
orgUserIDs.push(proj.userID);
|
|
|
if (proj.projType === projType.tender) {
|
|
if (proj.projType === projType.tender) {
|
|
|
// 设置项目类别
|
|
// 设置项目类别
|
|
@@ -747,14 +745,14 @@ module.exports = {
|
|
|
}
|
|
}
|
|
|
orgUserIDs = Array.from(new Set(orgUserIDs));
|
|
orgUserIDs = Array.from(new Set(orgUserIDs));
|
|
|
let userObjIDs = [];
|
|
let userObjIDs = [];
|
|
|
- for(let uID of orgUserIDs){
|
|
|
|
|
|
|
+ for (let uID of orgUserIDs) {
|
|
|
userObjIDs.push(mongoose.Types.ObjectId(uID));
|
|
userObjIDs.push(mongoose.Types.ObjectId(uID));
|
|
|
}
|
|
}
|
|
|
- let orgUsersInfo = await userModel.find({_id: {$in : userObjIDs}});
|
|
|
|
|
|
|
+ let orgUsersInfo = await userModel.find({ _id: { $in: userObjIDs } });
|
|
|
//建设项目
|
|
//建设项目
|
|
|
let consProjIDs = [],
|
|
let consProjIDs = [],
|
|
|
ungroupedTenders = [];
|
|
ungroupedTenders = [];
|
|
|
- for(let proj of receiveProjects){
|
|
|
|
|
|
|
+ for (let proj of receiveProjects) {
|
|
|
// 设置分享信息
|
|
// 设置分享信息
|
|
|
proj.shareInfo = shareInfoMap[proj.ID] || [];
|
|
proj.shareInfo = shareInfoMap[proj.ID] || [];
|
|
|
if (proj.projType === projType.project) {
|
|
if (proj.projType === projType.project) {
|
|
@@ -787,9 +785,9 @@ module.exports = {
|
|
|
}
|
|
}
|
|
|
//设置项目类型为来自别人分享
|
|
//设置项目类型为来自别人分享
|
|
|
proj.shareType = 'receive';
|
|
proj.shareType = 'receive';
|
|
|
- for(let userData of orgUsersInfo){
|
|
|
|
|
- if(proj.userID == userData._id.toString()){
|
|
|
|
|
- let userInfo = {name: userData.real_name, mobile: userData.mobile, company: userData.company, email: userData.email};
|
|
|
|
|
|
|
+ for (let userData of orgUsersInfo) {
|
|
|
|
|
+ if (proj.userID == userData._id.toString()) {
|
|
|
|
|
+ let userInfo = { name: userData.real_name, mobile: userData.mobile, company: userData.company, email: userData.email };
|
|
|
proj.userInfo = userInfo;
|
|
proj.userInfo = userInfo;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -797,17 +795,17 @@ module.exports = {
|
|
|
consProjIDs = Array.from(new Set(consProjIDs));
|
|
consProjIDs = Array.from(new Set(consProjIDs));
|
|
|
let summaryInfo = await pm_facade.getSummaryInfo(consProjIDs);
|
|
let summaryInfo = await pm_facade.getSummaryInfo(consProjIDs);
|
|
|
let tendersFeeInfo = await pm_facade.getTendersFeeInfo(ungroupedTenders);
|
|
let tendersFeeInfo = await pm_facade.getTendersFeeInfo(ungroupedTenders);
|
|
|
- rst.summaryInfo = {grouped: summaryInfo, ungrouped: tendersFeeInfo};
|
|
|
|
|
|
|
+ rst.summaryInfo = { grouped: summaryInfo, ungrouped: tendersFeeInfo };
|
|
|
}
|
|
}
|
|
|
callback(req, res, 0, 'success', rst);
|
|
callback(req, res, 0, 'success', rst);
|
|
|
}
|
|
}
|
|
|
- catch (err){
|
|
|
|
|
|
|
+ catch (err) {
|
|
|
console.log(err);
|
|
console.log(err);
|
|
|
callback(req, res, 1, err, null);
|
|
callback(req, res, 1, err, null);
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
getProjectsByQuery: async function (req, res) {
|
|
getProjectsByQuery: async function (req, res) {
|
|
|
- try{
|
|
|
|
|
|
|
+ try {
|
|
|
let data = JSON.parse(req.body.data);
|
|
let data = JSON.parse(req.body.data);
|
|
|
let compilation = req.session.sessionCompilation._id;
|
|
let compilation = req.session.sessionCompilation._id;
|
|
|
let query = data.query;
|
|
let query = data.query;
|
|
@@ -816,57 +814,58 @@ module.exports = {
|
|
|
let projects = await projectModel.find(query, options);
|
|
let projects = await projectModel.find(query, options);
|
|
|
callback(req, res, 0, 'success', projects);
|
|
callback(req, res, 0, 'success', projects);
|
|
|
}
|
|
}
|
|
|
- catch (err){
|
|
|
|
|
|
|
+ catch (err) {
|
|
|
callback(req, res, 1, err, null);
|
|
callback(req, res, 1, err, null);
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
- getSummaryInfo: async function(req, res){
|
|
|
|
|
- try{
|
|
|
|
|
|
|
+ getSummaryInfo: async function (req, res) {
|
|
|
|
|
+ try {
|
|
|
let data = JSON.parse(req.body.data);
|
|
let data = JSON.parse(req.body.data);
|
|
|
let summaryInfo = await pm_facade.getSummaryInfo(data.projectIDs);
|
|
let summaryInfo = await pm_facade.getSummaryInfo(data.projectIDs);
|
|
|
callback(req, res, 0, 'success', summaryInfo);
|
|
callback(req, res, 0, 'success', summaryInfo);
|
|
|
}
|
|
}
|
|
|
- catch (err){
|
|
|
|
|
|
|
+ catch (err) {
|
|
|
callback(req, res, 1, err, null);
|
|
callback(req, res, 1, err, null);
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
- changeFile:async function(req,res){
|
|
|
|
|
- try{
|
|
|
|
|
|
|
+ changeFile: async function (req, res) {
|
|
|
|
|
+ try {
|
|
|
let data = JSON.parse(req.body.data);
|
|
let data = JSON.parse(req.body.data);
|
|
|
console.log(data);
|
|
console.log(data);
|
|
|
- await pm_facade.changeFile(data.projects,data.user_id,data.fileID,data.name,data.from,data.type);
|
|
|
|
|
|
|
+ await pm_facade.changeFile(data.projects, data.user_id, data.fileID, data.name, data.from, data.type);
|
|
|
callback(req, res, 0, 'success', []);
|
|
callback(req, res, 0, 'success', []);
|
|
|
}
|
|
}
|
|
|
- catch (err){
|
|
|
|
|
|
|
+ catch (err) {
|
|
|
console.log(err);
|
|
console.log(err);
|
|
|
callback(req, res, 1, err, null);
|
|
callback(req, res, 1, err, null);
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
- exportProject:async function(req,res){
|
|
|
|
|
- let result={
|
|
|
|
|
- error:0
|
|
|
|
|
|
|
+ exportProject: async function (req, res) {
|
|
|
|
|
+ let result = {
|
|
|
|
|
+ error: 0
|
|
|
};
|
|
};
|
|
|
try {
|
|
try {
|
|
|
- let data = {dataString:req.body.data,userID:req.session.sessionUser.id};
|
|
|
|
|
- result = await redirectToImportServer(data,"exportProject",req);
|
|
|
|
|
- }catch (err){
|
|
|
|
|
|
|
+ let data = { dataString: req.body.data, userID: req.session.sessionUser.id };
|
|
|
|
|
+ result = await redirectToImportServer(data, "exportProject", req);
|
|
|
|
|
+ } catch (err) {
|
|
|
console.log(err);
|
|
console.log(err);
|
|
|
- result.error=1;
|
|
|
|
|
|
|
+ result.error = 1;
|
|
|
result.message = err.message;
|
|
result.message = err.message;
|
|
|
}
|
|
}
|
|
|
res.json(result);
|
|
res.json(result);
|
|
|
|
|
+
|
|
|
},
|
|
},
|
|
|
- importProject:async function(req,res){
|
|
|
|
|
|
|
+ importProject: async function (req, res) {
|
|
|
let data = JSON.parse(req.body.data);
|
|
let data = JSON.parse(req.body.data);
|
|
|
- let result={
|
|
|
|
|
- error:0
|
|
|
|
|
|
|
+ let result = {
|
|
|
|
|
+ error: 0
|
|
|
};
|
|
};
|
|
|
try {
|
|
try {
|
|
|
data.session = req.session;
|
|
data.session = req.session;
|
|
|
result = await redirectToImportServer(data,"importProject",req);
|
|
result = await redirectToImportServer(data,"importProject",req);
|
|
|
- }catch (err){
|
|
|
|
|
|
|
+ } catch (err) {
|
|
|
console.log(err);
|
|
console.log(err);
|
|
|
- result.error=1;
|
|
|
|
|
|
|
+ result.error = 1;
|
|
|
result.message = err.message;
|
|
result.message = err.message;
|
|
|
}
|
|
}
|
|
|
res.json(result);
|
|
res.json(result);
|
|
@@ -886,31 +885,31 @@ module.exports = {
|
|
|
}
|
|
}
|
|
|
res.json(result);
|
|
res.json(result);
|
|
|
},
|
|
},
|
|
|
- importProcessChecking:async function (req,res) {
|
|
|
|
|
- let result={
|
|
|
|
|
- error:0
|
|
|
|
|
|
|
+ importProcessChecking: async function (req, res) {
|
|
|
|
|
+ let result = {
|
|
|
|
|
+ error: 0
|
|
|
};
|
|
};
|
|
|
- try{
|
|
|
|
|
|
|
+ try {
|
|
|
let data = JSON.parse(req.body.data);
|
|
let data = JSON.parse(req.body.data);
|
|
|
data.userID = req.session.sessionUser.id;
|
|
data.userID = req.session.sessionUser.id;
|
|
|
data.compilationID = req.session.sessionCompilation._id;
|
|
data.compilationID = req.session.sessionCompilation._id;
|
|
|
result.data = await pm_facade.importProcessChecking(data);
|
|
result.data = await pm_facade.importProcessChecking(data);
|
|
|
- } catch (err){
|
|
|
|
|
|
|
+ } catch (err) {
|
|
|
console.log(err);
|
|
console.log(err);
|
|
|
- result.error=1;
|
|
|
|
|
|
|
+ result.error = 1;
|
|
|
result.message = err.message;
|
|
result.message = err.message;
|
|
|
}
|
|
}
|
|
|
res.json(result);
|
|
res.json(result);
|
|
|
},
|
|
},
|
|
|
- getUploadToken:function (req,res) {
|
|
|
|
|
- let result={
|
|
|
|
|
- error:0
|
|
|
|
|
|
|
+ getUploadToken: function (req, res) {
|
|
|
|
|
+ let result = {
|
|
|
|
|
+ error: 0
|
|
|
};
|
|
};
|
|
|
try {
|
|
try {
|
|
|
- result =pm_facade.uploadToken();
|
|
|
|
|
- }catch (err){
|
|
|
|
|
|
|
+ result = pm_facade.uploadToken();
|
|
|
|
|
+ } catch (err) {
|
|
|
console.log(err);
|
|
console.log(err);
|
|
|
- result.error=1;
|
|
|
|
|
|
|
+ result.error = 1;
|
|
|
result.message = err.message;
|
|
result.message = err.message;
|
|
|
}
|
|
}
|
|
|
res.json(result);
|
|
res.json(result);
|
|
@@ -918,15 +917,15 @@ module.exports = {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
-async function redirectToImportServer(data,action,req) {
|
|
|
|
|
- let importURL = config.getImportURL(process.env.NODE_ENV,req.headers.origin);
|
|
|
|
|
|
|
+async function redirectToImportServer(data, action, req) {
|
|
|
|
|
+ let importURL = config.getImportURL(process.env.NODE_ENV, req.headers.origin);
|
|
|
let options = {
|
|
let options = {
|
|
|
method: 'POST',
|
|
method: 'POST',
|
|
|
uri: `http://${importURL}/import/${action}`,
|
|
uri: `http://${importURL}/import/${action}`,
|
|
|
body: data,
|
|
body: data,
|
|
|
- timeout:220000,
|
|
|
|
|
|
|
+ timeout: 220000,
|
|
|
json: true
|
|
json: true
|
|
|
};
|
|
};
|
|
|
- console.log("post import data to:"+options.uri);
|
|
|
|
|
|
|
+ console.log("post import data to:" + options.uri);
|
|
|
return await rp.post(options);
|
|
return await rp.post(options);
|
|
|
}
|
|
}
|