浏览代码

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

zhangweicheng 6 年之前
父节点
当前提交
2ce6f10b40

+ 19 - 19
web/building_saas/main/html/main.html

@@ -39,8 +39,8 @@
         let userAccount = '<%- userAccount %>';
         let userID = '<%- userID %>';
         let projectReadOnly = JSON.parse('<%- projectReadOnly %>');
-//        const G_SHOW_BLOCK_LIB = true;
-        const G_SHOW_BLOCK_LIB = false;
+        const G_SHOW_BLOCK_LIB = true;
+//        const G_SHOW_BLOCK_LIB = false;
     </script>
 </head>
 
@@ -1760,7 +1760,7 @@
         </div>
     </div>
     <!--弹出 生成组价模板-->
-    <div class="modal fade" id="zujiamb" data-backdrop="static">
+    <div class="modal fade" id="div_createBlocks" data-backdrop="static">
         <div class="modal-dialog" role="document">
             <div class="modal-content">
                 <div class="modal-header">
@@ -1777,7 +1777,7 @@
                     <div class="form-group">
                         <div class="form-check form-check-inline">
                             <input class="form-check-input" type="checkbox" name="inlineRadioOptions" id="ckb_block_exist_cover" value="option1">
-                            <label class="form-check-label" for="ckb_block_exist_cover">当存在同名模板时,提示是否覆盖</label>
+                            <label class="form-check-label" for="ckb_block_exist_cover">当存在同名模板时覆盖</label>
                         </div>
                     </div>
                 </div>
@@ -1789,7 +1789,7 @@
         </div>
     </div>
     <!--弹出 匹配原则-->
-    <div class="modal fade" id="blockAdjustOptions" data-backdrop="static">
+    <div class="modal fade" id="div_cloneOptions" data-backdrop="static">
         <div class="modal-dialog" role="document">
             <div class="modal-content">
                 <div class="modal-header">
@@ -1803,16 +1803,16 @@
                         <label>选择匹配模式:</label>
                         <div>
                             <div class="form-check form-check-inline">
-                                <input class="form-check-input" type="checkbox" name="inlineRadioOptions" id="inlinecheckbox1" value="option1" checked>
-                                <label class="form-check-label" for="inlinecheckbox1">项目编码(前9位)</label>
+                                <input class="form-check-input" type="checkbox" id="clone_option_code" value="option1" checked>
+                                <label class="form-check-label" for="clone_option_code">项目编码(前9位)</label>
                             </div>
                             <div class="form-check form-check-inline">
-                                <input class="form-check-input" type="checkbox" name="inlineRadioOptions" id="inlinecheckbox2" value="option2">
-                                <label class="form-check-label" for="inlinecheckbox2">项目名称</label>
+                                <input class="form-check-input" type="checkbox" id="clone_option_name" value="option2">
+                                <label class="form-check-label" for="clone_option_name">项目名称</label>
                             </div>
                             <div class="form-check form-check-inline">
-                                <input class="form-check-input" type="checkbox" name="inlineRadioOptions" id="inlinecheckbox3" value="option3" checked>
-                                <label class="form-check-label" for="inlinecheckbox3">单位</label>
+                                <input class="form-check-input" type="checkbox" id="clone_option_unit" value="option3" checked>
+                                <label class="form-check-label" for="clone_option_unit">单位</label>
                             </div>
                         </div>
                     </div>
@@ -1820,12 +1820,12 @@
                         <label for="exampleInputPassword1">插入为选定节点的:</label>
                         <div>
                             <div class="form-check form-check-inline">
-                                <input class="form-check-input" type="radio" name="rationQuantity" id="inlineRadio21" value="option1" checked>
-                                <label class="form-check-label" for="inlineRadio21">根据含量计算定额工程量</label>
+                                <input class="form-check-input" type="radio" name="rationQuantity" id="clone_option_quantity" value="option1" checked>
+                                <label class="form-check-label" for="clone_option_quantity">根据含量计算定额工程量</label>
                             </div>
                             <div class="form-check form-check-inline">
-                                <input class="form-check-input" type="radio" name="rationQuantity" id="inlineRadio22" value="option2">
-                                <label class="form-check-label" for="inlineRadio22">含量和定额工程量为零</label>
+                                <input class="form-check-input" type="radio" name="rationQuantity" id="clone_option_zeroQuantity" value="option2">
+                                <label class="form-check-label" for="clone_option_zeroQuantity">含量和定额工程量为零</label>
                             </div>
                         </div>
                     </div>
@@ -1833,12 +1833,12 @@
                         <label for="exampleInputPassword1">清单下有定额时:</label>
                         <div>
                             <div class="form-check form-check-inline">
-                                <input class="form-check-input" type="radio" name="rationCover" id="inlineRadio33" value="option3" checked>
-                                <label class="form-check-label" for="inlineRadio33">跳过不覆盖</label>
+                                <input class="form-check-input" type="radio" name="rationCover" id="clone_option_noCover" value="option3" checked>
+                                <label class="form-check-label" for="clone_option_noCover">跳过不覆盖</label>
                             </div>
                             <div class="form-check form-check-inline">
-                                <input class="form-check-input" type="radio" name="rationCover" id="inlineRadio32" value="option2">
-                                <label class="form-check-label" for="inlineRadio32">直接覆盖</label>
+                                <input class="form-check-input" type="radio" name="rationCover" id="clone_option_overwriteRations" value="option2">
+                                <label class="form-check-label" for="clone_option_overwriteRations">直接覆盖</label>
                             </div>
                         </div>
                     </div>

+ 1 - 1
web/building_saas/main/js/controllers/block_controller.js

@@ -242,7 +242,7 @@ let BlockController = {
         if(blockData.firstNodeType == blockType.RATION){ //复制的是定额,需根据新的父项信息和工程量明细计算工程量
             for(let d of blockData.datas){
                 d.billsItemID = parentID;
-                if (blockData.zeroRationQuantity){
+                if (blockData.zeroQuantity){   // 来自克隆块
                     d.quantity = 0;
                     d.quantityEXP = '';
                     d.contain = '';

+ 62 - 39
web/building_saas/main/js/views/block_lib.js

@@ -364,49 +364,48 @@ var blockLibObj = {
             nID = -1;
         }
 
-        let newNode = tree.insert(pID, nID);
-        newNode.data.type = nodeType;
-        newNode.data.nodeName = nodeName;
-        if (nodeType == 2){
-            let bill = source.datas[0];
-            newNode.data.compilationID = source.compilationID;
-            newNode.data.copyTime = source.copyTime;
-            newNode.data.firstNodeType = source.firstNodeType;
-            newNode.data.isFBFX = source.isFBFX;
-
-            newNode.data.code = bill.code;
-            newNode.data.name = bill.name;
-            newNode.data.unit = bill.unit;
-            newNode.data.itemCharacterText = bill.itemCharacterText;
-            newNode.data.unitFee = (bill.feesIndex && bill.feesIndex.common) ? bill.feesIndex.common.unitFee : 0;
-            newNode.data.children = bill.children;
-
-            for (let r of bill.children){
-                r.unitFee =  (r.feesIndex && r.feesIndex.common) ? r.feesIndex.common.unitFee : 0;
-                if (r.programID)
-                    r.programName = projectObj.project.calcProgram.compiledTemplateMaps[r.programID];
-                // delete r.ID;         // 这个不能删!
-                delete r.billsItemID;
-                delete r.fees;
-                delete r.feesIndex;
-            };
-        }
-
-        tree.selected = newNode;
+        let newN = tree.insert(pID, nID);
+        newN.data.type = nodeType;
+        newN.data.nodeName = nodeName;
+        if (nodeType == 2)
+            blockLibObj.assignData(newN, source);
 
+        tree.selected = newN;
         let sheet = blockLibObj.mainSheet;
         sheet.suspendPaint();
         sheet.suspendEvent();
-
-        let idx = tree.items.indexOf(newNode);
+        let idx = tree.items.indexOf(newN);
         sheet.addRows(idx, 1);
         sheet.getRange(idx, 0, 1, 1).locked(true);
-        sheet.setValue(idx, 0, newNode.data.nodeName);
+        sheet.setValue(idx, 0, newN.data.nodeName);
         sheet.setSelection(idx, 0, 1, 1);
-
         sheet.resumeEvent();
         sheet.resumePaint();
     },
+    assignData: function (block, source){
+        block.data.compilationID = source.compilationID;
+        block.data.copyTime = source.copyTime;
+        block.data.firstNodeType = source.firstNodeType;
+        block.data.isFBFX = source.isFBFX;
+
+        let bill = source.datas[0];
+        block.data.code = bill.code;
+        block.data.name = bill.name;
+        block.data.unit = bill.unit;
+        block.data.itemCharacterText = bill.itemCharacterText;
+        block.data.unitFee = (bill.feesIndex && bill.feesIndex.common) ? bill.feesIndex.common.unitFee : 0;
+        block.data.children = bill.children;
+
+        for (let r of bill.children){
+            r.unitFee =  (r.feesIndex && r.feesIndex.common) ? r.feesIndex.common.unitFee : 0;
+            if (r.programID)
+                r.programName = projectObj.project.calcProgram.compiledTemplateMaps[r.programID];
+            // delete r.ID;         // 这个不能删!
+            delete r.billsItemID;
+            delete r.fees;
+            delete r.feesIndex;
+        };
+    },
     reName: function (node, newName){
         if (newName == '') return;
         node.data.nodeName = newName;
@@ -434,6 +433,18 @@ var blockLibObj = {
     curIsCategory: function () {
         return this.mainTree.selected.data.type == 1;
     },
+    getSameNameNode: function(name){
+        let rst = null;
+        let nodes = blockLibObj.mainTree.items;
+        for (let i = 0; i < nodes.length; i++) {
+            let node = nodes[i];
+            if (node.data.nodeName == name){
+                rst = node;
+                break;
+            }
+        }
+        return rst;
+    },
     refreshSpread: function (){
         if (this.mainSpread)
             this.mainSpread.refresh();
@@ -533,18 +544,30 @@ var blockLibObj = {
     onCellDoubleClick: function (sender, args) {
         let projectNode = projectObj.project.mainTree.selected;
         if (!calcTools.isLeafBill(projectNode)) return;
-        $("#blockAdjustOptions").modal({show: true});
+        $("#div_cloneOptions").modal({show: true});
     },
-    oneToOneClone: function (projectNode, block) {
-        // 这里再次封装成伟城的块文件格式,可直接使用伟城的“粘贴块”接口。
-        // 这里结构作出调整:忽略叶子清单层,直接从定额开始(跟粘贴块有区别),始终强制在叶子清单下插入定额。
-        // 该操作前提:当前块文件的全部数据已从后台取到前台。
+    oneToOneClone: function (projectNode, block, options) {
+        // if (options.overwriteRations)
+        //     projectNode.deleteChildren();
+
+        let canClone = true;
+        if (options.checkCode)
+            canClone = canClone && (projectNode.data.code.substr(0, 9) == block.data.code.substr(0, 9));
+        if (options.checkName)
+            canClone = canClone && (projectNode.data.name == block.data.name);
+        if (options.checkUnit)
+            canClone = canClone && (projectNode.data.unit == block.data.unit);
+        if (!canClone) return;
+
+        /*  这里封装成伟城的块文件格式,可直接使用伟城的“粘贴块”接口。
+            但这里结构要作出调整:忽略叶子清单层,直接从定额开始(跟粘贴块有区别),始终强制在叶子清单下插入定额。
+            该操作前提:当前块文件的全部数据已从后台取到前台。  */
         let vBlock_WC = {
             compilationID: block.data.compilationID,
             copyTime: block.data.copyTime,
             firstNodeType: 1,           // 强制改成1 (因为是从清单下的定额开始。清单自身的还是保留,暂不使用使用)。
             isFBFX: block.data.isFBFX,
-            zeroRationQuantity: true,
+            zeroQuantity: options.zeroQuantity,
             datas: block.data.children       // rations
         };
         BlockController.confirmPaste(vBlock_WC, projectNode, 'sub');

+ 26 - 8
web/building_saas/main/js/views/project_view.js

@@ -1512,7 +1512,7 @@ var projectObj = {
                         if (!$("#kmbk").is(":visible")){
                             $('#blockLibTab').click()
                         };
-                        $("#zujiamb").modal({show: true});
+                        $("#div_createBlocks").modal({show: true});
                     },
                     visible: function(key, opt){
                         return G_SHOW_BLOCK_LIB;
@@ -2934,7 +2934,7 @@ $(function () {
 
     });
 
-    $("#zujiamb").on('show.bs.modal', function(){
+    $("#div_createBlocks").on('show.bs.modal', function(){
         function getBlockCategoriesHtml(Categories) {
             let result = '';
             if (Categories.length <= 0) return result;
@@ -2948,17 +2948,22 @@ $(function () {
         let sHtml = getBlockCategoriesHtml(blockLibObj.getCategories());
         $("#select_block_category").html(sHtml);
         $("#select_block_category")[0].selectedIndex = 0;
+        $('#ckb_block_exist_cover').prop("checked", false);
     });
 
-    $("#blockAdjustOptions").on('show.bs.modal', function(){
-
+    $("#div_cloneOptions").on('show.bs.modal', function(){
+        $('#clone_option_code').prop("checked", true);
+        $('#clone_option_name').prop("checked", false);
+        $('#clone_option_unit').prop("checked", true);
+        $('#clone_option_quantity').prop("checked", true);
+        $('#clone_option_noCover').prop("checked", true);
     });
 
     $("#btn_block_createBlocks").click(function () {
         if ($("#select_block_category")[0].options.length < 1) return;
         let cID = $("#select_block_category").val();
         let selected = projectObj.project.mainTree.selected;
-
+        let cover = $('#ckb_block_exist_cover').prop("checked");
         function createBlocks(aNode, categoryID){
             function createBlock(node) {
                 if (node.data.name == undefined || node.data.name == '') return;  // 清单名称为空,不生成块模板文件
@@ -2977,7 +2982,13 @@ $(function () {
 
                 let fileName = node.data.code + ' ' + node.data.name + ' ' + node.data.unit;
                 fileName = fileName.replace(/^\s+|\s+$/g, "");    // 只去两头空格
-                blockLibObj.newNode(2, fileName, categoryID, block_WC);
+
+                let extN = blockLibObj.getSameNameNode(fileName);
+                if (extN){
+                    if (cover) blockLibObj.assignData(extN, block_WC);
+                }
+                else
+                    blockLibObj.newNode(2, fileName, categoryID, block_WC);
             };
 
             function createRecursion(node){
@@ -2997,13 +3008,20 @@ $(function () {
 
         createBlocks(selected, cID);
         blockLibObj.loadDetailDatas(blockLibObj.mainTree.selected);
-        $("#zujiamb").modal("hide");
+        $("#div_createBlocks").modal("hide");
     });
 
     $("#btn_block_clone_ok").click(function () {
         let projectNode = projectObj.project.mainTree.selected;
         let block = blockLibObj.mainTree.selected;
-        blockLibObj.oneToOneClone(projectNode, block);
+        let options = {};
+        if ($('#clone_option_code').prop("checked")) options.checkCode = true;
+        if ($('#clone_option_name').prop("checked")) options.checkName = true;
+        if ($('#clone_option_unit').prop("checked")) options.checkUnit = true;
+        if ($('#clone_option_zeroQuantity').prop("checked")) options.zeroQuantity = true;
+        if ($('#clone_option_overwriteRations').prop("checked")) options.overwriteRations = true;
+
+        blockLibObj.oneToOneClone(projectNode, block, options);
     });