Prechádzať zdrojové kódy

Merge branch 'master' of http://192.168.1.12:3000/SmartCost/ConstructionCost

TonyKang 8 rokov pred
rodič
commit
2b681be8f8

+ 7 - 5
modules/ration_repository/models/ration_item.js

@@ -75,20 +75,22 @@ rationItemDAO.prototype.removeRationItems = function(rIds,callback){
 };
 
 rationItemDAO.prototype.getRationItemsByCode = function(repId, code,callback){
-    rationItemModel.find({"rationRepId": repId, "code": /code/, "$or": [{"isDeleted": null}, {"isDeleted": false}]},function(err,data){
+    rationItemModel.find({"rationRepId": repId, "code": {'$regex': code, $options: '$i'}, "$or": [{"isDeleted": null}, {"isDeleted": false}]},function(err,data){
         if(err) callback(true, "Fail to get items", "")
         else callback(false,"Get items successfully", data);
     })
 };
 
 rationItemDAO.prototype.findRation = function (repId, keyword, callback) {
-    rationItemModel.find({'rationRepId': repId,
+    var filter = {
+        'rationRepId': repId,
         '$and': [{
-            '$or': [{'code': /keyword/}, {'name': /keyword/}]
+            '$or': [{'code': {'$regex': keyword, $options: '$i'}}, {'name': {'$regex': keyword, $options: '$i'}}]
         }, {
-            '$or': [{'isDeleted': null}, {'isDeleted': false}]
+            '$or': [{'isDeleted': {"$exists":false}}, {'isDeleted': null}, {'isDeleted': false}]
         }]
-    }, function (err, data) {
+    };
+    rationItemModel.find(filter, function (err, data) {
         if (err) {
             callback(true, 'Fail to find ration', null);
         } else {

+ 3 - 8
web/building_saas/css/main.css

@@ -71,6 +71,9 @@ body {
     margin-left: 29px;
     background: #fff
 }
+.toolsbar {
+  border-bottom: 1px solid #ccc
+}
 .tools-btn {
     height: 30px;
     line-height: 30px;
@@ -79,7 +82,6 @@ body {
     background: #f7f7f9;
 }
 .main-side {
-    border-top: 1px solid #ccc;
     border-left: 1px solid #ccc;
     overflow-y: hidden;
 }
@@ -276,13 +278,6 @@ body {
   background:#fff
 }
 .side-search-box{
-  position: absolute;
   background:#fff;
-  top:33px;
-  left:0;
   border-bottom:1px solid #ddd
 }
-.side-search-box .result-box{
-  height:300px;
-  overflow: auto;
-}

+ 1 - 0
web/building_saas/js/global.js

@@ -8,6 +8,7 @@ function autoFlashHeight(){
     $(".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);
+    $(".main-data-side-search").height($(window).height()-headerHeight-toolsbarHeight-64);
     $(".side-content").height($(window).height()-headerHeight );
     $(".poj-list").height($(window).height()-headerHeight-toolsbarHeight);
     $(".form-list").height($(window).height()-headerHeight-50 );

+ 14 - 16
web/building_saas/main/html/main.html

@@ -197,9 +197,19 @@
                                       <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 class="input-group col-6" id="stdBillsSearch">
+                                              <input type="text" class="form-control form-control-sm" placeholder="搜索清单" value="1-1-2">
+                                              <span class="input-group-btn">
+                                                  <button class="btn btn-secondary btn-sm" type="button"><i class="fa fa-search" aria-hidden="true"></i></button>
+                                              </span>
+                                          </div>
+                                          <!--搜索结果窗体-->
+                                          <div class="side-search-box col-12 p-2" id="stdBillsSearchResult" style="display: none;">
+                                              <div class="d-flex justify-content-between">
+                                                  <span id = 'stdBillsSearchResultCount'>搜索结果:5</span>
+                                                  <a class="btn btn-secondary btn-sm" href="javascript:void(0);" id="nextStdBills">查找下一条</a>
+                                                  <a title="关闭搜索" class="btn btn-link btn-sm" href="javascript:void(0);" id="closeSearchStdBills"><i class="fa fa-remove" aria-hidden="true"></i></a>
+                                              </div>
                                           </div>
                                       </div>
                                   </div>
@@ -230,19 +240,7 @@
                                               </span>
                                           </div>
                                           <!--搜索结果窗体-->
-                                          <div class="side-search-box col-12 p-2" id="rationSearchResult" style="display: none;">
-                                              <div class="d-flex justify-content-between">
-                                                  <span>搜索结果:5</span><a title="关闭搜索" class="btn btn-link btn-sm" href="javascript:void(0)"><i class="fa fa-remove" aria-hidden="true"></i></a>
-                                              </div>
-                                              <div class="result-box w-100">
-                                                  <table class="table">
-                                                      <thead><tr><th></th><th>编号</th><th>名称</th><th>单位</th><th>基价</th></tr></thead>
-                                                      <tbody>
-                                                      <tr><td>1</td><td>1-1-8-2</td><td>机动翻斗车运第1个100m石方</td><td>1000m3</td><td>6249</td></tr>
-                                                      <tr><td>1</td><td>1-1-8-2</td><td>机动翻斗车运第1个100m石方</td><td>1000m3</td><td>6249</td></tr>
-                                                      </tbody>
-                                                  </table>
-                                              </div>
+                                          <div class="side-search-box col-12 p-0" id="rationSearchResult" style="display: none;">
                                           </div>
                                       </div>
                                   </div>

+ 37 - 0
web/building_saas/main/js/views/std_bills_lib.js

@@ -402,6 +402,39 @@ var LoadStdBills = (function () {
         }
     });
 
+    $('#stdBillsSearch>span>button').click(function () {
+        var keyword = $('#stdBillsSearch>input').val();
+        var result = stdBillsTree.items.filter(function (item) {
+            var codeIs = item.data.code ? item.data.code.indexOf(keyword) !== -1 : false;
+            var nameIs = item.data.name ? item.data.name.indexOf(keyword) !== -1 : false;
+            return codeIs || nameIs;
+        });
+        result.sort(function (x, y) {
+            return x.serialNo - y.serialNo;
+        });
+        if (result.length !== 0) {
+            var sel = stdBillsSpread.getActiveSheet().getSelections();
+            stdBillsTreeController.setTreeSelected(result[0]);
+            stdBillsSpread.getActiveSheet().setSelection(result[0].serialNo(), sel[0].col, 1, 1);
+
+            $('#nextStdBills').show();
+            $('#nextStdBills').click(function () {
+                var cur = stdBillsTree.selected, resultIndex = result.indexOf(cur), sel = stdBillsSpread.getActiveSheet().getSelections();
+                if (resultIndex === result.length - 1) {
+                    stdBillsTreeController.setTreeSelected(result[0]);
+                    stdBillsSpread.getActiveSheet().setSelection(result[0].serialNo(), sel[0].col, 1, 1);
+                } else {
+                    stdBillsTreeController.setTreeSelected(result[resultIndex + 1]);
+                    stdBillsSpread.getActiveSheet().setSelection(result[resultIndex + 1].serialNo(), sel[0].col, 1, 1);
+                }
+            });
+        } else {
+            $('#nextStdBills').hide();
+        }
+        $('#stdBillsSearchResultCount').text('搜索结果:' + result.length);
+        $('#stdBillsSearchResult').show();
+    });
+
     return LoadData;
 })();
 
@@ -411,3 +444,7 @@ $('#stdBillsLibSelect').change(function () {
         LoadStdBills(select.val());
     }
 });
+
+$('#closeSearchStdBills').click(function () {
+    $('#stdBillsSearchResult').hide();
+});

+ 148 - 154
web/building_saas/main/js/views/std_ration_lib.js

@@ -15,15 +15,7 @@ var rationLibObj = {
         if (!this.sectionRationsSpread) {
             this.sectionRationsSpread = SheetDataHelper.createNewSpread($('#stdSectionRations')[0]);
 
-
-            this.sectionRationsSpread.bind(GC.Spread.Sheets.Events.CellDoubleClick, function (sender, args) {
-                var select = $('#stdRationLibSelect'), rationCode = args.sheet.getText(args.row, 0);
-                if (rationCode !== '') {
-                    CommonAjax.postRationLib('/rationRepository/api/getRationItem', {user_id: userID, rationLibId: select.val(), code: rationCode}, function (data) {
-                        ProjectController.addRation(project, controller, data);
-                    });
-                }
-            });
+            this.sectionRationsSpread.bind(GC.Spread.Sheets.Events.CellDoubleClick, this.onRationSpreadCellDoubleClick);
         }
     },
     loadStdRationLibs: function () {
@@ -40,40 +32,15 @@ var rationLibObj = {
             $('#stdRationLibSelect').empty();
         });
     },
-    loadStdRation: (function () {
+    loadStdRation: function (rationLibID) {
         var that = this;
-        var rationChapterTreeSetting = {
-            "emptyRows":0,
-            "headRows":1,
-            "headRowHeight":[30],
-            "defaultRowHeight": 21,
-            "treeCol": 0,
-            "cols":[{
-                "width":300,
-                "readOnly": true,
-                "head":{
-                    "titleNames":["名称"],
-                    "spanCols":[1],
-                    "spanRows":[1],
-                    "vAlign":[1],
-                    "hAlign":[1],
-                    "font":["Arial"]
-                },
-                "data":{
-                    "field":"name",
-                    "vAlign":1,
-                    "hAlign":0,
-                    "font":"Arial"
-                }
-            }]
-        };
         var showRationChapterTree = function (datas) {
             var rationChapterTree = idTree.createNew({id: 'ID', pid: 'ParentID', nid: 'NextSiblingID', rootId: -1, autoUpdate: false});
-            rationLibObj.rationChapterTreeController = TREE_SHEET_CONTROLLER.createNew(rationChapterTree, rationLibObj.rationChapterSpread.getActiveSheet(), rationChapterTreeSetting);
+            var rationChapterTreeController = TREE_SHEET_CONTROLLER.createNew(rationChapterTree, that.rationChapterSpread.getActiveSheet(), that.rationChapterTreeSetting);
             rationChapterTree.loadDatas(datas);
-            rationLibObj.rationChapterTreeController.showTreeData();
+            rationChapterTreeController.showTreeData();
 
-            rationLibObj.rationChapterTreeController.bind(TREE_SHEET_CONTROLLER.eventName.treeSelectedChanged, function (node) {
+            rationChapterTreeController.bind(TREE_SHEET_CONTROLLER.eventName.treeSelectedChanged, function (node) {
                 rationLibObj.loadSectionRations(node.getID());
             });
 
@@ -84,109 +51,135 @@ var rationLibObj = {
             };
         };
 
-        var LoadData = function (rationLibID) {
-            CommonAjax.postRationLib('/rationRepository/api/getRationTree', {userId: userID, rationRepositoryId: rationLibID}, function (datas) {
-                showRationChapterTree(datas);
+        CommonAjax.postRationLib('/rationRepository/api/getRationTree', {userId: userID, rationRepositoryId: rationLibID}, function (datas) {
+            showRationChapterTree(datas);
+        }, function () {
+            showRationChapterTree([]);
+        });
+    },
+    loadSectionRations: function (sectionID) {
+        var showDatas = function (datas, setting) {
+            SheetDataHelper.loadSheetHeader(setting, rationLibObj.sectionRationsSpread.getActiveSheet());
+            SheetDataHelper.loadSheetData(setting, rationLibObj.sectionRationsSpread.getActiveSheet(), datas);
+        };
+        if (sectionID) {
+            CommonAjax.postRationLib('/rationRepository/api/getRationItems', {userId: userID, sectionID: sectionID}, function (datas) {
+                showDatas(datas, rationLibObj.sectionRationsSetting);
             }, function () {
-                showRationChapterTree([]);
+                showDatas([], rationLibObj.sectionRationsSetting);
             });
-        };
-
-        return LoadData;
-    })(),
-    loadSectionRations: (function () {
-        var sectionRationsSetting = {
-            "emptyRows":3,
-            "headRows":1,
-            "headRowHeight":[20],
-            "defaultRowHeight": 21,
-            "cols":[{
-                "width":100,
-                "readOnly": true,
-                "head":{
-                    "titleNames":["编码"],
-                    "spanCols":[1],
-                    "spanRows":[1],
-                    "vAlign":[1],
-                    "hAlign":[1],
-                    "font":["Arial"]
-                },
-                "data":{
-                    "field":"code",
-                    "vAlign":1,
-                    "hAlign":0,
-                    "font":"Arial"
-                }
-            }, {
-                "width":180,
-                "readOnly": true,
-                "head":{
-                    "titleNames":["名称"],
-                    "spanCols":[1],
-                    "spanRows":[1],
-                    "vAlign":[1],
-                    "hAlign":[1],
-                    "font":["Arial"]
-                },
-                "data":{
-                    "field":"name",
-                    "vAlign":1,
-                    "hAlign":0,
-                    "font":"Arial"
-                }
-            }, {
-                "width":50,
-                "readOnly":true,
-                "head":{
-                    "titleNames":["单位"],
-                    "spanCols":[1],
-                    "spanRows":[1],
-                    "vAlign":[1],
-                    "hAlign":[1],
-                    "font":["Arial"]
-                },
-                "data":{
-                    "field":"unit",
-                    "vAlign":1,
-                    "hAlign":1,
-                    "font":"Arial"
-                }
-            }, {
-                "width":80,
-                "readOnly":true,
-                "head":{
-                    "titleNames":["基价"],
-                    "spanCols":[1],
-                    "spanRows":[1],
-                    "vAlign":[1],
-                    "hAlign":[1],
-                    "font":["Arial"]
-                },
-                "data":{
-                    "field":"basePrice",
-                    "vAlign":1,
-                    "hAlign":2,
-                    "font":"Arial"
-                }
-            }]
-        };
-        var showDatas = function (datas) {
-            SheetDataHelper.loadSheetHeader(sectionRationsSetting, rationLibObj.sectionRationsSpread.getActiveSheet());
-            SheetDataHelper.loadSheetData(sectionRationsSetting, rationLibObj.sectionRationsSpread.getActiveSheet(), datas);
+        } else {
+            showDatas([], rationLibObj.sectionRationsSetting);
         }
-        var LoadData = function (sectionID) {
-            if (sectionID) {
-                CommonAjax.postRationLib('/rationRepository/api/getRationItems', {userId: userID, sectionID: sectionID}, function (datas) {
-                    showDatas(datas);
-                }, function () {
-                    showDatas([]);
-                });
-            } else {
-                showDatas([]);
+    },
+    onRationSpreadCellDoubleClick: function (sender, args) {
+        var select = $('#stdRationLibSelect'), rationCode = args.sheet.getText(args.row, 0);
+        if (rationCode !== '') {
+            CommonAjax.postRationLib('/rationRepository/api/getRationItem', {user_id: userID, rationLibId: select.val(), code: rationCode}, function (data) {
+                ProjectController.addRation(project, controller, data);
+            });
+        }
+    },
+    rationChapterTreeSetting: {
+        "emptyRows":0,
+        "headRows":1,
+        "headRowHeight":[30],
+        "defaultRowHeight": 21,
+        "treeCol": 0,
+        "cols":[{
+            "width":300,
+            "readOnly": true,
+            "head":{
+                "titleNames":["名称"],
+                "spanCols":[1],
+                "spanRows":[1],
+                "vAlign":[1],
+                "hAlign":[1],
+                "font":["Arial"]
+            },
+            "data":{
+                "field":"name",
+                "vAlign":1,
+                "hAlign":0,
+                "font":"Arial"
             }
-        };
-        return LoadData;
-    })()
+        }]
+    },
+    sectionRationsSetting: {
+        "emptyRows":3,
+        "headRows":1,
+        "headRowHeight":[20],
+        "defaultRowHeight": 21,
+        "cols":[{
+            "width":100,
+            "readOnly": true,
+            "head":{
+                "titleNames":["编码"],
+                "spanCols":[1],
+                "spanRows":[1],
+                "vAlign":[1],
+                "hAlign":[1],
+                "font":["Arial"]
+            },
+            "data":{
+                "field":"code",
+                "vAlign":1,
+                "hAlign":0,
+                "font":"Arial"
+            }
+        }, {
+            "width":180,
+            "readOnly": true,
+            "head":{
+                "titleNames":["名称"],
+                "spanCols":[1],
+                "spanRows":[1],
+                "vAlign":[1],
+                "hAlign":[1],
+                "font":["Arial"]
+            },
+            "data":{
+                "field":"name",
+                "vAlign":1,
+                "hAlign":0,
+                "font":"Arial"
+            }
+        }, {
+            "width":50,
+            "readOnly":true,
+            "head":{
+                "titleNames":["单位"],
+                "spanCols":[1],
+                "spanRows":[1],
+                "vAlign":[1],
+                "hAlign":[1],
+                "font":["Arial"]
+            },
+            "data":{
+                "field":"unit",
+                "vAlign":1,
+                "hAlign":1,
+                "font":"Arial"
+            }
+        }, {
+            "width":80,
+            "readOnly":true,
+            "head":{
+                "titleNames":["基价"],
+                "spanCols":[1],
+                "spanRows":[1],
+                "vAlign":[1],
+                "hAlign":[1],
+                "font":["Arial"]
+            },
+            "data":{
+                "field":"basePrice",
+                "vAlign":1,
+                "hAlign":2,
+                "font":"Arial"
+            }
+        }]
+    }
 };
 
 $('#stdRationTab').on('shown.bs.tab', function (e) {
@@ -205,7 +198,7 @@ $('#stdRationLibSelect').change(function () {
 $('#rationSearch').click(function () {
     var keyword = $('#rationSearchKeyword').val(), rationLibID = $('#stdRationLibSelect').val();
     var getResultHtml = function (result) {
-        var html = [], i;
+        var html = [], i, serialNo;
         html.push('<div class="d-flex justify-content-between">');
         html.push('<span>搜索结果:');
         html.push(result.length.toString());
@@ -213,27 +206,28 @@ $('#rationSearch').click(function () {
         html.push('<a title="关闭搜索" class="btn btn-link btn-sm" href="javascript:void(0)"><i class="fa fa-remove" aria-hidden="true"></i></a>');
         html.push('</div>');
 
-        html.push('<div class="result-box w-100">');
-        html.push('<table class="table">');
-        html.push('<thead><tr><th></th><th>编号</th><th>名称</th><th>单位</th><th>基价</th></tr></thead>');
-        html.push('<tbody>');
-        for (i = 0; i < result.length; i++) {
-            html.push('<tr>');
-            html.push('<td>' + i.toString() + '</td>');
-            html.push('<td>' + result[i].code + '</td>');
-            html.push('<td>' + result[i].name + '</td>');
-            html.push('<td>' + result[i].unit + '</td>');
-            html.push('</tr>');
-        }
-        html.push('</tbody>');
-        html.push('</table>');
+        html.push('<div class="w-100 main-data-side-search">');
         html.push('</div>');
         return html.join('');
-    }
+    };
+    var showResult = function (result) {
+        var resultSpread = SheetDataHelper.createNewSpread($('.main-data-side-search')[0]);
+
+        SheetDataHelper.loadSheetHeader(rationLibObj.sectionRationsSetting, resultSpread.getActiveSheet());
+        SheetDataHelper.loadSheetData(rationLibObj.sectionRationsSetting, resultSpread.getActiveSheet(), result);
+
+        resultSpread.bind(GC.Spread.Sheets.Events.CellDoubleClick, rationLibObj.onRationSpreadCellDoubleClick);
+    };
     CommonAjax.postRationLib('/rationRepository/api/findRation', {'user_id': userID, 'rationLibId': rationLibID, 'keyword': keyword}, function (result) {
-        var resultObj = $('#rationSearchResult');
+        var resultObj = $('#rationSearchResult'), resultSpread = null;
         resultObj.empty();
         resultObj.append(getResultHtml(result));
+        $('a', resultObj).click(function () {
+            resultObj.hide();
+            $(".main-data-side-search", resultObj).height(0);
+        });
         resultObj.show();
+        $(".main-data-side-search", resultObj).height($(window).height() - $(".header").height() - $(".sidebar-tools-bar").height() - 64);
+        showResult(result);
     });
 });