From 3654c46cf7127c6f3fc2d52f6e02a2361770145b Mon Sep 17 00:00:00 2001 From: ZCF1024 <184248697@qq.com> Date: Sun, 3 Jan 2021 15:49:25 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E5=9B=BE=E8=A1=A8?= =?UTF-8?q?=E5=8F=AF=E6=8B=96=E5=8A=A8=E5=8C=BA=E5=9F=9F=E9=AB=98=E4=BA=AE?= =?UTF-8?q?=E6=95=88=E6=9E=9C=EF=BC=8C=E9=BC=A0=E6=A0=87=E7=BB=8F=E8=BF=87?= =?UTF-8?q?=E5=8F=AF=E6=8B=96=E5=8A=A8=E5=8C=BA=E5=9F=9F=E6=97=B6=E9=BC=A0?= =?UTF-8?q?=E6=A0=87=E6=98=BE=E7=A4=BA=E5=8D=81=E5=AD=97=EF=BC=8C=E4=B8=8D?= =?UTF-8?q?=E5=8F=AF=E6=8B=96=E5=8A=A8=E5=8C=BA=E5=9F=9F=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E7=AE=AD=E5=A4=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/css/luckysheet-core.css | 4 ++++ src/expendPlugins/chart/plugin.js | 24 +++++++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/css/luckysheet-core.css b/src/css/luckysheet-core.css index c995f00..30f0dc9 100644 --- a/src/css/luckysheet-core.css +++ b/src/css/luckysheet-core.css @@ -18,6 +18,10 @@ user-select: none; } +.chart-moveable{ + cursor: move; +} + .luckysheet { position: absolute; /* width: 100%; diff --git a/src/expendPlugins/chart/plugin.js b/src/expendPlugins/chart/plugin.js index 063b97d..a3d4579 100644 --- a/src/expendPlugins/chart/plugin.js +++ b/src/expendPlugins/chart/plugin.js @@ -9,7 +9,7 @@ import { rowLocation, colLocation, mouseposition } from '../../global/location' import { setluckysheet_scroll_status } from '../../methods/set' import { luckysheetMoveHighlightCell, - luckysheetMoveHighlightCell2, + luckysheetMoveHighlightCell2, luckysheetMoveHighlightRange, luckysheetMoveHighlightRange2, luckysheetMoveEndCell @@ -132,6 +132,8 @@ function renderCharts(chartLists, isDemo) { }) ).appendTo($('.luckysheet-cell-main')) + setChartMoveableEffect($t); + $(`#${chart_id_c}`).children('.luckysheet-modal-dialog-content')[0].id = chart_id let container = document.getElementById(chart_id_c) @@ -1217,6 +1219,8 @@ function createLuckyChart(width, height, left, top) { delChart(chart_id) }) + setChartMoveableEffect($t); + // edit current chart $(`#${chart_id}_c .luckysheet-modal-controll-update`).click(function (e) { showChartSettingComponent() @@ -1329,6 +1333,24 @@ function createLuckyChart(width, height, left, top) { }) } +/** + * 设置图表可拖动区域高亮效果,鼠标经过可拖动区域时鼠标显示“十字”,不可拖动区域显示箭头 + * @param {JQuery} $container 图表的容器DIV + */ +function setChartMoveableEffect($container) { + $container.find('.luckysheet-modal-dialog-content').hover(function () { + $container.removeClass("chart-moveable"); + }, function () { + $container.addClass("chart-moveable"); + }); + + $container.hover(function () { + $container.addClass("chart-moveable"); + }, function () { + $container.removeClass("chart-moveable"); + }); +} + // delete chart function delChart(chart_id) { // delete container From 9f72f37a0b4ac089b8ec21b4478cbb9c1cd4f7e6 Mon Sep 17 00:00:00 2001 From: ZCF1024 <184248697@qq.com> Date: Sun, 3 Jan 2021 16:50:55 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=A4=84=E7=90=86=E5=8D=95=E5=85=83?= =?UTF-8?q?=E6=A0=BC=E4=B8=8A=E9=BC=A0=E6=A0=87=E6=8B=96=E6=8B=BD=E5=81=9C?= =?UTF-8?q?=E6=AD=A2=E4=BA=8B=E4=BB=B6=EF=BC=8C=E5=B9=B6=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=AF=B9=E5=BA=94=E7=9A=84=E9=92=A9=E5=AD=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/handler.js | 45 ++++++++++++++++++++++++++++++++++++++ src/index.html | 3 +++ 2 files changed, 48 insertions(+) diff --git a/src/controllers/handler.js b/src/controllers/handler.js index dd983f6..7628c3c 100644 --- a/src/controllers/handler.js +++ b/src/controllers/handler.js @@ -1465,12 +1465,57 @@ export default function luckysheetHandler() { imageCtrl.inserImg(src); } } + handleCellDragStopEvent(e); }, false); document.getElementById('luckysheet-cell-main').addEventListener('dragover', function(e){ e.preventDefault(); e.stopPropagation(); }, false); + /** + * 处理单元格上鼠标拖拽停止事件 + * @param {DragEvent} event + */ + function handleCellDragStopEvent(event) { + if (luckysheetConfigsetting && luckysheetConfigsetting.hook && luckysheetConfigsetting.hook.cellDragStop) { + let mouse = mouseposition(event.pageX, event.pageY); + let x = mouse[0] + $("#luckysheet-cell-main").scrollLeft(); + let y = mouse[1] + $("#luckysheet-cell-main").scrollTop(); + + let row_location = rowLocation(y), + row = row_location[1], + row_pre = row_location[0], + row_index = row_location[2]; + let col_location = colLocation(x), + col = col_location[1], + col_pre = col_location[0], + col_index = col_location[2]; + + let margeset = menuButton.mergeborer(Store.flowdata, row_index, col_index); + if (!!margeset) { + row = margeset.row[1]; + row_pre = margeset.row[0]; + row_index = margeset.row[2]; + + col = margeset.column[1]; + col_pre = margeset.column[0]; + col_index = margeset.column[2]; + } + + let sheetFile = sheetmanage.getSheetByIndex(); + + let luckysheetTableContent = $("#luckysheetTableContent").get(0).getContext("2d"); + method.createHookFunction("cellDragStop", Store.flowdata[row_index][col_index], { + r: row_index, + c: col_index, + "start_r": row_pre, + "start_c": col_pre, + "end_r": row, + "end_c": col + }, sheetFile, luckysheetTableContent, event); + } + } + //表格mousemove $(document).on("mousemove.luckysheetEvent",function (event) { luckysheetPostil.overshow(event); //有批注显示 diff --git a/src/index.html b/src/index.html index a64c409..1cfc67a 100644 --- a/src/index.html +++ b/src/index.html @@ -93,6 +93,9 @@ } ], hook:{ + cellDragStop: function (cell, postion, sheetFile, moveState, ctx, event) { + console.info(cell, postion, sheetFile, ctx, event); + }, rowTitleCellRenderBefore:function(rowNum,postion,ctx){ // console.log(rowNum); },