Explorar o código

清单精灵单/多选,上拉框、定额库搜索本定额/全部定额

zhongzewei %!s(int64=6) %!d(string=hai) anos
pai
achega
d68be96e4e

+ 1 - 1
modules/complementary_ration_lib/models/searchModel.js

@@ -62,7 +62,7 @@ class SearchDao{
     async findRation(userId, rationRepId, keyword, callback){
         try{
             let filter = {
-                'rationRepId': rationRepId,
+                'rationRepId': {$in: rationRepId},
                 '$and': [{
                     '$or': [{'code': {'$regex': keyword, $options: '$i'}}, {'name': {'$regex': keyword, $options: '$i'}}]
                 }, {

+ 1 - 0
public/web/sheet/sheet_data_helper.js

@@ -179,6 +179,7 @@ var SheetDataHelper = {
                             .css("box-shadow", "1px 2px 5px rgba(0,0,0,0.4)")
                             .css("font", "0.9rem Calibri")
                             .css("background", "Black")
+                            .css("color", "White")
                             .css("padding", 5)
                             .attr("id", 'autoTip');
                         $(div).hide();

+ 1 - 0
public/web/tree_sheet/tree_sheet_helper.js

@@ -381,6 +381,7 @@ var TREE_SHEET_HELPER = {
         };
         TreeNodeCellType.prototype.processMouseEnter = function(hitinfo){
             if(hitinfo.sheet.name() === 'stdBillsGuidance_bills'){
+
                 TREE_SHEET_HELPER.delayShowTips(hitinfo,setting);
             }
         };

+ 6 - 3
web/building_saas/complementary_glj_lib/js/glj.js

@@ -404,13 +404,16 @@ let repositoryGljObj = {
                 }
                 else {
                     $('#gljAlertBtn').click();
-                    $('#aleConfBtn').click(function () {
+                    $('#aleConfBtn').unbind('click');
+                    $('#aleConfBtn').bind('click', function () {
                         me.workBook.getSheet(0).setActiveCell(me.editingRowIdx, focusToCol);
                     });
-                    $('#gljAleClose').click(function () {
+                    $('#gljAleClose').unbind('click');
+                    $('#gljAleClose').bind('click', function () {
                         me.workBook.getSheet(0).setActiveCell(me.editingRowIdx, focusToCol);
                     });
-                    $('#aleCanceBtn').click(function () {
+                    $('#aleCanceBtn').unbind('click');
+                    $('#aleCanceBtn').bind('click', function () {
                         me.addGljObj = null;
                         me.workBook.getSheet(0).suspendPaint();
                         me.workBook.getSheet(0).suspendEvent();

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

@@ -171,7 +171,7 @@
                                           <div class=" main-data-bottom ovf-hidden" style="width: 50%; float: left; margin: 0; padding:0;" id="assSpread"></div>
                                       </div>
                                       <div class="main-data-bottom ovf-hidden" style="display: none" id="comments">
-                                          <textarea class="form-control" rows="8" readonly=""></textarea>
+                                          <textarea style="font-size: 0.9rem" class="form-control" rows="8" readonly=""></textarea>
                                       </div>
                                       <div id="tzjnrCon" class="container-fluid main-data-bottom" style="background: #F1F1F1; overflow: hidden">
                                           <div class="row" style="overflow: hidden">
@@ -406,7 +406,11 @@
                                           <!--搜索结果窗体-->
                                           <div class="side-search-box col-12 p-0" id="rationSearchResult" style="display: none;">
                                               <div class="d-flex justify-content-between">
-                                                  <span id="rationSearchCount"></span>
+                                                  <div class="my-1">
+                                                      <span id="rationSearchCount"></span>
+                                                      <button id="curRationLib" type="button" class="btn btn-sm btn-secondary" style="margin-left: 15px;">本定额</button>
+                                                      <button id="allRationLibs" type="button" class="btn btn-sm btn-light">全部定额</button>
+                                                  </div>
                                                   <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="w-100 main-data-side-search"></div>
@@ -1641,10 +1645,6 @@
                 $("#checkCount").text(checkCount);
 
             }
-            /*$('#billsGuidance_items').keydown(function(e){
-                if(e.keyCode === 18){
-                }
-            });*/
 
             /*$(document).ready(function(){
                 document.addEventListener('visibilitychange', function() {

+ 1 - 1
web/building_saas/main/js/views/main_tree_col.js

@@ -255,7 +255,7 @@ let MainTreeCol = {
              if(node.sourceType == ModuleNames.bills &&projectObj.ifItemCharHiden(setting)){//清单、并且项目特征列隐藏的时候悬浮提示
                 tips = node.data.itemCharacterText?node.data.itemCharacterText:'';
              }
-             console.log(setting);
+           //  console.log(setting);
             let dynamicCombo = sheetCommonObj.getTipsCombo(true,tips,setting);//sheetCommonObj.getDynamicCombo(true);
             dynamicCombo.itemHeight(10).items(['m', 'm2', 'm3', 'km', 't', 'kg', '台班', '工日', '昼夜', '元', '项', '处', '个', '件',
                 '根', '组', '系统', '台', '套', '株', '丛', '缸', '支', '只', '块', '座', '对', '份', '樘', '攒', '榀']).editable(true);

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

@@ -631,7 +631,6 @@ var projectObj = {
                 }
             }
             if(!$("#de").is(":visible"))  $('#stdRationTab').click();
-            console.log($('#stdRationLibSelect').select().val());
         }
 
     },
@@ -2162,7 +2161,7 @@ $('#recColSetting').click(function () {
 $('#property_default').click(function () {
     let project = projectObj.project,
         projectID = project.ID();
-    //清除窗口拖动比例缓存
+    //todo 清除窗口拖动比例缓存
 
     CommonAjax.post('/pm/api/defaultSettings', {user_id: userID, projectID: projectID}, function (rstData) {
         window.location.href = `/main?project=${projectID}`;

+ 63 - 5
web/building_saas/main/js/views/std_billsGuidance_lib.js

@@ -10,6 +10,8 @@
 
 //清单指引/精灵获取完清单数据后的回调函数
 let doAfterLoadGuidance = null;
+//选项单选多选状态(按住alt为多选) 单选:0 多选:1
+let billsGuidanceSelMode = 0;
 
 const billsGuidance = (function () {
     let currentLib = null;
@@ -484,9 +486,11 @@ const billsGuidance = (function () {
         module.tree.loadDatas(datas);
         if(module === bills){
             initExpandStat();
-            setBillsHint(bills.tree.items, stdBillsJobData, stdBillsFeatureData);
         }
         module.controller.showTreeData();
+        if(module === bills){
+            setBillsHint(bills.tree.items, stdBillsJobData, stdBillsFeatureData);
+        }
     }
     //项目指引表焦点控制
     //@param {Number}row @return {void}
@@ -761,15 +765,16 @@ const billsGuidance = (function () {
             this.isEscKey=false;
             this.displayText='';
         }
-        function getHtml(node, cellRect, cellStyle) {
+       /* function getHtml(node, cellRect, cellStyle, top) {
             if(!node){
                 return '';
             }
             let height = cellRect.height;
+            top = top.replace('px', '');
             let htmlArr = [];
             let options = getOptions(node.data, bills.tree.selected.elf.datas);
             //let optionsTitle = node.data.options.split(';').join('\n');
-            htmlArr.push(`<div style="height: ${height}px; background: ${cellStyle.backColor};overflow: hidden; white-space: nowrap; text-overflow: ellipsis">${node.data.options}</div><div style="background: ${cellStyle.backColor};border: 1px solid; overflow: auto; height: ${options.length > 6 ? height*6 : height*options.length+5}px; font-size: 0.9rem;">`);
+            htmlArr.push(`<div style="height: ${height}px; background: ${cellStyle.backColor};overflow: hidden; white-space: nowrap; text-overflow: ellipsis">${node.data.options}</div><div id="optDiv" style="position: fixed; width: ${cellRect.width}px; top: ${top - (options.length - 2) * height - 5}px;background: ${cellStyle.backColor};border: 1px solid; overflow: auto; height: ${options.length > 6 ? height*6 : height*options.length+5}px; font-size: 0.9rem;">`);
             for(let opt of options){
                 htmlArr.push(`<div title="${opt.name ? opt.name : ''}" class="elf-options" style="height: ${height}px;overflow: hidden; white-space: nowrap; text-overflow: ellipsis">
                         <input rank="${opt.rank}" value="${opt.ID}" style="margin-left: 5px; vertical-align: middle" type="checkbox" 
@@ -777,6 +782,39 @@ const billsGuidance = (function () {
             }
             htmlArr.push(`</div>`);
             return htmlArr.join('');
+        }*/
+        function setOptionsDiv($editor, node, cellRect, cellStyle, top) {
+            if(!node){
+                return '';
+            }
+            let height = cellRect.height;
+            top = top.replace('px', '');
+            let options = getOptions(node.data, bills.tree.selected.elf.datas);
+            let $editInput = $(`<div style="height: ${height}px; background: ${cellStyle.backColor};overflow: hidden; white-space: nowrap; text-overflow: ellipsis">${node.data.options}</div>`),
+                $optDiv = $(`<div style="position: fixed; width: ${cellRect.width}px; top: ${top - (options.length - 2) * height - 5}px;background: ${cellStyle.backColor};border: 1px solid; overflow: auto; height: ${options.length > 6 ? height*6 : height*options.length+5}px; font-size: 0.9rem;"></div>`);
+            for(let opt of options){
+                let $opt = $(`<div title="${opt.name ? opt.name : ''}" class="elf-options" style="height: ${height}px;overflow: hidden; white-space: nowrap; text-overflow: ellipsis"></div>`),
+                    $optInput = $(`<input rank="${opt.rank}" value="${opt.ID}" style="margin-left: 5px; vertical-align: middle" type="checkbox" 
+                    ${node.data.optionChecked && _.find(node.data.optionChecked, {ID: opt.ID}) ? 'checked' : ''}>`);
+                $opt.text(`${opt.name ? opt.name : ''}`);
+                $opt.prepend($optInput);
+                $optDiv.append($opt);
+                //选项复选框点击监听
+                $optInput.click(function () {
+                    //单选
+                    if(billsGuidanceSelMode === 0){
+                        let $allInput = $optDiv.find('input');
+                        for(let input of $allInput){
+                            $(input).prop('checked', false);
+                        }
+                        $(this).prop('checked', 'checked');
+                    } else {//多选
+
+                    }
+                });
+            }
+            $editor.append($editInput);
+            $editor.append($optDiv);
         }
         //选择后处理
         function doAfterSel(node) {
@@ -852,8 +890,10 @@ const billsGuidance = (function () {
                 $editor.css("background", "white");
                 $editor.css("width", cellRect.width);
                 $editor.attr("gcUIElement", "gcEditingInput");
+                let activeCellTop = $editor.parent().parent().css('top');
                 let node = bills.tree.selected.elf.tree.items[elfSheet.getActiveRowIndex()];
-                $editor.html(getHtml(node, cellRect, cellStyle));
+                setOptionsDiv($editor, node, cellRect, cellStyle, activeCellTop);
+                this.isEscKey = false;
             }
         }
         OptionsCellType.prototype.deactivateEditor = function (editorContext, context) {
@@ -981,6 +1021,7 @@ const billsGuidance = (function () {
         for(let item of items){
             itemsMapping[item.id] = item;
         }
+        let tagInfo = [];
         for(let billsNode of billsNodes){
             let hintArr = [];
             let billsItems = billsNode.data.items;
@@ -1024,9 +1065,15 @@ const billsGuidance = (function () {
                 hintArr.push(billsNode.data.recharge);
             }*/
             if(hintArr.length > 0){
-                bills.workBook.getActiveSheet().setTag(billsNode.serialNo(), 0, hintArr.join('\n'));
+                tagInfo.push({row: billsNode.serialNo(), value: hintArr.join('\n')});
             }
         }
+        let sheet = bills.workBook.getActiveSheet();
+        renderSheetFunc(sheet, function () {
+            for(let tagI of tagInfo){
+                sheet.setTag(tagI.row, 0, tagI.value);
+            }
+        });
     }
     //初始选择清单指引库
     //@param {Number}libID @return {void}
@@ -1362,6 +1409,17 @@ const billsGuidance = (function () {
             billsLibObj.clearHighLight(bills.workBook);
             refreshWorkBook();
         });
+        //监听alt建,确定选项单选多选状态
+        $('#billsGuidance_items').keydown(function(e){
+            if(e.keyCode === 18){
+                billsGuidanceSelMode = 1;
+            }
+        });
+        $('#billsGuidance_items').keyup(function(e){
+            if(e.keyCode === 18){
+                billsGuidanceSelMode = 0;
+            }
+        });
     }
     //刷新表
     //@return {void}

+ 1 - 1
web/building_saas/main/js/views/std_bills_lib.js

@@ -225,7 +225,7 @@ var billsLibObj = {
                 that.stdBillsTree.setRootExpanded(that.stdBillsTree.roots, false);
             }
             stdBillsTreeController.showTreeData();
-            billsLibObj.setTagForHint(that.stdBillsTree.items);
+            //billsLibObj.setTagForHint(that.stdBillsTree.items);
             that.showBillsRela(that.stdBillsTree.firstNode());
             stdBillsTreeController.bind(TREE_SHEET_CONTROLLER.eventName.treeSelectedChanged, that.showBillsRela);
             that.stdBillsSpread.unbind(GC.Spread.Sheets.Events.CellDoubleClick);

+ 70 - 22
web/building_saas/main/js/views/std_ration_lib.js

@@ -67,7 +67,6 @@ var rationLibObj = {
         var that = this;
         var showRationChapterTree = function (datas) {
             var rationChapterTree = idTree.createNew({id: 'ID', pid: 'ParentID', nid: 'NextSiblingID', rootId: -1, autoUpdate: false});
-            console.log(that);
             that.tree = rationChapterTree;
             var rationChapterTreeController = TREE_SHEET_CONTROLLER.createNew(rationChapterTree, that.rationChapterSpread.getActiveSheet(), that.rationChapterTreeSetting);
             rationChapterTree.loadDatas(datas);
@@ -132,9 +131,6 @@ var rationLibObj = {
             sheet.setTag(i, 0, '');
         }
         for(let i = 0, len = datas.length; i < len; i++){
-            if(datas[i].code === 'AA0032'){
-                console.log(datas[i]);
-            }
             sheet.setTag(i, 0, datas[i].hint ? datas[i].hint : '');
         }
         sheet.resumePaint();
@@ -448,13 +444,50 @@ $('#rationSearchKeyword').keyup(function () {
         if($('#rationSearchResult').is(':visible')){
             $('#rationSearchResult').hide();
             $(".main-data-side-search", $('#rationSearchResult')).height(0);
+            switchRationSearchMode(0);
             autoFlashHeight();
             rationLibObj.refreshSpread();
         }
     }
 });
+
+//变换搜索本定额、全部定额状态
+function switchRationSearchMode(mode) {
+    //搜索本定额
+    if(mode === 0){
+        $('#curRationLib').removeClass('btn-light');
+        $('#curRationLib').addClass('btn-secondary');
+        $('#allRationLibs').removeClass('btn-secondary');
+        $('#allRationLibs').addClass('btn-light');
+    } else {//搜索全部定额
+        $('#allRationLibs').removeClass('btn-light');
+        $('#allRationLibs').addClass('btn-secondary');
+        $('#curRationLib').removeClass('btn-secondary');
+        $('#curRationLib').addClass('btn-light');
+    }
+}
+
+//搜索本定额
+$('#curRationLib').click(function () {
+    if($(this).hasClass('btn-secondary')){
+        return;
+    }
+    switchRationSearchMode(0);
+    $('#rationSearch').click();
+});
+
+//搜索全部定额
+$('#allRationLibs').click(function () {
+    if($(this).hasClass('btn-secondary')){
+        return;
+    }
+    switchRationSearchMode(1);
+    $('#rationSearch').click();
+});
+
+//搜索
 $('#rationSearch').click(function () {
-    var keyword = $('#rationSearchKeyword').val(), rationLibID = $('#stdRationLibSelect').val();
+    var keyword = $('#rationSearchKeyword').val();
     if(keyword === ''){
         if($('#rationSearchResult').is(':visible')){
             $('#rationSearchResult').hide();
@@ -464,19 +497,15 @@ $('#rationSearch').click(function () {
         }
         return;
     }
-    var getResultHtml = function (result) {
-        var html = [], i, serialNo;
-        html.push('<div class="d-flex justify-content-between">');
-        html.push('<span>搜索结果:');
-        html.push(result.length.toString());
-        html.push('</span>');
-        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="w-100 main-data-side-search">');
-        html.push('</div>');
-        return html.join('');
-    };
+    //获取搜索定额的库:本库/所有库
+    let rationLibIDs = [];
+    if($('#curRationLib').hasClass('btn-secondary')){
+        rationLibIDs.push($('#stdRationLibSelect').val());
+    } else {
+        for(let lib of projectInfoObj.projectInfo.engineeringInfo.ration_lib){
+            rationLibIDs.push(lib.id);
+        }
+    }
     let bindContextmenuOpr = function (sheet) {
         $.contextMenu({
             selector: '#rationSearchResult',
@@ -503,7 +532,23 @@ $('#rationSearch').click(function () {
                                     $(".main-data-side-search", $('#rationSearchResult')).height(0);
                                     autoFlashHeight();
                                     rationLibObj.refreshSpread();
-                                    rationLibObj.locateAtRation(data.rationRepId, data.code);
+                                    switchRationSearchMode(0);
+                                    if($('#stdRationLibSelect').select().val() != data.rationRepId){
+                                        let libOpts = $('#stdRationLibSelect').find('option');
+                                        for(let libOpt of libOpts){
+                                            if($(libOpt).val() == data.rationRepId){
+                                                $(libOpt).prop('selected', 'selected');
+                                                break;
+                                            }
+                                        }
+                                        $('#stdRationLibSelect').change();
+                                        rationLibObj.doAfterGetRationTree = function () {
+                                            this.locateAtRation(data.rationRepId, data.code);
+                                            this.doAfterGetRationTree = null;
+                                        };
+                                    } else {
+                                        rationLibObj.locateAtRation(data.rationRepId, data.code);
+                                    }
                                 }}
                         }
                     };
@@ -528,7 +573,8 @@ $('#rationSearch').click(function () {
         SheetDataHelper.loadSheetData(rationLibObj.sectionRationsSetting, rationLibObj.resultSpread.getActiveSheet(), result);
         rationLibObj.setTagForHint(rationLibObj.resultSpread.getActiveSheet(), result);
     };
-    CommonAjax.post('/complementaryRation/api/findRation', {'user_id': userID, 'rationRepId': rationLibID, 'keyword': keyword}, function (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;
@@ -537,11 +583,10 @@ $('#rationSearch').click(function () {
             return rst;
         });
         var resultObj = $('#rationSearchResult');
-        /*resultObj.empty();
-        resultObj.append(getResultHtml(result));*/
         $('#rationSearchCount').text(`搜索结果:${result.length.toString()}`);
         $('a', result).unbind('click');
         $('a', resultObj).bind('click', function () {
+            switchRationSearchMode(0);
             resultObj.hide();
             $(".main-data-side-search", resultObj).height(0);
             autoFlashHeight();
@@ -550,5 +595,8 @@ $('#rationSearch').click(function () {
         resultObj.show();
         $(".main-data-side-search", resultObj).height($(window).height() - $(".header").height() - $(".toolsbar").height() - 64);
         showResult(result);
+        $.bootstrapLoading.end();
+    }, function () {
+        $.bootstrapLoading.end();
     });
 });

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

@@ -146,10 +146,11 @@ $("#linkTZJNR").click(function () {
     $("#tzjnrCon").show();
     adaptiveTzjnrWidth();
     pageCCOprObj.resizeWidth();
-    //$("#add-rule").show();
     $("#add-rule p").not(":first").css('margin-bottom', 4);
     pageCCOprObj.active = true;
     refreshSubSpread();
+    contentOprObj.workBook.getActiveSheet().showColumn(0, GC.Spread.Sheets.HorizontalPosition.left);
+    characterOprObj.workBook.getActiveSheet().showColumn(0, GC.Spread.Sheets.HorizontalPosition.left);
     let selectedNode = projectObj.mainController.tree.selected;
     if (projectObj.project.property.addRule !== undefined) {
         setRule(projectObj.project.property.addRule);