|
@@ -18,12 +18,12 @@ import rttFacade from "../facade/rpt_tpl_tree_node_facade";
|
|
|
import CompilationModel from "../../users/models/compilation_model";
|
|
|
|
|
|
//统一回调函数
|
|
|
-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 });
|
|
|
};
|
|
|
|
|
|
let mExport = {
|
|
|
- getCustomerCfg: function(req, res) {
|
|
|
+ getCustomerCfg: function (req, res) {
|
|
|
let params = JSON.parse(req.body.params),
|
|
|
userId = params.userId,
|
|
|
me = this;
|
|
@@ -43,7 +43,7 @@ let mExport = {
|
|
|
rst.push(null);
|
|
|
for (let itemCfg of custCfg) {
|
|
|
// rst = itemCfg;
|
|
|
- let doc = (itemCfg._doc)?itemCfg._doc:itemCfg;
|
|
|
+ let doc = (itemCfg._doc) ? itemCfg._doc : itemCfg;
|
|
|
let dest = {};
|
|
|
copyRptCfg(doc, dest);
|
|
|
if (doc.userId !== "-100") {
|
|
@@ -59,10 +59,10 @@ let mExport = {
|
|
|
copyRptCfg(rst[0], userDest);
|
|
|
rst.push(userDest);
|
|
|
}
|
|
|
- callback(req,res, false, "", rst);
|
|
|
+ callback(req, res, false, "", rst);
|
|
|
} else {
|
|
|
//failed
|
|
|
- callback(req,res, true, "失败!", null);
|
|
|
+ callback(req, res, true, "失败!", null);
|
|
|
}
|
|
|
})
|
|
|
},
|
|
@@ -76,27 +76,27 @@ let mExport = {
|
|
|
rptCustCfgFacade.saveCustomizeCfg(custCfg).then(function (rst) {
|
|
|
if (rst) {
|
|
|
//success
|
|
|
- callback(req,res, false, "", "success!");
|
|
|
+ callback(req, res, false, "", "success!");
|
|
|
} else {
|
|
|
//failed
|
|
|
- callback(req,res, true, "更新失败!", null);
|
|
|
+ callback(req, res, true, "更新失败!", null);
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
- getDftTemplates: function(req, res) {
|
|
|
- let filter = {"userId": "-100", "$or": [{"isDeleted": null}, {"isDeleted": false} ]};
|
|
|
- TreeNodeModel.find(filter, '-_id', function(err, data){
|
|
|
+ getDftTemplates: function (req, res) {
|
|
|
+ let filter = { "userId": "-100", "$or": [{ "isDeleted": null }, { "isDeleted": false }] };
|
|
|
+ TreeNodeModel.find(filter, '-_id', function (err, data) {
|
|
|
if (err) {
|
|
|
- callback(req,res, true,"", null);
|
|
|
+ callback(req, res, true, "", null);
|
|
|
} else {
|
|
|
- callback(req,res,false,"", data);
|
|
|
+ callback(req, res, false, "", data);
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
- getExtCodeTpl: function(req, res) {
|
|
|
- rptExtCodeModel.find({}).exec().then(function(rstCodeTpl) {
|
|
|
+ getExtCodeTpl: function (req, res) {
|
|
|
+ rptExtCodeModel.find({}).exec().then(function (rstCodeTpl) {
|
|
|
if (rstCodeTpl) {
|
|
|
- callback(req,res, false, "", rstCodeTpl);
|
|
|
+ callback(req, res, false, "", rstCodeTpl);
|
|
|
} else {
|
|
|
callback(req, res, 'The report template was not found!', null);
|
|
|
}
|
|
@@ -104,16 +104,16 @@ let mExport = {
|
|
|
},
|
|
|
getCompilationList(req, res) {
|
|
|
let compilationModel = new CompilationModel();
|
|
|
- let compilationList = compilationModel.getCompilationList();
|
|
|
+ let compilationList = compilationModel.getPermissionCompilationList(req);
|
|
|
if (compilationList) {
|
|
|
compilationList.then(function (rst) {
|
|
|
- callback(req,res,false,"", rst);
|
|
|
+ callback(req, res, false, "", rst);
|
|
|
})
|
|
|
} else {
|
|
|
- callback(req,res, true,"no result", null);
|
|
|
+ callback(req, res, true, "no result", null);
|
|
|
}
|
|
|
},
|
|
|
- getRptTplTree: function(req, res) {
|
|
|
+ getRptTplTree: function (req, res) {
|
|
|
let params = JSON.parse(req.body.params),
|
|
|
compilationId = params.compilationId,
|
|
|
userId = params.userId,
|
|
@@ -134,11 +134,11 @@ let mExport = {
|
|
|
if (!compilationId) {
|
|
|
compilationId = req.session.sessionCompilation._id;
|
|
|
}
|
|
|
- rttFacade.findTplTree(compilationId, userIds).then(function(result) {
|
|
|
+ rttFacade.findTplTree(compilationId, userIds).then(function (result) {
|
|
|
if (result) {
|
|
|
- callback(req,res,false,"", result);
|
|
|
+ callback(req, res, false, "", result);
|
|
|
} else {
|
|
|
- callback(req,res, true,"no result", null);
|
|
|
+ callback(req, res, true, "no result", null);
|
|
|
}
|
|
|
});
|
|
|
},
|
|
@@ -149,76 +149,76 @@ let mExport = {
|
|
|
if (!compilationId) {
|
|
|
compilationId = req.session.sessionCompilation._id;
|
|
|
}
|
|
|
- rttFacade.findTplTreeByCompilation(compilationId).then(function(result) {
|
|
|
+ rttFacade.findTplTreeByCompilation(compilationId).then(function (result) {
|
|
|
if (result) {
|
|
|
- callback(req,res,false,"", result);
|
|
|
+ callback(req, res, false, "", result);
|
|
|
} else {
|
|
|
- callback(req,res, true,"no result", null);
|
|
|
+ callback(req, res, true, "no result", null);
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
- updateTreeNodes: function(req, res) {
|
|
|
+ updateTreeNodes: function (req, res) {
|
|
|
let params = JSON.parse(req.body.params),
|
|
|
nodes = params.nodes;
|
|
|
let functions = [];
|
|
|
for (let node of nodes) {
|
|
|
- functions.push((function(doc) {
|
|
|
- return function(cb) {
|
|
|
- TreeNodeModel.update({ID: doc.ID}, doc, cb);
|
|
|
+ functions.push((function (doc) {
|
|
|
+ return function (cb) {
|
|
|
+ TreeNodeModel.update({ ID: doc.ID }, doc, cb);
|
|
|
};
|
|
|
})(node));
|
|
|
}
|
|
|
- async.parallel(functions, function(err, results) {
|
|
|
- callback(req,res, err, "", results);
|
|
|
+ async.parallel(functions, function (err, results) {
|
|
|
+ callback(req, res, err, "", results);
|
|
|
});
|
|
|
},
|
|
|
- deleteRptTplNodes: function(req, res){
|
|
|
+ deleteRptTplNodes: function (req, res) {
|
|
|
let params = JSON.parse(req.body.params),
|
|
|
nodeIds = params.nodeIds,
|
|
|
preNodeId = params.preNodeId,
|
|
|
preNodeNextId = params.preNodeNextId;
|
|
|
let functions = [];
|
|
|
if (preNodeId !== -1) {
|
|
|
- functions.push((function(nodeId, nextId) {
|
|
|
- return function(cb) {
|
|
|
- TreeNodeModel.update({ID: nodeId}, {"NextSiblingID": nextId}, cb);
|
|
|
+ functions.push((function (nodeId, nextId) {
|
|
|
+ return function (cb) {
|
|
|
+ TreeNodeModel.update({ ID: nodeId }, { "NextSiblingID": nextId }, cb);
|
|
|
};
|
|
|
})(preNodeId, preNodeNextId));
|
|
|
}
|
|
|
for (let nId of nodeIds) {
|
|
|
- functions.push((function(nodeId) {
|
|
|
- return function(cb) {
|
|
|
- TreeNodeModel.update({ID: nodeId}, {"isDeleted": true}, cb);
|
|
|
+ functions.push((function (nodeId) {
|
|
|
+ return function (cb) {
|
|
|
+ TreeNodeModel.update({ ID: nodeId }, { "isDeleted": true }, cb);
|
|
|
};
|
|
|
})(nId));
|
|
|
}
|
|
|
- async.parallel(functions, function(err, results) {
|
|
|
- callback(req,res, err, "", results);
|
|
|
+ async.parallel(functions, function (err, results) {
|
|
|
+ callback(req, res, err, "", results);
|
|
|
});
|
|
|
},
|
|
|
- createTreeRootNode: function(req, res){
|
|
|
+ createTreeRootNode: function (req, res) {
|
|
|
let params = JSON.parse(req.body.params),
|
|
|
doc = params.doc;
|
|
|
rttFacade.createNewTree(doc).then(function (rst) {
|
|
|
if (rst) {
|
|
|
//success
|
|
|
- callback(req,res, false, "", rst);
|
|
|
+ callback(req, res, false, "", rst);
|
|
|
} else {
|
|
|
//failed
|
|
|
- callback(req,res, true, "创建失败!", null);
|
|
|
+ callback(req, res, true, "创建失败!", null);
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
- updateTreeRootNode: function(req, res){
|
|
|
+ updateTreeRootNode: function (req, res) {
|
|
|
let params = JSON.parse(req.body.params),
|
|
|
doc = params.doc;
|
|
|
rttFacade.updateTree(doc.compilationId, doc.engineerId, doc.userId, doc).then(function (rst) {
|
|
|
if (rst) {
|
|
|
//success
|
|
|
- callback(req,res, false, "", rst);
|
|
|
+ callback(req, res, false, "", rst);
|
|
|
} else {
|
|
|
//failed
|
|
|
- callback(req,res, true, "更新失败!", null);
|
|
|
+ callback(req, res, true, "更新失败!", null);
|
|
|
}
|
|
|
})
|
|
|
},
|
|
@@ -228,17 +228,17 @@ let mExport = {
|
|
|
compilationId = params.compilationId, engineerId = params.engineerId,
|
|
|
userId = params.userId,
|
|
|
nodeName = params.nodeName
|
|
|
- ;
|
|
|
+ ;
|
|
|
if (req.session.sessionUser && req.session.sessionUser.id) userId = req.session.sessionUser.id;
|
|
|
- let filter = {"compilationId": compilationId, "engineerId": engineerId, "userId": userId, "$or": [{"isDeleted": null}, {"isDeleted": false}]};
|
|
|
- let updateStatement = {"$set": {"name": nodeName}};
|
|
|
+ let filter = { "compilationId": compilationId, "engineerId": engineerId, "userId": userId, "$or": [{ "isDeleted": null }, { "isDeleted": false }] };
|
|
|
+ let updateStatement = { "$set": { "name": nodeName } };
|
|
|
rttFacade.updateTreeInDetail(filter, updateStatement).then(function (rst) {
|
|
|
if (rst) {
|
|
|
//success
|
|
|
- callback(req,res, false, "", rst);
|
|
|
+ callback(req, res, false, "", rst);
|
|
|
} else {
|
|
|
//failed
|
|
|
- callback(req,res, true, "更新失败!", null);
|
|
|
+ callback(req, res, true, "更新失败!", null);
|
|
|
}
|
|
|
});
|
|
|
},
|
|
@@ -248,17 +248,17 @@ let mExport = {
|
|
|
// engineerId = params.engineerId,
|
|
|
userId = params.userId,
|
|
|
subNode = params.subNode
|
|
|
- ;
|
|
|
+ ;
|
|
|
if (req.session.sessionUser && req.session.sessionUser.id) userId = req.session.sessionUser.id; //备注:这段逻辑只会在前端有效,后端运维不会走到
|
|
|
- let filter = {"compilationId": compilationId, "userId": userId, "items.ID": subNode.ID, "$or": [{"isDeleted": null}, {"isDeleted": false}]};
|
|
|
- let updateStatement = {$set: {"items.$": subNode}};
|
|
|
+ let filter = { "compilationId": compilationId, "userId": userId, "items.ID": subNode.ID, "$or": [{ "isDeleted": null }, { "isDeleted": false }] };
|
|
|
+ let updateStatement = { $set: { "items.$": subNode } };
|
|
|
rttFacade.updateTreeInDetail(filter, updateStatement).then(function (rst) {
|
|
|
if (rst) {
|
|
|
//success
|
|
|
- callback(req,res, false, "", rst);
|
|
|
+ callback(req, res, false, "", rst);
|
|
|
} else {
|
|
|
//failed
|
|
|
- callback(req,res, true, "更新失败!", null);
|
|
|
+ callback(req, res, true, "更新失败!", null);
|
|
|
}
|
|
|
});
|
|
|
},
|
|
@@ -275,32 +275,32 @@ let mExport = {
|
|
|
rttFacade.removeTreePhycically(compilationId, engineerId, userId).then(function (rst) {
|
|
|
if (rst) {
|
|
|
//success
|
|
|
- callback(req,res, false, "", rst);
|
|
|
+ callback(req, res, false, "", rst);
|
|
|
} else {
|
|
|
//failed
|
|
|
- callback(req,res, true, "删除失败!", null);
|
|
|
+ callback(req, res, true, "删除失败!", null);
|
|
|
}
|
|
|
})
|
|
|
} else {
|
|
|
rttFacade.removeTree(compilationId, engineerId, userId).then(function (rst) {
|
|
|
if (rst) {
|
|
|
//success
|
|
|
- callback(req,res, false, "", rst);
|
|
|
+ callback(req, res, false, "", rst);
|
|
|
} else {
|
|
|
//failed
|
|
|
- callback(req,res, true, "删除失败!", null);
|
|
|
+ callback(req, res, true, "删除失败!", null);
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
},
|
|
|
- getNewNodeID: function(req, res) {
|
|
|
+ getNewNodeID: function (req, res) {
|
|
|
let params = JSON.parse(req.body.params),
|
|
|
scope = params.scope;
|
|
|
- counter.counterDAO.getIDAfterCount(counter.moduleName.report, scope, function(err, result){
|
|
|
- callback(req,res, false, "", result.sequence_value);
|
|
|
+ counter.counterDAO.getIDAfterCount(counter.moduleName.report, scope, function (err, result) {
|
|
|
+ callback(req, res, false, "", result.sequence_value);
|
|
|
});
|
|
|
},
|
|
|
- createDftRptTpl: function(req, res) {
|
|
|
+ createDftRptTpl: function (req, res) {
|
|
|
let params = JSON.parse(req.body.params),
|
|
|
treeNodeId = params.treeNodeId,
|
|
|
rptDftTplId = params.rptDftTplId,
|
|
@@ -310,10 +310,10 @@ let mExport = {
|
|
|
engineerId = params.engineerId,
|
|
|
userId = params.userId,
|
|
|
subNode = params.subNode
|
|
|
- ;
|
|
|
+ ;
|
|
|
if (req.session.sessionUser && req.session.sessionUser.id) userId = req.session.sessionUser.id;
|
|
|
- let filter = {"ID": rptDftTplId};
|
|
|
- RptTplModel.findOne(filter, '-_id').exec().then(function(dftTplRst) {
|
|
|
+ let filter = { "ID": rptDftTplId };
|
|
|
+ RptTplModel.findOne(filter, '-_id').exec().then(function (dftTplRst) {
|
|
|
if (dftTplRst) {
|
|
|
let _doc = dftTplRst["_doc"];
|
|
|
_doc["ID"] = treeNodeId;
|
|
@@ -323,17 +323,17 @@ let mExport = {
|
|
|
let rptTpl = new RptTplModel(_doc);
|
|
|
rptTpl.save(function (err, actTplRst) {
|
|
|
if (err) {
|
|
|
- callback(req,res, "报表模板创建错误", "", null);
|
|
|
+ callback(req, res, "报表模板创建错误", "", null);
|
|
|
} else {
|
|
|
- let filter = {"compilationId": compilationId, "engineerId": engineerId, "userId": userId, "items.ID": subNode.ID, "$or": [{"isDeleted": null}, {"isDeleted": false}]};
|
|
|
- let updateStatement = {$set: {"items.$": subNode}};
|
|
|
+ let filter = { "compilationId": compilationId, "engineerId": engineerId, "userId": userId, "items.ID": subNode.ID, "$or": [{ "isDeleted": null }, { "isDeleted": false }] };
|
|
|
+ let updateStatement = { $set: { "items.$": subNode } };
|
|
|
rttFacade.updateTreeInDetail(filter, updateStatement).then(function (rst) {
|
|
|
if (rst) {
|
|
|
//success
|
|
|
- callback(req,res, false, "", actTplRst);
|
|
|
+ callback(req, res, false, "", actTplRst);
|
|
|
} else {
|
|
|
//failed
|
|
|
- callback(req,res, true, "更新失败!", null);
|
|
|
+ callback(req, res, true, "更新失败!", null);
|
|
|
}
|
|
|
});
|
|
|
}
|
|
@@ -346,10 +346,10 @@ let mExport = {
|
|
|
getRefRptTpl: function (req, res) {
|
|
|
let params = JSON.parse(req.body.params),
|
|
|
rptTplId = params.rptTplId;
|
|
|
- let filter = {"ID": rptTplId};
|
|
|
- RptTplModel.findOne(filter, '-_id').exec().then(function(rstTpl) {
|
|
|
+ let filter = { "ID": rptTplId };
|
|
|
+ RptTplModel.findOne(filter, '-_id').exec().then(function (rstTpl) {
|
|
|
if (rstTpl) {
|
|
|
- callback(req,res, false, "", rstTpl);
|
|
|
+ callback(req, res, false, "", rstTpl);
|
|
|
} else {
|
|
|
callback(req, res, 'The report template was not found!', null);
|
|
|
}
|
|
@@ -358,8 +358,8 @@ let mExport = {
|
|
|
updateRptTpl: function (req, res) {
|
|
|
let params = JSON.parse(req.body.params),
|
|
|
rptTpl = JSON.parse(params.rptTpl);
|
|
|
- let filter = {"ID": parseInt(rptTpl[JV.PROP_ID])},
|
|
|
- options = {"overwrite": true};
|
|
|
+ let filter = { "ID": parseInt(rptTpl[JV.PROP_ID]) },
|
|
|
+ options = { "overwrite": true };
|
|
|
RptTplModel.update(filter, rptTpl, options, function (err, rst) {
|
|
|
if (err) {
|
|
|
callback(req, res, true, 'The report template was updated failed!', false);
|
|
@@ -372,8 +372,8 @@ let mExport = {
|
|
|
let params = JSON.parse(req.body.params),
|
|
|
orgRptTplId = params.orgRptTplId,
|
|
|
newID = params.newRptTplId;
|
|
|
- let filter = {"ID": orgRptTplId};
|
|
|
- RptTplModel.findOne(filter, '-_id').exec().then(function(baseTplRst) {
|
|
|
+ let filter = { "ID": orgRptTplId };
|
|
|
+ RptTplModel.findOne(filter, '-_id').exec().then(function (baseTplRst) {
|
|
|
if (baseTplRst) {
|
|
|
let _doc = baseTplRst["_doc"];
|
|
|
_doc["ID"] = newID;
|
|
@@ -383,9 +383,9 @@ let mExport = {
|
|
|
let rptTpl = new RptTplModel(_doc);
|
|
|
rptTpl.save(function (err, actTplRst) {
|
|
|
if (err) {
|
|
|
- callback(req,res, "报表模板创建错误", "", null);
|
|
|
+ callback(req, res, "报表模板创建错误", "", null);
|
|
|
} else {
|
|
|
- callback(req,res, false, "", newID);
|
|
|
+ callback(req, res, false, "", newID);
|
|
|
}
|
|
|
});
|
|
|
} else {
|
|
@@ -396,14 +396,16 @@ let mExport = {
|
|
|
};
|
|
|
|
|
|
function copyRptCfg(src, dest) {
|
|
|
- dest.margins = {Left: src.margins.Left, Right: src.margins.Right, Top: src.margins.Top, Bottom: src.margins.Bottom};
|
|
|
+ dest.margins = { Left: src.margins.Left, Right: src.margins.Right, Top: src.margins.Top, Bottom: src.margins.Bottom };
|
|
|
dest.showVerticalLine = src.showVerticalLine;
|
|
|
dest.isNarrow = src.isNarrow;
|
|
|
dest.fillZero = src.fillZero;
|
|
|
dest.fonts = [];
|
|
|
for (let font of src.fonts) {
|
|
|
- dest.fonts.push({"ID": font["ID"], "CfgDispName": font["CfgDispName"], "Name": font["Name"], "FontHeight": font["FontHeight"], "FontColor": font["FontColor"],
|
|
|
- "FontBold": font["FontBold"], "FontItalic": font["FontItalic"], "FontUnderline": font["FontUnderline"], "FontStrikeOut": font["FontStrikeOut"], "FontAngle": font["FontAngle"]});
|
|
|
+ dest.fonts.push({
|
|
|
+ "ID": font["ID"], "CfgDispName": font["CfgDispName"], "Name": font["Name"], "FontHeight": font["FontHeight"], "FontColor": font["FontColor"],
|
|
|
+ "FontBold": font["FontBold"], "FontItalic": font["FontItalic"], "FontUnderline": font["FontUnderline"], "FontStrikeOut": font["FontStrikeOut"], "FontAngle": font["FontAngle"]
|
|
|
+ });
|
|
|
}
|
|
|
}
|
|
|
|