Pārlūkot izejas kodu

Merge branch 'master' of http://smartcost.f3322.net:3000/SmartCost/YangHuCost

zhongzewei 6 gadi atpakaļ
vecāks
revīzija
3c903e5d07

+ 5 - 0
modules/all_models/project_glj.js

@@ -102,6 +102,11 @@ let modelSchema = {
         type: Number,
         default: 0
     },
+    //以下仅普通材料可用
+    grossWeightCoe: Number, //毛重系数
+    purchaseStorageRate: Number, //采购保管费率
+    offSiteTransportLossRate: Number, //场外运输损耗率
+    handlingLossRate: Number, //每增一次装卸损耗率
     ratio_data: Schema.Types.Mixed,
     remark:String
 };

+ 5 - 1
modules/glj/models/glj_list_model.js

@@ -602,7 +602,11 @@ class GLJListModel extends BaseModel {
                     adjCoe:tmp.adjCoe,
                     original_code:tmp.code,
                     materialType: tmp.materialType,   //三材类别
-                    materialCoe: tmp.materialCoe
+                    materialCoe: tmp.materialCoe,
+                    grossWeightCoe:tmp.grossWeightCoe,
+                    purchaseStorageRate:tmp.purchaseStorageRate,
+                    offSiteTransportLossRate:tmp.offSiteTransportLossRate,
+                    handlingLossRate:tmp.handlingLossRate
                 };
                 gljInsertData.push(gljData);
             }

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

@@ -443,6 +443,10 @@ async function addRationGLJ(std,newRation,compilation) {
                 newGLJ.adjCoe = std_glj.adjCoe;
                 newGLJ.materialType = std_glj.materialType;
                 newGLJ.materialCoe = std_glj.materialCoe;
+                newGLJ.grossWeightCoe = std_glj.grossWeightCoe;
+                newGLJ.purchaseStorageRate = std_glj.purchaseStorageRate;
+                newGLJ.offSiteTransportLossRate = std_glj.offSiteTransportLossRate;
+                newGLJ.handlingLossRate = std_glj.handlingLossRate;
                 newGLJ.createType = 'normal';
                 let info =  await ration_glj_facade.getInfoFromProjectGLJ(newGLJ,unitPriceFileId,ext);
                 newGLJ = ration_glj_facade.createNewRecord(info);

+ 42 - 12
modules/ration_glj/facade/glj_calculate_facade.js

@@ -8,6 +8,8 @@ let _=require("lodash");
 let ration_glj = mongoose.model('ration_glj');
 let ration = mongoose.model('ration');
 let ration_coe = mongoose.model('ration_coe');
+const ProjectModel = require('../../pm/models/project_model').project;
+let mixRatioModel = mongoose.model('mix_ratio');
 let std_ration_lib_ration_items = mongoose.model('std_ration_lib_ration_items');
 let std_glj_lib_gljList_model = mongoose.model('std_glj_lib_gljList');
 let glj_type_util = require('../../../public/cache/std_glj_type_util');
@@ -49,9 +51,7 @@ async function calculateQuantity(query,noNeedCal,refreshRationName = false){
          let impactRation = await ration.findOne({ID:query.rationID,projectID:query.projectID});
          let gljList = await ration_glj.find(query);//{projectID:query.projectID,rationID:query.rationID}
          let coeList = await ration_coe.find({projectID:query.projectID,rationID:query.rationID}).sort('seq').exec();
-         let assList=[];
-         let assRation = null;
-         let adjustState=[];
+         let assList=[], assRation = null, adjustState=[],mixRatioMap = {};
          if(!impactRation){//如果定额不存在或者已删除,返回空
              return null;
          }
@@ -65,12 +65,15 @@ async function calculateQuantity(query,noNeedCal,refreshRationName = false){
                  }
              }
          }
-         gljList = sortRationGLJ(gljList);
-         for(let i =0;i<gljList.length;i++ ){
-             let r = await calculateQuantityPerGLJ(gljList[i],gljList,coeList,assList,adjustState,noNeedCal);
-             result.glj_result.push(r);
+         for(let glj of gljList){//先把混凝土,砂浆,配合比有自定义消耗的挑出来
+             if(gljUtil.isConcreteType(glj.type)&& !noCustomQuantiyt(glj)) await getMixRatioMap(glj,mixRatioMap);
          }
 
+        gljList = sortRationGLJ(gljList);
+        for(let i =0;i<gljList.length;i++ ){
+            let r = await calculateQuantityPerGLJ(gljList[i],gljList,coeList,assList,adjustState,mixRatioMap,noNeedCal);
+            result.glj_result.push(r);
+        }
          if(noNeedCal==null){
             await ration_glj.bulkWrite(generateUpdateTasks(result.glj_result));
          }
@@ -137,8 +140,16 @@ function sortRationGLJ(list) {
     return list;
 }
 
-async function calculateQuantityPerGLJ(glj,gljList,coeList,assList,adjustState,noNeedCal) {
-    let decimalObject =await decimal_facade.getProjectDecimal(glj.projectID);
+function sortBeforeCalc(list) {
+    list = _.sortByAll(list, [function (item) {
+       return gljUtil.isConcreteType(item.type)?1:2;
+    }]);
+    return list;
+}
+
+
+async function calculateQuantityPerGLJ(glj,gljList,coeList,assList,adjustState,mixRatioMap,noNeedCal) {
+    let decimalObject = await decimal_facade.getProjectDecimal(glj.projectID);
     let decimal = (decimalObject&&decimalObject.glj&&decimalObject.glj.quantity)?decimalObject.glj.quantity:3;
     let quantity =  scMathUtil.roundTo(parseFloat(glj.quantity),-decimal);
     let result={
@@ -151,12 +162,12 @@ async function calculateQuantityPerGLJ(glj,gljList,coeList,assList,adjustState,n
         }
     };
     try {
-        if(noNeedCal==null){
-            if(!glj._doc.hasOwnProperty('customQuantity')||glj.customQuantity==null||glj.customQuantity==""){
+        if(noNeedCal==null){//计算顺序:辅助定额,附注条件,自定义消耗(如果有就不用前计算两项),自定义乘系数
+            if(noCustomQuantiyt(glj)){
                 quantity =scMathUtil.roundTo(parseFloat(glj.rationItemQuantity),-decimal);
                 quantity =scMathUtil.roundTo(await calculateAss(quantity,assList,glj),-decimal);
                 quantity = calculateQuantityByCoes(quantity,coeList,glj,gljList,decimal);
-            }else {
+            }else {//对于有自定义消耗量的,并且是混凝土,浆砂,配合比 这三种类型,其组成物的消耗量要跟据自定义消耗量做相应的换算
                 quantity = glj.customQuantity;
                 result.doc.customQuantity = glj.customQuantity;
             }
@@ -176,6 +187,25 @@ async function calculateQuantityPerGLJ(glj,gljList,coeList,assList,adjustState,n
     }
 }
 
+async function getMixRatioMap(glj,mixRatioMap) {//生成组成物对应的父工料机的映射表
+    let unitPriceFileId = await ProjectModel.getUnitPriceFileId(glj.projectID);
+    let connect_key = gljUtil.getIndex(glj);
+    let mixList =  await mixRatioModel.find({"unit_price_file_id":unitPriceFileId,'connect_key':connect_key})
+    for(let m of mixList){
+        let mkey = gljUtil.getIndex(m);
+        if(mixRatioMap[mkey]){
+            mixRatioMap[mkey].push({customQuantity:glj.customQuantity,rationItemQuantity:glj.rationItemQuantity,consumption:m.consumption});
+        }else {
+            mixRatioMap[mkey] = [{customQuantity:glj.customQuantity,rationItemQuantity:glj.rationItemQuantity,consumption:m.consumption}];
+        }
+    }
+}
+
+
+function noCustomQuantiyt(glj) {//是否有自定义消耗量
+    return !glj._doc.hasOwnProperty('customQuantity')||glj.customQuantity==null||glj.customQuantity==""
+}
+
 async function calculateAss(quantity,assList,glj) {
     for(let i=0;i<assList.length;i++){
         if(assList[i].assRation){

+ 4 - 0
modules/ration_glj/facade/ration_glj_facade.js

@@ -595,6 +595,10 @@ function getGLJSearchInfo(ration_glj) {
         adjCoe: ration_glj.adjCoe,
         materialType:ration_glj.materialType,
         materialCoe:ration_glj.materialCoe,
+        grossWeightCoe:ration_glj.grossWeightCoe,
+        purchaseStorageRate:ration_glj.purchaseStorageRate,
+        offSiteTransportLossRate:ration_glj.offSiteTransportLossRate,
+        handlingLossRate:ration_glj.handlingLossRate,
         from: ration_glj.from ? ration_glj.from : 'std'//std:标准工料机库, cpt:补充工料机库
     };
     let glj_type_object = glj_type_util.getStdGljTypeCacheObj();

+ 5 - 1
public/gljUtil.js

@@ -17,7 +17,8 @@ module.exports = {
     getBasePrice:getBasePrice,
     getAdjustPrice:getAdjustPrice,
     getMainType:getMainType,
-    isConcreteType:isConcreteType
+    isConcreteType:isConcreteType,
+    getIndex:getIndex
 };
 
 function calcProjectGLJQuantity(projectGLJDatas,rationGLJDatas,rationDatas,billsDatas,q_decimal) {
@@ -47,6 +48,9 @@ function calcPriceDiff(glj,calcOptions) {
 function getMainType() {
     return gljNodeUtil.getMainType();
 }
+function getIndex(obj, pops) {
+    return gljNodeUtil.getIndex(obj, pops);
+}
 
 function isConcreteType(type) {
     return gljNodeUtil.isConcreteType(type);

+ 1 - 0
public/web/gljUtil.js

@@ -288,6 +288,7 @@ let gljUtil = {
     getIndex(obj, pops){
         let t_index = '';
         let k_arr = [];
+        if(!this.isDef(pops)) pops = this.gljKeyArray;
         for (let p of pops) {
             let tmpK = (obj[p] == undefined || obj[p] == null || obj[p] == '') ? 'null' : obj[p];
             k_arr.push(tmpK);

+ 68 - 0
public/web/sheet/sheet_common.js

@@ -544,6 +544,74 @@ var sheetCommonObj = {
         };
         return new selectButton();
     },
+    getCusButtonCellType:function (callback,readOnly=false) {
+        var ns = GC.Spread.Sheets;
+        function CusButtonCellType() {
+        }
+        CusButtonCellType.prototype = new ns.CellTypes.Text();
+        CusButtonCellType.prototype.paint = function (ctx, value, x, y, w, h, style, options) {
+
+            if(!readOnly){
+                if(options.sheet.getActiveRowIndex()==options.row&&options.sheet.getActiveColumnIndex()==options.col){
+                    var image = document.getElementById('f_btn'),imageMagin = 3;
+                    var imageHeight = 15;
+                    var imageWidth = 25;
+                    var imageX = x + w - imageWidth- imageMagin, imageY = y + h / 2 - imageHeight / 2;
+                    ctx.save();
+                    ctx.fillStyle = style.backColor;
+                    ctx.fillRect(x,y,w,h);
+                    ctx.drawImage(image, imageX, imageY,imageWidth,imageHeight);
+                    ctx.beginPath();
+                    ctx.arc(imageX+imageWidth/2,imageY+imageHeight/2,1,0,360,false);
+                    ctx.arc(imageX+imageWidth/2-4,imageY+imageHeight/2,1,0,360,false);
+                    ctx.arc(imageX+imageWidth/2+4,imageY+imageHeight/2,1,0,360,false);
+                    ctx.fillStyle="black";//填充颜色,默认是黑色
+                    ctx.fill();//画实心圆
+                    ctx.closePath();
+                    ctx.restore();
+                    //这里的左对齐的,当显示的字长度超过空白地方时,要改成右对齐
+                    if(style.hAlign == 0){
+                        w = w - imageWidth - imageMagin;
+                        if(value){
+                            let textWidth = ctx.measureText(value).width;
+                            let spaceWidth = w;
+                            if(spaceWidth<textWidth){
+                                style.hAlign = 2;
+                            }
+                        }
+                    }else if(style.hAlign == 2){//如果是右对齐的,往左边挪,给按钮留出空间
+                        x = x - imageWidth - imageMagin;
+                    }
+
+                }
+            }
+            GC.Spread.Sheets.CellTypes.Text.prototype.paint.apply(this, arguments);
+        };
+        CusButtonCellType.prototype.getHitInfo = function (x, y, cellStyle, cellRect, context) {
+            return {
+                x: x,
+                y: y,
+                row: context.row,
+                col: context.col,
+                cellStyle: cellStyle,
+                cellRect: cellRect,
+                sheetArea: context.sheetArea
+            };
+        };
+
+        CusButtonCellType.prototype.processMouseDown = function (hitinfo) {
+            if(hitinfo.sheet.getActiveRowIndex()==hitinfo.row&&hitinfo.sheet.getActiveColumnIndex()==hitinfo.col){
+                var offset=hitinfo.cellRect.x+hitinfo.cellRect.width-6;
+                var imageWidth = 25;
+                if(hitinfo.x<offset&&hitinfo.x>offset-imageWidth){
+                    if(!readOnly){
+                        if(callback) callback(hitinfo)
+                    }
+                }
+            }
+        };
+        return new CusButtonCellType();
+    },
     setReplaceButton(row,col,sheet){
         let replaceButton = function(){
 

+ 0 - 1
web/building_saas/main/html/calc_program_manage.html

@@ -10,7 +10,6 @@
 
 <body>
     <div style="">
-        <img id="f_btn" src="/web/dest/css/img/feeRate_btn.jpg" alt="" style="display: none" />
     </div>
     <div class="toolsbar px-1" />
     <div class="container-fluid">

+ 2 - 3
web/building_saas/main/js/models/fee_rate.js

@@ -60,7 +60,7 @@ var FeeRate = {
         };
         FeeRate.prototype.getAllSubRates = function () {
             let rates =  this.getActivateFeeRate().rates;
-            let subRates = [],nameMap={};
+            let subRates = [],nameMap={},temRates=[];
             for(let r of rates){
                 if(gljUtil.isDef(r.subFeeRate)){
                     for(let p of r.subFeeRate.recodes){
@@ -74,11 +74,10 @@ var FeeRate = {
                                 subRates.push(sub);
                             }
                         }
-
                     }
                 }
             }
-            return subRates;
+            return _.sortByAll(subRates,['ID'])//要保证树节点的ID子项是紧跟着父项的,不然的话显示会有问题
         };
         FeeRate.prototype.getSubViewData= function(item) {
             var datas = [];

+ 4 - 0
web/building_saas/main/js/models/project_glj.js

@@ -537,6 +537,10 @@ ProjectGLJ.prototype.addMixRatio = function(selections,callback){
                 repositoryId:glj.repositoryId,
                 materialType:glj.materialType,
                 materialCoe:glj.materialCoe,
+                grossWeightCoe:glj.grossWeightCoe,
+                purchaseStorageRate:glj.purchaseStorageRate,
+                offSiteTransportLossRate:glj.offSiteTransportLossRate,
+                handlingLossRate:glj.handlingLossRate
             };
             if (glj.hasOwnProperty("compilationId")) {
                 pglj.from = "cpt";

+ 16 - 0
web/building_saas/main/js/models/ration_glj.js

@@ -584,6 +584,10 @@ let ration_glj = {
                         adjCoe: glj.adjCoe,
                         materialType:glj.materialType,
                         materialCoe:glj.materialCoe,
+                        grossWeightCoe:glj.grossWeightCoe,
+                        purchaseStorageRate:glj.purchaseStorageRate,
+                        offSiteTransportLossRate:glj.offSiteTransportLossRate,
+                        handlingLossRate:glj.handlingLossRate,
                         repositoryId: glj.repositoryId
                     };
                     if(pEngineer) new_glj.programID = pEngineer;
@@ -663,6 +667,10 @@ let ration_glj = {
                 createType: 'add',
                 materialType:glj.materialType,
                 materialCoe:glj.materialCoe,
+                grossWeightCoe:glj.grossWeightCoe,
+                purchaseStorageRate:glj.purchaseStorageRate,
+                offSiteTransportLossRate:glj.offSiteTransportLossRate,
+                handlingLossRate:glj.handlingLossRate,
                 repositoryId: glj.repositoryId
             };
             if (glj.hasOwnProperty("compilationId")) {
@@ -766,6 +774,10 @@ let ration_glj = {
             oldData.repositoryId = glj.repositoryId;
             oldData.materialType = glj.materialType;
             oldData. materialCoe =  glj.materialCoe;
+            oldData.grossWeightCoe= glj.grossWeightCoe;
+            oldData.purchaseStorageRate = glj.purchaseStorageRate;
+            oldData.offSiteTransportLossRate = glj.offSiteTransportLossRate;
+            oldData.handlingLossRate = glj.handlingLossRate;
             if (glj.hasOwnProperty("compilationId")) {
                 oldData.from = "cpt";
                 if (glj.code.indexOf('-') != -1) {//这条工料机是用户通过修改包称、规格、型号等保存到补充工料机库的
@@ -830,6 +842,10 @@ let ration_glj = {
                 repositoryId: glj.repositoryId,
                 materialType: glj.materialType,   //三材类别
                 materialCoe: glj.materialCoe,
+                grossWeightCoe:glj.grossWeightCoe,
+                purchaseStorageRate:glj.purchaseStorageRate,
+                offSiteTransportLossRate:glj.offSiteTransportLossRate,
+                handlingLossRate:glj.handlingLossRate,
                 projectID: oldData.projectID
             };
             if (glj.hasOwnProperty("compilationId")) {

+ 9 - 42
web/building_saas/main/js/views/calc_base_view.js

@@ -352,18 +352,15 @@ let calcBaseView = {
         }
         CalcBaseCellType.prototype = new ns.CellTypes.Text();
         CalcBaseCellType.prototype.paint = function (ctx, value, x, y, w, h, style, options) {
-            //  if(value!=null){
-            // ctx.fillText(value,x+3+ctx.measureText(value).width,y+h-3);
-            // ctx.fillText(value,x+w-3,y+h-3);
-            GC.Spread.Sheets.CellTypes.Text.prototype.paint.apply(this, arguments);
-            // }
             if(calcBaseView.editingCell && !projectReadOnly && calcBaseView.ifEdit(type, options.row)){
-                if(calcBaseView.editingCell.row==options.row&&calcBaseView.editingCell.col==options.col){
+                if(options.sheet.getActiveRowIndex()==options.row&&options.sheet.getActiveColumnIndex()==options.col){
                     var image = document.getElementById('f_btn'),imageMagin = 3;
-                    var imageHeight = h-2*imageMagin;
-                    var imageWidth = w*2/(type=='bills'?7:20);
+                    var imageHeight = 15;
+                    var imageWidth = 25;
                     var imageX = x + w - imageWidth- imageMagin, imageY = y + h / 2 - imageHeight / 2;
                     ctx.save();
+                    ctx.fillStyle = style.backColor;
+                    ctx.fillRect(x,y,w,h);
                     ctx.drawImage(image, imageX, imageY,imageWidth,imageHeight);
                     ctx.beginPath();
                     ctx.arc(imageX+imageWidth/2,imageY+imageHeight/2,1,0,360,false);
@@ -373,8 +370,10 @@ let calcBaseView = {
                     ctx.fill();//画实心圆
                     ctx.closePath();
                     ctx.restore();
+                    x = x - imageWidth - imageMagin;
                 }
             }
+            GC.Spread.Sheets.CellTypes.Text.prototype.paint.apply(this, arguments);
         };
         CalcBaseCellType.prototype.getHitInfo = function (x, y, cellStyle, cellRect, context) {
             return {
@@ -389,11 +388,9 @@ let calcBaseView = {
         };
         CalcBaseCellType.prototype.processMouseDown = function (hitinfo) {
             let me = calcBaseView;
-            if(me.editingCell && hitinfo.row==me.editingCell.row){
+            if(hitinfo.sheet.getActiveRowIndex()==hitinfo.row&&hitinfo.sheet.getActiveColumnIndex()==hitinfo.col){
                 var offset=hitinfo.cellRect.x+hitinfo.cellRect.width-6;
-                var imageMagin=3;
-                var imageHeight = hitinfo.cellRect.height-2*imageMagin;
-                var imageWidth = hitinfo.cellRect.width*2/7;
+                var imageWidth = 25;
                 if(hitinfo.x<offset&&hitinfo.x>offset-imageWidth){
                     if(!projectReadOnly && me.ifEdit(type, hitinfo.row)){
                         hitinfo.sheet.setActiveCell(hitinfo.row, hitinfo.col);
@@ -406,39 +403,9 @@ let calcBaseView = {
                         $('#tabCalcBase').tab('show');
                         calcBaseView.initCalctor(type);
                     }
-                }else {//鼠标点击其它地方,消失
-                    hideButton(hitinfo);
                 }
             }
         };
-        CalcBaseCellType.prototype.processMouseEnter = function (hitinfo){
-            let me = calcBaseView;
-            me.pmLeave = false;
-            if(me.editingCell==null){
-                var showSelectBtn = true;
-                showSelectBtn=me.ifEdit(type, hitinfo.row);
-                if(showSelectBtn){
-                    me.editingCell={
-                        row:hitinfo.row,
-                        col:hitinfo.col
-                    };
-                    hitinfo.sheet.invalidateLayout();
-                    hitinfo.sheet.repaint();
-                }
-            }
-        };
-        CalcBaseCellType.prototype.processMouseLeave = function (hitinfo) {
-            hideButton(hitinfo);
-        };
-
-        function hideButton(hitinfo) {
-            if(!calcBaseView.pmLeave){
-                calcBaseView.editingCell=null;
-                hitinfo.sheet.invalidateLayout();
-                hitinfo.sheet.repaint();
-                calcBaseView.pmLeave = true;
-            }
-        }
         return new CalcBaseCellType();
     },
 };

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

@@ -680,6 +680,10 @@ projectGljObject={
             supply_quantity:glj.supply_quantity,
             materialType:glj.materialType,
             materialCoe:glj.materialCoe,
+            grossWeightCoe:glj.grossWeightCoe,
+            purchaseStorageRate:glj.purchaseStorageRate,
+            offSiteTransportLossRate:glj.offSiteTransportLossRate,
+            handlingLossRate:glj.handlingLossRate,
             delivery:glj.delivery,
             delivery_address:glj.delivery_address,
             is_adjust_price:glj.is_adjust_price,

+ 10 - 43
web/building_saas/main/js/views/project_view.js

@@ -1928,18 +1928,15 @@ var projectObj = {
         }
         CommonTotalFeeCellType.prototype = new ns.CellTypes.Text();
         CommonTotalFeeCellType.prototype.paint = function (ctx, value, x, y, w, h, style, options) {
-            //  if(value!=null){
-            // ctx.fillText(value,x+3+ctx.measureText(value).width,y+h-3);
-            // ctx.fillText(value,x+w-3,y+h-3);
-            GC.Spread.Sheets.CellTypes.Text.prototype.paint.apply(this, arguments);
-            // }
-            if(calcBaseView.editingCell && !projectReadOnly && calcBaseView.ifEdit(type, options.row)){
-                if(calcBaseView.editingCell.row==options.row&&calcBaseView.editingCell.col==options.col){
+            if(!projectReadOnly && calcBaseView.ifEdit(type, options.row)){
+                if(options.sheet.getActiveRowIndex()==options.row&&options.sheet.getActiveColumnIndex()==options.col){
                     var image = document.getElementById('f_btn'),imageMagin = 3;
-                    var imageHeight = h-2*imageMagin;
-                    var imageWidth = w*2/(type=='bills'?7:20);
+                    var imageHeight = 15;
+                    var imageWidth = 25;
                     var imageX = x + w - imageWidth- imageMagin, imageY = y + h / 2 - imageHeight / 2;
                     ctx.save();
+                    ctx.fillStyle = style.backColor;
+                    ctx.fillRect(x,y,w,h);
                     ctx.drawImage(image, imageX, imageY,imageWidth,imageHeight);
                     ctx.beginPath();
                     ctx.arc(imageX+imageWidth/2,imageY+imageHeight/2,1,0,360,false);
@@ -1949,8 +1946,10 @@ var projectObj = {
                     ctx.fill();//画实心圆
                     ctx.closePath();
                     ctx.restore();
+                    x = x - imageWidth - imageMagin;
                 }
             }
+            GC.Spread.Sheets.CellTypes.Text.prototype.paint.apply(this, arguments);
         };
         CommonTotalFeeCellType.prototype.getHitInfo = function (x, y, cellStyle, cellRect, context) {
             return {
@@ -1965,11 +1964,9 @@ var projectObj = {
         };
         CommonTotalFeeCellType.prototype.processMouseDown = function (hitinfo) {
             let me = calcBaseView;
-            if(me.editingCell && hitinfo.row==me.editingCell.row){
+            if(hitinfo.sheet.getActiveRowIndex()==hitinfo.row&&hitinfo.sheet.getActiveColumnIndex()==hitinfo.col){
                 var offset=hitinfo.cellRect.x+hitinfo.cellRect.width-6;
-                var imageMagin=3;
-                var imageHeight = hitinfo.cellRect.height-2*imageMagin;
-                var imageWidth = hitinfo.cellRect.width*2/7;
+                var imageWidth = 25;
                 if(hitinfo.x<offset&&hitinfo.x>offset-imageWidth){
                     if(!projectReadOnly && me.ifEdit(type, hitinfo.row)){
                         if(hitinfo.sheet.getParent() === projectObj.mainSpread){
@@ -1983,39 +1980,9 @@ var projectObj = {
                         calcBaseView.initCalctor(type);
                         feeRateObject.showSelectModal(hitinfo);
                     }
-                }else {//鼠标点击其它地方,消失
-                    hideButton(hitinfo);
                 }
             }
         };
-        CommonTotalFeeCellType.prototype.processMouseEnter = function (hitinfo){
-            let me = calcBaseView;
-            me.pmLeave = false;
-            if(me.editingCell==null){
-                var showSelectBtn = true;
-                showSelectBtn=me.ifEdit(type, hitinfo.row);
-                if(showSelectBtn){
-                    me.editingCell={
-                        row:hitinfo.row,
-                        col:hitinfo.col
-                    };
-                    hitinfo.sheet.invalidateLayout();
-                    hitinfo.sheet.repaint();
-                }
-            }
-        };
-        CommonTotalFeeCellType.prototype.processMouseLeave = function (hitinfo) {
-            hideButton(hitinfo);
-        };
-
-        function hideButton(hitinfo) {
-            if(!calcBaseView.pmLeave){
-                calcBaseView.editingCell=null;
-                hitinfo.sheet.invalidateLayout();
-                hitinfo.sheet.repaint();
-                calcBaseView.pmLeave = true;
-            }
-        }
         return new CommonTotalFeeCellType();
     },
     selectColAndFocus :function (newNode,field = 'code') {//选中单元格并设置焦点

+ 16 - 70
web/building_saas/main/js/views/quantity_edit_view.js

@@ -54,7 +54,7 @@ let quantityEditObj = {
         $("#quantityEXPValue").val(strartString+value+endString);
         setCursor($("#quantityEXPValue")[0],startIndex+value.length);//设置回光标位置
     },
-    getQuantityEditCellType:function () {
+    getQuantityEditCellType:function () {//这个需配合整个表的selection change事件,当change的时候会repaint,按钮会显示
         var ns = GC.Spread.Sheets;
         function QuantityEditCellType() {
             var init=false;
@@ -62,17 +62,15 @@ let quantityEditObj = {
         }
         QuantityEditCellType.prototype = new ns.CellTypes.Text();
         QuantityEditCellType.prototype.paint = function (ctx, value, x, y, w, h, style, options) {
-            // if(value!=null){
-            // ctx.fillText(value,x+3+ctx.measureText(value).width,y+h-3);
-            // }
-            GC.Spread.Sheets.CellTypes.Text.prototype.paint.apply(this, arguments);
-            if(quantityEditObj.editingCell && !projectReadOnly){
-                if(quantityEditObj.editingCell.row==options.row&&quantityEditObj.editingCell.col==options.col){
+            if(!projectReadOnly){
+                if(options.sheet.getActiveRowIndex()==options.row&&options.sheet.getActiveColumnIndex()==options.col){
                     var image = document.getElementById('f_btn'),imageMagin = 3;
-                    var imageHeight = h-2*imageMagin;
-                    var imageWidth = w*2/7;
+                    var imageHeight = 15;
+                    var imageWidth = 25;
                     var imageX = x + w - imageWidth- imageMagin, imageY = y + h / 2 - imageHeight / 2;
                     ctx.save();
+                    ctx.fillStyle = style.backColor;
+                    ctx.fillRect(x,y,w,h);
                     ctx.drawImage(image, imageX, imageY,imageWidth,imageHeight);
                     ctx.beginPath();
                     ctx.arc(imageX+imageWidth/2,imageY+imageHeight/2,1,0,360,false);
@@ -82,9 +80,10 @@ let quantityEditObj = {
                     ctx.fill();//画实心圆
                     ctx.closePath();
                     ctx.restore();
+                    x = x - imageWidth - imageMagin;
                 }
             }
-
+            GC.Spread.Sheets.CellTypes.Text.prototype.paint.apply(this, arguments);
         };
         QuantityEditCellType.prototype.getHitInfo = function (x, y, cellStyle, cellRect, context) {
             return {
@@ -99,71 +98,18 @@ let quantityEditObj = {
         };
 
         //2018 -09 -26  修改工程量这个输入控件,删除悬浮提示注释,还原时通过git 历史
-
         QuantityEditCellType.prototype.processMouseDown = function (hitinfo) {
             let me=quantityEditObj;
-           /* if(isDoubleClick(this) == true && !projectReadOnly){//如果是双击,直接显示 2019-1-17 需求更改,取消双击弹出
-                me.showSelectModal(hitinfo);
-                return ;
-            }*/
-           if(me.editingCell && hitinfo.row==me.editingCell.row){
-               if(me.editingCell.isBtn == false){//是第一次点击,刷新显示按钮
-                   me.editingCell.isBtn = true;
-                   hitinfo.sheet.invalidateLayout();
-                   hitinfo.sheet.repaint();
-               }else {
-                   var offset=hitinfo.cellRect.x+hitinfo.cellRect.width-6;
-                   var imageMagin=3;
-                   var imageHeight = hitinfo.cellRect.height-2*imageMagin;
-                   var imageWidth = hitinfo.cellRect.width*2/7;
-                   if(hitinfo.x<offset&&hitinfo.x>offset-imageWidth){
-                       if(!projectReadOnly){
-                           me.showSelectModal(hitinfo);
-                       }
-                   }/*else {//点击其它地方,按钮消失
-                    hideButton(hitinfo)
-                    }*/
-               }
-            }
-        };
-        QuantityEditCellType.prototype.processMouseEnter = function (hitinfo) {
-            var me=quantityEditObj;
-            me.pmLeave = false;
-            if(me.editingCell==null){
-                me.editingCell={
-                    row:hitinfo.row,
-                    col:hitinfo.col,
-                    isBtn :false//鼠标刚进入的时候按钮还是没显示的状态
+            if(hitinfo.sheet.getActiveRowIndex()==hitinfo.row&&hitinfo.sheet.getActiveColumnIndex()==hitinfo.col){
+                var offset=hitinfo.cellRect.x+hitinfo.cellRect.width-6;
+                var imageWidth = 25;
+                if(hitinfo.x<offset&&hitinfo.x>offset-imageWidth){
+                    if(!projectReadOnly){
+                        me.showSelectModal(hitinfo);
+                    }
                 }
-               // hitinfo.sheet.invalidateLayout();
-                //hitinfo.sheet.repaint();
             }
         };
-        QuantityEditCellType.prototype.processMouseLeave = function (hitinfo) {
-            hideButton(hitinfo);
-        };
-
-        function hideButton(hitinfo) {
-            if(!quantityEditObj.pmLeave){//鼠标进入显示三个点按钮
-                quantityEditObj.editingCell=null;
-                hitinfo.sheet.invalidateLayout();
-                hitinfo.sheet.repaint();
-                quantityEditObj.pmLeave = true;
-            }
-        }
-
-        function isDoubleClick(quantityCell) {
-            let nowTime = +new Date();
-            if(quantityCell.clickTime !=0){
-                if(nowTime - quantityCell.clickTime < 280) {//判断为双击
-                    quantityCell.clickTime = 0;
-                    return true;
-                }
-            }
-            quantityCell.clickTime = nowTime;//计录点击时间
-            return false
-        }
-
         return new QuantityEditCellType();
     },
     showSelectModal:function (hitinfo) {

+ 4 - 2
web/building_saas/pm/js/pm_newMain.js

@@ -574,6 +574,9 @@ const projTreeObj = {
             }
         }
     },
+    cusButtonClick:async function(info){
+        projTreeObj.changeFileClick(null,info);
+    },
     onDragDropBlock : function (sender,args) {//拖动移动项目位置
         let selected = projTreeObj.tree.selected;
         let targetNode = projTreeObj.tree.items[args.toRow];
@@ -1047,8 +1050,7 @@ const projTreeObj = {
                     me.setCellValue({row: i, col: j}, nodes[i],sheet,setting);
                     let dataCode = headers[j].dataCode;
                     if(nodes[i].data.projType == "Tender" && (dataCode=="feeRateFile" || dataCode == "unitPriceFile")) {
-                        sheet.setCellType(i, j,sheetCommonObj.getSelectButton(headers[j].width),GC.Spread.Sheets.SheetArea.viewport);
-                        sheet.getCell(i, j,GC.Spread.Sheets.SheetArea.viewport).locked(false);
+                        sheet.setCellType(i, j,sheetCommonObj.getCusButtonCellType(me.cusButtonClick,false),GC.Spread.Sheets.SheetArea.viewport);
                     }
                     //sheet.setValue(i, j, nodes[i]['data'][dataCode]);
                 }

+ 1 - 0
web/common/html/header.html

@@ -1,3 +1,4 @@
+<img id="f_btn" src="/web/dest/css/img/feeRate_btn.jpg" alt="" style="display: none" />
 <nav class="navbar navbar-expand-lg p-0 d-flex">
     <% if(controller === 'boot' || controller === 'pm'){ %>
     <!--<a style="text-decoration: none" href="javascript:void(0);" class="header-logo">-->