浏览代码

清单指引定额悬浮提示

zhongzewei 7 年之前
父节点
当前提交
ce06e75c84

+ 10 - 0
modules/all_models/compilation.js

@@ -57,6 +57,16 @@ let modelSchema = {
     release_time: {
     release_time: {
         type: Number,
         type: Number,
         default: 0
         default: 0
+    },
+    //价格属性
+    priceProperties: {
+        type: Array,
+        default: []
+    },
+    //消耗量属性
+    consumeAmtProperties: {
+        type: Array,
+        default: []
     }
     }
 };
 };
 mongoose.model(collectionName, new Schema(modelSchema, {versionKey: false, collection: collectionName}));
 mongoose.model(collectionName, new Schema(modelSchema, {versionKey: false, collection: collectionName}));

+ 1 - 1
modules/all_models/stdRation_ration.js

@@ -38,7 +38,7 @@ const rationItemSchema = new Schema({
     materialPrice: Number,
     materialPrice: Number,
     machinePrice: Number,
     machinePrice: Number,
     sectionId: Number,
     sectionId: Number,
-    rationRepId: Number,
+    rationRepId: {type: Number, index: true},
     caption: String,
     caption: String,
     feeType: Number,
     feeType: Number,
     jobContent: String,
     jobContent: String,

+ 2 - 1
modules/ration_repository/controllers/ration_controller.js

@@ -12,10 +12,11 @@ class RationController extends BaseController{
     async getRationItemsByLib(req, res){
     async getRationItemsByLib(req, res){
         try{
         try{
             let data = JSON.parse(req.body.data);
             let data = JSON.parse(req.body.data);
-            let rationItems = await rationItem.getRationItemsByLib(data.rationLibId);
+            let rationItems = await rationItem.getRationItemsByLib(data.rationLibId, data.showHint, data.returnFields);
             callback(req, res, 0, '', rationItems);
             callback(req, res, 0, '', rationItems);
         }
         }
         catch(err){
         catch(err){
+            console.log(err);
             callback(req, res, 1, err, null);
             callback(req, res, 1, err, null);
         }
         }
     }
     }

+ 41 - 2
modules/ration_repository/models/ration_item.js

@@ -9,13 +9,52 @@ let gljDao = require('./glj_repository');
 let rationRepositoryDao = require('./repository_map');
 let rationRepositoryDao = require('./repository_map');
 const scMathUtil = require('../../../public/scMathUtil').getUtil();
 const scMathUtil = require('../../../public/scMathUtil').getUtil();
 const rationItemModel = mongoose.model('std_ration_lib_ration_items');
 const rationItemModel = mongoose.model('std_ration_lib_ration_items');
+const stdRationLibModel = mongoose.model('std_ration_lib_map');
 const compleRationModel = mongoose.model('complementary_ration_items');
 const compleRationModel = mongoose.model('complementary_ration_items');
 import STDGLJListModel from '../../std_glj_lib/models/gljModel';
 import STDGLJListModel from '../../std_glj_lib/models/gljModel';
 
 
 var rationItemDAO = function(){};
 var rationItemDAO = function(){};
 
 
-rationItemDAO.prototype.getRationItemsByLib = async function (rationRepId) {
-    return await rationItemModel.find({rationRepId: rationRepId, $or: [{isDeleted: null}, {isDeleted: false}]});
+rationItemDAO.prototype.getRationItemsByLib = async function (rationRepId, showHint = null, returnFields = '') {
+    let rationLib = await stdRationLibModel.findOne({ID: rationRepId, deleted: false});
+    if(!rationLib){
+        return [];
+    }
+    let startDate = new Date();
+    let rations = await rationItemModel.find({rationRepId: rationRepId}, returnFields);
+    console.log(`Date: ${new Date() - startDate}====================================`);
+    if(!showHint){
+        return rations;
+    }
+    else {
+        const stdBillsLibListsModel = new STDGLJListModel();
+        const stdGLJData = await stdBillsLibListsModel.getGljItemsByRepId(rationLib.gljLib, '-_id ID code name unit');
+        let gljMapping = {};
+        for(let glj of stdGLJData){
+            gljMapping[glj.ID] = glj;
+        }
+        //设置悬浮
+        for(let ration of rations){
+            let hintsArr = [];
+            for(let rationGlj of ration.rationGljList){
+                let subGlj = gljMapping[rationGlj.gljId];
+                if(subGlj){
+                    hintsArr.push(` ${subGlj.code} ${subGlj.name} ${subGlj.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>');
+        }
+        return rations;
+    }
 };
 };
 
 
 rationItemDAO.prototype.sortToNumber = function (datas) {
 rationItemDAO.prototype.sortToNumber = function (datas) {

+ 3 - 8
modules/std_billsGuidance_lib/facade/facades.js

@@ -118,15 +118,15 @@ async function updateBillsGuideLib(data) {
 }
 }
 
 
 async function getLibWithBills(libID){
 async function getLibWithBills(libID){
-    let guidanceLib = await getBillsGuideLibs({ID: libID, deleted: false});
+    let guidanceLib = await getBillsGuideLibs({ID: libID});
     if(guidanceLib.length === 0){
     if(guidanceLib.length === 0){
         throw '不存在此指引库!';
         throw '不存在此指引库!';
     }
     }
-    let billsLib = await stdBillsLibModel.findOne({billsLibId: guidanceLib[0].billsLibId, deleted: false});
+    let billsLib = await stdBillsLibModel.findOne({billsLibId: guidanceLib[0].billsLibId});
     if(!billsLib){
     if(!billsLib){
         throw '引用的清单规则库不存在!';
         throw '引用的清单规则库不存在!';
     }
     }
-    let bills = await stdBillsModel.find({billsLibId: billsLib.billsLibId, deleted: false}, '-_id code name ID NextSiblingID ParentID');
+    let bills = await stdBillsModel.find({billsLibId: billsLib.billsLibId}, '-_id code name ID NextSiblingID ParentID');
     return {guidanceLib: guidanceLib[0], bills};
     return {guidanceLib: guidanceLib[0], bills};
 }
 }
 
 
@@ -225,18 +225,13 @@ async function getItemsBybills(guidanceLibID, billsID){
 async function updateItems(updateDatas) {
 async function updateItems(updateDatas) {
     let bulkArr = [];
     let bulkArr = [];
     for(let updateData of updateDatas){
     for(let updateData of updateDatas){
-        console.log(updateData.updateType);
         if(updateData.updateType === 'create'){
         if(updateData.updateType === 'create'){
             bulkArr.push({insertOne: {document: updateData.updateData}});
             bulkArr.push({insertOne: {document: updateData.updateData}});
         }
         }
         else if(updateData.updateType === 'update'){
         else if(updateData.updateType === 'update'){
-            console.log('enterUpdate================');
-            console.log(updateData.findData);
             bulkArr.push({updateOne: {filter: updateData.findData, update: {$set: updateData.updateData}}});
             bulkArr.push({updateOne: {filter: updateData.findData, update: {$set: updateData.updateData}}});
         }
         }
         else{
         else{
-            console.log('enterDel====================');
-            console.log(updateData.findData);
             bulkArr.push({deleteOne: {filter: updateData.findData}});
             bulkArr.push({deleteOne: {filter: updateData.findData}});
         }
         }
     }
     }

+ 2 - 2
modules/std_glj_lib/models/gljModel.js

@@ -493,8 +493,8 @@ class GljDao  extends OprDao{
         });
         });
     }
     }
 
 
-    async getGljItemsByRepId(repositoryId){
-         return gljModel.find({"repositoryId": repositoryId});
+    async getGljItemsByRepId(repositoryId, returnFields = ''){
+         return gljModel.find({"repositoryId": repositoryId}, returnFields);
     }
     }
 }
 }
 
 

+ 1 - 0
web/maintain/billsGuidance_lib/html/zhiyin.html

@@ -113,6 +113,7 @@
     <script src="/lib/lodash/lodash.js"></script>
     <script src="/lib/lodash/lodash.js"></script>
     <script src="/public/web/uuid.js"></script>
     <script src="/public/web/uuid.js"></script>
     <script src="/public/web/sheet/sheet_common.js"></script>
     <script src="/public/web/sheet/sheet_common.js"></script>
+    <script src="/public/web/sheet/sheet_data_helper.js"></script>
     <script src="/public/web/QueryParam.js"></script>
     <script src="/public/web/QueryParam.js"></script>
     <script src="/public/web/common_ajax.js"></script>
     <script src="/public/web/common_ajax.js"></script>
     <script src="/web/maintain/billsGuidance_lib/js/global.js"></script>
     <script src="/web/maintain/billsGuidance_lib/js/global.js"></script>

+ 124 - 2
web/maintain/billsGuidance_lib/js/billsGuidance.js

@@ -326,6 +326,22 @@ const billsGuidance = (function () {
             guideItemInitSel(guideSheet.getActiveRowIndex() ? guideSheet.getActiveRowIndex() : 0);
             guideItemInitSel(guideSheet.getActiveRowIndex() ? guideSheet.getActiveRowIndex() : 0);
         }
         }
     }
     }
+    //选中的节点是否全是同层节点
+    //@param {Object}sheet {Array}items @return {Boolean}
+    function itemsSameDepth(sheet, items) {
+        let sels = sheet.getSelections();
+        if(sels.length === 0 || items.length === 0){
+            return false;
+        }
+        let depths = [];
+        for(let i = 0; i < sels[0].rowCount; i++){
+            let row = sels[0].row + i;
+            let node = items[row];
+            if(node){
+                 depths.push(node.depth());
+            }
+        }
+    }
     //节点子项是否全是工作内容
     //节点子项是否全是工作内容
     //@param {Object}node @return {Boolean}
     //@param {Object}node @return {Boolean}
     function allJobChildren(node){
     function allJobChildren(node){
@@ -395,6 +411,7 @@ const billsGuidance = (function () {
     //项目指引表焦点控制
     //项目指引表焦点控制
     //@param {Number}row @return {void}
     //@param {Number}row @return {void}
     function guideItemInitSel(row){
     function guideItemInitSel(row){
+        console.log('et');
         let billsNode = bills.tree.selected;
         let billsNode = bills.tree.selected;
         let node = null;
         let node = null;
         if(billsNode && billsNode.guidance.tree){
         if(billsNode && billsNode.guidance.tree){
@@ -417,6 +434,105 @@ const billsGuidance = (function () {
             buildSheet(module);
             buildSheet(module);
         }
         }
     }
     }
+    function tipDivCheck(){
+        setTimeout(function () {
+            let tips = $('#autoTip');
+            if(ration.tipDiv == 'show'){
+                return;
+            } else if(ration.tipDiv == 'hide'&&tips){
+                tips.hide();
+                ration._toolTipElement = null;
+            }
+        },600)
+    }
+    //获取悬浮提示单元格
+    //@param {Object}sheet @return {Object}
+    function getTipCellType(sheet) {
+        let setting = {};
+        let TipCellType = function () {};
+        TipCellType.prototype = new GC.Spread.Sheets.CellTypes.Text();
+        TipCellType.prototype.getHitInfo = function (x, y, cellStyle, cellRect, context) {
+            return {
+                x: x,
+                y: y,
+                row: context.row,
+                col: context.col,
+                cellStyle: cellStyle,
+                cellRect: cellRect,
+                sheet: context.sheet,
+                sheetArea: context.sheetArea
+            };
+        };
+        TipCellType.prototype.processMouseEnter = function (hitinfo) {
+            let text = hitinfo.sheet.getText(hitinfo.row, hitinfo.col);
+            let tag = hitinfo.sheet.getTag(hitinfo.row, hitinfo.col);
+            /*     let hintHeight = datas[hitinfo.row] ?
+             datas[hitinfo.row].hintHeight ? datas[hitinfo.row].hintHeight : null
+             : null; //定额库定额悬浮提示位置相关*/
+            if(tag !== undefined && tag){
+                text = tag;
+            }
+            if(sheet && sheet.getParent().qo){
+                setting.pos = SheetDataHelper.getObjPos(sheet.getParent().qo);
+            }
+            if (setting.pos && text && text !== '') {
+                //固定不显示的div,存储文本获取固定div宽度,toolTipElement由于显示和隐藏,获取宽度不正确
+                if(!this._fixedTipElement){
+                    let div = $('#fixedTip')[0];
+                    if (!div) {
+                        div = document.createElement("div");
+                        $(div).css("padding", 5)
+                            .attr("id", 'fixedTip');
+                        $(div).hide();
+                        document.body.insertBefore(div, null);
+                    }
+                    this._fixedTipElement = div;
+                }
+                $(this._fixedTipElement).html(text);
+                if (!this._toolTipElement) {
+                    let div = $('#autoTip')[0];
+                    if (!div) {
+                        div = document.createElement("div");
+                        $(div).css("position", "absolute")
+                            .css("border", "1px #C0C0C0 solid")
+                            .css("box-shadow", "1px 2px 5px rgba(0,0,0,0.4)")
+                            .css("font", "0.9rem Calibri")
+                            .css("background", "white")
+                            .css("padding", 5)
+                            .attr("id", 'autoTip');
+                        $(div).hide();
+                        document.body.insertBefore(div, null);
+                    }
+                    this._toolTipElement = div;
+                    //实时读取位置信息
+                    if(hitinfo.sheet && hitinfo.sheet.getParent().qo){
+                        setting.pos = SheetDataHelper.getObjPos(hitinfo.sheet.getParent().qo);
+                    }
+                    $(this._toolTipElement).html(text);
+                    //定额库定额特殊处理
+                    if($(hitinfo.sheet.getParent().qo).attr('id') === 'rationSpread'){
+                        let divWidth = $(this._fixedTipElement).width(),
+                            divHeight = $(this._fixedTipElement).height();
+                        $(this._toolTipElement).css("top", setting.pos.y  + hitinfo.y - divHeight).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);
+                    }
+                    $(this._toolTipElement).show("fast");
+                    ration.tipDiv = 'show';//做个标记
+                }
+            }
+        };
+        TipCellType.prototype.processMouseLeave = function (hininfo) {
+            ration.tipDiv = 'hide';
+            if (this._toolTipElement) {
+                $(this._toolTipElement).hide();
+                this._toolTipElement = null;
+            }
+            tipDivCheck();//延时检查:当tips正在show的时候,就调用了hide方法,会导致tips一直存在,所以设置一个超时处理
+        }
+        return new TipCellType();
+    }
     //输出表数据(定额表)
     //输出表数据(定额表)
     //@param {Object}sheet {Array}headers {Array}datas @return {void}
     //@param {Object}sheet {Array}headers {Array}datas @return {void}
     function showData(sheet, headers, datas){
     function showData(sheet, headers, datas){
@@ -424,12 +540,17 @@ const billsGuidance = (function () {
             sheet.setRowCount(datas.length);
             sheet.setRowCount(datas.length);
             //复选框
             //复选框
             let checkBoxType = new GC.Spread.Sheets.CellTypes.CheckBox();
             let checkBoxType = new GC.Spread.Sheets.CellTypes.CheckBox();
+            let tipCellType = getTipCellType(sheet);
             sheet.setCellType(-1, 0, checkBoxType);
             sheet.setCellType(-1, 0, checkBoxType);
             for(let col = 0, cLen = headers.length; col < cLen; col++){
             for(let col = 0, cLen = headers.length; col < cLen; col++){
                 for(let row = 0, rLen = datas.length; row < rLen; row++){
                 for(let row = 0, rLen = datas.length; row < rLen; row++){
                     sheet.setValue(row, col, datas[row][headers[col]['dataCode']]);
                     sheet.setValue(row, col, datas[row][headers[col]['dataCode']]);
+                    if(col === 1){
+                        sheet.setTag(row, col, datas[row]['hint']);
+                    }
                 }
                 }
             }
             }
+            sheet.setCellType(-1, 1, tipCellType);
         };
         };
         renderSheetFunc(sheet, fuc);
         renderSheetFunc(sheet, fuc);
     }
     }
@@ -463,7 +584,7 @@ const billsGuidance = (function () {
         let sectionSheet = section.workBook.getActiveSheet();
         let sectionSheet = section.workBook.getActiveSheet();
         CommonAjax.post('/rationRepository/api/getRationTree', {rationLibId: rationLibId}, function (sectionDatas) {
         CommonAjax.post('/rationRepository/api/getRationTree', {rationLibId: rationLibId}, function (sectionDatas) {
             //获取所有定额数据
             //获取所有定额数据
-            CommonAjax.post('/rationRepository/api/getRationItemsByLib', {rationLibId: rationLibId}, function (rstData) {
+            CommonAjax.post('/rationRepository/api/getRationItemsByLib', {rationLibId: rationLibId, showHint: true, returnFields: '-_id code ID sectionId name unit basePrice rationGljList'}, function (rstData) {
                 section.cache = sectionDatas;
                 section.cache = sectionDatas;
                 initTree(section, section.workBook.getActiveSheet(), section.treeSetting, sectionDatas);
                 initTree(section, section.workBook.getActiveSheet(), section.treeSetting, sectionDatas);
                 //初始焦点在第一行(切换库)
                 //初始焦点在第一行(切换库)
@@ -847,8 +968,9 @@ const billsGuidance = (function () {
                 ration.cache = ration.datas;
                 ration.cache = ration.datas;
             }
             }
             else{
             else{
+                let reg = new RegExp(searchStr, 'i');
                 ration.cache = _.filter(ration.datas, function (data) {
                 ration.cache = _.filter(ration.datas, function (data) {
-                    return data.code.includes(searchStr);
+                    return reg.test(data.code);
                 });
                 });
             }
             }
             $('.top-content').hide();
             $('.top-content').hide();