TonyKang преди 7 години
родител
ревизия
15b67fb555

+ 33 - 0
modules/all_models/rpt_customize_cfg.js

@@ -0,0 +1,33 @@
+/**
+ * Created by Tony on 2018/4/18.
+ * 用户自定义报表输出格式(如字体,边距,竖线,窄体,小数补0等)
+ */
+import mongoose from "mongoose";
+let Schema = mongoose.Schema;
+let CustomizeCfgSchema = new Schema({
+    userId: String,
+    fonts: [{
+        "ID" : String,
+        "CfgDispName" : String,
+        "Name" : String,
+        "FontHeight" : Number,
+        "FontColor" : String,
+        "FontBold" : String,
+        "FontItalic" : String,
+        "FontUnderline" : String,
+        "FontStrikeOut" : String,
+        "FontAngle" : Number
+        }
+    ],
+    margins: {
+        Left: Number,
+        Right: Number,
+        Top: Number,
+        Bottom: Number
+    },
+    showVerticalLine: Boolean,
+    isNarrow: Boolean,
+    fillZero: Boolean
+});
+
+mongoose.model("rpt_customize_cfg", CustomizeCfgSchema, "rpt_customize_cfg");

+ 49 - 34
modules/reports/controllers/rpt_tpl_controller.js

@@ -10,22 +10,48 @@ import counter from "../../../public/counter/counter";
 let RptTplModel = mongoose.model('rpt_templates');
 let TreeNodeModel = mongoose.model('rpt_tpl_tree');
 
-import rpttplDefObj from "../../../public/rpt_tpl_def";
-let rptTplDef = rpttplDefObj.getUtil();
+let rptCustCfgFacade = require("../facade/rpt_cust_cfg_facade");
 
-//import stringUtil from "../../../public/stringUtil";
 import JV from "../rpt_component/jpc_value_define";
 import rttFacade from "../facade/rpt_tpl_tree_node_facade";
 import CompilationModel from "../../users/models/compilation_model";
 
-//import test_glj_type_util from "../../../public/cache/std_glj_type_util");
-
 //统一回调函数
 let callback = function(req, res, err, message, data){
     res.json({error: err, message: message, data: data});
 };
 
 let mExport = {
+    getCustomerCfg(req, res) {
+        let params = JSON.parse(req.body.params)
+            // userId = params.userId
+        ;
+        let userId = req.session.sessionUser.id;
+        let userIds = [];
+        userIds.push(userId);
+        if (userId !== "-100") {
+            userIds.push("-100");
+        }
+        rptCustCfgFacade.getCustomizeCfg(userIds).then(function (custCfg) {
+            if (custCfg) {
+                //success
+                let rst = null;
+                if (custCfg.length > 0) {
+                    for (let itemCfg of custCfg) {
+                        rst = itemCfg;
+                        let doc = (itemCfg._doc)?itemCfg._doc:itemCfg;
+                        if (doc.userId !== "-100") {
+                            break;
+                        }
+                    }
+                }
+                callback(req,res, false, "", rst);
+            } else {
+                //failed
+                callback(req,res, true, "失败!", null);
+            }
+        })
+    },
     getDftTemplates(req, res) {
         let filter = {"userId": "-100", "$or": [{"isDeleted": null}, {"isDeleted": false} ]};
         TreeNodeModel.find(filter, '-_id', function(err, data){
@@ -50,12 +76,18 @@ let mExport = {
     getRptTplTree: function(req, res) {
         let params = JSON.parse(req.body.params),
             compilationId = params.compilationId,
-            userId = params.userId,
+            // userId = params.userId,
             engineerId = params.engineerId;
+        let userId = req.session.sessionUser.id;
+        let userIds = [];
+        userIds.push(userId);
+        if (userId != "-100") {
+            userIds.push("-100");
+        }
         if (!compilationId) {
             compilationId = req.session.sessionCompilation._id;
         }
-        rttFacade.findTplTree(compilationId, engineerId, userId).then(function(result) {
+        rttFacade.findTplTree(compilationId, engineerId, userIds).then(function(result) {
             if (result) {
                 callback(req,res,false,"", result);
             } else {
@@ -63,29 +95,6 @@ let mExport = {
             }
         });
     },
-    // getRptTplTree_org: function(req, res) {
-    //     let params = JSON.parse(req.body.params),
-    //         grpType = params.grpType,
-    //         userId = params.userId,
-    //         tplType = params.tplType;
-    //     let filter = {"grpType": grpType, "$or": [{"isDeleted": null}, {"isDeleted": false} ]};
-    //     if (userId) {
-    //         filter.userId = userId;
-    //     }
-    //     if ((tplType && tplType !== rptTplDef.TplType.ALL)) {
-    //         filter.tplType = tplType;
-    //     }
-    //     TreeNodeModel.find(filter, '-_id', function(err, data){
-    //         if (err) {
-    //             callback(req,res, true,"", null);
-    //         } else {
-    //             callback(req,res,false,"", data);
-    //         }
-    //     });
-    //     // let obj = test_glj_type_util.getStdGljTypeCacheObj();
-    //     // console.log(obj.toArray());
-    //     // console.log(obj.getItemById(1));
-    // },
     updateTreeNodes: function(req, res) {
         let params = JSON.parse(req.body.params),
             nodes = params.nodes;
@@ -153,9 +162,11 @@ let mExport = {
     },
     updateTopNodeName: function (req, res) {
         let params = JSON.parse(req.body.params),
-            compilationId = params.compilationId, engineerId = params.engineerId, userId = params.userId,
+            compilationId = params.compilationId, engineerId = params.engineerId,
+            // userId = params.userId,
             nodeName = params.nodeName
         ;
+        let userId = req.session.sessionUser.id;
         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) {
@@ -170,9 +181,11 @@ let mExport = {
     },
     updateSubLevelOneNode: function (req, res) {
         let params = JSON.parse(req.body.params),
-            compilationId = params.compilationId, engineerId = params.engineerId, userId = params.userId,
+            compilationId = params.compilationId, engineerId = params.engineerId,
+            // userId = params.userId,
             subNode = params.subNode
         ;
+        let userId = req.session.sessionUser.id;
         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) {
@@ -190,9 +203,10 @@ let mExport = {
         let params = JSON.parse(req.body.params),
             compilationId = params.compilationId,
             engineerId = params.engineerId,
-            userId = params.userId,
+            // userId = params.userId,
             isPhysically = params.isPhysically
             ;
+        let userId = req.session.sessionUser.id;
         if (isPhysically) {
             rttFacade.removeTreePhycically(compilationId, engineerId, userId).then(function (rst) {
                 if (rst) {
@@ -254,9 +268,10 @@ let mExport = {
             grpKey = params.grpKey,
             compilationId = params.compilationId,
             engineerId = params.engineerId,
-            userId = params.userId,
+            // userId = params.userId,
             subNode = params.subNode
         ;
+        let userId = req.session.sessionUser.id;
         let filter = {"ID": rptDftTplId};
         RptTplModel.findOne(filter, '-_id').exec().then(function(dftTplRst) {
             if (dftTplRst) {

+ 18 - 0
modules/reports/facade/rpt_cust_cfg_facade.js

@@ -0,0 +1,18 @@
+/**
+ * Created by Tony on 2018/4/18.
+ */
+
+import mongoose from "mongoose";
+let rpt_customize_cfg_mdl = mongoose.model("rpt_customize_cfg");
+
+module.exports = {
+    getCustomizeCfg: getCustomizeCfg
+};
+
+async function getCustomizeCfg(userIds) {
+    let filter = {"userId": userIds};
+    if (userIds instanceof Array) {
+        filter.userId = {$in: userIds};
+    }
+    return await rpt_customize_cfg_mdl.find(filter, '-_id');
+}

+ 1 - 0
modules/reports/routes/rpt_tpl_router.js

@@ -28,6 +28,7 @@ module.exports = function (app) {
     rptTplRouter.post('/getRefRptTpl', reportTplController.getRefRptTpl);
     rptTplRouter.post('/updateRptTpl', reportTplController.updateRptTpl);
     rptTplRouter.post('/getCompilationList', reportTplController.getCompilationList);
+    rptTplRouter.post('/getCustomizeCfg', reportTplController.getCustomerCfg);
 
     rptTplRouter.post('/getUserRptCfg', reportCfgController.getReportUserCfg);
     rptTplRouter.post('/getMappingFields', reportCfgController.getAllMappingFields);

+ 2 - 2
public/web/rpt_value_define.js

@@ -235,8 +235,8 @@ const JV = {
 
     ORIENTATION_PORTRAIT: "PORTRAIT",
     ORIENTATION_LANDSCAPE: "LANDSCAPE",
-    ORIENTATION_PORTRAIT_CHN: "纵",
-    ORIENTATION_LANDSCAPE_CHN: "横",
+    ORIENTATION_PORTRAIT_CHN: "纵",
+    ORIENTATION_LANDSCAPE_CHN: "横",
     SIZE_A3: [11.69, 16.54],
     SIZE_A4: [8.27, 11.69],
     SIZE_A5: [5.83, 8.27],