chenshilong 5 lat temu
rodzic
commit
9e386b3d33

+ 23 - 21
public/web/sheet/sheet_common.js

@@ -682,46 +682,48 @@ var sheetCommonObj = {
         //sheet.setCellType(row, col,this.getSelectButton(header.headerWidth),GC.Spread.Sheets.SheetArea.viewport);
     },
 
-    getCusButtonCellType:function (callback,readOnly=false,ostyle) {
+    getCusButtonCellType: function (callback, readOnly = false, ostyle) {
         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;
+            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;
+                    var imageX = x + w - imageWidth - imageMagin, imageY = y + h / 2 - imageHeight / 2;
                     ctx.save();
-                    if(style.backColor){
+                    if (style.backColor) {
                         ctx.fillStyle = style.backColor;
-                        ctx.fillRect(x,y,w,h);
+                        ctx.fillRect(x, y, w, h);
                     }
-                    ctx.drawImage(image, imageX, imageY,imageWidth,imageHeight);
+                    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.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();
                     w = w - imageWidth - imageMagin;
                     //这里的左对齐的,当显示的字长度超过空白地方时,要改成右对齐
-                    if(style.hAlign == 0){
-                        if(value){
+                    if (style.hAlign == 0) {
+                        if (value) {
                             let textWidth = ctx.measureText(value).width;
                             let spaceWidth = w;
-                            if(spaceWidth<textWidth){
+                            if (spaceWidth < textWidth) {
                                 style.hAlign = 2;
                             }
                         }
                     }
                 }
             }
-            if(ostyle)  gljUtil.setProperty(style,ostyle);
+            if (ostyle) gljUtil.setProperty(style, ostyle);
             GC.Spread.Sheets.CellTypes.Text.prototype.paint.apply(this, arguments);
         };
         CusButtonCellType.prototype.getHitInfo = function (x, y, cellStyle, cellRect, context) {
@@ -737,12 +739,12 @@ var sheetCommonObj = {
         };
 
         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;
+            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)
+                if (hitinfo.x < offset && hitinfo.x > offset - imageWidth) {
+                    if (!readOnly) {
+                        if (callback) callback(hitinfo)
                     }
                 }
             }

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

@@ -233,7 +233,8 @@ let calcProgramManage = {
         }
     },
     onDetailEnterCell: function (sender, args) {
-        calcProgramManage.detailSheet.repaint();   // 这句是为了触发sheetCommonObj → getCusButtonCellType → CusButtonCellType → paint方法。
+        // if (args.col == 2)    // 加这句,切换单元格后,原单元格的三点图片不会消失。
+            calcProgramManage.detailSheet.repaint();   // 这句是为了触发sheetCommonObj → getCusButtonCellType → CusButtonCellType → paint方法。
         // for test.
         // let t = calcProgramManage.getSelectionInfo().template;
         // let c = calcProgramManage.getSelectionInfo().calcItem;