Browse Source

fix(main): bug

bug

BREAKING CHANGE: bug
master
wpxp123456 5 years ago
parent
commit
67ebe1978b
  1. 4
      src/controllers/controlHistory.js
  2. 30
      src/controllers/handler.js
  3. 312
      src/controllers/locationCell.js
  4. 4
      src/controllers/pivotTable.js
  5. 53
      src/controllers/postil.js
  6. 3
      src/controllers/selection.js
  7. 5
      src/controllers/server.js
  8. 88
      src/global/draw.js
  9. 5
      src/global/formula.js

4
src/controllers/controlHistory.js

@ -43,6 +43,10 @@ const controlHistory = {
for(let r = st_r;r < ed_r + 1; r++){
for(let c = st_c; c < ed_c +1; c++){
if(r > ctr.data.length - 1){
break;
}
if(ctr.data[r][c] == null){
formula.delFunctionGroup(r,c);
}

30
src/controllers/handler.js

@ -3383,7 +3383,7 @@ export default function luckysheetHandler() {
//格式刷
if(menuButton.luckysheetPaintModelOn){
selection.pasteHandlerOfPaintModel(luckysheet_copy_save);
selection.pasteHandlerOfPaintModel(Store.luckysheet_copy_save);
if(menuButton.luckysheetPaintSingle){
//单次 格式刷
@ -9251,6 +9251,7 @@ export default function luckysheetHandler() {
let txtdata = clipboardData.getData("text/html");
//如果标示是qksheet复制的内容,判断剪贴板内容是否是当前页面复制的内容
let isEqual = true;
if(txtdata.indexOf("luckysheet_copy_action_table") >- 1 && Store.luckysheet_copy_save["copyRange"] != null && Store.luckysheet_copy_save["copyRange"].length > 0){
//剪贴板内容解析
let cpDataArr = [];
@ -9281,31 +9282,36 @@ export default function luckysheetHandler() {
let copy_index = Store.luckysheet_copy_save["dataSheetIndex"];
let d;
if(copy_index == Store.currentSheetIndex){
let d = editor.deepCopyFlowData(Store.flowdata);
d = editor.deepCopyFlowData(Store.flowdata);
}
else{
let d = Store.luckysheetfile[getSheetIndex(copy_index)].data;
d = Store.luckysheetfile[getSheetIndex(copy_index)].data;
}
let isEqual = true;
for(let r = copy_r1; r <= copy_r2; r++){
if(r - copy_r1 > 5){
if(r - copy_r1 > cpDataArr.length - 1){
break;
}
for(let c = copy_c1; c <= copy_c2; c++){
let cell = d[r][c];
if(cell != null && cell.ct != null && cell.ct.fa.indexOf("w") > -1){
let v = d[r][c].v;
let v;
if(cell != null){
if(cell.ct != null && cell.ct.fa.indexOf("w") > -1){
v = d[r][c].v;
}
else{
v = d[r][c].m;
}
}
else{
let v = d[r][c].m;
v = "";
}
if(v != cpDataArr[r - copy_r1][c - copy_c1]){
if(cpDataArr[r - copy_r1][c - copy_c1] != v){
isEqual = false;
break;
}
@ -9317,11 +9323,11 @@ export default function luckysheetHandler() {
//剪切板内容 和 luckysheet本身复制的内容 一致
if(Store.luckysheet_paste_iscut){
Store.luckysheet_paste_iscut = false;
selection.pasteHandlerOfCutPaste(luckysheet_copy_save);
selection.pasteHandlerOfCutPaste(Store.luckysheet_copy_save);
selection.clearcopy(e);
}
else{
selection.pasteHandlerOfCopyPaste(luckysheet_copy_save);
selection.pasteHandlerOfCopyPaste(Store.luckysheet_copy_save);
}
}
else{

312
src/controllers/locationCell.js

@ -1,5 +1,6 @@
import { replaceHtml } from '../utils/util';
import { getSheetIndex } from '../methods/get';
import { isRealNull } from '../global/validate';
import { isEditMode } from '../global/validate';
import tooltip from '../global/tooltip';
import { modelHTML } from './constant';
@ -209,36 +210,57 @@ const luckysheetLocationCell = {
apply: function(range, type, value){
let rangeArr = [];
if(type == "locationFormula" || type == "locationConstant" || type == "locationNull" || type == "locationCF"){
let str, computeMap = {};
if(type == "locationFormula" || type == "locationConstant" || type == "locationNull"){ //公式 常量 空值
let minR = null, maxR = null, minC = null, maxC = null, cellSave = {};
if(type == "locationFormula"){ //公式
if(value == "all"){
str = "Store.flowdata[r] != null && Store.flowdata[r][c] != null && Store.flowdata[r][c].v != null && Store.flowdata[r][c].f != null";
for(let s = 0; s < range.length; s++){
let st_r = range[s].row[0],
ed_r = range[s].row[1],
st_c = range[s].column[0],
ed_c = range[s].column[1];
if(minR == null || minR < st_r){
minR = st_r;
}
else{
str = "Store.flowdata[r] != null && Store.flowdata[r][c] != null && Store.flowdata[r][c].v != null && Store.flowdata[r][c].f != null && Store.flowdata[r][c].ct != null && value.indexOf(Store.flowdata[r][c].ct.t) != -1";
if(maxR == null || maxR > ed_r){
maxR = ed_r;
}
if(minC == null || minC < st_c){
minC = st_c;
}
else if(type == "locationConstant"){ //常量
if(value == "all"){
str = "Store.flowdata[r] != null && Store.flowdata[r][c] != null && Store.flowdata[r][c].v != null && Store.flowdata[r][c].f == null && Store.flowdata[r][c].ct != null";
if(maxC == null || maxC > ed_c){
maxC = ed_c;
}
else{
str = "Store.flowdata[r] != null && Store.flowdata[r][c] != null && Store.flowdata[r][c].v != null && Store.flowdata[r][c].f == null && Store.flowdata[r][c].ct != null && value.indexOf(Store.flowdata[r][c].ct.t) != -1";
for(let r = st_r; r <= ed_r; r++){
for(let c = st_c; c <= ed_c; c++){
let cell = Store.flowdata[r][c];
if(cell != null && cell.mc != null){
cell = Store.flowdata[cell.mc.r][cell.mc.c];
}
if(type == 'locationFormula' && cell != null && !isRealNull(cell.v) && cell.f != null && (value == 'all' || (cell.ct != null && value.indexOf(cell.ct.t) > -1))){
cellSave[r + '_' + c] = 0;
}
else if(type == 'locationConstant' && cell != null && !isRealNull(cell.v) && (value == 'all' || (cell.ct != null && value.indexOf(cell.ct.t) > -1))){
cellSave[r + '_' + c] = 0;
}
else if(type == 'locationNull' && (cell == null || isRealNull(cell.v))){
cellSave[r + '_' + c] = 0;
}
}
else if(type == "locationNull"){ //空值
str = "Store.flowdata[r] != null && (Store.flowdata[r][c] == null || Store.flowdata[r][c].v == null || Store.flowdata[r][c].v == '') ";
}
}
rangeArr = this.getRangeArr(minR, maxR, minC, maxC, cellSave, rangeArr);
}
else if(type == "locationCF"){ //条件格式
let index = getSheetIndex(Store.currentSheetIndex);
let ruleArr = Store.luckysheetfile[index]["luckysheet_conditionformat_save"];
let data = Store.luckysheetfile[index]["data"];
computeMap = conditionformat.compute(ruleArr, data);
if(JSON.stringify(computeMap) == "{}"){
if(ruleArr == null || ruleArr.length == 0){
if(isEditMode()){
alert("未找到单元格");
}
@ -249,159 +271,50 @@ const luckysheetLocationCell = {
return;
}
str = "(r + '_' + c) in computeMap";
}
for(let s = 0; s < range.length; s++){
let st_r = range[s].row[0], ed_r = range[s].row[1];
let st_c = range[s].column[0], ed_c = range[s].column[1];
if(st_r == ed_r){
let stack_stc = null, stack_edc = null;
computeMap = conditionformat.compute(ruleArr, data);
var r = st_r; //r, c var定义,否则eval报错
for(var c = st_c; c <= ed_c; c++){
if(c == st_c){
if(eval(str)){
stack_stc = c;
}
else{
stack_stc = null;
}
}
else if(c == ed_c){
if(eval(str)){
if(stack_stc == null){
rangeArr.push({"row": [st_r, ed_r], "column": [ed_c, ed_c]});
}
else{
rangeArr.push({"row": [st_r, ed_r], "column": [stack_stc, ed_c]});
}
}
else{
if(stack_edc == null && stack_stc != null){
rangeArr.push({"row": [st_r, ed_r], "column": [stack_stc, stack_stc]});
}
else if(stack_edc != null){
rangeArr.push({"row": [st_r, ed_r], "column": [stack_stc, stack_edc]});
}
}
}
else{
if(eval(str)){
if(stack_stc == null){
stack_stc = c;
}
else{
stack_edc = c;
}
if(Object.keys(computeMap).length == 0){
if(isEditMode()){
alert("未找到单元格");
}
else{
if(stack_edc == null && stack_stc != null){
rangeArr.push({"row": [st_r, ed_r], "column": [stack_stc, stack_stc]});
stack_stc = null;
}
else if(stack_edc != null){
rangeArr.push({"row": [st_r, ed_r], "column": [stack_stc, stack_edc]});
stack_stc = null;
stack_edc = null;
}
}
}
tooltip.info("提示", "未找到单元格");
}
return;
}
else{
let stack = {};
for(var r = st_r; r <= ed_r; r++){
stack[r] = [];
let stack_stc = null, stack_edc = null;
let minR = null, maxR = null, minC = null, maxC = null, cellSave = {};
for(var c = st_c; c <= ed_c; c++){
if(c == ed_c){
if(eval(str)){
if(stack_stc == null){
stack[r].push({"status": false, "range": [ed_c, ed_c]});
}
else{
stack[r].push({"status": false, "range": [stack_stc, ed_c]});
}
}
else{
if(stack_edc == null && stack_stc != null){
stack[r].push({"status": false, "range": [stack_stc, stack_stc]});
}
else if(stack_edc != null){
stack[r].push({"status": false, "range": [stack_stc, stack_edc]});
}
}
}
else if(c == st_c){
if(eval(str)){
stack_stc = c;
}
else{
stack_stc = null;
}
}
else{
if(eval(str)){
if(stack_stc == null){
stack_stc = c;
}
else{
stack_edc = c;
}
}
else{
if(stack_edc == null && stack_stc != null){
stack[r].push({"status": false, "range": [stack_stc, stack_stc]});
stack_stc = null;
}
else if(stack_edc != null){
stack[r].push({"status": false, "range": [stack_stc, stack_edc]});
stack_stc = null;
stack_edc = null;
}
}
}
}
}
for(let s = 0; s < range.length; s++){
let st_r = range[s].row[0],
ed_r = range[s].row[1],
st_c = range[s].column[0],
ed_c = range[s].column[1];
for(let i = st_r; i <= ed_r; i++){
if(i == ed_r){
if(stack[i].length > 0){
for(let j = 0; j < stack[i].length; j++){
if(!stack[i][j].status){
rangeArr.push({"row": [ed_r, ed_r], "column": stack[i][j].range});
if(minR == null || minR < st_r){
minR = st_r;
}
if(maxR == null || maxR > ed_r){
maxR = ed_r;
}
if(minC == null || minC < st_c){
minC = st_c;
}
if(maxC == null || maxC > ed_c){
maxC = ed_c;
}
else{
if(stack[i].length > 0){
for(let j = 0; j < stack[i].length; j++){
if(!stack[i][j].status){
let b = 0;
for(let a = 1; a < (ed_r - i); a++){
if(stack[i + a][j] != null && stack[i + a][j].range[0] == stack[i][j].range[0] && stack[i + a][j].range[1] == stack[i][j].range[1]){
b = a;
stack[i + a][j].status = true;
}
else{
break;
}
}
rangeArr.push({"row": [i, i + b], "column": stack[i][j].range});
}
}
}
for(let r = st_r; r <= ed_r; r++){
for(let c = st_c; c <= ed_c; c++){
if((r + '_' + c) in computeMap){
cellSave[r + '_' + c] = 0;
}
}
}
}
rangeArr = this.getRangeArr(minR, maxR, minC, maxC, cellSave, rangeArr);
}
else if(type == "locationStepRow"){ //间隔行
for(let s = 0; s < range.length; s++){
@ -477,6 +390,99 @@ const luckysheetLocationCell = {
$("#luckysheet-scrollbar-y").scrollTop(row_pre - 20);
}
}
},
getRangeArr(minR, maxR, minC, maxC, cellSave, rangeArr){
if(Object.keys(cellSave).length == 0){
return rangeArr;
}
let _this = this;
let stack_str = null,
stack_edr = null,
stack_stc = null,
stack_edc = null;
for(let r = minR; r <= maxR; r++){
for(let c = minC; c <= maxC; c++){
let cell = Store.flowdata[r][c];
if((r + '_' + c) in cellSave){
if(cell != null && cell.mc != null){
if(stack_stc == null){
let range = {
'row': [cell.mc.r, cell.mc.r + cell.mc.rs - 1],
'column': [cell.mc.c, cell.mc.c + cell.mc.cs - 1]
};
rangeArr.push(range);
cellSave = _this.deleteCellInSave(cellSave, range);
return _this.getRangeArr(minR, maxR, minC, maxC, cellSave, rangeArr);
}
else if(c < stack_edc){
let range = {
'row': [stack_str, stack_edr],
'column': [stack_stc, stack_edc]
}
rangeArr.push(range);
cellSave = _this.deleteCellInSave(cellSave, range);
return _this.getRangeArr(minR, maxR, minC, maxC, cellSave, rangeArr);
}
else{
break;
}
}
else if(stack_stc == null){
stack_stc = c;
stack_edc = c;
stack_str = r;
stack_edr = r;
}
else if(c > stack_edc){
stack_edc = c;
}
}
else if(stack_stc != null){
if(cell != null && cell.mc != null){
break;
}
else if(c < stack_stc){
}
else if(c <= stack_edc){
let range = {
'row': [stack_str, stack_edr],
'column': [stack_stc, stack_edc]
}
rangeArr.push(range);
cellSave = _this.deleteCellInSave(cellSave, range);
return _this.getRangeArr(minR, maxR, minC, maxC, cellSave, rangeArr);
}
else{
stack_edr = r;
}
}
}
}
if(stack_stc != null){
let range = {
'row': [stack_str, stack_edr],
'column': [stack_stc, stack_edc]
}
rangeArr.push(range);
cellSave = _this.deleteCellInSave(cellSave, range);
return _this.getRangeArr(minR, maxR, minC, maxC, cellSave, rangeArr);
}
},
deleteCellInSave(cellSave, range){
for(let r = range.row[0]; r <= range.row[1]; r++){
for(let c = range.column[0]; c <= range.column[1]; c++){
delete cellSave[r + '_' + c];
}
}
return cellSave;
}
}

4
src/controllers/pivotTable.js

@ -2682,7 +2682,7 @@ const pivotTable = {
curentLevelarr_row = curentLevelarr_row[curentLevelobj_row[r.toString()][item]].children;
}
else {
let orderby = r == 0 ? "self" : ((row[r - 1].orderby == "self" || row[r - 1].orderby == null) ? item : (showType == "column" ? item + values[parseInt(row[r - 1].orderby)].fullname : item + "计"));
let orderby = r == 0 ? "self" : ((row[r - 1].orderby == "self" || row[r - 1].orderby == null) ? item : (showType == "column" ? item + values[parseInt(row[r - 1].orderby)].fullname : item + "计"));
if(name == null){
name = "(空白)";
@ -2712,7 +2712,7 @@ const pivotTable = {
curentLevelarr_col = curentLevelarr_col[curentLevelobj_col[r.toString()][item]].children;
}
else {
let orderby = r == 0 ? "self" : ((column[r - 1].orderby == "self" || column[r - 1].orderby == null) ? item : (showType == "column" ? "计" + item : values[parseInt(column[r - 1].orderby)].fullname + item));
let orderby = r == 0 ? "self" : ((column[r - 1].orderby == "self" || column[r - 1].orderby == null) ? item : (showType == "column" ? "计" + item : values[parseInt(column[r - 1].orderby)].fullname + item));
if(name == null){
name = "(空白)";

53
src/controllers/postil.js

@ -161,6 +161,12 @@ const luckysheetPostil = {
let row_index = rowLocation(y)[2];
let col_index = colLocation(x)[2];
let margeset = menuButton.mergeborer(Store.flowdata, row_index, col_index);
if(!!margeset){
row_index = margeset.row[2];
col_index = margeset.column[2];
}
if(Store.flowdata[row_index] == null || Store.flowdata[row_index][col_index] == null || Store.flowdata[row_index][col_index].ps == null){
return;
}
@ -173,8 +179,21 @@ const luckysheetPostil = {
let value = postil["value"] == null ? "" : postil["value"];
let toX = Store.visibledatacolumn[col_index];
let toY = row_index == 0 ? 0 : Store.visibledatarow[row_index - 1];
let row = Store.visibledatarow[row_index],
row_pre = row_index - 1 == -1 ? 0 : Store.visibledatarow[row_index - 1];
let col = Store.visibledatacolumn[col_index],
col_pre = col_index - 1 == -1 ? 0 : Store.visibledatacolumn[col_index - 1];
if(!!margeset){
row = margeset.row[1];
row_pre = margeset.row[0];
col = margeset.column[1];
col_pre = margeset.column[0];
}
let toX = col;
let toY = row_pre;
let fromX = toX + 18;
let fromY = toY - 18;
@ -186,7 +205,7 @@ const luckysheetPostil = {
let size = _this.getArrowCanvasSize(fromX, fromY, toX, toY);
let html = '<div id="luckysheet-postil-overshow">' +
'<canvas class="arrowCanvas" width="'+ size[2] +'" height="'+ size[3] +'" style="position:absolute;left:'+ size[0] +'px;top:'+ size[1] +'px;z-index:100;"></canvas>' +
'<canvas class="arrowCanvas" width="'+ size[2] +'" height="'+ size[3] +'" style="position:absolute;left:'+ size[0] +'px;top:'+ size[1] +'px;z-index:100;pointer-events:none;"></canvas>' +
'<div style="width:132px;min-height:72px;color:#000;padding:5px;border:1px solid #000;background-color:rgb(255,255,225);position:absolute;left:'+ fromX +'px;top:'+ fromY +'px;z-index:100;">'+ value +'</div>' +
'</div>';
@ -330,7 +349,7 @@ const luckysheetPostil = {
let size = _this.getArrowCanvasSize(left, top, toX, toY);
let html = '<div id="luckysheet-postil-show_'+ r +'_'+ c +'" class="luckysheet-postil-show">' +
'<canvas class="arrowCanvas" width="'+ size[2] +'" height="'+ size[3] +'" style="position:absolute;left:'+ size[0] +'px;top:'+ size[1] +'px;z-index:100;"></canvas>' +
'<canvas class="arrowCanvas" width="'+ size[2] +'" height="'+ size[3] +'" style="position:absolute;left:'+ size[0] +'px;top:'+ size[1] +'px;z-index:100;pointer-events:none;"></canvas>' +
'<div class="luckysheet-postil-show-main" style="width:'+ width +'px;height:'+ height +'px;color:#000;padding:5px;border:1px solid #000;background-color:rgb(255,255,225);position:absolute;left:'+ left +'px;top:'+ top +'px;box-sizing:border-box;z-index:100;">' +
'<div class="luckysheet-postil-dialog-move">' +
'<div class="luckysheet-postil-dialog-move-item luckysheet-postil-dialog-move-item-t" data-type="t"></div>' +
@ -366,8 +385,22 @@ const luckysheetPostil = {
newPs: function(r, c){
let _this = this;
let toX = Store.visibledatacolumn[c];
let toY = r == 0 ? 0 : Store.visibledatarow[r - 1];
let row = Store.visibledatarow[r],
row_pre = r - 1 == -1 ? 0 : Store.visibledatarow[r - 1];
let col = Store.visibledatacolumn[c],
col_pre = c - 1 == -1 ? 0 : Store.visibledatacolumn[c - 1];
let margeset = menuButton.mergeborer(Store.flowdata, r, c);
if(!!margeset){
row = margeset.row[1];
row_pre = margeset.row[0];
col = margeset.column[1];
col_pre = margeset.column[0];
}
let toX = col;
let toY = row_pre;
let fromX = toX + 18;
let fromY = toY - 18;
@ -379,7 +412,7 @@ const luckysheetPostil = {
let size = _this.getArrowCanvasSize(fromX, fromY, toX, toY);
let html = '<div id="luckysheet-postil-show_'+ r +'_'+ c +'" class="luckysheet-postil-show luckysheet-postil-show-active">' +
'<canvas class="arrowCanvas" width="'+ size[2] +'" height="'+ size[3] +'" style="position:absolute;left:'+ size[0] +'px;top:'+ size[1] +'px;z-index:100;"></canvas>' +
'<canvas class="arrowCanvas" width="'+ size[2] +'" height="'+ size[3] +'" style="position:absolute;left:'+ size[0] +'px;top:'+ size[1] +'px;z-index:100;pointer-events:none;"></canvas>' +
'<div class="luckysheet-postil-show-main" style="width:144px;height:84px;color:#000;padding:5px;border:1px solid #000;background-color:rgb(255,255,225);position:absolute;left:'+ fromX +'px;top:'+ fromY +'px;box-sizing:border-box;z-index:100;">' +
'<div class="luckysheet-postil-dialog-move">' +
'<div class="luckysheet-postil-dialog-move-item luckysheet-postil-dialog-move-item-t" data-type="t"></div>' +
@ -467,7 +500,7 @@ const luckysheetPostil = {
let size = _this.getArrowCanvasSize(left, top, toX, toY);
let html = '<div id="luckysheet-postil-show_'+ r +'_'+ c +'" class="luckysheet-postil-show luckysheet-postil-show-active">' +
'<canvas class="arrowCanvas" width="'+ size[2] +'" height="'+ size[3] +'" style="position:absolute;left:'+ size[0] +'px;top:'+ size[1] +'px;z-index:100;"></canvas>' +
'<canvas class="arrowCanvas" width="'+ size[2] +'" height="'+ size[3] +'" style="position:absolute;left:'+ size[0] +'px;top:'+ size[1] +'px;z-index:100;pointer-events:none;"></canvas>' +
'<div class="luckysheet-postil-show-main" style="width:'+ width +'px;height:'+ height +'px;color:#000;padding:5px;border:1px solid #000;background-color:rgb(255,255,225);position:absolute;left:'+ left +'px;top:'+ top +'px;box-sizing:border-box;z-index:100;">' +
'<div class="luckysheet-postil-dialog-move">' +
'<div class="luckysheet-postil-dialog-move-item luckysheet-postil-dialog-move-item-t" data-type="t"></div>' +
@ -565,7 +598,7 @@ const luckysheetPostil = {
let size = _this.getArrowCanvasSize(left, top, toX, toY);
let html = '<div id="luckysheet-postil-show_'+ r +'_'+ c +'" class="luckysheet-postil-show">' +
'<canvas class="arrowCanvas" width="'+ size[2] +'" height="'+ size[3] +'" style="position:absolute;left:'+ size[0] +'px;top:'+ size[1] +'px;z-index:100;"></canvas>' +
'<canvas class="arrowCanvas" width="'+ size[2] +'" height="'+ size[3] +'" style="position:absolute;left:'+ size[0] +'px;top:'+ size[1] +'px;z-index:100;pointer-events:none;"></canvas>' +
'<div class="luckysheet-postil-show-main" style="width:'+ width +'px;height:'+ height +'px;color:#000;padding:5px;border:1px solid #000;background-color:rgb(255,255,225);position:absolute;left:'+ left +'px;top:'+ top +'px;box-sizing:border-box;z-index:100;">' +
'<div class="luckysheet-postil-dialog-move">' +
'<div class="luckysheet-postil-dialog-move-item luckysheet-postil-dialog-move-item-t" data-type="t"></div>' +
@ -679,7 +712,7 @@ const luckysheetPostil = {
let size = _this.getArrowCanvasSize(left, top, toX, toY);
let html = '<div id="luckysheet-postil-show_'+ rowIndex +'_'+ colIndex +'" class="luckysheet-postil-show">' +
'<canvas class="arrowCanvas" width="'+ size[2] +'" height="'+ size[3] +'" style="position:absolute;left:'+ size[0] +'px;top:'+ size[1] +'px;z-index:100;"></canvas>' +
'<canvas class="arrowCanvas" width="'+ size[2] +'" height="'+ size[3] +'" style="position:absolute;left:'+ size[0] +'px;top:'+ size[1] +'px;z-index:100;pointer-events:none;"></canvas>' +
'<div class="luckysheet-postil-show-main" style="width:'+ width +'px;height:'+ height +'px;color:#000;padding:5px;border:1px solid #000;background-color:rgb(255,255,225);position:absolute;left:'+ left +'px;top:'+ top +'px;box-sizing:border-box;z-index:100;">' +
'<div class="luckysheet-postil-dialog-move">' +
'<div class="luckysheet-postil-dialog-move-item luckysheet-postil-dialog-move-item-t" data-type="t"></div>' +

3
src/controllers/selection.js

@ -1391,6 +1391,7 @@ const selection = {
}
//复制范围 是否有 条件格式
let ruleArr_cf = [];
if(copyRange["copyRange"].length == 1){
let c_file = Store.luckysheetfile[getSheetIndex(copySheetIndex)];
let a_file = Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)];
@ -1400,7 +1401,7 @@ const selection = {
c_c1 = copyRange["copyRange"][0].column[0],
c_c2 = copyRange["copyRange"][0].column[1];
let ruleArr_cf = $.extend(true, [], c_file["luckysheet_conditionformat_save"]);
ruleArr_cf = $.extend(true, [], c_file["luckysheet_conditionformat_save"]);
let cdformat = $.extend(true, [], a_file["luckysheet_conditionformat_save"]);
if(ruleArr_cf != null && ruleArr_cf.length > 0){

5
src/controllers/server.js

@ -38,11 +38,12 @@ const server = {
for(let i = 0; i < n; i++){
let str = r1 + timeR * i;
let edr;
if(i == n - 1){
let edr = r2;
edr = r2;
}
else{
let edr = r1 + timeR * (i + 1) - 1;
edr = r1 + timeR * (i + 1) - 1;
}
let v = [];

88
src/global/draw.js

@ -54,7 +54,7 @@ function luckysheetDrawgridRowTitle(scrollHeight, drawHeight, offsetTop) {
);
luckysheetTableContent.font = luckysheetdefaultstyle.font;
luckysheetTableContent.textBaseline = luckysheetdefaultstyle.textBaseline;
luckysheetTableContent.textBaseline = luckysheetdefaultstyle.textBaseline; //基准线 垂直居中
luckysheetTableContent.fillStyle = luckysheetdefaultstyle.fillStyle;
let dataset_row_st, dataset_row_ed;
@ -156,7 +156,7 @@ function luckysheetDrawgridColumnTitle(scrollWidth, drawWidth, offsetLeft) {
luckysheetTableContent.font = luckysheetdefaultstyle.font;
luckysheetTableContent.textBaseline = luckysheetdefaultstyle.textBaseline;
luckysheetTableContent.textBaseline = luckysheetdefaultstyle.textBaseline; //基准线 垂直居中
luckysheetTableContent.fillStyle = luckysheetdefaultstyle.fillStyle;
let dataset_col_st, dataset_col_ed;
@ -713,7 +713,8 @@ function luckysheetDrawMain(scrollWidth, scrollHeight, drawWidth, drawHeight, of
//垂直对齐 (默认为2,下对齐)
let verticalFixed = browser.luckysheetrefreshfixed();
let verticalAlignPos = (end_r + offsetTop - 2 + verticalFixed) * Store.devicePixelRatio - oneLineTextHeight;
let verticalAlignPos = (end_r + offsetTop - 2) * Store.devicePixelRatio;
luckysheetTableContent.textBaseline = 'bottom';
luckysheetTableContent.fillText(value == null ? "" : value, horizonAlignPos, verticalAlignPos);
}
@ -830,27 +831,6 @@ function luckysheetDrawMain(scrollWidth, scrollHeight, drawWidth, drawHeight, of
textH = oneLineTextHeight;
}
//水平对齐
let horizonAlign = menuButton.checkstatus(Store.flowdata, r, c , "ht");
let horizonAlignPos = (start_c + 4 + offsetLeft) * Store.devicePixelRatio; //horizonAlign默认为1,左对齐
if(horizonAlign == "0"){ //居中对齐
horizonAlignPos = (start_c + (end_c - start_c) / 2 + offsetLeft) * Store.devicePixelRatio - (textMetrics) / 2;
}
else if(horizonAlign == "2"){ //右对齐
horizonAlignPos = (end_c + offsetLeft - 8) * Store.devicePixelRatio - (textMetrics);
}
//垂直对齐
let verticalAlign = menuButton.checkstatus(Store.flowdata, r, c , "vt");
let verticalFixed = browser.luckysheetrefreshfixed();
let verticalAlignPos = (end_r + offsetTop - 2 + verticalFixed) * Store.devicePixelRatio - oneLineTextHeight; //verticalAlign默认为2,下对齐
if(verticalAlign == "0"){ //居中对齐
verticalAlignPos = (start_r + (end_r - start_r) / 2 + offsetTop + verticalFixed) * Store.devicePixelRatio - oneLineTextHeight / 2;
}
else if(verticalAlign == "1"){ //上对齐
verticalAlignPos = (start_r + offsetTop + verticalFixed) * Store.devicePixelRatio;
}
//水平对齐方式是 居中或居右对齐 且单元格宽度小于文字宽度 (用离屏canvas渲染)
let canvasName, cellsize;
if(browser.BrowserType() != "Safari" && (canvasType == "offline" || ((horizonAlign == "0" || horizonAlign == "2") && (end_c - start_c) < textW) || ((verticalAlign == "0" || verticalAlign == "2") && (end_r - start_r) < textH))){
@ -875,6 +855,38 @@ function luckysheetDrawMain(scrollWidth, scrollHeight, drawWidth, drawHeight, of
];
}
//水平对齐
let horizonAlign = menuButton.checkstatus(Store.flowdata, r, c , "ht");
let horizonAlignPos = (start_c + 4 + offsetLeft) * Store.devicePixelRatio; //horizonAlign默认为1,左对齐
if(horizonAlign == "0"){ //居中对齐
horizonAlignPos = (start_c + (end_c - start_c) / 2 + offsetLeft) * Store.devicePixelRatio - (textMetrics) / 2;
}
else if(horizonAlign == "2"){ //右对齐
horizonAlignPos = (end_c + offsetLeft - 8) * Store.devicePixelRatio - (textMetrics);
}
//垂直对齐
let verticalAlign = menuButton.checkstatus(Store.flowdata, r, c , "vt");
let verticalFixed = browser.luckysheetrefreshfixed();
//verticalAlign默认为2,下对齐
let verticalAlignPos = (end_r + offsetTop - 2 + verticalFixed) * Store.devicePixelRatio - oneLineTextHeight;
let verticalAlignPos_text = (end_r + offsetTop - 2 + verticalFixed) * Store.devicePixelRatio;
canvasName.textBaseline = "bottom";
if(verticalAlign == "0"){
//居中对齐
verticalAlignPos = (start_r + offsetTop + (end_r - start_r) / 2 + verticalFixed) * Store.devicePixelRatio - oneLineTextHeight / 2;
verticalAlignPos_text = (start_r + offsetTop + (end_r - start_r) / 2 + verticalFixed) * Store.devicePixelRatio;
canvasName.textBaseline = "middle";
}
else if(verticalAlign == "1"){
//上对齐
verticalAlignPos = (start_r + offsetTop + 2 + verticalFixed) * Store.devicePixelRatio;
verticalAlignPos_text = (start_r + offsetTop + 2 + verticalFixed) * Store.devicePixelRatio;
canvasName.textBaseline = "top";
}
//单元格 背景颜色
canvasName.fillStyle= menuButton.checkstatus(Store.flowdata, r, c , "bg");
@ -1047,7 +1059,17 @@ function luckysheetDrawMain(scrollWidth, scrollHeight, drawWidth, drawHeight, of
let l = checksCF["icons"]["left"];
let t = checksCF["icons"]["top"];
canvasName.drawImage(luckysheet_CFiconsImg, l * 42, t * 32, 32, 32, cellsize[0], verticalAlignPos + 2, oneLineTextHeight - 2, oneLineTextHeight - 2);
canvasName.drawImage(
luckysheet_CFiconsImg,
l * 42,
t * 32,
32,
32,
cellsize[0],
verticalAlignPos + 2,
oneLineTextHeight - 2,
oneLineTextHeight - 2
);
if(horizonAlign != "0" && horizonAlign != "2"){ //左对齐时 文本渲染空出一个图标的距离
horizonAlignPos = horizonAlignPos + oneLineTextHeight - 2;
@ -1071,7 +1093,7 @@ function luckysheetDrawMain(scrollWidth, scrollHeight, drawWidth, drawHeight, of
if(Store.flowdata[r][c].dd != null){
canvasName.fillStyle = "#0000ff";
canvasName.fillText(value == null ? "" : value, horizonAlignPos, verticalAlignPos);
canvasName.fillText(value == null ? "" : value, horizonAlignPos, verticalAlignPos_text);
canvasName.beginPath();
canvasName.strokeStyle = "#0000ff";
@ -1083,6 +1105,8 @@ function luckysheetDrawMain(scrollWidth, scrollHeight, drawWidth, drawHeight, of
else{
//自动换行、旋转、删除线功能
if(Store.flowdata[r][c].tb == "2"){
canvasName.textBaseline = 'top'; //自动换行 textBaseline以top计算
let strValue = value.toString();
let cellWidth = end_c - start_c - 8;
let strArr = [];
@ -1125,6 +1149,8 @@ function luckysheetDrawMain(scrollWidth, scrollHeight, drawWidth, drawHeight, of
}
}
else if(Store.flowdata[r][c].tr != null && Store.flowdata[r][c].tr != "0"){
canvasName.textBaseline = 'top'; //旋转 textBaseline以top计算
//单元格旋转属性
let tr = Store.flowdata[r][c].tr;
@ -1312,7 +1338,7 @@ function luckysheetDrawMain(scrollWidth, scrollHeight, drawWidth, drawHeight, of
}
}
else{
canvasName.fillText(value == null ? "" : value, horizonAlignPos, verticalAlignPos);
canvasName.fillText(value == null ? "" : value, horizonAlignPos, verticalAlignPos_text);
//是否有删除线
let cl = menuButton.checkstatus(Store.flowdata, r, c , "cl");
@ -1533,7 +1559,7 @@ function luckysheetDrawMain(scrollWidth, scrollHeight, drawWidth, drawHeight, of
let m_st = Store.devicePixelRatio * (start_c - 2 + 0.5 + offsetLeft);
let m_ed = Store.devicePixelRatio * (start_r + offsetTop);
let line_st = Store.devicePixelRatio * (start_c - 2 + 0.5 + offsetLeft);
let line_ed = Store.devicePixelRatio * (end_r - 2 + offsetTop);
let line_ed = Store.devicePixelRatio * (end_r - 2 + 0.5 + offsetTop);
menuButton.setLineDash(canvas, linetype, "v", m_st, m_ed, line_st, line_ed);
@ -1549,7 +1575,7 @@ function luckysheetDrawMain(scrollWidth, scrollHeight, drawWidth, drawHeight, of
let m_st = Store.devicePixelRatio * (end_c - 2 + 0.5 + offsetLeft);
let m_ed = Store.devicePixelRatio * (start_r + offsetTop);
let line_st = Store.devicePixelRatio * (end_c - 2 + 0.5 + offsetLeft);
let line_ed = Store.devicePixelRatio * (end_r - 2 + offsetTop);
let line_ed = Store.devicePixelRatio * (end_r - 2 + 0.5 + offsetTop);
menuButton.setLineDash(canvas, linetype, "v", m_st, m_ed, line_st, line_ed);
@ -1564,7 +1590,7 @@ function luckysheetDrawMain(scrollWidth, scrollHeight, drawWidth, drawHeight, of
let m_st = Store.devicePixelRatio * (start_c - 2 + offsetLeft);
let m_ed = Store.devicePixelRatio * (end_r - 2 + 0.5 + offsetTop);
let line_st = Store.devicePixelRatio * (end_c + offsetLeft - 2);
let line_st = Store.devicePixelRatio * (end_c - 2 + 0.5 + offsetLeft);
let line_ed = Store.devicePixelRatio * (end_r - 2 + 0.5 + offsetTop);
menuButton.setLineDash(canvas, linetype, "h", m_st, m_ed, line_st, line_ed);
@ -1580,7 +1606,7 @@ function luckysheetDrawMain(scrollWidth, scrollHeight, drawWidth, drawHeight, of
let m_st = Store.devicePixelRatio * (start_c - 2 + offsetLeft);
let m_ed = Store.devicePixelRatio * (start_r - 1 + 0.5 + offsetTop);
let line_st = Store.devicePixelRatio * (end_c + offsetLeft - 2);
let line_st = Store.devicePixelRatio * (end_c - 2 + 0.5 + offsetLeft);
let line_ed = Store.devicePixelRatio * (start_r - 1 + 0.5 + offsetTop);
menuButton.setLineDash(canvas, linetype, "h", m_st, m_ed, line_st, line_ed);

5
src/global/formula.js

@ -1284,12 +1284,12 @@ const luckysheetformula = {
_this.cancelNormalSelected();
let RowlChange = false;
if(d[r][c].tb == "2" && d[r][c].v != null){//自动换行
let cfg = $.extend(true, {}, getluckysheetfile()[getSheetIndex(Store.currentSheetIndex)]["config"]);
if(cfg["rowlen"] == null){
cfg["rowlen"] = {};
}
if(d[r][c].tb == "2" && d[r][c].v != null){//自动换行
let defaultrowlen = 19;
let offlinecanvas = $("#luckysheetTableContentF").get(0).getContext("2d");
@ -3034,8 +3034,11 @@ const luckysheetformula = {
$editer.html(value);
_this.functionRange($editer, value, value1);
_this.canceFunctionrangeSelected();
if(kcode != 46){//delete不执行此函数
_this.createRangeHightlight();
}
}
_this.rangestart = false;
_this.rangedrag_column_start = false;

Loading…
Cancel
Save