Browse Source

Merge branch 'master' of http://smartcost.f3322.net:3000/SmartCost/ConstructionCost

zhangweicheng 7 years ago
parent
commit
b735a1e56e

+ 1 - 1
modules/all_models/ration.js

@@ -55,7 +55,7 @@ let rationSchema = new Schema({
     rationAssList: [rationAssItemSchema],
     content: String,                            // 工作内容
     ruleText: String,                            // 计算规则
-    prefix: {type: Number, default: 0},                              //定额是补充、借用时用 1 complementary 2 borrow
+    prefix: {type: String, default: ''},                              //定额是补充、借用时用  补 借
 
     //工料机特有属性
     projectGLJID:Number,  //项目工料机ID

+ 2 - 0
modules/all_models/std_glj.js

@@ -27,6 +27,8 @@ const std_glj = new Schema({
     shortName: String,
     unit: String,
     adjCoe: Number,
+    materialType: String,
+    materialCoe: Number,
     component: [std_gljComponent]
 },{versionKey: false});
 

+ 6 - 6
modules/main/facade/ration_facade.js

@@ -80,13 +80,13 @@ async function insertNewRation(newData,firstLibID,std,calQuantity) {//插入新
             newData.comments = std.chapter.explanation;
             newData.ruleText = std.chapter.ruleText;
         }
-        newData.prefix = 0;
+        newData.prefix = '';
         newData.from = std.type === 'complementary' ? 'cpt' : 'std';
         if(firstLibID !== std.rationRepId){//借
-            newData.prefix = 2;
+            newData.prefix = '借';
         }
         else if(std.rationRepId === firstLibID && newData.from === 'cpt') {
-            newData.prefix = 1;
+            newData.prefix = '补';
         }
         newData.programID = std.feeType;
         newData.rationAssList =  createRationAss(std);
@@ -317,13 +317,13 @@ async function  updateRation(std,firstLibID,rationID,billsItemID,projectID,calQu
     }
     ration.from = std.type === 'complementary' ? 'cpt' : 'std';
     //定额前缀 none:0, complementary:1, borrow: 2
-    ration.prefix = 0;
+    ration.prefix = '';
     //借用优先级比补充高
     if(std.rationRepId !== parseInt(firstLibID)){//借用
-        ration.prefix = 2;
+        ration.prefix = '借';
     }
     else if(std.rationRepId === firstLibID && ration.from === 'cpt') {
-        ration.prefix = 1;
+        ration.prefix = '补';
     }
     ration.programID = std.feeType;
     ration.rationAssList = createRationAss(std);//生成辅助定额

+ 32 - 1
modules/reports/util/rpt_construct_data_util.js

@@ -396,6 +396,18 @@ function filterData(sourceData, handleCfg, prjData) {
         }
         return rst;
     };
+    let private_chkArrVal = function(arr, key, compVal, compStr){
+        let rst = false;
+        for (let arrItem of arr) {
+            if (arrItem[key]) {
+                rst = private_chkVal(arrItem[key], compVal, compStr);
+            }
+            if (rst) {
+                break;
+            }
+        }
+        return rst;
+    };
     let compareObj = {};
     for (let item of tempRstArr) {
         let compRst = true;
@@ -404,7 +416,26 @@ function filterData(sourceData, handleCfg, prjData) {
         for (let cfg of handleCfg[JV.PROP_FILTER_KEYS]) {
             if (cfg[JV.PROP_FILTER_COMPARE_VAL]) {
                 //比较key值
-                compRst = private_chkVal(item[cfg.key], cfg[JV.PROP_FILTER_COMPARE_VAL], cfg[JV.PROP_FILTER_CONDITION]);
+                let keys = cfg.key.split(".");
+                if (keys.length > 1) {
+                    let lastObj = item;
+                    for (let i = 0; i < keys.length - 1; i++) {
+                        lastObj = item[keys[i]];
+                        if (!(lastObj)) {
+                            compRst = false;
+                            break;
+                        }
+                    }
+                    if (lastObj) {
+                        if (lastObj instanceof Array) {
+                            compRst = private_chkArrVal(lastObj, keys[keys.length - 1], cfg[JV.PROP_FILTER_COMPARE_VAL], cfg[JV.PROP_FILTER_CONDITION]);
+                        } else {
+                            compRst = private_chkVal(lastObj[keys[keys.length - 1]], cfg[JV.PROP_FILTER_COMPARE_VAL], cfg[JV.PROP_FILTER_CONDITION]);
+                        }
+                    }
+                } else {
+                    compRst = private_chkVal(item[cfg.key], cfg[JV.PROP_FILTER_COMPARE_VAL], cfg[JV.PROP_FILTER_CONDITION]);
+                }
             } else if (cfg[JV.PROP_FILTER_COMPARE_OBJ] && cfg[JV.PROP_FILTER_COMPARE_OBJ_KEY]){
                 //通过其他对象来过滤
                 if (!curComparePrjData) {

+ 9 - 0
public/web/id_tree.js

@@ -679,6 +679,15 @@ var idTree = {
             }
             return data;
         };
+        //非叶子节点默认收起展开
+        Tree.prototype.setRootExpanded = function(nodes, expanded){
+            for(let node of nodes){
+                if(node.children.length > 0){
+                    node.setExpanded(expanded);
+                    this.setRootExpanded(node.children, expanded);
+                }
+            }
+        };
 
         /*Tree.prototype.editedData = function (field, id, newText) {
             var node = this.findNode(id), result = {allow: false, nodes: []};

+ 0 - 39
test/unit/reports/test_tpl_09_1.js

@@ -49,7 +49,6 @@ fs.readFile(__dirname.slice(0, __dirname.length - 18) + '/public/web/date_util.j
     eval(data);
 });
 
-//*
 test('测试 - 测试模板啦: ', function (t) {
     rptTplFacade.getRptTemplate(demoRptId).then(function(rptTpl) {
         let rptDataUtil = new rptDataExtractor();
@@ -60,9 +59,6 @@ test('测试 - 测试模板啦: ', function (t) {
         rptTplDataFacade.prepareProjectData(userId_Dft, demoPrjId, filter, function (err, msg, rawDataObj) {
             if (!err) {
                 try {
-                    // if (filter.indexOf('ration') >= 0 && filter.indexOf('ration_glj') >= 0) {
-                    //     rptDataUtil.moveRationData(rawDataObj, filter);
-                    // }
                     // fsUtil.writeObjToFile(rawDataObj, "D:/GitHome/ConstructionCost/tmp/rptTplRawDataObject_建筑09-1表.jsp");
                     let tplData = rptDataUtil.assembleData(rawDataObj);
                     // fsUtil.writeObjToFile(tplData, "D:/GitHome/ConstructionCost/tmp/rptTplAssembledData_建筑09-1表.jsp");
@@ -96,41 +92,6 @@ test('测试 - 测试模板啦: ', function (t) {
         })
     });
 });
-//*/
-
-/*/
-test('测试 - 保存小数位数问题: ', function (t) {
-    require('./rpt_test_decimal');
-    let rpt_decimal_mdl = mongoose.model("rpt_decimal_test");
-    let num = 300000;
-    let ID = 1;
-    for (let i = 0.0001; i < 1; (i+=0.0001)) {
-        let test_doc = {};
-        test_doc.ID = ID;
-        test_doc.Value1 = num + i;
-        test_doc.Value2 = num + i + 0.1 + 0.2;
-        test_doc.Value3 = parseFloat((num + i + 0.1 + 0.2).toFixed(5));
-        rpt_decimal_mdl.create(test_doc);
-        ID++;
-    }
-    t.pass('pass save decimal ok!');
-    t.end();
-});
-//*/
-/*/
-test('测试 - 显示保存小数位数问题: ', function (t) {
-    require('./rpt_test_decimal');
-    let rpt_decimal_mdl = mongoose.model("rpt_decimal_test");
-    rpt_decimal_mdl.find({}).then(function (rst) {
-        //console.log(rst);
-        if (rst.length > 0) {
-            fsUtil.writeObjToFile(rst, "D:/GitHome/ConstructionCost/tmp/testDecimalResult.jsp");
-        }
-        t.pass('pass get decimal ok!');
-        t.end();
-    });
-});
-//*/
 
 test('close the connection', function (t) {
     setTimeout(function () {

+ 103 - 0
test/unit/reports/test_tpl_11.js

@@ -0,0 +1,103 @@
+/**
+ * Created by Tony on 2018/5/11.
+ */
+
+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));
+});
+
+//config.setupCache();
+let cfgCacheUtil = require("../../../config/cacheCfg");
+cfgCacheUtil.setupDftCache();
+
+let fsUtil = require("../../../public/fsUtil");
+
+let demoPrjId = - 1;
+let demoRptId = 247, pagesize = "A4";
+
+// let userId_Leng = "59cdf14a0034a1000ba52b97"; //小冷User Id 换成_id了 QQ号
+let userId_Leng = "5acac1e885bf55000bd055ba"; //小冷User Id2
+// demoPrjId = 720; //QA: DW3
+//demoPrjId = 1626; //QA:
+demoPrjId = 2260; //QA:
+//*/
+let userId_Dft = userId_Leng;
+/*/
+ let userId_Dft = "595328da1934dc327cad08eb";
+ //*/
+
+let rptTplFacade = require("../../../modules/reports/facade/rpt_template_facade");
+let rptTplDataFacade = require("../../../modules/reports/facade/rpt_tpl_data_facade");
+
+import rptDataExtractor from "../../../modules/reports/util/rpt_construct_data_util";
+
+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('测试 - 测试模板: 表-11 ', function (t) {
+    rptTplFacade.getRptTemplate(demoRptId).then(function(rptTpl) {
+        let rptDataUtil = new rptDataExtractor();
+        rptDataUtil.initialize(rptTpl._doc);
+        let filter = rptDataUtil.getDataRequestFilter();
+        console.log(filter);
+        //正常应该根据报表模板定义的数据类型来请求数据
+        rptTplDataFacade.prepareProjectData(userId_Dft, demoPrjId, filter, function (err, msg, rawDataObj) {
+            if (!err) {
+                try {
+                    // fsUtil.writeObjToFile(rawDataObj, "D:/GitHome/ConstructionCost/tmp/rptTplRawDataObject_建筑11表.jsp");
+                    let tplData = rptDataUtil.assembleData(rawDataObj);
+                    // fsUtil.writeObjToFile(tplData, "D:/GitHome/ConstructionCost/tmp/rptTplAssembledData_建筑11表.jsp");
+                    //it's time to build the report!!!
+                    let printCom = JpcEx.createNew();
+                    rptTpl[JV.NODE_MAIN_INFO][JV.NODE_PAGE_INFO][JV.PROP_PAGE_SIZE] = pagesize;
+                    let defProperties = rpt_cfg;
+                    let dftOption = JV.PAGING_OPTION_NORMAL;
+                    printCom.initialize(rptTpl);
+                    printCom.analyzeData(rptTpl, tplData, defProperties, dftOption);
+                    let maxPages = printCom.totalPages;
+                    let pageRst = printCom.outputAsSimpleJSONPageArray(rptTpl, tplData, 1, maxPages, defProperties);
+                    if (pageRst) {
+                        // fsUtil.writeObjToFile(pageRst, "D:/GitHome/ConstructionCost/tmp/testBuiltPageResult_建筑11表.jsp");
+                    } else {
+                        console.log("oh! no pages were created!");
+                    }
+                } catch (ex) {
+                    console.log(ex);
+                    t.pass('pass with exception!');
+                    t.end();
+                }
+
+                t.pass('pass succeeded!');
+                t.end();
+            } else {
+                console.log(msg);
+                t.pass('pass with error!');
+                t.end();
+            }
+        })
+    });
+});
+
+test('close the connection', function (t) {
+    setTimeout(function () {
+        mongoose.disconnect();
+        t.pass('closing db connection');
+        t.end();
+    }, 1000);
+});

+ 1 - 1
web/building_saas/css/custom.css

@@ -10,7 +10,7 @@ label.title{
 
 
 div.resize{
-    height: 4px;
+    height: 6px;
     background: #f7f7f9;
     width: 100%;
     cursor: s-resize;

+ 5 - 2
web/building_saas/js/global.js

@@ -8,8 +8,11 @@ function autoFlashHeight(){
     let gljBottomContentHeight = $("#project-glj-main .bottom-content").height();
     let toolsBarHeightQ = $(".tools-bar-height-q").height();
     let toolsBarHeightD = $(".tools-bar-height-d").height();
-    $(".main-data-side-q").height($(window).height()-headerHeight-toolsbarHeight-toolsBarHeightQ-302);
-    $(".main-data-side-d").height($(window).height()-headerHeight-toolsbarHeight-toolsBarHeightD-302);
+    //$(".main-data-side-q").height($(window).height()-headerHeight-toolsbarHeight-toolsBarHeightQ-302);
+    $(".main-data-side-q").height($(window).height()-headerHeight-toolsbarHeight-toolsBarHeightQ-$('#qd').find('.bottom-content').find('.p-0').height()-5);
+    //$(".main-data-side-d").height($(window).height()-headerHeight-toolsbarHeight-toolsBarHeightD-302);
+    $(".main-data-side-d").height($(window).height()-headerHeight-toolsbarHeight-toolsBarHeightD-$('#stdSectionRations').height()-5);
+    $('.main-content').width($(window).width()-$('.main-nav').width()-$('.main-side').width()-5);
     //$("#main .main-data-top").height($(window).height()-headerHeight-toolsbarHeight-bottomContentHeight-1);
     $("#billsSpread").height($(window).height()-headerHeight-toolsbarHeight-mainBottomContentHeight-1);
     $("#project_glj_sheet").height($(window).height()-headerHeight-toolsbarHeight-gljBottomContentHeight-25);

+ 15 - 12
web/building_saas/main/html/main.html

@@ -100,7 +100,8 @@
               </div>
               <div class="container-fluid">
                   <div class="row">
-                      <div class="main-content col-lg-12 p-0" id="main">
+                      <!--col-lg-12 p-0-->
+                      <div class="main-content" style="width: 100%; display: inline-block" id="main">
                           <div class="top-content">
                               <div class="main-data-top" id="billsSpread"></div>
                           </div>
@@ -208,9 +209,9 @@
                               </div>
                           </div>
                       </div>
-                      <div class="main-side col-lg-0 p-0">
-                          <div class="resize col-lg-0 p-0"></div>
-                          <div class="tab-content">
+                      <div class="main-side" style="display: inline-block">
+                          <div class="resize" id="sideResize" style="width: 1%; height: 100%; resize:horizontal; cursor: w-resize; float: left; background: #F1F1F1"></div>
+                          <div class="tab-content" style="width: 99%; height: 100%; float: left">
                               <!--清单规则-->
                               <div class="tab-pane" id="qd">
                                   <div class="tools-bar-height-q container-fluid">
@@ -233,9 +234,11 @@
                                           </div>
                                       </div>
                                   </div>
-                                  <div class="main-data-side-q" id="stdBillsSpread">
+                                  <div class="top-content">
+                                      <div class="main-data-side-q" id="stdBillsSpread"></div>
                                   </div>
-                                  <div class="sidebar-bottom container-fluid">
+                                  <div class="resize" id="qdResize" style="background: #F1F1F1"></div>
+                                  <div class="bottom-content">
                                       <div class="row" id="stdBillsJobTab">
                                           <div class="col-lg-6 p-0" id="stdBillsJobs"></div>
                                           <div class="col-lg-6 p-0" id="stdBillsFeatures"></div>
@@ -264,13 +267,13 @@
                                           </div>
                                       </div>
                                   </div>
-                                  <div class="main-data-side-d" id="stdRationChapter">
+                                  <div class="top-content" style="overflow: hidden">
+                                      <div class="main-data-side-d" id="stdRationChapter">
                                   </div>
-                                  <div class="resize" style="background: #F1F1F1"></div>
-                                  <div class="sidebar-bottom container-fluid">
-                                      <div class="row">
-                                          <div class="col-lg-12 p-0" id="stdSectionRations"></div>
-                                      </div>
+                                  </div>
+                                  <div class="resize" id="deResize" style="background: #F1F1F1"></div>
+                                  <div class="bottom-content">
+                                      <div class="main-data-bottom" id="stdSectionRations"></div>
                                   </div>
                               </div>
                           </div>

+ 95 - 56
web/building_saas/main/js/main.js

@@ -4,9 +4,18 @@
 
 $(function () {
     // 读取本地存储的高度(必须放在载入spread之前)
-    loadSize("main", function() {
+    let mainResizeEles = {};
+    mainResizeEles.id = '#main';
+    mainResizeEles.resize = $('#main').find('.resize');
+    mainResizeEles.nearElement = $('#main').find('.top-content');
+    mainResizeEles.nearSpread = mainResizeEles.nearElement.children(".main-data-top");
+    mainResizeEles.farElement = $('#main').find('.bottom-content');
+    mainResizeEles.farSpread = mainResizeEles.farElement.children().find(".main-data-bottom");
+    mainResizeEles.nav = mainResizeEles.farElement.children('ul.nav');
+    loadSize(mainResizeEles, 'height', function() {
         refreshSubSpread();
     });
+
     $("#header-menu").removeAttr('style');
     projectInfoObj.showProjectInfo();
     projectObj.checkMainSpread();
@@ -23,13 +32,9 @@ $(function () {
         $(gljOprObj.activeTab).addClass('active');
         autoFlashHeight();
         projectObj.refreshMainSpread();
-        /*loadSize("main", function() {
-            projectObj.refreshMainSpread();
-            refreshSubSpread();
-        });*/
     });
 
-    slideResize($("#main"), function() {
+    slideResize(mainResizeEles, {min: 170, max: 700}, 'height', function() {
         projectObj.mainSpread.refresh();
         refreshSubSpread();
     });
@@ -47,49 +52,66 @@ $(function () {
 /**
  * 拖动更改div大小
  *
- * @param {Object} rootElement - 最顶层div
+ * @param {Object} eles - id:存储本地的标记 resize:拖动条 nearElement:左上外层div nearSpread:左上spread farElement:右下外层div evFixedSize:造价书左右拖动用
+ * @param {Object} limit - min/max
+ * @param {String} type - height/width
  * @param {function} callback - 成功后执行
  * @return {void}
  */
-function slideResize(rootElement, callback) {
-    let startY = 0;
+function slideResize(eles, limit, type, callback) {
+    if(type !== 'height' && type !== 'width'){
+        return;
+    }
+    //nearElement:左上, farElement:右下
+    let startP = 0;
     let drag = false;
-    const element = rootElement.find('.resize');
-    const topContentEle = rootElement.find(".top-content");
-    const bottomContentEle = rootElement.find(".bottom-content");
-    let topContentHeight = 0;
-    let bottomContentHeight = 0;
-    let navHeight = 0;
-    let topChangeHeight = 0;
-    let bottomChangeHeight = 0;
+    const resizeElement = eles.resize;
+    const nElement = eles.nearElement;
+    const fElement = eles.farElement;
+    const navContentEle = eles.nav ? eles.nav : null;
+    let nEleSize = 0;
+    let fEleSize = 0;
+    let navSize = 0;
+    let nEleChangeSize = 0;
+    let fEleChangeSize = 0;
 
     // 鼠标点下时
-    element.mousedown(function(e) {
+    resizeElement.mousedown(function(e) {
         drag = true;
-        startY = e.clientY;
-        // 获取上部分的高度
-        topContentHeight = topContentEle.height();
-        // 获取下部分的高度
-        bottomContentHeight = bottomContentEle.height();
-        // nav高度部分
-        navHeight = bottomContentEle.children('ul.nav').height() + 4;
-        element.tooltip('hide');
+        startP = type === 'height' ? e.clientY : e.clientX;
+        // 获取左(上)部分的宽度(高度)
+        nEleSize = nElement[type]();
+        // 获取右(下)部分的宽度(高度)
+        fEleSize = fElement[type]();
+        // nav宽(高度)部分
+        if(navContentEle){
+            navSize = navContentEle[type]() + 4;
+        }
+        resizeElement.tooltip('hide');
     });
 
     // 鼠标移动
     $("body").mousemove(function(e) {
         if (drag) {
-            let moveHeight = e.clientY - startY;
+            let moveSize = type === 'height' ? e.clientY - startP : e.clientX - startP;
             // 判断拖动范围不能超出
-            topChangeHeight = topContentHeight + moveHeight;
-            topChangeHeight = topChangeHeight < 170 ? 170 : topChangeHeight;
-            topChangeHeight = topChangeHeight > 700 ? 709 : topChangeHeight;
-            topContentEle.children(".main-data-top").height(topChangeHeight);
+            nEleChangeSize = nEleSize + moveSize;
+            nEleChangeSize = nEleChangeSize < limit.min ? limit.min : nEleChangeSize;
+            nEleChangeSize = nEleChangeSize > limit.max ? limit.max + 9 : nEleChangeSize;
 
-            bottomChangeHeight = bottomContentHeight - moveHeight;
-            bottomChangeHeight = bottomChangeHeight < 170 ? 170 : bottomChangeHeight;
-            bottomChangeHeight = bottomChangeHeight > 700 ? 709 : bottomChangeHeight;
-            bottomContentEle.children().find(".main-data-bottom").height(bottomChangeHeight - navHeight);
+            fEleChangeSize = fEleSize - moveSize;
+            fEleChangeSize = fEleChangeSize < limit.min ? limit.min : fEleChangeSize;
+            fEleChangeSize = fEleChangeSize > limit.max ? limit.max + 9 : fEleChangeSize;
+
+            if(type === 'width'){
+                let rePercent = getResizeWidthPercent(nEleChangeSize, fEleChangeSize);
+                eles.nearElement.css(type, rePercent.nearPercent);
+                eles.farElement.css(type, rePercent.farPercent);
+            }
+            else{
+                eles.nearSpread[type](nEleChangeSize);
+                eles.farSpread[type](fEleChangeSize - navSize);
+            }
         }
     });
 
@@ -99,11 +121,11 @@ function slideResize(rootElement, callback) {
             callback();
             drag = false;
             // 存入本地缓存
-            const id = rootElement.attr('id');
-            topChangeHeight = topChangeHeight >= 700 ? 709 : topChangeHeight;
-            bottomChangeHeight = bottomChangeHeight >= 700 ? 709 : bottomChangeHeight;
-            setLocalCache('topHeight:' + id, topChangeHeight);
-            setLocalCache('bottomHeight:' + id, bottomChangeHeight);
+            const id = eles.id;
+            nEleChangeSize = nEleChangeSize >= limit.max ? limit.max + 9  : nEleChangeSize;
+            fEleChangeSize = fEleChangeSize >= limit.max ? limit.max + 9  : fEleChangeSize;
+            setLocalCache(`near${type}:${id}`, nEleChangeSize);
+            setLocalCache(`far${type}:${id}`, fEleChangeSize);
         }
     });
 }
@@ -115,25 +137,42 @@ function slideResize(rootElement, callback) {
  * @param {function} callback - 回调函数
  * @return {void}
  */
-function loadSize(tag, callback) {
+
+function loadSize(eles, type, callback) {
+    let tag = eles.id;
     if (tag === '') {
         return;
     }
-    let o_topHeight = $("#"+ tag +" .main-data-top").height();
-    let o_bottomHeight = $("#"+ tag +" .main-data-bottom").height();
-    let topHeight = getLocalCache('topHeight:' + tag);
-    let bottomHeight = getLocalCache('bottomHeight:' + tag);
-    if (topHeight === null || bottomHeight === null) {
-        $("#"+ tag +" .main-data-top").height(o_topHeight);
-        $("#"+ tag +" .main-data-bottom").height(o_bottomHeight);
+    if(type !== 'height' && type !== 'width'){
+        return;
+    }
+    let o_nearSize = eles.nearSpread[type]();
+    let o_farSize = eles.farSpread[type]();
+    let nearSize = getLocalCache(`near${type}:${tag}`);
+    let farSize = getLocalCache(`far${type}:${tag}`);
+    if (nearSize === null || farSize === null) {
+        eles.nearSpread[type](o_nearSize);
+        eles.farSpread[type](o_farSize);
     }else {
-        const navHeight = $("#"+ tag +" .bottom-content").children('ul.nav').height() + 4;
-        topHeight = parseFloat(topHeight);
-        bottomHeight = parseFloat(bottomHeight);
-        $("#"+ tag +" .main-data-top").height(topHeight);
-        $("#"+ tag +" .main-data-bottom").height(bottomHeight - navHeight);
+        nearSize = parseFloat(nearSize);
+        farSize = parseFloat(farSize);
+        if(type !== 'width') {
+            const navSize = eles.nav ? eles.nav[type]() + 4 : 0;
+            eles.nearSpread[type](nearSize);
+            eles.farSpread[type](farSize - navSize);
+        }
+    }
+    if(type === 'width'){//使用百分比
+        let rePercent = getResizeWidthPercent(nearSize ? nearSize : o_nearSize, farSize ? farSize : o_farSize);
+        eles.nearElement.css(type, rePercent.nearPercent);
+        eles.farElement.css(type, rePercent.farPercent);
     }
-
-    // $("#"+ tag +" .bottom-content").height(bottomHeight);
     callback();
-}
+}
+
+function getResizeWidthPercent(nearSize, farSize){
+    const resizeWidth = 6;
+    let nearPercent = (nearSize / (resizeWidth + nearSize + farSize) * 100) + '%';
+    let farPercent = (farSize / (resizeWidth + nearSize + farSize) * 100) + '%';
+    return {nearPercent, farPercent};
+}

+ 7 - 3
web/building_saas/main/js/models/main_consts.js

@@ -159,9 +159,13 @@ const rationType = {
     install:4
 };
 const rationPrefix = { //定额前缀,补/借
-    none: 0,
-    complementary: 1,
-    borrow: 2
+    none: '',
+    complementary: '补',
+    borrow: '借'
+};
+const rationFrom = {
+    std: 'std',
+    cpt: 'cpt'
 };
 const leafBillGetFeeType = {
     rationContent: 0,

+ 11 - 0
web/building_saas/main/js/models/ration.js

@@ -630,6 +630,17 @@ var Ration = {
                 return 0;
             }
         } ;
+        //获取定额前缀
+        ration.prototype.getRationPrefix = function(firstLibID, ration){
+            if(firstLibID !== ration.libID){
+                return rationPrefix.borrow;
+            }
+            if(ration.from && ration.from === rationFrom.cpt){
+                return rationPrefix.complementary;
+            }
+            return rationPrefix.none;
+        };
+
         return new ration(project);
     }
 };

+ 2 - 8
web/building_saas/main/js/views/main_tree_col.js

@@ -43,15 +43,9 @@ let MainTreeCol = {
         },
         code: function (node) {
             if(node.sourceType === projectObj.project.Ration.getSourceType() && node.data.type === rationType.ration
-                && isDef(node.data.code) && isDef(node.data.prefix)){
-                if(node.data.prefix === rationPrefix.complementary){
-                    return '补' +  node.data.code.replace(new RegExp('补'), '');
-                }
-                if(node.data.prefix === rationPrefix.borrow){
-                    return '借' +  node.data.code.replace(new RegExp('借'), '');
-                }
+                && isDef(node.data.code) && isDef(node.data.prefix) && node.data.prefix !== ''){
+                return node.data.prefix + node.data.code.replace(new RegExp(node.data.prefix, 'g'), '');
             }
-
             return isDef(node.data.code) ? node.data.code : '';
         },
         marketPrice:function (node) {

+ 13 - 5
web/building_saas/main/js/views/project_glj_view.js

@@ -496,6 +496,18 @@ projectGljObject={
 
 
 $(function () {
+    let pojGljResizeEles = {};
+    pojGljResizeEles.id = '#project-glj-main';
+    pojGljResizeEles.resize = $('#project-glj-main').find('.resize');
+    pojGljResizeEles.nearElement = $('#project-glj-main').find('.top-content');
+    pojGljResizeEles.nearSpread = pojGljResizeEles.nearElement.children(".main-data-top");
+    pojGljResizeEles.farElement = $('#project-glj-main').find('.bottom-content');
+    pojGljResizeEles.farSpread = pojGljResizeEles.farElement.children().find(".main-data-bottom");
+    pojGljResizeEles.nav = pojGljResizeEles.farElement.children('ul.nav');
+    slideResize(pojGljResizeEles, {min: 170, max: 700}, 'height', function () {
+        projectGljObject.projectGljSpread.refresh();
+        projectGljObject.mixRatioSpread?projectGljObject.mixRatioSpread.refresh():'';
+    });
     $('#tab_project_glj').on('shown.bs.tab', function (e) {
         let me = projectGljObject;
         $(e.relatedTarget.hash).removeClass('active');
@@ -505,7 +517,7 @@ $(function () {
         me.unitPriceFileInit();
         //projectObj.project.projectGLJ.calcQuantity(); 在工程量有更新的地方调用
         me.showProjectGljData();
-        loadSize("project-glj-main", function () {
+        loadSize(pojGljResizeEles, 'height', function () {
             me.projectGljSpread.refresh();
             me.mixRatioSpread?me.mixRatioSpread.refresh():'';
         });
@@ -527,10 +539,6 @@ $(function () {
         me.showProjectGljData();
         me.initMixRatio();
     });
-    slideResize($("#project-glj-main"), function () {
-        projectGljObject.projectGljSpread.refresh();
-        projectGljObject.mixRatioSpread?projectGljObject.mixRatioSpread.refresh():'';
-    });
     $('#pop-used-list').popover({
             placement: "bottom",
             html: true,

+ 78 - 15
web/building_saas/main/js/views/side_tools.js

@@ -1,21 +1,87 @@
 /**
  * Created by Mai on 2017/6/16.
  */
+//造价书与清单定额库左右拖动
+let sideResizeEles = {};
+sideResizeEles.id = 'stdRationTab';
+sideResizeEles.resize = $('#sideResize');
+sideResizeEles.evFixedSize = `$(window).width()-$('.main-nav').width()-5`;
+sideResizeEles.nearElement = $('.main-content');
+sideResizeEles.nearSpread = $('.main-content');
+sideResizeEles.farElement = $('.main-side');
+sideResizeEles.farSpread = $('.main-side');
+sideResizeEles.nav = null;
+slideResize(sideResizeEles, {min: 250, max: $('#zaojiashu').width()-260}, 'width', function(){
+    projectObj.refreshMainSpread();
+    refreshSubSpread();
+    if(sideResizeEles.id === 'stdRationTab'){
+        rationLibObj.refreshSpread();
+    }
+    else{
+        billsLibObj.refreshBillsSpread();
+        billsLibObj.refreshBillsRelaSpread();
+    }
+});
+//定额库上下拖动
+let rationLibResizeEles = {};
+rationLibResizeEles.id = '#de';
+rationLibResizeEles.resize = $('#deResize');
+rationLibResizeEles.nearElement = $('#de').find('.top-content');
+rationLibResizeEles.nearSpread = $('#stdRationChapter');
+rationLibResizeEles.farElement = $('#de').find('.bottom-content');
+rationLibResizeEles.farSpread = $('#stdSectionRations');
+rationLibResizeEles.nav = null;
+slideResize(rationLibResizeEles, {min: 147, max: 680}, 'height', function() {
+    rationLibObj.refreshSpread();
+});
+
+//清单库上下拖动
+let billsLibResizeEles = {};
+billsLibResizeEles.id = '#qd';
+billsLibResizeEles.resize = $('#qdResize');
+billsLibResizeEles.nearElement = $('#qd').find('.top-content');
+billsLibResizeEles.nearSpread = $('#stdBillsSpread');
+billsLibResizeEles.farElement = $('#qd').find('.bottom-content');
+billsLibResizeEles.farSpread = billsLibResizeEles.farElement.find('.p-0');
+billsLibResizeEles.nav = null;
+slideResize(billsLibResizeEles, {min: 147, max: 680}, 'height', function() {
+    billsLibObj.refreshBillsSpread();
+    billsLibObj.refreshBillsRelaSpread();
+});
+
 
 var sideToolsObj = {
-    showSideTools: function (show) {
-        var main = $('.main-content'), side = $('.main-side');
+    showSideTools: function (tabPanel, show, id) {
+        sideResizeEles.id = id;
         if (show) {
-            main.removeClass('col-lg-12');
-            main.addClass('col-lg-8');
-            side.removeClass('col-lg-0');
-            side.addClass('col-lg-4');
+            sideResizeEles.nearElement.css('width', '66.666667%');
+            sideResizeEles.farElement.css('width', '33.333333%');
+            $('.main-side .tab-pane').hide();
+            tabPanel.show();
+            loadSize(sideResizeEles, 'width', function(){
+                refreshSubSpread();
+                if(id === 'stdRationTab'){//定额库
+                    //autoFlashHeight();
+                    loadSize(rationLibResizeEles, 'height', function(){
+                        rationLibObj.refreshSpread();;//subSpread、jobSpread、itemSpread显示问题
+                    });
+                }
+                else{//清单库
+                    loadSize(billsLibResizeEles, 'height', function(){
+                        //autoFlashHeight();
+                        billsLibObj.refreshBillsSpread();
+                        billsLibObj.refreshBillsRelaSpread();
+                    });
+                }
+            });
+
         } else {
-            main.removeClass('col-lg-8');
-            main.addClass('col-lg-12');
-            side.removeClass('col-lg-4');
-            side.addClass('col-lg-0');
+            sideResizeEles.nearElement.css('width', '100%');
+            sideResizeEles.farElement.css('width', '0%');
+            tabPanel.hide();
+            refreshSubSpread();
         }
+        autoFlashHeight();
     }
 };
 
@@ -24,13 +90,10 @@ $('.side-tabs ul li a').bind('click', function () {
     if (!tab.hasClass('active')) {
         $('.side-tabs ul li a').removeClass('active');
         tab.addClass('active');
-        sideToolsObj.showSideTools(tab.hasClass('active'));
-        $('.main-side .tab-pane').hide();
-        tabPanel.show();
+        sideToolsObj.showSideTools(tabPanel, tab.hasClass('active'), tab.attr('id'));
     } else {
         tab.removeClass('active');
-        sideToolsObj.showSideTools(tab.hasClass('active'));
-        tabPanel.hide();
+        sideToolsObj.showSideTools(tabPanel, tab.hasClass('active'), tab.attr('id'));
     }
     projectObj.refreshMainSpread();
 });

+ 10 - 6
web/building_saas/main/js/views/std_bills_lib.js

@@ -165,10 +165,9 @@ var billsLibObj = {
         CommonAjax.post('/stdBillsEditor/getBills', {userId: userID, billsLibId: stdBillsLibID}, function (datas) {
             stdBills = datas;
             stdBillsTree.loadDatas(stdBills);
-            //第一层默认收起
-            for(let root of stdBillsTree.roots){
-                root.setExpanded(false);
-            }
+            //非叶子节点默认收起
+            stdBillsTree.setRootExpanded(stdBillsTree.roots, false);
+
             stdBillsTreeController.showTreeData();
             billsLibObj.setTagForHint(datas);
             showBillsRela(stdBillsTree.firstNode());
@@ -397,10 +396,15 @@ function addEventOnResize(fn){
     }
 }
 addEventOnResize(billsLibObj.refreshSettingForHint);
+//赋初始高度
+if($('#stdBillsSpread').height() === 0 || $('#qd').find('.bottom-content').height() === 0){
+    $('#stdBillsSpread').height($(window).height()-$(".header").height()-$(".toolsbar").height()-$(".tools-bar-height-q").height()-312);
+    $('#qd').find('.bottom-content').find('.p-0').height(270);
+}
 
 $('#stdBillsTab').bind('click', function () {
     refreshSubSpread();//subSpread、jobSpread、itemSpread显示问题
-    $(".main-data-side-q").height($(window).height() - $(".header").height() - $(".toolsbar").height() -  $(".tools-bar-height-q").height() - 202);
+    //$(".main-data-side-q").height($(window).height() - $(".header").height() - $(".toolsbar").height() -  $(".tools-bar-height-q").height() - 202);
     var select = $('#stdBillsLibSelect');
     billsLibObj.refreshBillsSpread();
     billsLibObj.refreshBillsRelaSpread();
@@ -411,7 +415,7 @@ $('#stdBillsTab').bind('click', function () {
 });
 $('#stdBillsLibSelect').change(function () {
     $('#stdBillsSearchResult').hide();
-    $(".main-data-side-q").height($(window).height() - $(".header").height() - $(".toolsbar").height() -  $(".tools-bar-height-q").height() - 202);
+    //$(".main-data-side-q").height($(window).height() - $(".header").height() - $(".toolsbar").height() -  $(".tools-bar-height-q").height() - 202);
     billsLibObj.clearHighLight(billsLibObj.stdBillsSpread);
 
     var select = $(this);

+ 10 - 10
web/building_saas/main/js/views/std_ration_lib.js

@@ -50,10 +50,8 @@ var rationLibObj = {
             that.tree = rationChapterTree;
             var rationChapterTreeController = TREE_SHEET_CONTROLLER.createNew(rationChapterTree, that.rationChapterSpread.getActiveSheet(), that.rationChapterTreeSetting);
             rationChapterTree.loadDatas(datas);
-            //第一层默认收起
-            for(let root of that.tree.roots){
-                root.setExpanded(false);
-            }
+            //非叶子节点默认收起
+            that.tree.setRootExpanded(that.tree.roots, false);
             rationChapterTreeController.showTreeData();
 
             rationChapterTreeController.bind(TREE_SHEET_CONTROLLER.eventName.treeSelectedChanged, function (node) {
@@ -75,8 +73,6 @@ var rationLibObj = {
     },
     //双击隐藏显示
     onChapterSpreadCellDoubleClick: function (sender, args) {
-        console.log(args);
-        console.log(sender);
         let me = rationLibObj;
         let node = me.tree.items[args.row];
         if (!node || node.children.length === 0)
@@ -296,11 +292,14 @@ var rationLibObj = {
 };
 
 addEventOnResize(rationLibObj.refreshSettingForHint);
+//赋初始高度
+if($('#stdRationChapter').height() === 0 || $('#stdSectionRations').height() === 0){
+    $('#stdRationChapter').height($(window).height()-$(".header").height()-$(".toolsbar").height()-$(".tools-bar-height-q").height()-312);
+    $('#stdSectionRations').height(270);
+}
+
 $('#stdRationTab').bind('click', function () {
-    refreshSubSpread();//subSpread、jobSpread、itemSpread显示问题
     var select = $('#stdRationLibSelect');
-    $(".main-data-side-d").height($(window).height() - $(".header").height() - $(".toolsbar").height() -  $(".tools-bar-height-d").height() - 202);
-    rationLibObj.refreshSpread();
     rationLibObj.checkSpread();
     if (select[0].options.length === 0) {
         rationLibObj.loadStdRationLibs();
@@ -349,7 +348,8 @@ $('#rationSearch').click(function () {
         resultObj.append(getResultHtml(result));
         $('a', resultObj).click(function () {
             resultObj.hide();
-            $(".main-data-side-d").height($(window).height() - $(".header").height() - $(".toolsbar").height() -  $(".tools-bar-height-d").height() - 202);
+            //$(".main-data-side-d").height($(window).height() - $(".header").height() - $(".toolsbar").height() -  $(".tools-bar-height-d").height() - 202);
+            rationLibObj.refreshSpread();
             $(".main-data-side-search", resultObj).height(0);
         });
         resultObj.show();

+ 2 - 1
web/building_saas/pm/js/pm_newMain.js

@@ -139,9 +139,9 @@ const projTreeObj = {
     setSelStyle: function (sel, backColor,sheet) {
         let me = this;
         //let sheet = me.workBook.getSheet(0);
+        sel.row = sel.row === -1 ? 0 : sel.row;
         me.renderSheetFuc(sheet, function () {
             let style = me.getSelStyle(backColor);
-            /*sel.row = sel.row === -1 ? 0 : sel.row;*/
             for(let i = 0; i < sel.rowCount; i++){
                 let row = i + sel.row;
                 sheet.setStyle(row, -1, style);
@@ -1095,6 +1095,7 @@ $(document).ready(function() {
             alert('请选择需要重命名的数据');
             return false;
         }
+        $('#rename-name').val(projTreeObj.tree.selected.data.name ? projTreeObj.tree.selected.data.name : '');
         $('#rename-dialog').modal('show');
     });