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

Commit

Permalink
fix(bug): bug
Browse files Browse the repository at this point in the history
bug
  • Loading branch information
wpxp123456 committed Jul 24, 2020
1 parent 8be0467 commit 74639a8
Show file tree
Hide file tree
Showing 7 changed files with 122 additions and 43 deletions.
8 changes: 6 additions & 2 deletions src/controllers/conditionformat.js
Original file line number Diff line number Diff line change
Expand Up @@ -2064,6 +2064,9 @@ const conditionformat = {
$("#luckysheet-editorConditionRule-dialog #isPercent").attr("checked", "checked");
}
}

$("#luckysheet-editorConditionRule-dialog #textcolorshow").spectrum("set", ruleFormat.textColor);
$("#luckysheet-editorConditionRule-dialog #cellcolorshow").spectrum("set", ruleFormat.cellColor);
}
},
infoDialog: function(title, content){
Expand Down Expand Up @@ -3333,8 +3336,9 @@ const conditionformat = {
dSmall = genarate(conditionValue0)[2];
}
else{
dBig = genarate(conditionValue0.toString().split("-")[1])[2];
dSmall = genarate(conditionValue0.toString().split("-")[0])[2];
let str = conditionValue0.toString().split("-");
dBig = genarate(str[1].trim())[2];
dSmall = genarate(str[0].trim())[2];
}
//循环应用范围计算
for(let r = cellrange[s].row[0]; r <= cellrange[s].row[1]; r++){
Expand Down
16 changes: 8 additions & 8 deletions src/controllers/filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,14 +193,14 @@ function createFilterOptions(luckysheet_filter_save, filterObj) {
$("#luckysheet-filter-selected-sheet" + Store.currentSheetIndex).remove();
$("#luckysheet-filter-options-sheet" + Store.currentSheetIndex).remove();

if(Store.luckysheet_filter_save == null || JSON.stringify(Store.luckysheet_filter_save) == "{}"){
if(luckysheet_filter_save == null || JSON.stringify(luckysheet_filter_save) == "{}"){
return;
}

let r1 = Store.luckysheet_filter_save.row[0],
r2 = Store.luckysheet_filter_save.row[1];
let c1 = Store.luckysheet_filter_save.column[0],
c2 = Store.luckysheet_filter_save.column[1];
let r1 = luckysheet_filter_save.row[0],
r2 = luckysheet_filter_save.row[1];
let c1 = luckysheet_filter_save.column[0],
c2 = luckysheet_filter_save.column[1];

let row = Store.visibledatarow[r2],
row_pre = r1 - 1 == -1 ? 0 : Store.visibledatarow[r1 - 1];
Expand Down Expand Up @@ -254,13 +254,13 @@ function createFilterOptions(luckysheet_filter_save, filterObj) {
$("#luckysheet-rightclick-menu").hide();
$("#luckysheet-filter-menu, #luckysheet-filter-submenu").hide();

if ($("#luckysheet-cell-main").scrollTop() > Store.luckysheet_filter_save["top_move"]) {
$("#luckysheet-scrollbar-y").scrollTop(Store.luckysheet_filter_save["top_move"]);
if ($("#luckysheet-cell-main").scrollTop() > luckysheet_filter_save["top_move"]) {
$("#luckysheet-scrollbar-y").scrollTop(luckysheet_filter_save["top_move"]);
}

let file = Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)];

file.filter_select = Store.luckysheet_filter_save;
file.filter_select = luckysheet_filter_save;
}

export {
Expand Down
92 changes: 74 additions & 18 deletions src/controllers/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -2508,31 +2508,87 @@ export default function luckysheetHandler() {
let anchor = $(window.getSelection().anchorNode);
let anchorOffset = window.getSelection().anchorOffset;

let dir_n = dir, step = 1;
if(dir == 'up'){
dir_n = 'down';
step = -1;
}
if(dir == 'left'){
dir_n = 'right';
step = -1;
if(anchor.parent().is("span") && anchor.parent().next().length == 0 && anchorOffset > 0){
formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]);
luckysheetMoveHighlightCell("down", -1, "rangeOfSelect");

event.preventDefault();
}
else if(anchor.is("#luckysheet-rich-text-editor") && anchor.context.childElementCount == anchorOffset){
formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]);
luckysheetMoveHighlightCell("down", -1, "rangeOfSelect");

event.preventDefault();
}
else if(anchor.parent().is("#luckysheet-rich-text-editor") && anchor.context.length == anchorOffset){
formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]);
luckysheetMoveHighlightCell("down", -1, "rangeOfSelect");

event.preventDefault();
}
}
else if(dir == 'down'){
if(anchor.parent().is("span") && anchor.parent().next().length == 0 && anchorOffset > 0){
formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]);
luckysheetMoveHighlightCell("down", 1, "rangeOfSelect");

if(anchor.parent().is("span") && anchor.parent().next().length == 0 && anchorOffset > 0){
formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]);
luckysheetMoveHighlightCell(dir_n, step, "rangeOfSelect");
event.preventDefault();
}
else if(anchor.is("#luckysheet-rich-text-editor") && anchor.context.childElementCount == anchorOffset){
formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]);
luckysheetMoveHighlightCell("down", 1, "rangeOfSelect");

event.preventDefault();
}
else if(anchor.parent().is("#luckysheet-rich-text-editor") && anchor.context.length == anchorOffset){
formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]);
luckysheetMoveHighlightCell("down", 1, "rangeOfSelect");

event.preventDefault();
}
}
else if(anchor.is("#luckysheet-rich-text-editor") && anchor.context.childElementCount == anchorOffset){
formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]);
luckysheetMoveHighlightCell(dir_n, step, "rangeOfSelect");
else if(dir == 'left'){
if(anchor.parent().is("span") && anchor.parent().prev().length == 0 && anchorOffset == 0){
formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]);
luckysheetMoveHighlightCell("right", -1, "rangeOfSelect");

event.preventDefault();
}
else if(anchor.is("#luckysheet-rich-text-editor") && anchorOffset == 1){
formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]);
luckysheetMoveHighlightCell("right", -1, "rangeOfSelect");

event.preventDefault();
}
else if(anchor.parent().is("#luckysheet-rich-text-editor") && anchorOffset == 0){
formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]);
luckysheetMoveHighlightCell("right", -1, "rangeOfSelect");

event.preventDefault();
}
}
else if(anchor.parent().is("#luckysheet-rich-text-editor") && anchor.context.length == anchorOffset){
formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]);
luckysheetMoveHighlightCell(dir_n, step, "rangeOfSelect");
else if(dir == 'right'){
if(anchor.parent().is("span") && anchor.parent().next().length == 0 && anchorOffset > 0){
formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]);
luckysheetMoveHighlightCell("right", 1, "rangeOfSelect");

event.preventDefault();
}
else if(anchor.is("#luckysheet-rich-text-editor") && anchor.context.childElementCount == anchorOffset){
formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]);
luckysheetMoveHighlightCell("right", 1, "rangeOfSelect");

event.preventDefault();
}
else if(anchor.parent().is("#luckysheet-rich-text-editor") && anchor.context.length == anchorOffset){
formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]);
luckysheetMoveHighlightCell("right", 1, "rangeOfSelect");

event.preventDefault();
}
}
}

event.preventDefault();
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/controllers/menuButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -3540,7 +3540,7 @@ const menuButton = {
}
}

if(["0", "1", "2"].indexOf(foucsStatus) == -1){
if(["0", "1", "2"].indexOf(foucsStatus.toString()) == -1){
foucsStatus = "1";
}
}
Expand All @@ -3555,7 +3555,7 @@ const menuButton = {
}
}

if(["0", "1", "2"].indexOf(foucsStatus) == -1){
if(["0", "1", "2"].indexOf(foucsStatus.toString()) == -1){
foucsStatus = "2";
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/controllers/selection.js
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ const selection = {
}
}

if (getObjType(data) == "object") {
if (typeof data == "object") {
if (data.length == 0) { return; };

let cfg = $.extend(true, {}, Store.config);
Expand Down Expand Up @@ -1679,7 +1679,7 @@ const selection = {
},
matchcopy: function (data1, data2) {
let data1cache = [], data2cache = [], data1len, data2len;
if (getObjType(data1) == "object") {
if (typeof data1 == "object") {
data1cache = data1;
}
else {
Expand All @@ -1691,7 +1691,7 @@ const selection = {

data1len = data1cache.length;

if (getObjType(data2) == "object") {
if (typeof data2 == "object") {
data2cache = data2;
}
else {
Expand Down
23 changes: 23 additions & 0 deletions src/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,17 @@ import sheetmanage from './controllers/sheetmanage';
import luckysheetsizeauto from './controllers/resize';
import luckysheetHandler from './controllers/handler';
import {initPlugins} from './controllers/expendPlugins';
import {
getluckysheetfile,
getluckysheet_select_save,
getconfig,
getvisibledatarow,
getvisibledatacolumn
} from './methods/get';

let luckysheet = {};

//创建luckysheet表格
luckysheet.create = function (setting) {
let extendsetting = common_extend(defaultSetting, setting);

Expand Down Expand Up @@ -101,6 +109,21 @@ luckysheet.create = function (setting) {
}
}

//获取所有表格数据
luckysheet.getluckysheetfile = getluckysheetfile;

//获取当前表格 选区
luckysheet.getluckysheet_select_save = getluckysheet_select_save;

//获取当前表格 config配置
luckysheet.getconfig = getconfig;

//获取当前表格 行高数据
luckysheet.getvisibledatarow = getvisibledatarow;

//获取当前表格 列宽数据
luckysheet.getvisibledatacolumn = getvisibledatacolumn;

export {
luckysheet
}
16 changes: 6 additions & 10 deletions src/function/functionImplementation.js
Original file line number Diff line number Diff line change
Expand Up @@ -10301,11 +10301,9 @@ const functionImplementation = {

//计算
if(A1){
var reg = /^(([a-zA-Z]+)|([$][a-zA-Z]+))(([0-9]+)|([$][0-9]+))$/g;

if(reg.test(ref_text)){
var row = parseInt(ref_text.replace(/[^0-9]/g, "")) - 1;
var col = ABCatNum(ref_text.replace(/[^A-Za-z]/g, ""));
if(formula.iscelldata(ref_text)){
let cellrange = formula.getcellrange(ref_text);
let row = cellrange.row[0], col = cellrange.column[0];

if(row < 0 || row >= Store.flowdata.length || col < 0 || col >= Store.flowdata[0].length){
return formula.error.r;
Expand All @@ -10322,11 +10320,9 @@ const functionImplementation = {
}
}
else{
var reg = /^[R][0-9]+[C][0-9]+$/g;

if(reg.test(ref_text)){
var row = parseInt(ref_text.split("R")[1].split("C")[0]);
var col = parseInt(ref_text.split("R")[1].split("C")[1]);
if(formula.iscelldata(ref_text)){
let cellrange = formula.getcellrange(ref_text);
let row = cellrange.row[0], col = cellrange.column[0];

if(row < 0 || row >= Store.flowdata.length || col < 0 || col >= Store.flowdata[0].length){
return formula.error.r;
Expand Down

0 comments on commit 74639a8

Please sign in to comment.