瀏覽代碼

show RationLib & StdBillsLib by selected in project

MaiXinRong 8 年之前
父節點
當前提交
0d66de8f53

+ 1 - 1
lib/global.js

@@ -5,7 +5,7 @@ function autoFlashHeight(){
     var bottomContentHeight = $(".bottom-content").height();
     var sidebarToolsBarHeight = $(".sidebar-tools-bar").height();
     $(".main-data-side-f").height($(window).height()-headerHeight-toolsbarHeight-2);
-    $(".main-data-side-s").height($(window).height()-headerHeight-toolsbarHeight-sidebarToolsBarHeight-2);
+    $(".main-data-side-s").height($(window).height()-headerHeight-toolsbarHeight-sidebarToolsBarHeight-202);
     $(".main-data-top").height($(window).height()-headerHeight-toolsbarHeight-bottomContentHeight-1);
     $(".main-data-full").height($(window).height()-headerHeight-toolsbarHeight-1);
     $(".side-content").height($(window).height()-headerHeight );

+ 28 - 0
public/web/common_ajax.js

@@ -24,6 +24,34 @@ var CommonAjax = {
                 }
             },
             error: function(jqXHR, textStatus, errorThrown){
+                alert('url: ' + url +' error ' + textStatus + " " + errorThrown);
+                if (errorCallback) {
+                    errorCallback();
+                }
+            }
+        });
+    },
+    postRationLib: function (url, data, successCallback, errorCallback) {
+        $.ajax({
+            type:"POST",
+            url: url,
+            data: data,
+            dataType: 'json',
+            cache: false,
+            timeout: 50000,
+            success: function(result){
+                if (!result.error) {
+                    if (successCallback) {
+                        successCallback(result.data);
+                    }
+                } else {
+                    alert('error: ' + result.message);
+                    if (errorCallback) {
+                        errorCallback();
+                    }
+                }
+            },
+            error: function(jqXHR, textStatus, errorThrown){
                 alert('error ' + textStatus + " " + errorThrown);
                 if (errorCallback) {
                     errorCallback();

+ 12 - 4
public/web/idTree.js

@@ -66,7 +66,6 @@ var idTree = {
                     nodes[i].nextSibling = (i === nodes.length - 1) ? null : nodes[i + 1];
                 }
             },
-            // ��nodes�У���iIndex����������ʼȫ���Ƴ�
             // 在nodes中,从iIndex(包括)开始全部移除
             removeNodes: function (tree, parent, iIndex, count) {
                 var children = parent ? parent.children : tree.roots;
@@ -85,7 +84,6 @@ var idTree = {
                     children.splice(iIndex, children.length - iIndex);
                 }
             },
-            // ��nodes������addNodes, λ�ô�index��ʼ
             // 在parent.children/tree.roots中增加nodes, 位置从index开始
             addNodes: function (tree, parent, nodes, iIndex) {
                 var children = parent ? parent.children : tree.roots;
@@ -139,7 +137,6 @@ var idTree = {
         };
 
         var Node = function (tree, data) {
-            // ���µ����ԣ�����Ԫ�������ֱ���޸�
             // 以下的属性,本单元外均不可直接修改
             this.tree = tree;
             this.data = data;
@@ -442,8 +439,19 @@ var idTree = {
             }*/
         };
 
+        Tree.prototype.clearNodes = function () {
+            this.nodes = {};
+            this.roots = [];
+            this.items = [];
+        };
+
         Tree.prototype.loadDatas = function (datas) {
             var prefix = this.prefix, i, node, parent, next, that = this;
+
+            this.nodes = {};
+            this.roots = [];
+            this.items = [];
+
             // prepare index
             datas.forEach(function (data) {
                 var node = new Node(that, data);
@@ -594,7 +602,7 @@ var idTree = {
                 }
             }
             return data;
-        }
+        };
 
         /*Tree.prototype.editedData = function (field, id, newText) {
             var node = this.findNode(id), result = {allow: false, nodes: []};

+ 10 - 2
public/web/tree_sheet_controller.js

@@ -9,7 +9,8 @@ var TREE_SHEET_CONTROLLER = {
             this.sheet = sheet;
             this.setting = setting;
             this.event = {
-                refreshBaseActn: null
+                refreshBaseActn: null,
+                treeSelectedChanged: null
             };
             TREE_SHEET_HELPER.loadSheetHeader(this.setting, this.sheet);
         };
@@ -36,7 +37,7 @@ var TREE_SHEET_CONTROLLER = {
                         TREE_SHEET_HELPER.refreshTreeNodeData(that.setting, that.sheet, [newNode], false);
                         that.setTreeSelected(newNode);
                         that.sheet.setSelection(newNode.serialNo(), sels[0].col, 1, 1);
-                        that.sheet.showRow(newNode.serialNo(), GC.Spread.Sheets.VerticalPosition.center)
+                        that.sheet.showRow(newNode.serialNo(), GC.Spread.Sheets.VerticalPosition.center);
                     });
                 }
             }
@@ -121,6 +122,9 @@ var TREE_SHEET_CONTROLLER = {
             if (this.event.refreshBaseActn) {
                 this.event.refreshBaseActn(this.tree);
             }
+            if (this.event.treeSelectedChanged) {
+                this.event.treeSelectedChanged(this.tree.selected);
+            }
         }
 
         controller.prototype.bind = function (eventName, eventFun) {
@@ -128,5 +132,9 @@ var TREE_SHEET_CONTROLLER = {
         };
 
         return new controller();
+    },
+    eventName: {
+        refreshBaseActn: 'refreshBaseActn',
+        treeSelectedChanged: 'treeSelectedChanged'
     }
 };

+ 1 - 1
public/web/tree_sheet_helper.js

@@ -24,7 +24,7 @@ var TREE_SHEET_HELPER = {
             for (i = 0; i < col.head.spanCols.length; i++) {
                 if (col.head.spanCols[i] !== 0) {
                     cell = sheet.getCell(iRow, index, GC.Spread.Sheets.SheetArea.colHeader);
-                    cell.value(col.head.titleNames[i]).font(col.head.font).hAlign(col.head.hAlign[i]).vAlign(col.head.vAlign[i]);
+                    cell.value(col.head.titleNames[i]).font(col.head.font).hAlign(col.head.hAlign[i]).vAlign(col.head.vAlign[i]).wordWrap(col.head.wordWrap);
                 }
                 if (col.head.spanCols[i] > 1 || col.head.spanRows[i] > 1) {
                     sheet.addSpan(iRow, index, col.head.spanRows[i], col.head.spanCols[i], GC.Spread.Sheets.SheetArea.colHeader);

+ 1 - 2
public/web/urlUtil.js

@@ -5,7 +5,6 @@ var scUrlUtil = {
     GetQueryString: function (name) {
         var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
         var r = window.location.search.substr(1).match(reg);
-        if (r != null) return unescape(r[2]);
-        return null;
+        return r ?  unescape(r[2]) : null;
     }
 };

+ 9 - 2
web/css/main.css

@@ -1,7 +1,8 @@
 /*building SAAS 0.1*/
 /*bootstrap 初始化*/
 body {
-    font-size: 0.9rem
+    font-size: 0.9rem;
+    overflow: hidden;
 }
 .dropdown-menu {
     font-size: 0.9rem
@@ -80,7 +81,10 @@ body {
 .main-side {
     border-top: 1px solid #ccc;
     border-left: 1px solid #ccc;
-    overflow-y: auto;
+    overflow-y: hidden;
+}
+.sidebar-bottom,.sidebar-bottom .col-lg-6,.sidebar-bottom .col-lg-12 {
+  height:200px
 }
 .top-content, .fluid-content {
     overflow: auto;
@@ -211,6 +215,9 @@ body {
     height: 200px;
     overflow: auto;
 }
+.bottom-content .tab-content .ovf-hidden{
+    overflow: hidden;
+}
 .form-signin {
     max-width: 500px;
     margin: 150px auto;

+ 61 - 98
web/main/html/main.html

@@ -13,6 +13,8 @@
     <link rel="stylesheet" href="web/css/ztree/zTreeStyle.css" type="text/css">
     <!--SpreadJs-->
     <link rel="stylesheet" href="web/css/spreadjs/gc.spread.sheets.excel2013lightGray.10.0.1.css" type="text/css">
+    <script src="lib/jquery/jquery.min.js"></script>
+    <script src="lib/global.js"></script>
     <script>
         // 这里的变量供页面调用
         var userAccount = '<%- userAccount %>';
@@ -111,7 +113,7 @@
                               <a class="nav-link active px-3" data-toggle="tab" href="#qd" role="tab">清单规则</a>
                           </li>
                           <li class="nav-item">
-                              <a class="nav-link px-3" data-toggle="tab" href="#de" role="tab">定额库</a>
+                              <a class="nav-link px-3" data-toggle="tab" href="#de" role="tab" id="stdRationTab">定额库</a>
                           </li>
                       </ul>
                   </div>
@@ -119,75 +121,8 @@
               <div class="container-fluid">
                   <div class="row">
                       <div class="main-content col-lg-9 p-0">
-                          <div class="top-content" id="billsSpread">
-                              <!--<div class="warp-p2">-->
-                                  <!--&lt;!&ndash;<table class="table table-sm table-bordered m-0">-->
-                                      <!--<thead>-->
-                                          <!--<th>序号</th>-->
-                                          <!--<th>项目编码</th>-->
-                                          <!--<th>类别</th>-->
-                                          <!--<th>项目名称</th>-->
-                                          <!--<th>计量单位</th>-->
-                                          <!--<th>项目特征</th>-->
-                                          <!--<th>工作内容</th>-->
-                                          <!--<th>工程专业</th>-->
-                                          <!--<th>取费专业</th>-->
-                                          <!--<th>工程量计算规则</th>-->
-                                          <!--<th>工程量</th>-->
-                                          <!--<th>单价</th>-->
-                                          <!--<th>合价</th>-->
-                                          <!--<th>综合单价</th>-->
-                                          <!--<th>综合合价的公式</th>-->
-                                          <!--<th>综合合价</th>-->
-                                          <!--<th>人工费单价</th>-->
-                                          <!--<th>机械费单价</th>-->
-                                          <!--<th>主材费单价</th>-->
-                                          <!--<th>设备费单价</th>-->
-                                          <!--<th>企业管理费单价</th>-->
-                                          <!--<th>利润单价</th>-->
-                                          <!--<th>风险费单价</th>-->
-                                          <!--<th>人工价差单价</th>-->
-                                          <!--<th>材料价差单价</th>-->
-                                          <!--<th>机械价差单价</th>-->
-                                          <!--<th>是否暂估</th>-->
-                                          <!--<th>备注</th>-->
-                                          <!--<th>局部汇总</th>-->
-                                      <!--</thead>-->
-                                      <!--<tbody>-->
-                                          <!--<tr>-->
-                                              <!--<td>1</td>-->
-                                              <!--<td></td>-->
-                                              <!--<td></td>-->
-                                              <!--<td></td>-->
-                                              <!--<td></td>-->
-                                              <!--<td></td>-->
-                                              <!--<td></td>-->
-                                              <!--<td></td>-->
-                                              <!--<td></td>-->
-                                              <!--<td></td>-->
-                                              <!--<td></td>-->
-                                              <!--<td></td>-->
-                                              <!--<td></td>-->
-                                              <!--<td></td>-->
-                                              <!--<td></td>-->
-                                              <!--<td></td>-->
-                                              <!--<td></td>-->
-                                              <!--<td></td>-->
-                                              <!--<td></td>-->
-                                              <!--<td></td>-->
-                                              <!--<td></td>-->
-                                              <!--<td></td>-->
-                                              <!--<td></td>-->
-                                              <!--<td></td>-->
-                                              <!--<td></td>-->
-                                              <!--<td></td>-->
-                                              <!--<td></td>-->
-                                              <!--<td></td>-->
-                                              <!--<td></td>-->
-                                          <!--</tr>-->
-                                      <!--</tbody>-->
-                                  <!--</table>&ndash;&gt;-->
-                              <!--</div>-->
+                          <div class="top-content">
+                              <div class="main-data-top" id="billsSpread"></div>
                           </div>
                           <div class="bottom-content">
                               <ul class="nav nav-tabs" role="tablist">
@@ -216,7 +151,7 @@
                               <!-- Tab panes -->
                               <div class="tab-content">
                                   <div class="tab-pane active" id="gl" role="tabpanel">
-                                      <div class="warp-p2" id="gljSpread">
+                                      <div class="main-data-bottom ovf-hidden" id="gljSpread">
                                       </div>
                                   </div>
                                   <div class="tab-pane" id="fzt" role="tabpanel">
@@ -256,22 +191,48 @@
                           <div class="tab-content">
                               <!--清单规则-->
                               <div class="tab-pane active" id="qd" role="tabpanel">
-                                  <div class="warp-p2">
-                                      <div>
-                                          <select class="form-control form-control-sm" id="exampleSelect1">
-                                            <option>重庆市房屋建筑与装饰工程工程量计算规则(2013)</option>
-                                            <option>2</option>
-                                            <option>3</option>
-                                            <option>4</option>
-                                            <option>5</option>
+                                  <div class="sidebar-tools-bar container-fluid">
+                                      <div class="p-1 row">
+                                          <select class="form-control form-control-sm col-6" id="stdBillsLibSelect">
                                           </select>
+                                          <div class="input-group col-6">
+                                              <div class="input-group-addon form-control-sm"><i class="fa fa-search" aria-hidden="true"></i></div>
+                                              <input type="text" class="form-control form-control-sm" placeholder="搜索清单">
+                                          </div>
+                                      </div>
+                                  </div>
+                                  <div class="main-data-side-s" id="stdBillsSpread">
+                                  </div>
+                                  <div class="sidebar-bottom container-fluid">
+                                      <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>
+                                      </div>
+                                      <div class="row" id="stdBillsRemarkTab">
+                                          <div class="col-lg-12 p-0">
+                                              <textarea class="form-control" id="stdBillsRemark" rows="8" readonly="true"></textarea>
+                                          </div>
                                       </div>
                                   </div>
                               </div>
                               <!--定额库-->
                               <div class="tab-pane" id="de" role="tabpanel">
-                                  <div class="warp-p2">
-                                      定额内容
+                                  <div class="sidebar-tools-bar container-fluid">
+                                      <div class="p-1 row">
+                                          <select class="form-control form-control-sm col-6" id="stdRationLibSelect">
+                                          </select>
+                                          <div class="input-group col-6">
+                                              <div class="input-group-addon form-control-sm"><i class="fa fa-search" aria-hidden="true"></i></div>
+                                              <input type="text" class="form-control form-control-sm" placeholder="搜索定额">
+                                          </div>
+                                      </div>
+                                  </div>
+                                  <div class="main-data-side-s" id="stdRationChapter">
+                                  </div>
+                                  <div class="sidebar-bottom container-fluid">
+                                      <div class="row">
+                                          <div class="col-lg-12 p-0" id="stdSectionRations"></div>
+                                      </div>
                                   </div>
                               </div>
                           </div>
@@ -506,10 +467,15 @@
         </div>
     </div>
     <!-- JS. -->
-    <script src="lib/jquery/jquery.min.js"></script>
+    <script type="text/javascript">
+        autoFlashHeight();
+    </script>
+
     <script src="lib/tether/tether.min.js"></script>
     <script src="lib/bootstrap/bootstrap.min.js"></script>
-    <script src="lib/global.js"></script>
+    <script type="text/javascript" src="/lib/bootstrap/bootstrap-select.min.js"></script>
+    <!-- Common -->
+    <script type="text/javascript" src="/public/web/common_ajax.js"></script>
     <!--报表 zTree -->
     <script type="text/javascript" src="lib/ztree/jquery.ztree.core.js"></script>
     <script type="text/javascript" src="lib/ztree/jquery.ztree.excheck.js"></script>
@@ -529,12 +495,14 @@
     <!-- Controller -->
     <script type="text/javascript" src="public/web/tree_sheet_controller.js"></script>
     <script type="text/javascript" src="public/web/tree_sheet_helper.js"></script>
+    <script type="text/javascript" src="/web/scripts/sheetDataHelper.js"></script>
     <!-- Test Data -->
     <script type="text/javascript" src="test/tmp_data/bills_grid_setting.js"></script>
     <!-- view -->
     <script type="text/javascript" src="web/main/js/main_ajax.js"></script>
     <script type="text/javascript" src="web/main/js/main.js"></script>
-    <script type="text/javascript" src="/public/web/common_ajax.js"></script>
+    <script type="text/javascript" src="/web/main/js/views/std_bills_lib.js"></script>
+    <script type="text/javascript" src="/web/main/js/views/std_ration_lib.js"></script>
     <script type="text/javascript" src="/public/web/urlUtil.js"></script>
     <SCRIPT type="text/javascript">
   		<!--
@@ -635,22 +603,21 @@
         project.loadDatas(function (err) {
             if (!err) {
                 controller = TREE_SHEET_CONTROLLER.createNew(project.mainTree, billsSpread.getActiveSheet(), BillsGridSetting);
-                //controller = TREE_SHEET_CONTROLLER.createNew(project.Bills.tree, billsSpread.getActiveSheet(), BillsGridSetting);
 
                 controller.showTreeData();
                 controller.bind('refreshBaseActn', function (tree) {
-                    var showButton = function (show, btn) {
-                        if (show) {
-                            btn.show();
+                    var setButtonValid = function (valid, btn) {
+                        if (valid) {
+                            btn.removeClass('disabled');
                         } else {
-                            btn.hide();
+                            btn.addClass('disabled');
                         }
                     };
-                    showButton(tree.selected && tree.selected.canUpLevel(), $('#upLevel'));
-                    showButton(tree.selected && tree.selected.canDownLevel(), $('#downLevel'));
-                    showButton(tree.selected && tree.selected.canUpMove(), $('#upMove'));
-                    showButton(tree.selected && tree.selected.canDownMove(), $('#downMove'));
-                    showButton(tree.selected ? true : false, $('#delete'));
+                    setButtonValid(tree.selected && tree.selected.canUpLevel(), $('#upLevel'));
+                    setButtonValid(tree.selected && tree.selected.canDownLevel(), $('#downLevel'));
+                    setButtonValid(tree.selected && tree.selected.canUpMove(), $('#upMove'));
+                    setButtonValid(tree.selected && tree.selected.canDownMove(), $('#downMove'));
+                    setButtonValid(tree.selected ? true : false, $('#delete'));
                 });
 
                 gljView.showDatas(project.GLJ.datas);
@@ -770,8 +737,4 @@
         });
     });
 </script>
-
-<script type="text/javascript">
-    autoFlashHeight();
-</script>
 </html>

+ 3 - 1
web/main/js/main.js

@@ -30,7 +30,9 @@ var LoadData = function () {
     });*/
     GetProject(GetQueryString('project'), function (data) {
         Project = data;
-        $('#fullpath').html(loadFullPathHtml(Project));
+        if (Project) {
+            $('#fullpath').html(loadFullPathHtml(Project));
+        }
     });
 };
 

+ 339 - 0
web/main/js/views/std_bills_lib.js

@@ -0,0 +1,339 @@
+/**
+ * Created by Mai on 2017/5/16.
+ */
+
+/*var stdBillsLibController = {
+
+};*/
+
+CommonAjax.post('/stdBillsEditor/getStdBillsLib', {userId: userID}, function (datas) {
+    var i, select = $('#stdBillsLibSelect');
+    select.empty();
+    datas.forEach(function (data) {
+        var option = $('<option>').val(data.billsLibId).text(data.billsLibName);
+        select.append(option);
+    });
+    if (select.children.length !== 0) {
+        LoadStdBills(select.val());
+    }
+});
+
+var LoadStdBills = (function () {
+    var stdBillsSpread = SheetDataHelper.createNewSpread($('#stdBillsSpread')[0]);
+    var stdBillsJobSpread = null, stdBillsFeatureSpread = null;
+    var stdBillsTreeSetting = {
+            "treeCol": 0,
+            "emptyRows":0,
+            "headRows":1,
+            "headRowHeight":[
+                35
+            ],
+            "cols":[
+                {
+                    "width":100,
+                    "readOnly":null,
+                    "head":{
+                        "titleNames":[
+                            "项目编码"
+                        ],
+                        "spanCols":[
+                            1
+                        ],
+                        "spanRows":[
+                            1
+                        ],
+                        "vAlign":[
+                            1
+                        ],
+                        "hAlign":[
+                            1
+                        ],
+                        "font":[
+                            "12px Arial"
+                        ]
+                    },
+                    "data":{
+                        "field":"code",
+                        "vAlign":0,
+                        "hAlign":3,
+                        "font":"12px Arial"
+                    }
+                },
+                {
+                    "width":120,
+                    "readOnly":null,
+                    "head":{
+                        "titleNames":[
+                            "项目名称"
+                        ],
+                        "spanCols":[
+                            1
+                        ],
+                        "spanRows":[
+                            1
+                        ],
+                        "vAlign":[
+                            1
+                        ],
+                        "hAlign":[
+                            1
+                        ],
+                        "font":[
+                            "12px Arial"
+                        ]
+                    },
+                    "data":{
+                        "field":"name",
+                        "vAlign":0,
+                        "hAlign":3,
+                        "font":"12px Arial"
+                    }
+                },
+                {
+                    "width":40,
+                    "readOnly":null,
+                    "head":{
+                        "titleNames":[
+                            "计量单位"
+                        ],
+                        "spanCols":[
+                            1
+                        ],
+                        "spanRows":[
+                            1
+                        ],
+                        "vAlign":[
+                            1
+                        ],
+                        "hAlign":[
+                            1
+                        ],
+                        "font":[
+                            "12px Arial"
+                        ],
+                        "wordWrap": true
+                    },
+                    "data":{
+                        "field":"unti",
+                        "vAlign":0,
+                        "hAlign":3,
+                        "font":"12px Arial"
+                    }
+                },
+                {
+                    "width":100,
+                    "readOnly":null,
+                    "head":{
+                        "titleNames":[
+                            "工程量计算规则"
+                        ],
+                        "spanCols":[
+                            1
+                        ],
+                        "spanRows":[
+                            1
+                        ],
+                        "vAlign":[
+                            1
+                        ],
+                        "hAlign":[
+                            1
+                        ],
+                        "font":[
+                            "12px Arial"
+                        ]
+                    },
+                    "data":{
+                        "field":"ruleText",
+                        "vAlign":0,
+                        "hAlign":3,
+                        "font":"12px Arial"
+                    }
+                }
+            ]
+        };
+    var stdBillsData, stdBillsJobData, stdBillsFeatureData;
+    var stdBillsTree = idTree.createNew({id: 'ID', pid: 'ParentID', nid: 'NextSiblingID', rootId: -1, autoUpdate: true});
+    var stdBillsTreeController = TREE_SHEET_CONTROLLER.createNew(stdBillsTree, stdBillsSpread.getActiveSheet(), stdBillsTreeSetting);
+
+    var findData = function (value, field, Array) {
+        var i = 0;
+        for (i = 0; i < Array.length - 1; i++) {
+            if (value === Array[i][field]) {
+                return Array[i];
+            }
+        }
+        return null;
+    };
+    var getBillsJobs = function (node) {
+        var jobs = [], i, jobData = null;
+        if (node && node.data.jobs) {
+            for (i = 0; i < node.data.jobs.length - 1; i++) {
+                jobData = findData(node.data.jobs[i], 'id', stdBillsJobData);
+                if (jobData) {
+                    jobs.push(jobData);
+                }
+            }
+        }
+        return jobs;
+    };
+    var getBillsFeatures = function (node) {
+        var features = [], i, featureData = null;
+        if (node && node.data.items) {
+            for (i = 0; i < node.data.items.length - 1; i++) {
+                featureData = findData(node.data.items[i], 'id', stdBillsFeatureData);
+                if (featureData) {
+                    features.push(featureData);
+                }
+            }
+        }
+        return features;
+    };
+
+    var showJobs = function (jobs) {
+        var jobsSetting = {
+            "emptyRows":0,
+            "headRows":1,
+            "headRowHeight":[
+                20
+            ],
+            "cols":[
+                {
+                    "width":200,
+                    "readOnly":null,
+                    "head":{
+                        "titleNames":[
+                            "工程内容"
+                        ],
+                        "spanCols":[
+                            1
+                        ],
+                        "spanRows":[
+                            1
+                        ],
+                        "vAlign":[
+                            1
+                        ],
+                        "hAlign":[
+                            1
+                        ],
+                        "font":[
+                            "12px Arial"
+                        ]
+                    },
+                    "data":{
+                        "field":"content",
+                        "vAlign":0,
+                        "hAlign":3,
+                        "font":"12px Arial"
+                    }
+                }
+            ]
+        };
+        SheetDataHelper.loadSheetHeader(jobsSetting, stdBillsJobSpread.getActiveSheet());
+        SheetDataHelper.loadSheetData(jobsSetting, stdBillsJobSpread.getActiveSheet(), jobs);
+    };
+    var showFeatures = function (features) {
+        var featuresSetting = {
+            "emptyRows":0,
+            "headRows":1,
+            "headRowHeight":[
+                20
+            ],
+            "cols":[
+                {
+                    "width":200,
+                    "readOnly":null,
+                    "head":{
+                        "titleNames":[
+                            "项目特征"
+                        ],
+                        "spanCols":[
+                            1
+                        ],
+                        "spanRows":[
+                            1
+                        ],
+                        "vAlign":[
+                            1
+                        ],
+                        "hAlign":[
+                            1
+                        ],
+                        "font":[
+                            "12px Arial"
+                        ]
+                    },
+                    "data":{
+                        "field":"content",
+                        "vAlign":0,
+                        "hAlign":3,
+                        "font":"12px Arial"
+                    }
+                }
+            ]
+        };
+        SheetDataHelper.loadSheetHeader(featuresSetting, stdBillsFeatureSpread.getActiveSheet());
+        SheetDataHelper.loadSheetData(featuresSetting, stdBillsFeatureSpread.getActiveSheet(), features);
+    }
+
+    var showJobsAndFeatures = function (node) {
+        $('#stdBillsJobTab').show();
+        $('#stdBillsRemarkTab').hide();
+        if (!stdBillsJobSpread) {
+            stdBillsJobSpread = SheetDataHelper.createNewSpread($('#stdBillsJobs')[0]);
+        }
+        showJobs(getBillsJobs(node));
+        if (!stdBillsFeatureSpread) {
+            stdBillsFeatureSpread = SheetDataHelper.createNewSpread($('#stdBillsFeatures')[0]);
+        }
+        showFeatures(getBillsFeatures(node));
+    };
+
+    var showBillsRemark = function (node) {
+        $('#stdBillsJobTab').hide();
+        $('#stdBillsRemarkTab').show();
+        $('#stdBillsRemark').text(node && node.data.recharge ? node.data.recharge : '');
+    };
+
+    var LoadData = function (stdBillsLibID) {
+        CommonAjax.post('/stdBillsEditor/getBills', {userId: userID, billsLibId: stdBillsLibID}, function (datas) {
+            stdBills = datas;
+            stdBillsTree.loadDatas(stdBills);
+            stdBillsTreeController.showTreeData();
+            showBillsRemark(stdBillsTree.firstNode());
+
+            stdBillsTreeController.bind(TREE_SHEET_CONTROLLER.eventName.treeSelectedChanged, function (node) {
+                if (node.children.length === 0) {
+                    showJobsAndFeatures(node);
+                } else {
+                    showBillsRemark(node);
+                }
+            });
+        });
+        CommonAjax.post('/stdBillsEditor/getJobContent', {userId: userID, billsLibId: stdBillsLibID}, function (datas) {
+            stdBillsJobData = datas;
+        }, function () {
+            stdBillsJobData = [];
+        });
+        CommonAjax.post('/stdBillsEditor/getItemCharacter', {userId: userID, billsLibId: stdBillsLibID}, function (datas) {
+            stdBillsFeatureData = datas;
+        }, function () {
+            stdBillsFeatureData = [];
+        });
+    };
+
+    stdBillsSpread.options.tabStripVisible = false;
+    stdBillsSpread.options.scrollbarMaxAlign = true;
+    stdBillsSpread.options.cutCopyIndicatorVisible = false;
+    stdBillsSpread.options.allowCopyPasteExcelStyle = false;
+
+    return LoadData;
+})();
+
+$('#stdBillsLibSelect').change(function () {
+    var select = $(this);
+    if (this.children.length !== 0) {
+        LoadStdBills(select.val());
+    }
+});

+ 174 - 0
web/main/js/views/std_ration_lib.js

@@ -0,0 +1,174 @@
+/**
+ * Created by Mai on 2017/5/16.
+ */
+
+var rationChapterSpread, sectionRationsSpread;
+
+var LoadStdRationLibs = function () {
+    CommonAjax.postRationLib('/rationRepository/api/getRationDisplayNames', {user_id: userID}, function (datas) {
+        var select = $('#stdRationLibSelect');
+        select.empty();
+        datas.forEach(function (data) {
+            select.append($('<option>').val(data.ID).text(data.dispName));
+        });
+        if (select[0].options.length !== 0) {
+            LoadStdRation(select.val());
+        }
+    }, function () {
+        $('#stdRationLibSelect').empty();
+    });
+};
+
+var LoadStdRation = (function () {
+    var rationChapterTreeSetting = {
+        "emptyRows":0,
+        "headRows":1,
+        "headRowHeight":[30],
+        "treeCol": 0,
+        "cols":[{
+            "width":300,
+            "readOnly": true,
+            "head":{
+                "titleNames":["名称"],
+                "spanCols":[1],
+                "spanRows":[1],
+                "vAlign":[1],
+                "hAlign":[1],
+                "font":["9px Arial"]
+            },
+            "data":{
+                "field":"name",
+                "vAlign":0,
+                "hAlign":3,
+                "font":"9px Arial"
+            }
+        }]
+    };
+    var showRationChapterTree = function (datas) {
+        var rationChapterTree = idTree.createNew({id: 'ID', pid: 'ParentID', nid: 'NextSiblingID', rootId: -1, autoUpdate: false});
+        var rationChapterTreeController = TREE_SHEET_CONTROLLER.createNew(rationChapterTree, rationChapterSpread.getActiveSheet(), rationChapterTreeSetting);
+        rationChapterTree.loadDatas(datas);
+        rationChapterTreeController.showTreeData();
+
+        rationChapterTreeController.bind(TREE_SHEET_CONTROLLER.eventName.treeSelectedChanged, function (node) {
+            LoadSectionRations(node.getID());
+        });
+
+        if (rationChapterTree.firstNode()) {
+            LoadSectionRations(rationChapterTree.firstNode().getID());
+        } else {
+            LoadSectionRations();
+        };
+    }
+
+    var LoadData = function (rationLibID) {
+        CommonAjax.postRationLib('/rationRepository/api/getRationTree', {userId: userID, rationRepositoryId: rationLibID}, function (datas) {
+            showRationChapterTree(datas);
+        }, function () {
+            showRationChapterTree([]);
+        });
+    };
+
+    return LoadData;
+})();
+var LoadSectionRations = (function () {
+    var sectionRationsSetting = {
+            "emptyRows":3,
+            "headRows":1,
+            "headRowHeight":[20],
+            "cols":[
+                {
+                    "width":100,
+                    "readOnly": true,
+                    "head":{
+                        "titleNames":["编码"],
+                        "spanCols":[1],
+                        "spanRows":[1],
+                        "vAlign":[1],
+                        "hAlign":[1],
+                        "font":["12px Arial"]
+                    },
+                    "data":{
+                        "field":"code",
+                        "vAlign":0,
+                        "hAlign":3,
+                        "font":"12px Arial"
+                    }
+                },
+                {
+                    "width":180,
+                    "readOnly": true,
+                    "head":{
+                        "titleNames":["名称"],
+                        "spanCols":[1],
+                        "spanRows":[1],
+                        "vAlign":[1],
+                        "hAlign":[1],
+                        "font":["12px Arial"]
+                    },
+                    "data":{
+                        "field":"name",
+                        "vAlign":0,
+                        "hAlign":3,
+                        "font":"12px Arial"
+                    }
+                },
+                {
+                    "width":50,
+                    "readOnly":true,
+                    "head":{
+                        "titleNames":["单位"],
+                        "spanCols":[1],
+                        "spanRows":[1],
+                        "vAlign":[1],
+                        "hAlign":[1],
+                        "font":["12px Arial"]
+                    },
+                    "data":{
+                        "field":"unit",
+                        "vAlign":0,
+                        "hAlign":1,
+                        "font":"12px Arial"
+                    }
+                }
+            ]
+        };
+
+    var LoadData = function (sectionID) {
+        if (sectionID) {
+            CommonAjax.postRationLib('/rationRepository/api/getRationItems', {userId: userID, sectionID: sectionID}, function (datas) {
+                SheetDataHelper.loadSheetHeader(sectionRationsSetting, sectionRationsSpread.getActiveSheet());
+                SheetDataHelper.loadSheetData(sectionRationsSetting, sectionRationsSpread.getActiveSheet(), datas);
+            }, function () {
+                SheetDataHelper.loadSheetHeader(sectionRationsSetting, sectionRationsSpread.getActiveSheet());
+                SheetDataHelper.loadSheetData(sectionRationsSetting, sectionRationsSpread.getActiveSheet(), []);
+            });
+        } else {
+            SheetDataHelper.loadSheetHeader(sectionRationsSetting, sectionRationsSpread.getActiveSheet());
+            SheetDataHelper.loadSheetData(sectionRationsSetting, sectionRationsSpread.getActiveSheet(), []);
+        }
+    };
+
+    return LoadData;
+})();
+
+$('#stdRationTab').on('shown.bs.tab', function (e) {
+    var select = $('#stdRationLibSelect');
+    if (!rationChapterSpread) {
+        rationChapterSpread = SheetDataHelper.createNewSpread($('#stdRationChapter')[0]);
+    }
+    if (!sectionRationsSpread) {
+        sectionRationsSpread = SheetDataHelper.createNewSpread($('#stdSectionRations')[0]);
+    }
+    if (select[0].options.length === 0) {
+        LoadStdRationLibs();
+    };
+});
+
+$('#stdRationLibSelect').change(function () {
+    var select = $(this);
+    if (this.children.length !== 0) {
+        LoadStdRation(select.val());
+    }
+    rationChapterSpread.getActiveSheet().repaint();
+});

+ 10 - 0
web/scripts/sheetDataHelper.js

@@ -30,6 +30,15 @@ var __settingTemp = {
 };
 
 var SheetDataHelper = {
+    createNewSpread: function (obj) {
+        var spread = new GC.Spread.Sheets.Workbook(obj, {sheetCount: 1});
+        spread.options.tabStripVisible = false;
+        spread.options.scrollbarMaxAlign = true;
+        spread.options.cutCopyIndicatorVisible = false;
+        spread.options.allowCopyPasteExcelStyle = false;
+        spread.getActiveSheet().setRowCount(3);
+        return spread;
+    },
     loadSheetHeader: function (setting, sheet) {
         sheet.setColumnCount(setting.cols.length);
         sheet.setRowCount(setting.headRows, GC.Spread.Sheets.SheetArea.colHeader);
@@ -78,6 +87,7 @@ var SheetDataHelper = {
         sheet.suspendPaint();
         sheet.suspendEvent();
 
+        sheet.clear(0, 0, sheet.getRowCount(), sheet.getColumnCount(), GC.Spread.Sheets.SheetArea.viewport, GC.Spread.Sheets.StorageType.data);
         sheet.setRowCount(datas.length + setting.emptyRows, GC.Spread.Sheets.SheetArea.viewport);
         setting.cols.forEach(function (colSetting, iCol) {       
             sheet.setStyle(-1, iCol, SheetDataHelper.getSheetCellStyle(colSetting));