123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- /**
- * Created by Tony on 2018/4/8.
- */
- let test = require('tape');
- import JpcEx from "../../../modules/reports/rpt_component/jpc_ex";
- import JV from "../../../modules/reports/rpt_component/jpc_value_define";
- let config = require("../../../config/config.js");
- config.setupDb(process.env.NODE_ENV);
- let mongoose = require("mongoose");
- let fileUtils = require("../../../modules/common/fileUtils");
- let path = require('path');
- let dbm = require("../../../config/db/db_manager");
- let rpt_cfg = require('./rpt_cfg');
- dbm.connect(process.env.NODE_ENV);
- //统一引用models
- fileUtils.getGlobbedFiles('../../../modules/all_models/*.js').forEach(function(modelPath) {
- require(path.resolve(modelPath));
- });
- let cfgCacheUtil = require("../../../config/cacheCfg");
- cfgCacheUtil.setupDftCache();
- let fsUtil = require("../../../public/fsUtil");
- // let demoPrjId = - 1;
- let demoRptId = 232; //重庆09年建筑 09表
- // let demoRptId = 229; //重庆09年建筑 封2表
- let pagesize = "A4";
- // demoPrjId = 720; //QA: DW3
- // demoPrjId = 1626; //QA:
- //*/
- let userId_Leng = 1142; //小冷User Id
- let userId_Dft = userId_Leng;
- /*/
- let userId_Dft = 76075;
- //*/
- let rptTplFacade = require("../../../modules/reports/facade/rpt_template_facade");
- let fs = require('fs');
- //设置Date Format函数
- fs.readFile(__dirname.slice(0, __dirname.length - 18) + '/public/web/date_util.js', 'utf8', 'r', function (err, data) {
- eval(data);
- });
- //*
- test('测试 - 预览: ', function (t) {
- rptTplFacade.getRptTemplate(demoRptId).then(function(rptTpl) {
- if (rptTpl) {
- try {
- let printCom = JpcEx.createNew();
- let defProperties = rpt_cfg;
- rptTpl[JV.NODE_MAIN_INFO][JV.NODE_PAGE_INFO][JV.PROP_PAGE_SIZE] = pagesize;
- printCom.initialize(rptTpl);
- let pageRst = printCom.outputAsPreviewPage(rptTpl, defProperties);
- if (pageRst) {
- fsUtil.writeObjToFile(pageRst, "D:/GitHome/ConstructionCost/tmp/previewPageResult.jsp");
- t.pass('pass with succeed!');
- t.end();
- } else {
- console.log("oh! no pages were created!");
- t.pass('pass with no page!');
- t.end();
- }
- } catch (ex) {
- console.log(ex);
- t.pass('pass with exception!');
- t.end();
- }
- } else {
- t.pass('no template was found!');
- t.end();
- }
- });
- });
- //*/
- test('close the connection', function (t) {
- setTimeout(function () {
- mongoose.disconnect();
- t.pass('closing db connection');
- t.end();
- }, 1000);
- // mongoose.disconnect();
- // t.pass('closing db connection');
- // t.end();
- });
|