From 726300811a9fdb6e36d19187764aa73daacfc7b7 Mon Sep 17 00:00:00 2001 From: wpxp123456 <2677556700@qq.com> Date: Mon, 17 Aug 2020 17:30:06 +0800 Subject: [PATCH] fix(bug): bug bug --- src/controllers/filter.js | 16 ++++--- src/controllers/handler.js | 1 - src/controllers/rowColumnOperation.js | 66 ++++++++++++++++++------- src/controllers/sheetmanage.js | 69 ++++++++++++++++++++------- src/global/draw.js | 8 ++++ src/locale/en.js | 1 + src/locale/zh.js | 1 + 7 files changed, 121 insertions(+), 41 deletions(-) diff --git a/src/controllers/filter.js b/src/controllers/filter.js index d4ce2cb..d979f7e 100644 --- a/src/controllers/filter.js +++ b/src/controllers/filter.js @@ -100,11 +100,13 @@ function orderbydatafiler(str, stc, edr, edc, index, asc) { } if(hasMc){ + const locale_filter = locale().filter; + if(isEditMode()){ - alert("筛选选区有合并单元格,无法执行此操作!"); + alert(locale_filter.mergeError); } else{ - tooltip.info("筛选选区有合并单元格,无法执行此操作!", ""); + tooltip.info(locale_filter.mergeError, ""); } return; @@ -134,13 +136,15 @@ function createFilter() { if(Store.luckysheet_select_save.length > 1){ $("#luckysheet-rightclick-menu").hide(); $("#luckysheet-filter-menu, #luckysheet-filter-submenu").hide(); - $("#" + container).attr("tabindex", 0).focus(); + $("#" + Store.container).attr("tabindex", 0).focus(); + + const locale_splitText = locale().splitText; if(isEditMode()){ - alert("不能对多重选择区域执行此操作,请选择单个区域,然后再试"); + alert(locale_splitText.tipNoMulti); } else{ - tooltip.info("不能对多重选择区域执行此操作,请选择单个区域,然后再试", ""); + tooltip.info(locale_splitText.tipNoMulti, ""); } return; @@ -277,8 +281,6 @@ function createFilterOptions(luckysheet_filter_save, filterObj) { file.filter_select = luckysheet_filter_save; } - - function initialFilterHandler(){ //filter event handler let hidefilersubmenu = null; diff --git a/src/controllers/handler.js b/src/controllers/handler.js index 7bfe63d..6c0fef4 100644 --- a/src/controllers/handler.js +++ b/src/controllers/handler.js @@ -185,7 +185,6 @@ export default function luckysheetHandler() { // setTimeout(function(){ luckysheetscrollevent(); // },10); - }) .mousewheel(function (event, delta) { event.preventDefault(); diff --git a/src/controllers/rowColumnOperation.js b/src/controllers/rowColumnOperation.js index 9ccb240..6ca9cb8 100644 --- a/src/controllers/rowColumnOperation.js +++ b/src/controllers/rowColumnOperation.js @@ -35,12 +35,9 @@ import {getMeasureText} from '../global/getRowlen'; import { luckysheet_searcharray } from '../controllers/sheetSearch'; import Store from '../store'; - - export function rowColumnOperationInitial(){ - - //表格行标题 mouse事件 + //表格行标题 mouse事件 $("#luckysheet-rows-h").mousedown(function (event) { //有批注在编辑时 luckysheetPostil.removeActivePs(); @@ -809,7 +806,6 @@ export function rowColumnOperationInitial(){ } }); - //表格行标题 改变行高按钮 $("#luckysheet-rows-change-size").mousedown(function (event) { //有批注在编辑时 @@ -915,6 +911,10 @@ export function rowColumnOperationInitial(){ $("#luckysheet-rightclick-menu").hide(); luckysheetContainerFocus(); + const _locale = locale(); + const locale_drag = _locale.drag; + const locale_info = _locale.info; + if(Store.luckysheet_select_save.length > 1){ if(isEditMode()){ alert(locale_drag.noMulti); @@ -926,6 +926,8 @@ export function rowColumnOperationInitial(){ return; } + + let $t = $(this), value = $t.parent().find("input").val(); if (!isRealNum(value)) { if(isEditMode()){ @@ -956,6 +958,10 @@ export function rowColumnOperationInitial(){ $("#luckysheet-addTopRows").click(function (event) { $("#luckysheet-rightclick-menu").hide(); luckysheetContainerFocus(); + + const _locale = locale(); + const locale_drag = _locale.drag; + const locale_info = _locale.info; if(Store.luckysheet_select_save.length > 1){ if(isEditMode()){ @@ -984,10 +990,10 @@ export function rowColumnOperationInitial(){ if (value < 1 || value > 100) { if(isEditMode()){ - alert(llocale_info.tipInputNumberLimit); + alert(locale_info.tipInputNumberLimit); } else{ - tooltip.info(llocale_info.tipInputNumberLimit, ""); + tooltip.info(locale_info.tipInputNumberLimit, ""); } return; } @@ -998,6 +1004,10 @@ export function rowColumnOperationInitial(){ $("#luckysheet-addLeftCols").click(function (event) { $("#luckysheet-rightclick-menu").hide(); luckysheetContainerFocus(); + + const _locale = locale(); + const locale_drag = _locale.drag; + const locale_info = _locale.info; if(Store.luckysheet_select_save.length > 1){ if(isEditMode()){ @@ -1026,10 +1036,10 @@ export function rowColumnOperationInitial(){ if (value < 1 || value > 100) { if(isEditMode()){ - alert(llocale_info.tipInputNumberLimit); + alert(locale_info.tipInputNumberLimit); } else{ - tooltip.info(llocale_info.tipInputNumberLimit, ""); + tooltip.info(locale_info.tipInputNumberLimit, ""); } return; } @@ -1043,6 +1053,10 @@ export function rowColumnOperationInitial(){ $("#luckysheet-rightclick-menu").hide(); luckysheetContainerFocus(); + const _locale = locale(); + const locale_drag = _locale.drag; + const locale_info = _locale.info; + if(Store.luckysheet_select_save.length > 1){ if(isEditMode()){ alert(locale_drag.noMulti); @@ -1070,10 +1084,10 @@ export function rowColumnOperationInitial(){ if (value < 1 || value > 100) { if(isEditMode()){ - alert(llocale_info.tipInputNumberLimit); + alert(locale_info.tipInputNumberLimit); } else{ - tooltip.info(llocale_info.tipInputNumberLimit, ""); + tooltip.info(locale_info.tipInputNumberLimit, ""); } return; @@ -1086,6 +1100,10 @@ export function rowColumnOperationInitial(){ $("#luckysheet-rightclick-menu").hide(); luckysheetContainerFocus(); + const _locale = locale(); + const locale_drag = _locale.drag; + const locale_info = _locale.info; + if(Store.luckysheet_select_save.length > 1){ if(isEditMode()){ alert(locale_drag.noMulti); @@ -1113,10 +1131,10 @@ export function rowColumnOperationInitial(){ if (value < 1 || value > 100) { if(isEditMode()){ - alert(llocale_info.tipInputNumberLimit); + alert(locale_info.tipInputNumberLimit); } else{ - tooltip.info(llocale_info.tipInputNumberLimit, ""); + tooltip.info(locale_info.tipInputNumberLimit, ""); } return; @@ -1129,6 +1147,10 @@ export function rowColumnOperationInitial(){ $("#luckysheet-rightclick-menu").hide(); luckysheetContainerFocus(); + const _locale = locale(); + const locale_drag = _locale.drag; + const locale_info = _locale.info; + if(Store.luckysheet_select_save.length > 1){ if(isEditMode()){ alert(locale_drag.noMulti); @@ -1156,10 +1178,10 @@ export function rowColumnOperationInitial(){ if (value < 1 || value > 100) { if(isEditMode()){ - alert(llocale_info.tipInputNumberLimit); + alert(locale_info.tipInputNumberLimit); } else{ - tooltip.info(llocale_info.tipInputNumberLimit, ""); + tooltip.info(locale_info.tipInputNumberLimit, ""); } return; @@ -1174,6 +1196,8 @@ export function rowColumnOperationInitial(){ $("#luckysheet-rightclick-menu").hide(); luckysheetContainerFocus(); + const locale_drag = locale().drag; + if(Store.luckysheet_select_save.length > 1){ if(Store.luckysheetRightHeadClickIs == "row"){ if(isEditMode()){ @@ -1202,6 +1226,8 @@ export function rowColumnOperationInitial(){ $("#luckysheet-rightclick-menu").hide(); luckysheetContainerFocus(); + const locale_drag = locale().drag; + if(Store.luckysheet_select_save.length > 1){ if(Store.luckysheetRightHeadClickIs == "row"){ if(isEditMode()){ @@ -1230,6 +1256,8 @@ export function rowColumnOperationInitial(){ $("#luckysheet-rightclick-menu").hide(); luckysheetContainerFocus(); + const locale_drag = locale().drag; + if(Store.luckysheet_select_save.length > 1){ if(Store.luckysheetRightHeadClickIs == "row"){ if(isEditMode()){ @@ -1366,6 +1394,8 @@ export function rowColumnOperationInitial(){ } if(has_PartMC){ + const locale_drag = locale().drag; + if(isEditMode()){ alert(locale_drag.noPartMerge); } @@ -1418,11 +1448,13 @@ export function rowColumnOperationInitial(){ let size = parseInt($(this).siblings("input[type='number']").val().trim()); if(size < 0 || size > 255){ + const locale_info = locale().info; + if(isEditMode()){ - alert(llocale_info.tipRowHeightLimit); + alert(locale_info.tipRowHeightLimit); } else{ - tooltip.info(llocale_info.tipRowHeightLimit, ""); + tooltip.info(locale_info.tipRowHeightLimit, ""); } return; diff --git a/src/controllers/sheetmanage.js b/src/controllers/sheetmanage.js index 7ddc1e3..e9b8d5e 100644 --- a/src/controllers/sheetmanage.js +++ b/src/controllers/sheetmanage.js @@ -590,10 +590,16 @@ const sheetmanage = { Store.luckysheet_select_save = file["luckysheet_select_save"]; if(Store.luckysheet_select_save == null || Store.luckysheet_select_save.length == 0){ if(data[0] != null && data[0][0] != null && data[0][0].mc != null){ - Store.luckysheet_select_save = [{ "row": [0, data[0][0].mc.rs - 1], "column": [0, data[0][0].mc.cs - 1] }]; + Store.luckysheet_select_save = [{ + "row": [0, data[0][0].mc.rs - 1], + "column": [0, data[0][0].mc.cs - 1] + }]; } else{ - Store.luckysheet_select_save = [{ "row": [0, 0], "column": [0, 0] }]; + Store.luckysheet_select_save = [{ + "row": [0, 0], + "column": [0, 0] + }]; } } @@ -687,6 +693,21 @@ const sheetmanage = { Store.luckysheetcurrentisPivotTable = false; $("#luckysheet-modal-dialog-slider-pivot").hide(); luckysheetsizeauto(); + + //等待滚动条dom宽高加载完成后 初始化滚动位置 + if(file["scrollLeft"] != null && file["scrollLeft"] > 0){ + $("#luckysheet-scrollbar-x").scrollLeft(file["scrollLeft"] * Store.zoomRatio); + } + else{ + $("#luckysheet-scrollbar-x").scrollLeft(0); + } + + if(file["scrollTop"] != null && file["scrollTop"] > 0){ + $("#luckysheet-scrollbar-y").scrollTop(file["scrollTop"] * Store.zoomRatio); + } + else{ + $("#luckysheet-scrollbar-y").scrollTop(0); + } } if(typeof luckysheetConfigsetting.beforeCreateDom == "function" ){ @@ -758,8 +779,13 @@ const sheetmanage = { file["luckysheet_select_save"] = $.extend(true, [], Store.luckysheet_select_save); file["luckysheet_selection_range"] = $.extend(true, [], Store.luckysheet_selection_range); - file["scrollLeft"] = $("#luckysheet-scrollbar-x").scrollLeft();//列标题 - file["scrollTop"] = $("#luckysheet-scrollbar-y").scrollTop();//行标题 + if($("#luckysheet-scrollbar-x")[0].scrollWidth > $("#luckysheet-scrollbar-x")[0].offsetWidth){ + file["scrollLeft"] = $("#luckysheet-scrollbar-x").scrollLeft(); //横向滚动条 + } + + if($("#luckysheet-scrollbar-y")[0].scrollHeight > $("#luckysheet-scrollbar-y")[0].offsetHeight){ + file["scrollTop"] = $("#luckysheet-scrollbar-y").scrollTop(); //纵向滚动条 + } file["zoomRatio"] = Store.zoomRatio; }, @@ -777,7 +803,22 @@ const sheetmanage = { Store.config = file["config"]; - Store.luckysheet_select_save = file["luckysheet_select_save"] == null ? [] : file["luckysheet_select_save"]; + Store.luckysheet_select_save = file["luckysheet_select_save"]; + if(Store.luckysheet_select_save == null || Store.luckysheet_select_save.length == 0){ + if(Store.flowdata[0] != null && Store.flowdata[0][0] != null && Store.flowdata[0][0].mc != null){ + Store.luckysheet_select_save = [{ + "row": [0, Store.flowdata[0][0].mc.rs - 1], + "column": [0, Store.flowdata[0][0].mc.cs - 1] + }]; + } + else{ + Store.luckysheet_select_save = [{ + "row": [0, 0], + "column": [0, 0] + }]; + } + } + Store.luckysheet_selection_range = file["luckysheet_selection_range"] == null ? [] : file["luckysheet_selection_range"]; if(file["freezen"] == null){ @@ -789,7 +830,7 @@ const sheetmanage = { luckysheetFreezen.freezenverticaldata = file["freezen"].vertical == null ? null : file["freezen"].vertical.freezenverticaldata; } - if(file["zoomRatio"]!=null){ + if(file["zoomRatio"] != null){ Store.zoomRatio = file["zoomRatio"]; } else{ @@ -799,15 +840,15 @@ const sheetmanage = { createFilterOptions(file["filter_select"], file["filter"]); Store.scrollRefreshSwitch = false; - if(file["scrollLeft"]!=null && file["scrollLeft"]>0){ - $("#luckysheet-scrollbar-x").scrollLeft(file["scrollLeft"]*Store.zoomRatio); + if(file["scrollLeft"] != null && file["scrollLeft"] > 0){ + $("#luckysheet-scrollbar-x").scrollLeft(file["scrollLeft"] * Store.zoomRatio); } else{ $("#luckysheet-scrollbar-x").scrollLeft(0); } - if(file["scrollTop"]!=null && file["scrollTop"]>0){ - $("#luckysheet-scrollbar-y").scrollTop(file["scrollTop"]*Store.zoomRatio); + if(file["scrollTop"] != null && file["scrollTop"] > 0){ + $("#luckysheet-scrollbar-y").scrollTop(file["scrollTop"] * Store.zoomRatio); } else{ $("#luckysheet-scrollbar-y").scrollTop(0); @@ -816,8 +857,7 @@ const sheetmanage = { Store.scrollRefreshSwitch = true; }, 0); - - jfrefreshgrid_rhcw(Store.flowdata.length, Store.flowdata[0].length,false); + jfrefreshgrid_rhcw(Store.flowdata.length, Store.flowdata[0].length, false); }, restoreselect: function() { let index = this.getSheetIndex(Store.currentSheetIndex); @@ -879,14 +919,11 @@ const sheetmanage = { pivotTable.changePivotTable(index); } } - else if($("#luckysheet-modal-dialog-slider-pivot").is(":visible")) { + else{ Store.luckysheetcurrentisPivotTable = false; $("#luckysheet-modal-dialog-slider-pivot").hide(); luckysheetsizeauto(false); } - else if(Store.luckysheetcurrentisPivotTable) { - Store.luckysheetcurrentisPivotTable = false; - } let load = file["load"]; if (load != null) { diff --git a/src/global/draw.js b/src/global/draw.js index 2a28212..ec11b7e 100644 --- a/src/global/draw.js +++ b/src/global/draw.js @@ -2068,6 +2068,14 @@ function getCellOverflowMap(canvas, col_st, col_ed, row_st, row_end){ let data = Store.flowdata; + if(row_st < 0){ + row_st = 0; + } + + if(row_end > data.length - 1){ + row_end = data.length - 1; + } + for(let r = row_st; r <= row_end; r++){ for(let c = 0; c < data[r].length; c++){ let cell = data[r][c]; diff --git a/src/locale/en.js b/src/locale/en.js index e2076e3..824cd48 100644 --- a/src/locale/en.js +++ b/src/locale/en.js @@ -484,6 +484,7 @@ export default { filterDateFormatTip:"Date format", valueBlank:"(Null)", + mergeError:"There are merged cells in the filter selection, this operation cannot be performed!", }, rightclick: { copy: 'Copy', diff --git a/src/locale/zh.js b/src/locale/zh.js index 281a9fc..e76c2d7 100644 --- a/src/locale/zh.js +++ b/src/locale/zh.js @@ -501,6 +501,7 @@ export default { filterDateFormatTip:"日期格式", valueBlank:"(空白)", + mergeError:"筛选选区有合并单元格,无法执行此操作!", }, rightclick: { copy: '复制',