Skip to content
This repository has been archived by the owner on Mar 28, 2024. It is now read-only.

Commit

Permalink
fix(bug): setRangeShow api
Browse files Browse the repository at this point in the history
  • Loading branch information
jerry-f committed Jan 18, 2021
1 parent 3b1edf9 commit 5bbc45b
Showing 1 changed file with 38 additions and 12 deletions.
50 changes: 38 additions & 12 deletions src/global/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -1599,9 +1599,9 @@ export function getRange() {
*/
export function getRangeWithFlatten(range){
range = range || getRange();

let result = [];

range.forEach(ele=>{
// 这个data可能是个范围或者是单个cell
let rs = ele.row;
Expand All @@ -1623,11 +1623,11 @@ export function getRangeWithFlatten(range){
*/
export function getRangeValuesWithFlatte(range){
range = range || getRangeWithFlatten();

let values = [];

// 获取到的这个数据不是最新的数据
range.forEach(item=> {
range.forEach(item=> {
values.push(Store.flowdata[item.r][item.c]);
});
return values;
Expand Down Expand Up @@ -2605,6 +2605,30 @@ export function setRangeShow(range, options = {}) {
}];
}

if(getObjType(range) == 'array'){
for(let i = 0; i < range.length; i++){
if(getObjType(range[i]) === 'string'){
if(!formula.iscelldata(range[i])){
return tooltip.info("The range parameter is invalid.", "");
}
let cellrange = formula.getcellrange(range[i]);
range[i] = {
"row": cellrange.row,
"column": cellrange.column
}
}
else if(getObjType(range) == 'object'){
if(range.row == null || range.column == null){
return tooltip.info("The range parameter is invalid.", "");
}
range = {
"row": range.row,
"column": range.column
};
}
}
}

if(getObjType(range) != 'array'){
return tooltip.info("The range parameter is invalid.", "");
}
Expand All @@ -2623,9 +2647,11 @@ export function setRangeShow(range, options = {}) {

for(let i = 0; i < range.length; i++){
let changeparam = menuButton.mergeMoveMain(range[i].column, range[i].row, range[i]);
range[i] = {
"row": changeparam[1],
"column": changeparam[0]
if(changeparam) {
range[i] = {
"row": changeparam[1],
"column": changeparam[0]
}
}
}

Expand Down Expand Up @@ -5637,10 +5663,10 @@ export function setWorkbookName(name, options = {}) {
* @returns {String} 返回工作簿名称,如果读取失败则返回空字符串并弹窗提示
*/
export function getWorkbookName(options = {}) {

let name = "";
let element = $("#luckysheet_info_detail_input");

if(element.length == 0){

tooltip.info('Failed to get workbook name, label loading failed!');
Expand All @@ -5649,7 +5675,7 @@ export function getWorkbookName(options = {}) {
}

name = $.trim(element.val());

let {
success
} = {...options}
Expand Down Expand Up @@ -6628,13 +6654,13 @@ export function refreshMenuButtonFocus(data ,r,c , success){
if(r == null && c == null){
/* 获取选取范围 */
let last = Store.luckysheet_select_save[Store.luckysheet_select_save.length -1];

r = last.row_focus || last.row[0];
c = last.column_focus || last.column[0];
}

menuButton.menuButtonFocus(data, r, c);

setTimeout(() => {
if (success && typeof success === 'function') {
success();
Expand Down

0 comments on commit 5bbc45b

Please sign in to comment.