chenshilong 6 年之前
父節點
當前提交
fbaa139866

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

@@ -573,18 +573,18 @@
                                           <div id="div_block_tree" style="height:400px;"></div>
                                   </div>
                                   <div class="resize" id="kmbkResize" style="background: #F1F1F1"></div>
-                                  <div class="sidebar-middle container-fluid">
-                                      <table class="table table-sm table-bordered">
+                                  <div class="sidebar-middle container-fluid" id="div_block_bill" style="height:90px;">
+<!--                                      <table class="table table-sm table-bordered">
                                           <tr><th>项目编码</th><th>项目名称</th><th>单位</th><th>综合单价</th><th>项目特征</th></tr>
                                           <tr><td>010202002</td><td>咬合灌注桩</td><td>m2</td><td>18732.38</td><td></td></tr>
-                                      </table>
+                                      </table>-->
                                   </div>
-                                  <div class="sidebar-bottom container-fluid">
-                                      <table class="table table-sm table-bordered">
+                                  <div class="sidebar-bottom container-fluid" id="div_block_ration" style="height:200px;">
+<!--                                      <table class="table table-sm table-bordered">
                                           <tr><th>编码</th><th>名称</th><th>单位</th><th>含量</th><th>取费专业</th><th>综合单价</th><th>子目换算状态</th></tr>
                                           <tr><td>AA0043</td><td>人工沟槽 软</td><td>1000</td><td>0.01</td><td>人工土石</td><td></td><td></td></tr>
                                           <tr><td>AA0046</td><td>人工沟槽 硬</td><td>1000</td><td>0.21</td><td>人工土石</td><td></td><td></td></tr>
-                                      </table>
+                                      </table>-->
                                   </div>
                               </div>
                           </div>

+ 84 - 28
web/building_saas/main/js/views/block_lib.js

@@ -1,4 +1,5 @@
 /**
+ * 块模板库管理。
  * Created by CSL on 2018-09-19.
  */
 var blockLibObj = {
@@ -34,23 +35,66 @@ var blockLibObj = {
         }]
     },
     mainDatas: [],
+    billSpread: null,
+    billSheet: null,
+    billSetting: {
+        header: [
+            {headerName: "项目编码", headerWidth: 90, dataCode: "code", dataType: "String", hAlign: "center"},
+            {headerName: "项目名称", headerWidth: 100, dataCode: "name", dataType: "String"},
+            {headerName: "单位", headerWidth: 40, dataCode: "unit", dataType: "String", hAlign: "center"},
+            {headerName: "综合单价", headerWidth: 60, dataCode: "quantity", dataType: "Number"},
+            {headerName: "项目特征", headerWidth: 120, dataCode: "itemCharacterText", dataType: "String"}
+        ],
+        view: {
+            lockColumns: [0, 1, 2, 3, 4]
+        }
+    },
+    rationSpread: null,
+    rationSheet: null,
+    rationSetting: {
+        header: [
+            {headerName: "编码", headerWidth: 45, dataCode: "code", dataType: "String", hAlign: "center"},
+            {headerName: "名称", headerWidth: 100, dataCode: "name", dataType: "String"},
+            {headerName: "单位", headerWidth: 40, dataCode: "unit", dataType: "String", hAlign: "center"},
+            {headerName: "含量", headerWidth: 40, dataCode: "contain", dataType: "Number"},
+            {headerName: "取费专业", headerWidth: 60, dataCode: "programID", dataType: "Number"},
+            {headerName: "综合单价", headerWidth: 60, dataCode: "quantity", dataType: "Number"},
+            {headerName: "子目换算状态", headerWidth: 90, dataCode: "adjustState", dataType: "String"}
+        ],
+        view: {
+            lockColumns: [0, 1, 2, 3, 4, 5, 6]
+        }
+    },
+
     buildSheet: function () {
         $.bootstrapLoading.start();
         let me = this;
         me.mainDatas = [
+            {ID: 1, ParentID: -1, NextSiblingID: 2, name: '分类1', type: 1},
             {ID: 2, ParentID: -1, NextSiblingID: 3, name: '分类2', type: 1},
-            {ID: 3, ParentID: -1, NextSiblingID: -1, name: '分类3', type: 1},
-            {ID: 6, ParentID: 2, NextSiblingID: 7, name: '块1', type: 2},
-            {ID: 7, ParentID: 2, NextSiblingID: -1, name: '块2', type: 2},
-            {ID: 52, ParentID: -1, NextSiblingID: 53, name: '分类52', type: 1},
-            {ID: 55, ParentID: -1, NextSiblingID: -1, name: '分类55', type: 1},
-            {ID: 88, ParentID: 52, NextSiblingID: -1, name: '块88', type: 2}
+            {ID: 3, ParentID: -1, NextSiblingID: 4, name: '分类3', type: 1},
+            // {ID: 105, ParentID: 1, NextSiblingID: 106, name: '块1', type: 2},
+            // {ID: 106, ParentID: 1, NextSiblingID: 107, name: '块2', type: 2},
+            {ID: 7, ParentID: -1, NextSiblingID: 8, name: '分类7', type: 1},
+            {ID: 9, ParentID: -1, NextSiblingID: -1, name: '分类9', type: 1}//,
+            // {ID: 201, ParentID: 52, NextSiblingID: -1, name: '块201', type: 2}
         ];
 
         if (me.mainSpread) {
             me.mainSpread.destroy();
             me.mainSpread = null;
         };
+
+        if (me.billSpread) {
+            me.billSpread.destroy();
+            me.billSpread = null;
+        };
+
+        if (me.rationSpread) {
+            me.rationSpread.destroy();
+            me.rationSpread = null;
+        };
+
         me.mainSpread = SheetDataHelper.createNewSpread($('#div_block_tree')[0]);
         // me.mainSpread = TREE_SHEET_HELPER.createNewSpread($('#div_block_tree')[0]);
         me.mainSheet = me.mainSpread.getSheet(0);
@@ -65,14 +109,9 @@ var blockLibObj = {
             me.mainTreeController.showTreeData();
             me.mainSheet.getRange(-1, 0, -1, 1).cellType(me.getTreeCell(me.mainTree));
             me.mainTree.selected = me.mainTree.items[0];
-/*            me.mainTreeController.bind(TREE_SHEET_CONTROLLER.eventName.treeSelectedChanged, function (node) {
-                rationLibObj.loadSectionRations(node && node.children.length === 0 ? node.getID() : null);
+            me.mainTreeController.bind(TREE_SHEET_CONTROLLER.eventName.treeSelectedChanged, function (node) {
+                blockLibObj.loadDetailDatas(node);
             });
-            if (me.mainTree.firstNode() && me.mainTree.firstNode().length === 0) {
-                rationLibObj.loadSectionRations(me.mainTree.firstNode().getID());
-            } else {
-                rationLibObj.loadSectionRations();
-            };*/
         };
 
 /*        CommonAjax.post('/complementaryRation/api/getRationTree', {userId: userID, rationRepId: rationLibID}, function (datas) {
@@ -84,8 +123,36 @@ var blockLibObj = {
         });*/
 
         showblockTree(me.mainDatas);
+
+        me.billSpread = sheetCommonObj.buildSheet($('#div_block_bill')[0], me.billSetting, 1);
+        me.billSheet = me.billSpread.getSheet(0);
+        sheetCommonObj.spreadDefaultStyle(me.billSpread);
+
+        me.rationSpread = sheetCommonObj.buildSheet($('#div_block_ration')[0], me.rationSetting, 1);
+        me.rationSheet = me.rationSpread.getSheet(0);
+        sheetCommonObj.spreadDefaultStyle(me.rationSpread);
+
         $.bootstrapLoading.end();
     },
+    loadDetailDatas: function (node){
+        let me = this;
+        if (node.data.type == 2){
+            let sourceNode = node.data.sourceNode;
+            let rations = sourceNode.children;
+            let rationDatas = [];
+            for (let r of rations){
+                rationDatas.push(r.data);
+            };
+            sheetCommonObj.showData(me.billSheet, me.billSetting, [sourceNode.data]);
+            let rCount = (rationDatas.length > 0) ? rationDatas.length : 1;
+            me.rationSheet.setRowCount(rCount, GC.Spread.Sheets.SheetArea.viewport);
+            sheetCommonObj.showData(me.rationSheet, me.rationSetting, rationDatas);
+        }
+        else{
+            sheetCommonObj.cleanSheet(me.billSheet, me.billSetting, 1);
+            sheetCommonObj.cleanSheet(me.rationSheet, me.rationSetting, 1);
+        }
+    },
     getTreeCell: function (tree) {
         let me = this;
         let indent = 20, levelIndent = -5, halfBoxLength = 5, halfExpandLength = 3, imgWidth = 14, imgHeight = 14;
@@ -285,11 +352,10 @@ var blockLibObj = {
         };
         return new TreeCell();
     },
-    newNode: function (nodeType, nodeName, categoryID){     // 1 分类  2 块文件
+    newNode: function (nodeType, nodeName, categoryID, sourceNode){     // 1 分类(只用前两个参数)  2 块文件
         let tree = blockLibObj.mainTree;
         let pID = -1, nID = -1;
         let select = tree.selected;
-        let newNode = null;
         if (nodeType == 1){
             if (!select) {
                 nID = -1;
@@ -302,24 +368,15 @@ var blockLibObj = {
             };
         }
         else if (nodeType == 2) {
-/*            if (!select) {
-                pID = tree.items[0].getID();
-            }
-            else if (select.data.type == 1){
-                pID = select.getID();
-            }
-            else if (select.data.type == 2){
-                pID = select.getParentID();
-                nID = select.getNextSiblingID();
-            };*/
-
             pID = categoryID;
             nID = -1;
         }
 
-        newNode = tree.insert(pID, nID);
+        let newNode = tree.insert(pID, nID);
         newNode.data.type = nodeType;
         newNode.data.name = nodeName;
+        if (nodeType == 2)
+            newNode.data.sourceNode = sourceNode;
         tree.selected = newNode;
 
         let sheet = blockLibObj.mainSheet;
@@ -370,7 +427,6 @@ $(document).ready(function(){
 
     $('#btn_block_reName').on('click', function (){
         let select = blockLibObj.mainTree.selected;
-        // $('#lbl_block_reName').text(select.data.name);
         $('#input_block_reName').val(select.data.name);
     });
 

+ 2 - 1
web/building_saas/main/js/views/project_view.js

@@ -2899,7 +2899,7 @@ $(function () {
                 if (node.data.name == undefined || node.data.name == '') return;  // 清单名称为空,不生成块模板文件
                 let name = node.data.code + ' ' + node.data.name + ' ' + node.data.unit;
                 name = name.replace(/^\s+|\s+$/g, "");    // 只去两头空格
-                blockLibObj.newNode(2, name, categoryID);
+                blockLibObj.newNode(2, name, categoryID, node);
             };
 
             function createRecursion(node){
@@ -2918,6 +2918,7 @@ $(function () {
         };
 
         createBlocks(selected, cID);
+        blockLibObj.loadDetailDatas(blockLibObj.mainTree.selected);
         $("#zujiamb").modal("hide");
     });