Commit 88da4bfd authored by 宁天庆's avatar 宁天庆

修改复制

parent 1ea469c2
This source diff could not be displayed because it is too large. You can view the blob instead.
import { selectHightlightShow, selectionCopyShow } from './select'; import { selectHightlightShow, selectionCopyShow } from './select';
import menuButton from './menuButton'; import menuButton from './menuButton';
import conditionformat from './conditionformat'; import conditionformat from './conditionformat';
import {checkProtectionLockedRangeList} from './protection'; import { checkProtectionLockedRangeList } from './protection';
import editor from '../global/editor'; import editor from '../global/editor';
import tooltip from '../global/tooltip'; import tooltip from '../global/tooltip';
import formula from '../global/formula'; import formula from '../global/formula';
...@@ -18,7 +18,7 @@ import locale from '../locale/locale'; ...@@ -18,7 +18,7 @@ import locale from '../locale/locale';
import imageCtrl from './imageCtrl'; import imageCtrl from './imageCtrl';
const selection = { const selection = {
clearcopy: function (e) { clearcopy: function(e) {
let clipboardData = window.clipboardData; //for IE let clipboardData = window.clipboardData; //for IE
if (!clipboardData) { // for chrome if (!clipboardData) { // for chrome
if (!!e) { if (!!e) {
...@@ -37,14 +37,14 @@ const selection = { ...@@ -37,14 +37,14 @@ const selection = {
textarea.focus(); textarea.focus();
textarea.select(); textarea.select();
// 等50毫秒,keyPress事件发生了再去处理数据 // 等50毫秒,keyPress事件发生了再去处理数据
setTimeout(function () { textarea.blur().css("visibility", "visible"); }, 10); setTimeout(function() { textarea.blur().css("visibility", "visible"); }, 10);
} }
else { else {
clipboardData.setData('Text', cpdata); clipboardData.setData('Text', cpdata);
return false;//否则设不生效 return false;//否则设不生效
} }
}, },
getHtmlBorderStyle: function(type, color){ getHtmlBorderStyle: function(type, color) {
let style = ""; let style = "";
let borderType = { let borderType = {
"0": "none", "0": "none",
...@@ -64,38 +64,38 @@ const selection = { ...@@ -64,38 +64,38 @@ const selection = {
}; };
type = borderType[type.toString()]; type = borderType[type.toString()];
if(type.indexOf("Medium") > -1){ if (type.indexOf("Medium") > -1) {
style += "1pt "; style += "1pt ";
} }
else if(type == "Thick"){ else if (type == "Thick") {
style += "1.5pt "; style += "1.5pt ";
} }
else { else {
style += "0.5pt "; style += "0.5pt ";
} }
if(type == "Hair"){ if (type == "Hair") {
style += "double "; style += "double ";
} }
else if(type.indexOf("DashDotDot") > -1){ else if (type.indexOf("DashDotDot") > -1) {
style += "dotted "; style += "dotted ";
} }
else if(type.indexOf("DashDot") > -1){ else if (type.indexOf("DashDot") > -1) {
style += "dashed "; style += "dashed ";
} }
else if(type.indexOf("Dotted") > -1){ else if (type.indexOf("Dotted") > -1) {
style += "dotted "; style += "dotted ";
} }
else if(type.indexOf("Dashed") > -1){ else if (type.indexOf("Dashed") > -1) {
style += "dashed "; style += "dashed ";
} }
else{ else {
style += "solid "; style += "solid ";
} }
return style + color + ";"; return style + color + ";";
}, },
copy: function (e) {//copy事件 copy: function(e) {//copy事件
let clipboardData = window.clipboardData; //for IE let clipboardData = window.clipboardData; //for IE
if (!clipboardData) { // for chrome if (!clipboardData) { // for chrome
clipboardData = e.originalEvent.clipboardData; clipboardData = e.originalEvent.clipboardData;
...@@ -106,7 +106,7 @@ const selection = { ...@@ -106,7 +106,7 @@ const selection = {
let rowIndexArr = [], colIndexArr = []; let rowIndexArr = [], colIndexArr = [];
let copyRange = [], RowlChange = false, HasMC = false; let copyRange = [], RowlChange = false, HasMC = false;
for(let s = 0; s < Store.luckysheet_select_save.length; s++){ for (let s = 0; s < Store.luckysheet_select_save.length; s++) {
let range = Store.luckysheet_select_save[s]; let range = Store.luckysheet_select_save[s];
let r1 = range.row[0], let r1 = range.row[0],
...@@ -114,31 +114,31 @@ const selection = { ...@@ -114,31 +114,31 @@ const selection = {
let c1 = range.column[0], let c1 = range.column[0],
c2 = range.column[1]; c2 = range.column[1];
for(let copyR = r1; copyR <= r2; copyR++){ for (let copyR = r1; copyR <= r2; copyR++) {
if (Store.config["rowhidden"] != null && Store.config["rowhidden"][copyR] != null) { if (Store.config["rowhidden"] != null && Store.config["rowhidden"][copyR] != null) {
continue; continue;
} }
if(!rowIndexArr.includes(copyR)){ if (!rowIndexArr.includes(copyR)) {
rowIndexArr.push(copyR); rowIndexArr.push(copyR);
} }
if (Store.config["rowlen"] != null && (copyR in Store.config["rowlen"])){ if (Store.config["rowlen"] != null && (copyR in Store.config["rowlen"])) {
RowlChange = true; RowlChange = true;
} }
for(let copyC = c1; copyC <= c2; copyC++){ for (let copyC = c1; copyC <= c2; copyC++) {
if (Store.config["colhidden"] != null && Store.config["colhidden"][copyC] != null) { if (Store.config["colhidden"] != null && Store.config["colhidden"][copyC] != null) {
continue; continue;
} }
if(!colIndexArr.includes(copyC)){ if (!colIndexArr.includes(copyC)) {
colIndexArr.push(copyC); colIndexArr.push(copyC);
} }
let cell = Store.flowdata[copyR][copyC]; let cell = Store.flowdata[copyR][copyC];
if(getObjType(cell) == "object" && ("mc" in cell) && cell.mc.rs != null){ if (getObjType(cell) == "object" && ("mc" in cell) && cell.mc.rs != null) {
HasMC = true; HasMC = true;
} }
} }
...@@ -162,7 +162,7 @@ const selection = { ...@@ -162,7 +162,7 @@ const selection = {
let _this = this; let _this = this;
let borderInfoCompute; let borderInfoCompute;
if(Store.config["borderInfo"] && Store.config["borderInfo"].length > 0){ //边框 if (Store.config["borderInfo"] && Store.config["borderInfo"].length > 0) { //边框
borderInfoCompute = getBorderInfoCompute(); borderInfoCompute = getBorderInfoCompute();
} }
...@@ -190,12 +190,12 @@ const selection = { ...@@ -190,12 +190,12 @@ const selection = {
for (let j = 0; j < colIndexArr.length; j++) { for (let j = 0; j < colIndexArr.length; j++) {
let c = colIndexArr[j]; let c = colIndexArr[j];
if(r == rowIndexArr[0]){ if (r == rowIndexArr[0]) {
if(Store.config == null || Store.config["columnlen"] == null || Store.config["columnlen"][c.toString()] == null){ if (Store.config == null || Store.config["columnlen"] == null || Store.config["columnlen"][c.toString()] == null) {
colgroup += '<col width="72px"></col>'; colgroup += '<col width="72px"></col>';
} }
else { else {
colgroup += '<col width="'+ Store.config["columnlen"][c.toString()] +'px"></col>'; colgroup += '<col width="' + Store.config["columnlen"][c.toString()] + 'px"></col>';
} }
} }
...@@ -203,107 +203,106 @@ const selection = { ...@@ -203,107 +203,106 @@ const selection = {
continue; continue;
} }
let column = '<td ${span} style="${style}">'; let column = '<td ${span} data-var="${datavar}" style="${style}">';
if (d[r] != null && d[r][c] != null) { if (d[r] != null && d[r][c] != null) {
let style = "", span = ""; let style = "", span = "", datavar = d[r][c].filedData ? btoa(JSON.stringify(d[r][c].filedData)) : "";
let reg = /^(w|W)((0?)|(0\.0+))$/; let reg = /^(w|W)((0?)|(0\.0+))$/;
let c_value; let c_value;
if(d[r][c].ct != null && d[r][c].ct.fa != null && d[r][c].ct.fa.match(reg)){ if (d[r][c].ct != null && d[r][c].ct.fa != null && d[r][c].ct.fa.match(reg)) {
c_value = getcellvalue(r, c, d); c_value = getcellvalue(r, c, d);
} }
else{ else {
c_value = getcellvalue(r, c, d, "m"); c_value = getcellvalue(r, c, d, "m");
} }
style += menuButton.getStyleByCell(d, r, c); style += menuButton.getStyleByCell(d, r, c);
if (getObjType(d[r][c]) == "object" && ("mc" in d[r][c])) {
if(getObjType(d[r][c]) == "object" && ("mc" in d[r][c])){ if ("rs" in d[r][c]["mc"]) {
if("rs" in d[r][c]["mc"]){ span = 'rowspan="' + d[r][c]["mc"].rs + '" colspan="' + d[r][c]["mc"].cs + '"';
span = 'rowspan="'+ d[r][c]["mc"].rs +'" colspan="'+ d[r][c]["mc"].cs +'"';
//边框 //边框
if(borderInfoCompute && borderInfoCompute[r + "_" + c]){ if (borderInfoCompute && borderInfoCompute[r + "_" + c]) {
let bl_obj = { "color": {}, "style": {} }, let bl_obj = { "color": {}, "style": {} },
br_obj = { "color": {}, "style": {} }, br_obj = { "color": {}, "style": {} },
bt_obj = { "color": {}, "style": {} }, bt_obj = { "color": {}, "style": {} },
bb_obj = { "color": {}, "style": {} }; bb_obj = { "color": {}, "style": {} };
for(let bd_r = r; bd_r < (r + d[r][c]["mc"].rs); bd_r++){ for (let bd_r = r; bd_r < (r + d[r][c]["mc"].rs); bd_r++) {
for(let bd_c = c; bd_c < (c + d[r][c]["mc"].cs); bd_c++){ for (let bd_c = c; bd_c < (c + d[r][c]["mc"].cs); bd_c++) {
if(bd_r == r && borderInfoCompute[bd_r + "_" + bd_c] && borderInfoCompute[bd_r + "_" + bd_c].t){ if (bd_r == r && borderInfoCompute[bd_r + "_" + bd_c] && borderInfoCompute[bd_r + "_" + bd_c].t) {
let linetype = borderInfoCompute[bd_r + "_" + bd_c].t.style; let linetype = borderInfoCompute[bd_r + "_" + bd_c].t.style;
let bcolor = borderInfoCompute[bd_r + "_" + bd_c].t.color; let bcolor = borderInfoCompute[bd_r + "_" + bd_c].t.color;
if(bt_obj["style"][linetype] == null){ if (bt_obj["style"][linetype] == null) {
bt_obj["style"][linetype] = 1; bt_obj["style"][linetype] = 1;
} }
else{ else {
bt_obj["style"][linetype] = bt_obj["style"][linetype] + 1; bt_obj["style"][linetype] = bt_obj["style"][linetype] + 1;
} }
if(bt_obj["color"][bcolor] == null){ if (bt_obj["color"][bcolor] == null) {
bt_obj["color"][bcolor] = 1; bt_obj["color"][bcolor] = 1;
} }
else{ else {
bt_obj["color"][bcolor] = bt_obj["color"][bcolor] + 1; bt_obj["color"][bcolor] = bt_obj["color"][bcolor] + 1;
} }
} }
if(bd_r == (r + d[r][c]["mc"].rs - 1) && borderInfoCompute[bd_r + "_" + bd_c] && borderInfoCompute[bd_r + "_" + bd_c].b){ if (bd_r == (r + d[r][c]["mc"].rs - 1) && borderInfoCompute[bd_r + "_" + bd_c] && borderInfoCompute[bd_r + "_" + bd_c].b) {
let linetype = borderInfoCompute[bd_r + "_" + bd_c].b.style; let linetype = borderInfoCompute[bd_r + "_" + bd_c].b.style;
let bcolor = borderInfoCompute[bd_r + "_" + bd_c].b.color; let bcolor = borderInfoCompute[bd_r + "_" + bd_c].b.color;
if(bb_obj["style"][linetype] == null){ if (bb_obj["style"][linetype] == null) {
bb_obj["style"][linetype] = 1; bb_obj["style"][linetype] = 1;
} }
else{ else {
bb_obj["style"][linetype] = bb_obj["style"][linetype] + 1; bb_obj["style"][linetype] = bb_obj["style"][linetype] + 1;
} }
if(bb_obj["color"][bcolor] == null){ if (bb_obj["color"][bcolor] == null) {
bb_obj["color"][bcolor] = 1; bb_obj["color"][bcolor] = 1;
} }
else{ else {
bb_obj["color"][bcolor] = bb_obj["color"][bcolor] + 1; bb_obj["color"][bcolor] = bb_obj["color"][bcolor] + 1;
} }
} }
if(bd_c == c && borderInfoCompute[bd_r + "_" + bd_c] && borderInfoCompute[bd_r + "_" + bd_c].l){ if (bd_c == c && borderInfoCompute[bd_r + "_" + bd_c] && borderInfoCompute[bd_r + "_" + bd_c].l) {
let linetype = borderInfoCompute[r + "_" + c].l.style; let linetype = borderInfoCompute[r + "_" + c].l.style;
let bcolor = borderInfoCompute[bd_r + "_" + bd_c].l.color; let bcolor = borderInfoCompute[bd_r + "_" + bd_c].l.color;
if(bl_obj["style"][linetype] == null){ if (bl_obj["style"][linetype] == null) {
bl_obj["style"][linetype] = 1; bl_obj["style"][linetype] = 1;
} }
else{ else {
bl_obj["style"][linetype] = bl_obj["style"][linetype] + 1; bl_obj["style"][linetype] = bl_obj["style"][linetype] + 1;
} }
if(bl_obj["color"][bcolor] == null){ if (bl_obj["color"][bcolor] == null) {
bl_obj["color"][bcolor] = 1; bl_obj["color"][bcolor] = 1;
} }
else{ else {
bl_obj["color"][bcolor] = bl_obj["color"][bcolor] + 1; bl_obj["color"][bcolor] = bl_obj["color"][bcolor] + 1;
} }
} }
if(bd_c == (c + d[r][c]["mc"].cs - 1) && borderInfoCompute[bd_r + "_" + bd_c] && borderInfoCompute[bd_r + "_" + bd_c].r){ if (bd_c == (c + d[r][c]["mc"].cs - 1) && borderInfoCompute[bd_r + "_" + bd_c] && borderInfoCompute[bd_r + "_" + bd_c].r) {
let linetype = borderInfoCompute[bd_r + "_" + bd_c].r.style; let linetype = borderInfoCompute[bd_r + "_" + bd_c].r.style;
let bcolor = borderInfoCompute[bd_r + "_" + bd_c].r.color; let bcolor = borderInfoCompute[bd_r + "_" + bd_c].r.color;
if(br_obj["style"][linetype] == null){ if (br_obj["style"][linetype] == null) {
br_obj["style"][linetype] = 1; br_obj["style"][linetype] = 1;
} }
else{ else {
br_obj["style"][linetype] = br_obj["style"][linetype] + 1; br_obj["style"][linetype] = br_obj["style"][linetype] + 1;
} }
if(br_obj["color"][bcolor] == null){ if (br_obj["color"][bcolor] == null) {
br_obj["color"][bcolor] = 1; br_obj["color"][bcolor] = 1;
} }
else{ else {
br_obj["color"][bcolor] = br_obj["color"][bcolor] + 1; br_obj["color"][bcolor] = br_obj["color"][bcolor] + 1;
} }
} }
...@@ -312,117 +311,117 @@ const selection = { ...@@ -312,117 +311,117 @@ const selection = {
let rowlen = d[r][c]["mc"].rs, collen = d[r][c]["mc"].cs; let rowlen = d[r][c]["mc"].rs, collen = d[r][c]["mc"].cs;
if(JSON.stringify(bl_obj).length > 23){ if (JSON.stringify(bl_obj).length > 23) {
let bl_color = null, bl_style = null; let bl_color = null, bl_style = null;
for(let x in bl_obj.color){ for (let x in bl_obj.color) {
if(bl_obj.color[x] >= (rowlen / 2)){ if (bl_obj.color[x] >= (rowlen / 2)) {
bl_color = x; bl_color = x;
} }
} }
for(let x in bl_obj.style){ for (let x in bl_obj.style) {
if(bl_obj.style[x] >= (rowlen / 2)){ if (bl_obj.style[x] >= (rowlen / 2)) {
bl_style = x; bl_style = x;
} }
} }
if(bl_color != null && bl_style != null){ if (bl_color != null && bl_style != null) {
style += "border-left:" + _this.getHtmlBorderStyle(bl_style, bl_color); style += "border-left:" + _this.getHtmlBorderStyle(bl_style, bl_color);
} }
} }
if(JSON.stringify(br_obj).length > 23){ if (JSON.stringify(br_obj).length > 23) {
let br_color = null, br_style = null; let br_color = null, br_style = null;
for(let x in br_obj.color){ for (let x in br_obj.color) {
if(br_obj.color[x] >= (rowlen / 2)){ if (br_obj.color[x] >= (rowlen / 2)) {
br_color = x; br_color = x;
} }
} }
for(let x in br_obj.style){ for (let x in br_obj.style) {
if(br_obj.style[x] >= (rowlen / 2)){ if (br_obj.style[x] >= (rowlen / 2)) {
br_style = x; br_style = x;
} }
} }
if(br_color != null && br_style != null){ if (br_color != null && br_style != null) {
style += "border-right:" + _this.getHtmlBorderStyle(br_style, br_color); style += "border-right:" + _this.getHtmlBorderStyle(br_style, br_color);
} }
} }
if(JSON.stringify(bt_obj).length > 23){ if (JSON.stringify(bt_obj).length > 23) {
let bt_color = null, bt_style = null; let bt_color = null, bt_style = null;
for(let x in bt_obj.color){ for (let x in bt_obj.color) {
if(bt_obj.color[x] >= (collen / 2)){ if (bt_obj.color[x] >= (collen / 2)) {
bt_color = x; bt_color = x;
} }
} }
for(let x in bt_obj.style){ for (let x in bt_obj.style) {
if(bt_obj.style[x] >= (collen / 2)){ if (bt_obj.style[x] >= (collen / 2)) {
bt_style = x; bt_style = x;
} }
} }
if(bt_color != null && bt_style != null){ if (bt_color != null && bt_style != null) {
style += "border-top:" + _this.getHtmlBorderStyle(bt_style, bt_color); style += "border-top:" + _this.getHtmlBorderStyle(bt_style, bt_color);
} }
} }
if(JSON.stringify(bb_obj).length > 23){ if (JSON.stringify(bb_obj).length > 23) {
let bb_color = null, bb_style = null; let bb_color = null, bb_style = null;
for(let x in bb_obj.color){ for (let x in bb_obj.color) {
if(bb_obj.color[x] >= (collen / 2)){ if (bb_obj.color[x] >= (collen / 2)) {
bb_color = x; bb_color = x;
} }
} }
for(let x in bb_obj.style){ for (let x in bb_obj.style) {
if(bb_obj.style[x] >= (collen / 2)){ if (bb_obj.style[x] >= (collen / 2)) {
bb_style = x; bb_style = x;
} }
} }
if(bb_color != null && bb_style != null){ if (bb_color != null && bb_style != null) {
style += "border-bottom:" + _this.getHtmlBorderStyle(bb_style, bb_color); style += "border-bottom:" + _this.getHtmlBorderStyle(bb_style, bb_color);
} }
} }
} }
} }
else{ else {
continue; continue;
} }
} }
else{ else {
//边框 //边框
if(borderInfoCompute && borderInfoCompute[r + "_" + c]){ if (borderInfoCompute && borderInfoCompute[r + "_" + c]) {
//左边框 //左边框
if(borderInfoCompute[r + "_" + c].l){ if (borderInfoCompute[r + "_" + c].l) {
let linetype = borderInfoCompute[r + "_" + c].l.style; let linetype = borderInfoCompute[r + "_" + c].l.style;
let bcolor = borderInfoCompute[r + "_" + c].l.color; let bcolor = borderInfoCompute[r + "_" + c].l.color;
style += "border-left:" + _this.getHtmlBorderStyle(linetype, bcolor); style += "border-left:" + _this.getHtmlBorderStyle(linetype, bcolor);
} }
//右边框 //右边框
if(borderInfoCompute[r + "_" + c].r){ if (borderInfoCompute[r + "_" + c].r) {
let linetype = borderInfoCompute[r + "_" + c].r.style; let linetype = borderInfoCompute[r + "_" + c].r.style;
let bcolor = borderInfoCompute[r + "_" + c].r.color; let bcolor = borderInfoCompute[r + "_" + c].r.color;
style += "border-right:" + _this.getHtmlBorderStyle(linetype, bcolor); style += "border-right:" + _this.getHtmlBorderStyle(linetype, bcolor);
} }
//下边框 //下边框
if(borderInfoCompute[r + "_" + c].b){ if (borderInfoCompute[r + "_" + c].b) {
let linetype = borderInfoCompute[r + "_" + c].b.style; let linetype = borderInfoCompute[r + "_" + c].b.style;
let bcolor = borderInfoCompute[r + "_" + c].b.color; let bcolor = borderInfoCompute[r + "_" + c].b.color;
style += "border-bottom:" + _this.getHtmlBorderStyle(linetype, bcolor); style += "border-bottom:" + _this.getHtmlBorderStyle(linetype, bcolor);
} }
//上边框 //上边框
if(borderInfoCompute[r + "_" + c].t){ if (borderInfoCompute[r + "_" + c].t) {
let linetype = borderInfoCompute[r + "_" + c].t.style; let linetype = borderInfoCompute[r + "_" + c].t.style;
let bcolor = borderInfoCompute[r + "_" + c].t.color; let bcolor = borderInfoCompute[r + "_" + c].t.color;
style += "border-top:" + _this.getHtmlBorderStyle(linetype, bcolor); style += "border-top:" + _this.getHtmlBorderStyle(linetype, bcolor);
...@@ -430,12 +429,12 @@ const selection = { ...@@ -430,12 +429,12 @@ const selection = {
} }
} }
column = replaceHtml(column, {"style": style, "span": span}); column = replaceHtml(column, { "style": style, "span": span, "datavar": datavar });
if(c_value == null){ if (c_value == null) {
c_value = getcellvalue(r, c, d); c_value = getcellvalue(r, c, d);
} }
if (c_value == null &&d[r][c] && d[r][c].ct && d[r][c].ct.t == 'inlineStr') { if (c_value == null && d[r][c] && d[r][c].ct && d[r][c].ct.t == 'inlineStr') {
c_value = d[r][c].ct.s c_value = d[r][c].ct.s
.map((val) => { .map((val) => {
const brDom = $('<br style="mso-data-placement:same-cell;">'); const brDom = $('<br style="mso-data-placement:same-cell;">');
...@@ -464,7 +463,7 @@ const selection = { ...@@ -464,7 +463,7 @@ const selection = {
.join(''); .join('');
} }
if(c_value == null){ if (c_value == null) {
c_value = ""; c_value = "";
} }
...@@ -476,30 +475,30 @@ const selection = { ...@@ -476,30 +475,30 @@ const selection = {
let style = ""; let style = "";
//边框 //边框
if(borderInfoCompute && borderInfoCompute[r + "_" + c]){ if (borderInfoCompute && borderInfoCompute[r + "_" + c]) {
//左边框 //左边框
if(borderInfoCompute[r + "_" + c].l){ if (borderInfoCompute[r + "_" + c].l) {
let linetype = borderInfoCompute[r + "_" + c].l.style; let linetype = borderInfoCompute[r + "_" + c].l.style;
let bcolor = borderInfoCompute[r + "_" + c].l.color; let bcolor = borderInfoCompute[r + "_" + c].l.color;
style += "border-left:" + _this.getHtmlBorderStyle(linetype, bcolor); style += "border-left:" + _this.getHtmlBorderStyle(linetype, bcolor);
} }
//右边框 //右边框
if(borderInfoCompute[r + "_" + c].r){ if (borderInfoCompute[r + "_" + c].r) {
let linetype = borderInfoCompute[r + "_" + c].r.style; let linetype = borderInfoCompute[r + "_" + c].r.style;
let bcolor = borderInfoCompute[r + "_" + c].r.color; let bcolor = borderInfoCompute[r + "_" + c].r.color;
style += "border-right:" + _this.getHtmlBorderStyle(linetype, bcolor); style += "border-right:" + _this.getHtmlBorderStyle(linetype, bcolor);
} }
//下边框 //下边框
if(borderInfoCompute[r + "_" + c].b){ if (borderInfoCompute[r + "_" + c].b) {
let linetype = borderInfoCompute[r + "_" + c].b.style; let linetype = borderInfoCompute[r + "_" + c].b.style;
let bcolor = borderInfoCompute[r + "_" + c].b.color; let bcolor = borderInfoCompute[r + "_" + c].b.color;
style += "border-bottom:" + _this.getHtmlBorderStyle(linetype, bcolor); style += "border-bottom:" + _this.getHtmlBorderStyle(linetype, bcolor);
} }
//上边框 //上边框
if(borderInfoCompute[r + "_" + c].t){ if (borderInfoCompute[r + "_" + c].t) {
let linetype = borderInfoCompute[r + "_" + c].t.style; let linetype = borderInfoCompute[r + "_" + c].t.style;
let bcolor = borderInfoCompute[r + "_" + c].t.color; let bcolor = borderInfoCompute[r + "_" + c].t.color;
style += "border-top:" + _this.getHtmlBorderStyle(linetype, bcolor); style += "border-top:" + _this.getHtmlBorderStyle(linetype, bcolor);
...@@ -508,7 +507,7 @@ const selection = { ...@@ -508,7 +507,7 @@ const selection = {
column += ""; column += "";
column = replaceHtml(column, {"style": style, "span": ""}); column = replaceHtml(column, { "style": style, "span": "" });
column += ""; column += "";
} }
...@@ -531,7 +530,7 @@ const selection = { ...@@ -531,7 +530,7 @@ const selection = {
document.execCommand("Copy"); document.execCommand("Copy");
// 等50毫秒,keyPress事件发生了再去处理数据 // 等50毫秒,keyPress事件发生了再去处理数据
setTimeout(function () { setTimeout(function() {
$("#luckysheet-copy-content").blur(); $("#luckysheet-copy-content").blur();
}, 10); }, 10);
...@@ -549,7 +548,7 @@ const selection = { ...@@ -549,7 +548,7 @@ const selection = {
return false;//否则设不生效 return false;//否则设不生效
} }
}, },
copybyformat: function (e, txt) {//copy事件 copybyformat: function(e, txt) {//copy事件
let clipboardData = window.clipboardData; //for IE let clipboardData = window.clipboardData; //for IE
if (!clipboardData) { // for chrome if (!clipboardData) { // for chrome
clipboardData = e.originalEvent && e.originalEvent.clipboardData; clipboardData = e.originalEvent && e.originalEvent.clipboardData;
...@@ -569,7 +568,7 @@ const selection = { ...@@ -569,7 +568,7 @@ const selection = {
document.execCommand("selectAll"); document.execCommand("selectAll");
document.execCommand("Copy"); document.execCommand("Copy");
// 等50毫秒,keyPress事件发生了再去处理数据 // 等50毫秒,keyPress事件发生了再去处理数据
setTimeout(function () { textarea.blur(); }, 10); setTimeout(function() { textarea.blur(); }, 10);
} }
else { else {
clipboardData.setData('Text', cpdata); clipboardData.setData('Text', cpdata);
...@@ -577,10 +576,10 @@ const selection = { ...@@ -577,10 +576,10 @@ const selection = {
} }
}, },
isPasteAction: false, isPasteAction: false,
paste: function (e, triggerType) {//paste事件 paste: function(e, triggerType) {//paste事件
let _this = this; let _this = this;
if(Store.allowEdit===false){ if (Store.allowEdit === false) {
return; return;
} }
...@@ -592,53 +591,53 @@ const selection = { ...@@ -592,53 +591,53 @@ const selection = {
textarea.select(); textarea.select();
// 等50毫秒,keyPress事件发生了再去处理数据 // 等50毫秒,keyPress事件发生了再去处理数据
setTimeout(function () { setTimeout(function() {
let data = textarea.html(); let data = textarea.html();
if (data.indexOf("luckysheet_copy_action_table") >- 1 && Store.luckysheet_copy_save["copyRange"] != null && Store.luckysheet_copy_save["copyRange"].length > 0) { if (data.indexOf("luckysheet_copy_action_table") > - 1 && Store.luckysheet_copy_save["copyRange"] != null && Store.luckysheet_copy_save["copyRange"].length > 0) {
if(Store.luckysheet_paste_iscut){ if (Store.luckysheet_paste_iscut) {
Store.luckysheet_paste_iscut = false; Store.luckysheet_paste_iscut = false;
_this.pasteHandlerOfCutPaste(Store.luckysheet_copy_save); _this.pasteHandlerOfCutPaste(Store.luckysheet_copy_save);
_this.clearcopy(e); _this.clearcopy(e);
} }
else{ else {
_this.pasteHandlerOfCopyPaste(Store.luckysheet_copy_save); _this.pasteHandlerOfCopyPaste(Store.luckysheet_copy_save);
} }
} }
else if(data.indexOf("luckysheet_copy_action_image") > - 1){ else if (data.indexOf("luckysheet_copy_action_image") > - 1) {
imageCtrl.pasteImgItem(); imageCtrl.pasteImgItem();
} }
else if (triggerType != "btn") { else if (triggerType != "btn") {
_this.pasteHandler(data); _this.pasteHandler(data);
} }
else { else {
if(isEditMode()){ if (isEditMode()) {
alert(local_drag.pasteMustKeybordAlert); alert(local_drag.pasteMustKeybordAlert);
} }
else{ else {
tooltip.info(local_drag.pasteMustKeybordAlertHTMLTitle, local_drag.pasteMustKeybordAlertHTML); tooltip.info(local_drag.pasteMustKeybordAlertHTMLTitle, local_drag.pasteMustKeybordAlertHTML);
} }
} }
}, 10); }, 10);
}, },
pasteHandler: function (data, borderInfo) { pasteHandler: function(data, borderInfo) {
if(!checkProtectionLockedRangeList(Store.luckysheet_select_save, Store.currentSheetIndex)){ if (!checkProtectionLockedRangeList(Store.luckysheet_select_save, Store.currentSheetIndex)) {
return; return;
} }
if(Store.allowEdit===false){ if (Store.allowEdit === false) {
return; return;
} }
const _locale = locale() const _locale = locale()
const locale_paste = _locale.paste; const locale_paste = _locale.paste;
if(Store.luckysheet_select_save.length > 1){ if (Store.luckysheet_select_save.length > 1) {
if(isEditMode()){ if (isEditMode()) {
alert(locale_paste.errorNotAllowMulti); alert(locale_paste.errorNotAllowMulti);
} }
else{ else {
tooltip.info(`<i class="fa fa-exclamation-triangle"></i>${locale_paste.warning}`, locale_paste.errorNotAllowMulti); tooltip.info(`<i class="fa fa-exclamation-triangle"></i>${locale_paste.warning}`, locale_paste.errorNotAllowMulti);
} }
} }
...@@ -647,11 +646,11 @@ const selection = { ...@@ -647,11 +646,11 @@ const selection = {
if (data.length == 0) { return; }; if (data.length == 0) { return; };
let cfg = $.extend(true, {}, Store.config); let cfg = $.extend(true, {}, Store.config);
if(cfg["merge"] == null){ if (cfg["merge"] == null) {
cfg["merge"] = {}; cfg["merge"] = {};
} }
if(JSON.stringify(borderInfo).length > 2 && cfg["borderInfo"] == null){ if (JSON.stringify(borderInfo).length > 2 && cfg["borderInfo"] == null) {
cfg["borderInfo"] = []; cfg["borderInfo"] = [];
} }
...@@ -664,15 +663,15 @@ const selection = { ...@@ -664,15 +663,15 @@ const selection = {
//应用范围包含部分合并单元格,则return提示 //应用范围包含部分合并单元格,则return提示
let has_PartMC = false; let has_PartMC = false;
if(cfg["merge"] != null){ if (cfg["merge"] != null) {
has_PartMC = hasPartMC(cfg, minh, maxh, minc, maxc); has_PartMC = hasPartMC(cfg, minh, maxh, minc, maxc);
} }
if(has_PartMC){ if (has_PartMC) {
if(isEditMode()){ if (isEditMode()) {
alert(locale_paste.errorNotAllowMerged); alert(locale_paste.errorNotAllowMerged);
} }
else{ else {
tooltip.info(`<i class="fa fa-exclamation-triangle"></i>${locale_paste.warning}`, locale_paste.errorNotAllowMerged); tooltip.info(`<i class="fa fa-exclamation-triangle"></i>${locale_paste.warning}`, locale_paste.errorNotAllowMerged);
} }
...@@ -685,11 +684,11 @@ const selection = { ...@@ -685,11 +684,11 @@ const selection = {
//若应用范围超过最大行或最大列,增加行列 //若应用范围超过最大行或最大列,增加行列
let addr = maxh - rowMaxLength + 1, addc = maxc - cellMaxLength + 1; let addr = maxh - rowMaxLength + 1, addc = maxc - cellMaxLength + 1;
if(addr > 0 || addc > 0){ if (addr > 0 || addc > 0) {
d = datagridgrowth([].concat(d), addr, addc, true); d = datagridgrowth([].concat(d), addr, addc, true);
} }
if(cfg["rowlen"] == null){ if (cfg["rowlen"] == null) {
cfg["rowlen"] = {}; cfg["rowlen"] = {};
} }
...@@ -699,13 +698,13 @@ const selection = { ...@@ -699,13 +698,13 @@ const selection = {
let x = [].concat(d[h]); let x = [].concat(d[h]);
let currentRowLen = Store.defaultrowlen; let currentRowLen = Store.defaultrowlen;
if(cfg["rowlen"][h] != null){ if (cfg["rowlen"][h] != null) {
currentRowLen = cfg["rowlen"][h]; currentRowLen = cfg["rowlen"][h];
} }
for (let c = minc; c <= maxc; c++) { for (let c = minc; c <= maxc; c++) {
if(getObjType(x[c]) == "object" && ("mc" in x[c])){ if (getObjType(x[c]) == "object" && ("mc" in x[c])) {
if("rs" in x[c].mc){ if ("rs" in x[c].mc) {
delete cfg["merge"][x[c]["mc"].r + "_" + x[c]["mc"].c]; delete cfg["merge"][x[c]["mc"].r + "_" + x[c]["mc"].c];
} }
...@@ -719,8 +718,8 @@ const selection = { ...@@ -719,8 +718,8 @@ const selection = {
x[c] = $.extend(true, {}, value); x[c] = $.extend(true, {}, value);
if(value != null && "mc" in x[c]){ if (value != null && "mc" in x[c]) {
if(x[c]["mc"].rs != null){ if (x[c]["mc"].rs != null) {
x[c]["mc"].r = h; x[c]["mc"].r = h;
x[c]["mc"].c = c; x[c]["mc"].c = c;
...@@ -728,12 +727,12 @@ const selection = { ...@@ -728,12 +727,12 @@ const selection = {
offsetMC[value["mc"].r + "_" + value["mc"].c] = [x[c]["mc"].r, x[c]["mc"].c]; offsetMC[value["mc"].r + "_" + value["mc"].c] = [x[c]["mc"].r, x[c]["mc"].c];
} }
else{ else {
x[c] = { "mc": { r: offsetMC[value["mc"].r + "_" + value["mc"].c][0], c: offsetMC[value["mc"].r + "_" + value["mc"].c][1] } } x[c] = { "mc": { r: offsetMC[value["mc"].r + "_" + value["mc"].c][0], c: offsetMC[value["mc"].r + "_" + value["mc"].c][1] } }
} }
} }
if(borderInfo[(h - minh) + "_" + (c - minc)]){ if (borderInfo[(h - minh) + "_" + (c - minc)]) {
let bd_obj = { let bd_obj = {
"rangeType": "cell", "rangeType": "cell",
"value": { "value": {
...@@ -752,14 +751,14 @@ const selection = { ...@@ -752,14 +751,14 @@ const selection = {
let fontset = luckysheetfontformat(x[c]); let fontset = luckysheetfontformat(x[c]);
let oneLineTextHeight = menuButton.getTextSize("田", fontset)[1]; let oneLineTextHeight = menuButton.getTextSize("田", fontset)[1];
//比较计算高度和当前高度取最大高度 //比较计算高度和当前高度取最大高度
if(oneLineTextHeight > currentRowLen){ if (oneLineTextHeight > currentRowLen) {
currentRowLen = oneLineTextHeight; currentRowLen = oneLineTextHeight;
RowlChange = true; RowlChange = true;
} }
} }
d[h] = x; d[h] = x;
if(currentRowLen != Store.defaultrowlen){ if (currentRowLen != Store.defaultrowlen) {
cfg["rowlen"][h] = currentRowLen; cfg["rowlen"][h] = currentRowLen;
} }
} }
...@@ -767,14 +766,14 @@ const selection = { ...@@ -767,14 +766,14 @@ const selection = {
Store.luckysheet_select_save = [{ "row": [minh, maxh], "column": [minc, maxc] }]; Store.luckysheet_select_save = [{ "row": [minh, maxh], "column": [minc, maxc] }];
if(addr > 0 || addc > 0 || RowlChange){ if (addr > 0 || addc > 0 || RowlChange) {
let allParam = { let allParam = {
"cfg": cfg, "cfg": cfg,
"RowlChange": true "RowlChange": true
} }
jfrefreshgrid(d, Store.luckysheet_select_save, allParam); jfrefreshgrid(d, Store.luckysheet_select_save, allParam);
} }
else{ else {
let allParam = { let allParam = {
"cfg": cfg "cfg": cfg
} }
...@@ -805,22 +804,22 @@ const selection = { ...@@ -805,22 +804,22 @@ const selection = {
//应用范围包含部分合并单元格,则return提示 //应用范围包含部分合并单元格,则return提示
let has_PartMC = false; let has_PartMC = false;
if(Store.config["merge"] != null){ if (Store.config["merge"] != null) {
has_PartMC = hasPartMC(Store.config, curR, curR + rlen - 1, curC, curC + clen - 1); has_PartMC = hasPartMC(Store.config, curR, curR + rlen - 1, curC, curC + clen - 1);
} }
if(has_PartMC){ if (has_PartMC) {
if(isEditMode()){ if (isEditMode()) {
alert(locale_paste.errorNotAllowMerged); alert(locale_paste.errorNotAllowMerged);
} }
else{ else {
tooltip.info(`<i class="fa fa-exclamation-triangle"></i>${locale_paste.warning}`,locale_paste.errorNotAllowMerged); tooltip.info(`<i class="fa fa-exclamation-triangle"></i>${locale_paste.warning}`, locale_paste.errorNotAllowMerged);
} }
return; return;
} }
let addr = curR + rlen - d.length, addc = curC + clen - d[0].length; let addr = curR + rlen - d.length, addc = curC + clen - d[0].length;
if(addr > 0 || addc > 0){ if (addr > 0 || addc > 0) {
d = datagridgrowth([].concat(d), addr, addc, true); d = datagridgrowth([].concat(d), addr, addc, true);
} }
...@@ -829,7 +828,7 @@ const selection = { ...@@ -829,7 +828,7 @@ const selection = {
for (let c = 0; c < clen; c++) { for (let c = 0; c < clen; c++) {
let originCell = x[c + curC]; let originCell = x[c + curC];
let value = dataChe[r][c]; let value = dataChe[r][c];
if(isRealNum(value)){ if (isRealNum(value)) {
// 如果单元格设置了纯文本格式,那么就不要转成数值类型了,防止数值过大自动转成科学计数法 // 如果单元格设置了纯文本格式,那么就不要转成数值类型了,防止数值过大自动转成科学计数法
if (originCell && originCell.ct && originCell.ct.fa === '@') { if (originCell && originCell.ct && originCell.ct.fa === '@') {
value = String(value); value = String(value);
...@@ -837,21 +836,21 @@ const selection = { ...@@ -837,21 +836,21 @@ const selection = {
value = parseFloat(value); value = parseFloat(value);
} }
} }
if(originCell instanceof Object){ if (originCell instanceof Object) {
originCell.v = value; originCell.v = value;
if(originCell.ct!=null && originCell.ct.fa!=null){ if (originCell.ct != null && originCell.ct.fa != null) {
originCell.m = update(originCell["ct"]["fa"], value); originCell.m = update(originCell["ct"]["fa"], value);
} }
else{ else {
originCell.m = value; originCell.m = value;
} }
if(originCell.f!=null && originCell.f.length>0){ if (originCell.f != null && originCell.f.length > 0) {
originCell.f = ""; originCell.f = "";
formula.delFunctionGroup(r + curR,c + curC,Store.currentSheetIndex); formula.delFunctionGroup(r + curR, c + curC, Store.currentSheetIndex);
} }
} }
else{ else {
let cell = {}; let cell = {};
let mask = genarate(value); let mask = genarate(value);
cell.v = mask[2]; cell.v = mask[2];
...@@ -880,11 +879,11 @@ const selection = { ...@@ -880,11 +879,11 @@ const selection = {
} }
} }
}, },
pasteHandlerOfCutPaste: function(copyRange){ pasteHandlerOfCutPaste: function(copyRange) {
if(!checkProtectionLockedRangeList(Store.luckysheet_select_save, Store.currentSheetIndex)){ if (!checkProtectionLockedRangeList(Store.luckysheet_select_save, Store.currentSheetIndex)) {
return; return;
} }
if(Store.allowEdit === false){ if (Store.allowEdit === false) {
return; return;
} }
...@@ -892,7 +891,7 @@ const selection = { ...@@ -892,7 +891,7 @@ const selection = {
const locale_paste = _locale.paste; const locale_paste = _locale.paste;
let cfg = $.extend(true, {}, Store.config); let cfg = $.extend(true, {}, Store.config);
if(cfg["merge"] == null){ if (cfg["merge"] == null) {
cfg["merge"] = {}; cfg["merge"] = {};
} }
...@@ -906,7 +905,7 @@ const selection = { ...@@ -906,7 +905,7 @@ const selection = {
c_c1 = copyRange["copyRange"][0].column[0], c_c1 = copyRange["copyRange"][0].column[0],
c_c2 = copyRange["copyRange"][0].column[1]; c_c2 = copyRange["copyRange"][0].column[1];
let copyData = $.extend(true, [], getdatabyselection({"row": [c_r1, c_r2], "column": [c_c1, c_c2]}, copySheetIndex)); let copyData = $.extend(true, [], getdatabyselection({ "row": [c_r1, c_r2], "column": [c_c1, c_c2] }, copySheetIndex));
let copyh = copyData.length, copyc = copyData[0].length; let copyh = copyData.length, copyc = copyData[0].length;
...@@ -917,16 +916,16 @@ const selection = { ...@@ -917,16 +916,16 @@ const selection = {
//应用范围包含部分合并单元格,则提示 //应用范围包含部分合并单元格,则提示
let has_PartMC = false; let has_PartMC = false;
if(cfg["merge"] != null){ if (cfg["merge"] != null) {
has_PartMC = hasPartMC(cfg, minh, maxh, minc, maxc); has_PartMC = hasPartMC(cfg, minh, maxh, minc, maxc);
} }
if(has_PartMC){ if (has_PartMC) {
if(isEditMode()){ if (isEditMode()) {
alert(locale_paste.errorNotAllowMerged); alert(locale_paste.errorNotAllowMerged);
} }
else{ else {
tooltip.info(`<i class="fa fa-exclamation-triangle"></i>${locale_paste.warning}`,locale_paste.errorNotAllowMerged); tooltip.info(`<i class="fa fa-exclamation-triangle"></i>${locale_paste.warning}`, locale_paste.errorNotAllowMerged);
} }
return; return;
} }
...@@ -936,7 +935,7 @@ const selection = { ...@@ -936,7 +935,7 @@ const selection = {
let cellMaxLength = d[0].length; let cellMaxLength = d[0].length;
let addr = copyh + minh - rowMaxLength, addc = copyc + minc - cellMaxLength; let addr = copyh + minh - rowMaxLength, addc = copyc + minc - cellMaxLength;
if(addr > 0 || addc > 0){ if (addr > 0 || addc > 0) {
d = datagridgrowth([].concat(d), addr, addc, true); d = datagridgrowth([].concat(d), addr, addc, true);
} }
...@@ -945,13 +944,13 @@ const selection = { ...@@ -945,13 +944,13 @@ const selection = {
let dataVerification = $.extend(true, {}, Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)]["dataVerification"]); let dataVerification = $.extend(true, {}, Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)]["dataVerification"]);
//剪切粘贴在当前表操作,删除剪切范围内数据、合并单元格和数据验证 //剪切粘贴在当前表操作,删除剪切范围内数据、合并单元格和数据验证
if(Store.currentSheetIndex == copySheetIndex){ if (Store.currentSheetIndex == copySheetIndex) {
for(let i = c_r1; i <= c_r2; i++){ for (let i = c_r1; i <= c_r2; i++) {
for(let j = c_c1; j <= c_c2; j++){ for (let j = c_c1; j <= c_c2; j++) {
let cell = d[i][j]; let cell = d[i][j];
if(getObjType(cell) == "object" && ("mc" in cell)){ if (getObjType(cell) == "object" && ("mc" in cell)) {
if("rs" in cell["mc"]){ if ("rs" in cell["mc"]) {
delete cfg["merge"][cell["mc"].r + "_" + cell["mc"].c]; delete cfg["merge"][cell["mc"].r + "_" + cell["mc"].c];
} }
delete cell["mc"]; delete cell["mc"];
...@@ -964,21 +963,21 @@ const selection = { ...@@ -964,21 +963,21 @@ const selection = {
} }
//边框 //边框
if(cfg["borderInfo"] && cfg["borderInfo"].length > 0){ if (cfg["borderInfo"] && cfg["borderInfo"].length > 0) {
let source_borderInfo = []; let source_borderInfo = [];
for(let i = 0; i < cfg["borderInfo"].length; i++){ for (let i = 0; i < cfg["borderInfo"].length; i++) {
let bd_rangeType = cfg["borderInfo"][i].rangeType; let bd_rangeType = cfg["borderInfo"][i].rangeType;
if(bd_rangeType == "range"){ if (bd_rangeType == "range") {
let bd_range = cfg["borderInfo"][i].range; let bd_range = cfg["borderInfo"][i].range;
let bd_emptyRange = []; let bd_emptyRange = [];
for(let j = 0; j < bd_range.length; j++){ for (let j = 0; j < bd_range.length; j++) {
bd_emptyRange = bd_emptyRange.concat(conditionformat.CFSplitRange( bd_emptyRange = bd_emptyRange.concat(conditionformat.CFSplitRange(
bd_range[j], bd_range[j],
{"row": [c_r1, c_r2], "column": [c_c1, c_c2]}, { "row": [c_r1, c_r2], "column": [c_c1, c_c2] },
{"row": [minh, maxh], "column": [minc, maxc]}, { "row": [minh, maxh], "column": [minc, maxc] },
"restPart" "restPart"
)); ));
} }
...@@ -987,11 +986,11 @@ const selection = { ...@@ -987,11 +986,11 @@ const selection = {
source_borderInfo.push(cfg["borderInfo"][i]); source_borderInfo.push(cfg["borderInfo"][i]);
} }
else if(bd_rangeType == "cell"){ else if (bd_rangeType == "cell") {
let bd_r = cfg["borderInfo"][i].value.row_index; let bd_r = cfg["borderInfo"][i].value.row_index;
let bd_c = cfg["borderInfo"][i].value.col_index; let bd_c = cfg["borderInfo"][i].value.col_index;
if(!(bd_r >= c_r1 && bd_r <= c_r2 && bd_c >= c_c1 && bd_c <= c_c2)){ if (!(bd_r >= c_r1 && bd_r <= c_r2 && bd_c >= c_c1 && bd_c <= c_c2)) {
source_borderInfo.push(cfg["borderInfo"][i]); source_borderInfo.push(cfg["borderInfo"][i]);
} }
} }
...@@ -1006,7 +1005,7 @@ const selection = { ...@@ -1006,7 +1005,7 @@ const selection = {
let x = [].concat(d[h]); let x = [].concat(d[h]);
for (let c = minc; c <= maxc; c++) { for (let c = minc; c <= maxc; c++) {
if(borderInfoCompute[(c_r1 + h - minh) + "_" + (c_c1 + c - minc)]){ if (borderInfoCompute[(c_r1 + h - minh) + "_" + (c_c1 + c - minc)]) {
let bd_obj = { let bd_obj = {
"rangeType": "cell", "rangeType": "cell",
"value": { "value": {
...@@ -1019,13 +1018,13 @@ const selection = { ...@@ -1019,13 +1018,13 @@ const selection = {
} }
} }
if(cfg["borderInfo"] == null){ if (cfg["borderInfo"] == null) {
cfg["borderInfo"] = []; cfg["borderInfo"] = [];
} }
cfg["borderInfo"].push(bd_obj); cfg["borderInfo"].push(bd_obj);
} }
else if(borderInfoCompute[h + "_" + c]){ else if (borderInfoCompute[h + "_" + c]) {
let bd_obj = { let bd_obj = {
"rangeType": "cell", "rangeType": "cell",
"value": { "value": {
...@@ -1038,7 +1037,7 @@ const selection = { ...@@ -1038,7 +1037,7 @@ const selection = {
} }
} }
if(cfg["borderInfo"] == null){ if (cfg["borderInfo"] == null) {
cfg["borderInfo"] = []; cfg["borderInfo"] = [];
} }
...@@ -1046,12 +1045,12 @@ const selection = { ...@@ -1046,12 +1045,12 @@ const selection = {
} }
//数据验证 剪切 //数据验证 剪切
if(c_dataVerification[(c_r1 + h - minh) + "_" + (c_c1 + c - minc)]){ if (c_dataVerification[(c_r1 + h - minh) + "_" + (c_c1 + c - minc)]) {
dataVerification[h + "_" + c] = c_dataVerification[(c_r1 + h - minh) + "_" + (c_c1 + c - minc)]; dataVerification[h + "_" + c] = c_dataVerification[(c_r1 + h - minh) + "_" + (c_c1 + c - minc)];
} }
if(getObjType(x[c]) == "object" && ("mc" in x[c])){ if (getObjType(x[c]) == "object" && ("mc" in x[c])) {
if("rs" in x[c].mc){ if ("rs" in x[c].mc) {
delete cfg["merge"][x[c]["mc"].r + "_" + x[c]["mc"].c]; delete cfg["merge"][x[c]["mc"].r + "_" + x[c]["mc"].c];
} }
delete x[c].mc; delete x[c].mc;
...@@ -1064,8 +1063,8 @@ const selection = { ...@@ -1064,8 +1063,8 @@ const selection = {
x[c] = $.extend(true, {}, value); x[c] = $.extend(true, {}, value);
if(value != null && copyHasMC && ("mc" in x[c])){ if (value != null && copyHasMC && ("mc" in x[c])) {
if(x[c]["mc"].rs != null){ if (x[c]["mc"].rs != null) {
x[c]["mc"].r = h; x[c]["mc"].r = h;
x[c]["mc"].c = c; x[c]["mc"].c = c;
...@@ -1073,7 +1072,7 @@ const selection = { ...@@ -1073,7 +1072,7 @@ const selection = {
offsetMC[value["mc"].r + "_" + value["mc"].c] = [x[c]["mc"].r, x[c]["mc"].c]; offsetMC[value["mc"].r + "_" + value["mc"].c] = [x[c]["mc"].r, x[c]["mc"].c];
} }
else{ else {
x[c] = { "mc": { r: offsetMC[value["mc"].r + "_" + value["mc"].c][0], c: offsetMC[value["mc"].r + "_" + value["mc"].c][1] } } x[c] = { "mc": { r: offsetMC[value["mc"].r + "_" + value["mc"].c][0], c: offsetMC[value["mc"].r + "_" + value["mc"].c][1] } }
} }
} }
...@@ -1086,34 +1085,34 @@ const selection = { ...@@ -1086,34 +1085,34 @@ const selection = {
last["column"] = [minc, maxc]; last["column"] = [minc, maxc];
//若有行高改变,重新计算行高改变 //若有行高改变,重新计算行高改变
if(copyRowlChange){ if (copyRowlChange) {
if(Store.currentSheetIndex != copySheetIndex){ if (Store.currentSheetIndex != copySheetIndex) {
cfg = rowlenByRange(d, minh, maxh, cfg); cfg = rowlenByRange(d, minh, maxh, cfg);
} }
else{ else {
cfg = rowlenByRange(d, c_r1, c_r2, cfg); cfg = rowlenByRange(d, c_r1, c_r2, cfg);
cfg = rowlenByRange(d, minh, maxh, cfg); cfg = rowlenByRange(d, minh, maxh, cfg);
} }
} }
let source, target; let source, target;
if(Store.currentSheetIndex != copySheetIndex){ if (Store.currentSheetIndex != copySheetIndex) {
//跨表操作 //跨表操作
let sourceData = $.extend(true, [], Store.luckysheetfile[getSheetIndex(copySheetIndex)]["data"]); let sourceData = $.extend(true, [], Store.luckysheetfile[getSheetIndex(copySheetIndex)]["data"]);
let sourceConfig = $.extend(true, {}, Store.luckysheetfile[getSheetIndex(copySheetIndex)]["config"]); let sourceConfig = $.extend(true, {}, Store.luckysheetfile[getSheetIndex(copySheetIndex)]["config"]);
let sourceCurData = $.extend(true, [], sourceData); let sourceCurData = $.extend(true, [], sourceData);
let sourceCurConfig = $.extend(true, {}, sourceConfig); let sourceCurConfig = $.extend(true, {}, sourceConfig);
if(sourceCurConfig["merge"] == null){ if (sourceCurConfig["merge"] == null) {
sourceCurConfig["merge"] = {}; sourceCurConfig["merge"] = {};
} }
for(let source_r = c_r1; source_r <= c_r2; source_r++){ for (let source_r = c_r1; source_r <= c_r2; source_r++) {
for(let source_c = c_c1; source_c <= c_c2; source_c++){ for (let source_c = c_c1; source_c <= c_c2; source_c++) {
let cell = sourceCurData[source_r][source_c]; let cell = sourceCurData[source_r][source_c];
if(getObjType(cell) == "object" && ("mc" in cell)){ if (getObjType(cell) == "object" && ("mc" in cell)) {
if("rs" in cell["mc"]){ if ("rs" in cell["mc"]) {
delete sourceCurConfig["merge"][cell["mc"].r + "_" + cell["mc"].c]; delete sourceCurConfig["merge"][cell["mc"].r + "_" + cell["mc"].c];
} }
delete cell["mc"]; delete cell["mc"];
...@@ -1122,26 +1121,26 @@ const selection = { ...@@ -1122,26 +1121,26 @@ const selection = {
} }
} }
if(copyRowlChange){ if (copyRowlChange) {
sourceCurConfig = rowlenByRange(sourceCurData, c_r1, c_r2, sourceCurConfig); sourceCurConfig = rowlenByRange(sourceCurData, c_r1, c_r2, sourceCurConfig);
} }
//边框 //边框
if(sourceCurConfig["borderInfo"] && sourceCurConfig["borderInfo"].length > 0){ if (sourceCurConfig["borderInfo"] && sourceCurConfig["borderInfo"].length > 0) {
let source_borderInfo = []; let source_borderInfo = [];
for(let i = 0; i < sourceCurConfig["borderInfo"].length; i++){ for (let i = 0; i < sourceCurConfig["borderInfo"].length; i++) {
let bd_rangeType = sourceCurConfig["borderInfo"][i].rangeType; let bd_rangeType = sourceCurConfig["borderInfo"][i].rangeType;
if(bd_rangeType == "range"){ if (bd_rangeType == "range") {
let bd_range = sourceCurConfig["borderInfo"][i].range; let bd_range = sourceCurConfig["borderInfo"][i].range;
let bd_emptyRange = []; let bd_emptyRange = [];
for(let j = 0; j < bd_range.length; j++){ for (let j = 0; j < bd_range.length; j++) {
bd_emptyRange = bd_emptyRange.concat(conditionformat.CFSplitRange( bd_emptyRange = bd_emptyRange.concat(conditionformat.CFSplitRange(
bd_range[j], bd_range[j],
{"row": [c_r1, c_r2], "column": [c_c1, c_c2]}, { "row": [c_r1, c_r2], "column": [c_c1, c_c2] },
{"row": [minh, maxh], "column": [minc, maxc]}, { "row": [minh, maxh], "column": [minc, maxc] },
"restPart" "restPart"
)); ));
} }
...@@ -1150,11 +1149,11 @@ const selection = { ...@@ -1150,11 +1149,11 @@ const selection = {
source_borderInfo.push(sourceCurConfig["borderInfo"][i]); source_borderInfo.push(sourceCurConfig["borderInfo"][i]);
} }
else if(bd_rangeType == "cell"){ else if (bd_rangeType == "cell") {
let bd_r = sourceCurConfig["borderInfo"][i].value.row_index; let bd_r = sourceCurConfig["borderInfo"][i].value.row_index;
let bd_c = sourceCurConfig["borderInfo"][i].value.col_index; let bd_c = sourceCurConfig["borderInfo"][i].value.col_index;
if(!(bd_r >= c_r1 && bd_r <= c_r2 && bd_c >= c_c1 && bd_c <= c_c2)){ if (!(bd_r >= c_r1 && bd_r <= c_r2 && bd_c >= c_c1 && bd_c <= c_c2)) {
source_borderInfo.push(sourceCurConfig["borderInfo"][i]); source_borderInfo.push(sourceCurConfig["borderInfo"][i]);
} }
} }
...@@ -1167,17 +1166,17 @@ const selection = { ...@@ -1167,17 +1166,17 @@ const selection = {
let source_cdformat = $.extend(true, [], Store.luckysheetfile[getSheetIndex(copySheetIndex)]["luckysheet_conditionformat_save"]); let source_cdformat = $.extend(true, [], Store.luckysheetfile[getSheetIndex(copySheetIndex)]["luckysheet_conditionformat_save"]);
let source_curCdformat = $.extend(true, [], source_cdformat); let source_curCdformat = $.extend(true, [], source_cdformat);
let ruleArr = []; let ruleArr = [];
if(source_curCdformat != null && source_curCdformat.length > 0){ if (source_curCdformat != null && source_curCdformat.length > 0) {
for(let i = 0; i < source_curCdformat.length; i++){ for (let i = 0; i < source_curCdformat.length; i++) {
let source_curCdformat_cellrange = source_curCdformat[i].cellrange; let source_curCdformat_cellrange = source_curCdformat[i].cellrange;
let emptyRange = []; let emptyRange = [];
let emptyRange2 = []; let emptyRange2 = [];
for(let j = 0; j < source_curCdformat_cellrange.length; j++){ for (let j = 0; j < source_curCdformat_cellrange.length; j++) {
let range = conditionformat.CFSplitRange( let range = conditionformat.CFSplitRange(
source_curCdformat_cellrange[j], source_curCdformat_cellrange[j],
{"row": [c_r1, c_r2], "column": [c_c1, c_c2]}, { "row": [c_r1, c_r2], "column": [c_c1, c_c2] },
{"row": [minh, maxh], "column": [minc, maxc]}, { "row": [minh, maxh], "column": [minc, maxc] },
"restPart" "restPart"
); );
...@@ -1185,19 +1184,19 @@ const selection = { ...@@ -1185,19 +1184,19 @@ const selection = {
let range2 = conditionformat.CFSplitRange( let range2 = conditionformat.CFSplitRange(
source_curCdformat_cellrange[j], source_curCdformat_cellrange[j],
{"row": [c_r1, c_r2], "column": [c_c1, c_c2]}, { "row": [c_r1, c_r2], "column": [c_c1, c_c2] },
{"row": [minh, maxh], "column": [minc, maxc]}, { "row": [minh, maxh], "column": [minc, maxc] },
"operatePart" "operatePart"
); );
if(range2.length > 0){ if (range2.length > 0) {
emptyRange2 = emptyRange2.concat(range2); emptyRange2 = emptyRange2.concat(range2);
} }
} }
source_curCdformat[i].cellrange = emptyRange; source_curCdformat[i].cellrange = emptyRange;
if(emptyRange2.length > 0){ if (emptyRange2.length > 0) {
let ruleObj = $.extend(true, {}, source_curCdformat[i]); let ruleObj = $.extend(true, {}, source_curCdformat[i]);
ruleObj.cellrange = emptyRange2; ruleObj.cellrange = emptyRange2;
ruleArr.push(ruleObj); ruleArr.push(ruleObj);
...@@ -1207,13 +1206,13 @@ const selection = { ...@@ -1207,13 +1206,13 @@ const selection = {
let target_cdformat = $.extend(true, [], Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)]["luckysheet_conditionformat_save"]); let target_cdformat = $.extend(true, [], Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)]["luckysheet_conditionformat_save"]);
let target_curCdformat = $.extend(true, [], target_cdformat); let target_curCdformat = $.extend(true, [], target_cdformat);
if(ruleArr.length > 0){ if (ruleArr.length > 0) {
target_curCdformat = target_curCdformat.concat(ruleArr); target_curCdformat = target_curCdformat.concat(ruleArr);
} }
//数据验证 //数据验证
for(let i = c_r1; i <= c_r2; i++){ for (let i = c_r1; i <= c_r2; i++) {
for(let j = c_c1; j <= c_c2; j++){ for (let j = c_c1; j <= c_c2; j++) {
delete c_dataVerification[i + "_" + j]; delete c_dataVerification[i + "_" + j];
} }
} }
...@@ -1249,20 +1248,20 @@ const selection = { ...@@ -1249,20 +1248,20 @@ const selection = {
} }
} }
} }
else{ else {
//条件格式 //条件格式
let cdformat = $.extend(true, [], Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)]["luckysheet_conditionformat_save"]); let cdformat = $.extend(true, [], Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)]["luckysheet_conditionformat_save"]);
let curCdformat = $.extend(true, [], cdformat); let curCdformat = $.extend(true, [], cdformat);
if(curCdformat != null && curCdformat.length > 0){ if (curCdformat != null && curCdformat.length > 0) {
for(let i = 0; i < curCdformat.length; i++){ for (let i = 0; i < curCdformat.length; i++) {
let cellrange = curCdformat[i].cellrange; let cellrange = curCdformat[i].cellrange;
let emptyRange = []; let emptyRange = [];
for(let j = 0; j < cellrange.length; j++){ for (let j = 0; j < cellrange.length; j++) {
let range = conditionformat.CFSplitRange( let range = conditionformat.CFSplitRange(
cellrange[j], cellrange[j],
{"row": [c_r1, c_r2], "column": [c_c1, c_c2]}, { "row": [c_r1, c_r2], "column": [c_c1, c_c2] },
{"row": [minh, maxh], "column": [minc, maxc]}, { "row": [minh, maxh], "column": [minc, maxc] },
"allPart" "allPart"
); );
...@@ -1306,15 +1305,15 @@ const selection = { ...@@ -1306,15 +1305,15 @@ const selection = {
} }
} }
if(addr > 0 || addc > 0){ if (addr > 0 || addc > 0) {
jfrefreshgrid_pastcut(source, target, true); jfrefreshgrid_pastcut(source, target, true);
} }
else{ else {
jfrefreshgrid_pastcut(source, target, copyRowlChange); jfrefreshgrid_pastcut(source, target, copyRowlChange);
} }
}, },
pasteHandlerOfCopyPaste: function(copyRange){ pasteHandlerOfCopyPaste: function(copyRange) {
if(!checkProtectionLockedRangeList(Store.luckysheet_select_save, Store.currentSheetIndex)){ if (!checkProtectionLockedRangeList(Store.luckysheet_select_save, Store.currentSheetIndex)) {
return; return;
} }
...@@ -1322,7 +1321,7 @@ const selection = { ...@@ -1322,7 +1321,7 @@ const selection = {
const locale_paste = _locale.paste; const locale_paste = _locale.paste;
let cfg = $.extend(true, {}, Store.config); let cfg = $.extend(true, {}, Store.config);
if(cfg["merge"] == null){ if (cfg["merge"] == null) {
cfg["merge"] = {}; cfg["merge"] = {};
} }
...@@ -1337,12 +1336,12 @@ const selection = { ...@@ -1337,12 +1336,12 @@ const selection = {
c_c2 = copyRange["copyRange"][0].column[1]; c_c2 = copyRange["copyRange"][0].column[1];
let arr = [], isSameRow = false; let arr = [], isSameRow = false;
for(let i = 0; i < copyRange["copyRange"].length; i++){ for (let i = 0; i < copyRange["copyRange"].length; i++) {
let arrData = getdatabyselection({"row": copyRange["copyRange"][i].row, "column": copyRange["copyRange"][i].column}, copySheetIndex); let arrData = getdatabyselection({ "row": copyRange["copyRange"][i].row, "column": copyRange["copyRange"][i].column }, copySheetIndex);
if(copyRange["copyRange"].length > 1){ if (copyRange["copyRange"].length > 1) {
if(c_r1 == copyRange["copyRange"][1].row[0] && c_r2 == copyRange["copyRange"][1].row[1]){ if (c_r1 == copyRange["copyRange"][1].row[0] && c_r2 == copyRange["copyRange"][1].row[1]) {
arrData = arrData[0].map(function(col, a){ arrData = arrData[0].map(function(col, a) {
return arrData.map(function(row){ return arrData.map(function(row) {
return row[a]; return row[a];
}); });
}); });
...@@ -1351,18 +1350,18 @@ const selection = { ...@@ -1351,18 +1350,18 @@ const selection = {
isSameRow = true; isSameRow = true;
} }
else if(c_c1 == copyRange["copyRange"][1].column[0] && c_c2 == copyRange["copyRange"][1].column[1]){ else if (c_c1 == copyRange["copyRange"][1].column[0] && c_c2 == copyRange["copyRange"][1].column[1]) {
arr = arr.concat(arrData); arr = arr.concat(arrData);
} }
} }
else{ else {
arr = arrData; arr = arrData;
} }
} }
if(isSameRow){ if (isSameRow) {
arr = arr[0].map(function(col, b){ arr = arr[0].map(function(col, b) {
return arr.map(function(row){ return arr.map(function(row) {
return row[b]; return row[b];
}) })
}) })
...@@ -1371,10 +1370,10 @@ const selection = { ...@@ -1371,10 +1370,10 @@ const selection = {
let copyData = $.extend(true, [], arr); let copyData = $.extend(true, [], arr);
//多重选择选择区域 单元格如果有函数 则只取值 不取函数 //多重选择选择区域 单元格如果有函数 则只取值 不取函数
if(copyRange["copyRange"].length > 1){ if (copyRange["copyRange"].length > 1) {
for(let i = 0; i < copyData.length; i++){ for (let i = 0; i < copyData.length; i++) {
for(let j = 0; j < copyData[i].length; j++){ for (let j = 0; j < copyData[i].length; j++) {
if(copyData[i][j] != null && copyData[i][j].f != null){ if (copyData[i][j] != null && copyData[i][j].f != null) {
delete copyData[i][j].f; delete copyData[i][j].f;
delete copyData[i][j].spl; delete copyData[i][j].spl;
} }
...@@ -1392,23 +1391,23 @@ const selection = { ...@@ -1392,23 +1391,23 @@ const selection = {
let mh = (maxh - minh + 1) % copyh; let mh = (maxh - minh + 1) % copyh;
let mc = (maxc - minc + 1) % copyc; let mc = (maxc - minc + 1) % copyc;
if(mh != 0 || mc != 0){ //若应用范围不是copydata行列数的整数倍,则取copydata的行列数 if (mh != 0 || mc != 0) { //若应用范围不是copydata行列数的整数倍,则取copydata的行列数
maxh = minh + copyh - 1; maxh = minh + copyh - 1;
maxc = minc + copyc - 1; maxc = minc + copyc - 1;
} }
//应用范围包含部分合并单元格,则提示 //应用范围包含部分合并单元格,则提示
let has_PartMC = false; let has_PartMC = false;
if(cfg["merge"] != null){ if (cfg["merge"] != null) {
has_PartMC = hasPartMC(cfg, minh, maxh, minc, maxc); has_PartMC = hasPartMC(cfg, minh, maxh, minc, maxc);
} }
if(has_PartMC){ if (has_PartMC) {
if(isEditMode()){ if (isEditMode()) {
alert(locale_paste.errorNotAllowMerged); alert(locale_paste.errorNotAllowMerged);
} }
else{ else {
tooltip.info(`<i class="fa fa-exclamation-triangle"></i>${locale_paste.warning}`,locale_paste.errorNotAllowMerged); tooltip.info(`<i class="fa fa-exclamation-triangle"></i>${locale_paste.warning}`, locale_paste.errorNotAllowMerged);
} }
return; return;
} }
...@@ -1422,7 +1421,7 @@ const selection = { ...@@ -1422,7 +1421,7 @@ const selection = {
//若应用范围超过最大行或最大列,增加行列 //若应用范围超过最大行或最大列,增加行列
let addr = copyh + minh - rowMaxLength, addc = copyc + minc - cellMaxLength; let addr = copyh + minh - rowMaxLength, addc = copyc + minc - cellMaxLength;
if(addr > 0 || addc > 0){ if (addr > 0 || addc > 0) {
d = datagridgrowth([].concat(d), addr, addc, true); d = datagridgrowth([].concat(d), addr, addc, true);
} }
...@@ -1431,8 +1430,8 @@ const selection = { ...@@ -1431,8 +1430,8 @@ const selection = {
let dataVerification = null; let dataVerification = null;
let mth = 0, mtc = 0, maxcellCahe = 0, maxrowCache = 0; let mth = 0, mtc = 0, maxcellCahe = 0, maxrowCache = 0;
for(let th = 1; th <= timesH; th++){ for (let th = 1; th <= timesH; th++) {
for(let tc = 1; tc <= timesC; tc++){ for (let tc = 1; tc <= timesC; tc++) {
mth = minh + (th - 1) * copyh; mth = minh + (th - 1) * copyh;
mtc = minc + (tc - 1) * copyc; mtc = minc + (tc - 1) * copyc;
maxrowCache = minh + th * copyh; maxrowCache = minh + th * copyh;
...@@ -1447,7 +1446,7 @@ const selection = { ...@@ -1447,7 +1446,7 @@ const selection = {
let x = [].concat(d[h]); let x = [].concat(d[h]);
for (let c = mtc; c < maxcellCahe; c++) { for (let c = mtc; c < maxcellCahe; c++) {
if(borderInfoCompute[(c_r1 + h - mth) + "_" + (c_c1 + c - mtc)]){ if (borderInfoCompute[(c_r1 + h - mth) + "_" + (c_c1 + c - mtc)]) {
let bd_obj = { let bd_obj = {
"rangeType": "cell", "rangeType": "cell",
"value": { "value": {
...@@ -1460,13 +1459,13 @@ const selection = { ...@@ -1460,13 +1459,13 @@ const selection = {
} }
} }
if(cfg["borderInfo"] == null){ if (cfg["borderInfo"] == null) {
cfg["borderInfo"] = []; cfg["borderInfo"] = [];
} }
cfg["borderInfo"].push(bd_obj); cfg["borderInfo"].push(bd_obj);
} }
else if(borderInfoCompute[h + "_" + c]){ else if (borderInfoCompute[h + "_" + c]) {
let bd_obj = { let bd_obj = {
"rangeType": "cell", "rangeType": "cell",
"value": { "value": {
...@@ -1479,7 +1478,7 @@ const selection = { ...@@ -1479,7 +1478,7 @@ const selection = {
} }
} }
if(cfg["borderInfo"] == null){ if (cfg["borderInfo"] == null) {
cfg["borderInfo"] = []; cfg["borderInfo"] = [];
} }
...@@ -1487,16 +1486,16 @@ const selection = { ...@@ -1487,16 +1486,16 @@ const selection = {
} }
//数据验证 复制 //数据验证 复制
if(c_dataVerification[(c_r1 + h - mth) + "_" + (c_c1 + c - mtc)]){ if (c_dataVerification[(c_r1 + h - mth) + "_" + (c_c1 + c - mtc)]) {
if(dataVerification == null){ if (dataVerification == null) {
dataVerification = $.extend(true, {}, Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)].dataVerification) dataVerification = $.extend(true, {}, Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)].dataVerification)
} }
dataVerification[h + "_" + c] = c_dataVerification[(c_r1 + h - mth) + "_" + (c_c1 + c - mtc)]; dataVerification[h + "_" + c] = c_dataVerification[(c_r1 + h - mth) + "_" + (c_c1 + c - mtc)];
} }
if(getObjType(x[c]) == "object" && "mc" in x[c]){ if (getObjType(x[c]) == "object" && "mc" in x[c]) {
if("rs" in x[c].mc){ if ("rs" in x[c].mc) {
delete cfg["merge"][x[c]["mc"].r + "_" + x[c]["mc"].c]; delete cfg["merge"][x[c]["mc"].r + "_" + x[c]["mc"].c];
} }
delete x[c].mc; delete x[c].mc;
...@@ -1507,37 +1506,37 @@ const selection = { ...@@ -1507,37 +1506,37 @@ const selection = {
value = $.extend(true, {}, copyData[h - mth][c - mtc]); value = $.extend(true, {}, copyData[h - mth][c - mtc]);
} }
if(value != null && value.f != null){ if (value != null && value.f != null) {
let func = value.f; let func = value.f;
if(offsetRow > 0){ if (offsetRow > 0) {
func = "=" + formula.functionCopy(func, "down", offsetRow); func = "=" + formula.functionCopy(func, "down", offsetRow);
} }
if(offsetRow < 0){ if (offsetRow < 0) {
func = "=" + formula.functionCopy(func, "up", Math.abs(offsetRow)); func = "=" + formula.functionCopy(func, "up", Math.abs(offsetRow));
} }
if(offsetCol > 0){ if (offsetCol > 0) {
func = "=" + formula.functionCopy(func, "right", offsetCol); func = "=" + formula.functionCopy(func, "right", offsetCol);
} }
if(offsetCol < 0){ if (offsetCol < 0) {
func = "=" + formula.functionCopy(func, "left", Math.abs(offsetCol)); func = "=" + formula.functionCopy(func, "left", Math.abs(offsetCol));
} }
let funcV = formula.execfunction(func, h, c, undefined, true); let funcV = formula.execfunction(func, h, c, undefined, true);
if(value.spl != null){ if (value.spl != null) {
value.f = funcV[2]; value.f = funcV[2];
value.v = funcV[1]; value.v = funcV[1];
value.spl = funcV[3].data; value.spl = funcV[3].data;
} }
else{ else {
value.f = funcV[2]; value.f = funcV[2];
value.v = funcV[1]; value.v = funcV[1];
if(value.ct != null && value.ct["fa"] != null){ if (value.ct != null && value.ct["fa"] != null) {
value.m = update(value.ct["fa"], funcV[1]); value.m = update(value.ct["fa"], funcV[1]);
} }
} }
...@@ -1545,8 +1544,8 @@ const selection = { ...@@ -1545,8 +1544,8 @@ const selection = {
x[c] = $.extend(true, {}, value); x[c] = $.extend(true, {}, value);
if(value != null && copyHasMC && ("mc" in x[c])){ if (value != null && copyHasMC && ("mc" in x[c])) {
if(x[c]["mc"].rs != null){ if (x[c]["mc"].rs != null) {
x[c]["mc"].r = h; x[c]["mc"].r = h;
x[c]["mc"].c = c; x[c]["mc"].c = c;
...@@ -1554,7 +1553,7 @@ const selection = { ...@@ -1554,7 +1553,7 @@ const selection = {
offsetMC[value["mc"].r + "_" + value["mc"].c] = [x[c]["mc"].r, x[c]["mc"].c]; offsetMC[value["mc"].r + "_" + value["mc"].c] = [x[c]["mc"].r, x[c]["mc"].c];
} }
else{ else {
x[c] = { "mc": { r: offsetMC[value["mc"].r + "_" + value["mc"].c][0], c: offsetMC[value["mc"].r + "_" + value["mc"].c][1] } } x[c] = { "mc": { r: offsetMC[value["mc"].r + "_" + value["mc"].c][0], c: offsetMC[value["mc"].r + "_" + value["mc"].c][1] } }
} }
} }
...@@ -1567,43 +1566,43 @@ const selection = { ...@@ -1567,43 +1566,43 @@ const selection = {
//复制范围 是否有 条件格式和数据验证 //复制范围 是否有 条件格式和数据验证
let cdformat = null; let cdformat = null;
if(copyRange["copyRange"].length == 1){ if (copyRange["copyRange"].length == 1) {
let c_file = Store.luckysheetfile[getSheetIndex(copySheetIndex)]; let c_file = Store.luckysheetfile[getSheetIndex(copySheetIndex)];
let a_file = Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)]; let a_file = Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)];
let ruleArr_cf = $.extend(true, [], c_file["luckysheet_conditionformat_save"]); let ruleArr_cf = $.extend(true, [], c_file["luckysheet_conditionformat_save"]);
if(ruleArr_cf != null && ruleArr_cf.length > 0){ if (ruleArr_cf != null && ruleArr_cf.length > 0) {
cdformat = $.extend(true, [], a_file["luckysheet_conditionformat_save"]); cdformat = $.extend(true, [], a_file["luckysheet_conditionformat_save"]);
for(let i = 0; i < ruleArr_cf.length; i++){ for (let i = 0; i < ruleArr_cf.length; i++) {
let cf_range = ruleArr_cf[i].cellrange; let cf_range = ruleArr_cf[i].cellrange;
let emptyRange = []; let emptyRange = [];
for(let th = 1; th <= timesH; th++){ for (let th = 1; th <= timesH; th++) {
for(let tc = 1; tc <= timesC; tc++){ for (let tc = 1; tc <= timesC; tc++) {
mth = minh + (th - 1) * copyh; mth = minh + (th - 1) * copyh;
mtc = minc + (tc - 1) * copyc; mtc = minc + (tc - 1) * copyc;
maxrowCache = minh + th * copyh; maxrowCache = minh + th * copyh;
maxcellCahe = minc + tc * copyc; maxcellCahe = minc + tc * copyc;
for(let j = 0; j < cf_range.length; j++){ for (let j = 0; j < cf_range.length; j++) {
let range = conditionformat.CFSplitRange( let range = conditionformat.CFSplitRange(
cf_range[j], cf_range[j],
{"row": [c_r1, c_r2], "column": [c_c1, c_c2]}, { "row": [c_r1, c_r2], "column": [c_c1, c_c2] },
{"row": [mth, maxrowCache - 1], "column": [mtc, maxcellCahe - 1]}, { "row": [mth, maxrowCache - 1], "column": [mtc, maxcellCahe - 1] },
"operatePart" "operatePart"
); );
if(range.length > 0){ if (range.length > 0) {
emptyRange = emptyRange.concat(range); emptyRange = emptyRange.concat(range);
} }
} }
} }
} }
if(emptyRange.length > 0){ if (emptyRange.length > 0) {
ruleArr_cf[i].cellrange = emptyRange; ruleArr_cf[i].cellrange = emptyRange;
cdformat.push(ruleArr_cf[i]); cdformat.push(ruleArr_cf[i]);
} }
...@@ -1614,7 +1613,7 @@ const selection = { ...@@ -1614,7 +1613,7 @@ const selection = {
last["row"] = [minh, maxh]; last["row"] = [minh, maxh];
last["column"] = [minc, maxc]; last["column"] = [minc, maxc];
if(copyRowlChange || addr > 0 || addc > 0){ if (copyRowlChange || addr > 0 || addc > 0) {
cfg = rowlenByRange(d, minh, maxh, cfg); cfg = rowlenByRange(d, minh, maxh, cfg);
let allParam = { let allParam = {
...@@ -1625,7 +1624,7 @@ const selection = { ...@@ -1625,7 +1624,7 @@ const selection = {
} }
jfrefreshgrid(d, Store.luckysheet_select_save, allParam); jfrefreshgrid(d, Store.luckysheet_select_save, allParam);
} }
else{ else {
let allParam = { let allParam = {
"cfg": cfg, "cfg": cfg,
"cdformat": cdformat, "cdformat": cdformat,
...@@ -1636,8 +1635,8 @@ const selection = { ...@@ -1636,8 +1635,8 @@ const selection = {
selectHightlightShow(); selectHightlightShow();
} }
}, },
pasteHandlerOfPaintModel: function(copyRange){ pasteHandlerOfPaintModel: function(copyRange) {
if(!checkProtectionLockedRangeList(Store.luckysheet_select_save, Store.currentSheetIndex)){ if (!checkProtectionLockedRangeList(Store.luckysheet_select_save, Store.currentSheetIndex)) {
return; return;
} }
...@@ -1645,7 +1644,7 @@ const selection = { ...@@ -1645,7 +1644,7 @@ const selection = {
const locale_paste = _locale.paste; const locale_paste = _locale.paste;
let cfg = $.extend(true, {}, Store.config); let cfg = $.extend(true, {}, Store.config);
if(cfg["merge"] == null){ if (cfg["merge"] == null) {
cfg["merge"] = {}; cfg["merge"] = {};
} }
...@@ -1659,7 +1658,7 @@ const selection = { ...@@ -1659,7 +1658,7 @@ const selection = {
c_c1 = copyRange["copyRange"][0].column[0], c_c1 = copyRange["copyRange"][0].column[0],
c_c2 = copyRange["copyRange"][0].column[1]; c_c2 = copyRange["copyRange"][0].column[1];
let copyData = $.extend(true, [], getdatabyselection({"row": [c_r1, c_r2], "column": [c_c1, c_c2]}, copySheetIndex)); let copyData = $.extend(true, [], getdatabyselection({ "row": [c_r1, c_r2], "column": [c_c1, c_c2] }, copySheetIndex));
//应用范围 //应用范围
let last = Store.luckysheet_select_save[Store.luckysheet_select_save.length - 1]; let last = Store.luckysheet_select_save[Store.luckysheet_select_save.length - 1];
...@@ -1668,19 +1667,19 @@ const selection = { ...@@ -1668,19 +1667,19 @@ const selection = {
let copyh = copyData.length, copyc = copyData[0].length; let copyh = copyData.length, copyc = copyData[0].length;
if(minh == maxh && minc == maxc){ if (minh == maxh && minc == maxc) {
//应用范围是一个单元格,自动增加到复制范围大小 (若自动增加的范围包含部分合并单元格,则提示) //应用范围是一个单元格,自动增加到复制范围大小 (若自动增加的范围包含部分合并单元格,则提示)
let has_PartMC = false; let has_PartMC = false;
if(cfg["merge"] != null){ if (cfg["merge"] != null) {
has_PartMC = hasPartMC(cfg, minh, minh + copyh - 1, minc, minc + copyc - 1); has_PartMC = hasPartMC(cfg, minh, minh + copyh - 1, minc, minc + copyc - 1);
} }
if(has_PartMC){ if (has_PartMC) {
if(isEditMode()){ if (isEditMode()) {
alert(locale_paste.errorNotAllowMerged); alert(locale_paste.errorNotAllowMerged);
} }
else{ else {
tooltip.info(`<i class="fa fa-exclamation-triangle"></i>${locale_paste.warning}`,locale_paste.errorNotAllowMerged); tooltip.info(`<i class="fa fa-exclamation-triangle"></i>${locale_paste.warning}`, locale_paste.errorNotAllowMerged);
} }
return; return;
} }
...@@ -1707,12 +1706,12 @@ const selection = { ...@@ -1707,12 +1706,12 @@ const selection = {
mtc = minc + (tc - 1) * copyc; mtc = minc + (tc - 1) * copyc;
maxrowCache = minh + th * copyh > rowMaxLength ? rowMaxLength : minh + th * copyh; maxrowCache = minh + th * copyh > rowMaxLength ? rowMaxLength : minh + th * copyh;
if(maxrowCache > (maxh + 1)){ if (maxrowCache > (maxh + 1)) {
maxrowCache = maxh + 1; maxrowCache = maxh + 1;
} }
maxcellCahe = minc + tc * copyc > cellMaxLength ? cellMaxLength : minc + tc * copyc; maxcellCahe = minc + tc * copyc > cellMaxLength ? cellMaxLength : minc + tc * copyc;
if(maxcellCahe > (maxc + 1)){ if (maxcellCahe > (maxc + 1)) {
maxcellCahe = maxc + 1; maxcellCahe = maxc + 1;
} }
...@@ -1721,7 +1720,7 @@ const selection = { ...@@ -1721,7 +1720,7 @@ const selection = {
let x = [].concat(d[h]); let x = [].concat(d[h]);
for (let c = mtc; c < maxcellCahe; c++) { for (let c = mtc; c < maxcellCahe; c++) {
if(borderInfoCompute[(c_r1 + h - mth) + "_" + (c_c1 + c - mtc)]){ if (borderInfoCompute[(c_r1 + h - mth) + "_" + (c_c1 + c - mtc)]) {
let bd_obj = { let bd_obj = {
"rangeType": "cell", "rangeType": "cell",
"value": { "value": {
...@@ -1734,13 +1733,13 @@ const selection = { ...@@ -1734,13 +1733,13 @@ const selection = {
} }
} }
if(cfg["borderInfo"] == null){ if (cfg["borderInfo"] == null) {
cfg["borderInfo"] = []; cfg["borderInfo"] = [];
} }
cfg["borderInfo"].push(bd_obj); cfg["borderInfo"].push(bd_obj);
} }
else if(borderInfoCompute[h + "_" + c]){ else if (borderInfoCompute[h + "_" + c]) {
let bd_obj = { let bd_obj = {
"rangeType": "cell", "rangeType": "cell",
"value": { "value": {
...@@ -1753,7 +1752,7 @@ const selection = { ...@@ -1753,7 +1752,7 @@ const selection = {
} }
} }
if(cfg["borderInfo"] == null){ if (cfg["borderInfo"] == null) {
cfg["borderInfo"] = []; cfg["borderInfo"] = [];
} }
...@@ -1761,16 +1760,16 @@ const selection = { ...@@ -1761,16 +1760,16 @@ const selection = {
} }
//数据验证 复制 //数据验证 复制
if(c_dataVerification[(c_r1 + h - mth) + "_" + (c_c1 + c - mtc)]){ if (c_dataVerification[(c_r1 + h - mth) + "_" + (c_c1 + c - mtc)]) {
if(dataVerification == null){ if (dataVerification == null) {
dataVerification = $.extend(true, {}, Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)].dataVerification) dataVerification = $.extend(true, {}, Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)].dataVerification)
} }
dataVerification[h + "_" + c] = c_dataVerification[(c_r1 + h - mth) + "_" + (c_c1 + c - mtc)]; dataVerification[h + "_" + c] = c_dataVerification[(c_r1 + h - mth) + "_" + (c_c1 + c - mtc)];
} }
if(getObjType(x[c]) == "object" && ("mc" in x[c])){ if (getObjType(x[c]) == "object" && ("mc" in x[c])) {
if("rs" in x[c].mc){ if ("rs" in x[c].mc) {
delete cfg["merge"][x[c]["mc"].r + "_" + x[c]["mc"].c]; delete cfg["merge"][x[c]["mc"].r + "_" + x[c]["mc"].c];
} }
delete x[c].mc; delete x[c].mc;
...@@ -1781,44 +1780,44 @@ const selection = { ...@@ -1781,44 +1780,44 @@ const selection = {
value = copyData[h - mth][c - mtc]; value = copyData[h - mth][c - mtc];
} }
if(value != null){ if (value != null) {
delete value["v"]; delete value["v"];
delete value["m"]; delete value["m"];
delete value["f"]; delete value["f"];
delete value["spl"]; delete value["spl"];
if(value.ct && value.ct.t == 'inlineStr'){ if (value.ct && value.ct.t == 'inlineStr') {
delete value.ct; delete value.ct;
} }
if(getObjType(x[c]) == "object"){ if (getObjType(x[c]) == "object") {
if(x[c].ct && x[c].ct.t === "inlineStr"){ if (x[c].ct && x[c].ct.t === "inlineStr") {
delete value["ct"]; delete value["ct"];
}else{ } else {
let format = ['bg','fc','ct','ht','vt','bl','it','cl','un','fs','ff','tb'] let format = ['bg', 'fc', 'ct', 'ht', 'vt', 'bl', 'it', 'cl', 'un', 'fs', 'ff', 'tb']
format.forEach(item=>{ format.forEach(item => {
Reflect.deleteProperty(x[c],item); Reflect.deleteProperty(x[c], item);
}) })
} }
} }
else{ else {
x[c] = {"v": x[c] }; x[c] = { "v": x[c] };
} }
x[c] = $.extend(true, x[c], value); x[c] = $.extend(true, x[c], value);
if(x[c].ct && x[c].ct.t === "inlineStr"){ if (x[c].ct && x[c].ct.t === "inlineStr") {
x[c].ct.s.forEach(item=> item = $.extend(true, item, value)) x[c].ct.s.forEach(item => item = $.extend(true, item, value))
} }
if(copyHasMC && ("mc" in x[c])){ if (copyHasMC && ("mc" in x[c])) {
if(x[c]["mc"].rs != null){ if (x[c]["mc"].rs != null) {
x[c]["mc"].r = h; x[c]["mc"].r = h;
if(x[c]["mc"].rs + h >= maxrowCache){ if (x[c]["mc"].rs + h >= maxrowCache) {
x[c]["mc"].rs = maxrowCache - h; x[c]["mc"].rs = maxrowCache - h;
} }
x[c]["mc"].c = c; x[c]["mc"].c = c;
if(x[c]["mc"].cs + c >= maxcellCahe){ if (x[c]["mc"].cs + c >= maxcellCahe) {
x[c]["mc"].cs = maxcellCahe - c; x[c]["mc"].cs = maxcellCahe - c;
} }
...@@ -1826,13 +1825,13 @@ const selection = { ...@@ -1826,13 +1825,13 @@ const selection = {
offsetMC[value["mc"].r + "_" + value["mc"].c] = [x[c]["mc"].r, x[c]["mc"].c]; offsetMC[value["mc"].r + "_" + value["mc"].c] = [x[c]["mc"].r, x[c]["mc"].c];
} }
else{ else {
x[c] = { "mc": { r: offsetMC[value["mc"].r + "_" + value["mc"].c][0], c: offsetMC[value["mc"].r + "_" + value["mc"].c][1] } } x[c] = { "mc": { r: offsetMC[value["mc"].r + "_" + value["mc"].c][0], c: offsetMC[value["mc"].r + "_" + value["mc"].c][1] } }
} }
} }
if(x[c].v != null){ if (x[c].v != null) {
if(value["ct"] != null && value["ct"]["fa"] != null){ if (value["ct"] != null && value["ct"]["fa"] != null) {
let mask = update(value["ct"]["fa"], x[c].v); let mask = update(value["ct"]["fa"], x[c].v);
x[c].m = mask; x[c].m = mask;
} }
...@@ -1849,28 +1848,28 @@ const selection = { ...@@ -1849,28 +1848,28 @@ const selection = {
let cdformat = null; let cdformat = null;
let ruleArr = $.extend(true, [], Store.luckysheetfile[getSheetIndex(copySheetIndex)]["luckysheet_conditionformat_save"]); let ruleArr = $.extend(true, [], Store.luckysheetfile[getSheetIndex(copySheetIndex)]["luckysheet_conditionformat_save"]);
if(ruleArr != null && ruleArr.length > 0){ if (ruleArr != null && ruleArr.length > 0) {
cdformat = $.extend(true, [], Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)]["luckysheet_conditionformat_save"]); cdformat = $.extend(true, [], Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)]["luckysheet_conditionformat_save"]);
for(let i = 0; i < ruleArr.length; i++){ for (let i = 0; i < ruleArr.length; i++) {
let cdformat_cellrange = ruleArr[i].cellrange; let cdformat_cellrange = ruleArr[i].cellrange;
let emptyRange = []; let emptyRange = [];
for(let j = 0; j < cdformat_cellrange.length; j++){ for (let j = 0; j < cdformat_cellrange.length; j++) {
let range = conditionformat.CFSplitRange( let range = conditionformat.CFSplitRange(
cdformat_cellrange[j], cdformat_cellrange[j],
{"row": [c_r1, c_r2], "column": [c_c1, c_c2]}, { "row": [c_r1, c_r2], "column": [c_c1, c_c2] },
{"row": [minh, maxh], "column": [minc, maxc]}, { "row": [minh, maxh], "column": [minc, maxc] },
"operatePart" "operatePart"
); );
if(range.length > 0){ if (range.length > 0) {
emptyRange = emptyRange.concat(range); emptyRange = emptyRange.concat(range);
} }
} }
if(emptyRange.length > 0){ if (emptyRange.length > 0) {
ruleArr[i].cellrange = [{"row": [minh, maxh], "column": [minc, maxc]}]; ruleArr[i].cellrange = [{ "row": [minh, maxh], "column": [minc, maxc] }];
cdformat.push(ruleArr[i]); cdformat.push(ruleArr[i]);
} }
} }
...@@ -1879,7 +1878,7 @@ const selection = { ...@@ -1879,7 +1878,7 @@ const selection = {
last["row"] = [minh, maxh]; last["row"] = [minh, maxh];
last["column"] = [minc, maxc]; last["column"] = [minc, maxc];
if(copyRowlChange){ if (copyRowlChange) {
cfg = rowlenByRange(d, minh, maxh, cfg); cfg = rowlenByRange(d, minh, maxh, cfg);
let allParam = { let allParam = {
...@@ -1890,9 +1889,9 @@ const selection = { ...@@ -1890,9 +1889,9 @@ const selection = {
} }
jfrefreshgrid(d, Store.luckysheet_select_save, allParam); jfrefreshgrid(d, Store.luckysheet_select_save, allParam);
} }
else{ else {
// 选区格式刷存在超出边界的情况 // 选区格式刷存在超出边界的情况
if(maxh >= d.length){ if (maxh >= d.length) {
maxh = d.length - 1; maxh = d.length - 1;
} }
cfg = rowlenByRange(d, minh, maxh, cfg); //更新行高 cfg = rowlenByRange(d, minh, maxh, cfg); //更新行高
...@@ -1907,7 +1906,7 @@ const selection = { ...@@ -1907,7 +1906,7 @@ const selection = {
selectHightlightShow(); selectHightlightShow();
} }
}, },
matchcopy: function (data1, data2) { matchcopy: function(data1, data2) {
let data1cache = [], data2cache = [], data1len, data2len; let data1cache = [], data2cache = [], data1len, data2len;
if (typeof data1 == "object") { if (typeof data1 == "object") {
data1cache = data1; data1cache = data1;
......
...@@ -7142,6 +7142,7 @@ export function getScreenshotWithImg(action, options = {}) { ...@@ -7142,6 +7142,7 @@ export function getScreenshotWithImg(action, options = {}) {
// ctx_newCanvas.closePath(); // ctx_newCanvas.closePath();
//获取插入图片的元素,并在canvas上进行绘制 //获取插入图片的元素,并在canvas上进行绘制
let imagePromises = [];
if ($('#luckysheet-image-showBoxs')) { if ($('#luckysheet-image-showBoxs')) {
var imgs = $('#luckysheet-image-showBoxs img'); var imgs = $('#luckysheet-image-showBoxs img');
imgs.each(function(i) { imgs.each(function(i) {
...@@ -7150,11 +7151,21 @@ export function getScreenshotWithImg(action, options = {}) { ...@@ -7150,11 +7151,21 @@ export function getScreenshotWithImg(action, options = {}) {
var top = parent.css("top").replace('px', ''); var top = parent.css("top").replace('px', '');
var width = parent.css("width").replace('px', ''); var width = parent.css("width").replace('px', '');
var height = parent.css("height").replace('px', ''); var height = parent.css("height").replace('px', '');
imagePromises.push(new Promise((resolve, reject) => {
var img = new Image() var img = new Image()
img.src = $(this).attr("src"); img.src = $(this).attr("src");
ctx_newCanvas.drawImage(img, left, top, width, height); img.onload = () => {
ctx_newCanvas.drawImage(img, left - (visibledatacolumn[stc - 1] || 0), top - visibledatarow[str - 1] || 0, width, height);
resolve()
}
img.onerror = () => resolve();
}));
}); });
} }
Promise.all(imagePromises).then((d) => {
//获取统计图元素,并在canvas上进行绘制 //获取统计图元素,并在canvas上进行绘制
let targetDoms = document.querySelectorAll('.luckysheet-modal-dialog.luckysheet-modal-dialog-chart.luckysheet-data-visualization-chart'); let targetDoms = document.querySelectorAll('.luckysheet-modal-dialog.luckysheet-modal-dialog-chart.luckysheet-data-visualization-chart');
var chartCount = 0; var chartCount = 0;
...@@ -7166,6 +7177,8 @@ export function getScreenshotWithImg(action, options = {}) { ...@@ -7166,6 +7177,8 @@ export function getScreenshotWithImg(action, options = {}) {
action(newCanvas.get(0).toDataURL("image/png", 1)); action(newCanvas.get(0).toDataURL("image/png", 1));
} }
} }
});
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment