|
@@ -26,31 +26,33 @@ module.exports = {
|
|
|
var grp_id = req.body.grp_id;
|
|
|
var tpl_id = req.body.tpl_id;
|
|
|
var pageSize = req.body.pageSize;
|
|
|
- Template.get(grp_id, tpl_id, function(err, rptTpl){
|
|
|
+ var rptTpl = null;
|
|
|
+ Template.getPromise(grp_id, tpl_id).then(function(rst) {
|
|
|
+ rptTpl = rst;
|
|
|
if (rptTpl) {
|
|
|
- TemplateData.get(tpl_id, function(err, tplData){
|
|
|
- if (tplData) {
|
|
|
- var printCom = JpcEx.createNew();
|
|
|
- rptTpl[JV.NODE_MAIN_INFO][JV.NODE_PAGE_INFO][JV.PROP_PAGE_SIZE] = pageSize;
|
|
|
- var defProperties = rptUtil.getReportDefaultCache();
|
|
|
- printCom.initialize(rptTpl);
|
|
|
- printCom.analyzeData(rptTpl, tplData, defProperties);
|
|
|
- var maxPages = printCom.totalPages;
|
|
|
- var pageRst = printCom.outputAsSimpleJSONPageArray(rptTpl, tplData, 1, maxPages, defProperties);
|
|
|
- if (pageRst) {
|
|
|
- callback(req, res, err, pageRst);
|
|
|
- } else {
|
|
|
- callback(req, res, "Have errors while on going...", null);
|
|
|
- }
|
|
|
- //callback(req, res, err, tplData);
|
|
|
+ return TemplateData.getPromise(tpl_id);
|
|
|
+ } else {
|
|
|
+ callback(req, res, 'No report template was found!', null);
|
|
|
+ }
|
|
|
+ }).then(function(tplData){
|
|
|
+ if (tplData) {
|
|
|
+ var printCom = JpcEx.createNew();
|
|
|
+ rptTpl[JV.NODE_MAIN_INFO][JV.NODE_PAGE_INFO][JV.PROP_PAGE_SIZE] = pageSize;
|
|
|
+ var defProperties = rptUtil.getReportDefaultCache();
|
|
|
+ printCom.initialize(rptTpl);
|
|
|
+ printCom.analyzeData(rptTpl, tplData, defProperties);
|
|
|
+ var maxPages = printCom.totalPages;
|
|
|
+ var pageRst = printCom.outputAsSimpleJSONPageArray(rptTpl, tplData, 1, maxPages, defProperties);
|
|
|
+ if (pageRst) {
|
|
|
+ callback(req, res, null, pageRst);
|
|
|
} else {
|
|
|
- callback(req, res, err, null);
|
|
|
+ callback(req, res, "Have errors while on going...", null);
|
|
|
}
|
|
|
- })
|
|
|
- } else {
|
|
|
- callback(req, res, err, null);
|
|
|
+ } else {
|
|
|
+ callback(req, res, 'No report data were found!', null);
|
|
|
+ }
|
|
|
}
|
|
|
- });
|
|
|
+ );
|
|
|
},
|
|
|
remove: function(req, res){
|
|
|
}
|