|
@@ -2,48 +2,50 @@
|
|
* Created by Tony on 2017/3/17.
|
|
* Created by Tony on 2017/3/17.
|
|
*/
|
|
*/
|
|
var test = require('tape');
|
|
var test = require('tape');
|
|
-var cmn_ctrl = require('../../../modules/reports/models/cfg_control');
|
|
|
|
-var cmn_font = require('../../../modules/reports/models/cfg_font');
|
|
|
|
-var cmn_style = require('../../../modules/reports/models/cfg_style');
|
|
|
|
var mongoose = require('mongoose');
|
|
var mongoose = require('mongoose');
|
|
|
|
+var JV = require('../../../modules/reports/rpt_component/Jpc_ValueDefine');
|
|
|
|
+var Template = require('../../../modules/reports/models/rpt_template');
|
|
|
|
+var TemplateData = require('../../../modules/reports/models/rpt_temp_data');
|
|
|
|
+var JpcEx = require('../../../modules/reports/rpt_component/JpcEx');
|
|
|
|
+var rptUtil = require("../../../modules/reports/util/rpt_util");
|
|
|
|
|
|
test('test get report pages function: ', function (t) {
|
|
test('test get report pages function: ', function (t) {
|
|
- /*/
|
|
|
|
- t.plan(1);
|
|
|
|
- t.equal(2 + 3, 5);
|
|
|
|
- /*/
|
|
|
|
- cmn_ctrl.getAll(null, function(err, ctrls){
|
|
|
|
- t.notEqual(ctrls, null);
|
|
|
|
- t.end();
|
|
|
|
- return true;
|
|
|
|
- });
|
|
|
|
- //*/
|
|
|
|
|
|
+ rptUtil.setReportDefaultCache();
|
|
|
|
+ t.pass('just pass for cache setup!');
|
|
|
|
+ t.end();
|
|
});
|
|
});
|
|
|
|
|
|
test('test get report pages function: ', function (t) {
|
|
test('test get report pages function: ', function (t) {
|
|
- /*/
|
|
|
|
- t.plan(1);
|
|
|
|
- t.equal(7 * 8 + 9, 65);
|
|
|
|
- /*/
|
|
|
|
- cmn_font.getAll(null, function(err, fonts){
|
|
|
|
- t.notEqual(fonts, null);
|
|
|
|
|
|
+ var grp_id = "SC";
|
|
|
|
+ var tpl_id = "07_1";
|
|
|
|
+ var pageSize = "A4";
|
|
|
|
+ var rptTpl = null, tplData = null;
|
|
|
|
+ Template.getPromise(grp_id, tpl_id).then(function(rst) {
|
|
|
|
+ //console.log(rst);
|
|
|
|
+ rptTpl = rst;
|
|
|
|
+ console.log(rptTpl[JV.NODE_MAIN_INFO][JV.NODE_PAGE_INFO][JV.PROP_PAGE_SIZE]);
|
|
|
|
+ t.equal(rptTpl != null, true);
|
|
|
|
+ return TemplateData.getPromise(tpl_id);
|
|
|
|
+ }).then(function(rst){
|
|
|
|
+ //console.log(rst);
|
|
|
|
+ tplData = rst;
|
|
|
|
+ t.equal(tplData != null, true);
|
|
|
|
+ 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);
|
|
|
|
+ t.equal(pageRst != null, true);
|
|
|
|
+ }
|
|
t.end();
|
|
t.end();
|
|
- return true;
|
|
|
|
- });
|
|
|
|
- //*/
|
|
|
|
-});
|
|
|
|
-
|
|
|
|
-test('test get report pages function: ', function (t) {
|
|
|
|
- /*/
|
|
|
|
- t.plan(1);
|
|
|
|
- t.equal(1+2, 65);
|
|
|
|
- /*/
|
|
|
|
- cmn_style.getAll(null, function(err, styles){
|
|
|
|
- t.notEqual(styles, null);
|
|
|
|
|
|
+ }).catch(function (err) {
|
|
|
|
+ console.log("err: " + err);
|
|
t.end();
|
|
t.end();
|
|
- return true;
|
|
|
|
- });
|
|
|
|
- //*/
|
|
|
|
|
|
+ })
|
|
|
|
+
|
|
});
|
|
});
|
|
|
|
|
|
test('finish', function (t) {
|
|
test('finish', function (t) {
|