From 956bd2a01012b429c58a14b5b88d02a02350b662 Mon Sep 17 00:00:00 2001 From: javahuang Date: Tue, 20 Oct 2020 16:51:07 +0800 Subject: [PATCH] feat(row and column width): batch change the height and width of the selected row and column --- src/controllers/handler.js | 45 +++++++++++++++++++++++++-- src/controllers/rowColumnOperation.js | 12 ++++--- 2 files changed, 50 insertions(+), 7 deletions(-) diff --git a/src/controllers/handler.js b/src/controllers/handler.js index 432681ddc..aecb8e61f 100644 --- a/src/controllers/handler.js +++ b/src/controllers/handler.js @@ -3339,7 +3339,26 @@ export default function luckysheetHandler() { cfg["customHeight"][Store.luckysheet_rows_change_size_start[1]] = 1; - cfg["rowlen"][Store.luckysheet_rows_change_size_start[1]] = Math.ceil(size/Store.zoomRatio); + const changeRowIndex = Store.luckysheet_rows_change_size_start[1]; + let changeRowSelected = false; + if(Store["luckysheet_select_save"].length > 0) { + Store["luckysheet_select_save"].filter(select => select.row_select).some((select) => { + if(changeRowIndex >= select.row[0] && changeRowIndex <= select.row[1]) { + changeRowSelected = true; + } + return changeRowSelected; + }); + } + if(changeRowSelected) { + Store["luckysheet_select_save"].filter(select => select.row_select).forEach(select => { + for(let r = select.row[0]; r <= select.row[1]; r++) { + cfg["rowlen"][r] = Math.ceil(size/Store.zoomRatio); + } + }) + } + else { + cfg["rowlen"][Store.luckysheet_rows_change_size_start[1]] = Math.ceil(size/Store.zoomRatio); + } let images = imageCtrl.moveChangeSize("row", Store.luckysheet_rows_change_size_start[1], size); @@ -3421,7 +3440,27 @@ export default function luckysheetHandler() { cfg["customWidth"][Store.luckysheet_cols_change_size_start[1]] = 1; - cfg["columnlen"][Store.luckysheet_cols_change_size_start[1]] = Math.ceil(size/Store.zoomRatio); + const changeColumnIndex = Store.luckysheet_cols_change_size_start[1]; + let changeColumnSelected = false; + if(Store["luckysheet_select_save"].length > 0) { + Store["luckysheet_select_save"].filter(select => select.column_select).some((select) => { + if(changeColumnIndex >= select.column[0] && changeColumnIndex <= select.column[1]) { + changeColumnSelected = true; + } + return changeColumnSelected; + }); + } + if(changeColumnSelected) { + Store["luckysheet_select_save"].filter(select => select.column_select).forEach(select => { + for(let r = select.column[0]; r <= select.column[1]; r++) { + cfg["columnlen"][r] = Math.ceil(size/Store.zoomRatio); + } + }) + } + else { + cfg["columnlen"][Store.luckysheet_cols_change_size_start[1]] = Math.ceil(size/Store.zoomRatio); + } + let images = imageCtrl.moveChangeSize("column", Store.luckysheet_cols_change_size_start[1], size); @@ -4648,7 +4687,7 @@ export default function luckysheetHandler() { $("#luckysheet-wa-functionbox-confirm").click(); Store.luckysheet_select_status = false; - Store.luckysheet_select_save = [{ "row": [0, Store.flowdata.length - 1], "column": [0, Store.flowdata[0].length - 1], "row_focus": 0, "column_focus": 0 }]; + Store.luckysheet_select_save = [{ "row": [0, Store.flowdata.length - 1], "column": [0, Store.flowdata[0].length - 1], "row_focus": 0, "column_focus": 0, row_select: true, column_select: true }]; selectHightlightShow(); clearTimeout(Store.countfuncTimeout); diff --git a/src/controllers/rowColumnOperation.js b/src/controllers/rowColumnOperation.js index 1c0be6d16..cd22ca59a 100644 --- a/src/controllers/rowColumnOperation.js +++ b/src/controllers/rowColumnOperation.js @@ -316,7 +316,8 @@ export function rowColumnOperationInitial(){ "row": rowseleted, "column": [0, col_index], "row_focus": row_index, - "column_focus": 0 + "column_focus": 0, + "row_select": true }); } else{ @@ -333,7 +334,8 @@ export function rowColumnOperationInitial(){ "row": rowseleted, "column": [0, col_index], "row_focus": row_index, - "column_focus": 0 + "column_focus": 0, + "row_select": true }); } @@ -691,7 +693,8 @@ export function rowColumnOperationInitial(){ "row": [0, row_index], "column": columnseleted, "row_focus": 0, - "column_focus": col_index + "column_focus": col_index, + "column_select": true }); } else{ @@ -708,7 +711,8 @@ export function rowColumnOperationInitial(){ "row": [0, row_index], "column": columnseleted, "row_focus": 0, - "column_focus": col_index + "column_focus": col_index, + "column_select": true }); }