feat: integrate luckysheet inline and fullscreen
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
import { numFormat } from '../utils/util';
|
||||
|
||||
const analysis = {
|
||||
"STDEVP": function (mean, array1d) {
|
||||
let cov = 0;
|
||||
for (let i = 0; i < array1d.length; i++) {
|
||||
let xi = array1d[i];
|
||||
cov += Math.pow(xi - mean, 2);
|
||||
}
|
||||
return numFormat(Math.sqrt(cov / array1d.length));
|
||||
},
|
||||
"STDEV": function (mean, array1d) {
|
||||
let cov = 0;
|
||||
for (let i = 0; i < array1d.length; i++) {
|
||||
let xi = array1d[i];
|
||||
cov += Math.pow(xi - mean, 2);
|
||||
}
|
||||
return numFormat(Math.sqrt(cov / (array1d.length - 1)));
|
||||
},
|
||||
"VARP": function (mean, array1d) {
|
||||
let cov = 0;
|
||||
for (let i = 0; i < array1d.length; i++) {
|
||||
let xi = array1d[i];
|
||||
cov += Math.pow(xi - mean, 2);
|
||||
}
|
||||
return numFormat(cov / array1d.length);
|
||||
},
|
||||
"let": function (mean, array1d) {
|
||||
let cov = 0;
|
||||
for (let i = 0; i < array1d.length; i++) {
|
||||
let xi = array1d[i];
|
||||
cov += Math.pow(xi - mean, 2);
|
||||
}
|
||||
return numFormat(cov / (array1d.length - 1));
|
||||
},
|
||||
};
|
||||
|
||||
export default analysis;
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,72 @@
|
||||
import { getcellvalue } from './getdata';
|
||||
|
||||
const luckysheetArray = {
|
||||
transpose: function (getdata, useGetcellValue=true) {
|
||||
let arr = [];
|
||||
if (getdata.length == 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
if (getdata[0].length == 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
for (let c = 0; c < getdata[0].length; c++) {
|
||||
let a = [];
|
||||
for (let r = 0; r < getdata.length; r++) {
|
||||
let value = "";
|
||||
if (getdata[r] != null && getdata[r][c] != null) {
|
||||
if(useGetcellValue){
|
||||
value = getcellvalue(r, c, getdata);
|
||||
}
|
||||
else{
|
||||
value = getdata[r][c];
|
||||
}
|
||||
}
|
||||
a.push(value);
|
||||
}
|
||||
arr.push(a);
|
||||
}
|
||||
|
||||
return arr;
|
||||
},
|
||||
minusClear: function(p, m){
|
||||
if(m.row[0] > p.row[1] || m.row[1] < p.row[0] || m.column[0] > p.column[1] || m.column[1] < p.column[0]){
|
||||
return null;
|
||||
}
|
||||
|
||||
if(m.row[0] == p.row[0] && m.row[1] < p.row[1] && m.column[0] > p.column[0] && m.column[1] < p.column[1]){
|
||||
return [];
|
||||
}
|
||||
|
||||
let ret = [], range = {row:[], column:[]};
|
||||
|
||||
let row1 = null, column1 = [p.column[0], p.column[1]];
|
||||
if(m.row[1] > p.row[0] && m.row[1] < p.row[1]){
|
||||
row1 = [m.row[1] + 1, p.row[1]];
|
||||
}
|
||||
else if(m.row[0] > p.row[0] && m.row[0] < p.row[1]){
|
||||
row1 = [p.row[0], m.row[0] - 1];
|
||||
}
|
||||
|
||||
if(row1 != null){
|
||||
ret.push({"row": row1, "column": column1});
|
||||
}
|
||||
|
||||
let row2 = [p.row[0], p.row[1]], column2 = null;
|
||||
if(m.column[1] > p.column[0] && m.column[1] < p.column[1]){
|
||||
column2 = [m.column[1] + 1, p.column[1]];
|
||||
}
|
||||
else if(m.column[0] > p.column[0] && m.column[0] < p.column[1]){
|
||||
column2 = [p.column[0], m.column[0] - 1];
|
||||
}
|
||||
|
||||
if(column2 != null){
|
||||
ret.push({"row": row2, "column": column2});
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
export default luckysheetArray;
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,154 @@
|
||||
const browser = {
|
||||
mobilecheck: function() {
|
||||
var a = !1;
|
||||
return function(b) {
|
||||
('ongestureend' in window || /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(b) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(b.substr(0, 4))) && (a = !0);
|
||||
}(navigator.userAgent || navigator.vendor || window.opera), document.body && document.body.clientWidth && document.body.clientHeight && document.body.clientWidth < 350 && document.body.clientHeight < 500 && (a = !0), a;
|
||||
},
|
||||
iphoneCheck: function() {
|
||||
var a = !1;
|
||||
return /iPhone/i.test(navigator.userAgent) && (a = !0), !0;
|
||||
},
|
||||
isWeixin:function() {
|
||||
var a = navigator.userAgent.toLowerCase();
|
||||
return "micromessenger" == a.match(/MicroMessenger/i) ? !0 : !1;
|
||||
},
|
||||
isAndroid:function() {
|
||||
var a = navigator.userAgent,
|
||||
b = (navigator.appVersion, a.indexOf("Android") > -1 || a.indexOf("Linux") > -1);
|
||||
return b;
|
||||
},
|
||||
tabletCheck:function() {
|
||||
var a = /ipad|android|android 3.0|xoom|sch-i800|playbook|tablet|kindle/i.test(navigator.userAgent.toLowerCase());
|
||||
return a;
|
||||
},
|
||||
BrowserType: function() {
|
||||
var userAgent = navigator.userAgent; //取得浏览器的userAgent字符串
|
||||
var isOpera = userAgent.indexOf("Opera") > -1; //判断是否Opera浏览器
|
||||
var isIE = userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1 && !isOpera; //判断是否IE浏览器
|
||||
var isIE11 = userAgent.indexOf('Trident') > -1 && userAgent.indexOf("rv:11.0") > -1;
|
||||
var isEdge = userAgent.indexOf("Edge") > -1; //判断是否IE的Edge浏览器
|
||||
var isFF = userAgent.indexOf("Firefox") > -1; //判断是否Firefox浏览器
|
||||
var isSafari = userAgent.indexOf("Safari") > -1 && userAgent.indexOf("Chrome") == -1; //判断是否Safari浏览器
|
||||
var isChrome = userAgent.indexOf("Chrome") > -1 && userAgent.indexOf("Safari") > -1; //判断Chrome浏览器
|
||||
if (isIE) {
|
||||
var reIE = new RegExp("MSIE (\\d+\\.\\d+);");
|
||||
reIE.test(userAgent);
|
||||
var fIEVersion = parseFloat(RegExp["$1"]);
|
||||
if (fIEVersion == 7) {
|
||||
return "IE7";
|
||||
} else if (fIEVersion == 8) {
|
||||
return "IE8";
|
||||
} else if (fIEVersion == 9) {
|
||||
return "IE9";
|
||||
} else if (fIEVersion == 10) {
|
||||
return "IE10";
|
||||
// } else if (fIEVersion == 11) {
|
||||
// return "IE11";
|
||||
} else {
|
||||
return "0";
|
||||
} //IE版本过低
|
||||
} //isIE end
|
||||
if (isFF) {
|
||||
return "FF";
|
||||
}
|
||||
if (isOpera) {
|
||||
return "Opera";
|
||||
}
|
||||
if (isSafari) {
|
||||
return "Safari";
|
||||
}
|
||||
if (isChrome) {
|
||||
return "Chrome";
|
||||
}
|
||||
if (isEdge) {
|
||||
return "Edge";
|
||||
}
|
||||
if (isIE11) {
|
||||
return "IE11";
|
||||
}
|
||||
}, //myBrowser() end
|
||||
//判断是否是IE浏览器
|
||||
isIE: function() {
|
||||
var userAgent = navigator.userAgent; //取得浏览器的userAgent字符串
|
||||
var isOpera = userAgent.indexOf("Opera") > -1; //判断是否Opera浏览器
|
||||
var isIE = userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1 && !isOpera; //判断是否IE浏览器
|
||||
var isIE11 = userAgent.indexOf('Trident') > -1 && userAgent.indexOf("rv:11.0") > -1;
|
||||
if (isIE || isIE11) {
|
||||
return "1";
|
||||
} else {
|
||||
return "-1";
|
||||
}
|
||||
},
|
||||
//判断是否是IE浏览器,包括Edge浏览器
|
||||
IEVersion: function() {
|
||||
var userAgent = navigator.userAgent; //取得浏览器的userAgent字符串
|
||||
var isOpera = userAgent.indexOf("Opera") > -1; //判断是否Opera浏览器
|
||||
var isIE = userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1 && !isOpera; //判断是否IE浏览器
|
||||
var isIE11 = userAgent.indexOf('Trident') > -1 && userAgent.indexOf("rv:11.0") > -1;
|
||||
var isEdge = userAgent.indexOf("Windows NT 6.1; Trident/7.0;") > -1 && !isIE; //判断是否IE的Edge浏览器
|
||||
if (isIE) {
|
||||
var reIE = new RegExp("MSIE (\\d+\\.\\d+);");
|
||||
reIE.test(userAgent);
|
||||
var fIEVersion = parseFloat(RegExp["$1"]);
|
||||
if (fIEVersion == 7) {
|
||||
return "IE7";
|
||||
} else if (fIEVersion == 8) {
|
||||
return "IE8";
|
||||
} else if (fIEVersion == 9) {
|
||||
return "IE9";
|
||||
} else if (fIEVersion == 10) {
|
||||
return "IE10";
|
||||
// } else if (fIEVersion == 11) {
|
||||
// return "IE11";
|
||||
} else {
|
||||
return "0";
|
||||
} //IE版本过低
|
||||
} else if (isEdge) {
|
||||
return "Edge";
|
||||
} else if (isIE11) {
|
||||
return "IE11";
|
||||
} else {
|
||||
return "-1"; //非IE
|
||||
}
|
||||
},
|
||||
luckysheetrefreshfixednum:null,
|
||||
luckysheetrefreshfixed:function(){
|
||||
var _this = this;
|
||||
if(_this.luckysheetrefreshfixednum==null){
|
||||
if(_this.BrowserType()=="FF"){
|
||||
_this.luckysheetrefreshfixednum = 5;
|
||||
}
|
||||
else{
|
||||
_this.luckysheetrefreshfixednum = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return _this.luckysheetrefreshfixednum;
|
||||
},
|
||||
detectOS() {
|
||||
var userAgent = navigator.userAgent;
|
||||
var isWin = (navigator.platform == "Win32") || (navigator.platform == "Windows");
|
||||
var isMac = (navigator.platform == "Mac68K") || (navigator.platform == "MacPPC") || (navigator.platform == "Macintosh") || (navigator.platform == "MacIntel");
|
||||
if (isMac) return "Mac";
|
||||
var isUnix = (navigator.platform == "X11") && !isWin && !isMac;
|
||||
if (isUnix) return "Unix";
|
||||
var isLinux = (String(navigator.platform).indexOf("Linux") > -1);
|
||||
if (isLinux) return "Linux";
|
||||
if (isWin) {
|
||||
var isWin2K = userAgent.indexOf("Windows NT 5.0") > -1 || userAgent.indexOf("Windows 2000") > -1;
|
||||
if (isWin2K) return "Win2000";
|
||||
var isWinXP = userAgent.indexOf("Windows NT 5.1") > -1 || userAgent.indexOf("Windows XP") > -1;
|
||||
if (isWinXP) return "WinXP";
|
||||
var isWin2003 = userAgent.indexOf("Windows NT 5.2") > -1 || userAgent.indexOf("Windows 2003") > -1;
|
||||
if (isWin2003) return "Win2003";
|
||||
var isWinVista= userAgent.indexOf("Windows NT 6.0") > -1 || userAgent.indexOf("Windows Vista") > -1;
|
||||
if (isWinVista) return "WinVista";
|
||||
var isWin7 = userAgent.indexOf("Windows NT 6.1") > -1 || userAgent.indexOf("Windows 7") > -1;
|
||||
if (isWin7) return "Win7";
|
||||
}
|
||||
return "other";
|
||||
}
|
||||
};
|
||||
|
||||
export default browser;
|
||||
@@ -0,0 +1,34 @@
|
||||
import selection from '../controllers/selection';
|
||||
import menuButton from '../controllers/menuButton';
|
||||
|
||||
export default function cleargridelement(event) {
|
||||
$("#luckysheet-cols-h-hover").hide();
|
||||
$("#luckysheet-rightclick-menu").hide();
|
||||
|
||||
$("#luckysheet-cell-selected-boxs .luckysheet-cell-selected").hide();
|
||||
$("#luckysheet-cols-h-selected .luckysheet-cols-h-selected").hide();
|
||||
$("#luckysheet-rows-h-selected .luckysheet-rows-h-selected").hide();
|
||||
|
||||
$("#luckysheet-cell-selected-focus").hide();
|
||||
$("#luckysheet-rows-h-hover").hide();
|
||||
$("#luckysheet-selection-copy .luckysheet-selection-copy").hide();
|
||||
$("#luckysheet-cols-menu-btn").hide();
|
||||
$("#luckysheet-row-count-show, #luckysheet-column-count-show").hide();
|
||||
if (!event) {
|
||||
selection.clearcopy(event);
|
||||
}
|
||||
//else{
|
||||
// selection.clearcopy();
|
||||
//}
|
||||
|
||||
//选区下拉icon隐藏
|
||||
if($("#luckysheet-dropCell-icon").is(":visible")){
|
||||
if(event){
|
||||
$("#luckysheet-dropCell-icon").remove();
|
||||
}
|
||||
}
|
||||
//格式刷
|
||||
if(menuButton.luckysheetPaintModelOn && !event){
|
||||
menuButton.cancelPaintModel();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
import Store from '../store';
|
||||
import { getdatabyselectionNoCopy } from './getdata';
|
||||
import { isRealNull, isRealNum } from './validate';
|
||||
import { update } from './format';
|
||||
import locale from '../locale/locale';
|
||||
|
||||
//表格计数栏
|
||||
export function countfunc() {
|
||||
if(Store.luckysheet_select_save.length == 0){
|
||||
return;
|
||||
}
|
||||
|
||||
let min = Infinity, //最小值
|
||||
max = -Infinity, //最大值
|
||||
sum = 0, //求和
|
||||
count = 0, //计数(非空单元格)
|
||||
mean = 0; //平均值
|
||||
|
||||
for(let s = 0; s < Store.luckysheet_select_save.length; s++){
|
||||
let data = getdatabyselectionNoCopy(Store.luckysheet_select_save[s]);
|
||||
|
||||
for (let r = 0; r < data.length; r++) {
|
||||
for (let c = 0; c < data[0].length; c++) {
|
||||
if(isRealNull(data[r][c])){
|
||||
continue;
|
||||
}
|
||||
|
||||
count++;
|
||||
|
||||
if(data[r][c].ct != null && data[r][c].ct.t == "d"){
|
||||
continue;
|
||||
}
|
||||
|
||||
let value = data[r][c].v;
|
||||
|
||||
if(!isRealNum(value)){
|
||||
continue;
|
||||
}
|
||||
|
||||
value = parseFloat(value);
|
||||
|
||||
sum += value;
|
||||
|
||||
if(value < min){
|
||||
min = value;
|
||||
}
|
||||
|
||||
if(value > max){
|
||||
max = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let locale_formula = locale().formula;
|
||||
|
||||
let ret = "";
|
||||
ret += "<span>"+locale_formula.count+":" + count + "</span>";
|
||||
|
||||
//处理成亿万格式
|
||||
if (isFinite(max) || isFinite(min)) {
|
||||
ret += "<span>"+locale_formula.sum+":" + sum + "</span>";
|
||||
ret += "<span>"+locale_formula.average+":" + Math.round(sum / count * 10000) / 10000 + "</span>";
|
||||
}
|
||||
|
||||
if (isFinite(max)) {
|
||||
ret += "<span>"+locale_formula.max+":" + max + "</span>";
|
||||
}
|
||||
|
||||
if (isFinite(min)) {
|
||||
ret += "<span>"+locale_formula.min+":" + min + "</span>";
|
||||
}
|
||||
|
||||
$("#luckysheet-sta-content").html(ret);
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
import {
|
||||
gridHTML,
|
||||
menuToolBar,
|
||||
flow,
|
||||
columnHeaderHTML,
|
||||
maskHTML,
|
||||
colsmenuHTML,
|
||||
rightclickHTML,
|
||||
inputHTML,
|
||||
filtermenuHTML,
|
||||
filtersubmenuHTML,
|
||||
sheetconfigHTML,
|
||||
} from '../controllers/constant';
|
||||
import luckysheetConfigsetting from '../controllers/luckysheetConfigsetting';
|
||||
import luckysheetPostil from '../controllers/postil';
|
||||
import { datagridgrowth } from './getdata';
|
||||
import editor from './editor';
|
||||
import rhchInit from './rhchInit';
|
||||
import { replaceHtml } from '../utils/util';
|
||||
import Store from '../store';
|
||||
import locale from '../locale/locale';
|
||||
|
||||
export default function luckysheetcreatedom(colwidth, rowheight, data, menu, title) {
|
||||
// //最少30行
|
||||
// if(rowheight < 30){
|
||||
// rowheight = 30;
|
||||
// }
|
||||
|
||||
// //最少22列
|
||||
// if(colwidth < 22){
|
||||
// colwidth = 22;
|
||||
// }
|
||||
|
||||
let gh = gridHTML();
|
||||
gh = replaceHtml(gh, { "logotitle": title });//设置title
|
||||
gh = replaceHtml(gh, { "menu": menuToolBar() });//设置需要显示的菜单
|
||||
|
||||
// if (data.length == 0) {
|
||||
// Store.flowdata = datagridgrowth(data, rowheight, colwidth);
|
||||
// }
|
||||
// else if (data.length < rowheight && data[0].length < colwidth) {
|
||||
// Store.flowdata = datagridgrowth(data, rowheight - data.length, colwidth - data[0].length);
|
||||
// }
|
||||
// else if (data.length < rowheight) {
|
||||
// Store.flowdata = datagridgrowth(data, rowheight - data.length, 0);
|
||||
// }
|
||||
// else if (data[0].length < colwidth) {
|
||||
// Store.flowdata = datagridgrowth(data, 0, colwidth - data[0].length);
|
||||
// }
|
||||
// else {
|
||||
// Store.flowdata = data;
|
||||
// }
|
||||
|
||||
let flowHTML = flow;
|
||||
if(Store.config == null){
|
||||
Store.config = {};
|
||||
}
|
||||
|
||||
rhchInit(rowheight, colwidth);
|
||||
|
||||
const _locale = locale();
|
||||
const locale_info = _locale.info;
|
||||
|
||||
let addControll = '<button id="luckysheet-bottom-add-row" class="btn btn-default">'+locale_info.add+'</button><input id="luckysheet-bottom-add-row-input" type="text" class="luckysheet-datavisual-config-input luckysheet-mousedown-cancel" placeholder="'+(luckysheetConfigsetting.addRowCount || 100)+'"><span style="font-size: 14px;">'+ locale_info.row +'</span><span style="font-size: 14px;color: #9c9c9c;">('+locale_info.addLast+')</span>';
|
||||
let backControll = ' <button id="luckysheet-bottom-bottom-top" class="btn btn-default" style="">'+ locale_info.backTop +'</button>';
|
||||
// let pageControll = ' <span id="luckysheet-bottom-page-info" style="font-size: 14px;color: #f34141;">共'+ luckysheetConfigsetting.pageInfo.totalPage +'页,当前已显示'+ (luckysheetConfigsetting.pageInfo.currentPage) +'页,每页'+ luckysheetConfigsetting.pageInfo.pageSize +'条</span> <button id="luckysheet-bottom-page-next" class="btn btn-danger" style="">下一页</button>';
|
||||
let pageInfo = replaceHtml(locale_info.pageInfo,{
|
||||
total:luckysheetConfigsetting.total?luckysheetConfigsetting.total:"",
|
||||
totalPage:luckysheetConfigsetting.pageInfo.totalPage?luckysheetConfigsetting.pageInfo.totalPage:"",
|
||||
currentPage:luckysheetConfigsetting.pageInfo.currentPage?luckysheetConfigsetting.pageInfo.currentPage:"",
|
||||
});
|
||||
let pageControll = ' <span id="luckysheet-bottom-page-info" style="font-size: 14px;color: #f34141;">'+ pageInfo +'</span> <button id="luckysheet-bottom-page-next" class="btn btn-danger" style="">下一页</button>';
|
||||
let pageControll2 = ' <span id="luckysheet-bottom-page-info" style="font-size: 14px;color: #f34141;">'+pageInfo+'</span>';
|
||||
|
||||
let bottomControll = "";
|
||||
if(luckysheetConfigsetting.enableAddRow){
|
||||
bottomControll += addControll;
|
||||
}
|
||||
|
||||
if(luckysheetConfigsetting.enablePage){
|
||||
if(parseInt(luckysheetConfigsetting.pageInfo.totalPage) == 1){
|
||||
bottomControll += pageControll2;
|
||||
}
|
||||
else{
|
||||
bottomControll += pageControll;
|
||||
}
|
||||
}
|
||||
|
||||
if(luckysheetConfigsetting.enableAddBackTop){
|
||||
bottomControll += backControll;
|
||||
}
|
||||
|
||||
let flowstr = replaceHtml('<div id="luckysheetcoltable_0" class="luckysheet-cell-flow-col"> <div id ="luckysheet-sheettable_0" class="luckysheet-cell-sheettable" style="height:${height}px;width:${width}px;"></div><div id="luckysheet-bottom-controll-row" class="luckysheet-bottom-controll-row"> '+ bottomControll +' </div> </div>', { "height": Store.rh_height, "width": Store.ch_width - 1 });
|
||||
|
||||
let colsheader = replaceHtml(columnHeaderHTML, { "width": Store.ch_width, "index": 0, "column": "" });
|
||||
|
||||
flowHTML = replaceHtml(flowHTML, { "width": Store.ch_width, "flow": flowstr, "index": 0 });
|
||||
|
||||
gh = replaceHtml(gh, { "flow": flowHTML, "rowHeader": "<div style='height:" + Store.rh_height + "px' id='luckysheetrowHeader_0' class='luckysheetsheetchange'></div>", "columnHeader": colsheader, "functionButton": luckysheetConfigsetting.functionButton });//设置需要显示的菜单
|
||||
|
||||
$("#" + Store.container).append(gh);
|
||||
|
||||
$("#luckysheet-scrollbar-x div").width(Store.ch_width);
|
||||
$("#luckysheet-scrollbar-y div").height(Store.rh_height + Store.columnHeaderHeight - Store.cellMainSrollBarSize - 3);
|
||||
|
||||
//新建行菜单
|
||||
$("body").append(maskHTML);
|
||||
$("body").append(colsmenuHTML);
|
||||
$("body").append(rightclickHTML());
|
||||
$("body").append(inputHTML);
|
||||
$("body").append(replaceHtml(filtermenuHTML(), { "menuid": "filter" }));
|
||||
$("body").append(replaceHtml(filtersubmenuHTML(), { "menuid": "filter" }));
|
||||
$("body").append(sheetconfigHTML());
|
||||
|
||||
$("#luckysheet-rows-h").width((Store.rowHeaderWidth-1.5));
|
||||
$("#luckysheet-cols-h-c").height((Store.columnHeaderHeight-1.5));
|
||||
$("#luckysheet-left-top").css({width:Store.rowHeaderWidth-1.5, height:Store.columnHeaderHeight-1.5});
|
||||
|
||||
// //批注
|
||||
// luckysheetPostil.buildAllPs(Store.flowdata);
|
||||
|
||||
$("#luckysheet_info_detail_input").val(luckysheetConfigsetting.title);
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
import { datagridgrowth } from './getdata';
|
||||
import editor from './editor';
|
||||
import rhchInit from './rhchInit';
|
||||
import formula from './formula';
|
||||
import { luckysheetrefreshgrid } from './refresh';
|
||||
import sheetmanage from '../controllers/sheetmanage';
|
||||
import Store from '../store';
|
||||
|
||||
export default function luckysheetcreatesheet(colwidth, rowheight, data, cfg, active) {
|
||||
if(active == null){
|
||||
active = true;
|
||||
}
|
||||
|
||||
Store.visibledatarow = [];
|
||||
Store.visibledatacolumn = [];
|
||||
Store.ch_width = 0;
|
||||
Store.rh_height = 0;
|
||||
Store.zoomRatio = 1;
|
||||
|
||||
if(cfg != null){
|
||||
Store.config = cfg;
|
||||
}
|
||||
else{
|
||||
Store.config = {};
|
||||
}
|
||||
|
||||
if (data.length == 0) {
|
||||
Store.flowdata = datagridgrowth(data, rowheight, colwidth);
|
||||
}
|
||||
else if (data.length < rowheight && data[0].length < colwidth) {
|
||||
Store.flowdata = datagridgrowth(data, rowheight - data.length, colwidth - data[0].length);
|
||||
}
|
||||
else if (data.length < rowheight) {
|
||||
Store.flowdata = datagridgrowth(data, rowheight - data.length, 0);
|
||||
}
|
||||
else if (data[0].length < colwidth) {
|
||||
Store.flowdata = datagridgrowth(data, 0, colwidth - data[0].length);
|
||||
}
|
||||
else {
|
||||
Store.flowdata = data;
|
||||
}
|
||||
|
||||
editor.webWorkerFlowDataCache(Store.flowdata);//worker存数据
|
||||
|
||||
rhchInit(rowheight, colwidth);
|
||||
|
||||
if(active){
|
||||
sheetmanage.showSheet();
|
||||
|
||||
setTimeout(function () {
|
||||
sheetmanage.restoreCache();
|
||||
formula.execFunctionGroup();
|
||||
sheetmanage.restoreSheetAll(Store.currentSheetIndex);
|
||||
luckysheetrefreshgrid();
|
||||
}, 1);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
import Store from '../store';
|
||||
|
||||
function luckysheetRangeLast(obj) {
|
||||
let range;
|
||||
|
||||
if(document.createRange){ //chrome, firefox, opera, safari, ie9+
|
||||
if(obj.innerHTML != obj.innerText || obj.innerHTML == ""){
|
||||
obj.focus(); //解决ff不获取焦点无法定位问题
|
||||
range = window.getSelection();//创建range
|
||||
range.selectAllChildren(obj);//range 选择obj下所有子内容
|
||||
range.collapseToEnd();//光标移至最后
|
||||
}
|
||||
else{
|
||||
let len = obj.innerText.length;
|
||||
|
||||
range = document.createRange();
|
||||
range.selectNodeContents(obj);
|
||||
range.setStart(obj.childNodes[0], len);
|
||||
range.collapse(true);
|
||||
|
||||
let selection = window.getSelection();
|
||||
selection.removeAllRanges();
|
||||
selection.addRange(range);
|
||||
}
|
||||
}
|
||||
else if(document.selection){ //ie8 and lower
|
||||
range = document.body.createTextRange();
|
||||
range.moveToElementText(obj);
|
||||
range.collapse(false);
|
||||
range.select();
|
||||
}
|
||||
}
|
||||
|
||||
function getCursortPosition(textDom){
|
||||
let cursorPos = 0;
|
||||
|
||||
if(document.selection){
|
||||
textDom.focus();
|
||||
let selectRange = document.selection.createRange();
|
||||
selectRange.moveStart("character", -textDom.value.length);
|
||||
cursorPos = selectRange.text.length;
|
||||
}
|
||||
else if(textDom.selectionStart || textDom.selectionStart == "0"){
|
||||
cursorPos = textDom.selectionStart;
|
||||
}
|
||||
|
||||
return cursorPos;
|
||||
}
|
||||
|
||||
function hideMenuByCancel(event){
|
||||
|
||||
// Right-click the menu in the title bar, and click on the elements whose class is luckysheet-cols-rows-shift-left and luckysheet-cols-rows-shift-right will trigger the hiding of the menu bar. It should be prohibited. Exclude these two elements. There may be more Other elements will also jump here for more testing
|
||||
|
||||
if(event.target.classList && (event.target.classList.contains('luckysheet-cols-rows-shift-left') || event.target.classList.contains('luckysheet-cols-rows-shift-right'))){
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$(event.target).hasClass("luckysheet-mousedown-cancel") && $(event.target).filter("[class*='sp-palette']").length == 0 && $(event.target).filter("[class*='sp-thumb']").length == 0 && $(event.target).filter("[class*='sp-']").length == 0) {
|
||||
$("#luckysheet-rightclick-menu").hide();
|
||||
$("#luckysheet-cols-h-hover").hide();
|
||||
$("#luckysheet-cols-menu-btn").hide();
|
||||
// $("#luckysheet-rightclick-menu").hide();
|
||||
$("#luckysheet-sheet-list, #luckysheet-rightclick-sheet-menu, #luckysheet-user-menu").hide();
|
||||
$("body > .luckysheet-filter-menu, body > .luckysheet-filter-submenu, body > .luckysheet-cols-menu").hide();
|
||||
//$("body > luckysheet-menuButton").hide();
|
||||
Store.luckysheet_cols_menu_status = false;
|
||||
}
|
||||
}
|
||||
|
||||
function selectTextDom(ele){
|
||||
if (window.getSelection) {
|
||||
let range = document.createRange();
|
||||
range.selectNodeContents(ele);
|
||||
if(range.startContainer && isInPage(range.startContainer)){
|
||||
window.getSelection().removeAllRanges();
|
||||
window.getSelection().addRange(range);
|
||||
}
|
||||
}
|
||||
else if (document.selection) {
|
||||
let range = document.body.createTextRange();
|
||||
range.moveToElementText(ele);
|
||||
range.select();
|
||||
}
|
||||
}
|
||||
|
||||
function selectTextContent(ele){
|
||||
if (window.getSelection) {
|
||||
let range = document.createRange();
|
||||
var content=ele.firstChild;
|
||||
range.setStart(content,0);
|
||||
range.setEnd(content,content.length);
|
||||
if(range.startContainer && isInPage(range.startContainer)){
|
||||
window.getSelection().removeAllRanges();
|
||||
window.getSelection().addRange(range);
|
||||
}
|
||||
}
|
||||
else if (document.selection) {
|
||||
let range = document.body.createTextRange();
|
||||
range.moveToElementText(ele);
|
||||
range.select();
|
||||
}
|
||||
}
|
||||
|
||||
function selectTextContentCross(sEle, eEle){
|
||||
if (window.getSelection) {
|
||||
let range = document.createRange();
|
||||
var sContent=sEle.firstChild, eContent=eEle.firstChild;
|
||||
range.setStart(sContent,0);
|
||||
range.setEnd(eContent,eContent.length);
|
||||
if(range.startContainer && isInPage(range.startContainer)){
|
||||
window.getSelection().removeAllRanges();
|
||||
window.getSelection().addRange(range);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function selectTextContentCollapse(sEle, index){
|
||||
if (window.getSelection) {
|
||||
let range = document.createRange();
|
||||
var sContent=sEle.firstChild;
|
||||
if(index>sContent.length){
|
||||
index=sContent.length;
|
||||
}
|
||||
else if(index<0){
|
||||
index = 0;
|
||||
}
|
||||
range.setStart(sContent,index);
|
||||
range.collapse(true);
|
||||
if(range.startContainer && isInPage(range.startContainer)){
|
||||
window.getSelection().removeAllRanges();
|
||||
window.getSelection().addRange(range);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function isInPage(node) {
|
||||
return (node === document.body) ? false : document.body.contains(node);
|
||||
}
|
||||
|
||||
export {
|
||||
luckysheetRangeLast,
|
||||
getCursortPosition,
|
||||
hideMenuByCancel,
|
||||
selectTextContent,
|
||||
selectTextDom,
|
||||
selectTextContentCross,
|
||||
selectTextContentCollapse
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
import { hasChinaword } from './validate';
|
||||
import dayjs from 'dayjs'
|
||||
|
||||
function isdatetime(s) {
|
||||
if (s == null || s.toString().length < 5) {
|
||||
return false;
|
||||
}
|
||||
else if(checkDateTime(s)){
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
|
||||
function checkDateTime(str){
|
||||
var reg1 = /^(\d{4})-(\d{1,2})-(\d{1,2})(\s(\d{1,2}):(\d{1,2})(:(\d{1,2}))?)?$/;
|
||||
var reg2 = /^(\d{4})\/(\d{1,2})\/(\d{1,2})(\s(\d{1,2}):(\d{1,2})(:(\d{1,2}))?)?$/;
|
||||
|
||||
if(!reg1.test(str) && !reg2.test(str)){
|
||||
return false;
|
||||
}
|
||||
|
||||
var year = RegExp.$1,
|
||||
month = RegExp.$2,
|
||||
day = RegExp.$3;
|
||||
|
||||
if(year < 1900){
|
||||
return false;
|
||||
}
|
||||
|
||||
if(month > 12){
|
||||
return false;
|
||||
}
|
||||
|
||||
if(day > 31){
|
||||
return false;
|
||||
}
|
||||
|
||||
if(month == 2){
|
||||
if(new Date(year, 1, 29).getDate() == 29 && day > 29){
|
||||
return false;
|
||||
}
|
||||
else if(new Date(year, 1, 29).getDate() != 29 && day > 28){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
function diff(now, then) {
|
||||
return dayjs(now).diff(dayjs(then));
|
||||
}
|
||||
|
||||
function isdatatypemulti(s) {
|
||||
let type = {};
|
||||
|
||||
if (isdatetime(s)) {
|
||||
type["date"] = true;
|
||||
}
|
||||
|
||||
if (!isNaN(parseFloat(s)) && !hasChinaword(s)) {
|
||||
type["num"] = true;
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
function isdatatype(s) {
|
||||
let type = "string";
|
||||
|
||||
if (isdatetime(s)) {
|
||||
type = "date";
|
||||
}
|
||||
else if (!isNaN(parseFloat(s)) && !hasChinaword(s)) {
|
||||
type = "num";
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
export {
|
||||
isdatetime,
|
||||
diff,
|
||||
isdatatypemulti,
|
||||
isdatatype,
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,138 @@
|
||||
import { getObjType } from '../utils/util';
|
||||
import { getSheetIndex } from '../methods/get';
|
||||
import Store from '../store';
|
||||
|
||||
//动态数组计算
|
||||
function dynamicArrayCompute(dynamicArray) {
|
||||
let dynamicArray_compute = {};
|
||||
|
||||
if(getObjType(dynamicArray) == "array"){
|
||||
for(let i = 0; i < dynamicArray.length; i++){
|
||||
let d_row = dynamicArray[i].r;
|
||||
let d_col = dynamicArray[i].c;
|
||||
let d_f = dynamicArray[i].f;
|
||||
|
||||
if(Store.flowdata[d_row][d_col] != null && Store.flowdata[d_row][d_col].f != null && Store.flowdata[d_row][d_col].f == d_f){
|
||||
if((d_row + "_" + d_col) in dynamicArray_compute){
|
||||
dynamicArray_compute = dynamicArraySpillEditCompute(dynamicArray_compute, d_row , d_col);
|
||||
}
|
||||
|
||||
let d_data = dynamicArray[i].data;
|
||||
let d_rowlen = d_data.length;
|
||||
let d_collen = 1;
|
||||
|
||||
if(getObjType(d_data[0]) == "array"){
|
||||
d_collen = d_data[0].length;
|
||||
}
|
||||
|
||||
if(dynamicArrayRangeIsAllNull({ "row": [d_row, d_row + d_rowlen - 1], "column": [d_col, d_col + d_collen - 1] }, Store.flowdata)){
|
||||
for(let x = 0; x < d_rowlen; x++){
|
||||
for(let y = 0; y < d_collen; y++){
|
||||
let rowIndex = d_row + x;
|
||||
let colIndex = d_col + y;
|
||||
|
||||
if(getObjType(d_data[0]) == "array"){
|
||||
dynamicArray_compute[rowIndex + "_" + colIndex] = {"v": d_data[x][y], "r": d_row, "c": d_col};
|
||||
}
|
||||
else{
|
||||
dynamicArray_compute[rowIndex + "_" + colIndex] = {"v": d_data[x], "r": d_row, "c": d_col};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
dynamicArray_compute[d_row + "_" + d_col] = {"v": "#SPILL!", "r": d_row, "c": d_col};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return dynamicArray_compute;
|
||||
}
|
||||
|
||||
function dynamicArraySpillEditCompute(computeObj, r, c) {
|
||||
let rowIndex = computeObj[r + "_" + c].r;
|
||||
let colIndex = computeObj[r + "_" + c].c;
|
||||
|
||||
for(let x in computeObj){
|
||||
if(x == (rowIndex + "_" + colIndex)){
|
||||
computeObj[x].v = "#SPILL!";
|
||||
}
|
||||
else if(computeObj[x].r == rowIndex && computeObj[x].c == colIndex){
|
||||
delete computeObj[x];
|
||||
}
|
||||
}
|
||||
|
||||
return computeObj;
|
||||
}
|
||||
|
||||
//范围是否都是空单元格(除第一个单元格)
|
||||
function dynamicArrayRangeIsAllNull(range, data) {
|
||||
let r1 = range["row"][0], r2 = range["row"][1];
|
||||
let c1 = range["column"][0], c2 = range["column"][1];
|
||||
|
||||
let isAllNull = true;
|
||||
for(let r = r1; r <= r2; r++){
|
||||
for(let c = c1; c <= c2; c++){
|
||||
if(!(r == r1 && c == c1) && data[r][c] != null && data[r][c].v != null && data[r][c].v.toString() != ""){
|
||||
isAllNull = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return isAllNull;
|
||||
}
|
||||
|
||||
//点击表格区域是否属于动态数组区域
|
||||
function dynamicArrayHightShow(r, c) {
|
||||
let dynamicArray = Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)]["dynamicArray"] == null ? [] : Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)]["dynamicArray"];
|
||||
let dynamicArray_compute = dynamicArrayCompute(dynamicArray);
|
||||
|
||||
if((r + "_" + c) in dynamicArray_compute && dynamicArray_compute[r + "_" + c].v != "#SPILL!"){
|
||||
let d_row = dynamicArray_compute[r + "_" + c].r;
|
||||
let d_col = dynamicArray_compute[r + "_" + c].c;
|
||||
|
||||
let d_f = Store.flowdata[d_row][d_col].f;
|
||||
|
||||
let rlen, clen;
|
||||
for(let i = 0; i < dynamicArray.length; i++){
|
||||
if(dynamicArray[i].f == d_f){
|
||||
rlen = dynamicArray[i].data.length;
|
||||
|
||||
if(getObjType(dynamicArray[i].data[0]) == "array"){
|
||||
clen = dynamicArray[i].data[0].length;
|
||||
}
|
||||
else{
|
||||
clen = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let d_row_end = d_row + rlen - 1;
|
||||
let d_col_end = d_col + clen - 1;
|
||||
|
||||
let row = Store.visibledatarow[d_row_end],
|
||||
row_pre = d_row - 1 == -1 ? 0 : Store.visibledatarow[d_row - 1];
|
||||
let col = Store.visibledatacolumn[d_col_end],
|
||||
col_pre = d_col - 1 == -1 ? 0 : Store.visibledatacolumn[d_col - 1];
|
||||
|
||||
$("#luckysheet-dynamicArray-hightShow").css({
|
||||
"left": col_pre,
|
||||
"width": col - col_pre - 1,
|
||||
"top": row_pre,
|
||||
"height": row - row_pre - 1,
|
||||
"display": "block"
|
||||
});
|
||||
}
|
||||
else{
|
||||
$("#luckysheet-dynamicArray-hightShow").hide();
|
||||
}
|
||||
}
|
||||
|
||||
export {
|
||||
dynamicArrayCompute,
|
||||
dynamicArraySpillEditCompute,
|
||||
dynamicArrayRangeIsAllNull,
|
||||
dynamicArrayHightShow,
|
||||
}
|
||||
@@ -0,0 +1,169 @@
|
||||
import browser from './browser';
|
||||
import formula from './formula';
|
||||
import { datagridgrowth } from './getdata';
|
||||
import { jfrefreshgrid, jfrefreshgridall, jfrefreshrange } from './refresh';
|
||||
import { getSheetIndex } from '../methods/get';
|
||||
import Store from '../store';
|
||||
|
||||
const editor = {
|
||||
//worker+blob实现深拷贝替换extend
|
||||
deepCopyFlowDataState:false,
|
||||
deepCopyFlowDataCache:"",
|
||||
deepCopyFlowDataWorker:null,
|
||||
deepCopyFlowData:function(flowData){
|
||||
let _this = this;
|
||||
|
||||
if(_this.deepCopyFlowDataState){
|
||||
if(_this.deepCopyFlowDataWorker != null){
|
||||
_this.deepCopyFlowDataWorker.terminate();
|
||||
}
|
||||
return _this.deepCopyFlowDataCache;
|
||||
}
|
||||
else{
|
||||
if(flowData == null){
|
||||
flowData = Store.flowdata;
|
||||
}
|
||||
|
||||
return $.extend(true, [], flowData);
|
||||
}
|
||||
},
|
||||
webWorkerFlowDataCache:function(flowData){
|
||||
let _this = this;
|
||||
|
||||
try{
|
||||
if(_this.deepCopyFlowDataWorker != null){//存新的webwork前先销毁以前的
|
||||
_this.deepCopyFlowDataWorker.terminate();
|
||||
}
|
||||
|
||||
let funcTxt = 'data:text/javascript;chartset=US-ASCII,onmessage = function (e) { postMessage(e.data); };';
|
||||
_this.deepCopyFlowDataState = false;
|
||||
|
||||
//适配IE
|
||||
let worker;
|
||||
if(browser.isIE() == 1){
|
||||
let response = "self.onmessage=function(e){postMessage(e.data);}";
|
||||
worker = new Worker('./plugins/Worker-helper.js');
|
||||
worker.postMessage(response);
|
||||
}
|
||||
else{
|
||||
worker = new Worker(funcTxt);
|
||||
}
|
||||
|
||||
_this.deepCopyFlowDataWorker = worker;
|
||||
worker.postMessage(flowData);
|
||||
worker.onmessage = function(e) {
|
||||
_this.deepCopyFlowDataCache = e.data;
|
||||
_this.deepCopyFlowDataState = true;
|
||||
};
|
||||
}
|
||||
catch(e){
|
||||
_this.deepCopyFlowDataCache = $.extend(true, [], flowData);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {Array} dataChe
|
||||
* @param {Object} range 是否指定选区,默认为当前选区
|
||||
* @since Add range parameter. Update by siwei@2020-09-10.
|
||||
*/
|
||||
controlHandler: function (dataChe, range) {
|
||||
let _this = this;
|
||||
|
||||
let d = _this.deepCopyFlowData(Store.flowdata);//取数据
|
||||
|
||||
// let last = Store.luckysheet_select_save[Store.luckysheet_select_save.length - 1];
|
||||
let last = range || Store.luckysheet_select_save[Store.luckysheet_select_save.length - 1];
|
||||
let curR = last["row"] == null ? 0 : last["row"][0];
|
||||
let curC = last["column"] == null ? 0 : last["column"][0];
|
||||
let rlen = dataChe.length, clen = dataChe[0].length;
|
||||
|
||||
let addr = curR + rlen - d.length, addc = curC + clen - d[0].length;
|
||||
if(addr > 0 || addc > 0){
|
||||
d = datagridgrowth([].concat(d), addr, addc, true);
|
||||
}
|
||||
|
||||
for (let r = 0; r < rlen; r++) {
|
||||
let x = [].concat(d[r + curR]);
|
||||
for (let c = 0; c < clen; c++) {
|
||||
let value = "";
|
||||
if (dataChe[r] != null && dataChe[r][c] != null) {
|
||||
value = dataChe[r][c];
|
||||
}
|
||||
x[c + curC] = value;
|
||||
}
|
||||
d[r + curR] = x;
|
||||
}
|
||||
|
||||
if (addr > 0 || addc > 0) {
|
||||
jfrefreshgridall(d[0].length, d.length, d, null, Store.luckysheet_select_save, "datachangeAll");
|
||||
}
|
||||
else {
|
||||
jfrefreshrange(d, Store.luckysheet_select_save);
|
||||
}
|
||||
},
|
||||
clearRangeByindex: function (st_r, ed_r, st_c, ed_c, sheetIndex) {
|
||||
let index = getSheetIndex(sheetIndex);
|
||||
let d = $.extend(true, [], Store.luckysheetfile[index]["data"]);
|
||||
|
||||
for (let r = st_r; r <= ed_r; r++) {
|
||||
let x = [].concat(d[r]);
|
||||
for (let c = st_c; c <= ed_c; c++) {
|
||||
formula.delFunctionGroup(r, c);
|
||||
formula.execFunctionGroup(r, c, "");
|
||||
x[c] = null;
|
||||
}
|
||||
d[r] = x;
|
||||
}
|
||||
|
||||
if(sheetIndex == Store.currentSheetIndex){
|
||||
let rlen = ed_r - st_r + 1,
|
||||
clen = ed_c - st_c + 1;
|
||||
|
||||
if (rlen > 5000) {
|
||||
jfrefreshgrid(d, [{ "row": [st_r, ed_r], "column": [st_c, ed_c] }]);
|
||||
}
|
||||
else {
|
||||
jfrefreshrange(d, { "row": [st_r, ed_r], "column": [st_c, ed_c] });
|
||||
}
|
||||
}
|
||||
else{
|
||||
Store.luckysheetfile[index]["data"] = d;
|
||||
}
|
||||
},
|
||||
controlHandlerD: function (dataChe) {
|
||||
let _this = this;
|
||||
|
||||
let d = _this.deepCopyFlowData(Store.flowdata);//取数据
|
||||
|
||||
let last = Store.luckysheet_select_save[Store.luckysheet_select_save.length - 1];
|
||||
let r1 = last["row"][0], r2 = last["row"][1];
|
||||
let c1 = last["column"][0], c2 = last["column"][1];
|
||||
let rlen = dataChe.length, clen = dataChe[0].length;
|
||||
|
||||
let addr = r1 + rlen - d.length, addc = c1 + clen - d[0].length;
|
||||
if(addr >0 || addc > 0){
|
||||
d = datagridgrowth([].concat(d), addr, addc, true);
|
||||
}
|
||||
|
||||
for(let r = r1; r <= r2; r++){
|
||||
for(let c = c1; c <= c2; c++){
|
||||
d[r][c] = null;
|
||||
}
|
||||
}
|
||||
|
||||
for(let i = 0; i < rlen; i++){
|
||||
for(let j = 0; j < clen; j++){
|
||||
d[r1 + i][c1 + j] = dataChe[i][j];
|
||||
}
|
||||
}
|
||||
|
||||
let range = [
|
||||
{ "row": [r1, r2], "column": [c1, c2] },
|
||||
{ "row": [r1, r1 + rlen - 1], "column": [c1, c1 + clen - 1] }
|
||||
];
|
||||
|
||||
jfrefreshgrid(d, range);
|
||||
}
|
||||
};
|
||||
|
||||
export default editor;
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,687 @@
|
||||
import { getObjType } from '../utils/util';
|
||||
import { isRealNum, isRealNull, valueIsError } from './validate';
|
||||
import { update } from './format';
|
||||
import formula from './formula';
|
||||
import dayjs from "dayjs";
|
||||
|
||||
const error = {
|
||||
v: "#VALUE!", //错误的参数或运算符
|
||||
n: "#NAME?", //公式名称错误
|
||||
na: "#N/A", //函数或公式中没有可用数值
|
||||
r: "#REF!", //删除了由其他公式引用的单元格
|
||||
d: "#DIV/0!", //除数是0或空单元格
|
||||
nm: "#NUM!", //当公式或函数中某个数字有问题时
|
||||
nl: "#NULL!", //交叉运算符(空格)使用不正确
|
||||
sp: "#SPILL!" //数组范围有其它值
|
||||
}
|
||||
|
||||
const func_methods = {
|
||||
//单元格数据生成一维数组
|
||||
getCellDataArr: function(rangeObj, nullCellType, isNeglectNullCell){
|
||||
let dataArr = [];
|
||||
|
||||
if(rangeObj.data == null){
|
||||
if(!isNeglectNullCell){
|
||||
if(nullCellType === "number"){
|
||||
dataArr.push(0);
|
||||
}
|
||||
else if(nullCellType === "text"){
|
||||
dataArr.push("");
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
if(getObjType(rangeObj.data) === "array"){
|
||||
for(let i = 0; i < rangeObj.data.length; i++){
|
||||
for(let j = 0; j < rangeObj.data[i].length; j++){
|
||||
let cell = rangeObj.data[i][j];
|
||||
let value = cell
|
||||
|
||||
if(getObjType(cell) === 'object'){
|
||||
value = cell.v
|
||||
}
|
||||
|
||||
if(value == null ){
|
||||
if(!isNeglectNullCell){
|
||||
if(nullCellType === "number"){
|
||||
value = 0;
|
||||
}
|
||||
else if(nullCellType === "text"){
|
||||
value = '';
|
||||
}
|
||||
|
||||
dataArr.push(value);
|
||||
}
|
||||
}
|
||||
else{
|
||||
dataArr.push(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
if(isRealNull(rangeObj.data.v)){
|
||||
if(!isNeglectNullCell){
|
||||
if(nullCellType == "number"){
|
||||
dataArr.push(0);
|
||||
}
|
||||
else if(nullCellType == "text"){
|
||||
dataArr.push("");
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
dataArr.push(rangeObj.data.v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return dataArr;
|
||||
},
|
||||
//单元格数据生成二维数组
|
||||
getCellDataDyadicArr: function(rangeObj, nullCellType){
|
||||
let dataArr = [];
|
||||
|
||||
if(rangeObj.data == null){
|
||||
let rowArr = [];
|
||||
|
||||
if(nullCellType == "number"){
|
||||
rowArr.push(0);
|
||||
}
|
||||
else if(nullCellType == "text"){
|
||||
rowArr.push("");
|
||||
}
|
||||
|
||||
dataArr.push(rowArr);
|
||||
}
|
||||
else{
|
||||
if(getObjType(rangeObj.data) == "array"){
|
||||
for(let i = 0; i < rangeObj.data.length; i++){
|
||||
let rowArr = [];
|
||||
|
||||
for(let j = 0; j < rangeObj.data[i].length; j++){
|
||||
let cell = rangeObj.data[i][j];
|
||||
let value = cell;
|
||||
|
||||
if(getObjType(cell) === 'object'){
|
||||
value = cell.v
|
||||
}
|
||||
|
||||
if(value == null){
|
||||
if(nullCellType === "number"){
|
||||
value = 0;
|
||||
}
|
||||
else if(nullCellType === "text"){
|
||||
value = '';
|
||||
}
|
||||
}
|
||||
|
||||
rowArr.push(value);
|
||||
}
|
||||
|
||||
dataArr.push(rowArr);
|
||||
}
|
||||
}
|
||||
else{
|
||||
let rowArr = [];
|
||||
|
||||
let value = rangeObj.data.v;
|
||||
|
||||
if(isRealNull(value)){
|
||||
if(nullCellType == "number"){
|
||||
value = 0;
|
||||
}
|
||||
else if(nullCellType == "text"){
|
||||
value = "";
|
||||
}
|
||||
}
|
||||
|
||||
rowArr.push(value);
|
||||
|
||||
dataArr.push(rowArr);
|
||||
}
|
||||
}
|
||||
|
||||
return dataArr;
|
||||
},
|
||||
//数组数据生成一维数组
|
||||
getDataArr: function(arr, isNeglectNaN){
|
||||
let dataArr = [];
|
||||
|
||||
if(isNeglectNaN == null){
|
||||
isNeglectNaN = false;
|
||||
}
|
||||
|
||||
if(getObjType(arr[0]) == "array"){
|
||||
for(let i = 0; i < arr.length; i++){
|
||||
for(let j = 0; j < arr[i].length; j++){
|
||||
if(isNeglectNaN && !isRealNum(arr[i][j])){
|
||||
continue;
|
||||
}
|
||||
|
||||
dataArr.push(arr[i][j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
for(let i = 0; i < arr.length; i++){
|
||||
if(isNeglectNaN && !isRealNum(arr[i])){
|
||||
continue;
|
||||
}
|
||||
|
||||
dataArr.push(arr[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return dataArr;
|
||||
},
|
||||
getDataDyadicArr: function(arr){
|
||||
let dataArr = [];
|
||||
|
||||
if(getObjType(arr[0]) == "array"){
|
||||
for(let i = 0; i < arr.length; i++){
|
||||
let rowArr = [];
|
||||
|
||||
for(let j = 0; j < arr[i].length; j++){
|
||||
rowArr.push(arr[i][j]);
|
||||
}
|
||||
|
||||
dataArr.push(rowArr);
|
||||
}
|
||||
}
|
||||
else{
|
||||
let rowArr = [];
|
||||
|
||||
for(let i = 0; i < arr.length; i++){
|
||||
rowArr.push(arr[i]);
|
||||
}
|
||||
|
||||
dataArr.push(rowArr);
|
||||
}
|
||||
|
||||
return dataArr;
|
||||
},
|
||||
//是否是规则二维数组
|
||||
isDyadicArr: function(arr){
|
||||
let isDyadic = true;
|
||||
|
||||
if(arr.length > 1){
|
||||
let collen = arr[0].length;
|
||||
|
||||
for(let i = 1; i < arr.length; i++){
|
||||
if(arr[i].length != collen){
|
||||
isDyadic = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return isDyadic;
|
||||
},
|
||||
//获取单个单元格数据,数组第一个值
|
||||
getFirstValue: function(data, nullCellType){
|
||||
let _this = this;
|
||||
|
||||
if(nullCellType == null){
|
||||
nullCellType = "number";
|
||||
}
|
||||
|
||||
let value;
|
||||
|
||||
if(getObjType(data) == "array"){
|
||||
if(getObjType(data[0]) == "array"){
|
||||
if(!_this.isDyadicArr(data)){
|
||||
return error.v;
|
||||
}
|
||||
|
||||
value = data[0][0];
|
||||
}
|
||||
else{
|
||||
value = data[0];
|
||||
}
|
||||
}
|
||||
else if(getObjType(data) == "object" && data.startCell != null){
|
||||
if(data.data == null){
|
||||
if(nullCellType == "number"){
|
||||
value = 0;
|
||||
}
|
||||
else if(nullCellType == "text"){
|
||||
value = "";
|
||||
}
|
||||
}
|
||||
else{
|
||||
let cell_r = window.luckysheetCurrentRow;
|
||||
let cell_c = window.luckysheetCurrentColumn;
|
||||
|
||||
if(data.rowl == 1 && data.coll == 1){
|
||||
value = data.data;
|
||||
|
||||
if(value == null || isRealNull(value.v)){
|
||||
if(nullCellType == "number"){
|
||||
value = 0;
|
||||
}
|
||||
else if(nullCellType == "text"){
|
||||
value = "";
|
||||
}
|
||||
}
|
||||
else{
|
||||
value = value.v;
|
||||
}
|
||||
}
|
||||
else{
|
||||
if(data.data[0][0].mc != null && data.data[0][0].mc.rs == data.rowl && data.data[0][0].mc.cs == data.coll){
|
||||
value = data.data[0][0];
|
||||
|
||||
if(value == null || isRealNull(value.v)){
|
||||
if(nullCellType == "number"){
|
||||
value = 0;
|
||||
}
|
||||
else if(nullCellType == "text"){
|
||||
value = "";
|
||||
}
|
||||
}
|
||||
else{
|
||||
value = value.v;
|
||||
}
|
||||
}
|
||||
else if(data.rowl == 1 || data.coll == 1){
|
||||
let cellrange = formula.getcellrange(data.startCell);
|
||||
let str = cellrange.row[0],
|
||||
edr = str + data.rowl - 1,
|
||||
stc = cellrange.column[0],
|
||||
edc = stc + data.coll - 1;
|
||||
|
||||
if(data.rowl == 1){
|
||||
if(cell_c < stc || cell_c > edc){
|
||||
return error.v;
|
||||
}
|
||||
|
||||
value = data.data[0][cell_c - stc];
|
||||
}
|
||||
else if(data.coll == 1){
|
||||
if(cell_r < str || cell_r > edr){
|
||||
return error.v;
|
||||
}
|
||||
|
||||
value = data.data[cell_r - str][0];
|
||||
}
|
||||
|
||||
if(value == null || isRealNull(value.v) || value.mc != null){
|
||||
if(nullCellType == "number"){
|
||||
value = 0;
|
||||
}
|
||||
else if(nullCellType == "text"){
|
||||
value = "";
|
||||
}
|
||||
}
|
||||
else{
|
||||
value = value.v;
|
||||
}
|
||||
}
|
||||
else{
|
||||
return error.v;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
value = data;
|
||||
}
|
||||
|
||||
return value;
|
||||
},
|
||||
//获取单元格的逻辑值
|
||||
getCellBoolen: function(data){
|
||||
let _this = this;
|
||||
|
||||
let cumulative = _this.getFirstValue(data);
|
||||
|
||||
if(valueIsError(cumulative)){
|
||||
return cumulative;
|
||||
}
|
||||
|
||||
if(getObjType(cumulative) == "boolean"){
|
||||
|
||||
}
|
||||
else if(getObjType(cumulative) == "string" && (cumulative.toLowerCase() == "true" || cumulative.toLowerCase() == "false")){
|
||||
if(cumulative.toLowerCase() == "true"){
|
||||
cumulative = true;
|
||||
}
|
||||
else if(cumulative.toLowerCase() == "false"){
|
||||
cumulative = false;
|
||||
}
|
||||
}
|
||||
else if(isRealNum(cumulative)){
|
||||
cumulative = parseFloat(cumulative);
|
||||
|
||||
cumulative = cumulative == 0 ? false : true;
|
||||
}
|
||||
else{
|
||||
return error.v;
|
||||
}
|
||||
|
||||
return cumulative;
|
||||
},
|
||||
//获取单元格的日期
|
||||
getCellDate: function(data){
|
||||
let _this = this;
|
||||
|
||||
let date_text;
|
||||
|
||||
if(getObjType(data) == "array"){
|
||||
if(getObjType(data[0]) == "array"){
|
||||
if(!_this.isDyadicArr(data)){
|
||||
return error.v;
|
||||
}
|
||||
|
||||
date_text = data[0][0];
|
||||
}
|
||||
else{
|
||||
date_text = data[0];
|
||||
}
|
||||
}
|
||||
else if(getObjType(data) == "object" && data.startCell != null){
|
||||
if(data.data == null || getObjType(data.data) == "array" || isRealNull(data.data.v)){
|
||||
return error.v;
|
||||
}
|
||||
|
||||
date_text = data.data.v;
|
||||
|
||||
if(data.data.ct != null && data.data.ct.t == "d"){
|
||||
date_text = update("YYYY-MM-DD h:mm:ss", date_text);
|
||||
}
|
||||
}
|
||||
else{
|
||||
date_text = data;
|
||||
}
|
||||
|
||||
return date_text;
|
||||
},
|
||||
getCellrangeDate: function(data){
|
||||
let _this = this;
|
||||
|
||||
let date = [];
|
||||
|
||||
if(getObjType(data) == "array"){
|
||||
if(getObjType(data[0]) == "array" && !_this.isDyadicArr(data)){
|
||||
return error.v;
|
||||
}
|
||||
|
||||
date = date.concat(_this.getDataArr(data, false));
|
||||
}
|
||||
else if(getObjType(data) == "object" && data.startCell != null){
|
||||
if(data.data == null){
|
||||
date.push(0);
|
||||
}
|
||||
else{
|
||||
if(getObjType(data.data) == "array"){
|
||||
for(let i = 0; i < data.data.length; i++){
|
||||
for(let j = 0; j < data.data[i].length; j++){
|
||||
if(data.data[i][j] != null && !isRealNull(data.data[i][j].v)){
|
||||
let value = data.data[i][j].v;
|
||||
|
||||
if(data.data[i][j].ct != null && data.data[i][j].ct.t == "d"){
|
||||
value = update("YYYY-MM-DD h:mm:ss", value);
|
||||
}
|
||||
|
||||
date.push(value);
|
||||
}
|
||||
else{
|
||||
date.push(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
let value = data.data.v;
|
||||
|
||||
if(data.data.ct != null && data.data.ct.t == "d"){
|
||||
value = update("YYYY-MM-DD h:mm:ss", value);
|
||||
}
|
||||
|
||||
date.push(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
date.push(data);
|
||||
}
|
||||
|
||||
return date;
|
||||
},
|
||||
//获取正则字符串(处理 . * ? ~* ~?)
|
||||
getRegExpStr: function(str){
|
||||
return str.replace("~*", "\\*").replace("~?", "\\?").replace(".", "\\.").replace("*", ".*").replace("?", ".");
|
||||
},
|
||||
//阶乘
|
||||
factorial: function(num){
|
||||
if (num == 0 || num == 1) {
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
return (num * this.factorial(num - 1));
|
||||
}
|
||||
},
|
||||
//双阶乘
|
||||
factorialDouble: function(num){
|
||||
if (num <= 0) {
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
return (num * this.factorialDouble(num - 2));
|
||||
}
|
||||
},
|
||||
//总体方差
|
||||
variance: function(num_arr){
|
||||
let sum = 0, count = 0;
|
||||
|
||||
for(let i = 0; i < num_arr.length; i++){
|
||||
let number = num_arr[i];
|
||||
|
||||
sum += number;
|
||||
count++;
|
||||
}
|
||||
|
||||
let avg = sum / count;
|
||||
|
||||
let sum_variance = 0;
|
||||
|
||||
for(let j = 0; j < num_arr.length; j++){
|
||||
let number = num_arr[j];
|
||||
|
||||
sum_variance += (number - avg) * (number - avg);
|
||||
}
|
||||
|
||||
return sum_variance / count;
|
||||
},
|
||||
//样本方差
|
||||
variance_s: function(num_arr){
|
||||
let sum = 0, count = 0;
|
||||
|
||||
for(let i = 0; i < num_arr.length; i++){
|
||||
let number = num_arr[i];
|
||||
|
||||
sum += number;
|
||||
count++;
|
||||
}
|
||||
|
||||
let avg = sum / count;
|
||||
|
||||
let sum_variance = 0;
|
||||
|
||||
for(let j = 0; j < num_arr.length; j++){
|
||||
let number = num_arr[j];
|
||||
|
||||
sum_variance += (number - avg) * (number - avg);
|
||||
}
|
||||
|
||||
return sum_variance / (count - 1);
|
||||
},
|
||||
//总体标准偏差
|
||||
standardDeviation: function(num_arr){
|
||||
let sum = 0, count = 0;
|
||||
|
||||
for(let i = 0; i < num_arr.length; i++){
|
||||
let number = num_arr[i];
|
||||
|
||||
sum += number;
|
||||
count++;
|
||||
}
|
||||
|
||||
let avg = sum / count;
|
||||
|
||||
let sum_variance = 0;
|
||||
|
||||
for(let j = 0; j < num_arr.length; j++){
|
||||
let number = num_arr[j];
|
||||
|
||||
sum_variance += (number - avg) * (number - avg);
|
||||
}
|
||||
|
||||
return Math.sqrt(sum_variance / count);
|
||||
},
|
||||
//样本标准偏差
|
||||
standardDeviation_s: function(num_arr){
|
||||
let sum = 0, count = 0;
|
||||
|
||||
for(let i = 0; i < num_arr.length; i++){
|
||||
let number = num_arr[i];
|
||||
|
||||
sum += number;
|
||||
count++;
|
||||
}
|
||||
|
||||
let avg = sum / count;
|
||||
|
||||
let sum_variance = 0;
|
||||
|
||||
for(let j = 0; j < num_arr.length; j++){
|
||||
let number = num_arr[j];
|
||||
|
||||
sum_variance += (number - avg) * (number - avg);
|
||||
}
|
||||
|
||||
return Math.sqrt(sum_variance / (count - 1));
|
||||
},
|
||||
//是否是闰年
|
||||
isLeapYear: function(year){
|
||||
return new Date(year, 1, 29).getMonth() === 1;
|
||||
},
|
||||
//2月是否有29
|
||||
feb29Between: function(date1, date2){
|
||||
let _this = this;
|
||||
|
||||
let year1 = dayjs(date1).year();
|
||||
let mar1year1 = dayjs().set({ 'year': year1, 'month': 2, 'date': 1 });
|
||||
|
||||
if (_this.isLeapYear(year1) && dayjs(date1) < dayjs(mar1year1) && dayjs(date2) >= dayjs(mar1year1)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
let year2 = dayjs(date2).year();
|
||||
let mar1year2 = dayjs().set({ 'year': year2, 'month': 2, 'date': 1 });
|
||||
|
||||
return (_this.isLeapYear(year2) && dayjs(date2) >= dayjs(mar1year2) && dayjs(date1) < dayjs(mar1year2));
|
||||
},
|
||||
//SQL 查询
|
||||
findResultIndex: function(database, criterias){
|
||||
let matches = {};
|
||||
|
||||
for (let i = 1; i < database[0].length; ++i) {
|
||||
matches[i] = true;
|
||||
}
|
||||
|
||||
let maxCriteriaLength = criterias[0].length;
|
||||
|
||||
for (i = 1; i < criterias.length; ++i) {
|
||||
if (criterias[i].length > maxCriteriaLength) {
|
||||
maxCriteriaLength = criterias[i].length;
|
||||
}
|
||||
}
|
||||
|
||||
for (let k = 1; k < database.length; ++k) {
|
||||
for (let l = 1; l < database[k].length; ++l) {
|
||||
let currentCriteriaResult = false;
|
||||
let hasMatchingCriteria = false;
|
||||
|
||||
for (let j = 0; j < criterias.length; ++j) {
|
||||
let criteria = criterias[j];
|
||||
|
||||
if (criteria.length < maxCriteriaLength) {
|
||||
continue;
|
||||
}
|
||||
|
||||
let criteriaField = criteria[0];
|
||||
|
||||
if (database[k][0] !== criteriaField) {
|
||||
continue;
|
||||
}
|
||||
|
||||
hasMatchingCriteria = true;
|
||||
|
||||
for (let p = 1; p < criteria.length; ++p) {
|
||||
currentCriteriaResult = currentCriteriaResult || (new Function("return " + database[k][l] + criteria[p])()); // jshint ignore:line
|
||||
}
|
||||
}
|
||||
|
||||
if (hasMatchingCriteria) {
|
||||
matches[l] = matches[l] && currentCriteriaResult;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let result = [];
|
||||
|
||||
for (let n = 0; n < database[0].length; ++n) {
|
||||
if (matches[n]) {
|
||||
result.push(n - 1);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
},
|
||||
findField: function(database, title){
|
||||
let index = null;
|
||||
|
||||
for (let i = 0; i < database.length; i++) {
|
||||
if (database[i][0] == title) {
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (index == null) {
|
||||
return error.v;
|
||||
}
|
||||
|
||||
return index;
|
||||
},
|
||||
rest: function(array, idx){
|
||||
idx = idx || 1;
|
||||
|
||||
if (!array || typeof array.slice !== 'function') {
|
||||
return array;
|
||||
}
|
||||
|
||||
return array.slice(idx);
|
||||
},
|
||||
compact: function(array){
|
||||
if (!array) {
|
||||
return array;
|
||||
}
|
||||
|
||||
let result = [];
|
||||
|
||||
for (let i = 0; i < array.length; ++i) {
|
||||
if (!array[i]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
result.push(array[i]);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
export default func_methods;
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,567 @@
|
||||
import { getObjType,rgbTohex } from '../utils/util';
|
||||
import { getSheetIndex } from '../methods/get';
|
||||
import server from '../controllers/server';
|
||||
import formula from './formula';
|
||||
import editor from './editor';
|
||||
import { dynamicArrayCompute } from './dynamicArray';
|
||||
import sheetmanage from '../controllers/sheetmanage';
|
||||
import { isInlineStringCT,isInlineStringCell,convertCssToStyleList } from '../controllers/inlineString';
|
||||
import locale from '../locale/locale';
|
||||
import Store from '../store';
|
||||
|
||||
//Get selection range value
|
||||
export function getdatabyselection(range, sheetIndex) {
|
||||
if(range == null){
|
||||
range = Store.luckysheet_select_save[0];
|
||||
}
|
||||
|
||||
if (range["row"] == null || range["row"].length == 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
//取数据
|
||||
let d, cfg;
|
||||
if(sheetIndex != null && sheetIndex != Store.currentSheetIndex){
|
||||
d = Store.luckysheetfile[getSheetIndex(sheetIndex)]["data"];
|
||||
cfg = Store.luckysheetfile[getSheetIndex(sheetIndex)]["config"];
|
||||
}
|
||||
else{
|
||||
d = editor.deepCopyFlowData(Store.flowdata);
|
||||
cfg = Store.config;
|
||||
}
|
||||
|
||||
let data = [];
|
||||
|
||||
for (let r = range["row"][0]; r <= range["row"][1]; r++) {
|
||||
if(d[r] == null){
|
||||
continue;
|
||||
}
|
||||
|
||||
if (cfg["rowhidden"] != null && cfg["rowhidden"][r] != null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
let row = [];
|
||||
|
||||
for (let c = range["column"][0]; c <= range["column"][1]; c++) {
|
||||
row.push(d[r][c]);
|
||||
}
|
||||
|
||||
data.push(row);
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
export function getdatabyselectionD(d, range) {
|
||||
if (range == null || range["row"] == null || range["row"].length == 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
let dynamicArray_compute = dynamicArrayCompute(Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)]["dynamicArray"]);
|
||||
let data = [];
|
||||
|
||||
if(d==null){
|
||||
return data;
|
||||
}
|
||||
|
||||
for (let r = range["row"][0]; r <= range["row"][1]; r++) {
|
||||
if(d[r] == null){
|
||||
continue;
|
||||
}
|
||||
|
||||
// if (Store.config["rowhidden"] != null && Store.config["rowhidden"][r] != null) {
|
||||
// continue;
|
||||
// }
|
||||
|
||||
let row = [];
|
||||
|
||||
for (let c = range["column"][0]; c <= range["column"][1]; c++) {
|
||||
let value;
|
||||
|
||||
if((r + "_" + c) in dynamicArray_compute){
|
||||
value = dynamicArray_compute[r + "_" + c];
|
||||
}
|
||||
else{
|
||||
value = d[r][c];
|
||||
}
|
||||
|
||||
row.push(value);
|
||||
}
|
||||
|
||||
data.push(row);
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
export function getdatabyselectionNoCopy(range) {
|
||||
if (range == null || range["row"] == null || range["row"].length == 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
let data = [];
|
||||
|
||||
for (let r = range["row"][0]; r <= range["row"][1]; r++) {
|
||||
let row = [];
|
||||
|
||||
if (Store.config["rowhidden"] != null && Store.config["rowhidden"][r] != null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (let c = range["column"][0]; c <= range["column"][1]; c++) {
|
||||
let value = "";
|
||||
|
||||
if (Store.flowdata[r] != null && Store.flowdata[r][c] != null) {
|
||||
value = Store.flowdata[r][c];
|
||||
}
|
||||
|
||||
row.push(value);
|
||||
}
|
||||
|
||||
data.push(row);
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
//Get the value of the cell
|
||||
export function getcellvalue(r, c, data, type) {
|
||||
if (type == null) {
|
||||
type = "v";
|
||||
}
|
||||
|
||||
if (data == null) {
|
||||
data = Store.flowdata;
|
||||
}
|
||||
|
||||
let d_value;
|
||||
|
||||
if (r != null && c != null) {
|
||||
d_value = data[r][c];
|
||||
}
|
||||
else if (r != null) {
|
||||
d_value = data[r];
|
||||
}
|
||||
else if (c != null) {
|
||||
let newData = data[0].map(function(col, i) {
|
||||
return data.map(function(row) {
|
||||
return row[i];
|
||||
})
|
||||
});
|
||||
d_value = newData[c];
|
||||
}
|
||||
else {
|
||||
return data;
|
||||
}
|
||||
|
||||
let retv = d_value;
|
||||
|
||||
if(getObjType(d_value) == "object"){
|
||||
retv = d_value[type];
|
||||
|
||||
if (type == "f" && retv != null) {
|
||||
retv = formula.functionHTMLGenerate(retv);
|
||||
}
|
||||
else if(type == "f") {
|
||||
retv = d_value["v"];
|
||||
}
|
||||
// fix conditionalFormat "occurrenceDate" => "2023-05-17 to 2023-05-19"
|
||||
// else if(d_value && d_value.ct && d_value.ct.t == 'd') {
|
||||
// retv = d_value.m;
|
||||
// }
|
||||
}
|
||||
|
||||
if(retv == undefined){
|
||||
retv = null;
|
||||
}
|
||||
|
||||
return retv;
|
||||
}
|
||||
|
||||
//Data increase in rows and columns
|
||||
export function datagridgrowth(data, addr, addc, iscallback) {
|
||||
if (addr <= 0 && addc <= 0) {
|
||||
return data;
|
||||
}
|
||||
|
||||
if (addr <= 0) {
|
||||
addr = 0;
|
||||
}
|
||||
|
||||
if (addc <= 0) {
|
||||
addc = 0;
|
||||
}
|
||||
|
||||
let dataClen = 0;
|
||||
if (data.length == 0) {
|
||||
data = [];
|
||||
dataClen = 0;
|
||||
}
|
||||
else {
|
||||
dataClen = data[0].length;
|
||||
}
|
||||
|
||||
let coladd = [];//需要额外增加的空列
|
||||
for (let c = 0; c < addc; c++) {
|
||||
coladd.push(null);
|
||||
}
|
||||
|
||||
let rowadd = [];//完整的一个空行
|
||||
for (let r = 0; r < dataClen + addc; r++) {
|
||||
rowadd.push(null);
|
||||
}
|
||||
|
||||
// 下面循环非常耗时, 在coladd为空时是无用循环
|
||||
if (coladd && coladd.length) {
|
||||
for (let r = 0; r < data.length; r++) {
|
||||
data[r] = [].concat(data[r].concat(coladd));
|
||||
}
|
||||
}
|
||||
|
||||
for (let r = 0; r < addr; r++) {
|
||||
data.push([].concat(rowadd));
|
||||
}
|
||||
|
||||
if(!!iscallback){
|
||||
server.saveParam("all", Store.currentSheetIndex, data.length, { "k": "row" });
|
||||
server.saveParam("all", Store.currentSheetIndex, data[0].length, { "k": "column" });
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
//Get the formula of the cell
|
||||
export function getcellFormula(r, c, i, data) {
|
||||
let cell;
|
||||
if(data!=null){
|
||||
cell = data[r][c];
|
||||
}
|
||||
else{
|
||||
cell = getOrigincell(r,c,i);
|
||||
}
|
||||
|
||||
|
||||
if(cell==null){
|
||||
return null;
|
||||
}
|
||||
|
||||
return cell.f;
|
||||
}
|
||||
|
||||
|
||||
export function getOrigincell(r, c, i) {
|
||||
if(r==null || c==null){
|
||||
return;
|
||||
}
|
||||
let data;
|
||||
if (i == null) {
|
||||
data = Store.flowdata;
|
||||
}
|
||||
else{
|
||||
let sheet = sheetmanage.getSheetByIndex(i);
|
||||
data = sheet.data;
|
||||
}
|
||||
|
||||
if(!data || !data[r] || !data[r][c]){
|
||||
return;
|
||||
}
|
||||
|
||||
return data[r][c];
|
||||
|
||||
|
||||
}
|
||||
|
||||
export function getRealCellValue(r, c){
|
||||
let value = getcellvalue(r, c, null, "m");
|
||||
if(value == null){
|
||||
value = getcellvalue(r, c);
|
||||
if(value==null){
|
||||
let ct = getcellvalue(r, c, null, "ct");
|
||||
if(isInlineStringCT(ct)){
|
||||
value = ct.s;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
export function getInlineStringNoStyle(r, c){
|
||||
let ct = getcellvalue(r, c, null, "ct");
|
||||
if(isInlineStringCT(ct)){
|
||||
let strings = ct.s, value="";
|
||||
for(let i=0;i<strings.length;i++){
|
||||
let strObj = strings[i];
|
||||
if(strObj.v!=null){
|
||||
value += strObj.v;
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
export function getInlineStringStyle(r, c, data){
|
||||
let ct = getcellvalue(r, c, data, "ct");
|
||||
if (data == null) {
|
||||
data = Store.flowdata;
|
||||
}
|
||||
let cell = data[r][c];
|
||||
if(isInlineStringCT(ct)){
|
||||
let strings = ct.s, value="";
|
||||
for(let i=0;i<strings.length;i++){
|
||||
let strObj = strings[i];
|
||||
if(strObj.v!=null){
|
||||
let style = getFontStyleByCell(strObj);
|
||||
value += "<span index='"+ i +"' style='"+ style +"'>" + strObj.v + "</span>";
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
export function getFontStyleByCell(cell,checksAF,checksCF, isCheck=true){
|
||||
if(cell==null){
|
||||
return;
|
||||
}
|
||||
let style = "";
|
||||
const _locale = locale();
|
||||
const locale_fontarray = _locale.fontarray;
|
||||
for(let key in cell){
|
||||
let value = cell[key];
|
||||
if(isCheck){
|
||||
value = checkstatusByCell(cell, key);
|
||||
}
|
||||
if(key == "bl" && value != "0"){
|
||||
style += "font-weight: bold;";
|
||||
}
|
||||
|
||||
if(key == "it" && value != "0"){
|
||||
style += "font-style:italic;";
|
||||
}
|
||||
|
||||
if(key == "ff"){
|
||||
let f = value;
|
||||
if(!isNaN(parseInt(value))){
|
||||
f = locale_fontarray[parseInt(value)];
|
||||
}
|
||||
else{
|
||||
f = value;
|
||||
}
|
||||
style += "font-family: " + f + ";";
|
||||
}
|
||||
|
||||
if(key == "fs"){
|
||||
style += "font-size: "+ value + "pt;";
|
||||
}
|
||||
|
||||
if((key == "fc" && value != "#000000") || checksAF != null || (checksCF != null && checksCF["textColor"] != null)){
|
||||
if(checksCF != null && checksCF["textColor"] != null){
|
||||
style += "color: " + checksCF["textColor"] + ";";
|
||||
}
|
||||
else if(checksAF != null){
|
||||
style += "color: " + checksAF[0] + ";";
|
||||
}
|
||||
else{
|
||||
style += "color: " + value + ";";
|
||||
}
|
||||
}
|
||||
|
||||
if(key == "cl" && value != "0"){
|
||||
style += "text-decoration: line-through;";
|
||||
}
|
||||
|
||||
}
|
||||
return style;
|
||||
}
|
||||
|
||||
export function checkstatusByCell(cell, a){
|
||||
let foucsStatus =cell;
|
||||
let tf = {"bl":1, "it":1 , "ff":1, "cl":1, "un":1};
|
||||
|
||||
if(a in tf || (a=="fs" && isInlineStringCell(cell)) ){
|
||||
if(foucsStatus == null){
|
||||
foucsStatus = "0";
|
||||
}
|
||||
else{
|
||||
// var w = window.getSelection(), isInlineEdit=false;
|
||||
// if(w.type!="None"){
|
||||
// var range = w.getRangeAt(0);
|
||||
// let startContainer = range.startContainer;
|
||||
// if (parseInt($("#luckysheet-input-box").css("top")) > 0 && startContainer.parentNode.tagName=="SPAN" && !range.collapsed) {
|
||||
// let span = startContainer.parentNode;
|
||||
// let styleList = convertCssToStyleList(span.style.cssText);
|
||||
// foucsStatus = styleList[a];
|
||||
// isInlineEdit = true;
|
||||
// }
|
||||
// }
|
||||
|
||||
// if(!isInlineEdit){
|
||||
// if(isInlineStringCell(cell)){
|
||||
// foucsStatus = cell.ct.s[0][a];
|
||||
// }
|
||||
// else{
|
||||
// foucsStatus = foucsStatus[a];
|
||||
// }
|
||||
// }
|
||||
|
||||
foucsStatus = foucsStatus[a];
|
||||
|
||||
if(foucsStatus == null){
|
||||
foucsStatus = "0";
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(a == "fc"){
|
||||
if(foucsStatus == null){
|
||||
foucsStatus = "#000000";
|
||||
}
|
||||
else{
|
||||
foucsStatus = foucsStatus[a];
|
||||
|
||||
if(foucsStatus == null){
|
||||
foucsStatus = "#000000";
|
||||
}
|
||||
|
||||
if(foucsStatus.indexOf("rgba") > -1){
|
||||
foucsStatus = rgbTohex(foucsStatus);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(a == "bg"){
|
||||
if(foucsStatus == null){
|
||||
foucsStatus = null;
|
||||
}
|
||||
else{
|
||||
foucsStatus = foucsStatus[a];
|
||||
|
||||
if(foucsStatus == null){
|
||||
foucsStatus = null;
|
||||
}
|
||||
else if(foucsStatus.toString().indexOf("rgba") > -1){
|
||||
foucsStatus = rgbTohex(foucsStatus);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(a.substr(0, 2) == "bs"){
|
||||
if(foucsStatus == null){
|
||||
foucsStatus = "none";
|
||||
}
|
||||
else{
|
||||
foucsStatus = foucsStatus[a];
|
||||
if(foucsStatus == null){
|
||||
foucsStatus = "none";
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(a.substr(0, 2) == "bc"){
|
||||
if(foucsStatus == null){
|
||||
foucsStatus = "#000000";
|
||||
}
|
||||
else{
|
||||
foucsStatus = foucsStatus[a];
|
||||
if(foucsStatus == null){
|
||||
foucsStatus = "#000000";
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(a == "ht"){
|
||||
if(foucsStatus == null){
|
||||
foucsStatus = "1";
|
||||
}
|
||||
else{
|
||||
foucsStatus = foucsStatus[a];
|
||||
if(foucsStatus == null){
|
||||
foucsStatus = "1";
|
||||
}
|
||||
}
|
||||
|
||||
if(["0", "1", "2"].indexOf(foucsStatus.toString()) == -1){
|
||||
foucsStatus = "1";
|
||||
}
|
||||
}
|
||||
else if(a == "vt"){//默认垂直居中
|
||||
if(foucsStatus == null){
|
||||
foucsStatus = "0";
|
||||
}
|
||||
else{
|
||||
foucsStatus = foucsStatus[a];
|
||||
if(foucsStatus == null){
|
||||
foucsStatus = "0";
|
||||
}
|
||||
}
|
||||
|
||||
if(["0", "1", "2"].indexOf(foucsStatus.toString()) == -1){
|
||||
foucsStatus = "0";
|
||||
}
|
||||
}
|
||||
else if(a == "ct"){
|
||||
if(foucsStatus == null){
|
||||
foucsStatus = null;
|
||||
}
|
||||
else{
|
||||
foucsStatus = foucsStatus[a];
|
||||
if(foucsStatus == null){
|
||||
foucsStatus = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(a == "fs"){
|
||||
if(foucsStatus == null){
|
||||
foucsStatus = String(Store.defaultFontSize);
|
||||
}
|
||||
else{
|
||||
foucsStatus = foucsStatus[a];
|
||||
if(foucsStatus == null){
|
||||
foucsStatus = String(Store.defaultFontSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(a == "tb"){
|
||||
if(foucsStatus == null){
|
||||
foucsStatus = "0";
|
||||
}
|
||||
else{
|
||||
foucsStatus = foucsStatus[a];
|
||||
if(foucsStatus == null){
|
||||
foucsStatus = "0";
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(a == "tr"){
|
||||
if(foucsStatus == null){
|
||||
foucsStatus = "0";
|
||||
}
|
||||
else{
|
||||
foucsStatus = foucsStatus[a];
|
||||
if(foucsStatus == null){
|
||||
foucsStatus = "0";
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(a == "rt"){
|
||||
if(foucsStatus == null){
|
||||
foucsStatus = null;
|
||||
}
|
||||
else{
|
||||
foucsStatus = foucsStatus[a];
|
||||
if(foucsStatus == null){
|
||||
foucsStatus = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return foucsStatus;
|
||||
}
|
||||
|
||||
export function textTrim(x) {
|
||||
if(x==null || x.length==0){
|
||||
return x;
|
||||
}
|
||||
return x.replace(/^\s+|\s+$/gm,'');
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
import { getObjType } from '../utils/util';
|
||||
|
||||
const json = {
|
||||
parseJsonParm: function(obj){
|
||||
if(obj == null){
|
||||
return {};
|
||||
}
|
||||
else if(getObjType(obj) == "string"){
|
||||
try {
|
||||
let json = new Function("return " + obj)();
|
||||
return json;
|
||||
}
|
||||
catch(e) {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
else{
|
||||
return obj;
|
||||
}
|
||||
},
|
||||
hasKey: function(obj){
|
||||
let _this = this;
|
||||
let json = _this.parseJsonParm(obj);
|
||||
|
||||
for(let item in json){
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export default json;
|
||||
@@ -0,0 +1,7 @@
|
||||
export function showloading(txt) {
|
||||
$("#luckysheet-cell-loading").find("span").text(txt).end().show();
|
||||
};
|
||||
|
||||
export function hideloading() {
|
||||
$("#luckysheet-cell-loading").hide();
|
||||
};
|
||||
@@ -0,0 +1,88 @@
|
||||
import { luckysheet_searcharray } from '../controllers/sheetSearch';
|
||||
import Store from '../store';
|
||||
|
||||
function rowLocationByIndex(row_index) {
|
||||
let row = 0, row_pre = 0;
|
||||
row = Store.visibledatarow[row_index];
|
||||
|
||||
if (row_index == 0) {
|
||||
row_pre = 0;
|
||||
}
|
||||
else {
|
||||
row_pre = Store.visibledatarow[row_index - 1];
|
||||
}
|
||||
|
||||
return [row_pre, row, row_index];
|
||||
}
|
||||
|
||||
function rowLocation(y) {
|
||||
let row_index = luckysheet_searcharray(Store.visibledatarow, y);
|
||||
|
||||
if (row_index == -1 && y > 0) {
|
||||
row_index = Store.visibledatarow.length - 1;
|
||||
}
|
||||
else if (row_index == -1 && y <= 0) {
|
||||
row_index = 0;
|
||||
}
|
||||
|
||||
return rowLocationByIndex(row_index);
|
||||
}
|
||||
|
||||
function colLocationByIndex(col_index){
|
||||
let col = 0, col_pre = 0;
|
||||
col = Store.visibledatacolumn[col_index];
|
||||
|
||||
if (col_index == 0) {
|
||||
col_pre = 0;
|
||||
}
|
||||
else {
|
||||
col_pre = Store.visibledatacolumn[col_index - 1];
|
||||
}
|
||||
|
||||
return [col_pre, col, col_index];
|
||||
}
|
||||
|
||||
function colSpanLocationByIndex(col_index, span){
|
||||
let col = 0, col_pre = 0;
|
||||
col = Store.visibledatacolumn[col_index + span - 1];
|
||||
|
||||
if (col_index == 0) {
|
||||
col_pre = 0;
|
||||
}
|
||||
else {
|
||||
col_pre = Store.visibledatacolumn[col_index - 1];
|
||||
}
|
||||
|
||||
return [col_pre, col, col_index];
|
||||
}
|
||||
|
||||
function colLocation(x) {
|
||||
let col_index = luckysheet_searcharray(Store.visibledatacolumn, x);
|
||||
|
||||
if (col_index == -1 && x > 0) {
|
||||
col_index = Store.visibledatacolumn.length - 1;
|
||||
}
|
||||
else if (col_index == -1 && x <= 0) {
|
||||
col_index = 0;
|
||||
}
|
||||
|
||||
return colLocationByIndex(col_index);
|
||||
}
|
||||
|
||||
function mouseposition(x, y) {
|
||||
let container_offset = $("#" + Store.container).offset();
|
||||
|
||||
let newX = x - container_offset.left - Store.rowHeaderWidth,
|
||||
newY = y - container_offset.top - Store.infobarHeight - Store.toolbarHeight - Store.calculatebarHeight - Store.columnHeaderHeight;
|
||||
|
||||
return [newX, newY];
|
||||
}
|
||||
|
||||
export {
|
||||
rowLocationByIndex,
|
||||
rowLocation,
|
||||
colLocationByIndex,
|
||||
colSpanLocationByIndex,
|
||||
colLocation,
|
||||
mouseposition,
|
||||
}
|
||||
@@ -0,0 +1,529 @@
|
||||
import server from '../controllers/server';
|
||||
import { luckysheetlodingHTML, luckyColor } from '../controllers/constant';
|
||||
import sheetmanage from '../controllers/sheetmanage';
|
||||
import luckysheetformula from './formula';
|
||||
import imageCtrl from '../controllers/imageCtrl';
|
||||
import dataVerificationCtrl from '../controllers/dataVerificationCtrl';
|
||||
import pivotTable from '../controllers/pivotTable';
|
||||
import luckysheetFreezen from '../controllers/freezen';
|
||||
import { getSheetIndex } from '../methods/get';
|
||||
import { luckysheetextendData } from './extend';
|
||||
import luckysheetConfigsetting from '../controllers/luckysheetConfigsetting';
|
||||
import editor from './editor';
|
||||
import luckysheetcreatesheet from './createsheet';
|
||||
import Store from '../store';
|
||||
|
||||
const defaultConfig = {
|
||||
defaultStore:{
|
||||
container: null,
|
||||
luckysheetfile: null,
|
||||
defaultcolumnNum: 60,
|
||||
defaultrowNum: 84,
|
||||
fullscreenmode: true,
|
||||
devicePixelRatio: 1,
|
||||
|
||||
currentSheetIndex: 0,
|
||||
calculateSheetIndex: 0,
|
||||
flowdata: [],
|
||||
config: {},
|
||||
|
||||
visibledatarow: [],
|
||||
visibledatacolumn: [],
|
||||
ch_width: 0,
|
||||
rh_height: 0,
|
||||
|
||||
cellmainWidth: 0,
|
||||
cellmainHeight: 0,
|
||||
toolbarHeight: 0,
|
||||
infobarHeight: 0,
|
||||
calculatebarHeight: 0,
|
||||
rowHeaderWidth: 46,
|
||||
columnHeaderHeight: 20,
|
||||
cellMainSrollBarSize: 12,
|
||||
sheetBarHeight: 31,
|
||||
statisticBarHeight: 23,
|
||||
luckysheetTableContentHW: [0, 0],
|
||||
|
||||
defaultcollen: 73,
|
||||
defaultrowlen: 19,
|
||||
|
||||
jfcountfuncTimeout: null,
|
||||
jfautoscrollTimeout: null,
|
||||
|
||||
luckysheet_select_status: false,
|
||||
luckysheet_select_save: [{ "row": [0, 0], "column": [0, 0] }],
|
||||
luckysheet_selection_range: [],
|
||||
|
||||
luckysheet_copy_save: {}, //复制粘贴
|
||||
luckysheet_paste_iscut: false,
|
||||
|
||||
filterchage: true, //筛选
|
||||
luckysheet_filter_save: { "row": [], "column": [] },
|
||||
|
||||
luckysheet_sheet_move_status: false,
|
||||
luckysheet_sheet_move_data: [],
|
||||
luckysheet_scroll_status: false,
|
||||
|
||||
luckysheetisrefreshdetail: true,
|
||||
luckysheetisrefreshtheme: true,
|
||||
luckysheetcurrentisPivotTable: false,
|
||||
|
||||
luckysheet_rows_selected_status: false, //行列标题相关参
|
||||
luckysheet_cols_selected_status: false,
|
||||
luckysheet_rows_change_size: false,
|
||||
luckysheet_rows_change_size_start: [],
|
||||
luckysheet_cols_change_size: false,
|
||||
luckysheet_cols_change_size_start: [],
|
||||
luckysheet_cols_dbclick_timeout: null,
|
||||
luckysheet_cols_dbclick_times: 0,
|
||||
|
||||
luckysheetCellUpdate: [],
|
||||
|
||||
luckysheet_shiftpositon: null,
|
||||
|
||||
iscopyself: true,
|
||||
|
||||
orderbyindex: 0, //排序下标
|
||||
|
||||
luckysheet_model_move_state: false, //模态框拖动
|
||||
luckysheet_model_xy: [0, 0],
|
||||
luckysheet_model_move_obj: null,
|
||||
|
||||
luckysheet_cell_selected_move: false, //选区拖动替换
|
||||
luckysheet_cell_selected_move_index: [],
|
||||
|
||||
luckysheet_cell_selected_extend: false, //选区下拉
|
||||
luckysheet_cell_selected_extend_index: [],
|
||||
luckysheet_cell_selected_extend_time: null,
|
||||
|
||||
clearjfundo: true,
|
||||
jfredo: [],
|
||||
jfundo: [],
|
||||
lang: 'en', //language
|
||||
createChart: '',
|
||||
highlightChart: '',
|
||||
zIndex: 15,
|
||||
chartparam: {
|
||||
luckysheetCurrentChart: null, //current chart_id
|
||||
luckysheetCurrentChartActive: false,
|
||||
luckysheetCurrentChartMove: null, // Debounce state
|
||||
luckysheetCurrentChartMoveTimeout: null,//拖动图表框的节流定时器
|
||||
luckysheetCurrentChartMoveObj: null, //chart DOM object
|
||||
luckysheetCurrentChartMoveXy: null, //上一次操作结束的图表信息,x,y: chart框位置,scrollLeft1,scrollTop1: 滚动条位置
|
||||
luckysheetCurrentChartMoveWinH: null, //左右滚动条滑动距离
|
||||
luckysheetCurrentChartMoveWinW: null, //上下滚动条滑动距离
|
||||
luckysheetCurrentChartResize: null,
|
||||
luckysheetCurrentChartResizeObj: null,
|
||||
luckysheetCurrentChartResizeXy: null,
|
||||
luckysheetCurrentChartResizeWinH: null,
|
||||
luckysheetCurrentChartResizeWinW: null,
|
||||
luckysheetInsertChartTosheetChange: true, // 正在执行撤销
|
||||
luckysheetCurrentChartZIndexRank : 100,
|
||||
luckysheet_chart_redo_click:false, //撤销重做时标识
|
||||
luckysheetCurrentChartMaxState: false, //图表全屏状态
|
||||
jfrefreshchartall: '',
|
||||
changeChartCellData: '',
|
||||
renderChart: '',
|
||||
getChartJson: ''
|
||||
},
|
||||
functionList:null, //function list explanation
|
||||
luckysheet_function:null,
|
||||
chart_selection: {},
|
||||
currentChart: '',
|
||||
scrollRefreshSwitch:true,
|
||||
|
||||
measureTextCache:{},
|
||||
measureTextCellInfoCache:{},
|
||||
measureTextCacheTimeOut:null,
|
||||
cellOverflowMapCache:{},
|
||||
|
||||
zoomRatio:1,
|
||||
|
||||
visibledatacolumn_unique:null,
|
||||
visibledatarow_unique:null,
|
||||
|
||||
showGridLines:true,
|
||||
|
||||
toobarObject: {}, //toolbar constant
|
||||
inlineStringEditCache:null,
|
||||
inlineStringEditRange:null,
|
||||
|
||||
fontList:[],
|
||||
|
||||
currentSheetView:"viewNormal",
|
||||
|
||||
},
|
||||
defaultFormula:{
|
||||
searchFunctionCell: null,
|
||||
functionlistPosition: {},
|
||||
rangechangeindex: null,
|
||||
rangestart: false,
|
||||
rangetosheet: null,
|
||||
rangeSetValueTo: null,
|
||||
func_selectedrange: {}, //函数选区范围
|
||||
rangedrag_column_start: false,
|
||||
rangedrag_row_start: false,
|
||||
rangeResizeObj: null,
|
||||
rangeResize: null,
|
||||
rangeResizeIndex: null,
|
||||
rangeResizexy: null,
|
||||
rangeResizeWinH: null,
|
||||
rangeResizeWinW: null,
|
||||
rangeResizeTo: null,
|
||||
rangeMovexy: null,
|
||||
rangeMove: false,
|
||||
rangeMoveObj: null,
|
||||
rangeMoveIndex: null,
|
||||
rangeMoveRangedata: null,
|
||||
functionHTMLIndex: 0,
|
||||
functionRangeIndex: null,
|
||||
execvertex: {},
|
||||
execFunctionGroupData: null,
|
||||
execFunctionExist: null,
|
||||
formulaContainSheetList:{},
|
||||
cellTextToIndexList:{},
|
||||
isFunctionRangeSave: false,
|
||||
formulaContainCellList:{},
|
||||
execFunctionGlobalData:{},
|
||||
groupValuesRefreshData: [],
|
||||
functionResizeData: {},
|
||||
functionResizeStatus: false,
|
||||
functionResizeTimeout: null,
|
||||
data_parm_index: 0 //选择公式后参数索引标记
|
||||
},
|
||||
defaultSheet:{
|
||||
sheetMaxIndex: 0,
|
||||
nulldata: null,
|
||||
mergeCalculationSheet:{},
|
||||
checkLoadSheetIndexToDataIndex:{},
|
||||
CacheNotLoadControll:[],
|
||||
},
|
||||
defaultPivotTable:{
|
||||
pivotDatas: null,
|
||||
pivotSheetIndex: 0,
|
||||
pivotDataSheetIndex: 0,
|
||||
celldata: null,
|
||||
origindata: null,
|
||||
pivot_data_type: {},
|
||||
pivot_select_save: null,
|
||||
column: null,
|
||||
row: null,
|
||||
values: null,
|
||||
filter: null,
|
||||
showType: null,
|
||||
rowhidden: null,
|
||||
selected: null,
|
||||
caljs: null,
|
||||
initial: true,
|
||||
filterparm: null,
|
||||
luckysheet_pivotTable_select_state: false,
|
||||
jgridCurrentPivotInput: null,
|
||||
movestate: false,
|
||||
moveitemposition: [],
|
||||
movesave: {},
|
||||
drawPivotTable: true,
|
||||
pivotTableBoundary: [12, 6],
|
||||
},
|
||||
defaultImage:{
|
||||
imgItem: {
|
||||
type: '3', //1移动并调整单元格大小 2移动并且不调整单元格的大小 3不要移动单元格并调整其大小
|
||||
src: '', //图片url
|
||||
originWidth: null, //图片原始宽度
|
||||
originHeight: null, //图片原始高度
|
||||
default: {
|
||||
width: null, //图片 宽度
|
||||
height: null, //图片 高度
|
||||
left: null, //图片离表格左边的 位置
|
||||
top: null, //图片离表格顶部的 位置
|
||||
},
|
||||
crop: {
|
||||
width: null, //图片裁剪后 宽度
|
||||
height: null, //图片裁剪后 高度
|
||||
offsetLeft: 0, //图片裁剪后离未裁剪时 左边的位移
|
||||
offsetTop: 0, //图片裁剪后离未裁剪时 顶部的位移
|
||||
},
|
||||
isFixedPos: false, //固定位置
|
||||
fixedLeft: null, //固定位置 左位移
|
||||
fixedTop: null, //固定位置 右位移
|
||||
border: {
|
||||
width: 0, //边框宽度
|
||||
radius: 0, //边框半径
|
||||
style: 'solid', //边框类型
|
||||
color: '#000', //边框颜色
|
||||
}
|
||||
},
|
||||
images: null,
|
||||
currentImgId: null,
|
||||
currentWinW: null,
|
||||
currentWinH: null,
|
||||
resize: null,
|
||||
resizeXY: null,
|
||||
move: false,
|
||||
moveXY: null,
|
||||
cropChange: null,
|
||||
cropChangeXY: null,
|
||||
cropChangeObj: null,
|
||||
copyImgItemObj: null,
|
||||
},
|
||||
defaultDataVerification:{
|
||||
defaultItem: {
|
||||
type: 'dropdown', //类型
|
||||
type2: null, //
|
||||
value1: '', //
|
||||
value2: '', //
|
||||
checked: false,
|
||||
remote: false, //自动远程获取选项
|
||||
prohibitInput: false, //输入数据无效时禁止输入
|
||||
hintShow: false, //选中单元格时显示提示语
|
||||
hintText: '', //
|
||||
},
|
||||
curItem: null,
|
||||
dataVerification: null,
|
||||
selectRange: [],
|
||||
selectStatus: false,
|
||||
}
|
||||
}
|
||||
|
||||
const method = {
|
||||
//翻页
|
||||
addDataAjax: function(param, index, url, func){
|
||||
let _this = this;
|
||||
|
||||
if(index == null){
|
||||
index = Store.currentSheetIndex;
|
||||
}
|
||||
|
||||
if(url == null){
|
||||
url = server.loadSheetUrl;
|
||||
}
|
||||
|
||||
$("#luckysheet-grid-window-1").append(luckysheetlodingHTML());
|
||||
param.currentPage++;
|
||||
|
||||
let dataType = 'application/json;charset=UTF-8';
|
||||
let token = sessionStorage.getItem('x-auth-token');
|
||||
|
||||
$.ajax({
|
||||
method: 'POST',
|
||||
url: url,
|
||||
headers: { "x-auth-token": token },
|
||||
data: JSON.stringify(param),
|
||||
contentType: dataType,
|
||||
success: function(d) {
|
||||
//d可能为json字符串
|
||||
if(typeof d == "string"){
|
||||
d = JSON.parse(d);
|
||||
}
|
||||
|
||||
let dataset = d.data;
|
||||
|
||||
let newData = dataset.celldata;
|
||||
luckysheetextendData(dataset["row"], newData);
|
||||
|
||||
setTimeout(function(){
|
||||
Store.loadingObj.close()
|
||||
}, 500);
|
||||
|
||||
if(func && typeof(func)=="function"){
|
||||
func(dataset);
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
//重载
|
||||
reload: function(param, index, url, func){
|
||||
let _this = this;
|
||||
|
||||
if(index == null){
|
||||
index = Store.currentSheetIndex;
|
||||
}
|
||||
|
||||
if(url == null){
|
||||
url = server.loadSheetUrl;
|
||||
}
|
||||
|
||||
$("#luckysheet-grid-window-1").append(luckysheetlodingHTML());
|
||||
|
||||
let arg = {"gridKey" : server.gridKey, "index": index};
|
||||
param = $.extend(true, param, arg);
|
||||
let file = Store.luckysheetfile[getSheetIndex(index)];
|
||||
|
||||
$.post(url, param, function (d) {
|
||||
let dataset = new Function("return " + d)();
|
||||
file.celldata = dataset[index.toString()];
|
||||
let data = sheetmanage.buildGridData(file);
|
||||
|
||||
setTimeout(function(){
|
||||
Store.loadingObj.close()
|
||||
}, 500);
|
||||
|
||||
file["data"] = data;
|
||||
Store.flowdata = data;
|
||||
editor.webWorkerFlowDataCache(data);//worker存数据
|
||||
|
||||
luckysheetcreatesheet(data[0].length, data.length, data, null, false);
|
||||
file["load"] = "1";
|
||||
|
||||
Store.luckysheet_select_save.length = 0;
|
||||
Store.luckysheet_selection_range = [];
|
||||
|
||||
server.saveParam("shs", null, Store.currentSheetIndex);
|
||||
|
||||
sheetmanage.changeSheet(index);
|
||||
|
||||
if(func && typeof(func)=="function"){
|
||||
func();
|
||||
}
|
||||
});
|
||||
},
|
||||
clearSheetByIndex: function(i){
|
||||
let index = getSheetIndex(i);
|
||||
let sheetfile = Store.luckysheetfile[index];
|
||||
|
||||
if(!sheetfile.isPivotTable){
|
||||
sheetfile.data = [];
|
||||
sheetfile.row = Store.defaultrowNum;
|
||||
sheetfile.column = Store.defaultcolumnNum;
|
||||
|
||||
sheetfile.chart = [];
|
||||
sheetfile.config = null;
|
||||
sheetfile.filter = null;
|
||||
sheetfile.filter_select = null;
|
||||
sheetfile.celldata = [];
|
||||
sheetfile.pivotTable = {};
|
||||
sheetfile.calcChain = [];
|
||||
sheetfile.status = 0;
|
||||
sheetfile.load = 0;
|
||||
|
||||
Store.flowdata = [];
|
||||
editor.webWorkerFlowDataCache(Store.flowdata);//worker存数据
|
||||
|
||||
$("#"+ Store.container +" .luckysheet-data-visualization-chart").remove();
|
||||
$("#"+ Store.container +" .luckysheet-datavisual-selection-set").remove();
|
||||
|
||||
$("#luckysheet-row-count-show, #luckysheet-formula-functionrange-select, #luckysheet-row-count-show, #luckysheet-column-count-show, #luckysheet-change-size-line, #luckysheet-cell-selected-focus, #luckysheet-selection-copy, #luckysheet-cell-selected-extend, #luckysheet-cell-selected-move, #luckysheet-cell-selected").hide();
|
||||
|
||||
delete sheetfile.load;
|
||||
}
|
||||
else {
|
||||
delete Store.luckysheetfile[index];
|
||||
}
|
||||
},
|
||||
clear: function(index){
|
||||
let _this = this;
|
||||
|
||||
if(index == "all"){
|
||||
for(let i = 0; i < Store.luckysheetfile.length; i++){
|
||||
let sheetfile = Store.luckysheetfile[i];
|
||||
_this.clearSheetByIndex(sheetfile.index);
|
||||
}
|
||||
|
||||
}
|
||||
else{
|
||||
if(index == null){
|
||||
index = Store.currentSheetIndex;
|
||||
}
|
||||
_this.clearSheetByIndex(index);
|
||||
}
|
||||
|
||||
sheetmanage.changeSheet(Store.luckysheetfile[0].index);
|
||||
},
|
||||
destroy:function(){
|
||||
$("#" + Store.container).empty();
|
||||
$("body > .luckysheet-cols-menu").remove();
|
||||
|
||||
$("#luckysheet-modal-dialog-mask, #luckysheetTextSizeTest, #luckysheet-icon-morebtn-div").remove();
|
||||
$("#luckysheet-input-box").parent().remove();
|
||||
$("#luckysheet-formula-help-c").remove();
|
||||
$(".chartSetting, .luckysheet-modal-dialog-slider").remove();
|
||||
|
||||
//document event release
|
||||
$(document).off(".luckysheetEvent");
|
||||
$(document).off(".luckysheetProtection");
|
||||
|
||||
//参数重置
|
||||
luckysheetFreezen.initialHorizontal = true;
|
||||
luckysheetFreezen.initialVertical = true;
|
||||
|
||||
let defaultStore = $.extend(true, {}, defaultConfig.defaultStore);
|
||||
for(let key in defaultStore){
|
||||
if(key in Store){
|
||||
Store[key] = defaultStore[key];
|
||||
}
|
||||
}
|
||||
|
||||
let defaultFormula = $.extend(true, {}, defaultConfig.defaultFormula);
|
||||
for(let key in defaultFormula){
|
||||
if(key in luckysheetformula){
|
||||
luckysheetformula[key] = defaultFormula[key];
|
||||
}
|
||||
}
|
||||
|
||||
let defaultSheet = $.extend(true, {}, defaultConfig.defaultSheet);
|
||||
for(let key in defaultSheet){
|
||||
if(key in sheetmanage){
|
||||
sheetmanage[key] = defaultSheet[key];
|
||||
}
|
||||
}
|
||||
|
||||
let defaultPivotTable = $.extend(true, {}, defaultConfig.defaultPivotTable);
|
||||
for(let key in defaultPivotTable){
|
||||
if(key in pivotTable){
|
||||
pivotTable[key] = defaultPivotTable[key];
|
||||
}
|
||||
}
|
||||
|
||||
let defaultImage = $.extend(true, {}, defaultConfig.defaultImage);
|
||||
for(let key in defaultImage){
|
||||
if(key in imageCtrl){
|
||||
imageCtrl[key] = defaultImage[key];
|
||||
}
|
||||
}
|
||||
|
||||
let defaultDataVerification = $.extend(true, {}, defaultConfig.defaultDataVerification);
|
||||
for(let key in defaultDataVerification){
|
||||
if(key in dataVerificationCtrl){
|
||||
dataVerificationCtrl[key] = defaultDataVerification[key];
|
||||
}
|
||||
}
|
||||
|
||||
// remove proxy
|
||||
Store.asyncLoad = ['core'];
|
||||
},
|
||||
editorChart:function(c){
|
||||
let chart_selection_color = luckyColor[0];
|
||||
let chart_id = "luckysheetEditMode-datav-chart";
|
||||
let chart_selection_id = chart_id + "_selection";
|
||||
c.chart_id = chart_id;
|
||||
let chartTheme = c.chartTheme;
|
||||
chartTheme = chartTheme == null ? "default0000" : chartTheme;
|
||||
|
||||
luckysheet.insertChartTosheet(c.sheetIndex, c.dataSheetIndex, c.option, c.chartType, c.selfOption, c.defaultOption, c.row, c.column, chart_selection_color, chart_id, chart_selection_id, c.chartStyle, c.rangeConfigCheck, c.rangeRowCheck, c.rangeColCheck, c.chartMarkConfig, c.chartTitleConfig, c.winWidth, c.winHeight, c.scrollLeft, c.scrollTop, chartTheme, c.myWidth, c.myHeight, c.myLeft!=null?parseFloat(c.myLeft):null, c.myTop!=null?parseFloat(c.myTop):null, c.myindexrank, true);
|
||||
|
||||
$("#"+chart_id).find(".luckysheet-modal-controll-update").click();
|
||||
},
|
||||
/**
|
||||
* 获取单元格的值
|
||||
* @param {name} 函数名称
|
||||
* @param {arguments} 函数参数
|
||||
*/
|
||||
createHookFunction:function(){
|
||||
let hookName = arguments[0];
|
||||
if(luckysheetConfigsetting.hook && luckysheetConfigsetting.hook[hookName]!=null && (typeof luckysheetConfigsetting.hook[hookName] == "function")){
|
||||
var args = Array.prototype.slice.apply(arguments);
|
||||
args.shift();
|
||||
let ret = luckysheetConfigsetting.hook[hookName].apply(this, args);
|
||||
if(ret===false){
|
||||
return false;
|
||||
}
|
||||
else{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default method;
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,105 @@
|
||||
import Store from '../store';
|
||||
import { computeRowlenByContent,computeColWidthByContent } from './getRowlen';
|
||||
import luckysheetConfigsetting from '../controllers/luckysheetConfigsetting';
|
||||
|
||||
export default function rhchInit(rowheight, colwidth) {
|
||||
zoomSetting();//Zoom sheet on first load
|
||||
//行高
|
||||
if(rowheight != null){
|
||||
Store.visibledatarow = [];
|
||||
Store.rh_height = 0;
|
||||
|
||||
for (let r = 0; r < rowheight; r++) {
|
||||
let rowlen = Store.defaultrowlen;
|
||||
|
||||
if (Store.config["rowlen"] != null && Store.config["rowlen"][r] != null) {
|
||||
rowlen = Store.config["rowlen"][r];
|
||||
}
|
||||
|
||||
if (Store.config["rowhidden"] != null && Store.config["rowhidden"][r] != null) {
|
||||
Store.visibledatarow.push(Store.rh_height);
|
||||
continue;
|
||||
}
|
||||
|
||||
// 自动行高计算
|
||||
if (rowlen === 'auto') {
|
||||
rowlen = computeRowlenByContent(Store.flowdata, r);
|
||||
}
|
||||
Store.rh_height += Math.round((rowlen + 1) * Store.zoomRatio);
|
||||
|
||||
Store.visibledatarow.push(Store.rh_height); //行的临时长度分布
|
||||
}
|
||||
|
||||
// 如果增加行和回到顶部按钮隐藏,则减少底部空白区域,但是预留足够空间给单元格下拉按钮
|
||||
if (!luckysheetConfigsetting.enableAddRow && !luckysheetConfigsetting.enableAddBackTop) {
|
||||
Store.rh_height += 29;
|
||||
} else {
|
||||
Store.rh_height += 80; //最底部增加空白
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//列宽
|
||||
if(colwidth != null){
|
||||
Store.visibledatacolumn = [];
|
||||
Store.ch_width = 0;
|
||||
|
||||
let maxColumnlen = 120;
|
||||
|
||||
for (let c = 0; c < colwidth; c++) {
|
||||
let firstcolumnlen = Store.defaultcollen;
|
||||
|
||||
if (Store.config["columnlen"] != null && Store.config["columnlen"][c] != null) {
|
||||
firstcolumnlen = Store.config["columnlen"][c];
|
||||
}
|
||||
else {
|
||||
if (Store.flowdata[0] != null && Store.flowdata[0][c] != null) {
|
||||
if (firstcolumnlen > 300) {
|
||||
firstcolumnlen = 300;
|
||||
}
|
||||
else if (firstcolumnlen < Store.defaultcollen) {
|
||||
firstcolumnlen = Store.defaultcollen;
|
||||
}
|
||||
|
||||
if (firstcolumnlen != Store.defaultcollen) {
|
||||
if (Store.config["columnlen"] == null) {
|
||||
Store.config["columnlen"] = {};
|
||||
}
|
||||
|
||||
Store.config["columnlen"][c] = firstcolumnlen;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(Store.config["colhidden"] != null && Store.config["colhidden"][c] != null){
|
||||
Store.visibledatacolumn.push(Store.ch_width);
|
||||
continue;
|
||||
}
|
||||
|
||||
// 自动行高计算
|
||||
if (firstcolumnlen === 'auto') {
|
||||
firstcolumnlen = computeColWidthByContent(Store.flowdata, c, rowheight);
|
||||
}
|
||||
Store.ch_width += Math.round((firstcolumnlen + 1)*Store.zoomRatio);
|
||||
|
||||
Store.visibledatacolumn.push(Store.ch_width);//列的临时长度分布
|
||||
|
||||
// if(maxColumnlen < firstcolumnlen + 1){
|
||||
// maxColumnlen = firstcolumnlen + 1;
|
||||
// }
|
||||
}
|
||||
|
||||
// Store.ch_width += 120;
|
||||
Store.ch_width += maxColumnlen;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export function zoomSetting(){
|
||||
//zoom
|
||||
Store.rowHeaderWidth = luckysheetConfigsetting.rowHeaderWidth * Store.zoomRatio;
|
||||
Store.columnHeaderHeight = luckysheetConfigsetting.columnHeaderHeight *Store.zoomRatio;
|
||||
$("#luckysheet-rows-h").width((Store.rowHeaderWidth-1.5));
|
||||
$("#luckysheet-cols-h-c").height((Store.columnHeaderHeight-1.5));
|
||||
$("#luckysheet-left-top").css({width:Store.rowHeaderWidth-1.5, height:Store.columnHeaderHeight-1.5});
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
import luckysheetFreezen from '../controllers/freezen';
|
||||
import { luckysheet_searcharray } from '../controllers/sheetSearch';
|
||||
import { luckysheetrefreshgrid } from '../global/refresh';
|
||||
import Store from '../store';
|
||||
import method from '../global/method'
|
||||
|
||||
let scrollRequestAnimationFrameIni = true,scrollRequestAnimationFrame = false, scrollTimeOutCancel=null;
|
||||
|
||||
function execScroll(){
|
||||
let scrollLeft = $("#luckysheet-scrollbar-x").scrollLeft(),
|
||||
scrollTop = $("#luckysheet-scrollbar-y").scrollTop();
|
||||
luckysheetrefreshgrid(scrollLeft, scrollTop);
|
||||
scrollRequestAnimationFrame = window.requestAnimationFrame(execScroll);
|
||||
}
|
||||
|
||||
//全局滚动事件
|
||||
export default function luckysheetscrollevent(isadjust) {
|
||||
let $t = $("#luckysheet-cell-main");
|
||||
let scrollLeft = $("#luckysheet-scrollbar-x").scrollLeft(),
|
||||
scrollTop = $("#luckysheet-scrollbar-y").scrollTop(),
|
||||
canvasHeight = $("#luckysheetTableContent").height(); // canvas高度
|
||||
|
||||
// clearTimeout(scrollTimeOutCancel);
|
||||
|
||||
// scrollTimeOutCancel = setTimeout(() => {
|
||||
// scrollRequestAnimationFrameIni = true;
|
||||
// window.cancelAnimationFrame(scrollRequestAnimationFrame);
|
||||
// }, 500);
|
||||
|
||||
// if (!!isadjust) {
|
||||
// let scrollHeight = $t.get(0).scrollHeight;
|
||||
// let windowHeight = $t.height();
|
||||
// let scrollWidth = $t.get(0).scrollWidth;
|
||||
// let windowWidth = $t.width();
|
||||
|
||||
// let maxScrollLeft = scrollWidth - windowWidth;
|
||||
// let maxScrollTop = scrollHeight - windowHeight;
|
||||
|
||||
// let visibledatacolumn_c = Store.visibledatacolumn, visibledatarow_c = Store.visibledatarow;
|
||||
|
||||
// if (luckysheetFreezen.freezenhorizontaldata != null) {
|
||||
// visibledatarow_c = luckysheetFreezen.freezenhorizontaldata[3];
|
||||
// }
|
||||
|
||||
// if (luckysheetFreezen.freezenverticaldata != null) {
|
||||
// visibledatacolumn_c = luckysheetFreezen.freezenverticaldata[3];
|
||||
// }
|
||||
|
||||
// let col_ed = luckysheet_searcharray(visibledatacolumn_c, scrollLeft);
|
||||
// let row_ed = luckysheet_searcharray(visibledatarow_c, scrollTop);
|
||||
|
||||
// let refreshLeft = scrollLeft , refreshTop = scrollTop;
|
||||
|
||||
// if (col_ed <= 0) {
|
||||
// scrollLeft = 0;
|
||||
// }
|
||||
// else {
|
||||
// scrollLeft = visibledatacolumn_c[col_ed - 1];
|
||||
// }
|
||||
|
||||
// if (row_ed <= 0) {
|
||||
// scrollTop = 0;
|
||||
// }
|
||||
// else {
|
||||
// scrollTop = visibledatarow_c[row_ed - 1];
|
||||
// }
|
||||
// }
|
||||
|
||||
if (luckysheetFreezen.freezenhorizontaldata != null) {
|
||||
if (scrollTop < luckysheetFreezen.freezenhorizontaldata[2]) {
|
||||
scrollTop = luckysheetFreezen.freezenhorizontaldata[2];
|
||||
$("#luckysheet-scrollbar-y").scrollTop(scrollTop);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (luckysheetFreezen.freezenverticaldata != null) {
|
||||
if (scrollLeft < luckysheetFreezen.freezenverticaldata[2]) {
|
||||
scrollLeft = luckysheetFreezen.freezenverticaldata[2];
|
||||
$("#luckysheet-scrollbar-x").scrollLeft(scrollLeft);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$("#luckysheet-cols-h-c").scrollLeft(scrollLeft);//列标题
|
||||
$("#luckysheet-rows-h").scrollTop(scrollTop);//行标题
|
||||
|
||||
$t.scrollLeft(scrollLeft).scrollTop(scrollTop);
|
||||
|
||||
$("#luckysheet-input-box-index").css({
|
||||
"left": $("#luckysheet-input-box").css("left"),
|
||||
"top": (parseInt($("#luckysheet-input-box").css("top")) - 20) + "px",
|
||||
"z-index": $("#luckysheet-input-box").css("z-index")
|
||||
}).show();
|
||||
|
||||
// if(scrollRequestAnimationFrameIni && Store.scrollRefreshSwitch){
|
||||
// execScroll();
|
||||
// scrollRequestAnimationFrameIni = false;
|
||||
// }
|
||||
|
||||
luckysheetrefreshgrid(scrollLeft, scrollTop);
|
||||
|
||||
|
||||
$("#luckysheet-bottom-controll-row").css("left", scrollLeft);
|
||||
|
||||
//有选区且有冻结时,滚动适应
|
||||
if(luckysheetFreezen.freezenhorizontaldata != null || luckysheetFreezen.freezenverticaldata != null){
|
||||
luckysheetFreezen.scrollAdapt();
|
||||
}
|
||||
|
||||
if(!method.createHookFunction("scroll", {scrollLeft, scrollTop, canvasHeight})){ return; }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,262 @@
|
||||
import { getObjType } from "../utils/util";
|
||||
import { isRealNull, isRealNum, valueIsError } from "./validate";
|
||||
import { genarate, update } from "./format";
|
||||
import server from "../controllers/server";
|
||||
import luckysheetConfigsetting from "../controllers/luckysheetConfigsetting";
|
||||
import Store from "../store/index";
|
||||
|
||||
//Set cell value
|
||||
function setcellvalue(r, c, d, v) {
|
||||
if (d == null) {
|
||||
d = Store.flowdata;
|
||||
}
|
||||
// 若采用深拷贝,初始化时的单元格属性丢失
|
||||
// let cell = $.extend(true, {}, d[r][c]);
|
||||
let cell = d[r][c];
|
||||
|
||||
let vupdate;
|
||||
|
||||
if (getObjType(v) == "object") {
|
||||
if (cell == null) {
|
||||
cell = v;
|
||||
} else {
|
||||
if (v.f != null) {
|
||||
cell.f = v.f;
|
||||
} else if (cell.hasOwnProperty("f")) {
|
||||
delete cell.f;
|
||||
}
|
||||
|
||||
if (v.spl != null) {
|
||||
cell.spl = v.spl;
|
||||
}
|
||||
|
||||
if (v.ct != null) {
|
||||
cell.ct = v.ct;
|
||||
}
|
||||
}
|
||||
|
||||
if (getObjType(v.v) == "object") {
|
||||
vupdate = v.v.v;
|
||||
} else {
|
||||
vupdate = v.v;
|
||||
}
|
||||
} else {
|
||||
vupdate = v;
|
||||
}
|
||||
|
||||
// fix #81, vupdate = ''
|
||||
if (vupdate == null) {
|
||||
if (getObjType(cell) == "object") {
|
||||
delete cell.m;
|
||||
delete cell.v;
|
||||
} else {
|
||||
cell = null;
|
||||
}
|
||||
|
||||
d[r][c] = cell;
|
||||
|
||||
return cell;
|
||||
}
|
||||
|
||||
// 1.为null
|
||||
// 2.数据透视表的数据,flowdata的每个数据可能为字符串,结果就是cell == v == 一个字符串或者数字数据
|
||||
if (isRealNull(cell) || ((getObjType(cell) === "string" || getObjType(cell) === "number") && cell === v)) {
|
||||
cell = {};
|
||||
}
|
||||
|
||||
let vupdateStr = vupdate.toString();
|
||||
|
||||
if (vupdateStr.substr(0, 1) == "'") {
|
||||
cell.m = vupdateStr.substr(1);
|
||||
cell.ct = { fa: "@", t: "s" };
|
||||
cell.v = vupdateStr.substr(1);
|
||||
cell.qp = 1;
|
||||
} else if (cell.qp == 1) {
|
||||
cell.m = vupdateStr;
|
||||
cell.ct = { fa: "@", t: "s" };
|
||||
cell.v = vupdateStr;
|
||||
} else if (vupdateStr.toUpperCase() === "TRUE") {
|
||||
cell.m = "TRUE";
|
||||
cell.ct = { fa: "General", t: "b" };
|
||||
cell.v = true;
|
||||
} else if (vupdateStr.toUpperCase() === "FALSE") {
|
||||
cell.m = "FALSE";
|
||||
cell.ct = { fa: "General", t: "b" };
|
||||
cell.v = false;
|
||||
} else if (vupdateStr.substr(-1) === "%" && isRealNum(vupdateStr.substring(0, vupdateStr.length - 1))) {
|
||||
cell.ct = { fa: "0%", t: "n" };
|
||||
cell.v = vupdateStr.substring(0, vupdateStr.length - 1) / 100;
|
||||
cell.m = vupdate;
|
||||
} else if (valueIsError(vupdate)) {
|
||||
cell.m = vupdateStr;
|
||||
// cell.ct = { "fa": "General", "t": "e" };
|
||||
if (cell.ct != null) {
|
||||
cell.ct.t = "e";
|
||||
} else {
|
||||
cell.ct = { fa: "General", t: "e" };
|
||||
}
|
||||
cell.v = vupdate;
|
||||
} else {
|
||||
if (
|
||||
cell.f != null &&
|
||||
isRealNum(vupdate) &&
|
||||
!/^\d{6}(18|19|20)?\d{2}(0[1-9]|1[12])(0[1-9]|[12]\d|3[01])\d{3}(\d|X)$/i.test(vupdate)
|
||||
) {
|
||||
cell.v = parseFloat(vupdate);
|
||||
if (cell.ct == null) {
|
||||
cell.ct = { fa: "General", t: "n" };
|
||||
}
|
||||
|
||||
if (cell.v == Infinity || cell.v == -Infinity) {
|
||||
cell.m = cell.v.toString();
|
||||
} else {
|
||||
if (cell.v.toString().indexOf("e") > -1) {
|
||||
let len;
|
||||
if (cell.v.toString().split(".").length == 1) {
|
||||
len = 0;
|
||||
} else {
|
||||
len = cell.v
|
||||
.toString()
|
||||
.split(".")[1]
|
||||
.split("e")[0].length;
|
||||
}
|
||||
if (len > 5) {
|
||||
len = 5;
|
||||
}
|
||||
|
||||
cell.m = cell.v.toExponential(len).toString();
|
||||
} else {
|
||||
let v_p = Math.round(cell.v * 1000000000) / 1000000000;
|
||||
if (cell.ct == null) {
|
||||
let mask = genarate(v_p);
|
||||
cell.m = mask[0].toString();
|
||||
} else {
|
||||
let mask = update(cell.ct.fa, v_p);
|
||||
cell.m = mask.toString();
|
||||
}
|
||||
|
||||
// cell.m = mask[0].toString();
|
||||
}
|
||||
}
|
||||
} else if (cell.ct != null && cell.ct.fa == "@") {
|
||||
cell.m = vupdateStr;
|
||||
cell.v = vupdate;
|
||||
} else if (cell.ct != null && cell.ct.fa != null && cell.ct.fa != "General") {
|
||||
if (isRealNum(vupdate)) {
|
||||
vupdate = parseFloat(vupdate);
|
||||
}
|
||||
|
||||
let mask = update(cell.ct.fa, vupdate);
|
||||
|
||||
if (mask === vupdate) {
|
||||
//若原来单元格格式 应用不了 要更新的值,则获取更新值的 格式
|
||||
mask = genarate(vupdate);
|
||||
|
||||
cell.m = mask[0].toString();
|
||||
cell.ct = mask[1];
|
||||
cell.v = mask[2];
|
||||
} else {
|
||||
cell.m = mask.toString();
|
||||
cell.v = vupdate;
|
||||
}
|
||||
} else {
|
||||
if (
|
||||
isRealNum(vupdate) &&
|
||||
!/^\d{6}(18|19|20)?\d{2}(0[1-9]|1[12])(0[1-9]|[12]\d|3[01])\d{3}(\d|X)$/i.test(vupdate)
|
||||
) {
|
||||
if (typeof vupdate === "string") {
|
||||
let flag = vupdate.split("").every((ele) => ele == "0" || ele == ".");
|
||||
|
||||
// 1.1111111111111111 as an example, numbers within 18 characters need to be converted to numbers
|
||||
if (flag || vupdate.length < 18) {
|
||||
vupdate = parseFloat(vupdate);
|
||||
}
|
||||
}
|
||||
cell.v = vupdate; /* 备注:如果使用parseFloat,1.1111111111111111会转换为1.1111111111111112 ? */
|
||||
cell.ct = { fa: "General", t: "n" };
|
||||
if (cell.v == Infinity || cell.v == -Infinity) {
|
||||
cell.m = cell.v.toString();
|
||||
} else {
|
||||
let mask = genarate(cell.v);
|
||||
|
||||
cell.m = mask[0].toString();
|
||||
}
|
||||
} else {
|
||||
let mask = genarate(vupdate);
|
||||
|
||||
cell.m = mask[0].toString();
|
||||
cell.ct = mask[1];
|
||||
cell.v = mask[2];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!server.allowUpdate && !luckysheetConfigsetting.pointEdit) {
|
||||
if (
|
||||
cell.ct != null &&
|
||||
/^(w|W)((0?)|(0\.0+))$/.test(cell.ct.fa) == false &&
|
||||
cell.ct.t == "n" &&
|
||||
cell.v != null &&
|
||||
parseInt(cell.v).toString().length > 4
|
||||
) {
|
||||
let autoFormatw = luckysheetConfigsetting.autoFormatw.toString().toUpperCase();
|
||||
let accuracy = luckysheetConfigsetting.accuracy;
|
||||
|
||||
let sfmt = setAccuracy(autoFormatw, accuracy);
|
||||
|
||||
if (sfmt != "General") {
|
||||
cell.ct.fa = sfmt;
|
||||
cell.m = update(sfmt, cell.v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
d[r][c] = cell;
|
||||
return cell;
|
||||
}
|
||||
|
||||
//new runze 根据亿万格式autoFormatw和精确度accuracy 转换成 w/w0/w0.00 or 0/0.0格式
|
||||
function setAccuracy(autoFormatw, accuracy) {
|
||||
let acc = "0.";
|
||||
let fmt;
|
||||
|
||||
if (autoFormatw == "TRUE") {
|
||||
if (accuracy == undefined) {
|
||||
return "w";
|
||||
} else {
|
||||
let alength = parseInt(accuracy);
|
||||
|
||||
if (alength == 0) {
|
||||
return "w0";
|
||||
} else {
|
||||
acc = "w0.";
|
||||
|
||||
for (let i = 0; i < alength; i++) {
|
||||
acc += "0";
|
||||
}
|
||||
|
||||
fmt = acc;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (accuracy == undefined) {
|
||||
return "General";
|
||||
} else {
|
||||
let alength = parseInt(accuracy);
|
||||
|
||||
if (alength == 0) {
|
||||
return "0";
|
||||
} else {
|
||||
for (let i = 0; i < alength; i++) {
|
||||
acc += "0";
|
||||
}
|
||||
|
||||
fmt = acc;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return fmt.toString();
|
||||
}
|
||||
|
||||
export { setcellvalue, setAccuracy };
|
||||
@@ -0,0 +1,393 @@
|
||||
import { getObjType } from '../utils/util';
|
||||
import { isRealNull, isRealNum, isEditMode } from './validate';
|
||||
import { isdatetime, diff } from './datecontroll';
|
||||
import tooltip from './tooltip';
|
||||
import editor from './editor';
|
||||
import { rowlenByRange } from './getRowlen';
|
||||
import { jfrefreshgrid } from './refresh';
|
||||
import {checkProtectionAuthorityNormal} from '../controllers/protection';
|
||||
import Store from '../store';
|
||||
import locale from '../locale/locale';
|
||||
import numeral from 'numeral';
|
||||
|
||||
//数据排序方法
|
||||
function orderbydata(data, index, isAsc) {
|
||||
if (isAsc == null) {
|
||||
isAsc = true;
|
||||
}
|
||||
|
||||
let a = function (x, y) {
|
||||
let x1 = x[index] , y1 = y[index];
|
||||
|
||||
if(getObjType(x[index]) == "object"){
|
||||
x1 = x[index].v;
|
||||
}
|
||||
|
||||
if(getObjType(y[index]) == "object"){
|
||||
y1 = y[index].v;
|
||||
}
|
||||
|
||||
if(isRealNull(x1)){
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(isRealNull(y1)){
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (isdatetime(x1) && isdatetime(y1)) {
|
||||
return diff(x1, y1);
|
||||
}
|
||||
else if (isRealNum(x1) && isRealNum(y1)) {
|
||||
return numeral(x1).value() - numeral(y1).value();
|
||||
}
|
||||
else if (!isRealNum(x1) && !isRealNum(y1)) {
|
||||
return x1.localeCompare(y1, "zh");
|
||||
}
|
||||
else if (!isRealNum(x1)) {
|
||||
return 1;
|
||||
}
|
||||
else if (!isRealNum(y1)) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
let d = function (x, y) {
|
||||
let x1 = x[index] , y1 = y[index];
|
||||
|
||||
if(getObjType(x[index]) == "object"){
|
||||
x1 = x[index].v;
|
||||
}
|
||||
|
||||
if(getObjType(y[index]) == "object"){
|
||||
y1 = y[index].v;
|
||||
}
|
||||
|
||||
if(isRealNull(x1)){
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(isRealNull(y1)){
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (isdatetime(x1) && isdatetime(y1)) {
|
||||
return diff(y1, x1);
|
||||
}
|
||||
else if (isRealNum(x1) && isRealNum(y1)) {
|
||||
return numeral(y1).value() - numeral(x1).value();
|
||||
}
|
||||
else if (!isRealNum(x1) && !isRealNum(y1)) {
|
||||
return y1.localeCompare(x1, "zh");
|
||||
}
|
||||
else if (!isRealNum(x1)) {
|
||||
return -1;
|
||||
}
|
||||
else if (!isRealNum(y1)) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (isAsc) {
|
||||
return data.sort(a);
|
||||
}
|
||||
else {
|
||||
return data.sort(d);
|
||||
}
|
||||
}
|
||||
|
||||
function orderbydata1D(data, isAsc) {
|
||||
if (isAsc == null) {
|
||||
isAsc = true;
|
||||
}
|
||||
|
||||
let a = function (x, y) {
|
||||
let x1 = x, y1 = y;
|
||||
|
||||
if(getObjType(x) == "object"){
|
||||
x1 = x.v;
|
||||
}
|
||||
|
||||
if(getObjType(y) == "object"){
|
||||
y1 = y.v;
|
||||
}
|
||||
|
||||
if(x1 == null){
|
||||
x1 = "";
|
||||
}
|
||||
|
||||
if(y1 == null){
|
||||
y1 = "";
|
||||
}
|
||||
|
||||
if (isdatetime(x1) && isdatetime(y1)) {
|
||||
return diff(x1, y1);
|
||||
}
|
||||
else if (isRealNum(x1) && isRealNum(y1)) {
|
||||
return numeral(x1).value() - numeral(y1).value();
|
||||
}
|
||||
else if (!isRealNum(x1) && !isRealNum(y1)) {
|
||||
return x1.localeCompare(y1, "zh");
|
||||
}
|
||||
else if (!isRealNum(x1)) {
|
||||
return 1;
|
||||
}
|
||||
else if (!isRealNum(y1)) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
let d = function (x, y) {
|
||||
let x1 = x, y1 = y;
|
||||
|
||||
if(getObjType(x) == "object"){
|
||||
x1 = x.v;
|
||||
}
|
||||
|
||||
if(getObjType(y) == "object"){
|
||||
y1 = y.v;
|
||||
}
|
||||
|
||||
if(x1 == null){
|
||||
x1 = "";
|
||||
}
|
||||
|
||||
if(y1 == null){
|
||||
y1 = "";
|
||||
}
|
||||
|
||||
if (isdatetime(x1) && isdatetime(y1)) {
|
||||
return diff(y1, x1);
|
||||
}
|
||||
else if (isRealNum(x1) && isRealNum(y1)) {
|
||||
return numeral(y1).value() - numeral(x1).value();
|
||||
}
|
||||
else if (!isRealNum(x1) && !isRealNum(y1)) {
|
||||
return y1.localeCompare(x1, "zh");
|
||||
}
|
||||
else if (!isRealNum(x1)) {
|
||||
return -1;
|
||||
}
|
||||
else if (!isRealNum(y1)) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (isAsc) {
|
||||
return data.sort(a);
|
||||
}
|
||||
else {
|
||||
return data.sort(d);
|
||||
}
|
||||
}
|
||||
|
||||
//排序选区数据
|
||||
function sortSelection(isAsc) {
|
||||
if(!checkProtectionAuthorityNormal(Store.currentSheetIndex, "sort")){
|
||||
return;
|
||||
}
|
||||
|
||||
const _locale = locale();
|
||||
const locale_sort = _locale.sort;
|
||||
|
||||
if(Store.luckysheet_select_save.length > 1){
|
||||
if(isEditMode()){
|
||||
alert(locale_sort.noRangeError);
|
||||
}
|
||||
else{
|
||||
tooltip.info(locale_sort.noRangeError, "");
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if(isAsc == null){
|
||||
isAsc = true;
|
||||
}
|
||||
|
||||
let d = editor.deepCopyFlowData(Store.flowdata);
|
||||
|
||||
let r1 = Store.luckysheet_select_save[0].row[0],
|
||||
r2 = Store.luckysheet_select_save[0].row[1];
|
||||
let c1 = Store.luckysheet_select_save[0].column[0],
|
||||
c2 = Store.luckysheet_select_save[0].column[1];
|
||||
|
||||
let str, edr;
|
||||
|
||||
for(let r = r1; r <= r2; r++){
|
||||
if(d[r] != null && d[r][c1] != null){
|
||||
let cell = d[r][c1];
|
||||
|
||||
if(cell.mc != null || isRealNull(cell.v)){
|
||||
continue;
|
||||
}
|
||||
|
||||
if(str == null && /[\u4e00-\u9fa5]+/g.test(cell.v)){
|
||||
str = r + 1;
|
||||
edr = r + 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
if(str == null){
|
||||
str = r;
|
||||
}
|
||||
|
||||
edr = r;
|
||||
}
|
||||
}
|
||||
|
||||
if(str == null || str > r2){
|
||||
return;
|
||||
}
|
||||
|
||||
let hasMc = false; //排序选区是否有合并单元格
|
||||
let data = [];
|
||||
|
||||
for(let r = str; r <= edr; r++){
|
||||
let data_row = [];
|
||||
|
||||
for(let c = c1; c <= c2; c++){
|
||||
if(d[r][c] != null && d[r][c].mc != null){
|
||||
hasMc = true;
|
||||
break;
|
||||
}
|
||||
|
||||
data_row.push(d[r][c]);
|
||||
}
|
||||
|
||||
data.push(data_row);
|
||||
}
|
||||
|
||||
if(hasMc){
|
||||
if(isEditMode()){
|
||||
alert(locale_sort.mergeError);
|
||||
}
|
||||
else{
|
||||
tooltip.info(locale_sort.mergeError, "");
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
data = orderbydata(data, 0, isAsc);
|
||||
|
||||
for(let r = str; r <= edr; r++){
|
||||
for(let c = c1; c <= c2; c++){
|
||||
d[r][c] = data[r - str][c - c1];
|
||||
}
|
||||
}
|
||||
|
||||
let allParam = {};
|
||||
if(Store.config["rowlen"] != null){
|
||||
let cfg = $.extend(true, {}, Store.config);
|
||||
cfg = rowlenByRange(d, str, edr, cfg);
|
||||
|
||||
allParam = {
|
||||
"cfg": cfg,
|
||||
"RowlChange": true
|
||||
}
|
||||
}
|
||||
|
||||
jfrefreshgrid(d, [{ "row": [str, edr], "column": [c1, c2] }], allParam);
|
||||
}
|
||||
|
||||
//排序一列数据
|
||||
function sortColumnSeletion(colIndex, isAsc) {
|
||||
if(!checkProtectionAuthorityNormal(Store.currentSheetIndex, "sort")){
|
||||
return;
|
||||
}
|
||||
if(isAsc == null){
|
||||
isAsc = true;
|
||||
}
|
||||
|
||||
const _locale = locale();
|
||||
const locale_sort = _locale.sort;
|
||||
|
||||
let d = editor.deepCopyFlowData(Store.flowdata);
|
||||
|
||||
let r1 = 0, r2 = d.length - 1;
|
||||
let c1 = 0, c2 = d[0].length - 1;
|
||||
|
||||
let str, edr;
|
||||
|
||||
for(let r = r1; r <= r2; r++){
|
||||
if(d[r][colIndex] != null && d[r][colIndex].mc != null){
|
||||
continue;
|
||||
}
|
||||
|
||||
if(d[r][colIndex] != null && !isRealNull(d[r][colIndex].v) && /[\u4e00-\u9fa5]+/g.test(d[r][colIndex].v) && str == null){
|
||||
str = r + 1;
|
||||
edr = r + 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
if(str == null){
|
||||
str = r;
|
||||
}
|
||||
|
||||
if(d[r][colIndex] != null && !isRealNull(d[r][colIndex].v)){
|
||||
edr = r;
|
||||
}
|
||||
}
|
||||
|
||||
if(str == null || str > r2){
|
||||
return;
|
||||
}
|
||||
|
||||
let hasMc = false; //排序选区是否有合并单元格
|
||||
let data = [];
|
||||
|
||||
for(let r = str; r <= edr; r++){
|
||||
let data_row = [];
|
||||
|
||||
for(let c = c1; c <= c2; c++){
|
||||
if(d[r][c] != null && d[r][c].mc != null){
|
||||
hasMc = true;
|
||||
break;
|
||||
}
|
||||
|
||||
data_row.push(d[r][c]);
|
||||
}
|
||||
|
||||
data.push(data_row);
|
||||
}
|
||||
|
||||
if(hasMc){
|
||||
if(isEditMode()){
|
||||
alert(locale_sort.columnSortMergeError);
|
||||
}
|
||||
else{
|
||||
tooltip.info(locale_sort.columnSortMergeError, "");
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
data = orderbydata(data, colIndex, isAsc);
|
||||
|
||||
for(let r = str; r <= edr; r++){
|
||||
for(let c = c1; c <= c2; c++){
|
||||
d[r][c] = data[r - str][c - c1];
|
||||
}
|
||||
}
|
||||
|
||||
let allParam = {};
|
||||
if(Store.config["rowlen"] != null){
|
||||
let cfg = $.extend(true, {}, Store.config);
|
||||
cfg = rowlenByRange(d, str, edr, cfg);
|
||||
|
||||
allParam = {
|
||||
"cfg": cfg,
|
||||
"RowlChange": true
|
||||
}
|
||||
}
|
||||
|
||||
jfrefreshgrid(d, [{ "row": [str, edr], "column": [c1, c2] }], allParam);
|
||||
}
|
||||
|
||||
export {
|
||||
orderbydata,
|
||||
orderbydata1D,
|
||||
sortSelection,
|
||||
sortColumnSeletion,
|
||||
}
|
||||
@@ -0,0 +1,314 @@
|
||||
import { modelHTML, luckysheetchartpointconfigHTML, luckysheetToolHTML } from '../controllers/constant';
|
||||
import browser from './browser';
|
||||
import { replaceHtml } from '../utils/util';
|
||||
import locale from '../locale/locale';
|
||||
import server from '../controllers/server';
|
||||
|
||||
const tooltip = {
|
||||
info: function (title, content) {
|
||||
$("#luckysheet-modal-dialog-mask").show();
|
||||
$("#luckysheet-info").remove();
|
||||
|
||||
let _locale = locale();
|
||||
let locale_button = _locale.button;
|
||||
|
||||
$("body").append(replaceHtml(modelHTML, {
|
||||
"id": "luckysheet-info",
|
||||
"addclass": "",
|
||||
"title": title,
|
||||
"content": content,
|
||||
"botton": '<button class="btn btn-default luckysheet-model-close-btn"> '+locale_button.close+' </button>',
|
||||
"style": "z-index:100003"
|
||||
}));
|
||||
let $t = $("#luckysheet-info").find(".luckysheet-modal-dialog-content").css("min-width", 300).end(),
|
||||
myh = $t.outerHeight(),
|
||||
myw = $t.outerWidth();
|
||||
let winw = $(window).width(), winh = $(window).height();
|
||||
let scrollLeft = $(document).scrollLeft(), scrollTop = $(document).scrollTop();
|
||||
$("#luckysheet-info").css({ "left": (winw + scrollLeft - myw) / 2, "top": (winh + scrollTop - myh) / 3 }).show();
|
||||
},
|
||||
confirm: function (title, content, func1, func2, name1, name2) {
|
||||
$("#luckysheet-modal-dialog-mask").show();
|
||||
$("#luckysheet-confirm").remove();
|
||||
|
||||
const _locale = locale();
|
||||
const locale_button = _locale.button;
|
||||
|
||||
if(name1 == null){
|
||||
name1 = locale_button.confirm;
|
||||
}
|
||||
if(name2 == null){
|
||||
name2 = locale_button.cancel;
|
||||
}
|
||||
|
||||
$("body").append(replaceHtml(modelHTML, {
|
||||
"id": "luckysheet-confirm",
|
||||
"addclass": "",
|
||||
"style": "z-index:100003",
|
||||
"title": title,
|
||||
"content": content,
|
||||
"botton": '<button class="btn btn-primary luckysheet-model-conform-btn"> '+ name1 +' </button><button class="btn btn-default luckysheet-model-cancel-btn"> '+ name2 +' </button>'
|
||||
}));
|
||||
let $t = $("#luckysheet-confirm").find(".luckysheet-modal-dialog-content").css("min-width", 300).end(),
|
||||
myh = $t.outerHeight(),
|
||||
myw = $t.outerWidth();
|
||||
let winw = $(window).width(), winh = $(window).height();
|
||||
let scrollLeft = $(document).scrollLeft(), scrollTop = $(document).scrollTop();
|
||||
$("#luckysheet-confirm").css({ "left": (winw + scrollLeft - myw) / 2, "top": (winh + scrollTop - myh) / 3 }).show();
|
||||
$t.find(".luckysheet-model-conform-btn").click(function () {
|
||||
if (typeof func1 == 'function') {
|
||||
func1();
|
||||
}
|
||||
server.keepHighLightBox();
|
||||
$("#luckysheet-confirm").hide();
|
||||
$("#luckysheet-modal-dialog-mask").hide();
|
||||
});
|
||||
$t.find(".luckysheet-model-cancel-btn").click(function () {
|
||||
if (typeof func2 == 'function') {
|
||||
func2();
|
||||
}
|
||||
$("#luckysheet-confirm").hide();
|
||||
$("#luckysheet-modal-dialog-mask").hide();
|
||||
});
|
||||
},
|
||||
screenshot: function (title, content, imgurl) {
|
||||
|
||||
const _locale = locale();
|
||||
const locale_screenshot = _locale.screenshot;
|
||||
$("#luckysheet-modal-dialog-mask").show();
|
||||
$("#luckysheet-confirm").remove();
|
||||
$("body").append(replaceHtml(modelHTML, {
|
||||
"id": "luckysheet-confirm",
|
||||
"addclass": "",
|
||||
"style": "z-index:100003",
|
||||
"title": title,
|
||||
"content": content,
|
||||
"botton": '<a style="text-decoration:none;color:#fff;" class="download btn btn-primary luckysheet-model-conform-btn"> '+ locale_screenshot.downLoadBtn +' </a> <button class="btn btn-primary luckysheet-model-copy-btn"> '+ locale_screenshot.downLoadCopy +' </button><button class="btn btn-default luckysheet-model-cancel-btn"> '+ locale_screenshot.downLoadClose +' </button>'
|
||||
}));
|
||||
let $t = $("#luckysheet-confirm").find(".luckysheet-modal-dialog-content").css("min-width", 300).end(),
|
||||
myh = $t.outerHeight(),
|
||||
myw = $t.outerWidth();
|
||||
let winw = $(window).width(), winh = $(window).height();
|
||||
let scrollLeft = $(document).scrollLeft(), scrollTop = $(document).scrollTop();
|
||||
$("#luckysheet-confirm").css({ "left": (winw + scrollLeft - myw) / 2, "top": (winh + scrollTop - myh) / 3 }).show();
|
||||
$t.find(".luckysheet-model-conform-btn").click(function () {
|
||||
if(browser.isIE() == "1"){
|
||||
alert(locale_screenshot.browserNotTip);
|
||||
}
|
||||
else{
|
||||
if (!!window.ActiveXObject || "ActiveXObject" in window){
|
||||
if ($("#IframeReportImg").length === 0){
|
||||
$('<iframe style="display:none;" id="IframeReportImg" name="IframeReportImg" onload="downloadImg();" width="0" height="0" src="about:blank"></iframe>').appendTo("body");
|
||||
}
|
||||
if ($('#IframeReportImg').attr("src") != imgurl) {
|
||||
$('#IframeReportImg').attr("src",imgurl);
|
||||
} else {
|
||||
if ($('#IframeReportImg').src != "about:blank") {
|
||||
window.frames["IframeReportImg"].document.execCommand("SaveAs");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
$t.find(".luckysheet-model-cancel-btn").click(function () {
|
||||
$("#luckysheet-confirm").hide();
|
||||
$("#luckysheet-modal-dialog-mask").hide();
|
||||
});
|
||||
|
||||
$('#luckysheet-confirm .luckysheet-model-copy-btn').click(function(){
|
||||
let dt = new clipboard.DT();
|
||||
dt.setData("text/html", "<img src='"+ imgurl +"'>");
|
||||
if(browser.isIE() == "1"){
|
||||
alert(locale_screenshot.rightclickTip);
|
||||
}
|
||||
else{
|
||||
clipboard.write(dt);
|
||||
alert(locale_screenshot.successTip);
|
||||
}
|
||||
});
|
||||
},
|
||||
chartPointConfig: function (id, savefunc1, closefunc2) {
|
||||
$("body").append(replaceHtml(modelHTML, {
|
||||
"id": id,
|
||||
"addclass": "luckysheet-chart-point-config-c",
|
||||
"title": "数据点批量设置",
|
||||
"content": luckysheetchartpointconfigHTML,
|
||||
"botton": '<button class="btn btn-danger luckysheet-model-save-btn"> 保存设置 </button><button class="btn btn-default luckysheet-model-close-btn"> 取消 </button>',
|
||||
"style": "z-index:100003;height:80%;width:80%;top:10%;left:10%;"
|
||||
}));
|
||||
$("#luckysheet-modal-dialog-mask").show();
|
||||
let winw = $(window).width(), winh = $(window).height();
|
||||
$("#" + id).find(".luckysheet-chart-point-config").css("height", winh - 160);
|
||||
$("#" + id).css({
|
||||
"height": winh - 90,
|
||||
"width": winw - 100,
|
||||
"left": 7,
|
||||
"top": 14
|
||||
}).show().find(".luckysheet-model-save-btn").click(function () {
|
||||
if (typeof savefunc1 == 'function') {
|
||||
savefunc1();
|
||||
}
|
||||
|
||||
$("#" + id).hide();
|
||||
$("#luckysheet-modal-dialog-mask").hide();
|
||||
});
|
||||
|
||||
$("#" + id).find(".luckysheet-model-save-btn").click(function () {
|
||||
if (typeof closefunc2 == 'function') {
|
||||
closefunc2();
|
||||
}
|
||||
|
||||
$("#" + id).hide();
|
||||
$("#luckysheet-modal-dialog-mask").hide();
|
||||
});
|
||||
},
|
||||
sheetConfig: function () {
|
||||
|
||||
},
|
||||
hoverTipshowState: false,
|
||||
hoverTipshowTimeOut: null,
|
||||
createHoverTip: function (obj, to) {
|
||||
let _this = this;
|
||||
|
||||
$(obj).on("mouseover", to, function (e) {
|
||||
if (_this.hoverTipshowState) {
|
||||
return;
|
||||
}
|
||||
|
||||
clearTimeout(_this.hoverTipshowTimeOut);
|
||||
_this.hoverTipshowTimeOut = setTimeout(function(){
|
||||
let $t = $(e.currentTarget),
|
||||
toffset = $t.offset(),
|
||||
$toolup = $("#luckysheet-tooltip-up");
|
||||
|
||||
let tips = $t.data("tips");
|
||||
if (tips == null || tips.length == 0) {
|
||||
tips = $t.prev().data("tips");
|
||||
|
||||
if (tips == null || tips.length == 0) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if ($toolup.length == 0) {
|
||||
$("body").append(luckysheetToolHTML);
|
||||
$toolup = $("#luckysheet-tooltip-up");
|
||||
}
|
||||
|
||||
$toolup.removeClass("jfk-tooltip-hide").find("div.jfk-tooltip-contentId").html(tips);
|
||||
let toolwidth = $toolup.outerWidth();
|
||||
$toolup.find("div.jfk-tooltip-arrow").css("left", (toolwidth) / 2);
|
||||
|
||||
let toolleft = toffset.left + ($t.outerWidth() - toolwidth) / 2;
|
||||
if(toolleft < 2){
|
||||
toolleft = 2;
|
||||
$toolup.find("div.jfk-tooltip-arrow").css("left", $t.outerWidth() / 2);
|
||||
}
|
||||
|
||||
$toolup.css({ "top": toffset.top + $t.outerHeight() + 1, "left": toolleft });
|
||||
}, 300);
|
||||
|
||||
}).on("mouseout", to, function (e) {
|
||||
_this.hoverTipshowState = false;
|
||||
clearTimeout(_this.hoverTipshowTimeOut);
|
||||
$("#luckysheet-tooltip-up").addClass("jfk-tooltip-hide");
|
||||
}).on("click", to, function (e) {
|
||||
_this.hoverTipshowState = true;
|
||||
clearTimeout(_this.hoverTipshowTimeOut);
|
||||
$("#luckysheet-tooltip-up").addClass("jfk-tooltip-hide");
|
||||
});
|
||||
},
|
||||
popover: function(content, position, close, style, btntxt, exitsFuc){
|
||||
let _locale = locale();
|
||||
let locale_button = _locale.button;
|
||||
let locale_paint = _locale.paint;
|
||||
|
||||
if(btntxt == null){
|
||||
btntxt = locale_button.close;
|
||||
}
|
||||
|
||||
let htmldiv = '<div id="luckysheetpopover" class="luckysheetpopover"><div class="luckysheetpopover-content">'+locale_paint.start+'</div><div class="luckysheetpopover-btn">'+ btntxt +'</div></div>';
|
||||
$("#luckysheetpopover").remove();
|
||||
$("body").append(htmldiv);
|
||||
$("#luckysheetpopover .luckysheetpopover-content").html(content);
|
||||
|
||||
let w = $("#luckysheetpopover").outerWidth(),
|
||||
h = $("#luckysheetpopover").outerHeight();
|
||||
let pcss = {};
|
||||
|
||||
if(position == 'topLeft'){
|
||||
pcss.top = "20px";
|
||||
pcss.left = "20px";
|
||||
}
|
||||
else if(position == 'topCenter'){
|
||||
pcss.top = "20px";
|
||||
pcss.left = "50%";
|
||||
pcss["margin-left"] = -w/2;
|
||||
}
|
||||
else if(position == 'topRight'){
|
||||
pcss.top = "20px";
|
||||
pcss.right = "20px";
|
||||
}
|
||||
else if(position == 'midLeft'){
|
||||
pcss.top = "50%";
|
||||
pcss["margin-top"] = -h/2;
|
||||
pcss.left = "20px";
|
||||
}
|
||||
else if(position == 'center'){
|
||||
pcss.top = "50%";
|
||||
pcss["margin-top"] = -h/2;
|
||||
pcss.left = "50%";
|
||||
pcss["margin-left"] = -w/2;
|
||||
}
|
||||
else if(position == 'midRight'){
|
||||
pcss.top = "50%";
|
||||
pcss["margin-top"] = -h/2;
|
||||
pcss.right = "20px";
|
||||
}
|
||||
else if(position == 'bottomLeft'){
|
||||
pcss.bottom = "20px";
|
||||
pcss.left = "20px";
|
||||
}
|
||||
else if(position == 'bottomCenter'){
|
||||
pcss.bottom = "20px";
|
||||
pcss.left = "50%";
|
||||
pcss["margin-left"] = -w/2;
|
||||
}
|
||||
else if(position == 'bottomRight'){
|
||||
pcss.bottom = "20px";
|
||||
pcss.right = "20px";
|
||||
}
|
||||
else{
|
||||
pcss.top = "20px";
|
||||
pcss.left = "50%";
|
||||
pcss["margin-left"] = -w/2;
|
||||
}
|
||||
|
||||
if(style == "white"){
|
||||
pcss.background = "rgba(255, 255, 255, 0.65)";
|
||||
pcss.color = "#000";
|
||||
$("#luckysheetpopover .luckysheetpopover-btn").css({"border": "1px solid #000"});
|
||||
}
|
||||
|
||||
setTimeout(function(){
|
||||
$("#luckysheetpopover .luckysheetpopover-content").css({"margin-left": -$("#luckysheetpopover .luckysheetpopover-btn").outerWidth()/2});
|
||||
}, 1);
|
||||
$("#luckysheetpopover").css(pcss).fadeIn();
|
||||
$("#luckysheetpopover .luckysheetpopover-btn").click(function(){
|
||||
if(typeof(exitsFuc) == "function"){
|
||||
exitsFuc();
|
||||
}
|
||||
});
|
||||
|
||||
if(close != null && typeof(close) == "number"){
|
||||
setTimeout(function(){
|
||||
$("#luckysheetpopover").fadeOut().remove();
|
||||
if(typeof(exitsFuc) == "function"){
|
||||
exitsFuc();
|
||||
}
|
||||
}, close);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default tooltip;
|
||||
@@ -0,0 +1,220 @@
|
||||
import luckysheetConfigsetting from '../controllers/luckysheetConfigsetting';
|
||||
import Store from '../store';
|
||||
|
||||
export const error = {
|
||||
v: "#VALUE!", //错误的参数或运算符
|
||||
n: "#NAME?", //公式名称错误
|
||||
na: "#N/A", //函数或公式中没有可用数值
|
||||
r: "#REF!", //删除了由其他公式引用的单元格
|
||||
d: "#DIV/0!", //除数是0或空单元格
|
||||
nm: "#NUM!", //当公式或函数中某个数字有问题时
|
||||
nl: "#NULL!", //交叉运算符(空格)使用不正确
|
||||
sp: "#SPILL!" //数组范围有其它值
|
||||
}
|
||||
|
||||
//是否是空值
|
||||
function isRealNull(val) {
|
||||
if(val == null || val.toString().replace(/\s/g, "") == ""){
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//是否是纯数字
|
||||
function isRealNum(val) {
|
||||
if(val == null || val.toString().replace(/\s/g, "") === ""){
|
||||
return false;
|
||||
}
|
||||
|
||||
if(typeof val == "boolean"){
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!isNaN(val)){
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//是否是错误类型
|
||||
function valueIsError(value) {
|
||||
let isError = false;
|
||||
|
||||
for(let x in error){
|
||||
if(value == error[x]){
|
||||
isError = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return isError;
|
||||
}
|
||||
|
||||
//是否有中文
|
||||
function hasChinaword(s) {
|
||||
let patrn = /[\u4E00-\u9FA5]|[\uFE30-\uFFA0]/gi;
|
||||
|
||||
if (!patrn.exec(s)) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
//是否为非编辑模式
|
||||
function isEditMode() {
|
||||
if(luckysheetConfigsetting.editMode){
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 检查是否允许前台进行表格编辑
|
||||
* @param {*}
|
||||
* @return {Boolean} true:允许编辑 fasle:不允许
|
||||
*/
|
||||
function checkIsAllowEdit(){
|
||||
if (Store.allowEdit) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//范围是否只包含部分合并单元格
|
||||
function hasPartMC(cfg, r1, r2, c1, c2) {
|
||||
let hasPartMC = false;
|
||||
|
||||
for(let x in Store.config["merge"]){
|
||||
let mc = cfg["merge"][x];
|
||||
|
||||
if(r1 < mc.r){
|
||||
if(r2 >= mc.r && r2 < (mc.r + mc.rs - 1)){
|
||||
if(c1 >= mc.c && c1 <= (mc.c + mc.cs - 1)){
|
||||
hasPartMC = true;
|
||||
break;
|
||||
}
|
||||
else if(c2 >= mc.c && c2 <= (mc.c + mc.cs - 1)){
|
||||
hasPartMC = true;
|
||||
break;
|
||||
}
|
||||
else if(c1 < mc.c && c2 > (mc.c + mc.cs - 1)){
|
||||
hasPartMC = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if(r2 >= mc.r && r2 == (mc.r + mc.rs - 1)){
|
||||
if(c1 > mc.c && c1 < (mc.c + mc.cs - 1)){
|
||||
hasPartMC = true;
|
||||
break;
|
||||
}
|
||||
else if(c2 > mc.c && c2 < (mc.c + mc.cs - 1)){
|
||||
hasPartMC = true;
|
||||
break;
|
||||
}
|
||||
else if(c1 == mc.c && c2 < (mc.c + mc.cs - 1)){
|
||||
hasPartMC = true;
|
||||
break;
|
||||
}
|
||||
else if(c1 > mc.c && c2 == (mc.c + mc.cs - 1)){
|
||||
hasPartMC = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if(r2 > (mc.r + mc.rs - 1)){
|
||||
if(c1 > mc.c && c1 <= (mc.c + mc.cs - 1)){
|
||||
hasPartMC = true;
|
||||
break;
|
||||
}
|
||||
else if(c2 >= mc.c && c2 < (mc.c + mc.cs - 1)){
|
||||
hasPartMC = true;
|
||||
break;
|
||||
}
|
||||
else if(c1 == mc.c && c2 < (mc.c + mc.cs - 1)){
|
||||
hasPartMC = true;
|
||||
break;
|
||||
}
|
||||
else if(c1 > mc.c && c2 == (mc.c + mc.cs - 1)){
|
||||
hasPartMC = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(r1 == mc.r){
|
||||
if(r2 < (mc.r + mc.rs - 1)){
|
||||
if(c1 >= mc.c && c1 <= (mc.c + mc.cs - 1)){
|
||||
hasPartMC = true;
|
||||
break;
|
||||
}
|
||||
else if(c2 >= mc.c && c2 <= (mc.c + mc.cs - 1)){
|
||||
hasPartMC = true;
|
||||
break;
|
||||
}
|
||||
else if(c1 < mc.c && c2 > (mc.c + mc.cs - 1)){
|
||||
hasPartMC = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if(r2 >= (mc.r + mc.rs - 1)){
|
||||
if(c1 > mc.c && c1 <= (mc.c + mc.cs - 1)){
|
||||
hasPartMC = true;
|
||||
break;
|
||||
}
|
||||
else if(c2 >= mc.c && c2 < (mc.c + mc.cs - 1)){
|
||||
hasPartMC = true;
|
||||
break;
|
||||
}
|
||||
else if(c1 == mc.c && c2 < (mc.c + mc.cs - 1)){
|
||||
hasPartMC = true;
|
||||
break;
|
||||
}
|
||||
else if(c1 > mc.c && c2 == (mc.c + mc.cs - 1)){
|
||||
hasPartMC = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(r1 <= (mc.r + mc.rs - 1)){
|
||||
if(c1 >= mc.c && c1 <= (mc.c + mc.cs - 1)){
|
||||
hasPartMC = true;
|
||||
break;
|
||||
}
|
||||
else if(c2 >= mc.c && c2 <= (mc.c + mc.cs - 1)){
|
||||
hasPartMC = true;
|
||||
break;
|
||||
}
|
||||
else if(c1 < mc.c && c2 > (mc.c + mc.cs - 1)){
|
||||
hasPartMC = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return hasPartMC;
|
||||
}
|
||||
|
||||
//获取单个字符的字节数
|
||||
function checkWordByteLength(value) {
|
||||
return Math.ceil(value.charCodeAt().toString(2).length / 8);
|
||||
}
|
||||
|
||||
|
||||
export {
|
||||
isRealNull,
|
||||
isRealNum,
|
||||
valueIsError,
|
||||
hasChinaword,
|
||||
isEditMode,
|
||||
checkIsAllowEdit,
|
||||
hasPartMC,
|
||||
checkWordByteLength
|
||||
}
|
||||
Reference in New Issue
Block a user