zhongzewei 6 年之前
父節點
當前提交
b3521ecbf7

+ 69 - 0
modules/complementary_ration_lib/models/searchModel.js

@@ -69,15 +69,84 @@ class SearchDao{
                     '$or': [{'isDeleted': {"$exists":false}}, {'isDeleted': null}, {'isDeleted': false}, {deleteInfo: null}]
                 }]
             };
+            let stdGljIds = [],
+                comGljIds = [];
             let stdRations = 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);
+                }
             }
             filter.userId = userId;
             let compleRations = await compleRationModel.find(filter);
             for(let i = 0, len = compleRations.length; i <len; i++){
                 compleRations[i]._doc.type = 'complementary';
+                for(let glj of stdRations[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));
+            let gljIDMapping = {};
+            if(stdGljIds.length > 0){
+                let stdGljs = await stdGljModel.find({ID: {$in: stdGljIds}}, '-_id ID code name specs unit');
+                for(let stdGlj of stdGljs){
+                    gljIDMapping[stdGlj.ID] = stdGlj;
+                }
+            }
+            if(comGljIds.length > 0){
+                let comGljs = await complementaryGljModel.find({ID: {$in: stdGljIds}});
+                for(let comGlj of comGljs){
+                    gljIDMapping[comGlj.ID] = comGlj;
+                }
+            }
+            for(let ration of stdRations){
+                let hintsArr = [];
+                for(let rationGlj of ration.rationGljList){
+                    let glj = gljIDMapping[rationGlj.gljId];
+                    if(glj){
+                        hintsArr.push(` ${glj.code} ${glj.name}${glj.specs ? ' ' + glj.specs : ''} ${glj.unit} ${rationGlj.consumeAmt}`);
+                    }
+                }
+                hintsArr.push(`基价 元 ${ration.basePrice}`);
+                if(ration.jobContent && ration.jobContent.toString().trim() !== ''){
+                    hintsArr.push(`工作内容:`);
+                    hintsArr = hintsArr.concat(ration.jobContent.split('\n'));
+                }
+                if(ration.annotation && ration.annotation.toString().trim() !== ''){
+                    hintsArr.push(`附注:`);
+                    hintsArr = hintsArr.concat(ration.annotation.split('\n'));
+                }
+                ration._doc.hint = hintsArr.join('<br>');
+            }
+            for(let ration of compleRations){
+                let hintsArr = [];
+                for(let rationGlj of ration.rationGljList){
+                    let glj = gljIDMapping[rationGlj.gljId];
+                    if(glj){
+                        hintsArr.push(` ${glj.code} ${glj.name}${glj.specs ? ' ' + glj.specs : ''} ${glj.unit} ${rationGlj.consumeAmt}`);
+                    }
+                }
+                hintsArr.push(`基价 元 ${ration.basePrice}`);
+                if(ration.jobContent && ration.jobContent.toString().trim() !== ''){
+                    hintsArr.push(`工作内容:`);
+                    hintsArr = hintsArr.concat(ration.jobContent.split('\n'));
+                }
+                if(ration.annotation && ration.annotation.toString().trim() !== ''){
+                    hintsArr.push(`附注:`);
+                    hintsArr = hintsArr.concat(ration.annotation.split('\n'));
+                }
+                ration._doc.hint = hintsArr.join('<br>');
             }
+
+
             callback(0, stdRations.concat(compleRations));
         }
         catch(err){

+ 4 - 2
public/web/sheet/sheet_data_helper.js

@@ -192,14 +192,16 @@ var SheetDataHelper = {
                     }
                     $(this._toolTipElement).html(text);
                     //定额库定额特殊处理
-                    if($(hitinfo.sheet.getParent().qo).attr('id') === 'stdSectionRations'){
+                    if($(hitinfo.sheet.getParent().qo).attr('id') === 'stdSectionRations' ||
+                        $(hitinfo.sheet.getParent().qo).hasClass('main-data-side-search')){
                         let divWidth = $(this._fixedTipElement).width(),
                             divHeight = $(this._fixedTipElement).height();
                         if(divWidth > 600){
                             divWidth = 590;
                            $(this._toolTipElement).width(divWidth);
                         }
-                        $(this._toolTipElement).css("top", setting.pos.y  + hitinfo.y - divHeight).css("left", setting.pos.x - divWidth);
+                        let top = setting.pos.y  + hitinfo.y - divHeight < 0 ? 0 : setting.pos.y  + hitinfo.y - divHeight;
+                        $(this._toolTipElement).css("top", top).css("left", setting.pos.x - divWidth);
                     }
                     else{
                         $(this._toolTipElement).css("top", setting.pos.y + hitinfo.y +15).css("left", setting.pos.x + hitinfo.x + 15);

+ 32 - 26
web/building_saas/complementary_ration_lib/js/ration.js

@@ -70,33 +70,37 @@ let rationOprObj = {
     onSelectionChanged: function (sender, info) {
         if(info.oldSelections.length === 0 && info.newSelections.length > 0 || info.oldSelections[0].row !== info.newSelections[0].row){
             let row = info.newSelections[0].row;
-            let me = rationOprObj,
-                sheetGLJ = rationGLJOprObj.sheet, settingGLJ = rationGLJOprObj.setting,
-                sheetCoe = rationCoeOprObj.sheet, settingCoe = rationCoeOprObj.setting,
-                sheetAss = rationAssistOprObj.sheet, settingAss = rationAssistOprObj.setting,
-                sheetInst = rationInstObj.sheet, settingInst = rationInstObj.setting;
-            sheetCommonObj.cleanSheet(sheetGLJ, settingGLJ, -1);
-            sheetCommonObj.cleanSheet(sheetCoe, settingCoe, -1);
-            sheetCommonObj.cleanSheet(sheetAss, settingAss, -1);
-            sheetCommonObj.cleanSheet(sheetInst, settingInst, -1);
-            let cacheSection = me.getCache();
-            if (cacheSection && row < cacheSection.length) {
-                rationGLJOprObj.getGljItems(cacheSection[row], function () {
-                    me.workBook.focus(true);
-                });
-                rationCoeOprObj.getCoeItems(cacheSection[row], function () {
-                    me.workBook.focus(true);
-                });
-                rationAssistOprObj.getAssItems(cacheSection[row]);
-                rationInstObj.getInstItems(cacheSection[row], function () {
-                    me.workBook.focus(true);
-                });
-            }
-            else {
-                rationGLJOprObj.currentRationItem = null;
-            }
-            me.workBook.focus(true);
+            let me = rationOprObj;
+            me.rationSelInit(row);
+        }
+    },
+    rationSelInit: function (row) {
+        let me = rationOprObj,
+            sheetGLJ = rationGLJOprObj.sheet, settingGLJ = rationGLJOprObj.setting,
+            sheetCoe = rationCoeOprObj.sheet, settingCoe = rationCoeOprObj.setting,
+            sheetAss = rationAssistOprObj.sheet, settingAss = rationAssistOprObj.setting,
+            sheetInst = rationInstObj.sheet, settingInst = rationInstObj.setting;
+        sheetCommonObj.cleanSheet(sheetGLJ, settingGLJ, -1);
+        sheetCommonObj.cleanSheet(sheetCoe, settingCoe, -1);
+        sheetCommonObj.cleanSheet(sheetAss, settingAss, -1);
+        sheetCommonObj.cleanSheet(sheetInst, settingInst, -1);
+        let cacheSection = me.getCache();
+        if (cacheSection && row < cacheSection.length) {
+            rationGLJOprObj.getGljItems(cacheSection[row], function () {
+                me.workBook.focus(true);
+            });
+            rationCoeOprObj.getCoeItems(cacheSection[row], function () {
+                me.workBook.focus(true);
+            });
+            rationAssistOprObj.getAssItems(cacheSection[row]);
+            rationInstObj.getInstItems(cacheSection[row], function () {
+                me.workBook.focus(true);
+            });
+        }
+        else {
+            rationGLJOprObj.currentRationItem = null;
         }
+        me.workBook.focus(true);
     },
     isDef: function (v) {
         return v !== undefined && v !== null;
@@ -546,6 +550,8 @@ let rationOprObj = {
                     else if (a.code < b.code) rst = -1;
                     return rst;
                 });
+                let curRow = me.workBook.getActiveSheet().getActiveRowIndex();
+                me.rationSelInit(curRow);
                 //jobContent
                 if(jobContentOprObj ){
                     jobContentOprObj.currentRationItems = cacheSection;

+ 1 - 1
web/building_saas/glj/html/project_glj.html

@@ -157,7 +157,7 @@
                 </div>
             </div>
             <div class="modal-footer">
-                <button type="button" class="btn btn-primary" data-dismiss="modal" id="renameUnitFileConfirm" disabled>确定</button>
+                <button type="button" class="btn btn-primary" id="renameUnitFileConfirm">确定</button>
                 <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
             </div>
         </div>

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

@@ -446,7 +446,24 @@
                                           </div>
                                           <!--搜索结果窗体-->
                                           <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>
+                                                  <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>
                                           </div>
+                                          <!--
+                                          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('');
+                                          -->
                                       </div>
                                   </div>
                                   <div class="top-content" style="overflow: hidden">

+ 5 - 4
web/building_saas/main/js/views/project_glj_view.js

@@ -1262,10 +1262,10 @@ $(function () {
         projectGLJ.checkUnitFileName(this.value,function (data) {
             if(data){
                 $("#renameError_unitFile").text('已存在同名单价文件').show();
-                $('#renameUnitFileConfirm').attr("disabled","disabled");
+                //$('#renameUnitFileConfirm').attr("disabled","disabled");
             }else {
                 $("#renameError_unitFile").hide();
-                $('#renameUnitFileConfirm').removeAttr("disabled");
+               // $('#renameUnitFileConfirm').removeAttr("disabled");
             }
         });
 
@@ -1277,10 +1277,11 @@ $(function () {
         projectGLJ.checkUnitFileName(newName,function (data) {
             if(data){
                 $("#renameError_unitFile").text('已存在同名单价文件').show();
-                $('#renameUnitFileConfirm').attr("disabled","disabled");
+                //$('#renameUnitFileConfirm').attr("disabled","disabled");
             }else {
                 $("#renameError_unitFile").hide();
-                $('#renameUnitFileConfirm').removeAttr("disabled");
+                $('#rename-unitFile').modal('hide');
+               // $('#renameUnitFileConfirm').removeAttr("disabled");
                 let data = {project_id: scUrlUtil.GetQueryString('project'), change_id: changeUnitPriceId, type: 1,newName:newName};
                 projectObj.project.projectGLJ.changeFile(data,function () {
                     projectGljObject.changeFileCallback();

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

@@ -2555,7 +2555,7 @@ $('#importConfirm').click(function () {
         //选择的表及导入位置
         let importSheetsInfo = importBills.getImportSheetsInfo();
         if(importSheetsInfo.length === 0){
-            throw '请选要导入的表';
+            throw '请选要导入的表';
         }
         let importSheets = importBills.getImportSheets(importJson.sheets, importSheetsInfo, fileType);
         console.log(`importSheets`);

+ 80 - 15
web/building_saas/main/js/views/std_ration_lib.js

@@ -125,14 +125,16 @@ var rationLibObj = {
         });
         args.sheet.repaint();
     },
-    setTagForHint: function (datas) {
-        let sheet = this.sectionRationsSpread.getActiveSheet();
+    setTagForHint: function (sheet, datas) {
         sheet.suspendPaint();
         sheet.suspendEvent();
         for(let i = 0, len = sheet.getRowCount(); i < len; i++){
             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();
@@ -147,7 +149,7 @@ var rationLibObj = {
             });
             SheetDataHelper.loadSheetHeader(setting, rationLibObj.sectionRationsSpread.getActiveSheet());
             SheetDataHelper.loadSheetData(setting, rationLibObj.sectionRationsSpread.getActiveSheet(), datas);
-            rationLibObj.setTagForHint(datas);
+            rationLibObj.setTagForHint(rationSheet, datas);
         };
         if (sectionID) {
             CommonAjax.post('/complementaryRation/api/getRationGljItemsBySection', {user_Id: userID, sectionId: sectionID}, function (datas) {
@@ -440,8 +442,28 @@ $('#rationSearchKeyword').bind('keypress', function (event) {
         $('#rationSearch').click();
     }
 });
+$('#rationSearchKeyword').keyup(function () {
+    let keyword = $('#rationSearchKeyword').val();
+    if(keyword === ''){
+        if($('#rationSearchResult').is(':visible')){
+            $('#rationSearchResult').hide();
+            $(".main-data-side-search", $('#rationSearchResult')).height(0);
+            autoFlashHeight();
+            rationLibObj.refreshSpread();
+        }
+    }
+});
 $('#rationSearch').click(function () {
     var keyword = $('#rationSearchKeyword').val(), rationLibID = $('#stdRationLibSelect').val();
+    if(keyword === ''){
+        if($('#rationSearchResult').is(':visible')){
+            $('#rationSearchResult').hide();
+            $(".main-data-side-search", $('#rationSearchResult')).height(0);
+            autoFlashHeight();
+            rationLibObj.refreshSpread();
+        }
+        return;
+    }
     var getResultHtml = function (result) {
         var html = [], i, serialNo;
         html.push('<div class="d-flex justify-content-between">');
@@ -455,14 +477,56 @@ $('#rationSearch').click(function () {
         html.push('</div>');
         return html.join('');
     };
+    let bindContextmenuOpr = function (sheet) {
+        $.contextMenu({
+            selector: '#rationSearchResult',
+            build: function($triggerElement, e){
+                //控制允许右键菜单在哪个位置出现
+                let offset = $('.main-data-side-search').offset(),
+                    x = e.pageX - offset.left,
+                    y = e.pageY - offset.top;
+                let target = sheet.hitTest(x, y);
+                if(target.hitTestType === 3 && typeof target.row !== 'undefined' && typeof target.col !== 'undefined'){//在表格内
+                    sheet.setActiveCell(target.row, target.col);
+                    return {
+                        callback: function(){},
+                        items: {
+                            "locate": {
+                                name: "定位至章节",
+                                disabled: function () {
+                                    return target.row >= rationLibObj.resultCache.length;
+                                },
+                                icon: "fa-arrow-left",
+                                callback: function (key, opt) {
+                                    let data = rationLibObj.resultCache[target.row];
+                                    $('#rationSearchResult').hide();
+                                    $(".main-data-side-search", $('#rationSearchResult')).height(0);
+                                    autoFlashHeight();
+                                    rationLibObj.refreshSpread();
+                                    rationLibObj.locateAtRation(data.rationRepId, data.code);
+                                }}
+                        }
+                    };
+                }
+                else{
+                    return false;
+                }
+            }
+        });
+    };
     var showResult = function (result) {
-        let resultSpread = SheetDataHelper.createNewSpread($('.main-data-side-search')[0]);
-        rationLibObj.resultSpread = resultSpread;
-        rationLibObj.setTagForHint(result);
-        SheetDataHelper.loadSheetHeader(rationLibObj.sectionRationsSetting, resultSpread.getActiveSheet());
-        SheetDataHelper.loadSheetData(rationLibObj.sectionRationsSetting, resultSpread.getActiveSheet(), result);
-
-        resultSpread.bind(GC.Spread.Sheets.Events.CellDoubleClick, rationLibObj.onRationSpreadCellDoubleClick);
+        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);
+        }else {
+            rationLibObj.resultSpread.refresh();
+        }
+        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) {
         //sort
@@ -472,14 +536,15 @@ $('#rationSearch').click(function () {
             else if(a.code < b.code) rst = -1;
             return rst;
         });
-        var resultObj = $('#rationSearchResult'), resultSpread = null;
-        resultObj.empty();
-        resultObj.append(getResultHtml(result));
-        $('a', resultObj).click(function () {
+        var resultObj = $('#rationSearchResult');
+        /*resultObj.empty();
+        resultObj.append(getResultHtml(result));*/
+        $('#rationSearchCount').text(`搜索结果:${result.length.toString()}`);
+        $('a', result).unbind('click');
+        $('a', resultObj).bind('click', function () {
             resultObj.hide();
             $(".main-data-side-search", resultObj).height(0);
             autoFlashHeight();
-            //$(".main-data-side-d").height($(window).height() - $(".header").height() - $(".toolsbar").height() -  $(".tools-bar-height-d").height() - 202);
             rationLibObj.refreshSpread();
         });
         resultObj.show();