Browse Source

Merge remote-tracking branch 'origin/master'

vian 6 years ago
parent
commit
f05536850f

+ 10 - 1
.babelrc

@@ -1,3 +1,12 @@
 {
-  "presets": ["es2015", "stage-2"]
+  "presets": ["es2015", "stage-2"],
+  "plugins": [[
+  "transform-runtime",
+  {
+    "helpers": false,
+    "polyfill": false,
+    "regenerator": true,
+    "moduleName": "babel-runtime"
+  }
+]]
 }

+ 29 - 4
Dockerfile

@@ -1,19 +1,44 @@
-FROM costbase:2.0
+FROM costbase:2.0 as build
 
 RUN mv /home/ConstructionCost /home/YangHuCost
 
 WORKDIR /home/YangHuCost
 
-COPY . /home/YangHuCost
+COPY package.json /home/YangHuCost
+COPY .babelrc /home/YangHuCost/
 
 RUN cnpm install
 
+FROM base-alpine:latest as babel
+COPY --from=build /home/YangHuCost /home/YangHuCost
+
+COPY config /home/YangHuCost/src/config/
+COPY logs /home/YangHuCost/src/logs/
+COPY modules /home/YangHuCost/src/modules/
+COPY public /home/YangHuCost/src/public/
+COPY importserver.js server.js socket.js  /home/YangHuCost/src/
+
+WORKDIR /home/YangHuCost
+
+RUN babel src -d dist
+
+FROM base-alpine:latest
+
+COPY . /home/YangHuCost
+
+WORKDIR /home/YangHuCost
+
+COPY --from=babel /home/YangHuCost/dist /home/YangHuCost
+COPY --from=babel /home/YangHuCost/node_modules /home/YangHuCost/node_modules/
+COPY public/web /home/YangHuCost/public/web/
+
+
 RUN gulp build
 
 ENV NODE_ENV=prod
 
-ENTRYPOINT ["babel-node", "--max-old-space-size=2048"]
+ENTRYPOINT ["npm", "run"]
 
-CMD ["server.js"]
+CMD ["server"]
 
 

+ 1 - 0
config/gulpConfig.js

@@ -169,6 +169,7 @@ module.exports = {
         'web/building_saas/main/js/views/locate_view.js',
         'web/building_saas/complementary_ration_lib/js/main.js',
         'web/building_saas/main/js/views/material_calc_view.js',
+        'web/building_saas/main/js/views/electrovalence_view.js',
         'public/web/storageUtil.js'
     ],
     compleGlj_css: [

+ 29 - 0
modules/all_models/com_electrovalence.js

@@ -0,0 +1,29 @@
+/**
+ * Created by zhang on 2019/12/10.
+ */
+
+let mongoose = require('mongoose');
+let Schema = mongoose.Schema;
+
+let gljListSchema =new Schema({
+    ID:{type: String},
+    GLJID:Number,
+    projectGLJID:Number,
+    name:String,
+    code:String,
+    specs:String,
+    unit:String,
+    type:Number,
+    // 加权系数
+    coe: Number,
+    from:{type: String,default:'std'}//std, cpt  来自标准工料机库、补充工料机库
+},{versionKey:false,_id: false});
+
+
+let com_electrovalenceSchema = {//综合电价
+    ID:{type:String,index: true},
+    unit_price_file_id: Number,
+    gljList:[gljListSchema]
+};
+
+mongoose.model("com_electrovalence", new Schema(com_electrovalenceSchema, {versionKey: false, collection: "com_electrovalence"}));

+ 3 - 0
modules/glj/controllers/glj_controller.js

@@ -19,6 +19,7 @@ let EngineeringLibModel = require("../../users/models/engineering_lib_model");
 let mongoose = require('mongoose');
 let original_calc_model = mongoose.model('original_calc');
 let freight_calc_model = mongoose.model('freight_calc');
+let com_electrovalence_model = mongoose.model('com_electrovalence');
 let ration = mongoose.model('ration');
 let projectModel = mongoose.model('projects');
 let _ = require('lodash');
@@ -872,6 +873,8 @@ async function getGLJListByProjectID(projectId){
         }
         responseData.data.originalList = await original_calc_model.find({"unit_price_file_id":unitPriceFileId}).lean();
         responseData.data.freightList = await freight_calc_model .find({"unit_price_file_id":unitPriceFileId}).lean();
+        responseData.data.com_electrovalence = await com_electrovalence_model.findOne({"unit_price_file_id":unitPriceFileId}).lean();
+        //if(!responseData.data.com_electrovalence) responseData.data.com_electrovalence = {};
         // 先获取对应标段的项目工料机数据
         let gljListModel = new GLJListModel();
         let [gljList, mixRatioConnectData,mixRatioMap,unitPriceMap] = await gljListModel.getListByProjectId(projectId, unitPriceFileId,responseData.data.freightList,responseData.data.originalList);

+ 2 - 2
modules/reports/rpt_component/helper/jpc_helper_common.js

@@ -133,7 +133,7 @@ let JpcCommonHelper = {
         }
         return rst;
     },
-    getStringLinesInArea: function(area, strVal, pdfDoc, chnW, otherW) {
+    getStringLinesInArea: function(area, strVal, chnW, otherW) {
         //备注: 因后台的pdf kit判断字符串长度与前端的不一样,需要做些调整,不一次性地判断字符串长度。
         //      分2种字符:中文与非中文,按照各种字符的数量分别乘以相关一个字符的宽度再累计。
         //      另判断行数还不能直接用总长度除以宽度来计算,因每一行都会有不同的余量,所以得一行行走过来判断。
@@ -157,7 +157,7 @@ let JpcCommonHelper = {
         return rst;
         //备注: 其实是想用canvas的,但node canvas装起来麻烦,暂时用PDF Kit来顶用一下,以后有更好的再换
     },
-    splitString: function (area, strVal, pdfDoc, chnW, otherW) {
+    splitString: function (area, strVal, chnW, otherW) {
         let rst = [];
         if (strVal) {
             let areaWidth = area[JV.PROP_RIGHT] - area[JV.PROP_LEFT] - JV.OUTPUT_OFFSET[JV.OFFSET_IDX_RIGHT] - JV.OUTPUT_OFFSET[JV.OFFSET_IDX_LEFT] - 1;

+ 513 - 0
modules/reports/rpt_component/helper/jpc_helper_font_width.js

@@ -0,0 +1,513 @@
+/**
+ * Created by Tony on 2019/12/12.
+ */
+
+const fontWidthMap = {
+    "宋体": {
+        "宽": {
+            "_6": 6,
+            "_7": 7,
+            "_8": 8,
+            "_9": 9,
+            "_10": 10,
+            "_11": 11,
+            "_12": 12,
+            "_13": 13,
+            "_14": 14,
+            "_15": 15,
+            "_16": 16,
+            "_17": 17,
+            "_18": 18,
+            "_19": 19,
+            "_20": 20,
+            "_21": 21,
+            "_22": 22,
+            "_23": 23,
+            "_24": 24,
+            "_25": 25,
+            "_26": 26,
+            "_27": 27,
+            "_28": 28,
+            "_29": 29,
+            "_30": 30,
+            "_31": 31,
+            "_32": 32,
+            "_33": 33,
+            "_34": 34,
+            "_35": 35,
+            "_36": 36,
+            "_37": 37,
+            "_38": 38,
+            "_39": 39,
+            "_40": 40,
+            "_41": 41,
+            "_42": 42,
+            "_43": 43,
+            "_44": 44,
+            "_45": 45,
+            "_46": 46,
+            "_47": 47,
+            "_48": 48,
+            "_49": 49,
+            "_50": 50,
+            "_51": 51,
+            "_52": 52,
+            "_53": 53,
+            "_54": 54,
+            "_55": 55,
+            "_56": 56,
+            "_57": 57,
+            "_58": 58,
+            "_59": 59,
+            "_60": 60,
+            "_61": 61,
+            "_62": 62,
+            "_63": 63,
+            "_64": 64
+        },
+        "窄": {
+            "_6": 3,
+            "_7": 3.5,
+            "_8": 4,
+            "_9": 4.5,
+            "_10": 5,
+            "_11": 5.5,
+            "_12": 6,
+            "_13": 6.5,
+            "_14": 7,
+            "_15": 7.5,
+            "_16": 8,
+            "_17": 8.5,
+            "_18": 9,
+            "_19": 9.5,
+            "_20": 10,
+            "_21": 10.5,
+            "_22": 11,
+            "_23": 11.5,
+            "_24": 12,
+            "_25": 12.5,
+            "_26": 13,
+            "_27": 13.5,
+            "_28": 14,
+            "_29": 14.5,
+            "_30": 15,
+            "_31": 15.5,
+            "_32": 16,
+            "_33": 16.5,
+            "_34": 17,
+            "_35": 17.5,
+            "_36": 18,
+            "_37": 18.5,
+            "_38": 19,
+            "_39": 19.5,
+            "_40": 20,
+            "_41": 20.5,
+            "_42": 21,
+            "_43": 21.5,
+            "_44": 22,
+            "_45": 22.5,
+            "_46": 23,
+            "_47": 23.5,
+            "_48": 24,
+            "_49": 24.5,
+            "_50": 25,
+            "_51": 25.5,
+            "_52": 26,
+            "_53": 26.5,
+            "_54": 27,
+            "_55": 27.5,
+            "_56": 28,
+            "_57": 28.5,
+            "_58": 29,
+            "_59": 29.5,
+            "_60": 30,
+            "_61": 30.5,
+            "_62": 31,
+            "_63": 31.5,
+            "_64": 32
+        }
+    },
+    "黑体": {
+        "宽": {
+            "_6": 6,
+            "_7": 7,
+            "_8": 8,
+            "_9": 9,
+            "_10": 10,
+            "_11": 11,
+            "_12": 12,
+            "_13": 13,
+            "_14": 14,
+            "_15": 15,
+            "_16": 16,
+            "_17": 17,
+            "_18": 18,
+            "_19": 19,
+            "_20": 20,
+            "_21": 21,
+            "_22": 22,
+            "_23": 23,
+            "_24": 24,
+            "_25": 25,
+            "_26": 26,
+            "_27": 27,
+            "_28": 28,
+            "_29": 29,
+            "_30": 30,
+            "_31": 31,
+            "_32": 32,
+            "_33": 33,
+            "_34": 34,
+            "_35": 35,
+            "_36": 36,
+            "_37": 37,
+            "_38": 38,
+            "_39": 39,
+            "_40": 40,
+            "_41": 41,
+            "_42": 42,
+            "_43": 43,
+            "_44": 44,
+            "_45": 45,
+            "_46": 46,
+            "_47": 47,
+            "_48": 48,
+            "_49": 49,
+            "_50": 50,
+            "_51": 51,
+            "_52": 52,
+            "_53": 53,
+            "_54": 54,
+            "_55": 55,
+            "_56": 56,
+            "_57": 57,
+            "_58": 58,
+            "_59": 59,
+            "_60": 60,
+            "_61": 61,
+            "_62": 62,
+            "_63": 63,
+            "_64": 64
+        },
+        "窄": {
+            "_6": 3,
+            "_7": 3.5,
+            "_8": 4,
+            "_9": 4.5,
+            "_10": 5,
+            "_11": 5.5,
+            "_12": 6,
+            "_13": 6.5,
+            "_14": 7,
+            "_15": 7.5,
+            "_16": 8,
+            "_17": 8.5,
+            "_18": 9,
+            "_19": 9.5,
+            "_20": 10,
+            "_21": 10.5,
+            "_22": 11,
+            "_23": 11.5,
+            "_24": 12,
+            "_25": 12.5,
+            "_26": 13,
+            "_27": 13.5,
+            "_28": 14,
+            "_29": 14.5,
+            "_30": 15,
+            "_31": 15.5,
+            "_32": 16,
+            "_33": 16.5,
+            "_34": 17,
+            "_35": 17.5,
+            "_36": 18,
+            "_37": 18.5,
+            "_38": 19,
+            "_39": 19.5,
+            "_40": 20,
+            "_41": 20.5,
+            "_42": 21,
+            "_43": 21.5,
+            "_44": 22,
+            "_45": 22.5,
+            "_46": 23,
+            "_47": 23.5,
+            "_48": 24,
+            "_49": 24.5,
+            "_50": 25,
+            "_51": 25.5,
+            "_52": 26,
+            "_53": 26.5,
+            "_54": 27,
+            "_55": 27.5,
+            "_56": 28,
+            "_57": 28.5,
+            "_58": 29,
+            "_59": 29.5,
+            "_60": 30,
+            "_61": 30.5,
+            "_62": 31,
+            "_63": 31.5,
+            "_64": 32
+        }
+    },
+    "楷体": {
+        "宽": {
+            "_6": 6,
+            "_7": 7,
+            "_8": 8,
+            "_9": 9,
+            "_10": 10,
+            "_11": 11,
+            "_12": 12,
+            "_13": 13,
+            "_14": 14,
+            "_15": 15,
+            "_16": 16,
+            "_17": 17,
+            "_18": 18,
+            "_19": 19,
+            "_20": 20,
+            "_21": 21,
+            "_22": 22,
+            "_23": 23,
+            "_24": 24,
+            "_25": 25,
+            "_26": 26,
+            "_27": 27,
+            "_28": 28,
+            "_29": 29,
+            "_30": 30,
+            "_31": 31,
+            "_32": 32,
+            "_33": 33,
+            "_34": 34,
+            "_35": 35,
+            "_36": 36,
+            "_37": 37,
+            "_38": 38,
+            "_39": 39,
+            "_40": 40,
+            "_41": 41,
+            "_42": 42,
+            "_43": 43,
+            "_44": 44,
+            "_45": 45,
+            "_46": 46,
+            "_47": 47,
+            "_48": 48,
+            "_49": 49,
+            "_50": 50,
+            "_51": 51,
+            "_52": 52,
+            "_53": 53,
+            "_54": 54,
+            "_55": 55,
+            "_56": 56,
+            "_57": 57,
+            "_58": 58,
+            "_59": 59,
+            "_60": 60,
+            "_61": 61,
+            "_62": 62,
+            "_63": 63,
+            "_64": 64
+        },
+        "窄": {
+            "_6": 3,
+            "_7": 3.5,
+            "_8": 4,
+            "_9": 4.5,
+            "_10": 5,
+            "_11": 5.5,
+            "_12": 6,
+            "_13": 6.5,
+            "_14": 7,
+            "_15": 7.5,
+            "_16": 8,
+            "_17": 8.5,
+            "_18": 9,
+            "_19": 9.5,
+            "_20": 10,
+            "_21": 10.5,
+            "_22": 11,
+            "_23": 11.5,
+            "_24": 12,
+            "_25": 12.5,
+            "_26": 13,
+            "_27": 13.5,
+            "_28": 14,
+            "_29": 14.5,
+            "_30": 15,
+            "_31": 15.5,
+            "_32": 16,
+            "_33": 16.5,
+            "_34": 17,
+            "_35": 17.5,
+            "_36": 18,
+            "_37": 18.5,
+            "_38": 19,
+            "_39": 19.5,
+            "_40": 20,
+            "_41": 20.5,
+            "_42": 21,
+            "_43": 21.5,
+            "_44": 22,
+            "_45": 22.5,
+            "_46": 23,
+            "_47": 23.5,
+            "_48": 24,
+            "_49": 24.5,
+            "_50": 25,
+            "_51": 25.5,
+            "_52": 26,
+            "_53": 26.5,
+            "_54": 27,
+            "_55": 27.5,
+            "_56": 28,
+            "_57": 28.5,
+            "_58": 29,
+            "_59": 29.5,
+            "_60": 30,
+            "_61": 30.5,
+            "_62": 31,
+            "_63": 31.5,
+            "_64": 32
+        }
+    },
+    "Arial": {
+        "宽": {
+            "_6": 6,
+            "_7": 7,
+            "_8": 8,
+            "_9": 9,
+            "_10": 10,
+            "_11": 11,
+            "_12": 12,
+            "_13": 13,
+            "_14": 14,
+            "_15": 15,
+            "_16": 16,
+            "_17": 17,
+            "_18": 18,
+            "_19": 19,
+            "_20": 20,
+            "_21": 21,
+            "_22": 22,
+            "_23": 23,
+            "_24": 24,
+            "_25": 25,
+            "_26": 26,
+            "_27": 27,
+            "_28": 28,
+            "_29": 29,
+            "_30": 30,
+            "_31": 31,
+            "_32": 32,
+            "_33": 33,
+            "_34": 34,
+            "_35": 35,
+            "_36": 36,
+            "_37": 37,
+            "_38": 38,
+            "_39": 39,
+            "_40": 40,
+            "_41": 41,
+            "_42": 42,
+            "_43": 43,
+            "_44": 44,
+            "_45": 45,
+            "_46": 46,
+            "_47": 47,
+            "_48": 48,
+            "_49": 49,
+            "_50": 50,
+            "_51": 51,
+            "_52": 52,
+            "_53": 53,
+            "_54": 54,
+            "_55": 55,
+            "_56": 56,
+            "_57": 57,
+            "_58": 58,
+            "_59": 59,
+            "_60": 60,
+            "_61": 61,
+            "_62": 62,
+            "_63": 63,
+            "_64": 64
+        },
+        "窄": {
+            "_6": 3.3399999141693115,
+            "_7": 3.8899998664855957,
+            "_8": 4.449999809265137,
+            "_9": 5.009999752044678,
+            "_10": 5.559999942779541,
+            "_11": 6.119999885559082,
+            "_12": 6.670000076293945,
+            "_13": 7.230000019073486,
+            "_14": 7.789999961853027,
+            "_15": 8.34000015258789,
+            "_16": 8.899999618530273,
+            "_17": 9.449999809265136,
+            "_18": 10.010000228881836,
+            "_19": 10.569999694824218,
+            "_20": 11.119999885559082,
+            "_21": 11.679999351501464,
+            "_22": 12.239999771118164,
+            "_23": 12.789999961853027,
+            "_24": 13.34999942779541,
+            "_25": 13.899999618530273,
+            "_26": 14.460000038146972,
+            "_27": 15.019999504089355,
+            "_28": 15.569999694824218,
+            "_29": 16.1299991607666,
+            "_30": 16.68000030517578,
+            "_31": 17.239999771118164,
+            "_32": 17.799999237060547,
+            "_33": 18.350000381469726,
+            "_34": 18.90999984741211,
+            "_35": 19.469999313354492,
+            "_36": 20.020000457763672,
+            "_37": 20.579999923706054,
+            "_38": 21.1299991607666,
+            "_39": 21.689998626708984,
+            "_40": 22.25,
+            "_41": 22.799999237060547,
+            "_42": 23.35999870300293,
+            "_43": 23.90999984741211,
+            "_44": 24.469999313354492,
+            "_45": 25.029998779296875,
+            "_46": 25.579999923706054,
+            "_47": 26.139999389648437,
+            "_48": 26.69999885559082,
+            "_49": 27.25,
+            "_50": 27.809999465942383,
+            "_51": 28.35999870300293,
+            "_52": 28.920000076293945,
+            "_53": 29.479999542236328,
+            "_54": 30.029998779296875,
+            "_55": 30.59000015258789,
+            "_56": 31.139999389648437,
+            "_57": 31.69999885559082,
+            "_58": 32.2599983215332,
+            "_59": 32.80999755859375,
+            "_60": 33.369998931884766,
+            "_61": 33.93000030517578,
+            "_62": 34.47999954223633,
+            "_63": 35.040000915527344,
+            "_64": 35.59000015258789
+        }
+    },
+    getFontWidth: function(fontName, fontHeight, typeStr) {
+        let rst = 12;
+        if (fontWidthMap[fontName]) {
+            rst = fontWidthMap[fontName][typeStr]['_' + fontHeight];
+        } else {
+            rst = fontWidthMap['宋体'][typeStr]['_' + fontHeight];
+        }
+        return rst;
+    }
+};
+
+module.exports = fontWidthMap;

+ 20 - 12
modules/reports/rpt_component/jpc_flow_tab.js

@@ -9,10 +9,11 @@ let JpcDiscreteHelper = require('./helper/jpc_helper_discrete');
 let JpcTextHelper = require('./helper/jpc_helper_text');
 let JpcCommonOutputHelper = require('./helper/jpc_helper_common_output');
 let JpcAreaHelper = require('./helper/jpc_helper_area');
-let PDFKit = require('pdfkit');
-let fontUtil = require('../util/rpt_font_util');
+// let PDFKit = require('pdfkit');
+// let fontUtil = require('../util/rpt_font_util');
 let fsUtil = require("../../../public/fsUtil");
 let strUtil = require("../../../public/stringUtil");
+let fontWidthMap = require('./helper/jpc_helper_font_width');
 
 
 let JpcFlowTabSrv = function(){};
@@ -339,7 +340,7 @@ JpcFlowTabSrv.prototype.createNew = function(){
             let adHocAutoHeightStyleStr = [];
             let reg1 = new RegExp('\n\r','g'), reg2 = new RegExp('\r\n','g'),
                 reg3 = new RegExp('\n','g'), reg4 = new RegExp('\r','g');
-            let doc = new PDFKit({autoFirstPage: false});
+            // let doc = new PDFKit({autoFirstPage: false});
             let fonts = defProperties.fonts;
             let fontCache = {};
             let private_get_font = function (fontKey) {
@@ -391,19 +392,26 @@ JpcFlowTabSrv.prototype.createNew = function(){
                         let values = value.split('|');
                         if (values.length > rst) rst = values.length;
                         let font = private_get_font(tab_field[JV.PROP_FONT]);
+                        // if (font) {
+                        //     let fontFile = __dirname.slice(0, __dirname.length - 14) + '/util/pdf_base_files/' + fontUtil.getActualFont(font[JV.FONT_PROPS[0]], (font[JV.FONT_PROPS[3]] === 'T'), (font[JV.FONT_PROPS[4]] === 'T')) + '.ttf';
+                        //     doc.font(fontFile);
+                        //     doc.fontSize(parseInt(font[JV.FONT_PROPS[JV.FONT_PROP_IDX_HEIGHT]]));
+                        // } else {
+                        //     doc.font(__dirname.slice(0, __dirname.length - 14) + '/util/pdf_base_files/Smart.ttf');
+                        //     doc.fontSize(12);
+                        // }
+                        let chkFontName = '宋体';
+                        let chkFontHeight = 12;
                         if (font) {
-                            let fontFile = __dirname.slice(0, __dirname.length - 14) + '/util/pdf_base_files/' + fontUtil.getActualFont(font[JV.FONT_PROPS[0]], (font[JV.FONT_PROPS[3]] === 'T'), (font[JV.FONT_PROPS[4]] === 'T')) + '.ttf';
-                            doc.font(fontFile);
-                            doc.fontSize(parseInt(font[JV.FONT_PROPS[JV.FONT_PROP_IDX_HEIGHT]]));
-                        } else {
-                            doc.font(__dirname.slice(0, __dirname.length - 14) + '/util/pdf_base_files/Smart.ttf');
-                            doc.fontSize(12);
+                            chkFontName = font[JV.FONT_PROPS[0]];
+                            chkFontHeight = font[JV.FONT_PROPS[JV.FONT_PROP_IDX_HEIGHT]];
                         }
                         let hasSplitStr = false, splitStrArr = [];
                         let accAmt = 0;
-                        let chnW = doc.widthOfString('一'), otherW = doc.widthOfString('_');
+                        // let chnW = doc.widthOfString('一'), otherW = doc.widthOfString('_');
+                        let chnW = fontWidthMap.getFontWidth(chkFontName, chkFontHeight, '宽'), otherW = fontWidthMap.getFontWidth(chkFontName, chkFontHeight, '窄');
                         for (let i = 0; i < values.length; i++) {
-                            let amt = JpcCommonHelper.getStringLinesInArea(area, values[i], doc, chnW, otherW);
+                            let amt = JpcCommonHelper.getStringLinesInArea(area, values[i], chnW, otherW);
                             accAmt += amt;
                             if (amt > 1) {
                                 hasSplitStr = true;
@@ -418,7 +426,7 @@ JpcFlowTabSrv.prototype.createNew = function(){
                                 if (splitStrArr.indexOf(i) < 0) {
                                     newValArr.push(values[i]);
                                 } else {
-                                    newValArr = newValArr.concat(JpcCommonHelper.splitString(area, values[i], doc, chnW, otherW));
+                                    newValArr = newValArr.concat(JpcCommonHelper.splitString(area, values[i], chnW, otherW));
                                 }
                             }
                             JpcFieldHelper.setValue(data_field, theRecIdx, newValArr.join('|'));

+ 19 - 15
modules/reports/util/rpt_svg_util.js

@@ -4,10 +4,11 @@
  */
 
 let JV = require('../rpt_component/jpc_value_define');
-let pdf = require('pdfkit');
+// let pdf = require('pdfkit');
 let jpcCmnHelper = require('../rpt_component/helper/jpc_helper_common');
 let SCREEN_DPI = jpcCmnHelper.getScreenDPI();
-let fontUtil = require('./rpt_font_util');
+// let fontUtil = require('./rpt_font_util');
+let fontWidthMap = require('../rpt_component/helper/jpc_helper_font_width');
 
 module.exports = {
     exportSvgStr: function (pagesData, offsetX, offsetY) {
@@ -16,7 +17,7 @@ module.exports = {
             fonts = pagesData[JV.NODE_FONT_COLLECTION],
             controls = pagesData[JV.NODE_CONTROL_COLLECTION]
         ;
-        let pdf_doc = new pdf({autoFirstPage: false});
+        // let pdf_doc = new pdf({autoFirstPage: false});
         for (let idx = 0; idx < pagesData.items.length; idx++) {
             let page = pagesData.items[idx];
             let svgPageArr = [], pixelSize = getPixelSize(pagesData);
@@ -24,7 +25,7 @@ module.exports = {
             let adjustY = 0.5 * ((idx + 1) % 2);
             // let cnt = 0;
             for (let cell of page.cells) {
-                svgPageArr.push(buildCellSvg(cell, fonts, styles, controls, page[JV.PROP_PAGE_MERGE_BORDER], pagesData[JV.BAND_PROP_MERGE_BAND], offsetX, offsetY, adjustY, pdf_doc));
+                svgPageArr.push(buildCellSvg(cell, fonts, styles, controls, page[JV.PROP_PAGE_MERGE_BORDER], pagesData[JV.BAND_PROP_MERGE_BAND], offsetX, offsetY, adjustY));
                 // cnt++;
                 // console.log(cnt);
             }
@@ -55,7 +56,7 @@ function getActualBorderStyle(cell, styles, mergeBorderStyle, pageBorderArea, bo
     return rst;
 }
 
-function buildCellSvg(cell, fonts, styles, controls, pageMergeBorder, rptMergeBorder, offsetX, offsetY, adjustY, pdf_doc) {
+function buildCellSvg(cell, fonts, styles, controls, pageMergeBorder, rptMergeBorder, offsetX, offsetY, adjustY) {
     let rst = [];
     let style = styles[cell[JV.PROP_STYLE]];
     let mergeBandStyle = null;
@@ -101,18 +102,18 @@ function buildCellSvg(cell, fonts, styles, controls, pageMergeBorder, rptMergeBo
                 "' style='stroke:rgb(0,0,0);stroke-width:" + bottomBS[JV.PROP_LINE_WEIGHT] +"'/>")
         }
     }
-    buildText(rst, cell, font, controls[cell[JV.PROP_CONTROL]], offsetX, offsetY, adjustY, pdf_doc);
+    buildText(rst, cell, font, controls[cell[JV.PROP_CONTROL]], offsetX, offsetY, adjustY);
 
     return rst.join("");
 }
 
-function buildText(destRst, cell, font, control, offsetX, offsetY, adjustY, pdf_doc) {
+function buildText(destRst, cell, font, control, offsetX, offsetY, adjustY) {
     let orgFontHeight = parseInt(font[JV.FONT_PROPS[JV.FONT_PROP_IDX_HEIGHT]]);
     let fontWeight = (font[JV.FONT_PROPS[JV.FONT_PROP_IDX_BOLD]] === 'T')?"bold":"normal";
     let fontStyle = (font[JV.FONT_PROPS[JV.FONT_PROP_IDX_ITALIC]] === 'T')?"italic":"normal";
     let dftFontBold = font[JV.FONT_PROPS[3]];
     let dftFontItalic = font[JV.FONT_PROPS[4]];
-    let fontFile = __dirname + '/pdf_base_files/' + fontUtil.getActualFont(font[JV.FONT_PROPS[0]], (dftFontBold === 'T'), (dftFontItalic === 'T')) + '.ttf';
+    // let fontFile = __dirname + '/pdf_base_files/' + fontUtil.getActualFont(font[JV.FONT_PROPS[0]], (dftFontBold === 'T'), (dftFontItalic === 'T')) + '.ttf';
     let left = parseInt(cell[JV.PROP_AREA][JV.PROP_LEFT]) + offsetX + 0.5,
         right = parseInt(cell[JV.PROP_AREA][JV.PROP_RIGHT]) + offsetX + 0.5,
         top = parseInt(cell[JV.PROP_AREA][JV.PROP_TOP]) + offsetY + adjustY,
@@ -148,9 +149,10 @@ function buildText(destRst, cell, font, control, offsetX, offsetY, adjustY, pdf_
     let area = [cell[JV.PROP_AREA][JV.PROP_LEFT] + offsetX, cell[JV.PROP_AREA][JV.PROP_TOP] + offsetY, cell[JV.PROP_AREA][JV.PROP_RIGHT] + offsetX, cell[JV.PROP_AREA][JV.PROP_BOTTOM] + offsetY];
     let inner_draw_text = function (textValue) {
         let dftFontHeight = orgFontHeight;
-        pdf_doc.font(fontFile);
-        pdf_doc.fontSize(dftFontHeight);
-        let actLines = private_splitString(textValue, (area[JV.PROP_RIGHT] - area[JV.PROP_LEFT]), pdf_doc);
+        // pdf_doc.font(fontFile);
+        // pdf_doc.fontSize(dftFontHeight);
+        // let actLines = private_splitString(textValue, (area[JV.PROP_RIGHT] - area[JV.PROP_LEFT]), pdf_doc);
+        let actLines = private_splitStringEx(textValue, (area[JV.PROP_RIGHT] - area[JV.PROP_LEFT]), font[JV.FONT_PROPS[0]], dftFontHeight);
         function inner_build_text(innerTxt, innerArea) {
             let innerDftFontHeight = (dftFontHeight * 3 / 4); //SVG的字体与canvas的字体大小的切换, 不用考虑取整
             if (control) {
@@ -177,10 +179,11 @@ function buildText(destRst, cell, font, control, offsetX, offsetY, adjustY, pdf_
             while (true) {
                 if (dftFontHeight > 6) {
                     dftFontHeight--;
-                    pdf_doc.fontSize(dftFontHeight);
+                    // pdf_doc.fontSize(dftFontHeight);
                     let lines = Math.floor((area[JV.IDX_BOTTOM] - area[JV.IDX_TOP]) / (dftFontHeight + JV.OUTPUT_OFFSET[JV.OFFSET_IDX_BOTTOM] + JV.OUTPUT_OFFSET[JV.OFFSET_IDX_TOP] + 4));
                     lines = (lines === 0)?1:lines;
-                    actLines = private_splitString(textValue, (area[JV.PROP_RIGHT] - area[JV.PROP_LEFT]), pdf_doc);
+                    // actLines = private_splitString(textValue, (area[JV.PROP_RIGHT] - area[JV.PROP_LEFT]), pdf_doc);
+                    let actLines = private_splitStringEx(textValue, (area[JV.PROP_RIGHT] - area[JV.PROP_LEFT]), font[JV.FONT_PROPS[0]], dftFontHeight);
                     if (lines >= actLines.length) {
                         let aH = dftFontHeight + JV.OUTPUT_OFFSET[JV.OFFSET_IDX_BOTTOM] + JV.OUTPUT_OFFSET[JV.OFFSET_IDX_TOP] + 4;
                         if ((aH * actLines.length) < (area[JV.IDX_BOTTOM] - area[JV.IDX_TOP]) && (control && control.Vertical !== 'top')) {
@@ -250,12 +253,13 @@ function buildText(destRst, cell, font, control, offsetX, offsetY, adjustY, pdf_
     //*/
 }
 
-function private_splitString(strVal, areaWidth, doc) {
+function private_splitStringEx(strVal, areaWidth, chkFontName, chkFontHeight) {
     let rst = [];
     if (strVal) {
         let preSIdx = 0, txtWidth = 0;
         let currentW = 0;
-        let chnW = doc.widthOfString('一'), otherW = doc.widthOfString('_');
+        // let chnW = doc.widthOfString('一'), otherW = doc.widthOfString('_');
+        let chnW = fontWidthMap.getFontWidth(chkFontName, chkFontHeight, '宽'), otherW = fontWidthMap.getFontWidth(chkFontName, chkFontHeight, '窄');
         for (let sIdx = 0; sIdx < strVal.length; sIdx++) {
             currentW = (strVal.charCodeAt(sIdx) > 127)?chnW:otherW;
             txtWidth += currentW;

+ 6 - 2
package.json

@@ -5,6 +5,7 @@
   "devDependencies": {
     "body-parser": "^1.13.2",
     "babel-cli": "^6.24.1",
+    "babel-plugin-transform-runtime": "^6.23.0",
     "babel-preset-es2015": "^6.24.1",
     "babel-preset-stage-2": "^6.24.1",
     "express": "^4.13.1",
@@ -52,12 +53,15 @@
     "node-xlsx": "^0.11.2",
     "pdfkit": "^0.8.2",
     "request-promise": "^4.2.5",
-    "socket.io": "^2.0.3",
+    "socket.io": "2.0.3",
     "ua-parser-js": "^0.7.14",
     "uuid": "^3.1.0",
     "wiredep": "^2.2.2"
   },
   "scripts": {
-    "start": "C:\\Users\\mai\\AppData\\Roaming\\npm\\babel-node.cmd server.js"
+    "start": "C:\\Users\\mai\\AppData\\Roaming\\npm\\babel-node.cmd server.js",
+    "server":"node --max-old-space-size=2048 server.js",
+    "socket":"node socket.js",
+    "import":"node --max-old-space-size=2048 importserver.js"
   }
 }

+ 1 - 1
public/web/common_ajax.js

@@ -171,7 +171,7 @@ async function ajaxPost(url, data) {
             data: {'data': JSON.stringify(data)},
             dataType: 'json',
             cache: false,
-            timeout: 50000,
+            timeout: 200000,
             success: function(result){
                 let message = "";
                 if(result) message = result.message?result.message:result.msg;

+ 26 - 0
web/building_saas/glj/html/project_glj.html

@@ -267,4 +267,30 @@
             </div>
         </div>
     </div>
+</div>
+
+
+<!--弹出 计算综合电价窗口-->
+<div class="modal fade" id="electrovalenceDiv" data-backdrop="static">
+    <div class="modal-dialog" role="document">
+        <div class="modal-content">
+            <div class="modal-header">
+                <h5 class="modal-title">计算综合电价</h5>
+                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
+                    <span aria-hidden="true">&times;</span>
+                </button>
+            </div>
+            <div class="modal-body" style="height: 200px;padding: 0px">
+                <div class="ovf-hidden full-h" id="electrovalence_sheet"></div>
+            </div>
+            <div class="modal-footer">
+                <div style="width: 70%">
+                    <button type="button" class="btn btn-danger" id="removeElectrovalencec">删除</button>
+                    <label >综合电价:</label>
+                </div>
+                <button type="button" class="btn btn-primary" id="electrovalencecConfirm">确定</button>
+                <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
+            </div>
+        </div>
+    </div>
 </div>

BIN
web/building_saas/img/纵横公路养护云造价.png


+ 1 - 0
web/building_saas/main/html/main.html

@@ -2041,6 +2041,7 @@
     <script type="text/javascript" src="/web/building_saas/main/js/views/locate_view.js"></script>
     <script type="text/javascript" src="/web/building_saas/complementary_ration_lib/js/main.js"></script>
     <script type="text/javascript" src="/web/building_saas/main/js/views/material_calc_view.js"></script>
+    <script type="text/javascript" src="/web/building_saas/main/js/views/electrovalence_view.js"></script>
     <script type="text/javascript" src="/public/web/storageUtil.js"></script>
     <script type="text/javascript" src="/web/building_saas/report/js/rpt_jspdf.js"></script>
 

+ 43 - 0
web/building_saas/main/js/views/electrovalence_view.js

@@ -0,0 +1,43 @@
+/**
+ * Created by zhang on 2019/12/12.
+ */
+let electrovalenceObj = {
+    setting:{
+        header:[
+            {headerName: "代号", headerWidth: 70, dataCode: "code", dataType: "String"},
+            {headerName: "名称", headerWidth: 150, dataCode: "name",dataType: "String"},
+            {headerName: "规格", headerWidth: 60, dataCode: "specs", dataType: "Number",validator:"number"},
+            {headerName: "预算价", headerWidth: 75, dataCode: "marketPrice", hAlign: "right", dataType: "Number",validator:"number"},
+            {headerName: "加权系数", headerWidth: 60, dataCode: "coe", hAlign: "right", dataType: "Number",validator:"number"}
+        ],
+        view: {
+            lockColumns: ["code","specs"],
+            rowHeaderWidth:25,
+            colHeaderHeight:36
+        }
+    },
+    spread:null,
+    sheet:null,
+    datas:[],
+    initSpread:function () {
+        if(this.spread) return;
+        this.spread = SheetDataHelper.createNewSpread($("#electrovalence_sheet")[0]);
+        sheetCommonObj.spreadDefaultStyle(this.spread);
+        this.sheet = this.spread.getSheet(0);
+        sheetCommonObj.initSheet(this.sheet, this.setting, 30);
+    /*    this.materialSheet.bind(GC.Spread.Sheets.Events.ValueChanged, this.onMaterialValueChange);
+        this.materialSheet.bind(GC.Spread.Sheets.Events.SelectionChanged,this.onMaterialSelectionChange);
+        this.materialSheet.bind(GC.Spread.Sheets.Events.EditStarting,this.onMaterialEditStarting);*/
+        this.sheet.name('electrovalence_sheet');
+        if(projectReadOnly){
+            disableSpread(this.spread);
+        }
+    }
+};
+
+$(function () {
+
+    $("#electrovalenceDiv").on('shown.bs.modal', function () {
+        electrovalenceObj.initSpread();
+    });
+});

+ 10 - 1
web/building_saas/main/js/views/project_glj_view.js

@@ -1033,6 +1033,16 @@ projectGljObject={
                         let projectGLJ = projectGljObject.getProjectGLJSelected();
                         projectObj.project.projectGLJ.updateCalcMaterial(projectGLJ,'calcMaterial',1);
                     }
+                },
+                "calcElectrovalence": {
+                    name: "计算综合电价",
+                    icon: 'fa-sign-in',
+                    disabled: function () {
+                        return  false;
+                    },
+                    callback: function (key, opt) {
+                        $("#electrovalenceDiv").modal("show")
+                    }
                 }
             }
         });
@@ -1459,7 +1469,6 @@ $(function () {
     $("#mixRatio-nav").on('shown.bs.tab', function () {
         projectGljObject.mixRatioSpread.refresh();
     });
-
 });