Преглед на файлове

Merge branch '1.0.0_online' of http://smartcost.f3322.net:3000/SmartCost/ConstructionCost into 1.0.0_online

zhangweicheng преди 6 години
родител
ревизия
d8349d0412

+ 1 - 1
modules/bills_lib/models/bills_lib_interfaces.js

@@ -225,7 +225,7 @@ billsLibDao.prototype.getCurrentUniqId = function(callback){
 }
 //----------------------------Bills---------------------
 billsLibDao.prototype.getBills = function (billsLibId, callback) {
-    Bills.find({billsLibId: billsLibId, deleted: false}, "-_id",  function(err, billsData){
+    Bills.find({billsLibId: billsLibId}, "-_id -ruleText -recharge",  function(err, billsData){
         if(err){
             callback(1, "Error", null);
         }

+ 3 - 3
modules/std_billsGuidance_lib/facade/facades.js

@@ -31,15 +31,15 @@ async function getBillsGuideLibs(findData) {
 
 
 async function getLibWithBills(libID){
-    let guidanceLib = await getBillsGuideLibs({ID: libID, deleted: false});
+    let guidanceLib = await getBillsGuideLibs({ID: libID});
     if(guidanceLib.length === 0){
         throw '不存在此指引库!';
     }
-    let billsLib = await stdBillsLibModel.findOne({billsLibId: guidanceLib[0].billsLibId, deleted: false});
+    let billsLib = await stdBillsLibModel.findOne({billsLibId: guidanceLib[0].billsLibId});
     if(!billsLib){
         throw '引用的清单规则库不存在!';
     }
-    let bills = await stdBillsModel.find({billsLibId: billsLib.billsLibId, deleted: false});
+    let bills = await stdBillsModel.find({billsLibId: billsLib.billsLibId}, '-_id -ruleText -recharge');
     return {guidanceLib: guidanceLib[0], bills};
 }
 

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

@@ -1599,6 +1599,11 @@
         </script>
 
         <SCRIPT type="text/javascript">
+            let test = [{a: '1', b:'2'}, {t:{tt:'t',n: 'n'}}];
+            let clT = _.cloneDeep(test);
+            clT[0].a = '2222';
+            console.log(test);
+            console.log(clT);
             let clearFlag = false;
             function onCheck(e, treeId, treeNode) {
                 count();

+ 9 - 4
web/building_saas/main/js/models/calc_program.js

@@ -365,10 +365,15 @@ let calcTools = {
         };
 
         if (priceType == priceTypes.ptDiffPrice){
-            if (gljTypes == baseMaterialTypes)
-                result = (temp - temp2).toDecimal(decimalObj.ration.unitPrice)
-            else
-                result = (temp.toDecimal(decimalObj.ration.unitPrice) - temp2.toDecimal(decimalObj.ration.unitPrice)).toDecimal(decimalObj.ration.unitPrice);
+            if (typeof isCQ2018 != 'undefined'){
+                result = (temp - temp2).toDecimal(decimalObj.ration.unitPrice)    // 重庆2018所有都是先汇总相减后再取舍
+            }
+            else{
+                if (gljTypes == baseMaterialTypes)
+                    result = (temp - temp2).toDecimal(decimalObj.ration.unitPrice)
+                else
+                    result = (temp.toDecimal(decimalObj.ration.unitPrice) - temp2.toDecimal(decimalObj.ration.unitPrice)).toDecimal(decimalObj.ration.unitPrice);
+            };
         }
         else{
             result = result.toDecimal(decimalObj.ration.unitPrice);

+ 132 - 56
web/building_saas/main/js/views/std_billsGuidance_lib.js

@@ -292,7 +292,7 @@ const billsGuidance = (function () {
                     data: {
                         field: "name",
                         vAlign: 1,
-                        hAlign: 1,
+                        hAlign: 0,
                         font: "Arial"
                     }
                 },
@@ -544,7 +544,6 @@ const billsGuidance = (function () {
             return;
         }
         bills.tree.selected = node;
-        refreshInsertRation();
         if(!node.elf.tree){
             CommonAjax.post('/billsGuidance/api/getItemsByBills', {guidanceLibID: libSel.val(), billsID: node.getID()}, function (rstData) {
                 //定额数据删除编号信息
@@ -562,26 +561,54 @@ const billsGuidance = (function () {
                 let firstLevelDatas = _.filter(rstData, function (data) {
                     return data.ParentID == -1;
                 });
-                //初始数据的选项显示请选择
+                //第一层初始数据的选项显示
                 for(let fData of firstLevelDatas){
                     let options = getOptions(fData, rstData);
-                    fData.options = options.length > 0 ? '请选择' : '';
+                    fData.options = options.length > 0 ? options[0].name : '';
+                    //下挂的选项
+                    fData.optionsData = options && options.length > 0 ? _.cloneDeep(options) : [];
+                    fData.optionChecked = options && options.length > 0 ? [_.cloneDeep(options[0])] : [];
                 }
-                initTree(node.elf, elfSheet, elfItem.treeSetting, firstLevelDatas);
+                renderSheetFunc(elfSheet, function () {
+                    initTree(node.elf, elfSheet, elfItem.treeSetting, firstLevelDatas);
+                    //初始选择选项
+                    let initOptsOpr = [];
+                    for(let elfNode of node.elf.tree.items){
+                        if(elfNode.data.optionsData.length > 0){
+                            initOptsOpr.push({node: elfNode, data: elfNode.data.optionsData[0]});
+                        }
+                    }
+                    for(let opr of initOptsOpr){
+                        insertNodeByData(opr.node, opr.data);
+                    }
+                    TREE_SHEET_HELPER.refreshTreeNodeData(elfItem.treeSetting, elfSheet, node.elf.tree.items, false);
+                    setOptionsCellType(node.elf.tree.items);
+                    //项目指引初始焦点
+                    elfItemInitSel(elfSheet.getActiveRowIndex() ? elfSheet.getActiveRowIndex() : 0);
+                    refreshInsertRation();
+                });
+            });
+        }
+        else{
+            renderSheetFunc(elfSheet, function () {
+                node.elf.controller.showTreeData();
                 setOptionsCellType(node.elf.tree.items);
-                //elfSheet.getRange(-1, 1, -1, 1).cellType(getOptionsCellType(null, null, null));
-                //setItemCellType(node.guidance.tree.items);
                 //项目指引初始焦点
                 elfItemInitSel(elfSheet.getActiveRowIndex() ? elfSheet.getActiveRowIndex() : 0);
+                refreshInsertRation();
             });
         }
-        else{
-            node.elf.controller.showTreeData();
-            //elfSheet.getRange(-1, 1, -1, 1).cellType(getOptionsCellType(null, null, null));
-            setOptionsCellType(node.elf.tree.items);
-            //项目指引初始焦点
-            elfItemInitSel(elfSheet.getActiveRowIndex() ? elfSheet.getActiveRowIndex() : 0);
+    }
+    //获取选项的深度
+    //@param {Object}opt {Array}options(当前清单所有选项) @return {Array}
+    function getOptionDepth(opt, options) {
+        let parent = _.find(options, {ID: opt.ParentID});
+        let depth = 0;
+        while (parent){
+            depth++;
+            parent = _.find(options, {ID: parent.ParentID});
         }
+        return depth;
     }
     //获取施工工序含有的选项(即当前施工工序的子项),获取的顺序按照NextSiblingID排序
     //@param {Object}process {Array}datas @return {Array}
@@ -630,7 +657,7 @@ const billsGuidance = (function () {
     function setOptionsCellType(nodes) {
         let elfSheet = elfItem.workBook.getActiveSheet();
         for(let node of nodes){
-            if(node.data.options !== ''){
+            if(node.data.optionsData && node.data.optionsData.length > 0){
                 elfSheet.getCell(node.serialNo(), 1).locked(false).cellType(getOptionsCellType());
             }
             else {
@@ -638,6 +665,61 @@ const billsGuidance = (function () {
             }
         }
     }
+    //递归插入节点:原始项目指引数据奇数层为需要插入的节点,偶数层为下拉选项
+    //@param {Object}node(当前操作的节点) {Object}data(选项) @return {void}
+    function insertNodeByData(node, data) {
+        let elfSheet = elfItem.workBook.getActiveSheet();
+        let sameDepthNodes = node.children;
+        let insertNextSiblingID = -1,
+            insertParentID = node.data.ID;
+        //当前操作节点的选项
+        let nodeOpts = getOptions(node.data, bills.tree.selected.elf.datas);
+        let subOpts = getOptions(data, bills.tree.selected.elf.datas);
+        let dataDepth = getOptionDepth(data, bills.tree.selected.elf.datas);
+        if(subOpts.length >0 && subOpts[0].type !== itemType.ration){
+            if((dataDepth + 1) % 2 === 0){
+                //排序后的数据
+                let dataWithRank = _.find(nodeOpts, {ID: data.ID});
+                //确定插入位置
+                for(let subOpt of subOpts){
+                    for(let subNode of sameDepthNodes){
+                        //同层节点原本选项数据
+                        let subNodeOptData = _.find(bills.tree.selected.elf.datas, {ID: subNode.data.ID});
+                        //同层节点原本父选项数据
+                        let subNodeOptParent = _.find(bills.tree.selected.elf.datas, {ID: subNodeOptData.ParentID});
+                        let subNodeOptParentWithRank = _.find(nodeOpts, {ID: subNodeOptParent.ID});
+                        //父项顺序决定插入位置
+                        if(dataWithRank.rank < subNodeOptParentWithRank.rank){
+                            insertNextSiblingID = subNode.data.ID;
+                            break;
+                        }
+                        //父项顺序相同,根据子项顺序决定插入位置
+                        else if(dataWithRank.rank = subNodeOptParentWithRank.rank){
+                            if(subOpt.rank < subNode.data.rank){
+                                insertNextSiblingID = subNode.data.ID;
+                                break;
+                            }
+                        }
+                    }
+                    let sub2Opts = getOptions(subOpt, bills.tree.selected.elf.datas);
+                    subOpt.options = sub2Opts.length > 0 ? sub2Opts[0].name : '';
+                    let cloneOpt = _.cloneDeep(subOpt);//不改变原本的数据,比如ParentID
+                    cloneOpt.optionChecked = sub2Opts.length > 0 ? [_.cloneDeep(sub2Opts[0])] : [];
+                    cloneOpt.optionsData = sub2Opts.length > 0 ? _.cloneDeep(sub2Opts) : [];
+                    let newNode = node.tree.insertByData(cloneOpt, insertParentID, insertNextSiblingID);
+                    elfSheet.addRows(newNode.serialNo(), 1);
+                    node.tree.selected = newNode;
+                    elfSheet.setSelection(newNode.serialNo(), elfSheet.getSelections()[0].col, 1, 1);
+                    if(sub2Opts.length > 0 && sub2Opts[0].type !== itemType.ration){
+                        insertNodeByData(newNode, sub2Opts[0]);
+                    }
+                }
+            }
+            else {
+                insertNodeByData(node, subOpts[0]);
+            }
+        }
+    }
     //获取选项下拉多选单元格
     //@param {void} @return {void}
     function getOptionsCellType() {
@@ -654,8 +736,8 @@ const billsGuidance = (function () {
             let height = cellRect.height;
             let htmlArr = [];
             let options = getOptions(node.data, bills.tree.selected.elf.datas);
-            let optionsTitle = node.data.options.split(';').join('\n');
-            htmlArr.push(`<div title="${optionsTitle}" style="height: ${height}px; background: ${cellStyle.backColor};overflow: hidden; white-space: nowrap; text-overflow: ellipsis">${node.data.options}</div><div style="background: ${cellStyle.backColor};border: 1px solid; overflow: auto; height: ${options.length > 6 ? height*6 : height*options.length+5}px; font-size: 0.9rem;">`);
+            //let optionsTitle = node.data.options.split(';').join('\n');
+            htmlArr.push(`<div style="height: ${height}px; background: ${cellStyle.backColor};overflow: hidden; white-space: nowrap; text-overflow: ellipsis">${node.data.options}</div><div style="background: ${cellStyle.backColor};border: 1px solid; overflow: auto; height: ${options.length > 6 ? height*6 : height*options.length+5}px; font-size: 0.9rem;">`);
             for(let opt of options){
                 htmlArr.push(`<div title="${opt.name ? opt.name : ''}" class="elf-options" style="height: ${height}px;overflow: hidden; white-space: nowrap; text-overflow: ellipsis">
                         <input rank="${opt.rank}" value="${opt.ID}" style="margin-left: 5px; vertical-align: middle" type="checkbox" 
@@ -675,70 +757,56 @@ const billsGuidance = (function () {
                 checkedNameArr.push(opt.name);
                 optionChecked.push(opt);
             }
-            this.displayText = checkedNameArr.length > 0 ? checkedNameArr.join(';') : '请选择';
+            this.displayText = checkedNameArr.length > 0 ? checkedNameArr.join(';') : '';
             node.data.options = this.displayText;
             node.data.optionChecked = optionChecked;
             //删除节点
-            let deleteInfo = getDeleteInfo(node, optionChecked);
-            for(let dInfo of deleteInfo){
-                if(node.tree.delete(dInfo.node)){
-                    elfSheet.deleteRows(dInfo.deleteRow, dInfo.deleteCount);
-                }
+            let deleteNodes = getDeleteNodes(node, optionChecked);
+            for(let dNode of deleteNodes){
+                elfSheet.deleteRows(dNode.serialNo(), dNode.posterityCount() + 1);
+                node.tree.delete(dNode);
             }
             //插入节点
             for(let perCheked of optionChecked){
                 let exist = false;
+                let subOpts = getOptions(perCheked, bills.tree.selected.elf.datas);
                 for(let subNode of node.children){
-                    if(subNode.data.ID === perCheked.ID){
-                        exist = true;
+                    for(let subOpt of subOpts){
+                        if(subNode.data.ID === subOpt.ID){
+                            exist = true;
+                            break;
+                        }
                     }
                 }
                 //不重复且不为定额时插入
                 if(!exist && perCheked.type !== itemType.ration){
-                    insertNodeByData(node, perCheked);
+                    insertNodeByData(node, perCheked);//这里递归,默认第一个
                 }
             }
             TREE_SHEET_HELPER.refreshTreeNodeData(elfItem.treeSetting, elfSheet, node.tree.items, false);
             setOptionsCellType(node.tree.items);
             refreshInsertRation();
         }
-        //获取删除节点信息
-        function getDeleteInfo(node, optionChecked) {
+        //获取删除节点
+        function getDeleteNodes(node, optionChecked) {
             let rst = [];
             for(let subNode of node.children){
                 let exist = false;
                 for(let perChecked of optionChecked){
-                    if(subNode.data.ID === perChecked.ID){
-                        exist = true;
+                    let subOpts = getOptions(perChecked, bills.tree.selected.elf.datas);
+                    for(let subOpt of subOpts){
+                        if(subNode.data.ID === subOpt.ID){
+                            exist = true;
+                            break;
+                        }
                     }
                 }
                 if(!exist){
-                    let deleteRow = subNode.serialNo(),
-                        deleteCount = subNode.posterityCount() + 1;
-                    rst.push({node: subNode, deleteRow: deleteRow, deleteCount: deleteCount});
+                    rst.push(subNode);
                 }
             }
             return rst;
         }
-        //插入单个节点,node:当前操作的节点
-        function insertNodeByData(node, data) {
-            let sameDepthNodes = node.children;
-            let insertNextSiblingID = -1,
-                insertParentID = node.data.ID;
-            data.options = getOptions(data, bills.tree.selected.elf.datas).length > 0 ? '请选择' : '';
-            //确定插入位置
-            for(let subNode of sameDepthNodes){
-                if(data.rank < subNode.data.rank){
-                   insertNextSiblingID = subNode.data.ID;
-                   break;
-                }
-            }
-            let newNode = node.tree.insertByData(data, insertParentID, insertNextSiblingID);
-            elfSheet.addRows(newNode.serialNo(), 1);
-            node.tree.selected = newNode;
-            elfSheet.setSelection(newNode.serialNo(), elfSheet.getSelections()[0].col, 1, 1);
-
-        }
         OptionsCellType.prototype = new GC.Spread.Sheets.CellTypes.Base();
 
         OptionsCellType.prototype.createEditorElement = function (context) {
@@ -951,16 +1019,24 @@ const billsGuidance = (function () {
         }
         if(!bills.tree.selected.elf){
             return [];
-        }
+    }
         let tree = bills.tree.selected.elf.tree;
         if(!tree){
             return [];
         }
         for(let node of tree.items){
-            if(node.children.length === 0 && node.data.optionChecked){//定额数据只能在最底层节点中
-                for(let perChecked of node.data.optionChecked){
-                    if(perChecked.type === itemType.ration){
-                        rst.push({itemQuery: {userID: userID, ID: perChecked.rationID}, rationType: rationType.ration});
+            for(let perChecked of node.data.optionChecked){
+                //选项直接是定额
+                if(perChecked.type === itemType.ration){
+                    rst.push({itemQuery: {userID: userID, ID: perChecked.rationID}, rationType: rationType.ration});
+                }
+                //选项下子选项是定额
+                else {
+                    let rationOpts = getOptions(perChecked, bills.tree.selected.elf.datas);
+                    for(let ration of rationOpts){
+                        if(ration.type === itemType.ration){
+                            rst.push({itemQuery: {userID: userID, ID: ration.rationID}, rationType: rationType.ration});
+                        }
                     }
                 }
             }

+ 10 - 16
web/over_write/js/chongqing_2018.js

@@ -46,6 +46,7 @@ if(typeof materialComponent !== 'undefined'){
 }
 
 // CSL, 2018-08-21 计算程序、基数 的覆盖。---------------------------------------------------------------------------------
+let isCQ2018 = true;
 baseMaterialTypes.push(gljType.OTHER_MATERIAL);
 allMaterialTypes.delete(gljType.EQUIPMENT);
 baseMachineTypes.delete(gljType.MACHINE_COMPOSITION);
@@ -85,7 +86,7 @@ function overwriteRationCalcBases (taxType){
         rationCalcBases['材料费价差'] = function (node, isTender) {
             return calcTools.rationBaseFee(node, baseMaterialTypes, priceTypes.ptDiffPrice, isTender);
         };
-        if (isJY){
+/*        if (isJY){
             rationCalcBases['计价材料价差'] = function (node, isTender) {
                 let baseMaterialTypesWithoutOtherMaterial = [
                     gljType.GENERAL_MATERIAL,
@@ -97,7 +98,7 @@ function overwriteRationCalcBases (taxType){
                 ];
                 return calcTools.rationBaseFee(node, baseMaterialTypesWithoutOtherMaterial, priceTypes.ptDiffPrice, isTender);
             };
-        };
+        };*/
         rationCalcBases['机上人工费价差'] = function (node, isTender) {
             return calcTools.rationBaseFee(node, [gljType.MACHINE_LABOUR], priceTypes.ptDiffPrice, isTender);
         };
@@ -109,32 +110,25 @@ function overwriteRationCalcBases (taxType){
                 return calcTools.rationBaseFee(node, [gljType.OTHER_MACHINE_USED], priceTypes.ptBasePrice, isTender);
             };
             rationCalcBases['机械折旧费'] = function (node, isTender) {
-                return calcTools.machineDetailFee(node, node.data.gljList, [], baseMachineMasterTypes,
-                    gljType.DEPRECIATION_FEE, isTender);
+                return calcTools.machineDetailFee(node, node.data.gljList, [], gljType.DEPRECIATION_FEE, isTender);
             };
             rationCalcBases['特大机械检修费'] = function (node, isTender) {
-                return calcTools.machineDetailFee(node, node.data.gljList, [1, 2], baseMachineMasterTypes,
-                    gljType.INSPECTION_FEE, isTender);
+                return calcTools.machineDetailFee(node, node.data.gljList, [1, 2], gljType.INSPECTION_FEE, isTender);
             };
             rationCalcBases['中小机械检修费'] = function (node, isTender) {
-                return calcTools.machineDetailFee(node, node.data.gljList, [3, 4], baseMachineMasterTypes,
-                    gljType.INSPECTION_FEE, isTender);
+                return calcTools.machineDetailFee(node, node.data.gljList, [3, 4], gljType.INSPECTION_FEE, isTender);
             };
             rationCalcBases['特大机械维护费'] = function (node, isTender) {
-                return calcTools.machineDetailFee(node, node.data.gljList, [1, 2], baseMachineMasterTypes,
-                    gljType.MAINTENANCE, isTender);
+                return calcTools.machineDetailFee(node, node.data.gljList, [1, 2], gljType.MAINTENANCE, isTender);
             };
             rationCalcBases['中小机械维护费'] = function (node, isTender) {
-                return calcTools.machineDetailFee(node, node.data.gljList, [3, 4], baseMachineMasterTypes,
-                    gljType.MAINTENANCE, isTender);
+                return calcTools.machineDetailFee(node, node.data.gljList, [3, 4], gljType.MAINTENANCE, isTender);
             };
             rationCalcBases['安拆费及场外运输费'] = function (node, isTender) {
-                return calcTools.machineDetailFee(node, node.data.gljList, [], baseMachineMasterTypes,
-                    gljType.DISMANTLING_FREIGHT_FEE, isTender);
+                return calcTools.machineDetailFee(node, node.data.gljList, [], gljType.DISMANTLING_FREIGHT_FEE, isTender);
             };
             rationCalcBases['燃料动力费'] = function (node, isTender) {
-                return calcTools.machineDetailFee(node, node.data.gljList, [], baseMachineMasterTypes,
-                    gljType.FUEL_POWER_FEE, isTender);
+                return calcTools.machineDetailFee(node, node.data.gljList, [], gljType.FUEL_POWER_FEE, isTender);
             };
             rationCalcBases['定额仪器仪表费'] = function (node, isTender) {
                 return calcTools.rationBaseFee(node, [gljType.INSTRUMENT], priceTypes.ptBasePrice, isTender);