Selaa lähdekoodia

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

chenshilong 6 vuotta sitten
vanhempi
commit
5cb3adf80e

+ 1 - 0
config/gulpConfig.js

@@ -157,6 +157,7 @@ module.exports = {
         'web/building_saas/main/js/views/sub_fee_rate_views.js',
         'web/building_saas/main/js/views/calc_base_view.js',
         'web/building_saas/main/js/views/project_property_labour_coe_view.js',
+        'web/building_saas/main/js/views/locate_view.js',
         'web/building_saas/complementary_ration_lib/js/main.js',
         'public/web/storageUtil.js'
     ],

+ 1 - 1
modules/complementary_ration_lib/controllers/searchController.js

@@ -20,7 +20,7 @@ class SearchController extends BaseController{
 
     findRation(req, res){
         let data = JSON.parse(req.body.data);
-        searchDao.findRation(req.session.sessionUser.id, req.session.sessionCompilation._id, data.rationRepId, data.keyword, function (err, data) {
+        searchDao.findRation(req.session.sessionUser.id, req.session.sessionCompilation._id, data.rationRepId, data.keyword, data.skip, function (err, data) {
             callback(req, res, err, '', data);
         });
     }

+ 40 - 23
modules/complementary_ration_lib/models/searchModel.js

@@ -62,7 +62,13 @@ class SearchDao{
         return ration;
     }
 
-    async findRation(userId, compilationId, rationRepId, keyword, callback){
+    //@param {Object}skip({std: Number, comple: Number})
+    async findRation(userId, compilationId, rationRepId, keyword, skip, callback){
+        //每次限制结果数
+        const limit = 50;
+        //结果数
+        let resultCount = 0,
+            rst = {data: [], count: null};
         try{
             //是否需要查找补充定额
             let findCompleRtion = rationRepId.length > 0 && rationRepId.includes(compleRationLib) ? true : false;
@@ -78,16 +84,6 @@ class SearchDao{
                     '$or': [{'isDeleted': {"$exists":false}}, {'isDeleted': null}, {'isDeleted': false}, {deleteInfo: null}]
                 }]
             };
-
-            let stdGljIds = [],
-                comGljIds = [];
-            let stdRations = rationRepId.length === 0 ? [] : await stdRationModel.find(filter);
-            for(let i = 0, len = stdRations.length; i < len; i++){
-                stdRations[i]._doc.type = 'std';
-                for(let glj of stdRations[i].rationGljList){
-                    stdGljIds.push(glj.gljId);
-                }
-            }
             let compleFilter = {
                 userId: userId,
                 compilationId: compilationId,
@@ -97,18 +93,39 @@ class SearchDao{
                     '$or': [{deleteInfo: null}, {'deleteInfo.deleted': false}]
                 }]
             };
-            let compleRations = findCompleRtion ? await compleRationModel.find(compleFilter) : [];
-            for(let i = 0, len = compleRations.length; i <len; i++){
-                compleRations[i]._doc.type = 'complementary';
-                for(let glj of compleRations[i].rationGljList){
-                    if(glj.type === 'std'){
-                        stdGljIds.push(glj.gljId);
-                    }
-                    else {
-                        comGljIds.push(glj.gljId);
+            //结果数
+            if (skip && skip.std === 0 && skip.comple === 0) {
+                resultCount += rationRepId.length === 0 ? 0 : await stdRationModel.find(filter).count();
+                resultCount += findCompleRtion ? await compleRationModel.find(compleFilter).count() : 0;
+                rst.count = resultCount;
+            }
+            //搜索定额
+            let stdGljIds = [],
+                comGljIds = [];
+            let stdRations = rationRepId.length === 0 ? [] : await stdRationModel.find(filter).sort({code: 1}).skip(skip.std).limit(limit);
+            for(let i = 0, len = stdRations.length; i < len; i++){
+                stdRations[i]._doc.type = 'std';
+                for(let glj of stdRations[i].rationGljList){
+                    stdGljIds.push(glj.gljId);
+                }
+            }
+            let compleRations = [];
+            let residueLimit = limit - stdRations.length;
+            if (residueLimit > 0) {
+                compleRations = findCompleRtion ? await compleRationModel.find(compleFilter).sort({code: 1}).skip(skip.comple).limit(residueLimit) : [];
+                for(let i = 0, len = compleRations.length; i <len; i++){
+                    compleRations[i]._doc.type = 'complementary';
+                    for(let glj of compleRations[i].rationGljList){
+                        if(glj.type === 'std'){
+                            stdGljIds.push(glj.gljId);
+                        }
+                        else {
+                            comGljIds.push(glj.gljId);
+                        }
                     }
                 }
             }
+
             //设置悬浮信息
             stdGljIds = Array.from(new Set(stdGljIds));
             comGljIds = Array.from(new Set(comGljIds));
@@ -178,11 +195,11 @@ class SearchDao{
                 }
                 ration._doc.hint = hintsArr.join('<br>');
             }
-
-
-            callback(0, stdRations.concat(compleRations));
+            rst.data = stdRations.concat(compleRations);
+            callback(0, rst);
         }
         catch(err){
+            console.log(err);
             callback(err, null);
         }
     }

+ 4 - 19
modules/main/facade/ration_facade.js

@@ -172,7 +172,7 @@ async function getDefaultProgramID(data) {
     let searchDao = new SearchDao();
     let programID;
     let std = await searchDao.getRationItem(data.userID,data.compilationId,[data.libID],data.code, null);
-    if(std.feeType == undefined || std.feeType == null || std.feeType ==''){//定额取费专业为空的情况下,取项目属性中的定额取费专业ID
+    if(std == null||std ==undefined || std.feeType == undefined || std.feeType == null || std.feeType ==''){//定额取费专业为空的情况下,取项目属性中的定额取费专业ID
         programID = await getProgramForProject(data.projectID);
     }else {
         programID = std.feeType;
@@ -326,22 +326,7 @@ async function getCustomerCoe(projectID,rationID,seq,compilation){//取自定义
 
 //对于多单价,多组成物消耗量的编办,通过这个方法获取单价、组成物消耗量的字段,
 function getExtendData(property,compilation) {
-    let ext = {};
-    let region = property.region;
-    let taxType = property.taxType;
-    if(compilation.priceProperties && compilation.priceProperties.length > 0){//如果是具有多单价的编办,取单价对应的字段
-          let priceProperty  = _.find(compilation.priceProperties,{region:region,taxModel:parseInt(taxType)});
-          if(priceProperty){
-              ext['priceField'] =  priceProperty.price.dataCode;
-          }
-    }
-    if(compilation.consumeAmtProperties && compilation.consumeAmtProperties.length > 0){
-          let  consumeAmt =   _.find(compilation.consumeAmtProperties,{region:region,taxModel:parseInt(taxType)});
-          if(consumeAmt){
-              ext['quantityField'] =  consumeAmt.consumeAmt.dataCode;
-          }
-    }
-    return _.isEmpty(ext)?null:ext;
+    return projectDao.getExtendData(property,compilation);
 }
 
 
@@ -415,7 +400,7 @@ async function addRationGLJ(std,newRation,compilation) {
                 newGLJ.materialType = std_glj.materialType;
                 newGLJ.materialCoe = std_glj.materialCoe;
                 newGLJ.createType = 'normal';
-                let info =  await  ration_glj_facade.getInfoFromProjectGLJ(newGLJ,unitPriceFileId,ext);
+                let info =  await ration_glj_facade.getInfoFromProjectGLJ(newGLJ,unitPriceFileId,ext);
                 newGLJ = ration_glj_facade.createNewRecord(info);
                 newRationGLJList.push(newGLJ);
                 rationGLJShowList.push(info);
@@ -532,7 +517,7 @@ function createRationAss(std) {
     if(std.hasOwnProperty('rationAssList')&&std.rationAssList.length>0){
         for(let i=0;i<std.rationAssList.length;i++){
             let ass = std.rationAssList[i];
-            ass.actualValue = ass.stdValue;
+            ass._doc.actualValue = ass.stdValue;
             rationAssList.push(ass);
         }
     }

+ 19 - 0
modules/pm/models/project_model.js

@@ -695,6 +695,25 @@ ProjectsDAO.prototype.getProjectProperty = async function (projectId) {
     return projectData.property;
 };
 
+ProjectsDAO.prototype.getExtendData = function(property,compilation) {
+    let ext = {};
+    let region = property.region;
+    let taxType = property.taxType;
+    if(compilation.priceProperties && compilation.priceProperties.length > 0){//如果是具有多单价的编办,取单价对应的字段
+        let priceProperty  = _.find(compilation.priceProperties,{region:region,taxModel:parseInt(taxType)});
+        if(priceProperty){
+            ext['priceField'] =  priceProperty.price.dataCode;
+        }
+    }
+    if(compilation.consumeAmtProperties && compilation.consumeAmtProperties.length > 0){
+        let  consumeAmt =   _.find(compilation.consumeAmtProperties,{region:region,taxModel:parseInt(taxType)});
+        if(consumeAmt){
+            ext['quantityField'] =  consumeAmt.consumeAmt.dataCode;
+        }
+    }
+    return _.isEmpty(ext)?null:ext;
+}
+
 
 /**
  * 获取当前用户的建设项目数据

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

@@ -120,6 +120,9 @@
                   <div class="side-tabs">
                       <ul class="nav nav-tabs" role="tablist">
                           <li class="nav-item">
+                              <a class="nav-link px-3" href="javascript:void(0)" id = 'locateTab' relaPanel="#locate">查找定位</a>
+                          </li>
+                          <li class="nav-item">
                               <a class="nav-link px-3" href="javascript:void(0)" id = 'stdBillsGuidanceTab' relaPanel="#zy">清单指引</a>
                           </li>
                          <!-- <li class="nav-item">
@@ -312,6 +315,71 @@
                       <div class="main-side" style="display: inline-block">
                           <div class="resize" id="sideResize" style="width: 1%; height: 100%; resize:horizontal; cursor: w-resize; float: left; background: #F1F1F1"></div>
                           <div class="tab-content" style="width: 99%; height: 100%; float: left">
+                              <!--查找定位-->
+                              <div class="tab-pane" id="locate">
+                                  <div class="sidebar-tools-bar container-fluid tools-bar-height-y">
+                                      <div class="p-1 row">
+                                          <div class="input-group input-group-sm col-12">
+                                              <input type="text" class="form-control form-control-sm" placeholder="查找内容" value="">
+                                              <div class="input-group-append">
+                                                  <button class="btn btn-secondary btn-sm" type="button"><i class="fa fa-search" aria-hidden="true"></i></button>
+                                              </div>
+                                          </div>
+                                          <div class="form-group col-12 mb-1">
+                                              <div class="form-check form-check-inline">
+                                                  <input class="form-check-input" type="radio" name="content_type" id="bills" value="option1">
+                                                  <label class="form-check-label" for="bills">分项/清单</label>
+                                              </div>
+                                              <div class="form-check form-check-inline">
+                                                  <input class="form-check-input" type="radio" name="content_type" id="ration" value="option2">
+                                                  <label class="form-check-label" for="ration">定额</label>
+                                              </div>
+                                              <div class="form-check form-check-inline">
+                                                  <input class="form-check-input" type="radio" name="content_type" id="raion_glj" value="option3">
+                                                  <label class="form-check-label" for="raion_glj">人材机</label>
+                                              </div>
+                                              <!--<div class="form-check form-check-inline">
+                                                  <input class="form-check-input" type="radio" name="inlineRadioOptions" id="bookmark" value="option4">
+                                                  <label class="form-check-label" for="bookmark">书签标注</label>
+                                              </div>-->
+                                          </div>
+                                          <!--搜索分项/清单 出现-->
+                                          <div class="col-12"  id="outstandingOptions">
+                                              <div class="form-group form-check mb-0">
+                                                  <input type="checkbox" class="form-check-input" id ="outstanding">
+                                                  <label class="form-check-label" for="outstanding">超 <input type="number" style="width:50px"> % 时突出显示</label>
+                                              </div>
+                                          </div>
+                                      </div>
+                                  </div>
+                                  <!--上下结构-->
+                                  <div class="top-content" style="overflow: hidden">
+                                      <div class="" id="locate_result" >
+                                      </div>
+                                  </div>
+                                  <div class="resize" id="locate_resize" style="background: #F1F1F1"></div>
+                                  <div class="bottom-content">
+                                      <div class="" id="locate_sub"></div>
+                                  </div>
+                                <!--  <div class="main-data-side-y">
+                                      <table class="table table-sm table-bordered">
+                                          <tr><th>编码</th><th>项目名称</th><th>工程量</th><th>单位</th><th>综合单价</th><th>综合合价</th></tr>
+                                      </table>
+                                  </div>
+                                  <div class="sidebar-bottom container-fluid">
+                                      <div class="row">
+                                          <div class="col-lg-12">
+                                              <table class="table table-sm table-bordered">
+                                                  <tr><th>定额编号</th><th>定额名称</th></tr>
+                                                  <tr><td>AA0047</td><td>人工沟槽 较硬岩 槽深4m以内</td></tr>
+                                                  <tr><td>AA0005</td><td>人工挖沟槽土方 槽深4m以内</td></tr>
+                                              </table>
+                                          </div>
+                                      </div>
+                                  </div>-->
+
+                              </div>
+
                               <!--清单指引-->
                               <div class="tab-pane" id="zy">
                                   <div class="sidebar-tools-bar container-fluid tools-bar-height-z">
@@ -1782,6 +1850,7 @@
     <script type="text/javascript" src="/web/building_saas/main/js/views/sub_fee_rate_views.js"></script>
     <script type="text/javascript" src="/web/building_saas/main/js/views/calc_base_view.js"></script>
     <script type="text/javascript" src="/web/building_saas/main/js/views/project_property_labour_coe_view.js"></script>
+    <script type="text/javascript" src="/web/building_saas/main/js/views/locate_view.js"></script>
     <script type="text/javascript" src="/web/building_saas/complementary_ration_lib/js/main.js"></script>
     <script type="text/javascript" src="/public/web/storageUtil.js"></script>
     <!-- endinject -->

+ 38 - 0
web/building_saas/main/js/views/locate_view.js

@@ -0,0 +1,38 @@
+/**
+ * Created by zhang on 2018/11/16.
+ */
+let locateObject={
+
+
+    init:function () {
+        let tab_content = $('#locate').parent();
+        $('#locate_result').height(tab_content.height()*0.6);
+        $('#locate_sub').height(tab_content.height()*0.4);
+
+
+    },
+
+    onshow:function () {
+
+        locateObject.init();
+        console.log('#locate is now visible');
+        console.log($("#locate").is(':visible'))
+    }
+
+}
+
+
+
+
+/*
+$("input[name='install_setting_radios']").each(function(){
+    $(this).click(function(){
+        var settingVal = $(this).val();
+        let installSetting = projectInfoObj.projectInfo.property.installSetting;
+        if(installSetting==settingVal){
+            return;
+        }
+        projectObj.project.installation_fee.updateInstallSetting(settingVal);
+        installationFeeObj.cleanPositionIfNeed(settingVal);
+    });
+});*/

+ 3 - 1
web/building_saas/main/js/views/side_tools.js

@@ -103,7 +103,7 @@ var sideToolsObj = {
                 sideResizeEles.farElement.css('width', '33.333333%');
             }
             $('.main-side .tab-pane').hide();
-            tabPanel.show();
+            id === 'locateTab'?tabPanel.show(locateObject.onshow):tabPanel.show();//locateTab要等div显示后才执行刷新操作
             loadSize(sideResizeEles, 'width', function(){
                 if(id === 'stdBillsGuidanceTab'){//清单指引
                     loadSize(billsGuidanceLibResizeEles, 'height', function(){
@@ -116,6 +116,8 @@ var sideToolsObj = {
                 else if(id === 'blockLibTab'){//定额库
                     loadSize(blockLibResizeEles, 'height', function(){
                     });
+                }else if(id == "locateTab"){
+
                 }
                 else{//清单库
                     loadSize(billsLibResizeEles, 'height', function(){

+ 61 - 16
web/building_saas/main/js/views/std_ration_lib.js

@@ -5,6 +5,7 @@
 /*var rationChapterSpread, sectionRationsSpread;*/
 
 var rationLibObj = {
+    searchLimit: 50,
     libType: {complementary: 0, std: 1},
     compleRationLibId: 'compleRationLib',
     doAfterGetRationTree: null, //获取章节树回调
@@ -214,6 +215,19 @@ var rationLibObj = {
             });
         }
     },
+    //滚动条到底部加载
+    onRationSpreadTopRowChanged: function (sender, args) {
+        let me = rationLibObj;
+        if(me.searching) {
+            return;
+        }
+        let bottomRow = args.sheet.getViewportBottomRow(1),
+            rowCount = args.sheet.getRowCount();
+        //滚到了底部
+        if (bottomRow + 1 - me.sectionRationsSetting.emptyRows === rowCount - me.sectionRationsSetting.emptyRows) {
+            seachRation();
+        }
+    },
     loadStdRationContextMenu: function () {
         let rationSpread = rationLibObj.sectionRationsSpread, rationSheet = rationSpread.getActiveSheet(),  rationModel = projectObj.project.Ration;;
         $.contextMenu({
@@ -449,6 +463,25 @@ var rationLibObj = {
         let defaultLib = _.find(ration_lib,{'isDefault':true});
         let libID = defaultLib?defaultLib.id:ration_lib[0].id;
         return parseInt(libID);
+    },
+    //@param {Array}datas(resultCache) @return {Object}
+    //搜索skip信息,不能被每页搜索数整除,则说明上次搜索已经搜索完整
+    getSearchSkip: function (datas) {
+        if (datas.length % this.searchLimit !== 0) {
+            return null;
+        }
+        let skip = {std: 0, comple: 0};
+        if (!datas || !Array.isArray(datas) || datas.length === 0) {
+            return skip;
+        }
+        for (let data of datas) {
+            if (data.type === 'std') {
+                skip.std++;
+            } else {
+                skip.comple++;
+            }
+        }
+        return skip;
     }
 };
 
@@ -489,7 +522,7 @@ $('#rationSearchKeyword').keyup(function () {
     let keyword = $('#rationSearchKeyword').val();
     if(keyword === ''){
         if($('#rationSearchResult').is(':visible')){
-            rationLibObj.resultCache = null;
+            rationLibObj.resultCache = [];
             $('#rationSearchResult').hide();
             $(".main-data-side-search", $('#rationSearchResult')).height(0);
             switchRationSearchMode(0);
@@ -501,6 +534,7 @@ $('#rationSearchKeyword').keyup(function () {
 
 //变换搜索本定额、全部定额状态
 function switchRationSearchMode(mode) {
+    rationLibObj.resultCache = [];
     //搜索本定额
     if(mode === 0){
         $('#curRationLib').removeClass('btn-light');
@@ -534,11 +568,16 @@ $('#allRationLibs').click(function () {
 });
 
 //搜索
-$('#rationSearch').click(function () {
+function seachRation(){
+    let skip = rationLibObj.getSearchSkip(rationLibObj.resultCache);
+    if (!skip) {
+        return;
+    }
+    rationLibObj.searching = true;
     var keyword = $('#rationSearchKeyword').val();
     if(keyword === ''){
         if($('#rationSearchResult').is(':visible')){
-            rationLibObj.resultCache = null;
+            rationLibObj.resultCache = [];
             $('#rationSearchResult').hide();
             $(".main-data-side-search", $('#rationSearchResult')).height(0);
             autoFlashHeight();
@@ -610,33 +649,29 @@ $('#rationSearch').click(function () {
         });
     };
     var showResult = function (result) {
-        rationLibObj.resultCache = result;
         if(!rationLibObj.resultSpread){
             let resultSpread = SheetDataHelper.createNewSpread($('.main-data-side-search')[0]);
             rationLibObj.resultSpread = resultSpread;
             bindContextmenuOpr(resultSpread.getActiveSheet());
             SheetDataHelper.loadSheetHeader(rationLibObj.sectionRationsSetting, resultSpread.getActiveSheet());
             resultSpread.bind(GC.Spread.Sheets.Events.CellDoubleClick, rationLibObj.onRationSpreadCellDoubleClick);
+            resultSpread.bind(GC.Spread.Sheets.Events.TopRowChanged, rationLibObj.onRationSpreadTopRowChanged);
         }else {
             rationLibObj.resultSpread.refresh();
         }
         SheetDataHelper.loadSheetData(rationLibObj.sectionRationsSetting, rationLibObj.resultSpread.getActiveSheet(), result);
         rationLibObj.setTagForHint(rationLibObj.resultSpread.getActiveSheet(), result);
+        rationLibObj.resultCache = result;
     };
     $.bootstrapLoading.start();
-    CommonAjax.post('/complementaryRation/api/findRation', {'user_id': userID, 'rationRepId': rationLibIDs, 'keyword': keyword}, function (result) {
-        //sort
-        result.sort(function (a, b) {
-            let rst = 0;
-            if(a.code > b.code) rst = 1;
-            else if(a.code < b.code) rst = -1;
-            return rst;
-        });
+    CommonAjax.post('/complementaryRation/api/findRation', {'user_id': userID, 'rationRepId': rationLibIDs, 'keyword': keyword, skip: skip}, function (result) {
         var resultObj = $('#rationSearchResult');
-        $('#rationSearchCount').text(`搜索结果:${result.length.toString()}`);
-        $('a', result).unbind('click');
+        if (result.count !== null) {
+            $('#rationSearchCount').text(`搜索结果:${result.count}`);
+        }
+        $('a', resultObj).unbind('click');
         $('a', resultObj).bind('click', function () {
-            rationLibObj.resultCache = null;
+            rationLibObj.resultCache = [];
             switchRationSearchMode(0);
             resultObj.hide();
             $(".main-data-side-search", resultObj).height(0);
@@ -645,9 +680,19 @@ $('#rationSearch').click(function () {
         });
         resultObj.show();
         $(".main-data-side-search", resultObj).height($(window).height() - $(".header").height() - $(".toolsbar").height() - 64);
-        showResult(result);
+        showResult(rationLibObj.resultCache.concat(result.data));
+        rationLibObj.searching = false;
+        //以防一开始就需要加载后面的分页数据
+        if (result.data.length > 0) {
+            rationLibObj.onRationSpreadTopRowChanged({}, {sheet: rationLibObj.resultSpread.getActiveSheet()});
+        }
         $.bootstrapLoading.end();
     }, function () {
+        rationLibObj.searching = false;
         $.bootstrapLoading.end();
     });
+}
+$('#rationSearch').click(function () {
+    rationLibObj.resultCache = [];
+    seachRation();
 });